-
Notifications
You must be signed in to change notification settings - Fork 2
/
igv.js
48 lines (48 loc) · 954 KB
/
igv.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).igv=t()}(this,(function(){"use strict";
/*!
* jQuery JavaScript Library v3.3.1 -ajax,-ajax/jsonp,-ajax/load,-ajax/parseXML,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-event/ajax,-effects,-effects/Tween,-effects/animatedSelector
* https://jquery.com/
*
* Includes Sizzle.js
* https://sizzlejs.com/
*
* Copyright JS Foundation and other contributors
* Released under the MIT license
* https://jquery.org/license
*
* Date: 2018-01-20T17:24Z
*/var e=[],t=window.document,i=Object.getPrototypeOf,n=e.slice,r=e.concat,s=e.push,o=e.indexOf,a={},l=a.toString,h=a.hasOwnProperty,c=h.toString,d=c.call(Object),u={},f=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},p=function(e){return null!=e&&e===e.window},g={type:!0,src:!0,noModule:!0};function m(e,i,n){var r,s=(i=i||t).createElement("script");if(s.text=e,n)for(r in g)n[r]&&(s[r]=n[r]);i.head.appendChild(s).parentNode.removeChild(s)}function b(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?a[l.call(e)]||"object":typeof e}var w="3.3.1 -ajax,-ajax/jsonp,-ajax/load,-ajax/parseXML,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-event/ajax,-effects,-effects/Tween,-effects/animatedSelector",v=function(e,t){return new v.fn.init(e,t)},y=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;function _(e){var t=!!e&&"length"in e&&e.length,i=b(e);return!f(e)&&!p(e)&&("array"===i||0===t||"number"==typeof t&&t>0&&t-1 in e)}v.fn=v.prototype={jquery:w,constructor:v,length:0,toArray:function(){return n.call(this)},get:function(e){return null==e?n.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=v.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return v.each(this,e)},map:function(e){return this.pushStack(v.map(this,(function(t,i){return e.call(t,i,t)})))},slice:function(){return this.pushStack(n.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,i=+e+(e<0?t:0);return this.pushStack(i>=0&&i<t?[this[i]]:[])},end:function(){return this.prevObject||this.constructor()},push:s,sort:e.sort,splice:e.splice},v.extend=v.fn.extend=function(){var e,t,i,n,r,s,o=arguments[0]||{},a=1,l=arguments.length,h=!1;for("boolean"==typeof o&&(h=o,o=arguments[a]||{},a++),"object"==typeof o||f(o)||(o={}),a===l&&(o=this,a--);a<l;a++)if(null!=(e=arguments[a]))for(t in e)i=o[t],o!==(n=e[t])&&(h&&n&&(v.isPlainObject(n)||(r=Array.isArray(n)))?(r?(r=!1,s=i&&Array.isArray(i)?i:[]):s=i&&v.isPlainObject(i)?i:{},o[t]=v.extend(h,s,n)):void 0!==n&&(o[t]=n));return o},v.extend({expando:"jQuery"+(w+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isPlainObject:function(e){var t,n;return!(!e||"[object Object]"!==l.call(e))&&(!(t=i(e))||"function"==typeof(n=h.call(t,"constructor")&&t.constructor)&&c.call(n)===d)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},globalEval:function(e){m(e)},each:function(e,t){var i,n=0;if(_(e))for(i=e.length;n<i&&!1!==t.call(e[n],n,e[n]);n++);else for(n in e)if(!1===t.call(e[n],n,e[n]))break;return e},trim:function(e){return null==e?"":(e+"").replace(y,"")},makeArray:function(e,t){var i=t||[];return null!=e&&(_(Object(e))?v.merge(i,"string"==typeof e?[e]:e):s.call(i,e)),i},inArray:function(e,t,i){return null==t?-1:o.call(t,e,i)},merge:function(e,t){for(var i=+t.length,n=0,r=e.length;n<i;n++)e[r++]=t[n];return e.length=r,e},grep:function(e,t,i){for(var n=[],r=0,s=e.length,o=!i;r<s;r++)!t(e[r],r)!==o&&n.push(e[r]);return n},map:function(e,t,i){var n,s,o=0,a=[];if(_(e))for(n=e.length;o<n;o++)null!=(s=t(e[o],o,i))&&a.push(s);else for(o in e)null!=(s=t(e[o],o,i))&&a.push(s);return r.apply([],a)},guid:1,support:u}),"function"==typeof Symbol&&(v.fn[Symbol.iterator]=e[Symbol.iterator]),v.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),(function(e,t){a["[object "+t+"]"]=t.toLowerCase()}));var x=
/*!
* Sizzle CSS Selector Engine v2.3.3
* https://sizzlejs.com/
*
* Copyright jQuery Foundation and other contributors
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2016-08-08
*/
function(e){var t,i,n,r,s,o,a,l,h,c,d,u,f,p,g,m,b,w,v,y="sizzle"+1*new Date,_=e.document,x=0,k=0,C=oe(),S=oe(),A=oe(),E=function(e,t){return e===t&&(d=!0),0},M={}.hasOwnProperty,T=[],R=T.pop,L=T.push,I=T.push,B=T.slice,F=function(e,t){for(var i=0,n=e.length;i<n;i++)if(e[i]===t)return i;return-1},N="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",O="[\\x20\\t\\r\\n\\f]",P="(?:\\\\.|[\\w-]|[^\0-\\xa0])+",D="\\["+O+"*("+P+")(?:"+O+"*([*^$|!~]?=)"+O+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+P+"))|)"+O+"*\\]",z=":("+P+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+D+")*)|.*)\\)|)",H=new RegExp(O+"+","g"),V=new RegExp("^"+O+"+|((?:^|[^\\\\])(?:\\\\.)*)"+O+"+$","g"),U=new RegExp("^"+O+"*,"+O+"*"),q=new RegExp("^"+O+"*([>+~]|"+O+")"+O+"*"),j=new RegExp("="+O+"*([^\\]'\"]*?)"+O+"*\\]","g"),$=new RegExp(z),W=new RegExp("^"+P+"$"),G={ID:new RegExp("^#("+P+")"),CLASS:new RegExp("^\\.("+P+")"),TAG:new RegExp("^("+P+"|[*])"),ATTR:new RegExp("^"+D),PSEUDO:new RegExp("^"+z),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+O+"*(even|odd|(([+-]|)(\\d*)n|)"+O+"*(?:([+-]|)"+O+"*(\\d+)|))"+O+"*\\)|)","i"),bool:new RegExp("^(?:"+N+")$","i"),needsContext:new RegExp("^"+O+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+O+"*((?:-\\d)?\\d*)"+O+"*\\)|)(?=[^-]|$)","i")},Z=/^(?:input|select|textarea|button)$/i,Q=/^h\d$/i,X=/^[^{]+\{\s*\[native \w/,Y=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,K=/[+~]/,J=new RegExp("\\\\([\\da-f]{1,6}"+O+"?|("+O+")|.)","ig"),ee=function(e,t,i){var n="0x"+t-65536;return n!=n||i?t:n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320)},te=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"�":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},ne=function(){u()},re=be((function(e){return!0===e.disabled&&("form"in e||"label"in e)}),{dir:"parentNode",next:"legend"});try{I.apply(T=B.call(_.childNodes),_.childNodes),T[_.childNodes.length].nodeType}catch(e){I={apply:T.length?function(e,t){L.apply(e,B.call(t))}:function(e,t){for(var i=e.length,n=0;e[i++]=t[n++];);e.length=i-1}}}function se(e,t,n,r){var s,a,h,c,d,p,b,w=t&&t.ownerDocument,x=t?t.nodeType:9;if(n=n||[],"string"!=typeof e||!e||1!==x&&9!==x&&11!==x)return n;if(!r&&((t?t.ownerDocument||t:_)!==f&&u(t),t=t||f,g)){if(11!==x&&(d=Y.exec(e)))if(s=d[1]){if(9===x){if(!(h=t.getElementById(s)))return n;if(h.id===s)return n.push(h),n}else if(w&&(h=w.getElementById(s))&&v(t,h)&&h.id===s)return n.push(h),n}else{if(d[2])return I.apply(n,t.getElementsByTagName(e)),n;if((s=d[3])&&i.getElementsByClassName&&t.getElementsByClassName)return I.apply(n,t.getElementsByClassName(s)),n}if(i.qsa&&!A[e+" "]&&(!m||!m.test(e))){if(1!==x)w=t,b=e;else if("object"!==t.nodeName.toLowerCase()){for((c=t.getAttribute("id"))?c=c.replace(te,ie):t.setAttribute("id",c=y),a=(p=o(e)).length;a--;)p[a]="#"+c+" "+me(p[a]);b=p.join(","),w=K.test(e)&&pe(t.parentNode)||t}if(b)try{return I.apply(n,w.querySelectorAll(b)),n}catch(e){}finally{c===y&&t.removeAttribute("id")}}}return l(e.replace(V,"$1"),t,n,r)}function oe(){var e=[];return function t(i,r){return e.push(i+" ")>n.cacheLength&&delete t[e.shift()],t[i+" "]=r}}function ae(e){return e[y]=!0,e}function le(e){var t=f.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function he(e,t){var i=t&&e,n=i&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(n)return n;if(i)for(;i=i.nextSibling;)if(i===t)return-1;return e?1:-1}function ce(e){return function(t){return"input"===t.nodeName.toLowerCase()&&t.type===e}}function de(e){return function(t){var i=t.nodeName.toLowerCase();return("input"===i||"button"===i)&&t.type===e}}function ue(e){return function(t){return"form"in t?t.parentNode&&!1===t.disabled?"label"in t?"label"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&re(t)===e:t.disabled===e:"label"in t&&t.disabled===e}}function fe(e){return ae((function(t){return t=+t,ae((function(i,n){for(var r,s=e([],i.length,t),o=s.length;o--;)i[r=s[o]]&&(i[r]=!(n[r]=i[r]))}))}))}function pe(e){return e&&void 0!==e.getElementsByTagName&&e}for(t in i=se.support={},s=se.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&"HTML"!==t.nodeName},u=se.setDocument=function(e){var t,r,o=e?e.ownerDocument||e:_;return o!==f&&9===o.nodeType&&o.documentElement?(p=(f=o).documentElement,g=!s(f),_!==f&&(r=f.defaultView)&&r.top!==r&&(r.addEventListener?r.addEventListener("unload",ne,!1):r.attachEvent&&r.attachEvent("onunload",ne)),i.attributes=le((function(e){return e.className="i",!e.getAttribute("className")})),i.getElementsByTagName=le((function(e){return e.appendChild(f.createComment("")),!e.getElementsByTagName("*").length})),i.getElementsByClassName=X.test(f.getElementsByClassName),i.getById=le((function(e){return p.appendChild(e).id=y,!f.getElementsByName||!f.getElementsByName(y).length})),i.getById?(n.filter.ID=function(e){var t=e.replace(J,ee);return function(e){return e.getAttribute("id")===t}},n.find.ID=function(e,t){if(void 0!==t.getElementById&&g){var i=t.getElementById(e);return i?[i]:[]}}):(n.filter.ID=function(e){var t=e.replace(J,ee);return function(e){var i=void 0!==e.getAttributeNode&&e.getAttributeNode("id");return i&&i.value===t}},n.find.ID=function(e,t){if(void 0!==t.getElementById&&g){var i,n,r,s=t.getElementById(e);if(s){if((i=s.getAttributeNode("id"))&&i.value===e)return[s];for(r=t.getElementsByName(e),n=0;s=r[n++];)if((i=s.getAttributeNode("id"))&&i.value===e)return[s]}return[]}}),n.find.TAG=i.getElementsByTagName?function(e,t){return void 0!==t.getElementsByTagName?t.getElementsByTagName(e):i.qsa?t.querySelectorAll(e):void 0}:function(e,t){var i,n=[],r=0,s=t.getElementsByTagName(e);if("*"===e){for(;i=s[r++];)1===i.nodeType&&n.push(i);return n}return s},n.find.CLASS=i.getElementsByClassName&&function(e,t){if(void 0!==t.getElementsByClassName&&g)return t.getElementsByClassName(e)},b=[],m=[],(i.qsa=X.test(f.querySelectorAll))&&(le((function(e){p.appendChild(e).innerHTML="<a id='"+y+"'></a><select id='"+y+"-\r\\' msallowcapture=''><option selected=''></option></select>",e.querySelectorAll("[msallowcapture^='']").length&&m.push("[*^$]="+O+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||m.push("\\["+O+"*(?:value|"+N+")"),e.querySelectorAll("[id~="+y+"-]").length||m.push("~="),e.querySelectorAll(":checked").length||m.push(":checked"),e.querySelectorAll("a#"+y+"+*").length||m.push(".#.+[+~]")})),le((function(e){e.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var t=f.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&m.push("name"+O+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&m.push(":enabled",":disabled"),p.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&m.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),m.push(",.*:")}))),(i.matchesSelector=X.test(w=p.matches||p.webkitMatchesSelector||p.mozMatchesSelector||p.oMatchesSelector||p.msMatchesSelector))&&le((function(e){i.disconnectedMatch=w.call(e,"*"),w.call(e,"[s!='']:x"),b.push("!=",z)})),m=m.length&&new RegExp(m.join("|")),b=b.length&&new RegExp(b.join("|")),t=X.test(p.compareDocumentPosition),v=t||X.test(p.contains)?function(e,t){var i=9===e.nodeType?e.documentElement:e,n=t&&t.parentNode;return e===n||!(!n||1!==n.nodeType||!(i.contains?i.contains(n):e.compareDocumentPosition&&16&e.compareDocumentPosition(n)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},E=t?function(e,t){if(e===t)return d=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!i.sortDetached&&t.compareDocumentPosition(e)===n?e===f||e.ownerDocument===_&&v(_,e)?-1:t===f||t.ownerDocument===_&&v(_,t)?1:c?F(c,e)-F(c,t):0:4&n?-1:1)}:function(e,t){if(e===t)return d=!0,0;var i,n=0,r=e.parentNode,s=t.parentNode,o=[e],a=[t];if(!r||!s)return e===f?-1:t===f?1:r?-1:s?1:c?F(c,e)-F(c,t):0;if(r===s)return he(e,t);for(i=e;i=i.parentNode;)o.unshift(i);for(i=t;i=i.parentNode;)a.unshift(i);for(;o[n]===a[n];)n++;return n?he(o[n],a[n]):o[n]===_?-1:a[n]===_?1:0},f):f},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if((e.ownerDocument||e)!==f&&u(e),t=t.replace(j,"='$1']"),i.matchesSelector&&g&&!A[t+" "]&&(!b||!b.test(t))&&(!m||!m.test(t)))try{var n=w.call(e,t);if(n||i.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){}return se(t,f,null,[e]).length>0},se.contains=function(e,t){return(e.ownerDocument||e)!==f&&u(e),v(e,t)},se.attr=function(e,t){(e.ownerDocument||e)!==f&&u(e);var r=n.attrHandle[t.toLowerCase()],s=r&&M.call(n.attrHandle,t.toLowerCase())?r(e,t,!g):void 0;return void 0!==s?s:i.attributes||!g?e.getAttribute(t):(s=e.getAttributeNode(t))&&s.specified?s.value:null},se.escape=function(e){return(e+"").replace(te,ie)},se.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},se.uniqueSort=function(e){var t,n=[],r=0,s=0;if(d=!i.detectDuplicates,c=!i.sortStable&&e.slice(0),e.sort(E),d){for(;t=e[s++];)t===e[s]&&(r=n.push(s));for(;r--;)e.splice(n[r],1)}return c=null,e},r=se.getText=function(e){var t,i="",n=0,s=e.nodeType;if(s){if(1===s||9===s||11===s){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)i+=r(e)}else if(3===s||4===s)return e.nodeValue}else for(;t=e[n++];)i+=r(t);return i},n=se.selectors={cacheLength:50,createPseudo:ae,match:G,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(J,ee),e[3]=(e[3]||e[4]||e[5]||"").replace(J,ee),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,i=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":i&&$.test(i)&&(t=o(i,!0))&&(t=i.indexOf(")",i.length-t)-i.length)&&(e[0]=e[0].slice(0,t),e[2]=i.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(J,ee).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=C[e+" "];return t||(t=new RegExp("(^|"+O+")"+e+"("+O+"|$)"))&&C(e,(function(e){return t.test("string"==typeof e.className&&e.className||void 0!==e.getAttribute&&e.getAttribute("class")||"")}))},ATTR:function(e,t,i){return function(n){var r=se.attr(n,e);return null==r?"!="===t:!t||(r+="","="===t?r===i:"!="===t?r!==i:"^="===t?i&&0===r.indexOf(i):"*="===t?i&&r.indexOf(i)>-1:"$="===t?i&&r.slice(-i.length)===i:"~="===t?(" "+r.replace(H," ")+" ").indexOf(i)>-1:"|="===t&&(r===i||r.slice(0,i.length+1)===i+"-"))}},CHILD:function(e,t,i,n,r){var s="nth"!==e.slice(0,3),o="last"!==e.slice(-4),a="of-type"===t;return 1===n&&0===r?function(e){return!!e.parentNode}:function(t,i,l){var h,c,d,u,f,p,g=s!==o?"nextSibling":"previousSibling",m=t.parentNode,b=a&&t.nodeName.toLowerCase(),w=!l&&!a,v=!1;if(m){if(s){for(;g;){for(u=t;u=u[g];)if(a?u.nodeName.toLowerCase()===b:1===u.nodeType)return!1;p=g="only"===e&&!p&&"nextSibling"}return!0}if(p=[o?m.firstChild:m.lastChild],o&&w){for(v=(f=(h=(c=(d=(u=m)[y]||(u[y]={}))[u.uniqueID]||(d[u.uniqueID]={}))[e]||[])[0]===x&&h[1])&&h[2],u=f&&m.childNodes[f];u=++f&&u&&u[g]||(v=f=0)||p.pop();)if(1===u.nodeType&&++v&&u===t){c[e]=[x,f,v];break}}else if(w&&(v=f=(h=(c=(d=(u=t)[y]||(u[y]={}))[u.uniqueID]||(d[u.uniqueID]={}))[e]||[])[0]===x&&h[1]),!1===v)for(;(u=++f&&u&&u[g]||(v=f=0)||p.pop())&&((a?u.nodeName.toLowerCase()!==b:1!==u.nodeType)||!++v||(w&&((c=(d=u[y]||(u[y]={}))[u.uniqueID]||(d[u.uniqueID]={}))[e]=[x,v]),u!==t)););return(v-=r)===n||v%n==0&&v/n>=0}}},PSEUDO:function(e,t){var i,r=n.pseudos[e]||n.setFilters[e.toLowerCase()]||se.error("unsupported pseudo: "+e);return r[y]?r(t):r.length>1?(i=[e,e,"",t],n.setFilters.hasOwnProperty(e.toLowerCase())?ae((function(e,i){for(var n,s=r(e,t),o=s.length;o--;)e[n=F(e,s[o])]=!(i[n]=s[o])})):function(e){return r(e,0,i)}):r}},pseudos:{not:ae((function(e){var t=[],i=[],n=a(e.replace(V,"$1"));return n[y]?ae((function(e,t,i,r){for(var s,o=n(e,null,r,[]),a=e.length;a--;)(s=o[a])&&(e[a]=!(t[a]=s))})):function(e,r,s){return t[0]=e,n(t,null,s,i),t[0]=null,!i.pop()}})),has:ae((function(e){return function(t){return se(e,t).length>0}})),contains:ae((function(e){return e=e.replace(J,ee),function(t){return(t.textContent||t.innerText||r(t)).indexOf(e)>-1}})),lang:ae((function(e){return W.test(e||"")||se.error("unsupported lang: "+e),e=e.replace(J,ee).toLowerCase(),function(t){var i;do{if(i=g?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return(i=i.toLowerCase())===e||0===i.indexOf(e+"-")}while((t=t.parentNode)&&1===t.nodeType);return!1}})),target:function(t){var i=e.location&&e.location.hash;return i&&i.slice(1)===t.id},root:function(e){return e===p},focus:function(e){return e===f.activeElement&&(!f.hasFocus||f.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:ue(!1),disabled:ue(!0),checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!n.pseudos.empty(e)},header:function(e){return Q.test(e.nodeName)},input:function(e){return Z.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:fe((function(){return[0]})),last:fe((function(e,t){return[t-1]})),eq:fe((function(e,t,i){return[i<0?i+t:i]})),even:fe((function(e,t){for(var i=0;i<t;i+=2)e.push(i);return e})),odd:fe((function(e,t){for(var i=1;i<t;i+=2)e.push(i);return e})),lt:fe((function(e,t,i){for(var n=i<0?i+t:i;--n>=0;)e.push(n);return e})),gt:fe((function(e,t,i){for(var n=i<0?i+t:i;++n<t;)e.push(n);return e}))}},n.pseudos.nth=n.pseudos.eq,{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})n.pseudos[t]=ce(t);for(t in{submit:!0,reset:!0})n.pseudos[t]=de(t);function ge(){}function me(e){for(var t=0,i=e.length,n="";t<i;t++)n+=e[t].value;return n}function be(e,t,i){var n=t.dir,r=t.next,s=r||n,o=i&&"parentNode"===s,a=k++;return t.first?function(t,i,r){for(;t=t[n];)if(1===t.nodeType||o)return e(t,i,r);return!1}:function(t,i,l){var h,c,d,u=[x,a];if(l){for(;t=t[n];)if((1===t.nodeType||o)&&e(t,i,l))return!0}else for(;t=t[n];)if(1===t.nodeType||o)if(c=(d=t[y]||(t[y]={}))[t.uniqueID]||(d[t.uniqueID]={}),r&&r===t.nodeName.toLowerCase())t=t[n]||t;else{if((h=c[s])&&h[0]===x&&h[1]===a)return u[2]=h[2];if(c[s]=u,u[2]=e(t,i,l))return!0}return!1}}function we(e){return e.length>1?function(t,i,n){for(var r=e.length;r--;)if(!e[r](t,i,n))return!1;return!0}:e[0]}function ve(e,t,i,n,r){for(var s,o=[],a=0,l=e.length,h=null!=t;a<l;a++)(s=e[a])&&(i&&!i(s,n,r)||(o.push(s),h&&t.push(a)));return o}function ye(e,t,i,n,r,s){return n&&!n[y]&&(n=ye(n)),r&&!r[y]&&(r=ye(r,s)),ae((function(s,o,a,l){var h,c,d,u=[],f=[],p=o.length,g=s||function(e,t,i){for(var n=0,r=t.length;n<r;n++)se(e,t[n],i);return i}(t||"*",a.nodeType?[a]:a,[]),m=!e||!s&&t?g:ve(g,u,e,a,l),b=i?r||(s?e:p||n)?[]:o:m;if(i&&i(m,b,a,l),n)for(h=ve(b,f),n(h,[],a,l),c=h.length;c--;)(d=h[c])&&(b[f[c]]=!(m[f[c]]=d));if(s){if(r||e){if(r){for(h=[],c=b.length;c--;)(d=b[c])&&h.push(m[c]=d);r(null,b=[],h,l)}for(c=b.length;c--;)(d=b[c])&&(h=r?F(s,d):u[c])>-1&&(s[h]=!(o[h]=d))}}else b=ve(b===o?b.splice(p,b.length):b),r?r(null,o,b,l):I.apply(o,b)}))}function _e(e){for(var t,i,r,s=e.length,o=n.relative[e[0].type],a=o||n.relative[" "],l=o?1:0,c=be((function(e){return e===t}),a,!0),d=be((function(e){return F(t,e)>-1}),a,!0),u=[function(e,i,n){var r=!o&&(n||i!==h)||((t=i).nodeType?c(e,i,n):d(e,i,n));return t=null,r}];l<s;l++)if(i=n.relative[e[l].type])u=[be(we(u),i)];else{if((i=n.filter[e[l].type].apply(null,e[l].matches))[y]){for(r=++l;r<s&&!n.relative[e[r].type];r++);return ye(l>1&&we(u),l>1&&me(e.slice(0,l-1).concat({value:" "===e[l-2].type?"*":""})).replace(V,"$1"),i,l<r&&_e(e.slice(l,r)),r<s&&_e(e=e.slice(r)),r<s&&me(e))}u.push(i)}return we(u)}return ge.prototype=n.filters=n.pseudos,n.setFilters=new ge,o=se.tokenize=function(e,t){var i,r,s,o,a,l,h,c=S[e+" "];if(c)return t?0:c.slice(0);for(a=e,l=[],h=n.preFilter;a;){for(o in i&&!(r=U.exec(a))||(r&&(a=a.slice(r[0].length)||a),l.push(s=[])),i=!1,(r=q.exec(a))&&(i=r.shift(),s.push({value:i,type:r[0].replace(V," ")}),a=a.slice(i.length)),n.filter)!(r=G[o].exec(a))||h[o]&&!(r=h[o](r))||(i=r.shift(),s.push({value:i,type:o,matches:r}),a=a.slice(i.length));if(!i)break}return t?a.length:a?se.error(e):S(e,l).slice(0)},a=se.compile=function(e,t){var i,r=[],s=[],a=A[e+" "];if(!a){for(t||(t=o(e)),i=t.length;i--;)(a=_e(t[i]))[y]?r.push(a):s.push(a);a=A(e,function(e,t){var i=t.length>0,r=e.length>0,s=function(s,o,a,l,c){var d,p,m,b=0,w="0",v=s&&[],y=[],_=h,k=s||r&&n.find.TAG("*",c),C=x+=null==_?1:Math.random()||.1,S=k.length;for(c&&(h=o===f||o||c);w!==S&&null!=(d=k[w]);w++){if(r&&d){for(p=0,o||d.ownerDocument===f||(u(d),a=!g);m=e[p++];)if(m(d,o||f,a)){l.push(d);break}c&&(x=C)}i&&((d=!m&&d)&&b--,s&&v.push(d))}if(b+=w,i&&w!==b){for(p=0;m=t[p++];)m(v,y,o,a);if(s){if(b>0)for(;w--;)v[w]||y[w]||(y[w]=R.call(l));y=ve(y)}I.apply(l,y),c&&!s&&y.length>0&&b+t.length>1&&se.uniqueSort(l)}return c&&(x=C,h=_),v};return i?ae(s):s}(s,r)),a.selector=e}return a},l=se.select=function(e,t,i,r){var s,l,h,c,d,u="function"==typeof e&&e,f=!r&&o(e=u.selector||e);if(i=i||[],1===f.length){if((l=f[0]=f[0].slice(0)).length>2&&"ID"===(h=l[0]).type&&9===t.nodeType&&g&&n.relative[l[1].type]){if(!(t=(n.find.ID(h.matches[0].replace(J,ee),t)||[])[0]))return i;u&&(t=t.parentNode),e=e.slice(l.shift().value.length)}for(s=G.needsContext.test(e)?0:l.length;s--&&(h=l[s],!n.relative[c=h.type]);)if((d=n.find[c])&&(r=d(h.matches[0].replace(J,ee),K.test(l[0].type)&&pe(t.parentNode)||t))){if(l.splice(s,1),!(e=r.length&&me(l)))return I.apply(i,r),i;break}}return(u||a(e,f))(r,t,!g,i,!t||K.test(e)&&pe(t.parentNode)||t),i},i.sortStable=y.split("").sort(E).join("")===y,i.detectDuplicates=!!d,u(),se}(window);v.find=x,v.expr=x.selectors,v.expr[":"]=v.expr.pseudos,v.uniqueSort=v.unique=x.uniqueSort,v.text=x.getText,v.isXMLDoc=x.isXML,v.contains=x.contains,v.escapeSelector=x.escape;var k=function(e,t,i){for(var n=[],r=void 0!==i;(e=e[t])&&9!==e.nodeType;)if(1===e.nodeType){if(r&&v(e).is(i))break;n.push(e)}return n},C=function(e,t){for(var i=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&i.push(e);return i},S=v.expr.match.needsContext;function A(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}var E=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function M(e,t,i){return f(t)?v.grep(e,(function(e,n){return!!t.call(e,n,e)!==i})):t.nodeType?v.grep(e,(function(e){return e===t!==i})):"string"!=typeof t?v.grep(e,(function(e){return o.call(t,e)>-1!==i})):v.filter(t,e,i)}v.filter=function(e,t,i){var n=t[0];return i&&(e=":not("+e+")"),1===t.length&&1===n.nodeType?v.find.matchesSelector(n,e)?[n]:[]:v.find.matches(e,v.grep(t,(function(e){return 1===e.nodeType})))},v.fn.extend({find:function(e){var t,i,n=this.length,r=this;if("string"!=typeof e)return this.pushStack(v(e).filter((function(){for(t=0;t<n;t++)if(v.contains(r[t],this))return!0})));for(i=this.pushStack([]),t=0;t<n;t++)v.find(e,r[t],i);return n>1?v.uniqueSort(i):i},filter:function(e){return this.pushStack(M(this,e||[],!1))},not:function(e){return this.pushStack(M(this,e||[],!0))},is:function(e){return!!M(this,"string"==typeof e&&S.test(e)?v(e):e||[],!1).length}});var T,R=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(v.fn.init=function(e,i,n){var r,s;if(!e)return this;if(n=n||T,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&e.length>=3?[null,e,null]:R.exec(e))||!r[1]&&i)return!i||i.jquery?(i||n).find(e):this.constructor(i).find(e);if(r[1]){if(i=i instanceof v?i[0]:i,v.merge(this,v.parseHTML(r[1],i&&i.nodeType?i.ownerDocument||i:t,!0)),E.test(r[1])&&v.isPlainObject(i))for(r in i)f(this[r])?this[r](i[r]):this.attr(r,i[r]);return this}return(s=t.getElementById(r[2]))&&(this[0]=s,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):f(e)?void 0!==n.ready?n.ready(e):e(v):v.makeArray(e,this)}).prototype=v.fn,T=v(t);var L=/^(?:parents|prev(?:Until|All))/,I={children:!0,contents:!0,next:!0,prev:!0};function B(e,t){for(;(e=e[t])&&1!==e.nodeType;);return e}v.fn.extend({has:function(e){var t=v(e,this),i=t.length;return this.filter((function(){for(var e=0;e<i;e++)if(v.contains(this,t[e]))return!0}))},closest:function(e,t){var i,n=0,r=this.length,s=[],o="string"!=typeof e&&v(e);if(!S.test(e))for(;n<r;n++)for(i=this[n];i&&i!==t;i=i.parentNode)if(i.nodeType<11&&(o?o.index(i)>-1:1===i.nodeType&&v.find.matchesSelector(i,e))){s.push(i);break}return this.pushStack(s.length>1?v.uniqueSort(s):s)},index:function(e){return e?"string"==typeof e?o.call(v(e),this[0]):o.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(v.uniqueSort(v.merge(this.get(),v(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),v.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return k(e,"parentNode")},parentsUntil:function(e,t,i){return k(e,"parentNode",i)},next:function(e){return B(e,"nextSibling")},prev:function(e){return B(e,"previousSibling")},nextAll:function(e){return k(e,"nextSibling")},prevAll:function(e){return k(e,"previousSibling")},nextUntil:function(e,t,i){return k(e,"nextSibling",i)},prevUntil:function(e,t,i){return k(e,"previousSibling",i)},siblings:function(e){return C((e.parentNode||{}).firstChild,e)},children:function(e){return C(e.firstChild)},contents:function(e){return A(e,"iframe")?e.contentDocument:(A(e,"template")&&(e=e.content||e),v.merge([],e.childNodes))}},(function(e,t){v.fn[e]=function(i,n){var r=v.map(this,t,i);return"Until"!==e.slice(-5)&&(n=i),n&&"string"==typeof n&&(r=v.filter(n,r)),this.length>1&&(I[e]||v.uniqueSort(r),L.test(e)&&r.reverse()),this.pushStack(r)}}));var F=/[^\x20\t\r\n\f]+/g;function N(e){return e}function O(e){throw e}function P(e,t,i,n){var r;try{e&&f(r=e.promise)?r.call(e).done(t).fail(i):e&&f(r=e.then)?r.call(e,t,i):t.apply(void 0,[e].slice(n))}catch(e){i.apply(void 0,[e])}}v.Callbacks=function(e){e="string"==typeof e?function(e){var t={};return v.each(e.match(F)||[],(function(e,i){t[i]=!0})),t}(e):v.extend({},e);var t,i,n,r,s=[],o=[],a=-1,l=function(){for(r=r||e.once,n=t=!0;o.length;a=-1)for(i=o.shift();++a<s.length;)!1===s[a].apply(i[0],i[1])&&e.stopOnFalse&&(a=s.length,i=!1);e.memory||(i=!1),t=!1,r&&(s=i?[]:"")},h={add:function(){return s&&(i&&!t&&(a=s.length-1,o.push(i)),function t(i){v.each(i,(function(i,n){f(n)?e.unique&&h.has(n)||s.push(n):n&&n.length&&"string"!==b(n)&&t(n)}))}(arguments),i&&!t&&l()),this},remove:function(){return v.each(arguments,(function(e,t){for(var i;(i=v.inArray(t,s,i))>-1;)s.splice(i,1),i<=a&&a--})),this},has:function(e){return e?v.inArray(e,s)>-1:s.length>0},empty:function(){return s&&(s=[]),this},disable:function(){return r=o=[],s=i="",this},disabled:function(){return!s},lock:function(){return r=o=[],i||t||(s=i=""),this},locked:function(){return!!r},fireWith:function(e,i){return r||(i=[e,(i=i||[]).slice?i.slice():i],o.push(i),t||l()),this},fire:function(){return h.fireWith(this,arguments),this},fired:function(){return!!n}};return h},v.extend({Deferred:function(e){var t=[["notify","progress",v.Callbacks("memory"),v.Callbacks("memory"),2],["resolve","done",v.Callbacks("once memory"),v.Callbacks("once memory"),0,"resolved"],["reject","fail",v.Callbacks("once memory"),v.Callbacks("once memory"),1,"rejected"]],i="pending",n={state:function(){return i},always:function(){return r.done(arguments).fail(arguments),this},catch:function(e){return n.then(null,e)},pipe:function(){var e=arguments;return v.Deferred((function(i){v.each(t,(function(t,n){var s=f(e[n[4]])&&e[n[4]];r[n[1]]((function(){var e=s&&s.apply(this,arguments);e&&f(e.promise)?e.promise().progress(i.notify).done(i.resolve).fail(i.reject):i[n[0]+"With"](this,s?[e]:arguments)}))})),e=null})).promise()},then:function(e,i,n){var r=0;function s(e,t,i,n){return function(){var o=this,a=arguments,l=function(){var l,h;if(!(e<r)){if((l=i.apply(o,a))===t.promise())throw new TypeError("Thenable self-resolution");h=l&&("object"==typeof l||"function"==typeof l)&&l.then,f(h)?n?h.call(l,s(r,t,N,n),s(r,t,O,n)):(r++,h.call(l,s(r,t,N,n),s(r,t,O,n),s(r,t,N,t.notifyWith))):(i!==N&&(o=void 0,a=[l]),(n||t.resolveWith)(o,a))}},h=n?l:function(){try{l()}catch(n){v.Deferred.exceptionHook&&v.Deferred.exceptionHook(n,h.stackTrace),e+1>=r&&(i!==O&&(o=void 0,a=[n]),t.rejectWith(o,a))}};e?h():(v.Deferred.getStackHook&&(h.stackTrace=v.Deferred.getStackHook()),window.setTimeout(h))}}return v.Deferred((function(r){t[0][3].add(s(0,r,f(n)?n:N,r.notifyWith)),t[1][3].add(s(0,r,f(e)?e:N)),t[2][3].add(s(0,r,f(i)?i:O))})).promise()},promise:function(e){return null!=e?v.extend(e,n):n}},r={};return v.each(t,(function(e,s){var o=s[2],a=s[5];n[s[1]]=o.add,a&&o.add((function(){i=a}),t[3-e][2].disable,t[3-e][3].disable,t[0][2].lock,t[0][3].lock),o.add(s[3].fire),r[s[0]]=function(){return r[s[0]+"With"](this===r?void 0:this,arguments),this},r[s[0]+"With"]=o.fireWith})),n.promise(r),e&&e.call(r,r),r},when:function(e){var t=arguments.length,i=t,r=Array(i),s=n.call(arguments),o=v.Deferred(),a=function(e){return function(i){r[e]=this,s[e]=arguments.length>1?n.call(arguments):i,--t||o.resolveWith(r,s)}};if(t<=1&&(P(e,o.done(a(i)).resolve,o.reject,!t),"pending"===o.state()||f(s[i]&&s[i].then)))return o.then();for(;i--;)P(s[i],a(i),o.reject);return o.promise()}});var D=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;v.Deferred.exceptionHook=function(e,t){window.console&&window.console.warn&&e&&D.test(e.name)&&window.console.warn("jQuery.Deferred exception: "+e.message,e.stack,t)},v.readyException=function(e){window.setTimeout((function(){throw e}))};var z=v.Deferred();function H(){t.removeEventListener("DOMContentLoaded",H),window.removeEventListener("load",H),v.ready()}v.fn.ready=function(e){return z.then(e).catch((function(e){v.readyException(e)})),this},v.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--v.readyWait:v.isReady)||(v.isReady=!0,!0!==e&&--v.readyWait>0||z.resolveWith(t,[v]))}}),v.ready.then=z.then,"complete"===t.readyState||"loading"!==t.readyState&&!t.documentElement.doScroll?window.setTimeout(v.ready):(t.addEventListener("DOMContentLoaded",H),window.addEventListener("load",H));var V=function(e,t,i,n,r,s,o){var a=0,l=e.length,h=null==i;if("object"===b(i))for(a in r=!0,i)V(e,t,a,i[a],!0,s,o);else if(void 0!==n&&(r=!0,f(n)||(o=!0),h&&(o?(t.call(e,n),t=null):(h=t,t=function(e,t,i){return h.call(v(e),i)})),t))for(;a<l;a++)t(e[a],i,o?n:n.call(e[a],a,t(e[a],i)));return r?e:h?t.call(e):l?t(e[0],i):s},U=/^-ms-/,q=/-([a-z])/g;function j(e,t){return t.toUpperCase()}function $(e){return e.replace(U,"ms-").replace(q,j)}var W=function(e){return 1===e.nodeType||9===e.nodeType||!+e.nodeType};function G(){this.expando=v.expando+G.uid++}G.uid=1,G.prototype={cache:function(e){var t=e[this.expando];return t||(t={},W(e)&&(e.nodeType?e[this.expando]=t:Object.defineProperty(e,this.expando,{value:t,configurable:!0}))),t},set:function(e,t,i){var n,r=this.cache(e);if("string"==typeof t)r[$(t)]=i;else for(n in t)r[$(n)]=t[n];return r},get:function(e,t){return void 0===t?this.cache(e):e[this.expando]&&e[this.expando][$(t)]},access:function(e,t,i){return void 0===t||t&&"string"==typeof t&&void 0===i?this.get(e,t):(this.set(e,t,i),void 0!==i?i:t)},remove:function(e,t){var i,n=e[this.expando];if(void 0!==n){if(void 0!==t){i=(t=Array.isArray(t)?t.map($):(t=$(t))in n?[t]:t.match(F)||[]).length;for(;i--;)delete n[t[i]]}(void 0===t||v.isEmptyObject(n))&&(e.nodeType?e[this.expando]=void 0:delete e[this.expando])}},hasData:function(e){var t=e[this.expando];return void 0!==t&&!v.isEmptyObject(t)}};var Z=new G,Q=new G,X=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,Y=/[A-Z]/g;function K(e,t,i){var n;if(void 0===i&&1===e.nodeType)if(n="data-"+t.replace(Y,"-$&").toLowerCase(),"string"==typeof(i=e.getAttribute(n))){try{i=function(e){return"true"===e||"false"!==e&&("null"===e?null:e===+e+""?+e:X.test(e)?JSON.parse(e):e)}(i)}catch(e){}Q.set(e,t,i)}else i=void 0;return i}v.extend({hasData:function(e){return Q.hasData(e)||Z.hasData(e)},data:function(e,t,i){return Q.access(e,t,i)},removeData:function(e,t){Q.remove(e,t)},_data:function(e,t,i){return Z.access(e,t,i)},_removeData:function(e,t){Z.remove(e,t)}}),v.fn.extend({data:function(e,t){var i,n,r,s=this[0],o=s&&s.attributes;if(void 0===e){if(this.length&&(r=Q.get(s),1===s.nodeType&&!Z.get(s,"hasDataAttrs"))){for(i=o.length;i--;)o[i]&&0===(n=o[i].name).indexOf("data-")&&(n=$(n.slice(5)),K(s,n,r[n]));Z.set(s,"hasDataAttrs",!0)}return r}return"object"==typeof e?this.each((function(){Q.set(this,e)})):V(this,(function(t){var i;if(s&&void 0===t)return void 0!==(i=Q.get(s,e))||void 0!==(i=K(s,e))?i:void 0;this.each((function(){Q.set(this,e,t)}))}),null,t,arguments.length>1,null,!0)},removeData:function(e){return this.each((function(){Q.remove(this,e)}))}}),v.extend({queue:function(e,t,i){var n;if(e)return t=(t||"fx")+"queue",n=Z.get(e,t),i&&(!n||Array.isArray(i)?n=Z.access(e,t,v.makeArray(i)):n.push(i)),n||[]},dequeue:function(e,t){t=t||"fx";var i=v.queue(e,t),n=i.length,r=i.shift(),s=v._queueHooks(e,t);"inprogress"===r&&(r=i.shift(),n--),r&&("fx"===t&&i.unshift("inprogress"),delete s.stop,r.call(e,(function(){v.dequeue(e,t)}),s)),!n&&s&&s.empty.fire()},_queueHooks:function(e,t){var i=t+"queueHooks";return Z.get(e,i)||Z.access(e,i,{empty:v.Callbacks("once memory").add((function(){Z.remove(e,[t+"queue",i])}))})}}),v.fn.extend({queue:function(e,t){var i=2;return"string"!=typeof e&&(t=e,e="fx",i--),arguments.length<i?v.queue(this[0],e):void 0===t?this:this.each((function(){var i=v.queue(this,e,t);v._queueHooks(this,e),"fx"===e&&"inprogress"!==i[0]&&v.dequeue(this,e)}))},dequeue:function(e){return this.each((function(){v.dequeue(this,e)}))},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,t){var i,n=1,r=v.Deferred(),s=this,o=this.length,a=function(){--n||r.resolveWith(s,[s])};for("string"!=typeof e&&(t=e,e=void 0),e=e||"fx";o--;)(i=Z.get(s[o],e+"queueHooks"))&&i.empty&&(n++,i.empty.add(a));return a(),r.promise(t)}});var J=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,ee=new RegExp("^(?:([+-])=|)("+J+")([a-z%]*)$","i"),te=["Top","Right","Bottom","Left"],ie=function(e,t){return"none"===(e=t||e).style.display||""===e.style.display&&v.contains(e.ownerDocument,e)&&"none"===v.css(e,"display")},ne=function(e,t,i,n){var r,s,o={};for(s in t)o[s]=e.style[s],e.style[s]=t[s];for(s in r=i.apply(e,n||[]),t)e.style[s]=o[s];return r};var re={};function se(e){var t,i=e.ownerDocument,n=e.nodeName,r=re[n];return r||(t=i.body.appendChild(i.createElement(n)),r=v.css(t,"display"),t.parentNode.removeChild(t),"none"===r&&(r="block"),re[n]=r,r)}function oe(e,t){for(var i,n,r=[],s=0,o=e.length;s<o;s++)(n=e[s]).style&&(i=n.style.display,t?("none"===i&&(r[s]=Z.get(n,"display")||null,r[s]||(n.style.display="")),""===n.style.display&&ie(n)&&(r[s]=se(n))):"none"!==i&&(r[s]="none",Z.set(n,"display",i)));for(s=0;s<o;s++)null!=r[s]&&(e[s].style.display=r[s]);return e}v.fn.extend({show:function(){return oe(this,!0)},hide:function(){return oe(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each((function(){ie(this)?v(this).show():v(this).hide()}))}});var ae=/^(?:checkbox|radio)$/i,le=/<([a-z][^\/\0>\x20\t\r\n\f]+)/i,he=/^$|^module$|\/(?:java|ecma)script/i,ce={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};function de(e,t){var i;return i=void 0!==e.getElementsByTagName?e.getElementsByTagName(t||"*"):void 0!==e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?v.merge([e],i):i}function ue(e,t){for(var i=0,n=e.length;i<n;i++)Z.set(e[i],"globalEval",!t||Z.get(t[i],"globalEval"))}ce.optgroup=ce.option,ce.tbody=ce.tfoot=ce.colgroup=ce.caption=ce.thead,ce.th=ce.td;var fe=/<|&#?\w+;/;function pe(e,t,i,n,r){for(var s,o,a,l,h,c,d=t.createDocumentFragment(),u=[],f=0,p=e.length;f<p;f++)if((s=e[f])||0===s)if("object"===b(s))v.merge(u,s.nodeType?[s]:s);else if(fe.test(s)){for(o=o||d.appendChild(t.createElement("div")),a=(le.exec(s)||["",""])[1].toLowerCase(),l=ce[a]||ce._default,o.innerHTML=l[1]+v.htmlPrefilter(s)+l[2],c=l[0];c--;)o=o.lastChild;v.merge(u,o.childNodes),(o=d.firstChild).textContent=""}else u.push(t.createTextNode(s));for(d.textContent="",f=0;s=u[f++];)if(n&&v.inArray(s,n)>-1)r&&r.push(s);else if(h=v.contains(s.ownerDocument,s),o=de(d.appendChild(s),"script"),h&&ue(o),i)for(c=0;s=o[c++];)he.test(s.type||"")&&i.push(s);return d}!function(){var e=t.createDocumentFragment().appendChild(t.createElement("div")),i=t.createElement("input");i.setAttribute("type","radio"),i.setAttribute("checked","checked"),i.setAttribute("name","t"),e.appendChild(i),u.checkClone=e.cloneNode(!0).cloneNode(!0).lastChild.checked,e.innerHTML="<textarea>x</textarea>",u.noCloneChecked=!!e.cloneNode(!0).lastChild.defaultValue}();var ge=t.documentElement,me=/^key/,be=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,we=/^([^.]*)(?:\.(.+)|)/;function ve(){return!0}function ye(){return!1}function _e(){try{return t.activeElement}catch(e){}}function xe(e,t,i,n,r,s){var o,a;if("object"==typeof t){for(a in"string"!=typeof i&&(n=n||i,i=void 0),t)xe(e,a,i,n,t[a],s);return e}if(null==n&&null==r?(r=i,n=i=void 0):null==r&&("string"==typeof i?(r=n,n=void 0):(r=n,n=i,i=void 0)),!1===r)r=ye;else if(!r)return e;return 1===s&&(o=r,r=function(e){return v().off(e),o.apply(this,arguments)},r.guid=o.guid||(o.guid=v.guid++)),e.each((function(){v.event.add(this,t,r,n,i)}))}v.event={global:{},add:function(e,t,i,n,r){var s,o,a,l,h,c,d,u,f,p,g,m=Z.get(e);if(m)for(i.handler&&(i=(s=i).handler,r=s.selector),r&&v.find.matchesSelector(ge,r),i.guid||(i.guid=v.guid++),(l=m.events)||(l=m.events={}),(o=m.handle)||(o=m.handle=function(t){return void 0!==v&&v.event.triggered!==t.type?v.event.dispatch.apply(e,arguments):void 0}),h=(t=(t||"").match(F)||[""]).length;h--;)f=g=(a=we.exec(t[h])||[])[1],p=(a[2]||"").split(".").sort(),f&&(d=v.event.special[f]||{},f=(r?d.delegateType:d.bindType)||f,d=v.event.special[f]||{},c=v.extend({type:f,origType:g,data:n,handler:i,guid:i.guid,selector:r,needsContext:r&&v.expr.match.needsContext.test(r),namespace:p.join(".")},s),(u=l[f])||((u=l[f]=[]).delegateCount=0,d.setup&&!1!==d.setup.call(e,n,p,o)||e.addEventListener&&e.addEventListener(f,o)),d.add&&(d.add.call(e,c),c.handler.guid||(c.handler.guid=i.guid)),r?u.splice(u.delegateCount++,0,c):u.push(c),v.event.global[f]=!0)},remove:function(e,t,i,n,r){var s,o,a,l,h,c,d,u,f,p,g,m=Z.hasData(e)&&Z.get(e);if(m&&(l=m.events)){for(h=(t=(t||"").match(F)||[""]).length;h--;)if(f=g=(a=we.exec(t[h])||[])[1],p=(a[2]||"").split(".").sort(),f){for(d=v.event.special[f]||{},u=l[f=(n?d.delegateType:d.bindType)||f]||[],a=a[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),o=s=u.length;s--;)c=u[s],!r&&g!==c.origType||i&&i.guid!==c.guid||a&&!a.test(c.namespace)||n&&n!==c.selector&&("**"!==n||!c.selector)||(u.splice(s,1),c.selector&&u.delegateCount--,d.remove&&d.remove.call(e,c));o&&!u.length&&(d.teardown&&!1!==d.teardown.call(e,p,m.handle)||v.removeEvent(e,f,m.handle),delete l[f])}else for(f in l)v.event.remove(e,f+t[h],i,n,!0);v.isEmptyObject(l)&&Z.remove(e,"handle events")}},dispatch:function(e){var t,i,n,r,s,o,a=v.event.fix(e),l=new Array(arguments.length),h=(Z.get(this,"events")||{})[a.type]||[],c=v.event.special[a.type]||{};for(l[0]=a,t=1;t<arguments.length;t++)l[t]=arguments[t];if(a.delegateTarget=this,!c.preDispatch||!1!==c.preDispatch.call(this,a)){for(o=v.event.handlers.call(this,a,h),t=0;(r=o[t++])&&!a.isPropagationStopped();)for(a.currentTarget=r.elem,i=0;(s=r.handlers[i++])&&!a.isImmediatePropagationStopped();)a.rnamespace&&!a.rnamespace.test(s.namespace)||(a.handleObj=s,a.data=s.data,void 0!==(n=((v.event.special[s.origType]||{}).handle||s.handler).apply(r.elem,l))&&!1===(a.result=n)&&(a.preventDefault(),a.stopPropagation()));return c.postDispatch&&c.postDispatch.call(this,a),a.result}},handlers:function(e,t){var i,n,r,s,o,a=[],l=t.delegateCount,h=e.target;if(l&&h.nodeType&&!("click"===e.type&&e.button>=1))for(;h!==this;h=h.parentNode||this)if(1===h.nodeType&&("click"!==e.type||!0!==h.disabled)){for(s=[],o={},i=0;i<l;i++)void 0===o[r=(n=t[i]).selector+" "]&&(o[r]=n.needsContext?v(r,this).index(h)>-1:v.find(r,this,null,[h]).length),o[r]&&s.push(n);s.length&&a.push({elem:h,handlers:s})}return h=this,l<t.length&&a.push({elem:h,handlers:t.slice(l)}),a},addProp:function(e,t){Object.defineProperty(v.Event.prototype,e,{enumerable:!0,configurable:!0,get:f(t)?function(){if(this.originalEvent)return t(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[e]},set:function(t){Object.defineProperty(this,e,{enumerable:!0,configurable:!0,writable:!0,value:t})}})},fix:function(e){return e[v.expando]?e:new v.Event(e)},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==_e()&&this.focus)return this.focus(),!1},delegateType:"focusin"},blur:{trigger:function(){if(this===_e()&&this.blur)return this.blur(),!1},delegateType:"focusout"},click:{trigger:function(){if("checkbox"===this.type&&this.click&&A(this,"input"))return this.click(),!1},_default:function(e){return A(e.target,"a")}},beforeunload:{postDispatch:function(e){void 0!==e.result&&e.originalEvent&&(e.originalEvent.returnValue=e.result)}}}},v.removeEvent=function(e,t,i){e.removeEventListener&&e.removeEventListener(t,i)},v.Event=function(e,t){if(!(this instanceof v.Event))return new v.Event(e,t);e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||void 0===e.defaultPrevented&&!1===e.returnValue?ve:ye,this.target=e.target&&3===e.target.nodeType?e.target.parentNode:e.target,this.currentTarget=e.currentTarget,this.relatedTarget=e.relatedTarget):this.type=e,t&&v.extend(this,t),this.timeStamp=e&&e.timeStamp||Date.now(),this[v.expando]=!0},v.Event.prototype={constructor:v.Event,isDefaultPrevented:ye,isPropagationStopped:ye,isImmediatePropagationStopped:ye,isSimulated:!1,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=ve,e&&!this.isSimulated&&e.preventDefault()},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=ve,e&&!this.isSimulated&&e.stopPropagation()},stopImmediatePropagation:function(){var e=this.originalEvent;this.isImmediatePropagationStopped=ve,e&&!this.isSimulated&&e.stopImmediatePropagation(),this.stopPropagation()}},v.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,char:!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:function(e){var t=e.button;return null==e.which&&me.test(e.type)?null!=e.charCode?e.charCode:e.keyCode:!e.which&&void 0!==t&&be.test(e.type)?1&t?1:2&t?3:4&t?2:0:e.which}},v.event.addProp),v.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},(function(e,t){v.event.special[e]={delegateType:t,bindType:t,handle:function(e){var i,n=e.relatedTarget,r=e.handleObj;return n&&(n===this||v.contains(this,n))||(e.type=r.origType,i=r.handler.apply(this,arguments),e.type=t),i}}})),v.fn.extend({on:function(e,t,i,n){return xe(this,e,t,i,n)},one:function(e,t,i,n){return xe(this,e,t,i,n,1)},off:function(e,t,i){var n,r;if(e&&e.preventDefault&&e.handleObj)return n=e.handleObj,v(e.delegateTarget).off(n.namespace?n.origType+"."+n.namespace:n.origType,n.selector,n.handler),this;if("object"==typeof e){for(r in e)this.off(r,t,e[r]);return this}return!1!==t&&"function"!=typeof t||(i=t,t=void 0),!1===i&&(i=ye),this.each((function(){v.event.remove(this,e,i,t)}))}});var ke=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,Ce=/<script|<style|<link/i,Se=/checked\s*(?:[^=]|=\s*.checked.)/i,Ae=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;function Ee(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&v(e).children("tbody")[0]||e}function Me(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Te(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Re(e,t){var i,n,r,s,o,a,l,h;if(1===t.nodeType){if(Z.hasData(e)&&(s=Z.access(e),o=Z.set(t,s),h=s.events))for(r in delete o.handle,o.events={},h)for(i=0,n=h[r].length;i<n;i++)v.event.add(t,r,h[r][i]);Q.hasData(e)&&(a=Q.access(e),l=v.extend({},a),Q.set(t,l))}}function Le(e,t){var i=t.nodeName.toLowerCase();"input"===i&&ae.test(e.type)?t.checked=e.checked:"input"!==i&&"textarea"!==i||(t.defaultValue=e.defaultValue)}function Ie(e,t,i,n){t=r.apply([],t);var s,o,a,l,h,c,d=0,p=e.length,g=p-1,b=t[0],w=f(b);if(w||p>1&&"string"==typeof b&&!u.checkClone&&Se.test(b))return e.each((function(r){var s=e.eq(r);w&&(t[0]=b.call(this,r,s.html())),Ie(s,t,i,n)}));if(p&&(o=(s=pe(t,e[0].ownerDocument,!1,e,n)).firstChild,1===s.childNodes.length&&(s=o),o||n)){for(l=(a=v.map(de(s,"script"),Me)).length;d<p;d++)h=s,d!==g&&(h=v.clone(h,!0,!0),l&&v.merge(a,de(h,"script"))),i.call(e[d],h,d);if(l)for(c=a[a.length-1].ownerDocument,v.map(a,Te),d=0;d<l;d++)h=a[d],he.test(h.type||"")&&!Z.access(h,"globalEval")&&v.contains(c,h)&&(h.src&&"module"!==(h.type||"").toLowerCase()?v._evalUrl&&v._evalUrl(h.src):m(h.textContent.replace(Ae,""),c,h))}return e}function Be(e,t,i){for(var n,r=t?v.filter(t,e):e,s=0;null!=(n=r[s]);s++)i||1!==n.nodeType||v.cleanData(de(n)),n.parentNode&&(i&&v.contains(n.ownerDocument,n)&&ue(de(n,"script")),n.parentNode.removeChild(n));return e}v.extend({htmlPrefilter:function(e){return e.replace(ke,"<$1></$2>")},clone:function(e,t,i){var n,r,s,o,a=e.cloneNode(!0),l=v.contains(e.ownerDocument,e);if(!(u.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||v.isXMLDoc(e)))for(o=de(a),n=0,r=(s=de(e)).length;n<r;n++)Le(s[n],o[n]);if(t)if(i)for(s=s||de(e),o=o||de(a),n=0,r=s.length;n<r;n++)Re(s[n],o[n]);else Re(e,a);return(o=de(a,"script")).length>0&&ue(o,!l&&de(e,"script")),a},cleanData:function(e){for(var t,i,n,r=v.event.special,s=0;void 0!==(i=e[s]);s++)if(W(i)){if(t=i[Z.expando]){if(t.events)for(n in t.events)r[n]?v.event.remove(i,n):v.removeEvent(i,n,t.handle);i[Z.expando]=void 0}i[Q.expando]&&(i[Q.expando]=void 0)}}}),v.fn.extend({detach:function(e){return Be(this,e,!0)},remove:function(e){return Be(this,e)},text:function(e){return V(this,(function(e){return void 0===e?v.text(this):this.empty().each((function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)}))}),null,e,arguments.length)},append:function(){return Ie(this,arguments,(function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||Ee(this,e).appendChild(e)}))},prepend:function(){return Ie(this,arguments,(function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Ee(this,e);t.insertBefore(e,t.firstChild)}}))},before:function(){return Ie(this,arguments,(function(e){this.parentNode&&this.parentNode.insertBefore(e,this)}))},after:function(){return Ie(this,arguments,(function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)}))},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(v.cleanData(de(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map((function(){return v.clone(this,e,t)}))},html:function(e){return V(this,(function(e){var t=this[0]||{},i=0,n=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!Ce.test(e)&&!ce[(le.exec(e)||["",""])[1].toLowerCase()]){e=v.htmlPrefilter(e);try{for(;i<n;i++)1===(t=this[i]||{}).nodeType&&(v.cleanData(de(t,!1)),t.innerHTML=e);t=0}catch(e){}}t&&this.empty().append(e)}),null,e,arguments.length)},replaceWith:function(){var e=[];return Ie(this,arguments,(function(t){var i=this.parentNode;v.inArray(this,e)<0&&(v.cleanData(de(this)),i&&i.replaceChild(t,this))}),e)}}),v.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},(function(e,t){v.fn[e]=function(e){for(var i,n=[],r=v(e),o=r.length-1,a=0;a<=o;a++)i=a===o?this:this.clone(!0),v(r[a])[t](i),s.apply(n,i.get());return this.pushStack(n)}}));var Fe=new RegExp("^("+J+")(?!px)[a-z%]+$","i"),Ne=function(e){var t=e.ownerDocument.defaultView;return t&&t.opener||(t=window),t.getComputedStyle(e)},Oe=new RegExp(te.join("|"),"i");function Pe(e,t,i){var n,r,s,o,a=e.style;return(i=i||Ne(e))&&(""!==(o=i.getPropertyValue(t)||i[t])||v.contains(e.ownerDocument,e)||(o=v.style(e,t)),!u.pixelBoxStyles()&&Fe.test(o)&&Oe.test(t)&&(n=a.width,r=a.minWidth,s=a.maxWidth,a.minWidth=a.maxWidth=a.width=o,o=i.width,a.width=n,a.minWidth=r,a.maxWidth=s)),void 0!==o?o+"":o}function De(e,t){return{get:function(){if(!e())return(this.get=t).apply(this,arguments);delete this.get}}}!function(){function e(){if(h){l.style.cssText="position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0",h.style.cssText="position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%",ge.appendChild(l).appendChild(h);var e=window.getComputedStyle(h);n="1%"!==e.top,a=12===i(e.marginLeft),h.style.right="60%",o=36===i(e.right),r=36===i(e.width),h.style.position="absolute",s=36===h.offsetWidth||"absolute",ge.removeChild(l),h=null}}function i(e){return Math.round(parseFloat(e))}var n,r,s,o,a,l=t.createElement("div"),h=t.createElement("div");h.style&&(h.style.backgroundClip="content-box",h.cloneNode(!0).style.backgroundClip="",u.clearCloneStyle="content-box"===h.style.backgroundClip,v.extend(u,{boxSizingReliable:function(){return e(),r},pixelBoxStyles:function(){return e(),o},pixelPosition:function(){return e(),n},reliableMarginLeft:function(){return e(),a},scrollboxSize:function(){return e(),s}}))}();var ze,He,Ve=/^(none|table(?!-c[ea]).+)/,Ue=/^--/,qe={position:"absolute",visibility:"hidden",display:"block"},je={letterSpacing:"0",fontWeight:"400"},$e=["Webkit","Moz","ms"],We=t.createElement("div").style;function Ge(e){var t=v.cssProps[e];return t||(t=v.cssProps[e]=function(e){if(e in We)return e;for(var t=e[0].toUpperCase()+e.slice(1),i=$e.length;i--;)if((e=$e[i]+t)in We)return e}(e)||e),t}function Ze(e,t,i){var n=ee.exec(t);return n?Math.max(0,n[2]-(i||0))+(n[3]||"px"):t}function Qe(e,t,i,n,r,s){var o="width"===t?1:0,a=0,l=0;if(i===(n?"border":"content"))return 0;for(;o<4;o+=2)"margin"===i&&(l+=v.css(e,i+te[o],!0,r)),n?("content"===i&&(l-=v.css(e,"padding"+te[o],!0,r)),"margin"!==i&&(l-=v.css(e,"border"+te[o]+"Width",!0,r))):(l+=v.css(e,"padding"+te[o],!0,r),"padding"!==i?l+=v.css(e,"border"+te[o]+"Width",!0,r):a+=v.css(e,"border"+te[o]+"Width",!0,r));return!n&&s>=0&&(l+=Math.max(0,Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-s-l-a-.5))),l}function Xe(e,t,i){var n=Ne(e),r=Pe(e,t,n),s="border-box"===v.css(e,"boxSizing",!1,n),o=s;if(Fe.test(r)){if(!i)return r;r="auto"}return o=o&&(u.boxSizingReliable()||r===e.style[t]),("auto"===r||!parseFloat(r)&&"inline"===v.css(e,"display",!1,n))&&(r=e["offset"+t[0].toUpperCase()+t.slice(1)],o=!0),(r=parseFloat(r)||0)+Qe(e,t,i||(s?"border":"content"),o,n,r)+"px"}v.extend({cssHooks:{opacity:{get:function(e,t){if(t){var i=Pe(e,"opacity");return""===i?"1":i}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,t,i,n){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var r,s,o,a=$(t),l=Ue.test(t),h=e.style;if(l||(t=Ge(a)),o=v.cssHooks[t]||v.cssHooks[a],void 0===i)return o&&"get"in o&&void 0!==(r=o.get(e,!1,n))?r:h[t];"string"===(s=typeof i)&&(r=ee.exec(i))&&r[1]&&(i=function(e,t,i,n){var r,s,o=20,a=n?function(){return n.cur()}:function(){return v.css(e,t,"")},l=a(),h=i&&i[3]||(v.cssNumber[t]?"":"px"),c=(v.cssNumber[t]||"px"!==h&&+l)&&ee.exec(v.css(e,t));if(c&&c[3]!==h){for(l/=2,h=h||c[3],c=+l||1;o--;)v.style(e,t,c+h),(1-s)*(1-(s=a()/l||.5))<=0&&(o=0),c/=s;c*=2,v.style(e,t,c+h),i=i||[]}return i&&(c=+c||+l||0,r=i[1]?c+(i[1]+1)*i[2]:+i[2],n&&(n.unit=h,n.start=c,n.end=r)),r}(e,t,r),s="number"),null!=i&&i==i&&("number"===s&&(i+=r&&r[3]||(v.cssNumber[a]?"":"px")),u.clearCloneStyle||""!==i||0!==t.indexOf("background")||(h[t]="inherit"),o&&"set"in o&&void 0===(i=o.set(e,i,n))||(l?h.setProperty(t,i):h[t]=i))}},css:function(e,t,i,n){var r,s,o,a=$(t);return Ue.test(t)||(t=Ge(a)),(o=v.cssHooks[t]||v.cssHooks[a])&&"get"in o&&(r=o.get(e,!0,i)),void 0===r&&(r=Pe(e,t,n)),"normal"===r&&t in je&&(r=je[t]),""===i||i?(s=parseFloat(r),!0===i||isFinite(s)?s||0:r):r}}),v.each(["height","width"],(function(e,t){v.cssHooks[t]={get:function(e,i,n){if(i)return!Ve.test(v.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?Xe(e,t,n):ne(e,qe,(function(){return Xe(e,t,n)}))},set:function(e,i,n){var r,s=Ne(e),o="border-box"===v.css(e,"boxSizing",!1,s),a=n&&Qe(e,t,n,o,s);return o&&u.scrollboxSize()===s.position&&(a-=Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-parseFloat(s[t])-Qe(e,t,"border",!1,s)-.5)),a&&(r=ee.exec(i))&&"px"!==(r[3]||"px")&&(e.style[t]=i,i=v.css(e,t)),Ze(0,i,a)}}})),v.cssHooks.marginLeft=De(u.reliableMarginLeft,(function(e,t){if(t)return(parseFloat(Pe(e,"marginLeft"))||e.getBoundingClientRect().left-ne(e,{marginLeft:0},(function(){return e.getBoundingClientRect().left})))+"px"})),v.each({margin:"",padding:"",border:"Width"},(function(e,t){v.cssHooks[e+t]={expand:function(i){for(var n=0,r={},s="string"==typeof i?i.split(" "):[i];n<4;n++)r[e+te[n]+t]=s[n]||s[n-2]||s[0];return r}},"margin"!==e&&(v.cssHooks[e+t].set=Ze)})),v.fn.extend({css:function(e,t){return V(this,(function(e,t,i){var n,r,s={},o=0;if(Array.isArray(t)){for(n=Ne(e),r=t.length;o<r;o++)s[t[o]]=v.css(e,t[o],!1,n);return s}return void 0!==i?v.style(e,t,i):v.css(e,t)}),e,t,arguments.length>1)}}),v.fn.delay=function(e,t){return e=v.fx&&v.fx.speeds[e]||e,t=t||"fx",this.queue(t,(function(t,i){var n=window.setTimeout(t,e);i.stop=function(){window.clearTimeout(n)}}))},ze=t.createElement("input"),He=t.createElement("select").appendChild(t.createElement("option")),ze.type="checkbox",u.checkOn=""!==ze.value,u.optSelected=He.selected,(ze=t.createElement("input")).value="t",ze.type="radio",u.radioValue="t"===ze.value;var Ye,Ke=v.expr.attrHandle;v.fn.extend({attr:function(e,t){return V(this,v.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each((function(){v.removeAttr(this,e)}))}}),v.extend({attr:function(e,t,i){var n,r,s=e.nodeType;if(3!==s&&8!==s&&2!==s)return void 0===e.getAttribute?v.prop(e,t,i):(1===s&&v.isXMLDoc(e)||(r=v.attrHooks[t.toLowerCase()]||(v.expr.match.bool.test(t)?Ye:void 0)),void 0!==i?null===i?void v.removeAttr(e,t):r&&"set"in r&&void 0!==(n=r.set(e,i,t))?n:(e.setAttribute(t,i+""),i):r&&"get"in r&&null!==(n=r.get(e,t))?n:null==(n=v.find.attr(e,t))?void 0:n)},attrHooks:{type:{set:function(e,t){if(!u.radioValue&&"radio"===t&&A(e,"input")){var i=e.value;return e.setAttribute("type",t),i&&(e.value=i),t}}}},removeAttr:function(e,t){var i,n=0,r=t&&t.match(F);if(r&&1===e.nodeType)for(;i=r[n++];)e.removeAttribute(i)}}),Ye={set:function(e,t,i){return!1===t?v.removeAttr(e,i):e.setAttribute(i,i),i}},v.each(v.expr.match.bool.source.match(/\w+/g),(function(e,t){var i=Ke[t]||v.find.attr;Ke[t]=function(e,t,n){var r,s,o=t.toLowerCase();return n||(s=Ke[o],Ke[o]=r,r=null!=i(e,t,n)?o:null,Ke[o]=s),r}}));var Je=/^(?:input|select|textarea|button)$/i,et=/^(?:a|area)$/i;function tt(e){return(e.match(F)||[]).join(" ")}function it(e){return e.getAttribute&&e.getAttribute("class")||""}function nt(e){return Array.isArray(e)?e:"string"==typeof e&&e.match(F)||[]}v.fn.extend({prop:function(e,t){return V(this,v.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each((function(){delete this[v.propFix[e]||e]}))}}),v.extend({prop:function(e,t,i){var n,r,s=e.nodeType;if(3!==s&&8!==s&&2!==s)return 1===s&&v.isXMLDoc(e)||(t=v.propFix[t]||t,r=v.propHooks[t]),void 0!==i?r&&"set"in r&&void 0!==(n=r.set(e,i,t))?n:e[t]=i:r&&"get"in r&&null!==(n=r.get(e,t))?n:e[t]},propHooks:{tabIndex:{get:function(e){var t=v.find.attr(e,"tabindex");return t?parseInt(t,10):Je.test(e.nodeName)||et.test(e.nodeName)&&e.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),u.optSelected||(v.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),v.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],(function(){v.propFix[this.toLowerCase()]=this})),v.fn.extend({addClass:function(e){var t,i,n,r,s,o,a,l=0;if(f(e))return this.each((function(t){v(this).addClass(e.call(this,t,it(this)))}));if((t=nt(e)).length)for(;i=this[l++];)if(r=it(i),n=1===i.nodeType&&" "+tt(r)+" "){for(o=0;s=t[o++];)n.indexOf(" "+s+" ")<0&&(n+=s+" ");r!==(a=tt(n))&&i.setAttribute("class",a)}return this},removeClass:function(e){var t,i,n,r,s,o,a,l=0;if(f(e))return this.each((function(t){v(this).removeClass(e.call(this,t,it(this)))}));if(!arguments.length)return this.attr("class","");if((t=nt(e)).length)for(;i=this[l++];)if(r=it(i),n=1===i.nodeType&&" "+tt(r)+" "){for(o=0;s=t[o++];)for(;n.indexOf(" "+s+" ")>-1;)n=n.replace(" "+s+" "," ");r!==(a=tt(n))&&i.setAttribute("class",a)}return this},toggleClass:function(e,t){var i=typeof e,n="string"===i||Array.isArray(e);return"boolean"==typeof t&&n?t?this.addClass(e):this.removeClass(e):f(e)?this.each((function(i){v(this).toggleClass(e.call(this,i,it(this),t),t)})):this.each((function(){var t,r,s,o;if(n)for(r=0,s=v(this),o=nt(e);t=o[r++];)s.hasClass(t)?s.removeClass(t):s.addClass(t);else void 0!==e&&"boolean"!==i||((t=it(this))&&Z.set(this,"__className__",t),this.setAttribute&&this.setAttribute("class",t||!1===e?"":Z.get(this,"__className__")||""))}))},hasClass:function(e){var t,i,n=0;for(t=" "+e+" ";i=this[n++];)if(1===i.nodeType&&(" "+tt(it(i))+" ").indexOf(t)>-1)return!0;return!1}});var rt=/\r/g;v.fn.extend({val:function(e){var t,i,n,r=this[0];return arguments.length?(n=f(e),this.each((function(i){var r;1===this.nodeType&&(null==(r=n?e.call(this,i,v(this).val()):e)?r="":"number"==typeof r?r+="":Array.isArray(r)&&(r=v.map(r,(function(e){return null==e?"":e+""}))),(t=v.valHooks[this.type]||v.valHooks[this.nodeName.toLowerCase()])&&"set"in t&&void 0!==t.set(this,r,"value")||(this.value=r))}))):r?(t=v.valHooks[r.type]||v.valHooks[r.nodeName.toLowerCase()])&&"get"in t&&void 0!==(i=t.get(r,"value"))?i:"string"==typeof(i=r.value)?i.replace(rt,""):null==i?"":i:void 0}}),v.extend({valHooks:{option:{get:function(e){var t=v.find.attr(e,"value");return null!=t?t:tt(v.text(e))}},select:{get:function(e){var t,i,n,r=e.options,s=e.selectedIndex,o="select-one"===e.type,a=o?null:[],l=o?s+1:r.length;for(n=s<0?l:o?s:0;n<l;n++)if(((i=r[n]).selected||n===s)&&!i.disabled&&(!i.parentNode.disabled||!A(i.parentNode,"optgroup"))){if(t=v(i).val(),o)return t;a.push(t)}return a},set:function(e,t){for(var i,n,r=e.options,s=v.makeArray(t),o=r.length;o--;)((n=r[o]).selected=v.inArray(v.valHooks.option.get(n),s)>-1)&&(i=!0);return i||(e.selectedIndex=-1),s}}}}),v.each(["radio","checkbox"],(function(){v.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=v.inArray(v(e).val(),t)>-1}},u.checkOn||(v.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})})),u.focusin="onfocusin"in window;var st=/^(?:focusinfocus|focusoutblur)$/,ot=function(e){e.stopPropagation()};v.extend(v.event,{trigger:function(e,i,n,r){var s,o,a,l,c,d,u,g,m=[n||t],b=h.call(e,"type")?e.type:e,w=h.call(e,"namespace")?e.namespace.split("."):[];if(o=g=a=n=n||t,3!==n.nodeType&&8!==n.nodeType&&!st.test(b+v.event.triggered)&&(b.indexOf(".")>-1&&(w=b.split("."),b=w.shift(),w.sort()),c=b.indexOf(":")<0&&"on"+b,(e=e[v.expando]?e:new v.Event(b,"object"==typeof e&&e)).isTrigger=r?2:3,e.namespace=w.join("."),e.rnamespace=e.namespace?new RegExp("(^|\\.)"+w.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,e.result=void 0,e.target||(e.target=n),i=null==i?[e]:v.makeArray(i,[e]),u=v.event.special[b]||{},r||!u.trigger||!1!==u.trigger.apply(n,i))){if(!r&&!u.noBubble&&!p(n)){for(l=u.delegateType||b,st.test(l+b)||(o=o.parentNode);o;o=o.parentNode)m.push(o),a=o;a===(n.ownerDocument||t)&&m.push(a.defaultView||a.parentWindow||window)}for(s=0;(o=m[s++])&&!e.isPropagationStopped();)g=o,e.type=s>1?l:u.bindType||b,(d=(Z.get(o,"events")||{})[e.type]&&Z.get(o,"handle"))&&d.apply(o,i),(d=c&&o[c])&&d.apply&&W(o)&&(e.result=d.apply(o,i),!1===e.result&&e.preventDefault());return e.type=b,r||e.isDefaultPrevented()||u._default&&!1!==u._default.apply(m.pop(),i)||!W(n)||c&&f(n[b])&&!p(n)&&((a=n[c])&&(n[c]=null),v.event.triggered=b,e.isPropagationStopped()&&g.addEventListener(b,ot),n[b](),e.isPropagationStopped()&&g.removeEventListener(b,ot),v.event.triggered=void 0,a&&(n[c]=a)),e.result}},simulate:function(e,t,i){var n=v.extend(new v.Event,i,{type:e,isSimulated:!0});v.event.trigger(n,null,t)}}),v.fn.extend({trigger:function(e,t){return this.each((function(){v.event.trigger(e,t,this)}))},triggerHandler:function(e,t){var i=this[0];if(i)return v.event.trigger(e,t,i,!0)}}),u.focusin||v.each({focus:"focusin",blur:"focusout"},(function(e,t){var i=function(e){v.event.simulate(t,e.target,v.event.fix(e))};v.event.special[t]={setup:function(){var n=this.ownerDocument||this,r=Z.access(n,t);r||n.addEventListener(e,i,!0),Z.access(n,t,(r||0)+1)},teardown:function(){var n=this.ownerDocument||this,r=Z.access(n,t)-1;r?Z.access(n,t,r):(n.removeEventListener(e,i,!0),Z.remove(n,t))}}}));var at,lt=/\[\]$/,ht=/\r?\n/g,ct=/^(?:submit|button|image|reset|file)$/i,dt=/^(?:input|select|textarea|keygen)/i;function ut(e,t,i,n){var r;if(Array.isArray(t))v.each(t,(function(t,r){i||lt.test(e)?n(e,r):ut(e+"["+("object"==typeof r&&null!=r?t:"")+"]",r,i,n)}));else if(i||"object"!==b(t))n(e,t);else for(r in t)ut(e+"["+r+"]",t[r],i,n)}v.param=function(e,t){var i,n=[],r=function(e,t){var i=f(t)?t():t;n[n.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==i?"":i)};if(Array.isArray(e)||e.jquery&&!v.isPlainObject(e))v.each(e,(function(){r(this.name,this.value)}));else for(i in e)ut(i,e[i],t,r);return n.join("&")},v.fn.extend({serialize:function(){return v.param(this.serializeArray())},serializeArray:function(){return this.map((function(){var e=v.prop(this,"elements");return e?v.makeArray(e):this})).filter((function(){var e=this.type;return this.name&&!v(this).is(":disabled")&&dt.test(this.nodeName)&&!ct.test(e)&&(this.checked||!ae.test(e))})).map((function(e,t){var i=v(this).val();return null==i?null:Array.isArray(i)?v.map(i,(function(e){return{name:t.name,value:e.replace(ht,"\r\n")}})):{name:t.name,value:i.replace(ht,"\r\n")}})).get()}}),v.fn.extend({wrapAll:function(e){var t;return this[0]&&(f(e)&&(e=e.call(this[0])),t=v(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map((function(){for(var e=this;e.firstElementChild;)e=e.firstElementChild;return e})).append(this)),this},wrapInner:function(e){return f(e)?this.each((function(t){v(this).wrapInner(e.call(this,t))})):this.each((function(){var t=v(this),i=t.contents();i.length?i.wrapAll(e):t.append(e)}))},wrap:function(e){var t=f(e);return this.each((function(i){v(this).wrapAll(t?e.call(this,i):e)}))},unwrap:function(e){return this.parent(e).not("body").each((function(){v(this).replaceWith(this.childNodes)})),this}}),v.expr.pseudos.hidden=function(e){return!v.expr.pseudos.visible(e)},v.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},u.createHTMLDocument=((at=t.implementation.createHTMLDocument("").body).innerHTML="<form></form><form></form>",2===at.childNodes.length),v.parseHTML=function(e,i,n){return"string"!=typeof e?[]:("boolean"==typeof i&&(n=i,i=!1),i||(u.createHTMLDocument?((r=(i=t.implementation.createHTMLDocument("")).createElement("base")).href=t.location.href,i.head.appendChild(r)):i=t),o=!n&&[],(s=E.exec(e))?[i.createElement(s[1])]:(s=pe([e],i,o),o&&o.length&&v(o).remove(),v.merge([],s.childNodes)));var r,s,o},v.offset={setOffset:function(e,t,i){var n,r,s,o,a,l,h=v.css(e,"position"),c=v(e),d={};"static"===h&&(e.style.position="relative"),a=c.offset(),s=v.css(e,"top"),l=v.css(e,"left"),("absolute"===h||"fixed"===h)&&(s+l).indexOf("auto")>-1?(o=(n=c.position()).top,r=n.left):(o=parseFloat(s)||0,r=parseFloat(l)||0),f(t)&&(t=t.call(e,i,v.extend({},a))),null!=t.top&&(d.top=t.top-a.top+o),null!=t.left&&(d.left=t.left-a.left+r),"using"in t?t.using.call(e,d):c.css(d)}},v.fn.extend({offset:function(e){if(arguments.length)return void 0===e?this:this.each((function(t){v.offset.setOffset(this,e,t)}));var t,i,n=this[0];return n?n.getClientRects().length?(t=n.getBoundingClientRect(),i=n.ownerDocument.defaultView,{top:t.top+i.pageYOffset,left:t.left+i.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,i,n=this[0],r={top:0,left:0};if("fixed"===v.css(n,"position"))t=n.getBoundingClientRect();else{for(t=this.offset(),i=n.ownerDocument,e=n.offsetParent||i.documentElement;e&&(e===i.body||e===i.documentElement)&&"static"===v.css(e,"position");)e=e.parentNode;e&&e!==n&&1===e.nodeType&&((r=v(e).offset()).top+=v.css(e,"borderTopWidth",!0),r.left+=v.css(e,"borderLeftWidth",!0))}return{top:t.top-r.top-v.css(n,"marginTop",!0),left:t.left-r.left-v.css(n,"marginLeft",!0)}}},offsetParent:function(){return this.map((function(){for(var e=this.offsetParent;e&&"static"===v.css(e,"position");)e=e.offsetParent;return e||ge}))}}),v.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},(function(e,t){var i="pageYOffset"===t;v.fn[e]=function(n){return V(this,(function(e,n,r){var s;if(p(e)?s=e:9===e.nodeType&&(s=e.defaultView),void 0===r)return s?s[t]:e[n];s?s.scrollTo(i?s.pageXOffset:r,i?r:s.pageYOffset):e[n]=r}),e,n,arguments.length)}})),v.each(["top","left"],(function(e,t){v.cssHooks[t]=De(u.pixelPosition,(function(e,i){if(i)return i=Pe(e,t),Fe.test(i)?v(e).position()[t]+"px":i}))})),v.each({Height:"height",Width:"width"},(function(e,t){v.each({padding:"inner"+e,content:t,"":"outer"+e},(function(i,n){v.fn[n]=function(r,s){var o=arguments.length&&(i||"boolean"!=typeof r),a=i||(!0===r||!0===s?"margin":"border");return V(this,(function(t,i,r){var s;return p(t)?0===n.indexOf("outer")?t["inner"+e]:t.document.documentElement["client"+e]:9===t.nodeType?(s=t.documentElement,Math.max(t.body["scroll"+e],s["scroll"+e],t.body["offset"+e],s["offset"+e],s["client"+e])):void 0===r?v.css(t,i,a):v.style(t,i,r,a)}),t,o?r:void 0,o)}}))})),v.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),(function(e,t){v.fn[t]=function(e,i){return arguments.length>0?this.on(t,null,e,i):this.trigger(t)}})),v.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),v.fn.extend({bind:function(e,t,i){return this.on(e,null,t,i)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,i,n){return this.on(t,e,i,n)},undelegate:function(e,t,i){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",i)}}),v.proxy=function(e,t){var i,r,s;if("string"==typeof t&&(i=e[t],t=e,e=i),f(e))return r=n.call(arguments,2),s=function(){return e.apply(t||this,r.concat(n.call(arguments)))},s.guid=e.guid=e.guid||v.guid++,s},v.holdReady=function(e){e?v.readyWait++:v.ready(!0)},v.isArray=Array.isArray,v.parseJSON=JSON.parse,v.nodeName=A,v.isFunction=f,v.isWindow=p,v.camelCase=$,v.type=b,v.now=Date.now,v.isNumeric=function(e){var t=v.type(e);return("number"===t||"string"===t)&&!isNaN(e-parseFloat(e))};const ft=v;function pt(e){return gt("div",e)}function gt(e,t){const i=document.createElement(e);return t&&(t.class&&i.classList.add(t.class),t.id&&(i.id=t.id),t.style&&wt(i,t.style)),i}function mt(e){const t=getComputedStyle(e);"none"!==t.display&&(e._initialDisplay=t.display),e.style.display="none"}function bt(e){if("none"===getComputedStyle(e).display){const t=e._initialDisplay||"block";e.style.display=t}}function wt(e,t){for(let i of Object.keys(t))e.style[i]=t[i]}let vt=(e,{clientX:t,clientY:i})=>{const{left:n,top:r,width:s,height:o}=e.getBoundingClientRect(),a=t-n,l=i-r;return{x:a,y:l,xNormalized:a/s,yNormalized:l/o,width:s,height:o}};function yt(e,t){const{clientX:i,clientY:n}=e;return vt(t,{clientX:i,clientY:n})}var _t=Object.freeze({__proto__:null,applyStyle:wt,create:gt,div:pt,empty:function(e){for(;e.firstChild;)e.removeChild(e.firstChild)},guid:function(){return("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)},hide:mt,hideAll:function(e){document.querySelectorAll(e).forEach((e=>{mt(e)}))},offset:function(e){if(!e.getClientRects().length)return{top:0,left:0};const t=e.getBoundingClientRect(),i=e.ownerDocument.defaultView;return{top:t.top+i.pageYOffset,left:t.left+i.pageXOffset}},pageCoordinates:function(e){if(e.type.startsWith("touch")){const t=e.touches[0];return{x:t.pageX,y:t.pageY}}return{x:e.pageX,y:e.pageY}},relativeDOMBBox:(e,t)=>{const{x:i,y:n,width:r,height:s}=e.getBoundingClientRect(),{x:o,y:a,width:l,height:h}=t.getBoundingClientRect();return{x:o-i,y:a-n,width:l,height:h}},show:bt,translateMouseCoordinates:yt});function xt(e,t){const i=pt({class:"igv-ui-trackgear-popover-check-container"}),n=Ct("check",!0===t?"#444":"transparent");n.style.borderColor="gray",n.style.borderWidth="1px",n.style.borderStyle="solid",i.appendChild(n);let r=pt();return r.textContent=e,i.appendChild(r),i}function kt(e,t){return Ct(e,t)}function Ct(e,t){t=t||"currentColor";let i=St[e];i||(console.error(`No icon named: ${e}`),i=St.question);const n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttributeNS(null,"viewBox","0 0 "+i[0]+" "+i[1]);const r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttributeNS(null,"fill",t),r.setAttributeNS(null,"d",i[4]),n.appendChild(r),n}const St={check:[512,512,[],"f00c","M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"],cog:[512,512,[],"f013","M444.788 291.1l42.616 24.599c4.867 2.809 7.126 8.618 5.459 13.985-11.07 35.642-29.97 67.842-54.689 94.586a12.016 12.016 0 0 1-14.832 2.254l-42.584-24.595a191.577 191.577 0 0 1-60.759 35.13v49.182a12.01 12.01 0 0 1-9.377 11.718c-34.956 7.85-72.499 8.256-109.219.007-5.49-1.233-9.403-6.096-9.403-11.723v-49.184a191.555 191.555 0 0 1-60.759-35.13l-42.584 24.595a12.016 12.016 0 0 1-14.832-2.254c-24.718-26.744-43.619-58.944-54.689-94.586-1.667-5.366.592-11.175 5.459-13.985L67.212 291.1a193.48 193.48 0 0 1 0-70.199l-42.616-24.599c-4.867-2.809-7.126-8.618-5.459-13.985 11.07-35.642 29.97-67.842 54.689-94.586a12.016 12.016 0 0 1 14.832-2.254l42.584 24.595a191.577 191.577 0 0 1 60.759-35.13V25.759a12.01 12.01 0 0 1 9.377-11.718c34.956-7.85 72.499-8.256 109.219-.007 5.49 1.233 9.403 6.096 9.403 11.723v49.184a191.555 191.555 0 0 1 60.759 35.13l42.584-24.595a12.016 12.016 0 0 1 14.832 2.254c24.718 26.744 43.619 58.944 54.689 94.586 1.667 5.366-.592 11.175-5.459 13.985L444.788 220.9a193.485 193.485 0 0 1 0 70.2zM336 256c0-44.112-35.888-80-80-80s-80 35.888-80 80 35.888 80 80 80 80-35.888 80-80z"],exclamation:[192,512,[],"f12a","M176 432c0 44.112-35.888 80-80 80s-80-35.888-80-80 35.888-80 80-80 80 35.888 80 80zM25.26 25.199l13.6 272C39.499 309.972 50.041 320 62.83 320h66.34c12.789 0 23.331-10.028 23.97-22.801l13.6-272C167.425 11.49 156.496 0 142.77 0H49.23C35.504 0 24.575 11.49 25.26 25.199z"],"exclamation-circle":[512,512,[],"f06a","M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zm-248 50c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"],"exclamation-triangle":[576,512,[],"f071","M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"],minus:[448,512,[],"f068","M424 318.2c13.3 0 24-10.7 24-24v-76.4c0-13.3-10.7-24-24-24H24c-13.3 0-24 10.7-24 24v76.4c0 13.3 10.7 24 24 24h400z"],"minus-circle":[512,512,[],"f056","M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zM124 296c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h264c6.6 0 12 5.4 12 12v56c0 6.6-5.4 12-12 12H124z"],"minus-square":[448,512,[],"f146","M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48zM92 296c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h264c6.6 0 12 5.4 12 12v56c0 6.6-5.4 12-12 12H92z"],plus:[448,512,[],"f067","M448 294.2v-76.4c0-13.3-10.7-24-24-24H286.2V56c0-13.3-10.7-24-24-24h-76.4c-13.3 0-24 10.7-24 24v137.8H24c-13.3 0-24 10.7-24 24v76.4c0 13.3 10.7 24 24 24h137.8V456c0 13.3 10.7 24 24 24h76.4c13.3 0 24-10.7 24-24V318.2H424c13.3 0 24-10.7 24-24z"],"plus-circle":[512,512,[],"f055","M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm144 276c0 6.6-5.4 12-12 12h-92v92c0 6.6-5.4 12-12 12h-56c-6.6 0-12-5.4-12-12v-92h-92c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h92v-92c0-6.6 5.4-12 12-12h56c6.6 0 12 5.4 12 12v92h92c6.6 0 12 5.4 12 12v56z"],"plus-square":[448,512,[],"f0fe","M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48zm-32 252c0 6.6-5.4 12-12 12h-92v92c0 6.6-5.4 12-12 12h-56c-6.6 0-12-5.4-12-12v-92H92c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h92v-92c0-6.6 5.4-12 12-12h56c6.6 0 12 5.4 12 12v92h92c6.6 0 12 5.4 12 12v56z"],question:[384,512,[],"f128","M202.021 0C122.202 0 70.503 32.703 29.914 91.026c-7.363 10.58-5.093 25.086 5.178 32.874l43.138 32.709c10.373 7.865 25.132 6.026 33.253-4.148 25.049-31.381 43.63-49.449 82.757-49.449 30.764 0 68.816 19.799 68.816 49.631 0 22.552-18.617 34.134-48.993 51.164-35.423 19.86-82.299 44.576-82.299 106.405V320c0 13.255 10.745 24 24 24h72.471c13.255 0 24-10.745 24-24v-5.773c0-42.86 125.268-44.645 125.268-160.627C377.504 66.256 286.902 0 202.021 0zM192 373.459c-38.196 0-69.271 31.075-69.271 69.271 0 38.195 31.075 69.27 69.271 69.27s69.271-31.075 69.271-69.271-31.075-69.27-69.271-69.27z"],save:[448,512,[],"f0c7","M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z"],search:[512,512,[],"f002","M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z"],share:[512,512,[],"f064","M503.691 189.836L327.687 37.851C312.281 24.546 288 35.347 288 56.015v80.053C127.371 137.907 0 170.1 0 322.326c0 61.441 39.581 122.309 83.333 154.132 13.653 9.931 33.111-2.533 28.077-18.631C66.066 312.814 132.917 274.316 288 272.085V360c0 20.7 24.3 31.453 39.687 18.164l176.004-152c11.071-9.562 11.086-26.753 0-36.328z"],spinner:[512,512,[],"f110","M304 48c0 26.51-21.49 48-48 48s-48-21.49-48-48 21.49-48 48-48 48 21.49 48 48zm-48 368c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm208-208c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zM96 256c0-26.51-21.49-48-48-48S0 229.49 0 256s21.49 48 48 48 48-21.49 48-48zm12.922 99.078c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.491-48-48-48zm294.156 0c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.49-48-48-48zM108.922 60.922c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.491-48-48-48z"],square:[448,512,[],"f0c8","M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48z"],"square-full":[512,512,[],"f45c","M512 512H0V0h512v512z"],times:[384,512,[],"f00d","M323.1 441l53.9-53.9c9.4-9.4 9.4-24.5 0-33.9L279.8 256l97.2-97.2c9.4-9.4 9.4-24.5 0-33.9L323.1 71c-9.4-9.4-24.5-9.4-33.9 0L192 168.2 94.8 71c-9.4-9.4-24.5-9.4-33.9 0L7 124.9c-9.4 9.4-9.4 24.5 0 33.9l97.2 97.2L7 353.2c-9.4 9.4-9.4 24.5 0 33.9L60.9 441c9.4 9.4 24.5 9.4 33.9 0l97.2-97.2 97.2 97.2c9.3 9.3 24.5 9.3 33.9 0z"],"times-circle":[512,512,[],"f057","M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z"],wrench:[512,512,[],"f0ad","M481.156 200c9.3 0 15.12 10.155 10.325 18.124C466.295 259.992 420.419 288 368 288c-79.222 0-143.501-63.974-143.997-143.079C223.505 65.469 288.548-.001 368.002 0c52.362.001 98.196 27.949 123.4 69.743C496.24 77.766 490.523 88 481.154 88H376l-40 56 40 56h105.156zm-171.649 93.003L109.255 493.255c-24.994 24.993-65.515 24.994-90.51 0-24.993-24.994-24.993-65.516 0-90.51L218.991 202.5c16.16 41.197 49.303 74.335 90.516 90.503zM104 432c0-13.255-10.745-24-24-24s-24 10.745-24 24 10.745 24 24 24 24-10.745 24-24z"]};var At=Object.freeze({__proto__:null,createCheckbox:xt,createIcon:kt});function Et(e,t){var i=document.createElement("div");e.appendChild(i),i.appendChild(kt("times")),i.addEventListener("click",(function(e){e.preventDefault(),e.stopPropagation(),t()}))}var Mt=Object.freeze({__proto__:null,attachDialogCloseHandlerWithParent:Et});let Tt;function Rt(e,t,i){t.addEventListener("mousedown",function(e){e.stopPropagation(),e.preventDefault();const t=Lt.bind(this),n=It.bind(this),r=getComputedStyle(this);Tt={constraint:i,dragFunction:t,dragEndFunction:n,screenX:e.screenX,screenY:e.screenY,top:parseInt(r.top.replace("px","")),left:parseInt(r.left.replace("px",""))},document.addEventListener("mousemove",t),document.addEventListener("mouseup",n),document.addEventListener("mouseleave",n),document.addEventListener("mouseexit",n)}.bind(e))}function Lt(e){if(!Tt)return void console.error("No drag data!");e.stopPropagation(),e.preventDefault();const t=e.screenX-Tt.screenX,i=e.screenY-Tt.screenY,n=Tt.left+t,r=Tt.constraint?Math.max(Tt.constraint.minY,Tt.top+i):Tt.top+i;this.style.left=`${n}px`,this.style.top=`${r}px`}function It(e){if(!Tt)return void console.error("No drag data!");e.stopPropagation(),e.preventDefault();const t=Tt.dragFunction,i=Tt.dragEndFunction;document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",i),document.removeEventListener("mouseleave",i),document.removeEventListener("mouseexit",i),Tt=void 0}const Bt={401:"Access unauthorized",403:"Access forbidden",404:"Not found"};class Ft{constructor(e,t){this.alertProps=Object.assign({shouldFocus:!0,preventScroll:!1},t),this.container=pt({class:"igv-ui-alert-dialog-container"}),e.appendChild(this.container),this.container.setAttribute("tabIndex","-1");const i=pt();this.container.appendChild(i),this.errorHeadline=pt(),i.appendChild(this.errorHeadline),this.errorHeadline.textContent="";let n=pt({class:"igv-ui-alert-dialog-body"});this.container.appendChild(n),this.body=pt({class:"igv-ui-alert-dialog-body-copy"}),n.appendChild(this.body);let r=pt();this.container.appendChild(r),this.ok=pt(),r.appendChild(this.ok),this.ok.textContent="OK";const s=()=>{"function"==typeof this.callback&&(this.callback("OK"),this.callback=void 0),this.body.innerHTML="",mt(this.container)};this.ok.addEventListener("click",(e=>{e.stopPropagation(),s()})),this.container.addEventListener("keypress",(e=>{e.stopPropagation(),"Enter"===e.key&&s()})),Rt(this.container,i),mt(this.container)}present(e,t){this.errorHeadline.textContent=e.message?"ERROR":"";let i=e.message||e;Bt.hasOwnProperty(i)&&(i=Bt[i]),this.body.innerHTML=i,this.callback=t,bt(this.container),this.alertProps.shouldFocus&&this.container.focus({preventScroll:this.alertProps.preventScroll})}}class Nt{constructor(e){this.parent=e,this.container=pt({class:"igv-ui-generic-dialog-container"}),e.appendChild(this.container);const t=pt({class:"igv-ui-generic-dialog-header"});this.container.appendChild(t),this.label=pt({class:"igv-ui-generic-dialog-one-liner"}),this.container.appendChild(this.label),this.label.text="Unlabeled",this.input_container=pt({class:"igv-ui-generic-dialog-input"}),this.container.appendChild(this.input_container),this.input=document.createElement("input"),this.input_container.appendChild(this.input);const i=pt({class:"igv-ui-generic-dialog-ok-cancel"});this.container.appendChild(i),this.ok=pt(),i.appendChild(this.ok),this.ok.textContent="OK",this.cancel=pt(),i.appendChild(this.cancel),this.cancel.textContent="Cancel",mt(this.container),this.input.addEventListener("keyup",(e=>{13===e.keyCode&&("function"==typeof this.callback&&(this.callback(this.input.value),this.callback=void 0),this.input.value=void 0,mt(this.container))})),this.ok.addEventListener("click",(()=>{"function"==typeof this.callback&&(this.callback(this.input.value),this.callback=void 0),this.input.value=void 0,mt(this.container)}));const n=()=>{this.input.value="",mt(this.container)};this.cancel.addEventListener("click",n),Et(t,n),Rt(this.container,t)}present(e,t){this.label.textContent=e.label,this.input.value=e.value,this.callback=e.callback||e.click,bt(this.container),this.clampLocation(t.clientX,t.clientY)}clampLocation(e,t){const{width:i,height:n}=this.container.getBoundingClientRect(),r=window.innerHeight,s=window.innerWidth,o=Math.min(r-n,t),a=Math.min(s-i,e);this.container.style.left=`${a}px`,this.container.style.top=`${o}px`}}const Ot={licorice:"#000000",lead:"#1e1e1e",tungsten:"#3a3a3a",iron:"#545453",steel:"#6e6e6e",tin:"#878687",nickel:"#888787",aluminum:"#a09fa0",magnesium:"#b8b8b8",silver:"#d0d0d0",mercury:"#e8e8e8",snow:"#ffffff",cayenne:"#891100",mocha:"#894800",aspargus:"#888501",fern:"#458401",clover:"#028401",moss:"#018448",teal:"#008688",ocean:"#004a88",midnight:"#001888",eggplant:"#491a88",plum:"#891e88",maroon:"#891648",maraschino:"#ff2101",tangerine:"#ff8802",lemon:"#fffa03",lime:"#83f902",spring:"#05f802",seam_foam:"#03f987",turquoise:"#00fdff",aqua:"#008cff",blueberry:"#002eff",grape:"#8931ff",magenta:"#ff39ff",strawberry:"#ff2987",salmon:"#ff726e",cantaloupe:"#ffce6e",banana:"#fffb6d",honeydew:"#cefa6e",flora:"#68f96e",spindrift:"#68fbd0",ice:"#68fdff",sky:"#6acfff",orchid:"#6e76ff",lavender:"#d278ff",bubblegum:"#ff7aff",carnation:"#ff7fd3"};class Pt{constructor({parent:e,top:t,left:i,width:n,height:r,border:s,closeHandler:o}){let a=pt({class:"igv-ui-generic-container"});e.appendChild(a),mt(a),this.container=a,void 0!==t&&(this.container.style.top=`${t}px`),void 0!==i&&(this.container.style.left=`${i}px`),void 0!==n&&(this.container.style.width=`${n}px`),void 0!==r&&(this.container.style.height=`${r}px`),s&&(this.container.style.border=s);const l=pt();this.container.appendChild(l),Et(l,(e=>{mt(this.container),"function"==typeof o&&o(e)})),Rt(this.container,l)}show(){bt(this.container)}hide(){mt(this.container)}dispose(){this.container.parent&&this.container.parent.removeChild(this.container)}}class Dt extends Pt{constructor({parent:e,top:t,left:i,width:n,height:r,defaultColors:s,colorHandler:o}){super({parent:e,top:t,left:i,width:n,height:r,border:"1px solid gray"}),zt(this.container,o,s)}}const zt=(e,t,i)=>{const n=Object.values(Ot);for(let i of n){const n=pt({class:"igv-ui-color-swatch"});e.appendChild(n),Ht(n,i,t)}if(i)for(let n of i){const i=pt({class:"igv-ui-color-swatch"});e.appendChild(i),Ht(i,n,t)}},Ht=(e,t,i)=>{e.style.backgroundColor=t,e.addEventListener("mouseenter",(i=>e.style.borderColor=t)),e.addEventListener("mouseleave",(t=>e.style.borderColor="white")),e.addEventListener("click",(e=>{e.stopPropagation(),i(t)})),e.addEventListener("touchend",(e=>{e.stopPropagation(),i(t)}))};class Vt{constructor(e,t){this.parent=e,this.popover=pt({class:"igv-ui-popover"}),e.appendChild(this.popover);const i=pt();this.popover.appendChild(i);const n=pt();i.appendChild(n),t&&(n.textContent=t),Et(i,(()=>this.hide())),Rt(this.popover,i),this.popoverContent=pt(),this.popover.appendChild(this.popoverContent),this.popover.style.display="none"}presentContentWithEvent(e,t){this.popover.style.display="block",this.popoverContent.innerHTML=t,Ut(e,this.popover,this.popoverContent)}presentMenu(e,t){if(0===t.length)return;this.popover.style.display="block";const i=function(e,t){const i=e.map((function(e,i){let n;if("string"==typeof e)n=pt(),n.innerHTML=e;else if("Node"==typeof e)n=e;else{if("function"==typeof e.init&&e.init(),"checkbox"===e.type)n=xt("Show all bases",e.value);else if("color"===e.type){const r=new Dt({parent:t.parentElement,width:364,colorHandler:t=>e.click(t)});n=pt(),"string"==typeof e.label&&(n.innerHTML=e.label);const s=e=>{r.show(),mt(t),e.preventDefault(),e.stopPropagation()};n.addEventListener("click",s),n.addEventListener("touchend",s),n.addEventListener("mouseup",(function(e){e.preventDefault(),e.stopPropagation()}))}else n=pt(),"string"==typeof e.label&&(n.innerHTML=e.label);if(e.click&&"color"!==e.type){function o(i){e.click(),mt(t),i.preventDefault(),i.stopPropagation()}n.addEventListener("click",o),n.addEventListener("touchend",o),n.addEventListener("mouseup",(function(e){e.preventDefault(),e.stopPropagation()}))}}return{object:n,init:e.init}}));return i}(t,this.popover);for(let e of i)this.popoverContent.appendChild(e.object);Ut(e,this.popover,this.popoverContent)}hide(){this.popover.style.display="none",this.dispose()}dispose(){this.popover&&this.popover.parentNode.removeChild(this.popover);const e=Object.keys(this);for(let t of e)this[t]=void 0}}function Ut(e,t,i){const{x:n,y:r,width:s}=yt(e,t.parentNode);t.style.top=`${r}px`;const{width:o}=t.getBoundingClientRect(),a=n+o,l=a-s;t.style.left=`${a>s?n-l:n}px`,i.style.maxWidth=`${Math.min(o,s)}px`}class qt extends Pt{constructor({parent:e,width:t}){super({parent:e,width:t,border:"1px solid gray"})}configure(e,t){this.colorHandlers=t,this.setActiveColorHandler("color"),this.createSwatches(e)}setActiveColorHandler(e){this.activeColorHandler=this.colorHandlers[e]}createSwatches(e){this.container.querySelectorAll(".igv-ui-color-swatch").forEach((e=>e.remove()));const t=Object.values(Ot);for(let e of t){const t=pt({class:"igv-ui-color-swatch"});this.container.appendChild(t),this.decorateSwatch(t,e)}if(e)for(let t of e){const e=pt({class:"igv-ui-color-swatch"});this.container.appendChild(e),this.decorateSwatch(e,t)}}decorateSwatch(e,t){e.style.backgroundColor=t,e.addEventListener("mouseenter",(()=>e.style.borderColor=t)),e.addEventListener("mouseleave",(()=>e.style.borderColor="white")),e.addEventListener("click",(e=>{e.stopPropagation(),this.activeColorHandler(t)})),e.addEventListener("touchend",(e=>{e.stopPropagation(),this.activeColorHandler(t)}))}}if("undefined"!=typeof document){function Vb(e){for(let t of document.styleSheets)if(t=t.href?t.href.replace(/^.*[\\\/]/,""):"",t===e)return!0;return!1}Vb("igv-ui.css")||function(){const e=document.createElement("style");e.setAttribute("type","text/css"),e.setAttribute("title","igv-ui.css"),e.innerHTML='.igv-ui-popover {\n cursor: default;\n position: absolute;\n z-index: 2048;\n border-color: #7F7F7F;\n border-radius: 4px;\n border-style: solid;\n border-width: 1px;\n font-family: "Open Sans", sans-serif;\n font-size: small;\n background-color: white;\n}\n.igv-ui-popover > div:first-child {\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n width: 100%;\n height: 24px;\n cursor: move;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-bottom-color: #7F7F7F;\n border-bottom-style: solid;\n border-bottom-width: thin;\n background-color: #eee;\n}\n.igv-ui-popover > div:first-child > div:first-child {\n margin-left: 4px;\n}\n.igv-ui-popover > div:first-child > div:last-child {\n margin-right: 4px;\n height: 12px;\n width: 12px;\n color: #7F7F7F;\n}\n.igv-ui-popover > div:first-child > div:last-child:hover {\n cursor: pointer;\n color: #444;\n}\n.igv-ui-popover > div:last-child {\n overflow-y: auto;\n overflow-x: hidden;\n max-height: 400px;\n max-width: 800px;\n background-color: white;\n}\n.igv-ui-popover > div:last-child > div {\n -webkit-user-select: text;\n -moz-user-select: text;\n -ms-user-select: text;\n user-select: text;\n margin-left: 4px;\n margin-right: 4px;\n min-width: 220px;\n overflow-x: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.igv-ui-popover > div:last-child > div > span {\n font-weight: bolder;\n}\n.igv-ui-popover > div:last-child hr {\n width: 100%;\n}\n\n.igv-ui-alert-dialog-container {\n box-sizing: content-box;\n position: absolute;\n z-index: 2048;\n top: 50%;\n left: 50%;\n width: 400px;\n height: 200px;\n border-color: #7F7F7F;\n border-radius: 4px;\n border-style: solid;\n border-width: thin;\n outline: none;\n font-family: "Open Sans", sans-serif;\n font-size: 15px;\n font-weight: 400;\n background-color: white;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n}\n.igv-ui-alert-dialog-container > div:first-child {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n width: 100%;\n height: 24px;\n cursor: move;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-bottom-color: #7F7F7F;\n border-bottom-style: solid;\n border-bottom-width: thin;\n background-color: #eee;\n}\n.igv-ui-alert-dialog-container > div:first-child div:first-child {\n padding-left: 8px;\n}\n.igv-ui-alert-dialog-container .igv-ui-alert-dialog-body {\n -webkit-user-select: text;\n -moz-user-select: text;\n -ms-user-select: text;\n user-select: text;\n color: #373737;\n width: 100%;\n height: calc(100% - 24px - 64px);\n overflow-y: scroll;\n}\n.igv-ui-alert-dialog-container .igv-ui-alert-dialog-body .igv-ui-alert-dialog-body-copy {\n margin: 16px;\n width: auto;\n height: auto;\n overflow-wrap: break-word;\n word-break: break-word;\n background-color: white;\n border: unset;\n}\n.igv-ui-alert-dialog-container > div:last-child {\n width: 100%;\n margin-bottom: 10px;\n background-color: white;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: center;\n align-items: center;\n}\n.igv-ui-alert-dialog-container > div:last-child div {\n margin: unset;\n width: 40px;\n height: 30px;\n line-height: 30px;\n text-align: center;\n color: white;\n font-family: "Open Sans", sans-serif;\n font-size: small;\n font-weight: 400;\n border-color: #2B81AF;\n border-style: solid;\n border-width: thin;\n border-radius: 4px;\n background-color: #2B81AF;\n}\n.igv-ui-alert-dialog-container > div:last-child div:hover {\n cursor: pointer;\n border-color: #25597f;\n background-color: #25597f;\n}\n\n.igv-ui-color-swatch {\n position: relative;\n box-sizing: content-box;\n display: flex;\n flex-flow: row;\n flex-wrap: wrap;\n justify-content: center;\n align-items: center;\n width: 32px;\n height: 32px;\n border-style: solid;\n border-width: 2px;\n border-color: white;\n border-radius: 4px;\n}\n\n.igv-ui-color-swatch:hover {\n border-color: dimgray;\n}\n\n.igv-ui-colorpicker-menu-close-button {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n width: 100%;\n height: 32px;\n margin-top: 4px;\n margin-bottom: 4px;\n padding-right: 8px;\n}\n.igv-ui-colorpicker-menu-close-button i.fa {\n display: block;\n margin-left: 4px;\n margin-right: 4px;\n color: #5f5f5f;\n}\n.igv-ui-colorpicker-menu-close-button i.fa:hover,\n.igv-ui-colorpicker-menu-close-button i.fa:focus,\n.igv-ui-colorpicker-menu-close-button i.fa:active {\n cursor: pointer;\n color: #0f0f0f;\n}\n\n.igv-ui-generic-dialog-container {\n box-sizing: content-box;\n position: fixed;\n top: 0;\n left: 0;\n width: 300px;\n height: 200px;\n border-color: #7F7F7F;\n border-radius: 4px;\n border-style: solid;\n border-width: thin;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n z-index: 2048;\n background-color: white;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-header {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n width: 100%;\n height: 24px;\n cursor: move;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-bottom-color: #7F7F7F;\n border-bottom-style: solid;\n border-bottom-width: thin;\n background-color: #eee;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-header div {\n margin-right: 4px;\n margin-bottom: 2px;\n height: 12px;\n width: 12px;\n color: #7F7F7F;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-header div:hover {\n cursor: pointer;\n color: #444;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-one-liner {\n color: #373737;\n width: 95%;\n height: 24px;\n line-height: 24px;\n text-align: left;\n margin-top: 8px;\n padding-left: 8px;\n overflow-wrap: break-word;\n background-color: white;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-label-input {\n margin-top: 8px;\n width: 95%;\n height: 24px;\n color: #373737;\n line-height: 24px;\n padding-left: 8px;\n background-color: white;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-label-input div {\n width: 30%;\n height: 100%;\n font-size: 16px;\n text-align: right;\n padding-right: 8px;\n background-color: white;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-label-input input {\n display: block;\n height: 100%;\n width: 100%;\n padding-left: 4px;\n font-family: "Open Sans", sans-serif;\n font-weight: 400;\n color: #373737;\n text-align: left;\n outline: none;\n border-style: solid;\n border-width: thin;\n border-color: #7F7F7F;\n background-color: white;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-label-input input {\n width: 50%;\n font-size: 16px;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-input {\n margin-top: 8px;\n width: calc(100% - 16px);\n height: 24px;\n color: #373737;\n line-height: 24px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-input input {\n display: block;\n height: 100%;\n width: 100%;\n padding-left: 4px;\n font-family: "Open Sans", sans-serif;\n font-weight: 400;\n color: #373737;\n text-align: left;\n outline: none;\n border-style: solid;\n border-width: thin;\n border-color: #7F7F7F;\n background-color: white;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-input input {\n font-size: 16px;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel {\n width: 100%;\n height: 28px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel div {\n margin-top: 32px;\n color: white;\n font-family: "Open Sans", sans-serif;\n font-size: 14px;\n font-weight: 400;\n width: 75px;\n height: 28px;\n line-height: 28px;\n text-align: center;\n border-color: transparent;\n border-style: solid;\n border-width: thin;\n border-radius: 2px;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel div:first-child {\n margin-left: 32px;\n margin-right: 0;\n background-color: #5ea4e0;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel div:last-child {\n margin-left: 0;\n margin-right: 32px;\n background-color: #c4c4c4;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel div:first-child:hover {\n cursor: pointer;\n background-color: #3b5c7f;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel div:last-child:hover {\n cursor: pointer;\n background-color: #7f7f7f;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok {\n width: 100%;\n height: 36px;\n margin-top: 32px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok div {\n width: 98px;\n height: 36px;\n line-height: 36px;\n text-align: center;\n color: white;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n border-color: white;\n border-style: solid;\n border-width: thin;\n border-radius: 4px;\n background-color: #2B81AF;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok div:hover {\n cursor: pointer;\n background-color: #25597f;\n}\n\n.igv-ui-generic-container {\n box-sizing: content-box;\n position: absolute;\n z-index: 2048;\n background-color: white;\n cursor: pointer;\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-ui-generic-container > div:first-child {\n cursor: move;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n height: 24px;\n width: 100%;\n background-color: #dddddd;\n}\n.igv-ui-generic-container > div:first-child > div {\n display: block;\n color: #5f5f5f;\n cursor: pointer;\n width: 14px;\n height: 14px;\n margin-right: 8px;\n margin-bottom: 4px;\n}\n\n.igv-ui-dialog {\n z-index: 2048;\n position: fixed;\n width: fit-content;\n height: fit-content;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n background-color: white;\n border-color: #7F7F7F;\n border-radius: 4px;\n border-style: solid;\n border-width: thin;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n}\n.igv-ui-dialog .igv-ui-dialog-header {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n width: 100%;\n height: 24px;\n cursor: move;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-bottom-color: #7F7F7F;\n border-bottom-style: solid;\n border-bottom-width: thin;\n background-color: #eee;\n}\n.igv-ui-dialog .igv-ui-dialog-header div {\n margin-right: 4px;\n margin-bottom: 2px;\n height: 12px;\n width: 12px;\n color: #7F7F7F;\n}\n.igv-ui-dialog .igv-ui-dialog-header div:hover {\n cursor: pointer;\n color: #444;\n}\n.igv-ui-dialog .igv-ui-dialog-one-liner {\n width: 95%;\n height: 24px;\n line-height: 24px;\n text-align: left;\n margin: 8px;\n overflow-wrap: break-word;\n background-color: white;\n font-weight: bold;\n}\n.igv-ui-dialog .igv-ui-dialog-ok-cancel {\n width: 100%;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div {\n margin: 16px;\n margin-top: 32px;\n color: white;\n font-family: "Open Sans", sans-serif;\n font-size: 14px;\n font-weight: 400;\n width: 75px;\n height: 28px;\n line-height: 28px;\n text-align: center;\n border-color: transparent;\n border-style: solid;\n border-width: thin;\n border-radius: 2px;\n}\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div:first-child {\n background-color: #5ea4e0;\n}\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div:last-child {\n background-color: #c4c4c4;\n}\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div:first-child:hover {\n cursor: pointer;\n background-color: #3b5c7f;\n}\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div:last-child:hover {\n cursor: pointer;\n background-color: #7f7f7f;\n}\n.igv-ui-dialog .igv-ui-dialog-ok {\n width: 100%;\n height: 36px;\n margin-top: 32px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n.igv-ui-dialog .igv-ui-dialog-ok div {\n width: 98px;\n height: 36px;\n line-height: 36px;\n text-align: center;\n color: white;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n border-color: white;\n border-style: solid;\n border-width: thin;\n border-radius: 4px;\n background-color: #2B81AF;\n}\n.igv-ui-dialog .igv-ui-dialog-ok div:hover {\n cursor: pointer;\n background-color: #25597f;\n}\n\n.igv-ui-panel, .igv-ui-panel-row, .igv-ui-panel-column {\n z-index: 2048;\n background-color: white;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n display: flex;\n justify-content: flex-start;\n align-items: flex-start;\n}\n\n.igv-ui-panel-column {\n display: flex;\n flex-direction: column;\n}\n\n.igv-ui-panel-row {\n display: flex;\n flex-direction: row;\n}\n\n.igv-ui-textbox {\n background-color: white;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n display: flex;\n justify-content: flex-start;\n align-items: flex-start;\n}\n\n.igv-ui-table {\n background-color: white;\n}\n\n.igv-ui-table thead {\n position: sticky;\n top: 0;\n}\n\n.igv-ui-table th {\n text-align: left;\n}\n\n.igv-ui-table td {\n padding-right: 20px;\n}\n\n.igv-ui-table tr:hover {\n background-color: lightblue;\n}\n\n/*# sourceMappingURL=igv-ui.css.map */\n',document.head.append(e)}()}function jt(e,t){const i=_t.div({class:"igv-menu-popup-check-container"}),n=_t.div();i.appendChild(n);const r=At.createIcon("check",!0===t?"#444":"transparent");n.appendChild(r);const s=_t.div();return s.innerText=e,i.appendChild(s),i}const $t={trackMenuItemList:function(e){const t=new Set(["alignment","annotation","variant","eqtl","snp"]),i=e.track.config&&void 0!==e.track.config.visibilityWindow;let n=[];return"sequence"!==e.track.config.type&&(n.push(function(e){const t=t=>{const i=function(){let t=e.browser.inputDialog.input.value;t=""===t||void 0===t?"untitled":t.trim(),e.track.name=t},n={label:"Track Name",value:Gt(e.track)||"unnamed",callback:i};e.browser.inputDialog.present(n,t)},i=ft("<div>");return i.text("Set track name"),{object:i,click:t}}(e)),n.push(function(e){const t=t=>{const i=()=>{const t=Number(e.browser.inputDialog.input.value,10);void 0!==t&&(void 0!==e.track.minHeight&&e.track.minHeight>t&&(e.track.minHeight=t),void 0!==e.track.maxHeight&&e.track.maxHeight<t&&(e.track.minHeight=t),e.setTrackHeight(t,!0),e.checkContentHeight(),e.repaintViews(),e.track.autoHeight=!1)},n={label:"Track Height",value:e.track.height,callback:i};e.browser.inputDialog.present(n,t)},i=ft("<div>");return i.text("Set track height"),{object:i,click:t}}(e))),this.showColorPicker(e.track)&&(n.push("<hr/>"),n.push(Wt({trackView:e,label:"Set track color",option:"color"})),n.push(function({trackView:e,label:t}){const i=ft("<div>");return i.text(t),{object:i,click:()=>{e.track.color=void 0,e.repaintViews()}}}({trackView:e,label:"Unset track color"})),"wig"!==e.track.config.type&&"annotation"!==e.track.config.type||n.push(Wt({trackView:e,label:"Set alt color",option:"altColor"}))),e.track.menuItemList&&(n=n.concat(e.track.menuItemList())),(i||t.has(e.track.type))&&(n.push("<hr/>"),n.push(function(e){const t=t=>{const i=()=>{let t=e.browser.inputDialog.input.value;t=""===t||void 0===t?-1:t.trim(),e.track.visibilityWindow=Number.parseInt(t),e.track.config.visibilityWindow=Number.parseInt(t),e.updateViews()},n={label:"Visibility Window",value:e.track.visibilityWindow,callback:i};e.browser.inputDialog.present(n,t)},i=ft("<div>");return i.text("Set visibility window"),{object:i,click:t}}(e))),!1!==e.track.removable&&(n.push("<hr/>"),n.push(function(e){const t=ft("<div>");return t.text("Remove track"),{object:t,click:()=>e.browser.removeTrack(e.track)}}(e))),n},numericDataMenuItems:function(e){const t=[];t.push("<hr/>");const i=ft("<div>");i.text("Set data range");return t.push({object:i,click:()=>{e.browser.dataRangeDialog.configure(e),e.browser.dataRangeDialog.present(ft(e.browser.columnContainer))}}),void 0!==e.track.logScale&&t.push({object:ft(jt("Log scale",e.track.logScale)),click:()=>{e.track.logScale=!e.track.logScale,e.repaintViews()}}),t.push({object:ft(jt("Autoscale",e.track.autoscale)),click:()=>{e.track.autoscale=!e.track.autoscale,e.updateViews()}}),t},trackMenuItemListHelper:function(e,t){var i=[];return e.length>0&&(i=e.map((function(e,i){var n;if(e.name?(n=ft("<div>")).text(e.name):e.object?n=e.object:"string"==typeof e.label?(n=ft("<div>")).html(e.label):"string"==typeof e&&(n=e.startsWith("<")?ft(e):ft("<div>"+e+"</div>")),0===i&&n.addClass("igv-track-menu-border-top"),e.click){function r(i){e.click(i),t.hide(),i.preventDefault(),i.stopPropagation()}n.on("click",r),n.on("touchend",(function(e){r(e)})),n.on("mouseup",(function(e){e.preventDefault(),e.stopPropagation()}))}return{object:n,init:e.init||void 0}}))),i},showColorPicker:e=>void 0===e.type||"bedtype"===e.type||"alignment"===e.type||"annotation"===e.type||"variant"===e.type||"wig"===e.type||"interact"===e.type,createMenuItem(e,t){const i=ft("<div>");return i.text(e),{object:i,click:t}}};function Wt({trackView:e,label:t,option:i}){const n=ft("<div>");return n.text(t),{object:n,click:()=>e.presentColorPicker(i)}}function Gt(e){return e.trackView.viewports[0].$trackLabel.text()}class Zt{constructor(e,t,i){this.browser=e,this.$container=ft("<div>",{class:"igv-generic-dialog-container"}),t.append(this.$container),this.$container.offset({left:0,top:0});const n=ft("<div>",{class:"igv-generic-dialog-header"});this.$container.append(n),Mt.attachDialogCloseHandlerWithParent(n[0],(()=>{this.$minimum_input.val(void 0),this.$maximum_input.val(void 0),this.$container.offset({left:0,top:0}),this.$container.hide()})),this.$minimum=ft("<div>",{class:"igv-generic-dialog-label-input"}),this.$container.append(this.$minimum);const r=ft("<div>");r.text("Minimum"),this.$minimum.append(r),this.$minimum_input=ft("<input>"),this.$minimum.append(this.$minimum_input),this.$maximum=ft("<div>",{class:"igv-generic-dialog-label-input"}),this.$container.append(this.$maximum);const s=ft("<div>");s.text("Maximum"),this.$maximum.append(s),this.$maximum_input=ft("<input>"),this.$maximum.append(this.$maximum_input);const o=ft("<div>",{class:"igv-generic-dialog-ok-cancel"});this.$container.append(o),this.$ok=ft("<div>"),o.append(this.$ok),this.$ok.text("OK"),this.$cancel=ft("<div>"),o.append(this.$cancel),this.$cancel.text("Cancel"),this.$cancel.on("click",(()=>{this.$minimum_input.val(void 0),this.$maximum_input.val(void 0),this.$container.offset({left:0,top:0}),this.$container.hide()})),Rt(this.$container.get(0),n.get(0)),this.$container.hide()}configure(e){const t=e.dataRange();let i,n;t?(i=t.min,n=t.max):(i=0,n=100),this.$minimum_input.val(i),this.$maximum_input.val(n),this.$minimum_input.unbind(),this.$minimum_input.on("keyup",(t=>{13===t.keyCode&&this.processResults(e)})),this.$maximum_input.unbind(),this.$maximum_input.on("keyup",(t=>{13===t.keyCode&&this.processResults(e)})),this.$ok.unbind(),this.$ok.on("click",(t=>{this.processResults(e)}))}processResults(e){const t=Number(this.$minimum_input.val()),i=Number(this.$maximum_input.val());isNaN(t)||isNaN(i)?this.browser.alert.present(new Error("Must input numeric values"),void 0):e.setDataRange(t,i),this.$minimum_input.val(void 0),this.$maximum_input.val(void 0),this.$container.offset({left:0,top:0}),this.$container.hide()}present(e){const t=e.offset().top,i=ft("body").scrollTop();this.$container.offset({left:e.width()-this.$container.width(),top:t+i}),this.$container.show()}}function Qt(e){return"string"==typeof e||e instanceof String}function Xt(e){var t=String(e).split(/[.,]/);return t[0].split("").reverse().reduce((function(e,t,i){return i%3==0?e+","+t:e+t})).split("").reverse().join("")+(t[1]?"."+t[1]:"")}const Yt=function(e){return e.split(/\n|\r\n|\r/g)};function Kt(e,t){var i,n,r=[],s=e.length,o=0,a=!1;if(s>0)for(r[o]=e.charAt(0),i=1;i<s;i++)'"'===(n=e.charAt(i))?a=!a:a||n!==t?r[o]+=n:r[++o]="";return r}function Jt(e){return e.length>0?e.charAt(0).toUpperCase()+e.slice(1):e}function ei(e){if(void 0!==e.name)return e.name;if(Qt(e)){let t=e.lastIndexOf("/"),i=t<0?e:e.substr(t+1);return t=i.indexOf("?"),t>0&&(i=i.substr(0,t)),i}throw Error("Expected File or string, got "+typeof e)}function ti(e){return!!e&&("function"!=typeof e&&(e instanceof File||e.hasOwnProperty("name")&&"function"==typeof e.slice&&"function"==typeof e.arrayBuffer))}function ii(e,t){const i=document.createElement("a");i.setAttribute("href",t),i.setAttribute("download",e),i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i)}function ni(e){for(var t=ri,i=t.parser.loose.exec(e),n={},r=14;r--;)n[t.key[r]]=i[r]||"";return n[t.q.name]={},n[t.key[12]].replace(t.q.parser,(function(e,i,r){i&&(n[t.q.name][i]=r)})),n}"object"==typeof process&&"undefined"==typeof window&&(global.atob=function(e){return Buffer.from(e,"base64").toString("binary")});const ri={strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};function si(e){let t=e.length;for(;--t>=0;)e[t]=0}const oi=256,ai=286,li=30,hi=15,ci=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),di=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),ui=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),fi=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),pi=new Array(576);si(pi);const gi=new Array(60);si(gi);const mi=new Array(512);si(mi);const bi=new Array(256);si(bi);const wi=new Array(29);si(wi);const vi=new Array(li);function yi(e,t,i,n,r){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=n,this.max_length=r,this.has_stree=e&&e.length}let _i,xi,ki;function Ci(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}si(vi);const Si=e=>e<256?mi[e]:mi[256+(e>>>7)],Ai=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},Ei=(e,t,i)=>{e.bi_valid>16-i?(e.bi_buf|=t<<e.bi_valid&65535,Ai(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=i-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=i)},Mi=(e,t,i)=>{Ei(e,i[2*t],i[2*t+1])},Ti=(e,t)=>{let i=0;do{i|=1&e,e>>>=1,i<<=1}while(--t>0);return i>>>1},Ri=(e,t,i)=>{const n=new Array(16);let r,s,o=0;for(r=1;r<=hi;r++)o=o+i[r-1]<<1,n[r]=o;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=Ti(n[t]++,t))}},Li=e=>{let t;for(t=0;t<ai;t++)e.dyn_ltree[2*t]=0;for(t=0;t<li;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},Ii=e=>{e.bi_valid>8?Ai(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Bi=(e,t,i,n)=>{const r=2*t,s=2*i;return e[r]<e[s]||e[r]===e[s]&&n[t]<=n[i]},Fi=(e,t,i)=>{const n=e.heap[i];let r=i<<1;for(;r<=e.heap_len&&(r<e.heap_len&&Bi(t,e.heap[r+1],e.heap[r],e.depth)&&r++,!Bi(t,n,e.heap[r],e.depth));)e.heap[i]=e.heap[r],i=r,r<<=1;e.heap[i]=n},Ni=(e,t,i)=>{let n,r,s,o,a=0;if(0!==e.sym_next)do{n=255&e.pending_buf[e.sym_buf+a++],n+=(255&e.pending_buf[e.sym_buf+a++])<<8,r=e.pending_buf[e.sym_buf+a++],0===n?Mi(e,r,t):(s=bi[r],Mi(e,s+oi+1,t),o=ci[s],0!==o&&(r-=wi[s],Ei(e,r,o)),n--,s=Si(n),Mi(e,s,i),o=di[s],0!==o&&(n-=vi[s],Ei(e,n,o)))}while(a<e.sym_next);Mi(e,256,t)},Oi=(e,t)=>{const i=t.dyn_tree,n=t.stat_desc.static_tree,r=t.stat_desc.has_stree,s=t.stat_desc.elems;let o,a,l,h=-1;for(e.heap_len=0,e.heap_max=573,o=0;o<s;o++)0!==i[2*o]?(e.heap[++e.heap_len]=h=o,e.depth[o]=0):i[2*o+1]=0;for(;e.heap_len<2;)l=e.heap[++e.heap_len]=h<2?++h:0,i[2*l]=1,e.depth[l]=0,e.opt_len--,r&&(e.static_len-=n[2*l+1]);for(t.max_code=h,o=e.heap_len>>1;o>=1;o--)Fi(e,i,o);l=s;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Fi(e,i,1),a=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=a,i[2*l]=i[2*o]+i[2*a],e.depth[l]=(e.depth[o]>=e.depth[a]?e.depth[o]:e.depth[a])+1,i[2*o+1]=i[2*a+1]=l,e.heap[1]=l++,Fi(e,i,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const i=t.dyn_tree,n=t.max_code,r=t.stat_desc.static_tree,s=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,l=t.stat_desc.max_length;let h,c,d,u,f,p,g=0;for(u=0;u<=hi;u++)e.bl_count[u]=0;for(i[2*e.heap[e.heap_max]+1]=0,h=e.heap_max+1;h<573;h++)c=e.heap[h],u=i[2*i[2*c+1]+1]+1,u>l&&(u=l,g++),i[2*c+1]=u,c>n||(e.bl_count[u]++,f=0,c>=a&&(f=o[c-a]),p=i[2*c],e.opt_len+=p*(u+f),s&&(e.static_len+=p*(r[2*c+1]+f)));if(0!==g){do{for(u=l-1;0===e.bl_count[u];)u--;e.bl_count[u]--,e.bl_count[u+1]+=2,e.bl_count[l]--,g-=2}while(g>0);for(u=l;0!==u;u--)for(c=e.bl_count[u];0!==c;)d=e.heap[--h],d>n||(i[2*d+1]!==u&&(e.opt_len+=(u-i[2*d+1])*i[2*d],i[2*d+1]=u),c--)}})(e,t),Ri(i,h,e.bl_count)},Pi=(e,t,i)=>{let n,r,s=-1,o=t[1],a=0,l=7,h=4;for(0===o&&(l=138,h=3),t[2*(i+1)+1]=65535,n=0;n<=i;n++)r=o,o=t[2*(n+1)+1],++a<l&&r===o||(a<h?e.bl_tree[2*r]+=a:0!==r?(r!==s&&e.bl_tree[2*r]++,e.bl_tree[32]++):a<=10?e.bl_tree[34]++:e.bl_tree[36]++,a=0,s=r,0===o?(l=138,h=3):r===o?(l=6,h=3):(l=7,h=4))},Di=(e,t,i)=>{let n,r,s=-1,o=t[1],a=0,l=7,h=4;for(0===o&&(l=138,h=3),n=0;n<=i;n++)if(r=o,o=t[2*(n+1)+1],!(++a<l&&r===o)){if(a<h)do{Mi(e,r,e.bl_tree)}while(0!=--a);else 0!==r?(r!==s&&(Mi(e,r,e.bl_tree),a--),Mi(e,16,e.bl_tree),Ei(e,a-3,2)):a<=10?(Mi(e,17,e.bl_tree),Ei(e,a-3,3)):(Mi(e,18,e.bl_tree),Ei(e,a-11,7));a=0,s=r,0===o?(l=138,h=3):r===o?(l=6,h=3):(l=7,h=4)}};let zi=!1;const Hi=(e,t,i,n)=>{Ei(e,0+(n?1:0),3),Ii(e),Ai(e,i),Ai(e,~i),i&&e.pending_buf.set(e.window.subarray(t,t+i),e.pending),e.pending+=i};var Vi=(e,t,i,n)=>{let r,s,o=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<oi;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),Oi(e,e.l_desc),Oi(e,e.d_desc),o=(e=>{let t;for(Pi(e,e.dyn_ltree,e.l_desc.max_code),Pi(e,e.dyn_dtree,e.d_desc.max_code),Oi(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*fi[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),r=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=r&&(r=s)):r=s=i+5,i+4<=r&&-1!==t?Hi(e,t,i,n):4===e.strategy||s===r?(Ei(e,2+(n?1:0),3),Ni(e,pi,gi)):(Ei(e,4+(n?1:0),3),((e,t,i,n)=>{let r;for(Ei(e,t-257,5),Ei(e,i-1,5),Ei(e,n-4,4),r=0;r<n;r++)Ei(e,e.bl_tree[2*fi[r]+1],3);Di(e,e.dyn_ltree,t-1),Di(e,e.dyn_dtree,i-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),Ni(e,e.dyn_ltree,e.dyn_dtree)),Li(e),n&&Ii(e)},Ui={_tr_init:e=>{zi||((()=>{let e,t,i,n,r;const s=new Array(16);for(i=0,n=0;n<28;n++)for(wi[n]=i,e=0;e<1<<ci[n];e++)bi[i++]=n;for(bi[i-1]=n,r=0,n=0;n<16;n++)for(vi[n]=r,e=0;e<1<<di[n];e++)mi[r++]=n;for(r>>=7;n<li;n++)for(vi[n]=r<<7,e=0;e<1<<di[n]-7;e++)mi[256+r++]=n;for(t=0;t<=hi;t++)s[t]=0;for(e=0;e<=143;)pi[2*e+1]=8,e++,s[8]++;for(;e<=255;)pi[2*e+1]=9,e++,s[9]++;for(;e<=279;)pi[2*e+1]=7,e++,s[7]++;for(;e<=287;)pi[2*e+1]=8,e++,s[8]++;for(Ri(pi,287,s),e=0;e<li;e++)gi[2*e+1]=5,gi[2*e]=Ti(e,5);_i=new yi(pi,ci,257,ai,hi),xi=new yi(gi,di,0,li,hi),ki=new yi(new Array(0),ui,0,19,7)})(),zi=!0),e.l_desc=new Ci(e.dyn_ltree,_i),e.d_desc=new Ci(e.dyn_dtree,xi),e.bl_desc=new Ci(e.bl_tree,ki),e.bi_buf=0,e.bi_valid=0,Li(e)},_tr_stored_block:Hi,_tr_flush_block:Vi,_tr_tally:(e,t,i)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=i,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(bi[i]+oi+1)]++,e.dyn_dtree[2*Si(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Ei(e,2,3),Mi(e,256,pi),(e=>{16===e.bi_valid?(Ai(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var qi=(e,t,i,n)=>{let r=65535&e|0,s=e>>>16&65535|0,o=0;for(;0!==i;){o=i>2e3?2e3:i,i-=o;do{r=r+t[n++]|0,s=s+r|0}while(--o);r%=65521,s%=65521}return r|s<<16|0};const ji=new Uint32Array((()=>{let e,t=[];for(var i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t})());var $i=(e,t,i,n)=>{const r=ji,s=n+i;e^=-1;for(let i=n;i<s;i++)e=e>>>8^r[255&(e^t[i])];return-1^e},Wi={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Gi={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Zi,_tr_stored_block:Qi,_tr_flush_block:Xi,_tr_tally:Yi,_tr_align:Ki}=Ui,{Z_NO_FLUSH:Ji,Z_PARTIAL_FLUSH:en,Z_FULL_FLUSH:tn,Z_FINISH:nn,Z_BLOCK:rn,Z_OK:sn,Z_STREAM_END:on,Z_STREAM_ERROR:an,Z_DATA_ERROR:ln,Z_BUF_ERROR:hn,Z_DEFAULT_COMPRESSION:cn,Z_FILTERED:dn,Z_HUFFMAN_ONLY:un,Z_RLE:fn,Z_FIXED:pn,Z_DEFAULT_STRATEGY:gn,Z_UNKNOWN:mn,Z_DEFLATED:bn}=Gi,wn=258,vn=262,yn=42,_n=113,xn=666,kn=(e,t)=>(e.msg=Wi[t],t),Cn=e=>2*e-(e>4?9:0),Sn=e=>{let t=e.length;for(;--t>=0;)e[t]=0},An=e=>{let t,i,n,r=e.w_size;t=e.hash_size,n=t;do{i=e.head[--n],e.head[n]=i>=r?i-r:0}while(--t);t=r,n=t;do{i=e.prev[--n],e.prev[n]=i>=r?i-r:0}while(--t)};let En=(e,t,i)=>(t<<e.hash_shift^i)&e.hash_mask;const Mn=e=>{const t=e.state;let i=t.pending;i>e.avail_out&&(i=e.avail_out),0!==i&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+i),e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))},Tn=(e,t)=>{Xi(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Mn(e.strm)},Rn=(e,t)=>{e.pending_buf[e.pending++]=t},Ln=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},In=(e,t,i,n)=>{let r=e.avail_in;return r>n&&(r=n),0===r?0:(e.avail_in-=r,t.set(e.input.subarray(e.next_in,e.next_in+r),i),1===e.state.wrap?e.adler=qi(e.adler,t,r,i):2===e.state.wrap&&(e.adler=$i(e.adler,t,r,i)),e.next_in+=r,e.total_in+=r,r)},Bn=(e,t)=>{let i,n,r=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match;const l=e.strstart>e.w_size-vn?e.strstart-(e.w_size-vn):0,h=e.window,c=e.w_mask,d=e.prev,u=e.strstart+wn;let f=h[s+o-1],p=h[s+o];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do{if(i=t,h[i+o]===p&&h[i+o-1]===f&&h[i]===h[s]&&h[++i]===h[s+1]){s+=2,i++;do{}while(h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&s<u);if(n=wn-(u-s),s=u-wn,n>o){if(e.match_start=t,o=n,n>=a)break;f=h[s+o-1],p=h[s+o]}}}while((t=d[t&c])>l&&0!=--r);return o<=e.lookahead?o:e.lookahead},Fn=e=>{const t=e.w_size;let i,n,r;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-vn)&&(e.window.set(e.window.subarray(t,t+t-n),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),An(e),n+=t),0===e.strm.avail_in)break;if(i=In(e.strm,e.window,e.strstart+e.lookahead,n),e.lookahead+=i,e.lookahead+e.insert>=3)for(r=e.strstart-e.insert,e.ins_h=e.window[r],e.ins_h=En(e,e.ins_h,e.window[r+1]);e.insert&&(e.ins_h=En(e,e.ins_h,e.window[r+3-1]),e.prev[r&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=r,r++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<vn&&0!==e.strm.avail_in)},Nn=(e,t)=>{let i,n,r,s=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,o=0,a=e.strm.avail_in;do{if(i=65535,r=e.bi_valid+42>>3,e.strm.avail_out<r)break;if(r=e.strm.avail_out-r,n=e.strstart-e.block_start,i>n+e.strm.avail_in&&(i=n+e.strm.avail_in),i>r&&(i=r),i<s&&(0===i&&t!==nn||t===Ji||i!==n+e.strm.avail_in))break;o=t===nn&&i===n+e.strm.avail_in?1:0,Qi(e,0,0,o),e.pending_buf[e.pending-4]=i,e.pending_buf[e.pending-3]=i>>8,e.pending_buf[e.pending-2]=~i,e.pending_buf[e.pending-1]=~i>>8,Mn(e.strm),n&&(n>i&&(n=i),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+n),e.strm.next_out),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n,e.block_start+=n,i-=n),i&&(In(e.strm,e.strm.output,e.strm.next_out,i),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i)}while(0===o);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),o?4:t!==Ji&&t!==nn&&0===e.strm.avail_in&&e.strstart===e.block_start?2:(r=e.window_size-e.strstart,e.strm.avail_in>r&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,r+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),r>e.strm.avail_in&&(r=e.strm.avail_in),r&&(In(e.strm,e.window,e.strstart,r),e.strstart+=r,e.insert+=r>e.w_size-e.insert?e.w_size-e.insert:r),e.high_water<e.strstart&&(e.high_water=e.strstart),r=e.bi_valid+42>>3,r=e.pending_buf_size-r>65535?65535:e.pending_buf_size-r,s=r>e.w_size?e.w_size:r,n=e.strstart-e.block_start,(n>=s||(n||t===nn)&&t!==Ji&&0===e.strm.avail_in&&n<=r)&&(i=n>r?r:n,o=t===nn&&0===e.strm.avail_in&&i===n?1:0,Qi(e,e.block_start,i,o),e.block_start+=i,Mn(e.strm)),o?3:1)},On=(e,t)=>{let i,n;for(;;){if(e.lookahead<vn){if(Fn(e),e.lookahead<vn&&t===Ji)return 1;if(0===e.lookahead)break}if(i=0,e.lookahead>=3&&(e.ins_h=En(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==i&&e.strstart-i<=e.w_size-vn&&(e.match_length=Bn(e,i)),e.match_length>=3)if(n=Yi(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=En(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=En(e,e.ins_h,e.window[e.strstart+1]);else n=Yi(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(Tn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===nn?(Tn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Tn(e,!1),0===e.strm.avail_out)?1:2},Pn=(e,t)=>{let i,n,r;for(;;){if(e.lookahead<vn){if(Fn(e),e.lookahead<vn&&t===Ji)return 1;if(0===e.lookahead)break}if(i=0,e.lookahead>=3&&(e.ins_h=En(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==i&&e.prev_length<e.max_lazy_match&&e.strstart-i<=e.w_size-vn&&(e.match_length=Bn(e,i),e.match_length<=5&&(e.strategy===dn||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-3,n=Yi(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=r&&(e.ins_h=En(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,n&&(Tn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(n=Yi(e,0,e.window[e.strstart-1]),n&&Tn(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=Yi(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===nn?(Tn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Tn(e,!1),0===e.strm.avail_out)?1:2};function Dn(e,t,i,n,r){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=n,this.func=r}const zn=[new Dn(0,0,0,0,Nn),new Dn(4,4,8,4,On),new Dn(4,5,16,8,On),new Dn(4,6,32,32,On),new Dn(4,4,16,16,Pn),new Dn(8,16,32,32,Pn),new Dn(8,16,128,128,Pn),new Dn(8,32,128,256,Pn),new Dn(32,128,258,1024,Pn),new Dn(32,258,258,4096,Pn)];function Hn(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=bn,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),Sn(this.dyn_ltree),Sn(this.dyn_dtree),Sn(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),Sn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Sn(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Vn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==yn&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==_n&&t.status!==xn?1:0},Un=e=>{if(Vn(e))return kn(e,an);e.total_in=e.total_out=0,e.data_type=mn;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?yn:_n,e.adler=2===t.wrap?0:1,t.last_flush=-2,Zi(t),sn},qn=e=>{const t=Un(e);var i;return t===sn&&((i=e.state).window_size=2*i.w_size,Sn(i.head),i.max_lazy_match=zn[i.level].max_lazy,i.good_match=zn[i.level].good_length,i.nice_match=zn[i.level].nice_length,i.max_chain_length=zn[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),t},jn=(e,t,i,n,r,s)=>{if(!e)return an;let o=1;if(t===cn&&(t=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),r<1||r>9||i!==bn||n<8||n>15||t<0||t>9||s<0||s>pn||8===n&&1!==o)return kn(e,an);8===n&&(n=9);const a=new Hn;return e.state=a,a.strm=e,a.status=yn,a.wrap=o,a.gzhead=null,a.w_bits=n,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=r+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+3-1)/3),a.window=new Uint8Array(2*a.w_size),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<r+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Uint8Array(a.pending_buf_size),a.sym_buf=a.lit_bufsize,a.sym_end=3*(a.lit_bufsize-1),a.level=t,a.strategy=s,a.method=i,qn(e)};var $n=(e,t)=>{let i=t.length;if(Vn(e))return an;const n=e.state,r=n.wrap;if(2===r||1===r&&n.status!==yn||n.lookahead)return an;if(1===r&&(e.adler=qi(e.adler,t,i,0)),n.wrap=0,i>=n.w_size){0===r&&(Sn(n.head),n.strstart=0,n.block_start=0,n.insert=0);let e=new Uint8Array(n.w_size);e.set(t.subarray(i-n.w_size,i),0),t=e,i=n.w_size}const s=e.avail_in,o=e.next_in,a=e.input;for(e.avail_in=i,e.next_in=0,e.input=t,Fn(n);n.lookahead>=3;){let e=n.strstart,t=n.lookahead-2;do{n.ins_h=En(n,n.ins_h,n.window[e+3-1]),n.prev[e&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=e,e++}while(--t);n.strstart=e,n.lookahead=2,Fn(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,e.next_in=o,e.input=a,e.avail_in=s,n.wrap=r,sn},Wn={deflateInit:(e,t)=>jn(e,t,bn,15,8,gn),deflateInit2:jn,deflateReset:qn,deflateResetKeep:Un,deflateSetHeader:(e,t)=>Vn(e)||2!==e.state.wrap?an:(e.state.gzhead=t,sn),deflate:(e,t)=>{if(Vn(e)||t>rn||t<0)return e?kn(e,an):an;const i=e.state;if(!e.output||0!==e.avail_in&&!e.input||i.status===xn&&t!==nn)return kn(e,0===e.avail_out?hn:an);const n=i.last_flush;if(i.last_flush=t,0!==i.pending){if(Mn(e),0===e.avail_out)return i.last_flush=-1,sn}else if(0===e.avail_in&&Cn(t)<=Cn(n)&&t!==nn)return kn(e,hn);if(i.status===xn&&0!==e.avail_in)return kn(e,hn);if(i.status===yn&&0===i.wrap&&(i.status=_n),i.status===yn){let t=bn+(i.w_bits-8<<4)<<8,n=-1;if(n=i.strategy>=un||i.level<2?0:i.level<6?1:6===i.level?2:3,t|=n<<6,0!==i.strstart&&(t|=32),t+=31-t%31,Ln(i,t),0!==i.strstart&&(Ln(i,e.adler>>>16),Ln(i,65535&e.adler)),e.adler=1,i.status=_n,Mn(e),0!==i.pending)return i.last_flush=-1,sn}if(57===i.status)if(e.adler=0,Rn(i,31),Rn(i,139),Rn(i,8),i.gzhead)Rn(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),Rn(i,255&i.gzhead.time),Rn(i,i.gzhead.time>>8&255),Rn(i,i.gzhead.time>>16&255),Rn(i,i.gzhead.time>>24&255),Rn(i,9===i.level?2:i.strategy>=un||i.level<2?4:0),Rn(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(Rn(i,255&i.gzhead.extra.length),Rn(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=$i(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69;else if(Rn(i,0),Rn(i,0),Rn(i,0),Rn(i,0),Rn(i,0),Rn(i,9===i.level?2:i.strategy>=un||i.level<2?4:0),Rn(i,3),i.status=_n,Mn(e),0!==i.pending)return i.last_flush=-1,sn;if(69===i.status){if(i.gzhead.extra){let t=i.pending,n=(65535&i.gzhead.extra.length)-i.gzindex;for(;i.pending+n>i.pending_buf_size;){let r=i.pending_buf_size-i.pending;if(i.pending_buf.set(i.gzhead.extra.subarray(i.gzindex,i.gzindex+r),i.pending),i.pending=i.pending_buf_size,i.gzhead.hcrc&&i.pending>t&&(e.adler=$i(e.adler,i.pending_buf,i.pending-t,t)),i.gzindex+=r,Mn(e),0!==i.pending)return i.last_flush=-1,sn;t=0,n-=r}let r=new Uint8Array(i.gzhead.extra);i.pending_buf.set(r.subarray(i.gzindex,i.gzindex+n),i.pending),i.pending+=n,i.gzhead.hcrc&&i.pending>t&&(e.adler=$i(e.adler,i.pending_buf,i.pending-t,t)),i.gzindex=0}i.status=73}if(73===i.status){if(i.gzhead.name){let t,n=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>n&&(e.adler=$i(e.adler,i.pending_buf,i.pending-n,n)),Mn(e),0!==i.pending)return i.last_flush=-1,sn;n=0}t=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,Rn(i,t)}while(0!==t);i.gzhead.hcrc&&i.pending>n&&(e.adler=$i(e.adler,i.pending_buf,i.pending-n,n)),i.gzindex=0}i.status=91}if(91===i.status){if(i.gzhead.comment){let t,n=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>n&&(e.adler=$i(e.adler,i.pending_buf,i.pending-n,n)),Mn(e),0!==i.pending)return i.last_flush=-1,sn;n=0}t=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,Rn(i,t)}while(0!==t);i.gzhead.hcrc&&i.pending>n&&(e.adler=$i(e.adler,i.pending_buf,i.pending-n,n))}i.status=103}if(103===i.status){if(i.gzhead.hcrc){if(i.pending+2>i.pending_buf_size&&(Mn(e),0!==i.pending))return i.last_flush=-1,sn;Rn(i,255&e.adler),Rn(i,e.adler>>8&255),e.adler=0}if(i.status=_n,Mn(e),0!==i.pending)return i.last_flush=-1,sn}if(0!==e.avail_in||0!==i.lookahead||t!==Ji&&i.status!==xn){let n=0===i.level?Nn(i,t):i.strategy===un?((e,t)=>{let i;for(;;){if(0===e.lookahead&&(Fn(e),0===e.lookahead)){if(t===Ji)return 1;break}if(e.match_length=0,i=Yi(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(Tn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===nn?(Tn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Tn(e,!1),0===e.strm.avail_out)?1:2})(i,t):i.strategy===fn?((e,t)=>{let i,n,r,s;const o=e.window;for(;;){if(e.lookahead<=wn){if(Fn(e),e.lookahead<=wn&&t===Ji)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(r=e.strstart-1,n=o[r],n===o[++r]&&n===o[++r]&&n===o[++r])){s=e.strstart+wn;do{}while(n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&r<s);e.match_length=wn-(s-r),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(i=Yi(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=Yi(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(Tn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===nn?(Tn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Tn(e,!1),0===e.strm.avail_out)?1:2})(i,t):zn[i.level].func(i,t);if(3!==n&&4!==n||(i.status=xn),1===n||3===n)return 0===e.avail_out&&(i.last_flush=-1),sn;if(2===n&&(t===en?Ki(i):t!==rn&&(Qi(i,0,0,!1),t===tn&&(Sn(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),Mn(e),0===e.avail_out))return i.last_flush=-1,sn}return t!==nn?sn:i.wrap<=0?on:(2===i.wrap?(Rn(i,255&e.adler),Rn(i,e.adler>>8&255),Rn(i,e.adler>>16&255),Rn(i,e.adler>>24&255),Rn(i,255&e.total_in),Rn(i,e.total_in>>8&255),Rn(i,e.total_in>>16&255),Rn(i,e.total_in>>24&255)):(Ln(i,e.adler>>>16),Ln(i,65535&e.adler)),Mn(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?sn:on)},deflateEnd:e=>{if(Vn(e))return an;const t=e.state.status;return e.state=null,t===_n?kn(e,ln):sn},deflateSetDictionary:$n,deflateInfo:"pako deflate (from Nodeca project)"};const Gn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Zn={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const i=t.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const t in i)Gn(i,t)&&(e[t]=i[t])}}return e},flattenChunks:e=>{let t=0;for(let i=0,n=e.length;i<n;i++)t+=e[i].length;const i=new Uint8Array(t);for(let t=0,n=0,r=e.length;t<r;t++){let r=e[t];i.set(r,n),n+=r.length}return i}};let Qn=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(Ub){Qn=!1}const Xn=new Uint8Array(256);for(let qb=0;qb<256;qb++)Xn[qb]=qb>=252?6:qb>=248?5:qb>=240?4:qb>=224?3:qb>=192?2:1;Xn[254]=Xn[254]=1;var Yn={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,i,n,r,s,o=e.length,a=0;for(r=0;r<o;r++)i=e.charCodeAt(r),55296==(64512&i)&&r+1<o&&(n=e.charCodeAt(r+1),56320==(64512&n)&&(i=65536+(i-55296<<10)+(n-56320),r++)),a+=i<128?1:i<2048?2:i<65536?3:4;for(t=new Uint8Array(a),s=0,r=0;s<a;r++)i=e.charCodeAt(r),55296==(64512&i)&&r+1<o&&(n=e.charCodeAt(r+1),56320==(64512&n)&&(i=65536+(i-55296<<10)+(n-56320),r++)),i<128?t[s++]=i:i<2048?(t[s++]=192|i>>>6,t[s++]=128|63&i):i<65536?(t[s++]=224|i>>>12,t[s++]=128|i>>>6&63,t[s++]=128|63&i):(t[s++]=240|i>>>18,t[s++]=128|i>>>12&63,t[s++]=128|i>>>6&63,t[s++]=128|63&i);return t},buf2string:(e,t)=>{const i=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let n,r;const s=new Array(2*i);for(r=0,n=0;n<i;){let t=e[n++];if(t<128){s[r++]=t;continue}let o=Xn[t];if(o>4)s[r++]=65533,n+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&n<i;)t=t<<6|63&e[n++],o--;o>1?s[r++]=65533:t<65536?s[r++]=t:(t-=65536,s[r++]=55296|t>>10&1023,s[r++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Qn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let i="";for(let n=0;n<t;n++)i+=String.fromCharCode(e[n]);return i})(s,r)},utf8border:(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let i=t-1;for(;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+Xn[e[i]]>t?i:t}};var Kn=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Jn=Object.prototype.toString,{Z_NO_FLUSH:er,Z_SYNC_FLUSH:tr,Z_FULL_FLUSH:ir,Z_FINISH:nr,Z_OK:rr,Z_STREAM_END:sr,Z_DEFAULT_COMPRESSION:or,Z_DEFAULT_STRATEGY:ar,Z_DEFLATED:lr}=Gi;function hr(e){this.options=Zn.assign({level:or,method:lr,chunkSize:16384,windowBits:15,memLevel:8,strategy:ar},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Kn,this.strm.avail_out=0;let i=Wn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==rr)throw new Error(Wi[i]);if(t.header&&Wn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Yn.string2buf(t.dictionary):"[object ArrayBuffer]"===Jn.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,i=Wn.deflateSetDictionary(this.strm,e),i!==rr)throw new Error(Wi[i]);this._dict_set=!0}}function cr(e,t){const i=new hr(t);if(i.push(e,!0),i.err)throw i.msg||Wi[i.err];return i.result}hr.prototype.push=function(e,t){const i=this.strm,n=this.options.chunkSize;let r,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?nr:er,"string"==typeof e?i.input=Yn.string2buf(e):"[object ArrayBuffer]"===Jn.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),(s===tr||s===ir)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(r=Wn.deflate(i,s),r===sr)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=Wn.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===rr;if(0!==i.avail_out){if(s>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},hr.prototype.onData=function(e){this.chunks.push(e)},hr.prototype.onEnd=function(e){e===rr&&(this.result=Zn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var dr=function(e,t){return(t=t||{}).raw=!0,cr(e,t)},ur=function(e,t){return(t=t||{}).gzip=!0,cr(e,t)},fr={Deflate:hr,deflate:cr,deflateRaw:dr,gzip:ur,constants:Gi};const pr=16209;var gr=function(e,t){let i,n,r,s,o,a,l,h,c,d,u,f,p,g,m,b,w,v,y,_,x,k,C,S;const A=e.state;i=e.next_in,C=e.input,n=i+(e.avail_in-5),r=e.next_out,S=e.output,s=r-(t-e.avail_out),o=r+(e.avail_out-257),a=A.dmax,l=A.wsize,h=A.whave,c=A.wnext,d=A.window,u=A.hold,f=A.bits,p=A.lencode,g=A.distcode,m=(1<<A.lenbits)-1,b=(1<<A.distbits)-1;e:do{f<15&&(u+=C[i++]<<f,f+=8,u+=C[i++]<<f,f+=8),w=p[u&m];t:for(;;){if(v=w>>>24,u>>>=v,f-=v,v=w>>>16&255,0===v)S[r++]=65535&w;else{if(!(16&v)){if(0==(64&v)){w=p[(65535&w)+(u&(1<<v)-1)];continue t}if(32&v){A.mode=16191;break e}e.msg="invalid literal/length code",A.mode=pr;break e}y=65535&w,v&=15,v&&(f<v&&(u+=C[i++]<<f,f+=8),y+=u&(1<<v)-1,u>>>=v,f-=v),f<15&&(u+=C[i++]<<f,f+=8,u+=C[i++]<<f,f+=8),w=g[u&b];i:for(;;){if(v=w>>>24,u>>>=v,f-=v,v=w>>>16&255,!(16&v)){if(0==(64&v)){w=g[(65535&w)+(u&(1<<v)-1)];continue i}e.msg="invalid distance code",A.mode=pr;break e}if(_=65535&w,v&=15,f<v&&(u+=C[i++]<<f,f+=8,f<v&&(u+=C[i++]<<f,f+=8)),_+=u&(1<<v)-1,_>a){e.msg="invalid distance too far back",A.mode=pr;break e}if(u>>>=v,f-=v,v=r-s,_>v){if(v=_-v,v>h&&A.sane){e.msg="invalid distance too far back",A.mode=pr;break e}if(x=0,k=d,0===c){if(x+=l-v,v<y){y-=v;do{S[r++]=d[x++]}while(--v);x=r-_,k=S}}else if(c<v){if(x+=l+c-v,v-=c,v<y){y-=v;do{S[r++]=d[x++]}while(--v);if(x=0,c<y){v=c,y-=v;do{S[r++]=d[x++]}while(--v);x=r-_,k=S}}}else if(x+=c-v,v<y){y-=v;do{S[r++]=d[x++]}while(--v);x=r-_,k=S}for(;y>2;)S[r++]=k[x++],S[r++]=k[x++],S[r++]=k[x++],y-=3;y&&(S[r++]=k[x++],y>1&&(S[r++]=k[x++]))}else{x=r-_;do{S[r++]=S[x++],S[r++]=S[x++],S[r++]=S[x++],y-=3}while(y>2);y&&(S[r++]=S[x++],y>1&&(S[r++]=S[x++]))}break}}break}}while(i<n&&r<o);y=f>>3,i-=y,f-=y<<3,u&=(1<<f)-1,e.next_in=i,e.next_out=r,e.avail_in=i<n?n-i+5:5-(i-n),e.avail_out=r<o?o-r+257:257-(r-o),A.hold=u,A.bits=f};const mr=15,br=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),wr=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),vr=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),yr=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var _r=(e,t,i,n,r,s,o,a)=>{const l=a.bits;let h,c,d,u,f,p,g=0,m=0,b=0,w=0,v=0,y=0,_=0,x=0,k=0,C=0,S=null;const A=new Uint16Array(16),E=new Uint16Array(16);let M,T,R,L=null;for(g=0;g<=mr;g++)A[g]=0;for(m=0;m<n;m++)A[t[i+m]]++;for(v=l,w=mr;w>=1&&0===A[w];w--);if(v>w&&(v=w),0===w)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(b=1;b<w&&0===A[b];b++);for(v<b&&(v=b),x=1,g=1;g<=mr;g++)if(x<<=1,x-=A[g],x<0)return-1;if(x>0&&(0===e||1!==w))return-1;for(E[1]=0,g=1;g<mr;g++)E[g+1]=E[g]+A[g];for(m=0;m<n;m++)0!==t[i+m]&&(o[E[t[i+m]]++]=m);if(0===e?(S=L=o,p=20):1===e?(S=br,L=wr,p=257):(S=vr,L=yr,p=0),C=0,m=0,g=b,f=s,y=v,_=0,d=-1,k=1<<v,u=k-1,1===e&&k>852||2===e&&k>592)return 1;for(;;){M=g-_,o[m]+1<p?(T=0,R=o[m]):o[m]>=p?(T=L[o[m]-p],R=S[o[m]-p]):(T=96,R=0),h=1<<g-_,c=1<<y,b=c;do{c-=h,r[f+(C>>_)+c]=M<<24|T<<16|R|0}while(0!==c);for(h=1<<g-1;C&h;)h>>=1;if(0!==h?(C&=h-1,C+=h):C=0,m++,0==--A[g]){if(g===w)break;g=t[i+o[m]]}if(g>v&&(C&u)!==d){for(0===_&&(_=v),f+=b,y=g-_,x=1<<y;y+_<w&&(x-=A[y+_],!(x<=0));)y++,x<<=1;if(k+=1<<y,1===e&&k>852||2===e&&k>592)return 1;d=C&u,r[d]=v<<24|y<<16|f-s|0}}return 0!==C&&(r[f+C]=g-_<<24|64<<16|0),a.bits=v,0};const{Z_FINISH:xr,Z_BLOCK:kr,Z_TREES:Cr,Z_OK:Sr,Z_STREAM_END:Ar,Z_NEED_DICT:Er,Z_STREAM_ERROR:Mr,Z_DATA_ERROR:Tr,Z_MEM_ERROR:Rr,Z_BUF_ERROR:Lr,Z_DEFLATED:Ir}=Gi,Br=16180,Fr=16190,Nr=16191,Or=16192,Pr=16194,Dr=16199,zr=16200,Hr=16206,Vr=16209,Ur=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function qr(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const jr=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<Br||t.mode>16211?1:0},$r=e=>{if(jr(e))return Mr;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Br,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Sr},Wr=e=>{if(jr(e))return Mr;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,$r(e)},Gr=(e,t)=>{let i;if(jr(e))return Mr;const n=e.state;return t<0?(i=0,t=-t):(i=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Mr:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=i,n.wbits=t,Wr(e))},Zr=(e,t)=>{if(!e)return Mr;const i=new qr;e.state=i,i.strm=e,i.window=null,i.mode=Br;const n=Gr(e,t);return n!==Sr&&(e.state=null),n};let Qr,Xr,Yr=!0;const Kr=e=>{if(Yr){Qr=new Int32Array(512),Xr=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(_r(1,e.lens,0,288,Qr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;_r(2,e.lens,0,32,Xr,0,e.work,{bits:5}),Yr=!1}e.lencode=Qr,e.lenbits=9,e.distcode=Xr,e.distbits=5},Jr=(e,t,i,n)=>{let r;const s=e.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),n>=s.wsize?(s.window.set(t.subarray(i-s.wsize,i),0),s.wnext=0,s.whave=s.wsize):(r=s.wsize-s.wnext,r>n&&(r=n),s.window.set(t.subarray(i-n,i-n+r),s.wnext),(n-=r)?(s.window.set(t.subarray(i-n,i),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=r))),0};var es=(e,t)=>{let i,n,r,s,o,a,l,h,c,d,u,f,p,g,m,b,w,v,y,_,x,k,C=0;const S=new Uint8Array(4);let A,E;const M=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(jr(e)||!e.output||!e.input&&0!==e.avail_in)return Mr;i=e.state,i.mode===Nr&&(i.mode=Or),o=e.next_out,r=e.output,l=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,h=i.hold,c=i.bits,d=a,u=l,k=Sr;e:for(;;)switch(i.mode){case Br:if(0===i.wrap){i.mode=Or;break}for(;c<16;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}if(2&i.wrap&&35615===h){0===i.wbits&&(i.wbits=15),i.check=0,S[0]=255&h,S[1]=h>>>8&255,i.check=$i(i.check,S,2,0),h=0,c=0,i.mode=16181;break}if(i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&h)<<8)+(h>>8))%31){e.msg="incorrect header check",i.mode=Vr;break}if((15&h)!==Ir){e.msg="unknown compression method",i.mode=Vr;break}if(h>>>=4,c-=4,x=8+(15&h),0===i.wbits&&(i.wbits=x),x>15||x>i.wbits){e.msg="invalid window size",i.mode=Vr;break}i.dmax=1<<i.wbits,i.flags=0,e.adler=i.check=1,i.mode=512&h?16189:Nr,h=0,c=0;break;case 16181:for(;c<16;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}if(i.flags=h,(255&i.flags)!==Ir){e.msg="unknown compression method",i.mode=Vr;break}if(57344&i.flags){e.msg="unknown header flags set",i.mode=Vr;break}i.head&&(i.head.text=h>>8&1),512&i.flags&&4&i.wrap&&(S[0]=255&h,S[1]=h>>>8&255,i.check=$i(i.check,S,2,0)),h=0,c=0,i.mode=16182;case 16182:for(;c<32;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}i.head&&(i.head.time=h),512&i.flags&&4&i.wrap&&(S[0]=255&h,S[1]=h>>>8&255,S[2]=h>>>16&255,S[3]=h>>>24&255,i.check=$i(i.check,S,4,0)),h=0,c=0,i.mode=16183;case 16183:for(;c<16;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}i.head&&(i.head.xflags=255&h,i.head.os=h>>8),512&i.flags&&4&i.wrap&&(S[0]=255&h,S[1]=h>>>8&255,i.check=$i(i.check,S,2,0)),h=0,c=0,i.mode=16184;case 16184:if(1024&i.flags){for(;c<16;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}i.length=h,i.head&&(i.head.extra_len=h),512&i.flags&&4&i.wrap&&(S[0]=255&h,S[1]=h>>>8&255,i.check=$i(i.check,S,2,0)),h=0,c=0}else i.head&&(i.head.extra=null);i.mode=16185;case 16185:if(1024&i.flags&&(f=i.length,f>a&&(f=a),f&&(i.head&&(x=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(n.subarray(s,s+f),x)),512&i.flags&&4&i.wrap&&(i.check=$i(i.check,n,f,s)),a-=f,s+=f,i.length-=f),i.length))break e;i.length=0,i.mode=16186;case 16186:if(2048&i.flags){if(0===a)break e;f=0;do{x=n[s+f++],i.head&&x&&i.length<65536&&(i.head.name+=String.fromCharCode(x))}while(x&&f<a);if(512&i.flags&&4&i.wrap&&(i.check=$i(i.check,n,f,s)),a-=f,s+=f,x)break e}else i.head&&(i.head.name=null);i.length=0,i.mode=16187;case 16187:if(4096&i.flags){if(0===a)break e;f=0;do{x=n[s+f++],i.head&&x&&i.length<65536&&(i.head.comment+=String.fromCharCode(x))}while(x&&f<a);if(512&i.flags&&4&i.wrap&&(i.check=$i(i.check,n,f,s)),a-=f,s+=f,x)break e}else i.head&&(i.head.comment=null);i.mode=16188;case 16188:if(512&i.flags){for(;c<16;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}if(4&i.wrap&&h!==(65535&i.check)){e.msg="header crc mismatch",i.mode=Vr;break}h=0,c=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=Nr;break;case 16189:for(;c<32;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}e.adler=i.check=Ur(h),h=0,c=0,i.mode=Fr;case Fr:if(0===i.havedict)return e.next_out=o,e.avail_out=l,e.next_in=s,e.avail_in=a,i.hold=h,i.bits=c,Er;e.adler=i.check=1,i.mode=Nr;case Nr:if(t===kr||t===Cr)break e;case Or:if(i.last){h>>>=7&c,c-=7&c,i.mode=Hr;break}for(;c<3;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}switch(i.last=1&h,h>>>=1,c-=1,3&h){case 0:i.mode=16193;break;case 1:if(Kr(i),i.mode=Dr,t===Cr){h>>>=2,c-=2;break e}break;case 2:i.mode=16196;break;case 3:e.msg="invalid block type",i.mode=Vr}h>>>=2,c-=2;break;case 16193:for(h>>>=7&c,c-=7&c;c<32;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}if((65535&h)!=(h>>>16^65535)){e.msg="invalid stored block lengths",i.mode=Vr;break}if(i.length=65535&h,h=0,c=0,i.mode=Pr,t===Cr)break e;case Pr:i.mode=16195;case 16195:if(f=i.length,f){if(f>a&&(f=a),f>l&&(f=l),0===f)break e;r.set(n.subarray(s,s+f),o),a-=f,s+=f,l-=f,o+=f,i.length-=f;break}i.mode=Nr;break;case 16196:for(;c<14;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}if(i.nlen=257+(31&h),h>>>=5,c-=5,i.ndist=1+(31&h),h>>>=5,c-=5,i.ncode=4+(15&h),h>>>=4,c-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=Vr;break}i.have=0,i.mode=16197;case 16197:for(;i.have<i.ncode;){for(;c<3;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}i.lens[M[i.have++]]=7&h,h>>>=3,c-=3}for(;i.have<19;)i.lens[M[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,A={bits:i.lenbits},k=_r(0,i.lens,0,19,i.lencode,0,i.work,A),i.lenbits=A.bits,k){e.msg="invalid code lengths set",i.mode=Vr;break}i.have=0,i.mode=16198;case 16198:for(;i.have<i.nlen+i.ndist;){for(;C=i.lencode[h&(1<<i.lenbits)-1],m=C>>>24,b=C>>>16&255,w=65535&C,!(m<=c);){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}if(w<16)h>>>=m,c-=m,i.lens[i.have++]=w;else{if(16===w){for(E=m+2;c<E;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}if(h>>>=m,c-=m,0===i.have){e.msg="invalid bit length repeat",i.mode=Vr;break}x=i.lens[i.have-1],f=3+(3&h),h>>>=2,c-=2}else if(17===w){for(E=m+3;c<E;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}h>>>=m,c-=m,x=0,f=3+(7&h),h>>>=3,c-=3}else{for(E=m+7;c<E;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}h>>>=m,c-=m,x=0,f=11+(127&h),h>>>=7,c-=7}if(i.have+f>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=Vr;break}for(;f--;)i.lens[i.have++]=x}}if(i.mode===Vr)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=Vr;break}if(i.lenbits=9,A={bits:i.lenbits},k=_r(1,i.lens,0,i.nlen,i.lencode,0,i.work,A),i.lenbits=A.bits,k){e.msg="invalid literal/lengths set",i.mode=Vr;break}if(i.distbits=6,i.distcode=i.distdyn,A={bits:i.distbits},k=_r(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,A),i.distbits=A.bits,k){e.msg="invalid distances set",i.mode=Vr;break}if(i.mode=Dr,t===Cr)break e;case Dr:i.mode=zr;case zr:if(a>=6&&l>=258){e.next_out=o,e.avail_out=l,e.next_in=s,e.avail_in=a,i.hold=h,i.bits=c,gr(e,u),o=e.next_out,r=e.output,l=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,h=i.hold,c=i.bits,i.mode===Nr&&(i.back=-1);break}for(i.back=0;C=i.lencode[h&(1<<i.lenbits)-1],m=C>>>24,b=C>>>16&255,w=65535&C,!(m<=c);){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}if(b&&0==(240&b)){for(v=m,y=b,_=w;C=i.lencode[_+((h&(1<<v+y)-1)>>v)],m=C>>>24,b=C>>>16&255,w=65535&C,!(v+m<=c);){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}h>>>=v,c-=v,i.back+=v}if(h>>>=m,c-=m,i.back+=m,i.length=w,0===b){i.mode=16205;break}if(32&b){i.back=-1,i.mode=Nr;break}if(64&b){e.msg="invalid literal/length code",i.mode=Vr;break}i.extra=15&b,i.mode=16201;case 16201:if(i.extra){for(E=i.extra;c<E;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}i.length+=h&(1<<i.extra)-1,h>>>=i.extra,c-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=16202;case 16202:for(;C=i.distcode[h&(1<<i.distbits)-1],m=C>>>24,b=C>>>16&255,w=65535&C,!(m<=c);){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}if(0==(240&b)){for(v=m,y=b,_=w;C=i.distcode[_+((h&(1<<v+y)-1)>>v)],m=C>>>24,b=C>>>16&255,w=65535&C,!(v+m<=c);){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}h>>>=v,c-=v,i.back+=v}if(h>>>=m,c-=m,i.back+=m,64&b){e.msg="invalid distance code",i.mode=Vr;break}i.offset=w,i.extra=15&b,i.mode=16203;case 16203:if(i.extra){for(E=i.extra;c<E;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}i.offset+=h&(1<<i.extra)-1,h>>>=i.extra,c-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=Vr;break}i.mode=16204;case 16204:if(0===l)break e;if(f=u-l,i.offset>f){if(f=i.offset-f,f>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=Vr;break}f>i.wnext?(f-=i.wnext,p=i.wsize-f):p=i.wnext-f,f>i.length&&(f=i.length),g=i.window}else g=r,p=o-i.offset,f=i.length;f>l&&(f=l),l-=f,i.length-=f;do{r[o++]=g[p++]}while(--f);0===i.length&&(i.mode=zr);break;case 16205:if(0===l)break e;r[o++]=i.length,l--,i.mode=zr;break;case Hr:if(i.wrap){for(;c<32;){if(0===a)break e;a--,h|=n[s++]<<c,c+=8}if(u-=l,e.total_out+=u,i.total+=u,4&i.wrap&&u&&(e.adler=i.check=i.flags?$i(i.check,r,u,o-u):qi(i.check,r,u,o-u)),u=l,4&i.wrap&&(i.flags?h:Ur(h))!==i.check){e.msg="incorrect data check",i.mode=Vr;break}h=0,c=0}i.mode=16207;case 16207:if(i.wrap&&i.flags){for(;c<32;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}if(4&i.wrap&&h!==(4294967295&i.total)){e.msg="incorrect length check",i.mode=Vr;break}h=0,c=0}i.mode=16208;case 16208:k=Ar;break e;case Vr:k=Tr;break e;case 16210:return Rr;default:return Mr}return e.next_out=o,e.avail_out=l,e.next_in=s,e.avail_in=a,i.hold=h,i.bits=c,(i.wsize||u!==e.avail_out&&i.mode<Vr&&(i.mode<Hr||t!==xr))&&Jr(e,e.output,e.next_out,u-e.avail_out),d-=e.avail_in,u-=e.avail_out,e.total_in+=d,e.total_out+=u,i.total+=u,4&i.wrap&&u&&(e.adler=i.check=i.flags?$i(i.check,r,u,e.next_out-u):qi(i.check,r,u,e.next_out-u)),e.data_type=i.bits+(i.last?64:0)+(i.mode===Nr?128:0)+(i.mode===Dr||i.mode===Pr?256:0),(0===d&&0===u||t===xr)&&k===Sr&&(k=Lr),k},ts={inflateReset:Wr,inflateReset2:Gr,inflateResetKeep:$r,inflateInit:e=>Zr(e,15),inflateInit2:Zr,inflate:es,inflateEnd:e=>{if(jr(e))return Mr;let t=e.state;return t.window&&(t.window=null),e.state=null,Sr},inflateGetHeader:(e,t)=>{if(jr(e))return Mr;const i=e.state;return 0==(2&i.wrap)?Mr:(i.head=t,t.done=!1,Sr)},inflateSetDictionary:(e,t)=>{const i=t.length;let n,r,s;return jr(e)?Mr:(n=e.state,0!==n.wrap&&n.mode!==Fr?Mr:n.mode===Fr&&(r=1,r=qi(r,t,i,0),r!==n.check)?Tr:(s=Jr(e,t,i,i),s?(n.mode=16210,Rr):(n.havedict=1,Sr)))},inflateInfo:"pako inflate (from Nodeca project)"};var is=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const ns=Object.prototype.toString,{Z_NO_FLUSH:rs,Z_FINISH:ss,Z_OK:os,Z_STREAM_END:as,Z_NEED_DICT:ls,Z_STREAM_ERROR:hs,Z_DATA_ERROR:cs,Z_MEM_ERROR:ds}=Gi;function us(e){this.options=Zn.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Kn,this.strm.avail_out=0;let i=ts.inflateInit2(this.strm,t.windowBits);if(i!==os)throw new Error(Wi[i]);if(this.header=new is,ts.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Yn.string2buf(t.dictionary):"[object ArrayBuffer]"===ns.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=ts.inflateSetDictionary(this.strm,t.dictionary),i!==os)))throw new Error(Wi[i])}function fs(e,t){const i=new us(t);if(i.push(e),i.err)throw i.msg||Wi[i.err];return i.result}us.prototype.push=function(e,t){const i=this.strm,n=this.options.chunkSize,r=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=t===~~t?t:!0===t?ss:rs,"[object ArrayBuffer]"===ns.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),s=ts.inflate(i,o),s===ls&&r&&(s=ts.inflateSetDictionary(i,r),s===os?s=ts.inflate(i,o):s===cs&&(s=ls));i.avail_in>0&&s===as&&i.state.wrap>0&&0!==e[i.next_in];)ts.inflateReset(i),s=ts.inflate(i,o);switch(s){case hs:case cs:case ls:case ds:return this.onEnd(s),this.ended=!0,!1}if(a=i.avail_out,i.next_out&&(0===i.avail_out||s===as))if("string"===this.options.to){let e=Yn.utf8border(i.output,i.next_out),t=i.next_out-e,r=Yn.buf2string(i.output,e);i.next_out=t,i.avail_out=n-t,t&&i.output.set(i.output.subarray(e,e+t),0),this.onData(r)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(s!==os||0!==a){if(s===as)return s=ts.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},us.prototype.onData=function(e){this.chunks.push(e)},us.prototype.onEnd=function(e){e===os&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Zn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var ps=function(e,t){return(t=t||{}).raw=!0,fs(e,t)},gs={Inflate:us,inflate:fs,inflateRaw:ps,ungzip:fs,constants:Gi};const{Deflate:ms,deflate:bs,deflateRaw:ws,gzip:vs}=fr,{Inflate:ys,inflate:_s,inflateRaw:xs,ungzip:ks}=gs;var Cs=ws,Ss=_s,As=xs,Es=ks;const Ms=4;function Ts(e,t){const i=[];let n=0,r=0;for(t=t||e.byteLength-18;n<t;)try{const t=ArrayBuffer.isView(e)?e:new Uint8Array(e,n,18),s=t[11]<<8|t[10],o=(t[3],t[12],t[13],t[15],t[14],1+(t[17]<<8|t[16])),a=12+s+n,l=e.byteLength-a,h=o-s-19;if(l<h||h<=0)break;const c=new Uint8Array(e,a,h),d=As(c);n+=h-1+26,r+=d.byteLength,i.push(d)}catch(e){console.error(e);break}if(1===i.length)return i[0];{const e=new Uint8Array(r);let t=0;for(let n=0;n<i.length;++n){var s=new Uint8Array(i[n]);Is(s,0,e,t,s.length),t+=s.length}return e}}function Rs(e){const t=ArrayBuffer.isView(e)?e:new Uint8Array(e);return 1+(t[17]<<8|t[16])}const Ls="function"==typeof new Uint8Array(1).subarray;function Is(e,t,i,n,r){if(0!==r){if(!e)throw"Undef src";if(!i)throw"Undef dest";0===t&&r===e.length?Bs(e,i,n):Ls?Bs(e.subarray(t,t+r),i,n):1===e.BYTES_PER_ELEMENT&&r>100?Bs(new Uint8Array(e.buffer,e.byteOffset+t,r),i,n):function(e,t,i,n,r){for(let s=0;s<r;++s)i[n+s]=e[t+s]}(e,t,i,n,r)}}function Bs(e,t,i){t.set(e,i)}function Fs(e,t){const i=e.split(","),n=i[0].split(":")[1];let r=i[1];if(n.indexOf("base64")>=0){r=atob(r);const e=new Uint8Array(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);let i;return i=t||n.indexOf("gzip")>0?Es(e):e,i}return decodeURIComponent(r)}const Ns={lerp:(e,t,i)=>(1-i)*e+i*t,mean:function(e){var t,i=0,n=0;for(t=0;t<e.length;t++)isNaN(e[t])||(i+=e[t],n++);return n>0?i/n:0},meanAndStdev:function(e){var t,i,n=0,r=0,s=0;for(i=0;i<e.length;i++)t=e[i],isNaN(t)||(n+=t,r+=t*t,s++);return s>0?{mean:n/s,stdev:Math.sqrt(r-n*n/s)}:{mean:0,stdev:0}},median:function(e){var t=e.length;return e.sort(),t%2==0?(e[t/2-1]+e[t/2])/2:e[(t-1)/2]},percentile:function(e,t){if(0!==e.length){var i=Math.floor(e.length*((100-t)/100));return 0===i?(e.sort((function(e,t){return t-e})),e[i]):function(e,t){var i,n=new Os;for(i=0;i<e.length;i++){var r=e[i];(n.content.length<t||r>n.content[0])&&(n.content.length===t&&n.pop(),n.push(r))}return n.content[0]}(e,i)}},clamp:function(e,t,i){return Math.min(Math.max(e,t),i)},log2:function(e){return Math.log(e)/Math.LN2}};function Os(){this.content=[]}function Ps(e,t){return Math.random()*(t-e)+e}Os.prototype={push:function(e){this.content.push(e),this.bubbleUp(this.content.length-1)},pop:function(){var e=this.content[0],t=this.content.pop();return this.content.length>0&&(this.content[0]=t,this.sinkDown(0)),e},remove:function(e){for(var t=this.content.length,i=0;i<t;i++)if(this.content[i]===e){var n=this.content.pop();if(i===t-1)break;this.content[i]=n,this.bubbleUp(i),this.sinkDown(i);break}},size:function(){return this.content.length},bubbleUp:function(e){for(var t=this.content[e],i=t;e>0;){var n=Math.floor((e+1)/2)-1,r=this.content[n];if(i>=r)break;this.content[n]=t,this.content[e]=r,e=n}},sinkDown:function(e){for(var t=this.content.length,i=this.content[e],n=i;;){var r=2*(e+1),s=r-1,o=null;if(s<t){var a=this.content[s],l=a;a<n&&(o=s)}if(r<t)this.content[r]<(null==o?n:l)&&(o=r);if(null==o)break;this.content[e]=this.content[o],this.content[o]=i,e=o}}};const Ds={rgbListFromHSV:()=>{let e=[];for(let t=1;t>=.5;t-=.1)for(let i=0;i<1;i+=1/28){const n="rgb("+Ds.hsvToRgb(i,1,t).join(",")+")";e.push(n)}return e.pop(),e.push(Ds.rgbColor(16,16,16)),e},rgbToHex:function(e){return(e=e.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i))&&4===e.length?"#"+("0"+parseInt(e[1],10).toString(16)).slice(-2)+("0"+parseInt(e[2],10).toString(16)).slice(-2)+("0"+parseInt(e[3],10).toString(16)).slice(-2):""},hexToRgb:function(e){var t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(null!==t)return"rgb("+parseInt(t[1],16)+","+parseInt(t[2],16)+","+parseInt(t[3],16)+")"},hsvToRgb:function(e,t,i){var n,r,s,o=Math.floor(6*e),a=6*e-o,l=i*(1-t),h=i*(1-a*t),c=i*(1-(1-a)*t);switch(o%6){case 0:n=i,r=c,s=l;break;case 1:n=h,r=i,s=l;break;case 2:n=l,r=i,s=c;break;case 3:n=l,r=h,s=i;break;case 4:n=c,r=l,s=i;break;case 5:n=i,r=l,s=h}return[Math.floor(255*n),Math.floor(255*r),Math.floor(255*s)]},hslToRgb:function(e,t,i){var n,r,s;if(0===t)n=r=s=i;else{var o=i<.5?i*(1+t):i+t-i*t,a=2*i-o;n=Ds.hue2rgb(a,o,e+1/3),r=Ds.hue2rgb(a,o,e),s=Ds.hue2rgb(a,o,e-1/3)}return[255*n,255*r,255*s]},hue2rgb:(e,t,i)=>(i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+(t-e)*(2/3-i)*6:e),rgbaColor:function(e,t,i,n){return"rgba("+(e=Ns.clamp(e,0,255))+","+(t=Ns.clamp(t,0,255))+","+(i=Ns.clamp(i,0,255))+","+(n=Ns.clamp(n,0,1))+")"},rgbColor:function(e,t,i){return"rgb("+(e=Ns.clamp(e,0,255))+","+(t=Ns.clamp(t,0,255))+","+(i=Ns.clamp(i,0,255))+")"},greyScale:function(e){var t=Ns.clamp(e,0,255);return"rgb("+t+","+t+","+t+")"},randomGrey:function(e,t){e=Ns.clamp(e,0,255),t=Ns.clamp(t,0,255);var i=Math.round(Ps(e,t)).toString(10);return"rgb("+i+","+i+","+i+")"},randomRGB:function(e,t){return e=Ns.clamp(e,0,255),t=Ns.clamp(t,0,255),"rgb("+Math.round(Ps(e,t)).toString(10)+","+Math.round(Ps(e,t)).toString(10)+","+Math.round(Ps(e,t)).toString(10)+")"},randomRGBConstantAlpha:function(e,t,i){return e=Ns.clamp(e,0,255),t=Ns.clamp(t,0,255),"rgba("+Math.round(Ps(e,t)).toString(10)+","+Math.round(Ps(e,t)).toString(10)+","+Math.round(Ps(e,t)).toString(10)+","+i+")"},addAlpha:function(e,t){if("0"===e||"."===e)e="rgb(0,0,0)";else{const t=this.colorNameToHex(e);t&&(e=t)}var i=/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e);if(e.startsWith("rgba")){const i=e.lastIndexOf(",");return e.substring(0,i+1)+t.toString()+")"}return i&&(e=Ds.hexToRgb(e)),e.startsWith("rgb")?e.replace("rgb","rgba").replace(")",", "+t+")"):(console.log(e+" is not an rgb style string"),e)},rgbComponents:function(e){if("0"===e||"."===e)return[0,0,0];if(/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e))e=Ds.hexToRgb(e);else if(!e.startsWith("rgb")){const t=this.colorNameToHex(e);e=this.hexToRgb(t)}if(e.startsWith("rgb("))return e.substring(4,e.length-1).split(",").map((e=>Number.parseInt(e.trim())));if(e.startsWith("rgba("))return e.substring(5,e.length-1).split(",").map(((e,t)=>(e=e.trim(),3===t?Number.parseFloat(e):Number.parseInt(e))));throw Error("Unrecognized color string: color")},getCompositeColor:function(e,t,i){return"rgb("+Math.floor(i*t[0]+(1-i)*e[0])+","+Math.floor(i*t[1]+(1-i)*e[1])+","+Math.floor(i*t[2]+(1-i)*e[2])+")"},createColorString:function(e){return(e=function(e){return void 0===e||((e.startsWith("'")||e.startsWith('"'))&&(e=e.substring(1)),(e.endsWith("'")||e.endsWith('"'))&&(e=e.substring(0,e.length-1))),e}(e)).includes(",")?e.startsWith("rgb")?e:"rgb("+e+")":e},darkenLighten:function(e,t){let i,n=this.colorNameToHex(e);i=n?Ds.hexToRgb(n):e.startsWith("rgb(")?e:Ds.hexToRgb(e);const r=i.replace(")","").substring(4).split(","),s=Math.max(0,Math.min(255,Number.parseInt(r[0].trim())+t)),o=Math.max(0,Math.min(255,Number.parseInt(r[1].trim())+t)),a=Math.max(0,Math.min(255,Number.parseInt(r[2].trim())+t));return"rgb("+s.toString()+","+o.toString()+","+a.toString()+")"},colorNameToHex:function(e){return{aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4","indianred ":"#cd5c5c","indigo ":"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32",darkgrey:"#a9a9a9",darkslategrey:"#2f4f4f",dimgrey:"#696969",grey:"#808080",lightgray:"#d3d3d3",lightslategrey:"#778899",slategrey:"#708090"}[e]}},zs="googleapis";class Hs{constructor(){this.oauthTokens={}}setToken(e,t){t=t||zs,this.oauthTokens[t]=e}getToken(e){let t;e=e||zs;for(let i of Object.keys(this.oauthTokens)){if(Vs(i).test(e)){t=this.oauthTokens[i];break}}return t}removeToken(e){e=e||zs;for(let t of Object.keys(this.oauthTokens)){Vs(t).test(e)&&(this.oauthTokens[t]=void 0)}}}function Vs(e){return new RegExp("^"+e.split(/\*+/).map(Us).join(".*")+"$")}function Us(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")}function qs(e){return e.includes("googleapis")&&!e.includes("urlshortener")||js(e)||$s(e)}function js(e){return e.startsWith("gs://")||e.startsWith("https://www.googleapis.com/storage")||e.startsWith("https://storage.cloud.google.com")||e.startsWith("https://storage.googleapis.com")}function $s(e){return e.indexOf("drive.google.com")>=0||e.indexOf("www.googleapis.com/drive")>0}function Ws(e){let{bucket:t,object:i}=function(e){let t,i;if(e.startsWith("gs://")){const n=e.indexOf("/",5);if(n>=0){t=e.substring(5,n);const r=e.indexOf("?");i=r<0?e.substring(n+1):e.substring(n+1,r)}}else if(e.startsWith("https://storage.googleapis.com")||e.startsWith("https://storage.cloud.google.com")){const n=e.indexOf("/v1/b/",8);if(n>0){const r=e.indexOf("/o/",n);if(r>0){const s=e.indexOf("?",r);t=e.substring(n+6,r),i=s>0?e.substring(r+3,s):e.substring(r+3)}}else{const n=e.indexOf("/",8),r=e.indexOf("/",n+1),s=e.indexOf("?",r);r>0&&(t=e.substring(n+1,r),i=s<0?e.substring(r+1):e.substring(r+1,s))}}else if(e.startsWith("https://www.googleapis.com/storage/v1/b")){const n=e.indexOf("/v1/b/",8),r=e.indexOf("/o/",n);if(r>0){const s=e.indexOf("?",r);t=e.substring(n+6,r),i=s>0?e.substring(r+3,s):e.substring(r+3)}}if(t&&i)return{bucket:t,object:i};throw Error(`Unrecognized Google Storage URI: ${e}`)}(e);i=function(e){let t="";return e.split("").forEach((function(e){Gs.has(e)?t+=Gs.get(e):t+=e})),t}(i);const n=e.indexOf("?");return`https://storage.googleapis.com/storage/v1/b/${t}/o/${i}${n>0?e.substring(n)+"&alt=media":"?alt=media"}`}const Gs=new Map;function Zs(){return window.google&&window.google.igv}async function Qs(e){if(!Zs())throw Error("Google oAuth has not been initialized");if(google.igv.tokenResponse&&Date.now()<google.igv.tokenExpiresAt&&google.accounts.oauth2.hasGrantedAllScopes(google.igv.tokenResponse,e))return google.igv.tokenResponse.access_token;{const t=google.igv.tokenClient;return new Promise(((i,n)=>{try{t.callback=e=>{void 0!==e.error&&n(e),google.igv.tokenResponse=e,google.igv.tokenExpiresAt=Date.now()+1e3*e.expires_in,i(e.access_token)},t.requestAccessToken({scope:e})}catch(e){console.log(e)}}))}}function Xs(){return google.igv.apiKey}function Ys(e){var t=Ks(e);return t?"https://www.googleapis.com/drive/v3/files/"+t+"?alt=media&supportsTeamDrives=true":e}function Ks(e){if(e.includes("/open?id=")){const t=e.indexOf("/open?id=")+9,i=e.indexOf("&");if(t>0&&i>t)return e.substring(t,i);if(t>0)return e.substring(t)}else{if(e.includes("/file/d/")){const t=e.indexOf("/file/d/")+8,i=e.lastIndexOf("/");return e.substring(t,i)}if(e.startsWith("https://www.googleapis.com/drive")){let t=e.indexOf("/files/");const i=e.indexOf("?");if(t>0)return t+=7,i>0?e.substring(t,i):e.substring(t)}}throw Error("Unknown Google Drive url format: "+e)}Gs.set("!","%21"),Gs.set("#","%23"),Gs.set("$","%24"),Gs.set("%","%25"),Gs.set("&","%26"),Gs.set("'","%27"),Gs.set("(","%28"),Gs.set(")","%29"),Gs.set("*","%2A"),Gs.set("+","%2B"),Gs.set(",","%2C"),Gs.set("/","%2F"),Gs.set(":","%3A"),Gs.set(";","%3B"),Gs.set("=","%3D"),Gs.set("?","%3F"),Gs.set("@","%40"),Gs.set("[","%5B"),Gs.set("]","%5D"),Gs.set(" ","%20");class Js{constructor(e){this.requestsPerSecond=e.requestsPerSecond||10,this.lastStartTime=0,this.queued=[]}add(e,t){var i=this;return new Promise((function(t,n){i.queued.push({resolve:t,reject:n,asyncFunction:e}),i.dequeue()}))}addAll(e,t){var i=e.map(function(e){return this.add(e,t)}.bind(this));return Promise.all(i)}dequeue(){if(this.queued.length>0){var e=new Date,t=1e3/this.requestsPerSecond+1,i=e-this.lastStartTime;i>=t?this._execute():setTimeout(function(){this.dequeue()}.bind(this),t-i)}}async _execute(){this.lastStartTime=new Date;var e=this.queued.shift();const t=e.asyncFunction;try{const i=await t();e.resolve(i)}catch(t){e.reject(t)}}}function eo(e){return e.indexOf("X-Goog-Signature")>-1}function to(){if(Zs()){return Zs()&&google.igv.tokenResponse&&Date.now()<google.igv.tokenExpiresAt?google.igv.tokenResponse.access_token:void 0}}function io(e){let t;return t=function(e){const t=ArrayBuffer.isView(e)?e:new Uint8Array(e);return 31===t[0]&&139===t[1]}(e)?function(e){const t=ArrayBuffer.isView(e)?e:new Uint8Array(e);return 0!=(t[3]&Ms)&&66===t[12]&&67===t[13]?Ts(t.buffer):Es(t)}(e):new Uint8Array(e),"TextDecoder"in function(){if("undefined"!=typeof self)return self;return"undefined"!=typeof global?global:window}()?(new TextDecoder).decode(t):function(e){var t="",i=0;for(;i<e.length;){var n=e[i],r=0,s=0;if(n<=127?(r=0,s=255&n):n<=223?(r=1,s=31&n):n<=239?(r=2,s=15&n):n<=244&&(r=3,s=7&n),e.length-i-r>0)for(var o=0;o<r;)s=s<<6|63&(n=e[i+o+1]),o+=1;else s=65533,r=e.length-i;t+=String.fromCodePoint(s),i+=r+1}return t}(t)}const no=new class{constructor(){this.apiKey=void 0,this.googleThrottle=new Js({requestsPerSecond:8}),this.RANGE_WARNING_GIVEN=!1,this.oauth=new Hs,this.contentLengthMap=new Map}setApiKey(e){this.apiKey=e}async loadArrayBuffer(e,t){return(t=t||{}).responseType||(t.responseType="arraybuffer"),ti(e)?this._loadFileSlice(e,t):this.load(e,t)}async loadJson(e,t){"POST"===((t=t||{}).method||(t.sendData?"POST":"GET"))&&(t.contentType="application/json");const i=await this.loadString(e,t);return i?JSON.parse(i):i}async loadString(e,t){return t=t||{},e instanceof File?this._loadStringFromFile(e,t):this._loadStringFromUrl(e,t)}async load(e,t){t=t||{};const i=typeof e;if(ti(e=await("function"==typeof e?e():e)))return this._loadFileSlice(e,t);if("function"==typeof e.startsWith){if(e.startsWith("data:")){const i=Fs(e).buffer;if(t.range){const e=t.range.size?t.range.start+t.range.size:i.byteLength;return i.slice(t.range.start,e)}return i}return e.startsWith("https://drive.google.com")&&(e=Ys(e)),$s(e)||e.startsWith("https://www.dropbox.com")?this.googleThrottle.add((async()=>this._loadURL(e,t))):this._loadURL(e,t)}throw Error(`url must be either a 'File', 'string', 'function', or 'Promise'. Actual type: ${i}`)}async getContentLength(e,t){if(!this.contentLengthMap.has(e)){(t=t||{}).method="HEAD",t.GET_CONTENT_LENGTH=!0;const i=await this._loadURL(e,t),n=i?Number.parseInt(i):-1;this.contentLengthMap.set(e,n)}return this.contentLengthMap.get(e)}async _loadURL(e,t){const i=this;e=function(e){return e.startsWith("https://www.dropbox.com")?e.replace("//www.dropbox.com","//dl.dropboxusercontent.com"):e.startsWith("https://drive.google.com")?Ys(e):e.includes("//www.broadinstitute.org/igvdata")?e.replace("//www.broadinstitute.org/igvdata","//data.broadinstitute.org/igvdata"):e.includes("//igvdata.broadinstitute.org")?e.replace("//igvdata.broadinstitute.org","//s3.amazonaws.com/igv.broadinstitute.org"):e.includes("//igv.genepattern.org")?e.replace("//igv.genepattern.org","//igv-genepattern-org.s3.amazonaws.com"):e.startsWith("ftp://ftp.ncbi.nlm.nih.gov/geo")?e.replace("ftp://","https://"):e}(e);let n=(t=t||{}).oauthToken||this.getOauthToken(e);n&&(n=await("function"==typeof n?n():n));let r=-1;return!t.range||function(e){return e.indexOf("X-Amz-Signature")>-1}(e)||eo(e)||(r=await this.getContentLength(e)),new Promise((function(s,o){qs(e)&&!eo(e)&&(js(e)&&(e=Ws(e)),e=function(e){let t=no.apiKey;t||"undefined"==typeof gapi||(t=gapi.apiKey);if(void 0!==t&&!e.includes("key=")){const i=e.includes("?")?"&":"?";e=e+i+"key="+t}return e}(e),$s(e)&&function(e){if(e.includes("supportsTeamDrive"))return e;{const t=e.includes("?")?"&":"?";e=e+t+"supportsTeamDrive=true"}}(e),n||(n=to()));const a=t.headers||{};n&&function(e,t){t&&(e["Cache-Control"]="no-cache",e.Authorization="Bearer "+t)}(a,n);const l=t.range,h=new XMLHttpRequest,c=t.sendData||t.body,d=t.method||(c?"POST":"GET"),u=t.responseType,f=t.contentType,p=t.mimeType;if(h.open(d,e),t.timeout&&(h.timeout=t.timeout),l){let e="";l.size&&(e=l.start+l.size-1,r>0&&(e=Math.min(e,r-1))),h.setRequestHeader("Range","bytes="+l.start+"-"+e)}if(f&&h.setRequestHeader("Content-Type",f),p&&h.overrideMimeType(p),u&&(h.responseType=u),a)for(let e of Object.keys(a)){const t=a[e];h.setRequestHeader(e,t)}!0===t.withCredentials&&(h.withCredentials=!0),h.onload=async function(n){t.GET_CONTENT_LENGTH&&s(h.getResponseHeader("content-length")),0===h.status||h.status>=200&&h.status<=300?l&&206!==h.status&&0!==l.start?(h.response.length>1e5&&!i.RANGE_WARNING_GIVEN&&alert(`Warning: Range header ignored for URL: ${e}. This can have severe performance impacts.`),s(h.response.slice(l.start,l.start+l.size))):s(h.response):"undefined"==typeof gapi||404!==h.status&&401!==h.status&&403!==h.status||!qs(e)||t.retries?403===h.status?g("Access forbidden: "+e):416===h.status?g("Unsatisfiable range"):g(h.status):m()},h.onerror=function(i){qs(e)&&!t.retries?m():g("Error accessing resource: "+e+" Status: "+h.status)},h.ontimeout=function(e){g("Timed out")},h.onabort=function(e){console.log("Aborted"),o(e)};try{h.send(c)}catch(i){qs(e)&&!t.retries?m():g(i)}function g(e){if(!o)throw e;o(e)}async function m(){try{const n=await async function(e){if(Zs()){const t=function(e){return $s(e)?"https://www.googleapis.com/auth/drive.readonly":js(e)?"https://www.googleapis.com/auth/devstorage.read_only":"https://www.googleapis.com/auth/userinfo.profile"}(e);return await Qs(t)}throw Error("Authorization is required, but Google oAuth has not been initalized. Contact your site administrator for assistance.")}(e);t.retries=1,t.oauthToken=n;const r=await i.load(e,t);s(r)}catch(e){if(e.error){const t=e.error.startsWith("popup_blocked")?"Google login popup blocked by browser.":e.error;alert(t)}else g(e)}}}))}async _loadFileSlice(e,t){let i=t&&t.range?e.slice(t.range.start,t.range.start+t.range.size):e;const n=await i.arrayBuffer();return"arraybuffer"===t.responseType?n:io(n)}async _loadStringFromFile(e,t){const i=t.range?e.slice(t.range.start,t.range.start+t.range.size):e;return io(await i.arrayBuffer())}async _loadStringFromUrl(e,t){(t=t||{}).responseType="arraybuffer";return io(await this.load(e,t))}setOauthToken(e,t){this.oauth.setToken(e,t)}getOauthToken(e){const t=qs(e)?void 0:ni(e).host;let i=this.oauth.getToken(t);if(i)return i;if(void 0===t){const e=to();if(e&&e.expires_at>Date.now())return e.access_token}}};var ro=2,so={color:1};so.parent=so,so.left=so,so.right=so;class oo{constructor(){this.root=so}insert(e,t,i){var n=new fo(new uo(e,t,i));for(this.treeInsert(n),n.color=ro;n!==this.root&&n.parent.color===ro;)if(n.parent===n.parent.parent.left){let e=n.parent.parent.right;e.color===ro?(n.parent.color=1,e.color=1,n.parent.parent.color=ro,n=n.parent.parent):(n===n.parent.right&&(n=n.parent,lo.call(this,n)),n.parent.color=1,n.parent.parent.color=ro,ho.call(this,n.parent.parent))}else{let e=n.parent.parent.left;e.color===ro?(n.parent.color=1,e.color=1,n.parent.parent.color=ro,n=n.parent.parent):(n===n.parent.left&&(n=n.parent,ho.call(this,n)),n.parent.color=1,n.parent.parent.color=ro,lo.call(this,n.parent.parent))}this.root.color=1}findOverlapping(e,t){var i=new uo(e,t,0);if(this.root===so)return[];var n=ao.call(this,i,this.root,[]);return n.length>1&&n.sort((function(e,t){return e.low-t.low})),n}logIntervals(){!function e(t,i){for(var n="",r=0;r<i;r++)n+=" ";console.log(n+t.interval.low+" "+t.interval.high),i+=5,t.left!==so&&e(t.left,i);t.right!==so&&e(t.right,i)}(this.root,0)}mapIntervals(e){!function t(i){e(i.interval),i.left!==so&&t(i.left);i.right!==so&&t(i.right)}(this.root)}treeInsert(e){for(var t=this.root,i=so;t!==so;)i=t,t=e.interval.low<=t.interval.low?t.left:t.right;e.parent=i,i===so?(this.root=e,e.left=e.right=so):e.interval.low<=i.interval.low?i.left=e:i.right=e,co.call(this,e)}}function ao(e,t,i){return t.interval.overlaps(e)&&i.push(t.interval),t.left!==so&&t.left.max>=e.low&&ao.call(this,e,t.left,i),t.right!==so&&t.right.min<=e.high&&ao.call(this,e,t.right,i),i}function lo(e){var t=e.right;e.right=t.left,t.left!==so&&(t.left.parent=e),t.parent=e.parent,e.parent===so?this.root=t:e.parent.left===e?e.parent.left=t:e.parent.right=t,t.left=e,e.parent=t,co.call(this,e)}function ho(e){var t=e.left;e.left=t.right,t.right!==so&&(t.right.parent=e),t.parent=e.parent,e.parent===so?this.root=t:e.parent.right===e?e.parent.right=t:e.parent.left=t,t.right=e,e.parent=t,co.call(this,e)}function co(e){for(;e!==so;){var t=e.left.max>e.right.max?e.left.max:e.right.max,i=e.interval.high;e.max=t>i?t:i;var n=e.left.min<e.right.min?e.left.min:e.right.min,r=e.interval.low;e.min=n<r?n:r,e=e.parent}}class uo{constructor(e,t,i){this.low=e,this.high=t,this.value=i}equals(e){return!!e&&(this===e||this.low===e.low&&this.high===e.high)}compareTo(e){return this.low<e.low?-1:this.low>e.low?1:this.high<e.high?-1:this.high>e.high?1:0}overlaps(e){return this.low<=e.high&&e.low<=this.high}}function fo(e){this.parent=so,this.left=so,this.right=so,this.interval=e,this.color=ro}class po{constructor(e,t,i){e=e||[],this.treeMap=this.buildTreeMap(e,t),this.range=i,this.count=e.length}containsRange(e){return void 0===this.range||this.range.contains(e.chr,e.start,e.end)}queryFeatures(e,t,i){const n=this.treeMap[e];if(!n)return[];const r=n.findOverlapping(t,i);if(0===r.length)return[];{const n=[],s=this.allFeatures[e];if(s){for(let e of r){const r=e.value;for(let e=r.start;e<r.end;e++){let r=s[e];if(r.start>i)break;r.end>=t&&n.push(r)}}n.sort((function(e,t){return e.start-t.start}))}return n}}getAllFeatures(){return this.allFeatures}buildTreeMap(e,t){const i={},n=[];if(this.allFeatures={},e){for(let i of e){let e=i.chr;t&&(e=t.getChromosomeName(e));let r=this.allFeatures[e];r||(n.push(e),r=[],this.allFeatures[e]=r),r.push(i)}for(let e of n){const t=this.allFeatures[e];t.sort((function(e,t){return e.start===t.start?0:e.start>t.start?1:-1})),i[e]=go(t)}}return i}}function go(e){const t=new oo,i=e.length,n=Math.max(10,Math.round(i/10));for(let r=0;r<i;r+=n){const s=Math.min(i,r+n),o=new mo(r,s),a=e[r].start;let l=a;for(let t=r;t<s;t++)l=Math.max(l,e[t].end);t.insert(a,l,o)}return t}class mo{constructor(e,t){this.start=e,this.end=t}}const bo=function(e,t,i){if(e&&0!==e.length){const n=function(e){const t=new oo,i=e.length,n=Math.max(10,Math.round(i/100));e.sort((function(e,t){return e.start===t.start?0:e.start>t.start?1:-1}));for(let r=0;r<i;r+=n){const s=Math.min(i,r+n),o=e.slice(r,s),a=o[0].start;let l=a;o.forEach((function(e){l=Math.max(l,e.end)})),t.insert(a,l,o)}return t}(e),r=n.findOverlapping(t,i);return 0===r.length?[]:(e=[],r.forEach((function(n){const r=n.value,s=r.length;for(let n=0;n<s;n++){const s=r[n];if(s.start>i)break;s.end>t&&e.push(s)}})),e.sort((function(e,t){return e.start-t.start})),e)}return[]};const wo={cantaloupe:{r:255,g:206,b:110},honeydew:{r:206,g:250,b:110},spindrift:{r:104,g:251,b:208},sky:{r:106,g:207,b:255},lavender:{r:210,g:120,b:255},carnation:{r:255,g:127,b:211},licorice:{r:0,g:0,b:0},snow:{r:255,g:255,b:255},salmon:{r:255,g:114,b:110},banana:{r:255,g:251,b:109},flora:{r:104,g:249,b:110},ice:{r:104,g:253,b:255},orchid:{r:110,g:118,b:255},bubblegum:{r:255,g:122,b:255},lead:{r:30,g:30,b:30},mercury:{r:232,g:232,b:232},tangerine:{r:255,g:136,b:2},lime:{r:131,g:249,b:2},sea_foam:{r:3,g:249,b:135},aqua:{r:0,g:140,b:255},grape:{r:137,g:49,b:255},strawberry:{r:255,g:41,b:135},tungsten:{r:58,g:58,b:58},silver:{r:208,g:208,b:208},maraschino:{r:255,g:33,b:1},lemon:{r:255,g:250,b:3},spring:{r:5,g:248,b:2},turquoise:{r:0,g:253,b:255},blueberry:{r:0,g:46,b:255},magenta:{r:255,g:57,b:255},iron:{r:84,g:84,b:83},magnesium:{r:184,g:184,b:184},mocha:{r:137,g:72,b:0},fern:{r:69,g:132,b:1},moss:{r:1,g:132,b:72},ocean:{r:0,g:74,b:136},eggplant:{r:73,g:26,b:136},maroon:{r:137,g:22,b:72},steel:{r:110,g:110,b:110},aluminum:{r:160,g:159,b:160},cayenne:{r:137,g:17,b:0},aspargus:{r:136,g:133,b:1},clover:{r:2,g:132,b:1},teal:{r:0,g:134,b:136},midnight:{r:0,g:24,b:136},plum:{r:137,g:30,b:136},tin:{r:135,g:134,b:135},nickel:{r:136,g:135,b:135}};const vo={Set1:["rgb(228,26,28)","rgb(55,126,184)","rgb(77,175,74)","rgb(166,86,40)","rgb(152,78,163)","rgb(255,127,0)","rgb(247,129,191)","rgb(153,153,153)","rgb(255,255,51)"],Dark2:["rgb(27,158,119)","rgb(217,95,2)","rgb(117,112,179)","rgb(231,41,138)","rgb(102,166,30)","rgb(230,171,2)","rgb(166,118,29)","rgb(102,102,102)"],Set2:["rgb(102, 194,165)","rgb(252,141,98)","rgb(141,160,203)","rgb(231,138,195)","rgb(166,216,84)","rgb(255,217,47)","rgb(229,196,148)","rgb(179,179,179)"],Set3:["rgb(141,211,199)","rgb(255,255,179)","rgb(190,186,218)","rgb(251,128,114)","rgb(128,177,211)","rgb(253,180,98)","rgb(179,222,105)","rgb(252,205,229)","rgb(217,217,217)","rgb(188,128,189)","rgb(204,235,197)","rgb(255,237,111)"],Pastel1:["rgb(251,180,174)","rgb(179,205,227)","rgb(204,235,197)","rgb(222,203,228)","rgb(254,217,166)","rgb(255,255,204)","rgb(229,216,189)","rgb(253,218,236)"],Pastel2:["rgb(173,226,207)","rgb(253,205,172)","rgb(203,213,232)","rgb(244,202,228)","rgb(230,245,201)","rgb(255,242,174)","rgb(243,225,206)"],Accent:["rgb(127,201,127)","rgb(190,174,212)","rgb(253,192,134)","rgb(255,255,153)","rgb(56,108,176)","rgb(240,2,127)","rgb(191,91,23)"]};class yo{constructor(e){this.colors=vo[e],Array.isArray(this.colors)||(this.colors=[]),this.colorTable={},this.nextIdx=0,this.colorGenerator=new xo}getColor(e){return this.colorTable.hasOwnProperty(e)||(this.nextIdx<this.colors.length?this.colorTable[e]=this.colors[this.nextIdx]:this.colorTable[e]=this.colorGenerator.get(),this.nextIdx++),this.colorTable[e]}}class _o{constructor(e){this.colorTable=e||{},this.nextIdx=0,this.colorGenerator=new xo}getColor(e){if(!this.colorTable.hasOwnProperty(e)){if(this.colorTable.hasOwnProperty("*"))return this.colorTable["*"];this.colorTable[e]=this.colorGenerator.get()}return this.colorTable[e]}}function xo(){this.hue=Math.random(),this.goldenRatio=.618033988749895,this.hexwidth=2}function ko(e,t){e=Ns.clamp(e,0,255),t=Ns.clamp(t,0,255);return`rgb(${Math.round(Math.random()*(t-e)+e).toString(10)},${Math.round(Math.random()*(t-e)+e).toString(10)},${Math.round(Math.random()*(t-e)+e).toString(10)})`}xo.prototype.hsvToRgb=function(e,t,i){var n=Math.floor(6*e),r=6*e-n,s=i*(1-t),o=i*(1-r*t),a=i*(1-(1-r)*t),l=255,h=255,c=255;switch(n){case 0:l=i,h=a,c=s;break;case 1:l=o,h=i,c=s;break;case 2:l=s,h=i,c=a;break;case 3:l=s,h=o,c=i;break;case 4:l=a,h=s,c=i;break;case 5:l=i,h=s,c=o}return[Math.floor(256*l),Math.floor(256*h),Math.floor(256*c)]},xo.prototype.padHex=function(e){return e.length>this.hexwidth?e:new Array(this.hexwidth-e.length+1).join("0")+e},xo.prototype.get=function(e,t){this.hue+=this.goldenRatio,this.hue%=1,"number"!=typeof e&&(e=.5),"number"!=typeof t&&(t=.95);var i=this.hsvToRgb(this.hue,e,t);return"#"+this.padHex(i[0].toString(16))+this.padHex(i[1].toString(16))+this.padHex(i[2].toString(16))},new xo;const Co={configureHighDPICanvas:function(e,t,i){const n=window.devicePixelRatio;e.canvas.style.width=`${t}px`,e.canvas.width=Math.floor(n*t),e.canvas.style.height=`${i}px`,e.canvas.height=Math.floor(n*i),e.scale(n,n)},setProperties:function(e,t){for(var i in t)if(t.hasOwnProperty(i)){var n=t[i];e[i]=n}},strokeLine:function(e,t,i,n,r,s){t=Math.floor(t)+.5,i=Math.floor(i)+.5,n=Math.floor(n)+.5,r=Math.floor(r)+.5,s&&(e.save(),Co.setProperties(e,s)),e.beginPath(),e.moveTo(t,i),e.lineTo(n,r),e.stroke(),s&&e.restore()},fillRect:function(e,t,i,n,r,s){t=Math.round(t),i=Math.round(i),s&&(e.save(),Co.setProperties(e,s)),e.fillRect(t,i,n,r),s&&e.restore()},fillPolygon:function(e,t,i,n){n&&(e.save(),Co.setProperties(e,n)),So(e,t,i),e.fill(),n&&e.restore()},strokePolygon:function(e,t,i,n){n&&(e.save(),Co.setProperties(e,n)),So(e,t,i),e.stroke(),n&&e.restore()},fillText:function(e,t,i,n,r,s){if((r||s)&&e.save(),r&&Co.setProperties(e,r),s){for(var o in e.translate(i,n),s){var a=s[o];"translate"===o&&e.translate(a.x,a.y),"rotate"===o&&e.rotate(a.angle*Math.PI/180)}e.fillText(t,0,0)}else e.fillText(t,i,n);(r||s)&&e.restore()},strokeText:function(e,t,i,n,r,s){if((r||s)&&e.save(),r&&Co.setProperties(e,r),s){for(var o in e.translate(i,n),s){var a=s[o];"translate"===o&&e.translate(a.x,a.y),"rotate"===o&&e.rotate(a.angle*Math.PI/180)}e.strokeText(t,0,0)}else e.strokeText(t,i,n);(r||s)&&e.restore()},strokeCircle:function(e,t,i,n,r){r&&(e.save(),Co.setProperties(e,r)),e.beginPath(),e.arc(t,i,n,0,2*Math.PI),e.stroke(),r&&e.restore()},fillCircle:function(e,t,i,n,r){r&&(e.save(),Co.setProperties(e,r)),e.beginPath(),e.arc(t,i,n,0,2*Math.PI),e.fill(),r&&e.restore()},drawArrowhead:function(e,t,i,n,r){e.save(),n||(n=5),r&&(e.lineWidth=r),e.beginPath(),e.moveTo(t,i-n/2),e.lineTo(t,i+n/2),e.lineTo(t+n,i),e.lineTo(t,i-n/2),e.closePath(),e.fill(),e.restore()},dashedLine:function(e,t,i,n,r,s,o={}){void 0===s&&(s=2),e.setLineDash([s,s]),Co.strokeLine(e,t,i,n,r,o),e.setLineDash([])},roundRect:function(e,t,i,n,r,s,o,a){void 0===a&&(a=!0),void 0===s&&(s=5),e.beginPath(),e.moveTo(t+s,i),e.lineTo(t+n-s,i),e.quadraticCurveTo(t+n,i,t+n,i+s),e.lineTo(t+n,i+r-s),e.quadraticCurveTo(t+n,i+r,t+n-s,i+r),e.lineTo(t+s,i+r),e.quadraticCurveTo(t,i+r,t,i+r-s),e.lineTo(t,i+s),e.quadraticCurveTo(t,i,t+s,i),e.closePath(),a&&e.stroke(),o&&e.fill()},polygon:function(e,t,i,n,r){void 0===r&&(r=!0),e.beginPath();var s=t.length;e.moveTo(t[0],i[0]);for(var o=1;o<s;o++)e.lineTo(t[o],i[o]);e.closePath(),r&&e.stroke(),n&&e.fill()},drawRandomColorVerticalLines:e=>{for(let t=0;t<e.canvas.width;t++)Co.fillRect(e,t,0,1,e.canvas.height,{fillStyle:ko(100,250)})},labelTransformWithContext:(e,t)=>{e.translate(t,0),e.scale(-1,1),e.translate(-t,0)}};function So(e,t,i){var n,r=t.length;for(n=0;n<r;n++)t[n]=Math.round(t[n]),i[n]=Math.round(i[n]);for(e.beginPath(),e.moveTo(t[0],i[0]),n=1;n<r;n++)e.lineTo(t[n],i[n]);e.closePath()}class Ao{constructor(e){this.dialog=new Ft(e)}present(e,t){this.dialog.present(e,t)}}const Eo={gwascatalog:{fields:["bin","chr","start","end","name","pubMedID","author","pubDate","journal","title","trait","initSample","replSample","region","genes","riskAllele","riskAlFreq","pValue","pValueDesc","orOrBeta","ci95","platform","cnv"]},wgrna:{fields:["bin","chr","start","end","name","score","strand","thickStart","thickEnd","type"]},cpgislandext:{fields:["bin","chr","start","end","name","length","cpgNum","gcNum","perCpg","perGc","obsExp"]},clinVarMain:{fields:["chr1","start","end","name","score","strand","thickStart","thickEnd","reserved","blockCount","blockSizes","chromStarts","origName","clinSign","reviewStatus","type","geneId","snpId","nsvId","rcvAcc","testedInGtr","phenotypeList","phenotype","origin","assembly","cytogenetic","hgvsCod","hgvsProt","numSubmit","lastEval","guidelines","otherIds"]}};function Mo(e){const t=new Set(["boolean","number","string","symbol"]),i=typeof e;return void 0!==e&&(t.has(i)||e.substring||e.toFixed)}function To(e,t){var i={oauthToken:e.oauthToken,headers:e.headers,withCredentials:e.withCredentials,filename:e.filename};return Object.assign(i,t)}const Ro=function(e){var t,i;if(e&&e.length>0){t=Number.MAX_VALUE,i=-Number.MAX_VALUE;for(let n of e)Number.isNaN(n.value)||(t=Math.min(t,n.value),i=Math.max(i,n.value));i>0&&(t=Math.min(0,t)),i<0&&(i=0)}else t=0,i=100;return{min:t,max:i}},Lo=function(e,t,i){let n=t.start,r=t.end;if(void 0===r)n-=i/2,r=n+i,r>e?(r=e,n=r-i):n<0&&(n=0,r=i);else if(r-n<i){const t=(r+n)/2;t-i/2<0?(n=0,r=n+i):t+i/2>e?(r=e,n=r-i):(n=t-i/2,r=n+i)}t.start=Math.ceil(n),t.end=Math.floor(r)};async function Io(e){if(Qt(e)&&e.startsWith("https://drive.google.com")){if(void 0===Xs())throw Error("Google drive is referenced, but API key is not defined. An API key is required for Google Drive access");const t=await async function(e){let t="https://www.googleapis.com/drive/v3/files/"+Ks(e)+"?supportsTeamDrives=true";const i=Xs();i&&(t+="&key="+i);const n=await fetch(t);let r=await n.json();if(r.error&&404===r.error.code){let e="https://www.googleapis.com/auth/drive.readonly";const i=await Qs(e);if(!i)throw Error(r.error);{const e=await fetch(t,{headers:{Authorization:`Bearer ${i}`}});if(r=await e.json(),r.error)throw Error(r.error)}}return r}(e);return t.originalFileName||t.name}return ei(e)}function Bo(e){var t,i;return e>1e7?(t=" mb",i=e/1e6,Math.floor(i).toString()+t):e>1e4?(t=" kb",i=e/1e3,Xt(Math.floor(i))+t):Xt(e)+" bp"}function Fo(e){return Qt(e)&&e.startsWith("data:")}function No(e,t){const i=_t.div({class:t});e.appendChild(i)}function Oo(e,t){t.parentNode.insertBefore(e,t)}function Po(e,t){t.parentNode.insertBefore(e,t.nextSibling)}function Do(){return"https:"===window.location.protocol||"localhost"===window.location.hostname}function zo(e,t){if(e.length<6)return void console.log("Skipping line: "+e.join(" "));var i={chr1:e[0],start1:Number.parseInt(e[1]),end1:Number.parseInt(e[2]),chr2:e[3],start2:Number.parseInt(e[4]),end2:Number.parseInt(e[5])};if(isNaN(i.start1)||isNaN(i.end1)||isNaN(i.start2)||isNaN(i.end2))return;t&&void 0===t.hiccups&&(t.hiccups=!!t.columnNames&&Vo(t.columnNames));const n=t&&t.hiccups,r=n?6:10;if(n||(e.length>6&&"."!==e[6]&&(i.name=e[6]),e.length>7&&"."!==e[7]&&(i.score=Number(e[7])),e.length>8&&"."!==e[8]&&(i.strand1=e[8]),e.length>9&&"."!==e[9]&&(i.strand2=e[9])),t){const n=t.colorColumn;n&&n<e.length&&(i.color=Ds.createColorString(e[n]));const s=t.thicknessColumn;s&&s<e.length&&(i.thickness=e[s]),e.length>r&&t.columnNames&&t.columnNames.length===e.length&&(i.extras=e.slice(r))}return i.chr1===i.chr2&&(i.chr=i.chr1,i.start=Math.min(i.start1,i.start2),i.end=Math.max(i.end1,i.end2)),i}function Ho(e,t){if(!(e.length<8))return{chr:e[0],start:Number.parseInt(e[1]),end:Number.parseInt(e[2]),color:Ds.createColorString(e[6]),value:Number(e[7])}}function Vo(e){return e&&(e.includes("fdrDonut")||e.includes("fdr_donut"))}const Uo=new Set(["narrowpeak","broadpeak","regionpeak","peaks","bedgraph","wig","gff3","gff","gtf","fusionjuncspan","refflat","seg","aed","bed","vcf","bb","bigbed","biginteract","biggenepred","bignarrowpeak","bw","bigwig","bam","tdf","refgene","genepred","genepredext","bedpe","bp","snp","rmsk","cram","gwas","maf","mut","tsv","hiccups","fasta","fa","fna","pytor"]);function qo(e){return Eo&&Eo[e]?function(e){const t=e.fields,i=["chr","start","end"];for(let n=0;n<t.length;n++)for(let r of i)r===t[n]&&(e[r]=n);return e}(Eo[e]):void 0}function jo(e){var t,i;if((e=e.toLowerCase()).endsWith("refgene.txt.gz")||e.endsWith("refgene.txt.bgz")||e.endsWith("refgene.txt")||e.endsWith("refgene.sorted.txt.gz")||e.endsWith("refgene.sorted.txt.bgz"))return"refgene";switch((t=e.indexOf("?"))>0&&(e=e.substr(0,t)),e.endsWith(".gz")&&(e=e.substr(0,e.length-3)),(e.endsWith(".txt")||e.endsWith(".tab")||e.endsWith(".bgz"))&&(e=e.substr(0,e.length-4)),i=(t=e.lastIndexOf("."))<0?e:e.substr(t+1)){case"bw":return"bigwig";case"bb":return"bigbed";case"fasta":case"fa":case"fna":return"fasta";default:return Uo.has(i)?i:void 0}}function $o(e,t){if(Qt(e)){if(e.includes("?")){const i=e.indexOf("?");return e.substring(0,i)+"."+t+e.substring(i)}return e+"."+t}}function Wo(e){if(function(e){e.featureType&&(e.type=e.type||e.featureType,e.featureType=void 0);"junctions"===e.type?e.type="junction":"bed"===e.type?(e.type="annotation",e.format=e.format||"bed"):"annotations"===e.type?e.type="annotation":"alignments"===e.type?e.type="alignment":"bam"===e.type?(e.type="alignment",e.format="bam"):"vcf"===e.type?(e.type="variant",e.format="vcf"):"t2d"===e.type?e.type="gwas":"FusionJuncSpan"!==e.type||e.format?"aed"===e.type&&(e.type="annotation",e.format=e.format||"aed"):e.format="fusionjuncspan"}(e),e.type)return e.type;if(e.format){switch(e.format.toLowerCase()){case"bw":case"bigwig":case"wig":case"bedgraph":case"tdf":return"wig";case"vcf":return"variant";case"seg":return"seg";case"mut":case"maf":return"mut";case"bam":case"cram":return"alignment";case"hiccups":case"bedpe":case"bedpe-loop":case"biginteract":return"interact";case"bp":return"arc";case"gwas":return"gwas";case"bed":case"bigbed":case"bb":case"biggenepred":case"bignarrowpeak":return"bedtype";case"fasta":return"sequence";case"pytor":return"cnvpytor";default:return"annotation"}}}async function Go(e){if(e.url){const t=await no.loadString(e.url,To(e,{range:{start:0,size:1e3}}));if(t){if(Vo(t.split("\n")[0].split("\t")))return"hiccups"}}}var Zo=Object.freeze({__proto__:null,knownFileExtensions:Uo,getFormat:qo,inferFileFormat:jo,inferFileFormatFromHeader:Go,inferTrackType:Wo,inferIndexPath:$o});const Qo=[["A","T"],["G","C"],["Y","R"],["W","S"],["K","M"],["D","H"],["B","V"]],Xo=new Map;for(let jb of Qo){const $b=jb[0],Wb=jb[1];Xo.set($b,Wb),Xo.set(Wb,$b),Xo.set($b.toLowerCase(),Wb.toLowerCase()),Xo.set(Wb.toLowerCase(),$b.toLowerCase())}function Yo(e){let t="",i=e.length;for(;i-- >0;){const n=e[i];t+=Xo.has(n)?Xo.get(n):n}return t}class Ko{constructor(e,t,i){this.name=e,this.order=t,this.bpLength=i}}const Jo=Yt,ea=new Set(["fastaURL","indexURL","cytobandURL","indexed"]);class ta{constructor(e){this.fastaURL=e.fastaURL,this.withCredentials=e.withCredentials,this.chromosomeNames=[],this.chromosomes={},this.sequences=new Map;const t={};for(let i in e)e.hasOwnProperty(i)&&!ea.has(i)&&(t[i]=e[i]);this.config=t}async init(){return this.loadAll()}async getSequence(e,t,i){if(!this.sequences.has(e))return;let n=this.sequences.get(e).find((e=>e.contains(t,i)));if(!n&&(n=this.sequences.get(e).find((e=>e.overlaps(t,i))),!n))return;t-=n.offset,i-=n.offset;let r="";if(t<0)for(let e=t;e<Math.min(i,0);e++)r+="*";if(i<=0)return Promise.resolve(r);const s=n.sequence,o=Math.min(i,s.length);return r+s.substring(t,o)}async loadAll(){let e;if(Fo(this.fastaURL)){let t=Fs(this.fastaURL);e="";for(let i of t)e+=String.fromCharCode(i)}else e=await no.load(this.fastaURL,To(this.config));const t=new Set,i=Jo(e),n=i.length;let r,s=0,o=0,a={};for(;s<n;){if(r=i[s++].trim(),r.startsWith("#")||0===r.length);else if(r.startsWith(">")){a&&a.seq&&l.call(this,a,o++);const e=r.substr(1).split(/\s+/),t=e[0].split(":");if(a.chr=t[0],a.seq="",a.offset=0,t.length>1&&t[1].indexOf("-")>0){const i=t[1].split("-");2===i.length&&/^[0-9]+$/.test(i[0])&&/^[0-9]+$/.test(i[1]);const n=Number.parseInt(i[0]);if(Number.parseInt(i[1])>n&&(a.offset=n-1),e.length>1&&e[1].startsWith("@len="))try{a.length=parseInt(e[1].trim().substring(5))}catch(e){a.length=void 0,console.error(`Error parsing sequence length for ${r}`)}else a.length=void 0}}else a.seq+=r;a&&a.seq&&l.call(this,a,o)}function l(e,i){const n=e.length||e.offset+e.seq.length;if(t.has(e.chr)){const t=this.chromosomes[e.chr];t.bpLength=Math.max(t.bpLength,n)}else this.chromosomeNames.push(e.chr),this.sequences.set(e.chr,[]),this.chromosomes[e.chr]=new Ko(e.chr,i,n),t.add(e.chr);this.sequences.get(e.chr).push(new ia(e.offset,e.seq))}}}class ia{constructor(e,t){this.offset=e,this.sequence=t}contains(e,t){return this.offset<=e&&this.end>=t}overlaps(e,t){return this.offset<t&&this.end>e}get end(){return this.offset+this.sequence.length}}const na=function(e,t,i,n){this.chr=e,this.start=t,this.end=i,this.features=n};na.prototype.contains=function(e,t,i){return this.chr===e&&this.start<=t&&this.end>=i},na.prototype.containsRange=function(e){return this.chr===e.chr&&this.start<=e.start&&this.end>=e.end};const ra=Yt,sa=new Set(["fastaURL","indexURL","compressedIndexURL","cytobandURL","indexed"]);class oa{constructor(e){this.file=e.fastaURL,this.indexFile=e.indexURL||e.indexFile||this.file+".fai",this.compressedIndexFile=e.compressedIndexURL||!1,this.withCredentials=e.withCredentials,this.chromosomeNames=[],this.chromosomes={},this.sequences={},this.offsets={};const t={};for(let i in e)e.hasOwnProperty(i)&&!sa.has(i)&&(t[i]=e[i]);this.config=t}async init(){return this.getIndex()}async getSequence(e,t,i){if(!(this.interval&&this.interval.contains(e,t,i))){let n=t,r=i;if(i-t<5e4){const e=i-t,s=Math.round(t+e/2);n=Math.max(0,s-25e3),r=s+25e3}const s=await this.readSequence(e,n,r);this.interval=new na(e,n,r,s)}const n=t-this.interval.start,r=i-t;return this.interval.features?this.interval.features.substr(n,r):null}async getIndex(){if(this.index)return this.index;{const e=await no.load(this.indexFile,To(this.config)),t=ra(e),i=t.length;let n=0,r=0;for(this.index={};n<i;){const e=t[n++].split("\t");if(5===e.length){const t=e[0],i=parseInt(e[1]),n={size:i,position:parseInt(e[2]),basesPerLine:parseInt(e[3]),bytesPerLine:parseInt(e[4])};this.chromosomeNames.push(t),this.index[t]=n,this.chromosomes[t]=new Ko(t,r++,i)}}return this.index}}async getCompressedIndex(){if(this.compressedIndex)return this.compressedIndex;if(!this.compressedIndexFile)return this.compressedIndex=[],this.compressedIndex;this.compressedIndex=[];const e=await no.loadArrayBuffer(this.compressedIndexFile,To(this.config)),t=e.byteLength;if(t<8)return console.log("Cannot parse GZI index file: length ("+t+" bytes) is insufficient to determine content of index."),this.compressedIndex;const i=e.slice(0,8),n=Number(new DataView(i).getBigUint64(0,!0)),r=8+2*n*8;if(t!=r)return console.log("Incorrect file size of reference genome index. Expected : "+r+". Received : "+t),this.compressedIndex;this.compressedIndex.push([0,0]);for(let t=0;t<n;t++){const i=8+2*t*8,n=8+2*t*8+16,r=e.slice(i,n),s=new DataView(r),o=Number(s.getBigUint64(0,!0)),a=Number(s.getBigUint64(8,!0));this.compressedIndex.push([o,a])}return this.compressedIndex}async getRelevantCompressedBlockNumbers(e,t){if(e<0||t<0||t<e)return console.log("Incompatible query positions for reference-genome. Start:"+e+" | End:"+t),[];await this.getCompressedIndex();let i=[];const n=this.compressedIndex.length-1;if(0==this.compressedIndex.length)return console.log("Compressed index does not contain any content"),[];if(e>this.compressedIndex[n][1])return[n];let r=0,s=n,o=Math.floor(this.compressedIndex.length/2),a=this.compressedIndex.length+1,l=!1;for(let t=0;t<a;t++){const t=this.compressedIndex[o][1],i=o<this.compressedIndex.length-1?this.compressedIndex[o+1][1]:1/0;if(t<=e&&i>e){l=!0;break}t<e?r=o+1:s=o-1,o=Math.ceil((s-r)/2)+r}if(!l)return console.log("No blocks within compressed index found that correspond with query positions "+e+","+t),console.log(this.compressedIndex),[];i.push(o);for(let e=o+1;e<this.compressedIndex.length;e++){i.push(e);if(this.compressedIndex[e][1]>=t)break}const h=i[i.length-1];return h===this.compressedIndex.length-1&&this.compressedIndex[h][1]<t&&i.push(-1),i}async loadAndUncompressBlocks(e,t){if(await this.getCompressedIndex(),0==e.length)return"";let i=Array(e.length-1);for(let t=0;t<e.length-1;t++){const n=e[t],r=this.compressedIndex[n][0],s=e[t+1];let o=[];if(-1!=s){const e=this.compressedIndex[s][0]-r;o=await no.loadArrayBuffer(this.file,To(this.config,{range:{start:r,size:e}}))}else o=await no.loadArrayBuffer(this.file,To(this.config,{range:{start:r}}));const a=await Ts(o);i[t]=a}let n="";for(let e=0;e<i.length;e++)for(let t=0;t<i[e].length;t++){n+=String.fromCharCode(i[e][t])}const r=t-this.compressedIndex[e[0]][1];return n=n.substring(r),n}async readSequence(e,t,i){await this.getIndex(),await this.getCompressedIndex();const n=this.index[e];if(!n)return console.log("No index entry for chr: "+e),this.interval=new na(e,t,i,null),null;const r=Math.max(0,t),s=Math.min(n.size,i),o=n.bytesPerLine,a=n.basesPerLine,l=n.position,h=o-a,c=Math.floor(r/a),d=Math.floor(s/a),u=r-c*a,f=l+c*o+u,p=l+d*o+(s-d*a)-1,g=p-f+1;if(g<=0)return console.error("No sequence for "+e+":"+t+"-"+i),null;let m;if(this.compressedIndexFile){let e=await this.getRelevantCompressedBlockNumbers(f,p);if(0===e.length)return console.log("No blocks in the compressed index that correspond with the requested byte positions ("+f+","+p+")"),null;m=await this.loadAndUncompressBlocks(e,f)}else m=await no.load(this.file,To(this.config,{range:{start:f,size:g}}));if(!m)return null;let b,w="",v=0,y=m.length;for(u>0&&(b=Math.min(s-r,a-u),w+=m.substr(v,b),v+=b+h);v<y;)b=Math.min(a,y-v),w+=m.substr(v,b),v+=b+h;return w}}const aa=Yt;class la{constructor(e){this.url=e,this.chromosomeNames=[],this.chromosomes={}}async init(){return this.loadAll()}async getSequence(e,t,i){}async loadAll(){let e;if(Fo(this.url)){let t=Fs(this.fastaURL);e="";for(let i of t)e+=String.fromCharCode(i)}else e=await no.load(this.url,{});this.chromosomeNames=[],this.chromosomes={};const t=aa(e);let i=0;for(let e of t){const t=e.split("\t");this.chromosomeNames.push(t[0]);const n=Number.parseInt(t[1]),r=new Ko(t[0],i++,n);this.chromosomes[t[0]]=r}}}async function ha(e){let t;return t="chromsizes"===e.format?new la(e.fastaURL):Fo(e.fastaURL)||!1===e.indexed?new ta(e):new oa(e),await t.init(),t}const ca={A:"rgb( 0, 200, 0)",C:"rgb( 0,0,200)",T:"rgb(255,0,0)",G:"rgb(209,113, 5)",N:"rgb(80,80,80)"},da=Number.MIN_SAFE_INTEGER,ua={TTT:"F",TTC:"F",TTA:"L",TTG:"L",CTT:"L",CTC:"L",CTA:"L",CTG:"L",ATT:"I",ATC:"I",ATA:"I",ATG:"M",GTT:"V",GTC:"V",GTA:"V",GTG:"V",TCT:"S",TCC:"S",TCA:"S",TCG:"S",CCT:"P",CCC:"P",CCA:"P",CCG:"P",ACT:"T",ACC:"T",ACA:"T",ACG:"T",GCT:"A",GCC:"A",GCA:"A",GCG:"A",TAT:"Y",TAC:"Y",TAA:"STOP",TAG:"STOP",CAT:"H",CAC:"H",CAA:"Q",CAG:"Q",AAT:"N",AAC:"N",AAA:"K",AAG:"K",GAT:"D",GAC:"D",GAA:"E",GAG:"E",TGT:"C",TGC:"C",TGA:"STOP",TGG:"W",CGT:"R",CGC:"R",CGA:"R",CGG:"R",AGT:"S",AGC:"S",AGA:"R",AGG:"R",GGT:"G",GGC:"G",GGA:"G",GGG:"G"},fa={},pa=["A","G","C","T","Y","R","W","S","K","M","D","V","H","B","N","X"],ga=["T","C","G","A","R","Y","W","S","M","K","H","B","D","V","N","X"];for(let Gb=0;Gb<pa.length;Gb++)fa[pa[Gb]]=ga[Gb],fa[pa[Gb].toLowerCase()]=ga[Gb].toLowerCase();const ma=115;class ba{constructor(e,t){this.config=e,this.browser=t,this.type="sequence",this.removable=void 0===e.removable||e.removable,this.name=e.name,this.id=e.id,this.sequenceType=e.sequenceType||"dna",this.disableButtons=!1,this.order=e.order||da,this.ignoreTrackMenu=!1,this.reversed=!0===e.reversed,this.frameTranslate=!0===e.frameTranslate,this.height=this.frameTranslate?ma:25,e.url&&(e.fastaURL=e.url),e.fastaURL||(this.id=e.id||"sequence")}menuItemList(){return[{name:this.reversed?"Forward":"Reverse",click:()=>{this.reversed=!this.reversed,this.trackView.repaintViews()}},{name:this.frameTranslate?"Close Translation":"Three-frame Translate",click:()=>{if(this.frameTranslate=!this.frameTranslate,this.frameTranslate){for(let e of this.trackView.viewports)e.setContentHeight(ma);this.trackView.setTrackHeight(ma)}else{for(let e of this.trackView.viewports)e.setContentHeight(25);this.trackView.setTrackHeight(25)}this.trackView.repaintViews()}}]}contextMenuItemList(e){const t=e.viewport;if(t.referenceFrame.bpPerPixel<=1){const e=t.getWidth()*t.referenceFrame.bpPerPixel,i=t.referenceFrame.chr,n=Math.floor(t.referenceFrame.start),r=Math.ceil(n+e),s=[{label:this.reversed?"View visible sequence (reversed)...":"View visible sequence...",click:async()=>{let e=await this.browser.genome.sequence.getSequence(i,n,r);e?this.reversed&&(e=Yo(e)):e="Unknown sequence",this.browser.alert.present(e)}}];return Do()&&s.push({label:"Copy visible sequence",click:async()=>{let e=await this.browser.genome.sequence.getSequence(i,n,r);e?this.reversed&&(e=Yo(e)):e="Unknown sequence";try{await navigator.clipboard.writeText(e)}catch(e){console.error(e),this.browser.alert.present(`error copying sequence to clipboard ${e}`)}}}),s.push("<hr/>"),s}}translateSequence(e){const t=[[],[],[]];for(let i of[0,1,2]){let n=i;for(;e.length-n>=3;){let r=e.slice(n,n+3);this.reversed&&(r=r.split("").reverse().join(""));const s=ua[r.toUpperCase()]||"";t[i].push({codons:r,aminoA:s}),n+=3}}return t}async getSequenceSource(){return this.config.fastaURL?(this.fasta||(this.fasta=new wa(this.config,this.browser.genome),await this.fasta.init()),this.fasta):this.browser.genome.sequence}async getFeatures(e,t,i,n){if(t=Math.floor(t),i=Math.floor(i),n&&n>10)return null;{const n=await this.getSequenceSource();return{bpStart:t,sequence:await n.getSequence(e,t,i)}}}draw(e){const t=e.context;if(e.features){let i=e.features.sequence;if(!i)return;this.reversed&&(i=i.split("").map((function(e){return fa[e]})).join(""));const n=e.features.bpStart,r=1+e.bpStart+e.pixelWidth*e.bpPerPixel;for(let s=Math.floor(e.bpStart);s<=r;s++){const r=Math.floor(s-n);if(r>=0&&r<i.length){const n=(s-e.bpStart)/e.bpPerPixel,o=1/e.bpPerPixel,a=i[r],l=this.fillColor(a.toUpperCase());if(e.bpPerPixel>.1)Co.fillRect(t,n,5,o,10,{fillStyle:l});else{const i=n+.5*(o-t.measureText(a).width);"y"===e.axis?(t.save(),Co.labelTransformWithContext(t,i),Co.strokeText(t,a,i,15,{strokeStyle:l}),t.restore()):Co.strokeText(t,a,i,15,{strokeStyle:l})}}}if(this.frameTranslate){let r=25;const s=this.translateSequence(i);for(let i=0;i<s.length;i++){const o=s[i];for(let s=0;s<o.length;s++){let a=0==s%2?"rgb(160,160,160)":"rgb(224,224,224)";const l=o[s],h=n+i+3*s-e.bpStart,c=Math.floor(h/e.bpPerPixel),d=Math.floor((h+3)/e.bpPerPixel),u=Math.round((c+d)/2);if(d<0)continue;if(c>e.pixelWidth)break;let f=l.aminoA;l.aminoA.indexOf("STOP")>-1?(a="rgb(255, 0, 0)",f="STOP"):"M"===l.aminoA&&(a="rgb(0, 153, 0)",f="START"),Co.fillRect(t,c,r,d-c,25,{fillStyle:a}),e.bpPerPixel<=.1&&Co.strokeText(t,f,u-t.measureText(f).width/2,r+15)}r+=30}}}}get supportsWholeGenome(){return!1}computePixelHeight(e){return this.height=this.frameTranslate?ma:25,this.height}fillColor(e){return this.color?this.color:"dna"===this.sequenceType?ca[e]||"gray":"rgb(0, 0, 150)"}getState(){const e={type:"sequence"};return this.order!==da&&(e.order=this.order),this.reversed&&(e.revealed=!0),e}}class wa{constructor(e,t){this.config=e,this.genome=t}async init(){this.fasta=await ha(this.config),this.chrNameMap=new Map;for(let e of this.fasta.chromosomeNames)this.chrNameMap.set(this.genome.getChromosomeName(e),e)}async getSequence(e,t,i){const n=this.chrNameMap.has(e)?this.chrNameMap.get(e):e;return this.fasta.getSequence(n,t,i)}}class va{constructor(e,t,i,n){this.guid=_t.guid(),this.trackView=e,this.referenceFrame=i,this.browser=e.browser,this.$viewport=ft('<div class="igv-viewport">'),t.appendChild(this.$viewport.get(0)),e.track.height&&(this.$viewport.get(0).style.height=`${e.track.height}px`),e.track instanceof ba&&(this.alert=new Ft(this.$viewport.get(0))),this.contentTop=0,this.contentHeight=this.$viewport.height(),this.$viewport.width(n),this.initializationHelper()}initializationHelper(){}showMessage(e){this.messageDiv||(this.messageDiv=document.createElement("div"),this.messageDiv.className="igv-viewport-message",this.$viewport.append(ft(this.messageDiv))),this.messageDiv.textContent=e,this.messageDiv.style.display="inline-block"}hideMessage(e){this.messageDiv&&(this.messageDiv.style.display="none")}setTrackLabel(e){}startSpinner(){}stopSpinner(){}checkZoomIn(){return!0}shift(){}setTop(e){this.contentTop=e,this.$viewport.height()}async loadFeatures(){}clearCache(){}async repaint(){}draw(e,t,i){console.log("Viewport - draw(drawConfiguration, features, roiFeatures)")}checkContentHeight(e){let t=this.trackView.track;if(e=e||this.cachedFeatures,"FILL"===t.displayMode)this.setContentHeight(this.$viewport.height());else if("function"==typeof t.computePixelHeight&&e&&e.length>0){let i=t.computePixelHeight(e);i!==this.contentHeight&&this.setContentHeight(i)}}getContentHeight(){return this.contentHeight}setContentHeight(e){this.contentHeight=e}isLoading(){return!1}saveSVG(){}isVisible(){return this.$viewport.width()}setWidth(e){this.$viewport.width(e)}getWidth(){return this.$viewport.width()}getContentTop(){return this.contentTop}containsPosition(e,t){console.log("Viewport - containsPosition(chr, position)")}addMouseHandlers(){}removeMouseHandlers(){}dispose(){this.popover&&this.popover.dispose(),this.$viewport.get(0).remove();for(let e of Object.keys(this))this[e]=void 0}}
/*!!
* Canvas 2 Svg v1.0.19
* A low level canvas to SVG converter. Uses a mock canvas context to build an SVG document.
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
* Author:
* Kerry Liu
*
* Copyright (c) 2014 Gliffy Inc.
*/function ya(e,t){var i,n=Object.keys(t);for(i=0;i<n.length;i++)e=e.replace(new RegExp("\\{"+n[i]+"\\}","gi"),t[n[i]]);return e}function _a(e){var t,i,n;if(!e)throw new Error("cannot create a random attribute name for an undefined object");t="ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",i="";do{for(i="",n=0;n<12;n++)i+=t[Math.floor(51*Math.random())]}while(e[i]);return i}function xa(e){var t={alphabetic:"alphabetic",hanging:"hanging",top:"text-before-edge",bottom:"text-after-edge",middle:"central"};return t[e]||t.alphabetic}function ka(e){var t=Math.sqrt(e[0]*e[0]+e[1]*e[1]);return[e[0]/t,e[1]/t]}const Ca=function(e,t){var i,n,r,s={};for(e=e.split(","),t=t||10,i=0;i<e.length;i+=2)n="&"+e[i+1]+";",r=parseInt(e[i],t),s[n]="&#"+r+";";return s["\\xa0"]=" ",s}("50,nbsp,51,iexcl,52,cent,53,pound,54,curren,55,yen,56,brvbar,57,sect,58,uml,59,copy,5a,ordf,5b,laquo,5c,not,5d,shy,5e,reg,5f,macr,5g,deg,5h,plusmn,5i,sup2,5j,sup3,5k,acute,5l,micro,5m,para,5n,middot,5o,cedil,5p,sup1,5q,ordm,5r,raquo,5s,frac14,5t,frac12,5u,frac34,5v,iquest,60,Agrave,61,Aacute,62,Acirc,63,Atilde,64,Auml,65,Aring,66,AElig,67,Ccedil,68,Egrave,69,Eacute,6a,Ecirc,6b,Euml,6c,Igrave,6d,Iacute,6e,Icirc,6f,Iuml,6g,ETH,6h,Ntilde,6i,Ograve,6j,Oacute,6k,Ocirc,6l,Otilde,6m,Ouml,6n,times,6o,Oslash,6p,Ugrave,6q,Uacute,6r,Ucirc,6s,Uuml,6t,Yacute,6u,THORN,6v,szlig,70,agrave,71,aacute,72,acirc,73,atilde,74,auml,75,aring,76,aelig,77,ccedil,78,egrave,79,eacute,7a,ecirc,7b,euml,7c,igrave,7d,iacute,7e,icirc,7f,iuml,7g,eth,7h,ntilde,7i,ograve,7j,oacute,7k,ocirc,7l,otilde,7m,ouml,7n,divide,7o,oslash,7p,ugrave,7q,uacute,7r,ucirc,7s,uuml,7t,yacute,7u,thorn,7v,yuml,ci,fnof,sh,Alpha,si,Beta,sj,Gamma,sk,Delta,sl,Epsilon,sm,Zeta,sn,Eta,so,Theta,sp,Iota,sq,Kappa,sr,Lambda,ss,Mu,st,Nu,su,Xi,sv,Omicron,t0,Pi,t1,Rho,t3,Sigma,t4,Tau,t5,Upsilon,t6,Phi,t7,Chi,t8,Psi,t9,Omega,th,alpha,ti,beta,tj,gamma,tk,delta,tl,epsilon,tm,zeta,tn,eta,to,theta,tp,iota,tq,kappa,tr,lambda,ts,mu,tt,nu,tu,xi,tv,omicron,u0,pi,u1,rho,u2,sigmaf,u3,sigma,u4,tau,u5,upsilon,u6,phi,u7,chi,u8,psi,u9,omega,uh,thetasym,ui,upsih,um,piv,812,bull,816,hellip,81i,prime,81j,Prime,81u,oline,824,frasl,88o,weierp,88h,image,88s,real,892,trade,89l,alefsym,8cg,larr,8ch,uarr,8ci,rarr,8cj,darr,8ck,harr,8dl,crarr,8eg,lArr,8eh,uArr,8ei,rArr,8ej,dArr,8ek,hArr,8g0,forall,8g2,part,8g3,exist,8g5,empty,8g7,nabla,8g8,isin,8g9,notin,8gb,ni,8gf,prod,8gh,sum,8gi,minus,8gn,lowast,8gq,radic,8gt,prop,8gu,infin,8h0,ang,8h7,and,8h8,or,8h9,cap,8ha,cup,8hb,int,8hk,there4,8hs,sim,8i5,cong,8i8,asymp,8j0,ne,8j1,equiv,8j4,le,8j5,ge,8k2,sub,8k3,sup,8k4,nsub,8k6,sube,8k7,supe,8kl,oplus,8kn,otimes,8l5,perp,8m5,sdot,8o8,lceil,8o9,rceil,8oa,lfloor,8ob,rfloor,8p9,lang,8pa,rang,9ea,loz,9j0,spades,9j3,clubs,9j5,hearts,9j6,diams,ai,OElig,aj,oelig,b0,Scaron,b1,scaron,bo,Yuml,m6,circ,ms,tilde,802,ensp,803,emsp,809,thinsp,80c,zwnj,80d,zwj,80e,lrm,80f,rlm,80j,ndash,80k,mdash,80o,lsquo,80p,rsquo,80q,sbquo,80s,ldquo,80t,rdquo,80u,bdquo,810,dagger,811,Dagger,81g,permil,81p,lsaquo,81q,rsaquo,85c,euro",32),Sa={strokeStyle:{svgAttr:"stroke",canvas:"#000000",svg:"none",apply:"stroke"},fillStyle:{svgAttr:"fill",canvas:"#000000",svg:null,apply:"fill"},lineCap:{svgAttr:"stroke-linecap",canvas:"butt",svg:"butt",apply:"stroke"},lineJoin:{svgAttr:"stroke-linejoin",canvas:"miter",svg:"miter",apply:"stroke"},miterLimit:{svgAttr:"stroke-miterlimit",canvas:10,svg:4,apply:"stroke"},lineWidth:{svgAttr:"stroke-width",canvas:1,svg:1,apply:"stroke"},globalAlpha:{svgAttr:"opacity",canvas:1,svg:1,apply:"fill stroke"},font:{canvas:"10px sans-serif"},shadowColor:{canvas:"#000000"},shadowOffsetX:{canvas:0},shadowOffsetY:{canvas:0},shadowBlur:{canvas:0},textAlign:{canvas:"start"},textBaseline:{canvas:"alphabetic"},lineDash:{svgAttr:"stroke-dasharray",canvas:[],svg:null,apply:"stroke"}};class Aa{constructor(e,t){this.__root=e,this.__ctx=t}addColorStop(e,t){var i,n=this.__ctx.__createElement("stop");n.setAttribute("offset",e),t&&-1!==t.indexOf("rgba")?(i=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi.exec(t),n.setAttribute("stop-color",ya("rgb({r},{g},{b})",{r:i[1],g:i[2],b:i[3]})),n.setAttribute("stop-opacity",i[4])):n.setAttribute("stop-color",t),this.__root.appendChild(n)}}class Ea{constructor(e,t){this.__root=e,this.__ctx=t}}class Ma{constructor(e){if(!(this instanceof Ma))return new Ma(e);if(this.config=e,this.width=e.width,this.height=e.height,this.enableMirroring=e.enableMirroring||!1,this.canvas=this,this.__document=document,e.ctx?this.__ctx=e.ctx:(this.__canvas=this.__document.createElement("canvas"),this.__ctx=this.__canvas.getContext("2d")),this.isSVG=!0,this.__setDefaultStyles(),this.__stack=[this.__getStyleState()],this.__groupStack=[],this.__root=this.__createElement("svg"),this.__root.setAttribute("width",this.width),this.__root.setAttribute("height",this.height),this.__root.setAttribute("overflow","visible"),e.viewbox){const t=e.viewbox.x+" "+e.viewbox.y+" "+e.viewbox.width+" "+e.viewbox.height;this.__root.setAttribute("viewBox",t),this.viewbox=e.viewbox}this.__ids={},this.__defs=this.__createElement("defs"),this.__root.appendChild(this.__defs),this.multiLocusGap=e.multiLocusGap;let t={id:"svg_output_backdrop",width:"100%",height:"100%",fill:e.backdropColor||"white"},i=this.__createElement("rect",t);this.__root.appendChild(i),this.__rootGroup=this.__createElement("g",{id:"root-group"}),this.__root.appendChild(this.__rootGroup),this.__currentElement=this.__rootGroup}setWidth(e){this.width=e,this.__root.setAttribute("width",this.width);const t=this.config.viewbox.x+" "+this.config.viewbox.y+" "+e+" "+this.config.viewbox.height;this.__root.setAttribute("viewBox",t)}setHeight(e){this.height=e,this.__root.setAttribute("height",this.height);const t=this.config.viewbox.x+" "+this.config.viewbox.y+" "+this.config.viewbox.width+" "+e;this.__root.setAttribute("viewBox",t)}__createElement(e,t,i){void 0===t&&(t={});let n=this.__document.createElementNS("http://www.w3.org/2000/svg",e);i&&(n.setAttribute("fill","none"),n.setAttribute("stroke","none"));for(let e of Object.keys(t))n.setAttribute(e,t[e]);return n}__setDefaultStyles(){var e,t,i=Object.keys(Sa);for(e=0;e<i.length;e++)this[t=i[e]]=Sa[t].canvas}__applyStyleState(e){var t,i,n=Object.keys(e);for(t=0;t<n.length;t++)this[i=n[t]]=e[i]}__getStyleState(){var e,t,i={},n=Object.keys(Sa);for(e=0;e<n.length;e++)i[t=n[e]]=this[t];return i}__applyStyleToCurrentElement(e){var t=this.__currentElement,i=this.__currentElementsToStyle;i&&(t.setAttribute(e,""),t=i.element,i.children.forEach((function(t){t.setAttribute(e,"")})));var n,r,s,o,a,l=Object.keys(Sa);for(n=0;n<l.length;n++)if(r=Sa[l[n]],s=this[l[n]],r.apply)if(s instanceof Ea){if(s.__ctx)for(;s.__ctx.__defs.childNodes.length;)o=s.__ctx.__defs.childNodes[0].getAttribute("id"),this.__ids[o]=o,this.__defs.appendChild(s.__ctx.__defs.childNodes[0]);t.setAttribute(r.apply,ya("url(#{id})",{id:s.__root.getAttribute("id")}))}else if(s instanceof Aa)t.setAttribute(r.apply,ya("url(#{id})",{id:s.__root.getAttribute("id")}));else if(r&&-1!==r.apply.indexOf(e)&&r.svg!==s)if("stroke"!==r.svgAttr&&"fill"!==r.svgAttr||!s||-1===s.indexOf("rgba")){var h=r.svgAttr;if("globalAlpha"===l[n]&&(h=e+"-"+r.svgAttr,t.getAttribute(h)))continue;t.setAttribute(h,s)}else{a=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi.exec(s),t.setAttribute(r.svgAttr,ya("rgb({r},{g},{b})",{r:a[1],g:a[2],b:a[3]}));var c=a[4],d=this.globalAlpha;null!=d&&(c*=d),t.setAttribute(r.svgAttr+"-opacity",c)}}__closestGroupOrSvg(e){return"g"===(e=e||this.__currentElement).nodeName||"svg"===e.nodeName?e:this.__closestGroupOrSvg(e.parentNode)}getSerializedSvg(e){var t,i,n,r,s,o=(new XMLSerializer).serializeToString(this.__root);if(e)for(t=Object.keys(Ca),i=0;i<t.length;i++)n=t[i],r=Ca[n],(s=new RegExp(n,"gi")).test(o)&&(o=o.replace(s,r));return o}getSvg(){return this.__root}saveWithTranslationAndClipRect(e,t,i,n,r,s){const o=`${e}_clip_rect`;let a=this.__createElement("clipPath",{id:o});this.__defs.appendChild(a);const l={x:"0",y:s.toString(),width:n.toString(),height:r.toString()};a.appendChild(this.__createElement("rect",l));const h=this.__createElement("g");h.setAttribute("transform",ya("translate({x},{y})",{x:t,y:i})),h.setAttribute("clip-path",ya("url(#{id})",{id:o}));const c=this.__closestGroupOrSvg();c.appendChild(h),this.__groupStack.push(c),this.__currentElement=h,this.__stack.push(this.__getStyleState())}save(){var e=this.__createElement("g"),t=this.__closestGroupOrSvg();this.__groupStack.push(t),t.appendChild(e),this.__currentElement=e,this.__stack.push(this.__getStyleState())}restore(){this.__currentElement=this.__groupStack.pop(),this.__currentElementsToStyle=null,this.__currentElement||(this.__currentElement=this.__root.childNodes[1]);var e=this.__stack.pop();this.__applyStyleState(e)}__addTransform(e){var t=this.__closestGroupOrSvg();if(t.childNodes.length>0){"path"===this.__currentElement.nodeName&&(this.__currentElementsToStyle||(this.__currentElementsToStyle={element:t,children:[]}),this.__currentElementsToStyle.children.push(this.__currentElement),this.__applyCurrentDefaultPath());var i=this.__createElement("g");t.appendChild(i),this.__currentElement=i}var n=this.__currentElement.getAttribute("transform");n?n+=" ":n="",n+=e,this.__currentElement.setAttribute("transform",n)}addTrackGroupWithTranslationAndClipRect(e,t,i,n,r,s){const o=e+"_clip_rect";let a=this.__createElement("clipPath",{id:o});this.__defs.appendChild(a),a.appendChild(this.__createElement("rect",{x:"0",y:s.toString(),width:n.toString(),height:r.toString()}));let l=this.__createElement("g");this.__rootGroup.appendChild(l),l.setAttribute("transform",ya("translate({x},{y})",{x:t,y:i})),l.setAttribute("id",e+"_group"),l.setAttribute("clip-path",ya("url(#{id})",{id:o})),this.__currentElement=l}scale(e,t){void 0===t&&(t=e),this.__addTransform(ya("scale({x},{y})",{x:e,y:t}))}rotate(e){var t=180*e/Math.PI;this.__addTransform(ya("rotate({angle},{cx},{cy})",{angle:t,cx:0,cy:0}))}translate(e,t){this.__addTransform(ya("translate({x},{y})",{x:e,y:t}))}transform(e,t,i,n,r,s){this.__addTransform(ya("matrix({a},{b},{c},{d},{e},{f})",{a:e,b:t,c:i,d:n,e:r,f:s}))}beginPath(){var e;this.__currentDefaultPath="",this.__currentPosition={},e=this.__createElement("path",{},!0),this.__closestGroupOrSvg().appendChild(e),this.__currentElement=e}__applyCurrentDefaultPath(){var e=this.__currentElement;"path"===e.nodeName?e.setAttribute("d",this.__currentDefaultPath):console.error("Attempted to apply path command to node",e.nodeName)}__addPathCommand(e){this.__currentDefaultPath+=" ",this.__currentDefaultPath+=e}moveTo(e,t){"path"!==this.__currentElement.nodeName&&this.beginPath(),this.__currentPosition={x:e,y:t},this.__addPathCommand(ya("M {x} {y}",{x:e,y:t}))}closePath(){this.__currentDefaultPath&&this.__addPathCommand("Z")}lineTo(e,t){this.__currentPosition={x:e,y:t},this.__currentDefaultPath&&this.__currentDefaultPath.indexOf("M")>-1?this.__addPathCommand(ya("L {x} {y}",{x:e,y:t})):this.__addPathCommand(ya("M {x} {y}",{x:e,y:t}))}bezierCurveTo(e,t,i,n,r,s){this.__currentPosition={x:r,y:s},this.__addPathCommand(ya("C {cp1x} {cp1y} {cp2x} {cp2y} {x} {y}",{cp1x:e,cp1y:t,cp2x:i,cp2y:n,x:r,y:s}))}quadraticCurveTo(e,t,i,n){this.__currentPosition={x:i,y:n},this.__addPathCommand(ya("Q {cpx} {cpy} {x} {y}",{cpx:e,cpy:t,x:i,y:n}))}arcTo(e,t,i,n,r){var s=this.__currentPosition&&this.__currentPosition.x,o=this.__currentPosition&&this.__currentPosition.y;if(void 0!==s&&void 0!==o){if(r<0)throw new Error("IndexSizeError: The radius provided ("+r+") is negative.");if(s===e&&o===t||e===i&&t===n||0===r)this.lineTo(e,t);else{var a=ka([s-e,o-t]),l=ka([i-e,n-t]);if(a[0]*l[1]!=a[1]*l[0]){var h=a[0]*l[0]+a[1]*l[1],c=Math.acos(Math.abs(h)),d=ka([a[0]+l[0],a[1]+l[1]]),u=r/Math.sin(c/2),f=e+u*d[0],p=t+u*d[1],g=[-a[1],a[0]],m=[l[1],-l[0]],b=function(e){var t=e[0];return e[1]>=0?Math.acos(t):-Math.acos(t)},w=b(g),v=b(m);this.lineTo(f+g[0]*r,p+g[1]*r),this.arc(f,p,r,w,v)}else this.lineTo(e,t)}}}stroke(){"path"===this.__currentElement.nodeName&&this.__currentElement.setAttribute("paint-order","fill stroke markers"),this.__applyCurrentDefaultPath(),this.__applyStyleToCurrentElement("stroke")}fill(){"path"===this.__currentElement.nodeName&&this.__currentElement.setAttribute("paint-order","stroke fill markers"),this.__applyCurrentDefaultPath(),this.__applyStyleToCurrentElement("fill")}rect(e,t,i,n){"path"!==this.__currentElement.nodeName&&this.beginPath(),this.moveTo(e,t),this.lineTo(e+i,t),this.lineTo(e+i,t+n),this.lineTo(e,t+n),this.lineTo(e,t),this.closePath()}fillRect(e,t,i,n){n<0&&(t+=n,n=-n),i<0&&(e+=i,i=-i);var r,s,o,a={x:e,y:t,width:i,height:n};(!this.viewbox||(r=this.viewbox,s=a,r.x<s.x+s.width&&r.x+r.width>s.x&&r.y<s.y+s.height&&r.y+r.height>s.y))&&(o=this.__createElement("rect",a,!0),this.__closestGroupOrSvg().appendChild(o),this.__currentElement=o,this.__applyStyleToCurrentElement("fill"))}strokeRect(e,t,i,n){var r;r=this.__createElement("rect",{x:e,y:t,width:i,height:n},!0),this.__closestGroupOrSvg().appendChild(r),this.__currentElement=r,this.__applyStyleToCurrentElement("stroke")}strokeEllipse(e,t,i,n,r,s,o,a){this.__ellipse(e,t,i,n,r,s,o,a,"stroke")}fillEllipse(e,t,i,n,r,s,o,a){this.__ellipse(e,t,i,n,r,s,o,a,"fill")}__ellipse(e,t,i,n,r,s,o,a,l){const h={cx:e,cy:t,rx:i,ry:n},c=this.__createElement("ellipse",h,!0);this.__closestGroupOrSvg().appendChild(c),this.__currentElement=c,this.__applyStyleToCurrentElement(l)}__clearCanvas(){for(var e=this.__closestGroupOrSvg().getAttribute("transform"),t=this.__root.childNodes[1],i=t.childNodes,n=i.length-1;n>=0;n--)i[n]&&t.removeChild(i[n]);this.__currentElement=t,this.__groupStack=[],e&&this.__addTransform(e)}clearRect(e,t,i,n){if(0!==e||0!==t||i!==this.width||n!==this.height){var r,s=this.__closestGroupOrSvg();r=this.__createElement("rect",{x:e,y:t,width:i,height:n,fill:"#FFFFFF"},!0),s.appendChild(r)}else this.__clearCanvas()}createLinearGradient(e,t,i,n){var r=this.__createElement("linearGradient",{id:_a(this.__ids),x1:e+"px",x2:i+"px",y1:t+"px",y2:n+"px",gradientUnits:"userSpaceOnUse"},!1);return this.__defs.appendChild(r),new Aa(r,this)}createRadialGradient(e,t,i,n,r,s){var o=this.__createElement("radialGradient",{id:_a(this.__ids),cx:n+"px",cy:r+"px",r:s+"px",fx:e+"px",fy:t+"px",gradientUnits:"userSpaceOnUse"},!1);return this.__defs.appendChild(o),new Aa(o,this)}__parseFont(){var e=/^\s*(?=(?:(?:[-a-z]+\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\1|\2|\3)\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\d]+(?:\%|in|[cem]m|ex|p[ctx]))(?:\s*\/\s*(normal|[.\d]+(?:\%|in|[cem]m|ex|p[ctx])))?\s*([-,\'\"\sa-z0-9]+?)\s*$/i.exec(this.font),t={style:e[1]||"normal",size:e[4]||"10px",family:e[6]||"sans-serif",weight:e[3]||"normal",decoration:e[2]||"normal",href:null};return"underline"===this.__fontUnderline&&(t.decoration="underline"),this.__fontHref&&(t.href=this.__fontHref),t}__wrapTextLink(e,t){if(e.href){var i=this.__createElement("a");return i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",e.href),i.appendChild(t),i}return t}__applyText(e,t,i,n){var r,s,o=this.__parseFont(),a=this.__closestGroupOrSvg(),l=this.__createElement("text",{"font-family":o.family,"font-size":o.size,"font-style":o.style,"font-weight":o.weight,"text-decoration":o.decoration,x:t,y:i,"text-anchor":(r=this.textAlign,s={left:"start",right:"end",center:"middle",start:"start",end:"end"},s[r]||s.start),"dominant-baseline":xa(this.textBaseline)},!0);l.appendChild(this.__document.createTextNode(e)),this.__currentElement=l,this.__applyStyleToCurrentElement(n),a.appendChild(this.__wrapTextLink(o,l))}fillText(e,t,i){this.__applyText(e,t,i,"fill")}strokeText(e,t,i){this.__applyText(e,t,i,"stroke")}measureText(e){return this.__ctx.font=this.font,this.__ctx.measureText(e)}arc(e,t,i,n,r,s){if(n!==r){(n%=2*Math.PI)===(r%=2*Math.PI)&&(r=(r+2*Math.PI-.001*(s?-1:1))%(2*Math.PI));var o=e+i*Math.cos(r),a=t+i*Math.sin(r),l=e+i*Math.cos(n),h=t+i*Math.sin(n),c=s?0:1,d=0,u=r-n;u<0&&(u+=2*Math.PI),d=s?u>Math.PI?0:1:u>Math.PI?1:0,this.lineTo(l,h),this.__addPathCommand(ya("A {rx} {ry} {xAxisRotation} {largeArcFlag} {sweepFlag} {endX} {endY}",{rx:i,ry:i,xAxisRotation:0,largeArcFlag:d,sweepFlag:c,endX:o,endY:a})),this.__currentPosition={x:o,y:a}}}clip(){var e=this.__closestGroupOrSvg(),t=this.__createElement("clipPath"),i=_a(this.__ids),n=this.__createElement("g");this.__applyCurrentDefaultPath(),e.removeChild(this.__currentElement),t.setAttribute("id",i),t.appendChild(this.__currentElement),this.__defs.appendChild(t),e.setAttribute("clip-path",ya("url(#{id})",{id:i})),e.appendChild(n),this.__currentElement=n}drawImage(){var e,t,i,n,r,s,o,a,l,h,c,d,u,f=Array.prototype.slice.call(arguments),p=f[0],g=0,m=0;if(3===f.length)e=f[1],t=f[2],i=r=p.width,n=s=p.height;else if(5===f.length)e=f[1],t=f[2],i=f[3],n=f[4],r=p.width,s=p.height;else{if(9!==f.length)throw new Error("Invalid number of arguments passed to drawImage: "+arguments.length);g=f[1],m=f[2],r=f[3],s=f[4],e=f[5],t=f[6],i=f[7],n=f[8]}o=this.__closestGroupOrSvg(),this.__currentElement;var b="translate("+e+", "+t+")";if(p instanceof Ma){if((a=p.getSvg().cloneNode(!0)).childNodes&&a.childNodes.length>1){for(l=a.childNodes[0];l.childNodes.length;)u=l.childNodes[0].getAttribute("id"),this.__ids[u]=u,this.__defs.appendChild(l.childNodes[0]);if(h=a.childNodes[1]){var w,v=h.getAttribute("transform");w=v?v+" "+b:b,h.setAttribute("transform",w),o.appendChild(h)}}}else"CANVAS"!==p.nodeName&&"IMG"!==p.nodeName||((c=this.__createElement("image")).setAttribute("width",i),c.setAttribute("height",n),c.setAttribute("preserveAspectRatio","none"),(g||m||r!==p.width||s!==p.height)&&((d=this.__document.createElement("canvas")).width=i,d.height=n,d.getContext("2d").drawImage(p,g,m,r,s,0,0,i,n),p=d),c.setAttribute("transform",b),c.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href","CANVAS"===p.nodeName?p.toDataURL():p.getAttribute("src")),o.appendChild(c))}createPattern(e,t){let i,n=this.__document.__createElement("pattern"),r=_a(this.__ids);return n.setAttribute("id",r),n.setAttribute("width",e.width),n.setAttribute("height",e.height),"CANVAS"===e.nodeName||"IMG"===e.nodeName?(i=this.__createElement("image"),i.setAttribute("width",e.width),i.setAttribute("height",e.height),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href","CANVAS"===e.nodeName?e.toDataURL():e.getAttribute("src")),n.appendChild(i),this.__defs.appendChild(n)):e instanceof Ma&&(n.appendChild(e.__root.childNodes[1]),this.__defs.appendChild(n)),new Ea(n,this)}setLineDash(e){e&&e.length>0?this.lineDash=e.join(","):this.lineDash=null}drawFocusRing(){}createImageData(){}getImageData(){}putImageData(){}globalCompositeOperation(){}setTransform(){}}const Ta=function(e,t,i,n){this.start=e,this.end=t,this.name=i,this.stain=0,"acen"===n?this.type="c":(this.type=n.charAt(1),"p"===this.type&&(this.stain=parseInt(n.substring(4))))};function Ra(){return"2.15.5"}const La=Yt,Ia={loadGenome:async function(e){const t=e.cytobandURL,i=e.aliasURL,n=await ha(e);let r;i&&(r=await function(e,t){return no.loadString(e,To(t)).then((function(e){var t=La(e),i=[];return t.forEach((function(e){!e.startsWith("#")&&e.length>0&&i.push(e.split("\t"))})),i}))}(i,n.config));const s=new Ba(e,n,r);return t&&(s.cytobands=await async function(e,t,i){let n;if(Fo(e)){const t=Fs(e);n="";const i=t.length;for(let e=0;e<i;e++)n+=String.fromCharCode(t[e])}else n=await no.loadString(e,To(t));const r={};let s,o=[];const a=La(n);for(let e of a){var l=e.split("\t"),h=i.getChromosomeName(l[0]);if(s||(s=h),h!==s&&(r[s]=o,o=[],s=h),5===l.length){var c=parseInt(l[1]),d=parseInt(l[2]),u=l[3],f=l[4];o.push(new Ta(c,d,u,f))}}return r}(t,n.config,s)),s},initializeGenomes:async function(e){if(!Ia.KNOWN_GENOMES){const t={};if(!1!==e.loadDefaultGenomes)try{const r=`https://igv.org/genomes/genomes.json?randomSeed=${Math.random().toString(36)}&version=2.15.5`;n(await no.loadJson(r,{timeout:5e3}))}catch(s){console.error(s);try{const o=`https://s3.amazonaws.com/igv.org.genomes/genomes.json?randomSeed=${Math.random().toString(36)}&version=2.15.5`;n(await no.loadJson(o,{}))}catch(a){console.error(a),console.warn("Errors loading default genome definitions.")}}const i=e.genomeList||e.genomes;if(i)if("string"==typeof i){n(await no.loadJson(i,{}))}else n(i);function n(e){return e.forEach((function(e){t[e.id]=e})),t}Ia.KNOWN_GENOMES=t}},isWholeGenomeView:function(e){return"all"===e.toLowerCase()},expandReference:function(e,t){if(Qt(t)&&t.startsWith("{"))try{t=JSON.parse(t)}catch(e){}let i;if(Qt(t)?i=t:t.genome?i=t.genome:void 0!==t.id&&void 0===t.fastaURL&&(i=t.id),i){const t=Ia.KNOWN_GENOMES[i];return t||e.present(new Error(`Unknown genome id: ${i}`),void 0),t}return t}};class Ba{constructor(e,t,i){this.config=e,this.id=e.id||function(e){return void 0!==e.id?e.id:e.fastaURL&&Qt(e.fastaURL)?e.fastaURL:e.fastaURL&&e.fastaURL.name?e.fastaURL.name:("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)}(e),this.sequence=t,this.chromosomeNames=t.chromosomeNames,this.chromosomes=t.chromosomes,this.featureDB=new Map,this.wholeGenomeView=void 0===e.wholeGenomeView||e.wholeGenomeView,this.wholeGenomeView&&Object.keys(t.chromosomes).length>1?function(e,t){let i;if(t.chromosomeOrder)Array.isArray(t.chromosomeOrder)?e.wgChromosomeNames=t.chromosomeOrder:e.wgChromosomeNames=t.chromosomeOrder.split(",").map((e=>e.trim())),i=e.wgChromosomeNames.map((t=>e.chromosomes[t])).filter((e=>void 0!==e));else{const t=Object.keys(e.chromosomes).map((t=>e.chromosomes[t].bpLength)).reduce(((e,t)=>Math.max(e,t)))/50;i=Object.values(e.chromosomes).filter((e=>e.bpLength>t));const n=i.filter((e=>r(e.name.replace("chr","")))),s=i.filter((e=>!r(e.name.replace("chr",""))));n.sort(((e,t)=>Number.parseInt(e.name.replace("chr",""))-Number.parseInt(t.name.replace("chr",""))));const o=n.map((e=>e.name));for(let e of s)o.push(e.name);e.wgChromosomeNames=o}const n=i.reduce(((e,t)=>e+t.bpLength),0);function r(e){return/^\d+$/.test(e)}e.chromosomes.all={name:"all",bpLength:n}}(this,e):this.wgChromosomeNames=t.chromosomeNames;var n={},r=this;n.all="all",this.chromosomeNames.forEach((function(e){var t=e.startsWith("chr")?e.substring(3):"chr"+e;n[t.toLowerCase()]=e,"chrM"===e&&(n.mt="chrM"),"MT"===e&&(n.chrm="MT"),n[e.toLowerCase()]=e})),i&&i.forEach((function(e){var t,i;for(i=0;i<e.length;i++)if(r.chromosomes[e[i]]){t=e[i];break}t&&e.forEach((function(e){e!==t&&(n[e.toLowerCase()]=t,n[e]=t)}))})),this.chrAliasTable=n}showWholeGenomeView(){return!1!==this.config.wholeGenomeView}toJSON(){return Object.assign({},this.config,{tracks:void 0})}getInitialLocus(){}getHomeChromosomeName(){return this.showWholeGenomeView()&&this.chromosomes.hasOwnProperty("all")?"all":this.chromosomeNames[0]}getChromosomeName(e){const t=e?this.chrAliasTable[e.toLowerCase()]:e;return t||e}getChromosome(e){return e=this.getChromosomeName(e),this.chromosomes[e]}getCytobands(e){return this.cytobands?this.cytobands[e]:null}getLongestChromosome(){var e,t=this.chromosomes;for(let n in t){if(t.hasOwnProperty(n)){var i=t[n];(void 0===e||i.bpLength>e.bpLength)&&(e=i)}return e}}getChromosomes(){return this.chromosomes}getGenomeCoordinate(e,t){var i=this.getCumulativeOffset(e);if(void 0!==i)return i+t}getChromosomeCoordinate(e){let t;void 0===this.cumulativeOffsets&&(this.cumulativeOffsets=computeCumulativeOffsets.call(this));let i=0;for(let n of this.wgChromosomeNames){const r=this.cumulativeOffsets[n];if(r>e){return{chr:t,position:e-i}}t=n,i=r}return{chr:this.wgChromosomeNames[this.wgChromosomeNames.length-1],position:0}}getCumulativeOffset(e){void 0===this.cumulativeOffsets&&(this.cumulativeOffsets=function(){let e=this,t={},i=0;for(let n of e.wgChromosomeNames){t[n]=Math.floor(i);i+=e.getChromosome(n).bpLength}return t}.call(this));const t=this.getChromosomeName(e);return this.cumulativeOffsets[t]}getGenomeLength(){let e=this;if(!this.bpLength){let t=0;e.wgChromosomeNames.forEach((function(i){let n=e.chromosomes[i];t+=n.bpLength})),this.bpLength=t}return this.bpLength}async getSequence(e,t,i){return e=this.getChromosomeName(e),this.sequence.getSequence(e,t,i)}addFeaturesToDB(e,t){const i=(e,t)=>{const i=this.featureDB.get(e);i&&(t=t.end-t.start>i.end-i.start?t:i),this.featureDB.set(e,t)};for(let n of e)if(n.name&&i(n.name.toUpperCase(),n),n.gene&&n.gene.name&&i(n.gene.name.toUpperCase(),n),t.searchableFields)for(let e of t.searchableFields){const t=n.getAttributeValue(e);t&&(t.indexOf(" ")>0?i(t.replaceAll(" ","+").toUpperCase(),n):i(t.toUpperCase(),n))}}}let Fa,Na=0,Oa=0;class Pa extends va{constructor(e,t,i,n){super(e,t,i,n)}initializationHelper(){this.$spinner=ft("<div>",{class:"igv-loading-spinner-container"}),this.$viewport.append(this.$spinner),this.$spinner.append(ft("<div>"));const e=this.trackView.track;"sequence"!==e.type&&(this.$zoomInNotice=this.createZoomInNotice(this.$viewport)),e.name&&"sequence"!==e.id&&(this.$trackLabel=ft('<div class="igv-track-label">'),this.$viewport.append(this.$trackLabel),this.setTrackLabel(e.name),!1===this.browser.trackLabelsVisible&&this.$trackLabel.hide()),this.stopSpinner(),this.addMouseHandlers()}setContentHeight(e){super.setContentHeight(e),this.featureCache&&(this.featureCache.redraw=!0)}setTrackLabel(e){this.$trackLabel.empty(),this.$trackLabel.html(e);const t=this.$trackLabel.text();this.$trackLabel.attr("title",t)}startSpinner(){this.$spinner.show()}stopSpinner(){this.$spinner&&this.$spinner.hide()}checkZoomIn(){if(this.trackView.track&&"sequence"===this.trackView.track.type&&this.referenceFrame.bpPerPixel>10)return ft(this.canvas).remove(),this.canvas=void 0,!1;if(!this.viewIsReady())return!1;if((()=>{if("all"!==this.referenceFrame.chr.toLowerCase()||this.trackView.track.supportsWholeGenome){const e=this.trackView.track.visibilityWindow;return void 0!==e&&e>0&&this.referenceFrame.bpPerPixel*this.$viewport.width()>e}return!0})()){if(this.canvas&&(ft(this.canvas).remove(),this.canvas=void 0),this.trackView.track.autoHeight){const e=this.trackView.minHeight||0;this.setContentHeight(e)}return this.$zoomInNotice&&this.$zoomInNotice.show(),!1}return this.$zoomInNotice&&this.$zoomInNotice.hide(),!0}shift(){const e=this.referenceFrame;if(this.canvas&&this.canvas._data&&this.canvas._data.referenceFrame.chr===this.referenceFrame.chr&&this.canvas._data.bpPerPixel===e.bpPerPixel){const t=Math.round((this.canvas._data.bpStart-e.start)/e.bpPerPixel);this.canvas.style.left=t+"px"}}setTop(e){if(super.setTop(e),this.canvas){const t=this.$viewport.height(),i=e+this.canvas._data.pixelTop,n=i+this.canvas._data.pixelHeight;(i>0||n<t)&&this.repaint()}else this.repaint();let t=e+this.canvas._data.pixelTop;this.canvas.style.top=`${t}px`}async loadFeatures(){const e=this.referenceFrame,t=e.chr,i=this.browser.genome.getChromosome(t).bpLength,n=this.$viewport.width()*e.bpPerPixel,r=Math.floor(Math.max(0,e.start-n)),s=Math.ceil(Math.min(i,e.start+n+n));if(!this.loading||this.loading.start!==r||this.loading.end!==s){this.loading={start:r,end:s},this.startSpinner();try{const i=this.trackView.track,n=await this.getFeatures(i,t,r,s,e.bpPerPixel);if(n){let o=[];if(i.roiSets&&i.roiSets.length>0)for(let n of i.roiSets){const i=await n.getFeatures(t,r,s,e.bpPerPixel);o.push({track:n,features:i})}const a=i&&("wig"===i.type||"merged"===i.type);return this.featureCache=new Da(t,r,s,e.bpPerPixel,n,o,a),this.loading=!1,this.hideMessage(),this.stopSpinner(),this.featureCache}}catch(e){this.trackView&&!0!==this.trackView.disposed&&(this.showMessage("Error loading track data"),this.browser.alert.present(e),console.error(e))}finally{this.loading=!1,this.stopSpinner()}}}repaintDimensions(){const e=Ia.isWholeGenomeView(this.referenceFrame.chr),t=e?this.$viewport.width():3*this.$viewport.width(),i=this.referenceFrame.bpPerPixel;return{bpStart:this.referenceFrame.start-(e?0:t/3*i),bpEnd:this.referenceFrame.end+(e?0:t/3*i),pixelWidth:t}}repaint(){if(void 0===this.featureCache)return;const{features:e,roiFeatures:t}=this.featureCache,{bpStart:i,bpEnd:n,pixelWidth:r}=this.repaintDimensions(),s=this.$viewport.height(),o=this.getContentHeight(),a=t?Math.max(o,s):o,l=Math.min(a,3*s);if(0===r||0===l)return void(this.canvas&&ft(this.canvas).remove());const h=Math.max(0,-this.contentTop-Math.floor(l/3)),c=this.referenceFrame.bpPerPixel,d=Math.round((i-this.referenceFrame.start)/c),u=(this.contentTop||0)+h,f=document.createElement("canvas");f.style.position="relative",f.style.display="block",f.style.width=r+"px",f.style.height=l+"px",f.style.left=d+"px",f.style.top=u+"px";const p="FILL"===this.trackView.track.displayMode||!1!==this.trackView.track.supportHiDPI?window.devicePixelRatio:1;f.width=p*r,f.height=p*l;const g=f.getContext("2d");g.scale(p,p),g.translate(0,-h);const m={context:g,pixelXOffset:d,pixelWidth:r,pixelHeight:l,pixelTop:h,bpStart:i,bpEnd:n,bpPerPixel:c,referenceFrame:this.referenceFrame,selection:this.selection,viewport:this,viewportWidth:this.$viewport.width()};this.draw(m,e,t),this.canvas&&ft(this.canvas).remove(),f._data=m,this.canvas=f,this.$viewport.append(ft(f))}refresh(){if(!this.canvas||!this.featureCache)return;const e=this.canvas._data;e.context.clearRect(0,0,this.canvas.width,this.canvas.height);const{features:t,roiFeatures:i}=this.featureCache;this.draw(e,t,i)}draw(e,t,i){if(t&&(e.features=t,this.trackView.track.draw(e)),i&&i.length>0)for(let t of i)e.features=t.features,t.track.draw(e)}containsPosition(e,t){return this.referenceFrame.chr===e&&t>=this.referenceFrame.start&&t<=this.referenceFrame.calculateEnd(this.getWidth())}isLoading(){return this.loading}savePNG(){if(!this.canvas)return;const e=this.canvas._data,t=e?e.pixelTop:0,i=window.devicePixelRatio,n=this.$viewport.width()*i,r=this.$viewport.height()*i,s=-ft(this.canvas).position().left*i,o=(-this.contentTop-t)*i,a=this.canvas.getContext("2d").getImageData(s,o,n,r),l=document.createElement("canvas"),h=l.getContext("2d");l.width=a.width,l.height=a.height,h.putImageData(a,0,0);ii((this.$trackLabel.text()?this.$trackLabel.text():"image")+".png",l.toDataURL("image/png"))}saveSVG(){let{width:e,height:t}=this.browser.columnContainer.getBoundingClientRect();const i=new Ma({width:e,height:8e3,backdropColor:"white",multiLocusGap:0,viewbox:{x:0,y:0,width:e,height:8e3}}),n={deltaX:32,deltaY:32};this.renderViewportToSVG(i,n),i.setHeight(t);const r=(this.trackView.track.name||this.trackView.track.id).replace(/\W/g,""),s=this.browser.referenceFrameList.indexOf(this.referenceFrame),o=i.getSerializedSvg(!0),a=URL.createObjectURL(new Blob([o],{type:"application/octet-stream"}));ii(`${`${r}_referenceFrame_${s}_guid_${_t.guid()}`}.svg`,a)}renderViewportToSVG(e,{deltaX:t,deltaY:i}){if(this.$zoomInNotice&&this.$zoomInNotice.is(":visible"))return;const{width:n,height:r}=this.$viewport.get(0).getBoundingClientRect(),s=`${(this.trackView.track.name||this.trackView.track.id).replace(/\W/g,"")}_referenceFrame_${this.browser.referenceFrameList.indexOf(this.referenceFrame)}_guid_${_t.guid()}`;this.drawSVGWithContext(e,n,r,s,t,i+this.contentTop,-this.contentTop)}renderSVGContext(e,{deltaX:t,deltaY:i}){if(this.renderViewportToSVG(e,{deltaX:t,deltaY:i}),(!this.$zoomInNotice||!this.$zoomInNotice.is(":visible"))&&this.$trackLabel&&!0===this.browser.trackLabelsVisible){const{x:n,y:r,width:s,height:o}=_t.relativeDOMBBox(this.$viewport.get(0),this.$trackLabel.get(0));this.renderTrackLabelSVG(e,t+n,i+r,s,o)}}renderTrackLabelSVG(e,t,i,n,r){const s=`${(this.trackView.track.name||this.trackView.track.id).replace(/\W/g,"")}_track_label_guid_${_t.guid()}`;e.saveWithTranslationAndClipRect(s,t,i,n,r,0),e.fillStyle="white",e.fillRect(0,0,n,r),e.font="12px Arial",e.fillStyle="rgb(68, 68, 68)";const{width:o}=e.measureText(this.$trackLabel.text()),a=.25*(n-o),l=.7*(r-12);e.fillText(this.$trackLabel.text(),a,r-l),e.strokeStyle="rgb(68, 68, 68)",e.strokeRect(0,0,n,r),e.restore()}drawSVGWithContext(e,t,i,n,r,s,o){e.saveWithTranslationAndClipRect(n,r,s,t,i,o);let{start:a,bpPerPixel:l}=this.referenceFrame;const h={context:e,viewport:this,referenceFrame:this.referenceFrame,top:o,pixelTop:o,pixelWidth:t,pixelHeight:i,bpStart:a,bpEnd:a+t*l,bpPerPixel:l,viewportWidth:t,selection:this.selection},c=this.featureCache?this.featureCache.features:void 0,d=this.featureCache?this.featureCache.roiFeatures:void 0;this.draw(h,c,d),e.restore()}get cachedFeatures(){return this.featureCache?this.featureCache.features:[]}clearCache(){this.featureCache=void 0,this.canvas&&(this.canvas._data=void 0)}async getFeatures(e,t,i,n,r){if(this.featureCache&&this.featureCache.containsRange(t,i,n,r))return this.featureCache.features;if("function"==typeof e.getFeatures){const s=await e.getFeatures(t,i,n,r,this);return this.checkContentHeight(s),s}}needsRepaint(){if(!this.canvas)return!0;const e=this.canvas._data;return!e||this.referenceFrame.start<e.bpStart||this.referenceFrame.end>e.bpEnd||this.referenceFrame.chr!==e.referenceFrame.chr||this.referenceFrame.bpPerPixel!=e.bpPerPixel}needsReload(){if(!this.featureCache)return!0;const{chr:e,bpPerPixel:t}=this.referenceFrame,{bpStart:i,bpEnd:n}=this.repaintDimensions();return!this.featureCache.containsRange(e,i,n,t)}createZoomInNotice(e){const t=ft("<div>",{class:"igv-zoom-in-notice-container"});e.append(t);const i=ft("<div>");return t.append(i),i.text("Zoom in to see features"),t.hide(),t}viewIsReady(){return this.browser&&this.browser.referenceFrameList&&this.referenceFrame}addMouseHandlers(){const e=this.$viewport.get(0);this.addViewportContextMenuHandler(e);const t=e=>{this.enableClick=!0,this.browser.mouseDownOnViewport(e,this),_t.pageCoordinates(e)};e.addEventListener("mousedown",t),e.addEventListener("touchstart",t);const i=e=>{this.browser.dragObject||this.browser.isScrolling?(this.browser.cancelTrackPan(),this.enableClick=!1):(this.browser.cancelTrackPan(),this.browser.endTrackDrag())};e.addEventListener("mouseup",i),e.addEventListener("touchend",i),"function"==typeof this.trackView.track.hoverText&&e.addEventListener("mousemove",(e=>{if(0===e.buttons&&Date.now()-Oa>100){Oa=Date.now();const t=this.createClickState(e);if(t){const e=this.trackView.track.hoverText(t);e?this.$viewport[0].setAttribute("title",e):this.$viewport[0].removeAttribute("title")}}})),this.addViewportClickHandler(this.$viewport.get(0)),this.trackView.track.name&&"sequence"!==this.trackView.track.config.type&&this.addTrackLabelClickHandler(this.$trackLabel.get(0))}addViewportContextMenuHandler(e){e.addEventListener("contextmenu",(e=>{if(this.browser.dragObject)return!1;const t=this.createClickState(e);if(void 0===t)return!1;e.preventDefault();let i=[];if("function"==typeof this.trackView.track.contextMenuItemList){const e=this.trackView.track.contextMenuItemList(t);e&&(i=e)}i.length>0&&i.push({label:ft("<HR>")}),i.push({label:"Save Image (PNG)",click:()=>this.savePNG()}),i.push({label:"Save Image (SVG)",click:()=>this.saveSVG()}),this.browser.menuPopup.presentTrackContextMenu(e,i)}))}addViewportClickHandler(e){e.addEventListener("click",(e=>{if(this.enableClick&&this.canvas){if(3===e.which||e.ctrlKey)return;if(ft(".igv-popover").hide(),this.browser.dragObject||this.browser.isScrolling)return;e.preventDefault();const t=_t.translateMouseCoordinates(e,this.$viewport.get(0)).x,i=_t.translateMouseCoordinates(e,this.canvas).x,n=this.referenceFrame,r=Math.floor(n.start+n.toBP(i)),s=Date.now();if(s-Na<this.browser.constants.doubleClickDelay){Fa&&(window.clearTimeout(Fa),Fa=void 0);const e=Math.round(n.start+n.toBP(t));let i;if("all"===this.referenceFrame.chr.toLowerCase()){const t=this.browser.genome.getChromosomeCoordinate(e).chr;if(1===this.browser.referenceFrameList.length)i=t;else{const e=this.browser.referenceFrameList.map((({locusSearchString:e})=>e));e[this.browser.referenceFrameList.indexOf(this.referenceFrame)]=t,i=e.join(" ")}this.browser.search(i)}else this.browser.zoomWithScaleFactor(.5,e,this.referenceFrame)}else e.shiftKey&&"function"==typeof this.trackView.track.shiftClick?this.trackView.track.shiftClick(r,e):"function"==typeof this.trackView.track.popupData&&(Fa=setTimeout((()=>{const t=this.getPopupContent(e);t&&(this.popover&&this.popover.dispose(),this.popover=new Vt(this.browser.columnContainer),this.popover.presentContentWithEvent(e,t)),window.clearTimeout(Fa),Fa=void 0}),this.browser.constants.doubleClickDelay));Na=s}}))}addTrackLabelClickHandler(e){e.addEventListener("click",(e=>{e.stopPropagation();const{track:t}=this.trackView;let i;"function"==typeof t.description?i=t.description():t.description&&(i=`<div>${t.description}</div>`),i&&(this.popover&&this.popover.dispose(),this.popover=new Vt(this.browser.columnContainer,t.name||""),this.popover.presentContentWithEvent(e,i))}))}createClickState(e){if(!this.canvas)return;const t=this.referenceFrame,i=_t.translateMouseCoordinates(e,this.$viewport.get(0)),n=_t.translateMouseCoordinates(e,this.canvas),r=t.start+t.toBP(i.x);return{event:e,viewport:this,referenceFrame:t,genomicLocation:r,y:i.y-this.contentTop,canvasX:n.x,canvasY:n.y}}getPopupContent(e){const t=this.createClickState(e);if(void 0===t)return;let i=this.trackView.track;const n=i.popupData(t),r=this.browser.fireEvent("trackclick",[i,n]);let s;return void 0===r||!0===r?n&&n.length>0&&(s=n.map((e=>{if(e.name){const t=`<span>${e.name}</span>   ${e.value}`;return`<div title="${e.value}">${t}</div>`}return"<hr>"===e?e:e.html?e.html:`<div title="${e}">${e}</div>`})).join("")):"string"==typeof r&&(s=r),s}}class Da{constructor(e,t,i,n,r,s,o){this.chr=e,this.bpStart=t,this.bpEnd=i,this.bpPerPixel=n,this.features=r,this.roiFeatures=s,this.multiresolution=o}containsRange(e,t,i,n){const r=this.multiresolution?this.bpPerPixel/n:1;return t>=this.bpStart&&i<=this.bpEnd&&e===this.chr&&r>.5&&r<2}overlapsRange(e,t,i){return this.chr===e&&i>=this.bpStart&&t<=this.bpEnd}}function za(e,t){if(!(e.length<6))return{chr:e[0],start:e[1],end:e[2],chr1:e[8],start1:Number.parseInt(e[9]),end1:Number.parseInt(e[10]),chr2:e[13],start2:Number.parseInt(e[14]),end2:Number.parseInt(e[15]),name:e[3],score:Number(e[4]),value:Number(e[5]),color:"."===e[7]?void 0:"0"===e[7]?"rgb(0,0,0)":e[7]};console.log("Skipping line: "+e.join(" "))}const Ha=new Set(["transcript","primary_transcript","processed_transcript","mRNA","mrna","lnc_RNA","miRNA","ncRNA","rRNA","scRNA","snRNA","snoRNA","tRNA"]),Va=new Set(["CDS","cds"]),Ua=new Set(["start_codon","stop_codon"]),qa=new Set(["5UTR","3UTR","UTR","five_prime_UTR","three_prime_UTR","3'-UTR","5'-UTR"]),ja=new Set(["exon","coding-exon"]),$a=new Set;for(let Zb of[Va,Ua,qa,ja])for(let Qb of Zb)$a.add(Qb);function Wa(e){return e.includes("intron")}function Ga(e){return Va.has(e)||Ua.has(e)}function Za(e){return qa.has(e)}function Qa(e){return Ha.has(e)||e.endsWith("RNA")||e.endsWith("transcript")}function Xa(e){return $a.has(e)||e.endsWith("RNA")||Wa(e)}const Ya=new Set(["id","parent","name"]);class Ka{constructor(e){Object.assign(this,e)}popupData(e){const t=this.geneObject?this.geneObject.popupData():[];if(this.geneObject&&t.push("<hr/>"),this.name&&t.push({name:"Name",value:this.name}),t.push({name:"Type",value:this.type}),t.push({name:"Source",value:this.source}),void 0!==this.score&&t.push({name:"Score",value:this.score}),this.attributeString){const e=nl(this.attributeString,this.delim);for(let[i,n]of e)void 0!==n&&n.length>0&&!Ya.has(i.toLowerCase())&&t.push({name:i+":",value:n})}return t.push({name:"Location",value:`${this.chr}:${Xt(this.start+1)}-${Xt(this.end)}`}),t}getAttributeValue(e){if(this.hasOwnProperty(e))return this[e];if(this._attributeCache||(this._attributeCache=new Map),this._attributeCache.has(e))return this._attributeCache.get(e);{const t=nl(this.attributeString,this.delim);let i;for(let[n,r]of t)if(n===e){i=r;break}return this._attributeCache.set(e,i),i}}}class Ja extends Ka{constructor(e){super(e),this.exons=[],this.parts=[]}addExon(e){this.exons.push(e),this.start=Math.min(this.start,e.start),this.end=Math.max(this.end,e.end)}addPart(e){this.parts.push(e)}assembleParts(){if(0===this.parts.length)return;this.parts.sort((function(e,t){return e.start-t.start}));let e=this.parts[0].start,t=this.parts[0].end;for(let i=1;i<this.parts.length;i++){const n=this.parts[i];if(!Wa(n.type))if(n.start<=t)t=Math.max(t,n.end);else{this.findExonContaining({start:e,end:t})||this.exons.push({start:e,end:t,psuedo:!0}),e=n.start,t=n.end}}this.findExonContaining({start:e,end:t})||(this.exons.push({start:e,end:t,psuedo:!0}),this.start=Math.min(this.start,e),this.end=Math.max(this.end,t));for(let e of this.parts){const t=e.type;Ga(t)?this.addCDS(e):Za(t)&&this.addUTR(e)}}findExonContaining({start:e,end:t}){for(let i of this.exons)if(i.end>=t&&i.start<=e)return i}addCDS(e){let t;const i=this.exons;for(let n of i)if(n.start<=e.start&&n.end>=e.end){t=n;break}t?(t.cdStart=t.cdStart?Math.min(e.start,t.cdStart):e.start,t.cdEnd=t.cdEnd?Math.max(e.end,t.cdEnd):e.end):console.error("No exon found spanning "+e.start+"-"+e.end),this.cdStart=this.cdStart?Math.min(e.start,this.cdStart):e.start,this.cdEnd=this.cdEnd?Math.max(e.end,this.cdEnd):e.end}addUTR(e){let t;const i=this.exons;for(let n=0;n<i.length;n++)if(i[n].start<=e.start&&i[n].end>=e.end){t=i[n];break}t?e.start===t.start&&e.end===t.end?t.utr=!0:(e.end<t.end&&(t.cdStart=e.end),e.start>t.start&&(t.cdEnd=e.start)):console.error("No exon found spanning "+cds.start+"-"+cds.end)}finish(){this.assembleParts();var e=this.cdStart,t=this.cdEnd;this.exons.sort((function(e,t){return e.start-t.start})),e&&this.exons.forEach((function(i){(i.end<e||i.start>t)&&(i.utr=!0)}))}popupData(e){const t=super.popupData(e);for(let i of this.exons)if(!i.pseudo&&e>=i.start&&e<i.end&&"function"==typeof i.popupData){t.push("<hr/>");const n=i.popupData(e);for(let e of n)t.push(e)}for(let i of this.parts)if(e>=i.start&&e<i.end&&"function"==typeof i.popupData){t.push("<hr/>");const n=i.popupData(e);for(let e of n)t.push(e)}return t}}function el(e,t){const i=t.format;if(e.length<9)return;const n="gff3"===i?"=":" ";return new Ka({source:ol(e[1]),type:e[2],chr:e[0],start:parseInt(e[3])-1,end:parseInt(e[4]),score:"."===e[5]?void 0:Number(e[5]),strand:e[6],phase:"."===e[7]?0:parseInt(e[7]),attributeString:e[8],delim:n})}function tl(e,t){const i=el(e,t);if(!i)return;const n=nl(i.attributeString,i.delim);for(let[e,t]of n){const n=e.toLowerCase();"color"===n||"colour"===n?i.color=Ds.createColorString(t):"ID"===e?i.id=t:"Parent"===e&&(i.parent=t)}return i}function il(e,t){const i=el(e,t);if(!i)return;const n=nl(i.attributeString,i.delim);let r,s;switch(i.type){case"gene":r="gene_id";break;case"transcript":r="transcript_id",s="gene_id";break;default:s="transcript_id"}for(let[e,t]of n){const n=e.toLowerCase();"color"===n||"colour"===n?i.color=Ds.createColorString(t):e===r?i.id=t:e===s&&(i.parent=t)}return i}function nl(e,t,i=!1){var n=[];for(let r of e.split(";")){r=r.trim();const e=r.indexOf(t);if(e>0&&e<r.length-1){const t=rl(ol(r.substring(0,e).trim(),i));let s=rl(ol(r.substring(e+1).trim(),i));n.push([t,s])}}return n}function rl(e){return e.startsWith('"')&&e.endsWith('"')&&(e=e.substr(1,e.length-2)),e}const sl=new Map([["%09","\t"],["%0A","\n"],["%0D","\r"],["%25","%"],["%3B",";"],["%3D","="],["%26","&"],["%2C",","]]);function ol(e,t=!1){if(!e.includes("%"))return e;if(t)return decodeURIComponent(e);let i="";for(let t=0;t<e.length;t++)if(37===e.charCodeAt(t)&&t<e.length-2){const n=e.substring(t,t+3);sl.has(n)?i+=sl.get(n):i+=n,t+=2}else i+=e.charAt(t);return i}class al{constructor(e){this.message=e}}function ll(e,t){if(e.length<3)return;t&&t.gffTags;const i=e[0],n=parseInt(e[1]),r=e.length>2?parseInt(e[2]):n+1;if(isNaN(n)||isNaN(r))return new al("Unparsable bed record.");const s=new yl({chr:i,start:n,end:r,score:1e3});try{if(e.length>3){if(e[3].indexOf(";")>0&&e[3].indexOf("=")>0){const i=nl(e[3],"=",!0);s.attributes={};for(let e of i)s.attributes[e[0]]=e[1],null!=t.nameField&&e[0]===t.nameField&&(s.name=e[1])}s.name||(s.name="."===e[3]?"":e[3])}if(e.length>4&&(s.score="."===e[4]?0:Number(e[4]),isNaN(s.score)))return s;if(e.length>5&&(s.strand=e[5],"."!==s.strand&&"+"!==s.strand&&"-"!==s.strand))return s;if(e.length>6&&(s.cdStart=parseInt(e[6]),isNaN(s.cdStart)))return s;if(e.length>7&&(s.cdEnd=parseInt(e[7]),isNaN(s.cdEnd)))return s;if(e.length>8&&"."!==e[8]&&"0"!==e[8]&&(s.color=Ds.createColorString(e[8])),e.length>11){const t=parseInt(e[9]);if(t>1e3)return s;const i=e[10].replace(/,$/,"").split(","),r=e[11].replace(/,$/,"").split(",");if(i.length!==r.length||t!==i.length)return s;const o=[];for(let e=0;e<t;e++){const t=n+parseInt(r[e]),s=t+parseInt(i[e]);o.push({start:t,end:s})}o.length>0&&(gl(o,s.cdStart,s.cdEnd),s.exons=o)}if(t){let i=t.thicknessColumn,n=t.colorColumn;n&&n<e.length&&(s.color=Ds.createColorString(e[n])),i&&i<e.length&&(s.thickness=e[i])}}catch(e){}return s}function hl(e,t){if(e.length<=15)return;return{swScore:Number.parseInt(e[1]),milliDiv:Number.parseInt(e[2]),milliDel:Number.parseInt(e[3]),milliIns:Number.parseInt(e[4]),chr:e[5],start:Number.parseInt(e[6]),end:Number.parseInt(e[7]),strand:e[9],repName:e[10],repClass:e[11],repFamily:e[12],repStart:Number.parseInt(e[13]),repEnd:Number.parseInt(e[14]),repLeft:Number.parseInt(e[15])}}function cl(e,t){var i=void 0===t.shift?0:1;if(e.length<=9+i)return;const n=parseInt(e[5+i]),r=parseInt(e[6+i]);var s={name:e[0+i],chr:e[1+i],strand:e[2+i],start:parseInt(e[3+i]),end:parseInt(e[4+i]),cdStart:n,cdEnd:r,id:e[0+i]};const o=pl(parseInt(e[7+i]),e[8+i],e[9+i]);return gl(o,n,r),s.exons=o,s}function dl(e,t){var i=void 0===t.shift?0:1;if(e.length<=11+i)return;const n=parseInt(e[5+i]),r=parseInt(e[6+i]),s={name:e[11+i],chr:e[1+i],strand:e[2+i],start:parseInt(e[3+i]),end:parseInt(e[4+i]),cdStart:n,cdEnd:r,id:e[0+i]},o=pl(parseInt(e[7+i]),e[8+i],e[9+i]);return gl(o,n,r),s.exons=o,s}function ul(e,t){var i=void 0===t.shift?0:1;if(e.length<=10+i)return;const n=parseInt(e[6+i]),r=parseInt(e[7+i]);var s={name:e[0+i],id:e[1+i],chr:e[2+i],strand:e[3+i],start:parseInt(e[4+i]),end:parseInt(e[5+i]),cdStart:n,cdEnd:r};const o=pl(parseInt(e[8+i]),e[9+i],e[10+i]);return gl(o,n,r),s.exons=o,s}function fl(e,t){if(e.length<21)return;const i=e[13],n=parseInt(e[15]),r=parseInt(e[16]),s=e[8].charAt(0),o=parseInt(e[17]),a=[],l=e[20].replace(/,$/,"").split(","),h=e[18].replace(/,$/,"").split(",");for(let e=0;e<o;e++){const t=parseInt(l[e]),i=t+parseInt(h[e]);a.push({start:t,end:i})}return new _l({chr:i,start:n,end:r,strand:s,exons:a,tokens:e})}function pl(e,t,i){const n=parseInt(e),r=t.replace(/,$/,"").split(","),s=i.replace(/,$/,"").split(","),o=[];for(let e=0;e<n;e++){const t=parseInt(r[e]),i=parseInt(s[e]);o.push({start:t,end:i})}return o}function gl(e,t,i){for(let n of e){const e=n.end,r=n.start;e<t||r>i?n.utr=!0:(t>=r&&t<=e&&(n.cdStart=t),i>=r&&i<=e&&(n.cdEnd=i))}}function ml(e,t){var i,n,r,s,o,a,l;if(!(e.length<9))return i=e[0],n=parseInt(e[1]),r=parseInt(e[2]),o=e[3],a=Number(e[4]),s=e[5].trim(),l=Number(e[6]),0===a&&(a=l),{chr:i,start:n,end:r,name:o,score:a,strand:s,signal:l,pValue:Number(e[7]),qValue:Number(e[8])}}function bl(e,t){if(e.length<=3)return;const i={chr:e[0],start:parseInt(e[1]),end:parseInt(e[2]),value:Number(e[3])};if(t){let n=t.colorColumn;n&&n<e.length&&(i.color=Ds.createColorString(e[n]))}return i}function wl(e,t){const i=t.wig;if(i&&"fixedStep"===i.format){const t=i.index*i.step+i.start,n=t+i.span,r=Number(e[0]);return++i.index,isNaN(r)?null:{chr:i.chrom,start:t,end:n,value:r}}if(i&&"variableStep"===i.format){if(e.length<2)return null;const t=parseInt(e[0],10)-1,n=t+i.span,r=Number(e[1]);return isNaN(r)?null:{chr:i.chrom,start:t,end:n,value:r}}return bl(e)}function vl(e,t){if(e.length<6)return;const i=["bin","chr","start","end","name","score","strand","refNCBI","refUCSC","observed","molType","class","valid","avHet","avHetSE","func","locType","weight","exceptions","submitterCount","submitters","alleleFreqCount","alleles","alleleNs","alleleFreqs","bitfields"],n={chr:e[1],start:Number.parseInt(e[2]),end:Number.parseInt(e[3]),name:e[4],score:Number.parseInt(e[5])},r=Math.min(e.length,i.length);for(let t=6;t<r;t++)n[i[t]]=e[t];return n}class yl{constructor(e){Object.assign(this,e)}getAttributeValue(e){return this.hasOwnProperty(e)?this[e]:this.attributes?this.attributes[e]:void 0}}class _l{constructor(e){Object.assign(this,e)}get score(){const e=this.tokens,t=parseInt(e[0]),i=parseInt(e[2]),n=parseInt(e[1]),r=parseInt(e[4]),s=parseInt(e[6]),o=parseInt(e[10]);return Math.floor(1e3*(t+i-n-r-s)/o)}get matches(){return this.tokens[0]}get misMatches(){return this.tokens[1]}get repMatches(){return this.tokens[2]}get nCount(){return this.tokens[3]}get qNumInsert(){return this.tokens[4]}get qBaseInsert(){return this.tokens[5]}get tNumInsert(){return this.tokens[6]}get tBaseInsert(){return this.tokens[7]}popupData(){return[{name:"chr",value:this.chr},{name:"start",value:this.start+1},{name:"end",value:this.end},{name:"strand",value:this.strand},{name:"score",value:this.score},{name:"match",value:this.matches},{name:"mis-match",value:this.misMatches},{name:"rep. match",value:this.repMatches},{name:"N's",value:this.nCount},{name:"Q gap count",value:this.qNumInsert},{name:"Q gap bases",value:this.qBaseInsert},{name:"T gap count",value:this.tNumInsert},{name:"T gap bases",value:this.tBaseInsert}]}}function xl(e,t){if(!(e.length<7)){var i=e[0],n=e[1],r=parseInt(e[2]),s=parseInt(e[3]),o=parseInt(e[4]),a=parseInt(e[5]),l=e[6],h={chr:i,name:n,junction_left:r,junction_right:s,num_junction_reads:o,num_spanning_frags:a,spanning_frag_coords:[],start:-1,end:-1},c=r,d=s;if(a>0)for(var u=l.split(","),f=0;f<u.length;f++){var p=u[f].split("-"),g=p[0],m=p[1];g<c&&(c=g),m>d&&(d=m),h.spanning_frag_coords.push({left:g,right:m})}return h.start=c,h.end=d,h}}function kl(e,t){if(e.length<7)return null;const i={chr:e[0],start:parseInt(e[1])-1,end:parseInt(e[2]),"Strongest SNP-risk allele":e[3],"Disease/Phenotype":e[4],"P-value":e[5],"Odds ratio or beta":e[6]};return e.length>6&&(i.PUBMEDID=`<a target = "blank" href = "https://www.ncbi.nlm.nih.gov/pubmed/${e[7]}">${e[7]}</a>`),i}function Cl(e,t){const i=t.customFormat;if(e.length<i.fields.length)return;const n=i.coords||0,r=e[i.chr],s=parseInt(e[i.start])-n,o={chr:r,start:s,end:void 0!==i.end?parseInt(e[i.end]):s+1};return i.fields&&i.fields.forEach((function(t,n){n!==i.chr&&n!==i.start&&n!==i.end&&(o[t]=e[n])})),o}function Sl(e,t){const i=t.columnNames;if(!i)throw Error("Sample names are not defined. Missing column headers?");const n=i.length-3,r=e[0],s=parseInt(e[1]),o=parseInt(e[2]),a=e.slice(3).map(Number);return a.length==n?{chr:r,start:s,end:o,values:a}:void console.warn(`${r}:${s}-${o} row contains ${a.length} sample columns instead of the expected ${n} columns. Skipping...`)}class Al{constructor(e){this.config=e,this.header={},e.nameField&&(this.header.nameField=e.nameField),this.skipRows=0,e.decode?(this.decode=e.decode,this.delimiter=e.delimiter||"\t"):e.format&&(this.header.format=e.format.toLowerCase(),this.setDecoder(this.header.format)),this.delimiter||(this.delimiter="\t")}async parseHeader(e){let t,i,n=this.header;for(;void 0!==(i=await e.nextLine());)if(i.startsWith("track")||i.startsWith("#track")){let e=El(i);Object.assign(n,e)}else if(i.startsWith("browser"));else if(i.startsWith("#columns")){let e=Ml(i);Object.assign(n,e)}else if(i.startsWith("##gff-version 3"))n.format="gff3";else if(i.startsWith("#gffTags"))n.gffTags=!0;else{if(i.startsWith("fixedStep")||i.startsWith("variableStep"))break;if(i.startsWith("#")){const e=i.split(this.delimiter||"\t");e.length>1&&(t=e)}else{this.setDecoder(n.format);const e=i.split(this.delimiter||"\t");try{const i=Object.assign({columnNames:t},n);if(this.decode(e,i))break;e.length>1&&(t=e)}catch(i){e.length>1&&(t=e)}}}if(t){n.columnNames=t;for(let e=0;e<t.length;e++)"color"===t[e]||"colour"===t[e]?n.colorColumn=e:"thickness"===t[e]&&(n.thicknessColumn=e)}return this.header=n,n}async parseFeatures(e){const t=[],i=this.decode,n=this.header.format,r=this.delimiter||"\t";let s,o=0,a=0;for(;void 0!==(s=await e.nextLine());){if(o++,o<=this.skipRows)continue;if(!s||s.startsWith("track")||s.startsWith("#")||s.startsWith("browser"))continue;if("wig"===n&&s.startsWith("fixedStep")){this.header.wig=Tl(s);continue}if("wig"===n&&s.startsWith("variableStep")){this.header.wig=Rl(s);continue}const e=s.split(r);if(e.length<1)continue;const l=i(e,this.header);l instanceof al?(a++,a>0&&console.error(`Error parsing line '${s}': ${l.message}`)):l&&t.push(l)}return i===zo&&function(e){if(0==e.length)return;const t=e[0];if(void 0===t.score&&void 0!==t.name){for(let t of e)if(!("number"==typeof(i=t.name)?i-i==0:"string"==typeof i&&""!==i.trim()&&(Number.isFinite?Number.isFinite(+i):isFinite(+i)))&&"."!==t.name)return;for(let t of e)t.score=Number(t.name),delete t.name}var i;const n=e.filter((e=>e.chr1!==e.chr2));for(let t of n){const i=Object.assign({},t);i.dup=!0,e.push(i),t.chr=t.chr1,t.start=t.start1,t.end=t.end1,i.chr=i.chr2,i.start=i.start2,i.end=i.end2}}(t),t}setDecoder(e){switch(e){case"narrowpeak":case"broadpeak":case"regionpeak":case"peaks":this.decode=ml,this.delimiter=this.config.delimiter||/\s+/;break;case"bedgraph":this.decode=bl,this.delimiter=/\s+/;break;case"wig":this.decode=wl,this.delimiter=this.config.delimiter||/\s+/;break;case"gff3":case"gff":this.decode=tl,this.delimiter="\t";break;case"gtf":this.decode=il,this.delimiter="\t";break;case"fusionjuncspan":this.decode=xl,this.delimiter=this.config.delimiter||/\s+/;break;case"gtexgwas":this.skipRows=1,this.decode=kl,this.delimiter="\t";break;case"refflat":this.decode=ul,this.delimiter=this.config.delimiter||/\s+/;break;case"genepred":this.decode=cl,this.delimiter=this.config.delimiter||/\s+/;break;case"genepredext":this.decode=dl,this.delimiter=this.config.delimiter||/\s+/;break;case"ensgene":this.decode=cl,this.header.shift=1,this.delimiter=this.config.delimiter||/\s+/;break;case"refgene":this.decode=dl,this.delimiter=this.config.delimiter||/\s+/,this.header.shift=1;break;case"bed":this.decode=ll,this.delimiter=this.config.delimiter||/\s+/;break;case"bedpe":case"hiccups":this.decode=zo,this.delimiter=this.config.delimiter||"\t";break;case"bedpe-domain":this.decode=Ho,this.headerLine=!0,this.delimiter=this.config.delimiter||"\t";break;case"bedpe-loop":this.decode=zo,this.delimiter=this.config.delimiter||"\t",this.header={colorColumn:7};break;case"interact":this.decode=za,this.delimiter=this.config.delimiter||/\s+/;break;case"snp":this.decode=vl,this.delimiter="\t";break;case"rmsk":this.decode=hl,this.delimiter="\t";break;case"gcnv":this.decode=Sl,this.delimiter="\t";break;default:const t=qo(e);void 0!==t?(this.decode=Cl,this.header.customFormat=t,this.delimiter=t.delimiter||"\t"):(this.decode=ll,this.delimiter=this.config.delimiter||/\s+/)}}}function El(e){const t={},i=e.split(/(?:")([^"]+)(?:")|([^\s"]+)(?=\s+|$)/g);let n;const r=[];for(let e of i)e&&0!==e.trim().length&&(e.endsWith("=")?n=e:n?(r.push(n+e),n=void 0):r.push(e));for(let e of r){if(!e)return;var s=e.split("=",2);if(2===s.length){const e=s[0].trim(),i=s[1].trim();if(t.hasOwnProperty(e)){let n=t[e];Array.isArray(n)?n.push(i):t[e]=[n,i]}else t[e]=i}}return"interact"==t.type?t.format="interact":"gcnv"===t.type&&(t.format="gcnv"),t}function Ml(e){let t={},i=e.split(/\s+/);if(2===i.length){i[1].split(";").forEach((function(e){let i=e.split("=");"color"===i[0]?t.colorColumn=Number.parseInt(i[1])-1:"thickness"===i[0]&&(t.thicknessColumn=Number.parseInt(i[1])-1)}))}return t}function Tl(e){const t=e.split(/\s+/);return{format:"fixedStep",chrom:t[1].split("=")[1],start:parseInt(t[2].split("=")[1],10)-1,step:parseInt(t[3].split("=")[1],10),span:t.length>4?parseInt(t[4].split("=")[1],10):1,index:0}}function Rl(e){const t=e.split(/\s+/);return{format:"variableStep",chrom:t[1].split("=")[1],span:t.length>2?parseInt(t[2].split("=")[1],10):1}}class Ll{static defaults={height:50,color:"rgb(0, 0, 150)",altColor:"rgb(0, 0, 150)",autoHeight:!1,visibilityWindow:void 0,supportHiDPI:!0};constructor(e,t){this.browser=t,this.init(e)}init(e){this.config=e,e.displayMode&&(e.displayMode=e.displayMode.toUpperCase());const t=Object.assign({},Ll.defaults);if(this.constructor.defaults)for(let e of Object.keys(this.constructor.defaults))t[e]=this.constructor.defaults[e];for(let n of Object.keys(t))this[n]=e.hasOwnProperty(n)?e[n]:t[n],"color"!==n&&"altColor"!==n||(this[n]=Qt(i=this[n])&&i.indexOf(",")>0&&!i.startsWith("rgb(")&&!i.startsWith("rgba(")?`rgb(${i})`:i);var i;e.name||e.label?this.name=e.name||e.label:ti(e.url)?this.name=e.url.name:Qt(e.url)&&!e.url.startsWith("data:")&&(this.name=ei(e.url)),this.url=e.url,this.config.type&&(this.type=this.config.type),this.id=void 0===this.config.id?this.name:this.config.id,this.order=e.order,this.autoscaleGroup=e.autoscaleGroup,this.removable=void 0===e.removable||e.removable,this.minHeight=e.minHeight||Math.min(25,this.height),this.maxHeight=e.maxHeight||Math.max(1e3,this.height),e.onclick&&(this.onclick=e.onclick,e.onclick=void 0),e.description&&("function"==typeof e.description?this.description=e.description:this.description=()=>e.description),e.hoverTextFields?this.hoverText=Il.bind(this):"function"==typeof this.config.hoverText&&(this.hoverText=this.config.hoverText)}get name(){return this._name}set name(e){this._name=e,this.trackView&&this.trackView.setTrackLabelName(e)}updateConfig(e){this.init(e)}clearCachedFeatures(){this.trackView&&this.trackView.clearCachedFeatures()}updateViews(){this.trackView&&this.trackView.updateViews()}getState(){const e={};for(let i of Object.keys(this.config))i.startsWith("_")||(void 0===(t=this.config[i])||"function"==typeof t||t instanceof File||t instanceof Promise)||(e[i]=this.config[i]);var t;for(let t of Object.keys(e)){if(t.startsWith("_"))continue;const i=this[t];i&&(Mo(i)||"boolean"==typeof i||"metadata"===t)&&(e[t]=i)}const i=Ll.defaults;if(this.constructor.defaults)for(let e of Object.keys(this.constructor.defaults))i[e]=this.constructor.defaults[e];for(let t of Object.keys(i))void 0!==this[t]&&i[t]!==this[t]&&(e[t]=this[t]);return!this.autoscale&&this.dataRange&&(e.min=this.dataRange.min,e.max=this.dataRange.max),e}get supportsWholeGenome(){return!0===this.config.supportsWholeGenome}hasSamples(){return!1}getGenomeId(){return this.browser.genome?this.browser.genome.id:void 0}setTrackProperties(e){if(this.disposed)return;const t={};let i;for(let n of Object.keys(e))switch(n.toLowerCase()){case"usescore":t.useScore=1===e[n]||"1"===e[n]||"on"===e[n]||!0===e[n];break;case"visibility":switch(e[n]){case"2":case"3":case"pack":case"full":t.displayMode="EXPANDED";break;case"4":case"squish":t.displayMode="SQUISHED";break;case"1":case"dense":t.displayMode="COLLAPSED"}break;case"color":case"altcolor":t[n]=e[n].startsWith("rgb(")?e[n]:"rgb("+e[n]+")";break;case"featurevisiblitywindow":case"visibilitywindow":t.visibilityWindow=Number.parseInt(e[n]);break;case"maxheightpixels":i=e[n].split(":"),3===i.length&&(t.minHeight=Number.parseInt(i[2]),t.height=Number.parseInt(i[1]),t.maxHeight=Number.parseInt(i[0]));break;case"viewlimits":if(!this.config.autoscale){i=e[n].split(":");let r,s=0;1==i.length?r=Number(i[0]):2==i.length&&(s=Number(i[0]),r=Number(i[1])),t.autoscale=!1,t.dataRange={min:s,max:r},this.viewLimitMin=s,this.viewLimitMax=r}case"name":t[n]=e[n];break;case"url":t.infoURL=e[n];break;case"type":const r=e[n];Bl.has(r)?t[n]=Bl.get(r):t[n]=r;break;case"graphtype":t.graphType=e[n];break;default:t[n]=e[n]}for(let e of Object.keys(t))if(!this.config.hasOwnProperty(e)||"name"===e&&this.config._derivedName){let i=t[e];if("true"===i&&(i=!0),"false"===i&&(i=!1),this[e]=i,"height"===e&&this.trackView)try{const e=Number.parseInt(i);this.trackView.setTrackHeight(e)}catch(e){console.error(e)}}}clickedFeatures(e){const t=e.viewport.cachedFeatures;if(!t||!Array.isArray(t)||0===t.length)return[];const i=e.genomicLocation,n=e.referenceFrame.bpPerPixel>.2?3*e.referenceFrame.bpPerPixel:.2;return bo(t,i-n,i+n)}extractPopupData(e,t){const i=new Set(["row","color","chr","start","end","cdStart","cdEnd","strand","alpha"]),n=[];let r,s;for(let t in e)if(e.hasOwnProperty(t)&&!i.has(t)&&Mo(e[t])){let i=e[t];n.push({name:Jt(t),value:i}),"alleles"===t?r=e[t]:"alleleFreqs"===t&&(s=e[t])}if(r&&s){r.endsWith(",")&&(r=r.substr(0,r.length-1)),s.endsWith(",")&&(s=s.substr(0,s.length-1));let i=r.split(","),o=s.split(",");if(o.length>1){let r=[];for(let e=0;e<o.length;e++)r.push({a:i[e],af:Number(o[e])});r.sort((function(e,t){return e.af-t.af}));let s=r[r.length-1].a;if(1===s.length)for(let i=r.length-2;i>=0;i--){let o=r[i].a;if(1===o.length){t||(t=this.getGenomeId());const i=Ll.getCravatLink(e.chr,e.start+1,s,o,t);console.log(i),i&&(n.push("<hr/>"),n.push({html:i}),n.push("<hr/>"))}}}}if(e.attributes)for(let t of Object.keys(e.attributes))n.push({name:t,value:e.attributes[t]});let o=`${e.chr}:${Xt(e.start+1)}-${Xt(e.end)}`;return e.strand&&(o+=` (${e.strand})`),n.push({name:"Location",value:o}),n}description(){const e=(e,t)=>`<div class="igv-track-label-popup-shim"><b>${e}: </b>${t}</div>`;let t='<div class="igv-track-label-popup">';if(this.url?ti(this.url)?t+=e("Filename",this.url.name):t+=e("URL",this.url):t=this.name,this.config){if(this.config.metadata)for(let i of Object.keys(this.config.metadata)){t+=e(i,this.config.metadata[i])}for(let i of Object.keys(this.config)){if(i.startsWith("_"))continue;let n=i.substr(0,1);if(n!==n.toLowerCase()){const n=this.config[i];n&&Mo(n)&&(t+=e(i,n))}}}return t+="</div>",t}getColorForFeature(e){return"function"==typeof this.color?this.color(feature):this.color}dispose(){this.disposed=!0;for(let e of Object.keys(this))this[e]=void 0}static getCravatLink(e,t,i,n,r){if("hg38"===r||"GRCh38"===r){return`<a target="_blank" href="https://run.opencravat.org/result/nocache/variant.html?chrom=${e.startsWith("chr")?e:"chr"+e}&pos=${t}&ref_base=${i}&alt_base=${n}"><b>Cravat ${i}->${n}</b></a>`}}}function Il(e){if(!this.hoverTextFields)return;const t=this.clickedFeatures(e);if(t&&t.length>0){let e="";for(let i=0;i<t.length;i++){if(10===i){e+="; ...";break}if(!t[i])continue;const n=t[i]._f||t[i];e.length>0&&(e+="\n"),e="";for(let t of this.hoverTextFields)e.length>0&&(e+="\n"),n.hasOwnProperty(t)?e+=n[t]:"function"==typeof n.getAttribute&&(e+=n.getAttribute(t))}return e}}const Bl=new Map([["wiggle_0","wig"],["bed","bed"],["bigBed","bigBed"],["bigWig","bigWig"]]);class Fl{constructor(e){switch(this.type=e||"seg",this.type){case"mut":this.sampleColumn=3,this.chrColumn=0,this.startColumn=1,this.endColumn=2,this.dataColumn=4;break;case"maf":this.sampleColumn=15,this.chrColumn=4,this.startColumn=5,this.endColumn=6,this.dataColumn=8;break;default:this.sampleColumn=0,this.chrColumn=1,this.startColumn=2,this.endColumn=3}}async parseHeader(e){let t;for(;void 0!==(t=await e.nextLine());)if(!t.startsWith("#")){const e=t.split("\t");this.header={headings:e};break}return this.header}async parseFeatures(e){const t=[];let i;this.header||(this.header=await this.parseHeader(e)),"seg"===this.type&&(this.dataColumn=this.header.headings.length-1),this.header.headings.length>5&&(i=this.extractExtraColumns(this.header.headings));const n=this.header.headings[this.dataColumn];let r;for(;void 0!==(r=await e.nextLine());){const e=r.split("\t"),s="seg"===this.type?Number(e[this.dataColumn]):e[this.dataColumn];if(e.length>this.dataColumn){const r=new Nl({sample:e[this.sampleColumn],chr:e[this.chrColumn],start:parseInt(e[this.startColumn])-1,end:parseInt(e[this.endColumn]),value:s,valueColumnName:n});if(i){const t=this.extractExtraColumns(e);r.setAttributes({names:i,values:t})}t.push(r)}}return t}extractExtraColumns(e){const t=[];for(let i=0;i<e.length;i++)i!==this.chrColumn&&i!==this.startColumn&&i!==this.endColumn&&i!==this.sampleColumn&&t.push(e[i]);return t}}class Nl{constructor({sample:e,chr:t,start:i,end:n,value:r,valueColumnName:s}){this.sample=e,this.chr=t,this.start=i,this.end=n,this.value=r,this.valueColumnName=s}setAttributes({names:e,values:t}){this.attributeNames=e,this.attributeValues=t}getAttribute(e){if(this.attributeNames){const t=this.attributeNames.indexOf(e);if(t>=0)return this.attributeValues[t]}}popupData(e,t){const i=new Set(["chr","start","end","sample","value","row","color","sampleKey","uniqueSampleKey","sampleId","chromosome","uniquePatientKey"]),n=this.chr+":"+Xt(this.start+1)+"-"+Xt(this.end),r=[{name:"Sample",value:this.sample},{name:"Location",value:n},{name:this.valueColumnName?Jt(this.valueColumnName):"Value",value:this.value}];if("mut"===e&&"hg38"===t){const e=this.extractCravatLink(t);e&&(r.push("<hr/>"),r.push({html:e}),r.push("<hr/>"))}if(this.attributeNames&&this.attributeNames.length>0)for(let e=0;e<this.attributeNames.length;e++)!i.has(this.attributeNames[e])&this.valueColumnName!==this.attributeNames[e]&&r.push({name:Jt(this.attributeNames[e]),value:this.attributeValues[e]});return r}extractCravatLink(e){let t,i;if(this.attributeNames&&this.attributeNames.length>0)for(let n=0;n<this.attributeNames.length;n++)if(t||"Reference_Allele"!==this.attributeNames[n]||(t=this.attributeValues[n]),!i&&this.attributeNames[n].startsWith("Tumor_Seq_Allele")&&this.attributeValues[n]!==t&&(i=this.attributeValues[n]),t&&i)return Ll.getCravatLink(this.chr,this.start+1,t,i,e)}}function Ol(e){const t=new Pl;t.chr=e[0],t.pos=parseInt(e[1]),t.names=e[2],t.referenceBases=e[3],t.alternateBases=e[4],t.quality=e[5],t.filter=e[6],t.info={};const i=e[7];if(i)for(let e of i.split(";")){var n=e.split("=");t.info[n[0]]=n[1]}return t.init(),t}class Pl{init(){const e=this.referenceBases,t=this.alternateBases;if(this.info&&(this.info.VT?this.type=this.info.VT:this.info.SVTYPE?this.type="SV":this.info.PERIOD&&(this.type="STR")),void 0===this.type&&(this.type=function(e,t){const i=e.length;if(void 0===t)return"UNKNOWN";if(0===t.trim().length||"<NON_REF>"===t||"<*>"===t||"."===t)return"NONVARIANT";{const e=t.split(",").map((function(e){return 1===i&&1===e.length?"SNP":"<NON_REF>"===e?"NONVARIANT":"OTHER"}));let n=e[0];for(let t of e)if(t!==n)return"MIXED";return n}}(e,t)),"NONVARIANT"===this.type&&(this.heterozygosity=0),this.info.END)this.start=this.pos-1,this.info.CHR2&&this.info.CHR2!==this.chr?this.end=this.start+1:this.end=Number.parseInt(this.info.END);else if("NONVARIANT"===this.type)this.start=this.pos-1,this.end=this.start+e.length;else{const i=t.split(",").filter((e=>e.length>0));this.alleles=[],this.start=void 0,this.end=void 0;for(let t of i)if(this.alleles.push(t),"SV"!==this.type&&zl(t)){let i=t.length,n=e.length;const r=Math.min(i,n);let s=0;for(;s<r&&e.charCodeAt(s)===t.charCodeAt(s);)s++,i--,n--;for(;i>0&&n>0;){const r=s+i-1,o=s+n-1;if(t.charCodeAt(r)!==e.charCodeAt(o))break;i--,n--}for(;i>0&&n>0;){const r=s,o=s;if(t.charCodeAt(r)!==e.charCodeAt(o))break;s++,i--,n--}const o=this.pos+s-1,a=o+n;this.start=void 0===this.start?o:Math.min(this.start,o),this.end=void 0===this.end?a:Math.max(this.end,a)}void 0===this.start&&(this.start=this.pos-1,this.end=this.pos)}}popupData(e,t){const i=`${Xt(this.pos)}`,n=this.start===this.end?`${Xt(this.start)} | ${Xt(this.start+1)}`:`${Xt(this.start+1)}-${Xt(this.end)}`,r=[{name:"Chr",value:this.chr},{name:"Pos",value:i},{name:"Loc",value:n},{name:"ID",value:this.names?this.names:""},{name:"Ref",value:this.referenceBases},{name:"Alt",value:this.alternateBases.replace("<","<")},{name:"Qual",value:this.quality},{name:"Filter",value:this.filter}];if("SNP"===this.type){let e=this.referenceBases;if(1===e.length){let i=this.alternateBases.split(",");for(let n of i)if(1===n.length){let i=Ll.getCravatLink(this.chr,this.pos,e,n,t);i&&(r.push("<hr/>"),r.push({html:i}))}}}if(this.hasOwnProperty("heterozygosity")&&r.push({name:"Heterozygosity",value:this.heterozygosity}),this.info){r.push({html:'<hr style="border-top: dotted 1px;border-color: #c9c3ba" />'});for(let e of Object.keys(this.info))r.push({name:e,value:Hl(decodeURIComponent(this.info[e]))})}return r}getInfo(e){return this.info?this.info[e]:void 0}isRefBlock(){return"NONVARIANT"===this.type}}const Dl=new Set(["A","C","T","G"].map((e=>e.charCodeAt(0))));function zl(e){for(let t=0;t<e.length;t++)if(!Dl.has(e.charCodeAt(t)))return!1;return!0}function Hl(e,t){return void 0===t&&(t=","),Array.isArray(e)?e.join(t):e}class Vl{construtor(){}async parseHeader(e,t){const i={};i.chrAliasTable=new Map;let n=await e.nextLine();if(!n.startsWith("##fileformat"))throw new Error("Invalid VCF file: missing fileformat line");for(i.version=n.substr(13);void 0!==(n=await e.nextLine())&&n.startsWith("#");){let e;const s={};if(n.startsWith("##")){if(n.startsWith("##INFO")||n.startsWith("##FILTER")||n.startsWith("##FORMAT")){const t=n.indexOf("<"),o=n.lastIndexOf(">");if(!(t>2&&o>0)){console.log("Malformed VCF header line: "+n);continue}const a=n.substring(2,t-1);i[a]||(i[a]={});const l=Kt(n.substring(t+1,o-1),",");for(let t of l){var r=t.split("=");r.length>1&&("ID"===r[0]?e=r[1]:s[r[0]]=r[1])}e&&(i[a][e]=s)}else if(n.startsWith("##contig")&&t){const e=n.indexOf("<ID=");let r=n.indexOf(",",e);-1==r&&(r=n.indexOf(">",e));const s=n.substring(e+4,r),o=t.getChromosomeName(s);i.chrAliasTable.set(o,s)}}else if(n.startsWith("#CHROM")){const e=n.split("\t");if(e.length>8){i.callSets=[];for(let t=9;t<e.length;t++)i.callSets.push({id:t,name:e[t]})}}}return this.header=i,i}async parseFeatures(e){const t=[],i=this.header.callSets,n=8+(i?i.length+1:0);let r;for(;void 0!==(r=await e.nextLine());)if(r&&!r.startsWith("#")){const e=r.split("\t");if(e.length===n){const n=Ol(e);if(n.header=this.header,t.push(n),e.length>9){const t=Ul(e[8].split(":"));n.calls={};for(let r=9;r<e.length;r++){const s=e[r],o=i[r-9],a={callSetName:o.name,info:{}};n.calls[o.id]=a,s.split(":").forEach((function(e,i){if(i===t.genotypeIndex)a.genotype=[],e.split(/[\|\/]/).forEach((function(e){a.genotype.push("."===e?e:parseInt(e))}));else a.info[t.fields[i]]=e}))}}n.info&&n.info.CHR2&&n.info.END&&t.push(ql(n))}}return t}}function Ul(e){const t={genotypeIndex:-1,fields:e};for(let i=0;i<e.length;i++)"GT"===e[i]&&(t.genotypeIndex=i);return t}function ql(e){const t=e.info.CHR2,i=Number.parseInt(e.info.END);return{chr:t,start:i-1,end:i,_f:e}}class jl{constructor(e){if(this.config=e,e.columns){if(void 0===e.columns.chromosome||void 0===e.columns.position||void 0===e.columns.value)throw Error("columns property must define chrCol, posCol, and valueCol");this.posCol=e.columns.position-1,this.chrCol=e.columns.chromosome-1,this.valueCol=e.columns.value-1}else this.posCol=2,this.chrCol=1,this.valueCol=3}async parseHeader(e){const t=await e.nextLine();return this.parseHeaderLine(t)}parseHeaderLine(e){if(this.columns=e.split(/\t/),!this.config.columns)for(let e=0;e<this.columns.length;e++){switch(this.columns[e].toLowerCase()){case"chr":case"chromosome":case"chr_id":this.chrCol=e;break;case"bp":case"pos":case"position":case"chr_pos":this.posCol=e;break;case"p":case"pval":case"pvalue":case"p-value":case"p.value":this.valueCol=e}}return this.columns}async parseFeatures(e){const t=[],i=e.nextLine();let n;for(this.columns||this.parseHeaderLine(i);void 0!==(n=e.nextLine());){const e=n.split(/\t/);if(e.length===this.columns.length){const i=e[this.chrCol],r=parseInt(e[this.posCol])-1,s=r+1,o=Number(e[this.valueCol]);t.push(new $l({chr:i,start:r,end:s,value:o,line:n,columns:this.columns}))}}return t}}class $l{constructor({chr:e,start:t,end:i,value:n,line:r,columns:s}){this.chr=e,this.start=t,this.end=i,this.value=n,this.line=r,this.columns=s}popupData(){const e=this.line.split(/\t/);return this.columns.map((function(t,i){return{name:t,value:e[i]}}))}getAttribute(e){const t=this.line.split(/\t/);for(let i=0;i<this.columns.length;i++)if(this.columns[i]===e)return t[i]}}var Wl=new RegExp("([^:]*)\\(([^)]*)\\)"),Gl=new RegExp("([^:]*):([^(]*)\\(([^)]*)\\)");class Zl{constructor(e){const t=e?e.decode:void 0;this.nameField=e?e.nameField:void 0,this.skipRows=0,this.decode=t||eh,this.delimiter="\t"}async parseHeader(e){let t,i;for(;(t=await e.nextLine())&&(t.startsWith("track")||t.startsWith("#")||t.startsWith("browser"));)if(t.startsWith("track")||t.startsWith("#track")){let e=Yl(t);i?Object.assign(i,e):i=e}else if(t.startsWith("#columns")){let e=Kl(t);i?Object.assign(i,e):i=e}else t.startsWith("##gff-version 3")&&(this.format="gff3",i||(i={}),i.format="gff3");return this.header=i,i}async parseFeatures(e){const t=[],i=this.decode,n=this.delimiter||"\t";let r,s=0;for(;void 0!==(r=e.nextLine());){if(s++,s<=this.skipRows||r.startsWith("track")||r.startsWith("#")||r.startsWith("browser"))continue;let e=o();if(e.length<1)continue;if(!this.aed){this.aed=Xl(e);continue}const n=i.call(this,e,undefined);n&&t.push(n)}return t;function o(){for(var e,t,i=[],s="",o=!1;r||""===r;){for(e=0;e<r.length;e++)(t=r.charAt(e))===n?o?s+=t:(i.push(s),s=""):'"'===t?e+1<r.length&&'"'===r.charAt(e+1)?(o&&(s+='"'),e++):o=!o:s+=t;if(!o)break;s+="\n",r=nextLine()}return i.push(s),i}}}function Ql(e){var t=Gl.exec(e);if(t)return{namespace:t[1],name:t[2],type:t[3]};if(t=Wl.exec(e))return{namespace:"?",name:t[1],type:t[2]};throw new Error("Error parsing the header row of AED file - column not in ns:name(ns:type) format")}function Xl(e){var t,i,n;for(t={columns:[],metadata:{}},i=0;i<e.length;i++)n=Ql(e[i]),t.columns.push(n);return t}function Yl(e){const t={},i=e.split(/(?:")([^"]+)(?:")|([^\s"]+)(?=\s+|$)/g);let n;const r=[];for(let e of i)e&&0!==e.trim().length&&(e.endsWith("=")>0?n=e:n?(r.push(n+e),n=void 0):r.push(e));for(let e of r){if(!e)return;var s=e.split("=",2);if(2===s.length){const e=s[0].trim(),i=s[1].trim();t[e]=i}}return t}function Kl(e){let t={},i=e.split(/\s+/);if(2===i.length){i[1].split(";").forEach((function(e){let i=e.split("=");"color"===i[0]?t.colorColumn=Number.parseInt(i[1])-1:"thickness"===i[0]&&(t.thicknessColumn=Number.parseInt(i[1])-1)}))}return t}function Jl(e,t){var i,n,r=e.columns;this.aed=e,this.allColumns=t,this.chr=null,this.start=null,this.end=null,this.score=1e3,this.strand=".",this.cdStart=null,this.cdEnd=null,this.name=null,this.color=null;for(let e=0;e<t.length;e++)if(i=t[e]){"aed:Integer"===(n=r[e]).type&&(i=parseInt(i));var s=[];if(n.namespace.length>0)for(let e=0;e<n.namespace.length;e++)s.push(n.namespace.charCodeAt(e));"bio"===n.namespace.trim()?"sequence"===n.name?this.chr=i:"start"===n.name?this.start=i:"end"===n.name?this.end=i:"cdsMin"===n.name?this.cdStart=i:"cdsMax"===n.name?this.cdEnd=i:"strand"===n.name&&(this.strand=i):"aed"===n.namespace?"name"===n.name&&(this.name=i):"style"===n.namespace&&"color"===n.name&&(this.color=Ds.createColorString(i))}}function eh(e,t){var i,n,r,s,o,a,l=0,h=this.aed.columns;if(e.length===h.length){for(a=0;a<e.length;a++)s=h[a],""!==(r=e[a])&&l++,"name"===s.name&&"aed"===s.namespace?i=r:"value"===s.name&&"aed"===s.namespace&&(n=r);if(2===l&&i&&n)return o=Ql(i),this.aed.metadata[o.namespace]||(this.aed.metadata[o.namespace]={}),void(this.aed.metadata[o.namespace][o.name]||(this.aed.metadata[o.namespace][o.name]={type:o.type,value:n}));var c=new Jl(this.aed,e);if(c.chr&&(c.start||0===c.start)&&c.end)return c;console.log("Cannot parse feature: "+e.join(","))}else console.log("Corrupted AED file row: "+e.join(","))}Jl.prototype.popupData=function(){for(var e=[],t=this.aed,i=0;i<this.allColumns.length;i++){var n=this.allColumns[i],r=t.columns[i].name;"sequence"!==r&&"color"!==r&&n&&e.push({name:r,value:n})}return e};class th{constructor(e,t){this.littleEndian=void 0===t||t,this.position=0,this.view=e,this.length=e.byteLength}available(){return this.length-this.position}remLength(){return this.length-this.position}hasNext(){return this.position<this.length-1}getByte(){var e=this.view.getUint8(this.position,this.littleEndian);return this.position++,e}getShort(){var e=this.view.getInt16(this.position,this.littleEndian);return this.position+=2,e}getUShort(){var e=this.view.getUint16(this.position,this.littleEndian);return this.position+=2,e}getInt(){var e=this.view.getInt32(this.position,this.littleEndian);return this.position+=4,e}getUInt(){var e=this.view.getUint32(this.position,this.littleEndian);return this.position+=4,e}getLong(){var e=[];e[0]=this.view.getUint8(this.position),e[1]=this.view.getUint8(this.position+1),e[2]=this.view.getUint8(this.position+2),e[3]=this.view.getUint8(this.position+3),e[4]=this.view.getUint8(this.position+4),e[5]=this.view.getUint8(this.position+5),e[6]=this.view.getUint8(this.position+6),e[7]=this.view.getUint8(this.position+7);var t=0;if(this.littleEndian)for(let i=e.length-1;i>=0;i--)t=256*t+e[i];else for(let i=0;i<e.length;i++)t=256*t+e[i];return this.position+=8,t}getString(e){for(var t,i="";0!==(t=this.view.getUint8(this.position++))&&(i+=String.fromCharCode(t),!e||i.length!==e););return i}getFixedLengthString(e){var t,i,n="";for(t=0;t<e;t++)(i=this.view.getUint8(this.position++))>0&&(n+=String.fromCharCode(i));return n}getFixedLengthTrimmedString(e){var t,i,n="";for(t=0;t<e;t++)(i=this.view.getUint8(this.position++))>32&&(n+=String.fromCharCode(i));return n}getFloat(){var e=this.view.getFloat32(this.position,this.littleEndian);return this.position+=4,e}getDouble(){var e=this.view.getFloat64(this.position,this.littleEndian);return this.position+=8,e}skip(e){return this.position+=e,this.position}getVPointer(){var e=this.position,t=this.view.getUint8(e+1)<<8|this.view.getUint8(e),i=4294967296*(255&this.view.getUint8(e+6))+16777216*(255&this.view.getUint8(e+5))+65536*(255&this.view.getUint8(e+4))+256*(255&this.view.getUint8(e+3))+(255&this.view.getUint8(e+2));return this.position+=8,new ih(i,t)}}class ih{constructor(e,t){this.block=e,this.offset=t}isLessThan(e){return this.block<e.block||this.block===e.block&&this.offset<e.offset}isGreaterThan(e){return this.block>e.block||this.block===e.block&&this.offset>e.offset}isEqualTo(e){return this.block===e.block&&this.offset===e.offset}print(){return this.block+":"+this.offset}}function nh(e,t){if(0===e.length)return e;if(e.sort((function(e,t){const i=e.minv.block-t.minv.block;return 0!==i?i:e.minv.offset-t.minv.offset})),e.length<=1)return e;t&&(e=e.filter((e=>e.maxv.isGreaterThan(t))));const i=[];let n;for(let t of e)n&&rh(n,t)?t.maxv.isGreaterThan(n.maxv)&&(n.maxv=t.maxv):(i.push(t),n=t);return i}function rh(e,t){t.minv.block,e.maxv.block;return e.maxv.block-e.minv.block<5e6}class sh{constructor(e){this.tabix=!0}parse(e,t){const i=new th(new DataView(e)),n=i.getInt();if(21582659!==n)throw 38359875===n?Error("CSI version 2 is not supported. Please enter an issue at https://github.com/igvteam/igv.js"):Error("Not a CSI index");this.indices=[],this.blockMin=Number.MAX_SAFE_INTEGER,this.lastBlockPosition=[],this.sequenceIndexMap={},this.minShift=i.getInt(),this.depth=i.getInt();const r=[];let s=0;if(i.getInt()>=28){i.getInt(),i.getInt(),i.getInt(),i.getInt(),i.getInt(),i.getInt();const e=i.getInt(),n=i.position+e;let s=0;for(;i.position<n;){let e=i.getString();t&&(e=t.getChromosomeName(e)),this.sequenceIndexMap[e]=s,r[s]=e,s++}}const o=this.bin_limit()+1,a=i.getInt();for(let e=0;e<a;e++){const t=[],n=[],r=i.getInt();for(let e=0;e<r;e++){const e=i.getInt();if(n[e]=i.getVPointer(),e>o)i.getInt(),i.getVPointer(),i.getVPointer(),i.getLong(),i.getLong();else{t[e]=[];const n=i.getInt();for(let r=0;r<n;r++){const n=i.getVPointer(),r=i.getVPointer();n&&r&&(n.block<this.blockMin&&(this.blockMin=n.block),r.block>s&&(s=r.block),t[e].push([n,r]))}}}r>0&&(this.indices[e]={binIndex:t,loffset:n})}this.lastBlockPosition=s}get chromosomeNames(){return Object.keys(this.sequenceIndexMap)}chunksForRange(e,t,i){const n=this.indices[e];if(n){const e=this.reg2bins(t,i);if(0==e.length)return[];const r=[];for(let t of e)for(let e=t[0];e<=t[1];e++)if(n.binIndex[e]){const t=n.binIndex[e];for(let i of t){const t=i[0],n=i[1];r.push({minv:t,maxv:n,bin:e})}}return nh(r,n.loffset[e[0]])}return[]}reg2bins(e,t){(e-=1)<1&&(e=1),t>2**34&&(t=2**34),t-=1;let i=0,n=0,r=this.minShift+3*this.depth;const s=[];for(;i<=this.depth;r-=3,n+=1<<3*i,i+=1){const i=n+(e>>r),o=n+(t>>r);s.push([i,o])}return s}bin_limit(){return((1<<3*(this.depth+1))-1)/7}}class oh{constructor(){}async parse(e,t,i){const n=[];let r=Number.MAX_SAFE_INTEGER,s=0;const o=new th(new DataView(e)),a=o.getInt(),l={};if(!(21578050===a||t&&21578324===a))throw new Error(indexURL+" is not a "+(t?"tabix":"bai")+" file");{const e=o.getInt();if(t){o.getInt(),o.getInt(),o.getInt(),o.getInt(),o.getInt(),o.getInt(),o.getInt();for(let t=0;t<e;t++){let e=o.getString();i&&(e=i.getChromosomeName(e)),l[e]=t}}for(let t=0;t<e;t++){const e={},i=[],a=o.getInt();for(let t=0;t<a;t++){const t=o.getInt();if(37450===t)o.getInt(),o.getVPointer(),o.getVPointer(),o.getLong(),o.getLong();else{e[t]=[];const i=o.getInt();for(let n=0;n<i;n++){const i=o.getVPointer(),n=o.getVPointer();i&&n&&(i.block<r&&(r=i.block),n.block>s&&(s=n.block),e[t].push([i,n]))}}}const l=o.getInt();for(let e=0;e<l;e++){const e=o.getVPointer();i.push(e)}a>0&&(n[t]={binIndex:e,linearIndex:i})}this.firstBlockPosition=r,this.lastBlockPosition=s,this.indices=n,this.sequenceIndexMap=l,this.tabix=t}}get chromosomeNames(){return Object.keys(this.sequenceIndexMap)}chunksForRange(e,t,i){const n=this.indices[e];if(n){const e=function(e,t){const i=[];t>=1<<29&&(t=1<<29);return--t,i.push([0,0]),i.push([1+(e>>26),1+(t>>26)]),i.push([9+(e>>23),9+(t>>23)]),i.push([73+(e>>20),73+(t>>20)]),i.push([585+(e>>17),585+(t>>17)]),i.push([4681+(e>>14),4681+(t>>14)]),i}(t,i),r=[];for(let t of e)for(let e=t[0];e<=t[1];e++)if(n.binIndex[e]){const t=n.binIndex[e];for(let e of t){const t=e[0],i=e[1];r.push({minv:t,maxv:i})}}const s=n.linearIndex.length;let o;const a=Math.min(t>>14,s-1),l=Math.min(i>>14,s-1);for(let e=a;e<=l;e++){const t=n.linearIndex[e];if(t){o=t;break}}return nh(r,o)}return[]}}class ah{constructor(){}async parse(e,t){let i=0;this.chrIndex={},this.lastBlockPosition=[];const n=new th(new DataView(e));!function(e){e.getInt(),e.getInt();const t=e.getInt();if(e.getString(),e.getLong(),e.getLong(),e.getString(),e.getInt(),t>=3){let t=e.getInt();for(;t-- >0;)e.getString(),e.getString()}}(n);let r=n.getInt();for(;r-- >0;){let e=n.getString();t&&(e=t.getChromosomeName(e));const r=n.getInt(),s=n.getInt(),o=n.getInt();n.getInt(),n.getInt();let a=n.getLong();const l=[];for(let e=0;e<s;e++){const e=n.getLong();l.push({min:a,max:e}),a=e,e>i&&(i=e)}this.chrIndex[e]={chr:e,blocks:l,longestFeature:o,binWidth:r}}this.lastBlockPosition=i}get chromosomeNames(){return Object.keys(this.chrIndex)}chunksForRange(e,t,i){const n=this.chrIndex[e];if(n){const e=n.blocks,r=n.longestFeature,s=n.binWidth,o=Math.max(t-r,0),a=Math.floor(o/s);if(a>=e.length)return[];{const t=Math.min(Math.floor((i-1)/s),e.length-1),n=e[a].min,r=e[t].max;if(0===r-n)return[];return[{minv:{block:n,offset:0},maxv:{block:r,offset:0}}]}}}}async function lh(e,t,i){let n=await no.loadArrayBuffer(e,To(t)),r=new DataView(n);if(31===r.getUint8(0)&&139===r.getUint8(1)){n=Ts(n).buffer,r=new DataView(n)}switch(r.getInt32(0,!0)){case 21578050:return async function(e,t){const i=new oh;return await i.parse(e,!1,t),i}(n,i);case 21578324:return async function(e,t){const i=new oh;return await i.parse(e,!0,t),i}(n,i);case 21582659:return async function(e,t){const i=new sh;return i.parse(e,t),i}(n,i);case 1480870228:return async function(e,t){const i=new ah;return i.parse(e,t),i}(n,i);case 38359875:throw Error("CSI version 2 is not supported.");default:throw Error(`Unrecognized index type: ${e}`)}}function hh(e){return"string"==typeof e||e instanceof String?new ch(e):new dh(e)}class ch{constructor(e){this.data=e,this.ptr=0}nextLine(){var e=this.ptr,t=this.data.indexOf("\n",e),i=this.data;if(t>0)return this.ptr=t+1,t>e&&"\r"===i.charAt(t-1)?i.substring(e,t-1):i.substring(e,t);var n=i.length;return this.ptr=n,e>=n?void 0:i.substring(e)}}class dh{constructor(e){this.data=e,this.length=this.data.length,this.ptr=0}nextLine(){var e,t;if(t="",!(this.ptr>=this.length)){for(var i=this.ptr;i<this.length;i++)if("\r"!==(e=String.fromCharCode(this.data[i]))){if("\n"===e)break;t+=e}return this.ptr=i+1,t}}}class uh{constructor(e){this.config=e,this.filePtr=0,this.bufferPtr=0,this.buffer}async nextLine(){let e;try{for(;;){const t=this.buffer?this.buffer.length:0;for(;this.bufferPtr<t;){const t=String.fromCharCode(this.buffer[this.bufferPtr++]);if("\r"!==t){if("\n"===t)return e;e=e?e+t:t}}if(this.eof)return e;await this.readNextBlock()}}catch(t){return console.warn(t),this.eof=!0,e}}async readNextBlock(){const e=To(this.config,{range:{start:this.filePtr,size:26}}),t=Rs(await no.loadArrayBuffer(this.config.url,e));if(0===t)this.eof=!0,this.buffer=void 0;else{const e=To(this.config,{range:{start:this.filePtr,size:t}}),i=await no.loadArrayBuffer(this.config.url,e);i.byteLength<t&&(this.eof=!0),this.buffer=Ts(i),0==this.buffer.byteLength&&(this.eof=!0),this.bufferPtr=0,this.filePtr+=i.byteLength}}}const fh=e=>{const t=ArrayBuffer.isView(e)?e:new Uint8Array(e);return 1+(t[17]<<8|t[16])};class ph{constructor(e){this.config=e,this.cacheBlocks=0!=e.cacheBlocks,this.cache=void 0}async getData(e,t){const i=e.block,n=t.block,r=0===t.offset,s=await this.getInflatedBlocks(i,n,r);if(1===s.length)return s[0];let o=0;for(const e of s)o+=e.byteLength;const a=new Uint8Array(o);let l=0;for(const e of s)a.set(e,l),l+=e.byteLength;return a}async getInflatedBlocks(e,t,i){if(this.cacheBlocks){const n=this.cache;if(n&&n.startBlock<=e&&(n.endBlock>=t||i&&n.nextEndBlock===t)){const i=e-n.startBlock,r=t-n.startBlock;return mh(n.buffer,i,r)}{let r;if(!n||n.startBlock>t||n.endBlock<e)r=await this.loadBLockData(e,t,{skipEnd:i});else{const s=[];if(e<n.startBlock){const t=await this.loadBLockData(e,n.startBlock,{skipEnd:!0});s.push(t)}let o;if(e<=n.startBlock&&t>=n.endBlock)o=n.buffer;else{const i=Math.max(0,e-n.startBlock);let r;if(t>=n.endBlock)r=n.buffer.byteLength;else{const e=gh(n.buffer);for(let i=0;i<e.length-1;i++)if(n.startBlock+e[i]===t){r=e[i+1];break}}o=n.buffer.slice(i,r)}if(s.push(o),t>n.endBlock){const e=await this.loadBLockData(n.endBlock,t,{skipStart:!0,skipEnd:i});s.push(e)}r=function(e){if(1===e.length)return e[0];let t=0;for(const i of e)t+=i.byteLength;const i=new Uint8Array(t);let n=0;for(const t of e)i.set(new Uint8Array(t),n),n+=t.byteLength;return i.buffer}(s)}let s=t;if(i){const e=gh(r);t=e[e.length-1]}return this.cache={startBlock:e,endBlock:t,nextEndBlock:s,buffer:r},mh(r)}}return mh(await this.loadBLockData(e,t,{skipEnd:i}))}async loadBLockData(e,t,i){const n=this.config,r=i&&i.skipStart;let s=0;if(!(i&&i.skipEnd)){const e=To(n,{range:{start:t,size:26}}),i=await no.loadArrayBuffer(n.url,e);s=fh(i)}if(r){const t=To(n,{range:{start:e,size:26}}),i=await no.loadArrayBuffer(n.url,t);e+=fh(i)}const o=To(n,{range:{start:e,size:t+s-e}});return no.loadArrayBuffer(n.url,o)}}function gh(e){const t=e.byteLength;let i=0;const n=[0];for(;i<t;){const r=new Uint8Array(e,i);i+=1+(r[17]<<8|r[16]),i<t&&n.push(i)}return n}function mh(e,t,i){const n=[];let r=t=t||0;const s=e.byteLength-18;for(;r<s;)try{const t=new Uint8Array(e,r,18),s=t[11]<<8|t[10],o=t[17]<<8|t[16],a=12+s+r,l=e.byteLength-a,h=o-s-18;if(l<h||h<=0)break;const c=new Uint8Array(e,a,h),d=As(c);if(n.push(d),i===r)break;r+=o+1}catch(e){console.error(e);break}return n}class bh{constructor(e,t){var i;this.config=e||{},this.genome=t,this.indexURL=e.indexURL,this.indexed=e.indexed||void 0!==this.indexURL,this.queryable=this.indexed,ti(this.config.url)?this.filename=this.config.url.name:Fo(this.config.url)?(this.indexed=!1,this.dataURI=e.url):(i=ni(this.config.url),this.filename=e.filename||i.file),this.parser=this.getParser(this.config),"vcf"!==this.config.format||this.config.indexURL||console.warn("Warning: index file not specified. The entire vcf file will be loaded.")}async defaultVisibilityWindow(){if(this.config.indexURL){const e=await this.getIndex();if(e&&e.lastBlockPosition){let t=0;const i=1e4;for(let i of e.chromosomeNames){const e=this.genome.getChromosome(i);e&&(t+=e.bpLength)}return Math.round(t/e.lastBlockPosition*i)}}}async readFeatures(e,t,i){return await this.getIndex()?(this.indexed=!0,this.loadFeaturesWithIndex(e,t,i)):this.dataURI?(this.indexed=!1,this.loadFeaturesFromDataURI()):(this.indexed=!1,this.loadFeaturesNoIndex())}async readHeader(){if(this.dataURI)return await this.loadFeaturesFromDataURI(this.dataURI),this.header;if(this.config.indexURL){const e=await this.getIndex();if(!e)throw new Error("Unable to load index: "+this.config.indexURL);let t;if(e.tabix)this._blockLoader=new ph(this.config),t=new uh(this.config);else{const i=Object.values(e.chrIndex).flatMap((e=>e.blocks)).map((e=>e.max)).reduce(((e,t)=>Math.min(e,t)),Number.MAX_SAFE_INTEGER),n=To(this.config,{bgz:e.tabix,range:{start:0,size:i}});t=hh(await no.loadString(this.config.url,n))}return this.header=await this.parser.parseHeader(t),this.header}{const e=To(this.config),t=await no.loadString(this.config.url,e);let i=hh(t);return this.header=await this.parser.parseHeader(i),i=hh(t),this.features=await this.parser.parseFeatures(i),this.header}}getParser(e){switch(e.format){case"vcf":return new Vl(e);case"seg":return new Fl("seg");case"mut":return new Fl("mut");case"maf":return new Fl("maf");case"gwas":return new jl(e);case"aed":return new Zl(e);default:return new Al(e)}}async loadFeaturesNoIndex(){if(this.features){const e=this.features;return delete this.features,e}{const e=To(this.config),t=await no.loadString(this.config.url,e);if(!this.header){const e=hh(t);this.header=await this.parser.parseHeader(e)}const i=hh(t);return await this.parser.parseFeatures(i)}}async loadFeaturesWithIndex(e,t,i){this.dataURI||this.header||await this.readHeader();const n=this.config,r=this.parser,s=this.index.tabix,o=s?this.index.sequenceIndexMap[e]:e;if(void 0===o)return[];const a=this.genome,l=this.index.chunksForRange(o,t,i);if(l&&0!==l.length){const o=[];for(let h of l){let l;if(s)l=await this._blockLoader.getData(h.minv,h.maxv);else{const e=To(n,{range:{start:h.minv.block,size:h.maxv.block-h.minv.block+1}});l=await no.loadString(n.url,e)}const c=hh(h.minv.offset?l.slice(h.minv.offset):l);let d=await r.parseFeatures(c);d=d.filter((e=>void 0===e._f));let u=!1;for(let n=0;n<d.length;n++){const r=d[n];if((a?a.getChromosomeName(r.chr):r.chr)!==e){if(0===o.length)continue;break}if(r.start>i){o.push(r);break}r.end>=t&&r.start<=i&&(u||(u=!0,n>0&&o.push(d[n-1])),o.push(r))}}return o.sort((function(e,t){return e.start-t.start})),o}return[]}async getIndex(){return this.index?this.index:this.config.indexURL?(this.index=await this.loadIndex(),this.index):void 0}async loadIndex(){return lh(this.config.indexURL,this.config,this.genome)}async loadFeaturesFromDataURI(){if(this.features){const e=this.features;return delete this.features,e}{const e=Fs(this.dataURI);let t=hh(e);return this.header=await this.parser.parseHeader(t),this.header instanceof String&&this.header.startsWith("##gff-version 3")&&(this.format="gff3"),t=hh(e),this.features=await this.parser.parseFeatures(t),this.features}}}const wh=Qt;class vh{constructor(e){this.config=e}async readFeatures(e,t,i){let n;n="function"==typeof this.config.url?this.config.url({chr:e,start:t,end:i}):this.config.url.replace("$CHR",e).replace("$START",t).replace("$END",i);let r,s=Object.assign({},this.config);void 0!==this.config.body&&("function"==typeof this.config.body?s.body=this.config.body({chr:e,start:t,end:i}):s.body=this.config.body.replace("$CHR",e).replace("$START",t).replace("$END",i));const o=await no.load(n,s);if(o&&(r="function"==typeof this.config.parser?this.config.parser(o):wh(o)?JSON.parse(o):o),this.config.mappings){let e=Object.keys(this.config.mappings);for(let t of r)for(let i of e)t[i]=t[this.config.mappings[i]]}return r}}const yh=function(e,t){this.config=e,this.genome=t,this.expandQueryInterval=!1};yh.prototype.readFeatures=function(e,t,i){const n=Math.max(0,Math.floor(t));let r=Math.ceil(i);if(this.genome){const t=this.genome.getChromosome(e);t&&r>t.bpLength&&(r=t.bpLength)}const s=this.config.url+"?db="+this.config.db+"&table="+this.config.tableName+"&chr="+e+"&start="+n+"&end="+r;return no.loadJson(s,this.config).then((function(e){return e?(e.forEach((function(e){e.hasOwnProperty("exonStarts")&&e.hasOwnProperty("exonEnds")&&e.hasOwnProperty("exonCount")&&e.hasOwnProperty("cdsStart")&&e.hasOwnProperty("cdsEnd")&&function(e){var t,i,n,r,s,o;t=e.exonCount,i=e.exonStarts.split(","),n=e.exonEnds.split(","),r=[];for(var a=0;a<t;a++){var l={start:s=parseInt(i[a]),end:o=parseInt(n[a])};(e.cdsStart>o||e.cdsEnd<e.cdsStart)&&(l.utr=!0),e.cdsStart>=s&&e.cdsStart<=o&&(l.cdStart=e.cdsStart),e.cdsEnd>=s&&e.cdsEnd<=o&&(l.cdEnd=e.cdsEnd),r.push(l)}e.exons=r}(e)})),e):null}))};const _h=["Name","gene_name","gene","gene_id","alias","locus","name"];class xh{constructor(e){this.format=e.format,this.nameField=e.nameField,this.filterTypes=void 0===e.filterTypes?new Set(["chromosome"]):new Set(e.filterTypes)}combineFeatures(e,t){let i;const n=this.filterTypes;if(e=e.filter((e=>void 0===n||!n.has(e.type))),"gff3"===this.format){const t=this.combineFeaturesById(e);i=this.combineFeaturesByType(t)}else i=this.combineFeaturesByType(e);return i.sort((function(e,t){return e.start-t.start})),this.numberExons(i,t),this.nameFeatures(i),i}combineFeaturesById(e){const t=new Map,i=[];for(let n of e)if(Xa(n.type)||Qa(n.type)||!n.id)i.push(n);else{let e=t.get(n.chr);e||(e=new Map,t.set(n.chr,e));let i=e.get(n.id);i?i.push(n):e.set(n.id,[n])}for(let e of t.values())for(let t of e.values())if(t.length>1){const e=t[0];e.exons=[];for(let i of t)e.start=Math.min(e.start,i.start),e.end=Math.max(e.end,i.end),e.exons.push({start:i.start,end:i.end});i.push(e)}else i.push(t[0]);return i}combineFeaturesByType(e){const t=e.filter((e=>"gene"===e.type||e.type.endsWith("_gene"))),i=Object.create(null);for(let e of t)i[e.id]=e;const n=Object.create(null),r=[],s=new Set,o=this.filterTypes;e=e.filter((e=>void 0===o||!o.has(e.type)));for(let t of e)if("biological_region"===t.type&&console.log(),Qa(t.type)){const e=t.id;if(void 0!==e){const o=new Ja(t);n[e]=o,r.push(o),s.add(t);const a=i[t.parent];a&&(o.geneObject=a,s.add(a))}}for(let t of e)if(Xa(t.type)){const e=h(t);if(e)for(let i of e){let o=n[i];if(!o&&"gtf"===this.format){const e=Object.assign({},t);e.type="transcript",o=new Ja(e),n[i]=o,r.push(o)}if(void 0!==o){if(a=t.type,ja.has(a))if(e.length>1){const e=new Ka(t);o.addExon(e)}else o.addExon(t);else o.addPart(t);s.add(t)}}}var a;r.forEach((function(e){"function"==typeof e.finish&&e.finish()}));const l=e.filter((e=>!s.has(e)));for(let e of l)r.push(e);return r;function h(e){return e.parent&&""!==e.parent.trim()?e.parent.trim().split(","):null}}numberExons(e,t){for(let i of e)if(i.exons&&(!t||i.end<=t.end&&i.start>t.start))for(let e=0;e<i.exons.length;e++){i.exons[e].number="-"===i.strand?i.exons.length-e:e+1}}nameFeatures(e){for(let t of e)if(t.attributeString){const e="gff3"===this.format?"=":" ",i=nl(t.attributeString,e),n=new Map(i);if(this.nameField)t.name=n.get(this.nameField);else for(let e of _h)if(n.has(e)){t.name=n.get(e);break}}}}const kh=function(e){this.config=e,this.url=e.url,this.tissueId=e.tissueSiteDetailId,this.indexed=!0,this.datasetId=e.datasetId||"gtex_v8"};kh.prototype.readFeatures=async function(e,t,i){let n=e.startsWith("chr")?e:"chr"+e,r=Math.floor(t),s=Math.ceil(i),o=this.datasetId,a=this.url+"?chromosome="+n+"&start="+r+"&end="+s+"&tissueSiteDetailId="+this.tissueId+"&datasetId="+o;const l=await no.loadJson(a,{withCredentials:this.config.withCredentials});return l&&l.singleTissueEqtl?(l.singleTissueEqtl.forEach((function(e){e.chr=e.chromosome,e.position=e.pos,e.start=e.pos-1,e.end=e.start+1,e.snp=e.snpId,e.geneName=e.geneSymbol,e.geneId=e.gencodeId})),l.singleTissueEqtl):void 0};const Ch=function(e){this.config=e,this.url=e.url,this.cellConditionId=e.cellConditionId,this.valueThreshold=e.valueThreshold?e.valueThreshold:.05};Ch.prototype.readFeatures=function(e,t,i){var n=this,r=this.url+"?chromosome="+e+"&start="+t+"&end="+i+"&cell_condition_id="+this.cellConditionId;return new Promise((function(e,t){no.loadJson(r,{withCredentials:n.config.withCredentials}).then((function(t){t?(t.eqtls.forEach((function(e){e.chr=e.chromosome,e.start=e.position,e.end=e.position+1})),e(t.eqtls)):e(null)})).catch((function(e){t(e)}))}))};const Sh=no.apiKey;function Ah(e){var t=e.url+"/"+e.entity+"/"+e.entityId;return e.headers={"Cache-Control":"no-cache"},no.loadJson(t,e)}function Eh(e){return new Promise((function(t,i){var n=e.results?e.results:[],r=e.url,s=e.body,o=e.decode,a="?",l=e.fields;return Sh&&(r=r+a+"key="+Sh,a="&"),l&&(r=r+a+"fields="+l),function e(a){a?s.pageToken=a:void 0!==s.pageToken&&delete s.pageToken;var l=JSON.stringify(s);no.loadJson(r,{sendData:l,contentType:"application/json",headers:{"Cache-Control":"no-cache"}}).then((function(i){var r,s;i?((s=o?o(i):i)&&s.forEach((function(e){n.push(e)})),(r=i.nextPageToken)?e(r):t(n)):t(n)})).catch((function(e){i(e)}))}()}))}const Mh=function(e,t){this.config=e,this.genome=t,this.url=e.url,this.variantSetId=e.variantSetId,this.callSetIds=e.callSetIds,this.includeCalls=void 0===e.includeCalls||e.includeCalls};Mh.prototype.readHeader=function(){var e=this;return e.header?Promise.resolve(e.header):(e.header={},!1===e.includeCalls?Promise.resolve(e.header):Eh({url:e.url+"/callsets/search",fields:"nextPageToken,callSets(id,name)",body:{variantSetIds:Array.isArray(e.variantSetId)?e.variantSetId:[e.variantSetId],pageSize:"10000"},decode:function(t){if(e.callSetIds){var i=[],n=new Set;return e.callSetIds.forEach((function(e){n.add(e)})),t.callSets.forEach((function(e){n.has(e.id)&&i.push(e)})),i}return t.callSets}}).then((function(t){return e.header.callSets=t,e.header})))},Mh.prototype.readFeatures=function(e,t,i){const n=this,r=this.genome;return n.readHeader().then((function(e){return new Promise((function(e,t){n.chrAliasTable?e(n.chrAliasTable):n.readMetadata().then((function(t){n.metadata=t.metadata,n.chrAliasTable={},t.referenceBounds&&r&&t.referenceBounds.forEach((function(e){var t=e.referenceName,i=r.getChromosomeName(t);n.chrAliasTable[i]=t})),e(n.chrAliasTable)}))}))})).then((function(r){var s=r.hasOwnProperty(e)?r[e]:e;return Eh({url:n.url+"/variants/search",fields:n.includeCalls?void 0:"nextPageToken,variants(id,variantSetId,names,referenceName,start,end,referenceBases,alternateBases,quality,filter,info)",body:{variantSetIds:Array.isArray(n.variantSetId)?n.variantSetId:[n.variantSetId],callSetIds:n.callSetIds?n.callSetIds:void 0,referenceName:s,start:t.toString(),end:i.toString(),pageSize:"10000"},decode:function(e){var t,i=[];return e.variants.forEach((function(e){t=function(e){var t,i=new Pl;return i.chr=e.referenceName,i.start=parseInt(e.start),i.end=parseInt(e.end),i.pos=i.start+1,i.names=Hl(e.names,"; "),i.referenceBases=e.referenceBases,i.alternateBases=Hl(e.alternateBases),i.quality=e.quality,i.filter=Hl(e.filter),i.info={},e.info&&Object.keys(e.info).forEach((function(t){var n,r=e.info[t];n=Array.isArray(r)?r.join(","):r,i.info[t]=n})),i.calls={},e.calls&&e.calls.forEach((function(e){t=e.callSetId,i.calls[t]=e})),init(i),i}(e),t.isRefBlock()||i.push(t)})),i}})}))},Mh.prototype.readMetadata=function(){return Ah({url:this.url,entity:"variantsets",entityId:this.variantSetId})};class Th{constructor(e){this.config=e}async readFeatures(e,t,i){const n=(await no.loadJson(this.config.url+"/variants/?count=50000")).records,r=[];for(let e of n)if(e.coordinates){e.id;const t=e.coordinates;t.chromosome&&r.push(new Rh(t.chromosome,t.start-1,t.stop,e)),t.chromosome2&&r.push(new Rh(t.chromosome2,t.start2-1,t.stop2,e))}return r}}class Rh{constructor(e,t,i,n){if(this.chr=e,this.start=t,this.end=i,this.id=n.id,this.entrezName=n.entrez_name,this.name=n.name,this.actionabilityScore=n.civic_actionability_score,n.coordinates.reference_bases&&(this.refBases=n.coordinates.reference_bases),n.coordinates.variant_bases&&(this.altBases=n.coordinates.variant_bases),n.variant_types&&(this.variant_types=n.variant_types),this.locationString=this.chr+":"+Xt(this.start+1)+"-"+Xt(this.end),void 0!==this.actionabilityScore){let e;if(this.actionabilityScore<=10)e=.2;else{const t=Math.min(30,this.actionabilityScore);e=.2+.8*Math.log10((t-10)/2)}this.alpha=e}}popupData(){const e=i("CIViC","https://civicdb.org/links/variants/"+this.id);this.refBases!==this.altBases&&this.refBases&&1===this.refBases.length&&this.altBases&&this.altBases.length;const t=[e];if(t.push({name:"Entrez",value:i(this.entrezName,"https://ghr.nlm.nih.gov/gene/"+this.entrezName)}),t.push({name:"Name",value:this.name}),this.variant_types&&this.variant_types.length>0){const e=1===this.variant_types.length?"Type":"Types";let i;for(let e of this.variant_types)i?i+=", "+e.display_name:i=e.display_name;t.push({name:e,value:i})}return t.push({name:"Actionability",value:this.actionabilityScore}),t.push({name:"Location",value:this.locationString}),t;function i(e,t){return"<a target='_blank' href='"+t+"'>"+e+"</a>"}}}class Lh{constructor(e,t){if(this.config=e,this.genome=t,this.format=e.format?e.format.toUpperCase():"BAM","BAM"!==this.format&&"VCF"!==this.format)throw Error(`htsget format ${e.format} is not supported`)}async readHeaderData(){const e=`${Ih(this.config)}?class=header&format=${this.format}`,t=await no.loadJson(e,To(this.config));return await this.loadUrls(t.htsget.urls)}async readData(e,t,i){const n=`${Ih(this.config)}?format=${this.format}&referenceName=${e}&start=${Math.floor(t)}&end=${Math.ceil(i)}`,r=await no.loadJson(n,To(this.config));return this.loadUrls(r.htsget.urls)}async loadUrls(e){const t=[];for(let i of e)if(i.url.startsWith("data:"))t.push(Promise.resolve(Bh(i.url)));else{const e=To(this.config||{});i.headers&&(e.headers=Object.assign(e.headers||{},i.headers)),t.push(no.loadArrayBuffer(i.url,e))}return function(e){let t=0;for(let i of e)t+=i.byteLength;let i=0;const n=new Uint8Array(t);for(let t of e){const e=new Uint8Array(t);n.set(e,i),i+=e.length}return n}(await Promise.all(t))}static async inferFormat(e){try{const t=Ih(e),i=`${t}${t.includes("?")?"&":"?"}class=header`,n=await no.loadJson(i,To(e));if(n.htsget){const t=n.htsget.format;if("BAM"!==t&&"VCF"!==t)throw Error(`htsget format ${t} is not supported`);e.format=t.toLowerCase(),e.sourceType="htsget",e.name||(e.name=await Io(e.url))}}catch(e){}}}function Ih(e){if(e.url&&e.endpoint&&e.id)return e.url+e.endpoint+e.id;if(e.endpoint&&e.id)return e.endpoint+e.id;if(e.url)return e.url.startsWith("htsget://")?e.url.replace("htsget://","https://"):e.url;throw Error("Must specify either 'url', or 'endpoint' and 'id")}function Bh(e){const t=e.split(","),i=t[0].split(":")[1];let n=t[1];n=i.indexOf("base64")>=0?atob(n):decodeURI(n);const r=new Uint8Array(n.length);for(var s=0;s<n.length;s++)r[s]=n.charCodeAt(s);return r}class Fh extends Lh{constructor(e,t){super(e,t),this.parser=new Vl}async readHeader(){if(!this.header){const e=hh(await this.readHeaderData());this.header=await this.parser.parseHeader(e,this.genome),this.chrAliasTable=this.header.chrAliasTable}return this.header}async readFeatures(e,t,i){if(this.config.format&&"VCF"!==this.config.format.toUpperCase())throw Error(`htsget format ${this.config.format} is not supported`);this.chrAliasTable||await this.readHeader();let n=this.chrAliasTable.has(e)?this.chrAliasTable.get(e):e;const r=hh(await this.readData(n,t,i));return this.parser.parseFeatures(r)}}function Nh(e,t){t=t||Number.MAX_SAFE_INTEGER;const i=[];e.sort((function(e,t){return e.start-t.start})),i.push(-1e3);for(let n of e){let e=0;const r=Math.min(i.length,t);for(e=0;e<r;e++)if(n.start>=i[e]){n.row=e,i[e]=n.end;break}n.row=e,i[e]=n.end}}function Oh(e,t,i){const n=i||1e4,r=e=>{const i=Object.assign({},e);return i.chr="all",i.start=t.getGenomeCoordinate(e.chr,e.start),i.end=t.getGenomeCoordinate(e.chr,e.end),i._f=e,i.exons&&delete i.exons,i},s=new Set(t.wgChromosomeNames),o=[];let a=0;for(let i of t.wgChromosomeNames){if(Array.isArray(e)){const i={};for(let n of e){const e=t.getChromosomeName(n.chr);i.hasOwnProperty(e)||(i[e]=[]),i[e].push(n)}e=i}const l=e[i];if(l)for(let e of l){let i=t.getChromosomeName(e.chr);if(s.has(i))if(o.length<n)o.push(r(e));else{const t=n/(a+1);if(Math.random()<t){o[Math.floor(Math.random()*(n-1))]=r(e)}}a++}}return o.sort((function(e,t){return e.start-t.start})),o}function Ph(e,t){if(t=t||1e3,null==e||0===e.length)return;const i={},n=[];for(let t of e){const e=t.chr;let r=i[e];r||(r=[],i[e]=r,n.push(e)),r.push(t)}for(let e of n)Nh(i[e],t)}class Dh{constructor(e,t){this.config=e||{},this.genome=t,this.sourceType=void 0===e.sourceType?"file":e.sourceType,this.maxWGCount=e.maxWGCount||1e4;const i=new Set(["bigwig","bw","bigbed","bb","biginteract","biggenepred","bignarrowpeak","tdf"]);this.queryable=e.indexURL||!0===e.queryable,e.reader?(this.reader=e.reader,this.queryable=!1!==e.queryable):"ga4gh"===e.sourceType?(this.reader=new Mh(e,t),this.queryable=!0):"immvar"===e.sourceType?(this.reader=new Ch(e),this.queryable=!0):"eqtl"===e.type&&"gtex-ws"===e.sourceType?(this.reader=new kh(e),this.queryable=!0):"htsget"===e.sourceType?this.reader=new Fh(e,t):"ucscservice"===e.sourceType?(this.reader=new yh(e.source),this.queryable=!0):"custom"===e.sourceType?(this.reader=new vh(e.source),this.queryable=!1!==e.source.queryable):"civic-ws"===e.sourceType?(this.reader=new Th(e),this.queryable=!1):(this.reader=new bh(e,t),void 0!==e.queryable?this.queryable=e.queryable:(i.has(e.format)||this.reader.indexed)&&(this.queryable=!0)),this.searchable=!0===e.searchable||e.searchableFields||!1!==e.searchable&&!this.queryable}async defaultVisibilityWindow(){if(this.reader&&"function"==typeof this.reader.defaultVisibilityWindow)return this.reader.defaultVisibilityWindow()}async trackType(){const e=await this.getHeader();return e?e.type:void 0}async getHeader(){if(!this.header)if(this.reader&&"function"==typeof this.reader.readHeader){const e=await this.reader.readHeader();e?(this.header=e,e.format&&(this.config.format=e.format)):this.header={}}else this.header={};return this.header}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r}){const s=this.genome,o=s?s.getChromosomeName(e):e,a="all"===o.toLowerCase();return(a&&!this.wgFeatures&&this.supportsWholeGenome()||this.config.disableCache||!this.featureCache||!this.featureCache.containsRange(new na(o,t,i)))&&await this.loadFeatures(o,t,i,r),a?(this.wgFeatures||(this.supportsWholeGenome()?this.wgFeatures=Oh(this.featureCache.getAllFeatures(),this.genome,this.maxWGCount):this.wgFeatures=[]),this.wgFeatures):this.featureCache.queryFeatures(o,t,i)}supportsWholeGenome(){return!this.queryable}getAllFeatures(){return this.queryable||!this.featureCache?[]:this.featureCache.getAllFeatures()}async loadFeatures(e,t,i,n){const r=this.reader;let s=t,o=i;if((!n||n<=0)&&!1!==this.config.expandQuery){const t=this.genome?this.genome.getChromosome(e):void 0;s=0,o=Math.max(t?t.bpLength:Number.MAX_SAFE_INTEGER,i)}else if(n>i-t&&!1!==this.config.expandQuery){const e=Math.min(4.1*(i-t),n);s=Math.max(0,(t+i)/2-e),o=t+e}let a=await r.readFeatures(e,s,o);void 0===this.queryable&&(this.queryable=r.indexed);const l=this.queryable?new na(e,s,o):void 0;if(a){if(!1===this.config.assembleGFF||"gtf"!==this.config.format&&"gff3"!==this.config.format&&"gff"!==this.config.format||(a=new xh(this.config).combineFeatures(a,l)),"wig"!==this.config.format&&"junctions"!==this.config.type){Ph(a,this.config.maxRows||Number.MAX_SAFE_INTEGER)}this.featureCache=new po(a,this.genome,l),this.searchable&&this.genome.addFeaturesToDB(a,this.config)}else this.featureCache=new po([],l)}}class zh{constructor(e,t,i){this.path=e.url,this.bufferSize=i||512e3,this.range={start:-1,size:-1},this.config=e}async dataViewForRange(e,t){if(!(this.data&&this.range.start<=e.start&&this.range.start+this.range.size>=e.start+e.size)){let t;t=e.size?Math.max(this.bufferSize,e.size):this.bufferSize;const i={start:e.start,size:t},n=await no.loadArrayBuffer(this.path,To(this.config,{range:i}));this.data=n,this.range=i}const i=this.data.byteLength,n=e.start-this.range.start;return t?new Uint8Array(this.data,n,i-n):new DataView(this.data,n,i-n)}}let Hh=512e3;class Vh{constructor(e,t){this.path=e.url,this.format=e.format||"bigwig",this.genome=t,this.rpTreeCache={},this.config=e,this.loader=Fo(this.path)?new Kh(this.path):no}async readWGFeatures(e,t){await this.loadHeader();const i=this.chromTree.idToChrom.length-1,n=this.chromTree.idToChrom[0],r=this.chromTree.idToChrom[i];return this.readFeatures(n,0,r,Number.MAX_VALUE,e,t)}async readFeatures(e,t,i,n,r,s){await this.loadHeader();const o=this.chromTree.chromToID[e],a=this.chromTree.chromToID[i];if(void 0===o||void 0===a)return[];let l,h;if("bigwig"===this.type){const e=await this.getZoomHeaders();let t=r?function(e,t){let i;for(let n=0;n<t.length;n++){const r=t[n];if(r.reductionLevel<e){i=r;break}}return i}(r,e):void 0;t?(l=t.indexOffset,h=Yh):(l=this.header.fullIndexOffset,h=Qh)}else l=this.header.fullIndexOffset,h=Xh.call(this);const c=await this.loadRPTree(l),d=await c.findLeafItemsOverlapping(o,t,a,n);if(d&&0!==d.length){let e=Number.MAX_VALUE,i=0;for(let t of d)e=Math.min(e,t.dataOffset),i=Math.max(i,t.dataOffset+t.dataSize);const r=i-e,l=await this.loader.loadArrayBuffer(this.config.url,To(this.config,{range:{start:e,size:r}})),c=[];for(let i of d){const r=new Uint8Array(l,i.dataOffset-e,i.dataSize);let d;d=this.header.uncompressBuffSize>0?Ss(r):r,h.call(this,new DataView(d.buffer),o,t,a,n,c,this.chromTree.idToChrom,s)}return c.sort((function(e,t){return e.start-t.start})),c}return[]}async getZoomHeaders(){return this.zoomLevelHeaders||await this.loadHeader(),this.zoomLevelHeaders}async loadHeader(){if(this.header)return this.header;{let e,t=await this.loader.loadArrayBuffer(this.path,To(this.config,{range:{start:0,size:64}}));this.littleEndian=!0;let i=new th(new DataView(t)),n=i.getUInt();if(2291137574===n)this.type="bigwig";else if(2273964779===n)this.type="bigbed";else{this.littleEndian=!1,i.littleEndian=!1,i.position=0;let e=i.getUInt();654085990===e?this.type="bigwig":3958540679===e&&(this.type="bigbed")}e={bwVersion:i.getUShort(),nZoomLevels:i.getUShort(),chromTreeOffset:i.getLong(),fullDataOffset:i.getLong(),fullIndexOffset:i.getLong(),fieldCount:i.getUShort(),definedFieldCount:i.getUShort(),autoSqlOffset:i.getLong(),totalSummaryOffset:i.getLong(),uncompressBuffSize:i.getInt(),extensionOffset:i.getLong()};const r=64;let s={start:r,size:e.fullDataOffset-r+5};t=await this.loader.loadArrayBuffer(this.path,To(this.config,{range:s}));const o=e.nZoomLevels;i=new th(new DataView(t)),this.zoomLevelHeaders=[],this.firstZoomDataOffset=Number.MAX_SAFE_INTEGER;for(let e=1;e<=o;e++){const t=o-e,n=new Uh(t,i);this.firstZoomDataOffset=Math.min(n.dataOffset,this.firstZoomDataOffset),this.zoomLevelHeaders[t]=n}if(e.autoSqlOffset>0){i.position=e.autoSqlOffset-r;const t=i.getString();t&&(this.autoSql=function(e){let t;const i=[];let n=!1;const r=e.trim().split(/\s*[\r\n]+\s*/g);for(let e of r)if(e.startsWith("table"))t=e.split(/\s+/)[1].trim();else if(e.startsWith("("))n=!0;else if(e.startsWith(")"));else if(n&&e.length>0){const t=e.indexOf(";"),n=e.substr(0,t).split(/\s+/),r=e.substr(t+1).replace(/"/g,"").trim();i.push({type:n[0],name:n[1],description:r})}return{table:t,fields:i}}(t))}if(e.totalSummaryOffset>0&&(i.position=e.totalSummaryOffset-r,this.totalSummary=new Gh(i)),!(e.chromTreeOffset>0))throw"BigWig chromosome tree offset <= 0";return i.position=e.chromTreeOffset-r,this.chromTree=new $h(i,r,this.genome),i.position=e.fullDataOffset-r,e.dataCount=i.getInt(),this.setDefaultVisibilityWindow(e),this.header=e,this.header}}async loadRPTree(e){let t=this.rpTreeCache[e];return t||(t=new qh(e,this.config,this.littleEndian,this.loader),await t.load(),this.rpTreeCache[e]=t,t)}async getType(){return await this.loadHeader(),this.type}async getTrackType(){return await this.loadHeader(),"bigwig"===this.type?"wig":this.autoSql&&"chromatinInteract"===this.autoSql.table?"interact":"annotation"}setDefaultVisibilityWindow(e){if("bigwig"===this.type)this.visibilityWindow=-1;else{let t=this.genome?this.genome.getGenomeLength():3088286401;this.visibilityWindow=e.dataCount<1e3?-1:t/e.dataCount*1e3}}}class Uh{constructor(e,t){this.index=e,this.reductionLevel=t.getInt(),this.reserved=t.getInt(),this.dataOffset=t.getLong(),this.indexOffset=t.getLong()}}class qh{constructor(e,t,i,n){this.config=t,this.loader=n,this.fileOffset=e,this.path=t.url,this.littleEndian=i}async load(){const e=this.fileOffset+48,t=Fo(this.path)?this.loader:new zh(this.config,Hh);return this.rootNode=await this.readNode(e,t),this}async readNode(e,t){let i=await t.dataViewForRange({start:e,size:4},!1),n=new th(i,this.littleEndian);const r=1===n.getByte();n.getByte();const s=n.getUShort();let o={start:e+=4,size:s*(r?32:24)};i=await t.dataViewForRange(o,!1);const a=new Array(s);if(n=new th(i),r){for(let e=0;e<s;e++){let t={isLeaf:!0,startChrom:n.getInt(),startBase:n.getInt(),endChrom:n.getInt(),endBase:n.getInt(),dataOffset:n.getLong(),dataSize:n.getLong()};a[e]=t}return new jh(a)}for(let e=0;e<s;e++){let t={isLeaf:!1,startChrom:n.getInt(),startBase:n.getInt(),endChrom:n.getInt(),endBase:n.getInt(),childOffset:n.getLong()};a[e]=t}return new jh(a)}async findLeafItemsOverlapping(e,t,i,n){let r=this;return new Promise((function(s,o){let a=[],l=new Set,h=Fo(r.path)?r.loader:new zh(r.config,Hh);l.add(0),function c(d,u){if(Wh(d,e,t,i,n)){d.items.forEach((function(s){Wh(s,e,t,i,n)&&(s.isLeaf?a.push(s):s.childNode?c(s.childNode):(l.add(s.childOffset),r.readNode(s.childOffset,h).then((function(e){s.childNode=e,c(e,s.childOffset)})).catch(o)))}))}void 0!==u&&l.delete(u);0===l.size&&s(a)}(r.rootNode,0)}))}}class jh{constructor(e){this.items=e;let t,i,n=Number.MAX_SAFE_INTEGER,r=0,s=Number.MAX_SAFE_INTEGER,o=0;for(t=0;t<e.length;t++)i=e[t],n=Math.min(n,i.startChrom),r=Math.max(r,i.endChrom),s=Math.min(s,i.startBase),o=Math.max(o,i.endBase);this.startChrom=n,this.endChrom=r,this.startBase=s,this.endBase=o}}class $h{constructor(e,t,i){let n=e.getInt(),r=e.getInt(),s=e.getInt(),o=e.getInt(),a=e.getLong(),l=e.getLong(),h={},c=[];this.header={magic:n,blockSize:r,keySize:s,valSize:o,itemCount:a,reserved:l},this.chromToID=h,this.idToChrom=c,function e(n,r){r>=0&&(n.position=r);let o=n.getByte();n.getByte();let a,l,d,u,f,p,g=n.getUShort();if(1===o)for(a=0;a<g;a++)l=n.getFixedLengthTrimmedString(s),d=n.getInt(),n.getInt(),i&&(l=i.getChromosomeName(l)),h[l]=d,c[d]=l;else for(a=0;a<g;a++)l=n.getFixedLengthTrimmedString(s),u=n.getLong(),f=u-t,p=n.position,e(n,f),n.position=p}(e,-1)}}function Wh(e,t,i,n,r){return e?(n>e.startChrom||n===e.startChrom&&r>=e.startBase)&&(t<e.endChrom||t===e.endChrom&&i<=e.endBase):(console.log("null item for "+t+" "+i+" "+r),!1)}class Gh{constructor(e){e?(this.basesCovered=e.getLong(),this.minVal=e.getDouble(),this.maxVal=e.getDouble(),this.sumData=e.getDouble(),this.sumSquares=e.getDouble(),Zh.call(this)):(this.basesCovered=0,this.minVal=0,this.maxVal=0,this.sumData=0,this.sumSquares=0,this.mean=0,this.stddev=0)}}function Zh(){let e=this.basesCovered;if(e>0){this.mean=this.sumData/e,this.stddev=Math.sqrt(this.sumSquares/(e-1));let t=this.minVal<0?this.mean-2*this.stddev:0,i=this.maxVal>0?this.mean+2*this.stddev:0;this.defaultRange={min:t,max:i}}}function Qh(e,t,i,n,r,s,o){const a=new th(e),l=a.getInt(),h=a.getInt();let c=h,d=a.getInt();const u=a.getInt(),f=a.getInt(),p=a.getByte();a.getByte();let g=a.getUShort();if(l>=t&&l<=n){let e=0;for(;g-- >0;){let g;switch(p){case 1:c=a.getInt(),d=a.getInt(),g=a.getFloat();break;case 2:c=a.getInt(),g=a.getFloat(),d=c+f;break;case 3:g=a.getFloat(),c=h+e*u,d=c+f,e++}if(!(l<t||l===t&&d<i)){if(l>n||l===n&&c>=r)break;if(Number.isFinite(g)){const e=o[l];s.push({chr:e,start:c,end:d,value:g})}}}}}function Xh(){const e=function(e,t,i,n){if("biginteract"===n||i&&"chromatinInteract"===i.table||"interact"===i.table)return function(e,t){return e.chr1=t[5],e.start1=Number.parseInt(t[6]),e.end1=Number.parseInt(t[7]),e.chr2=t[10],e.start2=Number.parseInt(t[11]),e.end2=Number.parseInt(t[12]),e.name=t[0],e.score=Number(t[1]),e.value=Number(t[2]),e.color="."===t[4]?void 0:"0"===t[4]?"rgb(0,0,0)":t[4],e};{const n=e-3;return function(r,s){if(n>0&&(r.name=s[0]),n>1&&(r.score=Number(s[1])),n>2&&(r.strand=s[2]),n>3&&(r.cdStart=parseInt(s[3])),n>4&&(r.cdEnd=parseInt(s[4])),n>5&&"."!==s[5]&&"0"!==s[5]&&"-1"!==s[5]){const e=Ds.createColorString(s[5]);r.color=e.startsWith("rgb")?e:void 0}if(n>8){const e=parseInt(s[6]),t=s[7].split(","),i=s[8].split(","),n=[];for(let s=0;s<e;s++){const e=r.start+parseInt(i[s]),o=e+parseInt(t[s]);n.push({start:e,end:o})}!function(e,t,i){for(let n of e){const e=n.end,r=n.start;e<t||r>i?n.utr=!0:(t>=r&&t<=e&&(n.cdStart=t),i>=r&&i<=e&&(n.cdEnd=i))}}(n,r.cdStart,r.cdEnd),r.exons=n}if(i)for(let n=e;n<t;n++)if(n<i.fields.length){const e=i.fields[n].name,t=s[n-3];r[e]=t}}}}(this.header.definedFieldCount,this.header.fieldCount,this.autoSql,this.format);return function(t,i,n,r,s,o,a){const l=new th(t);for(;l.remLength()>=13;){const t=l.getInt(),h=a[t],c=l.getInt(),d=l.getInt(),u=l.getString();if(!(t<i||t===i&&d<n)){if(t>r||t===r&&c>=s)break;if(d>0){const t={chr:h,start:c,end:d};o.push(t);const i=u.split("\t");e(t,i)}}}}}function Yh(e,t,i,n,r,s,o,a){const l=new th(e);for(;l.remLength()>=32;){const e=l.getInt(),h=o[e],c=l.getInt(),d=l.getInt(),u=l.getInt(),f=l.getFloat(),p=l.getFloat(),g=l.getFloat();let m;switch(l.getFloat(),a){case"min":m=f;break;case"max":m=p;break;default:m=0===u?0:g/u}if(!(e<t||e===t&&d<i)){if(e>n||e===n&&c>=r)break;Number.isFinite(m)&&s.push({chr:h,start:c,end:d,value:m})}}}class Kh{constructor(e){this.data=Fs(e).buffer}loadArrayBuffer(e,t){const i=t.range;return i?this.data.slice(i.start,i.start+i.size):this.data}async dataViewForRange(e,t){const i=Math.min(this.data.byteLength-e.start,e.size);return t?new Uint8Array(this.data,e.start,i):new DataView(this.data,e.start,i)}}class Jh{constructor(e,t){this.reader=new Vh(e,t),this.genome=t,this.format=e.format||"bigwig",this.wgValues={},this.queryable=!0}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,windowFunction:r}){const s="bigwig"===this.reader.type,o="all"===e.toLowerCase()?s?await this.getWGValues(r):[]:await this.reader.readFeatures(e,t,e,i,n,r);return s||Nh(o),o}async getHeader(){return this.reader.loadHeader()}getDefaultRange(){return void 0!==this.reader.totalSummary?this.reader.totalSummary.defaultRange:void 0}async defaultVisibilityWindow(){return this.reader.defaultVisibilityWindow}async getWGValues(e){const t=this.genome;if(this.wgValues[e])return this.wgValues[e];{const i=t.getGenomeLength()/1e3,n=await this.reader.readWGFeatures(i,e);let r=[];for(let e of n){const i=e.chr,n=t.getCumulativeOffset(i),s=Object.assign({},e);s.chr="all",s.start=n+e.start,s.end=n+e.end,r.push(s)}return this.wgValues[e]=r,r}}supportsWholeGenome(){return"bigwig"===this.reader.type}async trackType(){return this.reader.getTrackType()}}class ec{constructor(e,t){this.config=e,this.genome=t,this.path=e.url,this.groupCache={},this.datasetCache={}}async readHeader(){if(void 0!==this.magic)return this;let e=await no.loadArrayBuffer(this.path,To(this.config,{range:{start:0,size:64e3}})),t=new th(new DataView(e));if(this.magic=t.getInt(),this.version=t.getInt(),this.indexPos=t.getLong(),this.indexSize=t.getInt(),t.getInt(),this.version>=2){let e=t.getInt();for(this.windowFunctions=[];e-- >0;)this.windowFunctions.push(t.getString())}this.trackType=t.getString(),this.trackLine=t.getString();let i=t.getInt();for(this.trackNames=[];i-- >0;)this.trackNames.push(t.getString());this.genomeID=t.getString(),this.flags=t.getInt(),this.compressed=0!=(1&this.flags),e=await no.loadArrayBuffer(this.path,To(this.config,{range:{start:this.indexPos,size:this.indexSize}})),t=new th(new DataView(e)),this.datasetIndex={};let n=t.getInt();for(;n-- >0;){const e=t.getString(),i=t.getLong(),n=t.getInt();this.datasetIndex[e]={position:i,size:n}}for(this.groupIndex={},n=t.getInt();n-- >0;){const e=t.getString(),i=t.getLong(),n=t.getInt();this.groupIndex[e]={position:i,size:n}}return this}async readDataset(e,t,i){const n=e+"_"+t+"_"+i;if(this.datasetCache[n])return this.datasetCache[n];{await this.readHeader();const r=this.version<2?"":"/"+t,s="all"===e.toLowerCase()||void 0===i?"0":i.toString();let o;o="raw"===t?"/"+e+"/raw":"/"+e+"/z"+s+r;const a=this.datasetIndex[o];if(void 0===a)return;const l=await no.loadArrayBuffer(this.path,To(this.config,{range:{start:a.position,size:a.size}}));if(!l)return;const h=new th(new DataView(l));let c=h.getInt();const d={};for(;c-- >0;)d[h.getString()]=h.getString();const u=h.getString(),f=h.getFloat();let p=h.getInt();const g=[];for(;p-- >0;)g.push({position:h.getLong(),size:h.getInt()});const m={name:o,attributes:d,dataType:u,tileWidth:f,tiles:g};return this.datasetCache[n]=m,m}}async readRootGroup(){const e=this.genome,t=this.groupCache["/"];if(t)return t;{const t=await this.readGroup("/"),i=t.chromosomes,n=t.maxZoom;n&&(this.maxZoom=Number(n));const r=t.totalCount;r&&(t.totalCount=Number(r));const s={};return i&&i.split(",").forEach((function(t){const i=e.getChromosomeName(t);s[i]=t})),this.chrAliasTable=s,this.groupCache["/"]=t,t}}async readGroup(e){const t=this.groupCache[e];if(t)return t;{await this.readHeader();const t=this.groupIndex[e];if(void 0===t)return;const i=await no.loadArrayBuffer(this.path,To(this.config,{range:{start:t.position,size:t.size}}));if(!i)return;const n=new th(new DataView(i)),r={name:e};let s=n.getInt();for(;s-- >0;){const e=n.getString(),t=n.getString();r[e]=t}return this.groupCache[e]=r,r}}async readTiles(e,t){if(e.sort((function(e,t){return e.position-t.position})),0===(e=e.filter((function(e){return e.size>0}))).length)return Promise.resolve([]);const i=e[0],n=e[e.length-1],r=i.position,s=n.position+n.size-r,o=await no.loadArrayBuffer(this.path,To(this.config,{range:{start:r,size:s}})),a=[];for(let i of e){const e=i.position-r,n=i.size;if(n>0){let i;if(this.compressed){i=Ss(o.slice(e,e+n)).buffer}else i=o.slice(e,e+n);const r=new th(new DataView(i)),s=r.getString();let l;switch(s){case"fixedStep":l=tc(r,t);break;case"variableStep":l=ic(r,t);break;case"bed":case"bedWithName":l=nc(r,t,s);break;default:throw"Unknown tile type: "+s}a.push(l)}}return a}async readTile(e,t){let i=await no.loadArrayBuffer(this.path,To(this.config,{range:{start:e.position,size:e.size}}));if(this.compressed){i=Ss(i).buffer}const n=new th(new DataView(i)),r=n.getString();switch(r){case"fixedStep":return tc(n,t);case"variableStep":return ic(n,t);case"bed":case"bedWithName":return nc(n,t,r);default:throw"Unknown tile type: "+r}}}function tc(e,t){const i=e.getInt(),n=e.getInt(),r=e.getFloat(),s=[];let o=t;for(;o-- >0;){let t=i;const n=[];for(;t-- >0;)n.push(e.getFloat());s.push(n)}return{type:"fixedStep",start:n,span:r,data:s,nTracks:t,nPositions:i}}function ic(e,t){const i=e.getInt(),n=e.getFloat(),r=e.getInt(),s=[];let o=r;for(;o-- >0;)s.push(e.getInt());e.getInt();const a=[];let l=t;for(;l-- >0;){o=r;const t=[];for(;o-- >0;)t.push(e.getFloat());a.push(t)}return{type:"variableStep",tileStart:i,span:n,start:s,data:a,nTracks:t,nPositions:r}}function nc(e,t,i){const n=e.getInt();let r=n;const s=[];for(;r-- >0;)s.push(e.getInt());r=n;const o=[];for(;r-- >0;)o.push(e.getInt());e.getInt();const a=[];let l=t;for(;l-- >0;){let t=n;const i=[];for(;t-- >0;)i.push(e.getFloat());a.push(i)}if("bedWithName"===i){r=n;const t=[];for(;r-- >0;)t.push(e.getString())}return{type:i,start:s,end:o,data:a,nTracks:t,nPositions:n}}class rc{constructor(e,t){this.genome=t,this.windowFunction=e.windowFunction||"mean",this.reader=new ec(e,t),this.queryable=!0}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n}){if("all"===e.toLowerCase()){const e=[],t=this.genome;if(this.genome.wgChromosomeNames)for(let i of t.wgChromosomeNames){const r=t.getChromosome(i).bpLength;n=r/1e3;const s=await this._getFeatures(i,0,r,n);if(s)for(let i of s){const n=Object.assign({},i);n.chr="all",n.start=t.getGenomeCoordinate(i.chr,i.start),n.end=t.getGenomeCoordinate(i.chr,i.end),n._f=i,e.push(n)}}return e}return this._getFeatures(e,t,i,n)}async _getFeatures(e,t,i,n){const r=new na(e,t,i),s=this.genome;if(!this.rootGroup&&(this.rootGroup=await this.reader.readRootGroup(),!this.normalizationFactor)){const e=this.rootGroup.totalCount;e&&(this.normalizationFactor=1e6/e)}r.bpPerPixel=n;const o=function(e,t,i){var n=i.getChromosome(e).bpLength;return Math.ceil(Math.log(Math.max(0,n/(700*t)))/lc)}(e,n,s);let a=this.reader.chrAliasTable[e],l=this.reader.maxZoom;void 0===a&&(a=e),void 0===l&&(l=-1);const h=o>l?"raw":this.windowFunction,c=await this.reader.readDataset(a,h,o);if(null==c)return[];const d=c.tileWidth,u=Math.floor(t/d),f=Math.floor(i/d),p=await this.reader.readTiles(c.tiles.slice(u,f+1),1),g=[];for(let r of p)switch(r.type){case"bed":sc(r,e,t,i,n,g);break;case"variableStep":oc(r,e,t,i,n,g);break;case"fixedStep":ac(r,e,t,i,n,g);break;default:throw"Unknown tile type: "+r.type}return g.sort((function(e,t){return e.start-t.start})),g}get supportsWholeGenome(){return!0}}function sc(e,t,i,n,r,s){const o=e.nPositions,a=e.start,l=e.end,h=e.data[0];for(let e=0;e<o;e++){const r=a[e],o=l[e];if(!(o<i)){if(r>n)break;s.push({chr:t,start:r,end:o,value:h[e]})}}}function oc(e,t,i,n,r,s){const o=e.nPositions,a=e.start,l=e.span,h=e.data[0];for(let e=0;e<o;e++){const r=a[e],o=r+l;if(!(o<i)){if(r>n)break;s.push({chr:t,start:r,end:o,value:h[e]})}}}function ac(e,t,i,n,r,s){const o=e.nPositions;let a=e.start;const l=e.span,h=e.data[0];for(let e=0;e<o;e++){const r=a+l;if(a>n)break;r>=i&&(Number.isNaN(h[e])||s.push({chr:t,start:a,end:r,value:h[e]})),a=r}}var lc=Math.log(2);class hc{constructor(e,t){this.config=e,this.genome=t,this.queryable=!1,this.searchable=!1!==e.searchable,this.updateFeatures(e.features)}updateFeatures(e){Ph(e=function(e,t){if(t)for(let i of e)i.chr=t.getChromosomeName(i.chr);return e}(e,this.genome)),this.config.mappings&&function(e,t){let i=Object.keys(t);e.forEach((function(e){i.forEach((function(i){e[i]=e[t[i]]}))}))}(e,this.config.mappings),this.featureCache=new po(e,this.genome),(this.searchable||this.config.searchableFields)&&this.genome.addFeaturesToDB(e,this.config)}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r}){const s=this.genome,o=s?s.getChromosomeName(e):e;return"all"===o.toLowerCase()?Oh(this.featureCache.getAllFeatures(),this.genome,this.maxWGCount):this.featureCache.queryFeatures(o,t,i)}getAllFeatures(){return this.featureCache.getAllFeatures()}supportsWholeGenome(){return!0}}const cc=new Set(["bigwig","bw","bigbed","bb","biginteract","biggenepred","bignarrowpeak"]);function dc(e,t){const i=e.format?e.format.toLowerCase():void 0;return e.features?new hc(e,t):cc.has(i)?new Jh(e,t):"tdf"===i?new rc(e,t):new Dh(e,t)}const uc=function(e,t){const{r:i,g:n,b:r}=wo[e];return`rgba(${i},${n},${r},${t})`}("nickel",2/16),fc=uc;class pc{constructor(e,t){if(this.url=e.url,e.name?this.name=e.name:e.url&&ti(e.url)?this.name=e.url.name:e.url&&Qt(e.url)&&!e.url.startsWith("data:")&&(this.name=ei(e.url)),this.isUserDefined=e.isUserDefined,e.features)this.featureSource=new mc(e.features,t);else{if(e.format)e.format=e.format.toLowerCase();else{const t=ei(e.url);e.format=jo(t)}this.featureSource=e.featureSource||dc(e,t)}!0===this.isUserDefined?(this.color=e.color||fc,this.headerColor="rgba(155,185,129)"):(this.color=e.color||uc,this.headerColor="rgb(190,190,190)")}async getFeatures(e,t,i){return this.featureSource.getFeatures({chr:e,start:t,end:i})}async getAllFeatures(){return"function"==typeof this.featureSource.getAllFeatures?await this.featureSource.getAllFeatures():{}}addFeature(e){this.isUserDefined?this.featureSource.addFeature(e):console.error("Attempt to add ROI to non user-defined set")}removeFeature(e){this.isUserDefined?this.featureSource.removeFeature(e):console.error("Attempt to remove ROI from non user-defined set")}toJSON(){if(this.url)return{name:this.name,color:this.color,url:this.url,isUserDefined:this.isUserDefined};{const e=this.featureSource.getAllFeatures(),t=[];for(let i of Object.keys(e))for(let n of e[i])t.push(n);return{name:this.name,color:this.color,features:t,isUserDefined:this.isUserDefined}}}dispose(){for(let e of Object.keys(this))this[e]=void 0}}function gc(e,t,i,n){let r=Math.round((e-i)/n);let s=Math.round((t-i)/n)-r;return s<3&&(s=3,r-=1),{x:r,width:s}}class mc{constructor(e,t){this.featureMap={},this.genome=t;for(let i of e){const e=t?t.getChromosomeName(i.chr):i.chr;let n=this.featureMap[e];n||(n=[],this.featureMap[e]=n),n.push(i)}for(let e of Object.keys(this.featureMap))this.featureMap[e].sort(((e,t)=>e.start-t.start))}getFeatures({chr:e,start:t,end:i}){if("all"===e.toLowerCase())return Oh(this.featureMap,this.genome);{const n=this.featureMap[e];return n?n.filter((e=>e.end>t&&e.start<i)):[]}}getAllFeatures(){return this.featureMap}supportsWholeGenome(){return!0}addFeature(e){let t=this.featureMap[e.chr];t||(t=[],this.featureMap[e.chr]=t),t.push(e),t.sort(((e,t)=>e.start-t.start))}removeFeature({chr:e,start:t,end:i}){if(this.featureMap[e]){const n=`${e}-${t}-${i}`;this.featureMap[e]=this.featureMap[e].filter((e=>n!==`${e.chr}-${e.start}-${e.end}`))}}}class bc{constructor(e,t,i,n){this.rulerViewport=e,this.rulerSweeper=_t.div({class:"igv-ruler-sweeper"}),t.appendChild(this.rulerSweeper),this.browser=i,this.referenceFrame=n,this.isMouseHandlers=void 0,this.addBrowserObserver()}addBrowserObserver(){this.boundObserverHandler=(()=>{this.referenceFrame&&(Ia.isWholeGenomeView(this.referenceFrame.chr)?this.removeMouseHandlers():this.addMouseHandlers())}).bind(this),this.browser.on("locuschange",this.boundObserverHandler)}removeBrowserObserver(){this.browser.off("locuschange",this.boundObserverHandler)}addMouseHandlers(){if(!0===this.isMouseHandlers)return;let e,t,i,n,r,s;this.boundContentMouseDownHandler=function(s){e=!0,t=!0;const{x:o}=_t.translateMouseCoordinates(s,this.rulerViewport.contentDiv);n=i=o,r=1,this.rulerSweeper.style.display="block",this.rulerSweeper.style.backgroundColor=!0===s.shiftKey?fc:"rgba(68, 134, 247, 0.25)",this.rulerSweeper.style.left=`${n}px`,this.rulerSweeper.style.width=`${r}px`}.bind(this),this.rulerViewport.contentDiv.addEventListener("mousedown",this.boundContentMouseDownHandler),this.boundDocumentMouseMoveHandler=function(o){let a;if(e&&t){const{x:e}=_t.translateMouseCoordinates(o,this.rulerViewport.contentDiv);a=Math.max(Math.min(e,this.rulerViewport.contentDiv.clientWidth),0),s=a-i,r=Math.abs(s),this.rulerSweeper.style.width=`${r}px`,s<0&&(n=i+s,this.rulerSweeper.style.left=`${n}px`)}}.bind(this),document.addEventListener("mousemove",this.boundDocumentMouseMoveHandler),this.boundDocumentMouseUpHandler=function(i){let s;if(!0===e&&!0===t&&(e=t=void 0,this.rulerSweeper.style.display="none",r>1)){s={start:Math.floor(this.referenceFrame.calculateEnd(n)),end:Math.floor(this.referenceFrame.calculateEnd(n+r))};!0===i.shiftKey?this.browser.roiManager.updateUserDefinedROISet(Object.assign({chr:this.referenceFrame.chr},s)):(Lo(this.browser.genome.getChromosome(this.referenceFrame.chr).bpLength,s,this.browser.minimumBases()),function(e,t,i){e.start=Math.round(t.start),e.end=Math.round(t.end),e.bpPerPixel=(e.end-e.start)/i}(this.referenceFrame,s,this.rulerViewport.contentDiv.clientWidth),this.browser.updateViews(this.referenceFrame))}}.bind(this),document.addEventListener("mouseup",this.boundDocumentMouseUpHandler),this.isMouseHandlers=!0}removeMouseHandlers(){this.rulerViewport.contentDiv.removeEventListener("mousedown",this.boundContentMouseDownHandler),document.removeEventListener("mousemove",this.boundDocumentMouseMoveHandler),document.removeEventListener("mouseup",this.boundDocumentMouseUpHandler),this.isMouseHandlers=!1}dispose(){this.removeBrowserObserver(),this.removeMouseHandlers(),this.rulerSweeper.remove()}}class wc{constructor(e){this.paired=!0,this.firstAlignment=e,this.chr=e.chr,this.readName=e.readName,e.start<e.mate.position?(this.start=e.start,this.scStart=e.scStart,this.connectingStart=e.start+e.lengthOnRef,this.connectingEnd=e.mate.position):(this.start=e.mate.position,this.scStart=this.start,this.connectingStart=e.mate.position,this.connectingEnd=e.start),this.end=Math.max(e.mate.position,e.start+e.lengthOnRef),this.lengthOnRef=this.end-this.start;let t=Math.max(this.end,e.scStart+e.scLengthOnRef);this.scLengthOnRef=t-this.scStart}setSecondAlignment(e){this.secondAlignment=e;const t=this.firstAlignment;e.start>t.start?this.connectingEnd=e.start:this.connectingStart=e.start+e.lengthOnRef,this.start=Math.min(t.start,e.start),this.end=Math.max(t.start+t.lengthOnRef,e.start+e.lengthOnRef),this.lengthOnRef=this.end-this.start,this.scStart=Math.min(t.scStart,e.scStart);const i=Math.max(t.scStart+t.scLengthOnRef,e.scStart+e.scLengthOnRef);this.scLengthOnRef=i-this.scStart}containsLocation(e,t){const i=t?this.scStart:this.start,n=t?this.scLengthOnRef:this.lengthOnRef;return e>=i&&e<=i+n}alignmentContaining(e,t){return this.firstAlignment.containsLocation(e,t)?this.firstAlignment:this.secondAlignment&&this.secondAlignment.containsLocation(e,t)?this.secondAlignment:void 0}popupData(e){let t=this.firstAlignment.popupData(e);return this.secondAlignment&&(t.push("-------------------------------"),t=t.concat(this.secondAlignment.popupData(e))),t}isPaired(){return!0}isMateMapped(){return!0}isProperPair(){return this.firstAlignment.isProperPair()}get fragmentLength(){return Math.abs(this.firstAlignment.fragmentLength)}firstOfPairStrand(){return this.firstAlignment.isFirstOfPair()?this.firstAlignment.strand:this.secondAlignment&&this.secondAlignment.isFirstOfPair()?this.secondAlignment.strand:this.firstAlignment.mate.strand}hasTag(e){return this.firstAlignment.hasTag(e)||this.secondAlignment&&this.secondAlignment.hasTag(e)}}class vc{constructor(){this.alignments=[],this.score=void 0}findAlignment(e){const t=(e,t)=>t>=e.start&&t<e.start+e.lengthOnRef;let i;for(let n=0;n<this.alignments.length;n++){const r=this.alignments[n];if(e>=r.start&&e<r.start+r.lengthOnRef){r.paired?r.firstAlignment&&t(r.firstAlignment,e)?i=r.firstAlignment:r.secondAlignment&&t(r.secondAlignment,e)&&(i=r.secondAlignment):i=r;break}}return i}getSortValue({position:e,option:t,tag:i},n){t||(t="BASE");const r=this.findAlignment(e);if(void 0===r)return Number.MAX_VALUE;switch(t){case"NUCLEOTIDE":case"BASE":return function(e,t,i){let n;const r=Math.floor(i)-t.start;r<t.sequence.length&&(n=t.sequence.charAt(r));if(!n)return 0;const s=e.readBaseAt(i),o=e.readBaseQualityAt(i),a=t.coverageMap,l=Math.floor(i-a.bpStart),h=a.coverage[l];let c=0;if(e.insertions)for(let t of e.insertions)t.start===i&&(c=-h.ins);if(s)if(n=n.toUpperCase(),"N"===s&&0===c)c=2;else if(n!==s&&"="!==s||0!==c){if("X"===s||n!==s){c-=h["pos"+s]+h["neg"+s]+o/1e3}}else c=4-o/1e3;else{const e=h.del;e>0?c-=e:0===c&&(c=1)}return c}(r,n,e);case"STRAND":return r.strand?1:-1;case"START":return r.start;case"TAG":return r.tags()[i];case"READ_NAME":return r.readName;case"INSERT_SIZE":return-Math.abs(r.fragmentLength);case"GAP_SIZE":return-r.gapSizeAt(e);case"MATE_CHR":return r.mate;case"MQ":return void 0===r.mq?Number.MAX_VALUE:-r.mq;case"ALIGNED_READ_LENGTH":return-r.lengthOnRef;default:return Number.MAX_VALUE}}}function yc(e){return e.isPaired()&&e.mate&&e.isMateMapped()&&e.chr===e.mate.chr&&(e.isFirstOfPair()||e.isSecondOfPair())&&!(e.isSecondary()||e.isSupplementary())}function _c(e){const t=[];for(let i of e)for(let e of i.alignments)e instanceof wc?(e.firstAlignment&&t.push(e.firstAlignment),e.secondAlignment&&t.push(e.secondAlignment)):t.push(e);return t}function xc(e,t,i,n){if(e){if(0===e.length)return[];{e.sort((function(e,t){return n?e.scStart-t.scStart:e.start-t.start}));const t=[];let i,r=0,s=0;const o=new Set,a=()=>{i=new vc,t.push(i),r=0,s=0,o.clear()};for(a();e.length>0;)if(s>=0&&s<e.length){const t=e[s];o.add(t),i.alignments.push(t),r=n?t.scStart+t.scLengthOnRef+2:t.start+t.lengthOnRef+2,s=kc(e,(e=>(n?e.scStart:e.start)>r),s)}else e=e.filter((e=>!o.has(e))),a();return t}}}function kc(e,t,i){let n=i-1,r=e.length;for(;1+n<r;){const i=n+(r-n>>1);t(e[i])?r=i:n=i}return r}class Cc{constructor(e,t,i,{samplingWindowSize:n,samplingDepth:r,pairsSupported:s,alleleFreqThreshold:o}){this.chr=e,this.start=Math.floor(t),this.end=Math.ceil(i),this.length=i-t,this.alleleFreqThreshold=void 0===o?.2:o,this.coverageMap=new Ac(e,t,i,this.alleleFreqThreshold),this.alignments=[],this.downsampledIntervals=[],this.samplingWindowSize=void 0===n?100:n,this.samplingDepth=void 0===r?1e3:r,this.pairsSupported=void 0===s||s,this.paired=!1,this.pairsCache={},this.downsampledReads=new Set,this.currentBucket=new Sc(this.start,this.start+this.samplingWindowSize,this),this.filter=function(e){return e.isMapped()&&!e.isFailsVendorQualityCheck()}}push(e){!1!==this.filter(e)&&(this.coverageMap.incCounts(e),this.pairsSupported&&this.downsampledReads.has(e.readName)||(e.start>=this.currentBucket.end&&(this.finishBucket(),this.currentBucket=new Sc(e.start,e.start+this.samplingWindowSize,this)),this.currentBucket.addAlignment(e)))}forEach(e){this.alignments.forEach(e)}finish(){void 0!==this.currentBucket&&this.finishBucket(),this.alignments.sort((function(e,t){return e.start-t.start})),this.pairsCache=void 0,this.downsampledReads=void 0}contains(e,t,i){return this.chr===e&&this.start<=t&&this.end>=i}hasDownsampledIntervals(){return this.downsampledIntervals&&this.downsampledIntervals.length>0}finishBucket(){this.alignments=this.alignments.concat(this.currentBucket.alignments),this.currentBucket.downsampledCount>0&&this.downsampledIntervals.push(new Mc(this.currentBucket.start,this.currentBucket.end,this.currentBucket.downsampledCount)),this.paired=this.paired||this.currentBucket.paired}setViewAsPairs(e){let t;t=e?function(e){const t={},i=[];for(let n of e)for(let e of n.alignments)if(yc(e)){let n=t[e.readName];n?(n.setSecondAlignment(e),t[e.readName]=void 0):(n=new wc(e),t[e.readName]=n,i.push(n))}else i.push(e);return i}(this.packedAlignmentRows):_c(this.packedAlignmentRows),this.packedAlignmentRows=xc(t,this.start,this.end)}setShowSoftClips(e){const t=this.allAlignments();this.packedAlignmentRows=xc(t,this.start,this.end,e)}repack(e,t){const i=this.allAlignments();this.packedAlignmentRows=xc(i,this.start,this.end,t)}allAlignments(){const e=[];for(let t of this.packedAlignmentRows)for(let i of t.alignments)e.push(i);return e}getMax(e,t){return this.coverageMap.getMax(e,t)}sortRows(e){const t=[],i=[];for(let n of this.packedAlignmentRows){void 0!==n.findAlignment(e.position)?t.push(n):i.push(n)}t.sort(((t,i)=>{const n=e.direction,r=t.getSortValue(e,this),s=i.getSortValue(e,this);if(void 0===s&&void 0!==s)return 1;if(void 0!==r&&void 0===s)return-1;const o=r>s?1:r<s?-1:0;return!0===n?o:-o}));for(let e of i)t.push(e);this.packedAlignmentRows=t}}class Sc{constructor(e,t,i){this.start=e,this.end=t,this.alignments=[],this.downsampledCount=0,this.samplingDepth=i.samplingDepth,this.pairsSupported=i.pairsSupported,this.downsampledReads=i.downsampledReads,this.pairsCache=i.pairsCache}addAlignment(e){var t,i,n;if(this.pairsSupported&&yc(e)&&(n=this.pairsCache[e.readName]))return n.setSecondAlignment(e),void(this.pairsCache[e.readName]=void 0);this.alignments.length<this.samplingDepth?this.pairsSupported&&yc(e)?(n=new wc(e),this.paired=!0,this.pairsCache[e.readName]=n,this.alignments.push(n)):this.alignments.push(e):((t=Math.floor(Math.random()*(this.samplingDepth+this.downsampledCount-1)))<this.samplingDepth?(i=this.alignments[t],this.pairsSupported&&yc(e)?(void 0!==this.pairsCache[i.readName]&&(this.pairsCache[i.readName]=void 0),n=new wc(e),this.paired=!0,this.pairsCache[e.readName]=n,this.alignments[t]=n):this.alignments[t]=e,this.downsampledReads.add(i.readName)):this.downsampledReads.add(e.readName),this.downsampledCount++)}}class Ac{constructor(e,t,i,n){this.chr=e,this.bpStart=t,this.length=i-t,this.coverage=new Array(this.length),this.maximum=0,this.threshold=n,this.qualityWeight=!0}getMax(e,t){let i=0;const n=this.coverage.length;for(let r=0;r<n;r++){const n=this.bpStart+r;if(n>t)break;const s=this.coverage[r];n>=e&&s&&(i=Math.max(i,s.total))}return i}incCounts(e){var t=this;if(void 0===e.blocks?i(e):e.blocks.forEach((function(e){i(e)})),e.gaps)for(let i of e.gaps)if("D"===i.type){const e=i.start-t.bpStart;for(let n=e;n<e+i.len;n++)n<0||(this.coverage[n]||(this.coverage[n]=new Ec(t.threshold)),this.coverage[n].del++)}if(e.insertions)for(let i of e.insertions){const e=i.start-this.bpStart;e<0||(this.coverage[e]||(this.coverage[e]=new Ec(t.threshold)),this.coverage[e].ins++)}function i(i){if("S"===i.type)return;const n=e.seq,r=e.qual,s=i.seqOffset;for(let o=i.start-t.bpStart,a=0;a<i.len;o++,a++){t.coverage[o]||(t.coverage[o]=new Ec(t.threshold));const i=null==n?"N":n.charAt(s+a),l=e.strand?"pos"+i:"neg"+i,h=r&&s+a<r.length?r[s+a]:30;t.coverage[o][l]+=1,t.coverage[o]["qual"+i]+=h,t.coverage[o].total+=1,t.coverage[o].qual+=h,t.maximum=Math.max(t.coverage[o].total,t.maximum)}}}}class Ec{constructor(e){this.qualityWeight=!0,this.posA=0,this.negA=0,this.posT=0,this.negT=0,this.posC=0,this.negC=0,this.posG=0,this.negG=0,this.posN=0,this.negN=0,this.pos=0,this.neg=0,this.qualA=0,this.qualT=0,this.qualC=0,this.qualG=0,this.qualN=0,this.qual=0,this.total=0,this.del=0,this.ins=0,this.threshold=e}hoverText(){const e=this.posA+this.posT+this.posC+this.posG+this.posN,t=this.negA+this.negT+this.negC+this.negG+this.negN;return`${this.total} (${e}+, ${t}-)`}isMismatch(e){const t=this.threshold*(this.qualityWeight&&this.qual?this.qual:this.total);let i=0;for(let t of["A","T","C","G"])t!==e&&(i+=this.qualityWeight&&this.qual?this["qual"+t]:this["pos"+t]+this["neg"+t]);return i>=t}}class Mc{constructor(e,t,i){this.start=e,this.end=t,this.counts=i}popupData(e){return[{name:"start",value:this.start+1},{name:"end",value:this.end},{name:"# downsampled:",value:this.counts}]}}class Tc{constructor(e){const t=e.split(",");this.chr=t[0],this.start=parseInt(t[1]),this.strand=t[2].charAt(0),this.mapQ=parseInt(t[4]),this.numMismatches=parseInt(t[5]),this.lenOnRef=Wc.computeLengthOnReference(t[3])}printString(){return this.chr+":"+Xt(this.start)+"-"+Xt(this.start+this.lenOnRef)+" ("+this.strand+") = "+Xt(this.lenOnRef)+"bp @MAPQ: "+this.mapQ+" NM: "+this.numMismatches}}function Rc(e){return e.split(";").filter((e=>e.length>0)).map((e=>new Tc(e)))}const Lc={c:1,C:1,s:2,S:2,i:4,I:4,f:4};class Ic{constructor(){this.hidden=!1}isMapped(){return 0==(4&this.flags)}isPaired(){return 0!=(1&this.flags)}isProperPair(){return 0!=(2&this.flags)}isFirstOfPair(){return 0!=(64&this.flags)}isSecondOfPair(){return 0!=(128&this.flags)}isSecondary(){return 0!=(256&this.flags)}isSupplementary(){return 0!=(2048&this.flags)}isFailsVendorQualityCheck(){return 0!=(512&this.flags)}isDuplicate(){return 0!=(1024&this.flags)}isMateMapped(){return 0==(8&this.flags)}isNegativeStrand(){return 0!=(16&this.flags)}isMateNegativeStrand(){return 0!=(32&this.flags)}hasTag(e){return(this.tagDict||Fc(this.tagBA)).hasOwnProperty(e)}tags(){return this.tagDict||(this.tagBA?(this.tagDict=Fc(this.tagBA),this.tagBA=void 0):this.tagDict={}),this.tagDict}containsLocation(e,t){const i=t?this.scStart:this.start,n=t?this.scLengthOnRef:this.lengthOnRef;return e>=i&&e<=i+n}popupData(e){const t=[];if(e=Math.floor(e),this.insertions){const n=this.seq;for(let r of this.insertions){var i=r.start;if(e===i||e===i-1)return t.push({name:"Insertion",value:n.substr(r.seqOffset,r.len)}),t.push({name:"Location",value:i}),t}}t.push({name:"Read Name",value:this.readName}),t.push("<hr/>"),t.push({name:"Alignment Start",value:Xt(1+this.start),borderTop:!0}),t.push({name:"Read Strand",value:!0===this.strand?"(+)":"(-)",borderTop:!0});let n=this.cigar;if(n&&n.length>50){const e=25;n=`${n.substring(0,e-2)} ... ${n.substring(n.length-e+2)}`}t.push({name:"Cigar",value:n}),t.push({name:"Mapping Quality",value:this.mq}),t.push({name:"Secondary",value:o(this.isSecondary())}),t.push({name:"Supplementary",value:o(this.isSupplementary())}),t.push({name:"Duplicate",value:o(this.isDuplicate())}),t.push({name:"Failed QC",value:o(this.isFailsVendorQualityCheck())}),this.isPaired()&&(t.push("<hr/>"),t.push({name:"First in Pair",value:!this.isSecondOfPair(),borderTop:!0}),t.push({name:"Mate is Mapped",value:o(this.isMateMapped())}),this.pairOrientation&&t.push({name:"Pair Orientation",value:this.pairOrientation}),this.isMateMapped()&&(t.push({name:"Mate Chromosome",value:this.mate.chr}),t.push({name:"Mate Start",value:this.mate.position+1}),t.push({name:"Mate Strand",value:!0===this.mate.strand?"(+)":"(-)"}),t.push({name:"Insert Size",value:this.fragmentLength})));const r=this.tags();if(r.hasOwnProperty("SA")){t.push("<hr/>"),t.push({name:"Supplementary Alignments",value:""});const e=Rc(r.SA);if(e){t.push("<ul>");for(let i of e)t.push(`<li>${i.printString()}</li>`);t.push("</ul>")}}const s=new Set(["SA","MD"]);t.push("<hr/>");for(let e in r)s.has(e)||t.push({name:e,value:r[e]});return t.push({name:"Hidden Tags",value:"SA, MD"}),t.push("<hr/>"),t.push({name:"Genomic Location: ",value:Xt(1+e)}),t.push({name:"Read Base:",value:this.readBaseAt(e)}),t.push({name:"Base Quality:",value:this.readBaseQualityAt(e)}),t;function o(e){return e?"Yes":"No"}}readBaseAt(e){const t=Bc(this.blocks,e);if(t){if("*"===this.seq)return"*";{const i=t.seqIndexAt(e);return this.seq[i]}}}readBaseQualityAt(e){const t=Bc(this.blocks,e);if(t){if("*"===this.qual)return 30;{const i=t.seqIndexAt(e);return i>=0&&this.qual&&i<this.qual.length?this.qual[i]:30}}}gapSizeAt(e){if(this.gaps)for(let t of this.gaps)if(e>=t.start&&e<t.start+t.len)return t.len;return 0}softClippedBlocks(){let e,t,i;for(let n of this.blocks)"S"===n.type?i?t=n:e=n:"H"!==n.type&&(i=!0);return{left:e,right:t}}}function Bc(e,t){for(let i=0;i<e.length;i++){const n=e[i];if(t>=n.start&&t<n.start+n.len)return n}}function Fc(e){let t=0;const i=e.length,n={};for(;t<i;){const i=String.fromCharCode(e[t])+String.fromCharCode(e[t+1]);t+=2;const s=String.fromCharCode(e[t++]);let o;if("A"===s)o=String.fromCharCode(e[t]),t++;else if("i"===s||"I"===s)o=Nc(e,t),t+=4;else if("c"===s)o=Dc(e,t),t++;else if("C"===s)o=zc(e,t),t++;else if("s"===s||"S"===s)o=Oc(e,t),t+=2;else if("f"===s)o=Pc(e,t),t+=4;else if("Z"===s)for(o="";;){var r=e[t++];if(0===r)break;o+=String.fromCharCode(r)}else{if("B"!==s){o="Error unknown type: "+s,n[i]=o;break}{const r=String.fromCharCode(e[t++]);let s=Lc[r];if(void 0===s){n[i]=`Error: unknown element type '${r}'`;break}t+=4+Nc(e,t)*s,o="[not shown]"}}n[i]=o}return n}function Nc(e,t){return e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t]}function Oc(e,t){return e[t+1]<<8|e[t]}function Pc(e,t){return new DataView(e.buffer).getFloat32(t)}function Dc(e,t){return new DataView(e.buffer).getInt8(t)}function zc(e,t){return new DataView(e.buffer).getUint8(t)}class Hc{constructor(e){e&&Object.assign(this,e)}seqIndexAt(e){return Math.floor(e)-this.start+this.seqOffset}}class Vc{constructor(e){e||(e={}),this.vendorFailed=void 0===e.vendorFailed||e.vendorFailed,this.duplicates=void 0===e.duplicates||e.duplicates,this.secondary=e.secondary||!1,this.supplementary=e.supplementary||!1,this.mqThreshold=void 0===e.mqThreshold?0:e.mqThreshold,e.readgroups&&(this.readgroups=new Set(e.readgroups))}pass(e){if(this.vendorFailed&&e.isFailsVendorQualityCheck())return!1;if(this.duplicates&&e.isDuplicate())return!1;if(this.secondary&&e.isSecondary())return!1;if(this.supplementary&&e.isSupplementary())return!1;if(e.mq<this.mqThreshold)return!1;if(this.readgroups){var t=e.tags().RG;return this.readgroups.has(t)}return!0}}const Uc=["=","A","C","x","G","x","x","x","T","x","x","x","x","x","x","N"],qc=["M","I","D","N","S","H","P","=","X","?","?","?","?","?","?","?"],jc=Zc(new Uint8Array([66,65,77,1]),0),$c=1e4,Wc={readHeader:function(e,t,i){return no.loadArrayBuffer(e,t).then((function(e){var t;return t=Ts(e),Wc.decodeBamHeader(t,i)}))},decodeBamHeader:function(e,t){var i,n,r,s,o;if((i=Zc(e,0))!==jc)throw new Error("BAM header errror: bad magic number. This could be caused by either a corrupt or missing file.");n=Zc(e,4);for(var a=0;a<n;++a)String.fromCharCode(e[a+8]);var l=Zc(e,n+8),h=n+12;for(r={},s=[],o={},a=0;a<l;++a){for(var c=Zc(e,h),d="",u=0;u<c-1;++u)d+=String.fromCharCode(e[h+4+u]);Zc(e,h+c+4),r[d]=a,s[a]=d,t&&(o[t.getChromosomeName(d)]=d),h=h+8+c}return{magicNumber:i,size:h,chrNames:s,chrToIndex:r,chrAliasTable:o}},bam_tag2cigar:function(e,t,i,n,r,s){function o(e){return"C"===e||"c"===e||"A"===e?1:"S"===e||"s"===e?2:"I"===e||"i"===e||"f"===e?4:0}if(1!==s.length||r.start<0)return!1;for(var a=i+(n+1>>1)+n;a+4<t;){if("CG"===String.fromCharCode(e[a])+String.fromCharCode(e[a+1]))break;var l=String.fromCharCode(e[a+2]);if("B"===l)a+=8+o(l=String.fromCharCode(e[a+3]))*Zc(e,a+4);else if("Z"===l||"H"===l)for(a+=3;0!==e[a++];);else a+=3+o(l)}if(a>=t)return!1;if("B"!==String.fromCharCode(e[a+2])||"I"!==String.fromCharCode(e[a+3]))return!1;var h=Zc(e,a+4),c=a+8;if(c+4*h>t)return!1;var d="",u=0;s.length=0,a=c;for(var f=0;f<h;++f,a+=4){var p=Zc(e,a),g=p>>4,m=qc[15&p];"M"!==m&&"EQ"!==m&&"X"!==m&&"D"!==m&&"N"!==m&&"="!==m||(u+=g),d=d+g+m,s.push({len:g,ltr:m})}return r.cigar=d,r.lengthOnRef=u,!0},decodeBamRecords:function(e,t,i,n,r,s,o,a){for(;t<e.length;){const u=t+Zc(e,t)+4,f=new Ic,p=Zc(e,t+4),g=Zc(e,t+8);if(u>e.length)return;if(p<0){t=u;continue}if(void 0!==r&&(p>r||g>o))return!0;if(void 0!==r&&p<r){t=u;continue}const m=Zc(e,t+12),b=(65280&m)>>8,w=255&m,v=Zc(e,t+16),y=(4294901760&v)>>16,_=65535&v,x=Zc(e,t+20),k=Zc(e,t+24),C=Zc(e,t+28),S=Zc(e,t+32);let A=[];for(let i=0;i<w-1;++i)A.push(String.fromCharCode(e[t+36+i]));A=A.join("");let E=0,M="",T=t+36+w;const R=[];let L;for(let t=0;t<_;++t){var l=Zc(e,T),h=l>>4,c=qc[15&l];"M"!==c&&"EQ"!==c&&"X"!==c&&"D"!==c&&"N"!==c&&"="!==c||(E+=h),M=M+h+c,T+=4,L={len:h,ltr:c},R.push(L)}if(f.chr=n[p],f.start=g,f.flags=y,f.strand=!(16&y),f.readName=A,f.cigar=M,f.lengthOnRef=E,f.fragmentLength=S,f.mq=b,Wc.bam_tag2cigar(e,u,T,x,f,R),f.end=f.start+f.lengthOnRef,f.end<s){t=u;continue}let I=[];const B=x+1>>1;for(let t=0;t<B;++t){var d=e[T+t];I.push(Uc[(240&d)>>4]),I.push(Uc[15&d])}I=I.slice(0,x).join(""),T+=B;const F=[];for(let t=0;t<x;++t)F.push(e[T+t]);T+=x,k>=0&&(f.mate={chr:n[k],position:C,strand:!(32&y)}),f.seq=I,f.qual=F,f.tagBA=new Uint8Array(e.buffer.slice(T,u)),this.setPairOrientation(f),(void 0===a||a.pass(f))&&(Gc(f,R),i.push(f)),t=u}},decodeSamRecords:function(e,t,i,n,r,s){var o,a,l,h,c,d,u,f,p,g;for(h=(o=Yt(e)).length,!1,a=0;a<h;a++)if(c=o[a].split("\t"),(p=new Ic).chr=c[2],p.start=Number.parseInt(c[3])-1,p.flags=Number.parseInt(c[1]),p.readName=c[0],p.strand=!(16&p.flags),p.mq=Number.parseInt(c[4]),p.cigar=c[5],p.fragmentLength=Number.parseInt(c[8]),p.seq=c[9],"*"!==p.chr&&p.isMapped()&&p.chr===i){if(p.start>r)break;if(f=0,(g=Qc(p.cigar)).forEach((function(e){var t=e.len,i=e.ltr;"M"!==i&&"EQ"!==i&&"X"!==i&&"D"!==i&&"N"!==i&&"="!==i||(f+=t)})),p.lengthOnRef=f,!(p.start+f<n)){for(d=c[10],p.qual=[],l=0;l<d.length;l++)p.qual[l]=d.charCodeAt(l)-33;p.tagDict=c.length<11?{}:Xc(c.slice(11)),p.isMateMapped()&&(u=c[6],p.mate={chr:"="===u?p.chr:u,position:Number.parseInt(c[7]),strand:!(32&p.flags)}),this.setPairOrientation(p),(void 0===s||s.pass(p))&&(Gc(p,g),t.push(p))}}},setReaderDefaults:function(e,t){e.filter=new Vc(t.filter),t.readgroup&&(e.filter.readgroups=new Set([t.readgroup])),e.alleleFreqThreshold=void 0===t.alleleFreqThreshold?.2:t.alleleFreqThreshold,e.samplingWindowSize=void 0===t.samplingWindowSize?100:t.samplingWindowSize,e.samplingDepth=void 0===t.samplingDepth?500:t.samplingDepth,e.samplingDepth>$c&&(console.log("Warning: attempt to set sampling depth > maximum value of "+$c),e.samplingDepth=$c),t.viewAsPairs?e.pairsSupported=!0:e.pairsSupported=void 0===t.pairsSupported||t.pairsSupported},setPairOrientation:function(e){if(e.isMapped()&&e.mate&&e.isMateMapped()&&e.mate.chr===e.chr){var t=e.strand?"F":"R",i=e.mate,n=i.strand?"F":"R",r=" ",s=" ";e.isFirstOfPair()?(r="1",s="2"):e.isSecondOfPair()&&(r="2",s="1");var o=[],a=e.fragmentLength,l=e.end-e.start;if(0===a)a=(e.start<i.position?i.position+l:i.position-l)-e.start;a>0?(o[0]=t,o[1]=r,o[2]=n,o[3]=s):(o[2]=t,o[3]=r,o[0]=n,o[1]=s),e.pairOrientation=o.join("")}},computeLengthOnReference:function(e){let t=0,i="";for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);if(r>47&&r<58)i+=e.charAt(n);else{switch(r){case 78:case 68:case 77:case 61:case 88:t+=parseInt(i.toString())}i=""}}return t}};function Gc(e,t){const i=[];let n,r,s=0,o=e.start;e.scStart=e.start,e.scLengthOnRef=e.lengthOnRef;for(let a of t){let t;switch(a.ltr){case"H":case"P":break;case"S":t=o,e.scLengthOnRef+=a.len,0===i.length&&(e.scStart-=a.len,t-=a.len),i.push(new Hc({start:t,seqOffset:s,len:a.len,type:"S"})),s+=a.len;break;case"N":case"D":void 0===r&&(r=[]),r.push({start:o,len:a.len,type:a.ltr}),o+=a.len;break;case"I":void 0===n&&(n=[]),n.push(new Hc({start:o,len:a.len,seqOffset:s,type:"I"})),s+=a.len;break;case"M":case"EQ":case"=":case"X":i.push(new Hc({start:o,seqOffset:s,len:a.len,type:"M"})),s+=a.len,o+=a.len;break;default:console.log("Error processing cigar element: "+a.len+a.ltr)}}e.blocks=i,e.insertions=n,e.gaps=r}function Zc(e,t){return e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t]}function Qc(e){var t,i,n,r,s,o,a,l,h;for(t=[],i=[],s=null,r=e.length,n=0;n<r;n++)o=e.charAt(n),h=void 0,(h=o.charCodeAt(0))>=48&&h<=57?i.push(o):(a=o,l=Number.parseInt(i.join("")),i=[],null!==s&&s.ltr===a?s.len+=l:(s={len:l,ltr:a},t.push(s)));return t}function Xc(e){var t={};return e.forEach((function(e){var i=e.split(":");t[i[0]]=i[2]})),t}class Yc{constructor(e,t){this.config=e,this.genome=t,this.bamPath=e.url,this.isDataUri=Fo(e.url),Wc.setReaderDefaults(this,e)}async readAlignments(e,t,i){if(this.alignmentCache){const n=this.header,r=n.chrAliasTable.hasOwnProperty(e)?n.chrAliasTable[e]:e,s=this.alignmentCache.queryFeatures(r,t,i),o=new Cc(e,t,i,this.config);for(let e of s)o.push(e);return o.finish(),o}if(this.isDataUri){const n=Ts(function(e){const t=e.split(","),i=t[0].split(":")[1];let n=t[1];n=i.indexOf("base64")>=0?atob(n):decodeURI(n);const r=new Uint8Array(n.length);for(var s=0;s<n.length;s++)r[s]=n.charCodeAt(s);return r}(this.bamPath).buffer);return this.parseAlignments(n),this.fetchAlignments(e,t,i)}{const n=Ts(await no.loadArrayBuffer(this.bamPath,To(this.config)));return this.parseAlignments(n),this.fetchAlignments(e,t,i)}}parseAlignments(e){const t=[];this.header=Wc.decodeBamHeader(e),Wc.decodeBamRecords(e,this.header.size,t,this.header.chrNames),this.alignmentCache=new po(t,this.genome)}fetchAlignments(e,t,i){const n=this.header.chrAliasTable.hasOwnProperty(e)?this.header.chrAliasTable[e]:e,r=this.alignmentCache.queryFeatures(n,t,i),s=new Cc(e,t,i,this.config);for(let e of r)s.push(e);return s.finish(),s}}class Kc{constructor(e,t){this.config=e,this.genome=t,this.bamPath=e.url,this.baiPath=e.indexURL,Wc.setReaderDefaults(this,e),this._blockLoader=new ph(e)}async readAlignments(e,t,i){const n=(await this.getChrIndex())[this.chrAliasTable.hasOwnProperty(e)?this.chrAliasTable[e]:e],r=new Cc(e,t,i,this.config);if(void 0===n)return r;{const e=(await this.getIndex()).chunksForRange(n,t,i);if(!e||0===e.length)return r;for(let s of e){const e=await this._blockLoader.getData(s.minv,s.maxv);if(Wc.decodeBamRecords(e,s.minv.offset,r,this.indexToChr,n,t,i,this.filter))break}return r.finish(),r}}async getHeader(){if(!this.header){const e=this.genome,t=await this.getIndex();let i;if(t.firstBlockPosition){const e=To(this.config,{range:{start:t.firstBlockPosition,size:26}}),n=Rs(await no.loadArrayBuffer(this.bamPath,e));i=t.firstBlockPosition+n}else i=64e3;const n=To(this.config,{range:{start:0,size:i}});this.header=await Wc.readHeader(this.bamPath,n,e)}return this.header}async getIndex(){const e=this.genome;return this.index||(this.index=await lh(this.baiPath,this.config,e)),this.index}async getChrIndex(){if(this.chrToIndex)return this.chrToIndex;{const e=await this.getHeader();return this.chrToIndex=e.chrToIndex,this.indexToChr=e.chrNames,this.chrAliasTable=e.chrAliasTable,this.chrToIndex}}}class Jc{constructor(e,t){this.config=e,this.genome=t;const i={};e.sources.sequences.forEach((function(n){const r=t?t.getChromosomeName(n):n;i[r]=function(e,t,i){const n={url:e.sources.url.replace("$CHR",i)};e.sources.indexURL&&(n.indexURL=e.sources.indexURL.replace("$CHR",i));const r=Object.assign(e,n);return new Kc(r,t)}(e,t,n)})),this.bamReaders=i,Wc.setReaderDefaults(this,e)}async readAlignments(e,t,i){if(this.bamReaders.hasOwnProperty(e)){let n=this.bamReaders[e];return await n.readAlignments(e,t,i)}return new Cc(e,t,i,this.config)}}const ed=function(e,t){this.config=e,this.genome=t,Wc.setReaderDefaults(this,e)};function td(){const e=this,t=this.genome;if(this.header)return Promise.resolve(this.header);{const i=this.config.url+"?file="+this.config.alignmentFile+"&options=-b,-H",n=To(this.config);return Wc.readHeader(i,n,t).then((function(t){return e.header=t,t}))}}ed.prototype.readAlignments=function(e,t,i){var n=this;return td.call(n).then((function(r){var s,o;return s=r.chrAliasTable.hasOwnProperty(e)?r.chrAliasTable[e]:e,o=n.config.url+"?reference="+n.config.referenceFile+"&file="+n.config.alignmentFile+"®ion="+s+":"+t+"-"+i,no.loadString(o,To(n.config)).then((function(o){var a;return r.chrToIndex[s],a=new Cc(e,t,i,n.config),Wc.decodeSamRecords(o,a,s,t,i,n.filter),a}))}))};class id extends Lh{constructor(e,t){super(e,t),Wc.setReaderDefaults(this,e)}async readAlignments(e,t,i){if(!this.header){const e=Ts((await this.readHeaderData()).buffer);this.header=Wc.decodeBamHeader(e,this.genome),this.chrAliasTable=new Map;for(let e of Object.keys(this.header.chrAliasTable))this.chrAliasTable.set(e,this.header.chrAliasTable[e])}let n=this.chrAliasTable.has(e)?this.chrAliasTable.get(e):e;const r=Ts((await this.readData(n,t,i)).buffer),s=this.header.chrToIndex[e],o=new Cc(e,t,i,this.config);return Wc.decodeBamRecords(r,this.header.size,o,this.header.chrNames,s,t,i),o.finish(),o}}
/*! For license information please see cram-bundle.js.LICENSE.txt */const nd=(()=>{var e={368:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{l(n.next(e))}catch(e){s(e)}}function a(e){try{l(n.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=r(i(4105)),o=r(i(1269)),a=i(597),l=i(3427),h=i(8577);function c(e,t){if(t.some((e=>void 0===e)))throw new h.CramMalformedError("invalid .crai index file");const[i,n,r,s,o,a]=t;e[i]||(e[i]=[]),e[i].push({start:n,span:r,containerStart:s,sliceStart:o,sliceBytes:a})}t.default=class{constructor(e){this.filehandle=(0,l.open)(e.url,e.path,e.filehandle),this._parseCache=new s.default({cache:new o.default({maxSize:1}),fill:(e,t)=>this.parseIndex()})}parseIndex(){const e={};return this.filehandle.readFile().then((e=>31===e[0]&&139===e[1]?(0,a.unzip)(e):e)).then((t=>{if(t.length>4&&21578050===t.readUInt32LE(0))throw new h.CramMalformedError("invalid .crai index file. note: file appears to be a .bai index. this is technically legal but please open a github issue if you need support");let i=[],n="";for(let r=0;r<t.length;r+=1){const s=t[r];if(s>=48&&s<=57||!n&&45===s)n+=String.fromCharCode(s);else if(9===s)i.push(Number.parseInt(n,10)),n="";else if(10===s)i.push(Number.parseInt(n,10)),n="",c(e,i),i=[];else if(13!==s&&32!==s)throw new h.CramMalformedError("invalid .crai index file")}return n&&i.push(Number.parseInt(n,10)),6===i.length&&c(e,i),Object.entries(e).forEach((([t,i])=>{e[t]=i.sort(((e,t)=>e.start-t.start||e.span-t.span))})),e}))}getIndex(e={}){return this._parseCache.get("index",null,e.signal)}hasDataForReferenceSequence(e){return n(this,void 0,void 0,(function*(){return!!(yield this.getIndex())[e]}))}getEntriesForRange(e,t,i){return n(this,void 0,void 0,(function*(){const n=(yield this.getIndex())[e];if(!n)return[];const r=e=>{const n=e.start,r=e.start+e.span;return n>i?-1:r<=t?1:0},s=[];for(let e=0;e<n.length;e+=1)0===r(n[e])&&s.push(n[e]);return s}))}}},1050:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(e,t){this.parameters=e,this.dataType=t}}},4863:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=i(8577),s=n(i(1050)),o=i(1074);class a extends s.default{constructor(e,t){if(super(e,t),"int"!==this.dataType)throw new r.CramUnimplementedError(`${this.dataType} decoding not yet implemented by BETA codec`)}decode(e,t,i,n){return(0,o.getBits)(t.content,n.coreBlock,this.parameters.length)-this.parameters.offset}}t.default=a},1738:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=i(9488),s=n(i(1050));class o extends s.default{constructor(e,t,i){if(super(e,t),this.instantiateCodec=i,"byteArray"!==t)throw new TypeError(`byteArrayLength does not support data type ${t}`)}decode(e,t,i,n){const r=this._getLengthCodec().decode(e,t,i,n),s=this._getDataCodec(),o=new Uint8Array(r);for(let a=0;a<r;a+=1)o[a]=s.decode(e,t,i,n);return o}_getLengthCodec(){const e=this.parameters.lengthsEncoding;return this.instantiateCodec(e,"int")}_getDataCodec(){const e=this.parameters.valuesEncoding;return this.instantiateCodec(e,"byte")}}t.default=o,"_getLengthCodec _getDataCodec".split(" ").forEach((e=>(0,r.tinyMemoize)(o,e)))},1405:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=i(8577),s=n(i(1050)),o=i(1074);class a extends s.default{constructor(e,t){if(super(e,t),"byteArray"!==t)throw new TypeError(`byteArrayStop codec does not support data type ${t}`)}decode(e,t,i,n){const{blockContentId:s}=this.parameters,o=i[s];if(!o)throw new r.CramMalformedError(`no block found with content ID ${s}`);const a=n.externalBlocks.getCursor(s);return this._decodeByteArray(o,a)}_decodeByteArray(e,t){const i=e.content,{stopByte:n}=this.parameters,r=t.bytePosition;let s=t.bytePosition;for(;i[s]!==n&&s<i.length;){if(s===i.length)throw new o.CramBufferOverrunError("byteArrayStop reading beyond length of data buffer?");s+=1}return t.bytePosition=s+1,i.subarray(r,s)}}t.default=a},5844:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=i(8577),s=n(i(1050)),o=i(9488),a=i(1074);class l extends s.default{constructor(e,t){if(super(e,t),"int"===this.dataType)this._decodeData=this._decodeInt;else{if("byte"!==this.dataType)throw new r.CramUnimplementedError(`${this.dataType} decoding not yet implemented by EXTERNAL codec`);this._decodeData=this._decodeByte}}decode(e,t,i,n){const{blockContentId:s}=this.parameters,o=i[s];if(!o)throw new r.CramMalformedError(`no block found with content ID ${s}`);const a=n.externalBlocks.getCursor(s);return this._decodeData(o,a)}_decodeInt(e,t){const[i,n]=(0,o.parseItf8)(e.content,t.bytePosition);return t.bytePosition=t.bytePosition+n,i}_decodeByte(e,t){if(t.bytePosition>=e.content.length)throw new a.CramBufferOverrunError("attempted to read beyond end of block. this file seems truncated.");return e.content[t.bytePosition++]}}t.default=l},4229:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=i(8577),s=n(i(1050)),o=i(1074);class a extends s.default{constructor(e,t){if(super(e,t),"int"!==this.dataType)throw new r.CramUnimplementedError(`${this.dataType} decoding not yet implemented by GAMMA codec`)}decode(e,t,i,n){let r=1;for(;0===(0,o.getBits)(t.content,n.coreBlock,1);)r+=1;return((0,o.getBits)(t.content,n.coreBlock,r-1)|1<<r-1)-this.parameters.offset}}t.default=a},1074:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getBits=t.CramBufferOverrunError=void 0;class i extends Error{}t.CramBufferOverrunError=i,t.getBits=function(e,t,n){let r=0;if(t.bytePosition+(7-t.bitPosition+n)/8>e.length)throw new i("read error during decoding. the file seems to be truncated.");for(let i=n;i;i--)r<<=1,r|=e[t.bytePosition]>>t.bitPosition&1,t.bitPosition-=1,t.bitPosition<0&&(t.bytePosition+=1),t.bitPosition&=7;return r}},2082:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=i(8577),s=n(i(1050)),o=i(1074);class a extends s.default{constructor(e,t){if(super(e,t),this.codes={},this.codeBook={},this.sortedByValue=[],this.sortedCodes=[],this.sortedValuesByBitCode=[],this.sortedBitCodes=[],this.sortedBitLengthsByBitCode=[],this.bitCodeToValue=[],!["byte","int"].includes(this.dataType))throw new TypeError(`${this.dataType} decoding not yet implemented by HUFFMAN_INT codec`);this.buildCodeBook(),this.buildCodes(),this.buildCaches(),0===this.sortedCodes[0].bitLength&&(this._decode=this._decodeZeroLengthCode)}buildCodeBook(){let e=new Array(this.parameters.numCodes);for(let t=0;t<this.parameters.numCodes;t+=1)e[t]={symbol:this.parameters.symbols[t],bitLength:this.parameters.bitLengths[t]};e=e.sort(((e,t)=>e.bitLength-t.bitLength||e.symbol-t.symbol)),this.codeBook={},e.forEach((e=>{this.codeBook[e.bitLength]||(this.codeBook[e.bitLength]=[]),this.codeBook[e.bitLength].push(e.symbol)}))}buildCodes(){this.codes={};let e=0,t=-1;Object.entries(this.codeBook).forEach((([i,n])=>{const s=parseInt(i,10);n.forEach((i=>{const n={bitLength:s,value:i,bitCode:0};t+=1;const o=s-e;if(t<<=o,n.bitCode=t,e+=o,function(e){let t=e-(e>>1)&1431655765;return t=(858993459&t)+(t>>2&858993459),16843009*(t+(t>>4)&252645135)>>24}(t)>s)throw new r.CramMalformedError("Symbol out of range");this.codes[i]=n}))}))}buildCaches(){this.sortedCodes=Object.values(this.codes).sort(((e,t)=>e.bitLength-t.bitLength||e.bitCode-t.bitCode)),this.sortedByValue=Object.values(this.codes).sort(((e,t)=>e.value-t.value)),this.sortedValuesByBitCode=this.sortedCodes.map((e=>e.value)),this.sortedBitCodes=this.sortedCodes.map((e=>e.bitCode)),this.sortedBitLengthsByBitCode=this.sortedCodes.map((e=>e.bitLength));const e=Math.max(...this.sortedBitCodes);this.bitCodeToValue=new Array(e+1).fill(-1);for(let e=0;e<this.sortedBitCodes.length;e+=1)this.bitCodeToValue[this.sortedCodes[e].bitCode]=e}decode(e,t,i,n){return this._decode(e,t,n.coreBlock)}_decodeZeroLengthCode(){return this.sortedCodes[0].value}_decode(e,t,i){const n=t.content;let s=0,a=0;for(let e=0;e<this.sortedCodes.length;e+=1){const t=this.sortedCodes[e].bitLength;a<<=t-s,a|=(0,o.getBits)(n,i,t-s),s=t;{const i=this.bitCodeToValue[a];if(i>-1&&this.sortedBitLengthsByBitCode[i]===t)return this.sortedValuesByBitCode[i];for(let i=e;this.sortedCodes[i+1].bitLength===t&&i<this.sortedCodes.length;i+=1)e+=1}}throw new r.CramMalformedError("Huffman symbol not found.")}}t.default=a},8772:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.instantiateCodec=void 0;const r=i(8577),s=n(i(2082)),o=n(i(5844)),a=n(i(1405)),l=n(i(1738)),h=n(i(4863)),c=n(i(4229)),d=n(i(8821)),u={1:o.default,3:s.default,4:l.default,5:a.default,6:h.default,7:d.default,9:c.default};t.instantiateCodec=function e(t,i){const n=(s="ignore"===i?0:t.codecId,u[s]);var s;if(!n)throw new r.CramUnimplementedError(`no codec implemented for codec ID ${t.codecId}`);return new n(t.parameters,i,e)}},8821:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=i(8577),s=n(i(1050)),o=i(1074);class a extends s.default{constructor(e,t){if(super(e,t),"int"!==this.dataType)throw new r.CramUnimplementedError(`${this.dataType} decoding not yet implemented by SUBEXP codec`)}decode(e,t,i,n){let r,s,a=0;for(;(0,o.getBits)(t.content,n.coreBlock,1);)a+=1;return 0===a?(r=this.parameters.K,s=(0,o.getBits)(t.content,n.coreBlock,r)):(r=a+this.parameters.K-1,s=1<<r|(0,o.getBits)(t.content,n.coreBlock,r)),s-this.parameters.offset}}t.default=a},2615:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default={CRAM_FLAG_PRESERVE_QUAL_SCORES:1,CRAM_FLAG_DETACHED:2,CRAM_FLAG_MATE_DOWNSTREAM:4,CRAM_FLAG_NO_SEQ:8,CRAM_FLAG_MASK:15,CRAM_M_REVERSE:1,CRAM_M_UNMAP:2,BAM_FPAIRED:1,BAM_FPROPER_PAIR:2,BAM_FUNMAP:4,BAM_FMUNMAP:8,BAM_FREVERSE:16,BAM_FMREVERSE:32,BAM_FREAD1:64,BAM_FREAD2:128,BAM_FSECONDARY:256,BAM_FQCFAIL:512,BAM_FDUP:1024,BAM_FSUPPLEMENTARY:2048,BAM_CMATCH:0,BAM_CINS:1,BAM_CDEL:2,BAM_CREF_SKIP:3,BAM_CSOFT_CLIP:4,BAM_CHARD_CLIP:5,BAM_CPAD:6,BAM_CEQUAL:7,BAM_CDIFF:8,BAM_CBACK:9,BAM_CIGAR_STR:"MIDNSHP:XB",BAM_CIGAR_SHIFT:4,BAM_CIGAR_MASK:15,BAM_CIGAR_TYPE:246183}},8543:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=i(8772),r=i(8577),s={BF:"int",CF:"int",RI:"int",RL:"int",AP:"int",RG:"int",MF:"int",NS:"int",NP:"int",TS:"int",NF:"int",TC:"byte",TN:"int",FN:"int",FC:"byte",FP:"int",BS:"byte",IN:"byteArray",SC:"byteArray",DL:"int",BA:"byte",BB:"byteArray",RS:"int",PD:"int",HC:"int",MQ:"int",RN:"byteArray",QS:"byte",QQ:"byteArray",TL:"int"};t.default=class{constructor(e){this.dataSeriesCodecCache={},this.tagCodecCache={},this.tagEncoding={},this.readNamesIncluded=e.preservation.RN,this.APdelta=e.preservation.AP,this.referenceRequired=!!e.preservation.RR,this.tagIdsDictionary=e.preservation.TD,this.substitutionMatrix=function(e){const t=new Array(5);for(let e=0;e<5;e+=1)t[e]=new Array(4);return t[0][e[0]>>6&3]="C",t[0][e[0]>>4&3]="G",t[0][e[0]>>2&3]="T",t[0][e[0]>>0&3]="N",t[1][e[1]>>6&3]="A",t[1][e[1]>>4&3]="G",t[1][e[1]>>2&3]="T",t[1][e[1]>>0&3]="N",t[2][e[2]>>6&3]="A",t[2][e[2]>>4&3]="C",t[2][e[2]>>2&3]="T",t[2][e[2]>>0&3]="N",t[3][e[3]>>6&3]="A",t[3][e[3]>>4&3]="C",t[3][e[3]>>2&3]="G",t[3][e[3]>>0&3]="N",t[4][e[4]>>6&3]="A",t[4][e[4]>>4&3]="C",t[4][e[4]>>2&3]="G",t[4][e[4]>>0&3]="T",t}(e.preservation.SM),this.dataSeriesEncoding=e.dataSeriesEncoding,this.tagEncoding=e.tagEncoding,this.preservation=e.preservation,this._size=e._size,this._endPosition=e._endPosition}getCodecForTag(e){if(!this.tagCodecCache[e]){const t=this.tagEncoding[e];t&&(this.tagCodecCache[e]=(0,n.instantiateCodec)(t,"byteArray"))}return this.tagCodecCache[e]}getTagNames(e){return this.tagIdsDictionary[e]}getCodecForDataSeries(e){let t=this.dataSeriesCodecCache[e];if(void 0===t){const i=this.dataSeriesEncoding[e];if(i){const o=s[e];if(!o)throw new r.CramMalformedError(`data series name ${e} not defined in file compression header`);t=(0,n.instantiateCodec)(i,o),this.dataSeriesCodecCache[e]=t}}return t}toJSON(){const e={};return Object.keys(this).forEach((t=>{/Cache$/.test(t)||(e[t]=this[t])})),e}}},6284:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{l(n.next(e))}catch(e){s(e)}}function a(e){try{l(n.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(8577),o=i(9488),a=r(i(6601)),l=r(i(8543));class h{constructor(e,t){this.file=e,this.filePosition=t}getHeader(){return this._readContainerHeader(this.filePosition)}getCompressionHeaderBlock(){return n(this,void 0,void 0,(function*(){if(!(yield this.getHeader()).numRecords)return null;const e=yield this.file.getSectionParsers(),t=yield this.getFirstBlock();if(void 0===t)return;if("COMPRESSION_HEADER"!==t.contentType)throw new s.CramMalformedError(`invalid content type ${t.contentType} in what is supposed to be the compression header block`);const i=(0,o.parseItem)(t.content,e.cramCompressionHeader.parser,0,t.contentPosition);return Object.assign(Object.assign({},t),{parsedContent:i})}))}getFirstBlock(){return n(this,void 0,void 0,(function*(){const e=yield this.getHeader();return this.file.readBlock(e._endPosition)}))}getCompressionScheme(){return n(this,void 0,void 0,(function*(){const e=yield this.getCompressionHeaderBlock();if(e)return new l.default(e.parsedContent)}))}getSlice(e,t){return new a.default(this,e,t)}_readContainerHeader(e){return n(this,void 0,void 0,(function*(){const t=yield this.file.getSectionParsers(),{cramContainerHeader1:i,cramContainerHeader2:n}=t,{size:r}=yield this.file.stat();if(e>=r)return;const s=Buffer.allocUnsafe(i.maxLength);yield this.file.read(s,0,i.maxLength,e);const a=(0,o.parseItem)(s,i.parser),l=(0,o.itf8Size)(a.numLandmarks);if(e+a.length>=r)return void console.warn(`${this.file}: container header at ${e} indicates that the container has length ${a.length}, which extends beyond the length of the file. Skipping this container.`);const h=Buffer.allocUnsafe(n.maxLength(a.numLandmarks));yield this.file.read(h,0,n.maxLength(a.numLandmarks),e+a._size-l);const c=(0,o.parseItem)(h,n.parser);return this.file.validateChecksums&&void 0!==c.crc32&&(yield this.file.checkCrc32(e,a._size+c._size-l-4,c.crc32,`container header beginning at position ${e}`)),Object.assign(a,c,{_size:a._size+c._size-l,_endPosition:a._size+c._size-l+e})}))}}t.default=h,"getHeader getCompressionHeaderBlock getCompressionScheme".split(" ").forEach((e=>(0,o.tinyMemoize)(h,e)))},5457:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{l(n.next(e))}catch(e){s(e)}}function a(e){try{l(n.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(597),o=r(i(2779)),a=r(i(1269)),l=i(8577),h=r(i(9675)),c=i(6141),d=r(i(3498)),u=r(i(6284)),f=i(3427),p=i(9488),g=i(7578);class m{constructor(e){var t;if(this.file=(0,f.open)(e.url,e.path,e.filehandle),this.validateChecksums=!0,this.fetchReferenceSequenceCallback=e.seqFetch,this.options={checkSequenceMD5:e.checkSequenceMD5,cacheSize:null!==(t=e.cacheSize)&&void 0!==t?t:2e4},this.featureCache=new a.default({maxSize:this.options.cacheSize}),function(){const e=new Uint32Array([287454020]),t=new Uint8Array(e.buffer);return 68===t[0]?0:17===t[0]?1:2}()>0)throw new Error("Detected big-endian machine, may be unable to run")}read(e,t,i,n){return this.file.read(e,t,i,n)}stat(){return this.file.stat()}getDefinition(){return n(this,void 0,void 0,(function*(){const e=Buffer.allocUnsafe(c.cramFileDefinition.maxLength);yield this.file.read(e,0,c.cramFileDefinition.maxLength,0);const t=c.cramFileDefinition.parser.parse(e).result;if(2!==t.majorVersion&&3!==t.majorVersion)throw new l.CramUnimplementedError(`CRAM version ${t.majorVersion} not supported`);return t}))}getSamHeader(){return n(this,void 0,void 0,(function*(){const e=yield this.getContainerById(0);if(!e)throw new l.CramMalformedError("file contains no containers");const t=yield e.getFirstBlock();if(void 0===t)return(0,g.parseHeaderText)("");const i=t.content,n=i.readInt32LE(0),r=i.toString("utf8",4,4+n);return this.header=r,(0,g.parseHeaderText)(r)}))}getHeaderText(){return n(this,void 0,void 0,(function*(){return yield this.getSamHeader(),this.header}))}getSectionParsers(){return n(this,void 0,void 0,(function*(){const{majorVersion:e}=yield this.getDefinition();return(0,c.getSectionParsers)(e)}))}getContainerById(e){return n(this,void 0,void 0,(function*(){const t=yield this.getSectionParsers();let i=t.cramFileDefinition.maxLength;const{size:n}=yield this.file.stat(),{cramContainerHeader1:r}=t;let s;for(let t=0;t<=e;t+=1){if(i+r.maxLength+8>=n)return;s=this.getContainerAtPosition(i);const o=yield s.getHeader();if(!o)throw new l.CramMalformedError(`container ${e} not found in file`);if(0===t){i=o._endPosition;for(let e=0;e<o.numBlocks;e+=1){const e=yield this.readBlock(i);if(void 0===e)return;i=e._endPosition}}else i+=o._size+o.length}return s}))}checkCrc32(e,t,i,r){return n(this,void 0,void 0,(function*(){const n=Buffer.allocUnsafe(t);yield this.file.read(n,0,t,e);const s=o.default.unsigned(n);if(s!==i)throw new l.CramMalformedError(`crc mismatch in ${r}: recorded CRC32 = ${i}, but calculated CRC32 = ${s}`)}))}containerCount(){return n(this,void 0,void 0,(function*(){const e=yield this.getSectionParsers(),{size:t}=yield this.file.stat(),{cramContainerHeader1:i}=e;let n=0,r=e.cramFileDefinition.maxLength;for(;r+i.maxLength+8<t;){const e=yield this.getContainerAtPosition(r).getHeader();if(!e)break;if(0===n){r=e._endPosition;for(let t=0;t<e.numBlocks;t+=1){const e=yield this.readBlock(r);if(void 0===e)return;r=e._endPosition}}else r+=e._size+e.length;n+=1}return n}))}getContainerAtPosition(e){return new u.default(this,e)}readBlockHeader(e){return n(this,void 0,void 0,(function*(){const t=yield this.getSectionParsers(),{cramBlockHeader:i}=t,{size:n}=yield this.file.stat();if(e+i.maxLength>=n)return;const r=Buffer.allocUnsafe(i.maxLength);return yield this.file.read(r,0,i.maxLength,e),(0,p.parseItem)(r,i.parser,0,e)}))}_parseSection(e,t,i=e.maxLength,r){return n(this,void 0,void 0,(function*(){let n;if(r)n=r;else{const{size:e}=yield this.file.stat();if(t+i>=e)return;n=Buffer.allocUnsafe(i),yield this.file.read(n,0,i,t)}const s=(0,p.parseItem)(n,e.parser,0,t);if(s._size!==i)throw new l.CramMalformedError(`section read error: requested size ${i} does not equal parsed size ${s._size}`);return s}))}_uncompress(e,t,i){if("gzip"===e)(0,s.unzip)(t).copy(i);else if("bzip2"===e){const e=bzip2.array(t);let n,r=bzip2.header(e),s=0;do{n=bzip2.decompress(e,r),-1!=n&&(Buffer.from(n).copy(i,s),s+=n.length,r-=n.length)}while(-1!=n)}else if("rans"===e)(0,h.default)(t,i);else if("rans4x16"===e)d.default.r4x16_uncompress(t,i);else if("arith"===e)d.default.arith_uncompress(t,i);else if("fqzcomp"===e)d.default.fqzcomp_uncompress(t,i);else{if("tok3"!==e)throw new l.CramUnimplementedError(`${e} decompression not yet implemented`);d.default.tok3_uncompress(t,i)}}readBlock(e){return n(this,void 0,void 0,(function*(){const{majorVersion:t}=yield this.getDefinition(),i=yield this.getSectionParsers(),n=yield this.readBlockHeader(e);if(void 0===n)return;const r=n._endPosition,s=Buffer.allocUnsafe(n.uncompressedSize),o=Object.assign(Object.assign({},n),{_endPosition:r,contentPosition:r,content:s});if("raw"!==n.compressionMethod){const e=Buffer.allocUnsafe(n.compressedSize);yield this.read(e,0,n.compressedSize,r),this._uncompress(n.compressionMethod,e,s)}else yield this.read(s,0,n.uncompressedSize,r);if(t>=3){const t=yield this._parseSection(i.cramBlockCrc32,r+n.compressedSize);if(void 0===t)return;o.crc32=t.crc32,this.validateChecksums&&(yield this.checkCrc32(e,n._size+n.compressedSize,t.crc32,"block data")),o._endPosition=t._endPosition,o._size=o.compressedSize+i.cramBlockCrc32.maxLength}else o._endPosition=r+o.compressedSize,o._size=o.compressedSize;return o}))}}t.default=m,"getDefinition getSectionParsers getSamHeader".split(" ").forEach((e=>(0,p.tinyMemoize)(m,e)))},8222:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CramRecord=void 0;const r=n(i(5457));var s=i(8631);Object.defineProperty(t,"CramRecord",{enumerable:!0,get:function(){return n(s).default}}),t.default=r.default},8631:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.MateFlagsDecoder=t.CramFlagsDecoder=t.BamFlagsDecoder=t.MateFlags=t.CramFlags=t.BamFlags=void 0;const r=n(i(2615)),s={a:0,A:0,c:1,C:1,g:2,G:2,t:3,T:3,n:4,N:4};function o(e){const t={};for(const[i,n]of e)t["is"+n]=e=>!!(e&i),t["set"+n]=e=>e|i;return t}t.BamFlags=[[1,"Paired"],[2,"ProperlyPaired"],[4,"SegmentUnmapped"],[8,"MateUnmapped"],[16,"ReverseComplemented"],[32,"MateReverseComplemented"],[64,"Read1"],[128,"Read2"],[256,"Secondary"],[512,"FailedQc"],[1024,"Duplicate"],[2048,"Supplementary"]],t.CramFlags=[[1,"PreservingQualityScores"],[2,"Detached"],[4,"WithMateDownstream"],[8,"DecodeSequenceAsStar"]],t.MateFlags=[[1,"OnNegativeStrand"],[2,"Unmapped"]],t.BamFlagsDecoder=o(t.BamFlags),t.CramFlagsDecoder=o(t.CramFlags),t.MateFlagsDecoder=o(t.MateFlags),t.default=class{constructor({flags:e,cramFlags:t,readLength:i,mappingQuality:n,lengthOnRef:r,qualityScores:s,mateRecordNumber:o,readBases:a,readFeatures:l,mateToUse:h,readGroupId:c,readName:d,sequenceId:u,uniqueId:f,templateSize:p,alignmentStart:g,tags:m}){this.flags=e,this.cramFlags=t,this.readLength=i,this.mappingQuality=n,this.lengthOnRef=r,this.qualityScores=s,a&&(this.readBases=a),this.readGroupId=c,this.readName=d,this.sequenceId=u,this.uniqueId=f,this.templateSize=p,this.alignmentStart=g,this.tags=m,l&&(this.readFeatures=l),h&&(this.mate={flags:h.mateFlags,readName:h.mateReadName,sequenceId:h.mateSequenceId,alignmentStart:h.mateAlignmentStart}),o&&(this.mateRecordNumber=o)}isPaired(){return!!(this.flags&r.default.BAM_FPAIRED)}isProperlyPaired(){return!!(this.flags&r.default.BAM_FPROPER_PAIR)}isSegmentUnmapped(){return!!(this.flags&r.default.BAM_FUNMAP)}isMateUnmapped(){return!!(this.flags&r.default.BAM_FMUNMAP)}isReverseComplemented(){return!!(this.flags&r.default.BAM_FREVERSE)}isMateReverseComplemented(){return!!(this.flags&r.default.BAM_FMREVERSE)}isRead1(){return!!(this.flags&r.default.BAM_FREAD1)}isRead2(){return!!(this.flags&r.default.BAM_FREAD2)}isSecondary(){return!!(this.flags&r.default.BAM_FSECONDARY)}isFailedQc(){return!!(this.flags&r.default.BAM_FQCFAIL)}isDuplicate(){return!!(this.flags&r.default.BAM_FDUP)}isSupplementary(){return!!(this.flags&r.default.BAM_FSUPPLEMENTARY)}isDetached(){return!!(this.cramFlags&r.default.CRAM_FLAG_DETACHED)}hasMateDownStream(){return!!(this.cramFlags&r.default.CRAM_FLAG_MATE_DOWNSTREAM)}isPreservingQualityScores(){return!!(this.cramFlags&r.default.CRAM_FLAG_PRESERVE_QUAL_SCORES)}isUnknownBases(){return!!(this.cramFlags&r.default.CRAM_FLAG_NO_SEQ)}getReadBases(){if(!this.readBases&&this._refRegion){const e=function(e,t){if(!e.lengthOnRef&&!e.readLength)return null;if(e.isUnknownBases())return null;const i=e.alignmentStart-t.start;if(!e.readFeatures)return t.seq.substr(i,e.lengthOnRef).toUpperCase();let n="",r=i,s=0;for(;n.length<e.readLength;)if(s<e.readFeatures.length){const i=e.readFeatures[s];if("Q"===i.code||"q"===i.code)s+=1;else if(i.pos===n.length+1)if(s+=1,"b"===i.code){const e=i.data;n+=e,r+=e.length}else"B"===i.code?(n+=i.data[0],r+=1):"X"===i.code?(n+=i.sub,r+=1):"I"===i.code?n+=i.data:"D"===i.code?r+=i.data:"i"===i.code?n+=i.data:"N"===i.code?r+=i.data:"S"===i.code?n+=i.data:"P"===i.code||i.code;else if(s<e.readFeatures.length){const i=t.seq.substr(r,e.readFeatures[s].pos-n.length-1);n+=i,r+=i.length}}else{const i=t.seq.substr(r,e.readLength-n.length);n+=i,r+=i.length}return n.toUpperCase()}(this,this._refRegion);e&&(this.readBases=e)}return this.readBases}getPairOrientation(){if(!this.isSegmentUnmapped()&&this.isPaired()&&!this.isMateUnmapped()&&this.mate&&this.sequenceId===this.mate.sequenceId){const e=this.isReverseComplemented()?"R":"F",t=this.isMateReverseComplemented()?"R":"F";let i=" ",n=" ";this.isRead1()?(i="1",n="2"):this.isRead2()&&(i="2",n="1");const r=[];let s=this.templateLength||this.templateSize;if(void 0===s)throw new Error("One of templateSize and templateLength must be set");return this.alignmentStart>this.mate.alignmentStart&&s>0&&(s=-s),s>0?(r[0]=e,r[1]=i,r[2]=t,r[3]=n):(r[2]=e,r[3]=i,r[0]=t,r[1]=n),r.join("")}return null}addReferenceSequence(e,t){this.readFeatures&&this.readFeatures.forEach((i=>{"X"===i.code&&function(e,t,i,n){if(!t)return;const r=n.refPos-t.start,o=t.seq.charAt(r);o&&(n.ref=o);let a=s[o];void 0===a&&(a=4);const l=i.substitutionMatrix[a][n.data];l&&(n.sub=l)}(0,e,t,i)})),!this.readBases&&e.start<=this.alignmentStart&&e.end>=this.alignmentStart+(this.lengthOnRef||this.readLength)-1&&(this._refRegion=e)}toJSON(){const e={};return Object.keys(this).forEach((t=>{"_"!==t.charAt(0)&&(e[t]=this[t])})),e.readBases=this.getReadBases(),e}}},6141:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getSectionParsers=t.cramFileDefinition=t.isMappedSliceHeader=void 0;const n=i(9996),r=(new n.Parser).itf8(),s={parser:(new n.Parser).string("magic",{length:4}).uint8("majorVersion").uint8("minorVersion").string("fileId",{length:20,stripNull:!0}),maxLength:26};t.cramFileDefinition=s;const o={parser:(new n.Parser).uint8("compressionMethod",{formatter:e=>{const t=["raw","gzip","bzip2","lzma","rans","rans4x16","arith","fqzcomp","tok3"][e];if(!t)throw new Error(`compression method number ${e} not implemented`);return t}}).uint8("contentType",{formatter:e=>{const t=["FILE_HEADER","COMPRESSION_HEADER","MAPPED_SLICE_HEADER","UNMAPPED_SLICE_HEADER","EXTERNAL_DATA","CORE_DATA"][e];if(!t)throw new Error(`invalid block content type id ${e}`);return t}}).itf8("contentId").itf8("compressedSize").itf8("uncompressedSize"),maxLength:17},a={parser:(new n.Parser).uint32("crc32"),maxLength:4},l=(new n.Parser).itf8("size").buffer("ents",{length:"size",formatter:e=>{function t(t,i){const n=e.toString("utf8",t,i),r=[];for(let e=0;e<n.length;e+=3)r.push(n.substr(e,3));return r}var i,n=[],r=0;for(i=0;i<e.length;i+=1)e[i]||(n.push(t(r,i)),r=i+1);return i>r&&n.push(t(r,i)),n}}),h=(new n.Parser).uint8(null,{formatter:e=>!!e}),c=(new n.Parser).itf8("mapSize").itf8("mapCount").array("ents",{length:"mapCount",type:(new n.Parser).string("key",{length:2,stripNull:!1}).choice("value",{tag:"key",choices:{MI:h,UI:h,PI:h,RN:h,AP:h,RR:h,SM:(new n.Parser).array(null,{type:"uint8",length:5}),TD:(new n.Parser).nest(null,{type:l,formatter:e=>e.ents})}})});function d(e){const t={};for(let i=0;i<e.ents.length;i+=1){const{key:n,value:r}=e.ents[i];t[n]&&console.warn(`duplicate key ${n} in map`),t[n]=r}return t}const u={cramFileDefinition:s,cramBlockHeader:o,cramBlockCrc32:a};t.isMappedSliceHeader=function(e){return"number"==typeof e.refSeqId};const f={cramUnmappedSliceHeader(e){let t=0,i=(new n.Parser).itf8("numRecords");return t+=5,e>=3?(i=i.ltf8("recordCounter"),t+=9):2===e&&(i=i.itf8("recordCounter"),t+=5),i=i.itf8("numBlocks").itf8("numContentIds").array("contentIds",{type:r,length:"numContentIds"}),t+=10,e>=2&&(i=i.array("md5",{type:"uint8",length:16}),t+=16),{parser:i,maxLength:e=>t+5*e}},cramMappedSliceHeader(e){let t=(new n.Parser).itf8("refSeqId").itf8("refSeqStart").itf8("refSeqSpan").itf8("numRecords"),i=20;return e>=3?(t=t.ltf8("recordCounter"),i+=9):2===e&&(t=t.itf8("recordCounter"),i+=5),t=t.itf8("numBlocks").itf8("numContentIds").array("contentIds",{type:r,length:"numContentIds"}).itf8("refBaseBlockId"),i+=15,e>=2&&(t=t.array("md5",{type:"uint8",length:16}),i+=16),{parser:t,maxLength:e=>i+5*e}},cramEncoding:e=>({parser:(new n.Parser).namely("cramEncoding").itf8("codecId").itf8("parametersBytes").choice("parameters",{tag:"codecId",choices:{0:new n.Parser,1:(new n.Parser).itf8("blockContentId"),2:(new n.Parser).itf8("offset").itf8("M"),3:n.Parser.start().itf8("numCodes").array("symbols",{length:"numCodes",type:r}).itf8("numLengths").array("bitLengths",{length:"numLengths",type:r}),4:n.Parser.start().nest("lengthsEncoding",{type:"cramEncoding"}).nest("valuesEncoding",{type:"cramEncoding"}),5:(new n.Parser).uint8("stopByte").itf8("blockContentId"),6:(new n.Parser).itf8("offset").itf8("length"),7:(new n.Parser).itf8("offset").itf8("K"),8:(new n.Parser).itf8("offset").itf8("log2m"),9:(new n.Parser).itf8("offset")}})}),cramDataSeriesEncodingMap(e){return(new n.Parser).itf8("mapSize").itf8("mapCount").array("ents",{length:"mapCount",type:(new n.Parser).string("key",{length:2,stripNull:!1}).nest("value",{type:this.cramEncoding(e).parser})})},cramTagEncodingMap(e){return(new n.Parser).itf8("mapSize").itf8("mapCount").array("ents",{length:"mapCount",type:(new n.Parser).itf8("key",{formatter:e=>String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)}).nest("value",{type:this.cramEncoding(e).parser})})},cramCompressionHeader(e){let t=new n.Parser;return t=t.nest("preservation",{type:c,formatter:d}).nest("dataSeriesEncoding",{type:this.cramDataSeriesEncodingMap(e),formatter:d}).nest("tagEncoding",{type:this.cramTagEncodingMap(e),formatter:d}),{parser:t}},cramContainerHeader1(e){let t=(new n.Parser).int32("length").itf8("refSeqId").itf8("refSeqStart").itf8("alignmentSpan").itf8("numRecords"),i=24;return e>=3?(t=t.ltf8("recordCounter"),i+=9):2===e&&(t=t.itf8("recordCounter"),i+=5),e>1&&(t=t.ltf8("numBases"),i+=9),t=t.itf8("numBlocks").itf8("numLandmarks"),i+=10,{parser:t,maxLength:i}},cramContainerHeader2(e){let t=(new n.Parser).itf8("numLandmarks").array("landmarks",{type:(new n.Parser).itf8(),length:"numLandmarks"}),i=0;return e>=3&&(t=t.uint32("crc32"),i=4),{parser:t,maxLength:e=>5+5*e+i}}};t.getSectionParsers=function(e){const t=Object.assign({},u);return Object.keys(f).forEach((i=>{t[i]=f[i](e)})),t}},3757:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=n(i(3720)),s=i(8577),o=i(8631),a=i(6141);function l(e){let t="";for(let i=0;i<e.length&&0!==e[i];i++)t+=String.fromCharCode(e[i]);return t}function h(e,t){if("Z"===e)return l(t);if("A"===e)return String.fromCharCode(t[0]);if("I"===e)return r.default.fromBytesLE(t).toNumber();if("i"===e)return new Int32Array(t.buffer)[0];if("s"===e)return new Int16Array(t.buffer)[0];if("S"===e)return new Uint16Array(t.buffer)[0];if("c"===e)return new Int8Array(t.buffer)[0];if("C"===e)return t[0];if("f"===e)return new Float32Array(t.buffer)[0];if("H"===e)return Number.parseInt(l(t).replace(/^0x/,""),16);if("B"===e)return function(e){const t=String.fromCharCode(e[0]),i=Int32Array.from(e.slice(1))[0],n=new Array(i);if(e=e.slice(5),"c"===t){const t=new Int8Array(e.buffer);for(let e=0;e<i;e+=1)n[e]=t[e]}else if("C"===t){const t=new Uint8Array(e.buffer);for(let e=0;e<i;e+=1)n[e]=t[e]}else if("s"===t){const t=new Int16Array(e.buffer);for(let e=0;e<i;e+=1)n[e]=t[e]}else if("S"===t){const t=new Uint16Array(e.buffer);for(let e=0;e<i;e+=1)n[e]=t[e]}else if("i"===t){const t=new Int32Array(e.buffer);for(let e=0;e<i;e+=1)n[e]=t[e]}else if("I"===t){const t=new Uint32Array(e.buffer);for(let e=0;e<i;e+=1)n[e]=t[e]}else{if("f"!==t)throw new Error("unknown type: "+t);{const t=new Float32Array(e.buffer);for(let e=0;e<i;e+=1)n[e]=t[e]}}return n}(t);throw new s.CramMalformedError(`Unrecognized tag type ${e}`)}t.default=function(e,t,i,n,r,c,d,u,f){let p=t("BF");const g=t("CF");if(!(0,a.isMappedSliceHeader)(n.parsedContent))throw new Error;let m;m=u>1&&-2===n.parsedContent.refSeqId?t("RI"):n.parsedContent.refSeqId;const b=t("RL");let w=t("AP");i.APdelta&&(w+=d.lastAlignmentStart),d.lastAlignmentStart=w;const v=t("RG");let y,_,x,k;if(i.readNamesIncluded&&(y=l(t("RN"))),o.CramFlagsDecoder.isDetached(g)){const e=t("MF");let n;i.readNamesIncluded||(n=l(t("RN")),y=n);const r=t("NS"),s=t("NP");(e||r>-1)&&(_={mateFlags:e,mateSequenceId:r,mateAlignmentStart:s,mateReadName:n}),x=t("TS"),o.MateFlagsDecoder.isUnmapped(e)&&(p=o.BamFlagsDecoder.setMateUnmapped(p)),o.MateFlagsDecoder.isOnNegativeStrand(e)&&(p=o.BamFlagsDecoder.setMateReverseComplemented(p))}else o.CramFlagsDecoder.isWithMateDownstream(g)&&(k=t("NF")+f+1);const C=t("TL");if(C<0)throw new s.CramMalformedError("invalid TL index");const S={},A=i.getTagNames(C),E=A.length;for(let t=0;t<E;t+=1){const n=A[t],o=n.substr(0,2),a=n.substr(2,1),l=i.getCodecForTag(n);if(!l)throw new s.CramMalformedError(`no codec defined for auxiliary tag ${n}`);const u=l.decode(e,r,c,d);S[o]=h(a,u)}let M,T,R,L,I;if(o.BamFlagsDecoder.isSegmentUnmapped(p))if(o.CramFlagsDecoder.isDecodeSequenceAsStar(g))I=null,L=null;else{const e=new Array(b);for(let i=0;i<e.length;i+=1)e[i]=t("BA");if(I=String.fromCharCode(...e),o.CramFlagsDecoder.isPreservingQualityScores(g)){L=new Array(b);for(let i=0;i<e.length;i+=1)L[i]=t("QS")}}else{const e=t("FN");if(e&&(M=function(e,t,i,n,r){let o=0,a=e-1;const l=new Array(t);function h([e,t]){const n=i(t);if("character"===e)return String.fromCharCode(n);if("string"===e){let e="";for(let t=0;t<n.byteLength;t++)e+=String.fromCharCode(n[t]);return e}return"numArray"===e?n.toArray():n}for(let e=0;e<t;e+=1){const t=String.fromCharCode(i("FC")),n=i("FP"),c={B:["character","BA"],S:["string",r>1?"SC":"IN"],X:["number","BS"],D:["number","DL"],I:["string","IN"],i:["character","BA"],b:["string","BB"],q:["numArray","QQ"],Q:["number","QS"],H:["number","HC"],P:["number","PD"],N:["number","RS"]}[t];if(!c)throw new s.CramMalformedError(`invalid read feature code "${t}"`);let d=h(c);const u={B:["number","QS"]}[t];u&&(d=[d,h(u)]),o+=n;const f=o;a+=n;const p=a;"D"===t||"N"===t?a+=d:"I"===t||"S"===t?a-=d.length:"i"===t&&(a-=1),l[e]={code:t,pos:f,refPos:p,data:d}}return l}(w,e,t,0,u)),T=b,M)for(const{code:e,data:t}of M)"D"===e||"N"===e?T+=t:"I"===e||"S"===e?T-=t.length:"i"===e&&(T-=1);if(Number.isNaN(T)&&(console.warn(`${y||`${m}:${w}`} record has invalid read features`),T=b),R=t("MQ"),o.CramFlagsDecoder.isPreservingQualityScores(g)){L=new Array(b);for(let e=0;e<L.length;e++)L[e]=t("QS")}}return{readLength:b,sequenceId:m,cramFlags:g,flags:p,alignmentStart:w,readGroupId:v,readName:y,mateToUse:_,templateSize:x,mateRecordNumber:k,readFeatures:M,lengthOnRef:T,mappingQuality:R,qualityScores:L,readBases:I,tags:S}}},6601:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{l(n.next(e))}catch(e){s(e)}}function a(e){try{l(n.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(8577),o=i(9488),a=r(i(2615)),l=r(i(3757)),h=r(i(8631)),c=i(6141),d=i(1074);function u(e,t,i,n){if(!n)throw new s.CramMalformedError("could not resolve intra-slice mate pairs, file seems truncated or malformed");const r=!!(n.mate||void 0!==n.mateRecordNumber&&n.mateRecordNumber!==t);i.readName||(i.readName=String(i.uniqueId),n.readName=i.readName),i.mate={sequenceId:n.sequenceId,alignmentStart:n.alignmentStart,uniqueId:n.uniqueId},n.readName&&(i.mate.readName=n.readName),n.mate||void 0!==n.mateRecordNumber||(n.mate={sequenceId:i.sequenceId,alignmentStart:i.alignmentStart,uniqueId:i.uniqueId},i.readName&&(n.mate.readName=i.readName)),i.flags|=a.default.BAM_FPAIRED,n.flags&a.default.BAM_FUNMAP&&(i.flags|=a.default.BAM_FMUNMAP),i.flags&a.default.BAM_FUNMAP&&(n.flags|=a.default.BAM_FMUNMAP),n.flags&a.default.BAM_FREVERSE&&(i.flags|=a.default.BAM_FMREVERSE),i.flags&a.default.BAM_FREVERSE&&(n.flags|=a.default.BAM_FMREVERSE),void 0===i.templateLength&&(r?function(e,t,i){const n=function t(i){const n=[i];if(void 0!==i.mateRecordNumber&&i.mateRecordNumber>=0){const r=e[i.mateRecordNumber];if(!r)throw new s.CramMalformedError("intra-slice mate record not found, this file seems malformed");n.push(...t(r))}return n}(i),r=n.map((e=>e.alignmentStart)),o=n.map((e=>e.alignmentStart+e.readLength-1)),a=Math.max(...o)-Math.min(...r)+1;a>=0&&n.forEach((e=>{if(void 0!==e.templateLength)throw new s.CramMalformedError("mate pair group has some members that have template lengths already, this file seems malformed");e.templateLength=a}))}(e,0,i):function(e,t){const i=Math.min(e.alignmentStart,t.alignmentStart),n=Math.max(e.alignmentStart+e.readLength-1,t.alignmentStart+t.readLength-1)-i+1;e.templateLength=n,t.templateLength=n}(i,n)),delete i.mateRecordNumber}class f{constructor(e,t,i){this.container=e,this.containerPosition=t,this.file=e.file}getHeader(){return n(this,void 0,void 0,(function*(){const e=yield this.file.getSectionParsers(),t=yield this.container.getHeader(),i=yield this.file.readBlock(t._endPosition+this.containerPosition);if(void 0===i)throw new Error;if("MAPPED_SLICE_HEADER"===i.contentType){const n=(0,o.parseItem)(i.content,e.cramMappedSliceHeader.parser,0,t._endPosition);return Object.assign(Object.assign({},i),{parsedContent:n})}if("UNMAPPED_SLICE_HEADER"===i.contentType){const n=(0,o.parseItem)(i.content,e.cramUnmappedSliceHeader.parser,0,t._endPosition);return Object.assign(Object.assign({},i),{parsedContent:n})}throw new s.CramMalformedError(`error reading slice header block, invalid content type ${i.contentType}`)}))}getBlocks(){return n(this,void 0,void 0,(function*(){const e=yield this.getHeader();let t=e._endPosition;const i=new Array(e.parsedContent.numBlocks);for(let e=0;e<i.length;e+=1){const n=yield this.file.readBlock(t);if(void 0===n)throw new Error;i[e]=n,t=i[e]._endPosition}return i}))}getCoreDataBlock(){return n(this,void 0,void 0,(function*(){return(yield this.getBlocks())[0]}))}_getBlocksContentIdIndex(){return n(this,void 0,void 0,(function*(){const e=yield this.getBlocks(),t={};return e.forEach((e=>{"EXTERNAL_DATA"===e.contentType&&(t[e.contentId]=e)})),t}))}getBlockByContentId(e){return n(this,void 0,void 0,(function*(){return(yield this._getBlocksContentIdIndex())[e]}))}getReferenceRegion(){return n(this,void 0,void 0,(function*(){const e=(yield this.getHeader()).parsedContent;if(!(0,c.isMappedSliceHeader)(e))throw new Error;if(e.refSeqId<0)return;const t=yield this.container.getCompressionScheme();if(void 0===t)throw new Error;if(e.refBaseBlockId>=0){const t=yield this.getBlockByContentId(e.refBaseBlockId);if(!t)throw new s.CramMalformedError("embedded reference specified, but reference block does not exist");return{seq:t.data.toString("utf8"),start:e.refSeqStart,end:e.refSeqStart+e.refSeqSpan-1,span:e.refSeqSpan}}if(t.referenceRequired||this.file.fetchReferenceSequenceCallback){if(!this.file.fetchReferenceSequenceCallback)throw new Error("reference sequence not embedded, and seqFetch callback not provided, cannot fetch reference sequence");const t=yield this.file.fetchReferenceSequenceCallback(e.refSeqId,e.refSeqStart,e.refSeqStart+e.refSeqSpan-1);if(t.length!==e.refSeqSpan)throw new s.CramArgumentError("seqFetch callback returned a reference sequence of the wrong length");return{seq:t,start:e.refSeqStart,end:e.refSeqStart+e.refSeqSpan-1,span:e.refSeqSpan}}}))}getAllRecords(){return this.getRecords((()=>!0))}_fetchRecords(){return n(this,void 0,void 0,(function*(){const{majorVersion:e}=yield this.file.getDefinition(),t=yield this.container.getCompressionScheme();if(void 0===t)throw new Error;const i=yield this.getHeader();if(void 0===i)throw new Error;const n=yield this._getBlocksContentIdIndex();if(e>1&&this.file.options.checkSequenceMD5&&(0,c.isMappedSliceHeader)(i.parsedContent)&&i.parsedContent.refSeqId>=0&&"0000000000000000"!==i.parsedContent.md5.join("")){const e=yield this.getReferenceRegion();if(e){const{seq:t,start:n,end:r}=e,a=(0,o.sequenceMD5)(t),l=i.parsedContent.md5.map((e=>(e<16?"0":"")+e.toString(16))).join("");if(a!==l)throw new s.CramMalformedError(`MD5 checksum reference mismatch for ref ${i.parsedContent.refSeqId} pos ${n}..${r}. recorded MD5: ${l}, calculated MD5: ${a}`)}}const r=yield this.getCoreDataBlock(),a={lastAlignmentStart:(0,c.isMappedSliceHeader)(i.parsedContent)?i.parsedContent.refSeqStart:0,coreBlock:{bitPosition:7,bytePosition:0},externalBlocks:{map:new Map,getCursor(e){let t=this.map.get(e);return void 0===t&&(t={bitPosition:7,bytePosition:0},this.map.set(e,t)),t}}},f=e=>{const i=t.getCodecForDataSeries(e);if(!i)throw new s.CramMalformedError(`no codec defined for ${e} data series`);return i.decode(this,r,n,a)};let p=new Array(i.parsedContent.numRecords);for(let s=0;s<p.length;s+=1)try{const o=(0,l.default)(this,f,t,i,r,n,a,e,s);p[s]=new h.default(Object.assign(Object.assign({},o),{uniqueId:i.contentPosition+i.parsedContent.recordCounter+s+1}))}catch(e){if(e instanceof d.CramBufferOverrunError){console.warn("read attempted beyond end of buffer, file seems truncated."),p=p.filter((e=>!!e));break}throw e}for(let e=0;e<p.length;e+=1){const{mateRecordNumber:t}=p[e];void 0!==t&&t>=0&&u(p,e,p[e],p[t])}return p}))}getRecords(e){return n(this,void 0,void 0,(function*(){const t=this.container.filePosition+this.containerPosition;let i=this.file.featureCache.get(t.toString());i||(i=this._fetchRecords(),this.file.featureCache.set(t.toString(),i));const r=(yield i).filter(e);if(r.length&&this.file.fetchReferenceSequenceCallback){const e=yield this.getHeader();if((0,c.isMappedSliceHeader)(e.parsedContent)&&(e.parsedContent.refSeqId>=0||-2===e.parsedContent.refSeqId)){const t=e.parsedContent.refSeqId>=0?e.parsedContent.refSeqId:void 0,i=yield this.container.getCompressionScheme();if(void 0===i)throw new Error;const s={};for(let e=0;e<r.length;e+=1){const i=void 0!==t?t:r[e].sequenceId;let n=s[i];n||(n={id:i,start:r[e].alignmentStart,end:-1/0,seq:null},s[i]=n);const o=r[e].alignmentStart+(r[e].lengthOnRef||r[e].readLength)-1;o>n.end&&(n.end=o),r[e].alignmentStart<n.start&&(n.start=r[e].alignmentStart)}yield Promise.all(Object.values(s).map((e=>n(this,void 0,void 0,(function*(){-1!==e.id&&e.start<=e.end&&(e.seq=yield this.file.fetchReferenceSequenceCallback(e.id,e.start,e.end))})))));for(let e=0;e<r.length;e+=1){const n=s[void 0!==t?t:r[e].sequenceId];if(n&&n.seq){const t=n.seq;r[e].addReferenceSequence(Object.assign(Object.assign({},n),{seq:t}),i)}}}}return r}))}}t.default=f,"getHeader getBlocks _getBlocksContentIdIndex".split(" ").forEach((e=>(0,o.tinyMemoize)(f,e)))},9488:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sequenceMD5=t.tinyMemoize=t.parseItem=t.parseItf8=t.itf8Size=void 0;const r=n(i(2568)),s=i(1074);t.itf8Size=function(e){return-128&e?-16384&e?-2097152&e?-268435456&e?5:4:3:2:1},t.parseItf8=function(e,t){let i=t;const n=e[i];let r;if(n<128?(r=n,i+=1):n<192?(r=16383&(n<<8|e[i+1]),i+=2):n<224?(r=2097151&(n<<16|e[i+1]<<8|e[i+2]),i+=3):n<240?(r=268435455&(n<<24|e[i+1]<<16|e[i+2]<<8|e[i+3]),i+=4):(r=(15&n)<<28|e[i+1]<<20|e[i+2]<<12|e[i+3]<<4|15&e[i+4],i+=5),i>e.length)throw new s.CramBufferOverrunError("Attempted to read beyond end of buffer; this file seems truncated.");return[r,i-t]},t.parseItem=function(e,t,i=0,n=0){const{offset:r,result:s}=t.parse(e);return Object.assign(Object.assign({},s),{_endPosition:r+n,_size:r-i})},t.tinyMemoize=function(e,t){const i=e.prototype[t],n=`_memo_${t}`;e.prototype[t]=function(){if(!(n in this)){const e=i.call(this);this[n]=e,Promise.resolve(e).catch((()=>{delete this[n]}))}return this[n]}},t.sequenceMD5=function(e){return(0,r.default)(e.toUpperCase().replace(/[^\x21-\x7e]/g,""))}},8577:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CramArgumentError=t.CramSizeLimitError=t.CramMalformedError=t.CramUnimplementedError=t.CramError=void 0;class i extends Error{}t.CramError=i;class n extends Error{}t.CramUnimplementedError=n,t.CramMalformedError=class extends i{},t.CramSizeLimitError=class extends i{},t.CramArgumentError=class extends i{}},5590:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CramRecord=t.CraiIndex=t.IndexedCramFile=t.CramFile=void 0;const a=s(i(8222));t.CramFile=a.default,Object.defineProperty(t,"CramRecord",{enumerable:!0,get:function(){return a.CramRecord}});const l=o(i(946));t.IndexedCramFile=l.default;const h=o(i(368));t.CraiIndex=h.default},946:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function o(e){try{l(n.next(e))}catch(e){s(e)}}function a(e){try{l(n.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(8577),o=r(i(8222));t.default=class{constructor(e){if(e.cram?this.cram=e.cram:this.cram=new o.default({url:e.cramUrl,path:e.cramPath,filehandle:e.cramFilehandle,seqFetch:e.seqFetch,checkSequenceMD5:e.checkSequenceMD5,cacheSize:e.cacheSize}),!(this.cram instanceof o.default))throw new Error("invalid arguments: no cramfile");if(this.index=e.index,!this.index.getEntriesForRange)throw new Error("invalid arguments: not an index");this.fetchSizeLimit=e.fetchSizeLimit||3e6}getRecordsForRange(e,t,i,r={}){return n(this,void 0,void 0,(function*(){if(r.viewAsPairs=r.viewAsPairs||!1,r.pairAcrossChr=r.pairAcrossChr||!1,r.maxInsertSize=r.maxInsertSize||2e5,"string"==typeof e)throw new s.CramUnimplementedError("string sequence names not yet supported");const n=e,o=yield this.index.getEntriesForRange(n,t,i),a=o.map((e=>e.sliceBytes)).reduce(((e,t)=>e+t),0);if(a>this.fetchSizeLimit)throw new s.CramSizeLimitError(`data size of ${a.toLocaleString()} bytes exceeded fetch size limit of ${this.fetchSizeLimit.toLocaleString()} bytes`);const l=n=>n.sequenceId===e&&n.alignmentStart<=i&&void 0!==n.lengthOnRef&&n.alignmentStart+n.lengthOnRef-1>=t,h=yield Promise.all(o.map((e=>this.getRecordsInSlice(e,l))));let c=Array.prototype.concat(...h);if(r.viewAsPairs){const e={},t={};for(let i=0;i<c.length;i+=1){const n=c[i].readName;if(void 0===n)throw new Error;const r=c[i].uniqueId;e[n]||(e[n]=0),e[n]+=1,t[r]=1}const i={};Object.entries(e).forEach((([e,t])=>{1===t&&(i[e]=!0)}));const s=[];for(let e=0;e<c.length;e+=1){const t=c[e],o=t.readName;if(void 0===o)throw new Error;if(i[o]&&t.mate&&(t.mate.sequenceId===n||r.pairAcrossChr)&&Math.abs(t.alignmentStart-t.mate.alignmentStart)<r.maxInsertSize){const e=this.index.getEntriesForRange(t.mate.sequenceId,t.mate.alignmentStart,t.mate.alignmentStart+1);s.push(e)}}const o=yield Promise.all(s);let a=[];for(let e=0;e<o.length;e+=1)a.push(...o[e]);a=a.sort(((e,t)=>e.toString().localeCompare(t.toString()))).filter(((e,t,i)=>!t||e.toString()!==i[t-1].toString()));const l=[],h=a.map((e=>e.sliceBytes)).reduce(((e,t)=>e+t),0);if(h>this.fetchSizeLimit)throw new Error(`mate data size of ${h.toLocaleString()} bytes exceeded fetch size limit of ${this.fetchSizeLimit.toLocaleString()} bytes`);a.forEach((e=>{let n=this.cram.featureCache.get(e.toString());n||(n=this.getRecordsInSlice(e,(()=>!0)),this.cram.featureCache.set(e.toString(),n));const r=n.then((e=>{const n=[];for(let r=0;r<e.length;r+=1){const s=e[r];if(void 0===s.readName)throw new Error;i[s.readName]&&!t[s.uniqueId]&&n.push(s)}return n}));l.push(r)}));const d=yield Promise.all(l);if(d.length){const e=d.reduce(((e,t)=>e.concat(t)));c=c.concat(e)}}return c}))}getRecordsInSlice({containerStart:e,sliceStart:t,sliceBytes:i},n){return this.cram.getContainerAtPosition(e).getSlice(t,i).getRecords(n)}hasDataForReferenceSequence(e){return this.index.hasDataForReferenceSequence(e)}}},3427:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.open=t.fromUrl=t.RemoteFile=t.LocalFile=void 0;const r=n(i(8575)),s=i(4319),o=i(2949);function a(e){const{protocol:t,pathname:i}=r.default.parse(e);return"file:"===t?new o.LocalFile(unescape((0,s.ensureNotNullish)(i))):new o.RemoteFile(e)}Object.defineProperty(t,"LocalFile",{enumerable:!0,get:function(){return o.LocalFile}}),Object.defineProperty(t,"RemoteFile",{enumerable:!0,get:function(){return o.RemoteFile}}),t.fromUrl=a,t.open=function(e,t,i){if(i)return i;if(e)return a(e);if(t)return new o.LocalFile(t);throw new Error("no url, path, or filehandle provided, cannot open")}},5702:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RANS_BYTE_L=t.TOTFREQ=t.TF_SHIFT=void 0,t.TF_SHIFT=12,t.TOTFREQ=4096,t.RANS_BYTE_L=1<<23},6484:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=i(8577),s=i(5702),o=n(i(7634));t.default=function(e,t,i,n){let a=e.getInt(),l=e.getInt(),h=e.getInt(),c=e.getInt();const d=n.remaining(),u=-4&d;for(let r=0;r<u;r+=4){const d=t.R[o.default.get(a,s.TF_SHIFT)],u=t.R[o.default.get(l,s.TF_SHIFT)],f=t.R[o.default.get(h,s.TF_SHIFT)],p=t.R[o.default.get(c,s.TF_SHIFT)];n.putAt(r,d),n.putAt(r+1,u),n.putAt(r+2,f),n.putAt(r+3,p),a=o.default.advanceSymbolStep(a,i[255&d],s.TF_SHIFT),l=o.default.advanceSymbolStep(l,i[255&u],s.TF_SHIFT),h=o.default.advanceSymbolStep(h,i[255&f],s.TF_SHIFT),c=o.default.advanceSymbolStep(c,i[255&p],s.TF_SHIFT),a=o.default.renormalize(a,e),l=o.default.renormalize(l,e),h=o.default.renormalize(h,e),c=o.default.renormalize(c,e)}let f;switch(n.setPosition(u),3&d){case 0:break;case 1:f=t.R[o.default.get(a,s.TF_SHIFT)],o.default.advanceSymbol(a,e,i[255&f],s.TF_SHIFT),n.put(f);break;case 2:f=t.R[o.default.get(a,s.TF_SHIFT)],o.default.advanceSymbol(a,e,i[255&f],s.TF_SHIFT),n.put(f),f=t.R[o.default.get(l,s.TF_SHIFT)],o.default.advanceSymbol(l,e,i[255&f],s.TF_SHIFT),n.put(f);break;case 3:f=t.R[o.default.get(a,s.TF_SHIFT)],o.default.advanceSymbol(a,e,i[255&f],s.TF_SHIFT),n.put(f),f=t.R[o.default.get(l,s.TF_SHIFT)],o.default.advanceSymbol(l,e,i[255&f],s.TF_SHIFT),n.put(f),f=t.R[o.default.get(h,s.TF_SHIFT)],o.default.advanceSymbol(h,e,i[255&f],s.TF_SHIFT),n.put(f);break;default:throw new r.CramMalformedError("invalid output size encountered during rANS decoding")}n.setPosition(0)}},7121:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=i(5702),s=n(i(7634));t.default=function(e,t,i,n){const o=t.remaining();let a=e.getInt(),l=e.getInt(),h=e.getInt(),c=e.getInt();const d=o>>2;let u=0,f=d,p=2*d,g=3*d,m=0,b=0,w=0,v=0;for(;u<d;u+=1,f+=1,p+=1,g+=1){const o=255&i[m].R[s.default.get(a,r.TF_SHIFT)],d=255&i[b].R[s.default.get(l,r.TF_SHIFT)],y=255&i[w].R[s.default.get(h,r.TF_SHIFT)],_=255&i[v].R[s.default.get(c,r.TF_SHIFT)];t.putAt(u,o),t.putAt(f,d),t.putAt(p,y),t.putAt(g,_),a=s.default.advanceSymbolStep(a,n[m][o],r.TF_SHIFT),l=s.default.advanceSymbolStep(l,n[b][d],r.TF_SHIFT),h=s.default.advanceSymbolStep(h,n[w][y],r.TF_SHIFT),c=s.default.advanceSymbolStep(c,n[v][_],r.TF_SHIFT),a=s.default.renormalize(a,e),l=s.default.renormalize(l,e),h=s.default.renormalize(h,e),c=s.default.renormalize(c,e),m=o,b=d,w=y,v=_}for(;g<o;g+=1){const o=255&i[v].R[s.default.get(c,r.TF_SHIFT)];t.putAt(g,o),c=s.default.advanceSymbol(c,e,n[v][o],r.TF_SHIFT),v=o}}},7634:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=i(8577),r=i(5702);class s{constructor(){this.F=void 0,this.C=void 0}}function o(e,t,i,n){return i*(e>>n)+(e&(1<<n)-1)-t}const a={FC:s,AriDecoder:class{constructor(){this.fc=new Array(256);for(let e=0;e<this.fc.length;e+=1)this.fc[e]=new s;this.R=null}},Symbol:class{constructor(){this.start=void 0,this.freq=void 0}},symbolInit:function(e,t,i){if(!(t<=65536))throw new n.CramMalformedError("assertion failed: start <= 1<<16");if(!(i<=65536-t))throw new n.CramMalformedError("assertion failed: freq <= 1<<16");e.start=t,e.freq=i},advanceStep:o,advanceSymbolStep:function(e,t,i){return o(e,t.start,t.freq,i)},get:function(e,t){return e&(1<<t)-1},advanceSymbol:function(e,t,i,n){return function(e,t,i,n,s){if((e=n*(e>>s)+(e&(1<<s)-1)-i)<r.RANS_BYTE_L)do{e=e<<8|255&t.get()}while(e<r.RANS_BYTE_L);return e}(e,t,i.start,i.freq,n)},renormalize:function(e,t){if(e<r.RANS_BYTE_L)do{e=e<<8|255&t.get()}while(e<r.RANS_BYTE_L);return e}};t.default=a},696:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.readStatsO1=t.readStatsO0=void 0;const r=i(8577),s=i(5702),o=n(i(7634));function a(e){if(!e)throw new r.CramMalformedError("assertion failed")}t.readStatsO0=function(e,t,i){let n=0,r=0,l=255&e.get();do{null==t.fc[l]&&(t.fc[l]=new o.default.FC),t.fc[l].F=255&e.get(),t.fc[l].F>=128&&(t.fc[l].F&=-129,t.fc[l].F=(127&t.fc[l].F)<<8|255&e.get()),t.fc[l].C=r,o.default.symbolInit(i[l],t.fc[l].C,t.fc[l].F),t.R||(t.R=new Array(s.TOTFREQ)),t.R.fill(l,r,r+t.fc[l].F),r+=t.fc[l].F,0===n&&l+1===(255&e.getByteAt(e.position()))?(l=255&e.get(),n=255&e.get()):0!==n?(n-=1,l+=1):l=255&e.get()}while(0!==l);a(r<s.TOTFREQ)},t.readStatsO1=function(e,t,i){let n=0,r=255&e.get();do{let l=0,h=0,c=255&e.get();null==t[r]&&(t[r]=new o.default.AriDecoder);do{null==t[r].fc[c]&&(t[r].fc[c]=new o.default.FC),t[r].fc[c].F=255&e.get(),t[r].fc[c].F>=128&&(t[r].fc[c].F&=-129,t[r].fc[c].F=(127&t[r].fc[c].F)<<8|255&e.get()),t[r].fc[c].C=h,0===t[r].fc[c].F&&(t[r].fc[c].F=s.TOTFREQ),null==i[r][c]&&(i[r][c]=new o.default.RansDecSymbol),o.default.symbolInit(i[r][c],t[r].fc[c].C,t[r].fc[c].F),null==t[r].R&&(t[r].R=new Array(s.TOTFREQ)),t[r].R.fill(c,h,h+t[r].fc[c].F),h+=t[r].fc[c].F,a(h<=s.TOTFREQ),0===l&&c+1===(255&e.getByteAt(e.position()))?(c=255&e.get(),l=255&e.get()):0!==l?(l-=1,c+=1):c=255&e.get()}while(0!==c);0===n&&r+1===(255&e.getByteAt(e.position()))?(r=255&e.get(),n=255&e.get()):0!==n?(n-=1,r+=1):r=255&e.get()}while(0!==r)}},9675:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=i(8577),s=n(i(7634)),o=i(696),a=n(i(6484)),l=n(i(7121));class h{constructor(e,t=0){this._buffer=e,this._position=t,this.length=e.length}get(){const e=this._buffer[this._position];return this._position+=1,e}getByte(){return this.get()}getByteAt(e){return this._buffer[e]}position(){return this._position}put(e){return this._buffer[this._position]=e,this._position+=1,e}putAt(e,t){return this._buffer[e]=t,t}setPosition(e){return this._position=e,e}getInt(){const e=this._buffer.readInt32LE(this._position);return this._position+=4,e}remaining(){return this._buffer.length-this._position}}t.default=function(e,t,i=0){if(0===e.length)return t.fill(0),t;const n=new h(e,i),c=n.get();if(0!==c&&1!==c)throw new r.CramMalformedError(`Invalid rANS order ${c}`);if(n.getInt()!==n.remaining()-4)throw new r.CramMalformedError("Incorrect input length.");const d=n.getInt(),u=new h(t||Buffer.allocUnsafe(d));if(u.length<d)throw new r.CramMalformedError(`Output buffer too small to fit ${d} bytes.`);switch(c){case 0:return function(e,t){const i=new s.default.AriDecoder,n=new Array(256);for(let e=0;e<n.length;e+=1)n[e]=new s.default.Symbol;return(0,o.readStatsO0)(e,i,n),(0,a.default)(e,i,n,t),t}(n,u);case 1:return function(e,t){const i=new Array(256);for(let e=0;e<i.length;e+=1)i[e]=new s.default.AriDecoder;const n=new Array(256);for(let e=0;e<n.length;e+=1){n[e]=new Array(256);for(let t=0;t<n[e].length;t+=1)n[e][t]=new s.default.Symbol}return(0,o.readStatsO1)(e,i,n),(0,l.default)(e,t,i,n),t}(n,u);default:throw new r.CramMalformedError(`Invalid rANS order: ${c}`)}}},7578:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseHeaderText=void 0,t.parseHeaderText=function(e){const t=e.split(/\r?\n/),i=[];return t.forEach((e=>{const[t,...n]=e.split(/\t/),r=n.map((e=>{const[t,i]=e.split(":",2);return{tag:t,value:i}}));t&&i.push({tag:t.substr(1),data:r})})),i}},4319:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ensureNotNullish=void 0,t.ensureNotNullish=function(e){if(null==e)throw new Error("Value must not be nullish.");return e}},597:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.unzip=void 0;const n=i(9591);t.unzip=function(e){return Buffer.from((0,n.inflate)(e))}},9996:(e,t,i)=>{function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}var r=i(8764).Buffer,s=i(22),o=i(2961)._,a=i(3720);"undefined"!=typeof window&&(window.Buffer=r),"undefined"!=typeof self&&(self.Buffer=r);var l={UInt8:1,UInt16LE:2,UInt16BE:2,UInt32LE:4,UInt32BE:4,Int8:1,Int16LE:2,Int16BE:2,Int32LE:4,Int32BE:4,FloatLE:4,FloatBE:4,DoubleLE:8,DoubleBE:8,UInt64:8,Int64:8},h={},c="___parser_",d=[];!function(){var e;for(e=1;e<=32;e++)d.push(e)}();var u={};Object.keys(l).concat(Object.keys({String:null,Buffer:null,Array:null,Skip:null,Choice:null,Nest:null,Bit:null,Itf8:null,Ltf8:null})).forEach((function(e){u[e.toLowerCase()]=e}));var f=function(){this.varName="",this.type="",this.options={},this.next=null,this.head=null,this.compiled=null,this.endian="le",this.constructorFn=null,this.alias=null};f.start=function(){return new f},Object.keys(l).forEach((function(e){f.prototype[e.toLowerCase()]=function(t,i){return this.setNextParser(e.toLowerCase(),t,i)};var t=e.replace(/BE|LE/,"").toLowerCase();t in f.prototype||(f.prototype[t]=function(e,i){return this[t+this.endian](e,i)})})),d.forEach((function(e){f.prototype["bit".concat(e.toString())]=function(t,i){return i||(i={}),i.length=e,this.setNextParser("bit",t,i)}})),f.prototype.namely=function(e){return h[e]=this,this.alias=e,this},f.prototype.skip=function(e,t){if(t&&t.assert)throw new Error("assert option on skip is not allowed.");return this.setNextParser("skip","",{length:e})},f.prototype.string=function(e,t){if(!t.zeroTerminated&&!t.length&&!t.greedy)throw new Error("Neither length, zeroTerminated, nor greedy is defined for string.");if((t.zeroTerminated||t.length)&&t.greedy)throw new Error("greedy is mutually exclusive with length and zeroTerminated for string.");if(t.stripNull&&!t.length&&!t.greedy)throw new Error("Length or greedy must be defined if stripNull is defined.");return t.encoding=t.encoding||"utf8",this.setNextParser("string",e,t)},f.prototype.buffer=function(e,t){if(!t.length&&!t.readUntil)throw new Error("Length nor readUntil is defined in buffer parser");return this.setNextParser("buffer",e,t)},f.prototype.array=function(e,t){if(!t.readUntil&&!t.length&&!t.lengthInBytes)throw new Error("Length option of array is not defined.");if(!t.type)throw new Error("Type option of array is not defined.");if("string"==typeof t.type&&!h[t.type]&&Object.keys(l).indexOf(u[t.type])<0)throw new Error('Specified primitive type "'.concat(t.type,'" is not supported.'));return this.setNextParser("array",e,t)},f.prototype.choice=function(e,t){if(1===arguments.length&&"object"===n(e)&&(t=e,e=null),!t.tag)throw new Error("Tag option of array is not defined.");if(!t.choices)throw new Error("Choices option of array is not defined.");return Object.keys(t.choices).forEach((function(i){if(!t.choices[i])throw new Error("Choice Case ".concat(i," of ").concat(e," is not valid."));if("string"==typeof t.choices[i]&&!h[t.choices[i]]&&Object.keys(l).indexOf(u[t.choices[i]])<0)throw new Error('Specified primitive type "'.concat(t.choices[i],'" is not supported.'))}),this),this.setNextParser("choice",e,t)},f.prototype.nest=function(e,t){if(1===arguments.length&&"object"===n(e)&&(t=e,e=null),!t.type)throw new Error("Type option of nest is not defined.");if(!(t.type instanceof f||h[t.type]))throw new Error("Type option of nest must be a Parser object.");if(!(t.type instanceof f||e))throw new Error("options.type must be a object if variable name is omitted.");return this.setNextParser("nest",e,t)},f.prototype.endianess=function(e){switch(e.toLowerCase()){case"little":this.endian="le";break;case"big":this.endian="be";break;default:throw new Error("Invalid endianess: ".concat(e))}return this},f.prototype.create=function(e){if(!(e instanceof Function))throw new Error("Constructor must be a Function object.");return this.constructorFn=e,this},f.prototype.getCode=function(){var e=new o;return e.pushCode("if (!Buffer.isBuffer(buffer)) {"),e.generateError('"argument buffer is not a Buffer object"'),e.pushCode("}"),this.alias?this.addAliasedCode(e):this.addRawCode(e),this.alias?e.pushCode("return {0}(0)",c+this.alias):e.pushCode("return { offset: offset, result: vars };"),e.code},f.prototype.addRawCode=function(e){e.pushCode("var offset = 0;"),this.constructorFn?e.pushCode("var vars = new constructorFn();"):e.pushCode("var vars = {};"),this.generate(e),this.resolveReferences(e),e.pushCode("return { offset: offset, result: vars };")},f.prototype.addAliasedCode=function(e){return e.pushCode("function {0}(offset) {",c+this.alias),this.constructorFn?e.pushCode("var vars = new constructorFn();"):e.pushCode("var vars = {};"),this.generate(e),e.markResolved(this.alias),this.resolveReferences(e),e.pushCode("return { offset: offset, result: vars };"),e.pushCode("}"),e},f.prototype.resolveReferences=function(e){var t=e.getUnresolvedReferences();e.markRequested(t),t.forEach((function(t){h[t].addAliasedCode(e)}))},f.prototype.compile=function(){var e="(function(buffer, constructorFn, Long) { ".concat(this.getCode()," })");this.compiled=s.runInThisContext(e)},f.prototype.sizeOf=function(){var e=NaN;if(Object.keys(l).indexOf(this.type)>=0)e=l[this.type];else if("String"===this.type&&"number"==typeof this.options.length)e=this.options.length;else if("Buffer"===this.type&&"number"==typeof this.options.length)e=this.options.length;else if("Array"===this.type&&"number"==typeof this.options.length){var t=NaN;"string"==typeof this.options.type?t=l[u[this.options.type]]:this.options.type instanceof f&&(t=this.options.type.sizeOf()),e=this.options.length*t}else"Skip"===this.type?e=this.options.length:"Nest"===this.type?e=this.options.type.sizeOf():this.type||(e=0);return this.next&&(e+=this.next.sizeOf()),e},f.prototype.parse=function(e){return this.compiled||this.compile(),this.compiled(e,this.constructorFn,a)},f.prototype.setNextParser=function(e,t,i){var n=new f;return n.type=u[e],n.varName=t,n.options=i||n.options,n.endian=this.endian,this.head?this.head.next=n:this.next=n,this.head=n,this},f.prototype.generate=function(e){this.type&&(this["generate".concat(this.type)](e),this.generateAssert(e));var t=e.generateVariable(this.varName);return this.options.formatter&&this.generateFormatter(e,t,this.options.formatter),this.generateNext(e)},f.prototype.generateAssert=function(e){if(this.options.assert){var t=e.generateVariable(this.varName);switch(n(this.options.assert)){case"function":e.pushCode("if (!({0}).call(vars, {1})) {",this.options.assert,t);break;case"number":e.pushCode("if ({0} !== {1}) {",this.options.assert,t);break;case"string":e.pushCode('if ("{0}" !== {1}) {',this.options.assert,t);break;default:throw new Error("Assert option supports only strings, numbers and assert functions.")}e.generateError('"Assert error: {0} is " + {0}',t),e.pushCode("}")}},f.prototype.generateNext=function(e){return this.next&&(e=this.next.generate(e)),e},Object.keys(l).forEach((function(e){f.prototype["generate".concat(e)]=function(t){"UInt64"===e?t.pushCode("{0} = Long.fromBytes(buffer.slice(offset,offset+8), true, this.endian === 'le').toNumber();",t.generateVariable(this.varName),e):"Int64"===e?t.pushCode("{0} = Long.fromBytes(buffer.slice(offset,offset+8), false, this.endian === 'le').toNumber();",t.generateVariable(this.varName),e):t.pushCode("{0} = buffer.read{1}(offset);",t.generateVariable(this.varName),e),t.pushCode("offset += {0};",l[e])}})),f.prototype.generateBit=function(e){var t=JSON.parse(JSON.stringify(this));if(t.varName=e.generateVariable(t.varName),e.bitFields.push(t),!this.next||this.next&&["Bit","Nest"].indexOf(this.next.type)<0){var i=0;e.bitFields.forEach((function(e){i+=e.options.length}));var n=e.generateTmpVariable();if(i<=8)e.pushCode("var {0} = buffer.readUInt8(offset);",n),i=8;else if(i<=16)e.pushCode("var {0} = buffer.readUInt16BE(offset);",n),i=16;else if(i<=24){var r=e.generateTmpVariable(),s=e.generateTmpVariable();e.pushCode("var {0} = buffer.readUInt16BE(offset);",r),e.pushCode("var {0} = buffer.readUInt8(offset + 2);",s),e.pushCode("var {2} = ({0} << 8) | {1};",r,s,n),i=24}else{if(!(i<=32))throw new Error("Currently, bit field sequence longer than 4-bytes is not supported.");e.pushCode("var {0} = buffer.readUInt32BE(offset);",n),i=32}e.pushCode("offset += {0};",i/8);var o=0,a="be"===this.endian;e.bitFields.forEach((function(t){e.pushCode("{0} = {1} >> {2} & {3};",t.varName,n,a?i-o-t.options.length:o,(1<<t.options.length)-1),o+=t.options.length})),e.bitFields=[]}},f.prototype.generateSkip=function(e){var t=e.generateOption(this.options.length);e.pushCode("offset += {0};",t)},f.prototype.generateString=function(e){var t=e.generateVariable(this.varName),i=e.generateTmpVariable();this.options.length&&this.options.zeroTerminated?(e.pushCode("var {0} = offset;",i),e.pushCode("while(buffer.readUInt8(offset++) !== 0 && offset - {0} < {1});",i,this.options.length),e.pushCode("{0} = buffer.toString('{1}', {2}, offset - {2} < {3} ? offset - 1 : offset);",t,this.options.encoding,i,this.options.length)):this.options.length?(e.pushCode("{0} = buffer.toString('{1}', offset, offset + {2});",t,this.options.encoding,e.generateOption(this.options.length)),e.pushCode("offset += {0};",e.generateOption(this.options.length))):this.options.zeroTerminated?(e.pushCode("var {0} = offset;",i),e.pushCode("while(buffer.readUInt8(offset++) !== 0);"),e.pushCode("{0} = buffer.toString('{1}', {2}, offset - 1);",t,this.options.encoding,i)):this.options.greedy&&(e.pushCode("var {0} = offset;",i),e.pushCode("while(buffer.length > offset++);"),e.pushCode("{0} = buffer.toString('{1}', {2}, offset);",t,this.options.encoding,i)),this.options.stripNull&&e.pushCode("{0} = {0}.replace(/\\x00+$/g, '')",t)},f.prototype.generateBuffer=function(e){"eof"===this.options.readUntil?e.pushCode("{0} = buffer.slice(offset);",e.generateVariable(this.varName)):(e.pushCode("{0} = buffer.slice(offset, offset + {1});",e.generateVariable(this.varName),e.generateOption(this.options.length)),e.pushCode("offset += {0};",e.generateOption(this.options.length))),this.options.clone&&e.pushCode("{0} = Buffer.from({0});",e.generateVariable(this.varName))},f.prototype.generateArray=function(e){var t=e.generateOption(this.options.length),i=e.generateOption(this.options.lengthInBytes),n=this.options.type,r=e.generateTmpVariable(),s=e.generateVariable(this.varName),o=e.generateTmpVariable(),a=this.options.key,d="string"==typeof a;if(d?e.pushCode("{0} = {};",s):e.pushCode("{0} = [];",s),"function"==typeof this.options.readUntil?e.pushCode("do {"):"eof"===this.options.readUntil?e.pushCode("for (var {0} = 0; offset < buffer.length; {0}++) {",r):void 0!==i?e.pushCode("for (var {0} = offset; offset - {0} < {1}; ) {",r,i):e.pushCode("for (var {0} = 0; {0} < {1}; {0}++) {",r,t),"string"==typeof n)if(h[n]){var p=e.generateTmpVariable();e.pushCode("var {0} = {1}(offset);",p,c+n),e.pushCode("var {0} = {1}.result; offset = {1}.offset;",o,p),n!==this.alias&&e.addReference(n)}else e.pushCode("var {0} = buffer.read{1}(offset);",o,u[n]),e.pushCode("offset += {0};",l[u[n]]);else n instanceof f&&(e.pushCode("var {0} = {};",o),e.pushScope(o),n.generate(e),e.popScope());d?e.pushCode("{0}[{2}.{1}] = {2};",s,a,o):e.pushCode("{0}.push({1});",s,o),e.pushCode("}"),"function"==typeof this.options.readUntil&&e.pushCode(" while (!({0}).call(this, {1}, buffer.slice(offset)));",this.options.readUntil,o)},f.prototype.generateChoiceCase=function(e,t,i){if("string"==typeof i)if(h[i]){var n=e.generateTmpVariable();e.pushCode("var {0} = {1}(offset);",n,c+i),e.pushCode("{0} = {1}.result; offset = {1}.offset;",e.generateVariable(this.varName),n),i!==this.alias&&e.addReference(i)}else e.pushCode("{0} = buffer.read{1}(offset);",e.generateVariable(this.varName),u[i]),e.pushCode("offset += {0};",l[u[i]]);else i instanceof f&&(e.pushPath(t),i.generate(e),e.popPath(t))},f.prototype.generateChoice=function(e){var t=e.generateOption(this.options.tag);this.varName&&e.pushCode("{0} = {};",e.generateVariable(this.varName)),e.pushCode("switch({0}) {",t),Object.keys(this.options.choices).forEach((function(t){var i=this.options.choices[t];Number.isNaN(parseInt(t,10))?e.pushCode("case '{0}':",t):e.pushCode("case {0}:",t),this.generateChoiceCase(e,this.varName,i),e.pushCode("break;")}),this),e.pushCode("default:"),this.options.defaultChoice?this.generateChoiceCase(e,this.varName,this.options.defaultChoice):e.generateError('"Met undefined tag value " + {0} + " at choice"',t),e.pushCode("}")},f.prototype.generateNest=function(e){var t=e.generateVariable(this.varName);if(this.options.type instanceof f)this.varName&&e.pushCode("{0} = {};",t),e.pushPath(this.varName),this.options.type.generate(e),e.popPath(this.varName);else if(h[this.options.type]){var i=e.generateTmpVariable();e.pushCode("var {0} = {1}(offset);",i,c+this.options.type),e.pushCode("{0} = {1}.result; offset = {1}.offset;",t,i),this.options.type!==this.alias&&e.addReference(this.options.type)}},f.prototype.generateFormatter=function(e,t,i){"function"==typeof i&&e.pushCode("{0} = ({1}).call(this, {0});",t,i)},f.prototype.isInteger=function(){return!!this.type.match(/U?Int[8|16|32][BE|LE]?|Bit\d+/)},f.prototype.itf8=function(e,t){return this.setNextParser("itf8",e,t)},f.prototype.itf8=function(e,t){return this.setNextParser("itf8",e,t)},f.prototype.generateItf8=function(e){var t=e.generateVariable(this.varName),i=e.generateTmpVariable();e.pushCode("\n var ".concat(i," = buffer[offset];\n if (").concat(i," < 0x80) {\n ").concat(t," = ").concat(i,";\n offset += 1;\n } else if (").concat(i," < 0xc0) {\n ").concat(t," = ((").concat(i,"<<8) | buffer[offset+1]) & 0x3fff;\n offset += 2;\n } else if (").concat(i," < 0xe0) {\n ").concat(t," = ((").concat(i,"<<16) | (buffer[offset+1]<< 8) | buffer[offset+2]) & 0x1fffff;\n offset += 3;\n } else if (").concat(i," < 0xf0) {\n ").concat(t," = ((").concat(i,"<<24) | (buffer[offset+1]<<16) | (buffer[offset+2]<<8) | buffer[offset+3]) & 0x0fffffff;\n offset += 4\n } else {\n ").concat(t," = ((").concat(i," & 0x0f)<<28) | (buffer[offset+1]<<20) | (buffer[offset+2]<<12) | (buffer[offset+3]<<4) | (buffer[offset+4] & 0x0f);\n // x=((0xff & 0x0f)<<28) | (0xff<<20) | (0xff<<12) | (0xff<<4) | (0x0f & 0x0f);\n // TODO *val_p = uv < 0x80000000UL ? uv : -((int32_t) (0xffffffffUL - uv)) - 1;\n offset += 5\n }\n "))},f.prototype.ltf8=function(e,t){return this.setNextParser("ltf8",e,t)},f.prototype.generateLtf8=function(e){var t=e.generateVariable(this.varName),i=e.generateTmpVariable();e.pushCode("\n var ".concat(i," = buffer[offset];\n if (").concat(i," < 0x80) {\n ").concat(t," = ").concat(i,";\n offset += 1;\n } else if (").concat(i," < 0xc0) {\n ").concat(t," = ((buffer[offset]<<8) | buffer[offset+1]) & 0x3fff;\n offset += 2;\n } else if (").concat(i," < 0xe0) {\n ").concat(t," = ((buffer[offset]<<16) | (buffer[offset+1]<<8) | buffer[offset+2]) & 0x1fffff;\n ").concat(t," = (((").concat(i," & 63) << 16) | buffer.readUInt16LE(offset + 1));\n offset += 3;\n } else if (").concat(i," < 0xf0) {\n ").concat(t," = ((buffer[offset]<<24) | (buffer[offset+1]<<16) | (buffer[offset+2]<<8) | buffer[offset+3]) & 0x0fffffff;\n offset += 4;\n } else if (").concat(i," < 0xf8) {\n ").concat(t," = (((buffer[offset] & 15) * Math.pow(2,32))) +\n (buffer[offset+1]<<24) | (buffer[offset+2]<<16 | buffer[offset+3]<<8 | buffer[offset+4])\n // TODO *val_p = uv < 0x80000000UL ? uv : -((int32_t) (0xffffffffUL - uv)) - 1;\n offset += 5;\n } else if (").concat(i," < 0xfc) {\n ").concat(t," = ((((buffer[offset] & 7) << 8) | buffer[offset+1] )) * Math.pow(2,32) +\n (buffer[offset+2]<<24) | (buffer[offset+3]<<16 | buffer[offset+4]<<8 | buffer[offset+5])\n offset += 6;\n } else if (").concat(i," < 0xfe) {\n ").concat(t," = ((((buffer[offset] & 3) << 16) | buffer[offset+1]<<8 | buffer[offset+2])) * Math.pow(2,32) +\n (buffer[offset+3]<<24) | (buffer[offset+4]<<16 | buffer[offset+5]<<8 | buffer[offset+6])\n offset += 7;\n } else if (").concat(i," < 0xff) {\n ").concat(t," = Long.fromBytesBE(buffer.slice(offset+1,offset+8));\n if (").concat(t,".greaterThan(Number.MAX_SAFE_INTEGER) || ").concat(t,".lessThan(Number.MIN_SAFE_INTEGER))\n throw new Error('integer overflow')\n ").concat(t," = ").concat(t,".toNumber()\n offset += 8;\n } else {\n ").concat(t," = Long.fromBytesBE(buffer.slice(offset+1,offset+9));\n if (").concat(t,".greaterThan(Number.MAX_SAFE_INTEGER) || ").concat(t,".lessThan(Number.MIN_SAFE_INTEGER))\n throw new Error('integer overflow')\n ").concat(t," = ").concat(t,".toNumber()\n offset += 9;\n }\n "))},t.Parser=f},2961:(e,t)=>{function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}var n=function(){this.code="",this.scopes=[["vars"]],this.isAsync=!1,this.bitFields=[],this.tmpVariableCount=0,this.references={}};n.prototype.generateVariable=function(e){var t=[];for(Array.prototype.push.apply(t,this.scopes[this.scopes.length-1]);/^\$parent\./.test(e);)t.pop(),e=e.replace(/^\$parent\./,"");return e&&t.push(e),t.join(".")},n.prototype.generateOption=function(e){switch(i(e)){case"number":return e.toString();case"string":return this.generateVariable(e);case"function":return"(".concat(e,").call(").concat(this.generateVariable(),", vars)");default:return}},n.prototype.generateError=function(){var e=Array.prototype.slice.call(arguments),t=n.interpolate.apply(this,e);this.isAsync?this.pushCode("return process.nextTick(function() { callback(new Error(".concat(t,"), vars); });")):this.pushCode("throw new Error(".concat(t,");"))},n.prototype.generateTmpVariable=function(){return"$tmp".concat(this.tmpVariableCount++)},n.prototype.pushCode=function(){var e=Array.prototype.slice.call(arguments);this.code+="".concat(n.interpolate.apply(this,e),"\n")},n.prototype.pushPath=function(e){e&&this.scopes[this.scopes.length-1].push(e)},n.prototype.popPath=function(e){e&&this.scopes[this.scopes.length-1].pop()},n.prototype.pushScope=function(e){this.scopes.push([e])},n.prototype.popScope=function(){this.scopes.pop()},n.prototype.addReference=function(e){this.references[e]||(this.references[e]={resolved:!1,requested:!1})},n.prototype.markResolved=function(e){this.references[e].resolved=!0},n.prototype.markRequested=function(e){e.forEach(function(e){this.references[e].requested=!0}.bind(this))},n.prototype.getUnresolvedReferences=function(){var e=this.references;return Object.keys(this.references).filter((function(t){return!e[t].resolved&&!e[t].requested}))},n.interpolate=function(e){var t=e.match(/{\d+}/g),i=Array.prototype.slice.call(arguments,1);return t&&t.forEach((function(t){var n=parseInt(t.substr(1,t.length-2),10);e=e.replace(t,i[n].toString())})),e},t._=n},22:e=>{e.exports.runInThisContext=function(e){return new Function("code","return eval(code);").call(globalThis,e)}},445:(e,t,i)=>{const n=i(7381),r=i(9260),s=i(576),o=i(4693),a=128;e.exports=class{decode(e){return this.stream=new r(e),this.decodeStream(this.stream)}decodeStream(e,t=0){var i=this.stream.ReadByte();16&i||(t=this.stream.ReadUint7());var n,r=t,s=1&i;if(8&i)return this.decodeStripe(this.stream,t);if(i&a&&([n,r]=this.decodePackMeta(this.stream)),32&i)var o=this.decodeCat(this.stream,r);else o=4&i?this.decodeExt(this.stream,r):64&i?s?this.decodeRLE1(this.stream,r):this.decodeRLE0(this.stream,r):s?this.decode1(this.stream,r):this.decode0(this.stream,r);return i&a&&(o=this.decodePack(o,n,t)),o}encode(e,t){if(this.stream=new r("",0,1.1*e.length+100),this.stream.WriteByte(t),16&t||this.stream.WriteUint7(e.length),8&t)return Buffer.concat([this.stream.buf.slice(0,this.stream.pos),this.encodeStripe(this.stream,e,t>>8)]);var i,n=1&t,s=e.length;return t&a&&([i,e,s]=this.encodePack(e)),t&a&&this.stream.WriteStream(i),64&t?n?this.encodeRLE1(e,s,this.stream):this.encodeRLE0(e,s,this.stream):n?this.encode1(e,s,this.stream):this.encode0(e,s,this.stream)}decode0(e,t){var i=new Buffer.allocUnsafe(t),r=e.ReadByte();0==r&&(r=256);var o=new s(r),a=new n(e);a.RangeStartDecode(e);for(var l=0;l<t;l++)i[l]=o.ModelDecode(e,a);return i}encode0(e,t,i){for(var r=0,o=0;o<t;o++)r<e[o]&&(r=e[o]);r++;var a=new s(r);i.WriteByte(r);var l=new n(i);for(o=0;o<t;o++)a.ModelEncode(i,l,e[o]);return l.RangeFinishEncode(i),i.buf.slice(0,i.pos)}decode1(e,t){var i=new Buffer.allocUnsafe(t),r=e.ReadByte();0==r&&(r=256);for(var o=new Array(r),a=0;a<r;a++)o[a]=new s(r);var l=new n(e);l.RangeStartDecode(e);var h=0;for(a=0;a<t;a++)i[a]=o[h].ModelDecode(e,l),h=i[a];return i}encode1(e,t,i){for(var r=0,o=0;o<t;o++)r<e[o]&&(r=e[o]);r++;var a=new Array(r);for(o=0;o<r;o++)a[o]=new s(r);i.WriteByte(r);var l=new n(i),h=0;for(o=0;o<t;o++)a[h].ModelEncode(i,l,e[o]),h=e[o];return l.RangeFinishEncode(i),i.buf.slice(0,i.pos)}decodeExt(e,t){var i=new Buffer.allocUnsafe(t),n=o.array(e.buf.slice(e.pos)),r=o.header(n),s=0;do{var a=o.decompress(n,r);-1!=a&&(Buffer.from(a).copy(i,s),s+=a.length,r-=a.length)}while(-1!=a);return i}encodeExt(e,t){}decodeRLE0(e,t){var i=new Buffer.allocUnsafe(t),r=e.ReadByte();0==r&&(r=256);for(var o=new s(r),a=new Array(258),l=0;l<=257;l++)a[l]=new s(4);var h=new n(e);for(h.RangeStartDecode(e),l=0;l<t;){i[l]=o.ModelDecode(e,h);for(var c=a[i[l]].ModelDecode(e,h),d=c,u=256;3==c;)c=a[u].ModelDecode(e,h),u=257,d+=c;for(var f=1;f<=d;f++)i[l+f]=i[l];l+=d+1}return i}encodeRLE0(e,t,i){for(var r=0,o=0;o<t;o++)r<e[o]&&(r=e[o]);r++;var a=new s(r),l=new Array(258);for(o=0;o<=257;o++)l[o]=new s(4);i.WriteByte(r);var h=new n(i);for(o=0;o<t;){a.ModelEncode(i,h,e[o]);for(var c=1;o+c<t&&e[o+c]==e[o];)c++;c--;var d=e[o];e[o],o+=c+1;var u=c>=3?3:c;for(l[d].ModelEncode(i,h,u),c-=u,d=256;3==u;)u=c>=3?3:c,l[d].ModelEncode(i,h,u),d=257,c-=u}return h.RangeFinishEncode(i),i.buf.slice(0,i.pos)}decodeRLE1(e,t){var i=new Buffer.allocUnsafe(t),r=e.ReadByte();0==r&&(r=256);for(var o=new Array(r),a=0;a<r;a++)o[a]=new s(r);var l=new Array(258);for(a=0;a<=257;a++)l[a]=new s(4);var h=new n(e);h.RangeStartDecode(e);var c=0;for(a=0;a<t;){i[a]=o[c].ModelDecode(e,h),c=i[a];for(var d=l[i[a]].ModelDecode(e,h),u=d,f=256;3==d;)d=l[f].ModelDecode(e,h),f=257,u+=d;for(var p=1;p<=u;p++)i[a+p]=i[a];a+=u+1}return i}encodeRLE1(e,t,i){for(var r=0,o=0;o<t;o++)r<e[o]&&(r=e[o]);r++;var a=new Array(r);for(o=0;o<r;o++)a[o]=new s(r);var l=new Array(258);for(o=0;o<=257;o++)l[o]=new s(4);i.WriteByte(r);for(var h=new n(i),c=(o=0,0);o<t;){a[c].ModelEncode(i,h,e[o]);for(var d=1;o+d<t&&e[o+d]==e[o];)d++;d--;var u=e[o];c=e[o],o+=d+1;var f=d>=3?3:d;for(l[u].ModelEncode(i,h,f),d-=f,u=256;3==f;)f=d>=3?3:d,l[u].ModelEncode(i,h,f),u=257,d-=f}return h.RangeFinishEncode(i),i.buf.slice(0,i.pos)}decodePackMeta(e){this.nsym=e.ReadByte();for(var t=new Array(this.nsym),i=0;i<this.nsym;i++)t[i]=e.ReadByte();return[t,e.ReadUint7()]}decodePack(e,t,i){var n=new Buffer.allocUnsafe(i);if(this.nsym<=1)for(var r=0;r<i;r++)n[r]=t[0];else if(this.nsym<=2){r=0;for(var s=0;r<i;r++){if(r%8==0)var o=e[s++];n[r]=t[1&o],o>>=1}}else if(this.nsym<=4)for(r=0,s=0;r<i;r++)r%4==0&&(o=e[s++]),n[r]=t[3&o],o>>=2;else{if(!(this.nsym<=16))return e;for(r=0,s=0;r<i;r++)r%2==0&&(o=e[s++]),n[r]=t[15&o],o>>=4}return n}packMeta(e){for(var t=new r("",0,1024),i=new Array(256),n=0;n<e.length;n++)i[e[n]]=1;var s=0;for(n=0;n<256;n++)i[n]&&(i[n]=++s);for(t.WriteByte(s),n=0;n<256;n++)i[n]&&(t.WriteByte(n),i[n]--);return[t,i,s]}encodePack(e){var t,i,n;[t,i,n]=this.packMeta(e);var r=e.length,s=0;if(n<=1)return t.WriteUint7(0),[t,new Buffer.allocUnsafe(0),0];if(n<=2){for(var o=new Buffer.allocUnsafe(Math.floor((r+7)/8)),a=(s=0,0);s<(-8&r);s+=8,a++)o[a]=(i[e[s+0]]<<0)+(i[e[s+1]]<<1)+(i[e[s+2]]<<2)+(i[e[s+3]]<<3)+(i[e[s+4]]<<4)+(i[e[s+5]]<<5)+(i[e[s+6]]<<6)+(i[e[s+7]]<<7);if(s<r){o[a]=0;for(var l=0;s<r;)o[a]|=i[e[s++]]<<l,l++;a++}return t.WriteUint7(a),[t,o,o.length]}if(n<=4){for(o=new Buffer.allocUnsafe(Math.floor((r+3)/4)),s=0,a=0;s<(-4&r);s+=4,a++)o[a]=(i[e[s+0]]<<0)+(i[e[s+1]]<<2)+(i[e[s+2]]<<4)+(i[e[s+3]]<<6);if(s<r){for(o[a]=0,l=0;s<r;)o[a]|=i[e[s++]]<<l,l+=2;a++}return t.WriteUint7(a),[t,o,o.length]}if(n<=16){for(o=new Buffer.allocUnsafe(Math.floor((r+1)/2)),s=0,a=0;s<(-2&r);s+=2,a++)o[a]=(i[e[s+0]]<<0)+(i[e[s+1]]<<4);return s<r&&(o[a++]=i[e[s++]]),t.WriteUint7(a),[t,o,o.length]}return t.WriteUint7(e.length),[t,e,e.length]}encodeStripe(e,t,i){0==i&&(i=4);for(var n=new Array(i),s=new Array(i),o=0;o<i;o++)s[o]=Math.floor(t.length/i)+(t.length%i>o),n[o]=new Array(s[o]);for(var a=0,l=0;l<t.length;l+=i,a++)for(var h=0;h<i;h++)a<n[h].length&&(n[h][a]=t[l+h]);var c=new Array(i),d=0;for(o=0;o<i;o++){var u=this.encode(n[o],0),f=this.encode(n[o],1);c[o]=f.length<u.length?f:u,d+=c[o].length}var p=new r("",0,d+5*i+1);for(p.WriteByte(i),o=0;o<i;o++)p.WriteUint7(c[o].length);for(o=0;o<i;o++)p.WriteData(c[o],c[o].length);return p.buf.slice(0,p.buf.pos)}decodeStripe(e,t){for(var i=e.ReadByte(),n=new Array(i),r=new Array(i),s=0;s<i;s++)n[s]=e.ReadUint7();var o=new Array(i);for(s=0;s<i;s++)r[s]=Math.floor(t/i)+(t%i>s),o[s]=this.decodeStream(e,r[s]);var a=new Buffer.allocUnsafe(t);for(s=0;s<i;s++)for(var l=0;l<r[s];l++)a[l*i+s]=o[s][l];return a}decodeCat(e,t){for(var i=new Buffer.allocUnsafe(t),n=0;n<t;n++)i[n]=e.ReadByte();return i}}},7381:e=>{e.exports=class{constructor(e){this.low=0,this.range=4294967295,this.code=0,this.FFnum=0,this.carry=0,this.cache=0}RangeStartDecode(e){for(var t=0;t<5;t++)this.code=(this.code<<8)+e.ReadByte();this.code&=4294967295,this.code>>>=0}RangeGetFrequency(e){return this.range=Math.floor(this.range/e),Math.floor(this.code/this.range)}RangeDecode(e,t,i,n){for(this.code-=t*this.range,this.range*=i;this.range<1<<24;)this.range*=256,this.code=256*this.code+e.ReadByte()}RangeShiftLow(e){if(this.low<4278190080|this.carry){for(e.WriteByte(this.cache+this.carry);this.FFnum;)e.WriteByte(this.carry-1),this.FFnum--;this.cache=this.low>>>24,this.carry=0}else this.FFnum++;this.low<<=8,this.low>>>=0}RangeEncode(e,t,i,n){var r=this.low;for(this.range=Math.floor(this.range/n),this.low+=t*this.range,this.low>>>=0,this.range*=i,this.low<r&&(0!=this.carry&&console.log("ERROR: Multiple carry"),this.carry=1);this.range<1<<24;)this.range*=256,this.RangeShiftLow(e)}RangeFinishEncode(e){for(var t=0;t<5;t++)this.RangeShiftLow(e)}}},576:e=>{e.exports=class{constructor(e=256){this.total_freq=e,this.max_sym=e-1,this.S=new Array,this.F=new Array;for(var t=0;t<=this.max_sym;t++)this.S[t]=t,this.F[t]=1}ModelDecode(e,t){for(var i=t.RangeGetFrequency(this.total_freq),n=0,r=0;n+this.F[r]<=i;)n+=this.F[r++];t.RangeDecode(e,n,this.F[r],this.total_freq),this.F[r]+=16,this.total_freq+=16,this.total_freq>65519&&this.ModelRenormalise();var s=this.S[r];if(r>0&&this.F[r]>this.F[r-1]){var o=this.F[r];this.F[r]=this.F[r-1],this.F[r-1]=o,o=this.S[r],this.S[r]=this.S[r-1],this.S[r-1]=o}return s}ModelRenormalise(){this.total_freq=0;for(var e=0;e<=this.max_sym;e++)this.F[e]-=Math.floor(this.F[e]/2),this.total_freq+=this.F[e]}ModelEncode(e,t,i){for(var n=0,r=0;this.S[r]!=i;r++)n+=this.F[r];if(t.RangeEncode(e,n,this.F[r],this.total_freq),this.F[r]+=16,this.total_freq+=16,this.total_freq>65519&&this.ModelRenormalise(),i=this.S[r],r>0&&this.F[r]>this.F[r-1]){var s=this.F[r];this.F[r]=this.F[r-1],this.F[r-1]=s,s=this.S[r],this.S[r]=this.S[r-1],this.S[r-1]=s}}}},5260:(e,t,i)=>{const n=i(9260),r=i(576),s=i(7381);function o(e,t,i){for(var n=0,r=0,s=-1,o=new Array(1024);r<i;){var a=e.ReadByte();if(o[n++]=a,r+=a,a==s){var l=e.ReadByte();for(r+=a*l;l--;)o[n++]=a}s=a}var h=0;for(n=0,r=0;r<i;){var c=0;do{var d=o[n++];c+=d}while(255==d);for(;c--;)t[r++]=h;h++}}function a(e,t,i){var n=e.context;return t.qctx=(t.qctx<<e.qshift)+e.qtab[i],n+=(t.qctx&(1<<e.qbits)-1)<<e.qloc,e.do_pos&&(n+=e.ptab[Math.min(t.p,1023)]<<e.ploc),e.do_delta&&(n+=e.dtab[Math.min(t.delta,255)]<<e.dloc,t.delta+=t.prevq!=i?1:0,t.prevq=i),e.do_sel&&(n+=t.s<<e.sloc),t.p--,65535&n}function l(e){var t={};t.context=e.ReadUint16(),t.pflags=e.ReadByte(),t.do_dedup=2&t.pflags,t.fixed_len=4&t.pflags,t.do_sel=8&t.pflags,t.do_qmap=16&t.pflags,t.do_pos=32&t.pflags,t.do_delta=64&t.pflags,t.do_qtab=128&t.pflags,t.max_sym=e.ReadByte();var i=e.ReadByte();if(t.qbits=i>>4,t.qshift=15&i,i=e.ReadByte(),t.qloc=i>>4,t.sloc=15&i,i=e.ReadByte(),t.ploc=i>>4,t.dloc=15&i,t.qmap=new Array(256),16&t.pflags)for(var n=0;n<t.max_sym;n++)t.qmap[n]=e.ReadByte();else for(n=0;n<256;n++)t.qmap[n]=n;if(t.qtab=new Array(1024),t.qbits>0&&128&t.pflags)o(e,t.qtab,256);else for(n=0;n<256;n++)t.qtab[n]=n;return t.ptab=new Array(1024),32&t.pflags&&o(e,t.ptab,1024),t.dtab=new Array(256),64&t.pflags&&o(e,t.dtab,256),t}function h(e,t,i,n,r,s){i.max_sel>0?r.s=n.sel.ModelDecode(e,t):r.s=0,r.x=i.stab[r.s];var o=i.params[r.x];if(o.fixed_len>=0){var a=n.len[0].ModelDecode(e,t);a|=n.len[1].ModelDecode(e,t)<<8,a|=n.len[2].ModelDecode(e,t)<<16,a|=n.len[3].ModelDecode(e,t)<<24,o.fixed_len>0&&(o.fixed_len=-a)}else a=-o.fixed_len;r.len=a,i.do_rev&&(s[r.rec]=n.rev.ModelDecode(e,t)),r.is_dup=0,2&o.pflags&&n.dup.ModelDecode(e,t)&&(r.is_dup=1),r.p=a,r.delta=0,r.qctx=0,r.prevq=0,r.rec++}function c(e,t,i){for(var n=0,r=0,s=new Array(2*i),o=0;n<i;){for(var a=n;n<i&&t[n]==r;)n++;var l=n-a;do{var h=Math.min(255,l);s[o++]=h,l-=h}while(255==h);r++}var c=-1,d=new Array(2*i),u=0;for(n=0;n<o;){var f=s[n++];if(d[u++]=f,f==c){for(a=n;n<o&&s[n]==c&&n-a<255;)n++;d[u++]=n-a}else c=f}e.WriteData(d,u)}e.exports={decode:function(e,t){return function(e,t){var i=e.ReadUint7(),n=function(e){var t={max_sym:0};if(5==e.ReadByte()){var i=e.ReadByte(),n=1&i?e.ReadByte():1,r=i.nparam>1?i.nparam-1:0,s=new Array(256);if(2&i)r=e.ReadByte(),o(e,s,256);else{for(var a=0;a<n;a++)s[a]=a;for(;a<256;a++)s[a]=n-1}t.do_rev=4&i,t.stab=s,t.max_sel=r,t.params=new Array(t.nparam);for(var h=0;h<n;h++)t.params[h]=l(e),t.max_sym<t.params[h].max_sym&&(t.max_sym=t.params[h].max_sym);return t}console.error("Invalid FQZComp version number")}(e);if(n){var c=n.params,d=new Array(t.length),u=function(e){var t={};t.qual=new Array(65536);for(var i=0;i<65536;i++)t.qual[i]=new r(e.max_sym+1);for(t.len=new Array(4),i=0;i<4;i++)t.len[i]=new r(256);return t.rev=new r(2),t.dup=new r(2),e.max_sel>0&&(t.sel=new r(e.max_sel+1)),t}(n),f=new s(e);f.RangeStartDecode(e);for(var p=new Buffer.allocUnsafe(i),g={qctx:0,prevq:0,delta:0,p:0,s:0,x:0,len:0,is_dup:0,rec:0},m=0;m<i;){if(0==g.p){if(h(e,f,n,u,g,d),g.is_dup>0&&u.dup.ModelDecode(e,f)){for(var b=0;b<len;b++)p[m+b]=p[m+b-g.len];m+=g.len,g.p=0;continue}t.push(g.len);var w=(c=n.params[g.x]).context}var v=u.qual[w].ModelDecode(e,f);p[m++]=c.qmap[v],w=a(c,g,v)}return n.do_rev&&function(e,t,i,n){for(var r=0,s=0;s<t;){if(i[r])for(var o=0,a=n[r]-1;o<a;){var l=e[s+o];e[s+o]=e[s+a],e[s+a]=l,o++,a--}s+=n[r++]}}(p,i,d,t),p}}(new n(e),t)},encode:function(e,t,i){for(var o=new Array(2),a=new Array(2),l=new Array(2),h=new Array(2),d=new Array(256),u=0;u<2;u++)o[u]=new Array(256),a[u]=new Array(256),l[u]=new Array(1024),h[u]=new Array(256);(p=new n("",0,1.1*e.length+100)).WriteUint7(e.length);var f=function(e,t,i,n){for(var r=i[0],s=0;s<i.length&&i[s]==r;s++);var o=s==i.length?1:0,a=0,l=0;for(s=0;s<256;s++)n[0][s]=0;var h=0,c=0;for(s=0;s<e.length;s++)0==c&&(c=t[h<t.length-1?h++:h]),n[0][e[s]]++,c--;for(s=0;s<256;s++)n[0][s]&&(l<s&&(l=s),a++);var d=5,u=0;return a<=16&&(u=1,d=a<=2?1:a<=4?2:a<=8?3:4),[{qbits:8+(d>4),qshift:d,qloc:7,pbits:7,pshift:t[0]>128?1:0,ploc:0,dbits:d>4?0:1,dshift:3,dloc:15,sbits:0,sloc:15,do_stab:0,context:0,max_sym:l,nsym:a,do_qmap:u,do_dedup:0,fixed_len:1==t.length?1:0,do_sel:0,do_rev:0,do_pos:1,do_delta:d<=4?1:0,do_qtab:0,qbits:8+(d>4)-(0==o),sbits:1,sloc:15-(d<=4),do_stab:1,do_sel:1}]}(e,t,i,o),p=function(e,t,i,n,r,s,o){for(var a=[0,1,1,1,2,2,2,2,2,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7],l=0;l<t.length;l++)o[l]=l;for(;l<256;l++)o[l]=t.length-1;e.WriteByte(5);var h=(t.length>1?1:0)|(t[0].do_stab?2:0);if(e.WriteByte(h),1&h&&e.WriteByte(t.length),2&h){var d=1<<t[0].sbits;d>0&&d--,e.WriteByte(d),c(e,o,256)}for(var u=0;u<t.length;u++){if(e.WriteUint16(t[u].context),e.WriteByte((t[u].do_qtab?128:0)|(t[u].do_delta?64:0)|(t[u].do_pos?32:0)|(t[u].do_qmap?16:0)|(t[u].do_sel?8:0)|(t[u].fixed_len?4:0)|(t[u].do_dedup?2:0)),t[u].do_qmap?e.WriteByte(t[u].nsym):e.WriteByte(t[u].max_sym),e.WriteByte(t[u].qbits<<4|t[u].qshift),e.WriteByte(t[u].qloc<<4|t[u].sloc),e.WriteByte(t[u].ploc<<4|t[u].dloc),t[u].do_qmap){t[u].max_sym=t[u].nsym;var f=0;for(l=0;l<256;l++)i[u][l]&&(e.WriteByte(l),i[u][l]=f++);for(;f<t[u].nsym;f++)e.WriteByte(0)}else for(l=0;l<256;l++)i[u][l]=l;if(t[u].qbits>0){for(l=0;l<256;l++)n[u][l]=l;t[u].do_qtab&&c(e,n[u],256)}if(t[u].pbits>0){for(l=0;l<1024;l++)r[u][l]=Math.min((1<<t[u].pbits)-1,l>>t[u].pshift);c(e,r[u],1024)}if(t[u].dbits>0){for(l=0;l<256;l++)a[l]>(1<<t[u].dbits)-1&&(a[l]=(1<<t[u].dbits)-1);for(l=0;l<256;l++)s[u][l]=a[Math.min(a.length-1,l>>t[u].dshift)];c(e,s[u],256)}}return e}(p,f,o,a,l,h,d);return function(e,t,i,n,o,a,l,h,c,d){var u=1<<o[0].sbits;u>0&&u--;for(var f=t.length,p=0,g=0;g<o.length;g++)p<o[g].max_sym&&(p=o[g].max_sym);for(var m=new Array(65536),b=0;b<65536;b++)m[b]=new r(p+1);var w=new Array(4);for(b=0;b<4;b++)w[b]=new r(256);new r(2),new r(2);for(var v=new r(u+1),y=new s(t),_=(g=0,b=0,0);b<f;){if(0==g){var x=n[_];o[0].sbits>0&&v.ModelEncode(e,y,x);var k=d[x],C=i[Math.min(i.length-1,_++)];o[k].fixed_len?o[k].fixed_len>0&&(w[0].ModelEncode(e,y,255&C),w[1].ModelEncode(e,y,C>>8&255),w[2].ModelEncode(e,y,C>>16&255),w[3].ModelEncode(e,y,C>>24&255),o[k].fixed_len=-1):(w[0].ModelEncode(e,y,255&C),w[1].ModelEncode(e,y,C>>8&255),w[2].ModelEncode(e,y,C>>16&255),w[3].ModelEncode(e,y,C>>24&255)),o[k].do_dedup&&process.exit(1),g=C;var S=0,A=o[k].context,E=0,M=0}var T=t[b++],R=a[k][T];m[A].ModelEncode(e,y,R),E=(E<<o[k].qshift)+l[k][R],A=o[k].context,A+=(E&(1<<o[k].qbits)-1)<<o[k].qloc,o[k].pbits>0&&(A+=h[k][Math.min(g,1023)]<<o[k].ploc),o[k].dbits>0&&(A+=c[k][Math.min(S,255)]<<o[k].dloc,S+=M!=R?1:0,M=R),o[k].do_sel&&(A+=x<<o[k].sloc),A&=65535,g--}return y.RangeFinishEncode(e),e.buf.slice(0,e.pos)}(p,e,t,i,f,o,a,l,h,d)}}},3498:(e,t,i)=>{var n=i(4459),r=i(594),s=i(445),o=i(5260),a=i(2881);e.exports={r4x8_uncompress:function(e,t){n.decode(e).copy(t,0,0)},r4x16_uncompress:function(e,t){r.decode(e).copy(t,0,0)},arith_uncompress:function(e,t){s.decode(e).copy(t,0,0)},fqzcomp_uncompress:function(e,t){var i=new Array;o.decode(e,i).copy(t,0,0)},tok3_uncompress:function(e,t){var i=a.decode(e,0,"\0");Buffer.from(i,"binary").copy(t,0,0)}}},9260:e=>{e.exports=class{constructor(e,t=0,i=0){0!=i?(this.buf=Buffer.allocUnsafe(i),this.length=i):(this.buf=e,this.length=e.length),this.pos=t}EOF(){return this.pos>=this.length}ReadData(e){var t=this.buf.slice(this.pos,this.pos+e);return this.pos+=e,t}ReadByte(){const e=this.buf[this.pos];return this.pos++,e}ReadChar(){const e=this.buf[this.pos];return this.pos++,String.fromCharCode(e)}ReadUint16(){return this.ReadByte()|this.ReadByte()<<8}ReadUint32(){const e=this.buf.readInt32LE(this.pos);return this.pos+=4,e}ReadString(){var e="";do{var t=this.buf[this.pos++];t&&(e+=String.fromCharCode(t))}while(t);return e}ReadUint7(){var e=0;do{var t=this.ReadByte();e=e<<7|127&t}while(128&t);return e}ReadITF8(){var e=this.buf[this.pos];return this.pos++,e>=240?(e=(15&e)<<28,e+=(this.buf[this.pos+0]<<20)+(this.buf[this.pos+1]<<12)+(this.buf[this.pos+2]<<4)+(this.buf[this.pos+3]>>4),this.pos+=4):e>=224?(e=(15&e)<<24,e+=(this.buf[this.pos+0]<<16)+(this.buf[this.pos+1]<<8)+(this.buf[this.pos+2]<<0),this.pos+=3):e>=192?(e=(31&e)<<16,e+=(this.buf[this.pos+0]<<8)+(this.buf[this.pos+1]<<0),this.pos+=2):e>=128&&(e=(63&e)<<8,e+=this.buf[this.pos],this.pos++),e}WriteByte(e){this.buf[this.pos++]=e}WriteChar(e){this.buf[this.pos++]=e.charCodeAt(0)}WriteString(e){for(var t=0;t<e.length;t++)this.buf[this.pos++]=e.charCodeAt(t);this.buf[this.pos++]=0}WriteData(e,t){for(var i=0;i<t;i++)this.buf[this.pos++]=e[i]}WriteStream(e){this.WriteData(e.buf,e.pos)}WriteUint16(e){this.WriteByte(255&e),this.WriteByte(e>>8&255)}WriteUint32(e){this.buf.writeInt32LE(e,this.pos),this.pos+=4}WriteUint7(e){var t=0,i=e;do{t+=7,i>>=7}while(i>0);do{t-=7,this.WriteByte((e>>t&127)+((t>0)<<7))}while(t>0)}WriteITF8(e){e<0&&(e=1+e),e<=127?this.buf[this.pos++]=e:e<=16383?(this.buf[this.pos++]=128|Math.floor(e/256),this.buf[this.pos++]=255&e):e<131071?(this.buf[this.pos++]=192|Math.floor(e/65536),this.buf[this.pos++]=255&Math.floor(e/256),this.buf[this.pos++]=255&e):e<268435455?(this.buf[this.pos++]=224|Math.floor(e/16777216),this.buf[this.pos++]=255&Math.floor(e/65536),this.buf[this.pos++]=255&Math.floor(e/256),this.buf[this.pos++]=255&e):(this.buf[this.pos++]=240|Math.floor(e/268435456),this.buf[this.pos++]=255&Math.floor(e/1048576),this.buf[this.pos++]=255&Math.floor(e/4096),this.buf[this.pos++]=255&Math.floor(e/4),this.buf[this.pos++]=15&e)}WriteByteNeg(e){this.buf[--this.pos]=e}}},4459:(e,t,i)=>{const n=i(9260);function r(e){return 4095&e}function s(e,t){for(var i=0;t>=e[i+1];)i++;return i}function o(e){for(var t=new Array(4096),i=0,n=0;n<4096;n++){for(;n>=e[i+1];)i++;t[n]=i}return t}function a(e,t,i){return i*(e>>12)+(4095&e)-t}function l(e,t){for(;t<1<<23;)t=(t<<8)+e.ReadByte();return t}function h(e,t){t.WriteByteNeg(e>>24&255),t.WriteByteNeg(e>>16&255),t.WriteByteNeg(e>>8&255),t.WriteByteNeg(e>>0&255)}function c(e,t,i,n,r){return e=function(e,t,i,n){for(var r=(1<<23>>n<<8)*i;e>=r;)t.WriteByteNeg(255&e),e>>=8;return e}(e,t,n,r),(Math.floor(e/n)<<r)+e%n+i}function d(e,t,i){for(var n=0;n<256;n++)t[n]=0;var r=e.ReadByte(),s=r,o=0;do{var a=e.ReadITF8();t[r]=a,o>0?(o--,r++):(r=e.ReadByte())==s+1&&(o=e.ReadByte()),s=r}while(0!=r);for(i[0]=0,n=0;n<=255;n++)i[n+1]=i[n]+t[n]}function u(e){for(var t=0,i=0;i<256;i++)t+=e[i];const n=4096;var r=n/t;do{var s=0,o=0,a=0;for(t=0,i=0;i<256;i++)0!=e[i]&&(s<e[i]&&(s=e[i],o=i),e[i]=Math.floor(e[i]*r),0==e[i]&&(e[i]=1),t+=e[i]);t<n?e[o]+=n-t:t-n<e[o]/2&&e[o]>2?e[o]-=t-n:t!=n&&(r*=.99,a=1)}while(a)}function f(e,t){for(var i=0,n=0;n<256;n++)if(t[n]){if(i>0)i--;else if(e.WriteByte(n),n>0&&t[n-1]>0){for(i=n+1;i<256&&t[i];i++);i-=n+1,e.WriteByte(i)}e.WriteITF8(t[n])}e.WriteByte(0)}e.exports={decode:function(e){var t=new n(e),i=t.ReadByte(),h=(t.ReadUint32(),t.ReadUint32());return 0==i?function(e,t){var i=new Array(256),n=new Array(256);d(e,i,n);for(var s=o(n),h=new Array(4),c=0;c<4;c++)h[c]=e.ReadUint32();var u=new Buffer.allocUnsafe(t);for(c=0;c<t;c++){var f=c%4,p=s[r(h[f])];u[c]=p,h[f]=a(h[f],n[p],i[p]),h[f]=l(e,h[f])}return u}(t,h):function(e,t){var i=new Array(256),n=new Array(256);!function(e,t,i){for(var n=0;n<256;n++){t[n]=new Array(256),i[n]=new Array(256);for(var r=0;r<256;r++)t[n][r]=0}var s=e.ReadByte(),o=s,a=0;do{d(e,t[s],i[s]),a>0?(a--,s++):(s=e.ReadByte())==o+1&&(a=e.ReadByte()),o=s}while(0!=s)}(e,i,n);for(var h=new Array(256),c=0;c<256;c++)h[c]=o(n[c]);for(var u=new Array(4),f=new Array(4),p=0;p<4;p++)u[p]=e.ReadUint32(),f[p]=0;var g=new Buffer.allocUnsafe(t),m=Math.floor(t/4);for(c=0;c<m;c++)for(p=0;p<4;p++){var b=r(u[p]),w=h[f[p]][b];g[c+p*m]=w,u[p]=a(u[p],n[f[p]][w],i[f[p]][w]),u[p]=l(e,u[p]),f[p]=w}for(c*=4;c<t;)b=r(u[3]),w=s(n[f[3]],b),g[c++]=w,u[3]=a(u[3],n[f[3]][w],i[f[3]][w]),u[3]=l(e,u[3]),f[3]=w;return g}(t,h)},encode:function(e,t){return 0==t?function(e){const t=e.length;var i=new n("",0,780);i.WriteByte(0),i.WriteUint32(0),i.WriteUint32(0);var r=new Array(256);(function(e,t){for(var i=0;i<256;i++)t[i]=0;for(i=0;i<e.length;i++)t[e[i]]++})(e,r),u(r),f(i,r);var s=new Array(256);s[0]=0;for(var o=1;o<256;o++)s[o]=s[o-1]+r[o-1];var a=new Array(4);for(o=0;o<4;o++)a[o]=1<<23;var l=Math.floor(1.05*t+100),d=new n("",l,l);for(o=t-1;o>=0;o--)a[o%4]=c(a[o%4],d,s[e[o]],r[e[o]],12);for(o=3;o>=0;o--)h(a[o],d);var p=i.pos;return i.buf.writeInt32LE(p-9+(d.length-d.pos),1),i.buf.writeInt32LE(t,5),Buffer.concat([i.buf.slice(0,i.pos),d.buf.slice(d.pos,d.length)],i.pos+d.length-d.pos)}(e):function(e){const t=e.length;var i=new n("",0,198156);i.WriteByte(1),i.WriteUint32(0),i.WriteUint32(0);for(var r=new Array(256),s=new Array(256),o=new Array(256),a=0;a<256;a++)s[a]=new Array(256),o[a]=new Array(256);for(function(e,t,i){for(var n=0;n<256;n++){i[n]=0;for(var r=0;r<256;r++)t[n][r]=0}var s=0;for(n=0;n<e.length;n++)i[e[n]]++,t[s][e[n]]++,s=e[n];t[0][e[1*(e.length>>2)]]++,t[0][e[2*(e.length>>2)]]++,t[0][e[3*(e.length>>2)]]++,i[0]+=3}(e,s,r),function(e,t){for(var i=0;i<256;i++)t[i]&&u(e[i])}(s,r),function(e,t,i){for(var n=0,r=0;r<256;r++)if(i[r]){if(n>0)n--;else if(e.WriteByte(r),r>0&&i[r-1]>0){for(n=r+1;n<256&&i[n];n++);n-=r+1,e.WriteByte(n)}f(e,t[r])}e.WriteByte(0)}(i,s,r),a=0;a<256;a++)if(r[a]){o[a][0]=0;for(var l=1;l<256;l++)o[a][l]=o[a][l-1]+s[a][l-1]}var d=new Array(4),p=new Array(4);for(l=0;l<4;l++)d[l]=1<<23,p[l]=0;var g=new n("",t,t),m=Math.floor(t/4),b=new Array(4),w=new Array(4);for(l=0;l<4;l++)b[l]=(l+1)*m-2,w[l]=e[b[l]+1];for(w[3]=e[t-1],a=t-2;a>4*m-2;a--)d[3]=c(d[3],g,o[e[a]][w[3]],s[e[a]][w[3]],12),w[3]=e[a];for(;b[0]>=0;)for(l=3;l>=0;l--){var v=e[b[l]];d[l]=c(d[l],g,o[v][w[l]],s[v][w[l]],12),w[l]=v,b[l]--}for(l=3;l>=0;l--)d[l]=c(d[l],g,o[0][w[l]],s[0][w[l]],12);for(a=3;a>=0;a--)h(d[a],g);var y=i.pos;return i.buf.writeInt32LE(y-9+(g.length-g.pos),1),i.buf.writeInt32LE(t,5),Buffer.concat([i.buf.slice(0,i.pos),g.buf.slice(g.pos,g.length)],i.pos+g.length-g.pos)}(e)}}},594:(e,t,i)=>{const n=i(9260);function r(e,t){return e&(1<<t)-1}function s(e,t){for(var i=0;t>=e[i+1];)i++;return i}function o(e,t){for(var i=1<<t,n=new Array(i),r=0,s=0;s<i;s++){for(;s>=e[r+1];)r++;n[s]=r}return n}function a(e,t,i,n){return i*(e>>n)+(e&(1<<n)-1)-t}function l(e,t){return t<32768&&(t=(t<<16)+e.ReadUint16()),t}function h(e,t){t.WriteByteNeg(e>>24&255),t.WriteByteNeg(e>>16&255),t.WriteByteNeg(e>>8&255),t.WriteByteNeg(e>>0&255)}function c(e,t,i,n,r){return e=function(e,t,i,n){for(var r=(1<<31-n)*i;e>=r;)t.WriteByteNeg(e>>8&255),t.WriteByteNeg(255&e),e>>=16;return e}(e,t,n,r),(Math.floor(e/n)<<r)+e%n+i}function d(e,t,i){0==i&&(i=4);for(var r=new Array(i),s=new Array(i),o=0;o<i;o++)s[o]=Math.floor(t.length/i)+(t.length%i>o),r[o]=new Array(s[o]);for(var a=0,l=0;l<t.length;l+=i,a++)for(var h=0;h<i;h++)a<r[h].length&&(r[h][a]=t[l+h]);var c=new Array(i),d=0;for(o=0;o<i;o++){var u=f(r[o],0),p=f(r[o],1);c[o]=p.length<u.length?p:u,d+=c[o].length}var g=new n("",0,d+5*i+1);for(g.WriteByte(i),o=0;o<i;o++)g.WriteUint7(c[o].length);for(o=0;o<i;o++)g.WriteData(c[o],c[o].length);return g.buf.slice(0,g.buf.pos)}function u(e,t){var i=e.ReadByte(),h=1&i,c=8&i,d=32&i,f=64&i,m=128&i;if(16&i||(t=e.ReadUint7()),c)return function(e,t){for(var i=e.ReadByte(),n=new Array(i),r=new Array(i),s=0;s<i;s++)n[s]=e.ReadUint7();var o=new Array(i);for(s=0;s<i;s++)r[s]=Math.floor(t/i)+(t%i>s),o[s]=u(e,r[s]);var a=new Buffer.allocUnsafe(t);for(s=0;s<i;s++)for(var l=0;l<r[s];l++)a[l*i+s]=o[s][l];return a}(e,t);if(m)var w=t,[v,y,t]=function(e){for(var t=e.ReadByte(),i=new Array(t),n=0;n<t;n++)i[n]=e.ReadByte();return[i,t,e.ReadUint7()]}(e);if(f)var _=t,[x,k,t]=function(e){var t=e.ReadUint7(),i=e.ReadUint7();if(1&t)var r=e.ReadData((t-1)/2);else{var s=e.ReadUint7();r=e.ReadData(s),r=g(new n(r),t/2)}r=new n(r);var o=new Array(256),a=r.ReadByte();0==a&&(a=256);for(var l=0;l<a;l++)o[r.ReadByte()]=1;return[o,r,i]}(e);if(d)var C=e.ReadData(t);else C=0==h?g(e,t):function(e,t){var i=(u=e.ReadByte())>>4,h=e;if(1&u){var c=e.ReadUint7(),d=e.ReadUint7(),u=new n(e.ReadData(d));h=new n(g(u,c))}var f=new Array(256),m=new Array(256);!function(e,t,i,n){for(var r=0;r<256;r++){t[r]=new Array(256),i[r]=new Array(256);for(var s=0;s<256;s++)t[r][s]=0}var o=p(e);for(r=0;r<256;r++)if(o[r]){var a=0;for(s=0;s<256;s++)o[s]&&(a>0?a--:(t[r][s]=e.ReadUint7(),0==t[r][s]&&(a=e.ReadByte())));for(b(t[r],n),i[r][0]=0,s=0;s<256;s++)i[r][s+1]=i[r][s]+t[r][s]}}(h,f,m,i);for(var w=new Array(256),v=0;v<256;v++)w[v]=o(m[v],i);for(var y=new Array(4),_=new Array(4),x=0;x<4;x++)y[x]=e.ReadUint32(),_[x]=0;var k=new Buffer.allocUnsafe(t),C=Math.floor(t/4);for(v=0;v<C;v++)for(x=0;x<4;x++){var S=r(y[x],i),A=w[_[x]][S];k[v+x*C]=A,y[x]=a(y[x],m[_[x]][A],f[_[x]][A],i),y[x]=l(e,y[x]),_[x]=A}for(v*=4;v<t;)S=r(y[3],i),A=s(m[_[3]],S),k[v++]=A,y[3]=a(y[3],m[_[3]][A],f[_[3]][A],i),y[3]=l(e,y[3]),_[3]=A;return k}(e,t);return f&&(C=function(e,t,i,r){new n(e);for(var s=new Buffer.allocUnsafe(r),o=0,a=0;o<r;a++){var l=e[a];if(t[l])for(var h=i.ReadUint7(),c=0;c<=h;c++)s[o++]=l;else s[o++]=l}return s}(C,x,k,_)),m&&(C=function(e,t,i,n){var r=new Buffer.allocUnsafe(n),s=0;if(i<=1)for(var o=0;o<n;o++)r[o]=t[0];else if(i<=2)for(o=0;o<n;o++){if(o%8==0)var a=e[s++];r[o]=t[1&a],a>>=1}else if(i<=4)for(o=0;o<n;o++)o%4==0&&(a=e[s++]),r[o]=t[3&a],a>>=2;else if(i<=16)for(o=0;o<n;o++)o%2==0&&(a=e[s++]),r[o]=t[15&a],a>>=4;return r}(C,v,y,w)),C}function f(e,t){var i=new n("",0,10);i.WriteByte(t);var r=1&t,s=8&t,o=32&t,a=64&t,l=128&t,u=t>>8;if(16&t||i.WriteUint7(e.length),s)return Buffer.concat([i.buf.slice(0,i.pos),d(0,e,u)]);var f=new Buffer.alloc(0);l&&([f,e]=function(e){for(var t=new Array(256),i=0;i<256;i++)t[i]=0;for(i=0;i<e.length;i++)t[e[i]]++;var r=new Array(256),s=0;for(i=0;i<256;i++)t[i]>0&&(r[i]=s++);if(!(s>16)){if(s<=1)var o=new Buffer.allocUnsafe(0);else if(s<=2){o=new Buffer.allocUnsafe(Math.ceil(e.length/8));var a=-1;for(i=0;i<e.length;i++)i%8==0&&(o[++a]=0),o[a]+=r[e[i]]<<i%8}else if(s<=4)for(o=new Buffer.allocUnsafe(Math.ceil(e.length/4)),a=-1,i=0;i<e.length;i++)i%4==0&&(o[++a]=0),o[a]+=r[e[i]]<<i%4*2;else for(o=new Buffer.allocUnsafe(Math.ceil(e.length/2)),a=-1,i=0;i<e.length;i++)i%2==0&&(o[++a]=0),o[a]+=r[e[i]]<<i%2*4;var l=new n("",0,s+5);for(l.WriteByte(s),a=0,i=0;i<256;i++)t[i]>0&&(t[i]=a++,l.WriteByte(i));return l.WriteUint7(o.length),[l.buf.slice(0,l.pos),o]}}(e));var p=new Buffer.alloc(0);if(a&&([p,e]=function(e){for(var t=new Array(256),i=0;i<256;i++)t[i]=0;var r=-1;for(i=0;i<e.length;i++)t[e[i]]+=e[i]==r?1:-1,r=e[i];var s=0;for(i=0;i<256;i++)t[i]>0&&s++;for(s||(s=1,t[0]=1),(h=new n("",0,s+1+e.length)).WriteByte(s),i=0;i<256;i++)t[i]>0&&h.WriteByte(i);var o=new Buffer.allocUnsafe(e.length),a=0;for(i=0;i<e.length;i++)if(o[a++]=e[i],t[e[i]]>0){r=e[i];for(var l=0;i+l+1<e.length&&e[i+l+1]==r;)l++;h.WriteUint7(l),i+=l}var h,c=v(h.buf.slice(0,h.pos)),d=new n("",0,16);return d.WriteUint7(2*h.pos),d.WriteUint7(a),d.WriteUint7(c.length),[h=Buffer.concat([d.buf.slice(0,d.pos),c]),o.slice(0,a)]}(e)),e.length<4&&1==r&&(r=0,i.buf[0]&=-2),o)var g=e;else g=0==r?v(e):function(e){const t=e.length;for(var i=new n("",0,198156),r=new Array(256),s=new Array(256),o=new Array(256),a=0;a<256;a++)s[a]=new Array(256),o[a]=new Array(256);(function(e,t,i){for(var n=0;n<256;n++){i[n]=0;for(var r=0;r<256;r++)t[n][r]=0}var s=0;for(n=0;n<e.length;n++)i[s]++,t[s][e[n]]++,s=e[n];i[s]++,t[0][e[1*(e.length>>2)]]++,t[0][e[2*(e.length>>2)]]++,t[0][e[3*(e.length>>2)]]++,i[0]+=3})(e,s,r),function(e,t,i){for(var n=0;n<256;n++)if(t[n]){var r=Math.ceil(Math.log2(t[n]));r>12&&(r=12),m(e[n],r)}}(s,r);var l=new n("",0,198156);!function(e,t,i){w(e,i);for(var n=0;n<256;n++)if(i[n])for(var r=0,s=0;s<256;s++)if(i[s])if(r)r--;else if(e.WriteUint7(t[n][s]),!t[n][s]){for(var o=s+1;o<256;o++)if(i[o]){if(0!=t[n][o])break;r++}e.WriteByte(r)}}(l,s,r);var d=v(l.buf.slice(0,l.pos));for(d.length<l.pos?(i.WriteByte(193),i.WriteUint7(l.pos),i.WriteUint7(d.length),i.WriteData(d,d.length)):(i.WriteByte(192),i.WriteData(l.buf,l.pos)),function(e,t,i){for(var n=0;n<256;n++)t[n]&&b(e[n],12)}(s,r),a=0;a<256;a++)if(r[a]){o[a][0]=0;for(var u=1;u<256;u++)o[a][u]=o[a][u-1]+s[a][u-1]}var f=new Array(4),p=new Array(4);for(u=0;u<4;u++)f[u]=32768,p[u]=0;var g=new n("",1.05*t+100>>0,1.05*t+100>>0),y=Math.floor(t/4),_=new Array(4),x=new Array(4);for(u=0;u<4;u++)_[u]=(u+1)*y-2,x[u]=e[_[u]+1];for(x[3]=e[t-1],a=t-2;a>4*y-2;a--)f[3]=c(f[3],g,o[e[a]][x[3]],s[e[a]][x[3]],12),x[3]=e[a];for(;_[0]>=0;)for(u=3;u>=0;u--){var k=e[_[u]];f[u]=c(f[u],g,o[k][x[u]],s[k][x[u]],12),x[u]=k,_[u]--}for(u=3;u>=0;u--)f[u]=c(f[u],g,o[0][x[u]],s[0][x[u]],12);for(a=3;a>=0;a--)h(f[a],g);return Buffer.concat([i.buf.slice(0,i.pos),g.buf.slice(g.pos,g.length)],i.pos+g.length-g.pos)}(e);return Buffer.concat([i.buf.slice(0,i.pos),f,p,g])}function p(e){for(var t=new Array(256),i=0;i<256;i++)t[i]=0;var n=0,r=e.ReadByte(),s=r;do{t[r]=1,n>0?(n--,r++):(r=e.ReadByte())==s+1&&(n=e.ReadByte()),s=r}while(0!=r);return t}function g(e,t){var i=new Array(256),n=new Array(256);!function(e,t,i){for(var n=0;n<256;n++)t[n]=0;var r=p(e);for(n=0;n<256;n++)r[n]>0&&(t[n]=e.ReadUint7());for(b(t,12),i[0]=0,n=0;n<=255;n++)i[n+1]=i[n]+t[n]}(e,i,n);for(var s=o(n,12),h=new Array(4),c=0;c<4;c++)h[c]=e.ReadUint32();var d=new Buffer.allocUnsafe(t);for(c=0;c<t;c++){var u=c%4,f=s[r(h[u],12)];d[c]=f,h[u]=a(h[u],n[f],i[f],12),h[u]=l(e,h[u])}return d}function m(e,t){for(var i=0,n=0;n<256;n++)i+=e[n];const r=1<<t;var s=r/i;do{var o=0,a=0,l=0;for(i=0,n=0;n<256;n++)0!=e[n]&&(o<e[n]&&(o=e[n],a=n),e[n]=Math.floor(e[n]*s),0==e[n]&&(e[n]=1),i+=e[n]);i<r?e[a]+=r-i:i-r<e[a]/2&&e[a]>2?e[a]-=i-r:i!=r&&(s=r/i,l=1)}while(l)}function b(e,t){for(var i=0,n=0;n<256;n++)i+=e[n];if(0!=i&&i!=1<<t){for(var r=0;i<1<<t;)i*=2,r++;for(n=0;n<256;n++)e[n]<<=r}}function w(e,t){for(var i=0,n=0;n<256;n++)if(t[n])if(i>0)i--;else if(e.WriteByte(n),n>0&&t[n-1]>0){for(i=n+1;i<256&&t[i];i++);i-=n+1,e.WriteByte(i)}e.WriteByte(0)}function v(e){const t=e.length;var i=new n("",0,780),r=new Array(256);!function(e,t){for(var i=0;i<256;i++)t[i]=0;for(i=0;i<e.length;i++)t[e[i]]++}(e,r);var s=Math.ceil(Math.log2(t));s>12&&(s=12),m(r,s),function(e,t){w(e,t);for(var i=0;i<256;i++)t[i]&&e.WriteUint7(t[i])}(i,r),m(r,12);var o=new Array(256);o[0]=0;for(var a=1;a<256;a++)o[a]=o[a-1]+r[a-1];var l=new Array(4);for(a=0;a<4;a++)l[a]=32768;var d=new n("",1.05*t+100>>0,1.05*t+100>>0);for(a=t-1;a>=0;a--)l[a%4]=c(l[a%4],d,o[e[a]],r[e[a]],12);for(a=3;a>=0;a--)h(l[a],d);return Buffer.concat([i.buf.slice(0,i.pos),d.buf.slice(d.pos,d.length)],i.pos+d.length-d.pos)}e.exports={decode:function(e){return u(new n(e),0)},encode:f}},2881:(e,t,i)=>{const n=i(9260),r=i(594);var s=new(i(445));function o(e,t){for(var i=e+"";i.length<t;)i="0"+i;return i}function a(e,t,i,n){var r=e[0][0].ReadByte(),s=n-e[0][r].ReadUint32();if(5==r)return t[n]=t[s],i[n]=i[s],t[n];var a=1;t[n]="",i[n]=new Array(256);do{switch(r=e[a][0].ReadByte()){case 2:i[n][a]=e[a][2].ReadChar();break;case 1:i[n][a]=e[a][1].ReadString();break;case 7:i[n][a]=e[a][7].ReadUint32();break;case 3:var l=e[a][3].ReadUint32(),h=e[a][4].ReadByte();i[n][a]=o(l,h);break;case 8:i[n][a]=(i[s][a]>>0)+e[a][8].ReadByte();break;case 9:l=(i[s][a]>>0)+e[a][9].ReadByte(),h=i[s][a].length,i[n][a]=o(l,h);break;case 10:i[n][a]=i[s][a];break;default:i[n][a]=""}t[n]+=i[n][a++]}while(12!=r);return t[n]}function l(e,t,i,n,r,s){for(var o=0;o<n.length;o++)if(!(i>0&&5==t[o][0].type)&&t[o][i])switch(e[0].WriteByte(t[o][i].type),t[o][i].type){case 6:e[6].WriteUint32(t[o][i].val);break;case 5:e[5].WriteUint32(t[o][i].val);break;case 1:e[1].WriteString(t[o][i].val);break;case 2:e[2].WriteChar(t[o][i].val);break;case 7:e[7].WriteUint32(t[o][i].val);break;case 3:e[3].WriteUint32(t[o][i].val),e[4].WriteByte(t[o][i].val.length);break;case 8:case 9:e[t[o][i].type].WriteByte(t[o][i].val)}}function h(e,t,i,n){for(var r=0;r<=12;r++)if(!(e[r].pos<=0)){n.WriteByte(r+(0==r?128:0)),e[r]=e[r].buf.slice(0,e[r].pos);var s=c(e[r],i);n.WriteUint7(s.length),n.WriteData(s,s.length)}}function c(e,t){var i,n=1<<30,o=[0,1,64,65,128,129,201];for(var a in o){var l=o[a];if(!(1&l&&e.length<100||8&l&&e.length%4!=0)){try{var h=t?s.encode(e,l):r.encode(e,l)}catch(e){h=0}h&&n>h.length&&(n=h.length,i=h)}}return i}function d(e,t,i,n,r){var s=0,o=r-1;e[r]=new Array(256),t[n]?e[r][0]={type:5,val:r-t[n]}:e[r][0]={type:6,val:0==r?0:1},t[n]=r;for(var a=n.match(/([a-zA-Z0-9]{1,9})|([^a-zA-Z0-9]+)/g),l=0;l<a.length;l++){var h=l+1,c=1,d=a[l];if(a[l].match(/^0+[0-9]*$/g)?c=3:a[l].match(/^[0-9]+$/g)?c=7:1==a[l].length&&(c=2),o>=0&&e[o][h])if(e[o][h].str==a[l])c=10,d="";else if(7==e[o][h].type||8==e[o][h].type){var u=d-e[o][h].str;i[h]++,u>=0&&u<256&&i[h]>r/2&&(c=8,d=u)}else 3!=e[o][h].type&&9!=e[o][h].type||e[o][h].str.length!=d.length||(u=d-e[o][h].str,i[h]++,u>=0&&u<256&&i[h]>r/2&&(c=9,d=u));e[r][h]={str:a[l],val:d,type:c},s<e[r][h].val.length+3&&(s=e[r][h].val.length+3)}return e[r][++h]={type:12},[h+1,s]}e.exports={encode:function(e,t){var i=e.toString();"\n"==i[i.length-1]&&(i=i.substring(0,i.length-1));var r=i.split("\n"),s=new n("",0,2*i.length+1e4);s.WriteUint32(i.length),s.WriteUint32(r.length),s.WriteByte(t);for(var o=new Array(r.length),a={},c=new Array(256).fill(0),u=0,f=0,p=0;p<r.length;p++){var[g,m]=d(o,a,c,r[p],p);u<g&&(u=g),f<m&&(f=m)}for(var b=0;b<u;b++){for(var w=new Array(13),v=0;v<=12;v++)w[v]=new n("",0,r.length*f);l(w,o,b,r),h(w,0,t,s)}return s.buf.slice(0,s.pos)},decode:function(e,t,i){(e=new n(e)).ReadUint32();var o=e.ReadUint32(),l=e.ReadByte(),h=function(e,t,i,o){for(var a=-1,l=new Array(256);!e.EOF();){var h=e.ReadByte(),c=128&h,d=64&h,u=63&h;if(c&&(l[++a]=new Array(13)),0!=u&&c){var f=new Array(o-1).fill(10);l[a][0]=new n(Buffer.from([u].concat(f)))}if(d){var p=e.ReadByte(),g=e.ReadByte();l[a][u]=new n(l[p][g].buf)}else{var m=e.ReadUint7(),b=e.ReadData(m);l[a][u]=i?s.decode(b):r.decode(b),l[a][u]=new n(l[a][u])}}return l}(e,0,l,o),c=new Array(o),d=new Array(o),u="";void 0===i&&(i="\n");for(var f=0;f<o;f++)u+=a(h,c,d,f)+i;return u}}},1422:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=i(8904),s=n(i(9049)),o=n(i(450));class a{constructor({fill:e,cache:t}){if("function"!=typeof e)throw new TypeError("must pass a fill function");if("object"!=typeof t)throw new TypeError("must pass a cache object");if("function"!=typeof t.get||"function"!=typeof t.set||"function"!=typeof t.delete)throw new TypeError("cache must implement get(key), set(key, val), and and delete(key)");this.cache=t,this.fillCallback=e}static isAbortException(e){return"AbortError"===e.name||"ERR_ABORTED"===e.code||"AbortError: aborted"===e.message||"Error: aborted"===e.message}evict(e,t){this.cache.get(e)===t&&this.cache.delete(e)}fill(e,t,i,n){const r=new s.default,a=new o.default;a.addCallback(n);const l={aborter:r,promise:this.fillCallback(t,r.signal,(e=>{a.callback(e)})),settled:!1,statusReporter:a,get aborted(){return this.aborter.signal.aborted}};l.aborter.addSignal(i),l.aborter.signal.addEventListener("abort",(()=>{l.settled||this.evict(e,l)})),l.promise.then((()=>{l.settled=!0}),(()=>{l.settled=!0,this.evict(e,l)})).catch((e=>{throw console.error(e),e})),this.cache.set(e,l)}static checkSinglePromise(e,t){function i(){if(t&&t.aborted)throw Object.assign(new Error("aborted"),{code:"ERR_ABORTED"})}return e.then((e=>(i(),e)),(e=>{throw i(),e}))}has(e){return this.cache.has(e)}get(e,t,i,n){if(!i&&t instanceof r.AbortSignal)throw new TypeError("second get argument appears to be an AbortSignal, perhaps you meant to pass `null` for the fill data?");const s=this.cache.get(e);return s?s.aborted&&!s.settled?(this.evict(e,s),this.get(e,t,i,n)):s.settled?s.promise:(s.aborter.addSignal(i),s.statusReporter.addCallback(n),a.checkSinglePromise(s.promise,i)):(this.fill(e,t,i,n),a.checkSinglePromise(this.cache.get(e).promise,i))}delete(e){const t=this.cache.get(e);t&&(t.settled||t.aborter.abort(),this.cache.delete(e))}clear(){const e=this.cache.keys();let t=0;for(let i=e.next();!i.done;i=e.next())this.delete(i.value),t+=1;return t}}t.default=a},9049:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=i(8904);class r{}t.default=class{constructor(){this.signals=new Set,this.abortController=new n.AbortController}addSignal(e=new r){if(this.signal.aborted)throw new Error("cannot add a signal, already aborted!");this.signals.add(e),e.aborted?this.handleAborted(e):"function"==typeof e.addEventListener&&e.addEventListener("abort",(()=>{this.handleAborted(e)}))}handleAborted(e){this.signals.delete(e),0===this.signals.size&&this.abortController.abort()}get signal(){return this.abortController.signal}abort(){this.abortController.abort()}}},450:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(){this.callbacks=new Set}addCallback(e=(()=>{})){this.callbacks.add(e),e(this.currentMessage)}callback(e){this.currentMessage=e,this.callbacks.forEach((t=>{t(e)}))}}},8904:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AbortSignal=t.AbortController=void 0;const n=i(5988);var r=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==i.g)return i.g;throw new Error("unable to locate global object")};let s=void 0===r().AbortController?n.AbortController:r().AbortController;t.AbortController=s;let o=void 0===r().AbortController?n.AbortSignal:r().AbortSignal;t.AbortSignal=o},4105:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=n(i(1422));t.default=r.default},5988:(e,t)=>{function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function r(e,t,i){return t&&n(e.prototype,t),i&&n(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},s(e)}function o(e,t){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},o(e,t)}function a(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function l(){return l="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,i){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=s(e)););return e}(e,t);if(n){var r=Object.getOwnPropertyDescriptor(n,t);return r.get?r.get.call(arguments.length<3?e:i):r.value}},l.apply(this,arguments)}Object.defineProperty(t,"__esModule",{value:!0});var h=function(){function e(){i(this,e),Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}return r(e,[{key:"addEventListener",value:function(e,t,i){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:i})}},{key:"removeEventListener",value:function(e,t){if(e in this.listeners)for(var i=this.listeners[e],n=0,r=i.length;n<r;n++)if(i[n].callback===t)return void i.splice(n,1)}},{key:"dispatchEvent",value:function(e){if(e.type in this.listeners){for(var t=this.listeners[e.type].slice(),i=0,n=t.length;i<n;i++){var r=t[i];try{r.callback.call(this,e)}catch(e){Promise.resolve().then((function(){throw e}))}r.options&&r.options.once&&this.removeEventListener(e.type,r.callback)}return!e.defaultPrevented}}}]),e}(),c=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&o(e,t)}(d,e);var t,n,c=(t=d,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,i=s(t);if(n){var r=s(this).constructor;e=Reflect.construct(i,arguments,r)}else e=i.apply(this,arguments);return function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return a(e)}(this,e)});function d(){var e;return i(this,d),(e=c.call(this)).listeners||h.call(a(e)),Object.defineProperty(a(e),"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(a(e),"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(a(e),"reason",{value:void 0,writable:!0,configurable:!0}),e}return r(d,[{key:"toString",value:function(){return"[object AbortSignal]"}},{key:"dispatchEvent",value:function(e){"abort"===e.type&&(this.aborted=!0,"function"==typeof this.onabort&&this.onabort.call(this,e)),l(s(d.prototype),"dispatchEvent",this).call(this,e)}}]),d}(h),d=function(){function e(){i(this,e),Object.defineProperty(this,"signal",{value:new c,writable:!0,configurable:!0})}return r(e,[{key:"abort",value:function(e){var t;try{t=new Event("abort")}catch(e){"undefined"!=typeof document?document.createEvent?(t=document.createEvent("Event")).initEvent("abort",!1,!1):(t=document.createEventObject()).type="abort":t={type:"abort",bubbles:!1,cancelable:!1}}var i=e;if(void 0===i)if("undefined"==typeof document)(i=new Error("This operation was aborted")).name="AbortError";else try{i=new DOMException("signal is aborted without reason")}catch(e){(i=new Error("This operation was aborted")).name="AbortError"}this.signal.reason=i,this.signal.dispatchEvent(t)}},{key:"toString",value:function(){return"[object AbortController]"}}]),e}();"undefined"!=typeof Symbol&&Symbol.toStringTag&&(d.prototype[Symbol.toStringTag]="AbortController",c.prototype[Symbol.toStringTag]="AbortSignal"),t.AbortController=d,t.AbortSignal=c,t.abortableFetch=function(e){"function"==typeof e&&(e={fetch:e});var t=e,i=t.fetch,n=t.Request,r=void 0===n?i.Request:n,s=t.AbortController,o=t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL,a=void 0!==o&&o;if(!function(e){return e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):"function"==typeof e.Request&&!e.Request.prototype.hasOwnProperty("signal")||!e.AbortController}({fetch:i,Request:r,AbortController:s,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:a}))return{fetch:i,Request:l};var l=r;(l&&!l.prototype.hasOwnProperty("signal")||a)&&((l=function(e,t){var i;t&&t.signal&&(i=t.signal,delete t.signal);var n=new r(e,t);return i&&Object.defineProperty(n,"signal",{writable:!1,enumerable:!1,configurable:!0,value:i}),n}).prototype=r.prototype);var h=i;return{fetch:function(e,t){var i=l&&l.prototype.isPrototypeOf(e)?e.signal:t?t.signal:void 0;if(i){var n;try{n=new DOMException("Aborted","AbortError")}catch(e){(n=new Error("Aborted")).name="AbortError"}if(i.aborted)return Promise.reject(n);var r=new Promise((function(e,t){i.addEventListener("abort",(function(){return t(n)}),{once:!0})}));return t&&t.signal&&delete t.signal,Promise.race([r,h(e,t)])}return h(e,t)},Request:l}}},9742:(e,t)=>{t.byteLength=function(e){var t=a(e),i=t[0],n=t[1];return 3*(i+n)/4-n},t.toByteArray=function(e){var t,i,s=a(e),o=s[0],l=s[1],h=new r(function(e,t,i){return 3*(t+i)/4-i}(0,o,l)),c=0,d=l>0?o-4:o;for(i=0;i<d;i+=4)t=n[e.charCodeAt(i)]<<18|n[e.charCodeAt(i+1)]<<12|n[e.charCodeAt(i+2)]<<6|n[e.charCodeAt(i+3)],h[c++]=t>>16&255,h[c++]=t>>8&255,h[c++]=255&t;return 2===l&&(t=n[e.charCodeAt(i)]<<2|n[e.charCodeAt(i+1)]>>4,h[c++]=255&t),1===l&&(t=n[e.charCodeAt(i)]<<10|n[e.charCodeAt(i+1)]<<4|n[e.charCodeAt(i+2)]>>2,h[c++]=t>>8&255,h[c++]=255&t),h},t.fromByteArray=function(e){for(var t,n=e.length,r=n%3,s=[],o=16383,a=0,h=n-r;a<h;a+=o)s.push(l(e,a,a+o>h?h:a+o));return 1===r?(t=e[n-1],s.push(i[t>>2]+i[t<<4&63]+"==")):2===r&&(t=(e[n-2]<<8)+e[n-1],s.push(i[t>>10]+i[t>>4&63]+i[t<<2&63]+"=")),s.join("")};for(var i=[],n=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0;o<64;++o)i[o]=s[o],n[s.charCodeAt(o)]=o;function a(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var i=e.indexOf("=");return-1===i&&(i=t),[i,i===t?0:4-i%4]}function l(e,t,n){for(var r,s,o=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(i[(s=r)>>18&63]+i[s>>12&63]+i[s>>6&63]+i[63&s]);return o.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},2779:(e,t,i)=>{var n=i(8764).Buffer,r=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];function s(e){if(n.isBuffer(e))return e;var t="function"==typeof n.alloc&&"function"==typeof n.from;if("number"==typeof e)return t?n.alloc(e):new n(e);if("string"==typeof e)return t?n.from(e):new n(e);throw new Error("input must be buffer, number, or string, received "+typeof e)}function o(e,t){e=s(e),n.isBuffer(t)&&(t=t.readUInt32BE(0));for(var i=-1^~~t,o=0;o<e.length;o++)i=r[255&(i^e[o])]^i>>>8;return-1^i}function a(){return function(e){var t=s(4);return t.writeInt32BE(e,0),t}(o.apply(null,arguments))}"undefined"!=typeof Int32Array&&(r=new Int32Array(r)),a.signed=function(){return o.apply(null,arguments)},a.unsigned=function(){return o.apply(null,arguments)>>>0},e.exports=a},8764:(e,t,i)=>{const n=i(9742),r=i(645),s="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=l,t.SlowBuffer=function(e){return+e!=e&&(e=0),l.alloc(+e)},t.INSPECT_MAX_BYTES=50;const o=2147483647;function a(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,l.prototype),t}function l(e,t,i){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return d(e)}return h(e,t,i)}function h(e,t,i){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!l.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const i=0|g(e,t);let n=a(i);const r=n.write(e,t);return r!==i&&(n=n.slice(0,r)),n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(Q(e,Uint8Array)){const t=new Uint8Array(e);return f(t.buffer,t.byteOffset,t.byteLength)}return u(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(Q(e,ArrayBuffer)||e&&Q(e.buffer,ArrayBuffer))return f(e,t,i);if("undefined"!=typeof SharedArrayBuffer&&(Q(e,SharedArrayBuffer)||e&&Q(e.buffer,SharedArrayBuffer)))return f(e,t,i);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return l.from(n,t,i);const r=function(e){if(l.isBuffer(e)){const t=0|p(e.length),i=a(t);return 0===i.length||e.copy(i,0,0,t),i}return void 0!==e.length?"number"!=typeof e.length||X(e.length)?a(0):u(e):"Buffer"===e.type&&Array.isArray(e.data)?u(e.data):void 0}(e);if(r)return r;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return l.from(e[Symbol.toPrimitive]("string"),t,i);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function c(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function d(e){return c(e),a(e<0?0:0|p(e))}function u(e){const t=e.length<0?0:0|p(e.length),i=a(t);for(let n=0;n<t;n+=1)i[n]=255&e[n];return i}function f(e,t,i){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(i||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===t&&void 0===i?new Uint8Array(e):void 0===i?new Uint8Array(e,t):new Uint8Array(e,t,i),Object.setPrototypeOf(n,l.prototype),n}function p(e){if(e>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function g(e,t){if(l.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Q(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const i=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===i)return 0;let r=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return W(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return G(e).length;default:if(r)return n?-1:W(e).length;t=(""+t).toLowerCase(),r=!0}}function m(e,t,i){let n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return R(this,t,i);case"utf8":case"utf-8":return A(this,t,i);case"ascii":return M(this,t,i);case"latin1":case"binary":return T(this,t,i);case"base64":return S(this,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,t,i);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function b(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function w(e,t,i,n,r){if(0===e.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),X(i=+i)&&(i=r?0:e.length-1),i<0&&(i=e.length+i),i>=e.length){if(r)return-1;i=e.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof t&&(t=l.from(t,n)),l.isBuffer(t))return 0===t.length?-1:v(e,t,i,n,r);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(e,t,i):Uint8Array.prototype.lastIndexOf.call(e,t,i):v(e,[t],i,n,r);throw new TypeError("val must be string, number or Buffer")}function v(e,t,i,n,r){let s,o=1,a=e.length,l=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;o=2,a/=2,l/=2,i/=2}function h(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(r){let n=-1;for(s=i;s<a;s++)if(h(e,s)===h(t,-1===n?0:s-n)){if(-1===n&&(n=s),s-n+1===l)return n*o}else-1!==n&&(s-=s-n),n=-1}else for(i+l>a&&(i=a-l),s=i;s>=0;s--){let i=!0;for(let n=0;n<l;n++)if(h(e,s+n)!==h(t,n)){i=!1;break}if(i)return s}return-1}function y(e,t,i,n){i=Number(i)||0;const r=e.length-i;n?(n=Number(n))>r&&(n=r):n=r;const s=t.length;let o;for(n>s/2&&(n=s/2),o=0;o<n;++o){const n=parseInt(t.substr(2*o,2),16);if(X(n))return o;e[i+o]=n}return o}function _(e,t,i,n){return Z(W(t,e.length-i),e,i,n)}function x(e,t,i,n){return Z(function(e){const t=[];for(let i=0;i<e.length;++i)t.push(255&e.charCodeAt(i));return t}(t),e,i,n)}function k(e,t,i,n){return Z(G(t),e,i,n)}function C(e,t,i,n){return Z(function(e,t){let i,n,r;const s=[];for(let o=0;o<e.length&&!((t-=2)<0);++o)i=e.charCodeAt(o),n=i>>8,r=i%256,s.push(r),s.push(n);return s}(t,e.length-i),e,i,n)}function S(e,t,i){return 0===t&&i===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,i))}function A(e,t,i){i=Math.min(e.length,i);const n=[];let r=t;for(;r<i;){const t=e[r];let s=null,o=t>239?4:t>223?3:t>191?2:1;if(r+o<=i){let i,n,a,l;switch(o){case 1:t<128&&(s=t);break;case 2:i=e[r+1],128==(192&i)&&(l=(31&t)<<6|63&i,l>127&&(s=l));break;case 3:i=e[r+1],n=e[r+2],128==(192&i)&&128==(192&n)&&(l=(15&t)<<12|(63&i)<<6|63&n,l>2047&&(l<55296||l>57343)&&(s=l));break;case 4:i=e[r+1],n=e[r+2],a=e[r+3],128==(192&i)&&128==(192&n)&&128==(192&a)&&(l=(15&t)<<18|(63&i)<<12|(63&n)<<6|63&a,l>65535&&l<1114112&&(s=l))}}null===s?(s=65533,o=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),r+=o}return function(e){const t=e.length;if(t<=E)return String.fromCharCode.apply(String,e);let i="",n=0;for(;n<t;)i+=String.fromCharCode.apply(String,e.slice(n,n+=E));return i}(n)}t.kMaxLength=o,l.TYPED_ARRAY_SUPPORT=function(){try{const e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),l.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(l.prototype,"parent",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.buffer}}),Object.defineProperty(l.prototype,"offset",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.byteOffset}}),l.poolSize=8192,l.from=function(e,t,i){return h(e,t,i)},Object.setPrototypeOf(l.prototype,Uint8Array.prototype),Object.setPrototypeOf(l,Uint8Array),l.alloc=function(e,t,i){return function(e,t,i){return c(e),e<=0?a(e):void 0!==t?"string"==typeof i?a(e).fill(t,i):a(e).fill(t):a(e)}(e,t,i)},l.allocUnsafe=function(e){return d(e)},l.allocUnsafeSlow=function(e){return d(e)},l.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==l.prototype},l.compare=function(e,t){if(Q(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),Q(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),!l.isBuffer(e)||!l.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let i=e.length,n=t.length;for(let r=0,s=Math.min(i,n);r<s;++r)if(e[r]!==t[r]){i=e[r],n=t[r];break}return i<n?-1:n<i?1:0},l.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},l.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return l.alloc(0);let i;if(void 0===t)for(t=0,i=0;i<e.length;++i)t+=e[i].length;const n=l.allocUnsafe(t);let r=0;for(i=0;i<e.length;++i){let t=e[i];if(Q(t,Uint8Array))r+t.length>n.length?(l.isBuffer(t)||(t=l.from(t)),t.copy(n,r)):Uint8Array.prototype.set.call(n,t,r);else{if(!l.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(n,r)}r+=t.length}return n},l.byteLength=g,l.prototype._isBuffer=!0,l.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)b(this,t,t+1);return this},l.prototype.swap32=function(){const e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)b(this,t,t+3),b(this,t+1,t+2);return this},l.prototype.swap64=function(){const e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)b(this,t,t+7),b(this,t+1,t+6),b(this,t+2,t+5),b(this,t+3,t+4);return this},l.prototype.toString=function(){const e=this.length;return 0===e?"":0===arguments.length?A(this,0,e):m.apply(this,arguments)},l.prototype.toLocaleString=l.prototype.toString,l.prototype.equals=function(e){if(!l.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===l.compare(this,e)},l.prototype.inspect=function(){let e="";const i=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(e+=" ... "),"<Buffer "+e+">"},s&&(l.prototype[s]=l.prototype.inspect),l.prototype.compare=function(e,t,i,n,r){if(Q(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),!l.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===i&&(i=e?e.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),t<0||i>e.length||n<0||r>this.length)throw new RangeError("out of range index");if(n>=r&&t>=i)return 0;if(n>=r)return-1;if(t>=i)return 1;if(this===e)return 0;let s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(t>>>=0);const a=Math.min(s,o),h=this.slice(n,r),c=e.slice(t,i);for(let e=0;e<a;++e)if(h[e]!==c[e]){s=h[e],o=c[e];break}return s<o?-1:o<s?1:0},l.prototype.includes=function(e,t,i){return-1!==this.indexOf(e,t,i)},l.prototype.indexOf=function(e,t,i){return w(this,e,t,i,!0)},l.prototype.lastIndexOf=function(e,t,i){return w(this,e,t,i,!1)},l.prototype.write=function(e,t,i,n){if(void 0===t)n="utf8",i=this.length,t=0;else if(void 0===i&&"string"==typeof t)n=t,i=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(i)?(i>>>=0,void 0===n&&(n="utf8")):(n=i,i=void 0)}const r=this.length-t;if((void 0===i||i>r)&&(i=r),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let s=!1;for(;;)switch(n){case"hex":return y(this,e,t,i);case"utf8":case"utf-8":return _(this,e,t,i);case"ascii":case"latin1":case"binary":return x(this,e,t,i);case"base64":return k(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,t,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const E=4096;function M(e,t,i){let n="";i=Math.min(e.length,i);for(let r=t;r<i;++r)n+=String.fromCharCode(127&e[r]);return n}function T(e,t,i){let n="";i=Math.min(e.length,i);for(let r=t;r<i;++r)n+=String.fromCharCode(e[r]);return n}function R(e,t,i){const n=e.length;(!t||t<0)&&(t=0),(!i||i<0||i>n)&&(i=n);let r="";for(let n=t;n<i;++n)r+=Y[e[n]];return r}function L(e,t,i){const n=e.slice(t,i);let r="";for(let e=0;e<n.length-1;e+=2)r+=String.fromCharCode(n[e]+256*n[e+1]);return r}function I(e,t,i){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>i)throw new RangeError("Trying to access beyond buffer length")}function B(e,t,i,n,r,s){if(!l.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>r||t<s)throw new RangeError('"value" argument is out of bounds');if(i+n>e.length)throw new RangeError("Index out of range")}function F(e,t,i,n,r){U(t,n,r,e,i,7);let s=Number(t&BigInt(4294967295));e[i++]=s,s>>=8,e[i++]=s,s>>=8,e[i++]=s,s>>=8,e[i++]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[i++]=o,o>>=8,e[i++]=o,o>>=8,e[i++]=o,o>>=8,e[i++]=o,i}function N(e,t,i,n,r){U(t,n,r,e,i,7);let s=Number(t&BigInt(4294967295));e[i+7]=s,s>>=8,e[i+6]=s,s>>=8,e[i+5]=s,s>>=8,e[i+4]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[i+3]=o,o>>=8,e[i+2]=o,o>>=8,e[i+1]=o,o>>=8,e[i]=o,i+8}function O(e,t,i,n,r,s){if(i+n>e.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function P(e,t,i,n,s){return t=+t,i>>>=0,s||O(e,0,i,4),r.write(e,t,i,n,23,4),i+4}function D(e,t,i,n,s){return t=+t,i>>>=0,s||O(e,0,i,8),r.write(e,t,i,n,52,8),i+8}l.prototype.slice=function(e,t){const i=this.length;(e=~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),(t=void 0===t?i:~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),t<e&&(t=e);const n=this.subarray(e,t);return Object.setPrototypeOf(n,l.prototype),n},l.prototype.readUintLE=l.prototype.readUIntLE=function(e,t,i){e>>>=0,t>>>=0,i||I(e,t,this.length);let n=this[e],r=1,s=0;for(;++s<t&&(r*=256);)n+=this[e+s]*r;return n},l.prototype.readUintBE=l.prototype.readUIntBE=function(e,t,i){e>>>=0,t>>>=0,i||I(e,t,this.length);let n=this[e+--t],r=1;for(;t>0&&(r*=256);)n+=this[e+--t]*r;return n},l.prototype.readUint8=l.prototype.readUInt8=function(e,t){return e>>>=0,t||I(e,1,this.length),this[e]},l.prototype.readUint16LE=l.prototype.readUInt16LE=function(e,t){return e>>>=0,t||I(e,2,this.length),this[e]|this[e+1]<<8},l.prototype.readUint16BE=l.prototype.readUInt16BE=function(e,t){return e>>>=0,t||I(e,2,this.length),this[e]<<8|this[e+1]},l.prototype.readUint32LE=l.prototype.readUInt32LE=function(e,t){return e>>>=0,t||I(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},l.prototype.readUint32BE=l.prototype.readUInt32BE=function(e,t){return e>>>=0,t||I(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},l.prototype.readBigUInt64LE=K((function(e){q(e>>>=0,"offset");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||j(e,this.length-8);const n=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,r=this[++e]+256*this[++e]+65536*this[++e]+i*2**24;return BigInt(n)+(BigInt(r)<<BigInt(32))})),l.prototype.readBigUInt64BE=K((function(e){q(e>>>=0,"offset");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||j(e,this.length-8);const n=t*2**24+65536*this[++e]+256*this[++e]+this[++e],r=this[++e]*2**24+65536*this[++e]+256*this[++e]+i;return(BigInt(n)<<BigInt(32))+BigInt(r)})),l.prototype.readIntLE=function(e,t,i){e>>>=0,t>>>=0,i||I(e,t,this.length);let n=this[e],r=1,s=0;for(;++s<t&&(r*=256);)n+=this[e+s]*r;return r*=128,n>=r&&(n-=Math.pow(2,8*t)),n},l.prototype.readIntBE=function(e,t,i){e>>>=0,t>>>=0,i||I(e,t,this.length);let n=t,r=1,s=this[e+--n];for(;n>0&&(r*=256);)s+=this[e+--n]*r;return r*=128,s>=r&&(s-=Math.pow(2,8*t)),s},l.prototype.readInt8=function(e,t){return e>>>=0,t||I(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},l.prototype.readInt16LE=function(e,t){e>>>=0,t||I(e,2,this.length);const i=this[e]|this[e+1]<<8;return 32768&i?4294901760|i:i},l.prototype.readInt16BE=function(e,t){e>>>=0,t||I(e,2,this.length);const i=this[e+1]|this[e]<<8;return 32768&i?4294901760|i:i},l.prototype.readInt32LE=function(e,t){return e>>>=0,t||I(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},l.prototype.readInt32BE=function(e,t){return e>>>=0,t||I(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},l.prototype.readBigInt64LE=K((function(e){q(e>>>=0,"offset");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||j(e,this.length-8);const n=this[e+4]+256*this[e+5]+65536*this[e+6]+(i<<24);return(BigInt(n)<<BigInt(32))+BigInt(t+256*this[++e]+65536*this[++e]+this[++e]*2**24)})),l.prototype.readBigInt64BE=K((function(e){q(e>>>=0,"offset");const t=this[e],i=this[e+7];void 0!==t&&void 0!==i||j(e,this.length-8);const n=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(n)<<BigInt(32))+BigInt(this[++e]*2**24+65536*this[++e]+256*this[++e]+i)})),l.prototype.readFloatLE=function(e,t){return e>>>=0,t||I(e,4,this.length),r.read(this,e,!0,23,4)},l.prototype.readFloatBE=function(e,t){return e>>>=0,t||I(e,4,this.length),r.read(this,e,!1,23,4)},l.prototype.readDoubleLE=function(e,t){return e>>>=0,t||I(e,8,this.length),r.read(this,e,!0,52,8)},l.prototype.readDoubleBE=function(e,t){return e>>>=0,t||I(e,8,this.length),r.read(this,e,!1,52,8)},l.prototype.writeUintLE=l.prototype.writeUIntLE=function(e,t,i,n){e=+e,t>>>=0,i>>>=0,n||B(this,e,t,i,Math.pow(2,8*i)-1,0);let r=1,s=0;for(this[t]=255&e;++s<i&&(r*=256);)this[t+s]=e/r&255;return t+i},l.prototype.writeUintBE=l.prototype.writeUIntBE=function(e,t,i,n){e=+e,t>>>=0,i>>>=0,n||B(this,e,t,i,Math.pow(2,8*i)-1,0);let r=i-1,s=1;for(this[t+r]=255&e;--r>=0&&(s*=256);)this[t+r]=e/s&255;return t+i},l.prototype.writeUint8=l.prototype.writeUInt8=function(e,t,i){return e=+e,t>>>=0,i||B(this,e,t,1,255,0),this[t]=255&e,t+1},l.prototype.writeUint16LE=l.prototype.writeUInt16LE=function(e,t,i){return e=+e,t>>>=0,i||B(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},l.prototype.writeUint16BE=l.prototype.writeUInt16BE=function(e,t,i){return e=+e,t>>>=0,i||B(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},l.prototype.writeUint32LE=l.prototype.writeUInt32LE=function(e,t,i){return e=+e,t>>>=0,i||B(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},l.prototype.writeUint32BE=l.prototype.writeUInt32BE=function(e,t,i){return e=+e,t>>>=0,i||B(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},l.prototype.writeBigUInt64LE=K((function(e,t=0){return F(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),l.prototype.writeBigUInt64BE=K((function(e,t=0){return N(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),l.prototype.writeIntLE=function(e,t,i,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*i-1);B(this,e,t,i,n-1,-n)}let r=0,s=1,o=0;for(this[t]=255&e;++r<i&&(s*=256);)e<0&&0===o&&0!==this[t+r-1]&&(o=1),this[t+r]=(e/s>>0)-o&255;return t+i},l.prototype.writeIntBE=function(e,t,i,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*i-1);B(this,e,t,i,n-1,-n)}let r=i-1,s=1,o=0;for(this[t+r]=255&e;--r>=0&&(s*=256);)e<0&&0===o&&0!==this[t+r+1]&&(o=1),this[t+r]=(e/s>>0)-o&255;return t+i},l.prototype.writeInt8=function(e,t,i){return e=+e,t>>>=0,i||B(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},l.prototype.writeInt16LE=function(e,t,i){return e=+e,t>>>=0,i||B(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},l.prototype.writeInt16BE=function(e,t,i){return e=+e,t>>>=0,i||B(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},l.prototype.writeInt32LE=function(e,t,i){return e=+e,t>>>=0,i||B(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},l.prototype.writeInt32BE=function(e,t,i){return e=+e,t>>>=0,i||B(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},l.prototype.writeBigInt64LE=K((function(e,t=0){return F(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),l.prototype.writeBigInt64BE=K((function(e,t=0){return N(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),l.prototype.writeFloatLE=function(e,t,i){return P(this,e,t,!0,i)},l.prototype.writeFloatBE=function(e,t,i){return P(this,e,t,!1,i)},l.prototype.writeDoubleLE=function(e,t,i){return D(this,e,t,!0,i)},l.prototype.writeDoubleBE=function(e,t,i){return D(this,e,t,!1,i)},l.prototype.copy=function(e,t,i,n){if(!l.isBuffer(e))throw new TypeError("argument should be a Buffer");if(i||(i=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<i&&(n=i),n===i)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-i&&(n=e.length-t+i);const r=n-i;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,i,n):Uint8Array.prototype.set.call(e,this.subarray(i,n),t),r},l.prototype.fill=function(e,t,i,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,i=this.length):"string"==typeof i&&(n=i,i=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!l.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){const t=e.charCodeAt(0);("utf8"===n&&t<128||"latin1"===n)&&(e=t)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;let r;if(t>>>=0,i=void 0===i?this.length:i>>>0,e||(e=0),"number"==typeof e)for(r=t;r<i;++r)this[r]=e;else{const s=l.isBuffer(e)?e:l.from(e,n),o=s.length;if(0===o)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(r=0;r<i-t;++r)this[r+t]=s[r%o]}return this};const z={};function H(e,t,i){z[e]=class extends i{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}function V(e){let t="",i=e.length;const n="-"===e[0]?1:0;for(;i>=n+4;i-=3)t=`_${e.slice(i-3,i)}${t}`;return`${e.slice(0,i)}${t}`}function U(e,t,i,n,r,s){if(e>i||e<t){const n="bigint"==typeof t?"n":"";let r;throw r=s>3?0===t||t===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(s+1)}${n}`:`>= -(2${n} ** ${8*(s+1)-1}${n}) and < 2 ** ${8*(s+1)-1}${n}`:`>= ${t}${n} and <= ${i}${n}`,new z.ERR_OUT_OF_RANGE("value",r,e)}!function(e,t,i){q(t,"offset"),void 0!==e[t]&&void 0!==e[t+i]||j(t,e.length-(i+1))}(n,r,s)}function q(e,t){if("number"!=typeof e)throw new z.ERR_INVALID_ARG_TYPE(t,"number",e)}function j(e,t,i){if(Math.floor(e)!==e)throw q(e,i),new z.ERR_OUT_OF_RANGE(i||"offset","an integer",e);if(t<0)throw new z.ERR_BUFFER_OUT_OF_BOUNDS;throw new z.ERR_OUT_OF_RANGE(i||"offset",`>= ${i?1:0} and <= ${t}`,e)}H("ERR_BUFFER_OUT_OF_BOUNDS",(function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),H("ERR_INVALID_ARG_TYPE",(function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`}),TypeError),H("ERR_OUT_OF_RANGE",(function(e,t,i){let n=`The value of "${e}" is out of range.`,r=i;return Number.isInteger(i)&&Math.abs(i)>2**32?r=V(String(i)):"bigint"==typeof i&&(r=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(r=V(r)),r+="n"),n+=` It must be ${t}. Received ${r}`,n}),RangeError);const $=/[^+/0-9A-Za-z-_]/g;function W(e,t){let i;t=t||1/0;const n=e.length;let r=null;const s=[];for(let o=0;o<n;++o){if(i=e.charCodeAt(o),i>55295&&i<57344){if(!r){if(i>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(t-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(t-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((t-=1)<0)break;s.push(i)}else if(i<2048){if((t-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((t-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function G(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace($,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Z(e,t,i,n){let r;for(r=0;r<n&&!(r+i>=t.length||r>=e.length);++r)t[r+i]=e[r];return r}function Q(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function X(e){return e!=e}const Y=function(){const e="0123456789abcdef",t=new Array(256);for(let i=0;i<16;++i){const n=16*i;for(let r=0;r<16;++r)t[n+r]=e[i]+e[r]}return t}();function K(e){return"undefined"==typeof BigInt?J:e}function J(){throw new Error("BigInt not supported")}},4693:e=>{var t={array:function(e){var t=0,i=0,n=[0,1,3,7,15,31,63,127,255];return function(r){for(var s=0;r>0;){var o=8-t;r>=o?(s<<=o,s|=n[o]&e[i++],t=0,r-=o):(s<<=r,s|=(e[i]&n[r]<<8-r-t)>>8-r-t,t+=r,r=0)}return s}},simple:function(e){var i,n,r=t.header(e),s=[],o=0;do{-1!=(n=t.decompress(e,r))&&(s.push(n),o+=n.byteLength)}while(-1!=n);i=new Uint8Array(o),o=0;for(var a=0;a<s.length;++a)n=s[a],i.set(n,o),o+=n.byteLength;return i},header:function(e){if(4348520!=e(24))throw"No magic number found";var t=e(8)-48;if(t<1||t>9)throw"Not a BZIP archive";return t},decompress:function(e,t,i){for(var n=9e5,r="",s=0;s<6;s++)r+=e(8).toString(16);if("177245385090"==r)return-1;if("314159265359"!=r)throw"eek not valid bzip data";if(e(32),e(1))throw"unsupported obsolete version";var o=e(24);if(o>n)throw"Initial position larger than buffer size";var a=e(16),l=new Uint8Array(256),h=0;for(s=0;s<16;s++)if(a&1<<15-s){var c=e(16);for(g=0;g<16;g++)c&1<<15-g&&(l[h++]=16*s+g)}var d=e(3);if(d<2||d>6)throw"another error";var u=e(15);if(0==u)throw"meh";var f=[];for(s=0;s<d;s++)f[s]=s;var p=new Uint8Array(32768);for(s=0;s<u;s++){for(var g=0;e(1);g++)if(g>=d)throw"whoops another error";var m=f[g];f.splice(g,1),f.splice(0,0,m),p[s]=m}var b=h+2,w=[];for(g=0;g<d;g++){var v,y,_,x=new Uint8Array(258),k=new Uint8Array(21);for(a=e(5),s=0;s<b;s++){for(;;){if(a<1||a>20)throw"I gave up a while ago on writing error messages";if(!e(1))break;e(1)?a--:a++}x[s]=a}for(v=y=x[0],s=1;s<b;s++)x[s]>y?y=x[s]:x[s]<v&&(v=x[s]);(_=w[g]={}).permute=new Uint32Array(258),_.limit=new Uint32Array(21),_.base=new Uint32Array(21),_.minLen=v,_.maxLen=y;var C=_.base.subarray(1),S=_.limit.subarray(1),A=0;for(s=v;s<=y;s++)for(a=0;a<b;a++)x[a]==s&&(_.permute[A++]=a);for(s=v;s<=y;s++)k[s]=S[s]=0;for(s=0;s<b;s++)k[x[s]]++;for(A=a=0,s=v;s<y;s++)A+=k[s],S[s]=A-1,A<<=1,C[s+1]=A-(a+=k[s]);S[y]=A+k[y]-1,C[v]=0}var E,M,T,R=new Uint32Array(256);for(s=0;s<256;s++)f[s]=s;E=M=b=T=0;for(var L=new Uint32Array(n);;){if(!b--){if(b=49,T>=u)throw"meow i'm a kitty, that's an error";C=(_=w[p[T++]]).base.subarray(1),S=_.limit.subarray(1)}for(g=e(s=_.minLen);;){if(s>_.maxLen)throw"rawr i'm a dinosaur";if(g<=S[s])break;s++,g=g<<1|e(1)}if((g-=C[s])<0||g>=258)throw"moo i'm a cow";var I=_.permute[g];if(0!=I&&1!=I){if(E){if(E=0,M+a>=n)throw"Boom.";for(R[m=l[f[0]]]+=a;a--;)L[M++]=m}if(I>h)break;if(M>=n)throw"I can't think of anything. Error";m=f[s=I-1],f.splice(s,1),f.splice(0,0,m),R[m=l[m]]++,L[M++]=m}else E||(E=1,a=0),a+=0==I?E:2*E,E<<=1}if(o<0||o>=M)throw"I'm a monkey and I'm throwing something at someone, namely you";for(g=0,s=0;s<256;s++)c=g+R[s],R[s]=g,g=c;for(s=0;s<M;s++)L[R[m=255&L[s]]]|=s<<8,R[m]++;var B=0,F=0,N=0;M&&(F=255&(B=L[o]),B>>=8,N=-1);var O,P,D,z=new Uint8Array(n),H=0;for(i||(i=1/0);M;){for(M--,P=F,F=255&(B=L[B]),B>>=8,3==N++?(O=F,D=P,F=-1):(O=1,D=F);O--;)if(z[H++]=D,!--i)return z;F!=P&&(N=0)}return z.subarray(0,H)}};e.exports=t},487:e=>{var t={utf8:{stringToBytes:function(e){return t.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(t.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],i=0;i<e.length;i++)t.push(255&e.charCodeAt(i));return t},bytesToString:function(e){for(var t=[],i=0;i<e.length;i++)t.push(String.fromCharCode(e[i]));return t.join("")}}};e.exports=t},1012:e=>{var t,i;t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i={rotl:function(e,t){return e<<t|e>>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&i.rotl(e,8)|4278255360&i.rotl(e,24);for(var t=0;t<e.length;t++)e[t]=i.endian(e[t]);return e},randomBytes:function(e){for(var t=[];e>0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],i=0,n=0;i<e.length;i++,n+=8)t[n>>>5]|=e[i]<<24-n%32;return t},wordsToBytes:function(e){for(var t=[],i=0;i<32*e.length;i+=8)t.push(e[i>>>5]>>>24-i%32&255);return t},bytesToHex:function(e){for(var t=[],i=0;i<e.length;i++)t.push((e[i]>>>4).toString(16)),t.push((15&e[i]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],i=0;i<e.length;i+=2)t.push(parseInt(e.substr(i,2),16));return t},bytesToBase64:function(e){for(var i=[],n=0;n<e.length;n+=3)for(var r=e[n]<<16|e[n+1]<<8|e[n+2],s=0;s<4;s++)8*n+6*s<=8*e.length?i.push(t.charAt(r>>>6*(3-s)&63)):i.push("=");return i.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var i=[],n=0,r=0;n<e.length;r=++n%4)0!=r&&i.push((t.indexOf(e.charAt(n-1))&Math.pow(2,-2*r+8)-1)<<2*r|t.indexOf(e.charAt(n))>>>6-2*r);return i}},e.exports=i},2949:(e,t,i)=>{i.r(t),i.d(t,{BlobFile:()=>h,LocalFile:()=>r(),RemoteFile:()=>a,fromUrl:()=>c,open:()=>d});var n=i(7067),r=i.n(n),s=i(8764);const o="undefined"!=typeof window?window:"undefined"!=typeof self?self:{fetch:void 0};class a{constructor(e,t={}){this.baseOverrides={},this.url=e;const i=t.fetch||o.fetch&&o.fetch.bind(o);if(!i)throw new TypeError("no fetch function supplied, and none found in global environment");t.overrides&&(this.baseOverrides=t.overrides),this.fetchImplementation=i}async getBufferFromResponse(e){if("function"==typeof e.buffer)return e.buffer();if("function"==typeof e.arrayBuffer){const t=await e.arrayBuffer();return s.Buffer.from(t)}throw new TypeError("invalid HTTP response object, has no buffer method, and no arrayBuffer method")}async fetch(e,t){let i;try{i=await this.fetchImplementation(e,t)}catch(n){if(!`${n}`.includes("Failed to fetch"))throw n;console.warn(`generic-filehandle: refetching ${e} to attempt to work around chrome CORS header caching bug`),i=await this.fetchImplementation(e,{...t,cache:"reload"})}return i}async read(e,t=0,i,n=0,r={}){const{headers:s={},signal:o,overrides:a={}}=r;i<1/0?s.range=`bytes=${n}-${n+i}`:i===1/0&&0!==n&&(s.range=`bytes=${n}-`);const l={...this.baseOverrides,...a,headers:{...s,...a.headers,...this.baseOverrides.headers},method:"GET",redirect:"follow",mode:"cors",signal:o},h=await this.fetch(this.url,l);if(!h.ok)throw new Error(`HTTP ${h.status} ${h.statusText} ${this.url}`);if(200===h.status&&0===n||206===h.status){const n=await this.getBufferFromResponse(h),r=n.copy(e,t,0,Math.min(i,n.length)),s=h.headers.get("content-range"),o=/\/(\d+)$/.exec(s||"");return o&&o[1]&&(this._stat={size:parseInt(o[1],10)}),{bytesRead:r,buffer:e}}if(200===h.status)throw new Error("${this.url} fetch returned status 200, expected 206");throw new Error(`HTTP ${h.status} fetching ${this.url}`)}async readFile(e={}){let t,i;"string"==typeof e?(t=e,i={}):(t=e.encoding,i=e,delete i.encoding);const{headers:n={},signal:r,overrides:s={}}=i,o={headers:n,method:"GET",redirect:"follow",mode:"cors",signal:r,...this.baseOverrides,...s},a=await this.fetch(this.url,o);if(!a)throw new Error("generic-filehandle failed to fetch");if(200!==a.status)throw Object.assign(new Error(`HTTP ${a.status} fetching ${this.url}`),{status:a.status});if("utf8"===t)return a.text();if(t)throw new Error(`unsupported encoding: ${t}`);return this.getBufferFromResponse(a)}async stat(){if(!this._stat){const e=s.Buffer.allocUnsafe(10);if(await this.read(e,0,10,0),!this._stat)throw new Error(`unable to determine size of file at ${this.url}`)}return this._stat}async close(){}}function l(e){const t=new FileReader;return new Promise(((i,n)=>{t.onerror=()=>{t.abort(),n(new Error("problem reading blob"))},t.onabort=()=>{n(new Error("blob reading was aborted"))},t.onload=()=>{t.result&&"string"!=typeof t.result?i(t.result):n(new Error("unknown error reading blob"))},t.readAsArrayBuffer(e)}))}class h{constructor(e){this.blob=e,this.size=e.size}async read(e,t=0,i,n=0){if(!i)return{bytesRead:0,buffer:e};const r=n,o=r+i,a=await l(this.blob.slice(r,o)),h=s.Buffer.from(a);return{bytesRead:h.copy(e,t),buffer:h}}async readFile(e){let t;if(t="string"==typeof e?e:e&&e.encoding,"utf8"===t)return function(e){const t=new FileReader;return new Promise(((i,n)=>{t.onerror=()=>{t.abort(),n(new Error("problem reading blob"))},t.onabort=()=>{n(new Error("blob reading was aborted"))},t.onload=()=>{t.result&&"string"==typeof t.result?i(t.result):n(new Error("unknown error reading blob"))},t.readAsText(e)}))}(this.blob);if(t)throw new Error(`unsupported encoding: ${t}`);const i=await l(this.blob);return s.Buffer.from(i)}async stat(){return{size:this.size}}async close(){}}function c(e,t={}){return new a(e,t)}function d(e,t,i,n={}){if(void 0!==i)return i;if(void 0!==e)return c(e,n);if(void 0!==t)return new(r())(t,n);throw new Error("no url, path, or filehandle provided, cannot open")}},645:(e,t)=>{t.read=function(e,t,i,n,r){var s,o,a=8*r-n-1,l=(1<<a)-1,h=l>>1,c=-7,d=i?r-1:0,u=i?-1:1,f=e[t+d];for(d+=u,s=f&(1<<-c)-1,f>>=-c,c+=a;c>0;s=256*s+e[t+d],d+=u,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=n;c>0;o=256*o+e[t+d],d+=u,c-=8);if(0===s)s=1-h;else{if(s===l)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,n),s-=h}return(f?-1:1)*o*Math.pow(2,s-n)},t.write=function(e,t,i,n,r,s){var o,a,l,h=8*s-r-1,c=(1<<h)-1,d=c>>1,u=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:s-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=c):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),(t+=o+d>=1?u/l:u*Math.pow(2,1-d))*l>=2&&(o++,l/=2),o+d>=c?(a=0,o=c):o+d>=1?(a=(t*l-1)*Math.pow(2,r),o+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,r),o=0));r>=8;e[i+f]=255&a,f+=p,a/=256,r-=8);for(o=o<<r|a,h+=r;h>0;e[i+f]=255&o,f+=p,o/=256,h-=8);e[i+f-p]|=128*g}},8738:e=>{function t(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}e.exports=function(e){return null!=e&&(t(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&t(e.slice(0,0))}(e)||!!e._isBuffer)}},3720:e=>{e.exports=i;var t=null;try{t=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}function i(e,t,i){this.low=0|e,this.high=0|t,this.unsigned=!!i}function n(e){return!0===(e&&e.__isLong__)}i.prototype.__isLong__,Object.defineProperty(i.prototype,"__isLong__",{value:!0}),i.isLong=n;var r={},s={};function o(e,t){var i,n,o;return t?(o=0<=(e>>>=0)&&e<256)&&(n=s[e])?n:(i=l(e,(0|e)<0?-1:0,!0),o&&(s[e]=i),i):(o=-128<=(e|=0)&&e<128)&&(n=r[e])?n:(i=l(e,e<0?-1:0,!1),o&&(r[e]=i),i)}function a(e,t){if(isNaN(e))return t?b:m;if(t){if(e<0)return b;if(e>=f)return x}else{if(e<=-p)return k;if(e+1>=p)return _}return e<0?a(-e,t).neg():l(e%u|0,e/u|0,t)}function l(e,t,n){return new i(e,t,n)}i.fromInt=o,i.fromNumber=a,i.fromBits=l;var h=Math.pow;function c(e,t,i){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return m;if("number"==typeof t?(i=t,t=!1):t=!!t,(i=i||10)<2||36<i)throw RangeError("radix");var n;if((n=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===n)return c(e.substring(1),t,i).neg();for(var r=a(h(i,8)),s=m,o=0;o<e.length;o+=8){var l=Math.min(8,e.length-o),d=parseInt(e.substring(o,o+l),i);if(l<8){var u=a(h(i,l));s=s.mul(u).add(a(d))}else s=(s=s.mul(r)).add(a(d))}return s.unsigned=t,s}function d(e,t){return"number"==typeof e?a(e,t):"string"==typeof e?c(e,t):l(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}i.fromString=c,i.fromValue=d;var u=4294967296,f=u*u,p=f/2,g=o(1<<24),m=o(0);i.ZERO=m;var b=o(0,!0);i.UZERO=b;var w=o(1);i.ONE=w;var v=o(1,!0);i.UONE=v;var y=o(-1);i.NEG_ONE=y;var _=l(-1,2147483647,!1);i.MAX_VALUE=_;var x=l(-1,-1,!0);i.MAX_UNSIGNED_VALUE=x;var k=l(0,-2147483648,!1);i.MIN_VALUE=k;var C=i.prototype;C.toInt=function(){return this.unsigned?this.low>>>0:this.low},C.toNumber=function(){return this.unsigned?(this.high>>>0)*u+(this.low>>>0):this.high*u+(this.low>>>0)},C.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(k)){var t=a(e),i=this.div(t),n=i.mul(t).sub(this);return i.toString(e)+n.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var r=a(h(e,6),this.unsigned),s=this,o="";;){var l=s.div(r),c=(s.sub(l.mul(r)).toInt()>>>0).toString(e);if((s=l).isZero())return c+o;for(;c.length<6;)c="0"+c;o=""+c+o}},C.getHighBits=function(){return this.high},C.getHighBitsUnsigned=function(){return this.high>>>0},C.getLowBits=function(){return this.low},C.getLowBitsUnsigned=function(){return this.low>>>0},C.getNumBitsAbs=function(){if(this.isNegative())return this.eq(k)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<<t);t--);return 0!=this.high?t+33:t+1},C.isZero=function(){return 0===this.high&&0===this.low},C.eqz=C.isZero,C.isNegative=function(){return!this.unsigned&&this.high<0},C.isPositive=function(){return this.unsigned||this.high>=0},C.isOdd=function(){return 1==(1&this.low)},C.isEven=function(){return 0==(1&this.low)},C.equals=function(e){return n(e)||(e=d(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},C.eq=C.equals,C.notEquals=function(e){return!this.eq(e)},C.neq=C.notEquals,C.ne=C.notEquals,C.lessThan=function(e){return this.comp(e)<0},C.lt=C.lessThan,C.lessThanOrEqual=function(e){return this.comp(e)<=0},C.lte=C.lessThanOrEqual,C.le=C.lessThanOrEqual,C.greaterThan=function(e){return this.comp(e)>0},C.gt=C.greaterThan,C.greaterThanOrEqual=function(e){return this.comp(e)>=0},C.gte=C.greaterThanOrEqual,C.ge=C.greaterThanOrEqual,C.compare=function(e){if(n(e)||(e=d(e)),this.eq(e))return 0;var t=this.isNegative(),i=e.isNegative();return t&&!i?-1:!t&&i?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},C.comp=C.compare,C.negate=function(){return!this.unsigned&&this.eq(k)?k:this.not().add(w)},C.neg=C.negate,C.add=function(e){n(e)||(e=d(e));var t=this.high>>>16,i=65535&this.high,r=this.low>>>16,s=65535&this.low,o=e.high>>>16,a=65535&e.high,h=e.low>>>16,c=0,u=0,f=0,p=0;return f+=(p+=s+(65535&e.low))>>>16,u+=(f+=r+h)>>>16,c+=(u+=i+a)>>>16,c+=t+o,l((f&=65535)<<16|(p&=65535),(c&=65535)<<16|(u&=65535),this.unsigned)},C.subtract=function(e){return n(e)||(e=d(e)),this.add(e.neg())},C.sub=C.subtract,C.multiply=function(e){if(this.isZero())return m;if(n(e)||(e=d(e)),t)return l(t.mul(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned);if(e.isZero())return m;if(this.eq(k))return e.isOdd()?k:m;if(e.eq(k))return this.isOdd()?k:m;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(g)&&e.lt(g))return a(this.toNumber()*e.toNumber(),this.unsigned);var i=this.high>>>16,r=65535&this.high,s=this.low>>>16,o=65535&this.low,h=e.high>>>16,c=65535&e.high,u=e.low>>>16,f=65535&e.low,p=0,b=0,w=0,v=0;return w+=(v+=o*f)>>>16,b+=(w+=s*f)>>>16,w&=65535,b+=(w+=o*u)>>>16,p+=(b+=r*f)>>>16,b&=65535,p+=(b+=s*u)>>>16,b&=65535,p+=(b+=o*c)>>>16,p+=i*f+r*u+s*c+o*h,l((w&=65535)<<16|(v&=65535),(p&=65535)<<16|(b&=65535),this.unsigned)},C.mul=C.multiply,C.divide=function(e){if(n(e)||(e=d(e)),e.isZero())throw Error("division by zero");var i,r,s;if(t)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?l((this.unsigned?t.div_u:t.div_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?b:m;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return b;if(e.gt(this.shru(1)))return v;s=b}else{if(this.eq(k))return e.eq(w)||e.eq(y)?k:e.eq(k)?w:(i=this.shr(1).div(e).shl(1)).eq(m)?e.isNegative()?w:y:(r=this.sub(e.mul(i)),s=i.add(r.div(e)));if(e.eq(k))return this.unsigned?b:m;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();s=m}for(r=this;r.gte(e);){i=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var o=Math.ceil(Math.log(i)/Math.LN2),c=o<=48?1:h(2,o-48),u=a(i),f=u.mul(e);f.isNegative()||f.gt(r);)f=(u=a(i-=c,this.unsigned)).mul(e);u.isZero()&&(u=w),s=s.add(u),r=r.sub(f)}return s},C.div=C.divide,C.modulo=function(e){return n(e)||(e=d(e)),t?l((this.unsigned?t.rem_u:t.rem_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},C.mod=C.modulo,C.rem=C.modulo,C.not=function(){return l(~this.low,~this.high,this.unsigned)},C.and=function(e){return n(e)||(e=d(e)),l(this.low&e.low,this.high&e.high,this.unsigned)},C.or=function(e){return n(e)||(e=d(e)),l(this.low|e.low,this.high|e.high,this.unsigned)},C.xor=function(e){return n(e)||(e=d(e)),l(this.low^e.low,this.high^e.high,this.unsigned)},C.shiftLeft=function(e){return n(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?l(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):l(0,this.low<<e-32,this.unsigned)},C.shl=C.shiftLeft,C.shiftRight=function(e){return n(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?l(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):l(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},C.shr=C.shiftRight,C.shiftRightUnsigned=function(e){if(n(e)&&(e=e.toInt()),0==(e&=63))return this;var t=this.high;return e<32?l(this.low>>>e|t<<32-e,t>>>e,this.unsigned):l(32===e?t:t>>>e-32,0,this.unsigned)},C.shru=C.shiftRightUnsigned,C.shr_u=C.shiftRightUnsigned,C.toSigned=function(){return this.unsigned?l(this.low,this.high,!1):this},C.toUnsigned=function(){return this.unsigned?this:l(this.low,this.high,!0)},C.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},C.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},C.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},i.fromBytes=function(e,t,n){return n?i.fromBytesLE(e,t):i.fromBytesBE(e,t)},i.fromBytesLE=function(e,t){return new i(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},i.fromBytesBE=function(e,t){return new i(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)}},2568:(e,t,i)=>{var n,r,s,o,a;n=i(1012),r=i(487).utf8,s=i(8738),o=i(487).bin,(a=function(e,t){e.constructor==String?e=t&&"binary"===t.encoding?o.stringToBytes(e):r.stringToBytes(e):s(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var i=n.bytesToWords(e),l=8*e.length,h=1732584193,c=-271733879,d=-1732584194,u=271733878,f=0;f<i.length;f++)i[f]=16711935&(i[f]<<8|i[f]>>>24)|4278255360&(i[f]<<24|i[f]>>>8);i[l>>>5]|=128<<l%32,i[14+(l+64>>>9<<4)]=l;var p=a._ff,g=a._gg,m=a._hh,b=a._ii;for(f=0;f<i.length;f+=16){var w=h,v=c,y=d,_=u;h=p(h,c,d,u,i[f+0],7,-680876936),u=p(u,h,c,d,i[f+1],12,-389564586),d=p(d,u,h,c,i[f+2],17,606105819),c=p(c,d,u,h,i[f+3],22,-1044525330),h=p(h,c,d,u,i[f+4],7,-176418897),u=p(u,h,c,d,i[f+5],12,1200080426),d=p(d,u,h,c,i[f+6],17,-1473231341),c=p(c,d,u,h,i[f+7],22,-45705983),h=p(h,c,d,u,i[f+8],7,1770035416),u=p(u,h,c,d,i[f+9],12,-1958414417),d=p(d,u,h,c,i[f+10],17,-42063),c=p(c,d,u,h,i[f+11],22,-1990404162),h=p(h,c,d,u,i[f+12],7,1804603682),u=p(u,h,c,d,i[f+13],12,-40341101),d=p(d,u,h,c,i[f+14],17,-1502002290),h=g(h,c=p(c,d,u,h,i[f+15],22,1236535329),d,u,i[f+1],5,-165796510),u=g(u,h,c,d,i[f+6],9,-1069501632),d=g(d,u,h,c,i[f+11],14,643717713),c=g(c,d,u,h,i[f+0],20,-373897302),h=g(h,c,d,u,i[f+5],5,-701558691),u=g(u,h,c,d,i[f+10],9,38016083),d=g(d,u,h,c,i[f+15],14,-660478335),c=g(c,d,u,h,i[f+4],20,-405537848),h=g(h,c,d,u,i[f+9],5,568446438),u=g(u,h,c,d,i[f+14],9,-1019803690),d=g(d,u,h,c,i[f+3],14,-187363961),c=g(c,d,u,h,i[f+8],20,1163531501),h=g(h,c,d,u,i[f+13],5,-1444681467),u=g(u,h,c,d,i[f+2],9,-51403784),d=g(d,u,h,c,i[f+7],14,1735328473),h=m(h,c=g(c,d,u,h,i[f+12],20,-1926607734),d,u,i[f+5],4,-378558),u=m(u,h,c,d,i[f+8],11,-2022574463),d=m(d,u,h,c,i[f+11],16,1839030562),c=m(c,d,u,h,i[f+14],23,-35309556),h=m(h,c,d,u,i[f+1],4,-1530992060),u=m(u,h,c,d,i[f+4],11,1272893353),d=m(d,u,h,c,i[f+7],16,-155497632),c=m(c,d,u,h,i[f+10],23,-1094730640),h=m(h,c,d,u,i[f+13],4,681279174),u=m(u,h,c,d,i[f+0],11,-358537222),d=m(d,u,h,c,i[f+3],16,-722521979),c=m(c,d,u,h,i[f+6],23,76029189),h=m(h,c,d,u,i[f+9],4,-640364487),u=m(u,h,c,d,i[f+12],11,-421815835),d=m(d,u,h,c,i[f+15],16,530742520),h=b(h,c=m(c,d,u,h,i[f+2],23,-995338651),d,u,i[f+0],6,-198630844),u=b(u,h,c,d,i[f+7],10,1126891415),d=b(d,u,h,c,i[f+14],15,-1416354905),c=b(c,d,u,h,i[f+5],21,-57434055),h=b(h,c,d,u,i[f+12],6,1700485571),u=b(u,h,c,d,i[f+3],10,-1894986606),d=b(d,u,h,c,i[f+10],15,-1051523),c=b(c,d,u,h,i[f+1],21,-2054922799),h=b(h,c,d,u,i[f+8],6,1873313359),u=b(u,h,c,d,i[f+15],10,-30611744),d=b(d,u,h,c,i[f+6],15,-1560198380),c=b(c,d,u,h,i[f+13],21,1309151649),h=b(h,c,d,u,i[f+4],6,-145523070),u=b(u,h,c,d,i[f+11],10,-1120210379),d=b(d,u,h,c,i[f+2],15,718787259),c=b(c,d,u,h,i[f+9],21,-343485551),h=h+w>>>0,c=c+v>>>0,d=d+y>>>0,u=u+_>>>0}return n.endian([h,c,d,u])})._ff=function(e,t,i,n,r,s,o){var a=e+(t&i|~t&n)+(r>>>0)+o;return(a<<s|a>>>32-s)+t},a._gg=function(e,t,i,n,r,s,o){var a=e+(t&n|i&~n)+(r>>>0)+o;return(a<<s|a>>>32-s)+t},a._hh=function(e,t,i,n,r,s,o){var a=e+(t^i^n)+(r>>>0)+o;return(a<<s|a>>>32-s)+t},a._ii=function(e,t,i,n,r,s,o){var a=e+(i^(t|~n))+(r>>>0)+o;return(a<<s|a>>>32-s)+t},a._blocksize=16,a._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);var i=n.wordsToBytes(a(e,t));return t&&t.asBytes?i:t&&t.asString?o.bytesToString(i):n.bytesToHex(i)}},9591:(e,t,i)=>{var n={};(0,i(4236).assign)(n,i(4555),i(8843),i(1619)),e.exports=n},4555:(e,t,i)=>{var n=i(405),r=i(4236),s=i(9373),o=i(8898),a=i(2292),l=Object.prototype.toString;function h(e){if(!(this instanceof h))return new h(e);this.options=r.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new a,this.strm.avail_out=0;var i=n.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(0!==i)throw new Error(o[i]);if(t.header&&n.deflateSetHeader(this.strm,t.header),t.dictionary){var c;if(c="string"==typeof t.dictionary?s.string2buf(t.dictionary):"[object ArrayBuffer]"===l.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,0!==(i=n.deflateSetDictionary(this.strm,c)))throw new Error(o[i]);this._dict_set=!0}}function c(e,t){var i=new h(t);if(i.push(e,!0),i.err)throw i.msg||o[i.err];return i.result}h.prototype.push=function(e,t){var i,o,a=this.strm,h=this.options.chunkSize;if(this.ended)return!1;o=t===~~t?t:!0===t?4:0,"string"==typeof e?a.input=s.string2buf(e):"[object ArrayBuffer]"===l.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new r.Buf8(h),a.next_out=0,a.avail_out=h),1!==(i=n.deflate(a,o))&&0!==i)return this.onEnd(i),this.ended=!0,!1;0!==a.avail_out&&(0!==a.avail_in||4!==o&&2!==o)||("string"===this.options.to?this.onData(s.buf2binstring(r.shrinkBuf(a.output,a.next_out))):this.onData(r.shrinkBuf(a.output,a.next_out)))}while((a.avail_in>0||0===a.avail_out)&&1!==i);return 4===o?(i=n.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,0===i):2!==o||(this.onEnd(0),a.avail_out=0,!0)},h.prototype.onData=function(e){this.chunks.push(e)},h.prototype.onEnd=function(e){0===e&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},t.Deflate=h,t.deflate=c,t.deflateRaw=function(e,t){return(t=t||{}).raw=!0,c(e,t)},t.gzip=function(e,t){return(t=t||{}).gzip=!0,c(e,t)}},8843:(e,t,i)=>{var n=i(7948),r=i(4236),s=i(9373),o=i(1619),a=i(8898),l=i(2292),h=i(2401),c=Object.prototype.toString;function d(e){if(!(this instanceof d))return new d(e);this.options=r.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var i=n.inflateInit2(this.strm,t.windowBits);if(i!==o.Z_OK)throw new Error(a[i]);if(this.header=new h,n.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=s.string2buf(t.dictionary):"[object ArrayBuffer]"===c.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=n.inflateSetDictionary(this.strm,t.dictionary))!==o.Z_OK))throw new Error(a[i])}function u(e,t){var i=new d(t);if(i.push(e,!0),i.err)throw i.msg||a[i.err];return i.result}d.prototype.push=function(e,t){var i,a,l,h,d,u=this.strm,f=this.options.chunkSize,p=this.options.dictionary,g=!1;if(this.ended)return!1;a=t===~~t?t:!0===t?o.Z_FINISH:o.Z_NO_FLUSH,"string"==typeof e?u.input=s.binstring2buf(e):"[object ArrayBuffer]"===c.call(e)?u.input=new Uint8Array(e):u.input=e,u.next_in=0,u.avail_in=u.input.length;do{if(0===u.avail_out&&(u.output=new r.Buf8(f),u.next_out=0,u.avail_out=f),(i=n.inflate(u,o.Z_NO_FLUSH))===o.Z_NEED_DICT&&p&&(i=n.inflateSetDictionary(this.strm,p)),i===o.Z_BUF_ERROR&&!0===g&&(i=o.Z_OK,g=!1),i!==o.Z_STREAM_END&&i!==o.Z_OK)return this.onEnd(i),this.ended=!0,!1;u.next_out&&(0!==u.avail_out&&i!==o.Z_STREAM_END&&(0!==u.avail_in||a!==o.Z_FINISH&&a!==o.Z_SYNC_FLUSH)||("string"===this.options.to?(l=s.utf8border(u.output,u.next_out),h=u.next_out-l,d=s.buf2string(u.output,l),u.next_out=h,u.avail_out=f-h,h&&r.arraySet(u.output,u.output,l,h,0),this.onData(d)):this.onData(r.shrinkBuf(u.output,u.next_out)))),0===u.avail_in&&0===u.avail_out&&(g=!0)}while((u.avail_in>0||0===u.avail_out)&&i!==o.Z_STREAM_END);return i===o.Z_STREAM_END&&(a=o.Z_FINISH),a===o.Z_FINISH?(i=n.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===o.Z_OK):a!==o.Z_SYNC_FLUSH||(this.onEnd(o.Z_OK),u.avail_out=0,!0)},d.prototype.onData=function(e){this.chunks.push(e)},d.prototype.onEnd=function(e){e===o.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},t.Inflate=d,t.inflate=u,t.inflateRaw=function(e,t){return(t=t||{}).raw=!0,u(e,t)},t.ungzip=u},4236:(e,t)=>{var i="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var i=t.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(var r in i)n(i,r)&&(e[r]=i[r])}}return e},t.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var r={arraySet:function(e,t,i,n,r){if(t.subarray&&e.subarray)e.set(t.subarray(i,i+n),r);else for(var s=0;s<n;s++)e[r+s]=t[i+s]},flattenChunks:function(e){var t,i,n,r,s,o;for(n=0,t=0,i=e.length;t<i;t++)n+=e[t].length;for(o=new Uint8Array(n),r=0,t=0,i=e.length;t<i;t++)s=e[t],o.set(s,r),r+=s.length;return o}},s={arraySet:function(e,t,i,n,r){for(var s=0;s<n;s++)e[r+s]=t[i+s]},flattenChunks:function(e){return[].concat.apply([],e)}};t.setTyped=function(e){e?(t.Buf8=Uint8Array,t.Buf16=Uint16Array,t.Buf32=Int32Array,t.assign(t,r)):(t.Buf8=Array,t.Buf16=Array,t.Buf32=Array,t.assign(t,s))},t.setTyped(i)},9373:(e,t,i)=>{var n=i(4236),r=!0,s=!0;try{String.fromCharCode.apply(null,[0])}catch(e){r=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){s=!1}for(var o=new n.Buf8(256),a=0;a<256;a++)o[a]=a>=252?6:a>=248?5:a>=240?4:a>=224?3:a>=192?2:1;function l(e,t){if(t<65534&&(e.subarray&&s||!e.subarray&&r))return String.fromCharCode.apply(null,n.shrinkBuf(e,t));for(var i="",o=0;o<t;o++)i+=String.fromCharCode(e[o]);return i}o[254]=o[254]=1,t.string2buf=function(e){var t,i,r,s,o,a=e.length,l=0;for(s=0;s<a;s++)55296==(64512&(i=e.charCodeAt(s)))&&s+1<a&&56320==(64512&(r=e.charCodeAt(s+1)))&&(i=65536+(i-55296<<10)+(r-56320),s++),l+=i<128?1:i<2048?2:i<65536?3:4;for(t=new n.Buf8(l),o=0,s=0;o<l;s++)55296==(64512&(i=e.charCodeAt(s)))&&s+1<a&&56320==(64512&(r=e.charCodeAt(s+1)))&&(i=65536+(i-55296<<10)+(r-56320),s++),i<128?t[o++]=i:i<2048?(t[o++]=192|i>>>6,t[o++]=128|63&i):i<65536?(t[o++]=224|i>>>12,t[o++]=128|i>>>6&63,t[o++]=128|63&i):(t[o++]=240|i>>>18,t[o++]=128|i>>>12&63,t[o++]=128|i>>>6&63,t[o++]=128|63&i);return t},t.buf2binstring=function(e){return l(e,e.length)},t.binstring2buf=function(e){for(var t=new n.Buf8(e.length),i=0,r=t.length;i<r;i++)t[i]=e.charCodeAt(i);return t},t.buf2string=function(e,t){var i,n,r,s,a=t||e.length,h=new Array(2*a);for(n=0,i=0;i<a;)if((r=e[i++])<128)h[n++]=r;else if((s=o[r])>4)h[n++]=65533,i+=s-1;else{for(r&=2===s?31:3===s?15:7;s>1&&i<a;)r=r<<6|63&e[i++],s--;s>1?h[n++]=65533:r<65536?h[n++]=r:(r-=65536,h[n++]=55296|r>>10&1023,h[n++]=56320|1023&r)}return l(h,n)},t.utf8border=function(e,t){var i;for((t=t||e.length)>e.length&&(t=e.length),i=t-1;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+o[e[i]]>t?i:t}},6069:e=>{e.exports=function(e,t,i,n){for(var r=65535&e|0,s=e>>>16&65535|0,o=0;0!==i;){i-=o=i>2e3?2e3:i;do{s=s+(r=r+t[n++]|0)|0}while(--o);r%=65521,s%=65521}return r|s<<16|0}},1619:e=>{e.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},2869:e=>{var t=function(){for(var e,t=[],i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t}();e.exports=function(e,i,n,r){var s=t,o=r+n;e^=-1;for(var a=r;a<o;a++)e=e>>>8^s[255&(e^i[a])];return-1^e}},405:(e,t,i)=>{var n,r=i(4236),s=i(342),o=i(6069),a=i(2869),l=i(8898),h=-2,c=258,d=262,u=103,f=113,p=666;function g(e,t){return e.msg=l[t],t}function m(e){return(e<<1)-(e>4?9:0)}function b(e){for(var t=e.length;--t>=0;)e[t]=0}function w(e){var t=e.state,i=t.pending;i>e.avail_out&&(i=e.avail_out),0!==i&&(r.arraySet(e.output,t.pending_buf,t.pending_out,i,e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))}function v(e,t){s._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,w(e.strm)}function y(e,t){e.pending_buf[e.pending++]=t}function _(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function x(e,t,i,n){var s=e.avail_in;return s>n&&(s=n),0===s?0:(e.avail_in-=s,r.arraySet(t,e.input,e.next_in,s,i),1===e.state.wrap?e.adler=o(e.adler,t,s,i):2===e.state.wrap&&(e.adler=a(e.adler,t,s,i)),e.next_in+=s,e.total_in+=s,s)}function k(e,t){var i,n,r=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match,l=e.strstart>e.w_size-d?e.strstart-(e.w_size-d):0,h=e.window,u=e.w_mask,f=e.prev,p=e.strstart+c,g=h[s+o-1],m=h[s+o];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do{if(h[(i=t)+o]===m&&h[i+o-1]===g&&h[i]===h[s]&&h[++i]===h[s+1]){s+=2,i++;do{}while(h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&s<p);if(n=c-(p-s),s=p-c,n>o){if(e.match_start=t,o=n,n>=a)break;g=h[s+o-1],m=h[s+o]}}}while((t=f[t&u])>l&&0!=--r);return o<=e.lookahead?o:e.lookahead}function C(e){var t,i,n,s,o,a=e.w_size;do{if(s=e.window_size-e.lookahead-e.strstart,e.strstart>=a+(a-d)){r.arraySet(e.window,e.window,a,a,0),e.match_start-=a,e.strstart-=a,e.block_start-=a,t=i=e.hash_size;do{n=e.head[--t],e.head[t]=n>=a?n-a:0}while(--i);t=i=a;do{n=e.prev[--t],e.prev[t]=n>=a?n-a:0}while(--i);s+=a}if(0===e.strm.avail_in)break;if(i=x(e.strm,e.window,e.strstart+e.lookahead,s),e.lookahead+=i,e.lookahead+e.insert>=3)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+3-1])&e.hash_mask,e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<d&&0!==e.strm.avail_in)}function S(e,t){for(var i,n;;){if(e.lookahead<d){if(C(e),e.lookahead<d&&0===t)return 1;if(0===e.lookahead)break}if(i=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==i&&e.strstart-i<=e.w_size-d&&(e.match_length=k(e,i)),e.match_length>=3)if(n=s._tr_tally(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else n=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(v(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,4===t?(v(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(v(e,!1),0===e.strm.avail_out)?1:2}function A(e,t){for(var i,n,r;;){if(e.lookahead<d){if(C(e),e.lookahead<d&&0===t)return 1;if(0===e.lookahead)break}if(i=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==i&&e.prev_length<e.max_lazy_match&&e.strstart-i<=e.w_size-d&&(e.match_length=k(e,i),e.match_length<=5&&(1===e.strategy||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-3,n=s._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=r&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,n&&(v(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((n=s._tr_tally(e,0,e.window[e.strstart-1]))&&v(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=s._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,4===t?(v(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(v(e,!1),0===e.strm.avail_out)?1:2}function E(e,t,i,n,r){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=n,this.func=r}function M(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new r.Buf16(1146),this.dyn_dtree=new r.Buf16(122),this.bl_tree=new r.Buf16(78),b(this.dyn_ltree),b(this.dyn_dtree),b(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new r.Buf16(16),this.heap=new r.Buf16(573),b(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new r.Buf16(573),b(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function T(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=2,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:f,e.adler=2===t.wrap?0:1,t.last_flush=0,s._tr_init(t),0):g(e,h)}function R(e){var t,i=T(e);return 0===i&&((t=e.state).window_size=2*t.w_size,b(t.head),t.max_lazy_match=n[t.level].max_lazy,t.good_match=n[t.level].good_length,t.nice_match=n[t.level].nice_length,t.max_chain_length=n[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0),i}function L(e,t,i,n,s,o){if(!e)return h;var a=1;if(-1===t&&(t=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),s<1||s>9||8!==i||n<8||n>15||t<0||t>9||o<0||o>4)return g(e,h);8===n&&(n=9);var l=new M;return e.state=l,l.strm=e,l.wrap=a,l.gzhead=null,l.w_bits=n,l.w_size=1<<l.w_bits,l.w_mask=l.w_size-1,l.hash_bits=s+7,l.hash_size=1<<l.hash_bits,l.hash_mask=l.hash_size-1,l.hash_shift=~~((l.hash_bits+3-1)/3),l.window=new r.Buf8(2*l.w_size),l.head=new r.Buf16(l.hash_size),l.prev=new r.Buf16(l.w_size),l.lit_bufsize=1<<s+6,l.pending_buf_size=4*l.lit_bufsize,l.pending_buf=new r.Buf8(l.pending_buf_size),l.d_buf=1*l.lit_bufsize,l.l_buf=3*l.lit_bufsize,l.level=t,l.strategy=o,l.method=i,R(e)}n=[new E(0,0,0,0,(function(e,t){var i=65535;for(i>e.pending_buf_size-5&&(i=e.pending_buf_size-5);;){if(e.lookahead<=1){if(C(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+i;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,v(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-d&&(v(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(v(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(v(e,!1),e.strm.avail_out),1)})),new E(4,4,8,4,S),new E(4,5,16,8,S),new E(4,6,32,32,S),new E(4,4,16,16,A),new E(8,16,32,32,A),new E(8,16,128,128,A),new E(8,32,128,256,A),new E(32,128,258,1024,A),new E(32,258,258,4096,A)],t.deflateInit=function(e,t){return L(e,t,8,15,8,0)},t.deflateInit2=L,t.deflateReset=R,t.deflateResetKeep=T,t.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?h:(e.state.gzhead=t,0):h},t.deflate=function(e,t){var i,r,o,l;if(!e||!e.state||t>5||t<0)return e?g(e,h):h;if(r=e.state,!e.output||!e.input&&0!==e.avail_in||r.status===p&&4!==t)return g(e,0===e.avail_out?-5:h);if(r.strm=e,i=r.last_flush,r.last_flush=t,42===r.status)if(2===r.wrap)e.adler=0,y(r,31),y(r,139),y(r,8),r.gzhead?(y(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),y(r,255&r.gzhead.time),y(r,r.gzhead.time>>8&255),y(r,r.gzhead.time>>16&255),y(r,r.gzhead.time>>24&255),y(r,9===r.level?2:r.strategy>=2||r.level<2?4:0),y(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(y(r,255&r.gzhead.extra.length),y(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=a(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69):(y(r,0),y(r,0),y(r,0),y(r,0),y(r,0),y(r,9===r.level?2:r.strategy>=2||r.level<2?4:0),y(r,3),r.status=f);else{var d=8+(r.w_bits-8<<4)<<8;d|=(r.strategy>=2||r.level<2?0:r.level<6?1:6===r.level?2:3)<<6,0!==r.strstart&&(d|=32),d+=31-d%31,r.status=f,_(r,d),0!==r.strstart&&(_(r,e.adler>>>16),_(r,65535&e.adler)),e.adler=1}if(69===r.status)if(r.gzhead.extra){for(o=r.pending;r.gzindex<(65535&r.gzhead.extra.length)&&(r.pending!==r.pending_buf_size||(r.gzhead.hcrc&&r.pending>o&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),w(e),o=r.pending,r.pending!==r.pending_buf_size));)y(r,255&r.gzhead.extra[r.gzindex]),r.gzindex++;r.gzhead.hcrc&&r.pending>o&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=73)}else r.status=73;if(73===r.status)if(r.gzhead.name){o=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),w(e),o=r.pending,r.pending===r.pending_buf_size)){l=1;break}l=r.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,y(r,l)}while(0!==l);r.gzhead.hcrc&&r.pending>o&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),0===l&&(r.gzindex=0,r.status=91)}else r.status=91;if(91===r.status)if(r.gzhead.comment){o=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),w(e),o=r.pending,r.pending===r.pending_buf_size)){l=1;break}l=r.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,y(r,l)}while(0!==l);r.gzhead.hcrc&&r.pending>o&&(e.adler=a(e.adler,r.pending_buf,r.pending-o,o)),0===l&&(r.status=u)}else r.status=u;if(r.status===u&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&w(e),r.pending+2<=r.pending_buf_size&&(y(r,255&e.adler),y(r,e.adler>>8&255),e.adler=0,r.status=f)):r.status=f),0!==r.pending){if(w(e),0===e.avail_out)return r.last_flush=-1,0}else if(0===e.avail_in&&m(t)<=m(i)&&4!==t)return g(e,-5);if(r.status===p&&0!==e.avail_in)return g(e,-5);if(0!==e.avail_in||0!==r.lookahead||0!==t&&r.status!==p){var x=2===r.strategy?function(e,t){for(var i;;){if(0===e.lookahead&&(C(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,i=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(v(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(v(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(v(e,!1),0===e.strm.avail_out)?1:2}(r,t):3===r.strategy?function(e,t){for(var i,n,r,o,a=e.window;;){if(e.lookahead<=c){if(C(e),e.lookahead<=c&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=a[r=e.strstart-1])===a[++r]&&n===a[++r]&&n===a[++r]){o=e.strstart+c;do{}while(n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&r<o);e.match_length=c-(o-r),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(i=s._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(v(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(v(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(v(e,!1),0===e.strm.avail_out)?1:2}(r,t):n[r.level].func(r,t);if(3!==x&&4!==x||(r.status=p),1===x||3===x)return 0===e.avail_out&&(r.last_flush=-1),0;if(2===x&&(1===t?s._tr_align(r):5!==t&&(s._tr_stored_block(r,0,0,!1),3===t&&(b(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),w(e),0===e.avail_out))return r.last_flush=-1,0}return 4!==t?0:r.wrap<=0?1:(2===r.wrap?(y(r,255&e.adler),y(r,e.adler>>8&255),y(r,e.adler>>16&255),y(r,e.adler>>24&255),y(r,255&e.total_in),y(r,e.total_in>>8&255),y(r,e.total_in>>16&255),y(r,e.total_in>>24&255)):(_(r,e.adler>>>16),_(r,65535&e.adler)),w(e),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?0:1)},t.deflateEnd=function(e){var t;return e&&e.state?42!==(t=e.state.status)&&69!==t&&73!==t&&91!==t&&t!==u&&t!==f&&t!==p?g(e,h):(e.state=null,t===f?g(e,-3):0):h},t.deflateSetDictionary=function(e,t){var i,n,s,a,l,c,d,u,f=t.length;if(!e||!e.state)return h;if(2===(a=(i=e.state).wrap)||1===a&&42!==i.status||i.lookahead)return h;for(1===a&&(e.adler=o(e.adler,t,f,0)),i.wrap=0,f>=i.w_size&&(0===a&&(b(i.head),i.strstart=0,i.block_start=0,i.insert=0),u=new r.Buf8(i.w_size),r.arraySet(u,t,f-i.w_size,i.w_size,0),t=u,f=i.w_size),l=e.avail_in,c=e.next_in,d=e.input,e.avail_in=f,e.next_in=0,e.input=t,C(i);i.lookahead>=3;){n=i.strstart,s=i.lookahead-2;do{i.ins_h=(i.ins_h<<i.hash_shift^i.window[n+3-1])&i.hash_mask,i.prev[n&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=n,n++}while(--s);i.strstart=n,i.lookahead=2,C(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,e.next_in=c,e.input=d,e.avail_in=l,i.wrap=a,0},t.deflateInfo="pako deflate (from Nodeca project)"},2401:e=>{e.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},4264:e=>{e.exports=function(e,t){var i,n,r,s,o,a,l,h,c,d,u,f,p,g,m,b,w,v,y,_,x,k,C,S,A;i=e.state,n=e.next_in,S=e.input,r=n+(e.avail_in-5),s=e.next_out,A=e.output,o=s-(t-e.avail_out),a=s+(e.avail_out-257),l=i.dmax,h=i.wsize,c=i.whave,d=i.wnext,u=i.window,f=i.hold,p=i.bits,g=i.lencode,m=i.distcode,b=(1<<i.lenbits)-1,w=(1<<i.distbits)-1;e:do{p<15&&(f+=S[n++]<<p,p+=8,f+=S[n++]<<p,p+=8),v=g[f&b];t:for(;;){if(f>>>=y=v>>>24,p-=y,0==(y=v>>>16&255))A[s++]=65535&v;else{if(!(16&y)){if(0==(64&y)){v=g[(65535&v)+(f&(1<<y)-1)];continue t}if(32&y){i.mode=12;break e}e.msg="invalid literal/length code",i.mode=30;break e}_=65535&v,(y&=15)&&(p<y&&(f+=S[n++]<<p,p+=8),_+=f&(1<<y)-1,f>>>=y,p-=y),p<15&&(f+=S[n++]<<p,p+=8,f+=S[n++]<<p,p+=8),v=m[f&w];i:for(;;){if(f>>>=y=v>>>24,p-=y,!(16&(y=v>>>16&255))){if(0==(64&y)){v=m[(65535&v)+(f&(1<<y)-1)];continue i}e.msg="invalid distance code",i.mode=30;break e}if(x=65535&v,p<(y&=15)&&(f+=S[n++]<<p,(p+=8)<y&&(f+=S[n++]<<p,p+=8)),(x+=f&(1<<y)-1)>l){e.msg="invalid distance too far back",i.mode=30;break e}if(f>>>=y,p-=y,x>(y=s-o)){if((y=x-y)>c&&i.sane){e.msg="invalid distance too far back",i.mode=30;break e}if(k=0,C=u,0===d){if(k+=h-y,y<_){_-=y;do{A[s++]=u[k++]}while(--y);k=s-x,C=A}}else if(d<y){if(k+=h+d-y,(y-=d)<_){_-=y;do{A[s++]=u[k++]}while(--y);if(k=0,d<_){_-=y=d;do{A[s++]=u[k++]}while(--y);k=s-x,C=A}}}else if(k+=d-y,y<_){_-=y;do{A[s++]=u[k++]}while(--y);k=s-x,C=A}for(;_>2;)A[s++]=C[k++],A[s++]=C[k++],A[s++]=C[k++],_-=3;_&&(A[s++]=C[k++],_>1&&(A[s++]=C[k++]))}else{k=s-x;do{A[s++]=A[k++],A[s++]=A[k++],A[s++]=A[k++],_-=3}while(_>2);_&&(A[s++]=A[k++],_>1&&(A[s++]=A[k++]))}break}}break}}while(n<r&&s<a);n-=_=p>>3,f&=(1<<(p-=_<<3))-1,e.next_in=n,e.next_out=s,e.avail_in=n<r?r-n+5:5-(n-r),e.avail_out=s<a?a-s+257:257-(s-a),i.hold=f,i.bits=p}},7948:(e,t,i)=>{var n=i(4236),r=i(6069),s=i(2869),o=i(4264),a=i(9241),l=-2,h=12,c=30;function d(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function u(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function f(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new n.Buf32(852),t.distcode=t.distdyn=new n.Buf32(592),t.sane=1,t.back=-1,0):l}function p(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,f(e)):l}function g(e,t){var i,n;return e&&e.state?(n=e.state,t<0?(i=0,t=-t):(i=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?l:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=i,n.wbits=t,p(e))):l}function m(e,t){var i,n;return e?(n=new u,e.state=n,n.window=null,0!==(i=g(e,t))&&(e.state=null),i):l}var b,w,v=!0;function y(e){if(v){var t;for(b=new n.Buf32(512),w=new n.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(a(1,e.lens,0,288,b,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;a(2,e.lens,0,32,w,0,e.work,{bits:5}),v=!1}e.lencode=b,e.lenbits=9,e.distcode=w,e.distbits=5}function _(e,t,i,r){var s,o=e.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new n.Buf8(o.wsize)),r>=o.wsize?(n.arraySet(o.window,t,i-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((s=o.wsize-o.wnext)>r&&(s=r),n.arraySet(o.window,t,i-r,s,o.wnext),(r-=s)?(n.arraySet(o.window,t,i-r,r,0),o.wnext=r,o.whave=o.wsize):(o.wnext+=s,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=s))),0}t.inflateReset=p,t.inflateReset2=g,t.inflateResetKeep=f,t.inflateInit=function(e){return m(e,15)},t.inflateInit2=m,t.inflate=function(e,t){var i,u,f,p,g,m,b,w,v,x,k,C,S,A,E,M,T,R,L,I,B,F,N,O,P=0,D=new n.Buf8(4),z=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return l;(i=e.state).mode===h&&(i.mode=13),g=e.next_out,f=e.output,b=e.avail_out,p=e.next_in,u=e.input,m=e.avail_in,w=i.hold,v=i.bits,x=m,k=b,F=0;e:for(;;)switch(i.mode){case 1:if(0===i.wrap){i.mode=13;break}for(;v<16;){if(0===m)break e;m--,w+=u[p++]<<v,v+=8}if(2&i.wrap&&35615===w){i.check=0,D[0]=255&w,D[1]=w>>>8&255,i.check=s(i.check,D,2,0),w=0,v=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&w)<<8)+(w>>8))%31){e.msg="incorrect header check",i.mode=c;break}if(8!=(15&w)){e.msg="unknown compression method",i.mode=c;break}if(v-=4,B=8+(15&(w>>>=4)),0===i.wbits)i.wbits=B;else if(B>i.wbits){e.msg="invalid window size",i.mode=c;break}i.dmax=1<<B,e.adler=i.check=1,i.mode=512&w?10:h,w=0,v=0;break;case 2:for(;v<16;){if(0===m)break e;m--,w+=u[p++]<<v,v+=8}if(i.flags=w,8!=(255&i.flags)){e.msg="unknown compression method",i.mode=c;break}if(57344&i.flags){e.msg="unknown header flags set",i.mode=c;break}i.head&&(i.head.text=w>>8&1),512&i.flags&&(D[0]=255&w,D[1]=w>>>8&255,i.check=s(i.check,D,2,0)),w=0,v=0,i.mode=3;case 3:for(;v<32;){if(0===m)break e;m--,w+=u[p++]<<v,v+=8}i.head&&(i.head.time=w),512&i.flags&&(D[0]=255&w,D[1]=w>>>8&255,D[2]=w>>>16&255,D[3]=w>>>24&255,i.check=s(i.check,D,4,0)),w=0,v=0,i.mode=4;case 4:for(;v<16;){if(0===m)break e;m--,w+=u[p++]<<v,v+=8}i.head&&(i.head.xflags=255&w,i.head.os=w>>8),512&i.flags&&(D[0]=255&w,D[1]=w>>>8&255,i.check=s(i.check,D,2,0)),w=0,v=0,i.mode=5;case 5:if(1024&i.flags){for(;v<16;){if(0===m)break e;m--,w+=u[p++]<<v,v+=8}i.length=w,i.head&&(i.head.extra_len=w),512&i.flags&&(D[0]=255&w,D[1]=w>>>8&255,i.check=s(i.check,D,2,0)),w=0,v=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&((C=i.length)>m&&(C=m),C&&(i.head&&(B=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),n.arraySet(i.head.extra,u,p,C,B)),512&i.flags&&(i.check=s(i.check,u,C,p)),m-=C,p+=C,i.length-=C),i.length))break e;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===m)break e;C=0;do{B=u[p+C++],i.head&&B&&i.length<65536&&(i.head.name+=String.fromCharCode(B))}while(B&&C<m);if(512&i.flags&&(i.check=s(i.check,u,C,p)),m-=C,p+=C,B)break e}else i.head&&(i.head.name=null);i.length=0,i.mode=8;case 8:if(4096&i.flags){if(0===m)break e;C=0;do{B=u[p+C++],i.head&&B&&i.length<65536&&(i.head.comment+=String.fromCharCode(B))}while(B&&C<m);if(512&i.flags&&(i.check=s(i.check,u,C,p)),m-=C,p+=C,B)break e}else i.head&&(i.head.comment=null);i.mode=9;case 9:if(512&i.flags){for(;v<16;){if(0===m)break e;m--,w+=u[p++]<<v,v+=8}if(w!==(65535&i.check)){e.msg="header crc mismatch",i.mode=c;break}w=0,v=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=h;break;case 10:for(;v<32;){if(0===m)break e;m--,w+=u[p++]<<v,v+=8}e.adler=i.check=d(w),w=0,v=0,i.mode=11;case 11:if(0===i.havedict)return e.next_out=g,e.avail_out=b,e.next_in=p,e.avail_in=m,i.hold=w,i.bits=v,2;e.adler=i.check=1,i.mode=h;case h:if(5===t||6===t)break e;case 13:if(i.last){w>>>=7&v,v-=7&v,i.mode=27;break}for(;v<3;){if(0===m)break e;m--,w+=u[p++]<<v,v+=8}switch(i.last=1&w,v-=1,3&(w>>>=1)){case 0:i.mode=14;break;case 1:if(y(i),i.mode=20,6===t){w>>>=2,v-=2;break e}break;case 2:i.mode=17;break;case 3:e.msg="invalid block type",i.mode=c}w>>>=2,v-=2;break;case 14:for(w>>>=7&v,v-=7&v;v<32;){if(0===m)break e;m--,w+=u[p++]<<v,v+=8}if((65535&w)!=(w>>>16^65535)){e.msg="invalid stored block lengths",i.mode=c;break}if(i.length=65535&w,w=0,v=0,i.mode=15,6===t)break e;case 15:i.mode=16;case 16:if(C=i.length){if(C>m&&(C=m),C>b&&(C=b),0===C)break e;n.arraySet(f,u,p,C,g),m-=C,p+=C,b-=C,g+=C,i.length-=C;break}i.mode=h;break;case 17:for(;v<14;){if(0===m)break e;m--,w+=u[p++]<<v,v+=8}if(i.nlen=257+(31&w),w>>>=5,v-=5,i.ndist=1+(31&w),w>>>=5,v-=5,i.ncode=4+(15&w),w>>>=4,v-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=c;break}i.have=0,i.mode=18;case 18:for(;i.have<i.ncode;){for(;v<3;){if(0===m)break e;m--,w+=u[p++]<<v,v+=8}i.lens[z[i.have++]]=7&w,w>>>=3,v-=3}for(;i.have<19;)i.lens[z[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,N={bits:i.lenbits},F=a(0,i.lens,0,19,i.lencode,0,i.work,N),i.lenbits=N.bits,F){e.msg="invalid code lengths set",i.mode=c;break}i.have=0,i.mode=19;case 19:for(;i.have<i.nlen+i.ndist;){for(;M=(P=i.lencode[w&(1<<i.lenbits)-1])>>>16&255,T=65535&P,!((E=P>>>24)<=v);){if(0===m)break e;m--,w+=u[p++]<<v,v+=8}if(T<16)w>>>=E,v-=E,i.lens[i.have++]=T;else{if(16===T){for(O=E+2;v<O;){if(0===m)break e;m--,w+=u[p++]<<v,v+=8}if(w>>>=E,v-=E,0===i.have){e.msg="invalid bit length repeat",i.mode=c;break}B=i.lens[i.have-1],C=3+(3&w),w>>>=2,v-=2}else if(17===T){for(O=E+3;v<O;){if(0===m)break e;m--,w+=u[p++]<<v,v+=8}v-=E,B=0,C=3+(7&(w>>>=E)),w>>>=3,v-=3}else{for(O=E+7;v<O;){if(0===m)break e;m--,w+=u[p++]<<v,v+=8}v-=E,B=0,C=11+(127&(w>>>=E)),w>>>=7,v-=7}if(i.have+C>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=c;break}for(;C--;)i.lens[i.have++]=B}}if(i.mode===c)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=c;break}if(i.lenbits=9,N={bits:i.lenbits},F=a(1,i.lens,0,i.nlen,i.lencode,0,i.work,N),i.lenbits=N.bits,F){e.msg="invalid literal/lengths set",i.mode=c;break}if(i.distbits=6,i.distcode=i.distdyn,N={bits:i.distbits},F=a(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,N),i.distbits=N.bits,F){e.msg="invalid distances set",i.mode=c;break}if(i.mode=20,6===t)break e;case 20:i.mode=21;case 21:if(m>=6&&b>=258){e.next_out=g,e.avail_out=b,e.next_in=p,e.avail_in=m,i.hold=w,i.bits=v,o(e,k),g=e.next_out,f=e.output,b=e.avail_out,p=e.next_in,u=e.input,m=e.avail_in,w=i.hold,v=i.bits,i.mode===h&&(i.back=-1);break}for(i.back=0;M=(P=i.lencode[w&(1<<i.lenbits)-1])>>>16&255,T=65535&P,!((E=P>>>24)<=v);){if(0===m)break e;m--,w+=u[p++]<<v,v+=8}if(M&&0==(240&M)){for(R=E,L=M,I=T;M=(P=i.lencode[I+((w&(1<<R+L)-1)>>R)])>>>16&255,T=65535&P,!(R+(E=P>>>24)<=v);){if(0===m)break e;m--,w+=u[p++]<<v,v+=8}w>>>=R,v-=R,i.back+=R}if(w>>>=E,v-=E,i.back+=E,i.length=T,0===M){i.mode=26;break}if(32&M){i.back=-1,i.mode=h;break}if(64&M){e.msg="invalid literal/length code",i.mode=c;break}i.extra=15&M,i.mode=22;case 22:if(i.extra){for(O=i.extra;v<O;){if(0===m)break e;m--,w+=u[p++]<<v,v+=8}i.length+=w&(1<<i.extra)-1,w>>>=i.extra,v-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;M=(P=i.distcode[w&(1<<i.distbits)-1])>>>16&255,T=65535&P,!((E=P>>>24)<=v);){if(0===m)break e;m--,w+=u[p++]<<v,v+=8}if(0==(240&M)){for(R=E,L=M,I=T;M=(P=i.distcode[I+((w&(1<<R+L)-1)>>R)])>>>16&255,T=65535&P,!(R+(E=P>>>24)<=v);){if(0===m)break e;m--,w+=u[p++]<<v,v+=8}w>>>=R,v-=R,i.back+=R}if(w>>>=E,v-=E,i.back+=E,64&M){e.msg="invalid distance code",i.mode=c;break}i.offset=T,i.extra=15&M,i.mode=24;case 24:if(i.extra){for(O=i.extra;v<O;){if(0===m)break e;m--,w+=u[p++]<<v,v+=8}i.offset+=w&(1<<i.extra)-1,w>>>=i.extra,v-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=c;break}i.mode=25;case 25:if(0===b)break e;if(C=k-b,i.offset>C){if((C=i.offset-C)>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=c;break}C>i.wnext?(C-=i.wnext,S=i.wsize-C):S=i.wnext-C,C>i.length&&(C=i.length),A=i.window}else A=f,S=g-i.offset,C=i.length;C>b&&(C=b),b-=C,i.length-=C;do{f[g++]=A[S++]}while(--C);0===i.length&&(i.mode=21);break;case 26:if(0===b)break e;f[g++]=i.length,b--,i.mode=21;break;case 27:if(i.wrap){for(;v<32;){if(0===m)break e;m--,w|=u[p++]<<v,v+=8}if(k-=b,e.total_out+=k,i.total+=k,k&&(e.adler=i.check=i.flags?s(i.check,f,k,g-k):r(i.check,f,k,g-k)),k=b,(i.flags?w:d(w))!==i.check){e.msg="incorrect data check",i.mode=c;break}w=0,v=0}i.mode=28;case 28:if(i.wrap&&i.flags){for(;v<32;){if(0===m)break e;m--,w+=u[p++]<<v,v+=8}if(w!==(4294967295&i.total)){e.msg="incorrect length check",i.mode=c;break}w=0,v=0}i.mode=29;case 29:F=1;break e;case c:F=-3;break e;case 31:return-4;default:return l}return e.next_out=g,e.avail_out=b,e.next_in=p,e.avail_in=m,i.hold=w,i.bits=v,(i.wsize||k!==e.avail_out&&i.mode<c&&(i.mode<27||4!==t))&&_(e,e.output,e.next_out,k-e.avail_out)?(i.mode=31,-4):(x-=e.avail_in,k-=e.avail_out,e.total_in+=x,e.total_out+=k,i.total+=k,i.wrap&&k&&(e.adler=i.check=i.flags?s(i.check,f,k,e.next_out-k):r(i.check,f,k,e.next_out-k)),e.data_type=i.bits+(i.last?64:0)+(i.mode===h?128:0)+(20===i.mode||15===i.mode?256:0),(0===x&&0===k||4===t)&&0===F&&(F=-5),F)},t.inflateEnd=function(e){if(!e||!e.state)return l;var t=e.state;return t.window&&(t.window=null),e.state=null,0},t.inflateGetHeader=function(e,t){var i;return e&&e.state?0==(2&(i=e.state).wrap)?l:(i.head=t,t.done=!1,0):l},t.inflateSetDictionary=function(e,t){var i,n=t.length;return e&&e.state?0!==(i=e.state).wrap&&11!==i.mode?l:11===i.mode&&r(1,t,n,0)!==i.check?-3:_(e,t,n,n)?(i.mode=31,-4):(i.havedict=1,0):l},t.inflateInfo="pako inflate (from Nodeca project)"},9241:(e,t,i)=>{var n=i(4236),r=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],s=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],o=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],a=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];e.exports=function(e,t,i,l,h,c,d,u){var f,p,g,m,b,w,v,y,_,x=u.bits,k=0,C=0,S=0,A=0,E=0,M=0,T=0,R=0,L=0,I=0,B=null,F=0,N=new n.Buf16(16),O=new n.Buf16(16),P=null,D=0;for(k=0;k<=15;k++)N[k]=0;for(C=0;C<l;C++)N[t[i+C]]++;for(E=x,A=15;A>=1&&0===N[A];A--);if(E>A&&(E=A),0===A)return h[c++]=20971520,h[c++]=20971520,u.bits=1,0;for(S=1;S<A&&0===N[S];S++);for(E<S&&(E=S),R=1,k=1;k<=15;k++)if(R<<=1,(R-=N[k])<0)return-1;if(R>0&&(0===e||1!==A))return-1;for(O[1]=0,k=1;k<15;k++)O[k+1]=O[k]+N[k];for(C=0;C<l;C++)0!==t[i+C]&&(d[O[t[i+C]]++]=C);if(0===e?(B=P=d,w=19):1===e?(B=r,F-=257,P=s,D-=257,w=256):(B=o,P=a,w=-1),I=0,C=0,k=S,b=c,M=E,T=0,g=-1,m=(L=1<<E)-1,1===e&&L>852||2===e&&L>592)return 1;for(;;){v=k-T,d[C]<w?(y=0,_=d[C]):d[C]>w?(y=P[D+d[C]],_=B[F+d[C]]):(y=96,_=0),f=1<<k-T,S=p=1<<M;do{h[b+(I>>T)+(p-=f)]=v<<24|y<<16|_|0}while(0!==p);for(f=1<<k-1;I&f;)f>>=1;if(0!==f?(I&=f-1,I+=f):I=0,C++,0==--N[k]){if(k===A)break;k=t[i+d[C]]}if(k>E&&(I&m)!==g){for(0===T&&(T=E),b+=S,R=1<<(M=k-T);M+T<A&&!((R-=N[M+T])<=0);)M++,R<<=1;if(L+=1<<M,1===e&&L>852||2===e&&L>592)return 1;h[g=I&m]=E<<24|M<<16|b-c|0}}return 0!==I&&(h[b+I]=k-T<<24|64<<16|0),u.bits=E,0}},8898:e=>{e.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},342:(e,t,i)=>{var n=i(4236);function r(e){for(var t=e.length;--t>=0;)e[t]=0}var s=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],o=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],l=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],h=new Array(576);r(h);var c=new Array(60);r(c);var d=new Array(512);r(d);var u=new Array(256);r(u);var f=new Array(29);r(f);var p,g,m,b=new Array(30);function w(e,t,i,n,r){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=n,this.max_length=r,this.has_stree=e&&e.length}function v(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function y(e){return e<256?d[e]:d[256+(e>>>7)]}function _(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function x(e,t,i){e.bi_valid>16-i?(e.bi_buf|=t<<e.bi_valid&65535,_(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=i-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=i)}function k(e,t,i){x(e,i[2*t],i[2*t+1])}function C(e,t){var i=0;do{i|=1&e,e>>>=1,i<<=1}while(--t>0);return i>>>1}function S(e,t,i){var n,r,s=new Array(16),o=0;for(n=1;n<=15;n++)s[n]=o=o+i[n-1]<<1;for(r=0;r<=t;r++){var a=e[2*r+1];0!==a&&(e[2*r]=C(s[a]++,a))}}function A(e){var t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function E(e){e.bi_valid>8?_(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function M(e,t,i,n){var r=2*t,s=2*i;return e[r]<e[s]||e[r]===e[s]&&n[t]<=n[i]}function T(e,t,i){for(var n=e.heap[i],r=i<<1;r<=e.heap_len&&(r<e.heap_len&&M(t,e.heap[r+1],e.heap[r],e.depth)&&r++,!M(t,n,e.heap[r],e.depth));)e.heap[i]=e.heap[r],i=r,r<<=1;e.heap[i]=n}function R(e,t,i){var n,r,a,l,h=0;if(0!==e.last_lit)do{n=e.pending_buf[e.d_buf+2*h]<<8|e.pending_buf[e.d_buf+2*h+1],r=e.pending_buf[e.l_buf+h],h++,0===n?k(e,r,t):(k(e,(a=u[r])+256+1,t),0!==(l=s[a])&&x(e,r-=f[a],l),k(e,a=y(--n),i),0!==(l=o[a])&&x(e,n-=b[a],l))}while(h<e.last_lit);k(e,256,t)}function L(e,t){var i,n,r,s=t.dyn_tree,o=t.stat_desc.static_tree,a=t.stat_desc.has_stree,l=t.stat_desc.elems,h=-1;for(e.heap_len=0,e.heap_max=573,i=0;i<l;i++)0!==s[2*i]?(e.heap[++e.heap_len]=h=i,e.depth[i]=0):s[2*i+1]=0;for(;e.heap_len<2;)s[2*(r=e.heap[++e.heap_len]=h<2?++h:0)]=1,e.depth[r]=0,e.opt_len--,a&&(e.static_len-=o[2*r+1]);for(t.max_code=h,i=e.heap_len>>1;i>=1;i--)T(e,s,i);r=l;do{i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],T(e,s,1),n=e.heap[1],e.heap[--e.heap_max]=i,e.heap[--e.heap_max]=n,s[2*r]=s[2*i]+s[2*n],e.depth[r]=(e.depth[i]>=e.depth[n]?e.depth[i]:e.depth[n])+1,s[2*i+1]=s[2*n+1]=r,e.heap[1]=r++,T(e,s,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var i,n,r,s,o,a,l=t.dyn_tree,h=t.max_code,c=t.stat_desc.static_tree,d=t.stat_desc.has_stree,u=t.stat_desc.extra_bits,f=t.stat_desc.extra_base,p=t.stat_desc.max_length,g=0;for(s=0;s<=15;s++)e.bl_count[s]=0;for(l[2*e.heap[e.heap_max]+1]=0,i=e.heap_max+1;i<573;i++)(s=l[2*l[2*(n=e.heap[i])+1]+1]+1)>p&&(s=p,g++),l[2*n+1]=s,n>h||(e.bl_count[s]++,o=0,n>=f&&(o=u[n-f]),a=l[2*n],e.opt_len+=a*(s+o),d&&(e.static_len+=a*(c[2*n+1]+o)));if(0!==g){do{for(s=p-1;0===e.bl_count[s];)s--;e.bl_count[s]--,e.bl_count[s+1]+=2,e.bl_count[p]--,g-=2}while(g>0);for(s=p;0!==s;s--)for(n=e.bl_count[s];0!==n;)(r=e.heap[--i])>h||(l[2*r+1]!==s&&(e.opt_len+=(s-l[2*r+1])*l[2*r],l[2*r+1]=s),n--)}}(e,t),S(s,h,e.bl_count)}function I(e,t,i){var n,r,s=-1,o=t[1],a=0,l=7,h=4;for(0===o&&(l=138,h=3),t[2*(i+1)+1]=65535,n=0;n<=i;n++)r=o,o=t[2*(n+1)+1],++a<l&&r===o||(a<h?e.bl_tree[2*r]+=a:0!==r?(r!==s&&e.bl_tree[2*r]++,e.bl_tree[32]++):a<=10?e.bl_tree[34]++:e.bl_tree[36]++,a=0,s=r,0===o?(l=138,h=3):r===o?(l=6,h=3):(l=7,h=4))}function B(e,t,i){var n,r,s=-1,o=t[1],a=0,l=7,h=4;for(0===o&&(l=138,h=3),n=0;n<=i;n++)if(r=o,o=t[2*(n+1)+1],!(++a<l&&r===o)){if(a<h)do{k(e,r,e.bl_tree)}while(0!=--a);else 0!==r?(r!==s&&(k(e,r,e.bl_tree),a--),k(e,16,e.bl_tree),x(e,a-3,2)):a<=10?(k(e,17,e.bl_tree),x(e,a-3,3)):(k(e,18,e.bl_tree),x(e,a-11,7));a=0,s=r,0===o?(l=138,h=3):r===o?(l=6,h=3):(l=7,h=4)}}r(b);var F=!1;function N(e,t,i,r){x(e,0+(r?1:0),3),function(e,t,i,r){E(e),_(e,i),_(e,~i),n.arraySet(e.pending_buf,e.window,t,i,e.pending),e.pending+=i}(e,t,i)}t._tr_init=function(e){F||(function(){var e,t,i,n,r,l=new Array(16);for(i=0,n=0;n<28;n++)for(f[n]=i,e=0;e<1<<s[n];e++)u[i++]=n;for(u[i-1]=n,r=0,n=0;n<16;n++)for(b[n]=r,e=0;e<1<<o[n];e++)d[r++]=n;for(r>>=7;n<30;n++)for(b[n]=r<<7,e=0;e<1<<o[n]-7;e++)d[256+r++]=n;for(t=0;t<=15;t++)l[t]=0;for(e=0;e<=143;)h[2*e+1]=8,e++,l[8]++;for(;e<=255;)h[2*e+1]=9,e++,l[9]++;for(;e<=279;)h[2*e+1]=7,e++,l[7]++;for(;e<=287;)h[2*e+1]=8,e++,l[8]++;for(S(h,287,l),e=0;e<30;e++)c[2*e+1]=5,c[2*e]=C(e,5);p=new w(h,s,257,286,15),g=new w(c,o,0,30,15),m=new w(new Array(0),a,0,19,7)}(),F=!0),e.l_desc=new v(e.dyn_ltree,p),e.d_desc=new v(e.dyn_dtree,g),e.bl_desc=new v(e.bl_tree,m),e.bi_buf=0,e.bi_valid=0,A(e)},t._tr_stored_block=N,t._tr_flush_block=function(e,t,i,n){var r,s,o=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),L(e,e.l_desc),L(e,e.d_desc),o=function(e){var t;for(I(e,e.dyn_ltree,e.l_desc.max_code),I(e,e.dyn_dtree,e.d_desc.max_code),L(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*l[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),r=e.opt_len+3+7>>>3,(s=e.static_len+3+7>>>3)<=r&&(r=s)):r=s=i+5,i+4<=r&&-1!==t?N(e,t,i,n):4===e.strategy||s===r?(x(e,2+(n?1:0),3),R(e,h,c)):(x(e,4+(n?1:0),3),function(e,t,i,n){var r;for(x(e,t-257,5),x(e,i-1,5),x(e,n-4,4),r=0;r<n;r++)x(e,e.bl_tree[2*l[r]+1],3);B(e,e.dyn_ltree,t-1),B(e,e.dyn_dtree,i-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),R(e,e.dyn_ltree,e.dyn_dtree)),A(e),n&&E(e)},t._tr_tally=function(e,t,i){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&i,e.last_lit++,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(u[i]+256+1)]++,e.dyn_dtree[2*y(t)]++),e.last_lit===e.lit_bufsize-1},t._tr_align=function(e){x(e,2,3),k(e,256,h),function(e){16===e.bi_valid?(_(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},2292:e=>{e.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},2587:e=>{function t(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e,i,n,r){i=i||"&",n=n||"=";var s={};if("string"!=typeof e||0===e.length)return s;var o=/\+/g;e=e.split(i);var a=1e3;r&&"number"==typeof r.maxKeys&&(a=r.maxKeys);var l=e.length;a>0&&l>a&&(l=a);for(var h=0;h<l;++h){var c,d,u,f,p=e[h].replace(o,"%20"),g=p.indexOf(n);g>=0?(c=p.substr(0,g),d=p.substr(g+1)):(c=p,d=""),u=decodeURIComponent(c),f=decodeURIComponent(d),t(s,u)?Array.isArray(s[u])?s[u].push(f):s[u]=[s[u],f]:s[u]=f}return s}},2361:e=>{var t=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};e.exports=function(e,i,n,r){return i=i||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?Object.keys(e).map((function(r){var s=encodeURIComponent(t(r))+n;return Array.isArray(e[r])?e[r].map((function(e){return s+encodeURIComponent(t(e))})).join(i):s+encodeURIComponent(t(e[r]))})).join(i):r?encodeURIComponent(t(r))+n+encodeURIComponent(t(e)):""}},7673:(e,t,i)=>{t.decode=t.parse=i(2587),t.encode=t.stringify=i(2361)},1269:e=>{class t{constructor(e={}){if(!(e.maxSize&&e.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=e.maxSize,this.cache=new Map,this.oldCache=new Map,this._size=0}_set(e,t){this.cache.set(e,t),this._size++,this._size>=this.maxSize&&(this._size=0,this.oldCache=this.cache,this.cache=new Map)}get(e){if(this.cache.has(e))return this.cache.get(e);if(this.oldCache.has(e)){const t=this.oldCache.get(e);return this.oldCache.delete(e),this._set(e,t),t}}set(e,t){return this.cache.has(e)?this.cache.set(e,t):this._set(e,t),this}has(e){return this.cache.has(e)||this.oldCache.has(e)}peek(e){return this.cache.has(e)?this.cache.get(e):this.oldCache.has(e)?this.oldCache.get(e):void 0}delete(e){const t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}*keys(){for(const[e]of this)yield e}*values(){for(const[,e]of this)yield e}*[Symbol.iterator](){for(const e of this.cache)yield e;for(const e of this.oldCache){const[t]=e;this.cache.has(t)||(yield e)}}get size(){let e=0;for(const t of this.oldCache.keys())this.cache.has(t)||e++;return this._size+e}}e.exports=t},2511:function(e,t,i){var n;e=i.nmd(e),function(r){t&&t.nodeType,e&&e.nodeType;var s="object"==typeof i.g&&i.g;s.global!==s&&s.window!==s&&s.self;var o,a=2147483647,l=36,h=/^xn--/,c=/[^\x20-\x7E]/,d=/[\x2E\u3002\uFF0E\uFF61]/g,u={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},f=Math.floor,p=String.fromCharCode;function g(e){throw RangeError(u[e])}function m(e,t){for(var i=e.length,n=[];i--;)n[i]=t(e[i]);return n}function b(e,t){var i=e.split("@"),n="";return i.length>1&&(n=i[0]+"@",e=i[1]),n+m((e=e.replace(d,".")).split("."),t).join(".")}function w(e){for(var t,i,n=[],r=0,s=e.length;r<s;)(t=e.charCodeAt(r++))>=55296&&t<=56319&&r<s?56320==(64512&(i=e.charCodeAt(r++)))?n.push(((1023&t)<<10)+(1023&i)+65536):(n.push(t),r--):n.push(t);return n}function v(e){return m(e,(function(e){var t="";return e>65535&&(t+=p((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+p(e)})).join("")}function y(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function _(e,t,i){var n=0;for(e=i?f(e/700):e>>1,e+=f(e/t);e>455;n+=l)e=f(e/35);return f(n+36*e/(e+38))}function x(e){var t,i,n,r,s,o,h,c,d,u,p,m=[],b=e.length,w=0,y=128,x=72;for((i=e.lastIndexOf("-"))<0&&(i=0),n=0;n<i;++n)e.charCodeAt(n)>=128&&g("not-basic"),m.push(e.charCodeAt(n));for(r=i>0?i+1:0;r<b;){for(s=w,o=1,h=l;r>=b&&g("invalid-input"),((c=(p=e.charCodeAt(r++))-48<10?p-22:p-65<26?p-65:p-97<26?p-97:l)>=l||c>f((a-w)/o))&&g("overflow"),w+=c*o,!(c<(d=h<=x?1:h>=x+26?26:h-x));h+=l)o>f(a/(u=l-d))&&g("overflow"),o*=u;x=_(w-s,t=m.length+1,0==s),f(w/t)>a-y&&g("overflow"),y+=f(w/t),w%=t,m.splice(w++,0,y)}return v(m)}function k(e){var t,i,n,r,s,o,h,c,d,u,m,b,v,x,k,C=[];for(b=(e=w(e)).length,t=128,i=0,s=72,o=0;o<b;++o)(m=e[o])<128&&C.push(p(m));for(n=r=C.length,r&&C.push("-");n<b;){for(h=a,o=0;o<b;++o)(m=e[o])>=t&&m<h&&(h=m);for(h-t>f((a-i)/(v=n+1))&&g("overflow"),i+=(h-t)*v,t=h,o=0;o<b;++o)if((m=e[o])<t&&++i>a&&g("overflow"),m==t){for(c=i,d=l;!(c<(u=d<=s?1:d>=s+26?26:d-s));d+=l)k=c-u,x=l-u,C.push(p(y(u+k%x,0))),c=f(k/x);C.push(p(y(c,0))),s=_(i,v,n==r),i=0,++n}++i,++t}return C.join("")}o={version:"1.3.2",ucs2:{decode:w,encode:v},decode:x,encode:k,toASCII:function(e){return b(e,(function(e){return c.test(e)?"xn--"+k(e):e}))},toUnicode:function(e){return b(e,(function(e){return h.test(e)?x(e.slice(4).toLowerCase()):e}))}},void 0===(n=function(){return o}.call(t,i,t,e))||(e.exports=n)}()},8575:(e,t,i)=>{var n=i(2511),r=i(2502);function s(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}t.parse=v,t.resolve=function(e,t){return v(e,!1,!0).resolve(t)},t.resolveObject=function(e,t){return e?v(e,!1,!0).resolveObject(t):t},t.format=function(e){return r.isString(e)&&(e=v(e)),e instanceof s?e.format():s.prototype.format.call(e)},t.Url=s;var o=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,l=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,h=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),c=["'"].concat(h),d=["%","/","?",";","#"].concat(c),u=["/","?","#"],f=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:!0,"javascript:":!0},m={javascript:!0,"javascript:":!0},b={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},w=i(7673);function v(e,t,i){if(e&&r.isObject(e)&&e instanceof s)return e;var n=new s;return n.parse(e,t,i),n}s.prototype.parse=function(e,t,i){if(!r.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var s=e.indexOf("?"),a=-1!==s&&s<e.indexOf("#")?"?":"#",h=e.split(a);h[0]=h[0].replace(/\\/g,"/");var v=e=h.join(a);if(v=v.trim(),!i&&1===e.split("#").length){var y=l.exec(v);if(y)return this.path=v,this.href=v,this.pathname=y[1],y[2]?(this.search=y[2],this.query=t?w.parse(this.search.substr(1)):this.search.substr(1)):t&&(this.search="",this.query={}),this}var _=o.exec(v);if(_){var x=(_=_[0]).toLowerCase();this.protocol=x,v=v.substr(_.length)}if(i||_||v.match(/^\/\/[^@\/]+@[^@\/]+/)){var k="//"===v.substr(0,2);!k||_&&m[_]||(v=v.substr(2),this.slashes=!0)}if(!m[_]&&(k||_&&!b[_])){for(var C,S,A=-1,E=0;E<u.length;E++)-1!==(M=v.indexOf(u[E]))&&(-1===A||M<A)&&(A=M);for(-1!==(S=-1===A?v.lastIndexOf("@"):v.lastIndexOf("@",A))&&(C=v.slice(0,S),v=v.slice(S+1),this.auth=decodeURIComponent(C)),A=-1,E=0;E<d.length;E++){var M;-1!==(M=v.indexOf(d[E]))&&(-1===A||M<A)&&(A=M)}-1===A&&(A=v.length),this.host=v.slice(0,A),v=v.slice(A),this.parseHost(),this.hostname=this.hostname||"";var T="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!T)for(var R=this.hostname.split(/\./),L=(E=0,R.length);E<L;E++){var I=R[E];if(I&&!I.match(f)){for(var B="",F=0,N=I.length;F<N;F++)I.charCodeAt(F)>127?B+="x":B+=I[F];if(!B.match(f)){var O=R.slice(0,E),P=R.slice(E+1),D=I.match(p);D&&(O.push(D[1]),P.unshift(D[2])),P.length&&(v="/"+P.join(".")+v),this.hostname=O.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),T||(this.hostname=n.toASCII(this.hostname));var z=this.port?":"+this.port:"",H=this.hostname||"";this.host=H+z,this.href+=this.host,T&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==v[0]&&(v="/"+v))}if(!g[x])for(E=0,L=c.length;E<L;E++){var V=c[E];if(-1!==v.indexOf(V)){var U=encodeURIComponent(V);U===V&&(U=escape(V)),v=v.split(V).join(U)}}var q=v.indexOf("#");-1!==q&&(this.hash=v.substr(q),v=v.slice(0,q));var j=v.indexOf("?");if(-1!==j?(this.search=v.substr(j),this.query=v.substr(j+1),t&&(this.query=w.parse(this.query)),v=v.slice(0,j)):t&&(this.search="",this.query={}),v&&(this.pathname=v),b[x]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){z=this.pathname||"";var $=this.search||"";this.path=z+$}return this.href=this.format(),this},s.prototype.format=function(){var e=this.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var t=this.protocol||"",i=this.pathname||"",n=this.hash||"",s=!1,o="";this.host?s=e+this.host:this.hostname&&(s=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(s+=":"+this.port)),this.query&&r.isObject(this.query)&&Object.keys(this.query).length&&(o=w.stringify(this.query));var a=this.search||o&&"?"+o||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||b[t])&&!1!==s?(s="//"+(s||""),i&&"/"!==i.charAt(0)&&(i="/"+i)):s||(s=""),n&&"#"!==n.charAt(0)&&(n="#"+n),a&&"?"!==a.charAt(0)&&(a="?"+a),t+s+(i=i.replace(/[?#]/g,(function(e){return encodeURIComponent(e)})))+(a=a.replace("#","%23"))+n},s.prototype.resolve=function(e){return this.resolveObject(v(e,!1,!0)).format()},s.prototype.resolveObject=function(e){if(r.isString(e)){var t=new s;t.parse(e,!1,!0),e=t}for(var i=new s,n=Object.keys(this),o=0;o<n.length;o++){var a=n[o];i[a]=this[a]}if(i.hash=e.hash,""===e.href)return i.href=i.format(),i;if(e.slashes&&!e.protocol){for(var l=Object.keys(e),h=0;h<l.length;h++){var c=l[h];"protocol"!==c&&(i[c]=e[c])}return b[i.protocol]&&i.hostname&&!i.pathname&&(i.path=i.pathname="/"),i.href=i.format(),i}if(e.protocol&&e.protocol!==i.protocol){if(!b[e.protocol]){for(var d=Object.keys(e),u=0;u<d.length;u++){var f=d[u];i[f]=e[f]}return i.href=i.format(),i}if(i.protocol=e.protocol,e.host||m[e.protocol])i.pathname=e.pathname;else{for(var p=(e.pathname||"").split("/");p.length&&!(e.host=p.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==p[0]&&p.unshift(""),p.length<2&&p.unshift(""),i.pathname=p.join("/")}if(i.search=e.search,i.query=e.query,i.host=e.host||"",i.auth=e.auth,i.hostname=e.hostname||e.host,i.port=e.port,i.pathname||i.search){var g=i.pathname||"",w=i.search||"";i.path=g+w}return i.slashes=i.slashes||e.slashes,i.href=i.format(),i}var v=i.pathname&&"/"===i.pathname.charAt(0),y=e.host||e.pathname&&"/"===e.pathname.charAt(0),_=y||v||i.host&&e.pathname,x=_,k=i.pathname&&i.pathname.split("/")||[],C=(p=e.pathname&&e.pathname.split("/")||[],i.protocol&&!b[i.protocol]);if(C&&(i.hostname="",i.port=null,i.host&&(""===k[0]?k[0]=i.host:k.unshift(i.host)),i.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===p[0]?p[0]=e.host:p.unshift(e.host)),e.host=null),_=_&&(""===p[0]||""===k[0])),y)i.host=e.host||""===e.host?e.host:i.host,i.hostname=e.hostname||""===e.hostname?e.hostname:i.hostname,i.search=e.search,i.query=e.query,k=p;else if(p.length)k||(k=[]),k.pop(),k=k.concat(p),i.search=e.search,i.query=e.query;else if(!r.isNullOrUndefined(e.search))return C&&(i.hostname=i.host=k.shift(),(T=!!(i.host&&i.host.indexOf("@")>0)&&i.host.split("@"))&&(i.auth=T.shift(),i.host=i.hostname=T.shift())),i.search=e.search,i.query=e.query,r.isNull(i.pathname)&&r.isNull(i.search)||(i.path=(i.pathname?i.pathname:"")+(i.search?i.search:"")),i.href=i.format(),i;if(!k.length)return i.pathname=null,i.search?i.path="/"+i.search:i.path=null,i.href=i.format(),i;for(var S=k.slice(-1)[0],A=(i.host||e.host||k.length>1)&&("."===S||".."===S)||""===S,E=0,M=k.length;M>=0;M--)"."===(S=k[M])?k.splice(M,1):".."===S?(k.splice(M,1),E++):E&&(k.splice(M,1),E--);if(!_&&!x)for(;E--;E)k.unshift("..");!_||""===k[0]||k[0]&&"/"===k[0].charAt(0)||k.unshift(""),A&&"/"!==k.join("/").substr(-1)&&k.push("");var T,R=""===k[0]||k[0]&&"/"===k[0].charAt(0);return C&&(i.hostname=i.host=R?"":k.length?k.shift():"",(T=!!(i.host&&i.host.indexOf("@")>0)&&i.host.split("@"))&&(i.auth=T.shift(),i.host=i.hostname=T.shift())),(_=_||i.host&&k.length)&&!R&&k.unshift(""),k.length?i.pathname=k.join("/"):(i.pathname=null,i.path=null),r.isNull(i.pathname)&&r.isNull(i.search)||(i.path=(i.pathname?i.pathname:"")+(i.search?i.search:"")),i.auth=e.auth||i.auth,i.slashes=i.slashes||e.slashes,i.href=i.format(),i},s.prototype.parseHost=function(){var e=this.host,t=a.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},2502:e=>{e.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},7067:()=>{}},t={};function i(n){var r=t[n];if(void 0!==r)return r.exports;var s=t[n]={id:n,loaded:!1,exports:{}};return e[n].call(s.exports,s,s.exports,i),s.loaded=!0,s.exports}return i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),i(5590)})();class rd{constructor(e,t,i){this.config=e,this.browser=i,this.genome=t,this.cramFile=new nd.CramFile({filehandle:new sd(e.url,e),seqFetch:e.seqFetch||function(e,t,i){const n=this.genome.sequence,r=this.genome;return this.getHeader().then((function(s){const o=r.getChromosomeName(s.chrNames[e]);return n.getSequence(o,t-1,i)}))}.bind(this),checkSequenceMD5:void 0===e.checkSequenceMD5||e.checkSequenceMD5});const n=new sd(e.indexURL,e);this.indexedCramFile=new nd.IndexedCramFile({cram:this.cramFile,index:new nd.CraiIndex({filehandle:n}),fetchSizeLimit:3e7}),Wc.setReaderDefaults(this,e)}async getHeader(){if(!this.header){const e=this.genome,t=await this.cramFile.getSamHeader(),i={},n=[],r={},s=[];for(let o of t)if("SQ"===o.tag){for(let t of o.data)if("SN"===t.tag){const s=t.value;if(i[s]=n.length,n.push(s),e){r[e.getChromosomeName(s)]=s}break}}else"RG"===o.tag&&s.push(o.data);this.header={chrNames:n,chrToIndex:i,chrAliasTable:r,readGroups:s}}return this.header}async readAlignments(e,t,i){this.browser;const n=await this.getHeader(),r=n.chrAliasTable.hasOwnProperty(e)?n.chrAliasTable[e]:e,s=n.chrToIndex[r],o=new Cc(e,t,i,this.config);if(void 0===s)return o;try{const e=await this.indexedCramFile.getRecordsForRange(s,t,i);for(let r of e){const e=r.sequenceId,l=r.alignmentStart,h=l+r.lengthOnRef;if(e<0)continue;if(e>s||l>i)return;if(e<s)continue;if(h<t)continue;const c=a(r,n.chrNames);this.filter.pass(c)&&o.push(c)}return o.finish(),o}catch(e){let t=e.message;throw t&&t.indexOf("MD5")>=0&&(t="Sequence mismatch. Is this the correct genome for the loaded CRAM?"),this.browser.alert.present(new Error(t)),e}function a(e,t){const i=new Ic;if(i.chr=t[e.sequenceId],i.start=e.alignmentStart-1,i.lengthOnRef=e.lengthOnRef,i.flags=e.flags,i.strand=!(16&e.flags),i.fragmentLength=e.templateLength||e.templateSize,i.mq=e.mappingQuality,i.end=e.alignmentStart+e.lengthOnRef,i.readGroupId=e.readGroupId,e.mate&&void 0!==e.mate.sequenceId){const n=void 0!==e.mate.flags?!(1&e.mate.flags):!(32&e.flags);i.mate={chr:t[e.mate.sequenceId],position:e.mate.alignmentStart,strand:n}}return i.seq=e.getReadBases(),i.qual=e.qualityScores,i.tagDict=e.tags,i.readName=e.readName,function(e,t){const i=[];let n,r,s=0,o="";if(t.scStart=t.start,t.scLengthOnRef=t.lengthOnRef,e.readFeatures)for(let a of e.readFeatures){const e=a.code,l=a.data,h=a.pos-1,c=a.refPos-1;switch(e){case"S":case"I":case"i":case"N":case"D":if(h>s){const e=h-s;i.push(new Hc({start:c-e,seqOffset:s,len:e,type:"M"})),s+=e,o+=e+"M"}if("S"===e){let n=c;t.scLengthOnRef+=l.length,0===h&&(t.scStart-=l.length,n-=l.length);const r=l.length;i.push(new Hc({start:n,seqOffset:s,len:r,type:"S"})),s+=r,o+=r+e}else if("I"===e||"i"===e){void 0===n&&(n=[]);const t="i"===e?1:l.length;n.push(new Hc({start:c,len:t,seqOffset:s,type:"I"})),s+=t,o+=t+e}else"D"!==e&&"N"!==e||(r||(r=[]),r.push({start:c,len:l,type:e}),o+=l+e);break;case"H":case"P":o+=l+e}}const a=e.readLength-s;a>0&&(i.push(new Hc({start:e.alignmentStart+e.lengthOnRef-a-1,seqOffset:s,len:a,type:"M"})),o+=a+"M");t.blocks=i,t.insertions=n,t.gaps=r,t.cigar=o}(e,i),i.mate&&i.start>i.mate.position&&i.fragmentLength>0&&(i.fragmentLength=-i.fragmentLength),Wc.setPairOrientation(i),i}}}class sd{constructor(e,t){this.position=0,this.url=e,this.config=t,this.cache=new od({fetch:(e,t)=>this._fetch(e,t)})}async _fetch(e,t){const i={start:e,size:t};this._stat={size:void 0};const n=await no.loadArrayBuffer(this.url,To(this.config,{range:i}));return Buffer.from(n)}async read(e,t=0,i=1/0,n=0){let r=n;return null===n&&(r=this.position,this.position+=i),this.cache.get(e,t,i,n)}async readFile(){const e=await no.loadArrayBuffer(this.url,To(this.config));return Buffer.from(e)}async stat(){if(!this._stat){const e=Buffer.allocUnsafe(10);if(await this.read(e,0,10,0),!this._stat)throw new Error(`unable to determine size of file at ${this.url}`)}return this._stat}}class od{constructor({fetch:e,size:t=1e7,chunkSize:i=32768}){this.fetch=e,this.chunkSize=i,this.lruCache=new ad({maxSize:Math.floor(t/i)})}async get(e,t,i,n){if(e.length<t+i)throw new Error("output buffer not big enough for request");const r=Math.floor(n/this.chunkSize),s=Math.floor((n+i)/this.chunkSize),o=new Array(s-r+1);for(let e=r;e<=s;e+=1)o[e-r]=this._getChunk(e).then((t=>({data:t,chunkNumber:e})));const a=await Promise.all(o),l=n-a[0].chunkNumber*this.chunkSize;a.forEach((({data:o,chunkNumber:a})=>{const h=a*this.chunkSize;let c=0,d=this.chunkSize,u=t+(a-r)*this.chunkSize-l;a===r&&(u=t,c=l),a===s&&(d=n+i-h),o.copy(e,u,c,d)}))}_getChunk(e){const t=this.lruCache.get(e);if(t)return t;const i=this.fetch(e*this.chunkSize,this.chunkSize);return this.lruCache.set(e,i),i}}class ad{constructor(e={}){if(!(e.maxSize&&e.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=e.maxSize,this.cache=new Map,this.oldCache=new Map,this._size=0}_set(e,t){this.cache.set(e,t),this._size++,this._size>=this.maxSize&&(this._size=0,this.oldCache=this.cache,this.cache=new Map)}get(e){if(this.cache.has(e))return this.cache.get(e);if(this.oldCache.has(e)){const t=this.oldCache.get(e);return this._set(e,t),t}}set(e,t){return this.cache.has(e)?this.cache.set(e,t):this._set(e,t),this}has(e){return this.cache.has(e)||this.oldCache.has(e)}peek(e){return this.cache.has(e)?this.cache.get(e):this.oldCache.has(e)?this.oldCache.get(e):void 0}delete(e){const t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}*keys(){for(const[e]of this)yield e}*values(){for(const[,e]of this)yield e}*[Symbol.iterator](){for(const e of this.cache)yield e;for(const e of this.oldCache){const[t]=e;this.cache.has(t)||(yield e)}}get size(){let e=0;for(const t of this.oldCache.keys())this.cache.has(t)||e++;return this._size+e}}var ld={ALIGNMENT_MATCH:"M",INSERT:"I",DELETE:"D",SKIP:"N",CLIP_SOFT:"S",CLIP_HARD:"H",PAD:"P",SEQUENCE_MATCH:"=",SEQUENCE_MISMATCH:"X"};const hd=function(e,t){this.config=e,this.genome=t,this.url=e.url,this.filter=new Vc(e.filter),this.readGroupSetIds=e.readGroupSetIds,this.authKey=e.authKey,this.samplingWindowSize=void 0===e.samplingWindowSize?100:e.samplingWindowSize,this.samplingDepth=void 0===e.samplingDepth?1e3:e.samplingDepth,e.viewAsPairs?this.pairsSupported=!0:this.pairsSupported=void 0===e.pairsSupported||e.pairsSupported};hd.prototype.readAlignments=function(e,t,i){const n=this.genome,r=this;return(r.chrAliasTable?Promise.resolve(r.chrAliasTable):r.readMetadata().then((function(e){if(r.chrAliasTable={},n&&e.readGroups&&e.readGroups.length>0){var t=e.readGroups[0].referenceSetId;return t?Eh({url:r.url+"/references/search",body:{referenceSetId:t},decode:function(e){return e.references}}).then((function(e){return e.forEach((function(e){var t=e.name,i=n.getChromosomeName(t);r.chrAliasTable[i]=t})),r.chrAliasTable})):(function(e,t){var i;if("461916304629"===t||"337315832689"===t){for(i=1;i<23;i++)e["chr"+i]=i;e.chrX="X",e.chrY="Y",e.chrM="MT"}}(r.chrAliasTable,r.config.datasetId),r.chrAliasTable)}return r.chrAliasTable}))).then((function(n){var o=n.hasOwnProperty(e)?n[e]:e;return Eh({url:r.url+"/reads/search",body:{readGroupSetIds:[r.readGroupSetIds],referenceName:o,start:t,end:i,pageSize:"10000"},decode:s,results:new Cc(e,t,i,r.config)})}));function s(e){var t,i,s,o,a,l=e.alignments,h=l.length,c=[];for(t=0;t<h;t++){let e=l[t];(i=new Ic).readName=e.fragmentName,i.properPlacement=e.properPlacement,i.duplicateFragment=e.duplicateFragment,i.numberReads=e.numberReads,i.fragmentLength=e.fragmentLength,i.readNumber=e.readNumber,i.failedVendorQualityChecks=e.failedVendorQualityChecks,i.secondaryAlignment=e.secondaryAlignment,i.supplementaryAlignment=e.supplementaryAlignment,i.seq=e.alignedSequence,i.qual=e.alignedQuality,i.matePos=e.nextMatePosition,i.tagDict=e.info,i.flags=0,e.alignment?(i.mapped=!0,i.chr=e.alignment.position.referenceName,n&&(i.chr=n.getChromosomeName(i.chr)),i.start=parseInt(e.alignment.position.position),i.strand=!e.alignment.position.reverseStrand,i.mq=e.alignment.mappingQuality,i.cigar=d(e.alignment.cigar),s=u(e.alignment.cigar),i.lengthOnRef=s.lengthOnRef,a=f(i,s.array),i.blocks=a.blocks,i.insertions=a.insertions):i.mapped=!1,(o=e.nextMatePosition)&&(i.mate={chr:o.referenceFrame,position:parseInt(o.position),strand:!o.reverseStrand}),r.filter.pass(i)&&c.push(i)}return c;function d(e){var t="";return e.forEach((function(e){var i=ld[e.operation],n=e.operationLength;t+=n+i})),t}function u(e){var t,i,n,r,s=0,o=[];for(r=0;r<e.length;r++)t=e[r],n=ld[t.operation],i=parseInt(t.operationLength),"M"!==n&&"EQ"!==n&&"X"!==n&&"D"!==n&&"N"!==n&&"="!==n||(s+=i),o.push({len:i,ltr:n});return{lengthOnRef:s,array:o}}function f(e,t){for(var i,n,r,s=[],o=0,a=e.start,l=t.length,h=0;h<l;h++){var c=t[h];switch(c.ltr){case"H":case"P":break;case"S":o+=c.len,r="S";break;case"N":case"D":void 0===i&&(i=[]),i.push({start:a,len:c.len,type:c.ltr}),a+=c.len;break;case"I":void 0===n&&(n=[]),n.push(new Hc({start:a,len:c.len,seqOffset:o})),o+=c.len;break;case"M":case"EQ":case"=":case"X":s.push(new Hc({start:a,len:c.len,seqOffset:o,gapType:r})),o+=c.len,a+=c.len;break;default:console.log("Error processing cigar element: "+c.len+c.ltr)}}return{blocks:s,insertions:n,gaps:i}}}},hd.prototype.readMetadata=function(){return Ah({url:this.url,entity:"readgroupsets",entityId:this.readGroupSetIds})};class cd{constructor(e,t){const i=t.genome;if(this.config=e,this.genome=i,Fo(e.url)&&(this.config.indexed=!1),"ga4gh"===e.sourceType)this.bamReader=new hd(e,i);else if("pysam"===e.sourceType)this.bamReader=new ed(e,i);else if("htsget"===e.sourceType)this.bamReader=new id(e,i);else if("shardedBam"===e.sourceType)this.bamReader=new Jc(e,i);else if("cram"===e.format)this.bamReader=new rd(e,i,t);else{if(!this.config.indexURL&&!1!==e.indexed)if(Qt(this.config.url)){const e=$o(this.config.url,"bai");e?(console.error(`Warning: no indexURL specified for ${this.config.url}. Guessing ${this.baiPath}`),this.config.indexURL=e):(console.error(`Warning: no indexURL specified for ${this.config.url}.`),this.config.indexed=!1)}else console.error(`Warning: no indexURL specified for ${this.config.name}.`),this.config.indexed=!1;!1!==this.config.indexed?this.bamReader=new Kc(e,i):this.bamReader=new Yc(e,i)}this.viewAsPairs=e.viewAsPairs,this.showSoftClips=e.showSoftClips}setViewAsPairs(e){this.viewAsPairs=e}setShowSoftClips(e){this.showSoftClips=e}async getAlignments(e,t,i){const n=this.genome,r=this.showSoftClips,s=await this.bamReader.readAlignments(e,t,i);let o=s.alignments;this.viewAsPairs||(o=_c([{alignments:o}]));const a=o.length>0;if(s.packedAlignmentRows=xc(o,s.start,s.end,r),this.alignmentContainer=s,a){const t=await n.sequence.getSequence(e,s.start,s.end);if(t)return s.coverageMap.refSeq=t,s.sequence=t,s;console.error("No sequence for: "+e+":"+s.start+"-"+s.end)}return s}}function dd(e,t,i){var n,r,s,o,a,l,h,c={font:"normal 10px Arial",textAlign:"right",strokeStyle:"black"};if(void 0===this.dataRange||void 0===this.dataRange.max||void 0===this.dataRange.min)return;let d=void 0!==this.flipAxis&&this.flipAxis;function u(e){return 0===e?"0":Math.abs(e)>=10?e.toFixed():Math.abs(e)>=1?e.toFixed(1):e.toFixed(2)}Co.fillRect(e,0,0,t,i,{fillStyle:"rgb(255, 255, 255)"}),n=(h=.95*t)-8,a={x:r=h,y:s=o=.01*i},Co.strokeLine(e,n,s,r,o,c),Co.fillText(e,u(d?this.dataRange.min:this.dataRange.max),n+4,s+12,c),l={x:r,y:s=o=.99*i},Co.strokeLine(e,n,s,r,o,c),Co.fillText(e,u(d?this.dataRange.max:this.dataRange.min),n+4,s-4,c),Co.strokeLine(e,a.x,a.y,l.x,l.y,c)}class ud{constructor({chr:e,start:t,end:i}){this.chr=e,this.start=t,this.end=i}contains(e){return e.chr===this.chr&&e.start>=this.start&&e.end<=this.end}overlaps(e){return e.chr===this.chr&&!(e.end<this.start||e.start>this.end)}extend(e){e.chr===this.chr&&(this.start=Math.min(e.start,this.start),this.end=Math.max(e.end,this.end))}getLocusString(){if("all"===this.chr)return"all";{const e=Xt(Math.floor(this.start)+1),t=Xt(Math.round(this.end));return`${this.chr}:${e}-${t}`}}static fromLocusString(e){if("all"===e)return new ud({chr:"all"});const t=e.split(":"),i=t[0],n=t[1].split("-"),r=Number.parseInt(n[0].replace(/,/g,""))-1,s=Number.parseInt(n[1].replace(/,/g,""));return new ud({chr:i,start:r,end:s})}}
/*!
* vanilla-picker v2.12.1
* https://vanilla-picker.js.org
*
* Copyright 2017-2021 Andreas Borgen (https://github.com/Sphinxxxx), Adam Brooks (https://github.com/dissimulate)
* Released under the ISC license.
*/var fd=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},pd=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),gd=function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var i=[],n=!0,r=!1,s=void 0;try{for(var o,a=e[Symbol.iterator]();!(n=(o=a.next()).done)&&(i.push(o.value),!t||i.length!==t);n=!0);}catch(e){r=!0,s=e}finally{try{!n&&a.return&&a.return()}finally{if(r)throw s}}return i}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")};String.prototype.startsWith=String.prototype.startsWith||function(e){return 0===this.indexOf(e)},String.prototype.padStart=String.prototype.padStart||function(e,t){for(var i=this;i.length<e;)i=t+i;return i};var md={cb:"0f8ff",tqw:"aebd7",q:"-ffff",qmrn:"7fffd4",zr:"0ffff",bg:"5f5dc",bsq:"e4c4",bck:"---",nch:"ebcd",b:"--ff",bvt:"8a2be2",brwn:"a52a2a",brw:"deb887",ctb:"5f9ea0",hrt:"7fff-",chcT:"d2691e",cr:"7f50",rnw:"6495ed",crns:"8dc",crms:"dc143c",cn:"-ffff",Db:"--8b",Dcn:"-8b8b",Dgnr:"b8860b",Dgr:"a9a9a9",Dgrn:"-64-",Dkhk:"bdb76b",Dmgn:"8b-8b",Dvgr:"556b2f",Drng:"8c-",Drch:"9932cc",Dr:"8b--",Dsmn:"e9967a",Dsgr:"8fbc8f",DsTb:"483d8b",DsTg:"2f4f4f",Dtrq:"-ced1",Dvt:"94-d3",ppnk:"1493",pskb:"-bfff",mgr:"696969",grb:"1e90ff",rbrc:"b22222",rwht:"af0",stg:"228b22",chs:"-ff",gnsb:"dcdcdc",st:"8f8ff",g:"d7-",gnr:"daa520",gr:"808080",grn:"-8-0",grnw:"adff2f",hnw:"0fff0",htpn:"69b4",nnr:"cd5c5c",ng:"4b-82",vr:"0",khk:"0e68c",vnr:"e6e6fa",nrb:"0f5",wngr:"7cfc-",mnch:"acd",Lb:"add8e6",Lcr:"08080",Lcn:"e0ffff",Lgnr:"afad2",Lgr:"d3d3d3",Lgrn:"90ee90",Lpnk:"b6c1",Lsmn:"a07a",Lsgr:"20b2aa",Lskb:"87cefa",LsTg:"778899",Lstb:"b0c4de",Lw:"e0",m:"-ff-",mgrn:"32cd32",nn:"af0e6",mgnt:"-ff",mrn:"8--0",mqm:"66cdaa",mmb:"--cd",mmrc:"ba55d3",mmpr:"9370db",msg:"3cb371",mmsT:"7b68ee","":"-fa9a",mtr:"48d1cc",mmvt:"c71585",mnLb:"191970",ntc:"5fffa",mstr:"e4e1",mccs:"e4b5",vjw:"dead",nv:"--80",c:"df5e6",v:"808-0",vrb:"6b8e23",rng:"a5-",rngr:"45-",rch:"da70d6",pgnr:"eee8aa",pgrn:"98fb98",ptrq:"afeeee",pvtr:"db7093",ppwh:"efd5",pchp:"dab9",pr:"cd853f",pnk:"c0cb",pm:"dda0dd",pwrb:"b0e0e6",prp:"8-080",cc:"663399",r:"--",sbr:"bc8f8f",rb:"4169e1",sbrw:"8b4513",smn:"a8072",nbr:"4a460",sgrn:"2e8b57",ssh:"5ee",snn:"a0522d",svr:"c0c0c0",skb:"87ceeb",sTb:"6a5acd",sTgr:"708090",snw:"afa",n:"-ff7f",stb:"4682b4",tn:"d2b48c",t:"-8080",thst:"d8bfd8",tmT:"6347",trqs:"40e0d0",vt:"ee82ee",whT:"5deb3",wht:"",hts:"5f5f5",w:"-",wgrn:"9acd32"};function bd(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return(t>0?e.toFixed(t).replace(/0+$/,"").replace(/\.$/,""):e.toString())||"0"}var wd=function(){function e(t,i,n,r){fd(this,e);var s=this;if(void 0===t);else if(Array.isArray(t))this.rgba=t;else if(void 0===n){var o=t&&""+t;o&&function(t){if(t.startsWith("hsl")){var i=t.match(/([\-\d\.e]+)/g).map(Number),n=gd(i,4),r=n[0],o=n[1],a=n[2],l=n[3];void 0===l&&(l=1),r/=360,o/=100,a/=100,s.hsla=[r,o,a,l]}else if(t.startsWith("rgb")){var h=t.match(/([\-\d\.e]+)/g).map(Number),c=gd(h,4),d=c[0],u=c[1],f=c[2],p=c[3];void 0===p&&(p=1),s.rgba=[d,u,f,p]}else t.startsWith("#")?s.rgba=e.hexToRgb(t):s.rgba=e.nameToRgb(t)||e.hexToRgb(t)}(o.toLowerCase())}else this.rgba=[t,i,n,void 0===r?1:r]}return pd(e,[{key:"printRGB",value:function(e){var t=(e?this.rgba:this.rgba.slice(0,3)).map((function(e,t){return bd(e,3===t?3:0)}));return e?"rgba("+t+")":"rgb("+t+")"}},{key:"printHSL",value:function(e){var t=[360,100,100,1],i=["","%","%",""],n=(e?this.hsla:this.hsla.slice(0,3)).map((function(e,n){return bd(e*t[n],3===n?3:1)+i[n]}));return e?"hsla("+n+")":"hsl("+n+")"}},{key:"printHex",value:function(e){var t=this.hex;return e?t:t.substring(0,7)}},{key:"rgba",get:function(){if(this._rgba)return this._rgba;if(!this._hsla)throw new Error("No color is set");return this._rgba=e.hslToRgb(this._hsla)},set:function(e){3===e.length&&(e[3]=1),this._rgba=e,this._hsla=null}},{key:"rgbString",get:function(){return this.printRGB()}},{key:"rgbaString",get:function(){return this.printRGB(!0)}},{key:"hsla",get:function(){if(this._hsla)return this._hsla;if(!this._rgba)throw new Error("No color is set");return this._hsla=e.rgbToHsl(this._rgba)},set:function(e){3===e.length&&(e[3]=1),this._hsla=e,this._rgba=null}},{key:"hslString",get:function(){return this.printHSL()}},{key:"hslaString",get:function(){return this.printHSL(!0)}},{key:"hex",get:function(){return"#"+this.rgba.map((function(e,t){return t<3?e.toString(16):Math.round(255*e).toString(16)})).map((function(e){return e.padStart(2,"0")})).join("")},set:function(t){this.rgba=e.hexToRgb(t)}}],[{key:"hexToRgb",value:function(e){var t=(e.startsWith("#")?e.slice(1):e).replace(/^(\w{3})$/,"$1F").replace(/^(\w)(\w)(\w)(\w)$/,"$1$1$2$2$3$3$4$4").replace(/^(\w{6})$/,"$1FF");if(!t.match(/^([0-9a-fA-F]{8})$/))throw new Error("Unknown hex color; "+e);var i=t.match(/^(\w\w)(\w\w)(\w\w)(\w\w)$/).slice(1).map((function(e){return parseInt(e,16)}));return i[3]=i[3]/255,i}},{key:"nameToRgb",value:function(t){var i=t.toLowerCase().replace("at","T").replace(/[aeiouyldf]/g,"").replace("ght","L").replace("rk","D").slice(-5,4),n=md[i];return void 0===n?n:e.hexToRgb(n.replace(/\-/g,"00").padStart(6,"f"))}},{key:"rgbToHsl",value:function(e){var t=gd(e,4),i=t[0],n=t[1],r=t[2],s=t[3];i/=255,n/=255,r/=255;var o=Math.max(i,n,r),a=Math.min(i,n,r),l=void 0,h=void 0,c=(o+a)/2;if(o===a)l=h=0;else{var d=o-a;switch(h=c>.5?d/(2-o-a):d/(o+a),o){case i:l=(n-r)/d+(n<r?6:0);break;case n:l=(r-i)/d+2;break;case r:l=(i-n)/d+4}l/=6}return[l,h,c,s]}},{key:"hslToRgb",value:function(e){var t=gd(e,4),i=t[0],n=t[1],r=t[2],s=t[3],o=void 0,a=void 0,l=void 0;if(0===n)o=a=l=r;else{var h=function(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+(t-e)*(2/3-i)*6:e},c=r<.5?r*(1+n):r+n-r*n,d=2*r-c;o=h(d,c,i+1/3),a=h(d,c,i),l=h(d,c,i-1/3)}var u=[255*o,255*a,255*l].map(Math.round);return u[3]=s,u}}]),e}(),vd=function(){function e(){fd(this,e),this._events=[]}return pd(e,[{key:"add",value:function(e,t,i){e.addEventListener(t,i,!1),this._events.push({target:e,type:t,handler:i})}},{key:"remove",value:function(t,i,n){this._events=this._events.filter((function(r){var s=!0;return t&&t!==r.target&&(s=!1),i&&i!==r.type&&(s=!1),n&&n!==r.handler&&(s=!1),s&&e._doRemove(r.target,r.type,r.handler),!s}))}},{key:"destroy",value:function(){this._events.forEach((function(t){return e._doRemove(t.target,t.type,t.handler)})),this._events=[]}}],[{key:"_doRemove",value:function(e,t,i){e.removeEventListener(t,i,!1)}}]),e}();function yd(e,t,i){var n=!1;function r(e,t,i){return Math.max(t,Math.min(e,i))}function s(e,s,o){if(o&&(n=!0),n){e.preventDefault();var a=t.getBoundingClientRect(),l=a.width,h=a.height,c=s.clientX,d=s.clientY,u=r(c-a.left,0,l),f=r(d-a.top,0,h);i(u/l,f/h)}}function o(e,t){1===(void 0===e.buttons?e.which:e.buttons)?s(e,e,t):n=!1}function a(e,t){1===e.touches.length?s(e,e.touches[0],t):n=!1}e.add(t,"mousedown",(function(e){o(e,!0)})),e.add(t,"touchstart",(function(e){a(e,!0)})),e.add(window,"mousemove",o),e.add(t,"touchmove",a),e.add(window,"mouseup",(function(e){n=!1})),e.add(t,"touchend",(function(e){n=!1})),e.add(t,"touchcancel",(function(e){n=!1}))}var _d="keydown",xd="mousedown",kd="focusin";function Cd(e,t){return(t||document).querySelector(e)}function Sd(e){e.preventDefault(),e.stopPropagation()}function Ad(e,t,i,n,r){e.add(t,_d,(function(e){i.indexOf(e.key)>=0&&(r&&Sd(e),n(e))}))}var Ed=function(){function e(t){fd(this,e),this.settings={popup:"right",layout:"default",alpha:!0,editor:!0,editorFormat:"hex",cancelButton:!1,defaultColor:"#0cf"},this._events=new vd,this.onChange=null,this.onDone=null,this.onOpen=null,this.onClose=null,this.setOptions(t)}return pd(e,[{key:"setOptions",value:function(e){var t=this;if(e){var i=this.settings;if(e instanceof HTMLElement)i.parent=e;else{i.parent&&e.parent&&i.parent!==e.parent&&(this._events.remove(i.parent),this._popupInited=!1),function(e,t,i){for(var n in e)i&&i.indexOf(n)>=0||(t[n]=e[n])}(e,i),e.onChange&&(this.onChange=e.onChange),e.onDone&&(this.onDone=e.onDone),e.onOpen&&(this.onOpen=e.onOpen),e.onClose&&(this.onClose=e.onClose);var n=e.color||e.colour;n&&this._setColor(n)}var r=i.parent;if(r&&i.popup&&!this._popupInited){var s=function(e){return t.openHandler(e)};this._events.add(r,"click",s),Ad(this._events,r,[" ","Spacebar","Enter"],s),this._popupInited=!0}else e.parent&&!i.popup&&this.show()}}},{key:"openHandler",value:function(e){if(this.show()){e&&e.preventDefault(),this.settings.parent.style.pointerEvents="none";var t=e&&e.type===_d?this._domEdit:this.domElement;setTimeout((function(){return t.focus()}),100),this.onOpen&&this.onOpen(this.colour)}}},{key:"closeHandler",value:function(e){var t=e&&e.type,i=!1;if(e)if(t===xd||t===kd){var n=(this.__containedEvent||0)+100;e.timeStamp>n&&(i=!0)}else Sd(e),i=!0;else i=!0;i&&this.hide()&&(this.settings.parent.style.pointerEvents="",t!==xd&&this.settings.parent.focus(),this.onClose&&this.onClose(this.colour))}},{key:"movePopup",value:function(e,t){this.closeHandler(),this.setOptions(e),t&&this.openHandler()}},{key:"setColor",value:function(e,t){this._setColor(e,{silent:t})}},{key:"_setColor",value:function(e,t){if("string"==typeof e&&(e=e.trim()),e){t=t||{};var i=void 0;try{i=new wd(e)}catch(e){if(t.failSilently)return;throw e}if(!this.settings.alpha){var n=i.hsla;n[3]=1,i.hsla=n}this.colour=this.color=i,this._setHSLA(null,null,null,null,t)}}},{key:"setColour",value:function(e,t){this.setColor(e,t)}},{key:"show",value:function(){if(!this.settings.parent)return!1;if(this.domElement){var e=this._toggleDOM(!0);return this._setPosition(),e}var t=function(e){var t=document.createElement("div");return t.innerHTML=e,t.firstElementChild}(this.settings.template||'<div class="picker_wrapper" tabindex="-1"><div class="picker_arrow"></div><div class="picker_hue picker_slider"><div class="picker_selector"></div></div><div class="picker_sl"><div class="picker_selector"></div></div><div class="picker_alpha picker_slider"><div class="picker_selector"></div></div><div class="picker_editor"><input aria-label="Type a color name or hex value"/></div><div class="picker_sample"></div><div class="picker_done"><button>Ok</button></div><div class="picker_cancel"><button>Cancel</button></div></div>');return this.domElement=t,this._domH=Cd(".picker_hue",t),this._domSL=Cd(".picker_sl",t),this._domA=Cd(".picker_alpha",t),this._domEdit=Cd(".picker_editor input",t),this._domSample=Cd(".picker_sample",t),this._domOkay=Cd(".picker_done button",t),this._domCancel=Cd(".picker_cancel button",t),t.classList.add("layout_"+this.settings.layout),this.settings.alpha||t.classList.add("no_alpha"),this.settings.editor||t.classList.add("no_editor"),this.settings.cancelButton||t.classList.add("no_cancel"),this._ifPopup((function(){return t.classList.add("popup")})),this._setPosition(),this.colour?this._updateUI():this._setColor(this.settings.defaultColor),this._bindEvents(),!0}},{key:"hide",value:function(){return this._toggleDOM(!1)}},{key:"destroy",value:function(){this._events.destroy(),this.domElement&&this.settings.parent.removeChild(this.domElement)}},{key:"_bindEvents",value:function(){var e=this,t=this,i=this.domElement,n=this._events;function r(e,t,i){n.add(e,t,i)}r(i,"click",(function(e){return e.preventDefault()})),yd(n,this._domH,(function(e,i){return t._setHSLA(e)})),yd(n,this._domSL,(function(e,i){return t._setHSLA(null,e,1-i)})),this.settings.alpha&&yd(n,this._domA,(function(e,i){return t._setHSLA(null,null,null,1-i)}));var s=this._domEdit;r(s,"input",(function(e){t._setColor(this.value,{fromEditor:!0,failSilently:!0})})),r(s,"focus",(function(e){var t=this;t.selectionStart===t.selectionEnd&&t.select()})),this._ifPopup((function(){var t=function(t){return e.closeHandler(t)};r(window,xd,t),r(window,kd,t),Ad(n,i,["Esc","Escape"],t);var s=function(t){e.__containedEvent=t.timeStamp};r(i,xd,s),r(i,kd,s),r(e._domCancel,"click",t)}));var o=function(t){e._ifPopup((function(){return e.closeHandler(t)})),e.onDone&&e.onDone(e.colour)};r(this._domOkay,"click",o),Ad(n,i,["Enter"],o)}},{key:"_setPosition",value:function(){var e=this.settings.parent,t=this.domElement;e!==t.parentNode&&e.appendChild(t),this._ifPopup((function(i){"static"===getComputedStyle(e).position&&(e.style.position="relative");var n=!0===i?"popup_right":"popup_"+i;["popup_top","popup_bottom","popup_left","popup_right"].forEach((function(e){e===n?t.classList.add(e):t.classList.remove(e)})),t.classList.add(n)}))}},{key:"_setHSLA",value:function(e,t,i,n,r){r=r||{};var s=this.colour,o=s.hsla;[e,t,i,n].forEach((function(e,t){(e||0===e)&&(o[t]=e)})),s.hsla=o,this._updateUI(r),this.onChange&&!r.silent&&this.onChange(s)}},{key:"_updateUI",value:function(e){if(this.domElement){e=e||{};var t=this.colour,i=t.hsla,n="hsl("+360*i[0]+", 100%, 50%)",r=t.hslString,s=t.hslaString,o=this._domH,a=this._domSL,l=this._domA,h=Cd(".picker_selector",o),c=Cd(".picker_selector",a),d=Cd(".picker_selector",l);w(0,h,i[0]),this._domSL.style.backgroundColor=this._domH.style.color=n,w(0,c,i[1]),v(0,c,1-i[2]),a.style.color=r,v(0,d,1-i[3]);var u=r,f=u.replace("hsl","hsla").replace(")",", 0)"),p="linear-gradient("+[u,f]+")";if(this._domA.style.background=p+", linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%) 0 0 / 2em 2em,\n linear-gradient(45deg, lightgrey 25%, white 25%, white 75%, lightgrey 75%) 1em 1em / 2em 2em",!e.fromEditor){var g=this.settings.editorFormat,m=this.settings.alpha,b=void 0;switch(g){case"rgb":b=t.printRGB(m);break;case"hsl":b=t.printHSL(m);break;default:b=t.printHex(m)}this._domEdit.value=b}this._domSample.style.color=s}function w(e,t,i){t.style.left=100*i+"%"}function v(e,t,i){t.style.top=100*i+"%"}}},{key:"_ifPopup",value:function(e,t){this.settings.parent&&this.settings.popup?e&&e(this.settings.popup):t&&t()}},{key:"_toggleDOM",value:function(e){var t=this.domElement;if(!t)return!1;var i=e?"":"none",n=t.style.display!==i;return n&&(t.style.display=i),n}}]),e}(),Md=document.createElement("style");function Td(e){if(Rd[e])return Rd[e];if(Rd["chr"+e]){const t=Rd["chr"+e];return Rd[e]=t,t}{const r=(t=Math.round(255*Math.random()).toString(10),i=Math.round(255*Math.random()).toString(10),n=Math.round(255*Math.random()).toString(10),"rgb("+t+","+i+","+n+")");return Rd[e]=r,r}var t,i,n}Md.textContent='.picker_wrapper.no_alpha .picker_alpha{display:none}.picker_wrapper.no_editor .picker_editor{position:absolute;z-index:-1;opacity:0}.picker_wrapper.no_cancel .picker_cancel{display:none}.layout_default.picker_wrapper{display:flex;flex-flow:row wrap;justify-content:space-between;align-items:stretch;font-size:10px;width:25em;padding:.5em}.layout_default.picker_wrapper input,.layout_default.picker_wrapper button{font-size:1rem}.layout_default.picker_wrapper>*{margin:.5em}.layout_default.picker_wrapper::before{content:"";display:block;width:100%;height:0;order:1}.layout_default .picker_slider,.layout_default .picker_selector{padding:1em}.layout_default .picker_hue{width:100%}.layout_default .picker_sl{flex:1 1 auto}.layout_default .picker_sl::before{content:"";display:block;padding-bottom:100%}.layout_default .picker_editor{order:1;width:6.5rem}.layout_default .picker_editor input{width:100%;height:100%}.layout_default .picker_sample{order:1;flex:1 1 auto}.layout_default .picker_done,.layout_default .picker_cancel{order:1}.picker_wrapper{box-sizing:border-box;background:#f2f2f2;box-shadow:0 0 0 1px silver;cursor:default;font-family:sans-serif;color:#444;pointer-events:auto}.picker_wrapper:focus{outline:none}.picker_wrapper button,.picker_wrapper input{box-sizing:border-box;border:none;box-shadow:0 0 0 1px silver;outline:none}.picker_wrapper button:focus,.picker_wrapper button:active,.picker_wrapper input:focus,.picker_wrapper input:active{box-shadow:0 0 2px 1px #1e90ff}.picker_wrapper button{padding:.4em .6em;cursor:pointer;background-color:#f5f5f5;background-image:linear-gradient(0deg, gainsboro, transparent)}.picker_wrapper button:active{background-image:linear-gradient(0deg, transparent, gainsboro)}.picker_wrapper button:hover{background-color:#fff}.picker_selector{position:absolute;z-index:1;display:block;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%);border:2px solid #fff;border-radius:100%;box-shadow:0 0 3px 1px #67b9ff;background:currentColor;cursor:pointer}.picker_slider .picker_selector{border-radius:2px}.picker_hue{position:relative;background-image:linear-gradient(90deg, red, yellow, lime, cyan, blue, magenta, red);box-shadow:0 0 0 1px silver}.picker_sl{position:relative;box-shadow:0 0 0 1px silver;background-image:linear-gradient(180deg, white, rgba(255, 255, 255, 0) 50%),linear-gradient(0deg, black, rgba(0, 0, 0, 0) 50%),linear-gradient(90deg, #808080, rgba(128, 128, 128, 0))}.picker_alpha,.picker_sample{position:relative;background:linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%) 0 0/2em 2em,linear-gradient(45deg, lightgrey 25%, white 25%, white 75%, lightgrey 75%) 1em 1em/2em 2em;box-shadow:0 0 0 1px silver}.picker_alpha .picker_selector,.picker_sample .picker_selector{background:none}.picker_editor input{font-family:monospace;padding:.2em .4em}.picker_sample::before{content:"";position:absolute;display:block;width:100%;height:100%;background:currentColor}.picker_arrow{position:absolute;z-index:-1}.picker_wrapper.popup{position:absolute;z-index:2;margin:1.5em}.picker_wrapper.popup,.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{background:#f2f2f2;box-shadow:0 0 10px 1px rgba(0,0,0,.4)}.picker_wrapper.popup .picker_arrow{width:3em;height:3em;margin:0}.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{content:"";display:block;position:absolute;top:0;left:0;z-index:-99}.picker_wrapper.popup .picker_arrow::before{width:100%;height:100%;-webkit-transform:skew(45deg);transform:skew(45deg);-webkit-transform-origin:0 100%;transform-origin:0 100%}.picker_wrapper.popup .picker_arrow::after{width:150%;height:150%;box-shadow:none}.popup.popup_top{bottom:100%;left:0}.popup.popup_top .picker_arrow{bottom:0;left:0;-webkit-transform:rotate(-90deg);transform:rotate(-90deg)}.popup.popup_bottom{top:100%;left:0}.popup.popup_bottom .picker_arrow{top:0;left:0;-webkit-transform:rotate(90deg) scale(1, -1);transform:rotate(90deg) scale(1, -1)}.popup.popup_left{top:0;right:100%}.popup.popup_left .picker_arrow{top:0;right:0;-webkit-transform:scale(-1, 1);transform:scale(-1, 1)}.popup.popup_right{top:0;left:100%}.popup.popup_right .picker_arrow{top:0;left:0}',document.documentElement.firstElementChild.appendChild(Md),Ed.StyleElement=Md;const Rd={chrX:"rgb(204, 153, 0)",chrY:"rgb(153, 204, 0",chrUn:"rgb(50, 50, 50)",chr1:"rgb(80, 80, 255)",chrI:"rgb(139, 155, 187)",chr2:"rgb(206, 61, 50)",chrII:"rgb(206, 61, 50)",chr2a:"rgb(216, 71, 60)",chr2b:"rgb(226, 81, 70)",chr3:"rgb(116, 155, 88)",chrIII:"rgb(116, 155, 88)",chr4:"rgb(240, 230, 133)",chrIV:"rgb(240, 230, 133)",chr5:"rgb(70, 105, 131)",chr6:"rgb(186, 99, 56)",chr7:"rgb(93, 177, 221)",chr8:"rgb(128, 34, 104)",chr9:"rgb(107, 215, 107)",chr10:"rgb(213, 149, 167)",chr11:"rgb(146, 72, 34)",chr12:"rgb(131, 123, 141)",chr13:"rgb(199, 81, 39)",chr14:"rgb(213, 143, 92)",chr15:"rgb(122, 101, 165)",chr16:"rgb(228, 175, 105)",chr17:"rgb(59, 27, 83)",chr18:"rgb(205, 222, 183)",chr19:"rgb(97, 42, 121)",chr20:"rgb(174, 31, 99)",chr21:"rgb(231, 199, 111)",chr22:"rgb(90, 101, 94)",chr23:"rgb(204, 153, 0)",chr24:"rgb(153, 204, 0)",chr25:"rgb(51, 204, 0)",chr26:"rgb(0, 204, 51)",chr27:"rgb(0, 204, 153)",chr28:"rgb(0, 153, 204)",chr29:"rgb(10, 71, 255)",chr30:"rgb(71, 117, 255)",chr31:"rgb(255, 194, 10)",chr32:"rgb(255, 209, 71)",chr33:"rgb(153, 0, 51)",chr34:"rgb(153, 26, 0)",chr35:"rgb(153, 102, 0)",chr36:"rgb(128, 153, 0)",chr37:"rgb(51, 153, 0)",chr38:"rgb(0, 153, 26)",chr39:"rgb(0, 153, 102)",chr40:"rgb(0, 128, 153)",chr41:"rgb(0, 51, 153)",chr42:"rgb(26, 0, 153)",chr43:"rgb(102, 0, 153)",chr44:"rgb(153, 0, 128)",chr45:"rgb(214, 0, 71)",chr46:"rgb(255, 20, 99)",chr47:"rgb(0, 214, 143)",chr48:"rgb(20, 255, 177)"};class Ld{constructor(e){this.tracks=[],this.chordSets=[]}addChordSet(e){this.chordSets=this.chordSets.filter((t=>t.name!==e.name)),this.chordSets.push(e);let t=this.tracks.find((t=>e.trackName===t.name));t&&(t.chordSets=t.chordSets.filter((t=>t.name!==e.name)),t.chordSets.push(e)),t||(t=new Id(e),this.tracks.push(t))}clearChords(){this.tracks=[],this.chordSets=[]}getTrack(e){return this.tracks.find((t=>e===t.name))}getChordSet(e){return this.chordSets.find((t=>e===t.name))}}class Id{constructor(e){this.name=e.trackName,this.color=e.trackColor,this.visible=!0,this.chordSets=[e],this.id=("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)}get chords(){if(1===this.chordSets.length)return this.chordSets[0].chords;const e=[];for(let t of this.chordSets)for(let i of t.chords)e.push(i);return e}}const Bd=Math.exp(5);class Fd{static isInstalled(){return void 0!==window.JBrowseReactCircularGenomeView&&void 0!==window.React&&void 0!==window.ReactDOM}constructor(e,t){if(t=t||{},this.config=t,Fd.isInstalled()){this.parent=e,this.groupByTrack=!0===t.groupByTrack,this.chordManager=new Ld(t);const i=document.createElement("div");i.className="igv-circview-container",e.appendChild(i),this.createControls(i),this.resetControlPanel();const n=document.createElement("div");n.className="igv-circview-circular-genome-view",i.appendChild(n),this.container=n,t.assembly&&this.setAssembly(t.assembly),this.width=t.width||500,this.height=t.height||500,this.setSize(this.width,this.height)}else console.error("JBrowse circular view is not installed")}createControls(e){const t=document.createElement("div");t.className="igv-circview-toolbar",e.appendChild(t),this.toolbar=t;const i=document.createElement("div");i.className="igv-circview-track-panel",e.appendChild(i),this.controlPanel=i,this.controlPanel.style.display="none";const n=document.createElement("div");n.className="igv-circview-toolbar-button-container",this.toolbar.appendChild(n),this.showControlsButton=document.createElement("div"),this.showControlsButton.className="igv-circview-button",n.appendChild(this.showControlsButton),this.showControlsButton.innerText="none"===this.controlPanel.style.display?"Show Controls":"Hide Controls",this.showControlsButton.addEventListener("click",(e=>{this.controlPanel.querySelectorAll("div").length>0&&("none"===this.controlPanel.style.display?(this.controlPanel.style.display="flex",e.target.innerText="Hide Controls"):(this.controlPanel.style.display="none",e.target.innerText="Show Controls"))}));let r=document.createElement("div");r.className="igv-circview-button",n.appendChild(r),r.innerText="Clear All",r.addEventListener("click",(()=>{this.clearChords()})),!1!==this.config.showCloseButton&&(r=document.createElement("div"),r.className="igv-circview-button",n.appendChild(r),r.innerText="Close",r.addEventListener("click",(()=>{this.visible=!1})))}resetControlPanel(){this.controlPanel.innerHTML="",this.controlPanel.appendChild(this.createGroupByCB());const e=this.groupByTrack?this.chordManager.tracks:this.chordManager.chordSets;for(let t of e)this.addToControlPanel(t)}createGroupByCB(){const e=document.createElement("input");e.type="checkbox",e.id="groupByCB",e.style.width="1.4em",e.style.height="1.4em",e.checked=this.groupByTrack,e.onclick=e=>{this.groupByTrack=e.target.checked,this.resetControlPanel(),this.render()};const t=document.createElement("label");t.for="groupByCB",t.innerText="Group by track",t.style.color="black",t.style.paddingLeft="10px";const i=document.createElement("div");return i.style.width="100%",i.style.paddingTop="5px",i.style.paddingBottom="5px",i.style.background="rgb(216, 230, 234)",i.appendChild(e),i.appendChild(t),i}addToControlPanel(e){const t=document.createElement("div");this.controlPanel.appendChild(t);const i=document.createElement("div");i.className="igv-circview-button",t.appendChild(i),i.innerText=!0===e.visible?"Hide":"Show",i.addEventListener("click",(t=>{!0===e.visible?(this.hideChordSet(e.name),t.target.innerText="Show"):(this.showChordSet(e.name),t.target.innerText="Hide")}));const n=document.createElement("input"),r=e=>200*Math.log(e*Bd),s=document.createElement("div");s.className="igv-circview-button",s.innerHTML=" ",t.appendChild(s),s.style.backgroundColor=Nd(e.color,1);const o={parent:s,popup:"right",editorFormat:"rgb",color:e.color,onChange:({rgbaString:t})=>{s.style.backgroundColor=Nd(t,1),this.setColor(e.name,t),n.value=r(Od(e.color))}},a=new Ed(o);n.setAttribute("title","Adjust transparency of arcs"),n.type="range",n.style.width="100px",n.style.marginRight="10px",n.setAttribute("class","range"),n.setAttribute("min","0"),n.setAttribute("max","1000"),n.value=r(Od(e.color)),n.oninput=()=>{const t=(i=n.value,Math.exp(i/200)/Bd);var i;this.setColor(e.name,Nd(e.color,t)),a.setColor(e.color)},t.appendChild(n);const l=document.createElement("div");l.style.color="black",t.appendChild(l),l.innerText=l.title=e.name}setAssembly(e){const t=this.genomeId||zd();if(this.genomeId===t)return;this.chordManager.clearChords(),this.genomeId=t,this.chrNames=new Set(e.chromosomes.map((e=>Pd(e.name))));const i=[],n=[];for(let t of e.chromosomes){const e=Pd(t.name);n.push(t.color||Td(e)),i.push({refName:e,uniqueId:e,start:0,end:t.bpLength})}this.assembly={name:e.name,sequence:{trackId:t,type:"ReferenceSequenceTrack",adapter:{type:"FromConfigSequenceAdapter",features:i}},refNameColors:n},this.render()}addChords(e,t={}){const i=t.name||t.track||"*",n=i.split(" ")[0].replaceAll("%20"," "),r={name:i.replaceAll("%20"," "),trackName:n,chords:e,color:t.color||"black",trackColor:t.trackColor||t.color||"black",visible:!0,id:t.id||zd()};this.chordManager.addChordSet(r),this.resetControlPanel(),this.render()}setSize(e,t){if(t=t||e,this.width=e,this.height=t,this.viewState){const i=this.viewState.session.view;i.setWidth(e),i.setHeight(t),i.setBpPerPx(i.minBpPerPx)}}getSize(){return Math.min(this.width,this.height)}clearChords(){this.chordManager.clearChords(),this.resetControlPanel(),this.render()}clearSelection(){this.viewState.pluginManager.rootModel.session.clearSelection()}show(){this.parent.style.display="block"}hide(){this.parent.style.display="none"}get visible(){return"none"!==this.parent.style.display}set visible(e){this.parent.style.display=e?"block":"none"}hideChordSet(e){let t=this.getChordSet(e);t?(t.visible=!1,this.render()):console.warn(`No track with name: ${name}`)}showChordSet(e){let t=this.getChordSet(e);t?(t.visible=!0,this.render()):console.warn(`No track with name: ${e}`)}deleteTrack(e){let t=this.tracks.findIndex((t=>e===t.name));t>=0&&this.tracks.splice(t,1),this.render()}getChordSet(e){return this.groupByTrack?this.chordManager.getTrack(e):this.chordManager.getChordSet(e)}setColor(e,t){const i=this.getChordSet(e);if(i){i.color=t;const e=i.id;for(let i of this.viewState.config.tracks)if(e===i.trackId){i.displays[0].renderer.strokeColor.set(t);break}}}render(){const{createViewState:e,JBrowseCircularGenomeView:t}=JBrowseReactCircularGenomeView;ReactDOM.unmountComponentAtNode(this.container);const i=(this.groupByTrack?this.chordManager.tracks:this.chordManager.chordSets).filter((e=>e.visible)),n=[],r=[];for(let e of i)n.push({trackId:e.id,name:e.name,assemblyNames:["forIGV"],type:"VariantTrack",adapter:{type:"FromConfigAdapter",features:e.chords}}),r.push(e.color);this.viewState=e({assembly:this.assembly,tracks:n});for(let e=0;e<i.length;e++)this.viewState.config.tracks[e].displays[0].renderer.strokeColor.set(r[e]);this.element=React.createElement(t,{viewState:this.viewState}),this.setSize(this.width,this.height),ReactDOM.render(this.element,this.container);const s=this.config.onChordClick||Dd;for(let e=0;e<i.length;e++)this.viewState.session.view.showTrack(this.viewState.config.tracks[e].trackId),s&&(this.viewState.pluginManager.jexl.addFunction("onChordClick",s),this.viewState.config.tracks[e].displays[0].onChordClick.set("jexl:onChordClick(feature, track, pluginManager)"))}}function Nd(e,t){const[i,n,r,s]=e.split(",");return`${i},${n},${r},${t})`}function Od(e){return e.startsWith("rgba(")?Number(e.split(",")[3].replace(")","")):1}function Pd(e){return e.startsWith("chr")?e.substring(3):e}function Dd(e,t,i){console.log(e)}function zd(){return("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)}if("undefined"!=typeof document){function Xb(e){for(let t of document.styleSheets)if(t=t.href?t.href.replace(/^.*[\\\/]/,""):"",t===e)return!0;return!1}Xb("circular-view.css")||function(){const e=document.createElement("style");e.setAttribute("type","text/css"),e.innerHTML='.igv-circview-container {\n width: fit-content;\n height: fit-content;\n box-sizing: content-box;\n color: dimgray;\n font-family: "Open Sans", sans-serif;\n font-size: 12px;\n background-color: white;\n border-color: dimgray;\n border-style: solid;\n border-width: thin;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n}\n\n.igv-circview-toolbar {\n position: relative;\n width: 100%;\n height: 32px;\n background-color: lightgrey;\n border-bottom-style: solid;\n border-bottom-color: dimgray;\n border-bottom-width: thin;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n}\n\n.igv-circview-toolbar-button-container {\n height: 100%;\n width: fit-content;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-circview-toolbar-button-container > div {\n margin: 4px;\n}\n\n.igv-circview-track-panel {\n z-index: 1024;\n position: absolute;\n top: 33px;\n left: 0;\n width: 100%;\n height: fit-content;\n border-bottom-style: solid;\n border-bottom-color: dimgray;\n border-bottom-width: thin;\n background-color: white;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n}\n.igv-circview-track-panel > div {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-circview-track-panel > div > div {\n margin: 4px;\n}\n\n.igv-circview-swatch-button {\n cursor: pointer;\n padding: 5px;\n width: 8px;\n height: 8px;\n border: 1px solid #8d8b8b;\n border-radius: 16px;\n}\n\n.igv-circview-button {\n cursor: pointer;\n padding: 5px;\n color: #444;\n vertical-align: middle;\n text-align: center;\n font-family: "Open Sans", sans-serif;\n font-size: 12px;\n border: 1px solid #8d8b8b;\n border-radius: 4px;\n background: #efefef;\n box-shadow: 0 0 5px -1px rgba(0, 0, 0, 0.2);\n}\n\n.igv-circview-button:hover {\n background: #efefef;\n box-shadow: 0 0 5px -1px rgba(0, 0, 0, 0.6);\n}\n\n.igv-circview-button:active {\n color: #007bff;\n box-shadow: 0 0 5px -1px rgba(0, 0, 0, 0.6);\n}\n\n/*# sourceMappingURL=circular-view.css.map */\n',document.head.insertBefore(e,document.head.childNodes[document.head.childNodes.length-1])}()}const Hd=e=>e.startsWith("chr")?e.substring(3):e;function Vd(e){const t=[],i=[];for(let n of e.wgChromosomeNames){const r=e.getChromosome(n);i.push(mu(r.name)),t.push({name:r.name,bpLength:r.bpLength})}return t}function Ud(e,t,i,n){const r=t.color||"rgb(0,0,255)",s=Ds.addAlpha("all"===i.chr?r:mu(i.chr),n),o=Ds.addAlpha(r,n),a=t.name.replaceAll(" ","%20"),l="all"===i.chr?a:`${a} ${i.chr}:${i.start}-${i.end}`;t.browser.circularView.addChords(e,{track:l,color:s,trackColor:o}),t.browser.circularViewVisible||(t.browser.circularViewVisible=!0)}class qd{constructor(e,{minTLENPercentile:t,maxTLENPercentile:i}){this.totalCount=0,this.frCount=0,this.rfCount=0,this.ffCount=0,this.sumF=0,this.sumF2=0,this.lp=void 0===t?.1:t,this.up=void 0===i?99.5:i,this.isizes=[],this.compute(e)}compute(e){for(let n of e)if(n.isProperPair()){var t=Math.abs(n.fragmentLength);this.sumF+=t,this.sumF2+=t*t,this.isizes.push(t);var i=n.pairOrientation;if("string"==typeof i&&4===i.length)switch(""+i.charAt(0)+i.charAt(2)){case"FF":case"RR":this.ffCount++;break;case"FR":this.frCount++;break;case"RF":this.rfCount++}this.totalCount++}this.ffCount/this.totalCount>.9?this.orienation="ff":this.frCount/this.totalCount>.9?this.orienation="fr":this.rfCount/this.totalCount>.9&&(this.orienation="rf"),this.minTLEN=0===this.lp?0:jd(this.isizes,this.lp),this.maxTLEN=jd(this.isizes,this.up)}}function jd(e,t){if(0!==e.length){var i=Math.floor(e.length*(t/100));return e.sort((function(e,t){return e-t})),e[i]}}const $d={getTissueInfo:function(e,t){let i=(t=t||"https://gtexportal.org/rest/v1")+"/dataset/tissueInfo?datasetId="+(e=e||"gtex_v8");return no.loadJson(i,{})},trackConfiguration:function(e,t){return{type:"eqtl",sourceType:"gtex-ws",url:(t=t||"https://gtexportal.org/rest/v1")+"/association/singleTissueEqtlByLocation",tissueSiteDetailId:e.tissueSiteDetailId,name:e.tissueSiteDetailId.split("_").join(" "),visibilityWindow:25e4}}};function Wd(e,t,i){let n=(e.start-t)/i,r=(e.end-t)/i,s=r-n;return s<3&&(s=3,n-=1.5),{px:n,px1:r,pw:s}}function Gd(e,t,i,n,r,s){try{r.save(),r.fillStyle=this.color,r.strokeStyle=this.color;const n=this.getColorForFeature(e);let o,a;r.fillStyle=n,r.strokeStyle=n,"SQUISHED"===this.displayMode&&void 0!==e.row?(o=this.featureHeight/2,a=this.margin+this.squishedRowHeight*e.row):"EXPANDED"===this.displayMode&&void 0!==e.row?(o=this.featureHeight,a=this.margin+this.expandedRowHeight*e.row):(o=this.featureHeight,a=this.margin);const l=s.pixelWidth,h=a+o/2,c=o/2,d=h-c/2,u=e.exons?e.exons.length:0,f=Wd(e,t,i),p=this.arrowSpacing,g="+"===e.strand?1:"-"===e.strand?-1:0;if(0===u){const e=Math.max(0,f.px),t=Math.min(l,f.px1),i=t-e;if(r.fillRect(e,a,i,o),0!==g){r.fillStyle="white",r.strokeStyle="white";for(let i=e+p/2;i<t;i+=p)Co.strokeLine(r,i-2*g,h-2,i,h),Co.strokeLine(r,i-2*g,h+2,i,h);r.fillStyle=n,r.strokeStyle=n}}else{Co.strokeLine(r,f.px+1,h,f.px1-1,h);const s=Math.max(0,f.px)+p/2,m=Math.min(l,f.px1);for(let e=s;e<m;e+=p)Co.strokeLine(r,e-2*g,h-2,e,h),Co.strokeLine(r,e-2*g,h+2,e,h);for(let s=0;s<u;s++){const u=e.exons[s];let f,m=Math.round((u.start-t)/i),b=Math.round((u.end-t)/i),w=Math.max(1,b-m);if(!(m+w<0)){if(m>l)break;if(u.utr)r.fillRect(m,d,w,c);else if(u.cdStart&&(f=Math.round((u.cdStart-t)/i),r.fillRect(m,d,f-m,c),w-=f-m,m=f),u.cdEnd&&(f=Math.round((u.cdEnd-t)/i),r.fillRect(f,d,b-f,c),w-=b-f,b=f),w=Math.max(w,1),r.fillRect(m,a,w,o),w>p+5&&0!==g){r.fillStyle="white",r.strokeStyle="white";for(let e=m+p/2;e<b;e+=p)Co.strokeLine(r,e-2*g,h-2,e,h),Co.strokeLine(r,e-2*g,h+2,e,h);r.fillStyle=n,r.strokeStyle=n}}}}s.drawLabel&&"SQUISHED"!==this.displayMode&&Zd.call(this,r,e,f.px,f.px1,a,s.referenceFrame,s)}finally{r.restore()}}function Zd(e,t,i,n,r,s,o){try{e.save();let a=t.name;if(void 0===a&&t.gene&&(a=t.gene.name),void 0===a&&(a=t.id||t.ID),!a||"."===a)return;let l=o.pixelXOffset||0;const h=Math.max(i,-l);let c,d=(h+Math.min(n,-l+o.viewportWidth))/2;"COLLAPSED"===this.displayMode&&"SLANT"===this.labelDisplayMode&&(c={rotate:{angle:45}});const u=function(e,t){return t?e+20:e+25}(r,c);let f,p=this.getColorForFeature(t),g=!1;s.selection&&$d.gtexLoaded&&(g=!0,f=s.selection.colorForGene(a));const m={textAlign:"SLANT"===this.labelDisplayMode?void 0:"center",fillStyle:f||p,strokeStyle:f||p},b=e.measureText(a),w=d-b.width/2,v=d+b.width/2,y=o.rowLastLabelX[t.row]||-Number.MAX_SAFE_INTEGER;(o.labelAllFeatures||w>y||g)&&(o.rowLastLabelX[t.row]=v,"y"===o.axis?(e.save(),Co.labelTransformWithContext(e,d),Co.fillText(e,a,d,u,m,c),e.restore()):Co.fillText(e,a,d,u,m,c))}finally{e.restore()}}const Qd=new Set(["nonsense","missense","stop-loss","frameshift","cds-indel"]),Xd=new Set(["coding-synon"]),Yd=new Set(["splice-3","splice-5"]),Kd=new Set(["untranslated-5","untranslated-3"]);function Jd(e,t,i,n,r){var s,o,a,l,h=Wd(e,t,i),c=this.margin,d=this.snpColors.length;switch(s="squished"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight,this.colorBy){case"function":l=e.func,o=l.split(",").map((function(e){return Qd.has(e)||Yd.has(e)?d-1:Xd.has(e)?d-2:Kd.has(e)?d-3:0})).reduce((function(e,t){return Math.max(e,t)}));break;case"class":o="deletion"===(a=e.class)?d-1:"mnp"===a?d-2:"microsatellite"===a||"named"===a?d-3:0}r.fillStyle=this.snpColors[o],r.fillRect(h.px,c,h.pw,s)}function eu(e,t,i,n,r){const s="EXPANDED"===this.displayMode?this.expandedRowHeight:this.squishedRowHeight;let o=this.margin;"COLLAPSED"!==this.displayMode&&void 0!==e.row&&(o+=e.row*s);const a=o+.5*s,l=a-.5*s,h=a+.5*s,c=Math.round((e.junction_left-t)/i),d=Math.round((e.junction_right-t)/i);r.beginPath(),r.moveTo(c,a),r.bezierCurveTo(c,l,d,l,d,a),r.lineWidth=1+Math.log(e.num_junction_reads)/Math.log(2),r.strokeStyle="blue",r.stroke();const u=e.spanning_frag_coords;for(let e=0;e<u.length;e++){const n=u[e],s=Math.round((n.left-t)/i),o=Math.round((n.right-t)/i);r.beginPath(),r.moveTo(s,a),r.bezierCurveTo(s,h,o,h,o,a),r.lineWidth=1,r.strokeStyle="purple",r.stroke()}}class tu extends Ll{static defaults={type:"annotation",maxRows:1e3,displayMode:"EXPANDED",margin:10,featureHeight:14,autoHeight:!1,useScore:!1};constructor(e,t){super(e,t)}init(e){super.init(e),this.labelDisplayMode=e.labelDisplayMode,e._featureSource?(this.featureSource=e._featureSource,delete e._featureSource):this.featureSource=e.featureSource?e.featureSource:dc(e,this.browser.genome),"FusionJuncSpan"===e.type?(this.render=e.render||eu,this.squishedRowHeight=e.squishedRowHeight||50,this.expandedRowHeight=e.expandedRowHeight||50,this.height=e.height||this.margin+2*this.expandedRowHeight):"snp"===e.type?(this.render=e.render||Jd,this.snpColors=["rgb(0,0,0)","rgb(0,0,255)","rgb(0,255,0)","rgb(255,0,0)"],this.colorBy="function",this.expandedRowHeight=e.expandedRowHeight||10,this.squishedRowHeight=e.squishedRowHeight||5,this.height=e.height||30):(this.render=e.render||Gd,this.arrowSpacing=30,function(e){e.browser.on&&(e.browser.on("trackdragend",t),e.browser.on("trackremoved",i));function t(){e.trackView&&"SQUISHED"!==e.displayMode&&e.trackView.updateViews()}function i(n){e.browser.un&&e===n&&(e.browser.un("trackdragend",t),e.browser.un("trackremoved",i))}}(this),this.squishedRowHeight=e.squishedRowHeight||15,this.expandedRowHeight=e.expandedRowHeight||30,this.height=e.height||this.margin+2*this.expandedRowHeight,e.colorBy&&(e.colorBy.field&&(e.colorTable=e.colorBy.pallete||e.colorBy.palette,e.colorBy=e.colorBy.field),this.colorBy=e.colorBy,e.colorTable?this.colorTable=new _o(e.colorTable):this.colorTable=new yo("Set1")))}async postInit(){if("function"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),void 0===this.visibilityWindow&&"function"==typeof this.featureSource.defaultVisibilityWindow&&(this.visibilityWindow=await this.featureSource.defaultVisibilityWindow()),this}get supportsWholeGenome(){return void 0!==this.config.supportsWholeGenome?this.config.supportsWholeGenome:this.featureSource&&"function"==typeof this.featureSource.supportsWholeGenome?this.featureSource.supportsWholeGenome():!(void 0!==this.visibilityWindow||!1!==this.config.indexed&&this.config.indexURL)||void 0}async getFeatures(e,t,i,n){const r=this.visibilityWindow;return this.featureSource.getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r})}computePixelHeight(e){if("COLLAPSED"===this.displayMode)return this.margin+this.expandedRowHeight;{let t=0;if(e&&"function"==typeof e.forEach)for(let i of e)i.row&&i.row>t&&(t=i.row);return this.margin+(t+1)*("SQUISHED"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight)}}draw(e){const t=e.features,i=e.context,n=e.bpPerPixel,r=e.bpStart,s=e.pixelWidth,o=e.pixelHeight,a=r+s*n+1;if(this.config.isMergedTrack||Co.fillRect(i,0,e.pixelTop,s,o,{fillStyle:"rgb(255, 255, 255)"}),t){const l=[];e.rowLastX=[],e.rowLastLabelX=[];for(let i of t)if(i.start>r&&i.end<a){const t="COLLAPSED"===this.displayMode?0:i.row||0;void 0===l[t]?l[t]=1:l[t]++,e.rowLastX[t]=-Number.MAX_SAFE_INTEGER,e.rowLastLabelX[t]=-Number.MAX_SAFE_INTEGER}const h=s/Math.max(1,Math.max(...l));let c=[];for(let s of t){if(s.end<r)continue;if(s.start>a)break;const t="COLLAPSED"===this.displayMode?0:s.row;e.drawLabel=e.labelAllFeatures||h>10;const l=Math.ceil((s.end-r)/n),d=c[t];if(!d||l>d){this.render.call(this,s,r,n,o,i,e);const a=Math.floor((s.start-r)/n);d&&a-d<=0&&(i.globalAlpha=.5,Co.strokeLine(i,a,0,a,o,{strokeStyle:"rgb(255, 255, 255)"}),i.globalAlpha=1),c[t]=l}}}else console.log("No feature list")}clickedFeatures(e){const t=e.y-this.margin,i=super.clickedFeatures(e);let n;switch(this.displayMode){case"SQUISHED":n=Math.floor(t/this.squishedRowHeight);break;case"EXPANDED":n=Math.floor(t/this.expandedRowHeight);break;default:n=void 0}return i.filter((function(e){return void 0===n||void 0===e.row||n===e.row}))}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=e.genomicLocation,n=[];for(let e of t){const t=e._f||e,r="function"==typeof t.popupData?t.popupData(i):this.extractPopupData(t);if(r){n.length>0&&n.push("<hr/><hr/>");const s=this.infoURL||this.config.infoURL;for(let t of r)if(n.push(t),s&&t.name&&"name"===t.name.toLowerCase()&&t.value&&Qt(t.value)&&!t.value.startsWith("<")){const i=s.replace("$$",e.name);t.value=`<a target=_blank href=${i}>${t.value}</a>`}const o="gff"===this.config.format||"gff3"===this.config.format||"gtf"===this.config.format;if(t.exons)for(let e=0;e<t.exons.length;e++){const r=t.exons[e];if(i>=r.start&&i<=r.end){const i=o?r.number:"-"===t.strand?t.exons.length-e:e+1;i&&(n.push("<hr/>"),n.push({name:"Exon Number",value:i}));break}}}}return n}menuItemList(){const e=[];if(this.render===Jd){e.push("<hr/>");for(let t of["function","class"])e.push({object:ft(jt("Color by "+t,t===this.colorBy)),click:()=>{this.colorBy=t,this.trackView.repaintViews()}})}e.push("<hr/>");for(let t of["COLLAPSED","SQUISHED","EXPANDED"]){const i={COLLAPSED:"Collapse",SQUISHED:"Squish",EXPANDED:"Expand"};e.push({object:ft(jt(i[t],t===this.displayMode)),click:()=>{this.displayMode=t,this.config.displayMode=t,this.trackView.checkContentHeight(),this.trackView.repaintViews()}})}return e}contextMenuItemList(e){const t=this.clickedFeatures(e);if(void 0===t||0===t.length)return;t.length>1&&t.sort(((e,t)=>t.end-t.start-(e.end-e.start)));const i=t[0];if(i.end-i.start<=1e6){const e=[{label:"View feature sequence",click:async()=>{let e=await this.browser.genome.getSequence(i.chr,i.start,i.end);e?"-"===i.strand&&(e=Yo(e)):e="Unknown sequence",this.browser.alert.present(e)}}];return Do()&&void 0!==navigator.clipboard&&e.push({label:"Copy feature sequence",click:async()=>{let e=await this.browser.genome.getSequence(i.chr,i.start,i.end);e?"-"===i.strand&&(e=Yo(e)):e="Unknown sequence";try{await navigator.clipboard.writeText(e)}catch(e){console.error(e),this.browser.alert.present(`error copying sequence to clipboard ${e}`)}}}),e.push("<hr/>"),e}}description(){if(Jd===this.render){let e="<html>"+this.name+"<hr/>";return e+="<em>Color By Function:</em><br>",e+='<span style="color:red">Red</span>: Coding-Non-Synonymous, Splice Site<br>',e+='<span style="color:green">Green</span>: Coding-Synonymous<br>',e+='<span style="color:blue">Blue</span>: Untranslated<br>',e+='<span style="color:black">Black</span>: Intron, Locus, Unknown<br><br>',e+="<em>Color By Class:</em><br>",e+='<span style="color:red">Red</span>: Deletion<br>',e+='<span style="color:green">Green</span>: MNP<br>',e+='<span style="color:blue">Blue</span>: Microsatellite, Named<br>',e+='<span style="color:black">Black</span>: Indel, Insertion, SNP',e+="</html>",e}return super.description()}getColorForFeature(e){let t;if(this.altColor&&"-"===e.strand)t="function"==typeof this.altColor?this.altColor(e):this.altColor;else if(this.color)t="function"==typeof this.color?this.color(e):this.color;else if(this.colorBy){const i=e.getAttributeValue?e.getAttributeValue(this.colorBy):e[this.colorBy];t=this.colorTable.getColor(i)}else t=e.color?e.color:this.color;if(e.alpha&&1!==e.alpha)t=Ds.addAlpha(t,e.alpha);else if(this.useScore&&e.score&&!Number.isNaN(e.score)){const i=function(e,t,i){const n=(t-e)/9,r=Math.floor((i-e)/n);return Math.min(1,.2+.8*r/9)}(this.config.min?this.config.min:this.viewLimitMin?this.viewLimitMin:0,this.config.max?this.config.max:this.viewLimitMax?this.viewLimitMax:1e3,e.score);e.alpha=i,t=Ds.addAlpha(t,i)}return t}dispose(){this.trackView=void 0}}class iu{constructor(e){this.config=e,this.browser=e.browser,this.columnFormat=e.columnFormat,this.tableRowSelectionList=[],this.tableDOM=_t.div({class:"igv-roi-table"}),e.parent.appendChild(this.tableDOM),this.headerDOM=e,this.tableColumnTitles=this.tableDOM,this.tableRowContainer=this.tableDOM,this.footerDOM=e.gotoButtonHandler}set headerDOM({browser:e,parent:t,headerTitle:i,dismissHandler:n}){const r=_t.div();this.tableDOM.appendChild(r);const s=_t.div();r.appendChild(s),s.innerHTML=i;const o=_t.div();r.appendChild(o),o.appendChild(At.createIcon("times")),this.boundDismissHandler=function(e){e.stopPropagation(),n()}.bind(this),o.addEventListener("click",this.boundDismissHandler);const{y:a}=e.root.getBoundingClientRect(),{y:l}=t.getBoundingClientRect(),h=-(l-a);Rt(this.tableDOM,r,{minX:0,minY:h}),this.tableDOM.style.display="none",this._headerDOM=r}set tableColumnTitles(e){const t=_t.div({class:"igv-roi-table-column-titles"});e.appendChild(t);for(const{label:e,width:i}of this.columnFormat){const n=_t.div();t.appendChild(n),n.style.width=i,n.innerText=e}this._tableColumnTitlesDOM=t}get tableColumnTitles(){return this._tableColumnTitlesDOM}set tableRowContainer(e){const t=_t.div({class:"igv-roi-table-row-container"});e.appendChild(t),this._tableRowContainerDOM=t}get tableRowContainer(){return this._tableRowContainerDOM}set footerDOM(e){const t=_t.div();this.tableDOM.appendChild(t);const i=_t.div({class:"igv-roi-table-button"});t.appendChild(i),i.id="igv-roi-table-view-button",i.textContent="Go To",i.style.pointerEvents="none",this._footerDOM=t,this.gotoButton=i,this.boundGotoButtonHandler=e.bind(this),this.gotoButton.addEventListener("click",this.boundGotoButtonHandler)}tableRowDOMHelper(e){e.addEventListener("mousedown",(t=>{t.stopPropagation(),e.classList.toggle("igv-roi-table-row-selected"),e.classList.contains("igv-roi-table-row-selected")?e.classList.remove("igv-roi-table-row-hover"):e.classList.add("igv-roi-table-row-hover"),this.setTableRowSelectionState(e.classList.contains("igv-roi-table-row-selected"))})),e.addEventListener("mouseover",(t=>{e.classList.contains("igv-roi-table-row-selected")?e.classList.remove("igv-roi-table-row-hover"):e.classList.add("igv-roi-table-row-hover")})),e.addEventListener("mouseout",(t=>{e.classList.remove("igv-roi-table-row-hover")}))}clearTable(){const e=this.tableRowContainer.querySelectorAll(".igv-roi-table-row");for(let t of e)t.remove()}setTableRowSelectionState(e){e?this.tableRowSelectionList.push(1):this.tableRowSelectionList.pop(),this.gotoButton.style.pointerEvents=this.tableRowSelectionList.length>0?"auto":"none"}present(){this.tableDOM.style.left="0px";const{y:e}=this.browser.root.getBoundingClientRect(),{y:t}=this.config.parent.getBoundingClientRect();this.tableDOM.style.top=e-t+"px",this.tableDOM.style.display="flex"}dismiss(){this.tableDOM.style.display="none"}dispose(){this.tableDOM.innerHTML="",this.tableDOM.remove();for(const e of Object.keys(this))this[e]=void 0;document.removeEventListener("click",this.boundDismissHandler)}}class nu extends iu{constructor(e){super(Object.assign({width:"1024px"},e)),this.descriptionDOM=e}set descriptionDOM(e){if(e.description){let t;t=_t.div({class:"igv-roi-table-description"}),this.tableDOM.insertBefore(t,this.tableColumnTitles),t.style.height="auto",t.innerHTML="BLAT result for query sequence:",t=_t.div({class:"igv-roi-table-description"}),this.tableDOM.insertBefore(t,this.tableColumnTitles),t.style.height="auto",t.style.maxHeight="128px",t.innerHTML=e.description,t=_t.div({class:"igv-roi-table-goto-explainer"}),this.tableDOM.insertBefore(t,this.tableColumnTitles),t.innerHTML="Select one or more rows and click Go To to view the regions"}}tableRowDOM(e){const t=_t.div({class:"igv-roi-table-row"}),i=e.map((e=>isFinite(e)?Xt(e):e));for(let e=0;e<i.length;e++){const n=_t.div();t.appendChild(n);const r=this.columnFormat[e];n.style.width=r.width||"fit-content",n.innerText=i[e]}return this.tableRowDOMHelper(t),t}renderTable(e){if(Array.from(this.tableRowContainer.querySelectorAll(".igv-roi-table-row")).forEach((e=>e.remove())),e.length>0)for(let t of e){const e=this.tableRowDOM(t);this.tableRowContainer.appendChild(e)}}static getColumnFormatConfiguration(){return[{label:"chr",width:"7%"},{label:"start",width:"12%"},{label:"end",width:"12%"},{label:"strand",width:"5%"},{label:"score",width:"5%"},{label:"match",width:"5%"},{label:"mis-match",width:"7%"},{label:"rep. match",width:"7%"},{label:"N's",width:"3%"},{label:"Q gap count",width:"9%"},{label:"Q gap bases",width:"9%"},{label:"T gap count",width:"9%"},{label:"T gap bases",width:"9%"}]}static gotoButtonHandler(e){e.stopPropagation();const t=this.tableDOM.querySelectorAll(".igv-roi-table-row-selected"),i=[];for(const e of t){const t=[];e.querySelectorAll("div").forEach((e=>t.push(e.innerText)));const[n,r,s]=t;i.push(`${n}:${r}-${s}`)}for(const e of this.tableDOM.querySelectorAll(".igv-roi-table-row"))e.classList.remove("igv-roi-table-row-selected");this.setTableRowSelectionState(!1),this.browser.search(i.join(" "))}}const ru="https://igv.org/services/blatUCSC.php";async function su({url:e,userSeq:t,db:i}){e=e||ru;const n=await async function(e="",t,i){const n=new URLSearchParams;n.append("userSeq",t),n.append("db",i);const r=await fetch(e,{method:"post",body:n});return r.json()}(e,t,i);n.fields;return n.blat.map(fl)}const ou=25e3;class au extends tu{constructor(e,t){super(e,t),this.name||(this.name="Blat Results"),this.sequence=e.sequence,this.table=void 0}openTableView(){if(void 0===this.table){const e=this.config.features.map((e=>[e.chr,e.start+1,e.end,e.strand,e.score,e.matches,e.misMatches,e.repMatches,e.nCount,e.qNumInsert,e.qBaseInsert,e.tNumInsert,e.tBaseInsert])),t={browser:this.browser,parent:this.browser.parent,headerTitle:this.config.title,description:this.sequence,dismissHandler:()=>{this.table.dismiss(),this.table.dispose(),this.table=void 0},columnFormat:nu.getColumnFormatConfiguration(),gotoButtonHandler:nu.gotoButtonHandler};this.table=new nu(t),this.table.renderTable(e)}this.table.present()}menuItemList(){const e=super.menuItemList();return e.push("<hr/>"),e.push({label:"Open table view",click:()=>this.openTableView()}),e}dispose(){super.dispose(),this.table&&this.table.popover.parentElement.removeChild(this.table.popover)}}async function lu({sequence:e,browser:t,name:i,title:n}){if(e.length>ou)return void t.alert.present(`Sequence size exceeds maximum allowed length (${e.length} > ${ou})`);const r=t.genome.id,s=t.config.blatServerURL;try{const o={type:"blat",name:i||"blat results",title:n||"blat results",sequence:e,altColor:"rgb(176, 176, 236)",color:"rgb(236, 176, 176)",features:await su({url:s,userSeq:e,db:r})};(await t.loadTrack(o)).openTableView()}catch(e){t.alert.present(`Error performing blat search: ${e}`)}}const hu="rgb(185, 185, 185)",cu="rgb(150, 150, 150)";class du extends Ll{static defaults={alleleFreqThreshold:.2,visibilityWindow:3e4,showCoverage:!0,showAlignments:!0,viewAsPairs:!1,pairsSupported:!0,showSoftClips:!1,showAllBases:!1,showInsertions:!0,showMismatches:!0,color:hu,coverageColor:cu,height:300,coverageTrackHeight:50};constructor(e,t){super(e,t)}init(e){this.type="alignment",this.featureSource=new cd(e,this.browser),this.coverageTrack=new uu(e,this),this.alignmentTrack=new fu(e,this),super.init(e),this.alignmentTrack.setTop(this.coverageTrack,this.showCoverage),e.sort&&(Array.isArray(e.sort)?this.assignSort(e.sort[0]):this.assignSort(e.sort))}set height(e){this._height=e,this.showAlignments&&(this.alignmentTrack.height=this.showCoverage?e-this.coverageTrackHeight:e)}get height(){return this._height}get minTemplateLength(){const e=void 0!==this.config.minTLEN?this.config.minTLEN:this.config.minFragmentLength;return void 0!==e?e:this._pairedEndStats?this._pairedEndStats.minTLEN:0}get maxTemplateLength(){const e=void 0!==this.config.maxTLEN?this.config.maxTLEN:this.config.maxFragmentLength;return void 0!==e?e:this._pairedEndStats?this._pairedEndStats.maxTLEN:1e3}sort(e){e=this.assignSort(e);for(let t of this.trackView.viewports)if(t.containsPosition(e.chr,e.position)){const i=t.cachedFeatures;i&&(i.sortRows(e),t.repaint())}}assignSort(e){if(e.locus){const t=function(e){const t=e.split(":"),i=t[1].split("-"),n={chr:t[0],start:Number.parseInt(i[0].replace(/,/g,""))-1};return i.length>1?n.end=Number.parseInt(i[1].replace(/,/g,"")):n.end=n.start+1,n}(e.locus);e.chr=t.chr,e.position=t.start}else e.position--;return e.direction="ASC"===e.direction||!0===e.direction,e.chr=this.browser.genome.getChromosomeName(e.chr),this.sortObject=e,this.sortObject}async getFeatures(e,t,i,n,r){const s=await this.featureSource.getAlignments(e,t,i);if(s.paired&&!this._pairedEndStats&&!this.config.maxFragmentLength){const e=new qd(s.alignments,this.config);e.totalCount>99&&(this._pairedEndStats=e)}s.alignments=void 0;const o=this.sortObject;return o&&o.chr===e&&o.position>=t&&o.position<=i&&s.sortRows(o),s}computePixelHeight(e){return(this.showCoverage?this.coverageTrackHeight:0)+(this.showAlignments?this.alignmentTrack.computePixelHeight(e):0)}draw(e){Co.fillRect(e.context,0,e.pixelTop,e.pixelWidth,e.pixelHeight,{fillStyle:"rgb(255, 255, 255)"}),!0===this.showCoverage&&this.coverageTrackHeight>0?(this.trackView.axisCanvas.style.display="block",this.coverageTrack.draw(e)):this.trackView.axisCanvas.style.display="none",!0===this.showAlignments&&(this.alignmentTrack.setTop(this.coverageTrack,this.showCoverage),this.alignmentTrack.draw(e))}paintAxis(e,t,i){this.coverageTrack.paintAxis(e,t,this.coverageTrackHeight)}contextMenuItemList(e){return this.alignmentTrack.contextMenuItemList(e)}popupData(e){return!0===this.showCoverage&&e.y>=this.coverageTrack.top&&e.y<this.coverageTrackHeight?this.coverageTrack.popupData(e):this.alignmentTrack.popupData(e)}clickedFeatures(e){let t;return t=!0===this.showCoverage&&e.y>=this.coverageTrack.top&&e.y<this.coverageTrackHeight?this.coverageTrack.getClickedObject(e):this.alignmentTrack.getClickedObject(e),t?[t]:void 0}hoverText(e){if(!0===this.showCoverage&&e.y>=this.coverageTrack.top&&e.y<this.coverageTrackHeight){const t=this.coverageTrack.getClickedObject(e);if(t)return t.hoverText()}}menuItemList(){let e=[];e=e.concat($t.numericDataMenuItems(this.trackView)),e.push("<hr/>");const t=ft('<div class="igv-track-menu-category">');t.text("Color by:"),e.push({name:void 0,object:t,click:void 0,init:void 0});const i=[{key:"strand",label:"read strand"}];this.alignmentTrack.hasPairs&&(i.push({key:"firstOfPairStrand",label:"first-of-pair strand"}),i.push({key:"pairOrientation",label:"pair orientation"}),i.push({key:"tlen",label:"insert size (TLEN)"}),i.push({key:"unexpectedPair",label:"pair orientation & insert size (TLEN)"}));const n="tag"+(this.alignmentTrack.colorByTag?" ("+this.alignmentTrack.colorByTag+")":"");i.push({key:"tag",label:n});for(let t of i){const i=this.alignmentTrack.colorBy===t.key;e.push(this.colorByCB(t,i))}const r=()=>{if(!this.autoHeight){const e=(this.showCoverage?this.coverageTrackHeight:0)+(this.showAlignments?this.alignmentTrack.height:0);this.trackView.setTrackHeight(e)}};e.push("<hr/>"),e.push({object:ft(jt("Show Coverage",this.showCoverage)),click:()=>{this.showCoverage=!this.showCoverage,r(),this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),e.push({object:ft(jt("Show Alignments",this.showAlignments)),click:()=>{this.showAlignments=!this.showAlignments,r(),this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),e.push("<hr/>"),e.push({object:ft(jt("Show all bases",this.showAllBases)),click:()=>{this.showAllBases=!this.showAllBases,this.config.showAllBases=this.showAllBases,this.trackView.repaintViews()}}),e.push("<hr/>"),e.push({object:ft(jt("Show mismatches",this.showMismatches)),click:()=>{this.showMismatches=!this.showMismatches,this.config.showMismatches=this.showMismatches,this.trackView.repaintViews()}}),e.push({object:ft(jt("Show insertions",this.showInsertions)),click:()=>{this.showInsertions=!this.showInsertions,this.config.showInsertions=this.showInsertions,this.getCachedAlignmentContainers(),this.trackView.repaintViews()}}),e.push({object:ft(jt("Show soft clips",this.showSoftClips)),click:()=>{this.showSoftClips=!this.showSoftClips,this.config.showSoftClips=this.showSoftClips,this.featureSource.setShowSoftClips(this.showSoftClips);const e=this.getCachedAlignmentContainers();for(let t of e)t.setShowSoftClips(this.showSoftClips);this.trackView.repaintViews()}}),this.pairsSupported&&this.alignmentTrack.hasPairs&&(e.push("<hr/>"),e.push({object:ft(jt("View as pairs",this.viewAsPairs)),click:()=>{this.viewAsPairs=!this.viewAsPairs,this.config.viewAsPairs=this.viewAsPairs,this.featureSource.setViewAsPairs(this.viewAsPairs);const e=this.getCachedAlignmentContainers();for(let t of e)t.setViewAsPairs(this.viewAsPairs);this.trackView.repaintViews()}})),this.browser.circularView&&(this.alignmentTrack.hasPairs||this.alignmentTrack.hasSupplemental)&&(e.push("<hr/>"),this.alignmentTrack.hasPairs&&e.push({label:"Add discordant pairs to circular view",click:()=>{for(let e of this.trackView.viewports)this.addPairedChordsForViewport(e)}}),this.alignmentTrack.hasSupplemental&&e.push({label:"Add split reads to circular view",click:()=>{for(let e of this.trackView.viewports)this.addSplitChordsForViewport(e)}})),e.push("<hr/>");const s=ft('<div class="igv-track-menu-category">');return s.text("Display mode:"),e.push({name:void 0,object:s,click:void 0,init:void 0}),e.push({object:ft(jt("expand","EXPANDED"===this.alignmentTrack.displayMode)),click:()=>{this.alignmentTrack.displayMode="EXPANDED",this.config.displayMode="EXPANDED",this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),e.push({object:ft(jt("squish","SQUISHED"===this.alignmentTrack.displayMode)),click:()=>{this.alignmentTrack.displayMode="SQUISHED",this.config.displayMode="SQUISHED",this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),e}colorByCB(e,t){return{name:void 0,object:ft(jt(e.label,t)),click:t=>{"tag"!==e.key?e.key===this.alignmentTrack.colorBy?(this.alignmentTrack.colorBy="none",this.config.colorBy="none",this.trackView.repaintViews()):(this.alignmentTrack.colorBy=e.key,this.config.colorBy=e.key,this.trackView.repaintViews()):this.browser.inputDialog.present({label:"Tag Name",value:this.alignmentTrack.colorByTag?this.alignmentTrack.colorByTag:"",callback:e=>{e?(this.alignmentTrack.colorBy="tag",this.alignmentTrack.colorByTag=e,this.alignmentTrack.tagColors||(this.alignmentTrack.tagColors=new yo("Set1"))):(this.alignmentTrack.colorBy="none",this.alignmentTrack.colorByTag=""),this.trackView.repaintViews()}},t)},init:void 0}}getState(){const e=super.getState();return this.sortObject&&(e.sort={chr:this.sortObject.chr,position:this.sortObject.position+1,option:this.sortObject.option,direction:this.sortObject.direction?"ASC":"DESC"}),e}getCachedAlignmentContainers(){return this.trackView.viewports.map((e=>e.cachedFeatures))}get dataRange(){return this.coverageTrack.dataRange}set dataRange(e){this.coverageTrack.dataRange=e}get logScale(){return this.coverageTrack.logScale}set logScale(e){this.coverageTrack.logScale=e}get autoscale(){return this.coverageTrack.autoscale}set autoscale(e){this.coverageTrack.autoscale=e}addPairedChordsForViewport(e){const t=this.maxTemplateLength,i=[],n=e.referenceFrame;for(let r of e.cachedFeatures.allAlignments())r.end>=n.start&&r.start<=n.end&&(r.paired?r.end-r.start>t&&i.push(r):r.mate&&r.mate.chr&&(r.mate.chr!==r.chr||Math.max(r.fragmentLength)>t)&&i.push(r));Ud((e=>{const t=[];for(let i of e)if(i.paired)i.firstAlignment&&i.secondAlignment&&t.push({uniqueId:i.readName,refName:Hd(i.firstAlignment.chr),start:i.firstAlignment.start,end:i.firstAlignment.end,mate:{refName:Hd(i.secondAlignment.chr),start:i.secondAlignment.start,end:i.secondAlignment.end}});else{const e=i.mate;e&&e.chr&&e.position&&t.push({uniqueId:i.readName,refName:Hd(i.chr),start:i.start,end:i.end,mate:{refName:Hd(e.chr),start:e.position-1,end:e.position}})}return t})(i),this,n,.02)}addSplitChordsForViewport(e){const t=[],i=e.referenceFrame;for(let n of e.cachedFeatures.allAlignments()){const e=n.hasTag("SA");n.end>=i.start&&n.start<=i.end&&e&&t.push(n)}Ud((e=>{const t=e=>{const t=Rc(e.tags().SA);let n=0;for(let r of t)r.start!==e.start&&i.push({uniqueId:`${e.readName}_${n++}`,refName:Hd(e.chr),start:e.start,end:e.end,mate:{refName:Hd(r.chr),start:r.start,end:r.start+r.lenOnRef}})},i=[];for(let i of e)i.paired?(t(i.firstAlignment),i.secondAlignment&&t(i.secondAlignment)):t(i);return i})(t),this,i,.02)}}class uu{constructor(e,t){this.parent=t,this.featureSource=t.featureSource,this.paintAxis=dd,this.top=0,this.autoscale=e.autoscale||void 0===e.max,this.autoscale||(this.dataRange={min:e.min||0,max:e.max})}get height(){return this.parent.coverageTrackHeight}draw(e){const t=e.pixelTop;e.pixelHeight;const i=this.parent.browser.nucleotideColors;if(t>this.height)return;const n=e.context,r=e.features.coverageMap;let s;r.refSeq&&(s=r.refSeq.toUpperCase());const o=e.bpPerPixel,a=e.bpStart,l=a+e.pixelWidth*o+1;let h;h=this.parent.coverageColor?this.parent.coverageColor:void 0!==this.parent.color&&"function"!=typeof this.parent.color?Ds.darkenLighten(this.parent.color,-35):cu,Co.setProperties(n,{fillStyle:h,strokeStyle:h});const c=Math.max(1,Math.ceil(1/o));for(let e=0,t=r.coverage.length;e<t;e++){const t=r.bpStart+e;if(t<a)continue;if(t>l)break;const i=r.coverage[e];if(!i)continue;const s=Math.round(i.total/this.dataRange.max*this.height),h=this.height-s,d=Math.floor((t-a)/o);Co.fillRect(n,d,h,c,s)}if(s)for(let e=0,t=r.coverage.length;e<t;e++){const t=r.bpStart+e;if(t<a)continue;if(t>l)break;const h=r.coverage[e];if(!h)continue;const d=h.total/this.dataRange.max*this.height;let u=this.height-d;const f=Math.floor((t-a)/o),p=s[e];if(h.isMismatch(p)){Co.setProperties(n,{fillStyle:i[p]}),Co.fillRect(n,f,u,c,d);let e=0;for(let t of["A","C","T","G"]){const r=(h["pos"+t]+h["neg"+t])/this.dataRange.max*this.height;u=this.height-r-e,e+=r,Co.setProperties(n,{fillStyle:i[t]}),Co.fillRect(n,f,u,c,r)}}}}getClickedObject(e){let t=e.viewport.cachedFeatures;if(!t||0===t.length)return;const i=Math.floor(e.genomicLocation),n=t.coverageMap,r=Math.floor(i-n.bpStart);return n.coverage[r]}popupData(e){const t=[],i=this.getClickedObject(e);if(i){const n=Math.floor(e.genomicLocation),r=e.viewport.referenceFrame;t.push(r.chr+":"+Xt(1+n)),t.push({name:"Total Count",value:i.total});let s=i.posA+i.negA;s>0&&(s=s.toString()+" ("+Math.round(s/i.total*100)+"%, "+i.posA+"+, "+i.negA+"- )"),t.push({name:"A",value:s}),s=i.posC+i.negC,s>0&&(s=s.toString()+" ("+Math.round(s/i.total*100)+"%, "+i.posC+"+, "+i.negC+"- )"),t.push({name:"C",value:s}),s=i.posG+i.negG,s>0&&(s=s.toString()+" ("+Math.round(s/i.total*100)+"%, "+i.posG+"+, "+i.negG+"- )"),t.push({name:"G",value:s}),s=i.posT+i.negT,s>0&&(s=s.toString()+" ("+Math.round(s/i.total*100)+"%, "+i.posT+"+, "+i.negT+"- )"),t.push({name:"T",value:s}),s=i.posN+i.negN,s>0&&(s=s.toString()+" ("+Math.round(s/i.total*100)+"%, "+i.posN+"+, "+i.negN+"- )"),t.push({name:"N",value:s}),t.push("<HR/>"),t.push({name:"DEL",value:i.del.toString()}),t.push({name:"INS",value:i.ins.toString()})}return t}}class fu{constructor(e,t){this.parent=t,this.browser=t.browser,this.featureSource=t.featureSource,this.top=0===e.coverageTrackHeight?0:e.coverageTrackHeight+5,this.displayMode=e.displayMode||"EXPANDED",this.alignmentRowHeight=e.alignmentRowHeight||14,this.squishedRowHeight=e.squishedRowHeight||3,this.negStrandColor=e.negStrandColor||"rgba(150, 150, 230, 0.75)",this.posStrandColor=e.posStrandColor||"rgba(230, 150, 150, 0.75)",this.insertionColor=e.insertionColor||"rgb(138, 94, 161)",this.insertionTextColor=e.insertionTextColor||"white",this.showInsertionText=void 0!==e.showInsertionText&&!!e.showInsertionText,this.deletionColor=e.deletionColor||"black",this.deletionTextColor=e.deletionTextColor||"black",this.showDeletionText=void 0!==e.showDeletionText&&!!e.showDeletionText,this.skippedColor=e.skippedColor||"rgb(150, 170, 170)",this.pairConnectorColor=e.pairConnectorColor,this.smallTLENColor=e.smallTLENColor||e.smallFragmentLengthColor||"rgb(0, 0, 150)",this.largeTLENColor=e.largeTLENColor||e.largeFragmentLengthColor||"rgb(200, 0, 0)",this.pairOrientation=e.pairOrienation||"fr",this.pairColors={},this.pairColors.RL=e.rlColor||"rgb(0, 150, 0)",this.pairColors.RR=e.rrColor||"rgb(20, 50, 200)",this.pairColors.LL=e.llColor||"rgb(0, 150, 150)",this.colorBy=e.colorBy||"unexpectedPair",this.colorByTag=e.colorByTag?e.colorByTag.toUpperCase():void 0,this.bamColorTag=void 0===e.bamColorTag?"YC":e.bamColorTag,this.hideSmallIndels=e.hideSmallIndels,this.indelSizeThreshold=e.indelSizeThreshold||1,this.hasPairs=!1,this.hasSupplemental=!1}setTop(e,t){this.top=0===e.height||!1===t?0:5+e.height}computePixelHeight(e){if(e.packedAlignmentRows){return(e.hasDownsampledIntervals()?10:0)+("SQUISHED"===this.displayMode?this.squishedRowHeight:this.alignmentRowHeight)*e.packedAlignmentRows.length+5}return 0}draw(e){const t=e.features,i=e.context,n=e.bpPerPixel,r=e.bpStart,s=e.pixelWidth,o=r+s*n+1,a=this.parent.showSoftClips,l=this.parent.showAllBases,h=this.browser.nucleotideColors,c=t.packedAlignmentRows;i.save();let d=t.sequence;d&&(d=d.toUpperCase());let u=0,f=e.pixelTop;this.top&&i.translate(0,this.top);const p=f+e.pixelHeight;t.hasDownsampledIntervals()?(u=10,t.downsampledIntervals.forEach((function(e){var t=(e.start-r)/n,s=(e.end-r)/n;s-t>5&&(t+=1,s-=1),Co.fillRect(i,t,2,s-t,3,{fillStyle:"black"})}))):u=0,this.alignmentsYOffset=u;const g="SQUISHED"===this.displayMode?this.squishedRowHeight:this.alignmentRowHeight;if(c){const e=c.length;for(let t=0;t<e;t++){const e=c[t],i=u+g*t,n=g<=4?g:g-2;if(i>p)break;if(!(i+n<f))for(let t of e.alignments)if(this.hasPairs=this.hasPairs||t.isPaired(),this.browser.circularView&&(this.hasSupplemental=this.hasSupplemental||t.hasTag("SA")),!(t.start+t.lengthOnRef<r)){if(t.start>o)break;!0!==t.hidden&&(t instanceof wc?(m.call(this,t,i,n),b.call(this,t.firstAlignment,i,n),t.secondAlignment&&b.call(this,t.secondAlignment,i,n)):b.call(this,t,i,n))}}}function m(e,t,s){var a=this.getConnectorColor(e.firstAlignment),l=(e.connectingStart-r)/n,h=(e.connectingEnd-r)/n,c=t+s/2;e.connectingEnd<r||e.connectingStart>o||(e.mq<=0&&(a=Ds.addAlpha(a,.15)),Co.setProperties(i,{fillStyle:a,strokeStyle:a}),Co.strokeLine(i,l,c,h,c))}function b(e,c,u){if(e.start+e.lengthOnRef<r||e.start>o)return;const f=a?e.blocks:e.blocks.filter((e=>"S"!==e.type));let p=this.getAlignmentColor(e);const m=p;e.mq<=0&&(p=Ds.addAlpha(p,.15)),Co.setProperties(i,{fillStyle:p,strokeStyle:m});const b=[];for(let e=0;e<f.length;e++){const t=f[e];if(!(e!==f.length-1&&f[e+1].start<r)&&(b.push(...w.call(this,t,e)),t.start+t.len>o))break}if(e.gaps){const t=c+u/2;for(let s of e.gaps){const e=(s.start-r)/n,o=(s.start+s.len-r)/n,a=o-e,l=s.len.toString(),h=6*l.length,d=e+a/2,u="D"===s.type?this.deletionColor:this.skippedColor;if(Co.strokeLine(i,e,t,o,t,{strokeStyle:u,lineWidth:2}),this.showDeletionText&&s.len>1&&a>=h+8){const e=d-h/2;Co.fillRect(i,e-1,c-1,h+2,12,{fillStyle:"white"}),Co.fillText(i,l,e,c+10,{font:"normal 10px monospace",fillStyle:this.deletionTextColor})}}}if(e.insertions&&this.parent.showInsertions){let t=-1;for(let s of e.insertions){if(this.hideSmallIndels&&s.len<=this.indelSizeThreshold)continue;if(s.start<r)continue;if(s.start>o)break;const e=s.start-r,a=s.len.toString(),l=2+6*a.length,h=this.showInsertionText&&1!==s.len?Math.round(s.len/n):2,d=Math.max(Math.min(l,h),2),f=e/n-d/2;if(f-t>2){const e={fillStyle:this.insertionColor};Co.fillRect(i,f-2,c,d+4,2,e),Co.fillRect(i,f,c+2,d,u-4,e),Co.fillRect(i,f-2,c+u-2,d+4,2,e),this.showInsertionText&&s.len>1&&h>l&&Co.fillText(i,a,f+1,c+10,{font:"normal 10px monospace",fillStyle:this.insertionTextColor}),t=f}}}function w(o,a){const b=[],w=o.start-t.start,v=(o.start-r)/n,y=(o.start+o.len-r)/n,_=Math.max(1,y-v),x=100/n,k=Math.min(g/2,x/6),C="S"===o.type,S=e.mq<=0||this.highlightedAlignmentReadNamed===e.readName||C;let A=m;this.highlightedAlignmentReadNamed===e.readName?A="red":C&&(A="rgb(50,50,50)");const E=!0===e.strand&&a===f.length-1,M=!1===e.strand&&0===a;if(E|M){let e,t;E?(e=[v,y,y+k,y,v,v],t=[c,c,c+u/2,c+u,c+u,c]):M&&(e=[y,v,v-k,v,y,y],t=[c,c,c+u/2,c+u,c+u,c]),Co.fillPolygon(i,e,t,{fillStyle:p}),S&&Co.strokePolygon(i,e,t,{strokeStyle:A})}else Co.fillRect(i,v,c,_,u,{fillStyle:p}),S&&(i.save(),i.strokeStyle=A,i.strokeRect(v,c,_,u),i.restore());if(C||l||this.parent.showMismatches&&d&&e.seq&&"*"!==e.seq){const t=e.seq?e.seq.toUpperCase():void 0,i=e.qual,a=o.seqOffset,f=Math.max(1,1/n);for(let e=0,p=o.len;e<p;e++){const p=(o.start+e-r)/n;if(p+f<0)continue;if(p>s)break;let g=t?t.charAt(a+e):"";const m=w+e>=0?d.charAt(w+e):"";if("="===g&&(g=m),"X"===g||m!==g||C||l){let t;if(!C&&void 0!==i&&i.length>a+e){t=pu(i[a+e],h[g])}else t=h[g];t&&b.push({bbox:{x:p,y:c,width:f,height:u},baseColor:t,readChar:g})}}}return b}b.forEach((({bbox:e,baseColor:t,readChar:r})=>{!function(e,t,i,n,r){var s;if(t<=.1&&i.height>=8){const t=Math.min(10,i.height);e.font=t+"px sans-serif",s=i.x+i.width/2,Co.strokeText(e,r,s-e.measureText(r).width/2,t-1+i.y,{strokeStyle:n})}else Co.fillRect(e,i.x,i.y,i.width,i.height,{fillStyle:n})}(i,n,e,t,r)}))}i.restore()}popupData(e){const t=this.getClickedObject(e);return t?t.popupData(e.genomicLocation):void 0}contextMenuItemList(e){const t=e.viewport,i=[],n=i=>{const n=this.parent.sortObject,r=!n||n.position!==Math.floor(e.genomicLocation)||!n.direction,s={chr:t.referenceFrame.chr,position:Math.floor(e.genomicLocation),option:i,direction:r};this.parent.sortObject=s,t.cachedFeatures.sortRows(s),t.repaint()};i.push("<b>Sort by...</b>"),i.push({label:" base",click:()=>n("BASE")}),i.push({label:" read strand",click:()=>n("STRAND")}),i.push({label:" insert size",click:()=>n("INSERT_SIZE")}),i.push({label:" gap size",click:()=>n("GAP_SIZE")}),i.push({label:" chromosome of mate",click:()=>n("MATE_CHR")}),i.push({label:" mapping quality",click:()=>n("MQ")}),i.push({label:" read name",click:()=>n("READ_NAME")}),i.push({label:" aligned read length",click:()=>n("ALIGNED_READ_LENGTH")}),i.push({label:" tag",click:()=>{const i=this.parent.sortObject,n=!i||i.position!==Math.floor(e.genomicLocation)||!i.direction,r={label:"Tag Name",value:this.sortByTag?this.sortByTag:"",callback:i=>{if(i){const r={chr:t.referenceFrame.chr,position:Math.floor(e.genomicLocation),option:"TAG",tag:i,direction:n};this.sortByTag=i,this.parent.sortObject=r,t.cachedFeatures.sortRows(r),t.repaint()}}};this.browser.inputDialog.present(r,e.event)}}),i.push("<hr/>");const r=this.getClickedObject(e);if(r){const t=this.parent.showSoftClips,n="function"==typeof r.alignmentContaining?r.alignmentContaining(e.genomicLocation,t):r;if(n){n.isPaired()&&n.isMateMapped()&&i.push({label:"View mate in split screen",click:()=>{if(n.mate){const t=e.viewport.referenceFrame;if(this.browser.genome.getChromosome(n.mate.chr)){this.highlightedAlignmentReadNamed=n.readName;const e=t.end-t.start,i=n.mate.position-e/2,r=n.mate.position+e/2;this.browser.addMultiLocusPanel(n.mate.chr,i,r,t)}else this.browser.alert.present(`Reference does not contain chromosome: ${n.mate.chr}`)}},init:void 0}),i.push({label:"View read sequence",click:()=>{const e=n.seq;e&&"*"!==e?this.browser.alert.present(e):this.browser.alert.present("Read sequence: *")}}),Do()&&i.push({label:"Copy read sequence",click:async()=>{const e=n.seq;try{await navigator.clipboard.writeText(e)}catch(e){console.error(e),this.browser.alert.present(`error copying sequence to clipboard ${e}`)}}});const t=n.seq;if(t&&"*"!=t){t.length<ou&&i.push({label:"BLAT read sequence",click:()=>{const e=n.isNegativeStrand()?Yo(t):t,i=`${n.readName} - blat`,r=`${this.parent.name} - ${i}`;lu({sequence:e,browser:this.browser,name:i,title:r})}});const e=n.softClippedBlocks();e.left&&e.left.len>20&&e.left.len<ou&&i.push({label:"BLAT left soft-clipped sequence",click:()=>{const i=t.substr(e.left.seqOffset,e.left.len),r=n.isNegativeStrand()?Yo(i):i,s=`${n.readName} - blat left clip`,o=`${this.parent.name} - ${s}`;lu({sequence:r,browser:this.browser,name:s,title:o})}}),e.right&&e.right.len>20&&e.right.len<ou&&i.push({label:"BLAT right soft-clipped sequence",click:()=>{const i=t.substr(e.right.seqOffset,e.right.len),r=n.isNegativeStrand()?Yo(i):i,s=`${n.readName} - blat right clip`,o=`${this.parent.name} - ${s}`;lu({sequence:r,browser:this.browser,name:s,title:o})}})}i.push("<hr/>")}}return this.browser.circularView&&(this.hasPairs||this.hasSupplemental)&&(this.hasPairs&&i.push({label:"Add discordant pairs to circular view",click:()=>{this.parent.addPairedChordsForViewport(t)}}),this.hasSupplemental&&i.push({label:"Add split reads to circular view",click:()=>{this.parent.addSplitChordsForViewport(t)}}),i.push("<hr/>")),i}getClickedObject(e){const t=e.viewport,i=e.y,n=e.genomicLocation,r=this.parent.showSoftClips;let s=t.cachedFeatures;if(!s||0===s.length)return;let o=s.packedAlignmentRows,a=s.downsampledIntervals;const l="SQUISHED"===this.displayMode?this.squishedRowHeight:this.alignmentRowHeight;let h=Math.floor((i-this.top-this.alignmentsYOffset)/l);if(h<0){for(let e=0;e<a.length;e++)if(a[e].start<=n&&a[e].end>=n)return a[e]}else if(h<o.length){const e=o[h].alignments.filter((e=>e.containsLocation(n,r)));if(e.length>0)return e[0]}}getConnectorColor(e){if(this.pairConnectorColor)return this.pairConnectorColor;switch(this.colorBy){case"strand":case"firstOfPairStrand":case"pairOrientation":case"tag":return this.parent.color?"function"==typeof this.parent.color?this.parent.color(e):this.parent.color:"rgb(200, 200, 200)";default:return this.getAlignmentColor(e)}}getAlignmentColor(e){let t=hu;this.parent.color&&(t="function"==typeof this.parent.color?this.parent.color(e):this.parent.color);const i=this.colorBy;switch(i){case"strand":t=e.strand?this.posStrandColor:this.negStrandColor;break;case"firstOfPairStrand":e instanceof wc?t=e.firstOfPairStrand()?this.posStrandColor:this.negStrandColor:e.isPaired()&&(e.isFirstOfPair()?t=e.strand?this.posStrandColor:this.negStrandColor:e.isSecondOfPair()?t=e.strand?this.negStrandColor:this.posStrandColor:console.error("ERROR. Paired alignments are either first or second."));break;case"unexpectedPair":case"pairOrientation":if(this.pairOrientation&&e.pairOrientation){const i=gu[this.pairOrientation];if(i){const n=this.pairColors[i[e.pairOrientation]];if(n){t=n;break}}}if("pairOrientation"===i)break;case"tlen":case"fragmentLength":e.mate&&e.isMateMapped()&&(e.mate.chr!==e.chr?t=mu(e.mate.chr):this.parent.minTemplateLength&&Math.abs(e.fragmentLength)<this.parent.minTemplateLength?t=this.smallTLENColor:this.parent.maxTemplateLength&&Math.abs(e.fragmentLength)>this.parent.maxTemplateLength&&(t=this.largeTLENColor));break;case"tag":const n=e.tags()[this.colorByTag];void 0!==n&&(this.bamColorTag===this.colorByTag?t="rgb("+n+")":(this.tagColors||(this.tagColors=new yo("Set1")),t=this.tagColors.getColor(n)))}return t}}function pu(e,t){let i;return i=e<5?.1:Math.max(.1,Math.min(1,.1+.9*(e-5)/15)),i=Math.round(10*i)/10,i<1&&(t=Ds.addAlpha(t,i)),t}const gu={fr:{F1R2:"LR",F2R1:"LR",F1F2:"LL",F2F1:"LL",R1R2:"RR",R2R1:"RR",R1F2:"RL",R2F1:"RL"},rf:{R1F2:"LR",R2F1:"LR",R1R2:"LL",R2R1:"LL",F1F2:"RR",F2F1:"RR",F1R2:"RL",F2R1:"RL"},ff:{F2F1:"LR",R1R2:"LR",F2R1:"LL",R1F2:"LL",R2F1:"RR",F1R2:"RR",R2R1:"RL",F1F2:"RL"}};function mu(e){if(bu[e])return bu[e];if(bu["chr"+e]){const t=bu["chr"+e];return bu[e]=t,t}{const t=Ds.randomRGB(0,255);return bu[e]=t,t}}const bu={chrX:"rgb(204, 153, 0)",chrY:"rgb(153, 204, 0)",chrUn:"rgb(50, 50, 50)",chr1:"rgb(80, 80, 255)",chrI:"rgb(139, 155, 187)",chr2:"rgb(206, 61, 50)",chrII:"rgb(206, 61, 50)",chr2a:"rgb(216, 71, 60)",chr2b:"rgb(226, 81, 70)",chr3:"rgb(116, 155, 88)",chrIII:"rgb(116, 155, 88)",chr4:"rgb(240, 230, 133)",chrIV:"rgb(240, 230, 133)",chr5:"rgb(70, 105, 131)",chr6:"rgb(186, 99, 56)",chr7:"rgb(93, 177, 221)",chr8:"rgb(128, 34, 104)",chr9:"rgb(107, 215, 107)",chr10:"rgb(213, 149, 167)",chr11:"rgb(146, 72, 34)",chr12:"rgb(131, 123, 141)",chr13:"rgb(199, 81, 39)",chr14:"rgb(213, 143, 92)",chr15:"rgb(122, 101, 165)",chr16:"rgb(228, 175, 105)",chr17:"rgb(59, 27, 83)",chr18:"rgb(205, 222, 183)",chr19:"rgb(97, 42, 121)",chr20:"rgb(174, 31, 99)",chr21:"rgb(231, 199, 111)",chr22:"rgb(90, 101, 94)",chr23:"rgb(204, 153, 0)",chr24:"rgb(153, 204, 0)",chr25:"rgb(51, 204, 0)",chr26:"rgb(0, 204, 51)",chr27:"rgb(0, 204, 153)",chr28:"rgb(0, 153, 204)",chr29:"rgb(10, 71, 255)",chr30:"rgb(71, 117, 255)",chr31:"rgb(255, 194, 10)",chr32:"rgb(255, 209, 71)",chr33:"rgb(153, 0, 51)",chr34:"rgb(153, 26, 0)",chr35:"rgb(153, 102, 0)",chr36:"rgb(128, 153, 0)",chr37:"rgb(51, 153, 0)",chr38:"rgb(0, 153, 26)",chr39:"rgb(0, 153, 102)",chr40:"rgb(0, 128, 153)",chr41:"rgb(0, 51, 153)",chr42:"rgb(26, 0, 153)",chr43:"rgb(102, 0, 153)",chr44:"rgb(153, 0, 128)",chr45:"rgb(214, 0, 71)",chr46:"rgb(255, 20, 99)",chr47:"rgb(0, 214, 143)",chr48:"rgb(20, 255, 177)"};let wu,vu;class yu extends Pa{constructor(e,t,i,n){super(e,t,i,n)}get contentDiv(){return this.$viewport.get(0)}initializationHelper(){let e;this.$multiLocusCloseButton=ft("<div>",{class:"igv-multi-locus-close-button"}),this.$viewport.append(this.$multiLocusCloseButton),this.$multiLocusCloseButton.get(0).appendChild(At.createIcon("times-circle")),this.$multiLocusCloseButton.click((()=>{this.browser.removeMultiLocusPanel(this.referenceFrame)})),this.$rulerLabel=ft("<div>",{class:"igv-multi-locus-ruler-label"}),this.$viewport.append(this.$rulerLabel),e=document.createElement("div"),this.$rulerLabel.append(ft(e)),this.$rulerLabel.get(0).addEventListener("click",(async e=>{e.stopPropagation(),await this.browser.gotoMultilocusPanel(this.referenceFrame)})),this.$tooltip=ft("<div>",{class:"igv-ruler-tooltip"}),this.$tooltip.height(this.$viewport.height()),this.$viewport.append(this.$tooltip),this.$tooltipContent=ft("<div>"),this.$tooltip.append(this.$tooltipContent),this.rulerSweeper=new bc(this,this.$viewport.get(0).parentElement,this.browser,this.referenceFrame),this.attachMouseHandlers(Ia.isWholeGenomeView(this.referenceFrame.chr)),this.$tooltip.hide(),this.dismissLocusLabel()}presentLocusLabel(e){this.$multiLocusCloseButton.show(),this.$rulerLabel.show(),this.$rulerLabel.get(0).style.backgroundColor=mu(this.referenceFrame.chr);const t=this.$rulerLabel.get(0).querySelector("div"),{width:i}=this.$rulerLabel.get(0).getBoundingClientRect();t.innerHTML=`${this.referenceFrame.getMultiLocusLabel(e)}`;const{width:n}=t.getBoundingClientRect();n/i>.5&&(t.innerHTML=`${this.referenceFrame.getMultiLocusLabelBPLengthOnly(e)}`)}dismissLocusLabel(){this.$rulerLabel.hide(),this.$multiLocusCloseButton.hide()}attachMouseHandlers(e){if(this.namespace=`.ruler_track_viewport_${this.browser.referenceFrameList.indexOf(this.referenceFrame)}`,this.$viewport.off(this.namespace),!0===e){const e=this.browser.referenceFrameList.indexOf(this.referenceFrame),t=`click${this.namespace}`;this.$viewport.on(t,(t=>{const{x:i}=_t.translateMouseCoordinates(t,this.$viewport.get(0)),n=Math.round(this.referenceFrame.start+this.referenceFrame.toBP(i));let r;const{chr:s}=this.browser.genome.getChromosomeCoordinate(n);if(1===this.browser.referenceFrameList.length)r=s;else{let t=this.browser.referenceFrameList.map((({locusSearchString:e})=>e));t[e]=s,r=t.join(" ")}this.browser.search(r)})),this.$viewport.get(0).style.cursor="pointer"}else this.$viewport.get(0).style.cursor="default"}mouseMove(e){if(!0===this.browser.cursorGuideVisible){void 0===vu?(vu=this,this.$tooltip.show()):vu.guid!==this.guid?(vu.$tooltip&&vu.$tooltip.hide(),this.$tooltip.show(),vu=this):this.$tooltip.show();if(this.browser.isMultiLocusWholeGenomeView()||Ia.isWholeGenomeView(this.referenceFrame.chr))return void this.$tooltip.hide();const{x:t}=_t.translateMouseCoordinates(e,this.$viewport.get(0)),{start:i,bpPerPixel:n}=this.referenceFrame,r=Math.round(.5+i+Math.max(0,t)*n);this.$tooltipContent.text(Xt(r));const{width:s}=this.$tooltipContent.get(0).getBoundingClientRect(),{width:o}=this.$viewport.get(0).getBoundingClientRect();this.$tooltip.css({left:`${Ns.clamp(t,0,o-s)}px`}),clearTimeout(wu),wu=setTimeout((()=>{this.$tooltip&&this.$tooltip.hide()}),1e4)}}startSpinner(){}stopSpinner(){}dispose(){this.rulerSweeper.dispose(),super.dispose()}}class _u extends Pa{constructor(e,t,i,n){super(e,t,i,n)}initializationHelper(){this.canvas=document.createElement("canvas"),this.canvas.className="igv-ideogram-canvas",this.$viewport.append(ft(this.canvas)),this.ideogram_ctx=this.canvas.getContext("2d"),this.addMouseHandlers()}addMouseHandlers(){this.addViewportClickHandler(this.$viewport.get(0))}addViewportClickHandler(e){this.boundClickHandler=function(e){const{xNormalized:t,width:i}=_t.translateMouseCoordinates(e,this.ideogram_ctx.canvas),{bpLength:n}=this.browser.genome.getChromosome(this.referenceFrame.chr),r=this.referenceFrame.bpPerPixel*i/n;let s=t;s-r/2<0&&(s=r/2);s+r/2>1&&(s=1-r/2);const o=Math.round((s-r/2)*n),a=Math.round((s+r/2)*n);this.referenceFrame.start=o,this.referenceFrame.end=a,this.referenceFrame.bpPerPixel=(a-o)/i,this.browser.updateViews(this.referenceFrame,this.browser.trackViews,!0)}.bind(this),e.addEventListener("click",this.boundClickHandler)}setWidth(e){this.$viewport.width(e)}drawSVGWithContext(e,t,i,n,r,s,o){e.saveWithTranslationAndClipRect(n,r,s,t,i,o),this.trackView.track.draw({context:e,referenceFrame:this.referenceFrame,pixelWidth:t,pixelHeight:i}),e.restore()}repaint(){this.draw({referenceFrame:this.referenceFrame})}draw({referenceFrame:e}){Co.configureHighDPICanvas(this.ideogram_ctx,this.$viewport.width(),this.$viewport.height()),this.trackView.track.draw({context:this.ideogram_ctx,referenceFrame:e,pixelWidth:this.$viewport.width(),pixelHeight:this.$viewport.height()})}startSpinner(){}stopSpinner(){}}function xu(e,t,i,n){if("ruler"===e.track.type)return new yu(e,t,i,n);if("ideogram"===e.track.id)return new _u(e,t,i,n);return new Pa(e,t,i,n)}const ku={textAlign:"start",textBaseline:"bottom",strokeStyle:"black",fillStyle:"black"};class Cu{constructor(e,t,i,n){this.guid=_t.guid(),this.trackView=e,this.browser=e.browser,this.viewport=_t.div({class:"igv-viewport"}),t.appendChild(this.viewport),e.track.height&&(this.viewport.style.height=`${e.track.height}px`),this.canvas=document.createElement("canvas"),this.viewport.appendChild(this.canvas),this.ctx=this.canvas.getContext("2d"),this.trackScrollDelta=0,this.contentTop=0,this.setWidth(n),!1===this.browser.showSampleNames&&this.hide(),this.addMouseHandlers()}checkCanvas(){const e=window.devicePixelRatio,t=this.viewport.clientHeight,i=this.browser.sampleNameViewportWidth;if(this.canvas.width!==i*e||this.canvas.height!==t*e){const n=this.canvas;n.width=i*e,n.height=t*e,n.style.width=`${i}px`,n.style.height=`${t}px`,this.ctx=this.canvas.getContext("2d"),this.ctx.scale(e,e)}}setTop(e){if("function"==typeof this.trackView.track.getSamples){this.contentTop=e;const t=this.trackView.track.getSamples();this.repaint(t)}}setWidth(e){this.viewport.innerWidth=e,this.checkCanvas()}show(){this.viewport.style.display="block"}hide(){this.viewport.style.display="none"}async repaint(e){this.checkCanvas(),this.draw({context:this.ctx,samples:e})}draw({context:e,samples:t}){if(!t||0===t.names.length)return;!function(e,{textAlign:t,textBaseline:i,strokeStyle:n,fillStyle:r},s){const o=Math.min(s,10);e.font=`${o}px sans-serif`,e.textAlign=t,e.textBaseline=i,e.fillStyle=r}(e,ku,t.height);e.clearRect(0,0,e.canvas.width,e.canvas.height),e.fillStyle=function(e){const{r:t,g:i,b:n}=wo[e];return`rgb(${t},${i},${n})`}("lead");const i=this.viewport.getBoundingClientRect().height;let n=(t.yOffset||0)+this.contentTop;for(let r of t.names){if(n>i)break;if(n+t.height>0){const i=r,s=Su(e,i,n,t.height);e.fillText(i,4,s)}n+=t.height}}renderSVGContext(e,{deltaX:t,deltaY:i}){if("function"==typeof this.trackView.track.getSamples){const n=this.trackView.track.getSamples(),r=0,{width:s,height:o}=this.viewport.getBoundingClientRect(),a=`${(this.trackView.track.name||this.trackView.track.id).replace(/\W/g,"")}_sample_names_guid_${_t.guid()}`;e.saveWithTranslationAndClipRect(a,t,i+r,s,o,-r),this.draw({context:e,samples:n}),e.restore()}}addMouseHandlers(){this.addViewportContextMenuHandler(this.viewport)}removeMouseHandlers(){this.removeViewportContextMenuHandler(this.viewport)}addViewportContextMenuHandler(e){this.boundContextMenuHandler=function(e){e.preventDefault(),e.stopPropagation();const t={label:"Name Panel Width",value:this.browser.sampleNameViewportWidth,callback:e=>{this.browser.sampleNameViewportWidth=parseInt(e);for(let{sampleNameViewport:e}of this.browser.trackViews)e.setWidth(this.browser.sampleNameViewportWidth);this.browser.layoutChange()}};this.browser.inputDialog.present(t,e)}.bind(this),e.addEventListener("contextmenu",this.boundContextMenuHandler)}removeViewportContextMenuHandler(e){e.removeEventListener("contextmenu",this.boundContextMenuHandler)}dispose(){this.removeMouseHandlers(),this.viewport.remove()}}function Su(e,t,i,n){return i+n-function(e,t,i){const{actualBoundingBoxAscent:n,actualBoundingBoxDescent:r}=e.measureText(t);return(i-(n+r))/2}(e,t,n)}const Au=function(e){this.popover=_t.div({class:"igv-menu-popup"}),e.appendChild(this.popover);const t=_t.div({class:"igv-menu-popup-header"});this.popover.appendChild(t),Mt.attachDialogCloseHandlerWithParent(t,(()=>this.hide())),this.popoverContent=_t.div(),this.popover.appendChild(this.popoverContent),Rt(this.popover,t),t.addEventListener("click",(e=>{e.stopPropagation(),e.preventDefault()})),this.hide()};Au.prototype.hide=function(){this.popover.style.display="none"},Au.prototype.presentMenuList=function(e){if(Eu(),e.length>0){this.popoverContent.innerHTML="",e=$t.trackMenuItemListHelper(e,this);for(let t of e){t.init&&t.init();let i=t.object;0===e.indexOf(t)&&i.removeClass("igv-track-menu-border-top"),i.hasClass("igv-track-menu-border-top")||i.hasClass("igv-menu-popup-check-container")||i.is("div")&&i.addClass("igv-menu-popup-shim"),this.popoverContent.appendChild(i.get(0))}this.popover.style.display="flex";const{width:t}=this.popover.getBoundingClientRect();this.popover.style.left=-t+"px",this.popover.style.top="0px"}},Au.prototype.presentTrackContextMenu=function(e,t){this.popoverContent.innerHTML="";const i=(n=t,r=this.popover,n.map((e=>{let t;if("string"==typeof e&&"<hr/>"===e)t=document.createElement("hr");else if("string"==typeof e)t=_t.div({class:"context-menu"}),t.innerHTML=e;else if("Node"==typeof e)t=e;else{if("function"==typeof e.init&&e.init(),"checkbox"===e.type)t=jt("Show all bases",e.value);else if("color"===e.type){const i=new qt({parent:r.parentElement,width:364});i.configure(void 0,{color:t=>e.click(t)}),t=_t.div({class:"context-menu"}),"string"==typeof e.label&&(t.innerHTML=e.label);const n=e=>{i.show(),_t.hide(r),e.preventDefault(),e.stopPropagation()};t.addEventListener("click",n),t.addEventListener("touchend",n),t.addEventListener("mouseup",(function(e){e.preventDefault(),e.stopPropagation()}))}else t=_t.div({class:"context-menu"}),"string"==typeof e.label&&(t.innerHTML=e.label);if(e.click&&"color"!==e.type){function s(t){e.click(),_t.hide(r),t.preventDefault(),t.stopPropagation()}t.addEventListener("click",s),t.addEventListener("touchend",s),t.addEventListener("mouseup",(function(e){e.preventDefault(),e.stopPropagation()}))}}return{el:t,init:e.init}})));var n,r;for(let{el:e}of i)this.popoverContent.appendChild(e);!function(e,t){t.style.display="flex";const{x:i,y:n}=_t.translateMouseCoordinates(e,t.parentNode),{width:r}=t.getBoundingClientRect(),s=i+r,{width:o}=t.parentNode.getBoundingClientRect();t.style.left=`${s>o?i-(s-o):i}px`,t.style.top=`${n}px`}(e,this.popover)},Au.prototype.dispose=function(){this.popoverContent.innerHTML="",this.popover.innerHTML="",Object.keys(this).forEach((function(e){this[e]=void 0}))};const Eu=()=>{const e=document.querySelectorAll(".igv-menu-popup");for(let t=0;t<e.length;t++)e[t].style.display="none"},Mu=new Set(["ruler","ideogram"]),Tu=new Set(["ruler","sequence","ideogram"]);class Ru{constructor(e,t,i){this.browser=e,this.track=i,i.trackView=this,this.addDOMToColumnContainer(e,t,e.referenceFrameList)}startSpinner(){this.viewports&&this.viewports.length>0&&this.viewports[0].startSpinner()}stopSpinner(){this.viewports&&this.viewports.length>0&&this.viewports[0].stopSpinner()}addDOMToColumnContainer(e,t,i){this.axis=this.createAxis(e,this.track),this.viewports=[];const n=e.calculateViewportWidth(i.length),r=t.querySelectorAll(".igv-column");for(let e=0;e<r.length;e++){const t=xu(this,r[e],i[e],n);this.viewports.push(t)}this.sampleNameViewport=new Cu(this,e.columnContainer.querySelector(".igv-sample-name-column"),void 0,e.sampleNameViewportWidth),this.createTrackScrollbar(e),this.createTrackDragHandle(e),this.createTrackGearPopup(e)}createAxis(e,t){const i=_t.div();if(e.columnContainer.querySelector(".igv-axis-column").appendChild(i),i.style.height=`${t.height}px`,"function"==typeof t.paintAxis){t.dataRange&&i.addEventListener("click",(()=>{e.dataRangeDialog.configure(this),e.dataRangeDialog.present(ft(e.columnContainer))}));const{width:n,height:r}=i.getBoundingClientRect();this.axisCanvas=document.createElement("canvas"),this.axisCanvas.style.width=`${n}px`,this.axisCanvas.style.height=`${r}px`,i.appendChild(this.axisCanvas)}return i}resizeAxisCanvas(e,t){this.axis.style.width=`${e}px`,this.axis.style.height=`${t}px`,"function"==typeof this.track.paintAxis&&(this.axisCanvas.style.width=`${e}px`,this.axisCanvas.style.height=`${t}px`)}removeDOMFromColumnContainer(){this.boundAxisClickHander&&this.removeAxisEventListener(this.axis),this.axis.remove();for(let e of this.viewports)e.$viewport.remove();this.sampleNameViewport.dispose(),this.removeTrackScrollMouseHandlers(),this.outerScroll.remove(),this.removeTrackDragMouseHandlers(),this.dragHandle.remove(),this.removeTrackGearMouseHandlers(),this.gearContainer.remove()}renderSVGContext(e,{deltaX:t,deltaY:i}){!function(e,t,i,n,r){if("function"==typeof t.paintAxis){const{y:s,width:o,height:a}=i.getBoundingClientRect(),l=`${(t.name||t.id).replace(/\W/g,"")}_axis_guid_${_t.guid()}`;e.saveWithTranslationAndClipRect(l,n,s+r,o,a,0),t.paintAxis(e,o,a),e.restore()}}(e,this.track,this.axisCanvas,t,i);const{width:n}=this.axis.getBoundingClientRect(),{y:r}=this.viewports[0].$viewport.get(0).getBoundingClientRect();let s={deltaX:n+t,deltaY:r+i};for(let t of this.viewports){t.renderSVGContext(e,s);const{width:i}=t.$viewport.get(0).getBoundingClientRect();s.deltaX+=i}!0===this.browser.showSampleNames&&this.sampleNameViewport.renderSVGContext(e,s)}dataRange(){return this.track.dataRange?this.track.dataRange:void 0}setDataRange(e,t){void 0!==e&&(this.track.dataRange.min=e),void 0!==t&&(this.track.dataRange.max=t),this.track.autoscale=!1,this.repaintViews()}presentColorPicker(e){if(!1===Tu.has(this.track.type)){const t=[],i=this.track.color||this.track.defaultColor;Qt(i)&&t.push(i),this.track.altColor&&Qt(this.track.altColor)&&t.push(this.track.altColor);const n=t.map((e=>e.startsWith("#")?e:e.startsWith("rgb(")?Ds.rgbToHex(e):Ds.colorNameToHex(e))),r={color:e=>{this.track.color=e,this.repaintViews()},altColor:e=>{this.track.altColor=e,this.repaintViews()}};this.browser.genericColorPicker.configure(n,r),this.browser.genericColorPicker.setActiveColorHandler(e),this.browser.genericColorPicker.show()}}setTrackHeight(e,t){t||(this.track.minHeight&&(e=Math.max(this.track.minHeight,e)),this.track.maxHeight&&(e=Math.min(this.track.maxHeight,e))),this.track.height=e,this.resizeAxisCanvas(this.axis.clientWidth,this.track.height),"function"==typeof this.track.paintAxis&&this.paintAxis();for(let{$viewport:t}of this.viewports)t.height(e);if(this.sampleNameViewport.viewport.style.height=`${e}px`,"function"!=typeof this.track.computePixelHeight)for(let t of this.viewports)t.setContentHeight(e);this.repaintViews(),!1===Mu.has(this.track.type)&&this.updateScrollbar(),this.dragHandle.style.height=`${e}px`,this.gearContainer.style.height=`${e}px`}updateScrollbar(){const e=this.viewports[0].$viewport.height();this.outerScroll.style.height=`${e}px`;const t=this.maxViewportContentHeight(),i=Math.round(e/t*e);t>e?(this.innerScroll.style.display="block",this.innerScroll.style.height=`${i}px`):this.innerScroll.style.display="none"}moveScroller(e){const t=ft(this.innerScroll).position().top+e,i=Math.min(Math.max(0,t),this.outerScroll.clientHeight-this.innerScroll.clientHeight);ft(this.innerScroll).css("top",`${i}px`);const n=this.maxViewportContentHeight(),r=-Math.round(i*(n/this.viewports[0].$viewport.height()));for(let e of this.viewports)e.setTop(r);this.sampleNameViewport.trackScrollDelta=e,this.sampleNameViewport.setTop(r)}isLoading(){for(let e of this.viewports)if(e.isLoading())return!0}repaintViews(){for(let e of this.viewports)e.isVisible()&&e.repaint();"function"==typeof this.track.paintAxis&&this.paintAxis(),this.repaintSamples()}repaintSamples(){if("function"==typeof this.track.getSamples){const e=this.track.getSamples();this.sampleNameViewport.repaint(e)}}setTrackLabelName(e){this.viewports.forEach((t=>t.setTrackLabel(e)))}resize(e){for(let t of this.viewports)t.setWidth(e)}async updateViews(){if(!this.browser||!this.browser.referenceFrameList)return;const e=this.viewports.filter((e=>e.isVisible()));if(e.forEach((e=>e.shift())),this.browser.dragObject)return;const t=e.filter((e=>e.needsRepaint())).filter((e=>e.checkZoomIn())),i=t.filter((e=>e.needsReload()));for(let e of i)await e.loadFeatures();if(this.disposed)return;if(this.track&&"function"==typeof this.track.variantRowCount&&i.length>0){let e=0;for(let t of this.viewports)t.featureCache&&t.featureCache.features&&(e=Math.max(e,t.featureCache.features.reduce(((e,t)=>Math.max(e,t.row||0)),0)));if(this.track.nVariantRows!==e+1){this.track.variantRowCount(e+1);for(let e of this.viewports)e.checkContentHeight()}}if(this.track.autoscale){let t=[];for(let i of e){const e=i.referenceFrame,n=e.start,r=n+e.toBP(i.getWidth());if(i.featureCache&&i.featureCache.features)if("function"==typeof i.featureCache.features.getMax){const e=i.featureCache.features.getMax(n,r);t.push({value:e})}else{const e=bo(i.featureCache.features,n,r);for(let i of e)t.push(i)}}"function"==typeof this.track.doAutoscale?this.track.dataRange=this.track.doAutoscale(t):this.track.dataRange=Ro(t)}const n=this.track.autoscale||this.track.autoscaleGroup||"ruler"===this.track.type;for(let i of e)t.includes(i)?i.repaint():n&&i.refresh();this.adjustTrackHeight(),this.repaintSamples(),this.updateRulerViewportLabels()}clearCachedFeatures(){for(let e of this.viewports)e.clearCache()}updateRulerViewportLabels(){const e=this.browser.calculateViewportWidth(this.viewports.length);for(let t of this.viewports)"ruler"===this.track.type&&(this.viewports.length>1?t.presentLocusLabel(e):t.dismissLocusLabel())}async getInViewFeatures(){if(!this.browser||!this.browser.referenceFrameList)return[];let e=[];const t=this.viewports.filter((e=>e.isVisible()));for(let i of t){const t=i.referenceFrame,{chr:n,start:r,bpPerPixel:s}=i.referenceFrame,o=r+t.toBP(i.getWidth());if((!i.featureCache||!i.featureCache.containsRange(n,r,o,s))&&await i.loadFeatures(),i.featureCache&&i.featureCache.features)if("function"==typeof i.featureCache.features.getMax){const t=i.featureCache.features.getMax(r,o);e.push({value:t})}else{const t="function"==typeof i.featureCache.queryFeatures?i.featureCache.queryFeatures(n,r,o):bo(i.featureCache.features,r,o);e=e.concat(t)}}return e}checkContentHeight(){for(let e of this.viewports)e.checkContentHeight();this.adjustTrackHeight()}adjustTrackHeight(){var e=this.maxViewportContentHeight();if(this.track.autoHeight?this.setTrackHeight(e,!1):this.track.paintAxis&&this.paintAxis(),!1===Mu.has(this.track.type)){const t=this.viewports[0].getContentTop(),i=this.viewports[0].$viewport.height(),n=Math.min(0,i-e);if(t<n)for(let e of this.viewports)e.setTop(n);this.updateScrollbar()}}createTrackScrollbar(e){const t=_t.div();if(e.columnContainer.querySelector(".igv-scrollbar-column").appendChild(t),t.style.height=`${this.track.height}px`,this.outerScroll=t,!1===Mu.has(this.track.type)){const i=_t.div();t.appendChild(i),this.innerScroll=i,this.addTrackScrollMouseHandlers(e)}}createTrackDragHandle(e){const t="ideogram"===this.track.type||"ruler"===this.track.type?"igv-track-drag-shim":"igv-track-drag-handle";this.dragHandle=_t.div({class:t}),e.columnContainer.querySelector(".igv-track-drag-column").appendChild(this.dragHandle),this.dragHandle.style.height=`${this.track.height}px`,this.addTrackDragMouseHandlers(e)}createTrackGearPopup(e){this.gearContainer=_t.div(),e.columnContainer.querySelector(".igv-gear-menu-column").appendChild(this.gearContainer),this.gearContainer.style.height=`${this.track.height}px`,!0===this.track.ignoreTrackMenu||(this.gear=_t.div(),this.gearContainer.appendChild(this.gear),this.gear.appendChild(At.createIcon("cog")),this.trackGearPopup=new Au(this.gear),this.addTrackGearMouseHandlers())}addAxisEventListener(e){this.boundAxisClickHander=function(e){this.browser.dataRangeDialog.configure(this),this.browser.dataRangeDialog.present(ft(this.browser.columnContainer))}.bind(this),e.addEventListener("click",this.boundAxisClickHander)}removeAxisEventListener(e){e.removeEventListener("click",this.boundAxisClickHander)}addTrackScrollMouseHandlers(e){this.boundTrackScrollMouseDownHandler=function(t){t.stopPropagation();const{y:i}=_t.pageCoordinates(t);ft(this.innerScroll).data("yDown",i.toString()),this.boundColumnContainerMouseMoveHandler=function(e){e.stopPropagation();const{y:t}=_t.pageCoordinates(e);this.moveScroller(t-parseInt(ft(this.innerScroll).data("yDown"))),ft(this.innerScroll).data("yDown",t.toString())}.bind(this),e.columnContainer.addEventListener("mousemove",this.boundColumnContainerMouseMoveHandler)}.bind(this),this.innerScroll.addEventListener("mousedown",this.boundTrackScrollMouseDownHandler),this.boundColumnContainerMouseUpHandler=function(t){e.columnContainer.removeEventListener("mousemove",this.boundColumnContainerMouseMoveHandler)}.bind(this),e.columnContainer.addEventListener("mouseup",this.boundColumnContainerMouseUpHandler)}removeTrackScrollMouseHandlers(){!1===Mu.has(this.track.type)&&(this.innerScroll.removeEventListener("mousedown",this.boundTrackScrollMouseDownHandler),this.browser.columnContainer.removeEventListener("mouseup",this.boundColumnContainerMouseUpHandler),this.browser.columnContainer.removeEventListener("mousemove",this.boundColumnContainerMouseMoveHandler))}addTrackDragMouseHandlers(e){if("ideogram"===this.track.id||"ruler"===this.track.id);else{let t;function i(i){i.preventDefault(),t=i.target,t.classList.add("igv-track-drag-handle-hover"),e.startTrackDrag(this)}function n(i){e.endTrackDrag(),t&&i.target!==t&&t.classList.remove("igv-track-drag-handle-hover"),t=void 0}function r(i){i.preventDefault(),void 0===t&&i.target.classList.add("igv-track-drag-handle-hover"),e.updateTrackDrag(this)}function s(e){e.preventDefault(),void 0===t&&e.target.classList.remove("igv-track-drag-handle-hover")}this.boundTrackDragMouseDownHandler=i.bind(this),this.dragHandle.addEventListener("mousedown",this.boundTrackDragMouseDownHandler),this.boundDocumentTrackDragMouseUpHandler=n.bind(this),document.addEventListener("mouseup",this.boundDocumentTrackDragMouseUpHandler),this.boundTrackDragMouseEnterHandler=r.bind(this),this.dragHandle.addEventListener("mouseenter",this.boundTrackDragMouseEnterHandler),this.dragHandle.addEventListener("mouseout",(e=>{e.preventDefault(),void 0===t&&e.target.classList.remove("igv-track-drag-handle-hover")})),this.boundTrackDragMouseOutHandler=s.bind(this),this.dragHandle.addEventListener("mouseout",this.boundTrackDragMouseOutHandler)}}removeTrackDragMouseHandlers(){"ideogram"===this.track.id||"ruler"===this.track.id||(this.dragHandle.removeEventListener("mousedown",this.boundTrackDragMouseDownHandler),document.removeEventListener("mouseup",this.boundDocumentTrackDragMouseUpHandler),this.dragHandle.removeEventListener("mouseup",this.boundTrackDragMouseEnterHandler),this.dragHandle.removeEventListener("mouseout",this.boundTrackDragMouseOutHandler))}addTrackGearMouseHandlers(){if(!0===this.track.ignoreTrackMenu);else{function e(e){e.preventDefault(),e.stopPropagation(),this.trackGearPopup.presentMenuList($t.trackMenuItemList(this))}this.boundTrackGearClickHandler=e.bind(this),this.gear.addEventListener("click",this.boundTrackGearClickHandler)}}removeTrackGearMouseHandlers(){!0===this.track.ignoreTrackMenu||this.gear.removeEventListener("click",this.boundTrackGearClickHandler)}dispose(){this.removeAxisEventListener(this.axis),this.axis.remove();for(let e of this.viewports)e.dispose();this.sampleNameViewport.dispose(),this.removeTrackScrollMouseHandlers(),this.outerScroll.remove(),this.removeTrackDragMouseHandlers(),this.dragHandle.remove(),this.removeTrackGearMouseHandlers(),this.gearContainer.remove(),"function"==typeof this.track.dispose&&this.track.dispose();for(let e of Object.keys(this))this[e]=void 0;this.alert&&this.alert.container.remove(),this.disposed=!0}paintAxis(){if("function"==typeof this.track.paintAxis){const{width:e,height:t}=this.axisCanvas.getBoundingClientRect(),i=window.devicePixelRatio||1;this.axisCanvas.height=i*t,this.axisCanvas.width=i*e;const n=this.axisCanvas.getContext("2d");n.scale(i,i),this.track.paintAxis(n,e,t)}}maxViewportContentHeight(){return Math.max(this.viewports.map((e=>e.getContentHeight())))}}class Lu extends Ll{static defaults={height:50,color:"rgb(150, 150, 150)",altColor:"rgb(150, 150, 150)",flipAxis:!1,logScale:!1,windowFunction:"mean",graphType:"bar",autoscale:!0,normalize:void 0,scaleFactor:void 0};constructor(e,t){super(e,t)}init(e){super.init(e),this.type="wig",this.featureType="numeric",this.paintAxis=dd;const t=e.format?e.format.toLowerCase():e.format;e.featureSource?(this.featureSource=e.featureSource,delete e.featureSource):this.featureSource="bigwig"===t?new Jh(e,this.browser.genome):"tdf"===t?new rc(e,this.browser.genome):dc(e,this.browser.genome),void 0===e.max||!0===e.autoscale?this.autoscale=!0:this.dataRange={min:e.min||0,max:e.max}}async postInit(){const e=await this.getHeader();this.disposed||e&&this.setTrackProperties(e)}async getFeatures(e,t,i,n){const r=await this.featureSource.getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:this.visibilityWindow,windowFunction:this.windowFunction});if(this.normalize&&this.featureSource.normalizationFactor){const e=this.featureSource.normalizationFactor;for(let t of r)t.value*=e}if(this.scaleFactor){const e=this.scaleFactor;for(let t of r)t.value*=e}return r}menuItemList(){let e=[];return void 0!==this.flipAxis&&(e.push("<hr>"),e.push({label:"Flip y-axis",click:()=>{this.flipAxis=!this.flipAxis,this.trackView.repaintViews()}})),e=e.concat($t.numericDataMenuItems(this.trackView)),e}async getHeader(){return"function"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader()),this.header}getScaleFactor(e,t,i,n){return n?i/(Math.log10(t+1)-(e<=0?0:Math.log10(e+1))):i/(t-e)}computeYPixelValue(e,t){return(this.flipAxis?e-this.dataRange.min:this.dataRange.max-e)*t}computeYPixelValueInLogScale(e,t){let i=this.dataRange.max,n=this.dataRange.min;return i<=0?0:(n<=-1&&(n=0),n=n<=0?0:Math.log10(n+1),i=Math.log10(i+1),e=Math.log10(e+1),(this.flipAxis?e-n:i-e)*t)}draw(e){const t=e.features,i=e.context,n=e.bpPerPixel,r=e.bpStart,s=e.pixelWidth;e.pixelHeight;const o=r+s*n+1,a=this.color||Lu.defaults.color;let l;"string"==typeof a&&a.startsWith("rgb(")&&(l=Ds.addAlpha(a,.1));const h=this.getScaleFactor(this.dataRange.min,this.dataRange.max,e.pixelHeight,this.logScale),c=e=>this.logScale?this.computeYPixelValueInLogScale(e,h):this.computeYPixelValue(e,h);if(t&&t.length>0&&(void 0===this.dataRange.min&&(this.dataRange.min=0),this.dataRange.max>this.dataRange.min)){let s,a=-1;const h=c(0);for(let e of t){if(e.end<r)continue;if(e.start>o)break;const t=Math.floor((e.start-r)/n);if(isNaN(t))continue;let l=c(e.value);const d=Math.ceil((e.end-r)/n),u=Math.max(1,d-t),f=this.getColorForFeature(e);if("points"===this.graphType){const e=this.config.pointSize||3,n=t+u/2;Co.fillCircle(i,n,l,e/2,{fillStyle:f,strokeStyle:f})}else if("line"===this.graphType)null!=s&&Co.strokeLine(i,a,s,t,l,{fillStyle:f,strokeStyle:f}),Co.strokeLine(i,t,l,t+u,l,{fillStyle:f,strokeStyle:f});else{const e=l-h;Co.fillRect(i,t,h,u,e,{fillStyle:f})}a=t+u,s=l}if(this.dataRange.min<0){const t=this.dataRange.max/(this.dataRange.max-this.dataRange.min)*e.pixelHeight;Co.strokeLine(i,0,t,e.pixelWidth,t,{strokeStyle:l})}}if(this.config.hasOwnProperty("guideLines"))for(let t of this.config.guideLines)if(t.hasOwnProperty("color")&&t.hasOwnProperty("y")&&t.hasOwnProperty("dotted")){let i=c(t.y),n={strokeStyle:t.color,strokeWidth:2};t.dotted?Co.dashedLine(e.context,0,i,e.pixelWidth,i,5,n):Co.strokeLine(e.context,0,i,e.pixelWidth,i,n)}}popupData(e,t){if(void 0===t&&(t=this.clickedFeatures(e)),t&&t.length>0){const i=e.genomicLocation,n=[];t.sort((function(e,t){return Math.abs((e.start+e.end)/2-i)-Math.abs((t.start+t.end)/2-i)}));const r=t.length>10?t.slice(0,10):t;r.sort((function(e,t){return e.start-t.start}));for(let e of r)if(e){n.length>0&&n.push("<hr/>");let t=e.end-e.start==1?Xt(e.start+1):Xt(e.start+1)+"-"+Xt(e.end);n.push({name:"Position:",value:t}),n.push({name:"Value: ",value:Xt(e.value)})}return r.length<t.length&&n.push("<hr/>..."),n}return[]}get supportsWholeGenome(){return!this.config.indexURL&&!1!==this.config.supportsWholeGenome}getColorForFeature(e){let t=e.value<0&&this.altColor?this.altColor:this.color||Lu.defaults.color;return"function"==typeof t?t(e.value):t}dispose(){this.trackView=void 0}}function Iu(e){this.thresholds=e.thresholds,this.colors=e.colors}function Bu(e){this.scale=e,this.lowColor="rgb("+e.lowR+","+e.lowG+","+e.lowB+")",this.highColor="rgb("+e.highR+","+e.highG+","+e.highB+")",this.diff=e.high-e.low}Iu.prototype.getColor=function(e){for(let t of this.thresholds)if(e<t)return this.colors[this.thresholds.indexOf(t)];return this.colors[this.colors.length-1]},Bu.prototype.getColor=function(e){var t,i=this.scale;return e<=i.low?this.lowColor:e>=i.high?this.highColor:(t=(e-i.low)/this.diff,"rgb("+Math.floor(i.lowR+t*(i.highR-i.lowR))+","+Math.floor(i.lowG+t*(i.highG-i.lowG))+","+Math.floor(i.lowB+t*(i.highB-i.lowB))+")")};class Fu{constructor(e){this.color=e}getColor(){return this.color}}class Nu extends Ll{constructor(e,t){super(e,t)}init(e){if(super.init(e),this.type=e.type||"seg","maf"===this.type&&(this.type="mut"),this.isLog=e.isLog,this.displayMode=e.displayMode||"EXPANDED",this.height=e.height||300,this.maxHeight=e.maxHeight||500,this.squishedRowHeight=e.sampleSquishHeight||e.squishedRowHeight||2,this.expandedRowHeight=e.sampleExpandHeight||e.expandedRowHeight||13,this.sampleHeight=this.squishedRowHeight,e.color?this.color=e.color:(this.posColorScale=e.posColorScale||new Bu({low:.1,lowR:255,lowG:255,lowB:255,high:1.5,highR:255,highG:0,highB:0}),this.negColorScale=e.negColorScale||new Bu({low:-1.5,lowR:0,lowG:0,lowB:255,high:-.1,highR:255,highG:255,highB:255}),"mut"===this.type&&(this.colorTable=new _o(e.colorTable||Ou))),this.sampleKeys=[],this.sampleNames=new Map,e.samples){for(let t of e.samples)this.sampleKeys.push(t),this.sampleNames.set(t,t);this.explicitSamples=!0}const t=Object.assign({},this.config);t.maxWGCount=t.maxWGCount||Number.MAX_SAFE_INTEGER,this.featureSource=dc(t,this.browser.genome),this.initialSort=e.sort}async postInit(){"function"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader(),this.disposed)||this.header&&this.setTrackProperties(this.header)}menuItemList(){const e=[],t={SQUISHED:"Squish",EXPANDED:"Expand",FILL:"Fill"};e.push("<hr/>"),e.push("DisplayMode:");const i="seg"===this.type?["SQUISHED","EXPANDED","FILL"]:["SQUISHED","EXPANDED"];for(let n of i){const i=jt(t[n],n===this.displayMode);e.push({object:ft(i),click:()=>{this.displayMode=n,this.config.displayMode=n,this.trackView.checkContentHeight(),this.trackView.repaintViews(),this.trackView.moveScroller(this.trackView.sampleNameViewport.trackScrollDelta)}})}return e}hasSamples(){return!0}getSamples(){return{names:this.sampleKeys.map((e=>this.sampleNames.get(e))),height:this.sampleHeight,yOffset:0}}async getFeatures(e,t,i){const n=await this.featureSource.getFeatures({chr:e,start:t,end:i});if(this.initialSort){const e=this.initialSort;this.sortSamples(e.chr,e.start,e.end,e.direction,n),this.initialSort=void 0}return n}draw({context:e,renderSVG:t,pixelTop:i,pixelWidth:n,pixelHeight:r,features:s,bpPerPixel:o,bpStart:a}){if(Co.fillRect(e,0,i,n,r,{fillStyle:"rgb(255, 255, 255)"}),s&&s.length>0){this.checkForLog(s),this.updateSampleKeys(s);const t={};let l;switch(this.sampleKeys.forEach((function(e,i){t[e]=i})),this.displayMode){case"FILL":this.sampleHeight=r/this.sampleKeys.length,l=0;break;case"SQUISHED":this.sampleHeight=this.squishedRowHeight,l=0;break;default:this.sampleHeight=this.expandedRowHeight,l=1}const h=this.sampleHeight;for(let e of s)e.pixelRect=void 0;const c=i+r,d=a+n*o+1,u=o;this.sampleYStart=void 0;for(let n of s){if(n.end<a)continue;if(n.start>d)break;const r=n.sampleKey||n.sample;n.row=t[r];const s=n.row*h+l;void 0===this.sampleYStart&&(this.sampleYStart=s);if(s+h<i||s>c)continue;const o=Math.max(n.start,a);let f=Math.round((o-a)/u);const p=Math.min(n.end,d),g=Math.round((p-a)/u);let m,b,w=Math.max(1,g-f);if(this.color?m="function"==typeof this.color?this.color(n):this.color:this.colorTable&&(m=this.colorTable.getColor(n.value.toLowerCase())),"mut"===this.type)b=h-2*l,w<3&&(w=3,f-=1);else{let e=n.value;this.isLog||(e=Ns.log2(e/2)),m=e<-.1?this.negColorScale.getColor(e):e>.1?this.posColorScale.getColor(e):"white";let t=h;if(h<.25){const i=.1+2*Math.abs(e);t=Math.min(1,i*h)}b=t-2*l}n.pixelRect={x:f,y:s,w:w,h:b},e.fillStyle=m,e.fillRect(f,s,w,b)}}}checkForLog(e){if(void 0===this.isLog){this.isLog=!1;for(let t of e)if(t.value<0)return void(this.isLog=!0)}}computePixelHeight(e){if(!e)return 0;const t="SQUISHED"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight;return this.updateSampleKeys(e),this.sampleKeys.length*t}async sortSamples(e,t,i,n,r){if(r||(r=await this.featureSource.getFeatures({chr:e,start:t,end:i})),!r)return;this.updateSampleKeys(r);const s={},o="ASC"===n?1:-1,a=()=>{const e=i-t+1;for(let n of r){if(n.end<t)continue;if(n.start>i)break;const r=Math.max(t,n.start),o=(Math.min(i,n.end)-r)/e,a=n.sampleKey||n.sample,l=s[a]||0;s[a]=l+o*n.value}this.sampleKeys.sort((function(e,t){let i=s[e],n=s[t];return i||(i=o*Number.MAX_VALUE),n||(n=o*Number.MAX_VALUE),i===n?0:i>n?o:-1*o}))},l=()=>{for(let e of r){if(e.end<t)continue;if(e.start>i)break;const n=e.sampleKey||e.sample;(!s.hasOwnProperty(n)||e.value.localeCompare(s[n])>0)&&(s[n]=e.value)}this.sampleKeys.sort((function(e,t){let i=s[e]||"",n=s[t]||"";return o*i.localeCompare(n)}))};"mut"===this.type?l():a(),this.trackView.repaintViews()}clickedFeatures(e){const t=super.clickedFeatures(e),i=e.y;return t.filter((function(e){const t=e.pixelRect;return t&&i>=t.y&&i<=t.y+t.h}))}hoverText(e){const t=this.clickedFeatures(e);if(t&&t.length>0)return`${t[0].sample}: ${t[0].value}`}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=[];for(let e of t){i.length>0&&(i.push("<hr/>"),i.push("<hr/>"));const t=e._f||e,n="function"==typeof t.popupData?t.popupData(this.type,this.browser.genome.id):this.extractPopupData(t);Array.prototype.push.apply(i,n)}return i}contextMenuItemList(e){const t=e.viewport.referenceFrame,i=e.genomicLocation,n=this.config.sort?"ASC"===this.config.sort.direction?"DESC":"ASC":"DESC",r=t.toBP(2.5),s=t=>{const i=e.viewport.cachedFeatures;this.sortSamples(t.chr,t.start,t.end,t.direction,i)};return[{label:"seg"===this.type?"Sort by value":"Sort by type",click:t=>{const o={direction:n,chr:e.viewport.referenceFrame.chr,start:i-r,end:i+r};s(o),this.config.sort=o}}]}get supportsWholeGenome(){return(!1===this.config.indexed||!this.config.indexURL)&&!1!==this.config.supportsWholeGenome}updateSampleKeys(e){if(!this.explicitSamples)for(let t of e){const e=t.sampleKey||t.sample;this.sampleNames.has(e)||(this.sampleNames.set(e,t.sample),this.sampleKeys.push(e))}}}const Ou={indel:"rgb(0,200,0)","targeted region":"rgb(236,155,43)",truncating:"rgb(\t150,0,0)","non-coding transcript":"rgb(0,0,150)",synonymous:"rgb(109,165,95)",silent:"rgb(109,135,80)",missense_mutation:"rgb(72,130,187)",missense:"rgb(72,130,187)","splice site":"rgb(143,83,155)",splice_region:"rgb(143,83,155)",nonsense:"rgb(216, 57,81)",nonsense_mutation:"rgb(216, 57,81)",frame_shift_del:"rgb(226,135,65)",frame_shift_ins:"rgb(226,135,65)",in_frame_del:"rgb(247,235,94)",in_frame_ins:"rgb(247,235,94)","*other*":"rgb(159,91,50)"};class Pu extends Ll{constructor(e,t){super(e,t),this.type="merged",this.featureType="numeric",this.paintAxis=dd,this.graphType=e.graphType}init(e){if(!e.tracks)throw Error("Error: no tracks defined for merged track"+e);super.init(e)}async postInit(){this.tracks=[];const e=[];for(let t of this.config.tracks){t.isMergedTrack=!0;const i=await this.browser.createTrack(t);i?(i.autoscale=!1,this.tracks.push(i)):console.warn("Could not create track "+t),"function"==typeof i.postInit&&e.push(i.postInit())}this.flipAxis=!!this.config.flipAxis&&this.config.flipAxis,this.logScale=!!this.config.logScale&&this.config.logScale,this.autoscale=this.config.autoscale||void 0===this.config.max,this.autoscale||(this.dataRange={min:this.config.min||0,max:this.config.max});for(let e of this.tracks)e.autoscale=!1,e.dataRange=this.dataRange;return this.height=this.config.height||50,Promise.all(e)}get height(){return this._height}set height(e){if(this._height=e,this.tracks)for(let t of this.tracks)t.height=e,t.config.height=e}menuItemList(){let e=[];return void 0!==this.flipAxis&&e.push({label:"Flip y-axis",click:()=>{this.flipAxis=!this.flipAxis,this.trackView.repaintViews()}}),e=e.concat($t.numericDataMenuItems(this.trackView)),e}async getFeatures(e,t,i,n){const r=this.tracks.map((r=>r.getFeatures(e,t,i,n))),s=await Promise.all(r);return new Du(s)}draw(e){const t=e.features;for(let i=0,n=this.tracks.length;i<n;i++){const n=Object.assign({},e);n.features=t.featureArrays[i],this.tracks[i].dataRange=this.dataRange,this.tracks[i].flipAxis=this.flipAxis,this.tracks[i].logScale=this.logScale,this.graphType&&(this.tracks[i].graphType=this.graphType),this.tracks[i].draw(n)}}popupData(e){if(e.viewport&&e.viewport.cachedFeatures){const t=e.viewport.cachedFeatures.featureArrays;if(t&&t.length===this.tracks.length){const i=[];for(let n=0;n<this.tracks.length;n++){n>0&&i.push("<hr/>"),i.push(`<div style=background-color:rgb(245,245,245);border-bottom-style:dashed;border-bottom-width:1px;padding-bottom:5px;padding-top:10px;font-weight:bold;font-size:larger >${this.tracks[n].name}</div>`);const r=this.tracks[n].popupData(e,t[n]);i.push(...r)}return i}}}clickedFeatures(e){const t=e.viewport.cachedFeatures;if(!t)return[];const i=e.genomicLocation,n=[];for(let r of t.featureArrays){const t=e.referenceFrame.bpPerPixel>.2?3*e.referenceFrame.bpPerPixel:.2,s=bo(r,i-t,i+t);for(let e of s)n.push(e)}return n}get supportsWholeGenome(){return this.tracks.every((e=>e.supportsWholeGenome))}}class Du{constructor(e){this.featureArrays=e}getMax(e,t){let i=-Number.MAX_VALUE;for(let n of this.featureArrays)for(let r of n)if(void 0!==r.value&&!Number.isNaN(r.value)){if(r.end<e)continue;if(r.start>t)break;i=Math.max(i,r.value)}return i}}class zu extends Ll{static defaults={height:250,theta:Math.PI/4,arcOrientation:!0,showBlocks:!0,blockHeight:3,thickness:1,alpha:.02,logScale:!0};constructor(e,t){super(e,t)}init(e){super.init(e),this.sinTheta=Math.sin(this.theta),this.cosTheta=Math.cos(this.theta),this.arcType=function(e){if(!e.arcType)return"nested";switch(e.arcType){case"chiapet":return"inView";case"chiapetoutbound":return"partialInView";default:return e.arcType}}(e),this.alpha=e.alpha||.02,this.painter={flipAxis:!this.arcOrientation,dataRange:this.dataRange,paintAxis:dd},e.valueColumn?(this.valueColumn=e.valueColumn,this.hasValue=!0):e.useScore&&(this.hasValue=!0,this.valueColumn="score"),e.max?(this.dataRange={min:e.min||0,max:e.max},this.autoscale=!1):this.autoscale=!0,e.featureSource?(this.featureSource=e.featureSource,delete e._featureSource):(this.featureSource=dc(e,this.browser.genome),this.featureSource.getWGFeatures=ju)}async postInit(){if("function"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),void 0===this.visibilityWindow&&"function"==typeof this.featureSource.defaultVisibilityWindow&&(this.visibilityWindow=await this.featureSource.defaultVisibilityWindow(),this.featureSource.visibilityWindow=this.visibilityWindow),this}get supportsWholeGenome(){return!0}async getFeatures(e,t,i){const n=this.visibilityWindow,r=await this.featureSource.getFeatures({chr:e,start:t,end:i,visibilityWindow:n});return void 0===this.hasValue&&r&&r.length>0&&(this.hasValue=void 0!==r[0].score),r}draw(e){"proportional"===this.arcType||"inView"===this.arcType||"partialInView"===this.arcType?this.drawProportional(e):this.drawNested(e)}drawNested(e){const t=e.context,i=e.pixelWidth,n=e.pixelHeight,r=e.viewportWidth,s=e.bpPerPixel,o=e.bpStart,a=s;Co.fillRect(t,0,e.pixelTop,i,n,{fillStyle:"rgb(255, 255, 255)"});const l=e.features;if(l){(function(){let e=0;for(let t of l){let n=(t.start-o)/a,r=(t.end-o)/a;n>=0&&r<=i&&(e=Math.max(e,r-n))}let t=Math.min(r,e)/2;if(e>0){let e=(n-10)/t;this.theta=function(e){let t,i=[.01570925532366355,.15838444032453644,.3249196962329063,.5095254494944288,.7265425280053609,.9999999999999999],n=[.031415926535897934,.3141592653589793,.6283185307179586,.9424777960769379,1.2566370614359172,1.5707963267948966];for(t=0;t<i.length&&!(i[t]>e);t++);let r=0===t?0:i[t-1],s=t<i.length?i[t]:1,o=(e-r)/(s-r),a=0===t?0:n[t-1],l=t<n.length?n[t]:Math.PI/2;return Math.min(Math.PI/2,a+o*(l-a))}(e),this.sinTheta=Math.sin(this.theta),this.cosTheta=Math.cos(this.theta)}}).call(this);const s=this.arcOrientation?e.pixelHeight:0,c=this.arcOrientation;t.font="8px sans-serif",t.textAlign="center";for(let e of l){let n;if(e.drawState=void 0,"function"==typeof this.color?n=this.color(e):(n=this.color||e.color||"rgb(180,25,137)",n&&this.config.useScore&&(n=qu(n,(h=e.score,Math.min(1,.11+h/779*.89).toString())))),t.lineWidth=e.thickness||this.thickness||1,e.chr1===e.chr2||"all"===e.chr){const{m1:l,m2:h}=Hu(e,this.browser.genome);let d=Math.round((l-o)/a),u=Math.round((h-o)/a);if(u<0||d>i)continue;let f=u-d;f<3&&(f=3,d--);const p=f/2,g=p/this.sinTheta,m=this.cosTheta*g,b=d+p;let w,v,y;if(c?(w=this.height+m,v=Math.PI+Math.PI/2-this.theta,y=Math.PI+Math.PI/2+this.theta):(w=-m,v=Math.PI/2-this.theta,y=Math.PI/2+this.theta),this.showBlocks&&"all"!==e.chr){const i=(e.start1-o)/a,n=(e.end1-o)/a,r=(e.start2-o)/a,l=(e.end2-o)/a,h=this.arcOrientation?-this.blockHeight:this.blockHeight;t.fillRect(i,s,n-i,h),t.fillRect(r,s,l-r,h)}n&&!this.config.useScore&&f>r&&(n=qu(n,this.alpha)),t.strokeStyle=n,t.fillStyle=n,t.beginPath(),t.arc(b,w,g,v,y,!1),t.stroke(),e.drawState={xc:b,yc:w,r:g}}else{let r=Math.round((e.start-o)/a),s=Math.round((e.end-o)/a);if(s<0||r>i)continue;let l=s-r;l<3&&(l=3,r--);const h=e.chr===e.chr1?e.chr2:e.chr1;t.strokeStyle=n,t.fillStyle=qu(mu(h),.5),c?(t.fillRect(r,this.height/2,l,this.height/2),t.fillText(h,r+l/2,this.height/2-5),e.drawState={x:r,y:this.height/2,w:l,h:this.height/2}):(t.fillRect(r,0,l,this.height/2),t.fillText(h,r+l/2,this.height/2+13),e.drawState={x:r,y:0,w:l,h:this.height/2})}}}var h}getScaleFactor(e,t,i,n){return n?i/(Math.log10(t+1)-(e<=0?0:Math.log10(e+1))):i/(t-e)}drawProportional(e){const t=e.context,i=e.pixelWidth,n=e.pixelHeight,r=e.bpPerPixel,s=e.bpStart,o=r,a=e.referenceFrame.start,l=e.referenceFrame.end;Co.fillRect(t,0,e.pixelTop,i,n,{fillStyle:"rgb(255, 255, 255)"});const h=e.features;if(h&&h.length>0){const n=0,r=this.getScaleFactor(n,this.dataRange.max,e.pixelHeight-1,this.logScale),c=this.arcOrientation?e.pixelHeight:0;for(let e of h){e.drawState=void 0;const n=this.valueColumn?e[this.valueColumn]:e.score;if(void 0===n||Number.isNaN(n))continue;const h=Math.round((this.logScale?Math.log10(n+1):n)*r);if(e.chr1===e.chr2||"all"===e.chr){const{m1:i,m2:r}=Hu(e,this.browser.genome);let d=Math.round((i-s)/o),u=Math.round((r-s)/o)-d;if(u<3&&(u=3,d--),n<this.dataRange.min||n>this.dataRange.max)continue;if("proportional"!==this.arcType){const e="partialInView"===this.arcType,t=i>=a&&r<=l;let n=!1,s=!1;if(!t&&e&&(n=a<=i&&i<=l,n||(s=a<=r&&r<=l)),!(t||n||s))continue}const f=u/2,p=d+u/2;e.drawState={xc:p,yc:c,radiusX:f,radiusY:h};const g=!!this.arcOrientation,m=e.color||this.color;if(t.strokeStyle=m,t.lineWidth=e.thickness||this.thickness||1,!0===t.isSVG?t.strokeEllipse(p,c,f,h,0,0,Math.PI,g):(t.beginPath(),t.ellipse(p,c,f,h,0,0,Math.PI,g),t.stroke()),this.alpha&&(t.fillStyle=qu(m,this.alpha),!0===t.isSVG?t.fillEllipse(p,c,f,h,0,0,Math.PI,g):t.fill()),this.showBlocks&&"all"!==e.chr){t.fillStyle=m;const i=(e.start1-s)/o,n=(e.end1-s)/o,r=(e.start2-s)/o,a=(e.end2-s)/o,l=this.arcOrientation?-this.blockHeight:this.blockHeight;t.fillRect(i,c,n-i,l),t.fillRect(r,c,a-r,l)}}else{let r=Math.round((e.start-s)/o),a=Math.round((e.end-s)/o);if(a<0||r>i||n<this.dataRange.min||n>this.dataRange.max)continue;const l=Math.min(h,this.height-13);let c=a-r;c<3&&(c=3,r--);const d=e.chr===e.chr1?e.chr2:e.chr1;if(t.font="8px sans-serif",t.textAlign="center",t.fillStyle=qu(mu(d),.5),this.arcOrientation){const i=this.height-l;t.fillRect(r,i,c,l),t.fillText(d,r+c/2,i-5),e.drawState={x:r,y:i,w:c,h:l}}else t.fillRect(r,0,c,l),t.fillText(d,r+c/2,l+13),e.drawState={x:r,y:0,w:c,h:l}}}}}clearAxis(e,t,i){Co.fillRect(e,0,0,t,i,{fillStyle:"rgb(255, 255, 255)"})}paintAxis(e,t,i){const n={min:0,max:this.dataRange.max};"proportional"===this.arcType||"inView"===this.arcType||"partialInView"===this.arcType?(this.painter.flipAxis=!this.arcOrientation,this.painter.dataRange=n,this.painter.paintAxis(e,t,i)):this.clearAxis(e,t,i)}menuItemList(){let e=[];if(this.hasValue){e.push("<hr/>");const t={nested:"Nested",proportional:"Proportional - All",inView:"Proportional - Both Ends in View",partialInView:"Proportional - One End in View"};e.push("<b>Arc Type</b>");for(let i of["nested","proportional","inView","partialInView"])e.push({object:ft(jt(t[i],i===this.arcType)),click:()=>{this.arcType=i,this.trackView.repaintViews()}})}return e.push("<hr/>"),e.push({name:"Toggle arc direction",click:()=>{this.arcOrientation=!this.arcOrientation,this.trackView.repaintViews()}}),e.push({name:this.showBlocks?"Hide Blocks":"Show Blocks",click:()=>{this.showBlocks=!this.showBlocks,this.trackView.repaintViews()}}),"proportional"!==this.arcType&&"inView"!==this.arcType&&"partialInView"!==this.arcType||(e=e.concat($t.numericDataMenuItems(this.trackView))),this.browser.circularView&&(e.push("<hr/>"),e.push({label:"Add interactions to circular view",click:()=>{for(let e of this.trackView.viewports)this.addChordsForViewport(e.referenceFrame)}})),e}contextMenuItemList(e){if(this.browser.circularView){const t=e.viewport,i=[];return i.push({label:"Add interactions to circular view",click:()=>{const e=t.referenceFrame;this.addChordsForViewport(e)}}),i.push("<hr/>"),i}}addChordsForViewport(e){const t=("all"===e.chr?this.featureSource.getAllFeatures():this.featureSource.featureCache.queryFeatures(e.chr,e.start,e.end)).filter((e=>e.drawState));if(0===t.length)return;Ud(t.map((e=>{const t=e._f||e;return{uniqueId:`${t.chr1}:${t.start1}-${t.end1}_${t.chr2}:${t.start2}-${t.end2}`,refName:Hd(t.chr1),start:t.start1,end:t.end1,mate:{refName:Hd(t.chr2),start:t.start2,end:t.end2}}})),this,e,.5)}doAutoscale(e){let t=0;if(e)for(let i of e){const e=this.valueColumn?i[this.valueColumn]:i.score;Number.isNaN(e)||(t=Math.max(t,e))}return{min:0,max:t}}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=[];for(let e of t){const t=e._||e;if(i.push({name:"Region 1",value:Vu(t.chr1,t.start1,t.end1,t.strand1)}),i.push({name:"Region 2",value:Vu(t.chr2,t.start2,t.end2,t.strand2)}),t.name&&i.push({name:"Name",value:t.name}),void 0!==t.value&&i.push({name:"Value",value:t.value}),void 0!==t.score&&i.push({name:"Score",value:t.score}),t.extras&&this.header&&this.header.columnNames){const e=this.header.columnNames,n=this.header.hiccups?6:10;for(let r=n;r<e.length;r++)this.header.colorColumn!==r&&("info"===e[r]?$u(i,t.extras[r-n]):i.push({name:e[r],value:t.extras[r-n]}))}break}return i}clickedFeatures(e){const t=e.viewport.cachedFeatures,i=[];if(t){const n="proportional"===this.arcType||"inView"===this.arcType||"partialInView"===this.arcType;for(let r of t)if(r.drawState)if(r.chr1===r.chr2||"all"===r.chr)if(n){const{xc:t,yc:n,radiusX:s,radiusY:o}=r.drawState,a=e.canvasX-t,l=e.canvasY-n,h=a/s*(a/s)+l/o*(l/o);h<=1&&i.push({score:1/h,feature:r})}else{const{xc:t,yc:n,r:s}=r.drawState,o=e.canvasX-t,a=e.canvasY-n,l=Math.abs(Math.sqrt(o*o+a*a)-s);l<5&&i.push({score:l,feature:r})}else{const{x:t,y:n,w:s,h:o}=r.drawState,a=5;if(e.canvasX>=t-a&&e.canvasX<=t+s+a&&e.canvasY>=n&&e.canvasY<=n+o){const n=-Math.abs(e.canvasX-(t+s/2));i.push({score:n,feature:r});break}}}return i.length>1&&i.sort(((e,t)=>e.score-t.score)),i.map((e=>e.feature))}}function Hu(e,t){let i=(e.start1+e.end1)/2,n=(e.start2+e.end2)/2;if("all"===e.chr&&(i=t.getGenomeCoordinate(e.chr1,i),n=t.getGenomeCoordinate(e.chr2,n)),i>n){const e=i;i=n,n=e}return{m1:i,m2:n}}function Vu(e,t,i,n){return n&&"."!==n?`${e}:${Xt(t+1)}-${Xt(i)} (${n})`:`${e}:${Xt(t+1)}-${Xt(i)}`}const Uu=new Map;function qu(e,t){const i=`${e}_${t}`;let n=Uu.get(i);return n||(n=Ds.addAlpha(e,t),Uu.set(i,n)),n}function ju(e){const t=e=>{const t=Object.assign({},e);return t.chr="all",t.start=i.getGenomeCoordinate(e.chr1,e.start1),t.end=i.getGenomeCoordinate(e.chr2,e.end2),t},i=this.genome;let n,r=0;for(let t of i.wgChromosomeNames){let i=e[t];if(i)for(let e of i)e.dup||(r++,e.score&&(!n||e.score>n.score)&&(n=e))}const s=this.maxWGCount,o=n&&n.score>0&&r>s?5:1,a=Math.floor(s/o),l=n&&n.score>0?Math.log(n.score)/o:Number.MAX_SAFE_INTEGER;let h,c=[],d=[];for(let e=0;e<o;e++)d.push([0]),c.push([]);for(let n of i.wgChromosomeNames){let i=e[n];if(i)for(let e of i)if(!e.dup){const i=e.score?Math.max(0,Math.min(o-1,Math.floor(Math.log(e.score)/l))):0;if(c[i].length<a)c[i].push(t(e));else{const n=a/(d[i]+1);if(Math.random()<n){const n=Math.floor(Math.random()*(a-1));c[i][n]=t(e)}}d[i]++}}if(1===o)h=c[0];else{h=[];for(let e of c)for(let t of e)h.push(t);n&&h.push(t(n)),h.sort((function(e,t){return e.start-t.start})),console.log(h.length)}return h}function $u(e,t){const i=t.split(";");for(let t of i){const i=t.split("=");2===i.length&&e.push({name:i[0],value:i[1]})}}const Wu=Qt,Gu=new Map([["REF","referenceBases"],["ALT","alternateBases"],["QUAL","quality"],["FILTER","filter"]]);class Zu extends Ll{static defaults={displayMode:"EXPANDED",sortDirection:"ASC",showGenotypes:!0,squishedVariantHeight:2,squishedCallHeight:1,expandedCallHeight:10,expandedVGap:2,squishedVGap:1,expandedGroupGap:10,squishedGroupGap:5,featureHeight:14,noGenotypeColor:"rgb(200,180,180)",noCallColor:"rgb(225, 225, 225)",nonRefColor:"rgb(200, 200, 215)",mixedColor:"rgb(200, 220, 200)",homrefColor:"rgb(200, 200, 200)",homvarColor:"rgb(17,248,254)",hetvarColor:"rgb(34,12,253)",colorBy:void 0,visibilityWindow:void 0,labelDisplayMode:void 0,type:"variant"};constructor(e,t){super(e,t)}init(e){super.init(e),this.expandedVariantHeight=e.expandedVariantHeight||e.variantHeight||10,this.featureSource=dc(e,this.browser.genome),this._initColorBy=e.colorBy,e.colorTable&&(this.colorTables=new Map,this.colorTables.set(e.colorBy,new _o(e.colorTable))),this._strokecolor=e.strokecolor,this._context_hook=e.context_hook,this.variantRowCount(1)}async postInit(){if(this.header=await this.getHeader(),!this.disposed){if(void 0===this.visibilityWindow&&!1!==this.config.indexed){const e=ti(this.config.url)?this.config.url.name:this.config.url;Wu(e)&&e.toLowerCase().includes("gnomad")?this.visibilityWindow=1e3:"function"==typeof this.featureSource.defaultVisibilityWindow?this.visibilityWindow=await this.featureSource.defaultVisibilityWindow():this.visibilityWindow=1e6}return this}}get supportsWholeGenome(){return!1===this.config.indexed||!0===this.config.supportsWholeGenome}get color(){return this._color}set color(e){this._color=e,this.colorBy=void 0}async getHeader(){if(!this.header){if("function"==typeof this.featureSource.getHeader){const e=await this.featureSource.getHeader();e&&(this.callSets=e.callSets||[]),this.header=e}this.sampleNames=this.callSets?this.callSets.map((e=>e.name)):[]}return this.header}getCallsetsLength(){return this.callSets?this.callSets.length:0}async getFeatures(e,t,i,n){return void 0===this.header&&(this.header=await this.getHeader()),this.featureSource.getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:this.visibilityWindow})}hasSamples(){return this.getCallsetsLength()>0}getSamples(){return{yOffset:this.sampleYOffset,names:this.sampleNames,height:this.sampleHeight}}computePixelHeight(e){if(!e||0==e.length)return 10;const t="COLLAPSED"===this.displayMode?1:this.nVariantRows,i="SQUISHED"===this.displayMode?this.squishedVGap:this.expandedVGap,n="SQUISHED"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,r="SQUISHED"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight;return 10+t*(n+i)+i+((!1===this.showGenotypes?0:this.getCallsetsLength()*t)+1)*(r+i)}variantRowCount(e){this.nVariantRows=e}draw({context:e,pixelWidth:t,pixelHeight:i,bpPerPixel:n,bpStart:r,pixelTop:s,features:o}){Co.fillRect(e,0,s,t,i,{fillStyle:"rgb(255, 255, 255)"});const a="SQUISHED"===this.displayMode?this.squishedVGap:this.expandedVGap,l="COLLAPSED"===this.displayMode?1:this.nVariantRows,h="SQUISHED"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight;this.variantBandHeight=10+l*(h+a);let c=this.callSets;!c&&this._f&&(c=this._f.callSets);const d=this.getCallsetsLength();if(c&&d>0&&!1!==this.showGenotypes&&Co.strokeLine(e,0,this.variantBandHeight,t,this.variantBandHeight,{strokeStyle:"rgb(224,224,224) "}),o){const i="SQUISHED"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight,s="SQUISHED"===this.displayMode?this.squishedVGap:this.expandedVGap,a=r+t*n+1;for(let t of o){if(t.end<r)continue;if(t.start>a)break;const o="SQUISHED"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,l=10+("COLLAPSED"===this.displayMode?0:t.row*(o+s)),h=o;let u=Math.round((t.start-r)/n),f=Math.round((t.end-r)/n),p=Math.max(1,f-u);p<3?(p=3,u-=1):p>5&&(u+=1,p-=2),e.fillStyle=this.getColorForFeature(t),e.fillRect(u,l,p,h);let g=this.getVariantStrokecolor(t);if(g&&(e.strokeStyle=g,e.strokeRect(u,l,p,h)),this.callContextHook(t,e,u,l,p,h),t.pixelRect={x:u,y:l,w:p,h:h},d>0&&!1!==this.showGenotypes){const n="COLLAPSED"===this.displayMode?1:this.nVariantRows;this.sampleYOffset=this.variantBandHeight+s,this.sampleHeight=n*(i+s);let r=0;if(c&&t.calls)for(let n of c){const o=t.calls[n.id];if(o){const a="COLLAPSED"===this.displayMode?0:t.row,l=this.sampleYOffset+r*this.sampleHeight+a*(i+s);let h=!0,c=!0,d=!1;if(o.genotype)for(let e of o.genotype){if("."===e){d=!0;break}0!==e&&(c=!1),0===e&&(h=!1)}o.genotype?e.fillStyle=d?this.noCallColor:c?this.homrefColor:h?this.homvarColor:this.hetvarColor:e.fillStyle=this.noGenotypeColor,e.fillRect(u,l,p,i),n.pixelRect={x:u,y:l,w:p,h:i}}r++}}}}else console.log("No feature list")}getColorForFeature(e){const t=e._f||e;let i;if(this.colorBy){const e=this.colorBy;let n;if(t.info.hasOwnProperty(e))n=t.info[e];else if(Gu.has(e)){n=t[Gu.get(e)]}i=this.getVariantColorTable(e).getColor(n),i||(i="gray")}else i=this._color?"function"==typeof this._color?this._color(e):this._color:"NONVARIANT"===t.type?this.nonRefColor:"MIXED"===t.type?this.mixedColor:this.color;return i}getVariantStrokecolor(e){const t=e._f||e;let i;return i=this._strokecolor?"function"==typeof this._strokecolor?this._strokecolor(t):this._strokecolor:void 0,i}callContextHook(e,t,i,n,r,s){if(this._context_hook&&"function"==typeof this._context_hook){const o=e._f||e;t.save(),this._context_hook(o,t,i,n,r,s),t.restore()}}clickedFeatures(e){let t=super.clickedFeatures(e);const i="EXPANDED"===this.displayMode?this.expandedVGap:this.squishedVGap,n=i+("SQUISHED"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight),r=e.y;if(r<=this.variantBandHeight){const e="SQUISHED"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,n=Math.floor((r-10)/(e+i));"COLLAPSED"!==this.displayMode&&(t=t.filter((e=>e.row===n)))}else if(this.callSets){const e=this.callSets,i=r-this.variantBandHeight,s=Math.floor(i/this.sampleHeight);if(s>=0&&s<e.length){const r=Math.floor((i-s*this.sampleHeight)/n),o="COLLAPSED"===this.displayMode?t:t.filter((e=>e.row===r)),a=e[s];t=o.map((e=>{const t=e.calls[a.id];return function(e,t){if(e.genotype){let i="";if("."===t.alternateBases)i="No Call";else{const n=t.alternateBases.split(",");for(let r of e.genotype)if(i.length>0&&(i+="|"),"."===r)i+=".";else if(0===r)i+=t.referenceBases;else{i+=n[r-1].replace("<","<")}}e.genotypeName=i}}(t,e),t}))}}return t}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=e.genomicLocation,n=this.browser.genome.id,r=this.browser.sampleInformation;let s=[];for(let e of t){const t=e._f||e;if(s.length>0&&s.push({html:'<hr style="border-top-width:2px ;border-color: #c9c3ba" />'}),"function"==typeof t.popupData){const e=t.popupData(i,n);Array.prototype.push.apply(s,e)}else{const e=t;if(void 0!==e.callSetName&&s.push({name:"Name",value:e.callSetName}),e.genotypeName&&s.push({name:"Genotype",value:e.genotypeName}),void 0!==e.phaseset&&s.push({name:"Phase set",value:e.phaseset}),void 0!==e.genotypeLikelihood&&s.push({name:"genotypeLikelihood",value:e.genotypeLikelihood.toString()}),r){var o=r.getAttributes(e.callSetName);o&&Object.keys(o).forEach((function(e){var t=e.replace(/([A-Z])/g," $1");t=t.charAt(0).toUpperCase()+t.slice(1),s.push({name:t,value:o[e]})}))}var a=Object.keys(e.info);a.length&&s.push("<hr/>"),a.forEach((function(t){s.push({name:t,value:decodeURIComponent(e.info[t])})}))}}return s}menuItemList(){const e=[];if(this.header.INFO&&this.header.INFO){const t=this.header.INFO.SVTYPE?["SVTYPE"]:[];if(this._initColorBy&&"SVTYPE"!==this._initColorBy&&t.push(this._initColorBy),t.length>0){e.push("<hr/>");const i=ft('<div class="igv-track-menu-category igv-track-menu-border-top">');i.text("Color by:"),e.push({name:void 0,object:i,click:void 0,init:void 0}),t.sort();for(let i of t){const t=this.colorBy===i,n=i||"None";e.push(this.colorByCB({key:i,label:n},t))}e.push(this.colorByCB({key:void 0,label:"None"},void 0===this.colorBy)),e.push("<hr/>")}}this.getCallsetsLength()>0&&(e.push({object:ft('<div class="igv-track-menu-border-top">')}),e.push({object:ft(jt("Show Genotypes",this.showGenotypes)),click:()=>{this.showGenotypes=!this.showGenotypes,this.trackView.checkContentHeight(),this.trackView.repaintViews()}})),e.push({object:ft('<div class="igv-track-menu-border-top">')});for(let t of["COLLAPSED","SQUISHED","EXPANDED"]){e.push({object:ft(jt({COLLAPSED:"Collapse",SQUISHED:"Squish",EXPANDED:"Expand"}[t],t===this.displayMode)),click:()=>{this.displayMode=t,this.trackView.checkContentHeight(),this.trackView.repaintViews()}})}return this.browser.circularView&&(e.push("<hr>"),e.push({label:"Add SVs to circular view",click:()=>{for(let e of this.trackView.viewports)this.sendChordsForViewport(e)}})),e}contextMenuItemList(e){if(this.browser.circularView){const t=e.viewport,i=[];return i.push({label:"Add SVs to Circular View",click:()=>{this.sendChordsForViewport(t)}}),i.push("<hr/>"),i}}sendChordsForViewport(e){const t=e.referenceFrame;let i;if("all"===t.chr){const e=this.featureSource.getAllFeatures(),t=Object.keys(e).map((t=>e[t]));i=[].concat(...t)}else i=this.featureSource.featureCache.queryFeatures(t.chr,t.start,t.end);Ud(i.filter((e=>{const t=e._f||e;return t.info&&t.info.CHR2&&t.info.END&&(t.info.CHR2!==t.chr||Math.abs(Number.parseInt(t.info.END)-t.pos)>1e6)})).map((e=>{const t=e._f||e,i=Number.parseInt(t.info.END),n=i-100,r=i+100;return{uniqueId:`${t.chr}:${t.start}-${t.end}_${t.info.CHR2}:${t.info.END}`,refName:Hd(t.chr),start:t.start,end:t.end,mate:{refName:Hd(t.info.CHR2),start:n,end:r}}})),this,t,.5)}colorByCB(e,t){return{name:void 0,object:ft(jt(e.label,t)),click:()=>{e.key===this.colorBy?(this.colorBy=void 0,delete this.config.colorBy,this.trackView.repaintViews()):(this.colorBy=e.key,this.config.colorBy=e.key,this.trackView.repaintViews())},init:void 0}}getState(){const e=super.getState();return this._color&&"function"!=typeof this._color&&(e.color=this._color),e}getVariantColorTable(e){if(this.colorTables||(this.colorTables=new Map),!this.colorTables.has(e)){let t;if("SVTYPE"===e)t=Qu;else t=new yo("Set1");this.colorTables.set(e,t)}return this.colorTables.get(e)}}const Qu=new _o({DEL:"#ff2101",INS:"#001888",DUP:"#028401",INV:"#008688",CNV:"#8931ff",BND:"#891100","*":"#002eff"});class Xu extends Ll{constructor(e,t){super(e,t)}init(e){super.init(e),this.name=e.name,this.pValueField=e.pValueField||"pValue",this.geneField=e.geneField||"geneSymbol",this.snpField=e.snpField||"snp";const t=e.minLogP||e.min,i=e.maxLogP||e.max;this.dataRange={min:t||3.5,max:i||25},this.autoscale=!i||e.autoscale,this.autoscalePercentile=void 0===e.autoscalePercentile?98:e.autoscalePercentile,this.background=e.background,this.divider=e.divider||"rgb(225,225,225)",this.dotSize=e.dotSize||2,this.height=e.height||100,this.autoHeight=!1,this.disableButtons=e.disableButtons,this.visibilityWindow=void 0===e.visibilityWindow?2e6:e.visibilityWindow>=0?Math.min(2e6,e.visibilityWindow):2e6,this.featureSource=dc(e,this.browser.genome),$d.gtexLoaded=!0}paintAxis(e,t,i){const n=(this.dataRange.max-this.dataRange.min)/i,r={font:"normal 10px Arial",textAlign:"right",strokeStyle:"black"};Co.fillRect(e,0,0,t,i,{fillStyle:"rgb(255, 255, 255)"});const s=Math.ceil(10*(this.dataRange.max-this.dataRange.min)/i);for(let o=4;o<=this.dataRange.max;o+=s){const s=.85*t,a=s-5,l=s,h=i-(o-this.dataRange.min)/n;Co.strokeLine(e,a,h,l,h,r),h>8&&Co.fillText(e,o,a-1,h+2,r)}r.textAlign="center",Co.fillText(e,"-log10(pvalue)",t/4,i/2,r,{rotate:{angle:-90}})}async getFeatures(e,t,i){const n=this.pValueField,r=this.visibilityWindow,s=await this.featureSource.getFeatures({chr:e,start:t,end:i,visibilityWindow:r});return s.forEach((function(e){e.value=e[n]})),s}draw(e){const t=e.context,i=e.pixelWidth,n=e.pixelHeight;this.background&&Co.fillRect(t,0,0,i,n,{fillStyle:this.background}),Co.strokeLine(t,0,n-1,i,n-1,{strokeStyle:this.divider});const r=r=>{const s=r?2*this.dotSize:this.dotSize,o=e.bpStart,a=(this.dataRange.max-this.dataRange.min)/n,l=e.referenceFrame.selection;for(let c of e.features){const d=(c.start-o+.5)/e.bpPerPixel;if(d<0)continue;if(d>i)break;const u=c.snp.toUpperCase(),f=c[this.geneField].toUpperCase(),p=l&&(l.snp===u||l.gene===f);if(!r||p){l&&l.snp===u&&l.addGene(f);var h=-Math.log(c[this.pValueField])/Math.LN10;if(h>=this.dataRange.min){let e;h>this.dataRange.max?(h=this.dataRange.max,e=!0):e=!1;const i=Math.max(0+s,n-Math.round((h-this.dataRange.min)/a));let o;c.px=d,c.py=i,c.radius=s,r&&l?(o=l.colorForGene(f),Co.setProperties(t,{fillStyle:o,strokeStyle:"black"})):(o=e?"rgb(150, 150, 150)":"rgb(180, 180, 180)",Co.setProperties(t,{fillStyle:o,strokeStyle:o})),Co.fillCircle(t,d,i,s),Co.strokeCircle(t,d,i,s)}}}};r(!1),r(!0)}popupData(e,t){if(void 0===t&&(t=e.viewport.cachedFeatures),!t||0===t.length)return[];const i=this.name,n=[];for(let r of t)Math.abs(r.px-e.canvasX)<r.radius+3&&Math.abs(r.py-e.canvasY)<r.radius+3&&(n.length>0&&n.push("<hr/>"),n.push({name:"snp id",value:r.snp},{name:"gene id",value:r.geneId},{name:"gene name",value:r.geneName},{name:"p value",value:r.pValue},{name:"tissue",value:i}));return n}menuItemList(){return $t.numericDataMenuItems(this.trackView)}doAutoscale(e){if(e.length>0){var t=e.map((function(e){return-Math.log(e.value)/Math.LN10}));this.dataRange.max=Ns.percentile(t,this.autoscalePercentile)}else{const e=this.config.maxLogP||this.config.max;this.dataRange.max=e||25}return this.dataRange}}const Yu={X:"rgb(204, 153, 0)",Y:"rgb(153, 204, 0)",Un:"darkGray)",1:"rgb(80, 80, 255)",2:"rgb(206, 61, 50)","2a":"rgb(210, 65, 55)","2b":"rgb(215, 70, 60)",3:"rgb(116, 155, 88)",4:"rgb(240, 230, 133)",5:"rgb(70, 105, 131)",6:"rgb(186, 99, 56)",7:"rgb(93, 177, 221)",8:"rgb(128, 34, 104)",9:"rgb(107, 215, 107)",10:"rgb(213, 149, 167)",11:"rgb(146, 72, 34)",12:"rgb(131, 123, 141)",13:"rgb(199, 81, 39)",14:"rgb(213, 143, 92)",15:"rgb(122, 101, 165)",16:"rgb(228, 175, 105)",17:"rgb(59, 27, 83)",18:"rgb(205, 222, 183)",19:"rgb(97, 42, 121)",20:"rgb(174, 31, 99)",21:"rgb(231, 199, 111)",22:"rgb(90, 101, 94)",23:"rgb(204, 153, 0)",24:"rgb(153, 204, 0)",25:"rgb(51, 204, 0)",26:"rgb(0, 204, 51)",27:"rgb(0, 204, 153)",28:"rgb(0, 153, 204)",29:"rgb(10, 71, 255)",30:"rgb(71, 117, 255)",31:"rgb(255, 194, 10)",32:"rgb(255, 209, 71)",33:"rgb(153, 0, 51)",34:"rgb(153, 26, 0)",35:"rgb(153, 102, 0)",36:"rgb(128, 153, 0)",37:"rgb(51, 153, 0)",38:"rgb(0, 153, 26)",39:"rgb(0, 153, 102)",40:"rgb(0, 128, 153)",41:"rgb(0, 51, 153)",42:"rgb(26, 0, 153)",43:"rgb(102, 0, 153)",44:"rgb(153, 0, 128)",45:"rgb(214, 0, 71)",46:"rgb(255, 20, 99)",47:"rgb(0, 214, 143)",48:"rgb(20, 255, 177)"};for(let Yb of Object.keys(Yu)){Yu["chr"+Yb]=Yu[Yb]}for(let Kb=1;Kb<=48;Kb++){if(10===Kb)continue;const Jb=Ku(Kb);Yu[Jb]=Yu[Kb.toString()]}function Ku(e){if(!+e)return!1;for(var t=String(+e).split(""),i=["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM","","X","XX","XXX","XL","L","LX","LXX","LXXX","XC","","I","II","III","IV","V","VI","VII","VIII","IX"],n="",r=3;r--;)n=(i[+t.pop()+10*r]||"")+n;return Array(+t.join("")+1).join("M")+n}class Ju extends Ll{constructor(e,t){super(e,t)}init(e){super.init(e),this.useChrColors=void 0===e.useChrColors||e.useChrColors,this.trait=e.trait,this.posteriorProbability=e.posteriorProbability,this.valueProperty="bed"===e.format?"score":"value",this.height=e.height||100,this.autoscale=e.autoscale,this.autoscalePercentile=void 0===e.autoscalePercentile?98:e.autoscalePercentile,this.background=e.background,this.divider=e.divider||"rgb(225,225,225)",this.dotSize=e.dotSize||3,this.popoverWindow=void 0===e.popoverWindow?1e8:e.popoverWindow,this.useChrColors?this.colorScale=new _o(e.colorTable||Yu):e.color?this.colorScale=new Fu(e.color):this.colorScale=new Iu(e.colorScale||{thresholds:[5e-8,5e-4,.5],colors:["rgb(255,50,50)","rgb(251,100,100)","rgb(251,170,170)","rgb(227,238,249)"]}),this.featureSource=dc(e,this.browser.genome)}async postInit(){if("function"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),this.autoscale||(this.posteriorProbability?this.dataRange={min:void 0===this.config.min?0:this.config.min,max:void 0===this.config.max?1:this.config.max}:this.dataRange={min:void 0===this.config.min?0:this.config.min,max:void 0===this.config.max?25:this.config.max}),this}get supportsWholeGenome(){return!0}async getFeatures(e,t,i){const n=this.visibilityWindow;return this.featureSource.getFeatures({chr:e,start:t,end:i,visibilityWindow:n})}draw(e){const t=e.features,i=e.context,n=e.pixelWidth,r=e.pixelHeight;if(this.background&&Co.fillRect(i,0,0,n,r,{fillStyle:this.background}),Co.strokeLine(i,0,r-1,n,r-1,{strokeStyle:this.divider}),t){const s=e.bpPerPixel,o=e.bpStart,a=o+n*s+1;for(let e of t){const t=e.start;if(t<o)continue;if(t>a)break;let n;if(this.posteriorProbability)n=e[this.valueProperty];else{const t=e[this.valueProperty];if(!t)continue;n=-Math.log10(t)}const l=this.useChrColors?e._f?e._f.chr:e.chr:n,h=this.colorScale.getColor(l),c=(this.dataRange.max-this.dataRange.min)/r,d=Math.round((t-o)/s),u=Math.max(this.dotSize,r-Math.round((n-this.dataRange.min)/c));h&&Co.setProperties(i,{fillStyle:h,strokeStyle:"black"}),Co.fillCircle(i,d,u,this.dotSize),e.px=d,e.py=u}}}paintAxis(e,t,i){Co.fillRect(e,0,0,t,i,{fillStyle:"rgb(255, 255, 255)"});var n={font:"normal 10px Arial",textAlign:"right",strokeStyle:"black"};const r=(this.dataRange.max-this.dataRange.min)/i;if(this.posteriorProbability){const t=.1;for(let s=this.dataRange.min;s<this.dataRange.max;s+=t){const t=i-Math.round((s-this.dataRange.min)/r);Co.strokeLine(e,45,t-2,50,t-2,n),Co.fillText(e,s.toFixed(1),44,t+2,n)}}else{const t=Math.ceil(10*(this.dataRange.max-this.dataRange.min)/i);for(let s=this.dataRange.min;s<this.dataRange.max;s+=t){const t=i-Math.round((s-this.dataRange.min)/r);Co.strokeLine(e,45,t,50,t,n),Co.fillText(e,Math.floor(s),44,t+4,n)}}n.textAlign="center",this.posteriorProbability?Co.fillText(e,"PPA",t/2,i/2,n,{rotate:{angle:-90}}):Co.fillText(e,"-log10(pvalue)",t/2,i/2,n,{rotate:{angle:-90}})}popupData(e,t){void 0===t&&(t=e.viewport.cachedFeatures);let i=[];const n=e.viewport.trackView.track;if(t){let r=0;for(let s of t){const t=Math.abs(e.canvasX-s.px),o=Math.abs(e.canvasY-s.py),a=s[this.valueProperty];if(t<this.dotSize&&o<this.dotSize){if(r>0&&i.push("<HR/>"),5==r){i.push("...");break}if("function"==typeof s.popupData)i=i.concat(s.popupData());else{const e=s.realChr||s.chr,t=(s.realStart||s.start)+1;i.push({name:"chromosome",value:e}),i.push({name:"position",value:t}),i.push({name:"name",value:s.name}),n.posteriorProbability?i.push({name:"posterior probability",value:a}):i.push({name:"pValue",value:a})}r++}}}return i}menuItemList(){return $t.numericDataMenuItems(this.trackView)}doAutoscale(e){if(e.length>0){const t=this.valueProperty,i=this.posteriorProbability,n=e.map((function(e){const n=e[t];return{value:i?n:-Math.log(n)/Math.LN10}}));this.dataRange=Ro(n)}else this.posteriorProbability?this.dataRange={min:this.config.min||0,max:this.config.max||1}:this.dataRange={min:this.config.max||25,max:this.config.min||0};return this.dataRange}}class ef extends Ll{constructor(e,t){super(e,t)}init(e){super.init(e),this.autoscale=e.autoscale||void 0===e.max,this.dataRange={min:e.min||0,max:e.max},this.windowFunction=e.windowFunction||"mean",this.paintAxis=dd,this.graphType=e.graphType||"bar",e._featureSource?(this.featureSource=e._featureSource,delete e._featureSource):this.featureSource=dc(this.config,this.browser.genome),this.visibilityWindow=-1,this.featureSource.visibilityWindow=this.visibilityWindow}async postInit(){if("function"==typeof this.featureSource.getHeader){if(this.header=await this.featureSource.getHeader(),this.disposed)return;if(this.sampleNames=this.header.columnNames.slice(3),this.setTrackProperties(this.header),this.header.hasOwnProperty("clickToHighlight")){let e=this.header.clickToHighlight;this.config.clickToHighlight=e,this.config.samplesClickedToHighlight={}}if(this.header.hasOwnProperty("highlight")){this.config.highlightSamples={};let e=this.header.highlight;Array.isArray(e)||(e=[e]);for(let t of e){const e=t.split(";");2===e.length&&(this.config.highlightSamples[e[0]]=e[1])}}}}menuItemList(){return $t.numericDataMenuItems(this.trackView)}async getFeatures(e,t,i){const n=await this.featureSource.getFeatures({chr:e,start:0,end:Number.MAX_SAFE_INTEGER,visibilityWindow:this.visibilityWindow});let r,s;for(let e=1;e<n.length-1;e++)if(void 0===r&&n[e].end>t&&(r=e-1),void 0===s&&n[e].start>i){s=e+1;break}return void 0===r&&(r=0),void 0===s&&(s=n.length),n.slice(r,s)}draw(e){const{features:t,context:i,bpPerPixel:n,bpStart:r,pixelWidth:s,pixelHeight:o}=e,a=e=>(this.dataRange.max-e)/(this.dataRange.max-this.dataRange.min)*o,l=function(e){let t=Math.floor((e-r)/n);return isNaN(t)&&console.warn("isNaN(x). feature start "+Xt(e)+" bp start "+Xt(r)),t};if(t&&t.length>0&&(void 0===this.dataRange.min&&(this.dataRange.min=0),this.dataRange.max>this.dataRange.min)){const e=this.config.highlightSamples,n=this.config.onlyHandleClicksForHighlightedSamples,r=this.config.clickToHighlight;let s=-1,o={},h=[],c=[];this.clickDetectorCache={};for(let d of t){const t=l(d.start),u=l(d.end),f=s>=0?l(s):t;if(!isNaN(t)&&!isNaN(u)){this.clickDetectorCache[t]=[],this.clickDetectorCache[u]=[];for(let s=0;s<d.values.length;s++){const l=this.sampleNames[s],p=d.values[s],g=a(p);if(t-f>=1){const s=o[l],c=a(s),d=e&&e[l];d?h.push([f,c,t,g,d]):r&&l in this.config.samplesClickedToHighlight?h.push([f,c,t,g,this.config.samplesClickedToHighlight[l]]):Co.strokeLine(i,f,c,t,g,{strokeStyle:"#D9D9D9"}),n&&!(l in e)||this.clickDetectorCache[t].push([f,c,t,g,l,d||"gray"])}if(u-t>=1){const s=e&&e[l];s?c.push([t,g,u,g,s]):r&&l in this.config.samplesClickedToHighlight?c.push([t,g,u,g,this.config.samplesClickedToHighlight[l]]):Co.strokeLine(i,t,g,u,g,{strokeStyle:"gray"}),n&&!(l in e)||this.clickDetectorCache[u].push([t,g,u,g,l,s||"gray"])}o[l]=p}s=d.end}}for(let e of h)Co.strokeLine(i,e[0],e[1],e[2],e[3],{strokeStyle:e[4],lineWidth:1.3});for(let e of c)Co.strokeLine(i,e[0],e[1],e[2],e[3],{strokeStyle:e[4],lineWidth:2})}(e=>{if(this.config.hasOwnProperty("guideLines"))for(let t of this.config.guideLines)if(t.hasOwnProperty("color")&&t.hasOwnProperty("y")&&t.hasOwnProperty("dotted")){let i=a(t.y),n={strokeStyle:t.color,strokeWidth:2};t.dotted?Co.dashedLine(e.context,0,i,e.pixelWidth,i,5,n):Co.strokeLine(e.context,0,i,e.pixelWidth,i,n)}})(e)}doAutoscale(e){let t,i;return e.length>0?(t=Number.MAX_VALUE,i=-Number.MAX_VALUE,e.forEach((function(e){t=Math.min(t,...e.values),i=Math.max(i,...e.values)})),t-=.01,i+=.01):(t=0,i=100),{min:t,max:i}}clickedFeatures(e){const t=e.canvasX,i=e.canvasY;let n=null;for(n of Object.keys(this.clickDetectorCache))if(n=parseInt(n),n>=t)break;if(n){let e=Number.MAX_VALUE,o=[];const a=this.clickDetectorCache[n];for(let n of a){const r=n[0],s=n[2];if(t<r||t>s)return[];const a=n[1],l=n[3];if(i<Math.min(a,l)-10||i>Math.max(a,l)+10)continue;const h=tf(t,i,r,a,s,l);h<e&&(o=[{name:n[4],color:n[5]}],e=h)}if(e<5){if(this.config.clickToHighlight){if(o[0].name in this.config.samplesClickedToHighlight)delete this.config.samplesClickedToHighlight[o[0].name];else if("any"===this.config.clickToHighlight){var r=["red","darkblue","green","teal","olivedrab","orange","maroon","purple","blue","gold"],s=r[Math.floor(Math.random()*(r.length+1))];this.config.samplesClickedToHighlight[o[0].name]=s}else this.config.samplesClickedToHighlight[o[0].name]=this.config.clickToHighlight;this.trackView.repaintViews()}return o}}return[]}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=[];return t.forEach((function(e){for(let t of Object.keys(e))Mo(e[t])&&i.push({name:t,value:e[t]})})),i}get supportsWholeGenome(){return!1}}function tf(e,t,i,n,r,s){const o=r-i,a=s-n,l=Math.abs(o*(n-t)-(i-e)*a),h=Math.sqrt(o*o+a*a);return h>0?l/h:0}class nf extends Ll{constructor(e,t){super(e,t),e.height||(this.height=300),this.arcOrientation=!1,this.theta=Math.PI/2,"bp"===e.format?this.featureSource=new sf(e,t.genome):this.featureSource=new Dh(e,t.genome)}async getFeatures(e,t,i){const n=this.visibilityWindow;return this.featureSource.getFeatures({chr:e,start:t,end:i,visibilityWindow:n})}draw(e){const t=e.context,i=Math.PI/2,n=e.pixelWidth,r=e.pixelHeight;e.viewportWidth;const s=e.bpPerPixel,o=e.bpStart,a=s,l=this.arcOrientation;Co.fillRect(t,0,e.pixelTop,n,r,{fillStyle:"rgb(255, 255, 255)"});const h=e.features;if(h){rf(h,1);for(let e of h)if(e.startLeft){let n=Math.round((e.startLeft-o)/a),r=Math.round((e.startRight-o)/a),s=Math.round((e.endLeft-o)/a),h=Math.round((e.endRight-o)/a);t.fillStyle=e.color,t.strokeStyle=e.color,t.beginPath();let c=(n+h)/2,d=(h-n)/2,u=this.height,f=Math.PI+(Math.PI/2-i),p=2*Math.PI-(Math.PI/2-i);l?(u=0,t.arc(c,u,d,p,f),t.lineTo(h,u)):(t.arc(c,u,d,f,p),t.lineTo(s,u));const g=(r+s)/2,m=(s-r)/2,b=u;l?(t.arc(g,b,m,f,p,!0),t.lineTo(s,b)):(t.arc(g,b,m,p,f,!0),t.lineTo(n,b)),t.stroke(),t.fill(),e.drawState={x1:c,y1:u,r1:d,x2:g,y2:b,r2:m,sa:f,ea:p}}else{let n=Math.round((e.start-o)/a),r=Math.round((e.end-o)/a);t.strokeStyle=e.color,t.beginPath();let s=(n+r)/2,h=(r-n)/2,c=this.height,d=Math.PI+(Math.PI/2-i),u=2*Math.PI-(Math.PI/2-i);l?(c=0,t.arc(s,c,h,u,d)):t.arc(s,c,h,d,u),t.stroke(),e.drawState={x1:s,y1:c,r1:h,sa:d,ea:u}}}}clickedFeatures(e){const t=super.clickedFeatures(e),i=[];rf(t,-1);for(let n of t){const t=n.drawState,r=e.canvasX-t.x1,s=e.canvasY-t.y1,o=Math.sqrt(r*r+s*s),a=t.r1+3;let l,h;if(void 0===t.x2)l=o,h=t.r1-3;else{const i=e.canvasX-t.x2,n=e.canvasY-t.y2;l=Math.sqrt(i*i+n*n),h=t.r2-3}if(o<a&&l>h){i.push(n);break}}return i}popupData(e,t){if(void 0===t&&(t=this.clickedFeatures(e)),t&&t.length>0)return this.extractPopupData(t[0],this.getGenomeId())}menuItemList(){var e=this;return[{name:"Toggle arc direction",click:function(){e.arcOrientation=!e.arcOrientation,e.trackView.repaintViews()}}]}}function rf(e,t){e.sort((function(e,i){const n=void 0===e.score?-Number.MAX_VALUE:e.score,r=void 0===i.score?-Number.MAX_VALUE:i.score;return(void 0===t?1:t)*(n-r)}))}class sf{constructor(e,t){this.config=e,this.genome=t}async getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r}){const s=this.genome;if(this.featureCache)return this.featureCache.queryFeatures(e,t,i);{const n=To(this.config),r=await no.loadString(this.config.url,n);return this.featureCache=new po(function(e){if(!e)return null;const t=hh(e);let i,n=!0;const r=[],s=[],o=[];for(;void 0!==(i=t.nextLine());){const e=i.split("\t");if(n&&i.startsWith("color:")){const t="rgb("+e[1]+","+e[2]+","+e[3]+")";r.push(t),e.length>4&&s.push(e[4])}else{n=!1;const t=e[0],i=Number.parseInt(e[1])-1,l=Number.parseInt(e[2])-1,h=Number.parseInt(e[3]),c=Number.parseInt(e[4]);var a=Number.parseInt(e[5]);const d=r[a];let u;u=i<=c?{chr:t,startLeft:Math.min(i,l),startRight:Math.max(i,l),endLeft:Math.min(h,c),endRight:Math.max(h,c),color:d,score:a}:{chr:t,startLeft:Math.min(h,c),startRight:Math.max(h,c),endLeft:Math.min(i,l),endRight:Math.max(i,l),color:d,score:a},u.start=u.startLeft,u.end=u.endRight,s.length>a&&(u.description=s[a]),o.push(u)}}return o}(r),s),this.featureCache.queryFeatures(e,t,i)}}}class of{constructor(e){this.browser=e,this.type="ideogram",this.height=16,this.order=Number.MIN_SAFE_INTEGER,this.disableButtons=!0,this.ignoreTrackMenu=!0}async getFeatures(e,t,i){return[]}computePixelHeight(e){return this.height}draw({context:e,referenceFrame:t,pixelWidth:i,pixelHeight:n}){const r=t.chr,s=t.genome.getChromosome(r);if(void 0===s||i<=0||n<=0||"all"===r.toLowerCase())return;!function({ctx:e,chr:t,referenceFrame:i,genome:n,width:r,height:s,stainColors:o}){const a=1,l=.5*a,h=0;if(void 0===n)return;Co.fillRect(e,0,0,r,s,{fillStyle:Ds.greyScale(255)});const c=n.getCytobands(t);if(c){const t=h+s/2,i=[],n=[];if(0===c.length)return;const d=r/c[c.length-1].end;e.beginPath(),Co.roundRect(e,l,l+h,r-2*l,s-2*l,(s-2*l)/2,0,1),e.clip();for(let r=0;r<c.length;r++){const l=c[r],u=d*l.start,f=d*l.end;"c"===l.type?("p"===l.name.charAt(0)?(i[0]=u,n[0]=s+h,i[1]=u,n[1]=h,i[2]=f,n[2]=t):(i[0]=f,n[0]=s+h,i[1]=f,n[1]=h,i[2]=u,n[2]=t),e.fillStyle="rgb(150, 0, 0)",e.strokeStyle="rgb(150, 0, 0)",Co.polygon(e,i,n,1,0)):(e.fillStyle=af(o,l),Co.fillRect(e,u,a+h,f-u,s-2*a))}}e.strokeStyle=Ds.greyScale(41),Co.roundRect(e,l,l+h,r-2*l,s-2*l,(s-2*l)/2,0,1)}({ctx:e,chr:r,referenceFrame:t,genome:t.genome,width:i,height:n,stainColors:[]});const o=Math.round(t.bpPerPixel*i),a=t.start;let l=s.bpLength;const h=t.genome.getCytobands(r);if(h&&h.length>0&&h[h.length-1].end&&(l=Math.max(l,h[h.length-1].end),s.bpLength=l),o<l){const t=o/l,r=a/l;let s=Math.floor(r*i),h=Math.floor(t*i);s=Math.max(0,s),s=Math.min(i-h,s),e.save(),e.strokeStyle="red",e.lineWidth=h<2?1:2;const c=s+e.lineWidth/2;h=h<2?1:h-e.lineWidth;const d=e.lineWidth/2,u=n-e.lineWidth;e.strokeRect(c,d,h,u),e.restore()}}dispose(){this.trackView=void 0}}function af(e,t){if("c"===t.type)return"rgb(150, 10, 10)";var i=t.stain,n=230;"p"===t.type&&(n=Math.floor(230-i/100*230));var r=e[n];return r||(r="rgb("+n+","+n+","+n+")",e[n]=r),r}let lf=new yo("Dark2");["GT/AG","CT/AC","GC/AG","CT/GC","AT/AC","GT/AT","non-canonical"].forEach((e=>{lf.getColor(e)}));const hf={};class cf extends Ll{constructor(e,t){super(e,t)}init(e){super.init(e),this.type=e.type||"junctions",e._featureSource?(this.featureSource=e._featureSource,delete e._featureSource):this.featureSource=e.featureSource?e.featureSource:dc(e,this.browser.genome),this.margin=void 0===e.margin?10:e.margin,this.height||(this.height=100),void 0===e.colorByNumReadsThreshold&&(e.colorByNumReadsThreshold=5)}async postInit(){if("function"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),void 0===this.visibilityWindow&&"function"==typeof this.featureSource.defaultVisibilityWindow&&(this.visibilityWindow=await this.featureSource.defaultVisibilityWindow()),this}get supportsWholeGenome(){return!1}async getFeatures(e,t,i,n){const r=this.visibilityWindow;return this.featureSource.getFeatures({chr:e,start:t,end:i,bpPerPixel:n,visibilityWindow:r})}computePixelHeight(e){return this.height}draw(e){const t=e.features,i=e.context,n=e.bpPerPixel,r=e.bpStart,s=e.pixelWidth,o=e.pixelHeight,a=r+s*n+1;if(this.config.isMergedTrack||Co.fillRect(i,0,e.pixelTop,s,o,{fillStyle:"rgb(255, 255, 255)"}),t){hf.referenceFrame=e.viewport.referenceFrame,hf.referenceFrameStart=hf.referenceFrame.start,hf.referenceFrameEnd=hf.referenceFrameStart+hf.referenceFrame.toBP(e.viewport.getWidth()),hf.featureZoomOutTracker={};for(let e of t)if(!(e.end<r)){if(e.start>a)break;this.renderJunction(e,r,n,o,i)}}else console.log("No feature list")}renderJunction(e,t,i,n,r){e.isVisible=!1;const s=Math.round((e.start-t)/i),o=Math.round((e.end-t)/i),a=(s+o)/2;if(o-s<=3){if(a in hf.featureZoomOutTracker)return;hf.featureZoomOutTracker[a]=!0}if(this.config.hideAnnotatedJunctions&&"true"===e.attributes.annotated_junction)return;if(this.config.hideUnannotatedJunctions&&"false"===e.attributes.annotated_junction)return;if(this.config.hideMotifs&&this.config.hideMotifs.includes(e.attributes.motif))return;if(this.config.hideStrand===e.strand)return;if(this.config.minJunctionEndsVisible){let t=0;if(e.start>=hf.referenceFrameStart&&e.start<=hf.referenceFrameEnd&&(t+=1),e.end>=hf.referenceFrameStart&&e.end<=hf.referenceFrameEnd&&(t+=1),t<this.config.minJunctionEndsVisible)return}let l,h,c,d;if(e.attributes.uniquely_mapped){if(l=parseInt(e.attributes.uniquely_mapped),l<this.config.minUniquelyMappedReads)return;if(h=parseInt(e.attributes.multi_mapped),c=l+h,c<this.config.minTotalReads)return;if(c>0&&h/c>this.config.maxFractionMultiMappedReads)return;if(e.attributes.maximum_spliced_alignment_overhang&&parseInt(e.attributes.maximum_spliced_alignment_overhang)<this.config.minSplicedAlignmentOverhang)return}if(e.attributes.num_samples_with_this_junction){if(d=parseInt(e.attributes.num_samples_with_this_junction),this.config.minSamplesWithThisJunction&&d<this.config.minSamplesWithThisJunction)return;if(this.config.maxSamplesWithThisJunction&&d>this.config.maxSamplesWithThisJunction)return;if(e.attributes.num_samples_total&&(e.attributes.percent_samples_with_this_junction=100*d/Number(e.attributes.num_samples_total),this.config.minPercentSamplesWithThisJunction&&(e.attributes.percent_samples_with_this_junction<this.config.minPercentSamplesWithThisJunction||e.attributes.percent_samples_with_this_junction>this.config.maxPercentSamplesWithThisJunction)))return}const u=this.margin,f=this.height,p=u+.5*f;let g=u;const m=u+f-10,b=(s+a)/2,w=(a+o)/2;let v,y,_=1;e.attributes.line_width?_=Number(e.attributes.line_width):(void 0===this.config.thicknessBasedOn||"numUniqueReads"===this.config.thicknessBasedOn?_=l:"numReads"===this.config.thicknessBasedOn?_=c:"numSamplesWithThisJunction"===this.config.thicknessBasedOn&&void 0!==d&&(_=d),_=1+Math.log(_+1)/Math.log(12)),void 0===this.config.bounceHeightBasedOn||"random"===this.config.bounceHeightBasedOn?v=(e.start+e.end)%7:"distance"===this.config.bounceHeightBasedOn?v=6*(e.end-e.start)/(hf.referenceFrameEnd-hf.referenceFrameStart):"thickness"===this.config.bounceHeightBasedOn&&(v=2*_),g+=f*Math.max(7-v,0)/10,y=e.attributes.color?e.attributes.color:void 0===this.config.colorBy||"numUniqueReads"===this.config.colorBy?l>this.config.colorByNumReadsThreshold?"blue":"#AAAAAA":"numReads"===this.config.colorBy?c>this.config.colorByNumReadsThreshold?"blue":"#AAAAAA":"isAnnotatedJunction"===this.config.colorBy?"true"===e.attributes.annotated_junction?"#b0b0ec":"orange":"strand"===this.config.colorBy?"+"===e.strand?"#b0b0ec":"#ecb0b0":"motif"===this.config.colorBy?lf.getColor(e.attributes.motif):"#AAAAAA";let x="";e.attributes.label?x=e.attributes.label.replace(/_/g," "):void 0===this.config.labelWith||"uniqueReadCount"===this.config.labelWith?x=l:"totalReadCount"===this.config.labelWith?x=c:"numSamplesWithThisJunction"===this.config.labelWith?void 0!==d&&(x=d):"percentSamplesWithThisJunction"===this.config.labelWith?void 0!==e.attributes.percent_samples_with_this_junction&&(x=e.attributes.percent_samples_with_this_junction.toFixed(0)+"%"):"motif"===this.config.labelWith&&void 0!==e.attributes.motif&&(x+=e.attributes.motif),"uniqueReadCount"===this.config.labelWithInParen?x+=" ("+l+")":"totalReadCount"===this.config.labelWithInParen?x+=" ("+c+")":"multiMappedReadCount"===this.config.labelWithInParen?h>0&&(x+=" (+"+h+")"):"numSamplesWithThisJunction"===this.config.labelWithInParen?void 0!==d&&(x+=" ("+d+")"):"percentSamplesWithThisJunction"===this.config.labelWithInParen?void 0!==e.attributes.percent_samples_with_this_junction&&(x+=" ("+e.attributes.percent_samples_with_this_junction.toFixed(0)+"%)"):"motif"===this.config.labelWithInParen&&void 0!==e.attributes.motif&&(x+=` ${e.attributes.motif}`),e.isVisible=!0,r.beginPath(),r.moveTo(s,m),r.bezierCurveTo(b,g,w,g,o,m),r.lineWidth=_,r.strokeStyle=y,r.stroke();const k=(e,t,i,n)=>{e.beginPath(),e.moveTo(t,i),e.lineTo(t-n/2,i-n),e.lineTo(t+n/2,i-n),e.lineTo(t,i),e.closePath(),e.fill()};if(e.attributes.left_shape||e.attributes.right_shape){r.fillStyle=y;const t=r.lineWidth>2?10:7;e.attributes.left_shape&&k(r,s,m,t),e.attributes.right_shape&&k(r,o,m,t)}r.fillText(x,a-r.measureText(x).width/2,(7*g+p)/8)}clickedFeatures(e){return super.clickedFeatures(e).filter((function(e){return e.isVisible&&e.attributes}))}popupData(e,t){void 0===t&&(t=this.clickedFeatures(e));const i=e.genomicLocation,n=[];for(let e of t){const t="function"==typeof e.popupData?e.popupData(i):this.extractPopupData(e._f||e,this.getGenomeId());t&&(n.length>0&&n.push("<hr/><hr/>"),Array.prototype.push.apply(n,t))}return n}dispose(){this.trackView=void 0}}class df{constructor(e){var t;this.config=e,this.url=(t=e.path||e.url).includes("//www.dropbox.com")?t.replace("//www.dropbox.com","//dl.dropboxusercontent.com"):t.startsWith("ftp://ftp.ncbi.nlm.nih.gov")?t.replace("ftp://","https://"):t}async read(e,t){const i=this.config.headers||{};if(void 0!==e&&t){const n="bytes="+e+"-"+(e+t-1);i.Range=n}let n=this.url.slice();if(this.config.oauthToken){const e=async function(e){return"function"==typeof e?await Promise.resolve(e()):e}(this.config.oauthToken);i.Authorization=`Bearer ${e}`}this.config.apiKey&&(n=function(e,t,i){const n=e.includes("?")?"&":"?";return e+n+t+"="+i}(n,"key",this.config.apiKey));const r=await fetch(n,{method:"GET",headers:i,redirect:"follow",mode:"cors"}),s=r.status;if(s>=400){const e=Error(r.statusText);throw e.code=s,e}return r.arrayBuffer()}}class uf{constructor(e){this.file=e.file,this.fetchSize=e.fetchSize||16e3,this.maxSize=e.maxSize||1e6,this.buffers=[]}async read(e,t){let i=this.buffers.filter((i=>i.overlaps(e,e+t)));for(let n of i)if(n.contains(e,e+t))return n.slice(e,e+t);if(0===i.length){let i=Math.max(t,this.fetchSize);this.buffers.sort(((e,t)=>e.start-t.start));const n=function(e,t,i){let n=i-1,r=e.length;for(;1+n<r;){const i=n+(r-n>>1);t(e[i])?r=i:n=i}return r}(this.buffers,(t=>t.start>e),0);n<this.buffers.length&&(i=Math.min(i,this.buffers[n].start-e));const r=e,s=await this.file.read(r,i),o=new ff(r,s);return this.addBuffer(o),o.slice(e,e+t)}{i.sort(((e,t)=>e.start-t.start));const n=[];let r=e;for(let e of i){if(r<e.start){const t=r,i=e.start-r,s=await this.file.read(t,i),o=new ff(t,s);n.push(o)}n.push(e),r=e.end}const s=e+t;if(s>r){const e=r,t=s-e,i=await this.file.read(e,t),o=new ff(e,i);n.push(o)}const o=n[0].start,a=function(e){const t=e.reduce(((e,t)=>e+t.byteLength),0),i=new Uint8Array(t);let n=0;for(let t of e)i.set(new Uint8Array(t),n),n+=t.byteLength;return i.buffer}(n.map((e=>e.buffer))),l=new ff(o,a),h=new Set(i);return this.buffers=this.buffers.filter((e=>!h.has(e))),this.addBuffer(l),l.slice(e,e+t)}}addBuffer(e){const t=this.buffers.reduce(((e,t)=>e+t.size),0)+e.size;if(t>this.maxSize){const e=t-this.maxSize;this.buffers.sort(((e,t)=>e.creationTime-t.creationTime));let i,n=0;for(i=0;i<this.buffers.length&&(n+=this.buffers[i].size,!(n>e));i++);this.buffers=i<this.buffers.length-1?this.buffers.slice(i):[]}e.size<=this.maxSize&&this.buffers.push(e)}}class ff{constructor(e,t){this.creationTime=Date.now(),this.start=e,this.buffer=t}slice(e,t){if(e<this.start||t-e>this.buffer.byteLength)throw Error("buffer bounds error");return this.buffer.slice(e-this.start,t-this.start)}get end(){return this.start+this.buffer.byteLength}get size(){return this.buffer.byteLength}contains(e,t){return e>=this.start&&t<=this.end}overlaps(e,t){return e>this.start&&e<this.end||t>this.start&&t<this.end}toString(){return`Buffer ${this.creationTime} ${this.start} - ${this.end}`}}class pf{constructor(e){this.file=e}async read(e,t){if(0===t)return new ArrayBuffer;return(null!=e&&t?this.file.slice(e,e+t):this.file).arrayBuffer()}}async function gf(e,t,i=0){var n=new Map;for(let[r,s]of e.entries()){let e=await xf.unpack_from_async("<"+s,t,i);i+=xf.calcsize(s),1==e.length&&(e=e[0]),n.set(r,e)}return n}function mf(e,t,i=0){var n=new Map;for(let[r,s]of e.entries()){let e=xf.unpack_from("<"+s,t,i);i+=xf.calcsize(s),1==e.length&&(e=e[0]),n.set(r,e)}return n}function bf(e){e||e()}function wf(e){var t="<"+Array.from(e.values()).join("");return xf.calcsize(t)}function vf(e,t=8){return Math.ceil(e/t)*t}var yf={u:"Uint",i:"Int",f:"Float"};function _f(e){var t,i,n=xf._is_big_endian(e);if(/S/.test(e))t="getString",i=0|((e.match(/S(\d*)/)||[])[1]||1);else{let[n,r,s]=e.match(/[<>=!@]?(i|u|f)(\d*)/);i=parseInt(s||4,10),t="get"+yf[r]+(8*i).toFixed()}return[t,n,i]}var xf=new class{constructor(){this.big_endian=function(){const e=new Uint8Array(4);return!((new Uint32Array(e.buffer)[0]=1)&e[0])}(),this.getters={s:"getUint8",b:"getInt8",B:"getUint8",h:"getInt16",H:"getUint16",i:"getInt32",I:"getUint32",l:"getInt32",L:"getUint32",q:"getInt64",Q:"getUint64",f:"getFloat32",d:"getFloat64"},this.byte_lengths={s:1,b:1,B:1,h:2,H:2,i:4,I:4,l:4,L:4,q:8,Q:8,f:4,d:8};let e=Object.keys(this.byte_lengths).join("");this.fmt_size_regex="(\\d*)(["+e+"])"}calcsize(e){for(var t,i=0,n=new RegExp(this.fmt_size_regex,"g");null!==(t=n.exec(e));){let e=parseInt(t[1]||1,10),n=t[2];i+=e*this.byte_lengths[n]}return i}_is_big_endian(e){return!/^</.test(e)&&(!!/^(!|>)/.test(e)||this.big_endian)}async unpack_from_async(e,t,i){i=Number(i||0);const n=this.calcsize(e),r=await t.slice(i,i+n);let s=0;for(var o,a=new kf(r),l=[],h=this._is_big_endian(e),c=new RegExp(this.fmt_size_regex,"g");null!==(o=c.exec(e));){let e=parseInt(o[1]||1,10),t=o[2],i=this.getters[t],n=this.byte_lengths[t];if("s"==t)l.push((new TextDecoder).decode(r.slice(s,s+e))),s+=e;else for(var d=0;d<e;d++)l.push(a[i](s,!h)),s+=n}return l}unpack_from(e,t,i){i=Number(i||0);const n=this.calcsize(e),r=t.slice(i,i+n);let s=0;for(var o,a=new kf(r),l=[],h=this._is_big_endian(e),c=new RegExp(this.fmt_size_regex,"g");null!==(o=c.exec(e));){let e=parseInt(o[1]||1,10),t=o[2],i=this.getters[t],n=this.byte_lengths[t];if("s"==t)l.push((new TextDecoder).decode(r.slice(s,s+e))),s+=e;else for(var d=0;d<e;d++)l.push(a[i](s,!h)),s+=n}return l}};var kf=class extends DataView{getUint64(e,t){const i=BigInt(this.getUint32(e,t)),n=BigInt(this.getUint32(e+4,t));return Number(t?i+(n<<32n):(i<<32n)+n)}getInt64(e,t){var i,n;t?(i=this.getUint32(e,!0),n=this.getInt32(e+4,!0)):(n=this.getInt32(e,!1),i=this.getUint32(e+4,!1));let r=BigInt(i)+(BigInt(n)<<32n);return Number(r)}getString(e,t,i){const n=this.buffer.slice(e,e+i);return(new TextDecoder).decode(n)}getVLENStruct(e,t,i){return[this.getUint32(e,t),this.getUint64(e+4,t),this.getUint32(e+12,t)]}};function Cf(e){return e.toString(2).length}function Sf(e,t,i=0,n=!0){const r=t.slice(i,i+e);let s=new Uint8Array(r);n||s.reverse();let o=s.reduce(((e,t,i)=>e+(t<<8*i)),0);return o}var Af=class{constructor(e,t){this.buf=e,this.offset=t,this.dtype=this.determine_dtype()}async determine_dtype(){let e=await gf(Ef,this.buf,this.offset);this.offset+=Mf;let t=15&e.get("class_and_version");if(t==Tf)return this._determine_dtype_fixed_point(e);if(t==Rf)return this._determine_dtype_floating_point(e);if(t==Lf)throw"Time datatype class not supported.";if(t==If)return this._determine_dtype_string(e);if(t==Bf)throw"Bitfield datatype class not supported.";if(t==Ff)return{datatype_class:Ff,size:e.get("size")};if(t==Nf)return this._determine_dtype_compound(e);if(t==Of)return["REFERENCE",e.get("size")];if(t==Pf)return this.determine_dtype();if(t==zf)throw"Array datatype class not supported.";if(t==Df){let t=this._determine_dtype_vlen(e);if("VLEN_SEQUENCE"==t[0]){t=["VLEN_SEQUENCE",this.determine_dtype()]}return t}throw"Invalid datatype class "+t}_determine_dtype_fixed_point(e){let t=e.get("size");if(![1,2,4,8].includes(t))throw"Unsupported datatype size";var i;var n;return i=(8&e.get("class_bit_field_0"))>0?"i":"u",n=0==(1&e.get("class_bit_field_0"))?"<":">",this.offset+=4,n+i+t.toFixed()}_determine_dtype_floating_point(e){let t=e.get("size");if(![1,2,4,8].includes(t))throw"Unsupported datatype size";var i;return i=0==(1&e.get("class_bit_field_0"))?"<":">",this.offset+=12,i+"f"+t.toFixed()}_determine_dtype_string(e){return"S"+e.get("size").toFixed()}_determine_dtype_vlen(e){return 1!=(1&e.get("class_bit_field_0"))?["VLEN_SEQUENCE",0,0]:["VLEN_STRING",e.get("class_bit_field_0")>>4,1&e.get("class_bit_field_1")]}_determine_dtype_compound(e){throw"Compound type not yet implemented!"}},Ef=new Map([["class_and_version","B"],["class_bit_field_0","B"],["class_bit_field_1","B"],["class_bit_field_2","B"],["size","I"]]),Mf=wf(Ef);wf(new Map([["offset","I"],["dimensionality","B"],["reserved_0","B"],["reserved_1","B"],["reserved_2","B"],["permutation","I"],["reserved_3","I"],["dim_size_1","I"],["dim_size_2","I"],["dim_size_3","I"],["dim_size_4","I"]]));var Tf=0,Rf=1,Lf=2,If=3,Bf=4,Ff=5,Nf=6,Of=7,Pf=8,Df=9,zf=10;function Hf(e){let t=e.length;for(;--t>=0;)e[t]=0}Hf(new Array(576)),Hf(new Array(60)),Hf(new Array(512)),Hf(new Array(256)),Hf(new Array(29)),Hf(new Array(30));var Vf=(e,t,i,n)=>{let r=65535&e|0,s=e>>>16&65535|0,o=0;for(;0!==i;){o=i>2e3?2e3:i,i-=o;do{r=r+t[n++]|0,s=s+r|0}while(--o);r%=65521,s%=65521}return r|s<<16|0},Uf=new Uint32Array((()=>{let e,t=[];for(var i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t})()),qf=(e,t,i,n)=>{const r=Uf,s=n+i;e^=-1;for(let i=n;i<s;i++)e=e>>>8^r[255&(e^t[i])];return-1^e},jf={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},$f={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},Wf=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Gf={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const i=t.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const t in i)Wf(i,t)&&(e[t]=i[t])}}return e},flattenChunks:e=>{let t=0;for(let i=0,n=e.length;i<n;i++)t+=e[i].length;const i=new Uint8Array(t);for(let t=0,n=0,r=e.length;t<r;t++){let r=e[t];i.set(r,n),n+=r.length}return i}},Zf=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(ew){Zf=!1}var Qf=new Uint8Array(256);for(let tw=0;tw<256;tw++)Qf[tw]=tw>=252?6:tw>=248?5:tw>=240?4:tw>=224?3:tw>=192?2:1;Qf[254]=Qf[254]=1;var Xf={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,i,n,r,s,o=e.length,a=0;for(r=0;r<o;r++)i=e.charCodeAt(r),55296==(64512&i)&&r+1<o&&(n=e.charCodeAt(r+1),56320==(64512&n)&&(i=65536+(i-55296<<10)+(n-56320),r++)),a+=i<128?1:i<2048?2:i<65536?3:4;for(t=new Uint8Array(a),s=0,r=0;s<a;r++)i=e.charCodeAt(r),55296==(64512&i)&&r+1<o&&(n=e.charCodeAt(r+1),56320==(64512&n)&&(i=65536+(i-55296<<10)+(n-56320),r++)),i<128?t[s++]=i:i<2048?(t[s++]=192|i>>>6,t[s++]=128|63&i):i<65536?(t[s++]=224|i>>>12,t[s++]=128|i>>>6&63,t[s++]=128|63&i):(t[s++]=240|i>>>18,t[s++]=128|i>>>12&63,t[s++]=128|i>>>6&63,t[s++]=128|63&i);return t},buf2string:(e,t)=>{const i=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let n,r;const s=new Array(2*i);for(r=0,n=0;n<i;){let t=e[n++];if(t<128){s[r++]=t;continue}let o=Qf[t];if(o>4)s[r++]=65533,n+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&n<i;)t=t<<6|63&e[n++],o--;o>1?s[r++]=65533:t<65536?s[r++]=t:(t-=65536,s[r++]=55296|t>>10&1023,s[r++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Zf)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let i="";for(let n=0;n<t;n++)i+=String.fromCharCode(e[n]);return i})(s,r)},utf8border:(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let i=t-1;for(;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+Qf[e[i]]>t?i:t}};var Yf=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},Kf=function(e,t){let i,n,r,s,o,a,l,h,c,d,u,f,p,g,m,b,w,v,y,_,x,k,C,S;const A=e.state;i=e.next_in,C=e.input,n=i+(e.avail_in-5),r=e.next_out,S=e.output,s=r-(t-e.avail_out),o=r+(e.avail_out-257),a=A.dmax,l=A.wsize,h=A.whave,c=A.wnext,d=A.window,u=A.hold,f=A.bits,p=A.lencode,g=A.distcode,m=(1<<A.lenbits)-1,b=(1<<A.distbits)-1;e:do{f<15&&(u+=C[i++]<<f,f+=8,u+=C[i++]<<f,f+=8),w=p[u&m];t:for(;;){if(v=w>>>24,u>>>=v,f-=v,v=w>>>16&255,0===v)S[r++]=65535&w;else{if(!(16&v)){if(0==(64&v)){w=p[(65535&w)+(u&(1<<v)-1)];continue t}if(32&v){A.mode=12;break e}e.msg="invalid literal/length code",A.mode=30;break e}y=65535&w,v&=15,v&&(f<v&&(u+=C[i++]<<f,f+=8),y+=u&(1<<v)-1,u>>>=v,f-=v),f<15&&(u+=C[i++]<<f,f+=8,u+=C[i++]<<f,f+=8),w=g[u&b];i:for(;;){if(v=w>>>24,u>>>=v,f-=v,v=w>>>16&255,!(16&v)){if(0==(64&v)){w=g[(65535&w)+(u&(1<<v)-1)];continue i}e.msg="invalid distance code",A.mode=30;break e}if(_=65535&w,v&=15,f<v&&(u+=C[i++]<<f,f+=8,f<v&&(u+=C[i++]<<f,f+=8)),_+=u&(1<<v)-1,_>a){e.msg="invalid distance too far back",A.mode=30;break e}if(u>>>=v,f-=v,v=r-s,_>v){if(v=_-v,v>h&&A.sane){e.msg="invalid distance too far back",A.mode=30;break e}if(x=0,k=d,0===c){if(x+=l-v,v<y){y-=v;do{S[r++]=d[x++]}while(--v);x=r-_,k=S}}else if(c<v){if(x+=l+c-v,v-=c,v<y){y-=v;do{S[r++]=d[x++]}while(--v);if(x=0,c<y){v=c,y-=v;do{S[r++]=d[x++]}while(--v);x=r-_,k=S}}}else if(x+=c-v,v<y){y-=v;do{S[r++]=d[x++]}while(--v);x=r-_,k=S}for(;y>2;)S[r++]=k[x++],S[r++]=k[x++],S[r++]=k[x++],y-=3;y&&(S[r++]=k[x++],y>1&&(S[r++]=k[x++]))}else{x=r-_;do{S[r++]=S[x++],S[r++]=S[x++],S[r++]=S[x++],y-=3}while(y>2);y&&(S[r++]=S[x++],y>1&&(S[r++]=S[x++]))}break}}break}}while(i<n&&r<o);y=f>>3,i-=y,f-=y<<3,u&=(1<<f)-1,e.next_in=i,e.next_out=r,e.avail_in=i<n?n-i+5:5-(i-n),e.avail_out=r<o?o-r+257:257-(r-o),A.hold=u,A.bits=f},Jf=15,ep=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),tp=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),ip=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),np=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),rp=(e,t,i,n,r,s,o,a)=>{const l=a.bits;let h,c,d,u,f,p,g=0,m=0,b=0,w=0,v=0,y=0,_=0,x=0,k=0,C=0,S=null,A=0;const E=new Uint16Array(16),M=new Uint16Array(16);let T,R,L,I=null,B=0;for(g=0;g<=Jf;g++)E[g]=0;for(m=0;m<n;m++)E[t[i+m]]++;for(v=l,w=Jf;w>=1&&0===E[w];w--);if(v>w&&(v=w),0===w)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(b=1;b<w&&0===E[b];b++);for(v<b&&(v=b),x=1,g=1;g<=Jf;g++)if(x<<=1,x-=E[g],x<0)return-1;if(x>0&&(0===e||1!==w))return-1;for(M[1]=0,g=1;g<Jf;g++)M[g+1]=M[g]+E[g];for(m=0;m<n;m++)0!==t[i+m]&&(o[M[t[i+m]]++]=m);if(0===e?(S=I=o,p=19):1===e?(S=ep,A-=257,I=tp,B-=257,p=256):(S=ip,I=np,p=-1),C=0,m=0,g=b,f=s,y=v,_=0,d=-1,k=1<<v,u=k-1,1===e&&k>852||2===e&&k>592)return 1;for(;;){T=g-_,o[m]<p?(R=0,L=o[m]):o[m]>p?(R=I[B+o[m]],L=S[A+o[m]]):(R=96,L=0),h=1<<g-_,c=1<<y,b=c;do{c-=h,r[f+(C>>_)+c]=T<<24|R<<16|L|0}while(0!==c);for(h=1<<g-1;C&h;)h>>=1;if(0!==h?(C&=h-1,C+=h):C=0,m++,0==--E[g]){if(g===w)break;g=t[i+o[m]]}if(g>v&&(C&u)!==d){for(0===_&&(_=v),f+=b,y=g-_,x=1<<y;y+_<w&&(x-=E[y+_],!(x<=0));)y++,x<<=1;if(k+=1<<y,1===e&&k>852||2===e&&k>592)return 1;d=C&u,r[d]=v<<24|y<<16|f-s|0}}return 0!==C&&(r[f+C]=g-_<<24|64<<16|0),a.bits=v,0},{Z_FINISH:sp,Z_BLOCK:op,Z_TREES:ap,Z_OK:lp,Z_STREAM_END:hp,Z_NEED_DICT:cp,Z_STREAM_ERROR:dp,Z_DATA_ERROR:up,Z_MEM_ERROR:fp,Z_BUF_ERROR:pp,Z_DEFLATED:gp}=$f,mp=12,bp=30,wp=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function vp(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var yp,_p,xp=e=>{if(!e||!e.state)return dp;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,lp},kp=e=>{if(!e||!e.state)return dp;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,xp(e)},Cp=(e,t)=>{let i;if(!e||!e.state)return dp;const n=e.state;return t<0?(i=0,t=-t):(i=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?dp:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=i,n.wbits=t,kp(e))},Sp=(e,t)=>{if(!e)return dp;const i=new vp;e.state=i,i.window=null;const n=Cp(e,t);return n!==lp&&(e.state=null),n},Ap=!0,Ep=e=>{if(Ap){yp=new Int32Array(512),_p=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(rp(1,e.lens,0,288,yp,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;rp(2,e.lens,0,32,_p,0,e.work,{bits:5}),Ap=!1}e.lencode=yp,e.lenbits=9,e.distcode=_p,e.distbits=5},Mp=(e,t,i,n)=>{let r;const s=e.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),n>=s.wsize?(s.window.set(t.subarray(i-s.wsize,i),0),s.wnext=0,s.whave=s.wsize):(r=s.wsize-s.wnext,r>n&&(r=n),s.window.set(t.subarray(i-n,i-n+r),s.wnext),(n-=r)?(s.window.set(t.subarray(i-n,i),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=r))),0},Tp=(e,t)=>{let i,n,r,s,o,a,l,h,c,d,u,f,p,g,m,b,w,v,y,_,x,k,C=0;const S=new Uint8Array(4);let A,E;const M=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return dp;i=e.state,i.mode===mp&&(i.mode=13),o=e.next_out,r=e.output,l=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,h=i.hold,c=i.bits,d=a,u=l,k=lp;e:for(;;)switch(i.mode){case 1:if(0===i.wrap){i.mode=13;break}for(;c<16;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}if(2&i.wrap&&35615===h){i.check=0,S[0]=255&h,S[1]=h>>>8&255,i.check=qf(i.check,S,2,0),h=0,c=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&h)<<8)+(h>>8))%31){e.msg="incorrect header check",i.mode=bp;break}if((15&h)!==gp){e.msg="unknown compression method",i.mode=bp;break}if(h>>>=4,c-=4,x=8+(15&h),0===i.wbits)i.wbits=x;else if(x>i.wbits){e.msg="invalid window size",i.mode=bp;break}i.dmax=1<<i.wbits,e.adler=i.check=1,i.mode=512&h?10:mp,h=0,c=0;break;case 2:for(;c<16;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}if(i.flags=h,(255&i.flags)!==gp){e.msg="unknown compression method",i.mode=bp;break}if(57344&i.flags){e.msg="unknown header flags set",i.mode=bp;break}i.head&&(i.head.text=h>>8&1),512&i.flags&&(S[0]=255&h,S[1]=h>>>8&255,i.check=qf(i.check,S,2,0)),h=0,c=0,i.mode=3;case 3:for(;c<32;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}i.head&&(i.head.time=h),512&i.flags&&(S[0]=255&h,S[1]=h>>>8&255,S[2]=h>>>16&255,S[3]=h>>>24&255,i.check=qf(i.check,S,4,0)),h=0,c=0,i.mode=4;case 4:for(;c<16;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}i.head&&(i.head.xflags=255&h,i.head.os=h>>8),512&i.flags&&(S[0]=255&h,S[1]=h>>>8&255,i.check=qf(i.check,S,2,0)),h=0,c=0,i.mode=5;case 5:if(1024&i.flags){for(;c<16;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}i.length=h,i.head&&(i.head.extra_len=h),512&i.flags&&(S[0]=255&h,S[1]=h>>>8&255,i.check=qf(i.check,S,2,0)),h=0,c=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&(f=i.length,f>a&&(f=a),f&&(i.head&&(x=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(n.subarray(s,s+f),x)),512&i.flags&&(i.check=qf(i.check,n,f,s)),a-=f,s+=f,i.length-=f),i.length))break e;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===a)break e;f=0;do{x=n[s+f++],i.head&&x&&i.length<65536&&(i.head.name+=String.fromCharCode(x))}while(x&&f<a);if(512&i.flags&&(i.check=qf(i.check,n,f,s)),a-=f,s+=f,x)break e}else i.head&&(i.head.name=null);i.length=0,i.mode=8;case 8:if(4096&i.flags){if(0===a)break e;f=0;do{x=n[s+f++],i.head&&x&&i.length<65536&&(i.head.comment+=String.fromCharCode(x))}while(x&&f<a);if(512&i.flags&&(i.check=qf(i.check,n,f,s)),a-=f,s+=f,x)break e}else i.head&&(i.head.comment=null);i.mode=9;case 9:if(512&i.flags){for(;c<16;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}if(h!==(65535&i.check)){e.msg="header crc mismatch",i.mode=bp;break}h=0,c=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=mp;break;case 10:for(;c<32;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}e.adler=i.check=wp(h),h=0,c=0,i.mode=11;case 11:if(0===i.havedict)return e.next_out=o,e.avail_out=l,e.next_in=s,e.avail_in=a,i.hold=h,i.bits=c,cp;e.adler=i.check=1,i.mode=mp;case mp:if(t===op||t===ap)break e;case 13:if(i.last){h>>>=7&c,c-=7&c,i.mode=27;break}for(;c<3;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}switch(i.last=1&h,h>>>=1,c-=1,3&h){case 0:i.mode=14;break;case 1:if(Ep(i),i.mode=20,t===ap){h>>>=2,c-=2;break e}break;case 2:i.mode=17;break;case 3:e.msg="invalid block type",i.mode=bp}h>>>=2,c-=2;break;case 14:for(h>>>=7&c,c-=7&c;c<32;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}if((65535&h)!=(h>>>16^65535)){e.msg="invalid stored block lengths",i.mode=bp;break}if(i.length=65535&h,h=0,c=0,i.mode=15,t===ap)break e;case 15:i.mode=16;case 16:if(f=i.length,f){if(f>a&&(f=a),f>l&&(f=l),0===f)break e;r.set(n.subarray(s,s+f),o),a-=f,s+=f,l-=f,o+=f,i.length-=f;break}i.mode=mp;break;case 17:for(;c<14;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}if(i.nlen=257+(31&h),h>>>=5,c-=5,i.ndist=1+(31&h),h>>>=5,c-=5,i.ncode=4+(15&h),h>>>=4,c-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=bp;break}i.have=0,i.mode=18;case 18:for(;i.have<i.ncode;){for(;c<3;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}i.lens[M[i.have++]]=7&h,h>>>=3,c-=3}for(;i.have<19;)i.lens[M[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,A={bits:i.lenbits},k=rp(0,i.lens,0,19,i.lencode,0,i.work,A),i.lenbits=A.bits,k){e.msg="invalid code lengths set",i.mode=bp;break}i.have=0,i.mode=19;case 19:for(;i.have<i.nlen+i.ndist;){for(;C=i.lencode[h&(1<<i.lenbits)-1],m=C>>>24,b=C>>>16&255,w=65535&C,!(m<=c);){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}if(w<16)h>>>=m,c-=m,i.lens[i.have++]=w;else{if(16===w){for(E=m+2;c<E;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}if(h>>>=m,c-=m,0===i.have){e.msg="invalid bit length repeat",i.mode=bp;break}x=i.lens[i.have-1],f=3+(3&h),h>>>=2,c-=2}else if(17===w){for(E=m+3;c<E;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}h>>>=m,c-=m,x=0,f=3+(7&h),h>>>=3,c-=3}else{for(E=m+7;c<E;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}h>>>=m,c-=m,x=0,f=11+(127&h),h>>>=7,c-=7}if(i.have+f>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=bp;break}for(;f--;)i.lens[i.have++]=x}}if(i.mode===bp)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=bp;break}if(i.lenbits=9,A={bits:i.lenbits},k=rp(1,i.lens,0,i.nlen,i.lencode,0,i.work,A),i.lenbits=A.bits,k){e.msg="invalid literal/lengths set",i.mode=bp;break}if(i.distbits=6,i.distcode=i.distdyn,A={bits:i.distbits},k=rp(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,A),i.distbits=A.bits,k){e.msg="invalid distances set",i.mode=bp;break}if(i.mode=20,t===ap)break e;case 20:i.mode=21;case 21:if(a>=6&&l>=258){e.next_out=o,e.avail_out=l,e.next_in=s,e.avail_in=a,i.hold=h,i.bits=c,Kf(e,u),o=e.next_out,r=e.output,l=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,h=i.hold,c=i.bits,i.mode===mp&&(i.back=-1);break}for(i.back=0;C=i.lencode[h&(1<<i.lenbits)-1],m=C>>>24,b=C>>>16&255,w=65535&C,!(m<=c);){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}if(b&&0==(240&b)){for(v=m,y=b,_=w;C=i.lencode[_+((h&(1<<v+y)-1)>>v)],m=C>>>24,b=C>>>16&255,w=65535&C,!(v+m<=c);){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}h>>>=v,c-=v,i.back+=v}if(h>>>=m,c-=m,i.back+=m,i.length=w,0===b){i.mode=26;break}if(32&b){i.back=-1,i.mode=mp;break}if(64&b){e.msg="invalid literal/length code",i.mode=bp;break}i.extra=15&b,i.mode=22;case 22:if(i.extra){for(E=i.extra;c<E;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}i.length+=h&(1<<i.extra)-1,h>>>=i.extra,c-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;C=i.distcode[h&(1<<i.distbits)-1],m=C>>>24,b=C>>>16&255,w=65535&C,!(m<=c);){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}if(0==(240&b)){for(v=m,y=b,_=w;C=i.distcode[_+((h&(1<<v+y)-1)>>v)],m=C>>>24,b=C>>>16&255,w=65535&C,!(v+m<=c);){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}h>>>=v,c-=v,i.back+=v}if(h>>>=m,c-=m,i.back+=m,64&b){e.msg="invalid distance code",i.mode=bp;break}i.offset=w,i.extra=15&b,i.mode=24;case 24:if(i.extra){for(E=i.extra;c<E;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}i.offset+=h&(1<<i.extra)-1,h>>>=i.extra,c-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=bp;break}i.mode=25;case 25:if(0===l)break e;if(f=u-l,i.offset>f){if(f=i.offset-f,f>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=bp;break}f>i.wnext?(f-=i.wnext,p=i.wsize-f):p=i.wnext-f,f>i.length&&(f=i.length),g=i.window}else g=r,p=o-i.offset,f=i.length;f>l&&(f=l),l-=f,i.length-=f;do{r[o++]=g[p++]}while(--f);0===i.length&&(i.mode=21);break;case 26:if(0===l)break e;r[o++]=i.length,l--,i.mode=21;break;case 27:if(i.wrap){for(;c<32;){if(0===a)break e;a--,h|=n[s++]<<c,c+=8}if(u-=l,e.total_out+=u,i.total+=u,u&&(e.adler=i.check=i.flags?qf(i.check,r,u,o-u):Vf(i.check,r,u,o-u)),u=l,(i.flags?h:wp(h))!==i.check){e.msg="incorrect data check",i.mode=bp;break}h=0,c=0}i.mode=28;case 28:if(i.wrap&&i.flags){for(;c<32;){if(0===a)break e;a--,h+=n[s++]<<c,c+=8}if(h!==(4294967295&i.total)){e.msg="incorrect length check",i.mode=bp;break}h=0,c=0}i.mode=29;case 29:k=hp;break e;case bp:k=up;break e;case 31:return fp;default:return dp}return e.next_out=o,e.avail_out=l,e.next_in=s,e.avail_in=a,i.hold=h,i.bits=c,(i.wsize||u!==e.avail_out&&i.mode<bp&&(i.mode<27||t!==sp))&&Mp(e,e.output,e.next_out,u-e.avail_out),d-=e.avail_in,u-=e.avail_out,e.total_in+=d,e.total_out+=u,i.total+=u,i.wrap&&u&&(e.adler=i.check=i.flags?qf(i.check,r,u,e.next_out-u):Vf(i.check,r,u,e.next_out-u)),e.data_type=i.bits+(i.last?64:0)+(i.mode===mp?128:0)+(20===i.mode||15===i.mode?256:0),(0===d&&0===u||t===sp)&&k===lp&&(k=pp),k},Rp={inflateReset:kp,inflateReset2:Cp,inflateResetKeep:xp,inflateInit:e=>Sp(e,15),inflateInit2:Sp,inflate:Tp,inflateEnd:e=>{if(!e||!e.state)return dp;let t=e.state;return t.window&&(t.window=null),e.state=null,lp},inflateGetHeader:(e,t)=>{if(!e||!e.state)return dp;const i=e.state;return 0==(2&i.wrap)?dp:(i.head=t,t.done=!1,lp)},inflateSetDictionary:(e,t)=>{const i=t.length;let n,r,s;return e&&e.state?(n=e.state,0!==n.wrap&&11!==n.mode?dp:11===n.mode&&(r=1,r=Vf(r,t,i,0),r!==n.check)?up:(s=Mp(e,t,i,i),s?(n.mode=31,fp):(n.havedict=1,lp))):dp},inflateInfo:"pako inflate (from Nodeca project)"};var Lp=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1},Ip=Object.prototype.toString,{Z_NO_FLUSH:Bp,Z_FINISH:Fp,Z_OK:Np,Z_STREAM_END:Op,Z_NEED_DICT:Pp,Z_STREAM_ERROR:Dp,Z_DATA_ERROR:zp,Z_MEM_ERROR:Hp}=$f;function Vp(e){this.options=Gf.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Yf,this.strm.avail_out=0;let i=Rp.inflateInit2(this.strm,t.windowBits);if(i!==Np)throw new Error(jf[i]);if(this.header=new Lp,Rp.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Xf.string2buf(t.dictionary):"[object ArrayBuffer]"===Ip.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=Rp.inflateSetDictionary(this.strm,t.dictionary),i!==Np)))throw new Error(jf[i])}function Up(e,t){const i=new Vp(t);if(i.push(e),i.err)throw i.msg||jf[i.err];return i.result}Vp.prototype.push=function(e,t){const i=this.strm,n=this.options.chunkSize,r=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=t===~~t?t:!0===t?Fp:Bp,"[object ArrayBuffer]"===Ip.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),s=Rp.inflate(i,o),s===Pp&&r&&(s=Rp.inflateSetDictionary(i,r),s===Np?s=Rp.inflate(i,o):s===zp&&(s=Pp));i.avail_in>0&&s===Op&&i.state.wrap>0&&0!==e[i.next_in];)Rp.inflateReset(i),s=Rp.inflate(i,o);switch(s){case Dp:case zp:case Pp:case Hp:return this.onEnd(s),this.ended=!0,!1}if(a=i.avail_out,i.next_out&&(0===i.avail_out||s===Op))if("string"===this.options.to){let e=Xf.utf8border(i.output,i.next_out),t=i.next_out-e,r=Xf.buf2string(i.output,e);i.next_out=t,i.avail_out=n-t,t&&i.output.set(i.output.subarray(e,e+t),0),this.onData(r)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(s!==Np||0!==a){if(s===Op)return s=Rp.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},Vp.prototype.onData=function(e){this.chunks.push(e)},Vp.prototype.onEnd=function(e){e===Np&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Gf.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var qp=function(e,t){return(t=t||{}).raw=!0,Up(e,t)},jp={Inflate:Vp,inflate:Up,inflateRaw:qp,ungzip:Up,constants:$f},{Inflate:$p,inflate:Wp,inflateRaw:Gp,ungzip:Zp}=jp,Qp=Wp,Xp=Zp;var Yp=new Map([[1,function(e,t){let i=new Uint8Array(e);return Qp(i).buffer}],[2,function(e,t){let i=e.byteLength,n=new Uint8Array(i),r=Math.floor(i/t),s=new DataView(e);for(var o=0;o<t;o++)for(var a=0;a<r;a++)n[o+a*t]=s.getUint8(o*r+a);return n.buffer}],[3,function(e,t){return function(e){for(var t=e.byteLength%2!=0,i=e.byteLength-4,n=new DataView(e),r=0,s=0,o=0;o<i-1;o+=2){s=(s+(r=(r+n.getUint16(o,!0))%65535))%65535}if(t){s=(s+(r=(r+n.getUint8(i-1))%65535))%65535}var[a,l]=xf.unpack_from(">HH",e,i);if(l%=65535,r!=(a%=65535)||s!=l)throw'ValueError("fletcher32 checksum invalid")'}(e),e.slice(0,-4)}]]),Kp=class{constructor(e,t){this.fh=e,this.offset=t,this.depth=null}async init(){this.all_nodes=new Map,await this._read_root_node(),await this._read_children()}async _read_children(){let e=this.depth;for(;e>0;){for(var t of this.all_nodes.get(e))for(var i of t.get("addresses"))this._add_node(await this._read_node(i,e-1));e--}}async _read_root_node(){let e=await this._read_node(this.offset,null);this._add_node(e),this.depth=e.get("node_level")}_add_node(e){let t=e.get("node_level");this.all_nodes.has(t)?this.all_nodes.get(t).push(e):this.all_nodes.set(t,[e])}async _read_node(e,t){let i=await this._read_node_header(e,t);return i.set("keys",[]),i.set("addresses",[]),i}async _read_node_header(e){throw"NotImplementedError: must define _read_node_header in implementation class"}},Jp=class extends Kp{B_LINK_NODE=new Map([["signature","4s"],["node_type","B"],["node_level","B"],["entries_used","H"],["left_sibling","Q"],["right_sibling","Q"]]);async _read_node_header(e,t){let i=await gf(this.B_LINK_NODE,this.fh,e);if(null!=t&&i.get("node_level")!=t)throw"node level does not match";return i}},eg=class extends Jp{NODE_TYPE=0;constructor(e,t){super(e,t),this.ready=this.init()}async _read_node(e,t){let i=await this._read_node_header(e,t);e+=wf(this.B_LINK_NODE);let n=[],r=[],s=i.get("entries_used");for(var o=0;o<s;o++){let t=(await xf.unpack_from_async("<Q",this.fh,e))[0];e+=8;let i=(await xf.unpack_from_async("<Q",this.fh,e))[0];e+=8,n.push(t),r.push(i)}return n.push((await xf.unpack_from_async("<Q",this.fh,e))[0]),i.set("keys",n),i.set("addresses",r),i}symbol_table_addresses(){var e=[],t=this.all_nodes.get(0);for(var i of t)e=e.concat(i.get("addresses"));return e}},tg=class extends Jp{NODE_TYPE=1;constructor(e,t,i){super(e,t),this.dims=i,this.ready=this.init()}async _read_node(e,t){let i=await this._read_node_header(e,t);e+=wf(this.B_LINK_NODE);var n=[],r=[];let s=i.get("entries_used");for(var o=0;o<s;o++){let[t,i]=await xf.unpack_from_async("<II",this.fh,e);e+=8;let s="<"+this.dims.toFixed()+"Q",o=xf.calcsize(s),a=await xf.unpack_from_async(s,this.fh,e);e+=o;let l=(await xf.unpack_from_async("<Q",this.fh,e))[0];e+=8,n.push(new Map([["chunk_size",t],["filter_mask",i],["chunk_offset",a]])),r.push(l)}return i.set("keys",n),i.set("addresses",r),i}async construct_data_from_chunks(e,t,i,n){var r,s,o;if(i instanceof Array){let e=i[0];if("REFERENCE"==e){if(8!=i[1])throw"NotImplementedError('Unsupported Reference type')";i="<u8";r="getUint64",s=!1,o=8}else{if("VLEN_STRING"!=e&&"VLEN_SEQUENCE"!=e)throw"NotImplementedError('datatype not implemented')";r="getVLENStruct",s=!1,o=16}}else[r,s,o]=_f(i);var a=t.reduce((function(e,t){return e*t}),1),l=e.reduce((function(e,t){return e*t}),1);let h=t.length;var c=1;e.slice().map((function(e){let t=c;return c*=e,t}));c=1;var d=t.slice().reverse().map((function(e){let t=c;return c*=e,t})).reverse(),u=new Array(a);let f=l*o;for(var p of this.all_nodes.get(0)){let i=p.get("keys"),a=p.get("addresses"),c=i.length;for(var g=0;g<c;g++){let c=i[g],p=a[g];var m;if(null==n)m=await this.fh.slice(p,p+f);else{m=await this.fh.slice(p,p+c.get("chunk_size"));let e=c.get("filter_mask");m=this._filter_chunk(m,e,n,o)}for(var b=c.get("chunk_offset").slice(),w=b.slice(),v=w.map((function(){return 0})),y=new kf(m),_=0;_<l;_++){for(var x=h-1;x>=0&&v[x]>=e[x];x--)v[x]=0,w[x]=b[x],x>0&&(v[x-1]+=1,w[x-1]+=1);if(w.slice(0,-1).every((function(e,i){return e<t[i]}))){let e=_*o,t=y[r](e,!s,o),i=w.slice(0,-1).reduce((function(e,t,i){return t*d[i]+e}),0);u[i]=t}v[h-1]+=1,w[h-1]+=1}}}return u}_filter_chunk(e,t,i,n){let r=i.length,s=e.slice();for(var o=r-1;o>=0;o--){if(t&1<<o)continue;let e=i[o],r=e.get("filter_id"),a=e.get("client_data");if(!Yp.has(r))throw'NotImplementedError("Filter with id:'+r.toFixed()+' not supported")';s=Yp.get(r)(s,n,a)}return s}},ig=class extends Kp{B_TREE_HEADER=new Map([["signature","4s"],["version","B"],["node_type","B"],["node_size","I"],["record_size","H"],["depth","H"],["split_percent","B"],["merge_percent","B"],["root_address","Q"],["root_nrecords","H"],["total_nrecords","Q"]]);B_LINK_NODE=new Map([["signature","4s"],["version","B"],["node_type","B"]]);constructor(e,t){super(e,t),this.ready=this.init()}async _read_root_node(){let e=await this._read_tree_header(this.offset);this.address_formats=this._calculate_address_formats(e),this.header=e,this.depth=e.get("depth");let t=[e.get("root_address"),e.get("root_nrecords"),e.get("total_nrecords")],i=await this._read_node(t,this.depth);this._add_node(i)}async _read_tree_header(e){return await gf(this.B_TREE_HEADER,this.fh,this.offset)}_calculate_address_formats(e){let t=e.get("node_size"),i=e.get("record_size"),n=0,r=0,s=new Map,o=e.get("depth");for(var a=0;a<=o;a++){let e,l,h,c="",d="",u="";if(0==a?(e=0,l=0,h=0):1==a?(e=8,c="<Q",l=this._required_bytes(n),d=this._int_format(l),h=0):(e=8,c="<Q",l=this._required_bytes(n),d=this._int_format(l),h=this._required_bytes(r),u=this._int_format(h)),s.set(a,[e,l,h,c,d,u]),a<o){let s=e+l+h;n=this._nrecords_max(t,i,s),r>0?r*=n:r=n}}return s}_nrecords_max(e,t,i){return Math.floor((e-10-i)/(t+i))}_required_bytes(e){return Math.ceil(Cf(e)/8)}_int_format(e){return["<B","<H","<I","<Q"][e-1]}async _read_node(e,t){let[i,n,r]=e,s=this._read_node_header(i,t);i+=wf(this.B_LINK_NODE);let o=this.header.get("record_size"),a=[];for(let e=0;e<n;e++){let e=await this._parse_record(this.fh,i,o);i+=o,a.push(e)}let l=[],h=this.address_formats.get(t);if(0!=t){let[e,t,r,s,o,a]=h;for(let h=0;h<=n;h++){let n=(await xf.unpack_from_async(s,this.fh,i))[0];i+=e;let h=(await xf.unpack_from_async(o,this.fh,i))[0];i+=t;let c=h;r>0&&(c=(await xf.unpack_from_async(a,this.fh,i))[0],i+=r),l.push([n,h,c])}}return s.set("keys",a),s.set("addresses",l),s}async _read_node_header(e,t){let i=await gf(this.B_LINK_NODE,this.fh,e);return i.set("node_level",t),i}*iter_records(){for(let e of this.all_nodes.values())for(let t of e)for(let e of t.get("keys"))yield e}_parse_record(e){throw"NotImplementedError"}},ng=class extends ig{NODE_TYPE=5;async _parse_record(e,t,i){let n=(await xf.unpack_from_async("<I",e,t))[0];t+=4;const r=await e.slice(t,t+7);return new Map([["namehash",n],["heapid",r]])}},rg=class extends ig{NODE_TYPE=6;async _parse_record(e,t,i){let n=(await xf.unpack_from_async("<Q",e,t))[0];t+=8;const r=await e.slice(t,t+7);return new Map([["creationorder",n],["heapid",r]])}},sg=class{constructor(e,t,i=!1){this.ready=this.init(e,t,i)}async init(e,t,i){var n;if(i)n=new Map([["symbols",1]]);else{if("SNOD"!=(n=await gf(gg,e,t)).get("signature"))throw"incorrect node type";t+=mg}for(var r=[],s=n.get("symbols"),o=0;o<s;o++)r.push(await gf(fg,e,t)),t+=pg;return i&&(this.group_offset=r[0].get("object_header_address")),this.entries=r,this._contents=n,this}assign_name(e){this.entries.forEach((function(t){let i=t.get("link_name_offset"),n=e.get_object_name(i);t.set("link_name",n)}))}get_links(e){var t={};return this.entries.forEach((function(i){let n=i.get("cache_type"),r=i.get("link_name");if(0==n||1==n)t[r]=i.get("object_header_address");else if(2==n){let n=i.get("scratch"),o=new ArrayBuffer(4),a=new Uint8Array(o);for(var s=0;s<4;s++)a[s]=n.charCodeAt(s);let l=xf.unpack_from("<I",o,0)[0];t[r]=e.get_object_name(l)}})),t}},og=class{constructor(e,t){this.ready=this.init(e,t)}async init(e,t){let i=await gf(wg,e,t);t+=vg;let n=i.get("collection_size")-vg,r=await e.slice(t,t+n);this.heap_data=r,this._header=i,this._objects=null}get objects(){if(null==this._objects){this._objects=new Map;for(var e=0;e<=this.heap_data.byteLength-_g;){let t=mf(yg,this.heap_data,e);if(0==t.get("object_index"))break;e+=_g;let i=this.heap_data.slice(e,e+t.get("object_size"));this._objects.set(t.get("object_index"),i),e+=vf(t.get("object_size"))}}return this._objects}},ag=xf.unpack_from("8s",new Uint8Array([137,72,68,70,13,10,26,10]).buffer)[0],lg=xf.unpack_from("<Q",new Uint8Array([255,255,255,255,255,255,255,255]).buffer)[0],hg=new Map([["format_signature","8s"],["superblock_version","B"],["free_storage_version","B"],["root_group_version","B"],["reserved_0","B"],["shared_header_version","B"],["offset_size","B"],["length_size","B"],["reserved_1","B"],["group_leaf_node_k","H"],["group_internal_node_k","H"],["file_consistency_flags","L"],["base_address_lower","Q"],["free_space_address","Q"],["end_of_file_address","Q"],["driver_information_address","Q"]]),cg=wf(hg),dg=new Map([["format_signature","8s"],["superblock_version","B"],["offset_size","B"],["length_size","B"],["file_consistency_flags","B"],["base_address","Q"],["superblock_extension_address","Q"],["end_of_file_address","Q"],["root_group_address","Q"],["superblock_checksum","I"]]),ug=wf(dg),fg=new Map([["link_name_offset","Q"],["object_header_address","Q"],["cache_type","I"],["reserved","I"],["scratch","16s"]]),pg=wf(fg),gg=new Map([["signature","4s"],["version","B"],["reserved_0","B"],["symbols","H"]]),mg=wf(gg),bg=new Map([["signature","4s"],["version","B"],["reserved","3s"],["data_segment_size","Q"],["offset_to_free_list","Q"],["address_of_data_segment","Q"]]),wg=new Map([["signature","4s"],["version","B"],["reserved","3s"],["collection_size","Q"]]),vg=wf(wg),yg=new Map([["object_index","H"],["reference_count","H"],["reserved","I"],["object_size","Q"]]),_g=wf(yg),xg=new Map([["signature","4s"],["version","B"],["object_index_size","H"],["filter_info_size","H"],["flags","B"],["max_managed_object_size","I"],["next_huge_object_index","Q"],["btree_address_huge_objects","Q"],["managed_freespace_size","Q"],["freespace_manager_address","Q"],["managed_space_size","Q"],["managed_alloc_size","Q"],["next_directblock_iterator_address","Q"],["managed_object_count","Q"],["huge_objects_total_size","Q"],["huge_object_count","Q"],["tiny_objects_total_size","Q"],["tiny_object_count","Q"],["table_width","H"],["starting_block_size","Q"],["maximum_direct_block_size","Q"],["log2_maximum_heap_size","H"],["indirect_starting_rows_count","H"],["root_block_address","Q"],["indirect_current_rows_count","H"]]),kg=class{constructor(e,t){this.ready=this.init(e,t)}async init(e,t){let i=(await xf.unpack_from_async("<B",e,t))[0];if(1==i)var[n,r,s]=await this._parse_v1_objects(e,t);else{if(i!="O".charCodeAt(0))throw"InvalidHDF5File('unknown Data Object Header')";var[n,r,s]=await this._parse_v2_objects(e,t)}this.fh=e,this.msgs=n,this.msg_data=r,this.offset=t,this._global_heaps={},this._header=s,this._filter_pipeline=null,this._chunk_params_set=!1,this._chunks=null,this._chunk_dims=null,this._chunk_address=null}get dtype(){let e=this.find_msg_type(Yg)[0].get("offset_to_message");return new Af(this.fh,e).dtype}get chunks(){return this._get_chunk_params().then((()=>this._chunks))}get shape(){let e=this.find_msg_type(Qg)[0].get("offset_to_message");return async function(e,t){let i=(await xf.unpack_from_async("<B",e,t))[0];var n;if(1==i)bf(1==(n=await gf(Ig,e,t)).get("version")),t+=Bg;else{if(2!=i)throw"InvalidHDF5File('unknown dataspace message version')";bf(2==(n=await gf(Fg,e,t)).get("version")),t+=Ng}let r=n.get("dimensionality"),s=await xf.unpack_from_async("<"+(2*r).toFixed()+"I",e,t);return s.filter((function(e,t){return t%2==0}))}(this.fh,e)}async get_filter_pipeline(){if(null!=this._filter_pipeline)return this._filter_pipeline;let e=this.find_msg_type(tm);if(!e.length)return this._filter_pipeline=null,this._filter_pipeline;var t=e[0].get("offset_to_message");let[i,n]=await xf.unpack_from_async("<BB",this.fh,t);t+=xf.calcsize("<BB");var r=[];if(1==i){await xf.unpack_from_async("<HI",this.fh,t),t+=xf.calcsize("<HI");for(var s=0;s<n;s++){let e=await gf(Gg,this.fh,t);t+=Zg;let i=vf(e.get("name_length"),8),n="<"+i.toFixed()+"s",s=(await xf.unpack_from_async(n,this.fh,t))[0];e.set("filter_name",s),t+=i,n="<"+e.get("client_data_values").toFixed()+"I";let o=await xf.unpack_from_async(n,this.fh,t);e.set("client_data",o),t+=4*e.get("client_data_values"),e.get("client_data_values")%2&&(t+=4),r.push(e)}}else{if(2!=i)throw`version ${i} is not supported`;for(let e=0;e<n;e++){let e=new Map,i=this.fh,n=(await xf.unpack_from_async("<H",i,t))[0];t+=2,e.set("filter_id",n);let s=0;n>255&&(s=(await xf.unpack_from_async("<H",i,t))[0],t+=2);let o=(await xf.unpack_from_async("<H",i,t))[0];t+=2;let a=(1&o)>0;e.set("optional",a);let l,h=(await xf.unpack_from_async("<H",i,t))[0];t+=2,s>0&&(l=(await xf.unpack_from_async(`${s}s`,i,t))[0],t+=s),e.set("name",l);let c=await xf.unpack_from_async(`<${h}i`,i,t);t+=4*h,e.set("client_data_values",c),r.push(e)}}return this._filter_pipeline=r,this._filter_pipeline}find_msg_type(e){return this.msgs.filter((function(t){return t.get("type")==e}))}async get_attributes(){let e={},t=this.find_msg_type(im);for(let i of t){let t=i.get("offset_to_message"),[n,r]=await this.unpack_attribute(t);e[n]=r}return e}async get_fillvalue(){var e,t=this.find_msg_type(Kg)[0].get("offset_to_message");let i=(await xf.unpack_from_async("<B",this.fh,t))[0];var n,r,s;if(1==i||2==i)n=await gf(qg,this.fh,t),t+=jg,e=n.get("fillvalue_defined");else{if(3!=i)throw'InvalidHDF5File("Unknown fillvalue msg version: "'+String(i);n=await gf($g,this.fh,t),t+=Wg,e=32&n.get("flags")}if(e?(r=(await xf.unpack_from_async("<I",this.fh,t))[0],t+=4):r=0,r){let[e,i,n]=_f(await this.dtype);s=new kf(await this.fh.slice(t,t+n))[e](t,!i,n)}else s=0;return s}async unpack_attribute(e){let t=(await xf.unpack_from_async("<B",this.fh,e))[0];var i,n;if(1==t)bf(1==(i=await gf(Ag,this.fh,e)).get("version")),e+=Eg,n=8;else{if(3!=t)throw"unsupported attribute message version: "+t;bf(3==(i=await gf(Mg,this.fh,e)).get("version")),e+=Tg,n=1}let r=i.get("name_size"),s=(await xf.unpack_from_async("<"+r.toFixed()+"s",this.fh,e))[0];var o;s=s.replace(/\x00$/,""),e+=vf(r,n);try{o=await new Af(this.fh,e).dtype}catch(e){return console.warn("Attribute "+s+" type not implemented, set to null."),[s,null]}e+=vf(i.get("datatype_size"),n);let a=await this.determine_data_shape(this.fh,e),l=a.reduce((function(e,t){return e*t}),1);if(e+=vf(i.get("dataspace_size"),n),5===o.datatype_class)h=await this.fh.slice(e,e+o.size);else{var h=await this._attr_value(o,this.fh,l,e);0==a.length&&(h=h[0])}return[s,h]}async determine_data_shape(e,t){let i=(await xf.unpack_from_async("<B",e,t))[0];var n;if(1==i)bf(1==(n=await gf(Ig,e,t)).get("version")),t+=Bg;else{if(2!=i)throw"unknown dataspace message version";bf(2==(n=await gf(Fg,e,t)).get("version")),t+=Ng}let r=n.get("dimensionality");return await xf.unpack_from_async("<"+r.toFixed()+"Q",e,t)}async _attr_value(e,t,i,n){var r=new Array(i);if(e instanceof Array){let h=e[0];for(var s=0;s<i;s++)if("VLEN_STRING"==h){let i=e[2];var[o,a]=await this._vlen_size_and_data(t,n);const l=new TextDecoder(0==i?"ascii":"utf-8");r[s]=l.decode(a),n+=16}else if("REFERENCE"==h){var l=await xf.unpack_from_async("<Q",t,n);r[s]=l,n+=8}else{if("VLEN_SEQUENCE"!=h)throw"NotImplementedError";{let i=e[1];var[o,a]=this._vlen_size_and_data(t,n);r[s]=this._attr_value(i,a,o,0),n+=16}}}else{let[o,a,l]=_f(e);const h=await t.slice(n,n+i*l);let c=new kf(h,0),d=0;for(s=0;s<i;s++)r[s]=c[o](d,!a,l),d+=l}return r}async _vlen_size_and_data(e,t){let i=(await xf.unpack_from_async("<I",e,t))[0],n=await gf(Sg,e,t+4),r=n.get("collection_address");var s;return bf(n.get("collection_address")<Number.MAX_SAFE_INTEGER),r in this._global_heaps||(s=new og(this.fh,r),await s.ready,this._global_heaps[r]=s),[i,(s=this._global_heaps[r]).objects.get(n.get("object_index"))]}async _parse_v1_objects(e,t){let i=await gf(Rg,e,t);bf(1==i.get("version"));let n=i.get("total_header_messages");for(var r=i.get("object_header_size"),s=t+wf(Rg),o=await e.slice(s,s+r),a=[[s,r]],l=0,h=0,c=new Array(n),d=0;d<n;d++){h>=r&&([s,r]=a[++l],h=0);let t=await gf(Og,e,s+h),i=s+h+Pg;if(t.set("offset_to_message",i),t.get("type")==nm){var[u,f]=await xf.unpack_from_async("<QQ",e,i);a.push([u,f])}h+=Pg+t.get("size"),c[d]=t}return[c,o,i]}async _parse_v2_objects(e,t){var[i,n,r]=await this._parse_v2_header(e,t);t=r;for(var s=[],o=i.get("size_of_chunk_0"),a=e.slice(t,t+=o),l=[[r,o]],h=0,c=0;;){if(c>=o-zg){let e=l[++h];if(null==e)break;[r,o]=e,c=0}let t=await gf(Dg,e,r+c),i=r+c+zg+n;if(t.set("offset_to_message",i),t.get("type")==nm){var[d,u]=await xf.unpack_from_async("<QQ",e,i);l.push([d+4,u-4])}c+=zg+t.get("size")+n,s.push(t)}return[s,a,i]}async _parse_v2_header(e,t){let i=await gf(Lg,e,t);var n;if(t+=wf(Lg),bf(2==i.get("version")),n=4&i.get("flags")?2:0,bf(0==(16&i.get("flags"))),32&i.get("flags")){let n=await xf.unpack_from_async("<4I",e,t);t+=16,i.set("access_time",n[0]),i.set("modification_time",n[1]),i.set("change_time",n[2]),i.set("birth_time",n[3])}let r=["<B","<H","<I","<Q"][3&i.get("flags")];return i.set("size_of_chunk_0",(await xf.unpack_from_async(r,e,t))[0]),[i,n,t+=xf.calcsize(r)]}async find_link(e){if(this._links){for(link of this._links)if(e===link[0])return link}else{const t=[];for await(const i of this.iter_links()){if(e===i[0])return i;t.push(i)}this._links=t}}async get_links(){const e=[];for await(const t of this.iter_links())e.push(t);return Object.fromEntries(e)}async*iter_links(){for(let e of this.msgs)e.get("type")==rm?yield*this._iter_links_from_symbol_tables(e):e.get("type")==Jg?yield this._get_link_from_link_msg(e):e.get("type")==Xg&&(yield*this._iter_link_from_link_info_msg(e))}async*_iter_links_from_symbol_tables(e){bf(16==e.get("size"));let t=await gf(Hg,this.fh,e.get("offset_to_message"));yield*this._iter_links_btree_v1(t.get("btree_address"),t.get("heap_address"))}async*_iter_links_btree_v1(e,t){let i=new eg(this.fh,e);await i.ready;let n=new class{constructor(e,t){this.ready=this.init(e,t)}async init(e,t){let i=await gf(bg,e,t);bf("HEAP"==i.get("signature")),bf(0==i.get("version"));let n=i.get("address_of_data_segment"),r=await e.slice(n,n+i.get("data_segment_size"));i.set("heap_data",r),this._contents=i,this.data=r}get_object_name(e){let t=new Uint8Array(this.data).indexOf(0,e)-e;return xf.unpack_from("<"+t.toFixed()+"s",this.data,e)[0]}}(this.fh,t);await n.ready;for(let e of i.symbol_table_addresses()){let t=new sg(this.fh,e);await t.ready,t.assign_name(n),yield*Object.entries(t.get_links(n))}}async _get_link_from_link_msg(e){let t=e.get("offset_to_message");return await this._decode_link_msg(this.fh,t)[1]}async _decode_link_msg(e,t){let[i,n]=await xf.unpack_from_async("<BB",e,t);t+=2,bf(1==i);let r,s,o=2**(3&n),a=(16&n)>0,l=(4&n)>0;(8&n)>0?(r=(await xf.unpack_from_async("<B",e,t))[0],t+=1):r=0,bf([0,1].includes(r)),l&&(s=(await xf.unpack_from_async("<Q",e,t))[0],t+=8);let h=0;a&&(h=(await xf.unpack_from_async("<B",e,t))[0],t+=1);let c=0==h?"ascii":"utf-8",d=["<B","<H","<I","<Q"][3&n],u=(await xf.unpack_from_async(d,e,t))[0];t+=o;let f,p=new TextDecoder(c).decode(await e.slice(t,t+u));if(t+=u,0==r)f=(await xf.unpack_from_async("<Q",e,t))[0];else if(1==r){let i=(await xf.unpack_from_async("<H",e,t))[0];t+=2,f=new TextDecoder(c).decode(await e.slice(t,t+i))}return[s,[p,f]]}async*_iter_link_from_link_info_msg(e){let t=e.get("offset_to_message"),i=await this._decode_link_info_msg(this.fh,t),n=i.get("heap_address"),r=i.get("name_btree_address"),s=i.get("order_btree_address");null!=r&&(yield*this._iter_links_btree_v2(r,s,n))}async*_iter_links_btree_v2(e,t,i){let n,r=new class{constructor(e,t){this.fh=e,this.ready=this.init(t)}async init(e){let t=await gf(xg,this.fh,e);if(e+=wf(xg),bf("FRHP"==t.get("signature")),bf(0==t.get("version")),t.get("filter_info_size")>0)throw"Filter info size not supported on FractalHeap";if(t.get("btree_address_huge_objects")!=lg)throw"Huge objects not implemented in FractalHeap";t.set("btree_address_huge_objects",null),t.get("root_block_address")==lg&&t.set("root_block_address",null);let i=t.get("log2_maximum_heap_size"),n=this._min_size_nbits(i),r=new Map([["signature","4s"],["version","B"],["heap_header_adddress","Q"],["block_offset",`${n}B`]]);this.indirect_block_header=new Map(r),this.indirect_block_header_size=wf(r),2==(2&t.get("flags"))&&r.set("checksum","I"),this.direct_block_header=r,this.direct_block_header_size=wf(r);let s=t.get("maximum_direct_block_size");this._managed_object_offset_size=this._min_size_nbits(i);let o=Math.min(s,t.get("max_managed_object_size"));this._managed_object_length_size=this._min_size_integer(o);let a=t.get("starting_block_size"),l=t.get("table_width");if(!(a>0))throw"Starting block size == 0 not implemented";let h=Number(Math.floor(Math.log2(s)));bf(1n<<BigInt(h)==s);let c=Number(Math.floor(Math.log2(a)));bf(1n<<BigInt(c)==a),this._max_direct_nrows=h-c+2;let d=Math.floor(Math.log2(l));bf(1<<d==l),this._indirect_nrows_sub=d+c-1,this.header=t,this.nobjects=t.get("managed_object_count")+t.get("huge_object_count")+t.get("tiny_object_count");let u=[],f=t.get("root_block_address"),p=0;if(null!=f&&(p=t.get("indirect_current_rows_count")),p>0)for await(let e of this._iter_indirect_block(this.fh,f,p))u.push(e);else{let e=await this._read_direct_block(this.fh,f,a);u.push(e)}let g=u.reduce(((e,t)=>e+t.byteLength),0),m=new Uint8Array(g),b=0;u.forEach((e=>{m.set(new Uint8Array(e),b),b+=e.byteLength})),this.managed=m.buffer}async _read_direct_block(e,t,i){let n=await e.slice(t,t+i);return bf("FHDB"==mf(this.direct_block_header,n).get("signature")),n}get_data(e){let t=xf.unpack_from("<B",e,0)[0],i=t>>4&3,n=1;if(0==i){bf(0==t>>6);let i=this._managed_object_offset_size,r=Sf(i,e,n);n+=i,i=this._managed_object_length_size;let s=Sf(i,e,n);return this.managed.slice(r,r+s)}throw 1==i?"tiny objectID not supported in FractalHeap":2==i?"huge objectID not supported in FractalHeap":"unknown objectID type in FractalHeap"}_min_size_integer(e){return this._min_size_nbits(Cf(e))}_min_size_nbits(e){return Math.ceil(e/8)}async*_iter_indirect_block(e,t,i){let n=await gf(this.indirect_block_header,e,t);t+=this.indirect_block_header_size,bf("FHIB"==n.get("signature"));let r=n.get("block_offset").reduce(((e,t,i)=>e+(t<<8*i)),0);n.set("block_offset",r);let[s,o]=this._indirect_info(i),a=[];for(let i=0;i<s;i++){let n=(await xf.unpack_from_async("<Q",e,t))[0];if(t+=8,n==lg)break;let r=this._calc_block_size(i);a.push([n,r])}let l=[];for(let i=s;i<s+o;i++){let n=(await xf.unpack_from_async("<Q",e,t))[0];if(t+=8,n==lg)break;let r=this._calc_block_size(i),s=this._iblock_nrows_from_block_size(r);l.push([n,s])}for(let[t,i]of a){let n=await this._read_direct_block(e,t,i);yield n}for(let[t,i]of l)for await(let n of this._iter_indirect_block(e,t,i))yield n}_calc_block_size(e){let t=Math.floor(e/this.header.get("table_width"));return 2**Math.max(t-1,0)*this.header.get("starting_block_size")}_iblock_nrows_from_block_size(e){let t=Math.floor(Math.log2(e));return bf(2**t==e),t-this._indirect_nrows_sub}_indirect_info(e){let t,i,n=this.header.get("table_width"),r=e*n,s=this._max_direct_nrows*n;return e<=s?(t=r,i=0):(t=s,i=r-s),[t,i]}_int_format(e){return["B","H","I","Q"][e-1]}}(this.fh,i);await r.ready;const s=null!=t;s?(n=new rg(this.fh,t),await n.ready):(n=new ng(this.fh,e),await n.ready);let o=new Map;for(let e of n.iter_records()){let t=r.get_data(e.get("heapid")),[i,n]=await this._decode_link_msg(t,0);const a=s?i:n[0];o.set(a,n)}let a=Array.from(o.keys()).sort();for(let e of a)yield o.get(e)}async _decode_link_info_msg(e,t){let[i,n]=await xf.unpack_from_async("<BB",e,t);bf(0==i),t+=2,(1&n)>0&&(t+=8);let r=(2&n)>0?Ug:Vg,s=await gf(r,e,t),o=new Map;for(let[e,t]of s.entries())o.set(e,t==Cg?null:t);return o}get is_dataset(){return this.find_msg_type(Qg).length>0}async get_data(){let e=this.find_msg_type(em)[0].get("offset_to_message");var[t,i,n,r]=await this._get_data_message_properties(e);if(0==n)throw"Compact storage of DataObject not implemented";return 1==n?this._get_contiguous_data(r):2==n?this._get_chunked_data(e):void 0}async _get_data_message_properties(e){let t,i,n,[r,s,o]=await xf.unpack_from_async("<BBB",this.fh,e);return 1==r||2==r?(t=s,i=o,n=e,n+=xf.calcsize("<BBB"),n+=xf.calcsize("<BI"),bf(1==i||2==i)):3!=r&&4!=r||(i=s,n=e,n+=xf.calcsize("<BB")),bf(r>=1&&r<=4),[r,t,i,n]}async _get_contiguous_data(e){let[t]=await xf.unpack_from_async("<Q",this.fh,e);const i=await this.shape,n=await this.dtype;if(t==Cg){let e=i.reduce((function(e,t){return e*t}),1);return new Array(e)}var r=i.reduce((function(e,t){return e*t}),1);if(n instanceof Array){let e=n[0];if("REFERENCE"==e){if(8!=n[1])throw"NotImplementedError('Unsupported Reference type')";return await this.fh.slice(t,t+r)}if("VLEN_STRING"==e){let e=n[2];const i=new TextDecoder(0==e?"ascii":"utf-8");var s=[];for(o=0;o<r;o++){const[e,n]=await this._vlen_size_and_data(this.fh,t);s[o]=i.decode(n),t+=16}return s}throw"NotImplementedError('datatype not implemented')"}if(/[<>=!@\|]?(i|u|f|S)(\d*)/.test(n)){let[e,i,s]=_f(n),a=new Array(r);const l=await this.fh.slice(t,t+s*r);let h=new kf(l);for(var o=0;o<r;o++)a[o]=h[e](o*s,!i,s);return a}if(5===n.datatype_class)return this.fh.slice(t,t+n.size);throw"not Implemented - no proper dtype defined"}async _get_chunked_data(e){if(await this._get_chunk_params(),this._chunk_address==Cg)return[];var t=new tg(this.fh,this._chunk_address,this._chunk_dims);await t.ready;const i=await this.dtype,n=await this.shape,r=await this.chunks,s=await this.get_filter_pipeline();let o=await t.construct_data_from_chunks(r,n,i,s);if(i instanceof Array&&/^VLEN/.test(i[0])){let e=i[0];for(var a=0;a<o.length;a++){let[t,n,r]=o[a];var l;n in this._global_heaps?l=this._global_heaps[n]:(l=new og(this.fh,n),await l.ready,this._global_heaps[n]=l);let s=l.objects.get(r);if("VLEN_STRING"==e){let e=i[2];const t=new TextDecoder(0==e?"ascii":"utf-8");o[a]=t.decode(s)}}}return o}async _get_chunk_params(){if(!this._chunk_params_set){this._chunk_params_set=!0;var e=this.find_msg_type(em)[0].get("offset_to_message"),[t,i,n,r]=await this._get_data_message_properties(e);if(2==n){var s;if(1==t||2==t){var o=(await xf.unpack_from_async("<Q",this.fh,r))[0];s=r+xf.calcsize("<Q")}else if(3==t){var[i,o]=await xf.unpack_from_async("<BQ",this.fh,r);s=r+xf.calcsize("<BQ")}bf(t>=1&&t<=3);var a="<"+(i-1).toFixed()+"I",l=await xf.unpack_from_async(a,this.fh,s);this._chunks=l,this._chunk_dims=i,this._chunk_address=o}}}};var Cg=xf.unpack_from("<Q",new Uint8Array([255,255,255,255,255,255,255,255]).buffer),Sg=new Map([["collection_address","Q"],["object_index","I"]]);wf(Sg);var Ag=new Map([["version","B"],["reserved","B"],["name_size","H"],["datatype_size","H"],["dataspace_size","H"]]),Eg=wf(Ag),Mg=new Map([["version","B"],["flags","B"],["name_size","H"],["datatype_size","H"],["dataspace_size","H"],["character_set_encoding","B"]]),Tg=wf(Mg),Rg=new Map([["version","B"],["reserved","B"],["total_header_messages","H"],["object_reference_count","I"],["object_header_size","I"],["padding","I"]]),Lg=new Map([["signature","4s"],["version","B"],["flags","B"]]),Ig=new Map([["version","B"],["dimensionality","B"],["flags","B"],["reserved_0","B"],["reserved_1","I"]]),Bg=wf(Ig),Fg=new Map([["version","B"],["dimensionality","B"],["flags","B"],["type","B"]]),Ng=wf(Fg),Og=new Map([["type","H"],["size","H"],["flags","B"],["reserved","3s"]]),Pg=wf(Og),Dg=new Map([["type","B"],["size","H"],["flags","B"]]),zg=wf(Dg),Hg=new Map([["btree_address","Q"],["heap_address","Q"]]),Vg=new Map([["heap_address","Q"],["name_btree_address","Q"]]),Ug=new Map([["heap_address","Q"],["name_btree_address","Q"],["order_btree_address","Q"]]),qg=new Map([["version","B"],["space_allocation_time","B"],["fillvalue_write_time","B"],["fillvalue_defined","B"]]),jg=wf(qg),$g=new Map([["version","B"],["flags","B"]]),Wg=wf($g),Gg=new Map([["filter_id","H"],["name_length","H"],["flags","H"],["client_data_values","H"]]),Zg=wf(Gg),Qg=1,Xg=2,Yg=3,Kg=5,Jg=6,em=8,tm=11,im=12,nm=16,rm=17,sm=class{constructor(e,t){null==t?(this.parent=this,this.file=this):(this.parent=t,this.file=t.file),this.name=e}async init(e){const t=this.file.index;t&&this.name in t?this._links=t[this.name]:this._links=await e.get_links(),this._dataobjects=e,this._attrs=null,this._keys=null}get keys(){return null==this._keys&&(this._keys=Object.keys(this._links)),this._keys.slice()}get values(){return this.keys.map((e=>this.get(e)))}length(){return this.keys.length}_dereference(e){if(!e)throw"cannot deference null reference";let t=this.file._get_object_by_address(e);if(null==t)throw"reference not found in file";return t}async get(e){if("number"==typeof e)return this._dereference(e);var t=lm(e);if("/"==t)return this.file;if("."==t)return this;if(/^\//.test(t))return this.file.get(t.slice(1));if(""!=function(e){let t="/",i=e.lastIndexOf(t)+1,n=e.slice(0,i),r=new RegExp("^"+t+"+$"),s=new RegExp(t+"$");n&&!r.test(n)&&(n=n.replace(s,""));return n}(t))var[i,n]=t.split(/\/(.*)/);else var i=t,n=".";if(!(i in this._links))throw i+" not found in group";var r=lm(this.name+"/"+i);let s=this._links[i];if("string"==typeof s)try{return this.get(s)}catch(e){return null}var o=new kg(this.file._fh,s);if(await o.ready,o.is_dataset){if("."!=n)throw r+" is a dataset, not a group";return new am(r,o,this)}var a=new sm(r,this);return await a.init(o),a.get(n)}visit(e){return this.visititems(((t,i)=>e(t)))}visititems(e){var t=this.name.length;/\/$/.test(this.name)||(t+=1);for(var i=this.values.slice();i;){let n=i.shift();1==i.length&&console.log(n);let r=e(n.name.slice(t),n);if(null!=r)return r;n instanceof sm&&(i=i.concat(n.values))}return null}get attrs(){return null==this._attrs&&(this._attrs=this._dataobjects.get_attributes()),this._attrs}},om=class extends sm{constructor(e,t,i){super("/",null),this.ready=this.init(e,t,i)}async init(e,t,i){var n=new class{constructor(e,t){this.ready=this.init(e,t)}async init(e,t){let i=await xf.unpack_from_async("<B",e,t+8);var n;if(0==i)n=await gf(hg,e,t),this._end_of_sblock=t+cg;else{if(2!=i&&3!=i)throw"unsupported superblock version: "+i.toFixed();n=await gf(dg,e,t),this._end_of_sblock=t+ug}if(n.get("format_signature")!=ag)throw"Incorrect file signature: "+n.get("format_signature");if(8!=n.get("offset_size")||8!=n.get("length_size"))throw"File uses non-64-bit addressing";this.version=n.get("superblock_version"),this._contents=n,this._root_symbol_table=null,this._fh=e}async get_offset_to_dataobjects(){if(0==this.version){var e=new sg(this._fh,this._end_of_sblock,!0);return await e.ready,this._root_symbol_table=e,e.group_offset}if(2==this.version||3==this.version)return this._contents.get("root_group_address");throw"Not implemented version = "+this.version.toFixed()}}(e,0);await n.ready;var r=await n.get_offset_to_dataobjects(),s=new kg(e,r);if(await s.ready,this.parent=this,this.file=this,this.name="/",this._dataobjects=s,this._attrs=null,this._keys=null,this._fh=e,this.filename=t||"",this.mode="r",this.userblock_size=0,i&&i.index)this.index=i.index;else{let t;if(i&&i.indexOffset)t=i.indexOffset;else{const e=await this.attrs;if(e.hasOwnProperty("_index_offset"))t=e._index_offset;else{const e=this.indexName||"_index",i=await s.find_link(e);i&&(t=i[1])}}if(t)try{const i=new kg(e,t);await i.ready;const n=await i.get_data(),r=Xp(n),s=(new TextDecoder).decode(r);this.index=JSON.parse(s)}catch(e){console.error(`Error loading index by offset ${e}`)}}this.index&&this.name in this.index?this._links=this.index[this.name]:this._links=await s.get_links()}_get_object_by_address(e){return this._dataobjects.offset==e?this:this.visititems((e=>{e._dataobjects.offset}))}},am=class extends Array{constructor(e,t,i){super(),this.parent=i,this.file=i.file,this.name=e,this._dataobjects=t,this._attrs=null,this._astype=null}get value(){var e=this._dataobjects.get_data();return null==this._astype?this.getValue(e):e.astype(this._astype)}get shape(){return this._dataobjects.shape}get attrs(){return this._dataobjects.get_attributes()}get dtype(){return this._dataobjects.dtype}get fillvalue(){return this._dataobjects.get_fillvalue()}async to_array(){return function(e,t){const i=e.length,n=t.reduce(((e,t)=>e*t),1);i!==n&&console.warn(`shape product: ${n} does not match length of flattened array: ${i}`);let r=e;const s=t.slice(1).reverse();for(let e of s){const t=[],{length:i}=r;let n=0;for(;n<i;)t.push(r.slice(n,n+=e));r=t}return r}
/*! pako 2.0.4 https://github.com/nodeca/pako @license (MIT AND Zlib) */(await this.value,await this.shape)}async getValue(e){return(await this.dtype).startsWith("S")?(await e).map((e=>e.substr(0,e.indexOf("\0")))):e}};function lm(e){return e.replace(/\/(\/)+/g,"/")}async function hm(e){var t;e.url&&("function"==typeof(t=e.url).slice&&"function"==typeof t.arrayBuffer)&&(e.file=e.url,e.url=void 0);const i=void 0!==e.url;let n=e.reader?e.reader:function(e){if(e.url)return new df(e);if(e.path)return new NodeLocalFile(e);if(e.file)return new pf(e.file);throw Error("One of 'url', 'path (node only)', or 'file (browser only)' must be specified")}(e);const r=e.fetchSize||2e3,s=e.maxSize||2e5;i&&(n=new uf({file:n,fetchSize:r,maxSize:s}));const o=new cm(n),a=await async function(e){let t;if(e.indexReader)t=e.indexReader;else{if(e.index)return e.index;e.indexURL?t=new df({url:e.indexURL}):e.indexPath?t=new NodeLocalFile({path:e.indexPath}):e.indexFile&&(t=new pf({file:e.indexFile}))}if(t){const e=await t.read(),i=(new TextDecoder).decode(e);return JSON.parse(i)}return}(e),l=e.indexOffset,h=function(e){if(e.url)return dm(e.url);if(e.path)return dm(e.path);if(e.file)return e.file.name}(e),c=new om(o,h,{index:a,indexOffset:l});return await c.ready,c}class cm{constructor(e){this.fileReader=e}async slice(e,t){return this.fileReader.read(e,t-e)}}function dm(e){const t=e.lastIndexOf("/");return t>0?e.substring(t+1):e}class um{constructor(e,t=1e5){this.h5_file=e,this.bin_size=t,this.h5_obj=void 0}async fetch(){return this.h5_obj||(this.h5_obj=await hm({url:this.h5_file,fetchSize:1e6,maxSize:2e8})),this.h5_obj}async get_keys(){return(await this.fetch()).keys}async get_rd_signal(e=this.bin_size){let t=await this.fetch(),i=t.keys,n=new fm(i),r=n.get_rd_bins(),s=n.get_snp_bins();this.available_bins=[...new Set(r,s)],this.available_bins.includes(e)||(e=this.available_bins.at(-1));const o=await t.get("rd_chromosomes");await o.dtype;let a=await o.value,l=await this.rd_stat(t,i,e);var h=[],c=[],d=[],u=[],f=[],p=[];for(let n of a){var g=`his_rd_p_${n}_${e}`;let r=await this.get_chr_signal(t,i,n,e,g,l);h=h.concat(r);var m=`his_rd_p_${n}_${e}_GC`;let s=await this.get_chr_signal(t,i,n,e,m,l);c=c.concat(s);let o=`his_rd_p_${n}_${e}_partition_GC_merge`,a=await this.get_chr_signal(t,i,n,e,o,l);d=d.concat(a);let b=await this.rd_call_combined(t,i,n,e,l);u=u.concat(b);let w=`snp_likelihood_${n}_${e}_mask`,v=await this.get_baf_signals(t,i,n,e,w);f=f.concat(v[0]),p=p.concat(v[1])}this.callers=[],0!=u.length&&this.callers.push("ReadDepth"),0!=u.length&&this.callers.push("2D");var b={},w={RD_Raw:h,RD_Raw_gc_coor:c,ReadDepth:d,"2D":u,BAF1:f,BAF2:p};return b[e]=w,b}decode_segments(e){let t=[],i=[];for(let n of e)4294967295==n?(t.push(i),i=[]):i.push(n);return t}async rd_call_combined(e,t,i,n,r){let s,o=[],a=`his_rd_p_${i}_${n}_partition_GC_mosaic_segments_2d`;if(t.includes(a)){const t=await e.get(a);let i=await t.value;s=this.decode_segments(i)}let l=`his_rd_p_${i}_${n}_partition_GC_mosaic_call_2d`;if(t.includes(l)){const t=await e.get(l);let a=await t.to_array();s.forEach(((e,t)=>{e.forEach(((e,s)=>{o.push({chr:i,start:e*n,end:(e+1)*n,value:a[0][t]/r[4]*2})}))}))}return o}async rd_stat(e,t,i){let n,r=`rd_stat_${i}_auto`;if(t.includes(r)){const t=await e.get(r);n=await t.value}return n}async get_chr_signal(e,t,i,n,r,s){let o=[];if(t.includes(r)){const t=await e.get(r);(await t.value).forEach(((e,t)=>{o.push({chr:i,start:t*n,end:(t+1)*n,value:e/s[4]*2})}))}return o}async get_baf_signals(e,t,i,n,r){let s=[],o=[];if(t.includes(r)){let t=await e.get(r);(await t.to_array()).forEach(((e,t)=>{let r=Math.max(...e);const a=e.indexOf(r);let l=Math.max(a/200,1-a/200);s.push({chr:i,start:t*n,end:(t+1)*n,value:-2*l}),.5!=l&&o.push({chr:i,start:t*n,end:(t+1)*n,value:-2*(1-l)})}))}return[s,o]}async get_baf_signals_v2(e,t,i,n,r){let s=[],o=[];if(t.includes(r)){let t=await e.get(r);(await t.to_array()).forEach(((e,t)=>{isNaN(e)||(s.push({chr:i,start:t*n,end:(t+1)*n,value:-2*(.5-e)}),.5!=e&&o.push({chr:i,start:t*n,end:(t+1)*n,value:-2*(.5+e)}))}))}return console.log(i,s,o),[s,o]}}class fm{constructor(e){this.signals=e}get_rd_bins(){let e=[];this.signals.forEach((t=>{let i=t.match(/^his_rd_p_(.*)_(\d+)$/);i&&e.push({chr:i[1],bin_size:i[2]})}));return[...new Set(e.map((e=>Number(e.bin_size))))]}get_snp_bins(){let e=[];this.signals.forEach((t=>{let i=t.match(/^snp_likelihood_(.*)_(\d+)_mask$/);i&&e.push({chr:i[1],bin_size:i[2]})}));return[...new Set(e.map((e=>Number(e.bin_size))))]}}function pm(e){let t=function(e){if(e.length<4)return e;let t,i,n,r,s,o;return t=e.slice().sort(((e,t)=>e-t)),t.length/4%1==0?(i=.5*(t[t.length/4]+t[t.length/4+1]),n=.5*(t[t.length*(3/4)]+t[t.length*(3/4)+1])):(i=t[Math.floor(t.length/4+1)],n=t[Math.ceil(t.length*(3/4)+1)]),r=n-i,s=n+1.5*r,o=i-1.5*r,t.filter((e=>e>=o&&e<=s))}(e);const i=t.length,n=t.reduce(((e,t)=>e+t))/i,r=Math.sqrt(t.map((e=>Math.pow(e-n,2))).reduce(((e,t)=>e+t))/i);return[n,r]}var gm={range_function:function(e,t,i){return Array(Math.ceil((t-e)/i)).fill(e).map(((e,t)=>e+t*i))},getDistParams:pm,linspace:function(e,t,i){if(void 0===i&&(i=Math.max(Math.round(t-e)+1,1)),i<2)return 1===i?[e]:[];var n=Array(i);for(let r=--i;r>=0;r--)n[r]=(r*t+(i-r)*e)/i;return n},GetFit:class{constructor(e){this.allBins=e}getValues(){return Object.values(this.allBins).reduce(((e,t)=>e.concat(t.filter((e=>e.binScore>0)).map((e=>e.binScore)))),[])}getMean(e){return e.reduce((function(e,t){return e+t}))/e.length}fit_data(){return pm(this.getValues())}histogram(e,t){const i=t[1]-t[0],n=[];e.forEach(((e,r)=>{t.forEach(((t,r)=>{if(n[t]||(n[t]={count:0}),t<=e&&e<t+i)return n[t].count++,!1}))}));const r=[];return n.forEach(((e,t)=>{r.push(e.count)})),r}}};function mm(e,t){return isNaN(e)||isNaN(t)||t<=0?NaN:0===e?.5:.5+.5*(bm(.5*t,.5,1)-bm(.5*t,.5,t/(t+e*e)))*Math.sign(e)}function bm(e,t,i){if(0==i)return 0;if(1==i)return 1;{let n=_m(e+t)-_m(e)-_m(t)+e*Math.log(i)+t*Math.log(1-i);return i<(e+1)/(e+t+2)?Math.exp(n)*wm(e,t,i)/e:1-Math.exp(n)*wm(t,e,1-i)/t}}function wm(e,t,i,n=1e3){let r=1,s=1,o=1,a=e+t,l=e+1,h=e-1,c=1-a*i/l;for(let d=0;d<=n;d++){let n=parseFloat(d+1),u=n+n,f=n*(t-n)*i/((h+u)*(e+u)),p=r+f*s,g=c+f*o;f=-(e+n)*(a+n)*i/((l+u)*(e+u));let m=g+f*c,b=r;if(s=p/m,o=g/m,r=(p+f*r)/m,c=1,Math.abs(r-b)<3e-7*Math.abs(r))return r}}function vm(e){if(0==e||1==e)return 1;return e*vm(e-1)}function ym(e){let t;var i=[75122.633153,80916.6278952,36308.2951477,8687.24529705,1168.92649479,83.8676043424,2.50662827511],n=0,r=1;if(0==e)t=1e99;else if(e%1==0)t=vm(e-1);else{for(let t=0;t<i.length;t++)n+=i[t]*Math.pow(e,t),r*=e+t;t=n*Math.pow(e+5.5,e+.5)*Math.exp(-(e+5.5))/r}return t}function _m(e){return Math.log(ym(e))}var xm={TdistributionCDF:mm,gamma:ym,t_test_1_sample:function(e,t,i,n){0==i&&(i=1);var r=(e-t)/i*Math.sqrt(n);return 1-mm(Math.abs(r),n-1)},t_test_2_samples:function(e,t,i,n,r,s){0==t&&(t=1),0==r&&(r=1);var o=(e-n)/Math.sqrt(t**2/i+r**2/s),a=(t**2/i+r**2/s)**2*(i-1)*(s-1)/(t**4*(s-1)/i**2+r**4*(i-1)/s**2);return 1-mm(Math.abs(o),parseInt(a+.5))}};function km(e){return e.reduce((function(e,t){return e>t?e:t}))}function Cm(e,t,i,n){return t*Math.exp(-1*(e-i)**2/(2*n**2))/Math.sqrt(2*Math.PI)/n}function Sm(e,t,i,n){return Math.exp(-1*(e-i)**2/(t**2+n**2))}function Am(e,t){let i;try{i=e.reduce(((e,i,n)=>e+Math.min(i,t[n])))}catch{return console.log("Failed to find likelihood overlap: ",e,t),0}return i}function Em(e,t,i,n){return 0==t&&0==n?{nl:.5*(e+i),ne:0}:{nl:(e*n*n+i*t*t)/(t*t+n*n),ne:Math.sqrt(t*t*n*n/(t*t+n*n))}}function Mm(e,t){let i=parseInt(t*(e.length-1)),n=t*(e.length-1)-i;return i<e.length-1?e[i]*(1-n)+e[i+1]*n:e[i]}function Tm(e){const t=e.length,i=Math.max(...e);let n=e.indexOf(i);n>Math.floor(t/2)&&(n=t-1-n);const r=(t/2-n)/(t+1),s=Math.floor((t/2+n)/2),o=t-1-s;let a=e.slice(s,o+1).reduce(((e,t)=>e+t),0)/e.reduce(((e,t)=>e+t),0);return n===Math.floor(t/2)&&(a=1),{mean:r,p:a}}var Rm=class{constructor(e,t){this.wigFeatures=e,this.binSize=t}get_fit(){var e=new gm.GetFit(this.wigFeatures),[t,i]=e.fit_data();return{globalMean:t,globalStd:i}}async call_2d(e=null,t=null,i="both",n=.1,r=0,s=10,o=0){let a=this.get_fit();this.globalMean=a.globalMean,this.globalStd=a.globalStd;let l=null==e?.05*this.binSize/3e9:e,h=null==t?parseInt(this.binSize/1e4):t,c=[],d=[],u=[],f=[],p=[],g=[];for(const[e,t]of Object.entries(this.wigFeatures)){let e=[],i=[],s=[];t.forEach(((t,n)=>{t.hets_count>4&&t.dp_count>h&&(e.push([n]),i.push(t.binScore),s.push(t.likelihood_score),delete t.likelihood_score)}));let o=[];for(let e=1;e<i.length;e++)o.push(Math.abs(i[e]-i[e-1]));let a=[0];for(let e=1;e<o.length;e++)a.push(Math.min(o[e-1],o[e]));a.push(0);let g=i.map(((e,t)=>Math.sqrt(Math.sqrt(e)**2+this.globalStd**2+Math.pow(a[t]/2,2)))),m=[];for(let t=0;t<e.length-1;t++){let n=0;try{n=Am(s[t],s[t+1])}catch{console.log("Overlap failed: ",t,s[t],e[t+1],s[t+1])}let r=Sm(i[t],g[t],i[t+1],g[t+1]);m.push(r*n)}for(;m.length>0;){m=m.filter((e=>"number"==typeof e));let t=km(m);if(isNaN(t)&&console.log("NaN value",m),t<l)break;let n,r,o=m.indexOf(t),a=Em(i[o],g[o],i[o+1],g[o+1]);try{n=s[o].map(((e,t)=>e*s[o+1][t])),r=n.reduce(((e,t)=>e+t))}catch{console.log(s),console.log("max_overlap:",t,o,m.length),console.log("likelihood: ",o,s[o],s[o+1]),console.log("nlh: ",r)}if(i[o]=a.nl,g[o]=a.ne,s[o]=n.map((function(e){return e/r})),e[o].push(...e[o+1]),i.splice(o+1,1),g.splice(o+1,1),e.splice(o+1,1),s.splice(o+1,1),m.splice(o,1),o<m.length){let e=Sm(i[o],g[o],i[o+1],g[o+1])*Am(s[o],s[o+1]);m[o]=e}if(o>0){let e=Sm(i[o-1],g[o-1],i[o],g[o])*Am(s[o-1],s[o]);m[o-1]=e}}let b=-1;for(;;){m=[];for(let t=0;t<i.length;t++)for(let r=t;r<i.length;r++)e[r][0]-e[t].at(-1)<n*(e[t].length+e[r].length)&&m.push(Sm(i[t],g[t],i[r],g[r])*Am(s[t],s[r]));if(0==m.length)break;let t=km(m);if(t<l)break;let r=0,o=1;for(;r<e.length-1;){let a=Sm(i[r],g[r],i[o],g[o])*Am(s[r],s[o]);if(e[o][0]-e[r].at(-1)<n*(e[r].length+e[o].length)&&a==t){let t=Em(i[r],g[r],i[r+1],g[r+1]);i[r]=t.nl,g[r]=t.ne;let n=s[r].map(((e,t)=>e*s[r+1][t])),a=n.reduce(((e,t)=>e+t));s[r]=n.map((function(e){return e/a})),e[r].push(...e[r+1]),e[r]=e[r].sort(((e,t)=>e-t)),i.splice(o,1),g.splice(o,1),e.splice(o,1),s.splice(o,1),o>=e.length&&(r+=1,o=r+1)}else o+=1,o>=e.length&&(r+=1,o=r+1)}if(b==e.length)break;b=e.length}e.forEach(((e,n)=>{let o=Tm(s[n]);e.length>1&&(e.forEach(((e,s)=>{d.push(t[e]),o.mean<=r&&c.push(t[e]),t[e].segment_score=i[n]})),u.push(i[n]),f.push(g[n]),p.push(s[n]))}))}let m=parseInt(1e3*(1-o));0==m&&(m=1);let b=gm.linspace(o,1,m),w={},v={};for(let e=10;e>-1;e--)for(let t=0;t<e/2+1;t++){let n,r,s=e-t,o=b.map(((t,i)=>1-t+t*e/2)),a=e/2;e>0?(n=.5-t/(t+s),r=b.map(((e,i)=>.5-(1-e+e*t)/(2-2*e+(t+s)*e)))):(n=0,r=b.map(((e,t)=>0*e)));for(let i=0;i<u.length;i++){let l=Cm(a*this.globalMean,1,u[i],f[i])*Mm(p[i],.5+n);i in v?v[i].push([e,t,s,l,1]):v[i]=[e,t,s,l,1];let h=0,c=0,d=0;o.forEach(((e,t)=>{if(!isNaN(r[t])){let n=Cm(e*this.globalMean,1,u[i],f[i])*Mm(p[i],.5+r[t]);h+=n,n>c&&(c=n,d=b[t])}})),i in w?w[i].push([e,t,s,h/b.length,d]):w[i]=[e,t,s,h/b.length,d]}for(let e=0;e<u.length;e++)if("germline"==i)w[e].sort(((e,t)=>e[3]-t[3]));else if(w[e].sort(((e,t)=>e[3]-t[3])),"both"==i&&(v[e].sort(((e,t)=>e[3]-t[3])),v[e][0][3]>w[e][0][3])){let t=w[e].filter((t=>t[0]!=v[e][0][0]&&t[1]<=v[e][0][1]));w[e]=[v[e][0]].push(...t)}for(let e=0;e<u.length;e++)w[e][0][0],w[e][0][0],u[e],this.globalMean,xm.t_test_1_sample(this.globalMean,u[e],f[e],g[e])}return{binScore:this.formatDataStructure(this.wigFeatures,"binScore",this.globalMean),segment_score:this.formatDataStructure(this.wigFeatures,"segment_score",this.globalMean)}}formatDataStructure(e,t,i=1){const n=[];for(const[r,s]of Object.entries(e))s.forEach((e=>{var r={...e};1!=i&&(r.value=e[t]/i*2),n.push(r)}));return n}formatDataStructure_BAF(e,t=2){const i=[],n=[];for(const[t,r]of Object.entries(this.wigFeatures))r.forEach((t=>{var r={...t},s={...t};let o=t[e];.5!=o&&(s.value=-2*(1-o),n.push(s)),r.value=-2*o,i.push(r)}));return[i,n]}};function Lm(e){for(var t=1,i=1,n=1*e,r=1;r<50;r++)t*=r,n+=(i*=-1)*Math.pow(e,2*r+1)/(t*(2*r+1));return 2*n/Math.sqrt(3.14159265358979)}function Im(e,t,i,n,r){var s=new Nm(i.slice(n,r));return 0==s.std&&(s.std=t>0?t*s.mean/e:1),Om(e,s.mean,s.std,r-n)/(r-n)}function Bm(e,t,i,n,r){var s=new Nm(i.slice(n,r));if(s.mean<e){var o=(s.max-s.mean)/(t*Math.sqrt(2));return Math.pow(.5*(1+Lm(o)),r-n)}o=(s.min-s.mean)/(t*Math.sqrt(2));return Math.pow(.5*(1-Lm(o)),r-n)}function Fm(e,t,i,n,r,s,o=1e3){for(var a=Im(e,t,i,n,r),l=0,h=!1;a>s&!h&l<o;){h=!0,l+=1;var[c,d,u,f]=[1e10,1e10,1e10,1e10];if(n>0&&(c=Im(e,t,i,n-1,r)),r-n>2)var d=Im(e,t,i,n+1,r),u=Im(e,t,i,n,r-1);if(r<i.length)var f=Im(e,t,i,n,r+1);Math.min[f]<a&&(h=!1,c==Math.min[f]&&(n-=1,a=c),elif(d==Math.min[f]),n+=1,a=d,elif(u==Math.min[f]),r-=1,a=u,elif(f==Math.min[f]),r+=1,a=f)}return a<=s?r:0}class Nm{constructor(e){this.data=e,this.mean=e.reduce(((e,t)=>e+t))/e.length,this.std=Math.sqrt(e.reduce(((e,t)=>(t-this.mean)**2))/e.length)}}function Om(e,t,i,n){0==i&&(i=1);var r=(e-t)/i*Math.sqrt(n);return 1-xm.TdistributionCDF(Math.abs(r),n-1)}function Pm(e,t,i,n,r,s){0==t&&(t=1),0==r&&(r=1);var o=(e-n)/Math.sqrt(t**2/i+r**2/s),a=(t**2/i+r**2/s)**2*(i-1)*(s-1)/(t**4*(s-1)/i**2+r**4*(i-1)/s**2);return 1-xm.TdistributionCDF(Math.abs(o),parseInt(a+.5))}var Dm=class{constructor(e,t,i){this.rd=e,this.mean=t,this.std=i,this.bin_bands=[2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128]}get_rd_signal_bandwidth(e){var t=[];return e.forEach(((e,i)=>{var n=0;n=e>this.mean/4?this.mean/(this.std**2*e):4/this.std**2,t.push(n)})),t}meanShiftCaller(e=3){var t={};return Object.entries(this.rd).forEach((([i,n])=>{var r=new Array(n.length).fill(!1),s=new Array(n.length);for(let e=0;e<n.length;e++)r[e]||(s[e]=n[e]);this.bin_bands.forEach(((t,i)=>{var o=r.map(((e,t)=>!e)),a=[];Object.entries(n).forEach((([e,t])=>{a.push(t.binScore)}));var l=[0],h=0;for(let e=0;e<r.length;e++)r[e]?h>0&&(l.push(l[l.length-1]+h-1),h=0):h+=1;l.shift();for(let i=0;i<e;i++){var c=this.get_rd_signal_bandwidth(a),d=new Array(a.length).fill(0);for(let e=0;e<a.length;e++)for(let i=e-3*t;i<=e+3*t+1;i++)if(!(i<0||i>=a.length||Math.abs(e-i)>=a.length)){var u=(i-e)*Math.exp(-.5*(i-e)**2/t**2)*Math.exp(-.5*(a[e]-a[i])**2*c[e]);d[e]+=u}for(var f=new Array,p=0;p<d.length-1;p++)d[p]<0&d[p+1]>=0&&f.push(p);f.push(d.length-1),f=f.concat(l).sort(((e,t)=>e-t)),f=Array.from(new Set(f));var g=0;for(p=0;p<f.length;p++){var m=a.slice(g,f[p]+1),b=m.reduce(((e,t)=>e+t))/m.length;a.fill(b,g,f[p]+1),g=f[p]+1}}p=0;for(var w=0;p<s.length;p++)o[p]&&(s[p]=a[w],w++);for(f=new Array,p=0;p<s.length-1;p++){Math.abs(s[p+1]-s[p])>.01&&f.push(p+1)}f.unshift(0),f.push(s.length),r=new Array(this.rd.length).fill(!1);for(p=1;p<f.length;p++){var v=[f[p-1],f[p]],y=[f[p-1],f[p-1]];if(!(p>1))continue;y[0]=f[p-2];var _=[f[p],f[p]];if(!(p<f.length-1))continue;_[1]=f[p+1];var x=v[1]-v[0],k=y[1]-y[0],C=_[1]-_[0];if(x<=1)continue;var S=new Nm(s.slice(v[0],v[1]));if(C<=15||k<=15||x<=15){var A=1.8*Math.sqrt(s[y[0]]/this.mean)*this.std;if(Math.abs(s[y[0]]-s[v[0]])<A)continue;if(A=1.8*Math.sqrt(s[_[0]]/this.mean)*this.std,Math.abs(s[_[0]]-s[v[0]])<A)continue}else{var E=s.slice(y[0],y[1]),M=new Nm(E),T=s.slice(_[0],_[1]),R=new Nm(T);if(Pm(S.mean,S.std,S.data.length,M.mean,M.std,M.data.length)>.01/genome_size*bin_size*(x+k))continue;if(Pm(S.mean,S.std,S.data.length,R.mean,R.std,R.data.length)>.01/genome_size*bin_size*(x+C))continue}if(Om(this.mean,S.mean,S.std,S.data.length)>.05)continue;let e=a.slice(v[0],v[1]);var L=new Nm(e);r.fill(!0,v[0],v[1]),s.fill(L.mean,v[0],v[1])}})),t[i]=s})),t}call_mean_shift(e=3){for(var t=new Array(this.rd.length).fill(!1),i=new Array(this.rd.length),n=0;n<this.rd.length;n++)t[n]||(i[n]=this.rd[n]);return this.bin_bands.forEach(((n,r)=>{var s=t.map(((e,t)=>!e)),o=[];s.forEach(((e,t)=>{e&&o.push(this.rd[t])}));for(var a=[0],l=0,h=0;h<t.length;h++)t[h]?l>0&&(a.push(a[a.length-1]+l-1),l=0):l+=1;a.shift();for(var c=0;c<e;c++){var d=this.get_rd_signal_bandwidth(o),u=new Array(o.length).fill(0);for(h=0;h<o.length;h++)for(var f=h-3*n;f<=h+3*n+1;f++)if(!(f<0||f>=o.length||Math.abs(h-f)>=o.length)){var p=(f-h)*Math.exp(-.5*(f-h)**2/n**2)*Math.exp(-.5*(o[h]-o[f])**2*d[h]);u[h]+=p}var g=new Array;for(h=0;h<u.length-1;h++)u[h]<0&u[h+1]>=0&&g.push(h);g.push(u.length-1),g=g.concat(a).sort(((e,t)=>e-t)),g=Array.from(new Set(g));var m=0;for(h=0;h<g.length;h++){var b=o.slice(m,g[h]+1),w=b.reduce(((e,t)=>e+t))/b.length;o.fill(w,m,g[h]+1),m=g[h]+1}}for(h=0,f=0;h<i.length;h++)s[h]&&(i[h]=o[f],f++);for(g=new Array,h=0;h<i.length-1;h++){Math.abs(i[h+1]-i[h])>.01&&g.push(h+1)}g.unshift(0),g.push(i.length),t=new Array(this.rd.length).fill(!1);for(h=1;h<g.length;h++){var v=[g[h-1],g[h]],y=[g[h-1],g[h-1]];if(h>1){y[0]=g[h-2];var _=[g[h],g[h]];if(h<g.length-1){_[1]=g[h+1];var x=v[1]-v[0],k=y[1]-y[0],C=_[1]-_[0];if(!(x<=1)){var S=new Nm(i.slice(v[0],v[1]));if(C<=15||k<=15||x<=15){var A=1.8*Math.sqrt(i[y[0]]/this.mean)*this.std;if(Math.abs(i[y[0]]-i[v[0]])<A)continue;if(A=1.8*Math.sqrt(i[_[0]]/this.mean)*this.std,Math.abs(i[_[0]]-i[v[0]])<A)continue}else{var E=i.slice(y[0],y[1]),M=new Nm(E),T=i.slice(_[0],_[1]),R=new Nm(T);if(Pm(S.mean,S.std,S.data.length,M.mean,M.std,M.data.length)>3.483106931382794e-9*(x+k))continue;if(Pm(S.mean,S.std,S.data.length,R.mean,R.std,R.data.length)>3.483106931382794e-9*(x+C))continue}if(!(Om(this.mean,S.mean,S.std,S.data.length)>.05)){var L=new Nm(this.rd.slice(v[0],v[1]));t.fill(!0,v[0],v[1]),i.fill(L.mean,v[0],v[1])}}}}}})),i}cnv_calling(e=1e5){var t=(t=.25)*this.mean,i=this.mean-t,n=this.mean+t,r=2971e6,s=this.meanShiftCaller(),o={},a=[];return Object.entries(s).forEach((([l,h])=>{for(var c=!1;!c;){c=!0;var d=new Array(1).fill(0);for(let e=0;e<h.length-1;e++){Math.abs(h[e+1]-h[e])>.01&&d.push(e+1)}d.push(h.length);for(let e=0;e<d.length-2;e++){var u=Math.abs(h[d[e]]-h[d[e+1]]);if(u<t){var f=u+1,p=u+1;if(e>0&&(f=Math.abs(h[d[e]]-h[d[e-1]])),e<d.length-3&&(p=Math.abs(s[d[e+1]]-h[d[e+2]])),u<f&&u<p){c=!1;var g=new Nm(h.slice(d[e],d[e+2]));h.fill(g.mean,d[e],d[e+2]),d.splice(e+1,e+1)}}}}var m=[];Object.entries(this.rd[l]).forEach((([e,t])=>{m.push(t.binScore)}));for(var b,w=new Array(h.length).fill(""),v=0,y=.05*e/r;v<h.length;){for(var _=v,x=v;v<h.length&h[v]<i;)v+=1;if((C=v)>x+1){var k=Fm(this.mean,this.std,m,x,C,y);if(k){var C=k;w.fill("D",x,C)}}for(x=v;v<h.length&h[v]>n;)v+=1;(C=v)>x+1&&(k=Fm(this.mean,this.std,m,x,C,y))&&(C=k,w.fill("A",x,C)),v==_&&(v+=1)}for(v=0;v<h.length;){for(;v<h.length&""!=w[v];)v+=1;for(x=v;v<h.length&h[v]<i;)v+=1;(C=v)>x+1&&(Bm(this.mean,this.std,m,x,C)<1682935038707506e-26&&w.fill(["d"]*(C-x),x,C),v-=1),v+=1}(v=0)<h.length&&(b=w[v]),x=0;for(var S=[...m];v<h.length;){for(;w[v]==b&&!((v+=1)>=w.length););if(v>x){var A=new Nm(S.slice(x,v));S.fill(A.mean,x,v)}v<h.length&&(b=w[v]),x=v}for(o[l]=S,v=0;v<h.length;){if(""==(b=w[v])){v+=1;continue}for(x=v;v<h.length&b==w[v];)v+=1;let t,i=new Nm(S.slice(x,v)).mean/this.mean;t="D"==b?"deletion":"duplication";let n={chr:l,start:e*x+1,end:e*v,size:e*(v-x+1),value:2*i,event_type:t};a.push(n)}})),[o,a]}};class zm{constructor(e,t){this.allVariants=e,this.rowBinSize=1e4,this.binSize=t,this.binFactor=t/this.rowBinSize}async computeDepthFeatures(){const e=Object.keys(this.allVariants),t=[];for(let i of e){const e=this.allVariants[i];if(0===e.length)continue;const n=e[0];let r=0,s=0,o=n.start=n.start%this.binSize,a=o+this.binSize,l=0;for(let n of e){const e=n.start+1;l=Math.max(Math.floor((n.start-1)/this.binSize),0),e>a&&(s>0&&t.push({chr:i,start:o,end:a,value:r,bin:l,count:s}),r=0,o=n.start-n.start%this.binSize,a=o+this.binSize);const h=n.calls[9].info.DP;h&&(r+=Number.parseInt(h),s++)}s>0&&t.push({chr:i,start:o,end:a,value:r,bin:l,count:s})}return t}async computeReadDepth(){const e=Object.keys(this.allVariants);var t={};for(let n of e){const e=this.allVariants[n];var i;if(0!==e.length)for(let r of e){i=Math.max(Math.floor(r.start/this.rowBinSize),0),t[n]||(t[n]=[]),t[n][i]||(t[n][i]={chr:n,start:i*this.rowBinSize,end:(i+1)*this.rowBinSize,value:0,sum_score:0,count:0});const e=r.calls[9].info.DP;e&&(t[n][i].sum_score+=Number.parseInt(e),t[n][i].count++)}}var n={};for(let i of e){n[i]||(n[i]=[]);for(let e=0;e<t[i].length/this.binFactor;e++){const o=e;n[i][e]||(n[i][e]={chr:i,binScore:0,start:o*this.binSize,end:(o+1)*this.binSize});for(var r=10*e;r<10*e+10;r++)if(t[i][r]){var s=100*parseInt(t[i][r].sum_score/t[i][r].count);n[i][e].binScore+=s}}}return this.readDepthMeanshift(n)}readDepthMeanshift(e){var t=new gm.GetFit(e),[i,n]=t.fit_data(),r=new Dm(e,i,n),s=r.meanShiftCaller(),o=r.cnv_calling();return Object.entries(e).forEach((([e,t])=>{t.forEach(((t,i)=>{t.partition_level=parseInt(s[e][i]),t.partition_call=parseInt(o[0][e][i])}))})),[this.formatDataStructure(e,"binScore",i),this.formatDataStructure(e,"partition_level",i),this.formatDataStructure(e,"partition_call",i),o[1]]}formatDataStructure(e,t,i=1){const n=[];for(const[r,s]of Object.entries(e))s.forEach((e=>{var r={...e};1!=i&&(r.value=e[t]/i*2),n.push(r)}));return n}async computeBAF_v2(){const e=Object.keys(this.allVariants),t={},i=[],n=[];for(let o of e){const e=this.allVariants[o];if(0===e.length)continue;var r;for(let a of e){if(r=Math.max(Math.floor(a.start/this.binSize),0),t[o]||(t[o]=[]),!t[o][r]){if(r>0){let e=r-1;if(t[o][e]){const r=this.get_max_min_score(t[o][e]);if(.5!=r.value){let e=Object.assign({},r);e.value=-2*(1-r.value),n.push(e)}r.value=-2*r.value,t[o][e]=r,i.push(t[o][e])}}t[o][r]={chr:o,start:r*this.binSize,end:(r+1)*this.binSize,value:0,count:0,likelihood_score:[],min_score:0}}const e=a.calls[9];let l=e.genotype,h=e.info.AD.split(","),c=h[0],d=h[1];if(0==l[0]&&1==l[1]||1==l[0]&&0==l[1]){if(0==t[o][r].likelihood_score.length)t[o][r].likelihood_score=gm.linspace(0,1,100).map(((e,t)=>Hm(c,d,e)));else{var s=0;t[o][r].likelihood_score=gm.linspace(0,1,100).map(((e,i)=>{var n=t[o][r].likelihood_score[i]*Hm(c,d,e);return s+=n,n})),t[o][r].likelihood_score=gm.linspace(0,1,100).map(((e,i)=>t[o][r].likelihood_score[i]/s))}t[o][r].count++}}const a=this.get_max_min_score(t[o][r]);if(.5!=a.value){let e=Object.assign({},a);e.value=-2*(1-a.value),n.push(e)}a.value=-2*a.value,t[o][r]=a,i.push(t[o][r])}return[i,n]}format_BAF_likelihood(e){const t=[];for(const[i,n]of Object.entries(e))n.forEach((e=>{var i={...e};.5!=e.value&&(i.value=1-e.value,t.push(i))}));return t}get_max_min_score(e){if(e.likelihood_score.length>0){const t=Math.max(...e.likelihood_score),i=e.likelihood_score.indexOf(t);e.value=Math.max(i/100,1-i/100),e.min_score=Math.min(i/100,1-i/100)}else e.score=0;return e}async getAllbins(){const e=await this.computeDepthFeatures();return new gm.GetFit(e).fit_data(),e}async read_rd_baf(e="ReadDepth"){const t=Object.keys(this.allVariants);var i={};for(let e of t){const t=this.allVariants[e];var n;if(0!==t.length)for(let r of t){n=Math.max(Math.floor(r.start/this.rowBinSize),0),i[e]||(i[e]=[]),i[e][n]||(i[e][n]={chr:e,start:n*this.rowBinSize,end:(n+1)*this.rowBinSize,dp_sum_score:0,dp_count:0,hets_count:0,hets:[]});const t=r.calls[9],s=t.info.DP;s&&(i[e][n].dp_sum_score+=Number.parseInt(s),i[e][n].dp_count++);let o=t.info.AD.split(","),a=t.genotype;if(0==a[0]&&1==a[1]||1==a[0]&&0==a[1]){i[e][n].hets_count++;let t=parseInt(o[0]),r=parseInt(o[1]);i[e][n].hets.push({ref:t,alt:r})}}}var r,s=this.adjust_bin_size(i);if("ReadDepth"==e){r=this.readDepthMeanshift(s);var o=this.formatDataStructure_BAF(s,"max_likelihood")}else if("2D"==e){let e=new Rm(s,this.binSize),t=await e.call_2d();r=[t.binScore,[],t.segment_score];o=e.formatDataStructure_BAF("max_likelihood")}return[r,o]}formatDataStructure_BAF(e,t,i=2){const n=[],r=[];for(const[i,s]of Object.entries(e))s.forEach((e=>{delete e.likelihood_score;var i={...e},s={...e};let o=e[t];.5!=o&&(s.value=-2*(1-o),r.push(s)),i.value=-2*o,n.push(i)}));return[n,r]}adjust_bin_size(e){const t=Object.keys(this.allVariants);var i={};for(let s of t){i[s]||(i[s]=[]);for(let t=0;t<e[s].length/this.binFactor;t++){const o=t;i[s][t]||(i[s][t]={chr:s,start:o*this.binSize,end:(o+1)*this.binSize,dp_count:0,hets_count:0,binScore:0,likelihood_score:[]});for(var n=10*t;n<10*t+10;n++)if(e[s][n]){var r=100*parseInt(e[s][n].dp_sum_score/e[s][n].dp_count);i[s][t].binScore+=r,i[s][t].dp_count+=e[s][n].dp_count,i[s][t].hets_count+=e[s][n].hets_count,0!=e[s][n].hets.length&&e[s][n].hets.forEach(((e,n)=>{if(0==i[s][t].likelihood_score.length)i[s][t].likelihood_score=gm.linspace(0,1,100).map(((t,i)=>Hm(e.ref,e.alt,t)));else{var r=0;i[s][t].likelihood_score=gm.linspace(0,1,100).map(((n,o)=>{var a=i[s][t].likelihood_score[o]*Hm(e.ref,e.alt,n);return r+=a,a})),i[s][t].likelihood_score=gm.linspace(0,1,100).map(((e,n)=>i[s][t].likelihood_score[n]/r))}}))}const a=this.get_max_min_score(i[s][t]);i[s][t].max_likelihood=a.value}}return i}}function Hm(e,t,i,n=!0){return i**e*(1-i)**t+i**t*(1-i)**e}class Vm extends Ll{constructor(e,t){super(e,t),this.featureType="numeric",this.paintAxis=dd,e.max||(this.defaultScale=!0,this.autoscale=!1),this.height=void 0!==e.height?e.height:250}async init(e){this.type="cnvpytor",this.graphType=e.graphType||"points",this.bin_size=e.bin_size||1e5,this.signal_name=e.signal_name||"rd_snp",this.cnv_caller=e.cnv_caller||"2D",this.colors=e.colors||["gray","black","green","blue"],super.init(e)}get supportsWholeGenome(){return!0}get_signals(){let e=[];return"rd_snp"==this.signal_name?e=["RD_Raw","RD_Raw_gc_coor",this.cnv_caller,"BAF1","BAF2"]:"rd"==this.signal_name?e=["RD_Raw","RD_Raw_gc_coor",this.cnv_caller]:"snp"==this.signal_name?e=["BAF1","BAF2"]:"cnh"==this.signal_name&&(e=[this.cnv_caller]),e}get_signal_colors(){return[{singal_name:"RD_Raw",color:this.colors[0]},{singal_name:"RD_Raw_gc_coor",color:this.colors[1]},{singal_name:"ReadDepth",color:this.colors[2]},{singal_name:"2D",color:this.colors[2]},{singal_name:"BAF1",color:this.colors[3]},{singal_name:"BAF2",color:this.colors[3]}]}async postInit(){if("vcf"==this.config.format){this.featureSource=dc(this.config,this.browser.genome),this.header=await this.getHeader();var e=this.featureSource.reader.features.reduce((function(e,t){return e[t.chr]=e[t.chr]||[],e[t.chr].push(t),e}),Object.create(null));const t=new zm(e,this.bin_size);let i,n,r;this.wigFeatures_obj={},this.wigFeatures_obj[this.bin_size]={},"2D"==this.config.cnv_caller?(r=await t.read_rd_baf("2D"),i=r[0],n=r[1],this.wigFeatures_obj[this.bin_size]["2D"]=i[2],this.available_callers=["2D"]):(r=await t.read_rd_baf(),i=r[0],n=r[1],this.wigFeatures_obj[this.bin_size].ReadDepth=i[2],this.available_callers=["ReadDepth"]),this.wigFeatures_obj[this.bin_size].RD_Raw=i[0],this.wigFeatures_obj[this.bin_size].RD_Raw_gc_coor=i[1],this.wigFeatures_obj[this.bin_size].BAF1=n[0],this.wigFeatures_obj[this.bin_size].BAF2=n[1],this.available_bins=[this.bin_size],this.set_available_callers()}else this.cnvpytor_obj=new um(this.config.url,this.bin_size),this.wigFeatures_obj=await this.cnvpytor_obj.get_rd_signal(this.bin_size),this.available_bins=this.cnvpytor_obj.available_bins,this.available_callers=this.cnvpytor_obj.callers,this.set_available_callers();this.tracks=[];const t=[];this.signals=this.get_signals(),this.signal_colors=this.get_signal_colors();for(let e in this.wigFeatures_obj)for(const[i,n]of Object.entries(this.wigFeatures_obj[e]))if(this.signals.includes(i)){let e={type:"wig",isMergedTrack:!0};e.features=n,e.name=i,e.color=this.signal_colors.filter((e=>e.singal_name===i)).map((e=>e.color));const r=await this.browser.createTrack(e);r?(r.autoscale=!1,this.tracks.push(r)):console.warn("Could not create track "+e),"function"==typeof r.postInit&&t.push(r.postInit())}this.flipAxis=!!this.config.flipAxis&&this.config.flipAxis,this.logScale=!!this.config.logScale&&this.config.logScale,this.autoscale=this.config.autoscale,this.autoscale||(this.dataRange={min:this.config.min||0,max:this.config.max});for(let e of this.tracks)e.autoscale=!1,e.dataRange=this.dataRange;return Promise.all(t)}set_available_callers(){this.available_callers.includes(this.cnv_caller)||(this.available_callers.length>0?this.cnv_caller=this.available_callers[0]:this.cnv_caller=null)}async getHeader(){if(!this.header){if("function"==typeof this.featureSource.getHeader){const e=await this.featureSource.getHeader();e&&(this.callSets=e.callSets||[]),this.header=e}this.sampleNames=this.callSets?this.callSets.map((e=>e.name)):[]}return this.header}get height(){return this._height}set height(e){if(this._height=e,this.tracks)for(let t of this.tracks)t.height=e,t.config.height=e}menuItemList(){let e=[];void 0!==this.flipAxis&&e.push({label:"Flip y-axis",click:()=>{this.flipAxis=!this.flipAxis,this.trackView.repaintViews()}}),e=e.concat($t.numericDataMenuItems(this.trackView)),e.push("<hr/>"),e.push("Bin Sizes");for(let t of this.available_bins){const i=jt(t,t===this.bin_size);e.push({object:ft(i),click:async()=>{this.bin_size=t,await this.recreate_tracks(t),this.clearCachedFeatures(),this.trackView.updateViews(),this.trackView.repaintViews()}})}e.push("<hr/>"),e.push("Signal Type");let t={rd_snp:"RD and BAF Likelihood",rd:"RD Signal",snp:"BAF Likelihood"};for(let i in t){const n=jt(t[i],i===this.signal_name);e.push({object:ft(n),click:async()=>{this.signal_name=i,await this.recreate_tracks(this.bin_size),this.clearCachedFeatures(),this.trackView.updateViews(),this.trackView.repaintViews()}})}e.push("<hr/>"),e.push("CNV caller");for(let t of this.available_callers){const i=jt(t,t===this.cnv_caller);e.push({object:ft(i),click:async()=>{this.cnv_caller=t,await this.recreate_tracks(this.bin_size),this.clearCachedFeatures(),this.trackView.updateViews(),this.trackView.repaintViews()}})}return e}async recreate_tracks(e){this.tracks=[];const t=[];e in this.wigFeatures_obj||(this.wigFeatures_obj={...this.wigFeatures_obj,...await this.cnvpytor_obj.get_rd_signal(e)}),this.signals=this.get_signals(),this.signal_colors=this.get_signal_colors();for(const[i,n]of Object.entries(this.wigFeatures_obj[e]))if(this.signals.includes(i)){let e={type:"wig",isMergedTrack:!0};e.features=n,e.name=i,e.color=this.signal_colors.filter((e=>e.singal_name===i)).map((e=>e.color));const r=await this.browser.createTrack(e);r?(r.autoscale=!1,this.tracks.push(r)):console.warn("Could not create track "+e),"function"==typeof r.postInit&&t.push(r.postInit())}this.flipAxis=!!this.config.flipAxis&&this.config.flipAxis,this.logScale=!!this.config.logScale&&this.config.logScale,this.autoscale=this.config.autoscale,this.autoscale||(this.dataRange={min:this.config.min||0,max:this.config.max});for(let e of this.tracks)e.autoscale=!1,e.dataRange=this.dataRange;return Promise.all(t)}async getFeatures(e,t,i,n){if(this.tracks){const r=this.tracks.map((r=>r.getFeatures(e,t,i,n)));return Promise.all(r)}}getScaleFactor(e,t,i,n){return n?i/(Math.log10(t+1)-(e<=0?0:Math.log10(e+1))):i/(t-e)}computeYPixelValue(e,t){return(this.flipAxis?e-this.dataRange.min:this.dataRange.max-e)*t}computeYPixelValueInLogScale(e,t){let i=this.dataRange.max,n=this.dataRange.min;return i<=0?0:(n<=-1&&(n=0),n=n<=0?0:Math.log10(n+1),i=Math.log10(i+1),e=Math.log10(e+1),(this.flipAxis?e-n:i-e)*t)}draw(e){const t=e.features;if(!t)return;if(this.defaultScale&&("rd_snp"==this.signal_name?this.dataRange={min:this.config.min||this.dataRange.min||-2,max:this.config.max||this.dataRange.max||6}:"rd"==this.signal_name?this.dataRange={min:this.config.min||this.dataRange.min||0,max:this.config.max||this.dataRange.max||6}:"snp"==this.signal_name&&(this.dataRange={min:this.config.min||this.dataRange.min||-2,max:this.config.max||this.dataRange.max||0})),this.autoscale&&(this.dataRange=function(e,t){let i=0,n=-Number.MAX_VALUE;for(let e of t)for(let t of e)void 0===t.value||Number.isNaN(t.value)||(i=Math.min(i,t.value),n=Math.max(n,t.value));return{min:i,max:n}}(e.referenceFrame.chr,t)),this.tracks)for(let i=0,n=this.tracks.length;i<n;i++){const n=Object.assign({},e);n.features=t[i],this.tracks[i].dataRange=this.dataRange,this.tracks[i].flipAxis=this.flipAxis,this.tracks[i].logScale=this.logScale,this.graphType&&(this.tracks[i].graphType=this.graphType),this.tracks[i].draw(n)}const i=this.getScaleFactor(this.dataRange.min,this.dataRange.max,e.pixelHeight,this.logScale),n=e=>this.logScale?this.computeYPixelValueInLogScale(e,i):this.computeYPixelValue(e,i);if(this.config.hasOwnProperty("guideLines"))for(let t of this.config.guideLines)if(t.hasOwnProperty("color")&&t.hasOwnProperty("y")&&t.hasOwnProperty("dotted")){let i=n(t.y),r={strokeStyle:t.color,strokeWidth:1};t.dotted?Co.dashedLine(e.context,0,i,e.pixelWidth,i,5,r):Co.strokeLine(e.context,0,i,e.pixelWidth,i,r)}}popupData(e,t){const i=t||e.viewport.cachedFeatures;if(i&&i.length===this.tracks.length){const t=[];for(let n=0;n<this.tracks.length;n++){n>0&&t.push("<hr/>"),t.push(`<div style=background-color:rgb(245,245,245);border-bottom-style:dashed;border-bottom-width:1px;padding-bottom:5px;padding-top:10px;font-weight:bold;font-size:larger >${this.tracks[n].name}</div>`);const r=this.tracks[n].popupData(e,i[n]);t.push(...r)}return t}}}const Um=new Map([["ideogram",(e,t)=>new of(e,t)],["sequence",(e,t)=>new ba(e,t)],["feature",(e,t)=>new tu(e,t)],["seg",(e,t)=>new Nu(e,t)],["mut",(e,t)=>new Nu(e,t)],["maf",(e,t)=>new Nu(e,t)],["wig",(e,t)=>new Lu(e,t)],["merged",(e,t)=>new Pu(e,t)],["alignment",(e,t)=>new du(e,t)],["interaction",(e,t)=>new zu(e,t)],["interact",(e,t)=>new zu(e,t)],["variant",(e,t)=>new Zu(e,t)],["eqtl",(e,t)=>new Xu(e,t)],["gwas",(e,t)=>new Ju(e,t)],["arc",(e,t)=>new nf(e,t)],["gcnv",(e,t)=>new ef(e,t)],["junction",(e,t)=>new cf(e,t)],["blat",(e,t)=>new au(e,t)],["cnvpytor",(e,t)=>new Vm(e,t)]]),qm=function(e,t){Um.set(e,t)};var jm=qm,$m=function(e,t,i){let n;switch(e){case"annotation":case"genes":case"fusionjuncspan":case"snp":n="feature";break;case"seg":case"maf":case"mut":n="seg";break;case"junctions":case"splicejunctions":n="junction";break;default:n=e}return Um.has(n)?Um.get(n)(t,i):void 0};class Wm{constructor(e,t){const i=(new DOMParser).parseFromString(e,"text/xml");this.processRootNode(i,t);const n=i.getElementsByTagName("Resource"),r=i.getElementsByTagName("Track"),s=r&&r.length>0,o=[];this.tracks=o;const a=new Map;Array.from(n).forEach((function(e,t){var i={url:e.getAttribute("path"),indexURL:e.getAttribute("index"),order:t};a.set(i.url,i),s||o.push(i)})),s&&Array.from(r).forEach((function(e){const t=e.getElementsByTagName("Track");if(t&&t.length>0){const i={type:"merged",tracks:[]};Gm(e,i),o.push(i),Array.from(t).forEach((function(e){e.processed=!0;const t=e.getAttribute("id"),n=a.get(t);n&&(i.tracks.push(n),Gm(e,n),n.autoscale=!1,i.height=n.height)}))}else if(!e.processed){const t=e.getAttribute("id"),i=a.get(t);i&&(o.push(i),Gm(e,i))}}))}processRootNode(e,t){const i=e.getElementsByTagName("Session");!i||i.length;const n=i.item(0),r=n.getAttribute("genome"),s=n.getAttribute("locus"),o=n.getAttribute("ucscID");t&&t.hasOwnProperty(r)?this.genome=r:(this.reference={fastaURL:r},o&&(this.reference.id=o)),s&&(this.locus=s)}}function Gm(e,t){t.name=e.getAttribute("name");const i=e.getAttribute("color");i&&(t.color="rgb("+i+")");const n=e.getAttribute("altColor");i&&(t.altColor="rgb("+n+")");const r=e.getAttribute("height");r&&(t.height=parseInt(r));const s=e.getAttribute("autoScale");s&&(t.autoscale="true"===s);const o=e.getAttribute("autoscaleGroup");o&&(t.autoscaleGroup=o);const a=e.getAttribute("windowFunction");a&&(t.windowFunction=a);const l=e.getAttribute("visibilityWindow")||e.getAttribute("featureVisibilityWindow");l&&(t.visibilityWindow=l);const h=e.getAttribute("indexed");h&&(t.indexed="true"===h);const c=e.getAttribute("normalize");c&&(t.normalize="true"===c);const d=e.getElementsByTagName("DataRange");if(d.length>0){const e=d.item(0);t.min=Number(e.getAttribute("minimum")),t.max=Number(e.getAttribute("maximum")),t.logScale="LOG"===e.getAttribute("type")}}const Zm=Yt;class Qm{constructor(){this.attributes={},this.plinkLoaded=!1}async loadPlinkFile(e,t){t||(t={});var i=To(t);const n=await no.loadString(e,i);var r=Zm(n);for(let e of r){var s=e.split(" ");this.attributes[s[1]]={familyId:s[0],fatherId:s[2],motherId:s[3],sex:s[4],phenotype:s[5]}}return this.plinkLoaded=!0,this}getAttributes(e){return this.attributes[e]}getAttributeNames(){return this.hasAttributes()?Object.keys(this.attributes[Object.keys(this.attributes)[0]]):[]}hasAttributes(){return Object.keys(this.attributes).length>0}}class Xm{constructor(e,t){this.geneColors={},this.gene=null,this.snp=null,this.genesCount=0,e&&(this.gene=e.toUpperCase(),this.geneColors[this.gene]=Ym[this.genesCount++]),t&&(this.snp=t.toUpperCase())}addGene(e){this.geneColors[e.toUpperCase()]||(this.geneColors[e.toUpperCase()]=Ym[this.genesCount++])}colorForGene(e){return this.geneColors[e.toUpperCase()]}}var Ym=[];Ym.push("rgb(228,26,28)"),Ym.push("rgb(55,126,184)"),Ym.push("rgb(77,175,74)"),Ym.push("rgb(166,86,40)"),Ym.push("rgb(152,78,163)"),Ym.push("rgb(255,127,0)"),Ym.push("rgb(247,129,191)"),Ym.push("rgb(153,153,153)"),Ym.push("rgb(255,255,51)"),Ym.push("rgb(102, 194, 165"),Ym.push("rgb(252, 141, 98"),Ym.push("rgb(141, 160, 203"),Ym.push("rgb(231, 138, 195"),Ym.push("rgb(166, 216, 84"),Ym.push("rgb(255, 217, 47"),Ym.push("rgb(229, 196, 148"),Ym.push("rgb(179, 179, 179"),Ym.push("rgb( 141, 211, 199"),Ym.push("rgb(255, 255, 179"),Ym.push("rgb(190, 186, 218"),Ym.push("rgb(251, 128, 114"),Ym.push("rgb(128, 177, 211"),Ym.push("rgb(253, 180, 98"),Ym.push("rgb(179, 222, 105"),Ym.push("rgb(252, 205, 229"),Ym.push("rgb(217, 217, 217"),Ym.push("rgb(188, 128, 189"),Ym.push("rgb(204, 235, 197"),Ym.push("rgb(255, 237, 111");class Km{constructor(e,t,i,n,r){this.genome=e,this.chr=t,this.start=i,this.end=n,this.bpPerPixel=r,this.id=_t.guid()}extend(e){const t=Math.min(e.start,this.start),i=Math.max(e.end,this.end),n=(i-t)/(this.end-this.start);this.start=t,this.end=i,this.bpPerPixel*=n}calculateEnd(e){return this.start+this.bpPerPixel*e}calculateBPP(e,t){return(e-this.start)/t}set(e){this.chr=e.chr,this.start=e.start,this.bpPerPixel=e.bpPerPixel}toPixels(e){return e/this.bpPerPixel}toBP(e){return this.bpPerPixel*e}shiftPixels(e,t,i){const n=this.start,r=e*this.bpPerPixel;return this.start+=r,i&&this.clampStart(t),this.end=this.start+t*this.bpPerPixel,n!==this.start}clampStart(e){const t=this.genome.getChromosome(this.chr).bpStart||0;if(this.start=Math.max(t,this.start),e){const{bpLength:t}=this.genome.getChromosome(this.chr),i=t-e*this.bpPerPixel;this.start>i&&(this.start=i)}}async zoomWithScaleFactor(e,t,i,n){const r=void 0===n?this.start+this.toBP(i/2):n,{start:s,bpPerPixel:o}=this.start,{bpLength:a}=this.getChromosome(),l=t<1?e.minimumBases()/i:a/i;this.bpPerPixel=t<1?Math.max(this.bpPerPixel*t,l):Math.min(this.bpPerPixel*t,l);const h=this.bpPerPixel*i;this.start=r-.5*h,this.clampStart(i),this.end=this.start+h;(s!==this.start||o!==this.bpPerPixel)&&await e.updateViews(!0)}getChromosome(){return this.genome.getChromosome(this.chr)}getMultiLocusLabelBPLengthOnly(e){const t=" ",i=Math.floor(this.start)+1,n=Math.round(this.start+this.bpPerPixel*e);return`${t}${this.chr}${t}${Bo(n-i)}${t}`}getMultiLocusLabelLocusOnly(e){const t=" ",{chr:i,start:n,end:r}=this.getPresentationLocusComponents(e);return`${t}${i}:${n}-${r}${t}`}getMultiLocusLabel(e){const t=" ",{chr:i,start:n,end:r}=this.getPresentationLocusComponents(e),s=Math.floor(this.start)+1;return`${t}${i}:${n}-${r}${t}${t}(${Bo(Math.round(this.start+this.bpPerPixel*e)-s)})${t}`}getPresentationLocusComponents(e){if("all"===this.chr)return{chr:this.chr};{const t=Xt(Math.floor(this.start)+1),i=Xt(Math.round(this.start+this.bpPerPixel*e));return{chr:this.chr,start:t,end:i}}}getLocusString(){if("all"===this.chr)return"all";{const e=Xt(Math.floor(this.start)+1),t=Xt(Math.round(this.end));return`${this.chr}:${e}-${t}`}}description(e){console.log(` ${e||""} referenceFrame - ${this.chr} bpp ${this.bpPerPixel.toFixed(3)} start ${Xt(Math.round(this.start))} end ${Xt(Math.round(this.end))} `)}}const Jm={timeout:5e3,type:"plain",url:"https://igv.org/genomes/locus.php?genome=$GENOME$&name=$FEATURE$",coords:0,chromosomeField:"chromosome",startField:"start",endField:"end",geneField:"gene",snpField:"snp"};async function eb(e,t){if(void 0===t||""===t.trim())return;(t&&"all"===t.trim().toLowerCase()||"*"===t)&&(t="all");const i=t.split(" ");let n=e.searchConfig||Jm,r=[];const s=async i=>{let r=function(e,t){const i=t.split("\t");if(i.length>=3)try{const t=e.genome.getChromosomeName(i[0]),n=parseInt(i[1].replace(/,/g,""),10)-1,r=parseInt(i[2].replace(/,/g,""),10);if(!isNaN(n)&&!isNaN(r))return{chr:t,start:n,end:r}}catch(e){}const n=t.split(":"),r=n[0];if("all"===r&&e.genome.getChromosome(r))return{chr:r,start:0,end:e.genome.getChromosome(r).bpLength};if(void 0===e.genome.getChromosome(r))return;{const t={chr:e.genome.getChromosomeName(r),start:0,end:e.genome.getChromosome(r).bpLength};if(n.length>1){let i,r=n[1].split("-");if(r.length>2){if(!n[1].startsWith("-"))return;{const e=n[1].indexOf("-",1);if(e>0){r=[n[1].substring(0,e),n[1].substring(e+1)]}}}if(i=r[0].replace(/,/g,""),isNaN(i))return;if(t.start=parseInt(i,10)-1,t.end=t.start+1,1===r.length&&(t.start-=20,t.end+=20),2===r.length){if(i=r[1].replace(/,/g,""),isNaN(i))return;if(t.end=parseInt(i,10),t.start<0&&!e.isSoftclipped()){const e=-t.start;t.start+=e,t.end+=e}}}return t}}(e,i);if(!r){const n=e.genome.featureDB.get(i.toUpperCase());n&&(r={chr:n.chr,start:n.start,end:n.end,gene:n.name,locusSearchString:t})}if(!r&&e.config&&!1!==e.config.search)try{r=await async function(e,t,i){let n=i.url.replace("$FEATURE$",t.toUpperCase());n.indexOf("$GENOME$")>-1&&(n=n.replace("$GENOME$",e.genome.id?e.genome.id:"hg19"));const r=i.timeout?{timeout:i.timeout}:void 0,s=await no.loadString(n,r),o=function(e,t,i){let n;n="plain"===i.type?function(e,t){const i=[],n=[];return Yt(t).forEach((function(e){""===e||i.push(e)})),i.forEach((function(t){var i,r,s,o,a=t.split("\t");a.length>=3&&(s=(r=a[1].split(":"))[1].split("-"),i=a[2].trim(),o={gene:a[0],chromosome:e.genome.getChromosomeName(r[0].trim()),start:parseInt(s[0].replace(/,/g,"")),end:parseInt(s[1].replace(/,/g,"")),type:"gtex"===i?"snp":"gene"},n.push(o))})),n}(e,t):JSON.parse(t);i.resultsField&&(n=n[i.resultsField]);if(n&&0!==n.length){const t=i.chromosomeField||"chromosome",r=i.startField||"start",s=i.endField||"end",o=i.coords||1;let a;a=Array.isArray(n)?n[0]:n,a.hasOwnProperty(t)&&a.hasOwnProperty(r)||console.error("Search service results must include chromosome and start fields: "+a);const l=a[t],h=e.genome.getChromosome(l);if(!h)return;const c=h.name;let d=a[r]-o,u=a[s];void 0===u&&(u=d+1);const f={chr:c,start:d,end:u},p=a.type?a.type:"gene";return i.geneField&&"gene"===p&&(f.gene=a[i.geneField]),i.snpField&&"snp"===p&&(f.snp=a[i.snpField]),f}return}(e,s,i);o&&(o.locusSearchString=t);return o}(e,i,n)}catch(e){throw console.error(e),Error("Search service currently unavailable.")}return r};for(let e of i){const t=await s(e);t&&(t.locusSearchString=e,r.push(t))}if(0===r.length){const e=await s(t);e&&(e.locusSearchString=t,r.push(e))}return 0===r.length?void 0:r}class tb{constructor(e){this.browser=e}navbarDidResize(e){this.updateNavbar(this.createResponsiveClassSchedule(e))}updateNavbar(e){this.browser.$toggle_button_container.removeClass(),this.browser.$toggle_button_container.addClass(e.$toggle_button_container),ft(this.browser.zoomWidget.zoomContainer).removeClass(),ft(this.browser.zoomWidget.zoomContainer).addClass(e.zoomContainer)}createResponsiveClassSchedule(e){let t={};const i=this.browser.isMultiLocusWholeGenomeView()||this.browser.referenceFrameList&&Ia.isWholeGenomeView(this.browser.referenceFrameList[0].chr);return i?this.browser.windowSizePanel.hide():this.browser.windowSizePanel.show(),e>990?(t.$toggle_button_container="igv-navbar-toggle-button-container",t.zoomContainer="igv-zoom-widget"):e>860?(t.$toggle_button_container="igv-navbar-toggle-button-container",t.zoomContainer="igv-zoom-widget-900"):e>540?(t.$toggle_button_container="igv-navbar-toggle-button-container-750",t.zoomContainer="igv-zoom-widget-900"):(t.$toggle_button_container="igv-navbar-toggle-button-container-750",t.zoomContainer="igv-zoom-widget-900",this.browser.windowSizePanel.hide()),i&&(t.zoomContainer="igv-zoom-widget-hidden"),t}}const ib=function(e,t){this.container=_t.div({class:"igv-chromosome-select-widget-container"}),t.appendChild(this.container),this.select=document.createElement("select"),this.select.setAttribute("name","chromosome-select-widget"),this.container.appendChild(this.select),this.select.addEventListener("change",(()=>{this.select.blur(),""!==this.select.value&&e.search(this.select.value)})),this.showAllChromosomes=!1!==e.config.showAllChromosomes};ib.prototype.show=function(){this.container.style.display="flex"},ib.prototype.hide=function(){this.container.style.display="none"},ib.prototype.update=function(e){const t=this.showAllChromosomes?e.chromosomeNames.slice():e.wgChromosomeNames.slice();e.showWholeGenomeView()&&(t.unshift("all"),t.unshift("")),this.select.innerHTML="";for(let e of t){const t=document.createElement("option");t.setAttribute("value",e),t.innerText=e,this.select.appendChild(t)}};class nb{constructor(e,t){this.container=_t.div({class:"igv-windowsize-panel-container"}),e.appendChild(this.container),t.on("locuschange",(e=>{this.updatePanel(e)})),this.browser=t}show(){this.container.style.display="block"}hide(){this.container.style.display="none"}updatePanel(e){const t=this.browser.calculateViewportWidth(this.browser.referenceFrameList.length);this.container.innerText=1===e.length?Bo(Math.round(t*e[0].bpPerPixel)):""}}class rb{constructor(e,t){this.browser=t,this.columnContainer=e,this.horizontalGuide=_t.div({class:"igv-cursor-guide-horizontal"}),e.appendChild(this.horizontalGuide),this.verticalGuide=_t.div({class:"igv-cursor-guide-vertical"}),e.appendChild(this.verticalGuide),this.addMouseHandler(t),this.setVisibility(t.config.showCursorGuide)}addMouseHandler(e){this.boundMouseMoveHandler=function(t){const{x:i,y:n}=_t.translateMouseCoordinates(t,this.columnContainer);this.horizontalGuide.style.top=`${n}px`;const r=function(e,t){for(;e.parentElement;){if(e.parentElement.classList.contains(t))return e.parentElement;e=e.parentElement}return}(document.elementFromPoint(t.clientX,t.clientY),"igv-viewport");if(r&&e.getRulerTrackView()){this.verticalGuide.style.left=`${i}px`;const n=e.root.querySelectorAll(".igv-column");let s;const o=r.parentElement;for(let e=0;e<n.length;e++)void 0===s&&o===n[e]&&(s=e);const a=e.getRulerTrackView().viewports[s].mouseMove(t);if(a){const{start:e,bp:t,end:i}=a,n=(t-e)/(i-e);this.customMouseHandler&&this.customMouseHandler({start:e,bp:t,end:i,interpolant:n})}}}.bind(this),this.columnContainer.addEventListener("mousemove",this.boundMouseMoveHandler)}removeMouseHandler(){this.columnContainer.removeEventListener("mousemove",this.boundMouseMoveHandler)}setVisibility(e){!0===e?this.show():this.hide()}show(){this.verticalGuide.style.display="block",this.horizontalGuide.style.display="block"}hide(){if(this.verticalGuide.style.display="none",this.horizontalGuide.style.display="none",this.browser.getRulerTrackView())for(let e of this.browser.getRulerTrackView().viewports)e.$tooltip.hide()}}class sb{constructor(e,t){this.browser=e,this.button=_t.div({class:"igv-navbar-button"}),t.appendChild(this.button),this.button.textContent="cursor guide",this.button.addEventListener("click",(()=>{e.cursorGuideVisible=!e.cursorGuideVisible,e.setCursorGuideVisibility(e.cursorGuideVisible),this.setButtonState(e.cursorGuideVisible)})),this.setButtonState(e.cursorGuideVisible),e.config.showCursorTrackingGuideButton?this.show():this.hide()}setButtonState(e){!0===e?this.button.classList.add("igv-navbar-button-clicked"):this.button.classList.remove("igv-navbar-button-clicked")}show(){this.button.style.display="block",this.setButtonState(this.browser.cursorGuideVisible)}hide(){this.button.style.display="none"}}class ob{constructor(e,t){this.browser=e,this.button=_t.div({class:"igv-navbar-button"}),t.appendChild(this.button),this.button.textContent="center line",this.button.addEventListener("click",(()=>{e.isCenterLineVisible=!e.isCenterLineVisible,e.setCenterLineVisibility(e.isCenterLineVisible),this.setButtonState(e.isCenterLineVisible)})),this.setButtonState(e.isCenterLineVisible),e.config.showCenterGuideButton?this.show():this.hide()}setButtonState(e){!0===e?this.button.classList.add("igv-navbar-button-clicked"):this.button.classList.remove("igv-navbar-button-clicked")}show(){this.isVisible=!0,this.button.style.display="block",this.setButtonState(this.browser.isCenterLineVisible)}hide(){this.isVisible=!1,this.button.style.display="none"}}class ab{constructor(e,t){this.button=_t.div({class:"igv-navbar-button"}),e.appendChild(this.button),this.button.textContent="track labels",this.button.addEventListener("click",(()=>{t.trackLabelsVisible=!t.trackLabelsVisible,this.setState(t.trackLabelsVisible),t.setTrackLabelVisibility(t.trackLabelsVisible)})),this.browser=t,this.setVisibility(t.config.showTrackLabelButton),this.setState(t.trackLabelsVisible)}setVisibility(e){!0===e?this.show():this.hide()}setState(e){!0===e?this.button.classList.add("igv-navbar-button-clicked"):this.button.classList.remove("igv-navbar-button-clicked")}show(){this.button.style.display="block",this.setState(this.browser.trackLabelsVisible)}hide(){this.button.style.display="none"}}class lb{constructor(e,t){this.button=_t.div({class:"igv-navbar-button"}),e.appendChild(this.button),this.button.innerText="Sample Names",this.setState(t.showSampleNames),this.setVisibility(t.showSampleNameButton),this.button.addEventListener("click",(()=>{t.showSampleNames=!t.showSampleNames,this.setState(t.showSampleNames);for(let{sampleNameViewport:e}of t.trackViews)!1===t.showSampleNames?e.hide():e.show();t.layoutChange()}))}setVisibility(e){!0===e?this.show():this.hide()}setState(e){!0===e?this.button.classList.add("igv-navbar-button-clicked"):this.button.classList.remove("igv-navbar-button-clicked")}hide(){this.button.style.display="none"}show(){this.button.style.display="block"}}let hb=23,cb=0;const db=function(e,t){this.browser=e,this.zoomContainer=_t.div({class:"igv-zoom-widget"}),t.appendChild(this.zoomContainer),this.zoomOutButton=_t.div(),this.zoomContainer.appendChild(this.zoomOutButton),this.zoomOutButton.appendChild(At.createIcon("minus-circle")),this.zoomOutButton.addEventListener("click",(()=>{e.zoomOut()}));const i=_t.div();this.zoomContainer.appendChild(i),this.slider=document.createElement("input"),this.slider.type="range",this.slider.min="0",this.slider.max=`${hb}`,i.appendChild(this.slider),this.slider.addEventListener("change",(t=>{t.preventDefault(),t.stopPropagation();const i=e.referenceFrameList[0],{bpLength:n}=i.genome.getChromosome(i.chr),{end:r,start:s}=i,o=r-s,a=n/Math.pow(2,t.target.valueAsNumber);e.zoomWithScaleFactor(a/o)})),this.zoomInButton=_t.div(),this.zoomContainer.appendChild(this.zoomInButton),this.zoomInButton.appendChild(At.createIcon("plus-circle")),this.zoomInButton.addEventListener("click",(()=>{e.zoomIn()})),e.on("locuschange",(e=>{this.browser.isMultiLocusMode()?this.disable():(this.enable(),this.update(e))}))};db.prototype.update=function(e){const t=e[0],{bpLength:i}=t.genome.getChromosome(t.chr),{start:n,end:r}=t;hb=Math.ceil(Math.log2(i/this.browser.minimumBases())),this.slider.max=`${hb}`;const s=i/(r-n);cb=Math.log2(s),this.slider.value=`${Math.round(cb)}`},db.prototype.enable=function(){this.slider.disabled=!1},db.prototype.disable=function(){this.slider.disabled=!0},db.prototype.hide=function(){this.zoomContainer.style.display="none"},db.prototype.show=function(){this.zoomContainer.style.display="block"},db.prototype.hideSlider=function(){this.slider.style.display="none"},db.prototype.showSlider=function(){this.slider.style.display="block"};const ub=function(e,t){const i=_t.div({class:"igv-navbar-button"});e.append(i),i.textContent="Save SVG",i.addEventListener("click",(()=>t.saveSVGtoFile({})))},fb=(e,t)=>{const i=0===e?t.nextElementSibling:t.previousElementSibling;t.remove(),i.remove()},pb=e=>{const t=_t.div({class:"igv-column-shim"});Po(t,e);const i=_t.div({class:"igv-column"});return Po(i,t),i},gb=(e,t)=>{for(let i=0;i<t;i++){const n=_t.div({class:"igv-column"});if(Oo(n,e),t>1&&i>0){Oo(_t.div({class:"igv-column-shim"}),n)}}};class mb{constructor(e,t,i){this.browser=e,this.referenceFrame=t,this.column=i,this.container=_t.div({class:"igv-center-line"}),i.appendChild(this.container),e.isCenterLineVisible?this.show():this.hide()}repaint(){if(this.referenceFrame){if(1/this.referenceFrame.bpPerPixel>1){const e=Math.floor(this.referenceFrame.toPixels(1));this.container.style.width=`${e}px`,this.container.classList.remove("igv-center-line-thin"),this.container.classList.add("igv-center-line-wide")}else this.container.style.width="1px",this.container.classList.remove("igv-center-line-wide"),this.container.classList.add("igv-center-line-thin")}}show(){this.isVisible=!0,this.container.style.display="block",this.repaint()}hide(){this.isVisible=!1,this.container.style.display="none"}resize(){this.repaint()}}const bb=Xt;class wb{constructor(e){this.browser=e,this.height=40,this.name="",this.id="ruler",this.disableButtons=!0,this.ignoreTrackMenu=!0,this.order=.01*Number.MIN_SAFE_INTEGER,this.removable=!1,this.type="ruler"}async getFeatures(e,t,i){return[]}computePixelHeight(e){return this.height}draw({context:e,referenceFrame:t,pixelWidth:i,pixelHeight:n,bpPerPixel:r,bpStart:s}){Ia.isWholeGenomeView(t.chr)?this.drawWholeGenome({context:e,pixelWidth:i,pixelHeight:n,bpPerPixel:r}):this.doDraw({context:e,referenceFrame:t,pixelWidth:i,pixelHeight:n,bpStart:s})}drawWholeGenome({context:e,pixelWidth:t,pixelHeight:i,bpPerPixel:n}){e.save(),Co.fillRect(e,0,0,t,i,{fillStyle:"white"});for(let t of this.browser.genome.wgChromosomeNames){let r=this.browser.genome.getCumulativeOffset(t),s=this.browser.genome.getChromosome(t).bpLength,o=Math.round(r/n),a=Math.round(s/n);this.renderChromosomeRect(e,o,0,a,i,t)}e.restore()}doDraw({context:e,referenceFrame:t,pixelWidth:i,pixelHeight:n,bpStart:r}){e.clearRect(0,0,i,n);const s=function(e,t){if(e<10)return new vb(1,"bp",1);const i=Math.floor(Math.log10(e));let n="bp",r=1;i>9?(n="gb",r=1e9):i>6?(n="mb",r=1e6):i>3&&(n="kb",r=1e3);const s=Math.pow(10,i-1),o=e/s,a=75,l=Math.pow(10,i-1),h=Math.pow(10,i)/2;return new vb(o<a&&!0!==t?l:h,n,r)}(Math.floor(t.toBP(i)),e.isSVG);let o=Math.floor(r/s.majorTick)-1;const{tickDelta:a,labelLength:l}=function(e,t,i,n,r){const s=h(t,l(1+n,r),i)-h(t,l(n,r),i),o=`${Xt(Math.floor(l(n,r)/r.unitMultiplier))} ${r.majorUnit}`,a=Math.floor(e.measureText(o).width);return{tickDelta:s,labelLength:a};function l(e,t){return Math.floor(e*t.majorTick)}function h(e,t,i){return Math.round(e.toPixels(t-1-i+.5))}}(e,t,r,o,s);let h,c;this.browser.referenceFrameList.indexOf(t);let d=a;const u=.25*l;do{c=Math.floor(o*s.majorTick);const i=`${Xt(Math.floor(c/s.unitMultiplier))} ${s.majorUnit}`;h=Math.round(t.toPixels(c-1-r+.5));const n=Math.round(h-e.measureText(i).width/2);n>0&&u+l<=d&&(Co.fillText(e,i,n,this.height-8),d=0),h>0&&Co.strokeLine(e,h,this.height-6,h,this.height-2),c=Math.floor((1+o)*s.majorTick);let f=h+(Math.round(t.toPixels(c-1-r+.5))-h)/2;f>0&&Co.strokeLine(e,f,this.height-6,f,this.height-2),++o,d+=a}while(h<i);Co.strokeLine(e,0,this.height-2,i,this.height-2)}renderChromosomeRect(e,t,i,n,r,s){e.textAlign="center",e.textBaseline="middle",e.font="12px sans-serif",Co.strokeLine(e,t+n,i,t+n,i+r,{strokeStyle:Ds.greyScale(191)});const o=s.startsWith("chr")?s.substring(3):s;n>e.measureText(o).width&&Co.fillText(e,o,t+n/2,i+r/2,{fillStyle:Ds.greyScale(68)})}get supportsWholeGenome(){return!0}dispose(){}}class vb{constructor(e,t,i){this.majorTick=e,this.minorTick=e/10,this.majorUnit=t,this.unitMultiplier=i}description(e){console.log((e||"")+" tick "+bb(this.majorTick)+" label width "+bb(this.labelWidthBP)+" multiplier "+this.unitMultiplier)}}const yb=function(e,t){this.button=_t.div({class:"igv-navbar-button"}),e.appendChild(this.button),this.button.textContent="circular view",this.button.addEventListener("click",(()=>{t.circularViewVisible=!t.circularViewVisible})),this.browser=t,this.setVisibility(t.config.showCircularViewButton),this.setState(t.circularViewVisible)};yb.prototype.setVisibility=function(e){!0===e?this.show():this.hide()},yb.prototype.setState=function(e){!0===e?this.button.classList.add("igv-navbar-button-clicked"):this.button.classList.remove("igv-navbar-button-clicked")},yb.prototype.show=function(){this.button.style.display="block",this.setState(this.browser.circularViewVisible)},yb.prototype.hide=function(){this.button.style.display="none"};const _b=function(e,t,i){const n=_t.div({class:"igv-navbar-button"});e.append(n),n.textContent=i.label,n.addEventListener("click",(()=>i.callback(t)))};class xb{constructor(e,t,i,n,r){this.browser=e,this.roiMenu=t,this.roiTable=i,this.top=n,this.roiSets=r||[],this.boundLocusChangeHandler=kb.bind(this),e.on("locuschange",this.boundLocusChangeHandler)}async initialize(){this.roiSets.length>0&&(this.browser.showROITableButton=!0,this.browser.roiTableControl.setVisibility(this.browser.showROITableButton));const e=this.roiSets.map((e=>this.renderROISet({browser:this.browser,pixelTop:this.top,roiSet:e})));e.length>0&&await Promise.all(e);const t=await this.getTableRecords();this.roiTable.renderTable(t)}async loadROI(e,t){const i=Array.isArray(e)?e:[e];for(let e of i)this.roiSets.push(new pc(e,t));await this.initialize()}clearROIs(){this.roiTable.clearTable();const e=this.browser.columnContainer.querySelectorAll(".igv-roi-region");for(let t of e)t.remove();for(let e of this.roiSets)e.dispose();this.roiSets=[]}async getTableRecords(){const e=[];for(let t of this.roiSets){const i=t.isUserDefined?"":t.name||"",n=await t.getAllFeatures();for(let t of Object.keys(n))for(let r of n[t])e.push({setName:i,feature:r})}return e}presentTable(){this.roiTable.present()}async repaintTable(){const e=await this.getTableRecords();this.roiTable.renderTable(e)}dismissTable(){this.roiTable.dismiss()}async updateUserDefinedROISet(e){let t=await this.getUserDefinedROISet();void 0===t&&(t=this.initializeUserDefinedROISet()),t.addFeature(e),!1===this.browser.showROITableButton&&this.setROITableButtonVisibility(!0),await this.renderROISet({browser:this.browser,pixelTop:this.top,roiSet:t});const i=await this.getTableRecords();this.roiTable.renderTable(i)}setROITableButtonVisibility(e){this.browser.showROITableButton=e,this.browser.roiTableControl.setVisibility(this.browser.showROITableButton)}async renderAllROISets(){for(let e of this.roiSets)await this.renderROISet({browser:this.browser,pixelTop:this.top,roiSet:e})}async renderROISet({browser:e,pixelTop:t,roiSet:i}){const n=e.columnContainer.querySelectorAll(".igv-column");for(let r=0;r<n.length;r++){let{chr:s,start:o,end:a,bpPerPixel:l}=e.referenceFrameList[r];const h=n[r].querySelectorAll(".igv-roi-region");for(let e of h){const t=e.dataset.region,{chr:i,start:n,end:r}=Ab(t);(i!==s||r<o||n>a)&&e.remove()}const c=await i.getFeatures(s,o,a);if(c)for(let h of c){const c=Cb(s,h.start,h.end),{x:d,width:u}=gc(Math.max(o,h.start),Math.min(a,h.end),o,l),f=n[r].querySelector(Sb(c));if(f)f.style.left=`${d}px`,f.style.width=`${u}px`;else{const s=this.createRegionElement(e.columnContainer,t,d,u,i,c,h.name);n[r].appendChild(s)}}}}createRegionElement(e,t,i,n,r,s,o){const a=_t.div({class:"igv-roi-region"});a.style.top=`${t}px`,a.style.left=`${i}px`,a.style.width=`${n}px`,a.style.backgroundColor=r.color,a.dataset.region=s;const l=_t.div();return a.appendChild(l),l.style.backgroundColor=r.headerColor,!0===r.isUserDefined?l.addEventListener("click",(t=>{t.preventDefault(),t.stopPropagation();const{x:i,y:n}=_t.translateMouseCoordinates(t,e);this.roiMenu.present(i,n,this,e,a)})):o?l.addEventListener("click",(t=>{t.preventDefault(),t.stopPropagation(),this.popover&&this.popover.dispose(),this.popover=new Vt(e,r.name),this.popover.presentContentWithEvent(t,o)})):l.style.pointerEvents="none",a}async getUserDefinedROISet(){return this.roiSets.find((e=>!0===e.isUserDefined))}initializeUserDefinedROISet(){const e=new pc({isUserDefined:!0,features:[]},this.browser.genome);return this.roiSets.push(e),e}async deleteUserDefinedRegionWithKey(e,t){t.querySelectorAll(Sb(e)).forEach((e=>e.remove()));const i=await this.findUserDefinedRegionWithKey(e),n=await this.getUserDefinedROISet();n&&n.removeFeature(i);0===(await this.getTableRecords()).length&&(this.browser.roiTableControl.buttonHandler(!1),this.setROITableButtonVisibility(!1))}async findUserDefinedRegionWithKey(e){const{chr:t,start:i,end:n}=Ab(e),r=await this.getUserDefinedROISet();if(r){const e=await r.getFeatures(t,i,n);for(let r of e)if(r.chr===t&&r.start>=i&&r.end<=n)return r}}toJSON(){return this.roiSets.map((e=>e.toJSON()))}dispose(){this.browser.off("locuschange",this.boundLocusChangeHandler);const e=this.browser.columnContainer.querySelectorAll(".igv-roi-region");for(let t of e)t.remove();this.roiMenu&&this.roiMenu.dispose(),this.roiTable&&this.roiTable.dispose();for(let e of this.roiSets)e.dispose();for(let e of Object.keys(this))this[e]=void 0}}function kb(){this.renderAllROISets()}function Cb(e,t,i){return`${e}-${t}-${i}`}function Sb(e){return`[data-region="${e}"]`}function Ab(e){let[t,i,n]=e.split("-");return i=parseInt(i),n=parseInt(n),{chr:t,start:i,end:n,locus:`${t}:${i}-${n}`,bedRecord:`${t}\t${i}\t${n}`}}class Eb extends iu{constructor(e){super(Object.assign({width:"512px"},e))}tableRowDOM(e){const t=_t.div({class:"igv-roi-table-row"}),{setName:i,feature:n}=e;t.dataset.region=Cb(n.chr,n.start,n.end);let r=[n.chr,Xt(n.start),Xt(n.end),n.name||"",i];4===this.columnFormat.length&&(r=r.slice(0,4));for(let e=0;e<r.length;e++){const i=_t.div();t.appendChild(i),i.style.width=this.columnFormat[e].width,i.innerText=r[e]}return this.tableRowDOMHelper(t),t}renderTable(e){if(Array.from(this.tableRowContainer.querySelectorAll(".igv-roi-table-row")).forEach((e=>e.remove())),e.length>0){const t=e.sort(((e,t)=>e.feature.chr.localeCompare(t.feature.chr)||e.feature.start-t.feature.start||e.feature.end-t.feature.end));for(let e of t){const t=this.tableRowDOM(e);this.tableRowContainer.appendChild(t)}}}dispose(){document.removeEventListener("click",this.boundGotoButtonHandler),this.browser.roiTableControl.buttonHandler(!1),super.dispose()}static getColumnFormatConfiguration(e){return!0===e?[{label:"Chr",width:"20%"},{label:"Start",width:"15%"},{label:"End",width:"15%"},{label:"Description",width:"30%"},{label:"ROI Set",width:"20%"}]:[{label:"Chr",width:"25%"},{label:"Start",width:"20%"},{label:"End",width:"20%"},{label:"Description",width:"35%"}]}static gotoButtonHandler(e){e.stopPropagation();const t=this.tableDOM.querySelectorAll(".igv-roi-table-row-selected"),i=[];for(let e of t){const{locus:t}=Ab(e.dataset.region);i.push(t)}for(let e of this.tableDOM.querySelectorAll(".igv-roi-table-row"))e.classList.remove("igv-roi-table-row-selected");this.setTableRowSelectionState(!1),i.length>0&&this.browser.search(i.join(" "))}}class Mb{constructor(e,t){this.browser=e,this.container=_t.div({class:"igv-roi-menu-next-gen"}),t.appendChild(this.container);const i=_t.div();this.container.appendChild(i),Mt.attachDialogCloseHandlerWithParent(i,(()=>this.container.style.display="none")),this.body=_t.div(),this.container.appendChild(this.body),this.container.style.display="none"}async present(e,t,i,n,r){Tb(this.body);const s=await this.browser.roiManager.findUserDefinedRegionWithKey(r.dataset.region),o=_t.div();this.body.appendChild(o);const a="Description",l=s.name||a;o.innerText=l,o.setAttribute("title",l),a===l?o.classList.add("igv-roi-placeholder"):o.classList.remove("igv-roi-placeholder");const h=_t.div();this.body.appendChild(h),h.innerText="Set Description",h.addEventListener("click",(e=>{e.stopPropagation(),this.container.style.display="none";const t={label:"Description",value:s.name||"",callback:()=>{const e=this.browser.inputDialog.input.value||"";s.name=e.trim(),this.container.style.display="none",this.browser.roiManager.repaintTable()}};this.browser.inputDialog.present(t,e)}));const c=_t.div();this.body.appendChild(c),c.innerText="Delete Region",c.addEventListener("click",(e=>{e.stopPropagation(),this.container.style.display="none",this.browser.roiManager.deleteUserDefinedRegionWithKey(r.dataset.region,this.browser.columnContainer)})),this.container.style.left=`${e}px`,this.container.style.top=`${t}px`,this.container.style.display="flex"}async __present(e,t,i,n,r){Tb(this.container);const s=await this.browser.roiManager.findUserDefinedRegionWithKey(r.dataset.region);let o;o=_t.div({class:"igv-roi-menu-row-edit-description"}),this.container.appendChild(o),o.addEventListener("click",(e=>{e.stopPropagation()}));const a="description-input",l=document.createElement("label");o.appendChild(l),l.setAttribute("for",a),l.innerText="Description:";const h=document.createElement("input");o.appendChild(h),h.setAttribute("type","text"),h.setAttribute("name",a),h.setAttribute("placeholder",""),h.value=s.name||"",h.addEventListener("change",(async e=>{e.stopPropagation();(await this.browser.roiManager.findUserDefinedRegionWithKey(r.dataset.region)).name=h.value,h.blur(),this.container.style.display="none",await this.browser.roiManager.repaintTable()})),o=_t.div({class:"igv-roi-menu-row"}),o.innerText="Delete region",this.container.appendChild(o),o.addEventListener("click",(e=>{e.stopPropagation(),this.container.style.display="none",this.browser.roiManager.deleteUserDefinedRegionWithKey(r.dataset.region,this.browser.columnContainer)})),this.container.style.left=`${e}px`,this.container.style.top=`${t}px`,this.container.style.display="flex",n.addEventListener("click",(e=>{e.stopPropagation(),this.container.style.display="none"}))}dispose(){this.container.innerHTML=""}}function Tb(e){for(;e.firstChild;)e.removeChild(e.firstChild)}class Rb{constructor(e,t){this.name=e.name,this.featureSource=e.featureSource||dc(e,t),this.color=e.color||uc}async getFeatures(e,t,i){return this.featureSource.getFeatures({chr:e,start:t,end:i})}draw(e){const{context:t,bpPerPixel:i,bpStart:n,pixelTop:r,pixelHeight:s,pixelWidth:o,features:a}=e;if(!a)return;const l=n+o*i+1;for(let{start:e,end:o}of a){if(o<n)continue;if(e>l)break;const{x:a,width:h}=gc(e,o,n,i);Co.fillRect(t,a,r,h,s,{fillStyle:this.color})}}}class Lb{constructor(e,t){this.browser=t,this.button=_t.div({class:"igv-navbar-button"}),e.appendChild(this.button),this.button.textContent="ROI Table",this.button.addEventListener("click",(()=>{this.buttonHandler(!t.roiTableVisible)})),this.browser=t,this.setVisibility(t.showROITableButton),this.setState(t.roiTableVisible)}buttonHandler(e){this.browser.roiTableVisible=e,this.setState(this.browser.roiTableVisible),this.browser.setROITableVisibility(this.browser.roiTableVisible)}setVisibility(e){!0===e?this.show():this.hide()}setState(e){!0===e?this.button.classList.add("igv-navbar-button-clicked"):this.button.classList.remove("igv-navbar-button-clicked")}show(){this.button.style.display="block",this.setState(this.browser.roiTableVisible)}hide(){this.button.style.display="none"}}class Ib{constructor(e,t){this.config=e,this.guid=_t.guid(),this.namespace=".browser_"+this.guid,this.parent=t,this.root=_t.div({class:"igv-container"}),t.appendChild(this.root),this.alert=new Ao(this.root),this.columnContainer=_t.div({class:"igv-column-container"}),this.root.appendChild(this.columnContainer),this.menuPopup=new Au(this.columnContainer),this.initialize(e),this.trackViews=[],this.constants={dragThreshold:3,scrollThreshold:5,defaultColor:"rgb(0,0,150)",doubleClickDelay:e.doubleClickDelay||500},this.eventHandlers={},this.addMouseHandlers(),this.setControls(e)}initialize(e){e.gtex&&($d.gtexLoaded=!0),this.flanking=e.flanking,this.crossDomainProxy=e.crossDomainProxy,this.formats=e.formats,this.trackDefaults=e.trackDefaults,this.nucleotideColors=e.nucleotideColors||ca;for(let e of Object.keys(this.nucleotideColors))this.nucleotideColors[e.toLowerCase()]=this.nucleotideColors[e];this.trackLabelsVisible=e.showTrackLabels,this.roiTableVisible=e.showROITable,this.showROITableButton=e.showROITableButton,this.isCenterLineVisible=e.showCenterGuide,this.cursorGuideVisible=e.showCursorGuide,this.showSampleNames=e.showSampleNames,this.showSampleNameButton=e.showSampleNameButton,this.sampleNameViewportWidth=e.sampleNameViewportWidth||200,e.search&&(this.searchConfig={type:"json",url:e.search.url,coords:void 0===e.search.coords?1:e.search.coords,chromosomeField:e.search.chromosomeField||"chromosome",startField:e.search.startField||"start",endField:e.search.endField||"end",geneField:e.search.geneField||"gene",snpField:e.search.snpField||"snp",resultsField:e.search.resultsField})}setControls(e){const t=this.createStandardControls(e);t.insertBefore(ft(this.columnContainer)),this.$navigation=t,!1===e.showControls&&t.hide()}createStandardControls(e){this.navbarManager=new tb(this);const t=ft("<div>",{class:"igv-navbar"});this.$navigation=t;const i=ft("<div>",{class:"igv-navbar-left-container"});t.append(i);const n=ft("<div>",{class:"igv-logo"});i.append(n);const r=ft('<svg width="690px" height="324px" viewBox="0 0 690 324" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><title>IGV</title><g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="IGV" fill="#666666"><polygon id="Path" points="379.54574 8.00169252 455.581247 8.00169252 515.564813 188.87244 532.884012 253.529506 537.108207 253.529506 554.849825 188.87244 614.833392 8.00169252 689.60164 8.00169252 582.729511 320.722144 486.840288 320.722144"></polygon><path d="M261.482414,323.793286 C207.975678,323.793286 168.339046,310.552102 142.571329,284.069337 C116.803612,257.586572 103.919946,217.158702 103.919946,162.784513 C103.919946,108.410325 117.437235,67.8415913 144.472217,41.0770945 C171.507199,14.3125977 212.903894,0.930550071 268.663545,0.930550071 C283.025879,0.930550071 298.232828,1.84616386 314.284849,3.6774189 C330.33687,5.50867394 344.839793,7.97378798 357.794056,11.072835 L357.794056,68.968378 C339.48912,65.869331 323.578145,63.5450806 310.060654,61.9955571 C296.543163,60.4460336 284.574731,59.6712835 274.154998,59.6712835 C255.850062,59.6712835 240.502308,61.4320792 228.111274,64.9537236 C215.720241,68.4753679 205.793482,74.2507779 198.330701,82.2801269 C190.867919,90.309476 185.587729,100.87425 182.48997,113.974767 C179.392212,127.075284 177.843356,143.345037 177.843356,162.784513 C177.843356,181.942258 179.251407,198.000716 182.067551,210.960367 C184.883695,223.920018 189.671068,234.41436 196.429813,242.443709 C203.188559,250.473058 212.059279,256.178037 223.042241,259.558815 C234.025202,262.939594 247.683295,264.629958 264.01693,264.629958 C268.241146,264.629958 273.098922,264.489094 278.590403,264.207362 C284.081883,263.925631 289.643684,263.50304 295.275972,262.939577 L295.275972,159.826347 L361.595831,159.826347 L361.595831,308.579859 C344.698967,313.087564 327.239137,316.750019 309.215815,319.567334 C291.192494,322.38465 275.281519,323.793286 261.482414,323.793286 L261.482414,323.793286 L261.482414,323.793286 Z" id="Path"></path>;<polygon id="Path" points="0.81355666 5.00169252 73.0472883 5.00169252 73.0472883 317.722144 0.81355666 317.722144"></polygon></g> </g> </svg>');r.css("width","34px"),r.css("height","32px"),n.append(r),this.$current_genome=ft("<div>",{class:"igv-current-genome"}),i.append(this.$current_genome),this.$current_genome.text("");const s=ft("<div>",{class:"igv-navbar-genomic-location"});i.append(s),this.chromosomeSelectWidget=new ib(this,s.get(0)),void 0===e.showChromosomeWidget&&(e.showChromosomeWidget=!0),!0===e.showChromosomeWidget?this.chromosomeSelectWidget.show():this.chromosomeSelectWidget.hide();const o=ft("<div>",{class:"igv-locus-size-group"});s.append(o);const a=ft("<div>",{class:"igv-search-container"});o.append(a),this.$searchInput=ft("<input>",{class:"igv-search-input",type:"text",placeholder:"Locus Search"}),a.append(this.$searchInput),this.$searchInput.change((()=>this.doSearch(this.$searchInput.val())));const l=_t.div({class:"igv-search-icon-container"});a.append(ft(l)),l.appendChild(At.createIcon("search")),l.addEventListener("click",(()=>this.doSearch(this.$searchInput.val()))),this.windowSizePanel=new nb(o.get(0),this);const h=ft("<div>",{class:"igv-navbar-right-container"});t.append(h);const c=ft('<div class="igv-navbar-toggle-button-container">');if(h.append(c),this.$toggle_button_container=c,this.cursorGuide=new rb(this.columnContainer,this),this.cursorGuideButton=new sb(this,c.get(0)),this.centerLineButton=new ob(this,c.get(0)),this.setTrackLabelVisibility(e.showTrackLabels),this.trackLabelControl=new ab(c.get(0),this),this.roiTableControl=new Lb(c.get(0),this),this.sampleNameControl=new lb(c.get(0),this),!0===e.showSVGButton&&(this.svgSaveControl=new ub(c.get(0),this)),e.customButtons)for(let t of e.customButtons)new _b(c.get(0),this,t);return this.zoomWidget=new db(this,h.get(0)),!1===e.showNavigation&&this.$navigation.hide(),this.inputDialog=new Nt(this.root),this.inputDialog.container.id=`igv-input-dialog-${_t.guid()}`,this.dataRangeDialog=new Zt(this,ft(this.root)),this.dataRangeDialog.$container.get(0).id=`igv-data-range-dialog-${_t.guid()}`,this.genericColorPicker=new qt({parent:this.columnContainer,width:432}),this.genericColorPicker.container.id=`igv-track-color-picker-${_t.guid()}`,t}getSampleNameViewportWidth(){return!1===this.showSampleNames?0:this.sampleNameViewportWidth}isMultiLocusMode(){return this.referenceFrameList&&this.referenceFrameList.length>1}addTrackToFactory(e,t){jm(e,t)}isMultiLocusWholeGenomeView(){if(void 0===this.referenceFrameList||1===this.referenceFrameList.length)return!1;for(let e of this.referenceFrameList)if("all"===e.chr.toLowerCase())return!0;return!1}currentLoci(){const e=e=>`${e.chr}:${e.start+1}-${e.end}`;return void 0===this.referenceFrameList||0===this.referenceFrameList.length?"":1===this.referenceFrameList.length?e(this.referenceFrameList[0]):this.referenceFrameList.map((t=>e(t)))}toSVG(){const{y:e,width:t,height:i}=this.columnContainer.getBoundingClientRect(),n=new Ma({width:t,height:8e3,backdropColor:"white",multiLocusGap:0,viewbox:{x:0,y:0,width:t,height:8e3}});for(let t of this.trackViews)t.renderSVGContext(n,{deltaX:0,deltaY:-e});return n.setHeight(i),n.getSerializedSvg(!0)}renderSVG(e){const t=this.toSVG();return e.empty(),e.append(t),t}saveSVGtoFile(e){let t=this.toSVG();e.$container&&(e.$container.empty(),e.$container.append(t));ii(e.filename||"igvjs.svg",URL.createObjectURL(new Blob([t],{type:"application/octet-stream"})))}async loadSession(e){let t;return this.roiSets=[],t=e.url||e.file?await async function(e){const t=e.url||e.file;if(e.url&&(e.url.startsWith("blob:")||e.url.startsWith("data:"))){const t=Ib.uncompressSession(e.url);return JSON.parse(t)}{let i=e.filename;if(i||(i=e.url?await Io(e.url):e.file.name),i.endsWith(".xml")){const e=Ia.KNOWN_GENOMES,i=await no.loadString(t);return new Wm(i,e)}return i.endsWith(".json")?no.loadJson(t):void 0}}(e):e,this.loadSessionObject(t)}async loadSessionObject(e){this.cleanHouseForSession(),this.showSampleNames=e.showSampleNames||!1,this.sampleNameControl.setState(!0===this.showSampleNames),e.sampleNameViewportWidth&&(this.sampleNameViewportWidth=e.sampleNameViewportWidth),No(this.columnContainer,"igv-axis-column"),No(this.columnContainer,"igv-sample-name-column"),No(this.columnContainer,"igv-scrollbar-column"),No(this.columnContainer,"igv-track-drag-column"),No(this.columnContainer,"igv-gear-menu-column");const t=e.reference||e.genome;if(!t)return void console.warn("No genome or reference object specified");const i=await Ia.expandReference(this.alert,t);await this.loadReference(i,e.locus),this.centerLineList=this.createCenterLineList(this.columnContainer);let n=0;if(!1!==e.showIdeogram){const e=new of(this);e.id="ideogram";const t=new Ru(this,this.columnContainer,e),{$viewport:i}=t.viewports[0];n=function(e){e="string"==typeof e?document.querySelector(e):e;const t=window.getComputedStyle(e),i=parseFloat(t.marginTop)+parseFloat(t.marginBottom),n=e.offsetHeight;return Math.ceil(i+n)}(i.get(0)),this.trackViews.push(t)}if(!1!==e.showRuler&&this.trackViews.push(new Ru(this,this.columnContainer,new wb(this))),e.gtexSelections)for(let t of this.referenceFrameList)for(let i of Object.keys(e.gtexSelections)){const n=e.gtexSelections[i].gene,r=e.gtexSelections[i].snp;t.selection=new Xm(n,r)}this.roiManager&&this.roiManager.dispose();const r=new Mb(this,this.columnContainer),s={browser:this,parent:this.columnContainer,headerTitle:"Regions of Interest",dismissHandler:()=>this.roiTableControl.buttonHandler(!1),gotoButtonHandler:Eb.gotoButtonHandler};if(e.roi){const t=e.roi.map((e=>new pc(e,this.genome))),i=t.filter((({name:e})=>void 0!==e&&e.length>0));s.columnFormat=Eb.getColumnFormatConfiguration(i.length>0);const o=new Eb(s);this.roiManager=new xb(this,r,o,n,t)}else{s.columnFormat=Eb.getColumnFormatConfiguration(!1);const e=new Eb(s);this.roiManager=new xb(this,r,e,n,void 0)}await this.roiManager.initialize();const o=i.tracks||[],a=e.tracks?o.concat(e.tracks):o;0===a.filter((e=>"sequence"===e.type&&!e.url&&!e.fastaURL)).length&&a.push({type:"sequence",order:da});let l=1;for(let e of a)void 0===e.order&&(e.order=l++);await this.loadTrackList(a);for(let e of this.trackViews.filter((e=>"ruler"===e.track.type||"ideogram"===e.track.type)))e.updateViews();this.updateUIWithReferenceFrameList()}createCenterLineList(e){const t=e.querySelectorAll(".igv-center-line");for(let e=0;e<t.length;e++)t[e].remove();const i=[],n=e.querySelectorAll(".igv-column");for(let e=0;e<n.length;e++)i.push(new mb(this,this.referenceFrameList[e],n[e]));return i}async loadReference(e,t){const i=await Ia.loadGenome(e),n=void 0===this.genome||this.genome.id!==i.id;this.genome=i,this.updateNavbarDOMWithGenome(i),n&&this.removeAllTracks();let r=function(e,t){return e?Array.isArray(e)?e.join(" "):e:t.getHomeChromosomeName()}(t,i);if(!await this.search(r,!0)){console.log("Initial locus not found: "+r),r=i.getHomeChromosomeName();if(!await this.search(r,!0))throw new Error("Cannot set initial locus")}n&&this.circularView&&this.circularView.setAssembly({name:this.genome.id,id:this.genome.id,chromosomes:Vd(this.genome)})}cleanHouseForSession(){for(let e of this.trackViews)e.removeDOMFromColumnContainer();this.columnContainer.querySelectorAll(".igv-axis-column, .igv-column-shim, .igv-column, .igv-sample-name-column, .igv-scrollbar-column, .igv-track-drag-column, .igv-gear-menu-column").forEach((e=>e.remove())),this.trackViews=[],this.circularView&&this.circularView.clearChords()}updateNavbarDOMWithGenome(e){let t=e.id&&e.id.length<10?e.id:"";this.$current_genome.text(t),this.$current_genome.attr("title",e.id||""),this.chromosomeSelectWidget.update(e)}async loadGenome(e){const t=await Ia.expandReference(this.alert,e);await this.loadReference(t,void 0);const i=t.tracks||[];return 0===i.filter((e=>"sequence"===e.type)).length&&i.push({type:"sequence",order:da}),await this.loadTrackList(i),await this.updateViews(),this.genome}updateUIWithReferenceFrameList(){const e=this.referenceFrameList;this.updateLocusSearchWidget();const t=this.isMultiLocusWholeGenomeView()||Ia.isWholeGenomeView(e[0].chr);this.navbarManager.navbarDidResize(this.$navigation.width(),t),Ob(this.trackViews,this.trackLabelsVisible),this.setCenterLineAndCenterLineButtonVisibility(!Ia.isWholeGenomeView(e[0].chr))}setTrackLabelVisibility(e){Ob(this.trackViews,e)}setROITableVisibility(e){!0===e?this.roiManager.presentTable():this.roiManager.dismissTable()}setCursorGuideVisibility(e){e?this.cursorGuide.show():this.cursorGuide.hide()}setCustomCursorGuideMouseHandler(e){this.cursorGuide.customMouseHandler=e}setCenterLineVisibility(e){for(let t of this.centerLineList)!0===e?(t.show(),t.repaint()):t.hide()}setCenterLineAndCenterLineButtonVisibility(e){for(let t of this.centerLineList){e&&t.isVisible?t.show():t.container.style.display="none"}e&&this.centerLineButton.isVisible?this.centerLineButton.show():this.centerLineButton.button.style.display="none"}async loadTrackList(e){const t=[];for(let i of e)t.push(this._loadTrack(i));const i=await Promise.all(t);return this.trackViews.filter((function(e){return e.track.autoscaleGroup})).length>0&&this.updateViews(),i}async loadTrack(e){const t=this._loadTrack(e);return e.autoscaleGroup&&(await t,this.updateViews()),t}async _loadTrack(e){Qt(e)&&(e=JSON.parse(e));try{const t=await this.createTrack(e);if(void 0===t)return;void 0===t.order&&(t.order=this.trackViews.length);const i=new Ru(this,this.columnContainer,t);if(this.trackViews.push(i),Ob(this.trackViews,this.trackLabelsVisible),this.reorderTracks(),this.fireEvent("trackorderchanged",[this.getTrackOrder()]),"function"==typeof t.postInit)try{i.startSpinner(),await t.postInit()}finally{i.stopSpinner()}return t.autoscaleGroup||(e.sync?await i.updateViews():i.updateViews()),"function"==typeof t.hasSamples&&t.hasSamples()&&!1!==this.config.showSampleNameButton&&this.sampleNameControl.show(),t}catch(t){const i={401:"Access unauthorized",403:"Access forbidden",404:"Not found"};console.error(t);let n=t.message||t.error||t.toString();i.hasOwnProperty(n)&&(n=i[n]),n+=": "+e.url,this.alert.present(new Error(n),void 0)}}async loadROI(e){await this.roiManager.loadROI(e,this.genome)}clearROIs(){this.roiManager.clearROIs()}async getUserDefinedROIs(){if(this.roiManager){const e=await this.roiManager.getUserDefinedROISet();if(void 0===e)return[];const t=await e.getAllFeatures(),i=[];for(let e of Object.values(t))i.push(...e);return i}return[]}getRulerTrackView(){const e=this.trackViews.filter((({track:e})=>"ruler"===e.id));return e.length>0?e[0]:void 0}async createTrack(e){let t=await async function(e){return"function"==typeof e?e():e}
/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */(e.url||e.fastaURL);if(Qt(t)&&(t=t.trim()),t)if(e.format)e.format=e.format.toLowerCase();else if(e.fastaURL)e.format="fasta";else{let i=e.filename;i||(i=await Io(t));const n=jo(i);"tsv"===n?e.format=await Go(e):n?e.format=n:"htsget"===e.sourceType&&await Lh.inferFormat(e)}let i=e.type?e.type.toLowerCase():void 0;if(!i){if(i=Wo(e),"bedtype"===i){const t=dc(e,this.genome);e._featureSource=t;const n=await t.trackType();i=n||"annotation"}e.type=i}if(this.trackDefaults&&i){const t=this.trackDefaults[i];if(t)for(let i in t)t.hasOwnProperty(i)&&void 0===e[i]&&(e[i]=t[i])}const n=$m(i,e,this);if(void 0!==n)return e.roi&&e.roi.length>0&&(n.roiSets=e.roi.map((e=>new Rb(e,this.genome)))),n;this.alert.present(new Error(`Error creating track. Could not determine track type for file: ${e.url||e}`),void 0)}reorderTracks(){this.trackViews.sort((function(e,t){const i=e=>"ideogram"===e.track.id?1:"ruler"===e.track.id?2:3,n=i(e),r=i(t);if(n===r){return(e.track.order||0)-(t.track.order||0)}return n-r}));for(let{axis:e,viewports:t,sampleNameViewport:i,outerScroll:n,dragHandle:r,gearContainer:s}of this.trackViews){e.remove();for(let{$viewport:e}of t)e.detach();i.viewport.remove(),n.remove(),r.remove(),s.remove()}const e=this.columnContainer.querySelectorAll(".igv-column");for(let{axis:t,viewports:i,sampleNameViewport:n,outerScroll:r,dragHandle:s,gearContainer:o}of this.trackViews){this.columnContainer.querySelector(".igv-axis-column").appendChild(t);for(let t=0;t<e.length;t++){const{$viewport:n}=i[t];e[t].appendChild(n.get(0))}this.columnContainer.querySelector(".igv-sample-name-column").appendChild(n.viewport),this.columnContainer.querySelector(".igv-scrollbar-column").appendChild(r),this.columnContainer.querySelector(".igv-track-drag-column").appendChild(s),this.columnContainer.querySelector(".igv-gear-menu-column").appendChild(o)}}getTrackOrder(){return this.trackViews.filter((e=>e.track&&e.track.name)).map((e=>e.track.name))}removeTrackByName(e){const t=this.trackViews.slice();for(let i of t)e===i.track.name&&this.removeTrack(i.track)}removeTrack(e){for(let t of this.trackViews)if(e===t.track){this._removeTrack(t.track);break}}_removeTrack(e){e.disposed||(this.trackViews.splice(this.trackViews.indexOf(e.trackView),1),this.fireEvent("trackremoved",[e]),this.fireEvent("trackorderchanged",[this.getTrackOrder()]),e.trackView&&e.trackView.dispose())}removeAllTracks(){const e=[];for(let t of this.trackViews)"ruler"!==t.track.id&&"ideogram"!==t.track.id?(this.fireEvent("trackremoved",[t.track]),t.dispose()):e.push(t);this.trackViews=e}findTracks(e,t){let i="function"==typeof e?t=>e(t.track):i=>t===i.track[e];return this.trackViews.filter(i).map((e=>e.track))}setTrackHeight(e){this.trackHeight=e,this.trackViews.forEach((function(t){t.setTrackHeight(e)}))}async visibilityChange(){this.layoutChange()}async layoutChange(){if(this.referenceFrameList.find((e=>e.bpPerPixel<0))){const e=this.calculateViewportWidth(this.referenceFrameList.length);for(let t of this.referenceFrameList)t.bpPerPixel=(t.end-t.start)/e}if(this.referenceFrameList){const e=this.isMultiLocusWholeGenomeView()||Ia.isWholeGenomeView(this.referenceFrameList[0].chr);this.navbarManager.navbarDidResize(this.$navigation.width(),e)}Bb.call(this),await this.updateViews()}async updateViews(){const e=this.trackViews;this.updateLocusSearchWidget();for(let e of this.centerLineList)e.repaint();if(this.dragObject)for(let t of e)await t.updateViews();else{const r={},s=[];for(let i of e){const e=i.track.autoscaleGroup;if(e){var t=r[e];t||(t=[],r[e]=t),t.push(i)}else s.push(i)}if(Object.entries(r).length>0){const e=Object.keys(r);for(let t of e){const e=r[t],s=[];for(let t of e)s.push(t.getInViewFeatures());const o=await Promise.all(s);var i,n=[];for(let e of o)n=n.concat(e);i=Ro(n);const a=[];for(let t of e)t.track.dataRange=i,t.track.autoscale=!1,a.push(t.updateViews());await Promise.all(a)}}await Promise.all(s.map((e=>e.updateViews())))}}repaintViews(){for(let e of this.trackViews)e.repaintViews()}updateLocusSearchWidget(){if(!this.referenceFrameList)return;const e=this.referenceFrameList,t=this.calculateViewportWidth(this.referenceFrameList.length);for(let i of e)i.end=i.start+i.bpPerPixel*t;this.chromosomeSelectWidget.select.value=1===e.length?this.referenceFrameList[0].chr:"";const i=this.referenceFrameList.map((e=>e.getLocusString())).join(" ");this.$searchInput.val(i),this.fireEvent("locuschange",[this.referenceFrameList])}calculateViewportWidth(e){let{width:t}=this.columnContainer.getBoundingClientRect();return t-=50+this.getSampleNameViewportWidth()+14+12+28,t-=5*(e-1),Math.floor(t/e)}getCenterLineXOffset(){let{width:e}=this.columnContainer.getBoundingClientRect();return e-=50+this.getSampleNameViewportWidth()+14+12+28,Math.floor(e/2+50)}minimumBases(){return this.config.minimumBases}zoomIn(){this.zoomWithScaleFactor(.5)}zoomOut(){this.zoomWithScaleFactor(2)}async zoomWithScaleFactor(e,t,i){if(!this.referenceFrameList)return;const n=this.calculateViewportWidth(this.referenceFrameList.length);let r=i?[i]:this.referenceFrameList;for(let i of r)i.zoomWithScaleFactor(this,e,n,t)}async addMultiLocusPanel(e,t,i,n){if(!this.referenceFrameList)return;const r=this.calculateViewportWidth(1+this.referenceFrameList.length),s=this.calculateViewportWidth(this.referenceFrameList.length)/this.calculateViewportWidth(1+this.referenceFrameList.length);for(let e of this.referenceFrameList)e.bpPerPixel*=s;const o=(i-t)/r,a=new Km(this.genome,e,t,i,o),l=n?this.referenceFrameList.indexOf(n):this.referenceFrameList.length-1,h=1+l,{$viewport:c}=this.trackViews[0].viewports[l],d=pb(c.get(0).parentElement);if(h===this.referenceFrameList.length){this.referenceFrameList.push(a);for(let e of this.trackViews){const t=xu(e,d,a);e.viewports.push(t)}}else{this.referenceFrameList.splice(h,0,a);for(let e of this.trackViews){const t=xu(e,d,a);e.viewports.splice(h,0,t)}}this.centerLineList=this.createCenterLineList(this.columnContainer),Bb.call(this),await this.updateViews(!0)}async removeMultiLocusPanel(e){const t=this.referenceFrameList.indexOf(e),{$viewport:i}=this.trackViews[0].viewports[t];fb(t,i.parent().get(0));for(let{viewports:e}of this.trackViews)e[t].dispose(),e.splice(t,1);if(this.referenceFrameList.splice(t,1),1===this.referenceFrameList.length&&this.getRulerTrackView())for(let e of this.getRulerTrackView().viewports)e.dismissLocusLabel();const n=this.calculateViewportWidth(1+this.referenceFrameList.length)/this.calculateViewportWidth(this.referenceFrameList.length);await this.rescaleForMultiLocus(n)}async gotoMultilocusPanel(e){const t=this.referenceFrameList.indexOf(e);this.columnContainer.querySelectorAll(".igv-column").forEach(((e,i)=>{i===t||e.remove()})),this.columnContainer.querySelectorAll(".igv-column-shim").forEach((e=>e.remove()));for(let e of this.trackViews){const i=e.viewports[t];e.viewports.filter(((e,i)=>i!==t)).forEach((e=>e.dispose())),e.viewports=[i]}const i=this.calculateViewportWidth(1);e.bpPerPixel=(e.end-e.start)/i,this.referenceFrameList=[e],this.trackViews.forEach((({viewports:e})=>e.forEach((e=>e.setWidth(i))))),this.centerLineList=this.createCenterLineList(this.columnContainer),this.updateUIWithReferenceFrameList(),await this.updateViews(!0)}async rescaleForMultiLocus(e){const t=this.calculateViewportWidth(this.referenceFrameList.length);for(let t of this.referenceFrameList)t.bpPerPixel*=e;for(let{viewports:e}of this.trackViews)for(let i of e)i.setWidth(t);this.centerLineList=this.createCenterLineList(this.columnContainer),this.updateUIWithReferenceFrameList(),await this.updateViews()}async goto(e,t,i){await this.search(e+":"+t+"-"+i)}async doSearch(e,t){const i=await this.search(e,t);return i||this.alert.present(new Error(`Unrecognized locus: <b> ${e} </b>`)),i}async search(e,t){const i=await eb(this,e);if(i&&i.length>0){this.referenceFrameList=function(e,t,i,n,r,s){return e.map((e=>{if(i&&e.gene&&(e.start=Math.max(0,e.start-i),e.end+=i),!s){const i=t.getChromosome(e.chr);Lo(i.bpLength,e,n)}const o=new Km(t,e.chr,e.start,e.end,(e.end-e.start)/r);return o.locusSearchString=e.locusSearchString,(e.gene||e.snp)&&(o.selection=new Xm(e.gene,e.snp)),o}))}(i,this.genome,this.flanking,this.minimumBases(),this.calculateViewportWidth(i.length),this.isSoftclipped());for(let e of this.trackViews)e.removeDOMFromColumnContainer();this.columnContainer.querySelectorAll(".igv-column-shim, .igv-column").forEach((e=>e.remove())),gb(this.columnContainer.querySelector(".igv-sample-name-column"),this.referenceFrameList.length),this.centerLineList=this.createCenterLineList(this.columnContainer);for(let e of this.trackViews)e.addDOMToColumnContainer(this,this.columnContainer,this.referenceFrameList);return this.updateUIWithReferenceFrameList(),t||await this.updateViews(),!0}return!1}async loadSampleInformation(e){var t=e;ti(e)&&(t=e.name),"fam"===t.substr(t.lastIndexOf(".")+1)&&(this.sampleInformation=await function(e,t){return(new Qm).loadPlinkFile(e,t)}(e))}on(e,t){this.eventHandlers[e]||(this.eventHandlers[e]=[]),this.eventHandlers[e].push(t)}un(e,t){this.off(e,t)}off(e,t){if(e)if(t){const i=this.eventHandlers[e];if(i&&0!==i.length){const n=i.indexOf(t);-1!==n&&this.eventHandlers[e].splice(n,1)}else console.warn("No handlers to remove for event: "+e)}else this.eventHandlers[e]=[];else this.eventHandlers={}}fireEvent(e,t,i){const n=this.eventHandlers[e];if(void 0===n||0===n.length)return;const r=i||window;return n.map((function(e){return e.apply(r,t)}))[0]}dispose(){this.removeMouseHandlers();for(let e of this.trackViews)e.dispose()}toJSON(){const e={version:"2.15.5"};if(void 0!==this.showSampleNames&&(e.showSampleNames=this.showSampleNames),200!==this.sampleNameViewportWidth&&(e.sampleNameViewportWidth=this.sampleNameViewportWidth),e.reference=this.genome.toJSON(),e.reference.fastaURL instanceof File)throw new Error(`Error. Sessions cannot include local file references ${e.reference.fastaURL.name}.`);if(e.reference.indexURL instanceof File)throw new Error(`Error. Sessions cannot include local file references ${e.reference.indexURL.name}.`);const t=[],i={};let n=!1,r=this.trackViews[0];for(let{referenceFrame:e}of r.viewports){const r=e.getLocusString();if(t.push(r),e.selection){const t={gene:e.selection.gene,snp:e.selection.snp};i[r]=t,n=!0}}e.locus=1===t.length?t[0]:t,n&&(e.gtexSelections=i),e.roi=this.roiManager.toJSON();const s=[],o=[];for(let{track:e}of this.trackViews)try{let t;t="function"==typeof e.getState?e.getState():e.config,t&&(t.browser&&delete t.browser,t.order=e.order,s.push(t))}catch(t){console.error(`Track: ${e.name}: ${t}`),o.push(`Track: ${e.name}: ${t}`)}if(o.length>0){let e=1,t="Errors encountered saving session: </br>";for(let i of o)t+=` (${e++}) ${i.toString()} <br/>`;throw Error(t)}return e.tracks=s,e}compressedSession(){return function(e){const t=new Uint8Array(e.length);for(var i=0;i<e.length;i++)t[i]=e.charCodeAt(i);const n=new Cs(t),r=String.fromCharCode.apply(null,n);return btoa(r).replace(/\+/g,".").replace(/\//g,"_").replace(/=/g,"-")}(JSON.stringify(this.toJSON()))}sessionURL(){const e=window.location.href.slice(),t=e.indexOf("?");return(t>0?e.substring(0,t):e)+"?sessionURL=blob:"+this.compressedSession()}mouseDownOnViewport(e,t){var i;i=_t.pageCoordinates(e),this.vpMouseDown={viewport:t,lastMouseX:i.x,mouseDownX:i.x,lastMouseY:i.y,mouseDownY:i.y,referenceFrame:t.referenceFrame}}cancelTrackPan(){const e=this.dragObject;this.dragObject=void 0,this.isScrolling=!1,this.vpMouseDown=void 0,e&&e.viewport.referenceFrame.start!==e.start&&(this.updateViews(),this.fireEvent("trackdragend"))}isTrackPanning(){return this.dragObject}isSoftclipped(){return void 0!==this.trackViews.find((e=>!0===e.track.showSoftClips))}startTrackDrag(e){this.dragTrack=e}updateTrackDrag(e){if(e&&this.dragTrack){const t=this.dragTrack,i=this.trackViews.indexOf(e),n=this.trackViews.indexOf(t),r=this.trackViews;r[i]=t,r[n]=e;const s=this.trackViews[i].track.order;this.trackViews[n].track.order=s;const o=r.length;let a=s;if(i<n)for(let e=i+1;e<o;e++){const t=r[e].track;if(!(t.order<=a))break;t.order=Math.min(Number.MAX_SAFE_INTEGER,a+1),a=t.order}else for(let e=i-1;e>0;e--){const t=r[e].track;if(!(t.order>=a))break;t.order=Math.max(-Number.MAX_SAFE_INTEGER,a-1),a=t.order}this.reorderTracks()}}endTrackDrag(){this.dragTrack?(this.dragTrack=void 0,this.fireEvent("trackorderchanged",[this.getTrackOrder()])):this.dragTrack=void 0}addMouseHandlers(){this.addWindowResizeHandler(),this.addRootMouseUpHandler(),this.addRootMouseLeaveHandler(),this.addColumnContainerEventHandlers()}removeMouseHandlers(){this.removeWindowResizeHandler(),this.removeRootMouseUpHandler(),this.removeRootMouseLeaveHandler(),this.removeColumnContainerEventHandlers()}addWindowResizeHandler(){this.boundWindowResizeHandler=Bb.bind(this),window.addEventListener("resize",this.boundWindowResizeHandler)}removeWindowResizeHandler(){window.removeEventListener("resize",this.boundWindowResizeHandler)}addRootMouseUpHandler(){this.boundRootMouseUpHandler=Nb.bind(this),this.root.addEventListener("mouseup",this.boundRootMouseUpHandler)}removeRootMouseUpHandler(){this.root.removeEventListener("mouseup",this.boundRootMouseUpHandler)}addRootMouseLeaveHandler(){this.boundRootMouseLeaveHandler=Nb.bind(this),this.root.addEventListener("mouseleave",this.boundRootMouseLeaveHandler)}removeRootMouseLeaveHandler(){this.root.removeEventListener("mouseleave",this.boundRootMouseLeaveHandler)}addColumnContainerEventHandlers(){this.boundColumnContainerMouseMoveHandler=Fb.bind(this),this.boundColumnContainerTouchMoveHandler=Fb.bind(this),this.boundColumnContainerMouseLeaveHandler=Nb.bind(this),this.boundColumnContainerMouseUpHandler=Nb.bind(this),this.boundColumnContainerTouchEndHandler=Nb.bind(this),this.columnContainer.addEventListener("mousemove",this.boundColumnContainerMouseMoveHandler),this.columnContainer.addEventListener("touchmove",this.boundColumnContainerTouchMoveHandler),this.columnContainer.addEventListener("mouseleave",this.boundColumnContainerMouseLeaveHandler),this.columnContainer.addEventListener("mouseup",this.boundColumnContainerMouseUpHandler),this.columnContainer.addEventListener("touchend",this.boundColumnContainerTouchEndHandler)}removeColumnContainerEventHandlers(){this.columnContainer.removeEventListener("mousemove",this.boundColumnContainerMouseMoveHandler),this.columnContainer.removeEventListener("touchmove",this.boundColumnContainerTouchMoveHandler),this.columnContainer.removeEventListener("mouseleave",this.boundColumnContainerMouseLeaveHandler),this.columnContainer.removeEventListener("mouseup",this.boundColumnContainerMouseUpHandler),this.columnContainer.removeEventListener("touchend",this.boundColumnContainerTouchEndHandler)}static uncompressSession(e){let t;if(e.indexOf("/gzip;base64")>0){t=Fs(e);let i="";for(let e of t)i+=String.fromCharCode(e);return i}return function(e){e=e.replace(/\./g,"+").replace(/_/g,"/").replace(/-/g,"=");const t=atob(e),i=[];for(let e=0;e<t.length;e++)i.push(t.charCodeAt(e));const n=As(i);let r="";for(let e of n)r+=String.fromCharCode(e);return r}(e.substring(5))}createCircularView(e,t){var i;return t=!0===t,this.circularView=(i=this,new Fd(e,{onChordClick:(e,t,n)=>{const r=e.data,s=r.mate;function o(e){e.chr=i.genome.getChromosomeName(e.refName);let t=!1;for(let n of i.referenceFrameList){const i=ud.fromLocusString(n.getLocusString());if(i.contains(e)){t=!0;break}if(i.overlaps(e)){n.extend(e),t=!0;break}}if(!t){const t=2e3,n=(e.start+e.end)/2;i.addMultiLocusPanel(e.chr,n-t,n+t)}}o(r),o(s)}})),this.circularViewControl=new yb(this.$toggle_button_container.get(0),this),this.circularView.setAssembly({name:this.genome.id,id:this.genome.id,chromosomes:Vd(this.genome)}),this.circularViewVisible=t,this.circularView}get circularViewVisible(){return void 0!==this.circularView&&this.circularView.visible}set circularViewVisible(e){this.circularView&&(this.circularView.visible=e,this.circularViewControl.setState(e))}}async function Bb(){if(!this.referenceFrameList)return;const e=this.calculateViewportWidth(this.referenceFrameList.length);for(let t of this.referenceFrameList){const i=this.referenceFrameList.indexOf(t),{chr:n,genome:r}=t,{bpLength:s}=r.getChromosome(t.chr),o=t.toBP(e);Ia.isWholeGenomeView(n)||o>s?t.bpPerPixel=s/e:t.end=t.start+t.toBP(e);for(let{viewports:t}of this.trackViews)t[i].setWidth(e)}this.updateUIWithReferenceFrameList(),await this.updateViews(!0)}function Fb(e){e.preventDefault();const{x:t,y:i}=_t.pageCoordinates(e);if(this.vpMouseDown){const{viewport:e,referenceFrame:n}=this.vpMouseDown,r=Math.abs(t-this.vpMouseDown.mouseDownX)>Math.abs(i-this.vpMouseDown.mouseDownY);if(!this.dragObject&&!this.isScrolling)if(r)this.vpMouseDown.mouseDownX&&Math.abs(t-this.vpMouseDown.mouseDownX)>this.constants.dragThreshold&&(this.dragObject={viewport:e,start:n.start});else if(this.vpMouseDown.mouseDownY&&Math.abs(i-this.vpMouseDown.mouseDownY)>this.constants.scrollThreshold){this.isScrolling=!0;const t=e.$viewport.height(),i=e.trackView.maxViewportContentHeight();this.vpMouseDown.r=t/i}if(this.dragObject){const i=!this.isSoftclipped();let r=this.vpMouseDown.lastMouseX-t;n.shiftPixels(r,e.$viewport.width(),i)&&this.updateViews(),this.fireEvent("trackdrag")}if(this.isScrolling){const t=this.vpMouseDown.r*(this.vpMouseDown.lastMouseY-i);e.trackView.moveScroller(t)}this.vpMouseDown.lastMouseX=t,this.vpMouseDown.lastMouseY=i}}function Nb(e){this.cancelTrackPan(),this.endTrackDrag()}function Ob(e,t){for(let{viewports:i}of e)for(let e of i)e.$trackLabel&&(0===i.indexOf(e)&&!0===t?e.$trackLabel.show():e.$trackLabel.hide())}let Pb=[];const Db=no.setApiKey;!function(){var e=document.createElement("style");e.setAttribute("type","text/css"),e.innerHTML='.igv-navbar {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n box-sizing: border-box;\n width: 100%;\n color: #444;\n font-size: 12px;\n font-family: "Open Sans", sans-serif;\n font-weight: 400;\n line-height: 32px;\n padding-left: 8px;\n padding-right: 8px;\n margin-top: 2px;\n margin-bottom: 6px;\n height: 32px;\n border-style: solid;\n border-radius: 3px;\n border-width: thin;\n border-color: #bfbfbf;\n background-color: #f3f3f3;\n}\n.igv-navbar .igv-navbar-left-container {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n height: 32px;\n line-height: 32px;\n}\n.igv-navbar .igv-navbar-left-container .igv-logo {\n width: 34px;\n height: 32px;\n margin-right: 8px;\n}\n.igv-navbar .igv-navbar-left-container .igv-current-genome {\n height: 32px;\n margin-left: 4px;\n margin-right: 4px;\n user-select: none;\n line-height: 32px;\n vertical-align: middle;\n text-align: center;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n height: 100%;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-chromosome-select-widget-container {\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n height: 100%;\n width: 125px;\n margin-right: 4px;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-chromosome-select-widget-container select {\n display: block;\n cursor: pointer;\n width: 100px;\n height: 75%;\n outline: none;\n font-size: 12px;\n font-family: "Open Sans", sans-serif;\n font-weight: 400;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n margin-left: 8px;\n height: 22px;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-search-container {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n width: 210px;\n height: 22px;\n line-height: 22px;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-search-container input.igv-search-input {\n cursor: text;\n width: 85%;\n height: 22px;\n line-height: 22px;\n font-size: 12px;\n font-family: "Open Sans", sans-serif;\n font-weight: 400;\n text-align: left;\n padding-left: 8px;\n margin-right: 8px;\n outline: none;\n border-style: solid;\n border-radius: 3px;\n border-width: thin;\n border-color: #bfbfbf;\n background-color: white;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-search-container .igv-search-icon-container {\n cursor: pointer;\n height: 16px;\n width: 16px;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-windowsize-panel-container {\n margin-left: 4px;\n user-select: none;\n}\n.igv-navbar .igv-navbar-right-container {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n height: 32px;\n line-height: 32px;\n}\n.igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n height: 100%;\n}\n.igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container div {\n margin-left: 0;\n margin-right: 4px;\n}\n.igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container div:last-child {\n margin-left: 0;\n margin-right: 0;\n}\n.igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container-750 {\n display: none;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget {\n color: #737373;\n font-size: 18px;\n height: 32px;\n line-height: 32px;\n margin-left: 8px;\n user-select: none;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div {\n cursor: pointer;\n margin-left: unset;\n margin-right: unset;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div:first-child {\n height: 24px;\n width: 24px;\n margin-left: unset;\n margin-right: 8px;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div:last-child {\n height: 24px;\n width: 24px;\n margin-left: 8px;\n margin-right: unset;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div:nth-child(even) {\n display: block;\n height: fit-content;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget input {\n display: block;\n width: 125px;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget svg {\n display: block;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 {\n color: #737373;\n font-size: 18px;\n height: 32px;\n line-height: 32px;\n margin-left: 8px;\n user-select: none;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div {\n cursor: pointer;\n margin-left: unset;\n margin-right: unset;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div:first-child {\n height: 24px;\n width: 24px;\n margin-left: unset;\n margin-right: 8px;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div:last-child {\n height: 24px;\n width: 24px;\n margin-left: 8px;\n margin-right: unset;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div:nth-child(even) {\n width: 0;\n height: 0;\n display: none;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 input {\n width: 0;\n height: 0;\n display: none;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 svg {\n display: block;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-hidden {\n display: none;\n}\n\n.igv-navbar-button {\n display: block;\n box-sizing: unset;\n padding-left: 6px;\n padding-right: 6px;\n height: 18px;\n text-transform: capitalize;\n user-select: none;\n line-height: 18px;\n text-align: center;\n vertical-align: middle;\n font-family: "Open Sans", sans-serif;\n font-size: 11px;\n font-weight: 200;\n color: #737373;\n background-color: #f3f3f3;\n border-color: #737373;\n border-style: solid;\n border-width: thin;\n border-radius: 6px;\n}\n\n.igv-navbar-button-clicked {\n color: white;\n background-color: #737373;\n}\n\n.igv-navbar-button:hover {\n cursor: pointer;\n}\n\n.igv-zoom-in-notice-container {\n z-index: 1024;\n position: absolute;\n top: 8px;\n left: 50%;\n transform: translate(-50%, 0%);\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n justify-content: center;\n align-items: center;\n background-color: white;\n}\n.igv-zoom-in-notice-container > div {\n padding-left: 4px;\n padding-right: 4px;\n padding-top: 2px;\n padding-bottom: 2px;\n width: 100%;\n height: 100%;\n font-family: "Open Sans", sans-serif;\n font-size: 14px;\n font-weight: 400;\n color: #3f3f3f;\n}\n\n.igv-zoom-in-notice {\n position: absolute;\n top: 10px;\n left: 50%;\n}\n.igv-zoom-in-notice div {\n position: relative;\n left: -50%;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n color: #3f3f3f;\n background-color: rgba(255, 255, 255, 0.51);\n z-index: 64;\n}\n\n.igv-container-spinner {\n position: absolute;\n top: 90%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 1024;\n width: 24px;\n height: 24px;\n pointer-events: none;\n color: #737373;\n}\n\n.igv-multi-locus-close-button {\n position: absolute;\n top: 2px;\n right: 0;\n padding-left: 2px;\n padding-right: 2px;\n width: 12px;\n height: 12px;\n color: #666666;\n background-color: white;\n z-index: 1000;\n}\n.igv-multi-locus-close-button > svg {\n vertical-align: top;\n}\n\n.igv-multi-locus-close-button:hover {\n cursor: pointer;\n color: #434343;\n}\n\n.igv-multi-locus-ruler-label {\n z-index: 64;\n position: absolute;\n top: 2px;\n left: 0;\n width: 100%;\n height: 12px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: center;\n align-items: center;\n}\n.igv-multi-locus-ruler-label > div {\n font-family: "Open Sans", sans-serif;\n font-size: 12px;\n color: rgb(16, 16, 16);\n background-color: white;\n}\n.igv-multi-locus-ruler-label > div {\n cursor: pointer;\n}\n\n.igv-multi-locus-ruler-label-square-dot {\n z-index: 64;\n position: absolute;\n left: 50%;\n top: 5%;\n transform: translate(-50%, 0%);\n background-color: white;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-multi-locus-ruler-label-square-dot > div:first-child {\n width: 14px;\n height: 14px;\n}\n.igv-multi-locus-ruler-label-square-dot > div:last-child {\n margin-left: 16px;\n font-family: "Open Sans", sans-serif;\n font-size: 14px;\n font-weight: 400;\n color: rgb(16, 16, 16);\n}\n\n.igv-ruler-sweeper {\n display: none;\n pointer-events: none;\n position: absolute;\n top: 26px;\n bottom: 0;\n left: 0;\n width: 0;\n z-index: 99999;\n background-color: rgba(68, 134, 247, 0.25);\n}\n\n.igv-ruler-tooltip {\n pointer-events: none;\n z-index: 128;\n position: absolute;\n top: 0;\n left: 0;\n width: 1px;\n height: 32px;\n background-color: transparent;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-ruler-tooltip > div {\n pointer-events: none;\n width: 128px;\n height: auto;\n padding: 1px;\n color: #373737;\n font-size: 10px;\n font-family: "Open Sans", sans-serif;\n font-weight: 400;\n background-color: white;\n border-style: solid;\n border-width: thin;\n border-color: #373737;\n}\n\n.igv-track-label {\n position: absolute;\n left: 8px;\n top: 8px;\n width: auto;\n height: auto;\n max-width: 50%;\n padding-left: 4px;\n padding-right: 4px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n font-family: "Open Sans", sans-serif;\n font-size: small;\n font-weight: 400;\n text-align: center;\n user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n border-color: #444;\n border-radius: 2px;\n border-style: solid;\n border-width: thin;\n background-color: white;\n z-index: 128;\n cursor: pointer;\n}\n\n.igv-track-label:hover,\n.igv-track-label:focus,\n.igv-track-label:active {\n background-color: #e8e8e8;\n}\n\n.igv-track-label-popup-shim {\n padding-left: 8px;\n padding-right: 8px;\n padding-top: 4px;\n}\n\n.igv-center-line {\n display: none;\n pointer-events: none;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 50%;\n transform: translateX(-50%);\n z-index: 8;\n user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n border-left-style: dashed;\n border-left-width: thin;\n border-right-style: dashed;\n border-right-width: thin;\n}\n\n.igv-center-line-wide {\n background-color: rgba(0, 0, 0, 0);\n border-left-color: rgba(127, 127, 127, 0.51);\n border-right-color: rgba(127, 127, 127, 0.51);\n}\n\n.igv-center-line-thin {\n background-color: rgba(0, 0, 0, 0);\n border-left-color: rgba(127, 127, 127, 0.51);\n border-right-color: rgba(0, 0, 0, 0);\n}\n\n.igv-cursor-guide-horizontal {\n display: none;\n pointer-events: none;\n user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n position: absolute;\n left: 0;\n right: 0;\n top: 50%;\n height: 1px;\n z-index: 1;\n margin-left: 50px;\n margin-right: 54px;\n border-top-style: dotted;\n border-top-width: thin;\n border-top-color: rgba(127, 127, 127, 0.76);\n}\n\n.igv-cursor-guide-vertical {\n pointer-events: none;\n user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 50%;\n width: 1px;\n z-index: 1;\n border-left-style: dotted;\n border-left-width: thin;\n border-left-color: rgba(127, 127, 127, 0.76);\n display: none;\n}\n\n.igv-user-feedback {\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 512px;\n height: 360px;\n z-index: 2048;\n background-color: white;\n border-color: #a2a2a2;\n border-style: solid;\n border-width: thin;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n color: #444;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-user-feedback div:first-child {\n position: relative;\n height: 24px;\n width: 100%;\n background-color: white;\n border-bottom-color: #a2a2a2;\n border-bottom-style: solid;\n border-bottom-width: thin;\n}\n.igv-user-feedback div:first-child div {\n position: absolute;\n top: 2px;\n width: 16px;\n height: 16px;\n background-color: transparent;\n}\n.igv-user-feedback div:first-child div:first-child {\n left: 8px;\n}\n.igv-user-feedback div:first-child div:last-child {\n cursor: pointer;\n right: 8px;\n}\n.igv-user-feedback div:last-child {\n width: 100%;\n height: calc(100% - 24px);\n border-width: 0;\n}\n.igv-user-feedback div:last-child div {\n width: auto;\n height: auto;\n margin: 8px;\n}\n\n.igv-generic-dialog-container {\n position: absolute;\n top: 0;\n left: 0;\n width: 300px;\n height: 200px;\n border-color: #7F7F7F;\n border-radius: 4px;\n border-style: solid;\n border-width: thin;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n z-index: 2048;\n background-color: white;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-generic-dialog-container .igv-generic-dialog-header {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n width: 100%;\n height: 24px;\n cursor: move;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-bottom-color: #7F7F7F;\n border-bottom-style: solid;\n border-bottom-width: thin;\n background-color: #eee;\n}\n.igv-generic-dialog-container .igv-generic-dialog-header div {\n margin-right: 4px;\n margin-bottom: 2px;\n height: 12px;\n width: 12px;\n color: #7F7F7F;\n}\n.igv-generic-dialog-container .igv-generic-dialog-header div:hover {\n cursor: pointer;\n color: #444;\n}\n.igv-generic-dialog-container .igv-generic-dialog-one-liner {\n color: #373737;\n width: 95%;\n height: 24px;\n line-height: 24px;\n text-align: left;\n margin-top: 8px;\n padding-left: 8px;\n overflow-wrap: break-word;\n background-color: white;\n}\n.igv-generic-dialog-container .igv-generic-dialog-label-input {\n margin-top: 8px;\n width: 95%;\n height: 24px;\n color: #373737;\n line-height: 24px;\n padding-left: 8px;\n background-color: white;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-generic-dialog-container .igv-generic-dialog-label-input div {\n width: 30%;\n height: 100%;\n font-size: 16px;\n text-align: right;\n padding-right: 8px;\n background-color: white;\n}\n.igv-generic-dialog-container .igv-generic-dialog-label-input input {\n display: block;\n height: 100%;\n width: 100%;\n padding-left: 4px;\n font-family: "Open Sans", sans-serif;\n font-weight: 400;\n color: #373737;\n text-align: left;\n outline: none;\n border-style: solid;\n border-width: thin;\n border-color: #7F7F7F;\n background-color: white;\n}\n.igv-generic-dialog-container .igv-generic-dialog-label-input input {\n width: 50%;\n font-size: 16px;\n}\n.igv-generic-dialog-container .igv-generic-dialog-input {\n margin-top: 8px;\n width: calc(100% - 16px);\n height: 24px;\n color: #373737;\n line-height: 24px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n.igv-generic-dialog-container .igv-generic-dialog-input input {\n display: block;\n height: 100%;\n width: 100%;\n padding-left: 4px;\n font-family: "Open Sans", sans-serif;\n font-weight: 400;\n color: #373737;\n text-align: left;\n outline: none;\n border-style: solid;\n border-width: thin;\n border-color: #7F7F7F;\n background-color: white;\n}\n.igv-generic-dialog-container .igv-generic-dialog-input input {\n font-size: 16px;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel {\n width: 100%;\n height: 28px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div {\n margin-top: 32px;\n color: white;\n font-family: "Open Sans", sans-serif;\n font-size: 14px;\n font-weight: 400;\n width: 75px;\n height: 28px;\n line-height: 28px;\n text-align: center;\n border-color: transparent;\n border-style: solid;\n border-width: thin;\n border-radius: 2px;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:first-child {\n margin-left: 32px;\n margin-right: 0;\n background-color: #5ea4e0;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:last-child {\n margin-left: 0;\n margin-right: 32px;\n background-color: #c4c4c4;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:first-child:hover {\n cursor: pointer;\n background-color: #3b5c7f;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:last-child:hover {\n cursor: pointer;\n background-color: #7f7f7f;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok {\n width: 100%;\n height: 36px;\n margin-top: 32px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok div {\n width: 98px;\n height: 36px;\n line-height: 36px;\n text-align: center;\n color: white;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n border-color: white;\n border-style: solid;\n border-width: thin;\n border-radius: 4px;\n background-color: #2B81AF;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok div:hover {\n cursor: pointer;\n background-color: #25597f;\n}\n\n.igv-generic-container {\n position: absolute;\n top: 0;\n left: 0;\n z-index: 2048;\n background-color: white;\n cursor: pointer;\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-generic-container div:first-child {\n cursor: move;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n height: 24px;\n width: 100%;\n background-color: #dddddd;\n}\n.igv-generic-container div:first-child i {\n display: block;\n color: #5f5f5f;\n cursor: pointer;\n width: 14px;\n height: 14px;\n margin-right: 8px;\n margin-bottom: 4px;\n}\n\n.igv-menu-popup {\n position: absolute;\n top: 0;\n left: 0;\n width: max-content;\n z-index: 4096;\n cursor: pointer;\n font-family: "Open Sans", sans-serif;\n font-size: small;\n font-weight: 400;\n color: #4b4b4b;\n background: white;\n border-radius: 4px;\n border-color: #7F7F7F;\n border-style: solid;\n border-width: thin;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-end;\n text-align: left;\n}\n.igv-menu-popup > div:not(:first-child) {\n width: 100%;\n}\n.igv-menu-popup > div:not(:first-child) > div {\n background: white;\n}\n.igv-menu-popup > div:not(:first-child) > div.context-menu {\n padding-left: 4px;\n padding-right: 4px;\n}\n.igv-menu-popup > div:not(:first-child) > div:last-child {\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n border-bottom-color: transparent;\n border-bottom-style: solid;\n border-bottom-width: thin;\n}\n.igv-menu-popup > div:not(:first-child) > div:hover {\n background: #efefef;\n}\n\n.igv-menu-popup-shim {\n padding-left: 8px;\n padding-right: 8px;\n padding-bottom: 1px;\n padding-top: 1px;\n}\n\n.igv-menu-popup-header {\n position: relative;\n width: 100%;\n height: 24px;\n cursor: move;\n border-top-color: transparent;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-bottom-color: #7F7F7F;\n border-bottom-style: solid;\n border-bottom-width: thin;\n background-color: #eee;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n}\n.igv-menu-popup-header div {\n margin-right: 4px;\n height: 12px;\n width: 12px;\n color: #7F7F7F;\n}\n.igv-menu-popup-header div:hover {\n cursor: pointer;\n color: #444;\n}\n\n.igv-menu-popup-check-container {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n width: 100%;\n height: 20px;\n margin-right: 4px;\n background-color: transparent;\n}\n.igv-menu-popup-check-container div {\n padding-top: 2px;\n padding-left: 8px;\n}\n.igv-menu-popup-check-container div:first-child {\n position: relative;\n width: 12px;\n height: 12px;\n}\n.igv-menu-popup-check-container div:first-child svg {\n position: absolute;\n width: 12px;\n height: 12px;\n}\n\n.igv-user-feedback {\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 512px;\n height: 360px;\n z-index: 2048;\n background-color: white;\n border-color: #a2a2a2;\n border-style: solid;\n border-width: thin;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n color: #444;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-user-feedback div:first-child {\n position: relative;\n height: 24px;\n width: 100%;\n background-color: white;\n border-bottom-color: #a2a2a2;\n border-bottom-style: solid;\n border-bottom-width: thin;\n}\n.igv-user-feedback div:first-child div {\n position: absolute;\n top: 2px;\n width: 16px;\n height: 16px;\n background-color: transparent;\n}\n.igv-user-feedback div:first-child div:first-child {\n left: 8px;\n}\n.igv-user-feedback div:first-child div:last-child {\n cursor: pointer;\n right: 8px;\n}\n.igv-user-feedback div:last-child {\n width: 100%;\n height: calc(100% - 24px);\n border-width: 0;\n}\n.igv-user-feedback div:last-child div {\n width: auto;\n height: auto;\n margin: 8px;\n}\n\n.igv-loading-spinner-container {\n z-index: 1024;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 32px;\n height: 32px;\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n justify-content: center;\n align-items: center;\n}\n.igv-loading-spinner-container > div {\n box-sizing: border-box;\n width: 100%;\n height: 100%;\n border-radius: 50%;\n border: 4px solid rgba(128, 128, 128, 0.5);\n border-top-color: rgb(255, 255, 255);\n animation: spin 1s ease-in-out infinite;\n -webkit-animation: spin 1s ease-in-out infinite;\n}\n\n@keyframes spin {\n to {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n@-webkit-keyframes spin {\n to {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n.igv-roi-menu-next-gen {\n position: absolute;\n z-index: 512;\n font-family: "Open Sans", sans-serif;\n font-size: small;\n font-weight: 400;\n color: #4b4b4b;\n background-color: white;\n width: 192px;\n border-radius: 4px;\n border-color: #7F7F7F;\n border-style: solid;\n border-width: thin;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n}\n.igv-roi-menu-next-gen > div:first-child {\n height: 24px;\n border-top-color: transparent;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-bottom-color: #7F7F7F;\n border-bottom-style: solid;\n border-bottom-width: thin;\n background-color: #eee;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n}\n.igv-roi-menu-next-gen > div:first-child > div {\n margin-right: 4px;\n height: 12px;\n width: 12px;\n color: #7F7F7F;\n}\n.igv-roi-menu-next-gen > div:first-child > div:hover {\n cursor: pointer;\n color: #444;\n}\n.igv-roi-menu-next-gen > div:last-child {\n background-color: white;\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n border-bottom-color: transparent;\n border-bottom-style: solid;\n border-bottom-width: 0;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n text-align: start;\n vertical-align: middle;\n}\n.igv-roi-menu-next-gen > div:last-child > div {\n height: 24px;\n padding-left: 4px;\n border-bottom-style: solid;\n border-bottom-width: thin;\n border-bottom-color: #7f7f7f;\n}\n.igv-roi-menu-next-gen > div:last-child > div:not(:first-child):hover {\n background-color: rgba(127, 127, 127, 0.1);\n}\n.igv-roi-menu-next-gen > div:last-child div:first-child {\n font-style: italic;\n text-align: center;\n padding-right: 4px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.igv-roi-menu-next-gen > div:last-child > div:last-child {\n border-bottom-width: 0;\n border-bottom-color: transparent;\n}\n\n.igv-roi-placeholder {\n font-style: normal;\n color: rgba(75, 75, 75, 0.6);\n}\n\n.igv-roi-table {\n position: absolute;\n z-index: 1024;\n width: min-content;\n max-width: 1600px;\n border-color: #7f7f7f;\n border-radius: 4px;\n border-style: solid;\n border-width: thin;\n font-family: "Open Sans", sans-serif;\n font-size: 12px;\n font-weight: 400;\n background-color: white;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n cursor: default;\n}\n.igv-roi-table > div {\n height: 24px;\n font-size: 14px;\n text-align: start;\n vertical-align: middle;\n line-height: 24px;\n}\n.igv-roi-table > div:first-child {\n border-color: transparent;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-top-width: 0;\n border-bottom-color: #7f7f7f;\n border-bottom-style: solid;\n border-bottom-width: thin;\n background-color: #eee;\n cursor: move;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n}\n.igv-roi-table > div:first-child > div:first-child {\n text-align: center;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n margin-left: 4px;\n margin-right: 4px;\n width: calc(100% - 4px - 12px);\n}\n.igv-roi-table > div:first-child > div:last-child {\n margin-right: 4px;\n margin-bottom: 2px;\n height: 12px;\n width: 12px;\n color: #7f7f7f;\n}\n.igv-roi-table > div:first-child > div:last-child > svg {\n display: block;\n}\n.igv-roi-table > div:first-child > div:last-child:hover {\n cursor: pointer;\n color: #444;\n}\n.igv-roi-table > .igv-roi-table-description {\n padding: 4px;\n margin-left: 4px;\n word-break: break-all;\n overflow-y: auto;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n background-color: transparent;\n}\n.igv-roi-table > .igv-roi-table-goto-explainer {\n margin-top: 5px;\n margin-left: 4px;\n color: #7F7F7F;\n font-style: italic;\n height: 24px;\n border-top: solid lightgray;\n background-color: transparent;\n}\n.igv-roi-table > .igv-roi-table-column-titles {\n height: 24px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: stretch;\n align-items: stretch;\n padding-right: 16px;\n background-color: white;\n border-top-color: #7f7f7f;\n border-top-style: solid;\n border-top-width: thin;\n border-bottom-color: #7f7f7f;\n border-bottom-style: solid;\n border-bottom-width: thin;\n}\n.igv-roi-table > .igv-roi-table-column-titles > div {\n font-size: 14px;\n vertical-align: middle;\n line-height: 24px;\n text-align: left;\n margin-left: 4px;\n height: 24px;\n overflow: hidden;\n text-overflow: ellipsis;\n border-right-color: #7f7f7f;\n border-right-style: solid;\n border-right-width: thin;\n}\n.igv-roi-table > .igv-roi-table-column-titles > div:last-child {\n border-right: unset;\n}\n.igv-roi-table > .igv-roi-table-row-container {\n overflow: auto;\n resize: both;\n max-width: 1600px;\n height: 360px;\n background-color: transparent;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n}\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row {\n height: 24px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: stretch;\n align-items: stretch;\n}\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row > div {\n font-size: 14px;\n vertical-align: middle;\n line-height: 24px;\n text-align: left;\n margin-left: 4px;\n height: 24px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n border-right-color: transparent;\n border-right-style: solid;\n border-right-width: thin;\n}\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row > div:last-child {\n border-right: unset;\n}\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row-hover {\n background-color: rgba(0, 0, 0, 0.04);\n}\n.igv-roi-table > div:last-child {\n height: 32px;\n line-height: 32px;\n border-top-color: #7f7f7f;\n border-top-style: solid;\n border-top-width: thin;\n border-bottom-color: transparent;\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n border-bottom-width: 0;\n background-color: #eee;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n\n.igv-roi-table-row-selected {\n background-color: rgba(0, 0, 0, 0.125);\n}\n\n.igv-roi-table-button {\n cursor: pointer;\n height: 20px;\n user-select: none;\n line-height: 20px;\n text-align: center;\n vertical-align: middle;\n font-family: "Open Sans", sans-serif;\n font-size: 13px;\n font-weight: 400;\n color: black;\n padding-left: 6px;\n padding-right: 6px;\n background-color: rgb(239, 239, 239);\n border-color: black;\n border-style: solid;\n border-width: thin;\n border-radius: 3px;\n}\n\n.igv-roi-table-button:hover {\n font-weight: 400;\n background-color: rgba(0, 0, 0, 0.13);\n}\n\n.igv-roi-region {\n z-index: 64;\n position: absolute;\n top: 0;\n bottom: 0;\n pointer-events: none;\n overflow: visible;\n margin-top: 44px;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n}\n.igv-roi-region > div {\n position: relative;\n width: 100%;\n height: 8px;\n pointer-events: auto;\n}\n\n.igv-roi-menu {\n position: absolute;\n z-index: 1024;\n width: 144px;\n border-color: #7f7f7f;\n border-radius: 4px;\n border-style: solid;\n border-width: thin;\n font-family: "Open Sans", sans-serif;\n background-color: white;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n}\n.igv-roi-menu > div:not(:last-child) {\n border-bottom-color: rgba(128, 128, 128, 0.5);\n border-bottom-style: solid;\n border-bottom-width: thin;\n}\n.igv-roi-menu > div:first-child {\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-top-color: transparent;\n border-top-style: solid;\n border-top-width: 0;\n}\n.igv-roi-menu > div:last-child {\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n border-bottom-color: transparent;\n border-bottom-style: solid;\n border-bottom-width: 0;\n}\n\n.igv-roi-menu-row {\n height: 24px;\n padding-left: 8px;\n font-size: small;\n text-align: start;\n vertical-align: middle;\n line-height: 24px;\n background-color: white;\n}\n\n.igv-roi-menu-row-edit-description {\n width: -webkit-fill-available;\n font-size: small;\n text-align: start;\n vertical-align: middle;\n background-color: white;\n padding-left: 4px;\n padding-right: 4px;\n padding-bottom: 4px;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: stretch;\n align-items: stretch;\n}\n.igv-roi-menu-row-edit-description > label {\n margin-left: 2px;\n margin-bottom: 0;\n display: block;\n width: -webkit-fill-available;\n}\n.igv-roi-menu-row-edit-description > input {\n display: block;\n margin-left: 2px;\n margin-right: 2px;\n margin-bottom: 1px;\n width: -webkit-fill-available;\n}\n\n.igv-container {\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n padding-top: 4px;\n user-select: none;\n -webkit-user-select: none;\n -ms-user-select: none;\n}\n\n.igv-viewport {\n position: relative;\n margin-top: 5px;\n line-height: 1;\n overflow-x: hidden;\n overflow-y: hidden;\n}\n\n.igv-viewport-content {\n position: relative;\n width: 100%;\n}\n.igv-viewport-content > canvas {\n position: relative;\n display: block;\n}\n\n.igv-column-container {\n position: relative;\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n width: 100%;\n}\n\n.igv-column-shim {\n width: 1px;\n margin-left: 2px;\n margin-right: 2px;\n background-color: #545453;\n}\n\n.igv-column {\n position: relative;\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n box-sizing: border-box;\n height: 100%;\n}\n\n.igv-axis-column {\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n box-sizing: border-box;\n height: 100%;\n width: 50px;\n}\n.igv-axis-column > div {\n margin-top: 5px;\n width: 100%;\n}\n\n.igv-sample-name-column {\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n box-sizing: border-box;\n height: 100%;\n}\n\n.igv-scrollbar-column {\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n box-sizing: border-box;\n height: 100%;\n width: 14px;\n}\n.igv-scrollbar-column > div {\n position: relative;\n margin-top: 5px;\n width: 14px;\n}\n.igv-scrollbar-column > div > div {\n cursor: pointer;\n position: absolute;\n top: 0;\n left: 2px;\n width: 8px;\n border-width: 1px;\n border-style: solid;\n border-color: #c4c4c4;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n}\n.igv-scrollbar-column > div > div:hover {\n background-color: #c4c4c4;\n}\n\n.igv-track-drag-column {\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n box-sizing: border-box;\n height: 100%;\n width: 12px;\n background-color: white;\n}\n.igv-track-drag-column > .igv-track-drag-handle {\n z-index: 512;\n position: relative;\n cursor: pointer;\n margin-top: 5px;\n width: 100%;\n border-style: solid;\n border-width: 0;\n border-top-right-radius: 6px;\n border-bottom-right-radius: 6px;\n background-color: #c4c4c4;\n}\n.igv-track-drag-column .igv-track-drag-handle-hover {\n background-color: #787878;\n}\n.igv-track-drag-column > .igv-track-drag-shim {\n position: relative;\n margin-top: 5px;\n width: 100%;\n border-style: solid;\n border-width: 0;\n}\n\n.igv-gear-menu-column {\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n box-sizing: border-box;\n height: 100%;\n width: 28px;\n}\n.igv-gear-menu-column > div {\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n margin-top: 5px;\n width: 100%;\n background: white;\n}\n.igv-gear-menu-column > div > div {\n position: relative;\n margin-top: 4px;\n width: 16px;\n height: 16px;\n color: #7F7F7F;\n}\n.igv-gear-menu-column > div > div:hover {\n cursor: pointer;\n color: #444;\n}\n\n/*# sourceMappingURL=dom.css.map */\n',document.head.append(e)}();const zb=no.oauth;var Hb={TrackUtils:Zo,IGVGraphics:Co,MenuUtils:$t,DataRangeDialog:Zt,createTrack:async function(e,t){return await Ib.prototype.createTrack.call(t,e)},createBrowser:async function(e,t){void 0===t&&(t={}),Ia.KNOWN_GENOMES||await Ia.initializeGenomes(t),function(e){void 0===e.minimumBases&&(e.minimumBases=40);void 0===e.showIdeogram&&(e.showIdeogram=!0);void 0===e.showCircularView&&(e.showCircularView=!1);void 0===e.showCircularViewButton&&(e.showCircularViewButton=!1);void 0===e.showTrackLabelButton&&(e.showTrackLabelButton=!0);void 0===e.showTrackLabels&&(e.showTrackLabels=!0);void 0===e.showROITableButton&&(e.showROITableButton=!1);void 0===e.showROITable&&(e.showROITable=!1);void 0===e.showCursorTrackingGuideButton&&(e.showCursorTrackingGuideButton=!0);void 0===e.showCursorGuide&&(e.showCursorGuide=e.showCursorTrackingGuide||!1);void 0===e.showCenterGuideButton&&(e.showCenterGuideButton=!0);void 0===e.showCenterGuide&&(e.showCenterGuide=!1);void 0===e.showSampleNames&&(e.showSampleNames=!1);void 0===e.showSVGButton&&(e.showSVGButton=!0);void 0===e.showControls&&(e.showControls=!0);void 0===e.showNavigation&&(e.showNavigation=!0);void 0===e.showRuler&&(e.showRuler=!0);void 0===e.flanking&&(e.flanking=1e3);void 0===e.pairsSupported&&(e.pairsSupported=!0);e.tracks||(e.tracks=[])}(t),t.queryParametersSupported&&function(e){var t,i,n,r,s,o,a,l,h;let c,d,u;if(a=window.location.href,s={},t=a.indexOf("?"),i=a.lastIndexOf("#"),t>=0)for(i<0&&(i=a.length),n=t+1;n<i;)(r=a.indexOf("&",n))<0&&(r=i),2===(o=a.substring(n,r).split("=",2)).length?(l=o[0],h=decodeURIComponent(o[1]),"file"===l?c=h.split(","):"index"===l?d=h.split(","):"name"===l?u=h.split(","):"genome"!==l||!h.startsWith("https://")&&!h.startsWith("http://")||h.endsWith(".json")?e[l]=h:e.reference={fastaURL:h,indexURL:h+".fai"},n=r+1):n++;if(c){e.tracks||(e.tracks=[]);for(let t=0;t<c.length;t++){if(c[t].endsWith(".xml")||c[t].endsWith(".json")){e.sessionURL=c[t];break}const i={url:c[t]};d&&d.length>t&&(i.indexURL=d[t]),u&&u.length>t&&(i.name=u[t]),e.tracks.push(i)}}}(t),t.apiKey&&no.setApiKey(t.apiKey),t.oauthToken&&no.setOauthToken(t.oauthToken),t.clientId&&!Zs()&&await async function(e){if(!google.accounts.oauth2.initTokenClient)throw new Error("Google accounts token client not loaded (https://accounts.google.com/gsi/client)");if(Zs())throw new Error("Google client is already initialized");const t={client_id:e.client_id,scope:e.scope||"https://www.googleapis.com/auth/userinfo.profile",state:e.state||"igv",error:e=>{throw new Error(e.type)},hint:e.hint,hosted_domain:e.hosted_domain},i=google.accounts.oauth2.initTokenClient(t);google.igv={tokenClient:i,apiKey:e.apiKey}}({clientId:t.clientId,apiKey:t.apiKey,scope:"https://www.googleapis.com/auth/userinfo.profile"});const i=new Ib(t,e);return Pb.push(i),t.sessionURL?await i.loadSession({url:t.sessionURL}):await i.loadSessionObject(t),i.navbarManager.navbarDidResize(i.$navigation.width()),i},removeBrowser:function(e){e.dispose(),e.root.remove(),Pb=Pb.filter((t=>t!==e))},removeAllBrowsers:function(){for(let e of Pb)e.dispose(),e.root.remove();Pb=[]},visibilityChange:async function(){for(let e of Pb)await e.visibilityChange()},setGoogleOauthToken:function(e){return no.setOauthToken(e)},setOauthToken:function(e,t){return no.setOauthToken(e,t)},oauth:zb,version:Ra,setApiKey:Db};return Hb}));
//# sourceMappingURL=igv.min.js.map