igv 2.12.4 → 2.12.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/dist/igv.esm.js +77 -81
- package/dist/igv.esm.min.js +6 -6
- package/dist/igv.esm.min.js.map +1 -1
- package/dist/igv.js +4540 -4479
- package/dist/igv.min.js +7 -7
- package/dist/igv.min.js.map +1 -1
- package/package.json +2 -2
package/dist/igv.esm.min.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* Date: 2018-01-20T17:24Z
|
|
13
13
|
*/
|
|
14
|
-
var t=[],e=window.document,n=Object.getPrototypeOf,r=t.slice,i=t.concat,o=t.push,s=t.indexOf,a={},c=a.toString,l=a.hasOwnProperty,h=l.toString,u=h.call(Object),f={},d=function(t){return"function"==typeof t&&"number"!=typeof t.nodeType},p=function(t){return null!=t&&t===t.window},g={type:!0,src:!0,noModule:!0};function m(t,n,r){var i,o=(n=n||e).createElement("script");if(o.text=t,r)for(i in g)r[i]&&(o[i]=r[i]);n.head.appendChild(o).parentNode.removeChild(o)}function
|
|
14
|
+
var t=[],e=window.document,n=Object.getPrototypeOf,r=t.slice,i=t.concat,o=t.push,s=t.indexOf,a={},c=a.toString,l=a.hasOwnProperty,h=l.toString,u=h.call(Object),f={},d=function(t){return"function"==typeof t&&"number"!=typeof t.nodeType},p=function(t){return null!=t&&t===t.window},g={type:!0,src:!0,noModule:!0};function m(t,n,r){var i,o=(n=n||e).createElement("script");if(o.text=t,r)for(i in g)r[i]&&(o[i]=r[i]);n.head.appendChild(o).parentNode.removeChild(o)}function v(t){return null==t?t+"":"object"==typeof t||"function"==typeof t?a[c.call(t)]||"object":typeof t}var b="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",w=function(t,e){return new w.fn.init(t,e)},y=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;function x(t){var e=!!t&&"length"in t&&t.length,n=v(t);return!d(t)&&!p(t)&&("array"===n||0===e||"number"==typeof e&&e>0&&e-1 in t)}w.fn=w.prototype={jquery:b,constructor:w,length:0,toArray:function(){return r.call(this)},get:function(t){return null==t?r.call(this):t<0?this[t+this.length]:this[t]},pushStack:function(t){var e=w.merge(this.constructor(),t);return e.prevObject=this,e},each:function(t){return w.each(this,t)},map:function(t){return this.pushStack(w.map(this,(function(e,n){return t.call(e,n,e)})))},slice:function(){return this.pushStack(r.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(t){var e=this.length,n=+t+(t<0?e:0);return this.pushStack(n>=0&&n<e?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:o,sort:t.sort,splice:t.splice},w.extend=w.fn.extend=function(){var t,e,n,r,i,o,s=arguments[0]||{},a=1,c=arguments.length,l=!1;for("boolean"==typeof s&&(l=s,s=arguments[a]||{},a++),"object"==typeof s||d(s)||(s={}),a===c&&(s=this,a--);a<c;a++)if(null!=(t=arguments[a]))for(e in t)n=s[e],s!==(r=t[e])&&(l&&r&&(w.isPlainObject(r)||(i=Array.isArray(r)))?(i?(i=!1,o=n&&Array.isArray(n)?n:[]):o=n&&w.isPlainObject(n)?n:{},s[e]=w.extend(l,o,r)):void 0!==r&&(s[e]=r));return s},w.extend({expando:"jQuery"+(b+Math.random()).replace(/\D/g,""),isReady:!0,error:function(t){throw new Error(t)},noop:function(){},isPlainObject:function(t){var e,r;return!(!t||"[object Object]"!==c.call(t))&&(!(e=n(t))||"function"==typeof(r=l.call(e,"constructor")&&e.constructor)&&h.call(r)===u)},isEmptyObject:function(t){var e;for(e in t)return!1;return!0},globalEval:function(t){m(t)},each:function(t,e){var n,r=0;if(x(t))for(n=t.length;r<n&&!1!==e.call(t[r],r,t[r]);r++);else for(r in t)if(!1===e.call(t[r],r,t[r]))break;return t},trim:function(t){return null==t?"":(t+"").replace(y,"")},makeArray:function(t,e){var n=e||[];return null!=t&&(x(Object(t))?w.merge(n,"string"==typeof t?[t]:t):o.call(n,t)),n},inArray:function(t,e,n){return null==e?-1:s.call(e,t,n)},merge:function(t,e){for(var n=+e.length,r=0,i=t.length;r<n;r++)t[i++]=e[r];return t.length=i,t},grep:function(t,e,n){for(var r=[],i=0,o=t.length,s=!n;i<o;i++)!e(t[i],i)!==s&&r.push(t[i]);return r},map:function(t,e,n){var r,o,s=0,a=[];if(x(t))for(r=t.length;s<r;s++)null!=(o=e(t[s],s,n))&&a.push(o);else for(s in t)null!=(o=e(t[s],s,n))&&a.push(o);return i.apply([],a)},guid:1,support:f}),"function"==typeof Symbol&&(w.fn[Symbol.iterator]=t[Symbol.iterator]),w.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),(function(t,e){a["[object "+e+"]"]=e.toLowerCase()}));var k=
|
|
15
15
|
/*!
|
|
16
16
|
* Sizzle CSS Selector Engine v2.3.3
|
|
17
17
|
* https://sizzlejs.com/
|
|
@@ -22,8 +22,8 @@ var t=[],e=window.document,n=Object.getPrototypeOf,r=t.slice,i=t.concat,o=t.push
|
|
|
22
22
|
*
|
|
23
23
|
* Date: 2016-08-08
|
|
24
24
|
*/
|
|
25
|
-
function(t){var e,n,r,i,o,s,a,c,l,h,u,f,d,p,g,m,v,b,w,y="sizzle"+1*new Date,x=t.document,k=0,_=0,S=st(),C=st(),E=st(),A=function(t,e){return t===e&&(u=!0),0},T={}.hasOwnProperty,L=[],M=L.pop,R=L.push,I=L.push,N=L.slice,P=function(t,e){for(var n=0,r=t.length;n<r;n++)if(t[n]===e)return n;return-1},O="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",F="[\\x20\\t\\r\\n\\f]",D="(?:\\\\.|[\\w-]|[^\0-\\xa0])+",B="\\[[\\x20\\t\\r\\n\\f]*("+D+")(?:"+F+"*([*^$|!~]?=)"+F+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+D+"))|)"+F+"*\\]",z=":("+D+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+B+")*)|.*)\\)|)",H=new RegExp(F+"+","g"),V=new RegExp("^[\\x20\\t\\r\\n\\f]+|((?:^|[^\\\\])(?:\\\\.)*)[\\x20\\t\\r\\n\\f]+$","g"),j=new RegExp("^[\\x20\\t\\r\\n\\f]*,[\\x20\\t\\r\\n\\f]*"),U=new RegExp("^[\\x20\\t\\r\\n\\f]*([>+~]|[\\x20\\t\\r\\n\\f])[\\x20\\t\\r\\n\\f]*"),q=new RegExp("=[\\x20\\t\\r\\n\\f]*([^\\]'\"]*?)[\\x20\\t\\r\\n\\f]*\\]","g"),W=new RegExp(z),$=new RegExp("^"+D+"$"),G={ID:new RegExp("^#("+D+")"),CLASS:new RegExp("^\\.("+D+")"),TAG:new RegExp("^("+D+"|[*])"),ATTR:new RegExp("^"+B),PSEUDO:new RegExp("^"+z),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\([\\x20\\t\\r\\n\\f]*(even|odd|(([+-]|)(\\d*)n|)[\\x20\\t\\r\\n\\f]*(?:([+-]|)[\\x20\\t\\r\\n\\f]*(\\d+)|))[\\x20\\t\\r\\n\\f]*\\)|)","i"),bool:new RegExp("^(?:"+O+")$","i"),needsContext:new RegExp("^[\\x20\\t\\r\\n\\f]*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\([\\x20\\t\\r\\n\\f]*((?:-\\d)?\\d*)[\\x20\\t\\r\\n\\f]*\\)|)(?=[^-]|$)","i")},Z=/^(?:input|select|textarea|button)$/i,X=/^h\d$/i,Y=/^[^{]+\{\s*\[native \w/,K=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,Q=/[+~]/,J=new RegExp("\\\\([\\da-f]{1,6}[\\x20\\t\\r\\n\\f]?|([\\x20\\t\\r\\n\\f])|.)","ig"),tt=function(t,e,n){var r="0x"+e-65536;return r!=r||n?e:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},et=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,nt=function(t,e){return e?"\0"===t?"�":t.slice(0,-1)+"\\"+t.charCodeAt(t.length-1).toString(16)+" ":"\\"+t},rt=function(){f()},it=vt((function(t){return!0===t.disabled&&("form"in t||"label"in t)}),{dir:"parentNode",next:"legend"});try{I.apply(L=N.call(x.childNodes),x.childNodes),L[x.childNodes.length].nodeType}catch(t){I={apply:L.length?function(t,e){R.apply(t,N.call(e))}:function(t,e){for(var n=t.length,r=0;t[n++]=e[r++];);t.length=n-1}}}function ot(t,e,r,i){var o,a,l,h,u,p,v,b=e&&e.ownerDocument,k=e?e.nodeType:9;if(r=r||[],"string"!=typeof t||!t||1!==k&&9!==k&&11!==k)return r;if(!i&&((e?e.ownerDocument||e:x)!==d&&f(e),e=e||d,g)){if(11!==k&&(u=K.exec(t)))if(o=u[1]){if(9===k){if(!(l=e.getElementById(o)))return r;if(l.id===o)return r.push(l),r}else if(b&&(l=b.getElementById(o))&&w(e,l)&&l.id===o)return r.push(l),r}else{if(u[2])return I.apply(r,e.getElementsByTagName(t)),r;if((o=u[3])&&n.getElementsByClassName&&e.getElementsByClassName)return I.apply(r,e.getElementsByClassName(o)),r}if(n.qsa&&!E[t+" "]&&(!m||!m.test(t))){if(1!==k)b=e,v=t;else if("object"!==e.nodeName.toLowerCase()){for((h=e.getAttribute("id"))?h=h.replace(et,nt):e.setAttribute("id",h=y),a=(p=s(t)).length;a--;)p[a]="#"+h+" "+mt(p[a]);v=p.join(","),b=Q.test(t)&&pt(e.parentNode)||e}if(v)try{return I.apply(r,b.querySelectorAll(v)),r}catch(t){}finally{h===y&&e.removeAttribute("id")}}}return c(t.replace(V,"$1"),e,r,i)}function st(){var t=[];return function e(n,i){return t.push(n+" ")>r.cacheLength&&delete e[t.shift()],e[n+" "]=i}}function at(t){return t[y]=!0,t}function ct(t){var e=d.createElement("fieldset");try{return!!t(e)}catch(t){return!1}finally{e.parentNode&&e.parentNode.removeChild(e),e=null}}function lt(t,e){var n=e&&t,r=n&&1===t.nodeType&&1===e.nodeType&&t.sourceIndex-e.sourceIndex;if(r)return r;if(n)for(;n=n.nextSibling;)if(n===e)return-1;return t?1:-1}function ht(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function ut(t){return function(e){var n=e.nodeName.toLowerCase();return("input"===n||"button"===n)&&e.type===t}}function ft(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&it(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function dt(t){return at((function(e){return e=+e,at((function(n,r){for(var i,o=t([],n.length,e),s=o.length;s--;)n[i=o[s]]&&(n[i]=!(r[i]=n[i]))}))}))}function pt(t){return t&&void 0!==t.getElementsByTagName&&t}for(e in n=ot.support={},o=ot.isXML=function(t){var e=t&&(t.ownerDocument||t).documentElement;return!!e&&"HTML"!==e.nodeName},f=ot.setDocument=function(t){var e,i,s=t?t.ownerDocument||t:x;return s!==d&&9===s.nodeType&&s.documentElement?(p=(d=s).documentElement,g=!o(d),x!==d&&(i=d.defaultView)&&i.top!==i&&(i.addEventListener?i.addEventListener("unload",rt,!1):i.attachEvent&&i.attachEvent("onunload",rt)),n.attributes=ct((function(t){return t.className="i",!t.getAttribute("className")})),n.getElementsByTagName=ct((function(t){return t.appendChild(d.createComment("")),!t.getElementsByTagName("*").length})),n.getElementsByClassName=Y.test(d.getElementsByClassName),n.getById=ct((function(t){return p.appendChild(t).id=y,!d.getElementsByName||!d.getElementsByName(y).length})),n.getById?(r.filter.ID=function(t){var e=t.replace(J,tt);return function(t){return t.getAttribute("id")===e}},r.find.ID=function(t,e){if(void 0!==e.getElementById&&g){var n=e.getElementById(t);return n?[n]:[]}}):(r.filter.ID=function(t){var e=t.replace(J,tt);return function(t){var n=void 0!==t.getAttributeNode&&t.getAttributeNode("id");return n&&n.value===e}},r.find.ID=function(t,e){if(void 0!==e.getElementById&&g){var n,r,i,o=e.getElementById(t);if(o){if((n=o.getAttributeNode("id"))&&n.value===t)return[o];for(i=e.getElementsByName(t),r=0;o=i[r++];)if((n=o.getAttributeNode("id"))&&n.value===t)return[o]}return[]}}),r.find.TAG=n.getElementsByTagName?function(t,e){return void 0!==e.getElementsByTagName?e.getElementsByTagName(t):n.qsa?e.querySelectorAll(t):void 0}:function(t,e){var n,r=[],i=0,o=e.getElementsByTagName(t);if("*"===t){for(;n=o[i++];)1===n.nodeType&&r.push(n);return r}return o},r.find.CLASS=n.getElementsByClassName&&function(t,e){if(void 0!==e.getElementsByClassName&&g)return e.getElementsByClassName(t)},v=[],m=[],(n.qsa=Y.test(d.querySelectorAll))&&(ct((function(t){p.appendChild(t).innerHTML="<a id='"+y+"'></a><select id='"+y+"-\r\\' msallowcapture=''><option selected=''></option></select>",t.querySelectorAll("[msallowcapture^='']").length&&m.push("[*^$]=[\\x20\\t\\r\\n\\f]*(?:''|\"\")"),t.querySelectorAll("[selected]").length||m.push("\\[[\\x20\\t\\r\\n\\f]*(?:value|"+O+")"),t.querySelectorAll("[id~="+y+"-]").length||m.push("~="),t.querySelectorAll(":checked").length||m.push(":checked"),t.querySelectorAll("a#"+y+"+*").length||m.push(".#.+[+~]")})),ct((function(t){t.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var e=d.createElement("input");e.setAttribute("type","hidden"),t.appendChild(e).setAttribute("name","D"),t.querySelectorAll("[name=d]").length&&m.push("name[\\x20\\t\\r\\n\\f]*[*^$|!~]?="),2!==t.querySelectorAll(":enabled").length&&m.push(":enabled",":disabled"),p.appendChild(t).disabled=!0,2!==t.querySelectorAll(":disabled").length&&m.push(":enabled",":disabled"),t.querySelectorAll("*,:x"),m.push(",.*:")}))),(n.matchesSelector=Y.test(b=p.matches||p.webkitMatchesSelector||p.mozMatchesSelector||p.oMatchesSelector||p.msMatchesSelector))&&ct((function(t){n.disconnectedMatch=b.call(t,"*"),b.call(t,"[s!='']:x"),v.push("!=",z)})),m=m.length&&new RegExp(m.join("|")),v=v.length&&new RegExp(v.join("|")),e=Y.test(p.compareDocumentPosition),w=e||Y.test(p.contains)?function(t,e){var n=9===t.nodeType?t.documentElement:t,r=e&&e.parentNode;return t===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):t.compareDocumentPosition&&16&t.compareDocumentPosition(r)))}:function(t,e){if(e)for(;e=e.parentNode;)if(e===t)return!0;return!1},A=e?function(t,e){if(t===e)return u=!0,0;var r=!t.compareDocumentPosition-!e.compareDocumentPosition;return r||(1&(r=(t.ownerDocument||t)===(e.ownerDocument||e)?t.compareDocumentPosition(e):1)||!n.sortDetached&&e.compareDocumentPosition(t)===r?t===d||t.ownerDocument===x&&w(x,t)?-1:e===d||e.ownerDocument===x&&w(x,e)?1:h?P(h,t)-P(h,e):0:4&r?-1:1)}:function(t,e){if(t===e)return u=!0,0;var n,r=0,i=t.parentNode,o=e.parentNode,s=[t],a=[e];if(!i||!o)return t===d?-1:e===d?1:i?-1:o?1:h?P(h,t)-P(h,e):0;if(i===o)return lt(t,e);for(n=t;n=n.parentNode;)s.unshift(n);for(n=e;n=n.parentNode;)a.unshift(n);for(;s[r]===a[r];)r++;return r?lt(s[r],a[r]):s[r]===x?-1:a[r]===x?1:0},d):d},ot.matches=function(t,e){return ot(t,null,null,e)},ot.matchesSelector=function(t,e){if((t.ownerDocument||t)!==d&&f(t),e=e.replace(q,"='$1']"),n.matchesSelector&&g&&!E[e+" "]&&(!v||!v.test(e))&&(!m||!m.test(e)))try{var r=b.call(t,e);if(r||n.disconnectedMatch||t.document&&11!==t.document.nodeType)return r}catch(t){}return ot(e,d,null,[t]).length>0},ot.contains=function(t,e){return(t.ownerDocument||t)!==d&&f(t),w(t,e)},ot.attr=function(t,e){(t.ownerDocument||t)!==d&&f(t);var i=r.attrHandle[e.toLowerCase()],o=i&&T.call(r.attrHandle,e.toLowerCase())?i(t,e,!g):void 0;return void 0!==o?o:n.attributes||!g?t.getAttribute(e):(o=t.getAttributeNode(e))&&o.specified?o.value:null},ot.escape=function(t){return(t+"").replace(et,nt)},ot.error=function(t){throw new Error("Syntax error, unrecognized expression: "+t)},ot.uniqueSort=function(t){var e,r=[],i=0,o=0;if(u=!n.detectDuplicates,h=!n.sortStable&&t.slice(0),t.sort(A),u){for(;e=t[o++];)e===t[o]&&(i=r.push(o));for(;i--;)t.splice(r[i],1)}return h=null,t},i=ot.getText=function(t){var e,n="",r=0,o=t.nodeType;if(o){if(1===o||9===o||11===o){if("string"==typeof t.textContent)return t.textContent;for(t=t.firstChild;t;t=t.nextSibling)n+=i(t)}else if(3===o||4===o)return t.nodeValue}else for(;e=t[r++];)n+=i(e);return n},r=ot.selectors={cacheLength:50,createPseudo:at,match:G,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(t){return t[1]=t[1].replace(J,tt),t[3]=(t[3]||t[4]||t[5]||"").replace(J,tt),"~="===t[2]&&(t[3]=" "+t[3]+" "),t.slice(0,4)},CHILD:function(t){return t[1]=t[1].toLowerCase(),"nth"===t[1].slice(0,3)?(t[3]||ot.error(t[0]),t[4]=+(t[4]?t[5]+(t[6]||1):2*("even"===t[3]||"odd"===t[3])),t[5]=+(t[7]+t[8]||"odd"===t[3])):t[3]&&ot.error(t[0]),t},PSEUDO:function(t){var e,n=!t[6]&&t[2];return G.CHILD.test(t[0])?null:(t[3]?t[2]=t[4]||t[5]||"":n&&W.test(n)&&(e=s(n,!0))&&(e=n.indexOf(")",n.length-e)-n.length)&&(t[0]=t[0].slice(0,e),t[2]=n.slice(0,e)),t.slice(0,3))}},filter:{TAG:function(t){var e=t.replace(J,tt).toLowerCase();return"*"===t?function(){return!0}:function(t){return t.nodeName&&t.nodeName.toLowerCase()===e}},CLASS:function(t){var e=S[t+" "];return e||(e=new RegExp("(^|[\\x20\\t\\r\\n\\f])"+t+"("+F+"|$)"))&&S(t,(function(t){return e.test("string"==typeof t.className&&t.className||void 0!==t.getAttribute&&t.getAttribute("class")||"")}))},ATTR:function(t,e,n){return function(r){var i=ot.attr(r,t);return null==i?"!="===e:!e||(i+="","="===e?i===n:"!="===e?i!==n:"^="===e?n&&0===i.indexOf(n):"*="===e?n&&i.indexOf(n)>-1:"$="===e?n&&i.slice(-n.length)===n:"~="===e?(" "+i.replace(H," ")+" ").indexOf(n)>-1:"|="===e&&(i===n||i.slice(0,n.length+1)===n+"-"))}},CHILD:function(t,e,n,r,i){var o="nth"!==t.slice(0,3),s="last"!==t.slice(-4),a="of-type"===e;return 1===r&&0===i?function(t){return!!t.parentNode}:function(e,n,c){var l,h,u,f,d,p,g=o!==s?"nextSibling":"previousSibling",m=e.parentNode,v=a&&e.nodeName.toLowerCase(),b=!c&&!a,w=!1;if(m){if(o){for(;g;){for(f=e;f=f[g];)if(a?f.nodeName.toLowerCase()===v:1===f.nodeType)return!1;p=g="only"===t&&!p&&"nextSibling"}return!0}if(p=[s?m.firstChild:m.lastChild],s&&b){for(w=(d=(l=(h=(u=(f=m)[y]||(f[y]={}))[f.uniqueID]||(u[f.uniqueID]={}))[t]||[])[0]===k&&l[1])&&l[2],f=d&&m.childNodes[d];f=++d&&f&&f[g]||(w=d=0)||p.pop();)if(1===f.nodeType&&++w&&f===e){h[t]=[k,d,w];break}}else if(b&&(w=d=(l=(h=(u=(f=e)[y]||(f[y]={}))[f.uniqueID]||(u[f.uniqueID]={}))[t]||[])[0]===k&&l[1]),!1===w)for(;(f=++d&&f&&f[g]||(w=d=0)||p.pop())&&((a?f.nodeName.toLowerCase()!==v:1!==f.nodeType)||!++w||(b&&((h=(u=f[y]||(f[y]={}))[f.uniqueID]||(u[f.uniqueID]={}))[t]=[k,w]),f!==e)););return(w-=i)===r||w%r==0&&w/r>=0}}},PSEUDO:function(t,e){var n,i=r.pseudos[t]||r.setFilters[t.toLowerCase()]||ot.error("unsupported pseudo: "+t);return i[y]?i(e):i.length>1?(n=[t,t,"",e],r.setFilters.hasOwnProperty(t.toLowerCase())?at((function(t,n){for(var r,o=i(t,e),s=o.length;s--;)t[r=P(t,o[s])]=!(n[r]=o[s])})):function(t){return i(t,0,n)}):i}},pseudos:{not:at((function(t){var e=[],n=[],r=a(t.replace(V,"$1"));return r[y]?at((function(t,e,n,i){for(var o,s=r(t,null,i,[]),a=t.length;a--;)(o=s[a])&&(t[a]=!(e[a]=o))})):function(t,i,o){return e[0]=t,r(e,null,o,n),e[0]=null,!n.pop()}})),has:at((function(t){return function(e){return ot(t,e).length>0}})),contains:at((function(t){return t=t.replace(J,tt),function(e){return(e.textContent||e.innerText||i(e)).indexOf(t)>-1}})),lang:at((function(t){return $.test(t||"")||ot.error("unsupported lang: "+t),t=t.replace(J,tt).toLowerCase(),function(e){var n;do{if(n=g?e.lang:e.getAttribute("xml:lang")||e.getAttribute("lang"))return(n=n.toLowerCase())===t||0===n.indexOf(t+"-")}while((e=e.parentNode)&&1===e.nodeType);return!1}})),target:function(e){var n=t.location&&t.location.hash;return n&&n.slice(1)===e.id},root:function(t){return t===p},focus:function(t){return t===d.activeElement&&(!d.hasFocus||d.hasFocus())&&!!(t.type||t.href||~t.tabIndex)},enabled:ft(!1),disabled:ft(!0),checked:function(t){var e=t.nodeName.toLowerCase();return"input"===e&&!!t.checked||"option"===e&&!!t.selected},selected:function(t){return t.parentNode&&t.parentNode.selectedIndex,!0===t.selected},empty:function(t){for(t=t.firstChild;t;t=t.nextSibling)if(t.nodeType<6)return!1;return!0},parent:function(t){return!r.pseudos.empty(t)},header:function(t){return X.test(t.nodeName)},input:function(t){return Z.test(t.nodeName)},button:function(t){var e=t.nodeName.toLowerCase();return"input"===e&&"button"===t.type||"button"===e},text:function(t){var e;return"input"===t.nodeName.toLowerCase()&&"text"===t.type&&(null==(e=t.getAttribute("type"))||"text"===e.toLowerCase())},first:dt((function(){return[0]})),last:dt((function(t,e){return[e-1]})),eq:dt((function(t,e,n){return[n<0?n+e:n]})),even:dt((function(t,e){for(var n=0;n<e;n+=2)t.push(n);return t})),odd:dt((function(t,e){for(var n=1;n<e;n+=2)t.push(n);return t})),lt:dt((function(t,e,n){for(var r=n<0?n+e:n;--r>=0;)t.push(r);return t})),gt:dt((function(t,e,n){for(var r=n<0?n+e:n;++r<e;)t.push(r);return t}))}},r.pseudos.nth=r.pseudos.eq,{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})r.pseudos[e]=ht(e);for(e in{submit:!0,reset:!0})r.pseudos[e]=ut(e);function gt(){}function mt(t){for(var e=0,n=t.length,r="";e<n;e++)r+=t[e].value;return r}function vt(t,e,n){var r=e.dir,i=e.next,o=i||r,s=n&&"parentNode"===o,a=_++;return e.first?function(e,n,i){for(;e=e[r];)if(1===e.nodeType||s)return t(e,n,i);return!1}:function(e,n,c){var l,h,u,f=[k,a];if(c){for(;e=e[r];)if((1===e.nodeType||s)&&t(e,n,c))return!0}else for(;e=e[r];)if(1===e.nodeType||s)if(h=(u=e[y]||(e[y]={}))[e.uniqueID]||(u[e.uniqueID]={}),i&&i===e.nodeName.toLowerCase())e=e[r]||e;else{if((l=h[o])&&l[0]===k&&l[1]===a)return f[2]=l[2];if(h[o]=f,f[2]=t(e,n,c))return!0}return!1}}function bt(t){return t.length>1?function(e,n,r){for(var i=t.length;i--;)if(!t[i](e,n,r))return!1;return!0}:t[0]}function wt(t,e,n,r,i){for(var o,s=[],a=0,c=t.length,l=null!=e;a<c;a++)(o=t[a])&&(n&&!n(o,r,i)||(s.push(o),l&&e.push(a)));return s}function yt(t,e,n,r,i,o){return r&&!r[y]&&(r=yt(r)),i&&!i[y]&&(i=yt(i,o)),at((function(o,s,a,c){var l,h,u,f=[],d=[],p=s.length,g=o||function(t,e,n){for(var r=0,i=e.length;r<i;r++)ot(t,e[r],n);return n}(e||"*",a.nodeType?[a]:a,[]),m=!t||!o&&e?g:wt(g,f,t,a,c),v=n?i||(o?t:p||r)?[]:s:m;if(n&&n(m,v,a,c),r)for(l=wt(v,d),r(l,[],a,c),h=l.length;h--;)(u=l[h])&&(v[d[h]]=!(m[d[h]]=u));if(o){if(i||t){if(i){for(l=[],h=v.length;h--;)(u=v[h])&&l.push(m[h]=u);i(null,v=[],l,c)}for(h=v.length;h--;)(u=v[h])&&(l=i?P(o,u):f[h])>-1&&(o[l]=!(s[l]=u))}}else v=wt(v===s?v.splice(p,v.length):v),i?i(null,s,v,c):I.apply(s,v)}))}function xt(t){for(var e,n,i,o=t.length,s=r.relative[t[0].type],a=s||r.relative[" "],c=s?1:0,h=vt((function(t){return t===e}),a,!0),u=vt((function(t){return P(e,t)>-1}),a,!0),f=[function(t,n,r){var i=!s&&(r||n!==l)||((e=n).nodeType?h(t,n,r):u(t,n,r));return e=null,i}];c<o;c++)if(n=r.relative[t[c].type])f=[vt(bt(f),n)];else{if((n=r.filter[t[c].type].apply(null,t[c].matches))[y]){for(i=++c;i<o&&!r.relative[t[i].type];i++);return yt(c>1&&bt(f),c>1&&mt(t.slice(0,c-1).concat({value:" "===t[c-2].type?"*":""})).replace(V,"$1"),n,c<i&&xt(t.slice(c,i)),i<o&&xt(t=t.slice(i)),i<o&&mt(t))}f.push(n)}return bt(f)}return gt.prototype=r.filters=r.pseudos,r.setFilters=new gt,s=ot.tokenize=function(t,e){var n,i,o,s,a,c,l,h=C[t+" "];if(h)return e?0:h.slice(0);for(a=t,c=[],l=r.preFilter;a;){for(s in n&&!(i=j.exec(a))||(i&&(a=a.slice(i[0].length)||a),c.push(o=[])),n=!1,(i=U.exec(a))&&(n=i.shift(),o.push({value:n,type:i[0].replace(V," ")}),a=a.slice(n.length)),r.filter)!(i=G[s].exec(a))||l[s]&&!(i=l[s](i))||(n=i.shift(),o.push({value:n,type:s,matches:i}),a=a.slice(n.length));if(!n)break}return e?a.length:a?ot.error(t):C(t,c).slice(0)},a=ot.compile=function(t,e){var n,i=[],o=[],a=E[t+" "];if(!a){for(e||(e=s(t)),n=e.length;n--;)(a=xt(e[n]))[y]?i.push(a):o.push(a);a=E(t,function(t,e){var n=e.length>0,i=t.length>0,o=function(o,s,a,c,h){var u,p,m,v=0,b="0",w=o&&[],y=[],x=l,_=o||i&&r.find.TAG("*",h),S=k+=null==x?1:Math.random()||.1,C=_.length;for(h&&(l=s===d||s||h);b!==C&&null!=(u=_[b]);b++){if(i&&u){for(p=0,s||u.ownerDocument===d||(f(u),a=!g);m=t[p++];)if(m(u,s||d,a)){c.push(u);break}h&&(k=S)}n&&((u=!m&&u)&&v--,o&&w.push(u))}if(v+=b,n&&b!==v){for(p=0;m=e[p++];)m(w,y,s,a);if(o){if(v>0)for(;b--;)w[b]||y[b]||(y[b]=M.call(c));y=wt(y)}I.apply(c,y),h&&!o&&y.length>0&&v+e.length>1&&ot.uniqueSort(c)}return h&&(k=S,l=x),w};return n?at(o):o}(o,i)),a.selector=t}return a},c=ot.select=function(t,e,n,i){var o,c,l,h,u,f="function"==typeof t&&t,d=!i&&s(t=f.selector||t);if(n=n||[],1===d.length){if((c=d[0]=d[0].slice(0)).length>2&&"ID"===(l=c[0]).type&&9===e.nodeType&&g&&r.relative[c[1].type]){if(!(e=(r.find.ID(l.matches[0].replace(J,tt),e)||[])[0]))return n;f&&(e=e.parentNode),t=t.slice(c.shift().value.length)}for(o=G.needsContext.test(t)?0:c.length;o--&&(l=c[o],!r.relative[h=l.type]);)if((u=r.find[h])&&(i=u(l.matches[0].replace(J,tt),Q.test(c[0].type)&&pt(e.parentNode)||e))){if(c.splice(o,1),!(t=i.length&&mt(c)))return I.apply(n,i),n;break}}return(f||a(t,d))(i,e,!g,n,!e||Q.test(t)&&pt(e.parentNode)||e),n},n.sortStable=y.split("").sort(A).join("")===y,n.detectDuplicates=!!u,f(),ot}(window);y.find=_,y.expr=_.selectors,y.expr[":"]=y.expr.pseudos,y.uniqueSort=y.unique=_.uniqueSort,y.text=_.getText,y.isXMLDoc=_.isXML,y.contains=_.contains,y.escapeSelector=_.escape;var S=function(t,e,n){for(var r=[],i=void 0!==n;(t=t[e])&&9!==t.nodeType;)if(1===t.nodeType){if(i&&y(t).is(n))break;r.push(t)}return r},C=function(t,e){for(var n=[];t;t=t.nextSibling)1===t.nodeType&&t!==e&&n.push(t);return n},E=y.expr.match.needsContext;function A(t,e){return t.nodeName&&t.nodeName.toLowerCase()===e.toLowerCase()}var T=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function L(t,e,n){return d(e)?y.grep(t,(function(t,r){return!!e.call(t,r,t)!==n})):e.nodeType?y.grep(t,(function(t){return t===e!==n})):"string"!=typeof e?y.grep(t,(function(t){return s.call(e,t)>-1!==n})):y.filter(e,t,n)}y.filter=function(t,e,n){var r=e[0];return n&&(t=":not("+t+")"),1===e.length&&1===r.nodeType?y.find.matchesSelector(r,t)?[r]:[]:y.find.matches(t,y.grep(e,(function(t){return 1===t.nodeType})))},y.fn.extend({find:function(t){var e,n,r=this.length,i=this;if("string"!=typeof t)return this.pushStack(y(t).filter((function(){for(e=0;e<r;e++)if(y.contains(i[e],this))return!0})));for(n=this.pushStack([]),e=0;e<r;e++)y.find(t,i[e],n);return r>1?y.uniqueSort(n):n},filter:function(t){return this.pushStack(L(this,t||[],!1))},not:function(t){return this.pushStack(L(this,t||[],!0))},is:function(t){return!!L(this,"string"==typeof t&&E.test(t)?y(t):t||[],!1).length}});var M,R=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(y.fn.init=function(t,n,r){var i,o;if(!t)return this;if(r=r||M,"string"==typeof t){if(!(i="<"===t[0]&&">"===t[t.length-1]&&t.length>=3?[null,t,null]:R.exec(t))||!i[1]&&n)return!n||n.jquery?(n||r).find(t):this.constructor(n).find(t);if(i[1]){if(n=n instanceof y?n[0]:n,y.merge(this,y.parseHTML(i[1],n&&n.nodeType?n.ownerDocument||n:e,!0)),T.test(i[1])&&y.isPlainObject(n))for(i in n)d(this[i])?this[i](n[i]):this.attr(i,n[i]);return this}return(o=e.getElementById(i[2]))&&(this[0]=o,this.length=1),this}return t.nodeType?(this[0]=t,this.length=1,this):d(t)?void 0!==r.ready?r.ready(t):t(y):y.makeArray(t,this)}).prototype=y.fn,M=y(e);var I=/^(?:parents|prev(?:Until|All))/,N={children:!0,contents:!0,next:!0,prev:!0};function P(t,e){for(;(t=t[e])&&1!==t.nodeType;);return t}y.fn.extend({has:function(t){var e=y(t,this),n=e.length;return this.filter((function(){for(var t=0;t<n;t++)if(y.contains(this,e[t]))return!0}))},closest:function(t,e){var n,r=0,i=this.length,o=[],s="string"!=typeof t&&y(t);if(!E.test(t))for(;r<i;r++)for(n=this[r];n&&n!==e;n=n.parentNode)if(n.nodeType<11&&(s?s.index(n)>-1:1===n.nodeType&&y.find.matchesSelector(n,t))){o.push(n);break}return this.pushStack(o.length>1?y.uniqueSort(o):o)},index:function(t){return t?"string"==typeof t?s.call(y(t),this[0]):s.call(this,t.jquery?t[0]:t):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(t,e){return this.pushStack(y.uniqueSort(y.merge(this.get(),y(t,e))))},addBack:function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}}),y.each({parent:function(t){var e=t.parentNode;return e&&11!==e.nodeType?e:null},parents:function(t){return S(t,"parentNode")},parentsUntil:function(t,e,n){return S(t,"parentNode",n)},next:function(t){return P(t,"nextSibling")},prev:function(t){return P(t,"previousSibling")},nextAll:function(t){return S(t,"nextSibling")},prevAll:function(t){return S(t,"previousSibling")},nextUntil:function(t,e,n){return S(t,"nextSibling",n)},prevUntil:function(t,e,n){return S(t,"previousSibling",n)},siblings:function(t){return C((t.parentNode||{}).firstChild,t)},children:function(t){return C(t.firstChild)},contents:function(t){return A(t,"iframe")?t.contentDocument:(A(t,"template")&&(t=t.content||t),y.merge([],t.childNodes))}},(function(t,e){y.fn[t]=function(n,r){var i=y.map(this,e,n);return"Until"!==t.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=y.filter(r,i)),this.length>1&&(N[t]||y.uniqueSort(i),I.test(t)&&i.reverse()),this.pushStack(i)}}));var O=/[^\x20\t\r\n\f]+/g;function F(t){return t}function D(t){throw t}function B(t,e,n,r){var i;try{t&&d(i=t.promise)?i.call(t).done(e).fail(n):t&&d(i=t.then)?i.call(t,e,n):e.apply(void 0,[t].slice(r))}catch(t){n.apply(void 0,[t])}}y.Callbacks=function(t){t="string"==typeof t?function(t){var e={};return y.each(t.match(O)||[],(function(t,n){e[n]=!0})),e}(t):y.extend({},t);var e,n,r,i,o=[],s=[],a=-1,c=function(){for(i=i||t.once,r=e=!0;s.length;a=-1)for(n=s.shift();++a<o.length;)!1===o[a].apply(n[0],n[1])&&t.stopOnFalse&&(a=o.length,n=!1);t.memory||(n=!1),e=!1,i&&(o=n?[]:"")},l={add:function(){return o&&(n&&!e&&(a=o.length-1,s.push(n)),function e(n){y.each(n,(function(n,r){d(r)?t.unique&&l.has(r)||o.push(r):r&&r.length&&"string"!==b(r)&&e(r)}))}(arguments),n&&!e&&c()),this},remove:function(){return y.each(arguments,(function(t,e){for(var n;(n=y.inArray(e,o,n))>-1;)o.splice(n,1),n<=a&&a--})),this},has:function(t){return t?y.inArray(t,o)>-1:o.length>0},empty:function(){return o&&(o=[]),this},disable:function(){return i=s=[],o=n="",this},disabled:function(){return!o},lock:function(){return i=s=[],n||e||(o=n=""),this},locked:function(){return!!i},fireWith:function(t,n){return i||(n=[t,(n=n||[]).slice?n.slice():n],s.push(n),e||c()),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!r}};return l},y.extend({Deferred:function(t){var e=[["notify","progress",y.Callbacks("memory"),y.Callbacks("memory"),2],["resolve","done",y.Callbacks("once memory"),y.Callbacks("once memory"),0,"resolved"],["reject","fail",y.Callbacks("once memory"),y.Callbacks("once memory"),1,"rejected"]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},catch:function(t){return r.then(null,t)},pipe:function(){var t=arguments;return y.Deferred((function(n){y.each(e,(function(e,r){var o=d(t[r[4]])&&t[r[4]];i[r[1]]((function(){var t=o&&o.apply(this,arguments);t&&d(t.promise)?t.promise().progress(n.notify).done(n.resolve).fail(n.reject):n[r[0]+"With"](this,o?[t]:arguments)}))})),t=null})).promise()},then:function(t,n,r){var i=0;function o(t,e,n,r){return function(){var s=this,a=arguments,c=function(){var c,l;if(!(t<i)){if((c=n.apply(s,a))===e.promise())throw new TypeError("Thenable self-resolution");l=c&&("object"==typeof c||"function"==typeof c)&&c.then,d(l)?r?l.call(c,o(i,e,F,r),o(i,e,D,r)):(i++,l.call(c,o(i,e,F,r),o(i,e,D,r),o(i,e,F,e.notifyWith))):(n!==F&&(s=void 0,a=[c]),(r||e.resolveWith)(s,a))}},l=r?c:function(){try{c()}catch(r){y.Deferred.exceptionHook&&y.Deferred.exceptionHook(r,l.stackTrace),t+1>=i&&(n!==D&&(s=void 0,a=[r]),e.rejectWith(s,a))}};t?l():(y.Deferred.getStackHook&&(l.stackTrace=y.Deferred.getStackHook()),window.setTimeout(l))}}return y.Deferred((function(i){e[0][3].add(o(0,i,d(r)?r:F,i.notifyWith)),e[1][3].add(o(0,i,d(t)?t:F)),e[2][3].add(o(0,i,d(n)?n:D))})).promise()},promise:function(t){return null!=t?y.extend(t,r):r}},i={};return y.each(e,(function(t,o){var s=o[2],a=o[5];r[o[1]]=s.add,a&&s.add((function(){n=a}),e[3-t][2].disable,e[3-t][3].disable,e[0][2].lock,e[0][3].lock),s.add(o[3].fire),i[o[0]]=function(){return i[o[0]+"With"](this===i?void 0:this,arguments),this},i[o[0]+"With"]=s.fireWith})),r.promise(i),t&&t.call(i,i),i},when:function(t){var e=arguments.length,n=e,i=Array(n),o=r.call(arguments),s=y.Deferred(),a=function(t){return function(n){i[t]=this,o[t]=arguments.length>1?r.call(arguments):n,--e||s.resolveWith(i,o)}};if(e<=1&&(B(t,s.done(a(n)).resolve,s.reject,!e),"pending"===s.state()||d(o[n]&&o[n].then)))return s.then();for(;n--;)B(o[n],a(n),s.reject);return s.promise()}});var z=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;y.Deferred.exceptionHook=function(t,e){window.console&&window.console.warn&&t&&z.test(t.name)&&window.console.warn("jQuery.Deferred exception: "+t.message,t.stack,e)},y.readyException=function(t){window.setTimeout((function(){throw t}))};var H=y.Deferred();function V(){e.removeEventListener("DOMContentLoaded",V),window.removeEventListener("load",V),y.ready()}y.fn.ready=function(t){return H.then(t).catch((function(t){y.readyException(t)})),this},y.extend({isReady:!1,readyWait:1,ready:function(t){(!0===t?--y.readyWait:y.isReady)||(y.isReady=!0,!0!==t&&--y.readyWait>0||H.resolveWith(e,[y]))}}),y.ready.then=H.then,"complete"===e.readyState||"loading"!==e.readyState&&!e.documentElement.doScroll?window.setTimeout(y.ready):(e.addEventListener("DOMContentLoaded",V),window.addEventListener("load",V));var j=function(t,e,n,r,i,o,s){var a=0,c=t.length,l=null==n;if("object"===b(n))for(a in i=!0,n)j(t,e,a,n[a],!0,o,s);else if(void 0!==r&&(i=!0,d(r)||(s=!0),l&&(s?(e.call(t,r),e=null):(l=e,e=function(t,e,n){return l.call(y(t),n)})),e))for(;a<c;a++)e(t[a],n,s?r:r.call(t[a],a,e(t[a],n)));return i?t:l?e.call(t):c?e(t[0],n):o},U=/^-ms-/,q=/-([a-z])/g;function W(t,e){return e.toUpperCase()}function $(t){return t.replace(U,"ms-").replace(q,W)}var G=function(t){return 1===t.nodeType||9===t.nodeType||!+t.nodeType};function Z(){this.expando=y.expando+Z.uid++}Z.uid=1,Z.prototype={cache:function(t){var e=t[this.expando];return e||(e={},G(t)&&(t.nodeType?t[this.expando]=e:Object.defineProperty(t,this.expando,{value:e,configurable:!0}))),e},set:function(t,e,n){var r,i=this.cache(t);if("string"==typeof e)i[$(e)]=n;else for(r in e)i[$(r)]=e[r];return i},get:function(t,e){return void 0===e?this.cache(t):t[this.expando]&&t[this.expando][$(e)]},access:function(t,e,n){return void 0===e||e&&"string"==typeof e&&void 0===n?this.get(t,e):(this.set(t,e,n),void 0!==n?n:e)},remove:function(t,e){var n,r=t[this.expando];if(void 0!==r){if(void 0!==e){n=(e=Array.isArray(e)?e.map($):(e=$(e))in r?[e]:e.match(O)||[]).length;for(;n--;)delete r[e[n]]}(void 0===e||y.isEmptyObject(r))&&(t.nodeType?t[this.expando]=void 0:delete t[this.expando])}},hasData:function(t){var e=t[this.expando];return void 0!==e&&!y.isEmptyObject(e)}};var X=new Z,Y=new Z,K=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,Q=/[A-Z]/g;function J(t,e,n){var r;if(void 0===n&&1===t.nodeType)if(r="data-"+e.replace(Q,"-$&").toLowerCase(),"string"==typeof(n=t.getAttribute(r))){try{n=function(t){return"true"===t||"false"!==t&&("null"===t?null:t===+t+""?+t:K.test(t)?JSON.parse(t):t)}(n)}catch(t){}Y.set(t,e,n)}else n=void 0;return n}y.extend({hasData:function(t){return Y.hasData(t)||X.hasData(t)},data:function(t,e,n){return Y.access(t,e,n)},removeData:function(t,e){Y.remove(t,e)},_data:function(t,e,n){return X.access(t,e,n)},_removeData:function(t,e){X.remove(t,e)}}),y.fn.extend({data:function(t,e){var n,r,i,o=this[0],s=o&&o.attributes;if(void 0===t){if(this.length&&(i=Y.get(o),1===o.nodeType&&!X.get(o,"hasDataAttrs"))){for(n=s.length;n--;)s[n]&&0===(r=s[n].name).indexOf("data-")&&(r=$(r.slice(5)),J(o,r,i[r]));X.set(o,"hasDataAttrs",!0)}return i}return"object"==typeof t?this.each((function(){Y.set(this,t)})):j(this,(function(e){var n;if(o&&void 0===e)return void 0!==(n=Y.get(o,t))||void 0!==(n=J(o,t))?n:void 0;this.each((function(){Y.set(this,t,e)}))}),null,e,arguments.length>1,null,!0)},removeData:function(t){return this.each((function(){Y.remove(this,t)}))}}),y.extend({queue:function(t,e,n){var r;if(t)return e=(e||"fx")+"queue",r=X.get(t,e),n&&(!r||Array.isArray(n)?r=X.access(t,e,y.makeArray(n)):r.push(n)),r||[]},dequeue:function(t,e){e=e||"fx";var n=y.queue(t,e),r=n.length,i=n.shift(),o=y._queueHooks(t,e);"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===e&&n.unshift("inprogress"),delete o.stop,i.call(t,(function(){y.dequeue(t,e)}),o)),!r&&o&&o.empty.fire()},_queueHooks:function(t,e){var n=e+"queueHooks";return X.get(t,n)||X.access(t,n,{empty:y.Callbacks("once memory").add((function(){X.remove(t,[e+"queue",n])}))})}}),y.fn.extend({queue:function(t,e){var n=2;return"string"!=typeof t&&(e=t,t="fx",n--),arguments.length<n?y.queue(this[0],t):void 0===e?this:this.each((function(){var n=y.queue(this,t,e);y._queueHooks(this,t),"fx"===t&&"inprogress"!==n[0]&&y.dequeue(this,t)}))},dequeue:function(t){return this.each((function(){y.dequeue(this,t)}))},clearQueue:function(t){return this.queue(t||"fx",[])},promise:function(t,e){var n,r=1,i=y.Deferred(),o=this,s=this.length,a=function(){--r||i.resolveWith(o,[o])};for("string"!=typeof t&&(e=t,t=void 0),t=t||"fx";s--;)(n=X.get(o[s],t+"queueHooks"))&&n.empty&&(r++,n.empty.add(a));return a(),i.promise(e)}});var tt=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,et=new RegExp("^(?:([+-])=|)("+tt+")([a-z%]*)$","i"),nt=["Top","Right","Bottom","Left"],rt=function(t,e){return"none"===(t=e||t).style.display||""===t.style.display&&y.contains(t.ownerDocument,t)&&"none"===y.css(t,"display")},it=function(t,e,n,r){var i,o,s={};for(o in e)s[o]=t.style[o],t.style[o]=e[o];for(o in i=n.apply(t,r||[]),e)t.style[o]=s[o];return i};var ot={};function st(t){var e,n=t.ownerDocument,r=t.nodeName,i=ot[r];return i||(e=n.body.appendChild(n.createElement(r)),i=y.css(e,"display"),e.parentNode.removeChild(e),"none"===i&&(i="block"),ot[r]=i,i)}function at(t,e){for(var n,r,i=[],o=0,s=t.length;o<s;o++)(r=t[o]).style&&(n=r.style.display,e?("none"===n&&(i[o]=X.get(r,"display")||null,i[o]||(r.style.display="")),""===r.style.display&&rt(r)&&(i[o]=st(r))):"none"!==n&&(i[o]="none",X.set(r,"display",n)));for(o=0;o<s;o++)null!=i[o]&&(t[o].style.display=i[o]);return t}y.fn.extend({show:function(){return at(this,!0)},hide:function(){return at(this)},toggle:function(t){return"boolean"==typeof t?t?this.show():this.hide():this.each((function(){rt(this)?y(this).show():y(this).hide()}))}});var ct=/^(?:checkbox|radio)$/i,lt=/<([a-z][^\/\0>\x20\t\r\n\f]+)/i,ht=/^$|^module$|\/(?:java|ecma)script/i,ut={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 ft(t,e){var n;return n=void 0!==t.getElementsByTagName?t.getElementsByTagName(e||"*"):void 0!==t.querySelectorAll?t.querySelectorAll(e||"*"):[],void 0===e||e&&A(t,e)?y.merge([t],n):n}function dt(t,e){for(var n=0,r=t.length;n<r;n++)X.set(t[n],"globalEval",!e||X.get(e[n],"globalEval"))}ut.optgroup=ut.option,ut.tbody=ut.tfoot=ut.colgroup=ut.caption=ut.thead,ut.th=ut.td;var pt=/<|&#?\w+;/;function gt(t,e,n,r,i){for(var o,s,a,c,l,h,u=e.createDocumentFragment(),f=[],d=0,p=t.length;d<p;d++)if((o=t[d])||0===o)if("object"===b(o))y.merge(f,o.nodeType?[o]:o);else if(pt.test(o)){for(s=s||u.appendChild(e.createElement("div")),a=(lt.exec(o)||["",""])[1].toLowerCase(),c=ut[a]||ut._default,s.innerHTML=c[1]+y.htmlPrefilter(o)+c[2],h=c[0];h--;)s=s.lastChild;y.merge(f,s.childNodes),(s=u.firstChild).textContent=""}else f.push(e.createTextNode(o));for(u.textContent="",d=0;o=f[d++];)if(r&&y.inArray(o,r)>-1)i&&i.push(o);else if(l=y.contains(o.ownerDocument,o),s=ft(u.appendChild(o),"script"),l&&dt(s),n)for(h=0;o=s[h++];)ht.test(o.type||"")&&n.push(o);return u}!function(){var t=e.createDocumentFragment().appendChild(e.createElement("div")),n=e.createElement("input");n.setAttribute("type","radio"),n.setAttribute("checked","checked"),n.setAttribute("name","t"),t.appendChild(n),f.checkClone=t.cloneNode(!0).cloneNode(!0).lastChild.checked,t.innerHTML="<textarea>x</textarea>",f.noCloneChecked=!!t.cloneNode(!0).lastChild.defaultValue}();var mt=e.documentElement,vt=/^key/,bt=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,wt=/^([^.]*)(?:\.(.+)|)/;function yt(){return!0}function xt(){return!1}function kt(){try{return e.activeElement}catch(t){}}function _t(t,e,n,r,i,o){var s,a;if("object"==typeof e){for(a in"string"!=typeof n&&(r=r||n,n=void 0),e)_t(t,a,n,r,e[a],o);return t}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=xt;else if(!i)return t;return 1===o&&(s=i,i=function(t){return y().off(t),s.apply(this,arguments)},i.guid=s.guid||(s.guid=y.guid++)),t.each((function(){y.event.add(this,e,i,r,n)}))}y.event={global:{},add:function(t,e,n,r,i){var o,s,a,c,l,h,u,f,d,p,g,m=X.get(t);if(m)for(n.handler&&(n=(o=n).handler,i=o.selector),i&&y.find.matchesSelector(mt,i),n.guid||(n.guid=y.guid++),(c=m.events)||(c=m.events={}),(s=m.handle)||(s=m.handle=function(e){return void 0!==y&&y.event.triggered!==e.type?y.event.dispatch.apply(t,arguments):void 0}),l=(e=(e||"").match(O)||[""]).length;l--;)d=g=(a=wt.exec(e[l])||[])[1],p=(a[2]||"").split(".").sort(),d&&(u=y.event.special[d]||{},d=(i?u.delegateType:u.bindType)||d,u=y.event.special[d]||{},h=y.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&y.expr.match.needsContext.test(i),namespace:p.join(".")},o),(f=c[d])||((f=c[d]=[]).delegateCount=0,u.setup&&!1!==u.setup.call(t,r,p,s)||t.addEventListener&&t.addEventListener(d,s)),u.add&&(u.add.call(t,h),h.handler.guid||(h.handler.guid=n.guid)),i?f.splice(f.delegateCount++,0,h):f.push(h),y.event.global[d]=!0)},remove:function(t,e,n,r,i){var o,s,a,c,l,h,u,f,d,p,g,m=X.hasData(t)&&X.get(t);if(m&&(c=m.events)){for(l=(e=(e||"").match(O)||[""]).length;l--;)if(d=g=(a=wt.exec(e[l])||[])[1],p=(a[2]||"").split(".").sort(),d){for(u=y.event.special[d]||{},f=c[d=(r?u.delegateType:u.bindType)||d]||[],a=a[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),s=o=f.length;o--;)h=f[o],!i&&g!==h.origType||n&&n.guid!==h.guid||a&&!a.test(h.namespace)||r&&r!==h.selector&&("**"!==r||!h.selector)||(f.splice(o,1),h.selector&&f.delegateCount--,u.remove&&u.remove.call(t,h));s&&!f.length&&(u.teardown&&!1!==u.teardown.call(t,p,m.handle)||y.removeEvent(t,d,m.handle),delete c[d])}else for(d in c)y.event.remove(t,d+e[l],n,r,!0);y.isEmptyObject(c)&&X.remove(t,"handle events")}},dispatch:function(t){var e,n,r,i,o,s,a=y.event.fix(t),c=new Array(arguments.length),l=(X.get(this,"events")||{})[a.type]||[],h=y.event.special[a.type]||{};for(c[0]=a,e=1;e<arguments.length;e++)c[e]=arguments[e];if(a.delegateTarget=this,!h.preDispatch||!1!==h.preDispatch.call(this,a)){for(s=y.event.handlers.call(this,a,l),e=0;(i=s[e++])&&!a.isPropagationStopped();)for(a.currentTarget=i.elem,n=0;(o=i.handlers[n++])&&!a.isImmediatePropagationStopped();)a.rnamespace&&!a.rnamespace.test(o.namespace)||(a.handleObj=o,a.data=o.data,void 0!==(r=((y.event.special[o.origType]||{}).handle||o.handler).apply(i.elem,c))&&!1===(a.result=r)&&(a.preventDefault(),a.stopPropagation()));return h.postDispatch&&h.postDispatch.call(this,a),a.result}},handlers:function(t,e){var n,r,i,o,s,a=[],c=e.delegateCount,l=t.target;if(c&&l.nodeType&&!("click"===t.type&&t.button>=1))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&("click"!==t.type||!0!==l.disabled)){for(o=[],s={},n=0;n<c;n++)void 0===s[i=(r=e[n]).selector+" "]&&(s[i]=r.needsContext?y(i,this).index(l)>-1:y.find(i,this,null,[l]).length),s[i]&&o.push(r);o.length&&a.push({elem:l,handlers:o})}return l=this,c<e.length&&a.push({elem:l,handlers:e.slice(c)}),a},addProp:function(t,e){Object.defineProperty(y.Event.prototype,t,{enumerable:!0,configurable:!0,get:d(e)?function(){if(this.originalEvent)return e(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[t]},set:function(e){Object.defineProperty(this,t,{enumerable:!0,configurable:!0,writable:!0,value:e})}})},fix:function(t){return t[y.expando]?t:new y.Event(t)},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==kt()&&this.focus)return this.focus(),!1},delegateType:"focusin"},blur:{trigger:function(){if(this===kt()&&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(t){return A(t.target,"a")}},beforeunload:{postDispatch:function(t){void 0!==t.result&&t.originalEvent&&(t.originalEvent.returnValue=t.result)}}}},y.removeEvent=function(t,e,n){t.removeEventListener&&t.removeEventListener(e,n)},y.Event=function(t,e){if(!(this instanceof y.Event))return new y.Event(t,e);t&&t.type?(this.originalEvent=t,this.type=t.type,this.isDefaultPrevented=t.defaultPrevented||void 0===t.defaultPrevented&&!1===t.returnValue?yt:xt,this.target=t.target&&3===t.target.nodeType?t.target.parentNode:t.target,this.currentTarget=t.currentTarget,this.relatedTarget=t.relatedTarget):this.type=t,e&&y.extend(this,e),this.timeStamp=t&&t.timeStamp||Date.now(),this[y.expando]=!0},y.Event.prototype={constructor:y.Event,isDefaultPrevented:xt,isPropagationStopped:xt,isImmediatePropagationStopped:xt,isSimulated:!1,preventDefault:function(){var t=this.originalEvent;this.isDefaultPrevented=yt,t&&!this.isSimulated&&t.preventDefault()},stopPropagation:function(){var t=this.originalEvent;this.isPropagationStopped=yt,t&&!this.isSimulated&&t.stopPropagation()},stopImmediatePropagation:function(){var t=this.originalEvent;this.isImmediatePropagationStopped=yt,t&&!this.isSimulated&&t.stopImmediatePropagation(),this.stopPropagation()}},y.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(t){var e=t.button;return null==t.which&&vt.test(t.type)?null!=t.charCode?t.charCode:t.keyCode:!t.which&&void 0!==e&&bt.test(t.type)?1&e?1:2&e?3:4&e?2:0:t.which}},y.event.addProp),y.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},(function(t,e){y.event.special[t]={delegateType:e,bindType:e,handle:function(t){var n,r=this,i=t.relatedTarget,o=t.handleObj;return i&&(i===r||y.contains(r,i))||(t.type=o.origType,n=o.handler.apply(this,arguments),t.type=e),n}}})),y.fn.extend({on:function(t,e,n,r){return _t(this,t,e,n,r)},one:function(t,e,n,r){return _t(this,t,e,n,r,1)},off:function(t,e,n){var r,i;if(t&&t.preventDefault&&t.handleObj)return r=t.handleObj,y(t.delegateTarget).off(r.namespace?r.origType+"."+r.namespace:r.origType,r.selector,r.handler),this;if("object"==typeof t){for(i in t)this.off(i,e,t[i]);return this}return!1!==e&&"function"!=typeof e||(n=e,e=void 0),!1===n&&(n=xt),this.each((function(){y.event.remove(this,t,n,e)}))}});var St=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,Ct=/<script|<style|<link/i,Et=/checked\s*(?:[^=]|=\s*.checked.)/i,At=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;function Tt(t,e){return A(t,"table")&&A(11!==e.nodeType?e:e.firstChild,"tr")&&y(t).children("tbody")[0]||t}function Lt(t){return t.type=(null!==t.getAttribute("type"))+"/"+t.type,t}function Mt(t){return"true/"===(t.type||"").slice(0,5)?t.type=t.type.slice(5):t.removeAttribute("type"),t}function Rt(t,e){var n,r,i,o,s,a,c,l;if(1===e.nodeType){if(X.hasData(t)&&(o=X.access(t),s=X.set(e,o),l=o.events))for(i in delete s.handle,s.events={},l)for(n=0,r=l[i].length;n<r;n++)y.event.add(e,i,l[i][n]);Y.hasData(t)&&(a=Y.access(t),c=y.extend({},a),Y.set(e,c))}}function It(t,e){var n=e.nodeName.toLowerCase();"input"===n&&ct.test(t.type)?e.checked=t.checked:"input"!==n&&"textarea"!==n||(e.defaultValue=t.defaultValue)}function Nt(t,e,n,r){e=i.apply([],e);var o,s,a,c,l,h,u=0,p=t.length,g=p-1,v=e[0],b=d(v);if(b||p>1&&"string"==typeof v&&!f.checkClone&&Et.test(v))return t.each((function(i){var o=t.eq(i);b&&(e[0]=v.call(this,i,o.html())),Nt(o,e,n,r)}));if(p&&(s=(o=gt(e,t[0].ownerDocument,!1,t,r)).firstChild,1===o.childNodes.length&&(o=s),s||r)){for(c=(a=y.map(ft(o,"script"),Lt)).length;u<p;u++)l=o,u!==g&&(l=y.clone(l,!0,!0),c&&y.merge(a,ft(l,"script"))),n.call(t[u],l,u);if(c)for(h=a[a.length-1].ownerDocument,y.map(a,Mt),u=0;u<c;u++)l=a[u],ht.test(l.type||"")&&!X.access(l,"globalEval")&&y.contains(h,l)&&(l.src&&"module"!==(l.type||"").toLowerCase()?y._evalUrl&&y._evalUrl(l.src):m(l.textContent.replace(At,""),h,l))}return t}function Pt(t,e,n){for(var r,i=e?y.filter(e,t):t,o=0;null!=(r=i[o]);o++)n||1!==r.nodeType||y.cleanData(ft(r)),r.parentNode&&(n&&y.contains(r.ownerDocument,r)&&dt(ft(r,"script")),r.parentNode.removeChild(r));return t}y.extend({htmlPrefilter:function(t){return t.replace(St,"<$1></$2>")},clone:function(t,e,n){var r,i,o,s,a=t.cloneNode(!0),c=y.contains(t.ownerDocument,t);if(!(f.noCloneChecked||1!==t.nodeType&&11!==t.nodeType||y.isXMLDoc(t)))for(s=ft(a),r=0,i=(o=ft(t)).length;r<i;r++)It(o[r],s[r]);if(e)if(n)for(o=o||ft(t),s=s||ft(a),r=0,i=o.length;r<i;r++)Rt(o[r],s[r]);else Rt(t,a);return(s=ft(a,"script")).length>0&&dt(s,!c&&ft(t,"script")),a},cleanData:function(t){for(var e,n,r,i=y.event.special,o=0;void 0!==(n=t[o]);o++)if(G(n)){if(e=n[X.expando]){if(e.events)for(r in e.events)i[r]?y.event.remove(n,r):y.removeEvent(n,r,e.handle);n[X.expando]=void 0}n[Y.expando]&&(n[Y.expando]=void 0)}}}),y.fn.extend({detach:function(t){return Pt(this,t,!0)},remove:function(t){return Pt(this,t)},text:function(t){return j(this,(function(t){return void 0===t?y.text(this):this.empty().each((function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=t)}))}),null,t,arguments.length)},append:function(){return Nt(this,arguments,(function(t){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||Tt(this,t).appendChild(t)}))},prepend:function(){return Nt(this,arguments,(function(t){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var e=Tt(this,t);e.insertBefore(t,e.firstChild)}}))},before:function(){return Nt(this,arguments,(function(t){this.parentNode&&this.parentNode.insertBefore(t,this)}))},after:function(){return Nt(this,arguments,(function(t){this.parentNode&&this.parentNode.insertBefore(t,this.nextSibling)}))},empty:function(){for(var t,e=0;null!=(t=this[e]);e++)1===t.nodeType&&(y.cleanData(ft(t,!1)),t.textContent="");return this},clone:function(t,e){return t=null!=t&&t,e=null==e?t:e,this.map((function(){return y.clone(this,t,e)}))},html:function(t){return j(this,(function(t){var e=this[0]||{},n=0,r=this.length;if(void 0===t&&1===e.nodeType)return e.innerHTML;if("string"==typeof t&&!Ct.test(t)&&!ut[(lt.exec(t)||["",""])[1].toLowerCase()]){t=y.htmlPrefilter(t);try{for(;n<r;n++)1===(e=this[n]||{}).nodeType&&(y.cleanData(ft(e,!1)),e.innerHTML=t);e=0}catch(t){}}e&&this.empty().append(t)}),null,t,arguments.length)},replaceWith:function(){var t=[];return Nt(this,arguments,(function(e){var n=this.parentNode;y.inArray(this,t)<0&&(y.cleanData(ft(this)),n&&n.replaceChild(e,this))}),t)}}),y.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},(function(t,e){y.fn[t]=function(t){for(var n,r=[],i=y(t),s=i.length-1,a=0;a<=s;a++)n=a===s?this:this.clone(!0),y(i[a])[e](n),o.apply(r,n.get());return this.pushStack(r)}}));var Ot=new RegExp("^("+tt+")(?!px)[a-z%]+$","i"),Ft=function(t){var e=t.ownerDocument.defaultView;return e&&e.opener||(e=window),e.getComputedStyle(t)},Dt=new RegExp(nt.join("|"),"i");function Bt(t,e,n){var r,i,o,s,a=t.style;return(n=n||Ft(t))&&(""!==(s=n.getPropertyValue(e)||n[e])||y.contains(t.ownerDocument,t)||(s=y.style(t,e)),!f.pixelBoxStyles()&&Ot.test(s)&&Dt.test(e)&&(r=a.width,i=a.minWidth,o=a.maxWidth,a.minWidth=a.maxWidth=a.width=s,s=n.width,a.width=r,a.minWidth=i,a.maxWidth=o)),void 0!==s?s+"":s}function zt(t,e){return{get:function(){if(!t())return(this.get=e).apply(this,arguments);delete this.get}}}!function(){function t(){if(l){c.style.cssText="position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0",l.style.cssText="position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%",mt.appendChild(c).appendChild(l);var t=window.getComputedStyle(l);r="1%"!==t.top,a=12===n(t.marginLeft),l.style.right="60%",s=36===n(t.right),i=36===n(t.width),l.style.position="absolute",o=36===l.offsetWidth||"absolute",mt.removeChild(c),l=null}}function n(t){return Math.round(parseFloat(t))}var r,i,o,s,a,c=e.createElement("div"),l=e.createElement("div");l.style&&(l.style.backgroundClip="content-box",l.cloneNode(!0).style.backgroundClip="",f.clearCloneStyle="content-box"===l.style.backgroundClip,y.extend(f,{boxSizingReliable:function(){return t(),i},pixelBoxStyles:function(){return t(),s},pixelPosition:function(){return t(),r},reliableMarginLeft:function(){return t(),a},scrollboxSize:function(){return t(),o}}))}();var Ht,Vt,jt=/^(none|table(?!-c[ea]).+)/,Ut=/^--/,qt={position:"absolute",visibility:"hidden",display:"block"},Wt={letterSpacing:"0",fontWeight:"400"},$t=["Webkit","Moz","ms"],Gt=e.createElement("div").style;function Zt(t){var e=y.cssProps[t];return e||(e=y.cssProps[t]=function(t){if(t in Gt)return t;for(var e=t[0].toUpperCase()+t.slice(1),n=$t.length;n--;)if((t=$t[n]+e)in Gt)return t}(t)||t),e}function Xt(t,e,n){var r=et.exec(e);return r?Math.max(0,r[2]-(n||0))+(r[3]||"px"):e}function Yt(t,e,n,r,i,o){var s="width"===e?1:0,a=0,c=0;if(n===(r?"border":"content"))return 0;for(;s<4;s+=2)"margin"===n&&(c+=y.css(t,n+nt[s],!0,i)),r?("content"===n&&(c-=y.css(t,"padding"+nt[s],!0,i)),"margin"!==n&&(c-=y.css(t,"border"+nt[s]+"Width",!0,i))):(c+=y.css(t,"padding"+nt[s],!0,i),"padding"!==n?c+=y.css(t,"border"+nt[s]+"Width",!0,i):a+=y.css(t,"border"+nt[s]+"Width",!0,i));return!r&&o>=0&&(c+=Math.max(0,Math.ceil(t["offset"+e[0].toUpperCase()+e.slice(1)]-o-c-a-.5))),c}function Kt(t,e,n){var r=Ft(t),i=Bt(t,e,r),o="border-box"===y.css(t,"boxSizing",!1,r),s=o;if(Ot.test(i)){if(!n)return i;i="auto"}return s=s&&(f.boxSizingReliable()||i===t.style[e]),("auto"===i||!parseFloat(i)&&"inline"===y.css(t,"display",!1,r))&&(i=t["offset"+e[0].toUpperCase()+e.slice(1)],s=!0),(i=parseFloat(i)||0)+Yt(t,e,n||(o?"border":"content"),s,r,i)+"px"}y.extend({cssHooks:{opacity:{get:function(t,e){if(e){var n=Bt(t,"opacity");return""===n?"1":n}}}},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(t,e,n,r){if(t&&3!==t.nodeType&&8!==t.nodeType&&t.style){var i,o,s,a=$(e),c=Ut.test(e),l=t.style;if(c||(e=Zt(a)),s=y.cssHooks[e]||y.cssHooks[a],void 0===n)return s&&"get"in s&&void 0!==(i=s.get(t,!1,r))?i:l[e];"string"===(o=typeof n)&&(i=et.exec(n))&&i[1]&&(n=function(t,e,n,r){var i,o,s=20,a=r?function(){return r.cur()}:function(){return y.css(t,e,"")},c=a(),l=n&&n[3]||(y.cssNumber[e]?"":"px"),h=(y.cssNumber[e]||"px"!==l&&+c)&&et.exec(y.css(t,e));if(h&&h[3]!==l){for(c/=2,l=l||h[3],h=+c||1;s--;)y.style(t,e,h+l),(1-o)*(1-(o=a()/c||.5))<=0&&(s=0),h/=o;h*=2,y.style(t,e,h+l),n=n||[]}return n&&(h=+h||+c||0,i=n[1]?h+(n[1]+1)*n[2]:+n[2],r&&(r.unit=l,r.start=h,r.end=i)),i}(t,e,i),o="number"),null!=n&&n==n&&("number"===o&&(n+=i&&i[3]||(y.cssNumber[a]?"":"px")),f.clearCloneStyle||""!==n||0!==e.indexOf("background")||(l[e]="inherit"),s&&"set"in s&&void 0===(n=s.set(t,n,r))||(c?l.setProperty(e,n):l[e]=n))}},css:function(t,e,n,r){var i,o,s,a=$(e);return Ut.test(e)||(e=Zt(a)),(s=y.cssHooks[e]||y.cssHooks[a])&&"get"in s&&(i=s.get(t,!0,n)),void 0===i&&(i=Bt(t,e,r)),"normal"===i&&e in Wt&&(i=Wt[e]),""===n||n?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),y.each(["height","width"],(function(t,e){y.cssHooks[e]={get:function(t,n,r){if(n)return!jt.test(y.css(t,"display"))||t.getClientRects().length&&t.getBoundingClientRect().width?Kt(t,e,r):it(t,qt,(function(){return Kt(t,e,r)}))},set:function(t,n,r){var i,o=Ft(t),s="border-box"===y.css(t,"boxSizing",!1,o),a=r&&Yt(t,e,r,s,o);return s&&f.scrollboxSize()===o.position&&(a-=Math.ceil(t["offset"+e[0].toUpperCase()+e.slice(1)]-parseFloat(o[e])-Yt(t,e,"border",!1,o)-.5)),a&&(i=et.exec(n))&&"px"!==(i[3]||"px")&&(t.style[e]=n,n=y.css(t,e)),Xt(0,n,a)}}})),y.cssHooks.marginLeft=zt(f.reliableMarginLeft,(function(t,e){if(e)return(parseFloat(Bt(t,"marginLeft"))||t.getBoundingClientRect().left-it(t,{marginLeft:0},(function(){return t.getBoundingClientRect().left})))+"px"})),y.each({margin:"",padding:"",border:"Width"},(function(t,e){y.cssHooks[t+e]={expand:function(n){for(var r=0,i={},o="string"==typeof n?n.split(" "):[n];r<4;r++)i[t+nt[r]+e]=o[r]||o[r-2]||o[0];return i}},"margin"!==t&&(y.cssHooks[t+e].set=Xt)})),y.fn.extend({css:function(t,e){return j(this,(function(t,e,n){var r,i,o={},s=0;if(Array.isArray(e)){for(r=Ft(t),i=e.length;s<i;s++)o[e[s]]=y.css(t,e[s],!1,r);return o}return void 0!==n?y.style(t,e,n):y.css(t,e)}),t,e,arguments.length>1)}}),y.fn.delay=function(t,e){return t=y.fx&&y.fx.speeds[t]||t,e=e||"fx",this.queue(e,(function(e,n){var r=window.setTimeout(e,t);n.stop=function(){window.clearTimeout(r)}}))},Ht=e.createElement("input"),Vt=e.createElement("select").appendChild(e.createElement("option")),Ht.type="checkbox",f.checkOn=""!==Ht.value,f.optSelected=Vt.selected,(Ht=e.createElement("input")).value="t",Ht.type="radio",f.radioValue="t"===Ht.value;var Qt,Jt=y.expr.attrHandle;y.fn.extend({attr:function(t,e){return j(this,y.attr,t,e,arguments.length>1)},removeAttr:function(t){return this.each((function(){y.removeAttr(this,t)}))}}),y.extend({attr:function(t,e,n){var r,i,o=t.nodeType;if(3!==o&&8!==o&&2!==o)return void 0===t.getAttribute?y.prop(t,e,n):(1===o&&y.isXMLDoc(t)||(i=y.attrHooks[e.toLowerCase()]||(y.expr.match.bool.test(e)?Qt:void 0)),void 0!==n?null===n?void y.removeAttr(t,e):i&&"set"in i&&void 0!==(r=i.set(t,n,e))?r:(t.setAttribute(e,n+""),n):i&&"get"in i&&null!==(r=i.get(t,e))?r:null==(r=y.find.attr(t,e))?void 0:r)},attrHooks:{type:{set:function(t,e){if(!f.radioValue&&"radio"===e&&A(t,"input")){var n=t.value;return t.setAttribute("type",e),n&&(t.value=n),e}}}},removeAttr:function(t,e){var n,r=0,i=e&&e.match(O);if(i&&1===t.nodeType)for(;n=i[r++];)t.removeAttribute(n)}}),Qt={set:function(t,e,n){return!1===e?y.removeAttr(t,n):t.setAttribute(n,n),n}},y.each(y.expr.match.bool.source.match(/\w+/g),(function(t,e){var n=Jt[e]||y.find.attr;Jt[e]=function(t,e,r){var i,o,s=e.toLowerCase();return r||(o=Jt[s],Jt[s]=i,i=null!=n(t,e,r)?s:null,Jt[s]=o),i}}));var te=/^(?:input|select|textarea|button)$/i,ee=/^(?:a|area)$/i;function ne(t){return(t.match(O)||[]).join(" ")}function re(t){return t.getAttribute&&t.getAttribute("class")||""}function ie(t){return Array.isArray(t)?t:"string"==typeof t&&t.match(O)||[]}y.fn.extend({prop:function(t,e){return j(this,y.prop,t,e,arguments.length>1)},removeProp:function(t){return this.each((function(){delete this[y.propFix[t]||t]}))}}),y.extend({prop:function(t,e,n){var r,i,o=t.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&y.isXMLDoc(t)||(e=y.propFix[e]||e,i=y.propHooks[e]),void 0!==n?i&&"set"in i&&void 0!==(r=i.set(t,n,e))?r:t[e]=n:i&&"get"in i&&null!==(r=i.get(t,e))?r:t[e]},propHooks:{tabIndex:{get:function(t){var e=y.find.attr(t,"tabindex");return e?parseInt(e,10):te.test(t.nodeName)||ee.test(t.nodeName)&&t.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),f.optSelected||(y.propHooks.selected={get:function(t){var e=t.parentNode;return e&&e.parentNode&&e.parentNode.selectedIndex,null},set:function(t){var e=t.parentNode;e&&(e.selectedIndex,e.parentNode&&e.parentNode.selectedIndex)}}),y.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],(function(){y.propFix[this.toLowerCase()]=this})),y.fn.extend({addClass:function(t){var e,n,r,i,o,s,a,c=0;if(d(t))return this.each((function(e){y(this).addClass(t.call(this,e,re(this)))}));if((e=ie(t)).length)for(;n=this[c++];)if(i=re(n),r=1===n.nodeType&&" "+ne(i)+" "){for(s=0;o=e[s++];)r.indexOf(" "+o+" ")<0&&(r+=o+" ");i!==(a=ne(r))&&n.setAttribute("class",a)}return this},removeClass:function(t){var e,n,r,i,o,s,a,c=0;if(d(t))return this.each((function(e){y(this).removeClass(t.call(this,e,re(this)))}));if(!arguments.length)return this.attr("class","");if((e=ie(t)).length)for(;n=this[c++];)if(i=re(n),r=1===n.nodeType&&" "+ne(i)+" "){for(s=0;o=e[s++];)for(;r.indexOf(" "+o+" ")>-1;)r=r.replace(" "+o+" "," ");i!==(a=ne(r))&&n.setAttribute("class",a)}return this},toggleClass:function(t,e){var n=typeof t,r="string"===n||Array.isArray(t);return"boolean"==typeof e&&r?e?this.addClass(t):this.removeClass(t):d(t)?this.each((function(n){y(this).toggleClass(t.call(this,n,re(this),e),e)})):this.each((function(){var e,i,o,s;if(r)for(i=0,o=y(this),s=ie(t);e=s[i++];)o.hasClass(e)?o.removeClass(e):o.addClass(e);else void 0!==t&&"boolean"!==n||((e=re(this))&&X.set(this,"__className__",e),this.setAttribute&&this.setAttribute("class",e||!1===t?"":X.get(this,"__className__")||""))}))},hasClass:function(t){var e,n,r=0;for(e=" "+t+" ";n=this[r++];)if(1===n.nodeType&&(" "+ne(re(n))+" ").indexOf(e)>-1)return!0;return!1}});var oe=/\r/g;y.fn.extend({val:function(t){var e,n,r,i=this[0];return arguments.length?(r=d(t),this.each((function(n){var i;1===this.nodeType&&(null==(i=r?t.call(this,n,y(this).val()):t)?i="":"number"==typeof i?i+="":Array.isArray(i)&&(i=y.map(i,(function(t){return null==t?"":t+""}))),(e=y.valHooks[this.type]||y.valHooks[this.nodeName.toLowerCase()])&&"set"in e&&void 0!==e.set(this,i,"value")||(this.value=i))}))):i?(e=y.valHooks[i.type]||y.valHooks[i.nodeName.toLowerCase()])&&"get"in e&&void 0!==(n=e.get(i,"value"))?n:"string"==typeof(n=i.value)?n.replace(oe,""):null==n?"":n:void 0}}),y.extend({valHooks:{option:{get:function(t){var e=y.find.attr(t,"value");return null!=e?e:ne(y.text(t))}},select:{get:function(t){var e,n,r,i=t.options,o=t.selectedIndex,s="select-one"===t.type,a=s?null:[],c=s?o+1:i.length;for(r=o<0?c:s?o:0;r<c;r++)if(((n=i[r]).selected||r===o)&&!n.disabled&&(!n.parentNode.disabled||!A(n.parentNode,"optgroup"))){if(e=y(n).val(),s)return e;a.push(e)}return a},set:function(t,e){for(var n,r,i=t.options,o=y.makeArray(e),s=i.length;s--;)((r=i[s]).selected=y.inArray(y.valHooks.option.get(r),o)>-1)&&(n=!0);return n||(t.selectedIndex=-1),o}}}}),y.each(["radio","checkbox"],(function(){y.valHooks[this]={set:function(t,e){if(Array.isArray(e))return t.checked=y.inArray(y(t).val(),e)>-1}},f.checkOn||(y.valHooks[this].get=function(t){return null===t.getAttribute("value")?"on":t.value})})),f.focusin="onfocusin"in window;var se=/^(?:focusinfocus|focusoutblur)$/,ae=function(t){t.stopPropagation()};y.extend(y.event,{trigger:function(t,n,r,i){var o,s,a,c,h,u,f,g,m=[r||e],v=l.call(t,"type")?t.type:t,b=l.call(t,"namespace")?t.namespace.split("."):[];if(s=g=a=r=r||e,3!==r.nodeType&&8!==r.nodeType&&!se.test(v+y.event.triggered)&&(v.indexOf(".")>-1&&(b=v.split("."),v=b.shift(),b.sort()),h=v.indexOf(":")<0&&"on"+v,(t=t[y.expando]?t:new y.Event(v,"object"==typeof t&&t)).isTrigger=i?2:3,t.namespace=b.join("."),t.rnamespace=t.namespace?new RegExp("(^|\\.)"+b.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=void 0,t.target||(t.target=r),n=null==n?[t]:y.makeArray(n,[t]),f=y.event.special[v]||{},i||!f.trigger||!1!==f.trigger.apply(r,n))){if(!i&&!f.noBubble&&!p(r)){for(c=f.delegateType||v,se.test(c+v)||(s=s.parentNode);s;s=s.parentNode)m.push(s),a=s;a===(r.ownerDocument||e)&&m.push(a.defaultView||a.parentWindow||window)}for(o=0;(s=m[o++])&&!t.isPropagationStopped();)g=s,t.type=o>1?c:f.bindType||v,(u=(X.get(s,"events")||{})[t.type]&&X.get(s,"handle"))&&u.apply(s,n),(u=h&&s[h])&&u.apply&&G(s)&&(t.result=u.apply(s,n),!1===t.result&&t.preventDefault());return t.type=v,i||t.isDefaultPrevented()||f._default&&!1!==f._default.apply(m.pop(),n)||!G(r)||h&&d(r[v])&&!p(r)&&((a=r[h])&&(r[h]=null),y.event.triggered=v,t.isPropagationStopped()&&g.addEventListener(v,ae),r[v](),t.isPropagationStopped()&&g.removeEventListener(v,ae),y.event.triggered=void 0,a&&(r[h]=a)),t.result}},simulate:function(t,e,n){var r=y.extend(new y.Event,n,{type:t,isSimulated:!0});y.event.trigger(r,null,e)}}),y.fn.extend({trigger:function(t,e){return this.each((function(){y.event.trigger(t,e,this)}))},triggerHandler:function(t,e){var n=this[0];if(n)return y.event.trigger(t,e,n,!0)}}),f.focusin||y.each({focus:"focusin",blur:"focusout"},(function(t,e){var n=function(t){y.event.simulate(e,t.target,y.event.fix(t))};y.event.special[e]={setup:function(){var r=this.ownerDocument||this,i=X.access(r,e);i||r.addEventListener(t,n,!0),X.access(r,e,(i||0)+1)},teardown:function(){var r=this.ownerDocument||this,i=X.access(r,e)-1;i?X.access(r,e,i):(r.removeEventListener(t,n,!0),X.remove(r,e))}}}));var ce,le=/\[\]$/,he=/\r?\n/g,ue=/^(?:submit|button|image|reset|file)$/i,fe=/^(?:input|select|textarea|keygen)/i;function de(t,e,n,r){var i;if(Array.isArray(e))y.each(e,(function(e,i){n||le.test(t)?r(t,i):de(t+"["+("object"==typeof i&&null!=i?e:"")+"]",i,n,r)}));else if(n||"object"!==b(e))r(t,e);else for(i in e)de(t+"["+i+"]",e[i],n,r)}y.param=function(t,e){var n,r=[],i=function(t,e){var n=d(e)?e():e;r[r.length]=encodeURIComponent(t)+"="+encodeURIComponent(null==n?"":n)};if(Array.isArray(t)||t.jquery&&!y.isPlainObject(t))y.each(t,(function(){i(this.name,this.value)}));else for(n in t)de(n,t[n],e,i);return r.join("&")},y.fn.extend({serialize:function(){return y.param(this.serializeArray())},serializeArray:function(){return this.map((function(){var t=y.prop(this,"elements");return t?y.makeArray(t):this})).filter((function(){var t=this.type;return this.name&&!y(this).is(":disabled")&&fe.test(this.nodeName)&&!ue.test(t)&&(this.checked||!ct.test(t))})).map((function(t,e){var n=y(this).val();return null==n?null:Array.isArray(n)?y.map(n,(function(t){return{name:e.name,value:t.replace(he,"\r\n")}})):{name:e.name,value:n.replace(he,"\r\n")}})).get()}}),y.fn.extend({wrapAll:function(t){var e;return this[0]&&(d(t)&&(t=t.call(this[0])),e=y(t,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&e.insertBefore(this[0]),e.map((function(){for(var t=this;t.firstElementChild;)t=t.firstElementChild;return t})).append(this)),this},wrapInner:function(t){return d(t)?this.each((function(e){y(this).wrapInner(t.call(this,e))})):this.each((function(){var e=y(this),n=e.contents();n.length?n.wrapAll(t):e.append(t)}))},wrap:function(t){var e=d(t);return this.each((function(n){y(this).wrapAll(e?t.call(this,n):t)}))},unwrap:function(t){return this.parent(t).not("body").each((function(){y(this).replaceWith(this.childNodes)})),this}}),y.expr.pseudos.hidden=function(t){return!y.expr.pseudos.visible(t)},y.expr.pseudos.visible=function(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)},f.createHTMLDocument=((ce=e.implementation.createHTMLDocument("").body).innerHTML="<form></form><form></form>",2===ce.childNodes.length),y.parseHTML=function(t,n,r){return"string"!=typeof t?[]:("boolean"==typeof n&&(r=n,n=!1),n||(f.createHTMLDocument?((i=(n=e.implementation.createHTMLDocument("")).createElement("base")).href=e.location.href,n.head.appendChild(i)):n=e),s=!r&&[],(o=T.exec(t))?[n.createElement(o[1])]:(o=gt([t],n,s),s&&s.length&&y(s).remove(),y.merge([],o.childNodes)));var i,o,s},y.offset={setOffset:function(t,e,n){var r,i,o,s,a,c,l=y.css(t,"position"),h=y(t),u={};"static"===l&&(t.style.position="relative"),a=h.offset(),o=y.css(t,"top"),c=y.css(t,"left"),("absolute"===l||"fixed"===l)&&(o+c).indexOf("auto")>-1?(s=(r=h.position()).top,i=r.left):(s=parseFloat(o)||0,i=parseFloat(c)||0),d(e)&&(e=e.call(t,n,y.extend({},a))),null!=e.top&&(u.top=e.top-a.top+s),null!=e.left&&(u.left=e.left-a.left+i),"using"in e?e.using.call(t,u):h.css(u)}},y.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each((function(e){y.offset.setOffset(this,t,e)}));var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var t,e,n,r=this[0],i={top:0,left:0};if("fixed"===y.css(r,"position"))e=r.getBoundingClientRect();else{for(e=this.offset(),n=r.ownerDocument,t=r.offsetParent||n.documentElement;t&&(t===n.body||t===n.documentElement)&&"static"===y.css(t,"position");)t=t.parentNode;t&&t!==r&&1===t.nodeType&&((i=y(t).offset()).top+=y.css(t,"borderTopWidth",!0),i.left+=y.css(t,"borderLeftWidth",!0))}return{top:e.top-i.top-y.css(r,"marginTop",!0),left:e.left-i.left-y.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map((function(){for(var t=this.offsetParent;t&&"static"===y.css(t,"position");)t=t.offsetParent;return t||mt}))}}),y.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},(function(t,e){var n="pageYOffset"===e;y.fn[t]=function(r){return j(this,(function(t,r,i){var o;if(p(t)?o=t:9===t.nodeType&&(o=t.defaultView),void 0===i)return o?o[e]:t[r];o?o.scrollTo(n?o.pageXOffset:i,n?i:o.pageYOffset):t[r]=i}),t,r,arguments.length)}})),y.each(["top","left"],(function(t,e){y.cssHooks[e]=zt(f.pixelPosition,(function(t,n){if(n)return n=Bt(t,e),Ot.test(n)?y(t).position()[e]+"px":n}))})),y.each({Height:"height",Width:"width"},(function(t,e){y.each({padding:"inner"+t,content:e,"":"outer"+t},(function(n,r){y.fn[r]=function(i,o){var s=arguments.length&&(n||"boolean"!=typeof i),a=n||(!0===i||!0===o?"margin":"border");return j(this,(function(e,n,i){var o;return p(e)?0===r.indexOf("outer")?e["inner"+t]:e.document.documentElement["client"+t]:9===e.nodeType?(o=e.documentElement,Math.max(e.body["scroll"+t],o["scroll"+t],e.body["offset"+t],o["offset"+t],o["client"+t])):void 0===i?y.css(e,n,a):y.style(e,n,i,a)}),e,s?i:void 0,s)}}))})),y.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(t,e){y.fn[e]=function(t,n){return arguments.length>0?this.on(e,null,t,n):this.trigger(e)}})),y.fn.extend({hover:function(t,e){return this.mouseenter(t).mouseleave(e||t)}}),y.fn.extend({bind:function(t,e,n){return this.on(t,null,e,n)},unbind:function(t,e){return this.off(t,null,e)},delegate:function(t,e,n,r){return this.on(e,t,n,r)},undelegate:function(t,e,n){return 1===arguments.length?this.off(t,"**"):this.off(e,t||"**",n)}}),y.proxy=function(t,e){var n,i,o;if("string"==typeof e&&(n=t[e],e=t,t=n),d(t))return i=r.call(arguments,2),o=function(){return t.apply(e||this,i.concat(r.call(arguments)))},o.guid=t.guid=t.guid||y.guid++,o},y.holdReady=function(t){t?y.readyWait++:y.ready(!0)},y.isArray=Array.isArray,y.parseJSON=JSON.parse,y.nodeName=A,y.isFunction=d,y.isWindow=p,y.camelCase=$,y.type=b,y.now=Date.now,y.isNumeric=function(t){var e=y.type(t);return("number"===e||"string"===e)&&!isNaN(t-parseFloat(t))};const pe=y;function ge(t){return function(t,e){const n=document.createElement(t);e&&(e.class&&n.classList.add(e.class),e.id&&(n.id=e.id),e.style&&function(t,e){for(let n of Object.keys(e))t.style[n]=e[n]}(n,e.style));return n}("div",t)}function me(t){const e=getComputedStyle(t);"none"!==e.display&&(t._initialDisplay=e.display),t.style.display="none"}function ve(t){if(t.type.startsWith("touch")){const e=t.touches[0];return{x:e.pageX,y:e.pageY}}return{x:t.pageX,y:t.pageY}}function be(){return("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)}function we(t,e){const{clientX:n,clientY:r}=t;return((t,{clientX:e,clientY:n})=>{const{left:r,top:i,width:o,height:s}=t.getBoundingClientRect(),a=e-r,c=n-i;return{x:a,y:c,xNormalized:a/o,yNormalized:c/s,width:o,height:s}})(e,{clientX:n,clientY:r})}function ye(t,e){return function(t,e){e=e||"currentColor";let n=xe[t];n||(console.error(`No icon named: ${t}`),n=xe.question);const r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttributeNS(null,"viewBox","0 0 "+n[0]+" "+n[1]);const i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttributeNS(null,"fill",e),i.setAttributeNS(null,"d",n[4]),r.appendChild(i),r}(t,e)}const xe={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"]};function ke(t,e){var n=document.createElement("div");t.appendChild(n),n.appendChild(ye("times")),n.addEventListener("click",(function(t){t.preventDefault(),t.stopPropagation(),e()}))}function _e(t){return"string"==typeof t||t instanceof String}function Se(t){var e=String(t).split(/[.,]/);return e[0].split("").reverse().reduce((function(t,e,n){return n%3==0?t+","+e:t+e})).split("").reverse().join("")+(e[1]?"."+e[1]:"")}const Ce=function(t){return t.split(/\n|\r\n|\r/g)};function Ee(t,e){var n,r,i=[],o=t.length,s=0,a=!1;if(o>0)for(i[s]=t.charAt(0),n=1;n<o;n++)'"'===(r=t.charAt(n))?a=!a:a||r!==e?i[s]+=r:i[++s]="";return i}function Ae(t){return t.length>0?t.charAt(0).toUpperCase()+t.slice(1):t}function Te(t){return t.includes("googleapis")&&!t.includes("urlshortener")||Le(t)||Me(t)}function Le(t){return t.startsWith("gs://")||t.startsWith("https://www.googleapis.com/storage")||t.startsWith("https://storage.cloud.google.com")||t.startsWith("https://storage.googleapis.com")}function Me(t){return t.indexOf("drive.google.com")>=0||t.indexOf("www.googleapis.com/drive")>0}function Re(t){let{bucket:e,object:n}=function(t){let e,n;if(t.startsWith("gs://")){const r=t.indexOf("/",5);if(r>=0){e=t.substring(5,r);const i=t.indexOf("?");n=i<0?t.substring(r+1):t.substring(r+1,i)}}else if(t.startsWith("https://storage.googleapis.com")||t.startsWith("https://storage.cloud.google.com")){const r=t.indexOf("/v1/b/",8);if(r>0){const i=t.indexOf("/o/",r);if(i>0){const o=t.indexOf("?",i);e=t.substring(r+6,i),n=o>0?t.substring(i+3,o):t.substring(i+3)}}else{const r=t.indexOf("/",8),i=t.indexOf("/",r+1),o=t.indexOf("?",i);i>0&&(e=t.substring(r+1,i),n=o<0?t.substring(i+1):t.substring(i+1,o))}}else if(t.startsWith("https://www.googleapis.com/storage/v1/b")){const r=t.indexOf("/v1/b/",8),i=t.indexOf("/o/",r);if(i>0){const o=t.indexOf("?",i);e=t.substring(r+6,i),n=o>0?t.substring(i+3,o):t.substring(i+3)}}if(e&&n)return{bucket:e,object:n};throw Error(`Unrecognized Google Storage URI: ${t}`)}(t);n=function(t){let e="";return t.split("").forEach((function(t){Pe.has(t)?e+=Pe.get(t):e+=t})),e}(n);const r=t.indexOf("?");return`https://storage.googleapis.com/storage/v1/b/${e}/o/${n}${r>0?t.substring(r)+"&alt=media":"?alt=media"}`}function Ie(t){var e=Ne(t);return e?"https://www.googleapis.com/drive/v3/files/"+e+"?alt=media&supportsTeamDrives=true":t}function Ne(t){if(t.includes("/open?id=")){const e=t.indexOf("/open?id=")+9,n=t.indexOf("&");if(e>0&&n>e)return t.substring(e,n);if(e>0)return t.substring(e)}else{if(t.includes("/file/d/")){const e=t.indexOf("/file/d/")+8,n=t.lastIndexOf("/");return t.substring(e,n)}if(t.startsWith("https://www.googleapis.com/drive")){let e=t.indexOf("/files/");const n=t.indexOf("?");if(e>0)return e+=7,n>0?t.substring(e,n):t.substring(e)}}throw Error("Unknown Google Drive url format: "+t)}const Pe=new Map;Pe.set("!","%21"),Pe.set("#","%23"),Pe.set("$","%24"),Pe.set("%","%25"),Pe.set("&","%26"),Pe.set("'","%27"),Pe.set("(","%28"),Pe.set(")","%29"),Pe.set("*","%2A"),Pe.set("+","%2B"),Pe.set(",","%2C"),Pe.set("/","%2F"),Pe.set(":","%3A"),Pe.set(";","%3B"),Pe.set("=","%3D"),Pe.set("?","%3F"),Pe.set("@","%40"),Pe.set("[","%5B"),Pe.set("]","%5D"),Pe.set(" ","%20");async function Oe(t){if(Fe())return void console.warn("oAuth has already been initialized");gapi.apiKey=t.apiKey;const e=Object.assign({},t);return e.scope||(e.scope="profile"),t.client_id||(t.client_id=t.clientId),await async function(t){return new Promise((function(e,n){gapi.load(t,{callback:e,onerror:n})}))}("auth2"),new Promise((function(t,n){gapi.auth2.init(e).then(t,n)}))}function Fe(){return"undefined"!=typeof gapi&&gapi.auth2&&gapi.auth2.getAuthInstance()}let De=!1;async function Be(t){if("undefined"==typeof gapi)throw Error("Google authentication requires the 'gapi' library");if(!gapi.auth2)throw Error("Google 'auth2' has not been initialized");if(De)return new Promise((function(e,n){let r;r=setInterval((()=>{try{!1===De&&(e(Be(t)),clearInterval(r))}catch(t){clearInterval(r),n(t)}}),100)}));De=!0;try{let e,n=gapi.auth2.getAuthInstance().currentUser.get();if(n.isSignedIn()){n.hasGrantedScopes(t)||await n.grant({scope:t});const{access_token:r,expires_at:i}=n.getAuthResponse();if(Date.now()<i-3e5)e={access_token:r,expires_at:i};else{const{access_token:t,expires_at:r}=n.reloadAuthResponse();e={access_token:t,expires_at:r}}}else{n=await async function(t){const e=new gapi.auth2.SigninOptionsBuilder;return e.setPrompt("select_account"),e.setScope(t),gapi.auth2.getAuthInstance().signIn(e)}(t);const{access_token:r,expires_at:i}=n.getAuthResponse();e={access_token:r,expires_at:i}}return e}finally{De=!1}}function ze(){return gapi.apiKey}function He(t){for(var e=Ve,n=e.parser.loose.exec(t),r={},i=14;i--;)r[e.key[i]]=n[i]||"";return r[e.q.name]={},r[e.key[12]].replace(e.q.parser,(function(t,n,i){n&&(r[e.q.name][n]=i)})),r}"object"==typeof process&&"undefined"==typeof window&&(global.atob=function(t){return Buffer.from(t,"base64").toString("binary")});const Ve={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 je(t){if(void 0!==t.name)return t.name;if(_e(t)){let e=t.lastIndexOf("/"),n=e<0?t:t.substr(e+1);return e=n.indexOf("?"),e>0&&(n=n.substr(0,e)),n}throw Error("Expected File or string, got "+typeof t)}function Ue(t){return!!t&&("function"!=typeof t&&(t instanceof File||t.hasOwnProperty("name")&&"function"==typeof t.slice&&"function"==typeof t.arrayBuffer))}const qe=Ue;function We(t,e){const n=document.createElement("a");n.setAttribute("href",e),n.setAttribute("download",t),n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n)}
|
|
26
|
-
/*! pako 2.0.4 https://github.com/nodeca/pako @license (MIT AND Zlib) */function $e(t){let e=t.length;for(;--e>=0;)t[e]=0}const Ge=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]),Ze=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]),Xe=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Ye=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ke=new Array(576);$e(Ke);const Qe=new Array(60);$e(Qe);const Je=new Array(512);$e(Je);const tn=new Array(256);$e(tn);const en=new Array(29);$e(en);const nn=new Array(30);function rn(t,e,n,r,i){this.static_tree=t,this.extra_bits=e,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=t&&t.length}let on,sn,an;function cn(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}$e(nn);const ln=t=>t<256?Je[t]:Je[256+(t>>>7)],hn=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},un=(t,e,n)=>{t.bi_valid>16-n?(t.bi_buf|=e<<t.bi_valid&65535,hn(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=n-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=n)},fn=(t,e,n)=>{un(t,n[2*e],n[2*e+1])},dn=(t,e)=>{let n=0;do{n|=1&t,t>>>=1,n<<=1}while(--e>0);return n>>>1},pn=(t,e,n)=>{const r=new Array(16);let i,o,s=0;for(i=1;i<=15;i++)r[i]=s=s+n[i-1]<<1;for(o=0;o<=e;o++){let e=t[2*o+1];0!==e&&(t[2*o]=dn(r[e]++,e))}},gn=t=>{let e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0},mn=t=>{t.bi_valid>8?hn(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},vn=(t,e,n,r)=>{const i=2*e,o=2*n;return t[i]<t[o]||t[i]===t[o]&&r[e]<=r[n]},bn=(t,e,n)=>{const r=t.heap[n];let i=n<<1;for(;i<=t.heap_len&&(i<t.heap_len&&vn(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!vn(e,r,t.heap[i],t.depth));)t.heap[n]=t.heap[i],n=i,i<<=1;t.heap[n]=r},wn=(t,e,n)=>{let r,i,o,s,a=0;if(0!==t.last_lit)do{r=t.pending_buf[t.d_buf+2*a]<<8|t.pending_buf[t.d_buf+2*a+1],i=t.pending_buf[t.l_buf+a],a++,0===r?fn(t,i,e):(o=tn[i],fn(t,o+256+1,e),s=Ge[o],0!==s&&(i-=en[o],un(t,i,s)),r--,o=ln(r),fn(t,o,n),s=Ze[o],0!==s&&(r-=nn[o],un(t,r,s)))}while(a<t.last_lit);fn(t,256,e)},yn=(t,e)=>{const n=e.dyn_tree,r=e.stat_desc.static_tree,i=e.stat_desc.has_stree,o=e.stat_desc.elems;let s,a,c,l=-1;for(t.heap_len=0,t.heap_max=573,s=0;s<o;s++)0!==n[2*s]?(t.heap[++t.heap_len]=l=s,t.depth[s]=0):n[2*s+1]=0;for(;t.heap_len<2;)c=t.heap[++t.heap_len]=l<2?++l:0,n[2*c]=1,t.depth[c]=0,t.opt_len--,i&&(t.static_len-=r[2*c+1]);for(e.max_code=l,s=t.heap_len>>1;s>=1;s--)bn(t,n,s);c=o;do{s=t.heap[1],t.heap[1]=t.heap[t.heap_len--],bn(t,n,1),a=t.heap[1],t.heap[--t.heap_max]=s,t.heap[--t.heap_max]=a,n[2*c]=n[2*s]+n[2*a],t.depth[c]=(t.depth[s]>=t.depth[a]?t.depth[s]:t.depth[a])+1,n[2*s+1]=n[2*a+1]=c,t.heap[1]=c++,bn(t,n,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const n=e.dyn_tree,r=e.max_code,i=e.stat_desc.static_tree,o=e.stat_desc.has_stree,s=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,c=e.stat_desc.max_length;let l,h,u,f,d,p,g=0;for(f=0;f<=15;f++)t.bl_count[f]=0;for(n[2*t.heap[t.heap_max]+1]=0,l=t.heap_max+1;l<573;l++)h=t.heap[l],f=n[2*n[2*h+1]+1]+1,f>c&&(f=c,g++),n[2*h+1]=f,h>r||(t.bl_count[f]++,d=0,h>=a&&(d=s[h-a]),p=n[2*h],t.opt_len+=p*(f+d),o&&(t.static_len+=p*(i[2*h+1]+d)));if(0!==g){do{for(f=c-1;0===t.bl_count[f];)f--;t.bl_count[f]--,t.bl_count[f+1]+=2,t.bl_count[c]--,g-=2}while(g>0);for(f=c;0!==f;f--)for(h=t.bl_count[f];0!==h;)u=t.heap[--l],u>r||(n[2*u+1]!==f&&(t.opt_len+=(f-n[2*u+1])*n[2*u],n[2*u+1]=f),h--)}})(t,e),pn(n,l,t.bl_count)},xn=(t,e,n)=>{let r,i,o=-1,s=e[1],a=0,c=7,l=4;for(0===s&&(c=138,l=3),e[2*(n+1)+1]=65535,r=0;r<=n;r++)i=s,s=e[2*(r+1)+1],++a<c&&i===s||(a<l?t.bl_tree[2*i]+=a:0!==i?(i!==o&&t.bl_tree[2*i]++,t.bl_tree[32]++):a<=10?t.bl_tree[34]++:t.bl_tree[36]++,a=0,o=i,0===s?(c=138,l=3):i===s?(c=6,l=3):(c=7,l=4))},kn=(t,e,n)=>{let r,i,o=-1,s=e[1],a=0,c=7,l=4;for(0===s&&(c=138,l=3),r=0;r<=n;r++)if(i=s,s=e[2*(r+1)+1],!(++a<c&&i===s)){if(a<l)do{fn(t,i,t.bl_tree)}while(0!=--a);else 0!==i?(i!==o&&(fn(t,i,t.bl_tree),a--),fn(t,16,t.bl_tree),un(t,a-3,2)):a<=10?(fn(t,17,t.bl_tree),un(t,a-3,3)):(fn(t,18,t.bl_tree),un(t,a-11,7));a=0,o=i,0===s?(c=138,l=3):i===s?(c=6,l=3):(c=7,l=4)}};let _n=!1;const Sn=(t,e,n,r)=>{un(t,0+(r?1:0),3),((t,e,n,r)=>{mn(t),r&&(hn(t,n),hn(t,~n)),t.pending_buf.set(t.window.subarray(e,e+n),t.pending),t.pending+=n})(t,e,n,!0)};var Cn=(t,e,n,r)=>{let i,o,s=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,n=4093624447;for(e=0;e<=31;e++,n>>>=1)if(1&n&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),yn(t,t.l_desc),yn(t,t.d_desc),s=(t=>{let e;for(xn(t,t.dyn_ltree,t.l_desc.max_code),xn(t,t.dyn_dtree,t.d_desc.max_code),yn(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*Ye[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),i=t.opt_len+3+7>>>3,o=t.static_len+3+7>>>3,o<=i&&(i=o)):i=o=n+5,n+4<=i&&-1!==e?Sn(t,e,n,r):4===t.strategy||o===i?(un(t,2+(r?1:0),3),wn(t,Ke,Qe)):(un(t,4+(r?1:0),3),((t,e,n,r)=>{let i;for(un(t,e-257,5),un(t,n-1,5),un(t,r-4,4),i=0;i<r;i++)un(t,t.bl_tree[2*Ye[i]+1],3);kn(t,t.dyn_ltree,e-1),kn(t,t.dyn_dtree,n-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,s+1),wn(t,t.dyn_ltree,t.dyn_dtree)),gn(t),r&&mn(t)},En={_tr_init:t=>{_n||((()=>{let t,e,n,r,i;const o=new Array(16);for(n=0,r=0;r<28;r++)for(en[r]=n,t=0;t<1<<Ge[r];t++)tn[n++]=r;for(tn[n-1]=r,i=0,r=0;r<16;r++)for(nn[r]=i,t=0;t<1<<Ze[r];t++)Je[i++]=r;for(i>>=7;r<30;r++)for(nn[r]=i<<7,t=0;t<1<<Ze[r]-7;t++)Je[256+i++]=r;for(e=0;e<=15;e++)o[e]=0;for(t=0;t<=143;)Ke[2*t+1]=8,t++,o[8]++;for(;t<=255;)Ke[2*t+1]=9,t++,o[9]++;for(;t<=279;)Ke[2*t+1]=7,t++,o[7]++;for(;t<=287;)Ke[2*t+1]=8,t++,o[8]++;for(pn(Ke,287,o),t=0;t<30;t++)Qe[2*t+1]=5,Qe[2*t]=dn(t,5);on=new rn(Ke,Ge,257,286,15),sn=new rn(Qe,Ze,0,30,15),an=new rn(new Array(0),Xe,0,19,7)})(),_n=!0),t.l_desc=new cn(t.dyn_ltree,on),t.d_desc=new cn(t.dyn_dtree,sn),t.bl_desc=new cn(t.bl_tree,an),t.bi_buf=0,t.bi_valid=0,gn(t)},_tr_stored_block:Sn,_tr_flush_block:Cn,_tr_tally:(t,e,n)=>(t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&n,t.last_lit++,0===e?t.dyn_ltree[2*n]++:(t.matches++,e--,t.dyn_ltree[2*(tn[n]+256+1)]++,t.dyn_dtree[2*ln(e)]++),t.last_lit===t.lit_bufsize-1),_tr_align:t=>{un(t,2,3),fn(t,256,Ke),(t=>{16===t.bi_valid?(hn(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}};var An=(t,e,n,r)=>{let i=65535&t|0,o=t>>>16&65535|0,s=0;for(;0!==n;){s=n>2e3?2e3:n,n-=s;do{i=i+e[r++]|0,o=o+i|0}while(--s);i%=65521,o%=65521}return i|o<<16|0};const Tn=new Uint32Array((()=>{let t,e=[];for(var n=0;n<256;n++){t=n;for(var r=0;r<8;r++)t=1&t?3988292384^t>>>1:t>>>1;e[n]=t}return e})());var Ln=(t,e,n,r)=>{const i=Tn,o=r+n;t^=-1;for(let n=r;n<o;n++)t=t>>>8^i[255&(t^e[n])];return-1^t},Mn={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"},Rn={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:In,_tr_stored_block:Nn,_tr_flush_block:Pn,_tr_tally:On,_tr_align:Fn}=En,{Z_NO_FLUSH:Dn,Z_PARTIAL_FLUSH:Bn,Z_FULL_FLUSH:zn,Z_FINISH:Hn,Z_BLOCK:Vn,Z_OK:jn,Z_STREAM_END:Un,Z_STREAM_ERROR:qn,Z_DATA_ERROR:Wn,Z_BUF_ERROR:$n,Z_DEFAULT_COMPRESSION:Gn,Z_FILTERED:Zn,Z_HUFFMAN_ONLY:Xn,Z_RLE:Yn,Z_FIXED:Kn,Z_DEFAULT_STRATEGY:Qn,Z_UNKNOWN:Jn,Z_DEFLATED:tr}=Rn,er=(t,e)=>(t.msg=Mn[e],e),nr=t=>(t<<1)-(t>4?9:0),rr=t=>{let e=t.length;for(;--e>=0;)t[e]=0};let ir=(t,e,n)=>(e<<t.hash_shift^n)&t.hash_mask;const or=t=>{const e=t.state;let n=e.pending;n>t.avail_out&&(n=t.avail_out),0!==n&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+n),t.next_out),t.next_out+=n,e.pending_out+=n,t.total_out+=n,t.avail_out-=n,e.pending-=n,0===e.pending&&(e.pending_out=0))},sr=(t,e)=>{Pn(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,or(t.strm)},ar=(t,e)=>{t.pending_buf[t.pending++]=e},cr=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},lr=(t,e,n,r)=>{let i=t.avail_in;return i>r&&(i=r),0===i?0:(t.avail_in-=i,e.set(t.input.subarray(t.next_in,t.next_in+i),n),1===t.state.wrap?t.adler=An(t.adler,e,i,n):2===t.state.wrap&&(t.adler=Ln(t.adler,e,i,n)),t.next_in+=i,t.total_in+=i,i)},hr=(t,e)=>{let n,r,i=t.max_chain_length,o=t.strstart,s=t.prev_length,a=t.nice_match;const c=t.strstart>t.w_size-262?t.strstart-(t.w_size-262):0,l=t.window,h=t.w_mask,u=t.prev,f=t.strstart+258;let d=l[o+s-1],p=l[o+s];t.prev_length>=t.good_match&&(i>>=2),a>t.lookahead&&(a=t.lookahead);do{if(n=e,l[n+s]===p&&l[n+s-1]===d&&l[n]===l[o]&&l[++n]===l[o+1]){o+=2,n++;do{}while(l[++o]===l[++n]&&l[++o]===l[++n]&&l[++o]===l[++n]&&l[++o]===l[++n]&&l[++o]===l[++n]&&l[++o]===l[++n]&&l[++o]===l[++n]&&l[++o]===l[++n]&&o<f);if(r=258-(f-o),o=f-258,r>s){if(t.match_start=e,s=r,r>=a)break;d=l[o+s-1],p=l[o+s]}}}while((e=u[e&h])>c&&0!=--i);return s<=t.lookahead?s:t.lookahead},ur=t=>{const e=t.w_size;let n,r,i,o,s;do{if(o=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-262)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,r=t.hash_size,n=r;do{i=t.head[--n],t.head[n]=i>=e?i-e:0}while(--r);r=e,n=r;do{i=t.prev[--n],t.prev[n]=i>=e?i-e:0}while(--r);o+=e}if(0===t.strm.avail_in)break;if(r=lr(t.strm,t.window,t.strstart+t.lookahead,o),t.lookahead+=r,t.lookahead+t.insert>=3)for(s=t.strstart-t.insert,t.ins_h=t.window[s],t.ins_h=ir(t,t.ins_h,t.window[s+1]);t.insert&&(t.ins_h=ir(t,t.ins_h,t.window[s+3-1]),t.prev[s&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=s,s++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<262&&0!==t.strm.avail_in)},fr=(t,e)=>{let n,r;for(;;){if(t.lookahead<262){if(ur(t),t.lookahead<262&&e===Dn)return 1;if(0===t.lookahead)break}if(n=0,t.lookahead>=3&&(t.ins_h=ir(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==n&&t.strstart-n<=t.w_size-262&&(t.match_length=hr(t,n)),t.match_length>=3)if(r=On(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=ir(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=ir(t,t.ins_h,t.window[t.strstart+1]);else r=On(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(r&&(sr(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===Hn?(sr(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(sr(t,!1),0===t.strm.avail_out)?1:2},dr=(t,e)=>{let n,r,i;for(;;){if(t.lookahead<262){if(ur(t),t.lookahead<262&&e===Dn)return 1;if(0===t.lookahead)break}if(n=0,t.lookahead>=3&&(t.ins_h=ir(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==n&&t.prev_length<t.max_lazy_match&&t.strstart-n<=t.w_size-262&&(t.match_length=hr(t,n),t.match_length<=5&&(t.strategy===Zn||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-3,r=On(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=ir(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,r&&(sr(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(r=On(t,0,t.window[t.strstart-1]),r&&sr(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(r=On(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===Hn?(sr(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(sr(t,!1),0===t.strm.avail_out)?1:2};function pr(t,e,n,r,i){this.good_length=t,this.max_lazy=e,this.nice_length=n,this.max_chain=r,this.func=i}const gr=[new pr(0,0,0,0,((t,e)=>{let n=65535;for(n>t.pending_buf_size-5&&(n=t.pending_buf_size-5);;){if(t.lookahead<=1){if(ur(t),0===t.lookahead&&e===Dn)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;const r=t.block_start+n;if((0===t.strstart||t.strstart>=r)&&(t.lookahead=t.strstart-r,t.strstart=r,sr(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-262&&(sr(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Hn?(sr(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(sr(t,!1),t.strm.avail_out),1)})),new pr(4,4,8,4,fr),new pr(4,5,16,8,fr),new pr(4,6,32,32,fr),new pr(4,4,16,16,dr),new pr(8,16,32,32,dr),new pr(8,16,128,128,dr),new pr(8,32,128,256,dr),new pr(32,128,258,1024,dr),new pr(32,258,258,4096,dr)];function mr(){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=tr,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),rr(this.dyn_ltree),rr(this.dyn_dtree),rr(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),rr(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),rr(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}const vr=t=>{if(!t||!t.state)return er(t,qn);t.total_in=t.total_out=0,t.data_type=Jn;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:113,t.adler=2===e.wrap?0:1,e.last_flush=Dn,In(e),jn},br=t=>{const e=vr(t);var n;return e===jn&&((n=t.state).window_size=2*n.w_size,rr(n.head),n.max_lazy_match=gr[n.level].max_lazy,n.good_match=gr[n.level].good_length,n.nice_match=gr[n.level].nice_length,n.max_chain_length=gr[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),e},wr=(t,e,n,r,i,o)=>{if(!t)return qn;let s=1;if(e===Gn&&(e=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),i<1||i>9||n!==tr||r<8||r>15||e<0||e>9||o<0||o>Kn)return er(t,qn);8===r&&(r=9);const a=new mr;return t.state=a,a.strm=t,a.wrap=s,a.gzhead=null,a.w_bits=r,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=i+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<<i+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Uint8Array(a.pending_buf_size),a.d_buf=1*a.lit_bufsize,a.l_buf=3*a.lit_bufsize,a.level=e,a.strategy=o,a.method=n,br(t)};var yr=(t,e)=>{let n=e.length;if(!t||!t.state)return qn;const r=t.state,i=r.wrap;if(2===i||1===i&&42!==r.status||r.lookahead)return qn;if(1===i&&(t.adler=An(t.adler,e,n,0)),r.wrap=0,n>=r.w_size){0===i&&(rr(r.head),r.strstart=0,r.block_start=0,r.insert=0);let t=new Uint8Array(r.w_size);t.set(e.subarray(n-r.w_size,n),0),e=t,n=r.w_size}const o=t.avail_in,s=t.next_in,a=t.input;for(t.avail_in=n,t.next_in=0,t.input=e,ur(r);r.lookahead>=3;){let t=r.strstart,e=r.lookahead-2;do{r.ins_h=ir(r,r.ins_h,r.window[t+3-1]),r.prev[t&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=t,t++}while(--e);r.strstart=t,r.lookahead=2,ur(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,t.next_in=s,t.input=a,t.avail_in=o,r.wrap=i,jn},xr={deflateInit:(t,e)=>wr(t,e,tr,15,8,Qn),deflateInit2:wr,deflateReset:br,deflateResetKeep:vr,deflateSetHeader:(t,e)=>t&&t.state?2!==t.state.wrap?qn:(t.state.gzhead=e,jn):qn,deflate:(t,e)=>{let n,r;if(!t||!t.state||e>Vn||e<0)return t?er(t,qn):qn;const i=t.state;if(!t.output||!t.input&&0!==t.avail_in||666===i.status&&e!==Hn)return er(t,0===t.avail_out?$n:qn);i.strm=t;const o=i.last_flush;if(i.last_flush=e,42===i.status)if(2===i.wrap)t.adler=0,ar(i,31),ar(i,139),ar(i,8),i.gzhead?(ar(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)),ar(i,255&i.gzhead.time),ar(i,i.gzhead.time>>8&255),ar(i,i.gzhead.time>>16&255),ar(i,i.gzhead.time>>24&255),ar(i,9===i.level?2:i.strategy>=Xn||i.level<2?4:0),ar(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(ar(i,255&i.gzhead.extra.length),ar(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=Ln(t.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(ar(i,0),ar(i,0),ar(i,0),ar(i,0),ar(i,0),ar(i,9===i.level?2:i.strategy>=Xn||i.level<2?4:0),ar(i,3),i.status=113);else{let e=tr+(i.w_bits-8<<4)<<8,n=-1;n=i.strategy>=Xn||i.level<2?0:i.level<6?1:6===i.level?2:3,e|=n<<6,0!==i.strstart&&(e|=32),e+=31-e%31,i.status=113,cr(i,e),0!==i.strstart&&(cr(i,t.adler>>>16),cr(i,65535&t.adler)),t.adler=1}if(69===i.status)if(i.gzhead.extra){for(n=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>n&&(t.adler=Ln(t.adler,i.pending_buf,i.pending-n,n)),or(t),n=i.pending,i.pending!==i.pending_buf_size));)ar(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>n&&(t.adler=Ln(t.adler,i.pending_buf,i.pending-n,n)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(t.adler=Ln(t.adler,i.pending_buf,i.pending-n,n)),or(t),n=i.pending,i.pending===i.pending_buf_size)){r=1;break}r=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,ar(i,r)}while(0!==r);i.gzhead.hcrc&&i.pending>n&&(t.adler=Ln(t.adler,i.pending_buf,i.pending-n,n)),0===r&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(t.adler=Ln(t.adler,i.pending_buf,i.pending-n,n)),or(t),n=i.pending,i.pending===i.pending_buf_size)){r=1;break}r=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,ar(i,r)}while(0!==r);i.gzhead.hcrc&&i.pending>n&&(t.adler=Ln(t.adler,i.pending_buf,i.pending-n,n)),0===r&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&or(t),i.pending+2<=i.pending_buf_size&&(ar(i,255&t.adler),ar(i,t.adler>>8&255),t.adler=0,i.status=113)):i.status=113),0!==i.pending){if(or(t),0===t.avail_out)return i.last_flush=-1,jn}else if(0===t.avail_in&&nr(e)<=nr(o)&&e!==Hn)return er(t,$n);if(666===i.status&&0!==t.avail_in)return er(t,$n);if(0!==t.avail_in||0!==i.lookahead||e!==Dn&&666!==i.status){let n=i.strategy===Xn?((t,e)=>{let n;for(;;){if(0===t.lookahead&&(ur(t),0===t.lookahead)){if(e===Dn)return 1;break}if(t.match_length=0,n=On(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,n&&(sr(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Hn?(sr(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(sr(t,!1),0===t.strm.avail_out)?1:2})(i,e):i.strategy===Yn?((t,e)=>{let n,r,i,o;const s=t.window;for(;;){if(t.lookahead<=258){if(ur(t),t.lookahead<=258&&e===Dn)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(i=t.strstart-1,r=s[i],r===s[++i]&&r===s[++i]&&r===s[++i])){o=t.strstart+258;do{}while(r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&i<o);t.match_length=258-(o-i),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(n=On(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(n=On(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),n&&(sr(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Hn?(sr(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(sr(t,!1),0===t.strm.avail_out)?1:2})(i,e):gr[i.level].func(i,e);if(3!==n&&4!==n||(i.status=666),1===n||3===n)return 0===t.avail_out&&(i.last_flush=-1),jn;if(2===n&&(e===Bn?Fn(i):e!==Vn&&(Nn(i,0,0,!1),e===zn&&(rr(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),or(t),0===t.avail_out))return i.last_flush=-1,jn}return e!==Hn?jn:i.wrap<=0?Un:(2===i.wrap?(ar(i,255&t.adler),ar(i,t.adler>>8&255),ar(i,t.adler>>16&255),ar(i,t.adler>>24&255),ar(i,255&t.total_in),ar(i,t.total_in>>8&255),ar(i,t.total_in>>16&255),ar(i,t.total_in>>24&255)):(cr(i,t.adler>>>16),cr(i,65535&t.adler)),or(t),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?jn:Un)},deflateEnd:t=>{if(!t||!t.state)return qn;const e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&103!==e&&113!==e&&666!==e?er(t,qn):(t.state=null,113===e?er(t,Wn):jn)},deflateSetDictionary:yr,deflateInfo:"pako deflate (from Nodeca project)"};const kr=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var _r=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const n=e.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const e in n)kr(n,e)&&(t[e]=n[e])}}return t},Sr=t=>{let e=0;for(let n=0,r=t.length;n<r;n++)e+=t[n].length;const n=new Uint8Array(e);for(let e=0,r=0,i=t.length;e<i;e++){let i=t[e];n.set(i,r),r+=i.length}return n};let Cr=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(od){Cr=!1}const Er=new Uint8Array(256);for(let sd=0;sd<256;sd++)Er[sd]=sd>=252?6:sd>=248?5:sd>=240?4:sd>=224?3:sd>=192?2:1;Er[254]=Er[254]=1;var Ar=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,n,r,i,o,s=t.length,a=0;for(i=0;i<s;i++)n=t.charCodeAt(i),55296==(64512&n)&&i+1<s&&(r=t.charCodeAt(i+1),56320==(64512&r)&&(n=65536+(n-55296<<10)+(r-56320),i++)),a+=n<128?1:n<2048?2:n<65536?3:4;for(e=new Uint8Array(a),o=0,i=0;o<a;i++)n=t.charCodeAt(i),55296==(64512&n)&&i+1<s&&(r=t.charCodeAt(i+1),56320==(64512&r)&&(n=65536+(n-55296<<10)+(r-56320),i++)),n<128?e[o++]=n:n<2048?(e[o++]=192|n>>>6,e[o++]=128|63&n):n<65536?(e[o++]=224|n>>>12,e[o++]=128|n>>>6&63,e[o++]=128|63&n):(e[o++]=240|n>>>18,e[o++]=128|n>>>12&63,e[o++]=128|n>>>6&63,e[o++]=128|63&n);return e},Tr=(t,e)=>{const n=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let r,i;const o=new Array(2*n);for(i=0,r=0;r<n;){let e=t[r++];if(e<128){o[i++]=e;continue}let s=Er[e];if(s>4)o[i++]=65533,r+=s-1;else{for(e&=2===s?31:3===s?15:7;s>1&&r<n;)e=e<<6|63&t[r++],s--;s>1?o[i++]=65533:e<65536?o[i++]=e:(e-=65536,o[i++]=55296|e>>10&1023,o[i++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&Cr)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let n="";for(let r=0;r<e;r++)n+=String.fromCharCode(t[r]);return n})(o,i)},Lr=(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let n=e-1;for(;n>=0&&128==(192&t[n]);)n--;return n<0||0===n?e:n+Er[t[n]]>e?n:e};var Mr=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 Rr=Object.prototype.toString,{Z_NO_FLUSH:Ir,Z_SYNC_FLUSH:Nr,Z_FULL_FLUSH:Pr,Z_FINISH:Or,Z_OK:Fr,Z_STREAM_END:Dr,Z_DEFAULT_COMPRESSION:Br,Z_DEFAULT_STRATEGY:zr,Z_DEFLATED:Hr}=Rn;function Vr(t){this.options=_r({level:Br,method:Hr,chunkSize:16384,windowBits:15,memLevel:8,strategy:zr},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Mr,this.strm.avail_out=0;let n=xr.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(n!==Fr)throw new Error(Mn[n]);if(e.header&&xr.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Ar(e.dictionary):"[object ArrayBuffer]"===Rr.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,n=xr.deflateSetDictionary(this.strm,t),n!==Fr)throw new Error(Mn[n]);this._dict_set=!0}}function jr(t,e){const n=new Vr(e);if(n.push(t,!0),n.err)throw n.msg||Mn[n.err];return n.result}Vr.prototype.push=function(t,e){const n=this.strm,r=this.options.chunkSize;let i,o;if(this.ended)return!1;for(o=e===~~e?e:!0===e?Or:Ir,"string"==typeof t?n.input=Ar(t):"[object ArrayBuffer]"===Rr.call(t)?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(o===Nr||o===Pr)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(i=xr.deflate(n,o),i===Dr)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=xr.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Fr;if(0!==n.avail_out){if(o>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},Vr.prototype.onData=function(t){this.chunks.push(t)},Vr.prototype.onEnd=function(t){t===Fr&&(this.result=Sr(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Ur=function(t,e){return(e=e||{}).raw=!0,jr(t,e)},qr=function(t,e){return(e=e||{}).gzip=!0,jr(t,e)},Wr={Deflate:Vr,deflate:jr,deflateRaw:Ur,gzip:qr,constants:Rn};var $r=function(t,e){let n,r,i,o,s,a,c,l,h,u,f,d,p,g,m,v,b,w,y,x,k,_,S,C;const E=t.state;n=t.next_in,S=t.input,r=n+(t.avail_in-5),i=t.next_out,C=t.output,o=i-(e-t.avail_out),s=i+(t.avail_out-257),a=E.dmax,c=E.wsize,l=E.whave,h=E.wnext,u=E.window,f=E.hold,d=E.bits,p=E.lencode,g=E.distcode,m=(1<<E.lenbits)-1,v=(1<<E.distbits)-1;t:do{d<15&&(f+=S[n++]<<d,d+=8,f+=S[n++]<<d,d+=8),b=p[f&m];e:for(;;){if(w=b>>>24,f>>>=w,d-=w,w=b>>>16&255,0===w)C[i++]=65535&b;else{if(!(16&w)){if(0==(64&w)){b=p[(65535&b)+(f&(1<<w)-1)];continue e}if(32&w){E.mode=12;break t}t.msg="invalid literal/length code",E.mode=30;break t}y=65535&b,w&=15,w&&(d<w&&(f+=S[n++]<<d,d+=8),y+=f&(1<<w)-1,f>>>=w,d-=w),d<15&&(f+=S[n++]<<d,d+=8,f+=S[n++]<<d,d+=8),b=g[f&v];n:for(;;){if(w=b>>>24,f>>>=w,d-=w,w=b>>>16&255,!(16&w)){if(0==(64&w)){b=g[(65535&b)+(f&(1<<w)-1)];continue n}t.msg="invalid distance code",E.mode=30;break t}if(x=65535&b,w&=15,d<w&&(f+=S[n++]<<d,d+=8,d<w&&(f+=S[n++]<<d,d+=8)),x+=f&(1<<w)-1,x>a){t.msg="invalid distance too far back",E.mode=30;break t}if(f>>>=w,d-=w,w=i-o,x>w){if(w=x-w,w>l&&E.sane){t.msg="invalid distance too far back",E.mode=30;break t}if(k=0,_=u,0===h){if(k+=c-w,w<y){y-=w;do{C[i++]=u[k++]}while(--w);k=i-x,_=C}}else if(h<w){if(k+=c+h-w,w-=h,w<y){y-=w;do{C[i++]=u[k++]}while(--w);if(k=0,h<y){w=h,y-=w;do{C[i++]=u[k++]}while(--w);k=i-x,_=C}}}else if(k+=h-w,w<y){y-=w;do{C[i++]=u[k++]}while(--w);k=i-x,_=C}for(;y>2;)C[i++]=_[k++],C[i++]=_[k++],C[i++]=_[k++],y-=3;y&&(C[i++]=_[k++],y>1&&(C[i++]=_[k++]))}else{k=i-x;do{C[i++]=C[k++],C[i++]=C[k++],C[i++]=C[k++],y-=3}while(y>2);y&&(C[i++]=C[k++],y>1&&(C[i++]=C[k++]))}break}}break}}while(n<r&&i<s);y=d>>3,n-=y,d-=y<<3,f&=(1<<d)-1,t.next_in=n,t.next_out=i,t.avail_in=n<r?r-n+5:5-(n-r),t.avail_out=i<s?s-i+257:257-(i-s),E.hold=f,E.bits=d};const Gr=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]),Zr=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]),Xr=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 Kr=(t,e,n,r,i,o,s,a)=>{const c=a.bits;let l,h,u,f,d,p,g=0,m=0,v=0,b=0,w=0,y=0,x=0,k=0,_=0,S=0,C=null,E=0;const A=new Uint16Array(16),T=new Uint16Array(16);let L,M,R,I=null,N=0;for(g=0;g<=15;g++)A[g]=0;for(m=0;m<r;m++)A[e[n+m]]++;for(w=c,b=15;b>=1&&0===A[b];b--);if(w>b&&(w=b),0===b)return i[o++]=20971520,i[o++]=20971520,a.bits=1,0;for(v=1;v<b&&0===A[v];v++);for(w<v&&(w=v),k=1,g=1;g<=15;g++)if(k<<=1,k-=A[g],k<0)return-1;if(k>0&&(0===t||1!==b))return-1;for(T[1]=0,g=1;g<15;g++)T[g+1]=T[g]+A[g];for(m=0;m<r;m++)0!==e[n+m]&&(s[T[e[n+m]]++]=m);if(0===t?(C=I=s,p=19):1===t?(C=Gr,E-=257,I=Zr,N-=257,p=256):(C=Xr,I=Yr,p=-1),S=0,m=0,g=v,d=o,y=w,x=0,u=-1,_=1<<w,f=_-1,1===t&&_>852||2===t&&_>592)return 1;for(;;){L=g-x,s[m]<p?(M=0,R=s[m]):s[m]>p?(M=I[N+s[m]],R=C[E+s[m]]):(M=96,R=0),l=1<<g-x,h=1<<y,v=h;do{h-=l,i[d+(S>>x)+h]=L<<24|M<<16|R|0}while(0!==h);for(l=1<<g-1;S&l;)l>>=1;if(0!==l?(S&=l-1,S+=l):S=0,m++,0==--A[g]){if(g===b)break;g=e[n+s[m]]}if(g>w&&(S&f)!==u){for(0===x&&(x=w),d+=v,y=g-x,k=1<<y;y+x<b&&(k-=A[y+x],!(k<=0));)y++,k<<=1;if(_+=1<<y,1===t&&_>852||2===t&&_>592)return 1;u=S&f,i[u]=w<<24|y<<16|d-o|0}}return 0!==S&&(i[d+S]=g-x<<24|64<<16|0),a.bits=w,0};const{Z_FINISH:Qr,Z_BLOCK:Jr,Z_TREES:ti,Z_OK:ei,Z_STREAM_END:ni,Z_NEED_DICT:ri,Z_STREAM_ERROR:ii,Z_DATA_ERROR:oi,Z_MEM_ERROR:si,Z_BUF_ERROR:ai,Z_DEFLATED:ci}=Rn,li=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function hi(){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 ui=t=>{if(!t||!t.state)return ii;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,ei},fi=t=>{if(!t||!t.state)return ii;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,ui(t)},di=(t,e)=>{let n;if(!t||!t.state)return ii;const r=t.state;return e<0?(n=0,e=-e):(n=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?ii:(null!==r.window&&r.wbits!==e&&(r.window=null),r.wrap=n,r.wbits=e,fi(t))},pi=(t,e)=>{if(!t)return ii;const n=new hi;t.state=n,n.window=null;const r=di(t,e);return r!==ei&&(t.state=null),r};let gi,mi,vi=!0;const bi=t=>{if(vi){gi=new Int32Array(512),mi=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(Kr(1,t.lens,0,288,gi,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;Kr(2,t.lens,0,32,mi,0,t.work,{bits:5}),vi=!1}t.lencode=gi,t.lenbits=9,t.distcode=mi,t.distbits=5},wi=(t,e,n,r)=>{let i;const o=t.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new Uint8Array(o.wsize)),r>=o.wsize?(o.window.set(e.subarray(n-o.wsize,n),0),o.wnext=0,o.whave=o.wsize):(i=o.wsize-o.wnext,i>r&&(i=r),o.window.set(e.subarray(n-r,n-r+i),o.wnext),(r-=i)?(o.window.set(e.subarray(n-r,n),0),o.wnext=r,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=i))),0};var yi=(t,e)=>{let n,r,i,o,s,a,c,l,h,u,f,d,p,g,m,v,b,w,y,x,k,_,S=0;const C=new Uint8Array(4);let E,A;const T=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return ii;n=t.state,12===n.mode&&(n.mode=13),s=t.next_out,i=t.output,c=t.avail_out,o=t.next_in,r=t.input,a=t.avail_in,l=n.hold,h=n.bits,u=a,f=c,_=ei;t:for(;;)switch(n.mode){case 1:if(0===n.wrap){n.mode=13;break}for(;h<16;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}if(2&n.wrap&&35615===l){n.check=0,C[0]=255&l,C[1]=l>>>8&255,n.check=Ln(n.check,C,2,0),l=0,h=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&l)<<8)+(l>>8))%31){t.msg="incorrect header check",n.mode=30;break}if((15&l)!==ci){t.msg="unknown compression method",n.mode=30;break}if(l>>>=4,h-=4,k=8+(15&l),0===n.wbits)n.wbits=k;else if(k>n.wbits){t.msg="invalid window size",n.mode=30;break}n.dmax=1<<n.wbits,t.adler=n.check=1,n.mode=512&l?10:12,l=0,h=0;break;case 2:for(;h<16;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}if(n.flags=l,(255&n.flags)!==ci){t.msg="unknown compression method",n.mode=30;break}if(57344&n.flags){t.msg="unknown header flags set",n.mode=30;break}n.head&&(n.head.text=l>>8&1),512&n.flags&&(C[0]=255&l,C[1]=l>>>8&255,n.check=Ln(n.check,C,2,0)),l=0,h=0,n.mode=3;case 3:for(;h<32;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}n.head&&(n.head.time=l),512&n.flags&&(C[0]=255&l,C[1]=l>>>8&255,C[2]=l>>>16&255,C[3]=l>>>24&255,n.check=Ln(n.check,C,4,0)),l=0,h=0,n.mode=4;case 4:for(;h<16;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}n.head&&(n.head.xflags=255&l,n.head.os=l>>8),512&n.flags&&(C[0]=255&l,C[1]=l>>>8&255,n.check=Ln(n.check,C,2,0)),l=0,h=0,n.mode=5;case 5:if(1024&n.flags){for(;h<16;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}n.length=l,n.head&&(n.head.extra_len=l),512&n.flags&&(C[0]=255&l,C[1]=l>>>8&255,n.check=Ln(n.check,C,2,0)),l=0,h=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&(d=n.length,d>a&&(d=a),d&&(n.head&&(k=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(o,o+d),k)),512&n.flags&&(n.check=Ln(n.check,r,d,o)),a-=d,o+=d,n.length-=d),n.length))break t;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===a)break t;d=0;do{k=r[o+d++],n.head&&k&&n.length<65536&&(n.head.name+=String.fromCharCode(k))}while(k&&d<a);if(512&n.flags&&(n.check=Ln(n.check,r,d,o)),a-=d,o+=d,k)break t}else n.head&&(n.head.name=null);n.length=0,n.mode=8;case 8:if(4096&n.flags){if(0===a)break t;d=0;do{k=r[o+d++],n.head&&k&&n.length<65536&&(n.head.comment+=String.fromCharCode(k))}while(k&&d<a);if(512&n.flags&&(n.check=Ln(n.check,r,d,o)),a-=d,o+=d,k)break t}else n.head&&(n.head.comment=null);n.mode=9;case 9:if(512&n.flags){for(;h<16;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}if(l!==(65535&n.check)){t.msg="header crc mismatch",n.mode=30;break}l=0,h=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),t.adler=n.check=0,n.mode=12;break;case 10:for(;h<32;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}t.adler=n.check=li(l),l=0,h=0,n.mode=11;case 11:if(0===n.havedict)return t.next_out=s,t.avail_out=c,t.next_in=o,t.avail_in=a,n.hold=l,n.bits=h,ri;t.adler=n.check=1,n.mode=12;case 12:if(e===Jr||e===ti)break t;case 13:if(n.last){l>>>=7&h,h-=7&h,n.mode=27;break}for(;h<3;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}switch(n.last=1&l,l>>>=1,h-=1,3&l){case 0:n.mode=14;break;case 1:if(bi(n),n.mode=20,e===ti){l>>>=2,h-=2;break t}break;case 2:n.mode=17;break;case 3:t.msg="invalid block type",n.mode=30}l>>>=2,h-=2;break;case 14:for(l>>>=7&h,h-=7&h;h<32;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}if((65535&l)!=(l>>>16^65535)){t.msg="invalid stored block lengths",n.mode=30;break}if(n.length=65535&l,l=0,h=0,n.mode=15,e===ti)break t;case 15:n.mode=16;case 16:if(d=n.length,d){if(d>a&&(d=a),d>c&&(d=c),0===d)break t;i.set(r.subarray(o,o+d),s),a-=d,o+=d,c-=d,s+=d,n.length-=d;break}n.mode=12;break;case 17:for(;h<14;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}if(n.nlen=257+(31&l),l>>>=5,h-=5,n.ndist=1+(31&l),l>>>=5,h-=5,n.ncode=4+(15&l),l>>>=4,h-=4,n.nlen>286||n.ndist>30){t.msg="too many length or distance symbols",n.mode=30;break}n.have=0,n.mode=18;case 18:for(;n.have<n.ncode;){for(;h<3;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}n.lens[T[n.have++]]=7&l,l>>>=3,h-=3}for(;n.have<19;)n.lens[T[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,E={bits:n.lenbits},_=Kr(0,n.lens,0,19,n.lencode,0,n.work,E),n.lenbits=E.bits,_){t.msg="invalid code lengths set",n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have<n.nlen+n.ndist;){for(;S=n.lencode[l&(1<<n.lenbits)-1],m=S>>>24,v=S>>>16&255,b=65535&S,!(m<=h);){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}if(b<16)l>>>=m,h-=m,n.lens[n.have++]=b;else{if(16===b){for(A=m+2;h<A;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}if(l>>>=m,h-=m,0===n.have){t.msg="invalid bit length repeat",n.mode=30;break}k=n.lens[n.have-1],d=3+(3&l),l>>>=2,h-=2}else if(17===b){for(A=m+3;h<A;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}l>>>=m,h-=m,k=0,d=3+(7&l),l>>>=3,h-=3}else{for(A=m+7;h<A;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}l>>>=m,h-=m,k=0,d=11+(127&l),l>>>=7,h-=7}if(n.have+d>n.nlen+n.ndist){t.msg="invalid bit length repeat",n.mode=30;break}for(;d--;)n.lens[n.have++]=k}}if(30===n.mode)break;if(0===n.lens[256]){t.msg="invalid code -- missing end-of-block",n.mode=30;break}if(n.lenbits=9,E={bits:n.lenbits},_=Kr(1,n.lens,0,n.nlen,n.lencode,0,n.work,E),n.lenbits=E.bits,_){t.msg="invalid literal/lengths set",n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,E={bits:n.distbits},_=Kr(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,E),n.distbits=E.bits,_){t.msg="invalid distances set",n.mode=30;break}if(n.mode=20,e===ti)break t;case 20:n.mode=21;case 21:if(a>=6&&c>=258){t.next_out=s,t.avail_out=c,t.next_in=o,t.avail_in=a,n.hold=l,n.bits=h,$r(t,f),s=t.next_out,i=t.output,c=t.avail_out,o=t.next_in,r=t.input,a=t.avail_in,l=n.hold,h=n.bits,12===n.mode&&(n.back=-1);break}for(n.back=0;S=n.lencode[l&(1<<n.lenbits)-1],m=S>>>24,v=S>>>16&255,b=65535&S,!(m<=h);){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}if(v&&0==(240&v)){for(w=m,y=v,x=b;S=n.lencode[x+((l&(1<<w+y)-1)>>w)],m=S>>>24,v=S>>>16&255,b=65535&S,!(w+m<=h);){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}l>>>=w,h-=w,n.back+=w}if(l>>>=m,h-=m,n.back+=m,n.length=b,0===v){n.mode=26;break}if(32&v){n.back=-1,n.mode=12;break}if(64&v){t.msg="invalid literal/length code",n.mode=30;break}n.extra=15&v,n.mode=22;case 22:if(n.extra){for(A=n.extra;h<A;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}n.length+=l&(1<<n.extra)-1,l>>>=n.extra,h-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;S=n.distcode[l&(1<<n.distbits)-1],m=S>>>24,v=S>>>16&255,b=65535&S,!(m<=h);){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}if(0==(240&v)){for(w=m,y=v,x=b;S=n.distcode[x+((l&(1<<w+y)-1)>>w)],m=S>>>24,v=S>>>16&255,b=65535&S,!(w+m<=h);){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}l>>>=w,h-=w,n.back+=w}if(l>>>=m,h-=m,n.back+=m,64&v){t.msg="invalid distance code",n.mode=30;break}n.offset=b,n.extra=15&v,n.mode=24;case 24:if(n.extra){for(A=n.extra;h<A;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}n.offset+=l&(1<<n.extra)-1,l>>>=n.extra,h-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){t.msg="invalid distance too far back",n.mode=30;break}n.mode=25;case 25:if(0===c)break t;if(d=f-c,n.offset>d){if(d=n.offset-d,d>n.whave&&n.sane){t.msg="invalid distance too far back",n.mode=30;break}d>n.wnext?(d-=n.wnext,p=n.wsize-d):p=n.wnext-d,d>n.length&&(d=n.length),g=n.window}else g=i,p=s-n.offset,d=n.length;d>c&&(d=c),c-=d,n.length-=d;do{i[s++]=g[p++]}while(--d);0===n.length&&(n.mode=21);break;case 26:if(0===c)break t;i[s++]=n.length,c--,n.mode=21;break;case 27:if(n.wrap){for(;h<32;){if(0===a)break t;a--,l|=r[o++]<<h,h+=8}if(f-=c,t.total_out+=f,n.total+=f,f&&(t.adler=n.check=n.flags?Ln(n.check,i,f,s-f):An(n.check,i,f,s-f)),f=c,(n.flags?l:li(l))!==n.check){t.msg="incorrect data check",n.mode=30;break}l=0,h=0}n.mode=28;case 28:if(n.wrap&&n.flags){for(;h<32;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}if(l!==(4294967295&n.total)){t.msg="incorrect length check",n.mode=30;break}l=0,h=0}n.mode=29;case 29:_=ni;break t;case 30:_=oi;break t;case 31:return si;default:return ii}return t.next_out=s,t.avail_out=c,t.next_in=o,t.avail_in=a,n.hold=l,n.bits=h,(n.wsize||f!==t.avail_out&&n.mode<30&&(n.mode<27||e!==Qr))&&wi(t,t.output,t.next_out,f-t.avail_out),u-=t.avail_in,f-=t.avail_out,t.total_in+=u,t.total_out+=f,n.total+=f,n.wrap&&f&&(t.adler=n.check=n.flags?Ln(n.check,i,f,t.next_out-f):An(n.check,i,f,t.next_out-f)),t.data_type=n.bits+(n.last?64:0)+(12===n.mode?128:0)+(20===n.mode||15===n.mode?256:0),(0===u&&0===f||e===Qr)&&_===ei&&(_=ai),_},xi={inflateReset:fi,inflateReset2:di,inflateResetKeep:ui,inflateInit:t=>pi(t,15),inflateInit2:pi,inflate:yi,inflateEnd:t=>{if(!t||!t.state)return ii;let e=t.state;return e.window&&(e.window=null),t.state=null,ei},inflateGetHeader:(t,e)=>{if(!t||!t.state)return ii;const n=t.state;return 0==(2&n.wrap)?ii:(n.head=e,e.done=!1,ei)},inflateSetDictionary:(t,e)=>{const n=e.length;let r,i,o;return t&&t.state?(r=t.state,0!==r.wrap&&11!==r.mode?ii:11===r.mode&&(i=1,i=An(i,e,n,0),i!==r.check)?oi:(o=wi(t,e,n,n),o?(r.mode=31,si):(r.havedict=1,ei))):ii},inflateInfo:"pako inflate (from Nodeca project)"};var ki=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 _i=Object.prototype.toString,{Z_NO_FLUSH:Si,Z_FINISH:Ci,Z_OK:Ei,Z_STREAM_END:Ai,Z_NEED_DICT:Ti,Z_STREAM_ERROR:Li,Z_DATA_ERROR:Mi,Z_MEM_ERROR:Ri}=Rn;function Ii(t){this.options=_r({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Mr,this.strm.avail_out=0;let n=xi.inflateInit2(this.strm,e.windowBits);if(n!==Ei)throw new Error(Mn[n]);if(this.header=new ki,xi.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Ar(e.dictionary):"[object ArrayBuffer]"===_i.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(n=xi.inflateSetDictionary(this.strm,e.dictionary),n!==Ei)))throw new Error(Mn[n])}function Ni(t,e){const n=new Ii(e);if(n.push(t),n.err)throw n.msg||Mn[n.err];return n.result}Ii.prototype.push=function(t,e){const n=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let o,s,a;if(this.ended)return!1;for(s=e===~~e?e:!0===e?Ci:Si,"[object ArrayBuffer]"===_i.call(t)?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),o=xi.inflate(n,s),o===Ti&&i&&(o=xi.inflateSetDictionary(n,i),o===Ei?o=xi.inflate(n,s):o===Mi&&(o=Ti));n.avail_in>0&&o===Ai&&n.state.wrap>0&&0!==t[n.next_in];)xi.inflateReset(n),o=xi.inflate(n,s);switch(o){case Li:case Mi:case Ti:case Ri:return this.onEnd(o),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(0===n.avail_out||o===Ai))if("string"===this.options.to){let t=Lr(n.output,n.next_out),e=n.next_out-t,i=Tr(n.output,t);n.next_out=e,n.avail_out=r-e,e&&n.output.set(n.output.subarray(t,t+e),0),this.onData(i)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(o!==Ei||0!==a){if(o===Ai)return o=xi.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Ii.prototype.onData=function(t){this.chunks.push(t)},Ii.prototype.onEnd=function(t){t===Ei&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Sr(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Pi=function(t,e){return(e=e||{}).raw=!0,Ni(t,e)},Oi={Inflate:Ii,inflate:Ni,inflateRaw:Pi,ungzip:Ni,constants:Rn};const{Deflate:Fi,deflate:Di,deflateRaw:Bi,gzip:zi}=Wr,{Inflate:Hi,inflate:Vi,inflateRaw:ji,ungzip:Ui}=Oi;var qi={Deflate:Fi,deflate:Di,deflateRaw:Bi,gzip:zi,Inflate:Hi,inflate:Vi,inflateRaw:ji,ungzip:Ui,constants:Rn};qi.deflateRaw,qi.deflate,qi.inflateRaw;const Wi=qi.inflate;qi.gzip;function $i(t,e){const n=[];let r=0,i=0;for(e=e||t.byteLength-18;r<e;)try{const e=ArrayBuffer.isView(t)?t:new Uint8Array(t,r,18),o=e[11]<<8|e[10],s=(e[3],e[12],e[13],e[15],e[14],1+(e[17]<<8|e[16])),a=12+o+r,c=t.byteLength-a,l=s-o-19;if(c<l||l<=0)break;const h=new Uint8Array(t,a,l),u=qi.inflateRaw(h);r+=l-1+26,i+=u.byteLength,n.push(u)}catch(t){console.error(t);break}if(1===n.length)return n[0];{const t=new Uint8Array(i);let e=0;for(let r=0;r<n.length;++r){var o=new Uint8Array(n[r]);Xi(o,0,t,e,o.length),e+=o.length}return t}}function Gi(t){const e=ArrayBuffer.isView(t)?t:new Uint8Array(t);return 1+(e[17]<<8|e[16])}const Zi="function"==typeof new Uint8Array(1).subarray;function Xi(t,e,n,r,i){if(0!==i){if(!t)throw"Undef src";if(!n)throw"Undef dest";0===e&&i===t.length?Yi(t,n,r):Zi?Yi(t.subarray(e,e+i),n,r):1===t.BYTES_PER_ELEMENT&&i>100?Yi(new Uint8Array(t.buffer,t.byteOffset+e,i),n,r):function(t,e,n,r,i){for(let o=0;o<i;++o)n[r+o]=t[e+o]}(t,e,n,r,i)}}function Yi(t,e,n){e.set(t,n)}function Ki(t,e){const n=t.split(","),r=n[0].split(":")[1];let i=n[1];if(r.indexOf("base64")>=0){i=atob(i);const t=new Uint8Array(i.length);for(let e=0;e<i.length;e++)t[e]=i.charCodeAt(e);let n;return n=e||r.indexOf("gzip")>0?qi.ungzip(t):t,n}return decodeURIComponent(i)}const Qi=function(t,e){if(0!==t.length){var n=Math.floor(t.length*((100-e)/100));return 0===n?(t.sort((function(t,e){return e-t})),t[n]):function(t,e){var n,r=new eo;for(n=0;n<t.length;n++){var i=t[n];(r.content.length<e||i>r.content[0])&&(r.content.length===e&&r.pop(),r.push(i))}return r.content[0]}(t,n)}},Ji=function(t,e,n){return Math.min(Math.max(t,e),n)},to=function(t){return Math.log(t)/Math.LN2};function eo(){this.content=[]}function no(t,e){return Math.random()*(e-t)+t}eo.prototype={push:function(t){this.content.push(t),this.bubbleUp(this.content.length-1)},pop:function(){var t=this.content[0],e=this.content.pop();return this.content.length>0&&(this.content[0]=e,this.sinkDown(0)),t},remove:function(t){for(var e=this.content.length,n=0;n<e;n++)if(this.content[n]===t){var r=this.content.pop();if(n===e-1)break;this.content[n]=r,this.bubbleUp(n),this.sinkDown(n);break}},size:function(){return this.content.length},bubbleUp:function(t){for(var e=this.content[t],n=e;t>0;){var r=Math.floor((t+1)/2)-1,i=this.content[r];if(n>=i)break;this.content[r]=e,this.content[t]=i,t=r}},sinkDown:function(t){for(var e=this.content.length,n=this.content[t],r=n;;){var i=2*(t+1),o=i-1,s=null;if(o<e){var a=this.content[o],c=a;a<r&&(s=o)}if(i<e)this.content[i]<(null==s?r:c)&&(s=i);if(null==s)break;this.content[t]=this.content[s],this.content[s]=n,t=s}}};const ro={rgbListFromHSV:()=>{let t=[];for(let e=1;e>=.5;e-=.1)for(let n=0;n<1;n+=1/28){const r="rgb("+ro.hsvToRgb(n,1,e).join(",")+")";t.push(r)}return t.pop(),t.push(ro.rgbColor(16,16,16)),t},rgbToHex:function(t){return(t=t.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i))&&4===t.length?"#"+("0"+parseInt(t[1],10).toString(16)).slice(-2)+("0"+parseInt(t[2],10).toString(16)).slice(-2)+("0"+parseInt(t[3],10).toString(16)).slice(-2):""},hexToRgb:function(t){var e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);if(null!==e)return"rgb("+parseInt(e[1],16)+","+parseInt(e[2],16)+","+parseInt(e[3],16)+")"},hsvToRgb:function(t,e,n){var r,i,o,s=Math.floor(6*t),a=6*t-s,c=n*(1-e),l=n*(1-a*e),h=n*(1-(1-a)*e);switch(s%6){case 0:r=n,i=h,o=c;break;case 1:r=l,i=n,o=c;break;case 2:r=c,i=n,o=h;break;case 3:r=c,i=l,o=n;break;case 4:r=h,i=c,o=n;break;case 5:r=n,i=c,o=l}return[Math.floor(255*r),Math.floor(255*i),Math.floor(255*o)]},hslToRgb:function(t,e,n){var r,i,o;if(0===e)r=i=o=n;else{var s=n<.5?n*(1+e):n+e-n*e,a=2*n-s;r=ro.hue2rgb(a,s,t+1/3),i=ro.hue2rgb(a,s,t),o=ro.hue2rgb(a,s,t-1/3)}return[255*r,255*i,255*o]},hue2rgb:(t,e,n)=>(n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t),rgbaColor:function(t,e,n,r){return"rgba("+(t=Ji(t,0,255))+","+(e=Ji(e,0,255))+","+(n=Ji(n,0,255))+","+(r=Ji(r,0,1))+")"},rgbColor:function(t,e,n){return"rgb("+(t=Ji(t,0,255))+","+(e=Ji(e,0,255))+","+(n=Ji(n,0,255))+")"},greyScale:function(t){var e=Ji(t,0,255);return"rgb("+e+","+e+","+e+")"},randomGrey:function(t,e){t=Ji(t,0,255),e=Ji(e,0,255);var n=Math.round(no(t,e)).toString(10);return"rgb("+n+","+n+","+n+")"},randomRGB:function(t,e){return t=Ji(t,0,255),e=Ji(e,0,255),"rgb("+Math.round(no(t,e)).toString(10)+","+Math.round(no(t,e)).toString(10)+","+Math.round(no(t,e)).toString(10)+")"},randomRGBConstantAlpha:function(t,e,n){return t=Ji(t,0,255),e=Ji(e,0,255),"rgba("+Math.round(no(t,e)).toString(10)+","+Math.round(no(t,e)).toString(10)+","+Math.round(no(t,e)).toString(10)+","+n+")"},addAlpha:function(t,e){if("0"===t||"."===t)t="rgb(0,0,0)";else{const e=this.colorNameToHex(t);e&&(t=e)}var n=/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t);if(t.startsWith("rgba")){const n=t.lastIndexOf(",");return t.substring(0,n+1)+e.toString()+")"}return n&&(t=ro.hexToRgb(t)),t.startsWith("rgb")?t.replace("rgb","rgba").replace(")",", "+e+")"):(console.log(t+" is not an rgb style string"),t)},rgbComponents:function(t){if("0"===t||"."===t)return[0,0,0];if(/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t))t=ro.hexToRgb(t);else if(!t.startsWith("rgb")){const e=this.colorNameToHex(t);t=this.hexToRgb(e)}if(t.startsWith("rgb("))return t.substring(4,t.length-1).split(",").map((t=>Number.parseInt(t.trim())));if(t.startsWith("rgba("))return t.substring(5,t.length-1).split(",").map(((t,e)=>(t=t.trim(),3===e?Number.parseFloat(t):Number.parseInt(t))));throw Error("Unrecognized color string: color")},getCompositeColor:function(t,e,n){return"rgb("+Math.floor(n*e[0]+(1-n)*t[0])+","+Math.floor(n*e[1]+(1-n)*t[1])+","+Math.floor(n*e[2]+(1-n)*t[2])+")"},createColorString:function(t){return(t=function(t){return void 0===t||((t.startsWith("'")||t.startsWith('"'))&&(t=t.substring(1)),(t.endsWith("'")||t.endsWith('"'))&&(t=t.substring(0,t.length-1))),t}(t)).includes(",")?t.startsWith("rgb")?t:"rgb("+t+")":t},darkenLighten:function(t,e){let n,r=this.colorNameToHex(t);n=r?ro.hexToRgb(r):t.startsWith("rgb(")?t:ro.hexToRgb(t);const i=n.replace(")","").substring(4).split(","),o=Math.max(0,Math.min(255,Number.parseInt(i[0].trim())+e)),s=Math.max(0,Math.min(255,Number.parseInt(i[1].trim())+e)),a=Math.max(0,Math.min(255,Number.parseInt(i[2].trim())+e));return"rgb("+o.toString()+","+s.toString()+","+a.toString()+")"},colorNameToHex:function(t){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"}[t]}};let io;function oo(t,e){e.addEventListener("mousedown",so.bind(t))}function so(t){t.stopPropagation(),t.preventDefault(),function(t){if(!t.getClientRects().length)return{top:0,left:0};const e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView;e.top,n.pageYOffset,e.left,n.pageXOffset}(this);const e=ao.bind(this),n=co.bind(this),r=getComputedStyle(this),i=parseInt(r.top.replace("px","")),o=parseInt(r.left.replace("px",""));io={dragFunction:e,dragEndFunction:n,screenX:t.screenX,screenY:t.screenY,top:i,left:o},document.addEventListener("mousemove",e),document.addEventListener("mouseup",n),document.addEventListener("mouseleave",n),document.addEventListener("mouseexit",n)}function ao(t){if(!io)return void console.log("No drag data!");t.stopPropagation(),t.preventDefault();const e=t.screenX-io.screenX,n=t.screenY-io.screenY;this.style.left=`${io.left+e}px`,this.style.top=`${io.top+n}px`}function co(t){if(!io)return void console.log("No drag data!");t.stopPropagation(),t.preventDefault();const e=io.dragFunction,n=io.dragEndFunction;document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",n),document.removeEventListener("mouseleave",n),document.removeEventListener("mouseexit",n),io=void 0}const lo={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"},ho={oauthTokens:{},setToken:function(t,e){e=e||"googleapis",this.oauthTokens[e]=t,"googleapis"===e&&(this.google.access_token=t)},getToken:function(t){let e;t=t||"googleapis";for(let n of Object.keys(this.oauthTokens)){if(uo(n).test(t)){e=this.oauthTokens[n];break}}return e},removeToken:function(t){t=t||"googleapis";for(let e of Object.keys(this.oauthTokens)){uo(e).test(t)&&(this.oauthTokens[e]=void 0)}"googleapis"===t&&(this.google.access_token=void 0)},google:{setToken:function(t){ho.setToken(t)}}};function uo(t){return new RegExp("^"+t.split(/\*+/).map(fo).join(".*")+"$")}function fo(t){return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")}const po=new class{constructor(t){this.requestsPerSecond=t.requestsPerSecond||10,this.lastStartTime=0,this.queued=[]}add(t,e){var n=this;return new Promise((function(e,r){n.queued.push({resolve:e,reject:r,asyncFunction:t}),n.dequeue()}))}addAll(t,e){var n=t.map(function(t){return this.add(t,e)}.bind(this));return Promise.all(n)}dequeue(){if(this.queued.length>0){var t=new Date,e=1e3/this.requestsPerSecond+1,n=t-this.lastStartTime;n>=e?this._execute():setTimeout(function(){this.dequeue()}.bind(this),e-n)}}async _execute(){this.lastStartTime=new Date;var t=this.queued.shift();const e=t.asyncFunction;try{const n=await e();t.resolve(n)}catch(e){t.reject(e)}}}({requestsPerSecond:8}),go={apiKey:void 0,setApiKey:function(t){this.apiKey=t},load:mo,loadArrayBuffer:async function(t,e){return(e=e||{}).responseType||(e.responseType="arraybuffer"),Ue(t)?bo(t,e):mo(t,e)},loadJson:async function(t,e){"POST"===((e=e||{}).method||(e.sendData?"POST":"GET"))&&(e.contentType="application/json");const n=await this.loadString(t,e);return n?JSON.parse(n):n},loadString:async function(t,e){return e=e||{},t instanceof File?async function(t,e){const n=e.range?t.slice(e.range.start,e.range.start+e.range.size):t;return xo(await wo(n))}(t,e):async function(t,e){(e=e||{}).responseType="arraybuffer";return xo(await go.load(t,e))}(t,e)}};async function mo(t,e){e=e||{};const n=typeof t;if(Ue(t=await("function"==typeof t?t():t)))return bo(t,e);if("function"==typeof t.startsWith){if(t.startsWith("data:")){const n=Ki(t).buffer;if(e.range){const t=e.range.size?e.range.start+e.range.size:n.byteLength;return n.slice(e.range.start,t)}return n}return t.startsWith("https://drive.google.com")&&(t=Ie(t)),Me(t)||t.startsWith("https://www.dropbox.com")?po.add((async function(){return vo(t,e)})):vo(t,e)}throw Error(`url must be either a 'File', 'string', 'function', or 'Promise'. Actual type: ${n}`)}async function vo(t,e){t=function(t){return t.includes("//www.dropbox.com")?t.replace("//www.dropbox.com","//dl.dropboxusercontent.com"):t.includes("//drive.google.com")?Ie(t):t.includes("//www.broadinstitute.org/igvdata")?t.replace("//www.broadinstitute.org/igvdata","//data.broadinstitute.org/igvdata"):t.includes("//igvdata.broadinstitute.org")?t.replace("//igvdata.broadinstitute.org","https://dn7ywbm9isq8j.cloudfront.net"):t.startsWith("ftp://ftp.ncbi.nlm.nih.gov/geo")?t.replace("ftp://","https://"):t}(t);let n=(e=e||{}).oauthToken||function(t){const e=Te(t)?void 0:He(t).host;let n=ho.getToken(e);if(n)return n;if(void 0===e){const t=yo();if(t&&t.expires_at>Date.now())return t.access_token}}(t);return n&&(n=await("function"==typeof n?n():n)),new Promise((function(r,i){Te(t)&&(Le(t)&&(t=Re(t)),t=function(t){let e=go.apiKey;e||"undefined"==typeof gapi||(e=gapi.apiKey);if(void 0!==e&&!t.includes("key=")){const n=t.includes("?")?"&":"?";t=t+n+"key="+e}return t}(t),Me(t)&&function(t){if(t.includes("supportsTeamDrive"))return t;{const e=t.includes("?")?"&":"?";t=t+e+"supportsTeamDrive=true"}}(t),n||(n=yo()));const o=e.headers||{};n&&function(t,e){e&&(t["Cache-Control"]="no-cache",t.Authorization="Bearer "+e)}(o,n);const s=e.range,a=navigator.userAgent.indexOf("Chrome")>-1;0===navigator.vendor.indexOf("Apple")&&/\sSafari\//.test(navigator.userAgent),s&&a&&!function(t){return t.indexOf("X-Amz-Signature")>-1}(t)&&(t+=t.includes("?")?"&":"?",t+="someRandomSeed="+Math.random().toString(36));const c=new XMLHttpRequest,l=e.sendData||e.body,h=e.method||(l?"POST":"GET"),u=e.responseType,f=e.contentType,d=e.mimeType;if(c.open(h,t),e.timeout&&(c.timeout=e.timeout),s){var p=s.size?s.start+s.size-1:"";c.setRequestHeader("Range","bytes="+s.start+"-"+p)}if(f&&c.setRequestHeader("Content-Type",f),d&&c.overrideMimeType(d),u&&(c.responseType=u),o)for(let t of Object.keys(o)){const e=o[t];c.setRequestHeader(t,e)}!0===e.withCredentials&&(c.withCredentials=!0),c.onload=async function(n){0===c.status||c.status>=200&&c.status<=300?s&&206!==c.status&&0!==s.start?(c.response.length>1e5&&alert(`Warning: Range header ignored for URL: ${t}. This can have performance impacts.`),r(c.response.slice(s.start,s.start+s.size))):r(c.response):"undefined"==typeof gapi||404!==c.status&&401!==c.status&&403!==c.status||!Te(t)||e.retries?403===c.status?g("Access forbidden: "+t):416===c.status?g("Unsatisfiable range"):g(c.status):m()},c.onerror=function(n){Te(t)&&!e.retries&&m(),g("Error accessing resource: "+t+" Status: "+c.status)},c.ontimeout=function(t){g("Timed out")},c.onabort=function(t){console.log("Aborted"),i(t)};try{c.send(l)}catch(t){i(t)}function g(t){if(!i)throw t;i(t)}async function m(){try{const n=await async function(t){if(Fe()){const e=function(t){return Me(t)?"https://www.googleapis.com/auth/drive.file":Le(t)?"https://www.googleapis.com/auth/devstorage.read_only":"https://www.googleapis.com/auth/userinfo.profile"}(t),n=await Be(e);return n?n.access_token:void 0}throw Error("Authorization is required, but Google oAuth has not been initalized. Contact your site administrator for assistance.")}(t);e.retries=1,e.oauthToken=n;const i=await mo(t,e);r(i)}catch(t){if(t.error){const e=t.error.startsWith("popup_blocked")?"Google login popup blocked by browser.":t.error;alert(e)}else g(t)}}}))}async function bo(t,e){let n=e&&e.range?t.slice(e.range.start,e.range.start+e.range.size):t;return"arraybuffer"===e.responseType?wo(n):new Promise((function(e,r){const i=new FileReader;i.onload=function(t){e(i.result)},i.onerror=function(e){console.error("reject uploading local file "+t.name),r(null,i)},i.readAsBinaryString(n),console.warn("Deprecated method used: readAsBinaryString")}))}async function wo(t){return"function"==typeof t.arrayBuffer?t.arrayBuffer():new Promise((function(e,n){const r=new FileReader;r.onload=function(t){e(r.result)},r.onerror=function(t){console.error("reject uploading local file "+localfile.name),n(null,r)},r.readAsArrayBuffer(t)}))}function yo(){if(Fe()){const t=function(){let t=gapi.auth2.getAuthInstance().currentUser.get();if(t&&t.isSignedIn()){const{access_token:e,expires_at:n}=t.getAuthResponse();return{access_token:e,expires_at:n}}}();return t?t.access_token:void 0}}function xo(t){let e;return e=function(t){const e=ArrayBuffer.isView(t)?t:new Uint8Array(t);return 31===e[0]&&139===e[1]}(t)?function(t){const e=ArrayBuffer.isView(t)?t:new Uint8Array(t);return 0!=(4&e[3])&&66===e[12]&&67===e[13]?$i(e.buffer):qi.ungzip(e)}(t):new Uint8Array(t),"TextDecoder"in function(){if("undefined"!=typeof self)return self;return"undefined"!=typeof global?global:window}()?(new TextDecoder).decode(e):function(t){var e="",n=0;for(;n<t.length;){var r=t[n],i=0,o=0;if(r<=127?(i=0,o=255&r):r<=223?(i=1,o=31&r):r<=239?(i=2,o=15&r):r<=244&&(i=3,o=7&r),t.length-n-i>0)for(var s=0;s<i;)o=o<<6|63&(r=t[n+s+1]),s+=1;else o=65533,i=t.length-n;e+=String.fromCodePoint(o),n+=i+1}return e}(e)}var ko={color:1};ko.parent=ko,ko.left=ko,ko.right=ko;class _o{constructor(){this.root=ko}insert(t,e,n){var r=new Lo(new To(t,e,n));for(this.treeInsert(r),r.color=2;r!==this.root&&2===r.parent.color;)if(r.parent===r.parent.parent.left){let t=r.parent.parent.right;2===t.color?(r.parent.color=1,t.color=1,r.parent.parent.color=2,r=r.parent.parent):(r===r.parent.right&&(r=r.parent,Co.call(this,r)),r.parent.color=1,r.parent.parent.color=2,Eo.call(this,r.parent.parent))}else{let t=r.parent.parent.left;2===t.color?(r.parent.color=1,t.color=1,r.parent.parent.color=2,r=r.parent.parent):(r===r.parent.left&&(r=r.parent,Eo.call(this,r)),r.parent.color=1,r.parent.parent.color=2,Co.call(this,r.parent.parent))}this.root.color=1}findOverlapping(t,e){var n=new To(t,e,0);if(this.root===ko)return[];var r=So.call(this,n,this.root,[]);return r.length>1&&r.sort((function(t,e){return t.low-e.low})),r}logIntervals(){!function t(e,n){for(var r="",i=0;i<n;i++)r+=" ";console.log(r+e.interval.low+" "+e.interval.high),n+=5,e.left!==ko&&t(e.left,n);e.right!==ko&&t(e.right,n)}(this.root,0)}mapIntervals(t){!function e(n){t(n.interval),n.left!==ko&&e(n.left);n.right!==ko&&e(n.right)}(this.root)}treeInsert(t){for(var e=this.root,n=ko;e!==ko;)n=e,e=t.interval.low<=e.interval.low?e.left:e.right;t.parent=n,n===ko?(this.root=t,t.left=t.right=ko):t.interval.low<=n.interval.low?n.left=t:n.right=t,Ao.call(this,t)}}function So(t,e,n){return e.interval.overlaps(t)&&n.push(e.interval),e.left!==ko&&e.left.max>=t.low&&So.call(this,t,e.left,n),e.right!==ko&&e.right.min<=t.high&&So.call(this,t,e.right,n),n}function Co(t){var e=t.right;t.right=e.left,e.left!==ko&&(e.left.parent=t),e.parent=t.parent,t.parent===ko?this.root=e:t.parent.left===t?t.parent.left=e:t.parent.right=e,e.left=t,t.parent=e,Ao.call(this,t)}function Eo(t){var e=t.left;t.left=e.right,e.right!==ko&&(e.right.parent=t),e.parent=t.parent,t.parent===ko?this.root=e:t.parent.right===t?t.parent.right=e:t.parent.left=e,e.right=t,t.parent=e,Ao.call(this,t)}function Ao(t){for(;t!==ko;){var e=t.left.max>t.right.max?t.left.max:t.right.max,n=t.interval.high;t.max=e>n?e:n;var r=t.left.min<t.right.min?t.left.min:t.right.min,i=t.interval.low;t.min=r<i?r:i,t=t.parent}}class To{constructor(t,e,n){this.low=t,this.high=e,this.value=n}equals(t){return!!t&&(this===t||this.low===t.low&&this.high===t.high)}compareTo(t){return this.low<t.low?-1:this.low>t.low?1:this.high<t.high?-1:this.high>t.high?1:0}overlaps(t){return this.low<=t.high&&t.low<=this.high}}function Lo(t){this.parent=ko,this.left=ko,this.right=ko,this.interval=t,this.color=2}class Mo{constructor(t,e,n){t=t||[],this.treeMap=this.buildTreeMap(t,e),this.range=n,this.count=t.length}containsRange(t){return void 0===this.range||this.range.contains(t.chr,t.start,t.end)}queryFeatures(t,e,n){const r=this.treeMap[t];if(!r)return[];const i=r.findOverlapping(e,n);if(0===i.length)return[];{const r=[],o=this.allFeatures[t];if(o){for(let t of i){const i=t.value;for(let t=i.start;t<i.end;t++){let i=o[t];if(i.start>n)break;i.end>=e&&r.push(i)}}r.sort((function(t,e){return t.start-e.start}))}return r}}getAllFeatures(){return this.allFeatures}buildTreeMap(t,e){const n={},r=[];if(this.allFeatures={},t){for(let n of t){let t=n.chr;e&&(t=e.getChromosomeName(t));let i=this.allFeatures[t];i||(r.push(t),i=[],this.allFeatures[t]=i),i.push(n)}for(let t of r){const e=this.allFeatures[t];e.sort((function(t,e){return t.start===e.start?0:t.start>e.start?1:-1})),n[t]=Ro(e)}}return n}}function Ro(t){const e=new _o,n=t.length,r=Math.max(10,Math.round(n/10));for(let i=0;i<n;i+=r){const o=Math.min(n,i+r),s=new Io(i,o),a=t[i].start;let c=a;for(let e=i;e<o;e++)c=Math.max(c,t[e].end);e.insert(a,c,s)}return e}class Io{constructor(t,e){this.start=t,this.end=e}}const No=function(t,e,n){if(t&&0!==t.length){const r=function(t){const e=new _o,n=t.length,r=Math.max(10,Math.round(n/100));t.sort((function(t,e){return t.start===e.start?0:t.start>e.start?1:-1}));for(let i=0;i<n;i+=r){const o=Math.min(n,i+r),s=t.slice(i,o),a=s[0].start;let c=a;s.forEach((function(t){c=Math.max(c,t.end)})),e.insert(a,c,s)}return e}(t),i=r.findOverlapping(e,n);return 0===i.length?[]:(t=[],i.forEach((function(r){const i=r.value,o=i.length;for(let r=0;r<o;r++){const o=i[r];if(o.start>n)break;o.end>e&&t.push(o)}})),t.sort((function(t,e){return t.start-e.start})),t)}return[]};function Po(t,e){const n=ge({class:"igv-menu-popup-check-container"}),r=ge();n.appendChild(r);const i=ye("check",!0===e?"#444":"transparent");r.appendChild(i);const o=ge();return o.innerText=t,n.appendChild(o),n}const Oo={trackMenuItemList:function(t){const e=new Set(["alignment","annotation","variant","eqtl","snp"]),n=t.track.config&&void 0!==t.track.config.visibilityWindow;let r=[];return"sequence"!==t.track.config.type&&(r.push(function(t){const e=e=>{const n=function(){let e=t.browser.inputDialog.input.value;e=""===e||void 0===e?"untitled":e.trim(),t.track.name=e},r={label:"Track Name",value:Do(t.track)||"unnamed",callback:n};t.browser.inputDialog.present(r,e)},n=pe("<div>");return n.text("Set track name"),{object:n,click:e}}(t)),r.push(function(t){const e=e=>{const n=()=>{const e=Number(t.browser.inputDialog.input.value,10);void 0!==e&&(void 0!==t.track.minHeight&&t.track.minHeight>e&&(t.track.minHeight=e),void 0!==t.track.maxHeight&&t.track.maxHeight<e&&(t.track.minHeight=e),t.setTrackHeight(e,!0),t.checkContentHeight(),t.repaintViews(),t.track.autoHeight=!1)},r={label:"Track Height",value:t.track.height,callback:n};t.browser.inputDialog.present(r,e)},n=pe("<div>");return n.text("Set track height"),{object:n,click:e}}(t))),this.showColorPicker(t.track)&&(r.push("<hr/>"),r.push(Fo({trackView:t,label:"Set track color",option:"color"})),r.push(function({trackView:t,label:e}){const n=pe("<div>");return n.text(e),{object:n,click:()=>{t.track.color=void 0,t.repaintViews()}}}({trackView:t,label:"Unset track color"})),r.push(Fo({trackView:t,label:"Set alt color",option:"altColor"}))),t.track.menuItemList&&(r=r.concat(t.track.menuItemList())),(n||e.has(t.track.type))&&(r.push("<hr/>"),r.push(function(t){const e=e=>{const n=()=>{let e=t.browser.inputDialog.input.value;e=""===e||void 0===e?-1:e.trim(),t.track.visibilityWindow=Number.parseInt(e),t.track.config.visibilityWindow=Number.parseInt(e),t.updateViews()},r={label:"Visibility Window",value:t.track.visibilityWindow,callback:n};t.browser.inputDialog.present(r,e)},n=pe("<div>");return n.text("Set visibility window"),{object:n,click:e}}(t))),!1!==t.track.removable&&(r.push("<hr/>"),r.push(function(t){const e=pe("<div>");return e.text("Remove track"),{object:e,click:()=>t.browser.removeTrack(t.track)}}(t))),r},numericDataMenuItems:function(t){const e=[];e.push("<hr/>");const n=pe("<div>");n.text("Set data range");return e.push({object:n,click:()=>{t.browser.dataRangeDialog.configure(t),t.browser.dataRangeDialog.present(pe(t.browser.columnContainer))}}),void 0!==t.track.logScale&&e.push({object:pe(Po("Log scale",t.track.logScale)),click:()=>{t.track.logScale=!t.track.logScale,t.repaintViews()}}),e.push({object:pe(Po("Autoscale",t.track.autoscale)),click:()=>{t.track.autoscale=!t.track.autoscale,t.updateViews()}}),e},trackMenuItemListHelper:function(t,e){var n=[];return t.length>0&&(n=t.map((function(t,n){var r;if(t.name?(r=pe("<div>")).text(t.name):t.object?r=t.object:"string"==typeof t.label?(r=pe("<div>")).html(t.label):"string"==typeof t&&(r=t.startsWith("<")?pe(t):pe("<div>"+t+"</div>")),0===n&&r.addClass("igv-track-menu-border-top"),t.click){function i(n){t.click(n),e.hide(),n.preventDefault(),n.stopPropagation()}r.on("click",i),r.on("touchend",(function(t){i(t)})),r.on("mouseup",(function(t){t.preventDefault(),t.stopPropagation()}))}return{object:r,init:t.init||void 0}}))),n},showColorPicker:t=>void 0===t.type||"bedtype"===t.type||"alignment"===t.type||"annotation"===t.type||"variant"===t.type||"wig"===t.type||"interact"===t.type,createMenuItem(t,e){const n=pe("<div>");return n.text(t),{object:n,click:e}}};function Fo({trackView:t,label:e,option:n}){const r=pe("<div>");return r.text(e),{object:r,click:()=>t.presentColorPicker(n)}}function Do(t){return t.trackView.viewports[0].$trackLabel.text()}function Bo(t){return function(t,e){const n=document.createElement(t);e&&(e.class&&n.classList.add(e.class),e.id&&(n.id=e.id),e.style&&function(t,e){for(let n of Object.keys(e))t.style[n]=e[n]}(n,e.style));return n}("div",t)}function zo(t){const e=getComputedStyle(t);"none"!==e.display&&(t._initialDisplay=e.display),t.style.display="none"}function Ho(t){if("none"===getComputedStyle(t).display){const e=t._initialDisplay||"block";t.style.display=e}}function Vo(t,e){e=e||"currentColor";let n=jo[t];n||(console.error(`No icon named: ${t}`),n=jo.question);const r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttributeNS(null,"viewBox","0 0 "+n[0]+" "+n[1]);const i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttributeNS(null,"fill",e),i.setAttributeNS(null,"d",n[4]),r.appendChild(i),r}const jo={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"]};function Uo(t,e){var n=document.createElement("div");t.appendChild(n),n.appendChild(function(t,e){return Vo(t,e)}("times")),n.addEventListener("click",(function(t){t.preventDefault(),t.stopPropagation(),e()}))}let qo;function Wo(t,e){e.addEventListener("mousedown",$o.bind(t))}function $o(t){t.stopPropagation(),t.preventDefault(),function(t){if(!t.getClientRects().length)return{top:0,left:0};const e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView;e.top,n.pageYOffset,e.left,n.pageXOffset}(this);const e=Go.bind(this),n=Zo.bind(this),r=getComputedStyle(this),i=parseInt(r.top.replace("px","")),o=parseInt(r.left.replace("px",""));qo={dragFunction:e,dragEndFunction:n,screenX:t.screenX,screenY:t.screenY,top:i,left:o},document.addEventListener("mousemove",e),document.addEventListener("mouseup",n),document.addEventListener("mouseleave",n),document.addEventListener("mouseexit",n)}function Go(t){if(!qo)return void console.log("No drag data!");t.stopPropagation(),t.preventDefault();const e=t.screenX-qo.screenX,n=t.screenY-qo.screenY;this.style.left=`${qo.left+e}px`,this.style.top=`${qo.top+n}px`}function Zo(t){if(!qo)return void console.log("No drag data!");t.stopPropagation(),t.preventDefault();const e=qo.dragFunction,n=qo.dragEndFunction;document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",n),document.removeEventListener("mouseleave",n),document.removeEventListener("mouseexit",n),qo=void 0}const Xo={401:"Access unauthorized",403:"Access forbidden",404:"Not found"};class Yo{constructor(t,e){this.alertProps=Object.assign({shouldFocus:!0,preventScroll:!1},e),this.container=Bo({class:"igv-ui-alert-dialog-container"}),t.appendChild(this.container),this.container.setAttribute("tabIndex","-1");const n=Bo();this.container.appendChild(n),this.errorHeadline=Bo(),n.appendChild(this.errorHeadline),this.errorHeadline.textContent="";let r=Bo({class:"igv-ui-alert-dialog-body"});this.container.appendChild(r),this.body=Bo({class:"igv-ui-alert-dialog-body-copy"}),r.appendChild(this.body);let i=Bo();this.container.appendChild(i),this.ok=Bo(),i.appendChild(this.ok),this.ok.textContent="OK";const o=()=>{"function"==typeof this.callback&&(this.callback("OK"),this.callback=void 0),this.body.innerHTML="",zo(this.container)};this.ok.addEventListener("click",(t=>{t.stopPropagation(),o()})),this.container.addEventListener("keypress",(t=>{t.stopPropagation(),"Enter"===t.key&&o()})),Wo(this.container,n),zo(this.container)}present(t,e){this.errorHeadline.textContent=t.message?"ERROR":"";let n=t.message||t;Xo.hasOwnProperty(n)&&(n=Xo[n]),this.body.innerHTML=n,this.callback=e,Ho(this.container),this.alertProps.shouldFocus&&this.container.focus({preventScroll:this.alertProps.preventScroll})}}let Ko;const Qo={init(t,e={}){Ko=new Yo(t,e)},presentAlert(t,e){Ko||this.init(document.body),Ko.present(t,e)}};class Jo{constructor(t){this.parent=t,this.container=Bo({class:"igv-ui-generic-dialog-container"}),t.appendChild(this.container);const e=Bo({class:"igv-ui-generic-dialog-header"});this.container.appendChild(e),this.label=Bo({class:"igv-ui-generic-dialog-one-liner"}),this.container.appendChild(this.label),this.label.text="Unlabeled",this.input_container=Bo({class:"igv-ui-generic-dialog-input"}),this.container.appendChild(this.input_container),this.input=document.createElement("input"),this.input_container.appendChild(this.input);const n=Bo({class:"igv-ui-generic-dialog-ok-cancel"});this.container.appendChild(n),this.ok=Bo(),n.appendChild(this.ok),this.ok.textContent="OK",this.cancel=Bo(),n.appendChild(this.cancel),this.cancel.textContent="Cancel",zo(this.container),this.input.addEventListener("keyup",(t=>{13===t.keyCode&&("function"==typeof this.callback&&(this.callback(this.input.value),this.callback=void 0),this.input.value=void 0,zo(this.container))})),this.ok.addEventListener("click",(()=>{"function"==typeof this.callback&&(this.callback(this.input.value),this.callback=void 0),this.input.value=void 0,zo(this.container)}));const r=()=>{this.input.value="",zo(this.container)};this.cancel.addEventListener("click",r),Uo(e,r),Wo(this.container,e)}present(t,e){this.label.textContent=t.label,this.input.value=t.value,this.callback=t.callback||t.click,Ho(this.container);const{x:n,y:r}=function(t){if(t.type.startsWith("touch")){const e=t.touches[0];return{x:e.pageX,y:e.pageY}}return{x:t.pageX,y:t.pageY}}(e);this.clampLocation(n,r)}clampLocation(t,e){const{width:n,height:r}=this.container.getBoundingClientRect(),{x:i,y:o,width:s,height:a}=this.parent.getBoundingClientRect(),c=Math.min(Math.max(e,o),o+a-r),l=Math.min(Math.max(t,i),i+s-n);this.container.style.left=`${l}px`,this.container.style.top=`${c}px`}}const ts={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 es{constructor({parent:t,top:e,left:n,width:r,height:i,border:o,closeHandler:s}){let a=Bo({class:"igv-ui-generic-container"});t.appendChild(a),zo(a),this.container=a,void 0!==e&&(this.container.style.top=`${e}px`),void 0!==n&&(this.container.style.left=`${n}px`),void 0!==r&&(this.container.style.width=`${r}px`),void 0!==i&&(this.container.style.height=`${i}px`),o&&(this.container.style.border=o);const c=Bo();this.container.appendChild(c),Uo(c,(t=>{zo(this.container),"function"==typeof s&&s(t)})),Wo(this.container,c)}show(){Ho(this.container)}hide(){zo(this.container)}dispose(){this.container.parent&&this.container.parent.removeChild(this.container)}}class ns extends es{constructor({parent:t,top:e,left:n,width:r,height:i,defaultColors:o,colorHandler:s}){super({parent:t,top:e,left:n,width:r,height:i,border:"1px solid gray"}),rs(this.container,s,o)}}const rs=(t,e,n)=>{const r=Object.values(ts);for(let n of r){const r=Bo({class:"igv-ui-color-swatch"});t.appendChild(r),is(r,n,e)}if(n)for(let r of n){const n=Bo({class:"igv-ui-color-swatch"});t.appendChild(n),is(n,r,e)}},is=(t,e,n)=>{t.style.backgroundColor=e,t.addEventListener("mouseenter",(n=>t.style.borderColor=e)),t.addEventListener("mouseleave",(e=>t.style.borderColor="white")),t.addEventListener("click",(t=>{t.stopPropagation(),n(e)})),t.addEventListener("touchend",(t=>{t.stopPropagation(),n(e)}))};class os{constructor(t,e){this.parent=t,this.popover=Bo({class:"igv-ui-popover"}),t.appendChild(this.popover);const n=Bo();this.popover.appendChild(n);const r=Bo();n.appendChild(r),e&&(r.textContent=e),Uo(n,(()=>this.hide())),Wo(this.popover,n),this.popoverContent=Bo(),this.popover.appendChild(this.popoverContent),this.popover.style.display="none"}presentContentWithEvent(t,e){this.popover.style.display="block",this.popoverContent.innerHTML=e,ss(t,this.popover,this.popoverContent)}presentMenu(t,e){if(0===e.length)return;this.popover.style.display="block";const n=function(t,e){const n=t.map((function(t,n){let r;if("string"==typeof t)r=Bo(),r.innerHTML=t;else if("Node"==typeof t)r=t;else{if("function"==typeof t.init&&t.init(),"checkbox"===t.type)r=function(t,e){const n=Bo({class:"igv-ui-trackgear-popover-check-container"}),r=Vo("check",!0===e?"#444":"transparent");r.style.borderColor="gray",r.style.borderWidth="1px",r.style.borderStyle="solid",n.appendChild(r);let i=Bo();return i.textContent=t,n.appendChild(i),n}("Show all bases",t.value);else if("color"===t.type){const i=new ns({parent:e.parentElement,width:364,colorHandler:e=>t.click(e)});r=Bo(),"string"==typeof t.label&&(r.innerHTML=t.label);const o=t=>{i.show(),zo(e),t.preventDefault(),t.stopPropagation()};r.addEventListener("click",o),r.addEventListener("touchend",o),r.addEventListener("mouseup",(function(t){t.preventDefault(),t.stopPropagation()}))}else r=Bo(),"string"==typeof t.label&&(r.innerHTML=t.label);if(t.click&&"color"!==t.type){function s(n){t.click(),zo(e),n.preventDefault(),n.stopPropagation()}r.addEventListener("click",s),r.addEventListener("touchend",s),r.addEventListener("mouseup",(function(t){t.preventDefault(),t.stopPropagation()}))}}return{object:r,init:t.init}}));return n}(e,this.popover);for(let t of n)this.popoverContent.appendChild(t.object);ss(t,this.popover,this.popoverContent)}hide(){this.popover.style.display="none",this.dispose()}dispose(){this.popover&&this.popover.parentNode.removeChild(this.popover);const t=Object.keys(this);for(let e of t)this[e]=void 0}}function ss(t,e,n){const{x:r,y:i,width:o}=function(t,e){const{clientX:n,clientY:r}=t;return((t,{clientX:e,clientY:n})=>{const{left:r,top:i,width:o,height:s}=t.getBoundingClientRect(),a=e-r,c=n-i;return{x:a,y:c,xNormalized:a/o,yNormalized:c/s,width:o,height:s}})(e,{clientX:n,clientY:r})}(t,e.parentNode);e.style.top=`${i}px`;const{width:s}=e.getBoundingClientRect(),a=r+s,c=a-o;e.style.left=`${a>o?r-c:r}px`,n.style.maxWidth=`${Math.min(s,o)}px`}if("undefined"!=typeof document){function as(t){for(let e of document.styleSheets)if(e=e.href?e.href.replace(/^.*[\\\/]/,""):"",e===t)return!0;return!1}as("igv-ui.css")||function(){var t=document.createElement("style");t.setAttribute("type","text/css"),t.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 .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 .igv-ui-popover > div:first-child > div:first-child {\n margin-left: 4px; }\n .igv-ui-popover > div:first-child > div:last-child {\n margin-right: 4px;\n height: 12px;\n width: 12px;\n color: #7F7F7F; }\n .igv-ui-popover > div:first-child > div:last-child:hover {\n cursor: pointer;\n color: #444; }\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 .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 .igv-ui-popover > div:last-child > div > span {\n font-weight: bolder; }\n .igv-ui-popover > div:last-child hr {\n width: 100%; }\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 .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 .igv-ui-alert-dialog-container > div:first-child div:first-child {\n padding-left: 8px; }\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 .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 .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 .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 .igv-ui-alert-dialog-container > div:last-child div:hover {\n cursor: pointer;\n border-color: #25597f;\n background-color: #25597f; }\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.igv-ui-color-swatch:hover {\n border-color: dimgray; }\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 .igv-ui-colorpicker-menu-close-button i.fa {\n display: block;\n margin-left: 4px;\n margin-right: 4px;\n color: #5f5f5f; }\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.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 .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 .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 .igv-ui-generic-dialog-container .igv-ui-generic-dialog-header div:hover {\n cursor: pointer;\n color: #444; }\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 .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 .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 .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 .igv-ui-generic-dialog-container .igv-ui-generic-dialog-label-input input {\n width: 50%;\n font-size: 16px; }\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 .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 .igv-ui-generic-dialog-container .igv-ui-generic-dialog-input input {\n font-size: 16px; }\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 .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 .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 .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 .igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel div:first-child:hover {\n cursor: pointer;\n background-color: #3b5c7f; }\n .igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel div:last-child:hover {\n cursor: pointer;\n background-color: #7f7f7f; }\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 .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 .igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok div:hover {\n cursor: pointer;\n background-color: #25597f; }\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 .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 .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.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 .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 .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 .igv-ui-dialog .igv-ui-dialog-header div:hover {\n cursor: pointer;\n color: #444; }\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 .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 .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 .igv-ui-dialog .igv-ui-dialog-ok-cancel div:first-child {\n background-color: #5ea4e0; }\n .igv-ui-dialog .igv-ui-dialog-ok-cancel div:last-child {\n background-color: #c4c4c4; }\n .igv-ui-dialog .igv-ui-dialog-ok-cancel div:first-child:hover {\n cursor: pointer;\n background-color: #3b5c7f; }\n .igv-ui-dialog .igv-ui-dialog-ok-cancel div:last-child:hover {\n cursor: pointer;\n background-color: #7f7f7f; }\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 .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 .igv-ui-dialog .igv-ui-dialog-ok div:hover {\n cursor: pointer;\n background-color: #25597f; }\n\n.igv-ui-panel, .igv-ui-panel-column, .igv-ui-panel-row {\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.igv-ui-panel-column {\n display: flex;\n flex-direction: column; }\n\n.igv-ui-panel-row {\n display: flex;\n flex-direction: row; }\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/*# sourceMappingURL=igv-ui.css.map */\n',document.head.insertBefore(t,document.head.childNodes[document.head.childNodes.length-1])}()}class cs{constructor(t,e){this.$container=pe("<div>",{class:"igv-generic-dialog-container"}),t.append(this.$container),this.$container.offset({left:0,top:0});const n=pe("<div>",{class:"igv-generic-dialog-header"});this.$container.append(n),ke(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=pe("<div>",{class:"igv-generic-dialog-label-input"}),this.$container.append(this.$minimum);const r=pe("<div>");r.text("Minimum"),this.$minimum.append(r),this.$minimum_input=pe("<input>"),this.$minimum.append(this.$minimum_input),this.$maximum=pe("<div>",{class:"igv-generic-dialog-label-input"}),this.$container.append(this.$maximum);const i=pe("<div>");i.text("Maximum"),this.$maximum.append(i),this.$maximum_input=pe("<input>"),this.$maximum.append(this.$maximum_input);const o=pe("<div>",{class:"igv-generic-dialog-ok-cancel"});this.$container.append(o),this.$ok=pe("<div>"),o.append(this.$ok),this.$ok.text("OK"),this.$cancel=pe("<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()})),oo(this.$container.get(0),n.get(0)),this.$container.hide()}configure(t){const e=t.dataRange();let n,r;e?(n=e.min,r=e.max):(n=0,r=100),this.$minimum_input.val(n),this.$maximum_input.val(r),this.$minimum_input.unbind(),this.$minimum_input.on("keyup",(e=>{13===e.keyCode&&this.processResults(t)})),this.$maximum_input.unbind(),this.$maximum_input.on("keyup",(e=>{13===e.keyCode&&this.processResults(t)})),this.$ok.unbind(),this.$ok.on("click",(e=>{this.processResults(t)}))}processResults(t){const e=Number(this.$minimum_input.val()),n=Number(this.$maximum_input.val());isNaN(e)||isNaN(n)?Qo.presentAlert(new Error("Must input numeric values"),void 0):t.setDataRange(e,n),this.$minimum_input.val(void 0),this.$maximum_input.val(void 0),this.$container.offset({left:0,top:0}),this.$container.hide()}present(t){const e=t.offset().top,n=pe("body").scrollTop();this.$container.offset({left:t.width()-this.$container.width(),top:e+n}),this.$container.show()}}const ls={configureHighDPICanvas:function(t,e,n){const r=window.devicePixelRatio;t.canvas.style.width=`${e}px`,t.canvas.width=Math.floor(r*e),t.canvas.style.height=`${n}px`,t.canvas.height=Math.floor(r*n),t.scale(r,r)},setProperties:function(t,e){for(var n in e)if(e.hasOwnProperty(n)){var r=e[n];t[n]=r}},strokeLine:function(t,e,n,r,i,o){e=Math.floor(e)+.5,n=Math.floor(n)+.5,r=Math.floor(r)+.5,i=Math.floor(i)+.5,o&&(t.save(),ls.setProperties(t,o)),t.beginPath(),t.moveTo(e,n),t.lineTo(r,i),t.stroke(),o&&t.restore()},fillRect:function(t,e,n,r,i,o){e=Math.round(e),n=Math.round(n),o&&(t.save(),ls.setProperties(t,o)),t.fillRect(e,n,r,i),o&&t.restore()},fillPolygon:function(t,e,n,r){r&&(t.save(),ls.setProperties(t,r)),hs(t,e,n),t.fill(),r&&t.restore()},strokePolygon:function(t,e,n,r){r&&(t.save(),ls.setProperties(t,r)),hs(t,e,n),t.stroke(),r&&t.restore()},fillText:function(t,e,n,r,i,o){if((i||o)&&t.save(),i&&ls.setProperties(t,i),o){for(var s in t.translate(n,r),o){var a=o[s];"translate"===s&&t.translate(a.x,a.y),"rotate"===s&&t.rotate(a.angle*Math.PI/180)}t.fillText(e,0,0)}else t.fillText(e,n,r);(i||o)&&t.restore()},strokeText:function(t,e,n,r,i,o){if((i||o)&&t.save(),i&&ls.setProperties(t,i),o){for(var s in t.translate(n,r),o){var a=o[s];"translate"===s&&t.translate(a.x,a.y),"rotate"===s&&t.rotate(a.angle*Math.PI/180)}t.strokeText(e,0,0)}else t.strokeText(e,n,r);(i||o)&&t.restore()},strokeCircle:function(t,e,n,r,i){i&&(t.save(),ls.setProperties(t,i)),t.beginPath(),t.arc(e,n,r,0,2*Math.PI),t.stroke(),i&&t.restore()},fillCircle:function(t,e,n,r,i){i&&(t.save(),ls.setProperties(t,i)),t.beginPath(),t.arc(e,n,r,0,2*Math.PI),t.fill(),i&&t.restore()},drawArrowhead:function(t,e,n,r,i){t.save(),r||(r=5),i&&(t.lineWidth=i),t.beginPath(),t.moveTo(e,n-r/2),t.lineTo(e,n+r/2),t.lineTo(e+r,n),t.lineTo(e,n-r/2),t.closePath(),t.fill(),t.restore()},dashedLine:function(t,e,n,r,i,o,s={}){void 0===o&&(o=2),t.setLineDash([o,o]),ls.strokeLine(t,e,n,r,i,s),t.setLineDash([])},roundRect:function(t,e,n,r,i,o,s,a){void 0===a&&(a=!0),void 0===o&&(o=5),t.beginPath(),t.moveTo(e+o,n),t.lineTo(e+r-o,n),t.quadraticCurveTo(e+r,n,e+r,n+o),t.lineTo(e+r,n+i-o),t.quadraticCurveTo(e+r,n+i,e+r-o,n+i),t.lineTo(e+o,n+i),t.quadraticCurveTo(e,n+i,e,n+i-o),t.lineTo(e,n+o),t.quadraticCurveTo(e,n,e+o,n),t.closePath(),a&&t.stroke(),s&&t.fill()},polygon:function(t,e,n,r,i){void 0===i&&(i=!0),t.beginPath();var o=e.length;t.moveTo(e[0],n[0]);for(var s=1;s<o;s++)t.lineTo(e[s],n[s]);t.closePath(),i&&t.stroke(),r&&t.fill()}};function hs(t,e,n){var r,i=e.length;for(r=0;r<i;r++)e[r]=Math.round(e[r]),n[r]=Math.round(n[r]);for(t.beginPath(),t.moveTo(e[0],n[0]),r=1;r<i;r++)t.lineTo(e[r],n[r]);t.closePath()}const us={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"]}},fs=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"]);function ds(t){if(function(t){t.featureType&&(t.type=t.type||t.featureType,t.featureType=void 0);"junctions"===t.type?t.type="junction":"bed"===t.type?(t.type="annotation",t.format=t.format||"bed"):"annotations"===t.type?t.type="annotation":"alignments"===t.type?t.type="alignment":"bam"===t.type?(t.type="alignment",t.format="bam"):"vcf"===t.type?(t.type="variant",t.format="vcf"):"t2d"===t.type?t.type="gwas":"FusionJuncSpan"!==t.type||t.format?"aed"===t.type&&(t.type="annotation",t.format=t.format||"aed"):t.format="fusionjuncspan"}(t),t.type)return t.type;if(t.format){switch(t.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"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";default:return"annotation"}}}function ps(t){const e=new Set(["boolean","number","string","symbol"]),n=typeof t;return void 0!==t&&(e.has(n)||t.substring||t.toFixed)}function gs(t,e){var n={oauthToken:t.oauthToken,headers:t.headers,withCredentials:t.withCredentials,filename:t.filename};return Object.assign(n,e)}const ms=function(t){var e,n;return t.length>0?(e=Number.MAX_VALUE,n=-Number.MAX_VALUE,t.forEach((function(t){Number.isNaN(t.value)||(e=Math.min(e,t.value),n=Math.max(n,t.value))})),n>0&&(e=Math.min(0,e)),n<0&&(n=0)):(e=0,n=100),{min:e,max:n}},vs=function(t,e,n){let r=e.start,i=e.end;if(void 0===i)r-=n/2,i=r+n,i>t?(i=t,r=i-n):r<0&&(r=0,i=n);else if(i-r<n){const e=(i+r)/2;e-n/2<0?(r=0,i=r+n):e+n/2>t?(i=t,r=i-n):(r=e-n/2,i=r+n)}e.start=Math.ceil(r),e.end=Math.floor(i)};async function bs(t){if(_e(t)&&t.startsWith("https://drive.google.com")){if(void 0===ze())throw Error("Google drive is referenced, but API key is not defined. An API key is required for Google Drive access");const e=await async function(t){let e="https://www.googleapis.com/drive/v3/files/"+Ne(t)+"?supportsTeamDrives=true";const n=ze();n&&(e+="&key="+n);const r=await fetch(e);let i=await r.json();if(i.error&&404===i.error.code){const{access_token:t}=await Be("https://www.googleapis.com/auth/drive.readonly");if(!t)throw Error(i.error);{const n=await fetch(e,{headers:{Authorization:`Bearer ${t}`}});if(i=await n.json(),i.error)throw Error(i.error)}}return i}(t);return e.originalFileName||e.name}return je(t)}function ws(t){var e,n;return t>1e7?(e=" mb",n=t/1e6,Math.floor(n).toString()+e):t>1e4?(e=" kb",n=t/1e3,Se(Math.floor(n))+e):Se(t)+" bp"}function ys(t){return _e(t)&&t.startsWith("data:")}function xs(t,e){const n=ge({class:e});t.appendChild(n)}function ks(t,e){e.parentNode.insertBefore(t,e)}function _s(t,e){e.parentNode.insertBefore(t,e.nextSibling)}function Ss(){return"https:"===window.location.protocol||"localhost"===window.location.hostname}const Cs=[["A","T"],["G","C"],["Y","R"],["W","S"],["K","M"],["D","H"],["B","V"]],Es=new Map;for(let ad of Cs){const cd=ad[0],ld=ad[1];Es.set(cd,ld),Es.set(ld,cd),Es.set(cd.toLowerCase(),ld.toLowerCase()),Es.set(ld.toLowerCase(),cd.toLowerCase())}function As(t){let e="",n=t.length;for(;n-- >0;){const r=t[n];e+=Es.has(r)?Es.get(r):r}return e}const Ts=Number.MIN_SAFE_INTEGER,Ls={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"},Ms={},Rs=["A","G","C","T","Y","R","W","S","K","M","D","V","H","B","N","X"],Is=["T","C","G","A","R","Y","W","S","M","K","H","B","D","V","N","X"];for(let hd=0;hd<Rs.length;hd++)Ms[Rs[hd]]=Is[hd],Ms[Rs[hd].toLowerCase()]=Is[hd].toLowerCase();class Ns{constructor(t,e){this.type="sequence",this.browser=e,this.removable=!1,this.config=t,this.name="Sequence",this.id="sequence",this.sequenceType=t.sequenceType||"dna",this.disableButtons=!1,this.order=t.order||Ts,this.ignoreTrackMenu=!1,this.reversed=!0===t.reversed,this.frameTranslate=!0===t.frameTranslate,this.height=this.frameTranslate?115:25}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 t of this.trackView.viewports)t.setContentHeight(115);this.trackView.setTrackHeight(115)}else{for(let t of this.trackView.viewports)t.setContentHeight(25);this.trackView.setTrackHeight(25)}this.trackView.repaintViews()}}]}contextMenuItemList(t){const e=t.viewport;if(e.referenceFrame.bpPerPixel<=1){const t=e.getWidth()*e.referenceFrame.bpPerPixel,n=e.referenceFrame.chr,r=Math.floor(e.referenceFrame.start),i=Math.ceil(r+t),o=[{label:this.reversed?"View visible sequence (reversed)...":"View visible sequence...",click:async()=>{let t=await this.browser.genome.sequence.getSequence(n,r,i);this.reversed&&(t=As(t)),Qo.presentAlert(t)}}];return Ss()&&o.push({label:"Copy visible sequence",click:async()=>{let t=await this.browser.genome.sequence.getSequence(n,r,i);this.reversed&&(t=As(t));try{await navigator.clipboard.writeText(t)}catch(t){console.error(t),Qo.presentAlert(`error copying sequence to clipboard ${t}`)}}}),o.push("<hr/>"),o}}translateSequence(t){const e=[[],[],[]];for(let n of[0,1,2]){let r=n;for(;t.length-r>=3;){let i=t.slice(r,r+3);this.reversed&&(i=i.split("").reverse().join(""));const o=Ls[i.toUpperCase()]||"";e[n].push({codons:i,aminoA:o}),r+=3}}return e}async getFeatures(t,e,n,r){if(e=Math.floor(e),n=Math.floor(n),r&&r>1)return null;return{bpStart:e,sequence:await this.browser.genome.sequence.getSequence(t,e,n)}}draw(t){const e=t.context;if(t.features){let n=t.features.sequence;this.reversed&&(n=n.split("").map((function(t){return Ms[t]})).join(""));const r=t.features.bpStart,i=1+t.bpStart+t.pixelWidth*t.bpPerPixel;for(let o=Math.floor(t.bpStart);o<=i;o++){const i=Math.floor(o-r);if(i>=0&&i<n.length){const r=n[i],s=(o-t.bpStart)/t.bpPerPixel,a=1/t.bpPerPixel,c=this.fillColor(r);if(t.bpPerPixel>.1)ls.fillRect(e,s,5,a,10,{fillStyle:c});else{let t=s+.5*(a-e.measureText(r).width);ls.strokeText(e,r,t,15,{strokeStyle:c})}}}if(this.frameTranslate){let i=25;const o=this.translateSequence(n);for(let n=0;n<o.length;n++){const s=o[n];for(let o=0;o<s.length;o++){let a=0==o%2?"rgb(160,160,160)":"rgb(224,224,224)";const c=s[o],l=r+n+3*o-t.bpStart,h=Math.floor(l/t.bpPerPixel),u=Math.floor((l+3)/t.bpPerPixel),f=Math.round((h+u)/2);if(u<0)continue;if(h>t.pixelWidth)break;let d=c.aminoA;c.aminoA.indexOf("STOP")>-1?(a="rgb(255, 0, 0)",d="STOP"):"M"===c.aminoA&&(a="rgb(0, 153, 0)",d="START"),ls.fillRect(e,h,i,u-h,25,{fillStyle:a}),t.bpPerPixel<=.1&&ls.strokeText(e,d,f-e.measureText(d).width/2,i+15)}i+=30}}}}get supportsWholeGenome(){return!1}computePixelHeight(t){return this.height=this.frameTranslate?115:25,this.height}fillColor(t){return this.color?this.color:"dna"===this.sequenceType?this.browser.nucleotideColors[t]||"gray":"rgb(0, 0, 150)"}getState(){const t={type:"sequence"};return this.order!==Ts&&(t.order=this.order),this.reversed&&(t.revealed=!0),t}}
|
|
25
|
+
function(t){var e,n,r,i,o,s,a,c,l,h,u,f,d,p,g,m,v,b,w,y="sizzle"+1*new Date,x=t.document,k=0,_=0,S=st(),C=st(),E=st(),A=function(t,e){return t===e&&(u=!0),0},T={}.hasOwnProperty,L=[],M=L.pop,R=L.push,I=L.push,N=L.slice,P=function(t,e){for(var n=0,r=t.length;n<r;n++)if(t[n]===e)return n;return-1},O="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",F="[\\x20\\t\\r\\n\\f]",D="(?:\\\\.|[\\w-]|[^\0-\\xa0])+",B="\\[[\\x20\\t\\r\\n\\f]*("+D+")(?:"+F+"*([*^$|!~]?=)"+F+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+D+"))|)"+F+"*\\]",z=":("+D+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+B+")*)|.*)\\)|)",H=new RegExp(F+"+","g"),V=new RegExp("^[\\x20\\t\\r\\n\\f]+|((?:^|[^\\\\])(?:\\\\.)*)[\\x20\\t\\r\\n\\f]+$","g"),j=new RegExp("^[\\x20\\t\\r\\n\\f]*,[\\x20\\t\\r\\n\\f]*"),U=new RegExp("^[\\x20\\t\\r\\n\\f]*([>+~]|[\\x20\\t\\r\\n\\f])[\\x20\\t\\r\\n\\f]*"),q=new RegExp("=[\\x20\\t\\r\\n\\f]*([^\\]'\"]*?)[\\x20\\t\\r\\n\\f]*\\]","g"),W=new RegExp(z),$=new RegExp("^"+D+"$"),G={ID:new RegExp("^#("+D+")"),CLASS:new RegExp("^\\.("+D+")"),TAG:new RegExp("^("+D+"|[*])"),ATTR:new RegExp("^"+B),PSEUDO:new RegExp("^"+z),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\([\\x20\\t\\r\\n\\f]*(even|odd|(([+-]|)(\\d*)n|)[\\x20\\t\\r\\n\\f]*(?:([+-]|)[\\x20\\t\\r\\n\\f]*(\\d+)|))[\\x20\\t\\r\\n\\f]*\\)|)","i"),bool:new RegExp("^(?:"+O+")$","i"),needsContext:new RegExp("^[\\x20\\t\\r\\n\\f]*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\([\\x20\\t\\r\\n\\f]*((?:-\\d)?\\d*)[\\x20\\t\\r\\n\\f]*\\)|)(?=[^-]|$)","i")},Z=/^(?:input|select|textarea|button)$/i,X=/^h\d$/i,Y=/^[^{]+\{\s*\[native \w/,K=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,Q=/[+~]/,J=new RegExp("\\\\([\\da-f]{1,6}[\\x20\\t\\r\\n\\f]?|([\\x20\\t\\r\\n\\f])|.)","ig"),tt=function(t,e,n){var r="0x"+e-65536;return r!=r||n?e:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},et=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,nt=function(t,e){return e?"\0"===t?"�":t.slice(0,-1)+"\\"+t.charCodeAt(t.length-1).toString(16)+" ":"\\"+t},rt=function(){f()},it=vt((function(t){return!0===t.disabled&&("form"in t||"label"in t)}),{dir:"parentNode",next:"legend"});try{I.apply(L=N.call(x.childNodes),x.childNodes),L[x.childNodes.length].nodeType}catch(t){I={apply:L.length?function(t,e){R.apply(t,N.call(e))}:function(t,e){for(var n=t.length,r=0;t[n++]=e[r++];);t.length=n-1}}}function ot(t,e,r,i){var o,a,l,h,u,p,v,b=e&&e.ownerDocument,k=e?e.nodeType:9;if(r=r||[],"string"!=typeof t||!t||1!==k&&9!==k&&11!==k)return r;if(!i&&((e?e.ownerDocument||e:x)!==d&&f(e),e=e||d,g)){if(11!==k&&(u=K.exec(t)))if(o=u[1]){if(9===k){if(!(l=e.getElementById(o)))return r;if(l.id===o)return r.push(l),r}else if(b&&(l=b.getElementById(o))&&w(e,l)&&l.id===o)return r.push(l),r}else{if(u[2])return I.apply(r,e.getElementsByTagName(t)),r;if((o=u[3])&&n.getElementsByClassName&&e.getElementsByClassName)return I.apply(r,e.getElementsByClassName(o)),r}if(n.qsa&&!E[t+" "]&&(!m||!m.test(t))){if(1!==k)b=e,v=t;else if("object"!==e.nodeName.toLowerCase()){for((h=e.getAttribute("id"))?h=h.replace(et,nt):e.setAttribute("id",h=y),a=(p=s(t)).length;a--;)p[a]="#"+h+" "+mt(p[a]);v=p.join(","),b=Q.test(t)&&pt(e.parentNode)||e}if(v)try{return I.apply(r,b.querySelectorAll(v)),r}catch(t){}finally{h===y&&e.removeAttribute("id")}}}return c(t.replace(V,"$1"),e,r,i)}function st(){var t=[];return function e(n,i){return t.push(n+" ")>r.cacheLength&&delete e[t.shift()],e[n+" "]=i}}function at(t){return t[y]=!0,t}function ct(t){var e=d.createElement("fieldset");try{return!!t(e)}catch(t){return!1}finally{e.parentNode&&e.parentNode.removeChild(e),e=null}}function lt(t,e){var n=e&&t,r=n&&1===t.nodeType&&1===e.nodeType&&t.sourceIndex-e.sourceIndex;if(r)return r;if(n)for(;n=n.nextSibling;)if(n===e)return-1;return t?1:-1}function ht(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function ut(t){return function(e){var n=e.nodeName.toLowerCase();return("input"===n||"button"===n)&&e.type===t}}function ft(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&it(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function dt(t){return at((function(e){return e=+e,at((function(n,r){for(var i,o=t([],n.length,e),s=o.length;s--;)n[i=o[s]]&&(n[i]=!(r[i]=n[i]))}))}))}function pt(t){return t&&void 0!==t.getElementsByTagName&&t}for(e in n=ot.support={},o=ot.isXML=function(t){var e=t&&(t.ownerDocument||t).documentElement;return!!e&&"HTML"!==e.nodeName},f=ot.setDocument=function(t){var e,i,s=t?t.ownerDocument||t:x;return s!==d&&9===s.nodeType&&s.documentElement?(p=(d=s).documentElement,g=!o(d),x!==d&&(i=d.defaultView)&&i.top!==i&&(i.addEventListener?i.addEventListener("unload",rt,!1):i.attachEvent&&i.attachEvent("onunload",rt)),n.attributes=ct((function(t){return t.className="i",!t.getAttribute("className")})),n.getElementsByTagName=ct((function(t){return t.appendChild(d.createComment("")),!t.getElementsByTagName("*").length})),n.getElementsByClassName=Y.test(d.getElementsByClassName),n.getById=ct((function(t){return p.appendChild(t).id=y,!d.getElementsByName||!d.getElementsByName(y).length})),n.getById?(r.filter.ID=function(t){var e=t.replace(J,tt);return function(t){return t.getAttribute("id")===e}},r.find.ID=function(t,e){if(void 0!==e.getElementById&&g){var n=e.getElementById(t);return n?[n]:[]}}):(r.filter.ID=function(t){var e=t.replace(J,tt);return function(t){var n=void 0!==t.getAttributeNode&&t.getAttributeNode("id");return n&&n.value===e}},r.find.ID=function(t,e){if(void 0!==e.getElementById&&g){var n,r,i,o=e.getElementById(t);if(o){if((n=o.getAttributeNode("id"))&&n.value===t)return[o];for(i=e.getElementsByName(t),r=0;o=i[r++];)if((n=o.getAttributeNode("id"))&&n.value===t)return[o]}return[]}}),r.find.TAG=n.getElementsByTagName?function(t,e){return void 0!==e.getElementsByTagName?e.getElementsByTagName(t):n.qsa?e.querySelectorAll(t):void 0}:function(t,e){var n,r=[],i=0,o=e.getElementsByTagName(t);if("*"===t){for(;n=o[i++];)1===n.nodeType&&r.push(n);return r}return o},r.find.CLASS=n.getElementsByClassName&&function(t,e){if(void 0!==e.getElementsByClassName&&g)return e.getElementsByClassName(t)},v=[],m=[],(n.qsa=Y.test(d.querySelectorAll))&&(ct((function(t){p.appendChild(t).innerHTML="<a id='"+y+"'></a><select id='"+y+"-\r\\' msallowcapture=''><option selected=''></option></select>",t.querySelectorAll("[msallowcapture^='']").length&&m.push("[*^$]=[\\x20\\t\\r\\n\\f]*(?:''|\"\")"),t.querySelectorAll("[selected]").length||m.push("\\[[\\x20\\t\\r\\n\\f]*(?:value|"+O+")"),t.querySelectorAll("[id~="+y+"-]").length||m.push("~="),t.querySelectorAll(":checked").length||m.push(":checked"),t.querySelectorAll("a#"+y+"+*").length||m.push(".#.+[+~]")})),ct((function(t){t.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var e=d.createElement("input");e.setAttribute("type","hidden"),t.appendChild(e).setAttribute("name","D"),t.querySelectorAll("[name=d]").length&&m.push("name[\\x20\\t\\r\\n\\f]*[*^$|!~]?="),2!==t.querySelectorAll(":enabled").length&&m.push(":enabled",":disabled"),p.appendChild(t).disabled=!0,2!==t.querySelectorAll(":disabled").length&&m.push(":enabled",":disabled"),t.querySelectorAll("*,:x"),m.push(",.*:")}))),(n.matchesSelector=Y.test(b=p.matches||p.webkitMatchesSelector||p.mozMatchesSelector||p.oMatchesSelector||p.msMatchesSelector))&&ct((function(t){n.disconnectedMatch=b.call(t,"*"),b.call(t,"[s!='']:x"),v.push("!=",z)})),m=m.length&&new RegExp(m.join("|")),v=v.length&&new RegExp(v.join("|")),e=Y.test(p.compareDocumentPosition),w=e||Y.test(p.contains)?function(t,e){var n=9===t.nodeType?t.documentElement:t,r=e&&e.parentNode;return t===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):t.compareDocumentPosition&&16&t.compareDocumentPosition(r)))}:function(t,e){if(e)for(;e=e.parentNode;)if(e===t)return!0;return!1},A=e?function(t,e){if(t===e)return u=!0,0;var r=!t.compareDocumentPosition-!e.compareDocumentPosition;return r||(1&(r=(t.ownerDocument||t)===(e.ownerDocument||e)?t.compareDocumentPosition(e):1)||!n.sortDetached&&e.compareDocumentPosition(t)===r?t===d||t.ownerDocument===x&&w(x,t)?-1:e===d||e.ownerDocument===x&&w(x,e)?1:h?P(h,t)-P(h,e):0:4&r?-1:1)}:function(t,e){if(t===e)return u=!0,0;var n,r=0,i=t.parentNode,o=e.parentNode,s=[t],a=[e];if(!i||!o)return t===d?-1:e===d?1:i?-1:o?1:h?P(h,t)-P(h,e):0;if(i===o)return lt(t,e);for(n=t;n=n.parentNode;)s.unshift(n);for(n=e;n=n.parentNode;)a.unshift(n);for(;s[r]===a[r];)r++;return r?lt(s[r],a[r]):s[r]===x?-1:a[r]===x?1:0},d):d},ot.matches=function(t,e){return ot(t,null,null,e)},ot.matchesSelector=function(t,e){if((t.ownerDocument||t)!==d&&f(t),e=e.replace(q,"='$1']"),n.matchesSelector&&g&&!E[e+" "]&&(!v||!v.test(e))&&(!m||!m.test(e)))try{var r=b.call(t,e);if(r||n.disconnectedMatch||t.document&&11!==t.document.nodeType)return r}catch(t){}return ot(e,d,null,[t]).length>0},ot.contains=function(t,e){return(t.ownerDocument||t)!==d&&f(t),w(t,e)},ot.attr=function(t,e){(t.ownerDocument||t)!==d&&f(t);var i=r.attrHandle[e.toLowerCase()],o=i&&T.call(r.attrHandle,e.toLowerCase())?i(t,e,!g):void 0;return void 0!==o?o:n.attributes||!g?t.getAttribute(e):(o=t.getAttributeNode(e))&&o.specified?o.value:null},ot.escape=function(t){return(t+"").replace(et,nt)},ot.error=function(t){throw new Error("Syntax error, unrecognized expression: "+t)},ot.uniqueSort=function(t){var e,r=[],i=0,o=0;if(u=!n.detectDuplicates,h=!n.sortStable&&t.slice(0),t.sort(A),u){for(;e=t[o++];)e===t[o]&&(i=r.push(o));for(;i--;)t.splice(r[i],1)}return h=null,t},i=ot.getText=function(t){var e,n="",r=0,o=t.nodeType;if(o){if(1===o||9===o||11===o){if("string"==typeof t.textContent)return t.textContent;for(t=t.firstChild;t;t=t.nextSibling)n+=i(t)}else if(3===o||4===o)return t.nodeValue}else for(;e=t[r++];)n+=i(e);return n},r=ot.selectors={cacheLength:50,createPseudo:at,match:G,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(t){return t[1]=t[1].replace(J,tt),t[3]=(t[3]||t[4]||t[5]||"").replace(J,tt),"~="===t[2]&&(t[3]=" "+t[3]+" "),t.slice(0,4)},CHILD:function(t){return t[1]=t[1].toLowerCase(),"nth"===t[1].slice(0,3)?(t[3]||ot.error(t[0]),t[4]=+(t[4]?t[5]+(t[6]||1):2*("even"===t[3]||"odd"===t[3])),t[5]=+(t[7]+t[8]||"odd"===t[3])):t[3]&&ot.error(t[0]),t},PSEUDO:function(t){var e,n=!t[6]&&t[2];return G.CHILD.test(t[0])?null:(t[3]?t[2]=t[4]||t[5]||"":n&&W.test(n)&&(e=s(n,!0))&&(e=n.indexOf(")",n.length-e)-n.length)&&(t[0]=t[0].slice(0,e),t[2]=n.slice(0,e)),t.slice(0,3))}},filter:{TAG:function(t){var e=t.replace(J,tt).toLowerCase();return"*"===t?function(){return!0}:function(t){return t.nodeName&&t.nodeName.toLowerCase()===e}},CLASS:function(t){var e=S[t+" "];return e||(e=new RegExp("(^|[\\x20\\t\\r\\n\\f])"+t+"("+F+"|$)"))&&S(t,(function(t){return e.test("string"==typeof t.className&&t.className||void 0!==t.getAttribute&&t.getAttribute("class")||"")}))},ATTR:function(t,e,n){return function(r){var i=ot.attr(r,t);return null==i?"!="===e:!e||(i+="","="===e?i===n:"!="===e?i!==n:"^="===e?n&&0===i.indexOf(n):"*="===e?n&&i.indexOf(n)>-1:"$="===e?n&&i.slice(-n.length)===n:"~="===e?(" "+i.replace(H," ")+" ").indexOf(n)>-1:"|="===e&&(i===n||i.slice(0,n.length+1)===n+"-"))}},CHILD:function(t,e,n,r,i){var o="nth"!==t.slice(0,3),s="last"!==t.slice(-4),a="of-type"===e;return 1===r&&0===i?function(t){return!!t.parentNode}:function(e,n,c){var l,h,u,f,d,p,g=o!==s?"nextSibling":"previousSibling",m=e.parentNode,v=a&&e.nodeName.toLowerCase(),b=!c&&!a,w=!1;if(m){if(o){for(;g;){for(f=e;f=f[g];)if(a?f.nodeName.toLowerCase()===v:1===f.nodeType)return!1;p=g="only"===t&&!p&&"nextSibling"}return!0}if(p=[s?m.firstChild:m.lastChild],s&&b){for(w=(d=(l=(h=(u=(f=m)[y]||(f[y]={}))[f.uniqueID]||(u[f.uniqueID]={}))[t]||[])[0]===k&&l[1])&&l[2],f=d&&m.childNodes[d];f=++d&&f&&f[g]||(w=d=0)||p.pop();)if(1===f.nodeType&&++w&&f===e){h[t]=[k,d,w];break}}else if(b&&(w=d=(l=(h=(u=(f=e)[y]||(f[y]={}))[f.uniqueID]||(u[f.uniqueID]={}))[t]||[])[0]===k&&l[1]),!1===w)for(;(f=++d&&f&&f[g]||(w=d=0)||p.pop())&&((a?f.nodeName.toLowerCase()!==v:1!==f.nodeType)||!++w||(b&&((h=(u=f[y]||(f[y]={}))[f.uniqueID]||(u[f.uniqueID]={}))[t]=[k,w]),f!==e)););return(w-=i)===r||w%r==0&&w/r>=0}}},PSEUDO:function(t,e){var n,i=r.pseudos[t]||r.setFilters[t.toLowerCase()]||ot.error("unsupported pseudo: "+t);return i[y]?i(e):i.length>1?(n=[t,t,"",e],r.setFilters.hasOwnProperty(t.toLowerCase())?at((function(t,n){for(var r,o=i(t,e),s=o.length;s--;)t[r=P(t,o[s])]=!(n[r]=o[s])})):function(t){return i(t,0,n)}):i}},pseudos:{not:at((function(t){var e=[],n=[],r=a(t.replace(V,"$1"));return r[y]?at((function(t,e,n,i){for(var o,s=r(t,null,i,[]),a=t.length;a--;)(o=s[a])&&(t[a]=!(e[a]=o))})):function(t,i,o){return e[0]=t,r(e,null,o,n),e[0]=null,!n.pop()}})),has:at((function(t){return function(e){return ot(t,e).length>0}})),contains:at((function(t){return t=t.replace(J,tt),function(e){return(e.textContent||e.innerText||i(e)).indexOf(t)>-1}})),lang:at((function(t){return $.test(t||"")||ot.error("unsupported lang: "+t),t=t.replace(J,tt).toLowerCase(),function(e){var n;do{if(n=g?e.lang:e.getAttribute("xml:lang")||e.getAttribute("lang"))return(n=n.toLowerCase())===t||0===n.indexOf(t+"-")}while((e=e.parentNode)&&1===e.nodeType);return!1}})),target:function(e){var n=t.location&&t.location.hash;return n&&n.slice(1)===e.id},root:function(t){return t===p},focus:function(t){return t===d.activeElement&&(!d.hasFocus||d.hasFocus())&&!!(t.type||t.href||~t.tabIndex)},enabled:ft(!1),disabled:ft(!0),checked:function(t){var e=t.nodeName.toLowerCase();return"input"===e&&!!t.checked||"option"===e&&!!t.selected},selected:function(t){return t.parentNode&&t.parentNode.selectedIndex,!0===t.selected},empty:function(t){for(t=t.firstChild;t;t=t.nextSibling)if(t.nodeType<6)return!1;return!0},parent:function(t){return!r.pseudos.empty(t)},header:function(t){return X.test(t.nodeName)},input:function(t){return Z.test(t.nodeName)},button:function(t){var e=t.nodeName.toLowerCase();return"input"===e&&"button"===t.type||"button"===e},text:function(t){var e;return"input"===t.nodeName.toLowerCase()&&"text"===t.type&&(null==(e=t.getAttribute("type"))||"text"===e.toLowerCase())},first:dt((function(){return[0]})),last:dt((function(t,e){return[e-1]})),eq:dt((function(t,e,n){return[n<0?n+e:n]})),even:dt((function(t,e){for(var n=0;n<e;n+=2)t.push(n);return t})),odd:dt((function(t,e){for(var n=1;n<e;n+=2)t.push(n);return t})),lt:dt((function(t,e,n){for(var r=n<0?n+e:n;--r>=0;)t.push(r);return t})),gt:dt((function(t,e,n){for(var r=n<0?n+e:n;++r<e;)t.push(r);return t}))}},r.pseudos.nth=r.pseudos.eq,{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})r.pseudos[e]=ht(e);for(e in{submit:!0,reset:!0})r.pseudos[e]=ut(e);function gt(){}function mt(t){for(var e=0,n=t.length,r="";e<n;e++)r+=t[e].value;return r}function vt(t,e,n){var r=e.dir,i=e.next,o=i||r,s=n&&"parentNode"===o,a=_++;return e.first?function(e,n,i){for(;e=e[r];)if(1===e.nodeType||s)return t(e,n,i);return!1}:function(e,n,c){var l,h,u,f=[k,a];if(c){for(;e=e[r];)if((1===e.nodeType||s)&&t(e,n,c))return!0}else for(;e=e[r];)if(1===e.nodeType||s)if(h=(u=e[y]||(e[y]={}))[e.uniqueID]||(u[e.uniqueID]={}),i&&i===e.nodeName.toLowerCase())e=e[r]||e;else{if((l=h[o])&&l[0]===k&&l[1]===a)return f[2]=l[2];if(h[o]=f,f[2]=t(e,n,c))return!0}return!1}}function bt(t){return t.length>1?function(e,n,r){for(var i=t.length;i--;)if(!t[i](e,n,r))return!1;return!0}:t[0]}function wt(t,e,n,r,i){for(var o,s=[],a=0,c=t.length,l=null!=e;a<c;a++)(o=t[a])&&(n&&!n(o,r,i)||(s.push(o),l&&e.push(a)));return s}function yt(t,e,n,r,i,o){return r&&!r[y]&&(r=yt(r)),i&&!i[y]&&(i=yt(i,o)),at((function(o,s,a,c){var l,h,u,f=[],d=[],p=s.length,g=o||function(t,e,n){for(var r=0,i=e.length;r<i;r++)ot(t,e[r],n);return n}(e||"*",a.nodeType?[a]:a,[]),m=!t||!o&&e?g:wt(g,f,t,a,c),v=n?i||(o?t:p||r)?[]:s:m;if(n&&n(m,v,a,c),r)for(l=wt(v,d),r(l,[],a,c),h=l.length;h--;)(u=l[h])&&(v[d[h]]=!(m[d[h]]=u));if(o){if(i||t){if(i){for(l=[],h=v.length;h--;)(u=v[h])&&l.push(m[h]=u);i(null,v=[],l,c)}for(h=v.length;h--;)(u=v[h])&&(l=i?P(o,u):f[h])>-1&&(o[l]=!(s[l]=u))}}else v=wt(v===s?v.splice(p,v.length):v),i?i(null,s,v,c):I.apply(s,v)}))}function xt(t){for(var e,n,i,o=t.length,s=r.relative[t[0].type],a=s||r.relative[" "],c=s?1:0,h=vt((function(t){return t===e}),a,!0),u=vt((function(t){return P(e,t)>-1}),a,!0),f=[function(t,n,r){var i=!s&&(r||n!==l)||((e=n).nodeType?h(t,n,r):u(t,n,r));return e=null,i}];c<o;c++)if(n=r.relative[t[c].type])f=[vt(bt(f),n)];else{if((n=r.filter[t[c].type].apply(null,t[c].matches))[y]){for(i=++c;i<o&&!r.relative[t[i].type];i++);return yt(c>1&&bt(f),c>1&&mt(t.slice(0,c-1).concat({value:" "===t[c-2].type?"*":""})).replace(V,"$1"),n,c<i&&xt(t.slice(c,i)),i<o&&xt(t=t.slice(i)),i<o&&mt(t))}f.push(n)}return bt(f)}return gt.prototype=r.filters=r.pseudos,r.setFilters=new gt,s=ot.tokenize=function(t,e){var n,i,o,s,a,c,l,h=C[t+" "];if(h)return e?0:h.slice(0);for(a=t,c=[],l=r.preFilter;a;){for(s in n&&!(i=j.exec(a))||(i&&(a=a.slice(i[0].length)||a),c.push(o=[])),n=!1,(i=U.exec(a))&&(n=i.shift(),o.push({value:n,type:i[0].replace(V," ")}),a=a.slice(n.length)),r.filter)!(i=G[s].exec(a))||l[s]&&!(i=l[s](i))||(n=i.shift(),o.push({value:n,type:s,matches:i}),a=a.slice(n.length));if(!n)break}return e?a.length:a?ot.error(t):C(t,c).slice(0)},a=ot.compile=function(t,e){var n,i=[],o=[],a=E[t+" "];if(!a){for(e||(e=s(t)),n=e.length;n--;)(a=xt(e[n]))[y]?i.push(a):o.push(a);a=E(t,function(t,e){var n=e.length>0,i=t.length>0,o=function(o,s,a,c,h){var u,p,m,v=0,b="0",w=o&&[],y=[],x=l,_=o||i&&r.find.TAG("*",h),S=k+=null==x?1:Math.random()||.1,C=_.length;for(h&&(l=s===d||s||h);b!==C&&null!=(u=_[b]);b++){if(i&&u){for(p=0,s||u.ownerDocument===d||(f(u),a=!g);m=t[p++];)if(m(u,s||d,a)){c.push(u);break}h&&(k=S)}n&&((u=!m&&u)&&v--,o&&w.push(u))}if(v+=b,n&&b!==v){for(p=0;m=e[p++];)m(w,y,s,a);if(o){if(v>0)for(;b--;)w[b]||y[b]||(y[b]=M.call(c));y=wt(y)}I.apply(c,y),h&&!o&&y.length>0&&v+e.length>1&&ot.uniqueSort(c)}return h&&(k=S,l=x),w};return n?at(o):o}(o,i)),a.selector=t}return a},c=ot.select=function(t,e,n,i){var o,c,l,h,u,f="function"==typeof t&&t,d=!i&&s(t=f.selector||t);if(n=n||[],1===d.length){if((c=d[0]=d[0].slice(0)).length>2&&"ID"===(l=c[0]).type&&9===e.nodeType&&g&&r.relative[c[1].type]){if(!(e=(r.find.ID(l.matches[0].replace(J,tt),e)||[])[0]))return n;f&&(e=e.parentNode),t=t.slice(c.shift().value.length)}for(o=G.needsContext.test(t)?0:c.length;o--&&(l=c[o],!r.relative[h=l.type]);)if((u=r.find[h])&&(i=u(l.matches[0].replace(J,tt),Q.test(c[0].type)&&pt(e.parentNode)||e))){if(c.splice(o,1),!(t=i.length&&mt(c)))return I.apply(n,i),n;break}}return(f||a(t,d))(i,e,!g,n,!e||Q.test(t)&&pt(e.parentNode)||e),n},n.sortStable=y.split("").sort(A).join("")===y,n.detectDuplicates=!!u,f(),ot}(window);w.find=k,w.expr=k.selectors,w.expr[":"]=w.expr.pseudos,w.uniqueSort=w.unique=k.uniqueSort,w.text=k.getText,w.isXMLDoc=k.isXML,w.contains=k.contains,w.escapeSelector=k.escape;var _=function(t,e,n){for(var r=[],i=void 0!==n;(t=t[e])&&9!==t.nodeType;)if(1===t.nodeType){if(i&&w(t).is(n))break;r.push(t)}return r},S=function(t,e){for(var n=[];t;t=t.nextSibling)1===t.nodeType&&t!==e&&n.push(t);return n},C=w.expr.match.needsContext;function E(t,e){return t.nodeName&&t.nodeName.toLowerCase()===e.toLowerCase()}var A=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function T(t,e,n){return d(e)?w.grep(t,(function(t,r){return!!e.call(t,r,t)!==n})):e.nodeType?w.grep(t,(function(t){return t===e!==n})):"string"!=typeof e?w.grep(t,(function(t){return s.call(e,t)>-1!==n})):w.filter(e,t,n)}w.filter=function(t,e,n){var r=e[0];return n&&(t=":not("+t+")"),1===e.length&&1===r.nodeType?w.find.matchesSelector(r,t)?[r]:[]:w.find.matches(t,w.grep(e,(function(t){return 1===t.nodeType})))},w.fn.extend({find:function(t){var e,n,r=this.length,i=this;if("string"!=typeof t)return this.pushStack(w(t).filter((function(){for(e=0;e<r;e++)if(w.contains(i[e],this))return!0})));for(n=this.pushStack([]),e=0;e<r;e++)w.find(t,i[e],n);return r>1?w.uniqueSort(n):n},filter:function(t){return this.pushStack(T(this,t||[],!1))},not:function(t){return this.pushStack(T(this,t||[],!0))},is:function(t){return!!T(this,"string"==typeof t&&C.test(t)?w(t):t||[],!1).length}});var L,M=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(w.fn.init=function(t,n,r){var i,o;if(!t)return this;if(r=r||L,"string"==typeof t){if(!(i="<"===t[0]&&">"===t[t.length-1]&&t.length>=3?[null,t,null]:M.exec(t))||!i[1]&&n)return!n||n.jquery?(n||r).find(t):this.constructor(n).find(t);if(i[1]){if(n=n instanceof w?n[0]:n,w.merge(this,w.parseHTML(i[1],n&&n.nodeType?n.ownerDocument||n:e,!0)),A.test(i[1])&&w.isPlainObject(n))for(i in n)d(this[i])?this[i](n[i]):this.attr(i,n[i]);return this}return(o=e.getElementById(i[2]))&&(this[0]=o,this.length=1),this}return t.nodeType?(this[0]=t,this.length=1,this):d(t)?void 0!==r.ready?r.ready(t):t(w):w.makeArray(t,this)}).prototype=w.fn,L=w(e);var R=/^(?:parents|prev(?:Until|All))/,I={children:!0,contents:!0,next:!0,prev:!0};function N(t,e){for(;(t=t[e])&&1!==t.nodeType;);return t}w.fn.extend({has:function(t){var e=w(t,this),n=e.length;return this.filter((function(){for(var t=0;t<n;t++)if(w.contains(this,e[t]))return!0}))},closest:function(t,e){var n,r=0,i=this.length,o=[],s="string"!=typeof t&&w(t);if(!C.test(t))for(;r<i;r++)for(n=this[r];n&&n!==e;n=n.parentNode)if(n.nodeType<11&&(s?s.index(n)>-1:1===n.nodeType&&w.find.matchesSelector(n,t))){o.push(n);break}return this.pushStack(o.length>1?w.uniqueSort(o):o)},index:function(t){return t?"string"==typeof t?s.call(w(t),this[0]):s.call(this,t.jquery?t[0]:t):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(t,e){return this.pushStack(w.uniqueSort(w.merge(this.get(),w(t,e))))},addBack:function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}}),w.each({parent:function(t){var e=t.parentNode;return e&&11!==e.nodeType?e:null},parents:function(t){return _(t,"parentNode")},parentsUntil:function(t,e,n){return _(t,"parentNode",n)},next:function(t){return N(t,"nextSibling")},prev:function(t){return N(t,"previousSibling")},nextAll:function(t){return _(t,"nextSibling")},prevAll:function(t){return _(t,"previousSibling")},nextUntil:function(t,e,n){return _(t,"nextSibling",n)},prevUntil:function(t,e,n){return _(t,"previousSibling",n)},siblings:function(t){return S((t.parentNode||{}).firstChild,t)},children:function(t){return S(t.firstChild)},contents:function(t){return E(t,"iframe")?t.contentDocument:(E(t,"template")&&(t=t.content||t),w.merge([],t.childNodes))}},(function(t,e){w.fn[t]=function(n,r){var i=w.map(this,e,n);return"Until"!==t.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=w.filter(r,i)),this.length>1&&(I[t]||w.uniqueSort(i),R.test(t)&&i.reverse()),this.pushStack(i)}}));var P=/[^\x20\t\r\n\f]+/g;function O(t){return t}function F(t){throw t}function D(t,e,n,r){var i;try{t&&d(i=t.promise)?i.call(t).done(e).fail(n):t&&d(i=t.then)?i.call(t,e,n):e.apply(void 0,[t].slice(r))}catch(t){n.apply(void 0,[t])}}w.Callbacks=function(t){t="string"==typeof t?function(t){var e={};return w.each(t.match(P)||[],(function(t,n){e[n]=!0})),e}(t):w.extend({},t);var e,n,r,i,o=[],s=[],a=-1,c=function(){for(i=i||t.once,r=e=!0;s.length;a=-1)for(n=s.shift();++a<o.length;)!1===o[a].apply(n[0],n[1])&&t.stopOnFalse&&(a=o.length,n=!1);t.memory||(n=!1),e=!1,i&&(o=n?[]:"")},l={add:function(){return o&&(n&&!e&&(a=o.length-1,s.push(n)),function e(n){w.each(n,(function(n,r){d(r)?t.unique&&l.has(r)||o.push(r):r&&r.length&&"string"!==v(r)&&e(r)}))}(arguments),n&&!e&&c()),this},remove:function(){return w.each(arguments,(function(t,e){for(var n;(n=w.inArray(e,o,n))>-1;)o.splice(n,1),n<=a&&a--})),this},has:function(t){return t?w.inArray(t,o)>-1:o.length>0},empty:function(){return o&&(o=[]),this},disable:function(){return i=s=[],o=n="",this},disabled:function(){return!o},lock:function(){return i=s=[],n||e||(o=n=""),this},locked:function(){return!!i},fireWith:function(t,n){return i||(n=[t,(n=n||[]).slice?n.slice():n],s.push(n),e||c()),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!r}};return l},w.extend({Deferred:function(t){var e=[["notify","progress",w.Callbacks("memory"),w.Callbacks("memory"),2],["resolve","done",w.Callbacks("once memory"),w.Callbacks("once memory"),0,"resolved"],["reject","fail",w.Callbacks("once memory"),w.Callbacks("once memory"),1,"rejected"]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},catch:function(t){return r.then(null,t)},pipe:function(){var t=arguments;return w.Deferred((function(n){w.each(e,(function(e,r){var o=d(t[r[4]])&&t[r[4]];i[r[1]]((function(){var t=o&&o.apply(this,arguments);t&&d(t.promise)?t.promise().progress(n.notify).done(n.resolve).fail(n.reject):n[r[0]+"With"](this,o?[t]:arguments)}))})),t=null})).promise()},then:function(t,n,r){var i=0;function o(t,e,n,r){return function(){var s=this,a=arguments,c=function(){var c,l;if(!(t<i)){if((c=n.apply(s,a))===e.promise())throw new TypeError("Thenable self-resolution");l=c&&("object"==typeof c||"function"==typeof c)&&c.then,d(l)?r?l.call(c,o(i,e,O,r),o(i,e,F,r)):(i++,l.call(c,o(i,e,O,r),o(i,e,F,r),o(i,e,O,e.notifyWith))):(n!==O&&(s=void 0,a=[c]),(r||e.resolveWith)(s,a))}},l=r?c:function(){try{c()}catch(r){w.Deferred.exceptionHook&&w.Deferred.exceptionHook(r,l.stackTrace),t+1>=i&&(n!==F&&(s=void 0,a=[r]),e.rejectWith(s,a))}};t?l():(w.Deferred.getStackHook&&(l.stackTrace=w.Deferred.getStackHook()),window.setTimeout(l))}}return w.Deferred((function(i){e[0][3].add(o(0,i,d(r)?r:O,i.notifyWith)),e[1][3].add(o(0,i,d(t)?t:O)),e[2][3].add(o(0,i,d(n)?n:F))})).promise()},promise:function(t){return null!=t?w.extend(t,r):r}},i={};return w.each(e,(function(t,o){var s=o[2],a=o[5];r[o[1]]=s.add,a&&s.add((function(){n=a}),e[3-t][2].disable,e[3-t][3].disable,e[0][2].lock,e[0][3].lock),s.add(o[3].fire),i[o[0]]=function(){return i[o[0]+"With"](this===i?void 0:this,arguments),this},i[o[0]+"With"]=s.fireWith})),r.promise(i),t&&t.call(i,i),i},when:function(t){var e=arguments.length,n=e,i=Array(n),o=r.call(arguments),s=w.Deferred(),a=function(t){return function(n){i[t]=this,o[t]=arguments.length>1?r.call(arguments):n,--e||s.resolveWith(i,o)}};if(e<=1&&(D(t,s.done(a(n)).resolve,s.reject,!e),"pending"===s.state()||d(o[n]&&o[n].then)))return s.then();for(;n--;)D(o[n],a(n),s.reject);return s.promise()}});var B=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;w.Deferred.exceptionHook=function(t,e){window.console&&window.console.warn&&t&&B.test(t.name)&&window.console.warn("jQuery.Deferred exception: "+t.message,t.stack,e)},w.readyException=function(t){window.setTimeout((function(){throw t}))};var z=w.Deferred();function H(){e.removeEventListener("DOMContentLoaded",H),window.removeEventListener("load",H),w.ready()}w.fn.ready=function(t){return z.then(t).catch((function(t){w.readyException(t)})),this},w.extend({isReady:!1,readyWait:1,ready:function(t){(!0===t?--w.readyWait:w.isReady)||(w.isReady=!0,!0!==t&&--w.readyWait>0||z.resolveWith(e,[w]))}}),w.ready.then=z.then,"complete"===e.readyState||"loading"!==e.readyState&&!e.documentElement.doScroll?window.setTimeout(w.ready):(e.addEventListener("DOMContentLoaded",H),window.addEventListener("load",H));var V=function(t,e,n,r,i,o,s){var a=0,c=t.length,l=null==n;if("object"===v(n))for(a in i=!0,n)V(t,e,a,n[a],!0,o,s);else if(void 0!==r&&(i=!0,d(r)||(s=!0),l&&(s?(e.call(t,r),e=null):(l=e,e=function(t,e,n){return l.call(w(t),n)})),e))for(;a<c;a++)e(t[a],n,s?r:r.call(t[a],a,e(t[a],n)));return i?t:l?e.call(t):c?e(t[0],n):o},j=/^-ms-/,U=/-([a-z])/g;function q(t,e){return e.toUpperCase()}function W(t){return t.replace(j,"ms-").replace(U,q)}var $=function(t){return 1===t.nodeType||9===t.nodeType||!+t.nodeType};function G(){this.expando=w.expando+G.uid++}G.uid=1,G.prototype={cache:function(t){var e=t[this.expando];return e||(e={},$(t)&&(t.nodeType?t[this.expando]=e:Object.defineProperty(t,this.expando,{value:e,configurable:!0}))),e},set:function(t,e,n){var r,i=this.cache(t);if("string"==typeof e)i[W(e)]=n;else for(r in e)i[W(r)]=e[r];return i},get:function(t,e){return void 0===e?this.cache(t):t[this.expando]&&t[this.expando][W(e)]},access:function(t,e,n){return void 0===e||e&&"string"==typeof e&&void 0===n?this.get(t,e):(this.set(t,e,n),void 0!==n?n:e)},remove:function(t,e){var n,r=t[this.expando];if(void 0!==r){if(void 0!==e){n=(e=Array.isArray(e)?e.map(W):(e=W(e))in r?[e]:e.match(P)||[]).length;for(;n--;)delete r[e[n]]}(void 0===e||w.isEmptyObject(r))&&(t.nodeType?t[this.expando]=void 0:delete t[this.expando])}},hasData:function(t){var e=t[this.expando];return void 0!==e&&!w.isEmptyObject(e)}};var Z=new G,X=new G,Y=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,K=/[A-Z]/g;function Q(t,e,n){var r;if(void 0===n&&1===t.nodeType)if(r="data-"+e.replace(K,"-$&").toLowerCase(),"string"==typeof(n=t.getAttribute(r))){try{n=function(t){return"true"===t||"false"!==t&&("null"===t?null:t===+t+""?+t:Y.test(t)?JSON.parse(t):t)}(n)}catch(t){}X.set(t,e,n)}else n=void 0;return n}w.extend({hasData:function(t){return X.hasData(t)||Z.hasData(t)},data:function(t,e,n){return X.access(t,e,n)},removeData:function(t,e){X.remove(t,e)},_data:function(t,e,n){return Z.access(t,e,n)},_removeData:function(t,e){Z.remove(t,e)}}),w.fn.extend({data:function(t,e){var n,r,i,o=this[0],s=o&&o.attributes;if(void 0===t){if(this.length&&(i=X.get(o),1===o.nodeType&&!Z.get(o,"hasDataAttrs"))){for(n=s.length;n--;)s[n]&&0===(r=s[n].name).indexOf("data-")&&(r=W(r.slice(5)),Q(o,r,i[r]));Z.set(o,"hasDataAttrs",!0)}return i}return"object"==typeof t?this.each((function(){X.set(this,t)})):V(this,(function(e){var n;if(o&&void 0===e)return void 0!==(n=X.get(o,t))||void 0!==(n=Q(o,t))?n:void 0;this.each((function(){X.set(this,t,e)}))}),null,e,arguments.length>1,null,!0)},removeData:function(t){return this.each((function(){X.remove(this,t)}))}}),w.extend({queue:function(t,e,n){var r;if(t)return e=(e||"fx")+"queue",r=Z.get(t,e),n&&(!r||Array.isArray(n)?r=Z.access(t,e,w.makeArray(n)):r.push(n)),r||[]},dequeue:function(t,e){e=e||"fx";var n=w.queue(t,e),r=n.length,i=n.shift(),o=w._queueHooks(t,e);"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===e&&n.unshift("inprogress"),delete o.stop,i.call(t,(function(){w.dequeue(t,e)}),o)),!r&&o&&o.empty.fire()},_queueHooks:function(t,e){var n=e+"queueHooks";return Z.get(t,n)||Z.access(t,n,{empty:w.Callbacks("once memory").add((function(){Z.remove(t,[e+"queue",n])}))})}}),w.fn.extend({queue:function(t,e){var n=2;return"string"!=typeof t&&(e=t,t="fx",n--),arguments.length<n?w.queue(this[0],t):void 0===e?this:this.each((function(){var n=w.queue(this,t,e);w._queueHooks(this,t),"fx"===t&&"inprogress"!==n[0]&&w.dequeue(this,t)}))},dequeue:function(t){return this.each((function(){w.dequeue(this,t)}))},clearQueue:function(t){return this.queue(t||"fx",[])},promise:function(t,e){var n,r=1,i=w.Deferred(),o=this,s=this.length,a=function(){--r||i.resolveWith(o,[o])};for("string"!=typeof t&&(e=t,t=void 0),t=t||"fx";s--;)(n=Z.get(o[s],t+"queueHooks"))&&n.empty&&(r++,n.empty.add(a));return a(),i.promise(e)}});var J=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,tt=new RegExp("^(?:([+-])=|)("+J+")([a-z%]*)$","i"),et=["Top","Right","Bottom","Left"],nt=function(t,e){return"none"===(t=e||t).style.display||""===t.style.display&&w.contains(t.ownerDocument,t)&&"none"===w.css(t,"display")},rt=function(t,e,n,r){var i,o,s={};for(o in e)s[o]=t.style[o],t.style[o]=e[o];for(o in i=n.apply(t,r||[]),e)t.style[o]=s[o];return i};var it={};function ot(t){var e,n=t.ownerDocument,r=t.nodeName,i=it[r];return i||(e=n.body.appendChild(n.createElement(r)),i=w.css(e,"display"),e.parentNode.removeChild(e),"none"===i&&(i="block"),it[r]=i,i)}function st(t,e){for(var n,r,i=[],o=0,s=t.length;o<s;o++)(r=t[o]).style&&(n=r.style.display,e?("none"===n&&(i[o]=Z.get(r,"display")||null,i[o]||(r.style.display="")),""===r.style.display&&nt(r)&&(i[o]=ot(r))):"none"!==n&&(i[o]="none",Z.set(r,"display",n)));for(o=0;o<s;o++)null!=i[o]&&(t[o].style.display=i[o]);return t}w.fn.extend({show:function(){return st(this,!0)},hide:function(){return st(this)},toggle:function(t){return"boolean"==typeof t?t?this.show():this.hide():this.each((function(){nt(this)?w(this).show():w(this).hide()}))}});var at=/^(?:checkbox|radio)$/i,ct=/<([a-z][^\/\0>\x20\t\r\n\f]+)/i,lt=/^$|^module$|\/(?:java|ecma)script/i,ht={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 ut(t,e){var n;return n=void 0!==t.getElementsByTagName?t.getElementsByTagName(e||"*"):void 0!==t.querySelectorAll?t.querySelectorAll(e||"*"):[],void 0===e||e&&E(t,e)?w.merge([t],n):n}function ft(t,e){for(var n=0,r=t.length;n<r;n++)Z.set(t[n],"globalEval",!e||Z.get(e[n],"globalEval"))}ht.optgroup=ht.option,ht.tbody=ht.tfoot=ht.colgroup=ht.caption=ht.thead,ht.th=ht.td;var dt=/<|&#?\w+;/;function pt(t,e,n,r,i){for(var o,s,a,c,l,h,u=e.createDocumentFragment(),f=[],d=0,p=t.length;d<p;d++)if((o=t[d])||0===o)if("object"===v(o))w.merge(f,o.nodeType?[o]:o);else if(dt.test(o)){for(s=s||u.appendChild(e.createElement("div")),a=(ct.exec(o)||["",""])[1].toLowerCase(),c=ht[a]||ht._default,s.innerHTML=c[1]+w.htmlPrefilter(o)+c[2],h=c[0];h--;)s=s.lastChild;w.merge(f,s.childNodes),(s=u.firstChild).textContent=""}else f.push(e.createTextNode(o));for(u.textContent="",d=0;o=f[d++];)if(r&&w.inArray(o,r)>-1)i&&i.push(o);else if(l=w.contains(o.ownerDocument,o),s=ut(u.appendChild(o),"script"),l&&ft(s),n)for(h=0;o=s[h++];)lt.test(o.type||"")&&n.push(o);return u}!function(){var t=e.createDocumentFragment().appendChild(e.createElement("div")),n=e.createElement("input");n.setAttribute("type","radio"),n.setAttribute("checked","checked"),n.setAttribute("name","t"),t.appendChild(n),f.checkClone=t.cloneNode(!0).cloneNode(!0).lastChild.checked,t.innerHTML="<textarea>x</textarea>",f.noCloneChecked=!!t.cloneNode(!0).lastChild.defaultValue}();var gt=e.documentElement,mt=/^key/,vt=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,bt=/^([^.]*)(?:\.(.+)|)/;function wt(){return!0}function yt(){return!1}function xt(){try{return e.activeElement}catch(t){}}function kt(t,e,n,r,i,o){var s,a;if("object"==typeof e){for(a in"string"!=typeof n&&(r=r||n,n=void 0),e)kt(t,a,n,r,e[a],o);return t}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=yt;else if(!i)return t;return 1===o&&(s=i,i=function(t){return w().off(t),s.apply(this,arguments)},i.guid=s.guid||(s.guid=w.guid++)),t.each((function(){w.event.add(this,e,i,r,n)}))}w.event={global:{},add:function(t,e,n,r,i){var o,s,a,c,l,h,u,f,d,p,g,m=Z.get(t);if(m)for(n.handler&&(n=(o=n).handler,i=o.selector),i&&w.find.matchesSelector(gt,i),n.guid||(n.guid=w.guid++),(c=m.events)||(c=m.events={}),(s=m.handle)||(s=m.handle=function(e){return void 0!==w&&w.event.triggered!==e.type?w.event.dispatch.apply(t,arguments):void 0}),l=(e=(e||"").match(P)||[""]).length;l--;)d=g=(a=bt.exec(e[l])||[])[1],p=(a[2]||"").split(".").sort(),d&&(u=w.event.special[d]||{},d=(i?u.delegateType:u.bindType)||d,u=w.event.special[d]||{},h=w.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&w.expr.match.needsContext.test(i),namespace:p.join(".")},o),(f=c[d])||((f=c[d]=[]).delegateCount=0,u.setup&&!1!==u.setup.call(t,r,p,s)||t.addEventListener&&t.addEventListener(d,s)),u.add&&(u.add.call(t,h),h.handler.guid||(h.handler.guid=n.guid)),i?f.splice(f.delegateCount++,0,h):f.push(h),w.event.global[d]=!0)},remove:function(t,e,n,r,i){var o,s,a,c,l,h,u,f,d,p,g,m=Z.hasData(t)&&Z.get(t);if(m&&(c=m.events)){for(l=(e=(e||"").match(P)||[""]).length;l--;)if(d=g=(a=bt.exec(e[l])||[])[1],p=(a[2]||"").split(".").sort(),d){for(u=w.event.special[d]||{},f=c[d=(r?u.delegateType:u.bindType)||d]||[],a=a[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),s=o=f.length;o--;)h=f[o],!i&&g!==h.origType||n&&n.guid!==h.guid||a&&!a.test(h.namespace)||r&&r!==h.selector&&("**"!==r||!h.selector)||(f.splice(o,1),h.selector&&f.delegateCount--,u.remove&&u.remove.call(t,h));s&&!f.length&&(u.teardown&&!1!==u.teardown.call(t,p,m.handle)||w.removeEvent(t,d,m.handle),delete c[d])}else for(d in c)w.event.remove(t,d+e[l],n,r,!0);w.isEmptyObject(c)&&Z.remove(t,"handle events")}},dispatch:function(t){var e,n,r,i,o,s,a=w.event.fix(t),c=new Array(arguments.length),l=(Z.get(this,"events")||{})[a.type]||[],h=w.event.special[a.type]||{};for(c[0]=a,e=1;e<arguments.length;e++)c[e]=arguments[e];if(a.delegateTarget=this,!h.preDispatch||!1!==h.preDispatch.call(this,a)){for(s=w.event.handlers.call(this,a,l),e=0;(i=s[e++])&&!a.isPropagationStopped();)for(a.currentTarget=i.elem,n=0;(o=i.handlers[n++])&&!a.isImmediatePropagationStopped();)a.rnamespace&&!a.rnamespace.test(o.namespace)||(a.handleObj=o,a.data=o.data,void 0!==(r=((w.event.special[o.origType]||{}).handle||o.handler).apply(i.elem,c))&&!1===(a.result=r)&&(a.preventDefault(),a.stopPropagation()));return h.postDispatch&&h.postDispatch.call(this,a),a.result}},handlers:function(t,e){var n,r,i,o,s,a=[],c=e.delegateCount,l=t.target;if(c&&l.nodeType&&!("click"===t.type&&t.button>=1))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&("click"!==t.type||!0!==l.disabled)){for(o=[],s={},n=0;n<c;n++)void 0===s[i=(r=e[n]).selector+" "]&&(s[i]=r.needsContext?w(i,this).index(l)>-1:w.find(i,this,null,[l]).length),s[i]&&o.push(r);o.length&&a.push({elem:l,handlers:o})}return l=this,c<e.length&&a.push({elem:l,handlers:e.slice(c)}),a},addProp:function(t,e){Object.defineProperty(w.Event.prototype,t,{enumerable:!0,configurable:!0,get:d(e)?function(){if(this.originalEvent)return e(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[t]},set:function(e){Object.defineProperty(this,t,{enumerable:!0,configurable:!0,writable:!0,value:e})}})},fix:function(t){return t[w.expando]?t:new w.Event(t)},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==xt()&&this.focus)return this.focus(),!1},delegateType:"focusin"},blur:{trigger:function(){if(this===xt()&&this.blur)return this.blur(),!1},delegateType:"focusout"},click:{trigger:function(){if("checkbox"===this.type&&this.click&&E(this,"input"))return this.click(),!1},_default:function(t){return E(t.target,"a")}},beforeunload:{postDispatch:function(t){void 0!==t.result&&t.originalEvent&&(t.originalEvent.returnValue=t.result)}}}},w.removeEvent=function(t,e,n){t.removeEventListener&&t.removeEventListener(e,n)},w.Event=function(t,e){if(!(this instanceof w.Event))return new w.Event(t,e);t&&t.type?(this.originalEvent=t,this.type=t.type,this.isDefaultPrevented=t.defaultPrevented||void 0===t.defaultPrevented&&!1===t.returnValue?wt:yt,this.target=t.target&&3===t.target.nodeType?t.target.parentNode:t.target,this.currentTarget=t.currentTarget,this.relatedTarget=t.relatedTarget):this.type=t,e&&w.extend(this,e),this.timeStamp=t&&t.timeStamp||Date.now(),this[w.expando]=!0},w.Event.prototype={constructor:w.Event,isDefaultPrevented:yt,isPropagationStopped:yt,isImmediatePropagationStopped:yt,isSimulated:!1,preventDefault:function(){var t=this.originalEvent;this.isDefaultPrevented=wt,t&&!this.isSimulated&&t.preventDefault()},stopPropagation:function(){var t=this.originalEvent;this.isPropagationStopped=wt,t&&!this.isSimulated&&t.stopPropagation()},stopImmediatePropagation:function(){var t=this.originalEvent;this.isImmediatePropagationStopped=wt,t&&!this.isSimulated&&t.stopImmediatePropagation(),this.stopPropagation()}},w.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(t){var e=t.button;return null==t.which&&mt.test(t.type)?null!=t.charCode?t.charCode:t.keyCode:!t.which&&void 0!==e&&vt.test(t.type)?1&e?1:2&e?3:4&e?2:0:t.which}},w.event.addProp),w.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},(function(t,e){w.event.special[t]={delegateType:e,bindType:e,handle:function(t){var n,r=this,i=t.relatedTarget,o=t.handleObj;return i&&(i===r||w.contains(r,i))||(t.type=o.origType,n=o.handler.apply(this,arguments),t.type=e),n}}})),w.fn.extend({on:function(t,e,n,r){return kt(this,t,e,n,r)},one:function(t,e,n,r){return kt(this,t,e,n,r,1)},off:function(t,e,n){var r,i;if(t&&t.preventDefault&&t.handleObj)return r=t.handleObj,w(t.delegateTarget).off(r.namespace?r.origType+"."+r.namespace:r.origType,r.selector,r.handler),this;if("object"==typeof t){for(i in t)this.off(i,e,t[i]);return this}return!1!==e&&"function"!=typeof e||(n=e,e=void 0),!1===n&&(n=yt),this.each((function(){w.event.remove(this,t,n,e)}))}});var _t=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,St=/<script|<style|<link/i,Ct=/checked\s*(?:[^=]|=\s*.checked.)/i,Et=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;function At(t,e){return E(t,"table")&&E(11!==e.nodeType?e:e.firstChild,"tr")&&w(t).children("tbody")[0]||t}function Tt(t){return t.type=(null!==t.getAttribute("type"))+"/"+t.type,t}function Lt(t){return"true/"===(t.type||"").slice(0,5)?t.type=t.type.slice(5):t.removeAttribute("type"),t}function Mt(t,e){var n,r,i,o,s,a,c,l;if(1===e.nodeType){if(Z.hasData(t)&&(o=Z.access(t),s=Z.set(e,o),l=o.events))for(i in delete s.handle,s.events={},l)for(n=0,r=l[i].length;n<r;n++)w.event.add(e,i,l[i][n]);X.hasData(t)&&(a=X.access(t),c=w.extend({},a),X.set(e,c))}}function Rt(t,e){var n=e.nodeName.toLowerCase();"input"===n&&at.test(t.type)?e.checked=t.checked:"input"!==n&&"textarea"!==n||(e.defaultValue=t.defaultValue)}function It(t,e,n,r){e=i.apply([],e);var o,s,a,c,l,h,u=0,p=t.length,g=p-1,v=e[0],b=d(v);if(b||p>1&&"string"==typeof v&&!f.checkClone&&Ct.test(v))return t.each((function(i){var o=t.eq(i);b&&(e[0]=v.call(this,i,o.html())),It(o,e,n,r)}));if(p&&(s=(o=pt(e,t[0].ownerDocument,!1,t,r)).firstChild,1===o.childNodes.length&&(o=s),s||r)){for(c=(a=w.map(ut(o,"script"),Tt)).length;u<p;u++)l=o,u!==g&&(l=w.clone(l,!0,!0),c&&w.merge(a,ut(l,"script"))),n.call(t[u],l,u);if(c)for(h=a[a.length-1].ownerDocument,w.map(a,Lt),u=0;u<c;u++)l=a[u],lt.test(l.type||"")&&!Z.access(l,"globalEval")&&w.contains(h,l)&&(l.src&&"module"!==(l.type||"").toLowerCase()?w._evalUrl&&w._evalUrl(l.src):m(l.textContent.replace(Et,""),h,l))}return t}function Nt(t,e,n){for(var r,i=e?w.filter(e,t):t,o=0;null!=(r=i[o]);o++)n||1!==r.nodeType||w.cleanData(ut(r)),r.parentNode&&(n&&w.contains(r.ownerDocument,r)&&ft(ut(r,"script")),r.parentNode.removeChild(r));return t}w.extend({htmlPrefilter:function(t){return t.replace(_t,"<$1></$2>")},clone:function(t,e,n){var r,i,o,s,a=t.cloneNode(!0),c=w.contains(t.ownerDocument,t);if(!(f.noCloneChecked||1!==t.nodeType&&11!==t.nodeType||w.isXMLDoc(t)))for(s=ut(a),r=0,i=(o=ut(t)).length;r<i;r++)Rt(o[r],s[r]);if(e)if(n)for(o=o||ut(t),s=s||ut(a),r=0,i=o.length;r<i;r++)Mt(o[r],s[r]);else Mt(t,a);return(s=ut(a,"script")).length>0&&ft(s,!c&&ut(t,"script")),a},cleanData:function(t){for(var e,n,r,i=w.event.special,o=0;void 0!==(n=t[o]);o++)if($(n)){if(e=n[Z.expando]){if(e.events)for(r in e.events)i[r]?w.event.remove(n,r):w.removeEvent(n,r,e.handle);n[Z.expando]=void 0}n[X.expando]&&(n[X.expando]=void 0)}}}),w.fn.extend({detach:function(t){return Nt(this,t,!0)},remove:function(t){return Nt(this,t)},text:function(t){return V(this,(function(t){return void 0===t?w.text(this):this.empty().each((function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=t)}))}),null,t,arguments.length)},append:function(){return It(this,arguments,(function(t){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||At(this,t).appendChild(t)}))},prepend:function(){return It(this,arguments,(function(t){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var e=At(this,t);e.insertBefore(t,e.firstChild)}}))},before:function(){return It(this,arguments,(function(t){this.parentNode&&this.parentNode.insertBefore(t,this)}))},after:function(){return It(this,arguments,(function(t){this.parentNode&&this.parentNode.insertBefore(t,this.nextSibling)}))},empty:function(){for(var t,e=0;null!=(t=this[e]);e++)1===t.nodeType&&(w.cleanData(ut(t,!1)),t.textContent="");return this},clone:function(t,e){return t=null!=t&&t,e=null==e?t:e,this.map((function(){return w.clone(this,t,e)}))},html:function(t){return V(this,(function(t){var e=this[0]||{},n=0,r=this.length;if(void 0===t&&1===e.nodeType)return e.innerHTML;if("string"==typeof t&&!St.test(t)&&!ht[(ct.exec(t)||["",""])[1].toLowerCase()]){t=w.htmlPrefilter(t);try{for(;n<r;n++)1===(e=this[n]||{}).nodeType&&(w.cleanData(ut(e,!1)),e.innerHTML=t);e=0}catch(t){}}e&&this.empty().append(t)}),null,t,arguments.length)},replaceWith:function(){var t=[];return It(this,arguments,(function(e){var n=this.parentNode;w.inArray(this,t)<0&&(w.cleanData(ut(this)),n&&n.replaceChild(e,this))}),t)}}),w.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},(function(t,e){w.fn[t]=function(t){for(var n,r=[],i=w(t),s=i.length-1,a=0;a<=s;a++)n=a===s?this:this.clone(!0),w(i[a])[e](n),o.apply(r,n.get());return this.pushStack(r)}}));var Pt=new RegExp("^("+J+")(?!px)[a-z%]+$","i"),Ot=function(t){var e=t.ownerDocument.defaultView;return e&&e.opener||(e=window),e.getComputedStyle(t)},Ft=new RegExp(et.join("|"),"i");function Dt(t,e,n){var r,i,o,s,a=t.style;return(n=n||Ot(t))&&(""!==(s=n.getPropertyValue(e)||n[e])||w.contains(t.ownerDocument,t)||(s=w.style(t,e)),!f.pixelBoxStyles()&&Pt.test(s)&&Ft.test(e)&&(r=a.width,i=a.minWidth,o=a.maxWidth,a.minWidth=a.maxWidth=a.width=s,s=n.width,a.width=r,a.minWidth=i,a.maxWidth=o)),void 0!==s?s+"":s}function Bt(t,e){return{get:function(){if(!t())return(this.get=e).apply(this,arguments);delete this.get}}}!function(){function t(){if(l){c.style.cssText="position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0",l.style.cssText="position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%",gt.appendChild(c).appendChild(l);var t=window.getComputedStyle(l);r="1%"!==t.top,a=12===n(t.marginLeft),l.style.right="60%",s=36===n(t.right),i=36===n(t.width),l.style.position="absolute",o=36===l.offsetWidth||"absolute",gt.removeChild(c),l=null}}function n(t){return Math.round(parseFloat(t))}var r,i,o,s,a,c=e.createElement("div"),l=e.createElement("div");l.style&&(l.style.backgroundClip="content-box",l.cloneNode(!0).style.backgroundClip="",f.clearCloneStyle="content-box"===l.style.backgroundClip,w.extend(f,{boxSizingReliable:function(){return t(),i},pixelBoxStyles:function(){return t(),s},pixelPosition:function(){return t(),r},reliableMarginLeft:function(){return t(),a},scrollboxSize:function(){return t(),o}}))}();var zt,Ht,Vt=/^(none|table(?!-c[ea]).+)/,jt=/^--/,Ut={position:"absolute",visibility:"hidden",display:"block"},qt={letterSpacing:"0",fontWeight:"400"},Wt=["Webkit","Moz","ms"],$t=e.createElement("div").style;function Gt(t){var e=w.cssProps[t];return e||(e=w.cssProps[t]=function(t){if(t in $t)return t;for(var e=t[0].toUpperCase()+t.slice(1),n=Wt.length;n--;)if((t=Wt[n]+e)in $t)return t}(t)||t),e}function Zt(t,e,n){var r=tt.exec(e);return r?Math.max(0,r[2]-(n||0))+(r[3]||"px"):e}function Xt(t,e,n,r,i,o){var s="width"===e?1:0,a=0,c=0;if(n===(r?"border":"content"))return 0;for(;s<4;s+=2)"margin"===n&&(c+=w.css(t,n+et[s],!0,i)),r?("content"===n&&(c-=w.css(t,"padding"+et[s],!0,i)),"margin"!==n&&(c-=w.css(t,"border"+et[s]+"Width",!0,i))):(c+=w.css(t,"padding"+et[s],!0,i),"padding"!==n?c+=w.css(t,"border"+et[s]+"Width",!0,i):a+=w.css(t,"border"+et[s]+"Width",!0,i));return!r&&o>=0&&(c+=Math.max(0,Math.ceil(t["offset"+e[0].toUpperCase()+e.slice(1)]-o-c-a-.5))),c}function Yt(t,e,n){var r=Ot(t),i=Dt(t,e,r),o="border-box"===w.css(t,"boxSizing",!1,r),s=o;if(Pt.test(i)){if(!n)return i;i="auto"}return s=s&&(f.boxSizingReliable()||i===t.style[e]),("auto"===i||!parseFloat(i)&&"inline"===w.css(t,"display",!1,r))&&(i=t["offset"+e[0].toUpperCase()+e.slice(1)],s=!0),(i=parseFloat(i)||0)+Xt(t,e,n||(o?"border":"content"),s,r,i)+"px"}w.extend({cssHooks:{opacity:{get:function(t,e){if(e){var n=Dt(t,"opacity");return""===n?"1":n}}}},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(t,e,n,r){if(t&&3!==t.nodeType&&8!==t.nodeType&&t.style){var i,o,s,a=W(e),c=jt.test(e),l=t.style;if(c||(e=Gt(a)),s=w.cssHooks[e]||w.cssHooks[a],void 0===n)return s&&"get"in s&&void 0!==(i=s.get(t,!1,r))?i:l[e];"string"===(o=typeof n)&&(i=tt.exec(n))&&i[1]&&(n=function(t,e,n,r){var i,o,s=20,a=r?function(){return r.cur()}:function(){return w.css(t,e,"")},c=a(),l=n&&n[3]||(w.cssNumber[e]?"":"px"),h=(w.cssNumber[e]||"px"!==l&&+c)&&tt.exec(w.css(t,e));if(h&&h[3]!==l){for(c/=2,l=l||h[3],h=+c||1;s--;)w.style(t,e,h+l),(1-o)*(1-(o=a()/c||.5))<=0&&(s=0),h/=o;h*=2,w.style(t,e,h+l),n=n||[]}return n&&(h=+h||+c||0,i=n[1]?h+(n[1]+1)*n[2]:+n[2],r&&(r.unit=l,r.start=h,r.end=i)),i}(t,e,i),o="number"),null!=n&&n==n&&("number"===o&&(n+=i&&i[3]||(w.cssNumber[a]?"":"px")),f.clearCloneStyle||""!==n||0!==e.indexOf("background")||(l[e]="inherit"),s&&"set"in s&&void 0===(n=s.set(t,n,r))||(c?l.setProperty(e,n):l[e]=n))}},css:function(t,e,n,r){var i,o,s,a=W(e);return jt.test(e)||(e=Gt(a)),(s=w.cssHooks[e]||w.cssHooks[a])&&"get"in s&&(i=s.get(t,!0,n)),void 0===i&&(i=Dt(t,e,r)),"normal"===i&&e in qt&&(i=qt[e]),""===n||n?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),w.each(["height","width"],(function(t,e){w.cssHooks[e]={get:function(t,n,r){if(n)return!Vt.test(w.css(t,"display"))||t.getClientRects().length&&t.getBoundingClientRect().width?Yt(t,e,r):rt(t,Ut,(function(){return Yt(t,e,r)}))},set:function(t,n,r){var i,o=Ot(t),s="border-box"===w.css(t,"boxSizing",!1,o),a=r&&Xt(t,e,r,s,o);return s&&f.scrollboxSize()===o.position&&(a-=Math.ceil(t["offset"+e[0].toUpperCase()+e.slice(1)]-parseFloat(o[e])-Xt(t,e,"border",!1,o)-.5)),a&&(i=tt.exec(n))&&"px"!==(i[3]||"px")&&(t.style[e]=n,n=w.css(t,e)),Zt(0,n,a)}}})),w.cssHooks.marginLeft=Bt(f.reliableMarginLeft,(function(t,e){if(e)return(parseFloat(Dt(t,"marginLeft"))||t.getBoundingClientRect().left-rt(t,{marginLeft:0},(function(){return t.getBoundingClientRect().left})))+"px"})),w.each({margin:"",padding:"",border:"Width"},(function(t,e){w.cssHooks[t+e]={expand:function(n){for(var r=0,i={},o="string"==typeof n?n.split(" "):[n];r<4;r++)i[t+et[r]+e]=o[r]||o[r-2]||o[0];return i}},"margin"!==t&&(w.cssHooks[t+e].set=Zt)})),w.fn.extend({css:function(t,e){return V(this,(function(t,e,n){var r,i,o={},s=0;if(Array.isArray(e)){for(r=Ot(t),i=e.length;s<i;s++)o[e[s]]=w.css(t,e[s],!1,r);return o}return void 0!==n?w.style(t,e,n):w.css(t,e)}),t,e,arguments.length>1)}}),w.fn.delay=function(t,e){return t=w.fx&&w.fx.speeds[t]||t,e=e||"fx",this.queue(e,(function(e,n){var r=window.setTimeout(e,t);n.stop=function(){window.clearTimeout(r)}}))},zt=e.createElement("input"),Ht=e.createElement("select").appendChild(e.createElement("option")),zt.type="checkbox",f.checkOn=""!==zt.value,f.optSelected=Ht.selected,(zt=e.createElement("input")).value="t",zt.type="radio",f.radioValue="t"===zt.value;var Kt,Qt=w.expr.attrHandle;w.fn.extend({attr:function(t,e){return V(this,w.attr,t,e,arguments.length>1)},removeAttr:function(t){return this.each((function(){w.removeAttr(this,t)}))}}),w.extend({attr:function(t,e,n){var r,i,o=t.nodeType;if(3!==o&&8!==o&&2!==o)return void 0===t.getAttribute?w.prop(t,e,n):(1===o&&w.isXMLDoc(t)||(i=w.attrHooks[e.toLowerCase()]||(w.expr.match.bool.test(e)?Kt:void 0)),void 0!==n?null===n?void w.removeAttr(t,e):i&&"set"in i&&void 0!==(r=i.set(t,n,e))?r:(t.setAttribute(e,n+""),n):i&&"get"in i&&null!==(r=i.get(t,e))?r:null==(r=w.find.attr(t,e))?void 0:r)},attrHooks:{type:{set:function(t,e){if(!f.radioValue&&"radio"===e&&E(t,"input")){var n=t.value;return t.setAttribute("type",e),n&&(t.value=n),e}}}},removeAttr:function(t,e){var n,r=0,i=e&&e.match(P);if(i&&1===t.nodeType)for(;n=i[r++];)t.removeAttribute(n)}}),Kt={set:function(t,e,n){return!1===e?w.removeAttr(t,n):t.setAttribute(n,n),n}},w.each(w.expr.match.bool.source.match(/\w+/g),(function(t,e){var n=Qt[e]||w.find.attr;Qt[e]=function(t,e,r){var i,o,s=e.toLowerCase();return r||(o=Qt[s],Qt[s]=i,i=null!=n(t,e,r)?s:null,Qt[s]=o),i}}));var Jt=/^(?:input|select|textarea|button)$/i,te=/^(?:a|area)$/i;function ee(t){return(t.match(P)||[]).join(" ")}function ne(t){return t.getAttribute&&t.getAttribute("class")||""}function re(t){return Array.isArray(t)?t:"string"==typeof t&&t.match(P)||[]}w.fn.extend({prop:function(t,e){return V(this,w.prop,t,e,arguments.length>1)},removeProp:function(t){return this.each((function(){delete this[w.propFix[t]||t]}))}}),w.extend({prop:function(t,e,n){var r,i,o=t.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&w.isXMLDoc(t)||(e=w.propFix[e]||e,i=w.propHooks[e]),void 0!==n?i&&"set"in i&&void 0!==(r=i.set(t,n,e))?r:t[e]=n:i&&"get"in i&&null!==(r=i.get(t,e))?r:t[e]},propHooks:{tabIndex:{get:function(t){var e=w.find.attr(t,"tabindex");return e?parseInt(e,10):Jt.test(t.nodeName)||te.test(t.nodeName)&&t.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),f.optSelected||(w.propHooks.selected={get:function(t){var e=t.parentNode;return e&&e.parentNode&&e.parentNode.selectedIndex,null},set:function(t){var e=t.parentNode;e&&(e.selectedIndex,e.parentNode&&e.parentNode.selectedIndex)}}),w.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],(function(){w.propFix[this.toLowerCase()]=this})),w.fn.extend({addClass:function(t){var e,n,r,i,o,s,a,c=0;if(d(t))return this.each((function(e){w(this).addClass(t.call(this,e,ne(this)))}));if((e=re(t)).length)for(;n=this[c++];)if(i=ne(n),r=1===n.nodeType&&" "+ee(i)+" "){for(s=0;o=e[s++];)r.indexOf(" "+o+" ")<0&&(r+=o+" ");i!==(a=ee(r))&&n.setAttribute("class",a)}return this},removeClass:function(t){var e,n,r,i,o,s,a,c=0;if(d(t))return this.each((function(e){w(this).removeClass(t.call(this,e,ne(this)))}));if(!arguments.length)return this.attr("class","");if((e=re(t)).length)for(;n=this[c++];)if(i=ne(n),r=1===n.nodeType&&" "+ee(i)+" "){for(s=0;o=e[s++];)for(;r.indexOf(" "+o+" ")>-1;)r=r.replace(" "+o+" "," ");i!==(a=ee(r))&&n.setAttribute("class",a)}return this},toggleClass:function(t,e){var n=typeof t,r="string"===n||Array.isArray(t);return"boolean"==typeof e&&r?e?this.addClass(t):this.removeClass(t):d(t)?this.each((function(n){w(this).toggleClass(t.call(this,n,ne(this),e),e)})):this.each((function(){var e,i,o,s;if(r)for(i=0,o=w(this),s=re(t);e=s[i++];)o.hasClass(e)?o.removeClass(e):o.addClass(e);else void 0!==t&&"boolean"!==n||((e=ne(this))&&Z.set(this,"__className__",e),this.setAttribute&&this.setAttribute("class",e||!1===t?"":Z.get(this,"__className__")||""))}))},hasClass:function(t){var e,n,r=0;for(e=" "+t+" ";n=this[r++];)if(1===n.nodeType&&(" "+ee(ne(n))+" ").indexOf(e)>-1)return!0;return!1}});var ie=/\r/g;w.fn.extend({val:function(t){var e,n,r,i=this[0];return arguments.length?(r=d(t),this.each((function(n){var i;1===this.nodeType&&(null==(i=r?t.call(this,n,w(this).val()):t)?i="":"number"==typeof i?i+="":Array.isArray(i)&&(i=w.map(i,(function(t){return null==t?"":t+""}))),(e=w.valHooks[this.type]||w.valHooks[this.nodeName.toLowerCase()])&&"set"in e&&void 0!==e.set(this,i,"value")||(this.value=i))}))):i?(e=w.valHooks[i.type]||w.valHooks[i.nodeName.toLowerCase()])&&"get"in e&&void 0!==(n=e.get(i,"value"))?n:"string"==typeof(n=i.value)?n.replace(ie,""):null==n?"":n:void 0}}),w.extend({valHooks:{option:{get:function(t){var e=w.find.attr(t,"value");return null!=e?e:ee(w.text(t))}},select:{get:function(t){var e,n,r,i=t.options,o=t.selectedIndex,s="select-one"===t.type,a=s?null:[],c=s?o+1:i.length;for(r=o<0?c:s?o:0;r<c;r++)if(((n=i[r]).selected||r===o)&&!n.disabled&&(!n.parentNode.disabled||!E(n.parentNode,"optgroup"))){if(e=w(n).val(),s)return e;a.push(e)}return a},set:function(t,e){for(var n,r,i=t.options,o=w.makeArray(e),s=i.length;s--;)((r=i[s]).selected=w.inArray(w.valHooks.option.get(r),o)>-1)&&(n=!0);return n||(t.selectedIndex=-1),o}}}}),w.each(["radio","checkbox"],(function(){w.valHooks[this]={set:function(t,e){if(Array.isArray(e))return t.checked=w.inArray(w(t).val(),e)>-1}},f.checkOn||(w.valHooks[this].get=function(t){return null===t.getAttribute("value")?"on":t.value})})),f.focusin="onfocusin"in window;var oe=/^(?:focusinfocus|focusoutblur)$/,se=function(t){t.stopPropagation()};w.extend(w.event,{trigger:function(t,n,r,i){var o,s,a,c,h,u,f,g,m=[r||e],v=l.call(t,"type")?t.type:t,b=l.call(t,"namespace")?t.namespace.split("."):[];if(s=g=a=r=r||e,3!==r.nodeType&&8!==r.nodeType&&!oe.test(v+w.event.triggered)&&(v.indexOf(".")>-1&&(b=v.split("."),v=b.shift(),b.sort()),h=v.indexOf(":")<0&&"on"+v,(t=t[w.expando]?t:new w.Event(v,"object"==typeof t&&t)).isTrigger=i?2:3,t.namespace=b.join("."),t.rnamespace=t.namespace?new RegExp("(^|\\.)"+b.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=void 0,t.target||(t.target=r),n=null==n?[t]:w.makeArray(n,[t]),f=w.event.special[v]||{},i||!f.trigger||!1!==f.trigger.apply(r,n))){if(!i&&!f.noBubble&&!p(r)){for(c=f.delegateType||v,oe.test(c+v)||(s=s.parentNode);s;s=s.parentNode)m.push(s),a=s;a===(r.ownerDocument||e)&&m.push(a.defaultView||a.parentWindow||window)}for(o=0;(s=m[o++])&&!t.isPropagationStopped();)g=s,t.type=o>1?c:f.bindType||v,(u=(Z.get(s,"events")||{})[t.type]&&Z.get(s,"handle"))&&u.apply(s,n),(u=h&&s[h])&&u.apply&&$(s)&&(t.result=u.apply(s,n),!1===t.result&&t.preventDefault());return t.type=v,i||t.isDefaultPrevented()||f._default&&!1!==f._default.apply(m.pop(),n)||!$(r)||h&&d(r[v])&&!p(r)&&((a=r[h])&&(r[h]=null),w.event.triggered=v,t.isPropagationStopped()&&g.addEventListener(v,se),r[v](),t.isPropagationStopped()&&g.removeEventListener(v,se),w.event.triggered=void 0,a&&(r[h]=a)),t.result}},simulate:function(t,e,n){var r=w.extend(new w.Event,n,{type:t,isSimulated:!0});w.event.trigger(r,null,e)}}),w.fn.extend({trigger:function(t,e){return this.each((function(){w.event.trigger(t,e,this)}))},triggerHandler:function(t,e){var n=this[0];if(n)return w.event.trigger(t,e,n,!0)}}),f.focusin||w.each({focus:"focusin",blur:"focusout"},(function(t,e){var n=function(t){w.event.simulate(e,t.target,w.event.fix(t))};w.event.special[e]={setup:function(){var r=this.ownerDocument||this,i=Z.access(r,e);i||r.addEventListener(t,n,!0),Z.access(r,e,(i||0)+1)},teardown:function(){var r=this.ownerDocument||this,i=Z.access(r,e)-1;i?Z.access(r,e,i):(r.removeEventListener(t,n,!0),Z.remove(r,e))}}}));var ae,ce=/\[\]$/,le=/\r?\n/g,he=/^(?:submit|button|image|reset|file)$/i,ue=/^(?:input|select|textarea|keygen)/i;function fe(t,e,n,r){var i;if(Array.isArray(e))w.each(e,(function(e,i){n||ce.test(t)?r(t,i):fe(t+"["+("object"==typeof i&&null!=i?e:"")+"]",i,n,r)}));else if(n||"object"!==v(e))r(t,e);else for(i in e)fe(t+"["+i+"]",e[i],n,r)}w.param=function(t,e){var n,r=[],i=function(t,e){var n=d(e)?e():e;r[r.length]=encodeURIComponent(t)+"="+encodeURIComponent(null==n?"":n)};if(Array.isArray(t)||t.jquery&&!w.isPlainObject(t))w.each(t,(function(){i(this.name,this.value)}));else for(n in t)fe(n,t[n],e,i);return r.join("&")},w.fn.extend({serialize:function(){return w.param(this.serializeArray())},serializeArray:function(){return this.map((function(){var t=w.prop(this,"elements");return t?w.makeArray(t):this})).filter((function(){var t=this.type;return this.name&&!w(this).is(":disabled")&&ue.test(this.nodeName)&&!he.test(t)&&(this.checked||!at.test(t))})).map((function(t,e){var n=w(this).val();return null==n?null:Array.isArray(n)?w.map(n,(function(t){return{name:e.name,value:t.replace(le,"\r\n")}})):{name:e.name,value:n.replace(le,"\r\n")}})).get()}}),w.fn.extend({wrapAll:function(t){var e;return this[0]&&(d(t)&&(t=t.call(this[0])),e=w(t,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&e.insertBefore(this[0]),e.map((function(){for(var t=this;t.firstElementChild;)t=t.firstElementChild;return t})).append(this)),this},wrapInner:function(t){return d(t)?this.each((function(e){w(this).wrapInner(t.call(this,e))})):this.each((function(){var e=w(this),n=e.contents();n.length?n.wrapAll(t):e.append(t)}))},wrap:function(t){var e=d(t);return this.each((function(n){w(this).wrapAll(e?t.call(this,n):t)}))},unwrap:function(t){return this.parent(t).not("body").each((function(){w(this).replaceWith(this.childNodes)})),this}}),w.expr.pseudos.hidden=function(t){return!w.expr.pseudos.visible(t)},w.expr.pseudos.visible=function(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)},f.createHTMLDocument=((ae=e.implementation.createHTMLDocument("").body).innerHTML="<form></form><form></form>",2===ae.childNodes.length),w.parseHTML=function(t,n,r){return"string"!=typeof t?[]:("boolean"==typeof n&&(r=n,n=!1),n||(f.createHTMLDocument?((i=(n=e.implementation.createHTMLDocument("")).createElement("base")).href=e.location.href,n.head.appendChild(i)):n=e),s=!r&&[],(o=A.exec(t))?[n.createElement(o[1])]:(o=pt([t],n,s),s&&s.length&&w(s).remove(),w.merge([],o.childNodes)));var i,o,s},w.offset={setOffset:function(t,e,n){var r,i,o,s,a,c,l=w.css(t,"position"),h=w(t),u={};"static"===l&&(t.style.position="relative"),a=h.offset(),o=w.css(t,"top"),c=w.css(t,"left"),("absolute"===l||"fixed"===l)&&(o+c).indexOf("auto")>-1?(s=(r=h.position()).top,i=r.left):(s=parseFloat(o)||0,i=parseFloat(c)||0),d(e)&&(e=e.call(t,n,w.extend({},a))),null!=e.top&&(u.top=e.top-a.top+s),null!=e.left&&(u.left=e.left-a.left+i),"using"in e?e.using.call(t,u):h.css(u)}},w.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each((function(e){w.offset.setOffset(this,t,e)}));var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var t,e,n,r=this[0],i={top:0,left:0};if("fixed"===w.css(r,"position"))e=r.getBoundingClientRect();else{for(e=this.offset(),n=r.ownerDocument,t=r.offsetParent||n.documentElement;t&&(t===n.body||t===n.documentElement)&&"static"===w.css(t,"position");)t=t.parentNode;t&&t!==r&&1===t.nodeType&&((i=w(t).offset()).top+=w.css(t,"borderTopWidth",!0),i.left+=w.css(t,"borderLeftWidth",!0))}return{top:e.top-i.top-w.css(r,"marginTop",!0),left:e.left-i.left-w.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map((function(){for(var t=this.offsetParent;t&&"static"===w.css(t,"position");)t=t.offsetParent;return t||gt}))}}),w.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},(function(t,e){var n="pageYOffset"===e;w.fn[t]=function(r){return V(this,(function(t,r,i){var o;if(p(t)?o=t:9===t.nodeType&&(o=t.defaultView),void 0===i)return o?o[e]:t[r];o?o.scrollTo(n?o.pageXOffset:i,n?i:o.pageYOffset):t[r]=i}),t,r,arguments.length)}})),w.each(["top","left"],(function(t,e){w.cssHooks[e]=Bt(f.pixelPosition,(function(t,n){if(n)return n=Dt(t,e),Pt.test(n)?w(t).position()[e]+"px":n}))})),w.each({Height:"height",Width:"width"},(function(t,e){w.each({padding:"inner"+t,content:e,"":"outer"+t},(function(n,r){w.fn[r]=function(i,o){var s=arguments.length&&(n||"boolean"!=typeof i),a=n||(!0===i||!0===o?"margin":"border");return V(this,(function(e,n,i){var o;return p(e)?0===r.indexOf("outer")?e["inner"+t]:e.document.documentElement["client"+t]:9===e.nodeType?(o=e.documentElement,Math.max(e.body["scroll"+t],o["scroll"+t],e.body["offset"+t],o["offset"+t],o["client"+t])):void 0===i?w.css(e,n,a):w.style(e,n,i,a)}),e,s?i:void 0,s)}}))})),w.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(t,e){w.fn[e]=function(t,n){return arguments.length>0?this.on(e,null,t,n):this.trigger(e)}})),w.fn.extend({hover:function(t,e){return this.mouseenter(t).mouseleave(e||t)}}),w.fn.extend({bind:function(t,e,n){return this.on(t,null,e,n)},unbind:function(t,e){return this.off(t,null,e)},delegate:function(t,e,n,r){return this.on(e,t,n,r)},undelegate:function(t,e,n){return 1===arguments.length?this.off(t,"**"):this.off(e,t||"**",n)}}),w.proxy=function(t,e){var n,i,o;if("string"==typeof e&&(n=t[e],e=t,t=n),d(t))return i=r.call(arguments,2),o=function(){return t.apply(e||this,i.concat(r.call(arguments)))},o.guid=t.guid=t.guid||w.guid++,o},w.holdReady=function(t){t?w.readyWait++:w.ready(!0)},w.isArray=Array.isArray,w.parseJSON=JSON.parse,w.nodeName=E,w.isFunction=d,w.isWindow=p,w.camelCase=W,w.type=v,w.now=Date.now,w.isNumeric=function(t){var e=w.type(t);return("number"===e||"string"===e)&&!isNaN(t-parseFloat(t))};const de=w;function pe(t){return function(t,e){const n=document.createElement(t);e&&(e.class&&n.classList.add(e.class),e.id&&(n.id=e.id),e.style&&function(t,e){for(let n of Object.keys(e))t.style[n]=e[n]}(n,e.style));return n}("div",t)}function ge(t){const e=getComputedStyle(t);"none"!==e.display&&(t._initialDisplay=e.display),t.style.display="none"}function me(t){if(t.type.startsWith("touch")){const e=t.touches[0];return{x:e.pageX,y:e.pageY}}return{x:t.pageX,y:t.pageY}}function ve(){return("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)}function be(t,e){const{clientX:n,clientY:r}=t;return((t,{clientX:e,clientY:n})=>{const{left:r,top:i,width:o,height:s}=t.getBoundingClientRect(),a=e-r,c=n-i;return{x:a,y:c,xNormalized:a/o,yNormalized:c/s,width:o,height:s}})(e,{clientX:n,clientY:r})}function we(t,e){return function(t,e){e=e||"currentColor";let n=ye[t];n||(console.error(`No icon named: ${t}`),n=ye.question);const r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttributeNS(null,"viewBox","0 0 "+n[0]+" "+n[1]);const i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttributeNS(null,"fill",e),i.setAttributeNS(null,"d",n[4]),r.appendChild(i),r}(t,e)}const ye={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"]};function xe(t,e){var n=document.createElement("div");t.appendChild(n),n.appendChild(we("times")),n.addEventListener("click",(function(t){t.preventDefault(),t.stopPropagation(),e()}))}function ke(t){return"string"==typeof t||t instanceof String}function _e(t){var e=String(t).split(/[.,]/);return e[0].split("").reverse().reduce((function(t,e,n){return n%3==0?t+","+e:t+e})).split("").reverse().join("")+(e[1]?"."+e[1]:"")}const Se=function(t){return t.split(/\n|\r\n|\r/g)};function Ce(t,e){var n,r,i=[],o=t.length,s=0,a=!1;if(o>0)for(i[s]=t.charAt(0),n=1;n<o;n++)'"'===(r=t.charAt(n))?a=!a:a||r!==e?i[s]+=r:i[++s]="";return i}function Ee(t){return t.length>0?t.charAt(0).toUpperCase()+t.slice(1):t}function Ae(t){return t.includes("googleapis")&&!t.includes("urlshortener")||Te(t)||Le(t)}function Te(t){return t.startsWith("gs://")||t.startsWith("https://www.googleapis.com/storage")||t.startsWith("https://storage.cloud.google.com")||t.startsWith("https://storage.googleapis.com")}function Le(t){return t.indexOf("drive.google.com")>=0||t.indexOf("www.googleapis.com/drive")>0}function Me(t){let{bucket:e,object:n}=function(t){let e,n;if(t.startsWith("gs://")){const r=t.indexOf("/",5);if(r>=0){e=t.substring(5,r);const i=t.indexOf("?");n=i<0?t.substring(r+1):t.substring(r+1,i)}}else if(t.startsWith("https://storage.googleapis.com")||t.startsWith("https://storage.cloud.google.com")){const r=t.indexOf("/v1/b/",8);if(r>0){const i=t.indexOf("/o/",r);if(i>0){const o=t.indexOf("?",i);e=t.substring(r+6,i),n=o>0?t.substring(i+3,o):t.substring(i+3)}}else{const r=t.indexOf("/",8),i=t.indexOf("/",r+1),o=t.indexOf("?",i);i>0&&(e=t.substring(r+1,i),n=o<0?t.substring(i+1):t.substring(i+1,o))}}else if(t.startsWith("https://www.googleapis.com/storage/v1/b")){const r=t.indexOf("/v1/b/",8),i=t.indexOf("/o/",r);if(i>0){const o=t.indexOf("?",i);e=t.substring(r+6,i),n=o>0?t.substring(i+3,o):t.substring(i+3)}}if(e&&n)return{bucket:e,object:n};throw Error(`Unrecognized Google Storage URI: ${t}`)}(t);n=function(t){let e="";return t.split("").forEach((function(t){Ne.has(t)?e+=Ne.get(t):e+=t})),e}(n);const r=t.indexOf("?");return`https://storage.googleapis.com/storage/v1/b/${e}/o/${n}${r>0?t.substring(r)+"&alt=media":"?alt=media"}`}function Re(t){var e=Ie(t);return e?"https://www.googleapis.com/drive/v3/files/"+e+"?alt=media&supportsTeamDrives=true":t}function Ie(t){if(t.includes("/open?id=")){const e=t.indexOf("/open?id=")+9,n=t.indexOf("&");if(e>0&&n>e)return t.substring(e,n);if(e>0)return t.substring(e)}else{if(t.includes("/file/d/")){const e=t.indexOf("/file/d/")+8,n=t.lastIndexOf("/");return t.substring(e,n)}if(t.startsWith("https://www.googleapis.com/drive")){let e=t.indexOf("/files/");const n=t.indexOf("?");if(e>0)return e+=7,n>0?t.substring(e,n):t.substring(e)}}throw Error("Unknown Google Drive url format: "+t)}const Ne=new Map;Ne.set("!","%21"),Ne.set("#","%23"),Ne.set("$","%24"),Ne.set("%","%25"),Ne.set("&","%26"),Ne.set("'","%27"),Ne.set("(","%28"),Ne.set(")","%29"),Ne.set("*","%2A"),Ne.set("+","%2B"),Ne.set(",","%2C"),Ne.set("/","%2F"),Ne.set(":","%3A"),Ne.set(";","%3B"),Ne.set("=","%3D"),Ne.set("?","%3F"),Ne.set("@","%40"),Ne.set("[","%5B"),Ne.set("]","%5D"),Ne.set(" ","%20");async function Pe(t){if(Oe())return void console.warn("oAuth has already been initialized");gapi.apiKey=t.apiKey;const e=Object.assign({},t);return e.scope||(e.scope="profile"),t.client_id||(t.client_id=t.clientId),await async function(t){return new Promise((function(e,n){gapi.load(t,{callback:e,onerror:n})}))}("auth2"),new Promise((function(t,n){gapi.auth2.init(e).then(t,n)}))}function Oe(){return"undefined"!=typeof gapi&&gapi.auth2&&gapi.auth2.getAuthInstance()}let Fe=!1;async function De(t){if("undefined"==typeof gapi)throw Error("Google authentication requires the 'gapi' library");if(!gapi.auth2)throw Error("Google 'auth2' has not been initialized");if(Fe)return new Promise((function(e,n){let r;r=setInterval((()=>{try{!1===Fe&&(e(De(t)),clearInterval(r))}catch(t){clearInterval(r),n(t)}}),100)}));Fe=!0;try{let e,n=gapi.auth2.getAuthInstance().currentUser.get();if(n.isSignedIn()){n.hasGrantedScopes(t)||await n.grant({scope:t});const{access_token:r,expires_at:i}=n.getAuthResponse();if(Date.now()<i-3e5)e={access_token:r,expires_at:i};else{const{access_token:t,expires_at:r}=n.reloadAuthResponse();e={access_token:t,expires_at:r}}}else{n=await async function(t){const e=new gapi.auth2.SigninOptionsBuilder;return e.setPrompt("select_account"),e.setScope(t),gapi.auth2.getAuthInstance().signIn(e)}(t);const{access_token:r,expires_at:i}=n.getAuthResponse();e={access_token:r,expires_at:i}}return e}finally{Fe=!1}}function Be(){return gapi.apiKey}function ze(t){for(var e=He,n=e.parser.loose.exec(t),r={},i=14;i--;)r[e.key[i]]=n[i]||"";return r[e.q.name]={},r[e.key[12]].replace(e.q.parser,(function(t,n,i){n&&(r[e.q.name][n]=i)})),r}"object"==typeof process&&"undefined"==typeof window&&(global.atob=function(t){return Buffer.from(t,"base64").toString("binary")});const He={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 Ve(t){if(void 0!==t.name)return t.name;if(ke(t)){let e=t.lastIndexOf("/"),n=e<0?t:t.substr(e+1);return e=n.indexOf("?"),e>0&&(n=n.substr(0,e)),n}throw Error("Expected File or string, got "+typeof t)}function je(t){return!!t&&("function"!=typeof t&&(t instanceof File||t.hasOwnProperty("name")&&"function"==typeof t.slice&&"function"==typeof t.arrayBuffer))}const Ue=je;function qe(t,e){const n=document.createElement("a");n.setAttribute("href",e),n.setAttribute("download",t),n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n)}
|
|
26
|
+
/*! pako 2.0.4 https://github.com/nodeca/pako @license (MIT AND Zlib) */function We(t){let e=t.length;for(;--e>=0;)t[e]=0}const $e=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]),Ge=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]),Ze=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Xe=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ye=new Array(576);We(Ye);const Ke=new Array(60);We(Ke);const Qe=new Array(512);We(Qe);const Je=new Array(256);We(Je);const tn=new Array(29);We(tn);const en=new Array(30);function nn(t,e,n,r,i){this.static_tree=t,this.extra_bits=e,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=t&&t.length}let rn,on,sn;function an(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}We(en);const cn=t=>t<256?Qe[t]:Qe[256+(t>>>7)],ln=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},hn=(t,e,n)=>{t.bi_valid>16-n?(t.bi_buf|=e<<t.bi_valid&65535,ln(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=n-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=n)},un=(t,e,n)=>{hn(t,n[2*e],n[2*e+1])},fn=(t,e)=>{let n=0;do{n|=1&t,t>>>=1,n<<=1}while(--e>0);return n>>>1},dn=(t,e,n)=>{const r=new Array(16);let i,o,s=0;for(i=1;i<=15;i++)r[i]=s=s+n[i-1]<<1;for(o=0;o<=e;o++){let e=t[2*o+1];0!==e&&(t[2*o]=fn(r[e]++,e))}},pn=t=>{let e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0},gn=t=>{t.bi_valid>8?ln(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},mn=(t,e,n,r)=>{const i=2*e,o=2*n;return t[i]<t[o]||t[i]===t[o]&&r[e]<=r[n]},vn=(t,e,n)=>{const r=t.heap[n];let i=n<<1;for(;i<=t.heap_len&&(i<t.heap_len&&mn(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!mn(e,r,t.heap[i],t.depth));)t.heap[n]=t.heap[i],n=i,i<<=1;t.heap[n]=r},bn=(t,e,n)=>{let r,i,o,s,a=0;if(0!==t.last_lit)do{r=t.pending_buf[t.d_buf+2*a]<<8|t.pending_buf[t.d_buf+2*a+1],i=t.pending_buf[t.l_buf+a],a++,0===r?un(t,i,e):(o=Je[i],un(t,o+256+1,e),s=$e[o],0!==s&&(i-=tn[o],hn(t,i,s)),r--,o=cn(r),un(t,o,n),s=Ge[o],0!==s&&(r-=en[o],hn(t,r,s)))}while(a<t.last_lit);un(t,256,e)},wn=(t,e)=>{const n=e.dyn_tree,r=e.stat_desc.static_tree,i=e.stat_desc.has_stree,o=e.stat_desc.elems;let s,a,c,l=-1;for(t.heap_len=0,t.heap_max=573,s=0;s<o;s++)0!==n[2*s]?(t.heap[++t.heap_len]=l=s,t.depth[s]=0):n[2*s+1]=0;for(;t.heap_len<2;)c=t.heap[++t.heap_len]=l<2?++l:0,n[2*c]=1,t.depth[c]=0,t.opt_len--,i&&(t.static_len-=r[2*c+1]);for(e.max_code=l,s=t.heap_len>>1;s>=1;s--)vn(t,n,s);c=o;do{s=t.heap[1],t.heap[1]=t.heap[t.heap_len--],vn(t,n,1),a=t.heap[1],t.heap[--t.heap_max]=s,t.heap[--t.heap_max]=a,n[2*c]=n[2*s]+n[2*a],t.depth[c]=(t.depth[s]>=t.depth[a]?t.depth[s]:t.depth[a])+1,n[2*s+1]=n[2*a+1]=c,t.heap[1]=c++,vn(t,n,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const n=e.dyn_tree,r=e.max_code,i=e.stat_desc.static_tree,o=e.stat_desc.has_stree,s=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,c=e.stat_desc.max_length;let l,h,u,f,d,p,g=0;for(f=0;f<=15;f++)t.bl_count[f]=0;for(n[2*t.heap[t.heap_max]+1]=0,l=t.heap_max+1;l<573;l++)h=t.heap[l],f=n[2*n[2*h+1]+1]+1,f>c&&(f=c,g++),n[2*h+1]=f,h>r||(t.bl_count[f]++,d=0,h>=a&&(d=s[h-a]),p=n[2*h],t.opt_len+=p*(f+d),o&&(t.static_len+=p*(i[2*h+1]+d)));if(0!==g){do{for(f=c-1;0===t.bl_count[f];)f--;t.bl_count[f]--,t.bl_count[f+1]+=2,t.bl_count[c]--,g-=2}while(g>0);for(f=c;0!==f;f--)for(h=t.bl_count[f];0!==h;)u=t.heap[--l],u>r||(n[2*u+1]!==f&&(t.opt_len+=(f-n[2*u+1])*n[2*u],n[2*u+1]=f),h--)}})(t,e),dn(n,l,t.bl_count)},yn=(t,e,n)=>{let r,i,o=-1,s=e[1],a=0,c=7,l=4;for(0===s&&(c=138,l=3),e[2*(n+1)+1]=65535,r=0;r<=n;r++)i=s,s=e[2*(r+1)+1],++a<c&&i===s||(a<l?t.bl_tree[2*i]+=a:0!==i?(i!==o&&t.bl_tree[2*i]++,t.bl_tree[32]++):a<=10?t.bl_tree[34]++:t.bl_tree[36]++,a=0,o=i,0===s?(c=138,l=3):i===s?(c=6,l=3):(c=7,l=4))},xn=(t,e,n)=>{let r,i,o=-1,s=e[1],a=0,c=7,l=4;for(0===s&&(c=138,l=3),r=0;r<=n;r++)if(i=s,s=e[2*(r+1)+1],!(++a<c&&i===s)){if(a<l)do{un(t,i,t.bl_tree)}while(0!=--a);else 0!==i?(i!==o&&(un(t,i,t.bl_tree),a--),un(t,16,t.bl_tree),hn(t,a-3,2)):a<=10?(un(t,17,t.bl_tree),hn(t,a-3,3)):(un(t,18,t.bl_tree),hn(t,a-11,7));a=0,o=i,0===s?(c=138,l=3):i===s?(c=6,l=3):(c=7,l=4)}};let kn=!1;const _n=(t,e,n,r)=>{hn(t,0+(r?1:0),3),((t,e,n,r)=>{gn(t),r&&(ln(t,n),ln(t,~n)),t.pending_buf.set(t.window.subarray(e,e+n),t.pending),t.pending+=n})(t,e,n,!0)};var Sn=(t,e,n,r)=>{let i,o,s=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,n=4093624447;for(e=0;e<=31;e++,n>>>=1)if(1&n&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),wn(t,t.l_desc),wn(t,t.d_desc),s=(t=>{let e;for(yn(t,t.dyn_ltree,t.l_desc.max_code),yn(t,t.dyn_dtree,t.d_desc.max_code),wn(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*Xe[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),i=t.opt_len+3+7>>>3,o=t.static_len+3+7>>>3,o<=i&&(i=o)):i=o=n+5,n+4<=i&&-1!==e?_n(t,e,n,r):4===t.strategy||o===i?(hn(t,2+(r?1:0),3),bn(t,Ye,Ke)):(hn(t,4+(r?1:0),3),((t,e,n,r)=>{let i;for(hn(t,e-257,5),hn(t,n-1,5),hn(t,r-4,4),i=0;i<r;i++)hn(t,t.bl_tree[2*Xe[i]+1],3);xn(t,t.dyn_ltree,e-1),xn(t,t.dyn_dtree,n-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,s+1),bn(t,t.dyn_ltree,t.dyn_dtree)),pn(t),r&&gn(t)},Cn={_tr_init:t=>{kn||((()=>{let t,e,n,r,i;const o=new Array(16);for(n=0,r=0;r<28;r++)for(tn[r]=n,t=0;t<1<<$e[r];t++)Je[n++]=r;for(Je[n-1]=r,i=0,r=0;r<16;r++)for(en[r]=i,t=0;t<1<<Ge[r];t++)Qe[i++]=r;for(i>>=7;r<30;r++)for(en[r]=i<<7,t=0;t<1<<Ge[r]-7;t++)Qe[256+i++]=r;for(e=0;e<=15;e++)o[e]=0;for(t=0;t<=143;)Ye[2*t+1]=8,t++,o[8]++;for(;t<=255;)Ye[2*t+1]=9,t++,o[9]++;for(;t<=279;)Ye[2*t+1]=7,t++,o[7]++;for(;t<=287;)Ye[2*t+1]=8,t++,o[8]++;for(dn(Ye,287,o),t=0;t<30;t++)Ke[2*t+1]=5,Ke[2*t]=fn(t,5);rn=new nn(Ye,$e,257,286,15),on=new nn(Ke,Ge,0,30,15),sn=new nn(new Array(0),Ze,0,19,7)})(),kn=!0),t.l_desc=new an(t.dyn_ltree,rn),t.d_desc=new an(t.dyn_dtree,on),t.bl_desc=new an(t.bl_tree,sn),t.bi_buf=0,t.bi_valid=0,pn(t)},_tr_stored_block:_n,_tr_flush_block:Sn,_tr_tally:(t,e,n)=>(t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&n,t.last_lit++,0===e?t.dyn_ltree[2*n]++:(t.matches++,e--,t.dyn_ltree[2*(Je[n]+256+1)]++,t.dyn_dtree[2*cn(e)]++),t.last_lit===t.lit_bufsize-1),_tr_align:t=>{hn(t,2,3),un(t,256,Ye),(t=>{16===t.bi_valid?(ln(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}};var En=(t,e,n,r)=>{let i=65535&t|0,o=t>>>16&65535|0,s=0;for(;0!==n;){s=n>2e3?2e3:n,n-=s;do{i=i+e[r++]|0,o=o+i|0}while(--s);i%=65521,o%=65521}return i|o<<16|0};const An=new Uint32Array((()=>{let t,e=[];for(var n=0;n<256;n++){t=n;for(var r=0;r<8;r++)t=1&t?3988292384^t>>>1:t>>>1;e[n]=t}return e})());var Tn=(t,e,n,r)=>{const i=An,o=r+n;t^=-1;for(let n=r;n<o;n++)t=t>>>8^i[255&(t^e[n])];return-1^t},Ln={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"},Mn={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:Rn,_tr_stored_block:In,_tr_flush_block:Nn,_tr_tally:Pn,_tr_align:On}=Cn,{Z_NO_FLUSH:Fn,Z_PARTIAL_FLUSH:Dn,Z_FULL_FLUSH:Bn,Z_FINISH:zn,Z_BLOCK:Hn,Z_OK:Vn,Z_STREAM_END:jn,Z_STREAM_ERROR:Un,Z_DATA_ERROR:qn,Z_BUF_ERROR:Wn,Z_DEFAULT_COMPRESSION:$n,Z_FILTERED:Gn,Z_HUFFMAN_ONLY:Zn,Z_RLE:Xn,Z_FIXED:Yn,Z_DEFAULT_STRATEGY:Kn,Z_UNKNOWN:Qn,Z_DEFLATED:Jn}=Mn,tr=(t,e)=>(t.msg=Ln[e],e),er=t=>(t<<1)-(t>4?9:0),nr=t=>{let e=t.length;for(;--e>=0;)t[e]=0};let rr=(t,e,n)=>(e<<t.hash_shift^n)&t.hash_mask;const ir=t=>{const e=t.state;let n=e.pending;n>t.avail_out&&(n=t.avail_out),0!==n&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+n),t.next_out),t.next_out+=n,e.pending_out+=n,t.total_out+=n,t.avail_out-=n,e.pending-=n,0===e.pending&&(e.pending_out=0))},or=(t,e)=>{Nn(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,ir(t.strm)},sr=(t,e)=>{t.pending_buf[t.pending++]=e},ar=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},cr=(t,e,n,r)=>{let i=t.avail_in;return i>r&&(i=r),0===i?0:(t.avail_in-=i,e.set(t.input.subarray(t.next_in,t.next_in+i),n),1===t.state.wrap?t.adler=En(t.adler,e,i,n):2===t.state.wrap&&(t.adler=Tn(t.adler,e,i,n)),t.next_in+=i,t.total_in+=i,i)},lr=(t,e)=>{let n,r,i=t.max_chain_length,o=t.strstart,s=t.prev_length,a=t.nice_match;const c=t.strstart>t.w_size-262?t.strstart-(t.w_size-262):0,l=t.window,h=t.w_mask,u=t.prev,f=t.strstart+258;let d=l[o+s-1],p=l[o+s];t.prev_length>=t.good_match&&(i>>=2),a>t.lookahead&&(a=t.lookahead);do{if(n=e,l[n+s]===p&&l[n+s-1]===d&&l[n]===l[o]&&l[++n]===l[o+1]){o+=2,n++;do{}while(l[++o]===l[++n]&&l[++o]===l[++n]&&l[++o]===l[++n]&&l[++o]===l[++n]&&l[++o]===l[++n]&&l[++o]===l[++n]&&l[++o]===l[++n]&&l[++o]===l[++n]&&o<f);if(r=258-(f-o),o=f-258,r>s){if(t.match_start=e,s=r,r>=a)break;d=l[o+s-1],p=l[o+s]}}}while((e=u[e&h])>c&&0!=--i);return s<=t.lookahead?s:t.lookahead},hr=t=>{const e=t.w_size;let n,r,i,o,s;do{if(o=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-262)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,r=t.hash_size,n=r;do{i=t.head[--n],t.head[n]=i>=e?i-e:0}while(--r);r=e,n=r;do{i=t.prev[--n],t.prev[n]=i>=e?i-e:0}while(--r);o+=e}if(0===t.strm.avail_in)break;if(r=cr(t.strm,t.window,t.strstart+t.lookahead,o),t.lookahead+=r,t.lookahead+t.insert>=3)for(s=t.strstart-t.insert,t.ins_h=t.window[s],t.ins_h=rr(t,t.ins_h,t.window[s+1]);t.insert&&(t.ins_h=rr(t,t.ins_h,t.window[s+3-1]),t.prev[s&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=s,s++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<262&&0!==t.strm.avail_in)},ur=(t,e)=>{let n,r;for(;;){if(t.lookahead<262){if(hr(t),t.lookahead<262&&e===Fn)return 1;if(0===t.lookahead)break}if(n=0,t.lookahead>=3&&(t.ins_h=rr(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==n&&t.strstart-n<=t.w_size-262&&(t.match_length=lr(t,n)),t.match_length>=3)if(r=Pn(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=rr(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=rr(t,t.ins_h,t.window[t.strstart+1]);else r=Pn(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(r&&(or(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===zn?(or(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(or(t,!1),0===t.strm.avail_out)?1:2},fr=(t,e)=>{let n,r,i;for(;;){if(t.lookahead<262){if(hr(t),t.lookahead<262&&e===Fn)return 1;if(0===t.lookahead)break}if(n=0,t.lookahead>=3&&(t.ins_h=rr(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==n&&t.prev_length<t.max_lazy_match&&t.strstart-n<=t.w_size-262&&(t.match_length=lr(t,n),t.match_length<=5&&(t.strategy===Gn||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-3,r=Pn(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=rr(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,r&&(or(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(r=Pn(t,0,t.window[t.strstart-1]),r&&or(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(r=Pn(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===zn?(or(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(or(t,!1),0===t.strm.avail_out)?1:2};function dr(t,e,n,r,i){this.good_length=t,this.max_lazy=e,this.nice_length=n,this.max_chain=r,this.func=i}const pr=[new dr(0,0,0,0,((t,e)=>{let n=65535;for(n>t.pending_buf_size-5&&(n=t.pending_buf_size-5);;){if(t.lookahead<=1){if(hr(t),0===t.lookahead&&e===Fn)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;const r=t.block_start+n;if((0===t.strstart||t.strstart>=r)&&(t.lookahead=t.strstart-r,t.strstart=r,or(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-262&&(or(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===zn?(or(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(or(t,!1),t.strm.avail_out),1)})),new dr(4,4,8,4,ur),new dr(4,5,16,8,ur),new dr(4,6,32,32,ur),new dr(4,4,16,16,fr),new dr(8,16,32,32,fr),new dr(8,16,128,128,fr),new dr(8,32,128,256,fr),new dr(32,128,258,1024,fr),new dr(32,258,258,4096,fr)];function gr(){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=Jn,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),nr(this.dyn_ltree),nr(this.dyn_dtree),nr(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),nr(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),nr(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}const mr=t=>{if(!t||!t.state)return tr(t,Un);t.total_in=t.total_out=0,t.data_type=Qn;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:113,t.adler=2===e.wrap?0:1,e.last_flush=Fn,Rn(e),Vn},vr=t=>{const e=mr(t);var n;return e===Vn&&((n=t.state).window_size=2*n.w_size,nr(n.head),n.max_lazy_match=pr[n.level].max_lazy,n.good_match=pr[n.level].good_length,n.nice_match=pr[n.level].nice_length,n.max_chain_length=pr[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),e},br=(t,e,n,r,i,o)=>{if(!t)return Un;let s=1;if(e===$n&&(e=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),i<1||i>9||n!==Jn||r<8||r>15||e<0||e>9||o<0||o>Yn)return tr(t,Un);8===r&&(r=9);const a=new gr;return t.state=a,a.strm=t,a.wrap=s,a.gzhead=null,a.w_bits=r,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=i+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<<i+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Uint8Array(a.pending_buf_size),a.d_buf=1*a.lit_bufsize,a.l_buf=3*a.lit_bufsize,a.level=e,a.strategy=o,a.method=n,vr(t)};var wr=(t,e)=>{let n=e.length;if(!t||!t.state)return Un;const r=t.state,i=r.wrap;if(2===i||1===i&&42!==r.status||r.lookahead)return Un;if(1===i&&(t.adler=En(t.adler,e,n,0)),r.wrap=0,n>=r.w_size){0===i&&(nr(r.head),r.strstart=0,r.block_start=0,r.insert=0);let t=new Uint8Array(r.w_size);t.set(e.subarray(n-r.w_size,n),0),e=t,n=r.w_size}const o=t.avail_in,s=t.next_in,a=t.input;for(t.avail_in=n,t.next_in=0,t.input=e,hr(r);r.lookahead>=3;){let t=r.strstart,e=r.lookahead-2;do{r.ins_h=rr(r,r.ins_h,r.window[t+3-1]),r.prev[t&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=t,t++}while(--e);r.strstart=t,r.lookahead=2,hr(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,t.next_in=s,t.input=a,t.avail_in=o,r.wrap=i,Vn},yr={deflateInit:(t,e)=>br(t,e,Jn,15,8,Kn),deflateInit2:br,deflateReset:vr,deflateResetKeep:mr,deflateSetHeader:(t,e)=>t&&t.state?2!==t.state.wrap?Un:(t.state.gzhead=e,Vn):Un,deflate:(t,e)=>{let n,r;if(!t||!t.state||e>Hn||e<0)return t?tr(t,Un):Un;const i=t.state;if(!t.output||!t.input&&0!==t.avail_in||666===i.status&&e!==zn)return tr(t,0===t.avail_out?Wn:Un);i.strm=t;const o=i.last_flush;if(i.last_flush=e,42===i.status)if(2===i.wrap)t.adler=0,sr(i,31),sr(i,139),sr(i,8),i.gzhead?(sr(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)),sr(i,255&i.gzhead.time),sr(i,i.gzhead.time>>8&255),sr(i,i.gzhead.time>>16&255),sr(i,i.gzhead.time>>24&255),sr(i,9===i.level?2:i.strategy>=Zn||i.level<2?4:0),sr(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(sr(i,255&i.gzhead.extra.length),sr(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=Tn(t.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(sr(i,0),sr(i,0),sr(i,0),sr(i,0),sr(i,0),sr(i,9===i.level?2:i.strategy>=Zn||i.level<2?4:0),sr(i,3),i.status=113);else{let e=Jn+(i.w_bits-8<<4)<<8,n=-1;n=i.strategy>=Zn||i.level<2?0:i.level<6?1:6===i.level?2:3,e|=n<<6,0!==i.strstart&&(e|=32),e+=31-e%31,i.status=113,ar(i,e),0!==i.strstart&&(ar(i,t.adler>>>16),ar(i,65535&t.adler)),t.adler=1}if(69===i.status)if(i.gzhead.extra){for(n=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>n&&(t.adler=Tn(t.adler,i.pending_buf,i.pending-n,n)),ir(t),n=i.pending,i.pending!==i.pending_buf_size));)sr(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>n&&(t.adler=Tn(t.adler,i.pending_buf,i.pending-n,n)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(t.adler=Tn(t.adler,i.pending_buf,i.pending-n,n)),ir(t),n=i.pending,i.pending===i.pending_buf_size)){r=1;break}r=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,sr(i,r)}while(0!==r);i.gzhead.hcrc&&i.pending>n&&(t.adler=Tn(t.adler,i.pending_buf,i.pending-n,n)),0===r&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(t.adler=Tn(t.adler,i.pending_buf,i.pending-n,n)),ir(t),n=i.pending,i.pending===i.pending_buf_size)){r=1;break}r=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,sr(i,r)}while(0!==r);i.gzhead.hcrc&&i.pending>n&&(t.adler=Tn(t.adler,i.pending_buf,i.pending-n,n)),0===r&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&ir(t),i.pending+2<=i.pending_buf_size&&(sr(i,255&t.adler),sr(i,t.adler>>8&255),t.adler=0,i.status=113)):i.status=113),0!==i.pending){if(ir(t),0===t.avail_out)return i.last_flush=-1,Vn}else if(0===t.avail_in&&er(e)<=er(o)&&e!==zn)return tr(t,Wn);if(666===i.status&&0!==t.avail_in)return tr(t,Wn);if(0!==t.avail_in||0!==i.lookahead||e!==Fn&&666!==i.status){let n=i.strategy===Zn?((t,e)=>{let n;for(;;){if(0===t.lookahead&&(hr(t),0===t.lookahead)){if(e===Fn)return 1;break}if(t.match_length=0,n=Pn(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,n&&(or(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===zn?(or(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(or(t,!1),0===t.strm.avail_out)?1:2})(i,e):i.strategy===Xn?((t,e)=>{let n,r,i,o;const s=t.window;for(;;){if(t.lookahead<=258){if(hr(t),t.lookahead<=258&&e===Fn)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(i=t.strstart-1,r=s[i],r===s[++i]&&r===s[++i]&&r===s[++i])){o=t.strstart+258;do{}while(r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&i<o);t.match_length=258-(o-i),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(n=Pn(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(n=Pn(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),n&&(or(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===zn?(or(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(or(t,!1),0===t.strm.avail_out)?1:2})(i,e):pr[i.level].func(i,e);if(3!==n&&4!==n||(i.status=666),1===n||3===n)return 0===t.avail_out&&(i.last_flush=-1),Vn;if(2===n&&(e===Dn?On(i):e!==Hn&&(In(i,0,0,!1),e===Bn&&(nr(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),ir(t),0===t.avail_out))return i.last_flush=-1,Vn}return e!==zn?Vn:i.wrap<=0?jn:(2===i.wrap?(sr(i,255&t.adler),sr(i,t.adler>>8&255),sr(i,t.adler>>16&255),sr(i,t.adler>>24&255),sr(i,255&t.total_in),sr(i,t.total_in>>8&255),sr(i,t.total_in>>16&255),sr(i,t.total_in>>24&255)):(ar(i,t.adler>>>16),ar(i,65535&t.adler)),ir(t),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?Vn:jn)},deflateEnd:t=>{if(!t||!t.state)return Un;const e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&103!==e&&113!==e&&666!==e?tr(t,Un):(t.state=null,113===e?tr(t,qn):Vn)},deflateSetDictionary:wr,deflateInfo:"pako deflate (from Nodeca project)"};const xr=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var kr=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const n=e.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const e in n)xr(n,e)&&(t[e]=n[e])}}return t},_r=t=>{let e=0;for(let n=0,r=t.length;n<r;n++)e+=t[n].length;const n=new Uint8Array(e);for(let e=0,r=0,i=t.length;e<i;e++){let i=t[e];n.set(i,r),r+=i.length}return n};let Sr=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(sd){Sr=!1}const Cr=new Uint8Array(256);for(let ad=0;ad<256;ad++)Cr[ad]=ad>=252?6:ad>=248?5:ad>=240?4:ad>=224?3:ad>=192?2:1;Cr[254]=Cr[254]=1;var Er=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,n,r,i,o,s=t.length,a=0;for(i=0;i<s;i++)n=t.charCodeAt(i),55296==(64512&n)&&i+1<s&&(r=t.charCodeAt(i+1),56320==(64512&r)&&(n=65536+(n-55296<<10)+(r-56320),i++)),a+=n<128?1:n<2048?2:n<65536?3:4;for(e=new Uint8Array(a),o=0,i=0;o<a;i++)n=t.charCodeAt(i),55296==(64512&n)&&i+1<s&&(r=t.charCodeAt(i+1),56320==(64512&r)&&(n=65536+(n-55296<<10)+(r-56320),i++)),n<128?e[o++]=n:n<2048?(e[o++]=192|n>>>6,e[o++]=128|63&n):n<65536?(e[o++]=224|n>>>12,e[o++]=128|n>>>6&63,e[o++]=128|63&n):(e[o++]=240|n>>>18,e[o++]=128|n>>>12&63,e[o++]=128|n>>>6&63,e[o++]=128|63&n);return e},Ar=(t,e)=>{const n=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let r,i;const o=new Array(2*n);for(i=0,r=0;r<n;){let e=t[r++];if(e<128){o[i++]=e;continue}let s=Cr[e];if(s>4)o[i++]=65533,r+=s-1;else{for(e&=2===s?31:3===s?15:7;s>1&&r<n;)e=e<<6|63&t[r++],s--;s>1?o[i++]=65533:e<65536?o[i++]=e:(e-=65536,o[i++]=55296|e>>10&1023,o[i++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&Sr)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let n="";for(let r=0;r<e;r++)n+=String.fromCharCode(t[r]);return n})(o,i)},Tr=(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let n=e-1;for(;n>=0&&128==(192&t[n]);)n--;return n<0||0===n?e:n+Cr[t[n]]>e?n:e};var Lr=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 Mr=Object.prototype.toString,{Z_NO_FLUSH:Rr,Z_SYNC_FLUSH:Ir,Z_FULL_FLUSH:Nr,Z_FINISH:Pr,Z_OK:Or,Z_STREAM_END:Fr,Z_DEFAULT_COMPRESSION:Dr,Z_DEFAULT_STRATEGY:Br,Z_DEFLATED:zr}=Mn;function Hr(t){this.options=kr({level:Dr,method:zr,chunkSize:16384,windowBits:15,memLevel:8,strategy:Br},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Lr,this.strm.avail_out=0;let n=yr.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(n!==Or)throw new Error(Ln[n]);if(e.header&&yr.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Er(e.dictionary):"[object ArrayBuffer]"===Mr.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,n=yr.deflateSetDictionary(this.strm,t),n!==Or)throw new Error(Ln[n]);this._dict_set=!0}}function Vr(t,e){const n=new Hr(e);if(n.push(t,!0),n.err)throw n.msg||Ln[n.err];return n.result}Hr.prototype.push=function(t,e){const n=this.strm,r=this.options.chunkSize;let i,o;if(this.ended)return!1;for(o=e===~~e?e:!0===e?Pr:Rr,"string"==typeof t?n.input=Er(t):"[object ArrayBuffer]"===Mr.call(t)?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(o===Ir||o===Nr)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(i=yr.deflate(n,o),i===Fr)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=yr.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Or;if(0!==n.avail_out){if(o>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},Hr.prototype.onData=function(t){this.chunks.push(t)},Hr.prototype.onEnd=function(t){t===Or&&(this.result=_r(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var jr=function(t,e){return(e=e||{}).raw=!0,Vr(t,e)},Ur=function(t,e){return(e=e||{}).gzip=!0,Vr(t,e)},qr={Deflate:Hr,deflate:Vr,deflateRaw:jr,gzip:Ur,constants:Mn};var Wr=function(t,e){let n,r,i,o,s,a,c,l,h,u,f,d,p,g,m,v,b,w,y,x,k,_,S,C;const E=t.state;n=t.next_in,S=t.input,r=n+(t.avail_in-5),i=t.next_out,C=t.output,o=i-(e-t.avail_out),s=i+(t.avail_out-257),a=E.dmax,c=E.wsize,l=E.whave,h=E.wnext,u=E.window,f=E.hold,d=E.bits,p=E.lencode,g=E.distcode,m=(1<<E.lenbits)-1,v=(1<<E.distbits)-1;t:do{d<15&&(f+=S[n++]<<d,d+=8,f+=S[n++]<<d,d+=8),b=p[f&m];e:for(;;){if(w=b>>>24,f>>>=w,d-=w,w=b>>>16&255,0===w)C[i++]=65535&b;else{if(!(16&w)){if(0==(64&w)){b=p[(65535&b)+(f&(1<<w)-1)];continue e}if(32&w){E.mode=12;break t}t.msg="invalid literal/length code",E.mode=30;break t}y=65535&b,w&=15,w&&(d<w&&(f+=S[n++]<<d,d+=8),y+=f&(1<<w)-1,f>>>=w,d-=w),d<15&&(f+=S[n++]<<d,d+=8,f+=S[n++]<<d,d+=8),b=g[f&v];n:for(;;){if(w=b>>>24,f>>>=w,d-=w,w=b>>>16&255,!(16&w)){if(0==(64&w)){b=g[(65535&b)+(f&(1<<w)-1)];continue n}t.msg="invalid distance code",E.mode=30;break t}if(x=65535&b,w&=15,d<w&&(f+=S[n++]<<d,d+=8,d<w&&(f+=S[n++]<<d,d+=8)),x+=f&(1<<w)-1,x>a){t.msg="invalid distance too far back",E.mode=30;break t}if(f>>>=w,d-=w,w=i-o,x>w){if(w=x-w,w>l&&E.sane){t.msg="invalid distance too far back",E.mode=30;break t}if(k=0,_=u,0===h){if(k+=c-w,w<y){y-=w;do{C[i++]=u[k++]}while(--w);k=i-x,_=C}}else if(h<w){if(k+=c+h-w,w-=h,w<y){y-=w;do{C[i++]=u[k++]}while(--w);if(k=0,h<y){w=h,y-=w;do{C[i++]=u[k++]}while(--w);k=i-x,_=C}}}else if(k+=h-w,w<y){y-=w;do{C[i++]=u[k++]}while(--w);k=i-x,_=C}for(;y>2;)C[i++]=_[k++],C[i++]=_[k++],C[i++]=_[k++],y-=3;y&&(C[i++]=_[k++],y>1&&(C[i++]=_[k++]))}else{k=i-x;do{C[i++]=C[k++],C[i++]=C[k++],C[i++]=C[k++],y-=3}while(y>2);y&&(C[i++]=C[k++],y>1&&(C[i++]=C[k++]))}break}}break}}while(n<r&&i<s);y=d>>3,n-=y,d-=y<<3,f&=(1<<d)-1,t.next_in=n,t.next_out=i,t.avail_in=n<r?r-n+5:5-(n-r),t.avail_out=i<s?s-i+257:257-(i-s),E.hold=f,E.bits=d};const $r=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]),Gr=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]),Zr=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]),Xr=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 Yr=(t,e,n,r,i,o,s,a)=>{const c=a.bits;let l,h,u,f,d,p,g=0,m=0,v=0,b=0,w=0,y=0,x=0,k=0,_=0,S=0,C=null,E=0;const A=new Uint16Array(16),T=new Uint16Array(16);let L,M,R,I=null,N=0;for(g=0;g<=15;g++)A[g]=0;for(m=0;m<r;m++)A[e[n+m]]++;for(w=c,b=15;b>=1&&0===A[b];b--);if(w>b&&(w=b),0===b)return i[o++]=20971520,i[o++]=20971520,a.bits=1,0;for(v=1;v<b&&0===A[v];v++);for(w<v&&(w=v),k=1,g=1;g<=15;g++)if(k<<=1,k-=A[g],k<0)return-1;if(k>0&&(0===t||1!==b))return-1;for(T[1]=0,g=1;g<15;g++)T[g+1]=T[g]+A[g];for(m=0;m<r;m++)0!==e[n+m]&&(s[T[e[n+m]]++]=m);if(0===t?(C=I=s,p=19):1===t?(C=$r,E-=257,I=Gr,N-=257,p=256):(C=Zr,I=Xr,p=-1),S=0,m=0,g=v,d=o,y=w,x=0,u=-1,_=1<<w,f=_-1,1===t&&_>852||2===t&&_>592)return 1;for(;;){L=g-x,s[m]<p?(M=0,R=s[m]):s[m]>p?(M=I[N+s[m]],R=C[E+s[m]]):(M=96,R=0),l=1<<g-x,h=1<<y,v=h;do{h-=l,i[d+(S>>x)+h]=L<<24|M<<16|R|0}while(0!==h);for(l=1<<g-1;S&l;)l>>=1;if(0!==l?(S&=l-1,S+=l):S=0,m++,0==--A[g]){if(g===b)break;g=e[n+s[m]]}if(g>w&&(S&f)!==u){for(0===x&&(x=w),d+=v,y=g-x,k=1<<y;y+x<b&&(k-=A[y+x],!(k<=0));)y++,k<<=1;if(_+=1<<y,1===t&&_>852||2===t&&_>592)return 1;u=S&f,i[u]=w<<24|y<<16|d-o|0}}return 0!==S&&(i[d+S]=g-x<<24|64<<16|0),a.bits=w,0};const{Z_FINISH:Kr,Z_BLOCK:Qr,Z_TREES:Jr,Z_OK:ti,Z_STREAM_END:ei,Z_NEED_DICT:ni,Z_STREAM_ERROR:ri,Z_DATA_ERROR:ii,Z_MEM_ERROR:oi,Z_BUF_ERROR:si,Z_DEFLATED:ai}=Mn,ci=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function li(){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 hi=t=>{if(!t||!t.state)return ri;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,ti},ui=t=>{if(!t||!t.state)return ri;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,hi(t)},fi=(t,e)=>{let n;if(!t||!t.state)return ri;const r=t.state;return e<0?(n=0,e=-e):(n=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?ri:(null!==r.window&&r.wbits!==e&&(r.window=null),r.wrap=n,r.wbits=e,ui(t))},di=(t,e)=>{if(!t)return ri;const n=new li;t.state=n,n.window=null;const r=fi(t,e);return r!==ti&&(t.state=null),r};let pi,gi,mi=!0;const vi=t=>{if(mi){pi=new Int32Array(512),gi=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(Yr(1,t.lens,0,288,pi,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;Yr(2,t.lens,0,32,gi,0,t.work,{bits:5}),mi=!1}t.lencode=pi,t.lenbits=9,t.distcode=gi,t.distbits=5},bi=(t,e,n,r)=>{let i;const o=t.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new Uint8Array(o.wsize)),r>=o.wsize?(o.window.set(e.subarray(n-o.wsize,n),0),o.wnext=0,o.whave=o.wsize):(i=o.wsize-o.wnext,i>r&&(i=r),o.window.set(e.subarray(n-r,n-r+i),o.wnext),(r-=i)?(o.window.set(e.subarray(n-r,n),0),o.wnext=r,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=i))),0};var wi=(t,e)=>{let n,r,i,o,s,a,c,l,h,u,f,d,p,g,m,v,b,w,y,x,k,_,S=0;const C=new Uint8Array(4);let E,A;const T=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return ri;n=t.state,12===n.mode&&(n.mode=13),s=t.next_out,i=t.output,c=t.avail_out,o=t.next_in,r=t.input,a=t.avail_in,l=n.hold,h=n.bits,u=a,f=c,_=ti;t:for(;;)switch(n.mode){case 1:if(0===n.wrap){n.mode=13;break}for(;h<16;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}if(2&n.wrap&&35615===l){n.check=0,C[0]=255&l,C[1]=l>>>8&255,n.check=Tn(n.check,C,2,0),l=0,h=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&l)<<8)+(l>>8))%31){t.msg="incorrect header check",n.mode=30;break}if((15&l)!==ai){t.msg="unknown compression method",n.mode=30;break}if(l>>>=4,h-=4,k=8+(15&l),0===n.wbits)n.wbits=k;else if(k>n.wbits){t.msg="invalid window size",n.mode=30;break}n.dmax=1<<n.wbits,t.adler=n.check=1,n.mode=512&l?10:12,l=0,h=0;break;case 2:for(;h<16;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}if(n.flags=l,(255&n.flags)!==ai){t.msg="unknown compression method",n.mode=30;break}if(57344&n.flags){t.msg="unknown header flags set",n.mode=30;break}n.head&&(n.head.text=l>>8&1),512&n.flags&&(C[0]=255&l,C[1]=l>>>8&255,n.check=Tn(n.check,C,2,0)),l=0,h=0,n.mode=3;case 3:for(;h<32;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}n.head&&(n.head.time=l),512&n.flags&&(C[0]=255&l,C[1]=l>>>8&255,C[2]=l>>>16&255,C[3]=l>>>24&255,n.check=Tn(n.check,C,4,0)),l=0,h=0,n.mode=4;case 4:for(;h<16;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}n.head&&(n.head.xflags=255&l,n.head.os=l>>8),512&n.flags&&(C[0]=255&l,C[1]=l>>>8&255,n.check=Tn(n.check,C,2,0)),l=0,h=0,n.mode=5;case 5:if(1024&n.flags){for(;h<16;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}n.length=l,n.head&&(n.head.extra_len=l),512&n.flags&&(C[0]=255&l,C[1]=l>>>8&255,n.check=Tn(n.check,C,2,0)),l=0,h=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&(d=n.length,d>a&&(d=a),d&&(n.head&&(k=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(o,o+d),k)),512&n.flags&&(n.check=Tn(n.check,r,d,o)),a-=d,o+=d,n.length-=d),n.length))break t;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===a)break t;d=0;do{k=r[o+d++],n.head&&k&&n.length<65536&&(n.head.name+=String.fromCharCode(k))}while(k&&d<a);if(512&n.flags&&(n.check=Tn(n.check,r,d,o)),a-=d,o+=d,k)break t}else n.head&&(n.head.name=null);n.length=0,n.mode=8;case 8:if(4096&n.flags){if(0===a)break t;d=0;do{k=r[o+d++],n.head&&k&&n.length<65536&&(n.head.comment+=String.fromCharCode(k))}while(k&&d<a);if(512&n.flags&&(n.check=Tn(n.check,r,d,o)),a-=d,o+=d,k)break t}else n.head&&(n.head.comment=null);n.mode=9;case 9:if(512&n.flags){for(;h<16;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}if(l!==(65535&n.check)){t.msg="header crc mismatch",n.mode=30;break}l=0,h=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),t.adler=n.check=0,n.mode=12;break;case 10:for(;h<32;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}t.adler=n.check=ci(l),l=0,h=0,n.mode=11;case 11:if(0===n.havedict)return t.next_out=s,t.avail_out=c,t.next_in=o,t.avail_in=a,n.hold=l,n.bits=h,ni;t.adler=n.check=1,n.mode=12;case 12:if(e===Qr||e===Jr)break t;case 13:if(n.last){l>>>=7&h,h-=7&h,n.mode=27;break}for(;h<3;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}switch(n.last=1&l,l>>>=1,h-=1,3&l){case 0:n.mode=14;break;case 1:if(vi(n),n.mode=20,e===Jr){l>>>=2,h-=2;break t}break;case 2:n.mode=17;break;case 3:t.msg="invalid block type",n.mode=30}l>>>=2,h-=2;break;case 14:for(l>>>=7&h,h-=7&h;h<32;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}if((65535&l)!=(l>>>16^65535)){t.msg="invalid stored block lengths",n.mode=30;break}if(n.length=65535&l,l=0,h=0,n.mode=15,e===Jr)break t;case 15:n.mode=16;case 16:if(d=n.length,d){if(d>a&&(d=a),d>c&&(d=c),0===d)break t;i.set(r.subarray(o,o+d),s),a-=d,o+=d,c-=d,s+=d,n.length-=d;break}n.mode=12;break;case 17:for(;h<14;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}if(n.nlen=257+(31&l),l>>>=5,h-=5,n.ndist=1+(31&l),l>>>=5,h-=5,n.ncode=4+(15&l),l>>>=4,h-=4,n.nlen>286||n.ndist>30){t.msg="too many length or distance symbols",n.mode=30;break}n.have=0,n.mode=18;case 18:for(;n.have<n.ncode;){for(;h<3;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}n.lens[T[n.have++]]=7&l,l>>>=3,h-=3}for(;n.have<19;)n.lens[T[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,E={bits:n.lenbits},_=Yr(0,n.lens,0,19,n.lencode,0,n.work,E),n.lenbits=E.bits,_){t.msg="invalid code lengths set",n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have<n.nlen+n.ndist;){for(;S=n.lencode[l&(1<<n.lenbits)-1],m=S>>>24,v=S>>>16&255,b=65535&S,!(m<=h);){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}if(b<16)l>>>=m,h-=m,n.lens[n.have++]=b;else{if(16===b){for(A=m+2;h<A;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}if(l>>>=m,h-=m,0===n.have){t.msg="invalid bit length repeat",n.mode=30;break}k=n.lens[n.have-1],d=3+(3&l),l>>>=2,h-=2}else if(17===b){for(A=m+3;h<A;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}l>>>=m,h-=m,k=0,d=3+(7&l),l>>>=3,h-=3}else{for(A=m+7;h<A;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}l>>>=m,h-=m,k=0,d=11+(127&l),l>>>=7,h-=7}if(n.have+d>n.nlen+n.ndist){t.msg="invalid bit length repeat",n.mode=30;break}for(;d--;)n.lens[n.have++]=k}}if(30===n.mode)break;if(0===n.lens[256]){t.msg="invalid code -- missing end-of-block",n.mode=30;break}if(n.lenbits=9,E={bits:n.lenbits},_=Yr(1,n.lens,0,n.nlen,n.lencode,0,n.work,E),n.lenbits=E.bits,_){t.msg="invalid literal/lengths set",n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,E={bits:n.distbits},_=Yr(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,E),n.distbits=E.bits,_){t.msg="invalid distances set",n.mode=30;break}if(n.mode=20,e===Jr)break t;case 20:n.mode=21;case 21:if(a>=6&&c>=258){t.next_out=s,t.avail_out=c,t.next_in=o,t.avail_in=a,n.hold=l,n.bits=h,Wr(t,f),s=t.next_out,i=t.output,c=t.avail_out,o=t.next_in,r=t.input,a=t.avail_in,l=n.hold,h=n.bits,12===n.mode&&(n.back=-1);break}for(n.back=0;S=n.lencode[l&(1<<n.lenbits)-1],m=S>>>24,v=S>>>16&255,b=65535&S,!(m<=h);){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}if(v&&0==(240&v)){for(w=m,y=v,x=b;S=n.lencode[x+((l&(1<<w+y)-1)>>w)],m=S>>>24,v=S>>>16&255,b=65535&S,!(w+m<=h);){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}l>>>=w,h-=w,n.back+=w}if(l>>>=m,h-=m,n.back+=m,n.length=b,0===v){n.mode=26;break}if(32&v){n.back=-1,n.mode=12;break}if(64&v){t.msg="invalid literal/length code",n.mode=30;break}n.extra=15&v,n.mode=22;case 22:if(n.extra){for(A=n.extra;h<A;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}n.length+=l&(1<<n.extra)-1,l>>>=n.extra,h-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;S=n.distcode[l&(1<<n.distbits)-1],m=S>>>24,v=S>>>16&255,b=65535&S,!(m<=h);){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}if(0==(240&v)){for(w=m,y=v,x=b;S=n.distcode[x+((l&(1<<w+y)-1)>>w)],m=S>>>24,v=S>>>16&255,b=65535&S,!(w+m<=h);){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}l>>>=w,h-=w,n.back+=w}if(l>>>=m,h-=m,n.back+=m,64&v){t.msg="invalid distance code",n.mode=30;break}n.offset=b,n.extra=15&v,n.mode=24;case 24:if(n.extra){for(A=n.extra;h<A;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}n.offset+=l&(1<<n.extra)-1,l>>>=n.extra,h-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){t.msg="invalid distance too far back",n.mode=30;break}n.mode=25;case 25:if(0===c)break t;if(d=f-c,n.offset>d){if(d=n.offset-d,d>n.whave&&n.sane){t.msg="invalid distance too far back",n.mode=30;break}d>n.wnext?(d-=n.wnext,p=n.wsize-d):p=n.wnext-d,d>n.length&&(d=n.length),g=n.window}else g=i,p=s-n.offset,d=n.length;d>c&&(d=c),c-=d,n.length-=d;do{i[s++]=g[p++]}while(--d);0===n.length&&(n.mode=21);break;case 26:if(0===c)break t;i[s++]=n.length,c--,n.mode=21;break;case 27:if(n.wrap){for(;h<32;){if(0===a)break t;a--,l|=r[o++]<<h,h+=8}if(f-=c,t.total_out+=f,n.total+=f,f&&(t.adler=n.check=n.flags?Tn(n.check,i,f,s-f):En(n.check,i,f,s-f)),f=c,(n.flags?l:ci(l))!==n.check){t.msg="incorrect data check",n.mode=30;break}l=0,h=0}n.mode=28;case 28:if(n.wrap&&n.flags){for(;h<32;){if(0===a)break t;a--,l+=r[o++]<<h,h+=8}if(l!==(4294967295&n.total)){t.msg="incorrect length check",n.mode=30;break}l=0,h=0}n.mode=29;case 29:_=ei;break t;case 30:_=ii;break t;case 31:return oi;default:return ri}return t.next_out=s,t.avail_out=c,t.next_in=o,t.avail_in=a,n.hold=l,n.bits=h,(n.wsize||f!==t.avail_out&&n.mode<30&&(n.mode<27||e!==Kr))&&bi(t,t.output,t.next_out,f-t.avail_out),u-=t.avail_in,f-=t.avail_out,t.total_in+=u,t.total_out+=f,n.total+=f,n.wrap&&f&&(t.adler=n.check=n.flags?Tn(n.check,i,f,t.next_out-f):En(n.check,i,f,t.next_out-f)),t.data_type=n.bits+(n.last?64:0)+(12===n.mode?128:0)+(20===n.mode||15===n.mode?256:0),(0===u&&0===f||e===Kr)&&_===ti&&(_=si),_},yi={inflateReset:ui,inflateReset2:fi,inflateResetKeep:hi,inflateInit:t=>di(t,15),inflateInit2:di,inflate:wi,inflateEnd:t=>{if(!t||!t.state)return ri;let e=t.state;return e.window&&(e.window=null),t.state=null,ti},inflateGetHeader:(t,e)=>{if(!t||!t.state)return ri;const n=t.state;return 0==(2&n.wrap)?ri:(n.head=e,e.done=!1,ti)},inflateSetDictionary:(t,e)=>{const n=e.length;let r,i,o;return t&&t.state?(r=t.state,0!==r.wrap&&11!==r.mode?ri:11===r.mode&&(i=1,i=En(i,e,n,0),i!==r.check)?ii:(o=bi(t,e,n,n),o?(r.mode=31,oi):(r.havedict=1,ti))):ri},inflateInfo:"pako inflate (from Nodeca project)"};var xi=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 ki=Object.prototype.toString,{Z_NO_FLUSH:_i,Z_FINISH:Si,Z_OK:Ci,Z_STREAM_END:Ei,Z_NEED_DICT:Ai,Z_STREAM_ERROR:Ti,Z_DATA_ERROR:Li,Z_MEM_ERROR:Mi}=Mn;function Ri(t){this.options=kr({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Lr,this.strm.avail_out=0;let n=yi.inflateInit2(this.strm,e.windowBits);if(n!==Ci)throw new Error(Ln[n]);if(this.header=new xi,yi.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Er(e.dictionary):"[object ArrayBuffer]"===ki.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(n=yi.inflateSetDictionary(this.strm,e.dictionary),n!==Ci)))throw new Error(Ln[n])}function Ii(t,e){const n=new Ri(e);if(n.push(t),n.err)throw n.msg||Ln[n.err];return n.result}Ri.prototype.push=function(t,e){const n=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let o,s,a;if(this.ended)return!1;for(s=e===~~e?e:!0===e?Si:_i,"[object ArrayBuffer]"===ki.call(t)?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),o=yi.inflate(n,s),o===Ai&&i&&(o=yi.inflateSetDictionary(n,i),o===Ci?o=yi.inflate(n,s):o===Li&&(o=Ai));n.avail_in>0&&o===Ei&&n.state.wrap>0&&0!==t[n.next_in];)yi.inflateReset(n),o=yi.inflate(n,s);switch(o){case Ti:case Li:case Ai:case Mi:return this.onEnd(o),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(0===n.avail_out||o===Ei))if("string"===this.options.to){let t=Tr(n.output,n.next_out),e=n.next_out-t,i=Ar(n.output,t);n.next_out=e,n.avail_out=r-e,e&&n.output.set(n.output.subarray(t,t+e),0),this.onData(i)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(o!==Ci||0!==a){if(o===Ei)return o=yi.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Ri.prototype.onData=function(t){this.chunks.push(t)},Ri.prototype.onEnd=function(t){t===Ci&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=_r(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Ni=function(t,e){return(e=e||{}).raw=!0,Ii(t,e)},Pi={Inflate:Ri,inflate:Ii,inflateRaw:Ni,ungzip:Ii,constants:Mn};const{Deflate:Oi,deflate:Fi,deflateRaw:Di,gzip:Bi}=qr,{Inflate:zi,inflate:Hi,inflateRaw:Vi,ungzip:ji}=Pi;var Ui={Deflate:Oi,deflate:Fi,deflateRaw:Di,gzip:Bi,Inflate:zi,inflate:Hi,inflateRaw:Vi,ungzip:ji,constants:Mn};Ui.deflateRaw,Ui.deflate,Ui.inflateRaw;const qi=Ui.inflate;Ui.gzip;function Wi(t,e){const n=[];let r=0,i=0;for(e=e||t.byteLength-18;r<e;)try{const e=ArrayBuffer.isView(t)?t:new Uint8Array(t,r,18),o=e[11]<<8|e[10],s=(e[3],e[12],e[13],e[15],e[14],1+(e[17]<<8|e[16])),a=12+o+r,c=t.byteLength-a,l=s-o-19;if(c<l||l<=0)break;const h=new Uint8Array(t,a,l),u=Ui.inflateRaw(h);r+=l-1+26,i+=u.byteLength,n.push(u)}catch(t){console.error(t);break}if(1===n.length)return n[0];{const t=new Uint8Array(i);let e=0;for(let r=0;r<n.length;++r){var o=new Uint8Array(n[r]);Zi(o,0,t,e,o.length),e+=o.length}return t}}function $i(t){const e=ArrayBuffer.isView(t)?t:new Uint8Array(t);return 1+(e[17]<<8|e[16])}const Gi="function"==typeof new Uint8Array(1).subarray;function Zi(t,e,n,r,i){if(0!==i){if(!t)throw"Undef src";if(!n)throw"Undef dest";0===e&&i===t.length?Xi(t,n,r):Gi?Xi(t.subarray(e,e+i),n,r):1===t.BYTES_PER_ELEMENT&&i>100?Xi(new Uint8Array(t.buffer,t.byteOffset+e,i),n,r):function(t,e,n,r,i){for(let o=0;o<i;++o)n[r+o]=t[e+o]}(t,e,n,r,i)}}function Xi(t,e,n){e.set(t,n)}function Yi(t,e){const n=t.split(","),r=n[0].split(":")[1];let i=n[1];if(r.indexOf("base64")>=0){i=atob(i);const t=new Uint8Array(i.length);for(let e=0;e<i.length;e++)t[e]=i.charCodeAt(e);let n;return n=e||r.indexOf("gzip")>0?Ui.ungzip(t):t,n}return decodeURIComponent(i)}const Ki=function(t,e){if(0!==t.length){var n=Math.floor(t.length*((100-e)/100));return 0===n?(t.sort((function(t,e){return e-t})),t[n]):function(t,e){var n,r=new to;for(n=0;n<t.length;n++){var i=t[n];(r.content.length<e||i>r.content[0])&&(r.content.length===e&&r.pop(),r.push(i))}return r.content[0]}(t,n)}},Qi=function(t,e,n){return Math.min(Math.max(t,e),n)},Ji=function(t){return Math.log(t)/Math.LN2};function to(){this.content=[]}function eo(t,e){return Math.random()*(e-t)+t}to.prototype={push:function(t){this.content.push(t),this.bubbleUp(this.content.length-1)},pop:function(){var t=this.content[0],e=this.content.pop();return this.content.length>0&&(this.content[0]=e,this.sinkDown(0)),t},remove:function(t){for(var e=this.content.length,n=0;n<e;n++)if(this.content[n]===t){var r=this.content.pop();if(n===e-1)break;this.content[n]=r,this.bubbleUp(n),this.sinkDown(n);break}},size:function(){return this.content.length},bubbleUp:function(t){for(var e=this.content[t],n=e;t>0;){var r=Math.floor((t+1)/2)-1,i=this.content[r];if(n>=i)break;this.content[r]=e,this.content[t]=i,t=r}},sinkDown:function(t){for(var e=this.content.length,n=this.content[t],r=n;;){var i=2*(t+1),o=i-1,s=null;if(o<e){var a=this.content[o],c=a;a<r&&(s=o)}if(i<e)this.content[i]<(null==s?r:c)&&(s=i);if(null==s)break;this.content[t]=this.content[s],this.content[s]=n,t=s}}};const no={rgbListFromHSV:()=>{let t=[];for(let e=1;e>=.5;e-=.1)for(let n=0;n<1;n+=1/28){const r="rgb("+no.hsvToRgb(n,1,e).join(",")+")";t.push(r)}return t.pop(),t.push(no.rgbColor(16,16,16)),t},rgbToHex:function(t){return(t=t.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i))&&4===t.length?"#"+("0"+parseInt(t[1],10).toString(16)).slice(-2)+("0"+parseInt(t[2],10).toString(16)).slice(-2)+("0"+parseInt(t[3],10).toString(16)).slice(-2):""},hexToRgb:function(t){var e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);if(null!==e)return"rgb("+parseInt(e[1],16)+","+parseInt(e[2],16)+","+parseInt(e[3],16)+")"},hsvToRgb:function(t,e,n){var r,i,o,s=Math.floor(6*t),a=6*t-s,c=n*(1-e),l=n*(1-a*e),h=n*(1-(1-a)*e);switch(s%6){case 0:r=n,i=h,o=c;break;case 1:r=l,i=n,o=c;break;case 2:r=c,i=n,o=h;break;case 3:r=c,i=l,o=n;break;case 4:r=h,i=c,o=n;break;case 5:r=n,i=c,o=l}return[Math.floor(255*r),Math.floor(255*i),Math.floor(255*o)]},hslToRgb:function(t,e,n){var r,i,o;if(0===e)r=i=o=n;else{var s=n<.5?n*(1+e):n+e-n*e,a=2*n-s;r=no.hue2rgb(a,s,t+1/3),i=no.hue2rgb(a,s,t),o=no.hue2rgb(a,s,t-1/3)}return[255*r,255*i,255*o]},hue2rgb:(t,e,n)=>(n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t),rgbaColor:function(t,e,n,r){return"rgba("+(t=Qi(t,0,255))+","+(e=Qi(e,0,255))+","+(n=Qi(n,0,255))+","+(r=Qi(r,0,1))+")"},rgbColor:function(t,e,n){return"rgb("+(t=Qi(t,0,255))+","+(e=Qi(e,0,255))+","+(n=Qi(n,0,255))+")"},greyScale:function(t){var e=Qi(t,0,255);return"rgb("+e+","+e+","+e+")"},randomGrey:function(t,e){t=Qi(t,0,255),e=Qi(e,0,255);var n=Math.round(eo(t,e)).toString(10);return"rgb("+n+","+n+","+n+")"},randomRGB:function(t,e){return t=Qi(t,0,255),e=Qi(e,0,255),"rgb("+Math.round(eo(t,e)).toString(10)+","+Math.round(eo(t,e)).toString(10)+","+Math.round(eo(t,e)).toString(10)+")"},randomRGBConstantAlpha:function(t,e,n){return t=Qi(t,0,255),e=Qi(e,0,255),"rgba("+Math.round(eo(t,e)).toString(10)+","+Math.round(eo(t,e)).toString(10)+","+Math.round(eo(t,e)).toString(10)+","+n+")"},addAlpha:function(t,e){if("0"===t||"."===t)t="rgb(0,0,0)";else{const e=this.colorNameToHex(t);e&&(t=e)}var n=/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t);if(t.startsWith("rgba")){const n=t.lastIndexOf(",");return t.substring(0,n+1)+e.toString()+")"}return n&&(t=no.hexToRgb(t)),t.startsWith("rgb")?t.replace("rgb","rgba").replace(")",", "+e+")"):(console.log(t+" is not an rgb style string"),t)},rgbComponents:function(t){if("0"===t||"."===t)return[0,0,0];if(/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t))t=no.hexToRgb(t);else if(!t.startsWith("rgb")){const e=this.colorNameToHex(t);t=this.hexToRgb(e)}if(t.startsWith("rgb("))return t.substring(4,t.length-1).split(",").map((t=>Number.parseInt(t.trim())));if(t.startsWith("rgba("))return t.substring(5,t.length-1).split(",").map(((t,e)=>(t=t.trim(),3===e?Number.parseFloat(t):Number.parseInt(t))));throw Error("Unrecognized color string: color")},getCompositeColor:function(t,e,n){return"rgb("+Math.floor(n*e[0]+(1-n)*t[0])+","+Math.floor(n*e[1]+(1-n)*t[1])+","+Math.floor(n*e[2]+(1-n)*t[2])+")"},createColorString:function(t){return(t=function(t){return void 0===t||((t.startsWith("'")||t.startsWith('"'))&&(t=t.substring(1)),(t.endsWith("'")||t.endsWith('"'))&&(t=t.substring(0,t.length-1))),t}(t)).includes(",")?t.startsWith("rgb")?t:"rgb("+t+")":t},darkenLighten:function(t,e){let n,r=this.colorNameToHex(t);n=r?no.hexToRgb(r):t.startsWith("rgb(")?t:no.hexToRgb(t);const i=n.replace(")","").substring(4).split(","),o=Math.max(0,Math.min(255,Number.parseInt(i[0].trim())+e)),s=Math.max(0,Math.min(255,Number.parseInt(i[1].trim())+e)),a=Math.max(0,Math.min(255,Number.parseInt(i[2].trim())+e));return"rgb("+o.toString()+","+s.toString()+","+a.toString()+")"},colorNameToHex:function(t){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"}[t]}};let ro,io;function oo(t,e,n){n&&(io=Object.assign({},n)),e.addEventListener("mousedown",so.bind(t))}function so(t){t.stopPropagation(),t.preventDefault(),function(t){if(!t.getClientRects().length)return{top:0,left:0};const e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView;e.top,n.pageYOffset,e.left,n.pageXOffset}(this);const e=ao.bind(this),n=co.bind(this),r=getComputedStyle(this),i=parseInt(r.top.replace("px","")),o=parseInt(r.left.replace("px",""));ro={dragFunction:e,dragEndFunction:n,screenX:t.screenX,screenY:t.screenY,top:i,left:o},document.addEventListener("mousemove",e),document.addEventListener("mouseup",n),document.addEventListener("mouseleave",n),document.addEventListener("mouseexit",n)}function ao(t){if(!ro)return void console.log("No drag data!");t.stopPropagation(),t.preventDefault();const e=t.screenX-ro.screenX,n=t.screenY-ro.screenY,r=ro.left+e,i=io?Math.max(io.minY,ro.top+n):ro.top+n;this.style.left=`${r}px`,this.style.top=`${i}px`}function co(t){if(!ro)return void console.log("No drag data!");t.stopPropagation(),t.preventDefault();const e=ro.dragFunction,n=ro.dragEndFunction;document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",n),document.removeEventListener("mouseleave",n),document.removeEventListener("mouseexit",n),ro=void 0}const lo={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"},ho={oauthTokens:{},setToken:function(t,e){e=e||"googleapis",this.oauthTokens[e]=t,"googleapis"===e&&(this.google.access_token=t)},getToken:function(t){let e;t=t||"googleapis";for(let n of Object.keys(this.oauthTokens)){if(uo(n).test(t)){e=this.oauthTokens[n];break}}return e},removeToken:function(t){t=t||"googleapis";for(let e of Object.keys(this.oauthTokens)){uo(e).test(t)&&(this.oauthTokens[e]=void 0)}"googleapis"===t&&(this.google.access_token=void 0)},google:{setToken:function(t){ho.setToken(t)}}};function uo(t){return new RegExp("^"+t.split(/\*+/).map(fo).join(".*")+"$")}function fo(t){return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")}const po=new class{constructor(t){this.requestsPerSecond=t.requestsPerSecond||10,this.lastStartTime=0,this.queued=[]}add(t,e){var n=this;return new Promise((function(e,r){n.queued.push({resolve:e,reject:r,asyncFunction:t}),n.dequeue()}))}addAll(t,e){var n=t.map(function(t){return this.add(t,e)}.bind(this));return Promise.all(n)}dequeue(){if(this.queued.length>0){var t=new Date,e=1e3/this.requestsPerSecond+1,n=t-this.lastStartTime;n>=e?this._execute():setTimeout(function(){this.dequeue()}.bind(this),e-n)}}async _execute(){this.lastStartTime=new Date;var t=this.queued.shift();const e=t.asyncFunction;try{const n=await e();t.resolve(n)}catch(e){t.reject(e)}}}({requestsPerSecond:8}),go={apiKey:void 0,setApiKey:function(t){this.apiKey=t},load:mo,loadArrayBuffer:async function(t,e){return(e=e||{}).responseType||(e.responseType="arraybuffer"),je(t)?bo(t,e):mo(t,e)},loadJson:async function(t,e){"POST"===((e=e||{}).method||(e.sendData?"POST":"GET"))&&(e.contentType="application/json");const n=await this.loadString(t,e);return n?JSON.parse(n):n},loadString:async function(t,e){return e=e||{},t instanceof File?async function(t,e){const n=e.range?t.slice(e.range.start,e.range.start+e.range.size):t;return xo(await n.arrayBuffer())}(t,e):async function(t,e){(e=e||{}).responseType="arraybuffer";return xo(await go.load(t,e))}(t,e)}};async function mo(t,e){e=e||{};const n=typeof t;if(je(t=await("function"==typeof t?t():t)))return bo(t,e);if("function"==typeof t.startsWith){if(t.startsWith("data:")){const n=Yi(t).buffer;if(e.range){const t=e.range.size?e.range.start+e.range.size:n.byteLength;return n.slice(e.range.start,t)}return n}return t.startsWith("https://drive.google.com")&&(t=Re(t)),Le(t)||t.startsWith("https://www.dropbox.com")?po.add((async function(){return vo(t,e)})):vo(t,e)}throw Error(`url must be either a 'File', 'string', 'function', or 'Promise'. Actual type: ${n}`)}async function vo(t,e){t=function(t){return t.includes("//www.dropbox.com")?t.replace("//www.dropbox.com","//dl.dropboxusercontent.com"):t.includes("//drive.google.com")?Re(t):t.includes("//www.broadinstitute.org/igvdata")?t.replace("//www.broadinstitute.org/igvdata","//data.broadinstitute.org/igvdata"):t.includes("//igvdata.broadinstitute.org")?t.replace("//igvdata.broadinstitute.org","https://dn7ywbm9isq8j.cloudfront.net"):t.startsWith("ftp://ftp.ncbi.nlm.nih.gov/geo")?t.replace("ftp://","https://"):t}(t);let n=(e=e||{}).oauthToken||function(t){const e=Ae(t)?void 0:ze(t).host;let n=ho.getToken(e);if(n)return n;if(void 0===e){const t=yo();if(t&&t.expires_at>Date.now())return t.access_token}}(t);return n&&(n=await("function"==typeof n?n():n)),new Promise((function(r,i){Ae(t)&&!wo(t)&&(Te(t)&&(t=Me(t)),t=function(t){let e=go.apiKey;e||"undefined"==typeof gapi||(e=gapi.apiKey);if(void 0!==e&&!t.includes("key=")){const n=t.includes("?")?"&":"?";t=t+n+"key="+e}return t}(t),Le(t)&&function(t){if(t.includes("supportsTeamDrive"))return t;{const e=t.includes("?")?"&":"?";t=t+e+"supportsTeamDrive=true"}}(t),n||(n=yo()));const o=e.headers||{};n&&function(t,e){e&&(t["Cache-Control"]="no-cache",t.Authorization="Bearer "+e)}(o,n);const s=e.range,a=navigator.userAgent.indexOf("Chrome")>-1;0===navigator.vendor.indexOf("Apple")&&/\sSafari\//.test(navigator.userAgent),s&&a&&!function(t){return t.indexOf("X-Amz-Signature")>-1}(t)&&!wo(t)&&(t+=t.includes("?")?"&":"?",t+="someRandomSeed="+Math.random().toString(36));const c=new XMLHttpRequest,l=e.sendData||e.body,h=e.method||(l?"POST":"GET"),u=e.responseType,f=e.contentType,d=e.mimeType;if(c.open(h,t),e.timeout&&(c.timeout=e.timeout),s){var p=s.size?s.start+s.size-1:"";c.setRequestHeader("Range","bytes="+s.start+"-"+p)}if(f&&c.setRequestHeader("Content-Type",f),d&&c.overrideMimeType(d),u&&(c.responseType=u),o)for(let t of Object.keys(o)){const e=o[t];c.setRequestHeader(t,e)}!0===e.withCredentials&&(c.withCredentials=!0),c.onload=async function(n){0===c.status||c.status>=200&&c.status<=300?s&&206!==c.status&&0!==s.start?(c.response.length>1e5&&alert(`Warning: Range header ignored for URL: ${t}. This can have performance impacts.`),r(c.response.slice(s.start,s.start+s.size))):r(c.response):"undefined"==typeof gapi||404!==c.status&&401!==c.status&&403!==c.status||!Ae(t)||e.retries?403===c.status?g("Access forbidden: "+t):416===c.status?g("Unsatisfiable range"):g(c.status):m()},c.onerror=function(n){Ae(t)&&!e.retries&&m(),g("Error accessing resource: "+t+" Status: "+c.status)},c.ontimeout=function(t){g("Timed out")},c.onabort=function(t){console.log("Aborted"),i(t)};try{c.send(l)}catch(t){i(t)}function g(t){if(!i)throw t;i(t)}async function m(){try{const n=await async function(t){if(Oe()){const e=function(t){return Le(t)?"https://www.googleapis.com/auth/drive.file":Te(t)?"https://www.googleapis.com/auth/devstorage.read_only":"https://www.googleapis.com/auth/userinfo.profile"}(t),n=await De(e);return n?n.access_token:void 0}throw Error("Authorization is required, but Google oAuth has not been initalized. Contact your site administrator for assistance.")}(t);e.retries=1,e.oauthToken=n;const i=await mo(t,e);r(i)}catch(t){if(t.error){const e=t.error.startsWith("popup_blocked")?"Google login popup blocked by browser.":t.error;alert(e)}else g(t)}}}))}async function bo(t,e){let n=e&&e.range?t.slice(e.range.start,e.range.start+e.range.size):t;const r=await n.arrayBuffer();return"arraybuffer"===e.responseType?r:xo(r)}function wo(t){return t.indexOf("X-Goog-Signature")>-1}function yo(){if(Oe()){const t=function(){let t=gapi.auth2.getAuthInstance().currentUser.get();if(t&&t.isSignedIn()){const{access_token:e,expires_at:n}=t.getAuthResponse();return{access_token:e,expires_at:n}}}();return t?t.access_token:void 0}}function xo(t){let e;return e=function(t){const e=ArrayBuffer.isView(t)?t:new Uint8Array(t);return 31===e[0]&&139===e[1]}(t)?function(t){const e=ArrayBuffer.isView(t)?t:new Uint8Array(t);return 0!=(4&e[3])&&66===e[12]&&67===e[13]?Wi(e.buffer):Ui.ungzip(e)}(t):new Uint8Array(t),"TextDecoder"in function(){if("undefined"!=typeof self)return self;return"undefined"!=typeof global?global:window}()?(new TextDecoder).decode(e):function(t){var e="",n=0;for(;n<t.length;){var r=t[n],i=0,o=0;if(r<=127?(i=0,o=255&r):r<=223?(i=1,o=31&r):r<=239?(i=2,o=15&r):r<=244&&(i=3,o=7&r),t.length-n-i>0)for(var s=0;s<i;)o=o<<6|63&(r=t[n+s+1]),s+=1;else o=65533,i=t.length-n;e+=String.fromCodePoint(o),n+=i+1}return e}(e)}var ko={color:1};ko.parent=ko,ko.left=ko,ko.right=ko;class _o{constructor(){this.root=ko}insert(t,e,n){var r=new Lo(new To(t,e,n));for(this.treeInsert(r),r.color=2;r!==this.root&&2===r.parent.color;)if(r.parent===r.parent.parent.left){let t=r.parent.parent.right;2===t.color?(r.parent.color=1,t.color=1,r.parent.parent.color=2,r=r.parent.parent):(r===r.parent.right&&(r=r.parent,Co.call(this,r)),r.parent.color=1,r.parent.parent.color=2,Eo.call(this,r.parent.parent))}else{let t=r.parent.parent.left;2===t.color?(r.parent.color=1,t.color=1,r.parent.parent.color=2,r=r.parent.parent):(r===r.parent.left&&(r=r.parent,Eo.call(this,r)),r.parent.color=1,r.parent.parent.color=2,Co.call(this,r.parent.parent))}this.root.color=1}findOverlapping(t,e){var n=new To(t,e,0);if(this.root===ko)return[];var r=So.call(this,n,this.root,[]);return r.length>1&&r.sort((function(t,e){return t.low-e.low})),r}logIntervals(){!function t(e,n){for(var r="",i=0;i<n;i++)r+=" ";console.log(r+e.interval.low+" "+e.interval.high),n+=5,e.left!==ko&&t(e.left,n);e.right!==ko&&t(e.right,n)}(this.root,0)}mapIntervals(t){!function e(n){t(n.interval),n.left!==ko&&e(n.left);n.right!==ko&&e(n.right)}(this.root)}treeInsert(t){for(var e=this.root,n=ko;e!==ko;)n=e,e=t.interval.low<=e.interval.low?e.left:e.right;t.parent=n,n===ko?(this.root=t,t.left=t.right=ko):t.interval.low<=n.interval.low?n.left=t:n.right=t,Ao.call(this,t)}}function So(t,e,n){return e.interval.overlaps(t)&&n.push(e.interval),e.left!==ko&&e.left.max>=t.low&&So.call(this,t,e.left,n),e.right!==ko&&e.right.min<=t.high&&So.call(this,t,e.right,n),n}function Co(t){var e=t.right;t.right=e.left,e.left!==ko&&(e.left.parent=t),e.parent=t.parent,t.parent===ko?this.root=e:t.parent.left===t?t.parent.left=e:t.parent.right=e,e.left=t,t.parent=e,Ao.call(this,t)}function Eo(t){var e=t.left;t.left=e.right,e.right!==ko&&(e.right.parent=t),e.parent=t.parent,t.parent===ko?this.root=e:t.parent.right===t?t.parent.right=e:t.parent.left=e,e.right=t,t.parent=e,Ao.call(this,t)}function Ao(t){for(;t!==ko;){var e=t.left.max>t.right.max?t.left.max:t.right.max,n=t.interval.high;t.max=e>n?e:n;var r=t.left.min<t.right.min?t.left.min:t.right.min,i=t.interval.low;t.min=r<i?r:i,t=t.parent}}class To{constructor(t,e,n){this.low=t,this.high=e,this.value=n}equals(t){return!!t&&(this===t||this.low===t.low&&this.high===t.high)}compareTo(t){return this.low<t.low?-1:this.low>t.low?1:this.high<t.high?-1:this.high>t.high?1:0}overlaps(t){return this.low<=t.high&&t.low<=this.high}}function Lo(t){this.parent=ko,this.left=ko,this.right=ko,this.interval=t,this.color=2}class Mo{constructor(t,e,n){t=t||[],this.treeMap=this.buildTreeMap(t,e),this.range=n,this.count=t.length}containsRange(t){return void 0===this.range||this.range.contains(t.chr,t.start,t.end)}queryFeatures(t,e,n){const r=this.treeMap[t];if(!r)return[];const i=r.findOverlapping(e,n);if(0===i.length)return[];{const r=[],o=this.allFeatures[t];if(o){for(let t of i){const i=t.value;for(let t=i.start;t<i.end;t++){let i=o[t];if(i.start>n)break;i.end>=e&&r.push(i)}}r.sort((function(t,e){return t.start-e.start}))}return r}}getAllFeatures(){return this.allFeatures}buildTreeMap(t,e){const n={},r=[];if(this.allFeatures={},t){for(let n of t){let t=n.chr;e&&(t=e.getChromosomeName(t));let i=this.allFeatures[t];i||(r.push(t),i=[],this.allFeatures[t]=i),i.push(n)}for(let t of r){const e=this.allFeatures[t];e.sort((function(t,e){return t.start===e.start?0:t.start>e.start?1:-1})),n[t]=Ro(e)}}return n}}function Ro(t){const e=new _o,n=t.length,r=Math.max(10,Math.round(n/10));for(let i=0;i<n;i+=r){const o=Math.min(n,i+r),s=new Io(i,o),a=t[i].start;let c=a;for(let e=i;e<o;e++)c=Math.max(c,t[e].end);e.insert(a,c,s)}return e}class Io{constructor(t,e){this.start=t,this.end=e}}const No=function(t,e,n){if(t&&0!==t.length){const r=function(t){const e=new _o,n=t.length,r=Math.max(10,Math.round(n/100));t.sort((function(t,e){return t.start===e.start?0:t.start>e.start?1:-1}));for(let i=0;i<n;i+=r){const o=Math.min(n,i+r),s=t.slice(i,o),a=s[0].start;let c=a;s.forEach((function(t){c=Math.max(c,t.end)})),e.insert(a,c,s)}return e}(t),i=r.findOverlapping(e,n);return 0===i.length?[]:(t=[],i.forEach((function(r){const i=r.value,o=i.length;for(let r=0;r<o;r++){const o=i[r];if(o.start>n)break;o.end>e&&t.push(o)}})),t.sort((function(t,e){return t.start-e.start})),t)}return[]};function Po(t,e){const n=pe({class:"igv-menu-popup-check-container"}),r=pe();n.appendChild(r);const i=we("check",!0===e?"#444":"transparent");r.appendChild(i);const o=pe();return o.innerText=t,n.appendChild(o),n}const Oo={trackMenuItemList:function(t){const e=new Set(["alignment","annotation","variant","eqtl","snp"]),n=t.track.config&&void 0!==t.track.config.visibilityWindow;let r=[];return"sequence"!==t.track.config.type&&(r.push(function(t){const e=e=>{const n=function(){let e=t.browser.inputDialog.input.value;e=""===e||void 0===e?"untitled":e.trim(),t.track.name=e},r={label:"Track Name",value:Do(t.track)||"unnamed",callback:n};t.browser.inputDialog.present(r,e)},n=de("<div>");return n.text("Set track name"),{object:n,click:e}}(t)),r.push(function(t){const e=e=>{const n=()=>{const e=Number(t.browser.inputDialog.input.value,10);void 0!==e&&(void 0!==t.track.minHeight&&t.track.minHeight>e&&(t.track.minHeight=e),void 0!==t.track.maxHeight&&t.track.maxHeight<e&&(t.track.minHeight=e),t.setTrackHeight(e,!0),t.checkContentHeight(),t.repaintViews(),t.track.autoHeight=!1)},r={label:"Track Height",value:t.track.height,callback:n};t.browser.inputDialog.present(r,e)},n=de("<div>");return n.text("Set track height"),{object:n,click:e}}(t))),this.showColorPicker(t.track)&&(r.push("<hr/>"),r.push(Fo({trackView:t,label:"Set track color",option:"color"})),r.push(function({trackView:t,label:e}){const n=de("<div>");return n.text(e),{object:n,click:()=>{t.track.color=void 0,t.repaintViews()}}}({trackView:t,label:"Unset track color"})),r.push(Fo({trackView:t,label:"Set alt color",option:"altColor"}))),t.track.menuItemList&&(r=r.concat(t.track.menuItemList())),(n||e.has(t.track.type))&&(r.push("<hr/>"),r.push(function(t){const e=e=>{const n=()=>{let e=t.browser.inputDialog.input.value;e=""===e||void 0===e?-1:e.trim(),t.track.visibilityWindow=Number.parseInt(e),t.track.config.visibilityWindow=Number.parseInt(e),t.updateViews()},r={label:"Visibility Window",value:t.track.visibilityWindow,callback:n};t.browser.inputDialog.present(r,e)},n=de("<div>");return n.text("Set visibility window"),{object:n,click:e}}(t))),!1!==t.track.removable&&(r.push("<hr/>"),r.push(function(t){const e=de("<div>");return e.text("Remove track"),{object:e,click:()=>t.browser.removeTrack(t.track)}}(t))),r},numericDataMenuItems:function(t){const e=[];e.push("<hr/>");const n=de("<div>");n.text("Set data range");return e.push({object:n,click:()=>{t.browser.dataRangeDialog.configure(t),t.browser.dataRangeDialog.present(de(t.browser.columnContainer))}}),void 0!==t.track.logScale&&e.push({object:de(Po("Log scale",t.track.logScale)),click:()=>{t.track.logScale=!t.track.logScale,t.repaintViews()}}),e.push({object:de(Po("Autoscale",t.track.autoscale)),click:()=>{t.track.autoscale=!t.track.autoscale,t.updateViews()}}),e},trackMenuItemListHelper:function(t,e){var n=[];return t.length>0&&(n=t.map((function(t,n){var r;if(t.name?(r=de("<div>")).text(t.name):t.object?r=t.object:"string"==typeof t.label?(r=de("<div>")).html(t.label):"string"==typeof t&&(r=t.startsWith("<")?de(t):de("<div>"+t+"</div>")),0===n&&r.addClass("igv-track-menu-border-top"),t.click){function i(n){t.click(n),e.hide(),n.preventDefault(),n.stopPropagation()}r.on("click",i),r.on("touchend",(function(t){i(t)})),r.on("mouseup",(function(t){t.preventDefault(),t.stopPropagation()}))}return{object:r,init:t.init||void 0}}))),n},showColorPicker:t=>void 0===t.type||"bedtype"===t.type||"alignment"===t.type||"annotation"===t.type||"variant"===t.type||"wig"===t.type||"interact"===t.type,createMenuItem(t,e){const n=de("<div>");return n.text(t),{object:n,click:e}}};function Fo({trackView:t,label:e,option:n}){const r=de("<div>");return r.text(e),{object:r,click:()=>t.presentColorPicker(n)}}function Do(t){return t.trackView.viewports[0].$trackLabel.text()}function Bo(t){return function(t,e){const n=document.createElement(t);e&&(e.class&&n.classList.add(e.class),e.id&&(n.id=e.id),e.style&&function(t,e){for(let n of Object.keys(e))t.style[n]=e[n]}(n,e.style));return n}("div",t)}function zo(t){const e=getComputedStyle(t);"none"!==e.display&&(t._initialDisplay=e.display),t.style.display="none"}function Ho(t){if("none"===getComputedStyle(t).display){const e=t._initialDisplay||"block";t.style.display=e}}function Vo(t,e){e=e||"currentColor";let n=jo[t];n||(console.error(`No icon named: ${t}`),n=jo.question);const r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttributeNS(null,"viewBox","0 0 "+n[0]+" "+n[1]);const i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttributeNS(null,"fill",e),i.setAttributeNS(null,"d",n[4]),r.appendChild(i),r}const jo={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"]};function Uo(t,e){var n=document.createElement("div");t.appendChild(n),n.appendChild(function(t,e){return Vo(t,e)}("times")),n.addEventListener("click",(function(t){t.preventDefault(),t.stopPropagation(),e()}))}let qo;function Wo(t,e){e.addEventListener("mousedown",$o.bind(t))}function $o(t){t.stopPropagation(),t.preventDefault(),function(t){if(!t.getClientRects().length)return{top:0,left:0};const e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView;e.top,n.pageYOffset,e.left,n.pageXOffset}(this);const e=Go.bind(this),n=Zo.bind(this),r=getComputedStyle(this),i=parseInt(r.top.replace("px","")),o=parseInt(r.left.replace("px",""));qo={dragFunction:e,dragEndFunction:n,screenX:t.screenX,screenY:t.screenY,top:i,left:o},document.addEventListener("mousemove",e),document.addEventListener("mouseup",n),document.addEventListener("mouseleave",n),document.addEventListener("mouseexit",n)}function Go(t){if(!qo)return void console.log("No drag data!");t.stopPropagation(),t.preventDefault();const e=t.screenX-qo.screenX,n=t.screenY-qo.screenY;this.style.left=`${qo.left+e}px`,this.style.top=`${qo.top+n}px`}function Zo(t){if(!qo)return void console.log("No drag data!");t.stopPropagation(),t.preventDefault();const e=qo.dragFunction,n=qo.dragEndFunction;document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",n),document.removeEventListener("mouseleave",n),document.removeEventListener("mouseexit",n),qo=void 0}const Xo={401:"Access unauthorized",403:"Access forbidden",404:"Not found"};class Yo{constructor(t,e){this.alertProps=Object.assign({shouldFocus:!0,preventScroll:!1},e),this.container=Bo({class:"igv-ui-alert-dialog-container"}),t.appendChild(this.container),this.container.setAttribute("tabIndex","-1");const n=Bo();this.container.appendChild(n),this.errorHeadline=Bo(),n.appendChild(this.errorHeadline),this.errorHeadline.textContent="";let r=Bo({class:"igv-ui-alert-dialog-body"});this.container.appendChild(r),this.body=Bo({class:"igv-ui-alert-dialog-body-copy"}),r.appendChild(this.body);let i=Bo();this.container.appendChild(i),this.ok=Bo(),i.appendChild(this.ok),this.ok.textContent="OK";const o=()=>{"function"==typeof this.callback&&(this.callback("OK"),this.callback=void 0),this.body.innerHTML="",zo(this.container)};this.ok.addEventListener("click",(t=>{t.stopPropagation(),o()})),this.container.addEventListener("keypress",(t=>{t.stopPropagation(),"Enter"===t.key&&o()})),Wo(this.container,n),zo(this.container)}present(t,e){this.errorHeadline.textContent=t.message?"ERROR":"";let n=t.message||t;Xo.hasOwnProperty(n)&&(n=Xo[n]),this.body.innerHTML=n,this.callback=e,Ho(this.container),this.alertProps.shouldFocus&&this.container.focus({preventScroll:this.alertProps.preventScroll})}}let Ko;const Qo={init(t,e={}){Ko=new Yo(t,e)},presentAlert(t,e){Ko||this.init(document.body),Ko.present(t,e)}};class Jo{constructor(t){this.parent=t,this.container=Bo({class:"igv-ui-generic-dialog-container"}),t.appendChild(this.container);const e=Bo({class:"igv-ui-generic-dialog-header"});this.container.appendChild(e),this.label=Bo({class:"igv-ui-generic-dialog-one-liner"}),this.container.appendChild(this.label),this.label.text="Unlabeled",this.input_container=Bo({class:"igv-ui-generic-dialog-input"}),this.container.appendChild(this.input_container),this.input=document.createElement("input"),this.input_container.appendChild(this.input);const n=Bo({class:"igv-ui-generic-dialog-ok-cancel"});this.container.appendChild(n),this.ok=Bo(),n.appendChild(this.ok),this.ok.textContent="OK",this.cancel=Bo(),n.appendChild(this.cancel),this.cancel.textContent="Cancel",zo(this.container),this.input.addEventListener("keyup",(t=>{13===t.keyCode&&("function"==typeof this.callback&&(this.callback(this.input.value),this.callback=void 0),this.input.value=void 0,zo(this.container))})),this.ok.addEventListener("click",(()=>{"function"==typeof this.callback&&(this.callback(this.input.value),this.callback=void 0),this.input.value=void 0,zo(this.container)}));const r=()=>{this.input.value="",zo(this.container)};this.cancel.addEventListener("click",r),Uo(e,r),Wo(this.container,e)}present(t,e){this.label.textContent=t.label,this.input.value=t.value,this.callback=t.callback||t.click,Ho(this.container);const{x:n,y:r}=function(t){if(t.type.startsWith("touch")){const e=t.touches[0];return{x:e.pageX,y:e.pageY}}return{x:t.pageX,y:t.pageY}}(e);this.clampLocation(n,r)}clampLocation(t,e){const{width:n,height:r}=this.container.getBoundingClientRect(),{x:i,y:o,width:s,height:a}=this.parent.getBoundingClientRect(),c=Math.min(Math.max(e,o),o+a-r),l=Math.min(Math.max(t,i),i+s-n);this.container.style.left=`${l}px`,this.container.style.top=`${c}px`}}const ts={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 es{constructor({parent:t,top:e,left:n,width:r,height:i,border:o,closeHandler:s}){let a=Bo({class:"igv-ui-generic-container"});t.appendChild(a),zo(a),this.container=a,void 0!==e&&(this.container.style.top=`${e}px`),void 0!==n&&(this.container.style.left=`${n}px`),void 0!==r&&(this.container.style.width=`${r}px`),void 0!==i&&(this.container.style.height=`${i}px`),o&&(this.container.style.border=o);const c=Bo();this.container.appendChild(c),Uo(c,(t=>{zo(this.container),"function"==typeof s&&s(t)})),Wo(this.container,c)}show(){Ho(this.container)}hide(){zo(this.container)}dispose(){this.container.parent&&this.container.parent.removeChild(this.container)}}class ns extends es{constructor({parent:t,top:e,left:n,width:r,height:i,defaultColors:o,colorHandler:s}){super({parent:t,top:e,left:n,width:r,height:i,border:"1px solid gray"}),rs(this.container,s,o)}}const rs=(t,e,n)=>{const r=Object.values(ts);for(let n of r){const r=Bo({class:"igv-ui-color-swatch"});t.appendChild(r),is(r,n,e)}if(n)for(let r of n){const n=Bo({class:"igv-ui-color-swatch"});t.appendChild(n),is(n,r,e)}},is=(t,e,n)=>{t.style.backgroundColor=e,t.addEventListener("mouseenter",(n=>t.style.borderColor=e)),t.addEventListener("mouseleave",(e=>t.style.borderColor="white")),t.addEventListener("click",(t=>{t.stopPropagation(),n(e)})),t.addEventListener("touchend",(t=>{t.stopPropagation(),n(e)}))};class os{constructor(t,e){this.parent=t,this.popover=Bo({class:"igv-ui-popover"}),t.appendChild(this.popover);const n=Bo();this.popover.appendChild(n);const r=Bo();n.appendChild(r),e&&(r.textContent=e),Uo(n,(()=>this.hide())),Wo(this.popover,n),this.popoverContent=Bo(),this.popover.appendChild(this.popoverContent),this.popover.style.display="none"}presentContentWithEvent(t,e){this.popover.style.display="block",this.popoverContent.innerHTML=e,ss(t,this.popover,this.popoverContent)}presentMenu(t,e){if(0===e.length)return;this.popover.style.display="block";const n=function(t,e){const n=t.map((function(t,n){let r;if("string"==typeof t)r=Bo(),r.innerHTML=t;else if("Node"==typeof t)r=t;else{if("function"==typeof t.init&&t.init(),"checkbox"===t.type)r=function(t,e){const n=Bo({class:"igv-ui-trackgear-popover-check-container"}),r=Vo("check",!0===e?"#444":"transparent");r.style.borderColor="gray",r.style.borderWidth="1px",r.style.borderStyle="solid",n.appendChild(r);let i=Bo();return i.textContent=t,n.appendChild(i),n}("Show all bases",t.value);else if("color"===t.type){const i=new ns({parent:e.parentElement,width:364,colorHandler:e=>t.click(e)});r=Bo(),"string"==typeof t.label&&(r.innerHTML=t.label);const o=t=>{i.show(),zo(e),t.preventDefault(),t.stopPropagation()};r.addEventListener("click",o),r.addEventListener("touchend",o),r.addEventListener("mouseup",(function(t){t.preventDefault(),t.stopPropagation()}))}else r=Bo(),"string"==typeof t.label&&(r.innerHTML=t.label);if(t.click&&"color"!==t.type){function s(n){t.click(),zo(e),n.preventDefault(),n.stopPropagation()}r.addEventListener("click",s),r.addEventListener("touchend",s),r.addEventListener("mouseup",(function(t){t.preventDefault(),t.stopPropagation()}))}}return{object:r,init:t.init}}));return n}(e,this.popover);for(let t of n)this.popoverContent.appendChild(t.object);ss(t,this.popover,this.popoverContent)}hide(){this.popover.style.display="none",this.dispose()}dispose(){this.popover&&this.popover.parentNode.removeChild(this.popover);const t=Object.keys(this);for(let e of t)this[e]=void 0}}function ss(t,e,n){const{x:r,y:i,width:o}=function(t,e){const{clientX:n,clientY:r}=t;return((t,{clientX:e,clientY:n})=>{const{left:r,top:i,width:o,height:s}=t.getBoundingClientRect(),a=e-r,c=n-i;return{x:a,y:c,xNormalized:a/o,yNormalized:c/s,width:o,height:s}})(e,{clientX:n,clientY:r})}(t,e.parentNode);e.style.top=`${i}px`;const{width:s}=e.getBoundingClientRect(),a=r+s,c=a-o;e.style.left=`${a>o?r-c:r}px`,n.style.maxWidth=`${Math.min(s,o)}px`}if("undefined"!=typeof document){function as(t){for(let e of document.styleSheets)if(e=e.href?e.href.replace(/^.*[\\\/]/,""):"",e===t)return!0;return!1}as("igv-ui.css")||function(){var t=document.createElement("style");t.setAttribute("type","text/css"),t.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 .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 .igv-ui-popover > div:first-child > div:first-child {\n margin-left: 4px; }\n .igv-ui-popover > div:first-child > div:last-child {\n margin-right: 4px;\n height: 12px;\n width: 12px;\n color: #7F7F7F; }\n .igv-ui-popover > div:first-child > div:last-child:hover {\n cursor: pointer;\n color: #444; }\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 .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 .igv-ui-popover > div:last-child > div > span {\n font-weight: bolder; }\n .igv-ui-popover > div:last-child hr {\n width: 100%; }\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 .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 .igv-ui-alert-dialog-container > div:first-child div:first-child {\n padding-left: 8px; }\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 .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 .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 .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 .igv-ui-alert-dialog-container > div:last-child div:hover {\n cursor: pointer;\n border-color: #25597f;\n background-color: #25597f; }\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.igv-ui-color-swatch:hover {\n border-color: dimgray; }\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 .igv-ui-colorpicker-menu-close-button i.fa {\n display: block;\n margin-left: 4px;\n margin-right: 4px;\n color: #5f5f5f; }\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.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 .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 .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 .igv-ui-generic-dialog-container .igv-ui-generic-dialog-header div:hover {\n cursor: pointer;\n color: #444; }\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 .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 .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 .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 .igv-ui-generic-dialog-container .igv-ui-generic-dialog-label-input input {\n width: 50%;\n font-size: 16px; }\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 .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 .igv-ui-generic-dialog-container .igv-ui-generic-dialog-input input {\n font-size: 16px; }\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 .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 .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 .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 .igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel div:first-child:hover {\n cursor: pointer;\n background-color: #3b5c7f; }\n .igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel div:last-child:hover {\n cursor: pointer;\n background-color: #7f7f7f; }\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 .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 .igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok div:hover {\n cursor: pointer;\n background-color: #25597f; }\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 .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 .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.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 .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 .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 .igv-ui-dialog .igv-ui-dialog-header div:hover {\n cursor: pointer;\n color: #444; }\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 .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 .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 .igv-ui-dialog .igv-ui-dialog-ok-cancel div:first-child {\n background-color: #5ea4e0; }\n .igv-ui-dialog .igv-ui-dialog-ok-cancel div:last-child {\n background-color: #c4c4c4; }\n .igv-ui-dialog .igv-ui-dialog-ok-cancel div:first-child:hover {\n cursor: pointer;\n background-color: #3b5c7f; }\n .igv-ui-dialog .igv-ui-dialog-ok-cancel div:last-child:hover {\n cursor: pointer;\n background-color: #7f7f7f; }\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 .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 .igv-ui-dialog .igv-ui-dialog-ok div:hover {\n cursor: pointer;\n background-color: #25597f; }\n\n.igv-ui-panel, .igv-ui-panel-column, .igv-ui-panel-row {\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.igv-ui-panel-column {\n display: flex;\n flex-direction: column; }\n\n.igv-ui-panel-row {\n display: flex;\n flex-direction: row; }\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/*# sourceMappingURL=igv-ui.css.map */\n',document.head.insertBefore(t,document.head.childNodes[document.head.childNodes.length-1])}()}class cs{constructor(t,e){this.$container=de("<div>",{class:"igv-generic-dialog-container"}),t.append(this.$container),this.$container.offset({left:0,top:0});const n=de("<div>",{class:"igv-generic-dialog-header"});this.$container.append(n),xe(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=de("<div>",{class:"igv-generic-dialog-label-input"}),this.$container.append(this.$minimum);const r=de("<div>");r.text("Minimum"),this.$minimum.append(r),this.$minimum_input=de("<input>"),this.$minimum.append(this.$minimum_input),this.$maximum=de("<div>",{class:"igv-generic-dialog-label-input"}),this.$container.append(this.$maximum);const i=de("<div>");i.text("Maximum"),this.$maximum.append(i),this.$maximum_input=de("<input>"),this.$maximum.append(this.$maximum_input);const o=de("<div>",{class:"igv-generic-dialog-ok-cancel"});this.$container.append(o),this.$ok=de("<div>"),o.append(this.$ok),this.$ok.text("OK"),this.$cancel=de("<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()})),oo(this.$container.get(0),n.get(0)),this.$container.hide()}configure(t){const e=t.dataRange();let n,r;e?(n=e.min,r=e.max):(n=0,r=100),this.$minimum_input.val(n),this.$maximum_input.val(r),this.$minimum_input.unbind(),this.$minimum_input.on("keyup",(e=>{13===e.keyCode&&this.processResults(t)})),this.$maximum_input.unbind(),this.$maximum_input.on("keyup",(e=>{13===e.keyCode&&this.processResults(t)})),this.$ok.unbind(),this.$ok.on("click",(e=>{this.processResults(t)}))}processResults(t){const e=Number(this.$minimum_input.val()),n=Number(this.$maximum_input.val());isNaN(e)||isNaN(n)?Qo.presentAlert(new Error("Must input numeric values"),void 0):t.setDataRange(e,n),this.$minimum_input.val(void 0),this.$maximum_input.val(void 0),this.$container.offset({left:0,top:0}),this.$container.hide()}present(t){const e=t.offset().top,n=de("body").scrollTop();this.$container.offset({left:t.width()-this.$container.width(),top:e+n}),this.$container.show()}}const ls={configureHighDPICanvas:function(t,e,n){const r=window.devicePixelRatio;t.canvas.style.width=`${e}px`,t.canvas.width=Math.floor(r*e),t.canvas.style.height=`${n}px`,t.canvas.height=Math.floor(r*n),t.scale(r,r)},setProperties:function(t,e){for(var n in e)if(e.hasOwnProperty(n)){var r=e[n];t[n]=r}},strokeLine:function(t,e,n,r,i,o){e=Math.floor(e)+.5,n=Math.floor(n)+.5,r=Math.floor(r)+.5,i=Math.floor(i)+.5,o&&(t.save(),ls.setProperties(t,o)),t.beginPath(),t.moveTo(e,n),t.lineTo(r,i),t.stroke(),o&&t.restore()},fillRect:function(t,e,n,r,i,o){e=Math.round(e),n=Math.round(n),o&&(t.save(),ls.setProperties(t,o)),t.fillRect(e,n,r,i),o&&t.restore()},fillPolygon:function(t,e,n,r){r&&(t.save(),ls.setProperties(t,r)),hs(t,e,n),t.fill(),r&&t.restore()},strokePolygon:function(t,e,n,r){r&&(t.save(),ls.setProperties(t,r)),hs(t,e,n),t.stroke(),r&&t.restore()},fillText:function(t,e,n,r,i,o){if((i||o)&&t.save(),i&&ls.setProperties(t,i),o){for(var s in t.translate(n,r),o){var a=o[s];"translate"===s&&t.translate(a.x,a.y),"rotate"===s&&t.rotate(a.angle*Math.PI/180)}t.fillText(e,0,0)}else t.fillText(e,n,r);(i||o)&&t.restore()},strokeText:function(t,e,n,r,i,o){if((i||o)&&t.save(),i&&ls.setProperties(t,i),o){for(var s in t.translate(n,r),o){var a=o[s];"translate"===s&&t.translate(a.x,a.y),"rotate"===s&&t.rotate(a.angle*Math.PI/180)}t.strokeText(e,0,0)}else t.strokeText(e,n,r);(i||o)&&t.restore()},strokeCircle:function(t,e,n,r,i){i&&(t.save(),ls.setProperties(t,i)),t.beginPath(),t.arc(e,n,r,0,2*Math.PI),t.stroke(),i&&t.restore()},fillCircle:function(t,e,n,r,i){i&&(t.save(),ls.setProperties(t,i)),t.beginPath(),t.arc(e,n,r,0,2*Math.PI),t.fill(),i&&t.restore()},drawArrowhead:function(t,e,n,r,i){t.save(),r||(r=5),i&&(t.lineWidth=i),t.beginPath(),t.moveTo(e,n-r/2),t.lineTo(e,n+r/2),t.lineTo(e+r,n),t.lineTo(e,n-r/2),t.closePath(),t.fill(),t.restore()},dashedLine:function(t,e,n,r,i,o,s={}){void 0===o&&(o=2),t.setLineDash([o,o]),ls.strokeLine(t,e,n,r,i,s),t.setLineDash([])},roundRect:function(t,e,n,r,i,o,s,a){void 0===a&&(a=!0),void 0===o&&(o=5),t.beginPath(),t.moveTo(e+o,n),t.lineTo(e+r-o,n),t.quadraticCurveTo(e+r,n,e+r,n+o),t.lineTo(e+r,n+i-o),t.quadraticCurveTo(e+r,n+i,e+r-o,n+i),t.lineTo(e+o,n+i),t.quadraticCurveTo(e,n+i,e,n+i-o),t.lineTo(e,n+o),t.quadraticCurveTo(e,n,e+o,n),t.closePath(),a&&t.stroke(),s&&t.fill()},polygon:function(t,e,n,r,i){void 0===i&&(i=!0),t.beginPath();var o=e.length;t.moveTo(e[0],n[0]);for(var s=1;s<o;s++)t.lineTo(e[s],n[s]);t.closePath(),i&&t.stroke(),r&&t.fill()}};function hs(t,e,n){var r,i=e.length;for(r=0;r<i;r++)e[r]=Math.round(e[r]),n[r]=Math.round(n[r]);for(t.beginPath(),t.moveTo(e[0],n[0]),r=1;r<i;r++)t.lineTo(e[r],n[r]);t.closePath()}const us={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"]}},fs=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"]);function ds(t){if(function(t){t.featureType&&(t.type=t.type||t.featureType,t.featureType=void 0);"junctions"===t.type?t.type="junction":"bed"===t.type?(t.type="annotation",t.format=t.format||"bed"):"annotations"===t.type?t.type="annotation":"alignments"===t.type?t.type="alignment":"bam"===t.type?(t.type="alignment",t.format="bam"):"vcf"===t.type?(t.type="variant",t.format="vcf"):"t2d"===t.type?t.type="gwas":"FusionJuncSpan"!==t.type||t.format?"aed"===t.type&&(t.type="annotation",t.format=t.format||"aed"):t.format="fusionjuncspan"}(t),t.type)return t.type;if(t.format){switch(t.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"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";default:return"annotation"}}}function ps(t){const e=new Set(["boolean","number","string","symbol"]),n=typeof t;return void 0!==t&&(e.has(n)||t.substring||t.toFixed)}function gs(t,e){var n={oauthToken:t.oauthToken,headers:t.headers,withCredentials:t.withCredentials,filename:t.filename};return Object.assign(n,e)}const ms=function(t){var e,n;return t.length>0?(e=Number.MAX_VALUE,n=-Number.MAX_VALUE,t.forEach((function(t){Number.isNaN(t.value)||(e=Math.min(e,t.value),n=Math.max(n,t.value))})),n>0&&(e=Math.min(0,e)),n<0&&(n=0)):(e=0,n=100),{min:e,max:n}},vs=function(t,e,n){let r=e.start,i=e.end;if(void 0===i)r-=n/2,i=r+n,i>t?(i=t,r=i-n):r<0&&(r=0,i=n);else if(i-r<n){const e=(i+r)/2;e-n/2<0?(r=0,i=r+n):e+n/2>t?(i=t,r=i-n):(r=e-n/2,i=r+n)}e.start=Math.ceil(r),e.end=Math.floor(i)};async function bs(t){if(ke(t)&&t.startsWith("https://drive.google.com")){if(void 0===Be())throw Error("Google drive is referenced, but API key is not defined. An API key is required for Google Drive access");const e=await async function(t){let e="https://www.googleapis.com/drive/v3/files/"+Ie(t)+"?supportsTeamDrives=true";const n=Be();n&&(e+="&key="+n);const r=await fetch(e);let i=await r.json();if(i.error&&404===i.error.code){const{access_token:t}=await De("https://www.googleapis.com/auth/drive.readonly");if(!t)throw Error(i.error);{const n=await fetch(e,{headers:{Authorization:`Bearer ${t}`}});if(i=await n.json(),i.error)throw Error(i.error)}}return i}(t);return e.originalFileName||e.name}return Ve(t)}function ws(t){var e,n;return t>1e7?(e=" mb",n=t/1e6,Math.floor(n).toString()+e):t>1e4?(e=" kb",n=t/1e3,_e(Math.floor(n))+e):_e(t)+" bp"}function ys(t){return ke(t)&&t.startsWith("data:")}function xs(t,e){const n=pe({class:e});t.appendChild(n)}function ks(t,e){e.parentNode.insertBefore(t,e)}function _s(t,e){e.parentNode.insertBefore(t,e.nextSibling)}function Ss(){return"https:"===window.location.protocol||"localhost"===window.location.hostname}const Cs=[["A","T"],["G","C"],["Y","R"],["W","S"],["K","M"],["D","H"],["B","V"]],Es=new Map;for(let cd of Cs){const ld=cd[0],hd=cd[1];Es.set(ld,hd),Es.set(hd,ld),Es.set(ld.toLowerCase(),hd.toLowerCase()),Es.set(hd.toLowerCase(),ld.toLowerCase())}function As(t){let e="",n=t.length;for(;n-- >0;){const r=t[n];e+=Es.has(r)?Es.get(r):r}return e}const Ts=Number.MIN_SAFE_INTEGER,Ls={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"},Ms={},Rs=["A","G","C","T","Y","R","W","S","K","M","D","V","H","B","N","X"],Is=["T","C","G","A","R","Y","W","S","M","K","H","B","D","V","N","X"];for(let ud=0;ud<Rs.length;ud++)Ms[Rs[ud]]=Is[ud],Ms[Rs[ud].toLowerCase()]=Is[ud].toLowerCase();class Ns{constructor(t,e){this.type="sequence",this.browser=e,this.removable=!1,this.config=t,this.name="Sequence",this.id="sequence",this.sequenceType=t.sequenceType||"dna",this.disableButtons=!1,this.order=t.order||Ts,this.ignoreTrackMenu=!1,this.reversed=!0===t.reversed,this.frameTranslate=!0===t.frameTranslate,this.height=this.frameTranslate?115:25}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 t of this.trackView.viewports)t.setContentHeight(115);this.trackView.setTrackHeight(115)}else{for(let t of this.trackView.viewports)t.setContentHeight(25);this.trackView.setTrackHeight(25)}this.trackView.repaintViews()}}]}contextMenuItemList(t){const e=t.viewport;if(e.referenceFrame.bpPerPixel<=1){const t=e.getWidth()*e.referenceFrame.bpPerPixel,n=e.referenceFrame.chr,r=Math.floor(e.referenceFrame.start),i=Math.ceil(r+t),o=[{label:this.reversed?"View visible sequence (reversed)...":"View visible sequence...",click:async()=>{let t=await this.browser.genome.sequence.getSequence(n,r,i);this.reversed&&(t=As(t)),Qo.presentAlert(t)}}];return Ss()&&o.push({label:"Copy visible sequence",click:async()=>{let t=await this.browser.genome.sequence.getSequence(n,r,i);this.reversed&&(t=As(t));try{await navigator.clipboard.writeText(t)}catch(t){console.error(t),Qo.presentAlert(`error copying sequence to clipboard ${t}`)}}}),o.push("<hr/>"),o}}translateSequence(t){const e=[[],[],[]];for(let n of[0,1,2]){let r=n;for(;t.length-r>=3;){let i=t.slice(r,r+3);this.reversed&&(i=i.split("").reverse().join(""));const o=Ls[i.toUpperCase()]||"";e[n].push({codons:i,aminoA:o}),r+=3}}return e}async getFeatures(t,e,n,r){if(e=Math.floor(e),n=Math.floor(n),r&&r>1)return null;return{bpStart:e,sequence:await this.browser.genome.sequence.getSequence(t,e,n)}}draw(t){const e=t.context;if(t.features){let n=t.features.sequence;this.reversed&&(n=n.split("").map((function(t){return Ms[t]})).join(""));const r=t.features.bpStart,i=1+t.bpStart+t.pixelWidth*t.bpPerPixel;for(let o=Math.floor(t.bpStart);o<=i;o++){const i=Math.floor(o-r);if(i>=0&&i<n.length){const r=n[i],s=(o-t.bpStart)/t.bpPerPixel,a=1/t.bpPerPixel,c=this.fillColor(r);if(t.bpPerPixel>.1)ls.fillRect(e,s,5,a,10,{fillStyle:c});else{let t=s+.5*(a-e.measureText(r).width);ls.strokeText(e,r,t,15,{strokeStyle:c})}}}if(this.frameTranslate){let i=25;const o=this.translateSequence(n);for(let n=0;n<o.length;n++){const s=o[n];for(let o=0;o<s.length;o++){let a=0==o%2?"rgb(160,160,160)":"rgb(224,224,224)";const c=s[o],l=r+n+3*o-t.bpStart,h=Math.floor(l/t.bpPerPixel),u=Math.floor((l+3)/t.bpPerPixel),f=Math.round((h+u)/2);if(u<0)continue;if(h>t.pixelWidth)break;let d=c.aminoA;c.aminoA.indexOf("STOP")>-1?(a="rgb(255, 0, 0)",d="STOP"):"M"===c.aminoA&&(a="rgb(0, 153, 0)",d="START"),ls.fillRect(e,h,i,u-h,25,{fillStyle:a}),t.bpPerPixel<=.1&&ls.strokeText(e,d,f-e.measureText(d).width/2,i+15)}i+=30}}}}get supportsWholeGenome(){return!1}computePixelHeight(t){return this.height=this.frameTranslate?115:25,this.height}fillColor(t){return this.color?this.color:"dna"===this.sequenceType?this.browser.nucleotideColors[t]||"gray":"rgb(0, 0, 150)"}getState(){const t={type:"sequence"};return this.order!==Ts&&(t.order=this.order),this.reversed&&(t.revealed=!0),t}}
|
|
27
27
|
/*!!
|
|
28
28
|
* Canvas 2 Svg v1.0.19
|
|
29
29
|
* A low level canvas to SVG converter. Uses a mock canvas context to build an SVG document.
|
|
@@ -36,7 +36,7 @@ function(t){var e,n,r,i,o,s,a,c,l,h,u,f,d,p,g,m,v,b,w,y="sizzle"+1*new Date,x=t.
|
|
|
36
36
|
*
|
|
37
37
|
* Copyright (c) 2014 Gliffy Inc.
|
|
38
38
|
*/
|
|
39
|
-
function Ps(t,e){var n,r=Object.keys(e);for(n=0;n<r.length;n++)t=t.replace(new RegExp("\\{"+r[n]+"\\}","gi"),e[r[n]]);return t}function Os(t){var e,n,r;if(!t)throw new Error("cannot create a random attribute name for an undefined object");e="ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",n="";do{for(n="",r=0;r<12;r++)n+=e[Math.floor(Math.random()*e.length)]}while(t[n]);return n}function Fs(t){var e={alphabetic:"alphabetic",hanging:"hanging",top:"text-before-edge",bottom:"text-after-edge",middle:"central"};return e[t]||e.alphabetic}function Ds(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]);return[t[0]/e,t[1]/e]}const Bs=function(t,e){var n,r,i,o={};for(t=t.split(","),e=e||10,n=0;n<t.length;n+=2)r="&"+t[n+1]+";",i=parseInt(t[n],e),o[r]="&#"+i+";";return o["\\xa0"]=" ",o}("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),zs={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 Hs{constructor(t,e){this.__root=t,this.__ctx=e}addColorStop(t,e){var n,r=this.__ctx.__createElement("stop");r.setAttribute("offset",t),e&&-1!==e.indexOf("rgba")?(n=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi.exec(e),r.setAttribute("stop-color",Ps("rgb({r},{g},{b})",{r:n[1],g:n[2],b:n[3]})),r.setAttribute("stop-opacity",n[4])):r.setAttribute("stop-color",e),this.__root.appendChild(r)}}class Vs{constructor(t,e){this.__root=t,this.__ctx=e}}class js{constructor(t){if(!(this instanceof js))return new js(t);if(this.config=t,this.width=t.width,this.height=t.height,this.enableMirroring=t.enableMirroring||!1,this.canvas=this,this.__document=document,t.ctx?this.__ctx=t.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"),t.viewbox){const e=t.viewbox.x+" "+t.viewbox.y+" "+t.viewbox.width+" "+t.viewbox.height;this.__root.setAttribute("viewBox",e),this.viewbox=t.viewbox}this.__ids={},this.__defs=this.__createElement("defs"),this.__root.appendChild(this.__defs),this.multiLocusGap=t.multiLocusGap;let e={id:"svg_output_backdrop",width:"100%",height:"100%",fill:t.backdropColor||"white"},n=this.__createElement("rect",e);this.__root.appendChild(n),this.__rootGroup=this.__createElement("g",{id:"root-group"}),this.__root.appendChild(this.__rootGroup),this.__currentElement=this.__rootGroup}setWidth(t){this.width=t,this.__root.setAttribute("width",this.width);const e=this.config.viewbox.x+" "+this.config.viewbox.y+" "+t+" "+this.config.viewbox.height;this.__root.setAttribute("viewBox",e)}setHeight(t){this.height=t,this.__root.setAttribute("height",this.height);const e=this.config.viewbox.x+" "+this.config.viewbox.y+" "+this.config.viewbox.width+" "+t;this.__root.setAttribute("viewBox",e)}__createElement(t,e,n){void 0===e&&(e={});let r=this.__document.createElementNS("http://www.w3.org/2000/svg",t);n&&(r.setAttribute("fill","none"),r.setAttribute("stroke","none"));for(let t of Object.keys(e))r.setAttribute(t,e[t]);return r}__setDefaultStyles(){var t,e,n=Object.keys(zs);for(t=0;t<n.length;t++)this[e=n[t]]=zs[e].canvas}__applyStyleState(t){var e,n,r=Object.keys(t);for(e=0;e<r.length;e++)this[n=r[e]]=t[n]}__getStyleState(){var t,e,n={},r=Object.keys(zs);for(t=0;t<r.length;t++)n[e=r[t]]=this[e];return n}__applyStyleToCurrentElement(t){var e=this.__currentElement,n=this.__currentElementsToStyle;n&&(e.setAttribute(t,""),e=n.element,n.children.forEach((function(e){e.setAttribute(t,"")})));var r,i,o,s,a,c=Object.keys(zs);for(r=0;r<c.length;r++)if(i=zs[c[r]],o=this[c[r]],i.apply)if(o instanceof Vs){if(o.__ctx)for(;o.__ctx.__defs.childNodes.length;)s=o.__ctx.__defs.childNodes[0].getAttribute("id"),this.__ids[s]=s,this.__defs.appendChild(o.__ctx.__defs.childNodes[0]);e.setAttribute(i.apply,Ps("url(#{id})",{id:o.__root.getAttribute("id")}))}else if(o instanceof Hs)e.setAttribute(i.apply,Ps("url(#{id})",{id:o.__root.getAttribute("id")}));else if(i&&-1!==i.apply.indexOf(t)&&i.svg!==o)if("stroke"!==i.svgAttr&&"fill"!==i.svgAttr||!o||-1===o.indexOf("rgba")){var l=i.svgAttr;if("globalAlpha"===c[r]&&(l=t+"-"+i.svgAttr,e.getAttribute(l)))continue;e.setAttribute(l,o)}else{a=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi.exec(o),e.setAttribute(i.svgAttr,Ps("rgb({r},{g},{b})",{r:a[1],g:a[2],b:a[3]}));var h=a[4],u=this.globalAlpha;null!=u&&(h*=u),e.setAttribute(i.svgAttr+"-opacity",h)}}__closestGroupOrSvg(t){return"g"===(t=t||this.__currentElement).nodeName||"svg"===t.nodeName?t:this.__closestGroupOrSvg(t.parentNode)}getSerializedSvg(t){var e,n,r,i,o,s=(new XMLSerializer).serializeToString(this.__root);if(t)for(e=Object.keys(Bs),n=0;n<e.length;n++)r=e[n],i=Bs[r],(o=new RegExp(r,"gi")).test(s)&&(s=s.replace(o,i));return s}getSvg(){return this.__root}saveWithTranslationAndClipRect(t,e,n,r,i,o){const s=`${t}_clip_rect`;let a=this.__createElement("clipPath",{id:s});this.__defs.appendChild(a);const c={x:"0",y:o.toString(),width:r.toString(),height:i.toString()};a.appendChild(this.__createElement("rect",c));const l=this.__createElement("g");l.setAttribute("transform",Ps("translate({x},{y})",{x:e,y:n})),l.setAttribute("clip-path",Ps("url(#{id})",{id:s}));const h=this.__closestGroupOrSvg();h.appendChild(l),this.__groupStack.push(h),this.__currentElement=l,this.__stack.push(this.__getStyleState())}save(){var t=this.__createElement("g"),e=this.__closestGroupOrSvg();this.__groupStack.push(e),e.appendChild(t),this.__currentElement=t,this.__stack.push(this.__getStyleState())}restore(){this.__currentElement=this.__groupStack.pop(),this.__currentElementsToStyle=null,this.__currentElement||(this.__currentElement=this.__root.childNodes[1]);var t=this.__stack.pop();this.__applyStyleState(t)}__addTransform(t){var e=this.__closestGroupOrSvg();if(e.childNodes.length>0){"path"===this.__currentElement.nodeName&&(this.__currentElementsToStyle||(this.__currentElementsToStyle={element:e,children:[]}),this.__currentElementsToStyle.children.push(this.__currentElement),this.__applyCurrentDefaultPath());var n=this.__createElement("g");e.appendChild(n),this.__currentElement=n}var r=this.__currentElement.getAttribute("transform");r?r+=" ":r="",r+=t,this.__currentElement.setAttribute("transform",r)}addTrackGroupWithTranslationAndClipRect(t,e,n,r,i,o){const s=t+"_clip_rect";let a=this.__createElement("clipPath",{id:s});this.__defs.appendChild(a),a.appendChild(this.__createElement("rect",{x:"0",y:o.toString(),width:r.toString(),height:i.toString()}));let c=this.__createElement("g");this.__rootGroup.appendChild(c),c.setAttribute("transform",Ps("translate({x},{y})",{x:e,y:n})),c.setAttribute("id",t+"_group"),c.setAttribute("clip-path",Ps("url(#{id})",{id:s})),this.__currentElement=c}scale(t,e){void 0===e&&(e=t),this.__addTransform(Ps("scale({x},{y})",{x:t,y:e}))}rotate(t){var e=180*t/Math.PI;this.__addTransform(Ps("rotate({angle},{cx},{cy})",{angle:e,cx:0,cy:0}))}translate(t,e){this.__addTransform(Ps("translate({x},{y})",{x:t,y:e}))}transform(t,e,n,r,i,o){this.__addTransform(Ps("matrix({a},{b},{c},{d},{e},{f})",{a:t,b:e,c:n,d:r,e:i,f:o}))}beginPath(){var t;this.__currentDefaultPath="",this.__currentPosition={},t=this.__createElement("path",{},!0),this.__closestGroupOrSvg().appendChild(t),this.__currentElement=t}__applyCurrentDefaultPath(){var t=this.__currentElement;"path"===t.nodeName?t.setAttribute("d",this.__currentDefaultPath):console.error("Attempted to apply path command to node",t.nodeName)}__addPathCommand(t){this.__currentDefaultPath+=" ",this.__currentDefaultPath+=t}moveTo(t,e){"path"!==this.__currentElement.nodeName&&this.beginPath(),this.__currentPosition={x:t,y:e},this.__addPathCommand(Ps("M {x} {y}",{x:t,y:e}))}closePath(){this.__currentDefaultPath&&this.__addPathCommand("Z")}lineTo(t,e){this.__currentPosition={x:t,y:e},this.__currentDefaultPath&&this.__currentDefaultPath.indexOf("M")>-1?this.__addPathCommand(Ps("L {x} {y}",{x:t,y:e})):this.__addPathCommand(Ps("M {x} {y}",{x:t,y:e}))}bezierCurveTo(t,e,n,r,i,o){this.__currentPosition={x:i,y:o},this.__addPathCommand(Ps("C {cp1x} {cp1y} {cp2x} {cp2y} {x} {y}",{cp1x:t,cp1y:e,cp2x:n,cp2y:r,x:i,y:o}))}quadraticCurveTo(t,e,n,r){this.__currentPosition={x:n,y:r},this.__addPathCommand(Ps("Q {cpx} {cpy} {x} {y}",{cpx:t,cpy:e,x:n,y:r}))}arcTo(t,e,n,r,i){var o=this.__currentPosition&&this.__currentPosition.x,s=this.__currentPosition&&this.__currentPosition.y;if(void 0!==o&&void 0!==s){if(i<0)throw new Error("IndexSizeError: The radius provided ("+i+") is negative.");if(o===t&&s===e||t===n&&e===r||0===i)this.lineTo(t,e);else{var a=Ds([o-t,s-e]),c=Ds([n-t,r-e]);if(a[0]*c[1]!=a[1]*c[0]){var l=a[0]*c[0]+a[1]*c[1],h=Math.acos(Math.abs(l)),u=Ds([a[0]+c[0],a[1]+c[1]]),f=i/Math.sin(h/2),d=t+f*u[0],p=e+f*u[1],g=[-a[1],a[0]],m=[c[1],-c[0]],v=function(t){var e=t[0];return t[1]>=0?Math.acos(e):-Math.acos(e)},b=v(g),w=v(m);this.lineTo(d+g[0]*i,p+g[1]*i),this.arc(d,p,i,b,w)}else this.lineTo(t,e)}}}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(t,e,n,r){"path"!==this.__currentElement.nodeName&&this.beginPath(),this.moveTo(t,e),this.lineTo(t+n,e),this.lineTo(t+n,e+r),this.lineTo(t,e+r),this.lineTo(t,e),this.closePath()}fillRect(t,e,n,r){r<0&&(e+=r,r=-r),n<0&&(t+=n,n=-n);var i,o,s,a={x:t,y:e,width:n,height:r};(!this.viewbox||(i=this.viewbox,o=a,i.x<o.x+o.width&&i.x+i.width>o.x&&i.y<o.y+o.height&&i.y+i.height>o.y))&&(s=this.__createElement("rect",a,!0),this.__closestGroupOrSvg().appendChild(s),this.__currentElement=s,this.__applyStyleToCurrentElement("fill"))}strokeRect(t,e,n,r){var i;i=this.__createElement("rect",{x:t,y:e,width:n,height:r},!0),this.__closestGroupOrSvg().appendChild(i),this.__currentElement=i,this.__applyStyleToCurrentElement("stroke")}strokeEllipse(t,e,n,r,i,o,s,a){this.__ellipse(t,e,n,r,i,o,s,a,"stroke")}fillEllipse(t,e,n,r,i,o,s,a){this.__ellipse(t,e,n,r,i,o,s,a,"fill")}__ellipse(t,e,n,r,i,o,s,a,c){const l={cx:t,cy:e,rx:n,ry:r},h=this.__createElement("ellipse",l,!0);this.__closestGroupOrSvg().appendChild(h),this.__currentElement=h,this.__applyStyleToCurrentElement(c)}__clearCanvas(){for(var t=this.__closestGroupOrSvg().getAttribute("transform"),e=this.__root.childNodes[1],n=e.childNodes,r=n.length-1;r>=0;r--)n[r]&&e.removeChild(n[r]);this.__currentElement=e,this.__groupStack=[],t&&this.__addTransform(t)}clearRect(t,e,n,r){if(0!==t||0!==e||n!==this.width||r!==this.height){var i,o=this.__closestGroupOrSvg();i=this.__createElement("rect",{x:t,y:e,width:n,height:r,fill:"#FFFFFF"},!0),o.appendChild(i)}else this.__clearCanvas()}createLinearGradient(t,e,n,r){var i=this.__createElement("linearGradient",{id:Os(this.__ids),x1:t+"px",x2:n+"px",y1:e+"px",y2:r+"px",gradientUnits:"userSpaceOnUse"},!1);return this.__defs.appendChild(i),new Hs(i,this)}createRadialGradient(t,e,n,r,i,o){var s=this.__createElement("radialGradient",{id:Os(this.__ids),cx:r+"px",cy:i+"px",r:o+"px",fx:t+"px",fy:e+"px",gradientUnits:"userSpaceOnUse"},!1);return this.__defs.appendChild(s),new Hs(s,this)}__parseFont(){var t=/^\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),e={style:t[1]||"normal",size:t[4]||"10px",family:t[6]||"sans-serif",weight:t[3]||"normal",decoration:t[2]||"normal",href:null};return"underline"===this.__fontUnderline&&(e.decoration="underline"),this.__fontHref&&(e.href=this.__fontHref),e}__wrapTextLink(t,e){if(t.href){var n=this.__createElement("a");return n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",t.href),n.appendChild(e),n}return e}__applyText(t,e,n,r){var i,o,s=this.__parseFont(),a=this.__closestGroupOrSvg(),c=this.__createElement("text",{"font-family":s.family,"font-size":s.size,"font-style":s.style,"font-weight":s.weight,"text-decoration":s.decoration,x:e,y:n,"text-anchor":(i=this.textAlign,o={left:"start",right:"end",center:"middle",start:"start",end:"end"},o[i]||o.start),"dominant-baseline":Fs(this.textBaseline)},!0);c.appendChild(this.__document.createTextNode(t)),this.__currentElement=c,this.__applyStyleToCurrentElement(r),a.appendChild(this.__wrapTextLink(s,c))}fillText(t,e,n){this.__applyText(t,e,n,"fill")}strokeText(t,e,n){this.__applyText(t,e,n,"stroke")}measureText(t){return this.__ctx.font=this.font,this.__ctx.measureText(t)}arc(t,e,n,r,i,o){if(r!==i){(r%=2*Math.PI)===(i%=2*Math.PI)&&(i=(i+2*Math.PI-.001*(o?-1:1))%(2*Math.PI));var s=t+n*Math.cos(i),a=e+n*Math.sin(i),c=t+n*Math.cos(r),l=e+n*Math.sin(r),h=o?0:1,u=0,f=i-r;f<0&&(f+=2*Math.PI),u=o?f>Math.PI?0:1:f>Math.PI?1:0,this.lineTo(c,l),this.__addPathCommand(Ps("A {rx} {ry} {xAxisRotation} {largeArcFlag} {sweepFlag} {endX} {endY}",{rx:n,ry:n,xAxisRotation:0,largeArcFlag:u,sweepFlag:h,endX:s,endY:a})),this.__currentPosition={x:s,y:a}}}clip(){var t=this.__closestGroupOrSvg(),e=this.__createElement("clipPath"),n=Os(this.__ids),r=this.__createElement("g");this.__applyCurrentDefaultPath(),t.removeChild(this.__currentElement),e.setAttribute("id",n),e.appendChild(this.__currentElement),this.__defs.appendChild(e),t.setAttribute("clip-path",Ps("url(#{id})",{id:n})),t.appendChild(r),this.__currentElement=r}drawImage(){var t,e,n,r,i,o,s,a,c,l,h,u,f,d=Array.prototype.slice.call(arguments),p=d[0],g=0,m=0;if(3===d.length)t=d[1],e=d[2],n=i=p.width,r=o=p.height;else if(5===d.length)t=d[1],e=d[2],n=d[3],r=d[4],i=p.width,o=p.height;else{if(9!==d.length)throw new Error("Invalid number of arguments passed to drawImage: "+arguments.length);g=d[1],m=d[2],i=d[3],o=d[4],t=d[5],e=d[6],n=d[7],r=d[8]}s=this.__closestGroupOrSvg();var v="translate("+t+", "+e+")";if(p instanceof js){if((a=p.getSvg().cloneNode(!0)).childNodes&&a.childNodes.length>1){for(c=a.childNodes[0];c.childNodes.length;)f=c.childNodes[0].getAttribute("id"),this.__ids[f]=f,this.__defs.appendChild(c.childNodes[0]);if(l=a.childNodes[1]){var b,w=l.getAttribute("transform");b=w?w+" "+v:v,l.setAttribute("transform",b),s.appendChild(l)}}}else"CANVAS"!==p.nodeName&&"IMG"!==p.nodeName||((h=this.__createElement("image")).setAttribute("width",n),h.setAttribute("height",r),h.setAttribute("preserveAspectRatio","none"),(g||m||i!==p.width||o!==p.height)&&((u=this.__document.createElement("canvas")).width=n,u.height=r,u.getContext("2d").drawImage(p,g,m,i,o,0,0,n,r),p=u),h.setAttribute("transform",v),h.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href","CANVAS"===p.nodeName?p.toDataURL():p.getAttribute("src")),s.appendChild(h))}createPattern(t,e){let n,r=this.__document.__createElement("pattern"),i=Os(this.__ids);return r.setAttribute("id",i),r.setAttribute("width",t.width),r.setAttribute("height",t.height),"CANVAS"===t.nodeName||"IMG"===t.nodeName?(n=this.__createElement("image"),n.setAttribute("width",t.width),n.setAttribute("height",t.height),n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href","CANVAS"===t.nodeName?t.toDataURL():t.getAttribute("src")),r.appendChild(n),this.__defs.appendChild(r)):t instanceof js&&(r.appendChild(t.__root.childNodes[1]),this.__defs.appendChild(r)),new Vs(r,this)}setLineDash(t){t&&t.length>0?this.lineDash=t.join(","):this.lineDash=null}drawFocusRing(){}createImageData(){}getImageData(){}putImageData(){}globalCompositeOperation(){}setTransform(){}}const Us=function(t,e,n,r,i){this.name=t,this.order=e,this.bpStart=n,this.bpLength=r,this.rangeLocus=i},qs=Ce,Ws=new Set(["fastaURL","indexURL","cytobandURL","indexed"]);class $s{constructor(t){this.fastaURL=t.fastaURL,this.withCredentials=t.withCredentials,this.chromosomeNames=[],this.chromosomes={},this.sequences=new Map,this.offsets={};const e={};for(let n in t)t.hasOwnProperty(n)&&!Ws.has(n)&&(e[n]=t[n]);this.config=e}async init(){return this.loadAll()}async getSequence(t,e,n){this.offsets[t]&&(e-=this.offsets[t],n-=this.offsets[t]);let r="";if(e<0)for(let t=e;t<Math.min(n,0);t++)r+="*";if(n<=0)return Promise.resolve(r);const i=this.sequences.get(t),o=Math.min(n,i.length);return r+i.substring(e,o)}async loadAll(){let t;if(ys(this.fastaURL)){let e=Ki(this.fastaURL);t="";for(let n of e)t+=String.fromCharCode(n)}else t=await go.load(this.fastaURL,gs(this.config));const e=qs(t),n=e.length;let r,i,o,s,a=0,c=0,l=0;for(;a<n;)if(o=e[a++].trim(),o.startsWith("#")||0===o.length);else if(o.startsWith(">")){r&&(this.chromosomeNames.push(s),this.sequences.set(s,r),this.chromosomes[s]=new Us(s,l++,c,c+r.length,i));const t=o.substr(1).split(/\s+/)[0].split(":");if(s=t[0],r="",c=0,i=void 0,t.length>1&&t[1].indexOf("-")>0){const e=t[1].split("-");2===e.length&&/^[0-9]+$/.test(e[0])&&/^[0-9]+$/.test(e[1]);const n=Number.parseInt(e[0]);Number.parseInt(e[1])>n&&(c=n-1,this.offsets[s]=c,i=t[1])}}else r+=o;r&&(this.chromosomeNames.push(s),this.sequences.set(s,r),this.chromosomes[s]=new Us(s,l++,c,c+r.length,i))}}const Gs=function(t,e,n,r){this.chr=t,this.start=e,this.end=n,this.features=r};Gs.prototype.contains=function(t,e,n){return this.chr===t&&this.start<=e&&this.end>=n},Gs.prototype.containsRange=function(t){return this.chr===t.chr&&this.start<=t.start&&this.end>=t.end};const Zs=Ce,Xs=new Set(["fastaURL","indexURL","compressedIndexURL","cytobandURL","indexed"]);class Ys{constructor(t){this.file=t.fastaURL,this.indexFile=t.indexURL||t.indexFile||this.file+".fai",this.compressedIndexFile=t.compressedIndexURL||!1,this.withCredentials=t.withCredentials,this.chromosomeNames=[],this.chromosomes={},this.sequences={},this.offsets={};const e={};for(let n in t)t.hasOwnProperty(n)&&!Xs.has(n)&&(e[n]=t[n]);this.config=e}async init(){return this.getIndex()}async getSequence(t,e,n){if(!(this.interval&&this.interval.contains(t,e,n))){let r=e,i=n;if(n-e<5e4){const t=n-e,o=Math.round(e+t/2);r=Math.max(0,o-25e3),i=o+25e3}const o=await this.readSequence(t,r,i);this.interval=new Gs(t,r,i,o)}const r=e-this.interval.start,i=n-e;return this.interval.features?this.interval.features.substr(r,i):null}async getIndex(){if(this.index)return this.index;{const t=await go.load(this.indexFile,gs(this.config)),e=Zs(t),n=e.length;let r=0,i=0;for(this.index={};r<n;){const t=e[r++].split("\t");if(5===t.length){const e=t[0],n=parseInt(t[1]),r={size:n,position:parseInt(t[2]),basesPerLine:parseInt(t[3]),bytesPerLine:parseInt(t[4])};this.chromosomeNames.push(e),this.index[e]=r,this.chromosomes[e]=new Us(e,i++,0,n)}}return this.index}}async getCompressedIndex(){if(this.compressedIndex)return this.compressedIndex;if(!this.compressedIndexFile)return this.compressedIndex=[],this.compressedIndex;this.compressedIndex=[];const t=await go.loadArrayBuffer(this.compressedIndexFile,gs(this.config)),e=t.byteLength;if(e<8)return console.log("Cannot parse GZI index file: length ("+e+" bytes) is insufficient to determine content of index."),this.compressedIndex;const n=t.slice(0,8),r=Number(new DataView(n).getBigUint64(0,!0)),i=8+2*r*8;if(e!=i)return console.log("Incorrect file size of reference genome index. Expected : "+i+". Received : "+e),this.compressedIndex;this.compressedIndex.push([0,0]);for(let e=0;e<r;e++){const n=8+2*e*8,r=8+2*e*8+16,i=t.slice(n,r),o=new DataView(i),s=Number(o.getBigUint64(0,!0)),a=Number(o.getBigUint64(8,!0));this.compressedIndex.push([s,a])}return this.compressedIndex}async getRelevantCompressedBlockNumbers(t,e){if(t<0||e<0||e<t)return console.log("Incompatible query positions for reference-genome. Start:"+t+" | End:"+e),[];await this.getCompressedIndex();let n=[];const r=this.compressedIndex.length-1;if(0==this.compressedIndex.length)return console.log("Compressed index does not contain any content"),[];if(t>this.compressedIndex[r][1])return[r];let i=0,o=r,s=Math.floor(this.compressedIndex.length/2),a=this.compressedIndex.length+1,c=!1;for(let e=0;e<a;e++){const e=this.compressedIndex[s][1],n=s<this.compressedIndex.length-1?this.compressedIndex[s+1][1]:1/0;if(e<=t&&n>t){c=!0;break}e<t?i=s+1:o=s-1,s=Math.ceil((o-i)/2)+i}if(!c)return console.log("No blocks within compressed index found that correspond with query positions "+t+","+e),console.log(this.compressedIndex),[];n.push(s);for(let t=s+1;t<this.compressedIndex.length;t++){n.push(t);if(this.compressedIndex[t][1]>=e)break}const l=n[n.length-1];return l===this.compressedIndex.length-1&&this.compressedIndex[l][1]<e&&n.push(-1),n}async loadAndUncompressBlocks(t,e){if(await this.getCompressedIndex(),0==t.length)return"";let n=Array(t.length-1);for(let e=0;e<t.length-1;e++){const r=t[e],i=this.compressedIndex[r][0],o=t[e+1];let s=[];if(-1!=o){const t=this.compressedIndex[o][0]-i;s=await go.loadArrayBuffer(this.file,gs(this.config,{range:{start:i,size:t}}))}else s=await go.loadArrayBuffer(this.file,gs(this.config,{range:{start:i}}));const a=await $i(s);n[e]=a}let r="";for(let t=0;t<n.length;t++)for(let e=0;e<n[t].length;e++){r+=String.fromCharCode(n[t][e])}const i=e-this.compressedIndex[t[0]][1];return r=r.substring(i),r}async readSequence(t,e,n){await this.getIndex(),await this.getCompressedIndex();const r=this.index[t];if(!r)return console.log("No index entry for chr: "+t),this.interval=new Gs(t,e,n,null),null;const i=Math.max(0,e),o=Math.min(r.size,n),s=r.bytesPerLine,a=r.basesPerLine,c=r.position,l=s-a,h=Math.floor(i/a),u=Math.floor(o/a),f=i-h*a,d=c+h*s+f,p=c+u*s+(o-u*a)-1,g=p-d+1;if(g<=0)return console.error("No sequence for "+t+":"+e+"-"+n),null;let m;if(this.compressedIndexFile){let t=await this.getRelevantCompressedBlockNumbers(d,p);if(0===t.length)return console.log("No blocks in the compressed index that correspond with the requested byte positions ("+d+","+p+")"),null;m=await this.loadAndUncompressBlocks(t,d)}else m=await go.load(this.file,gs(this.config,{range:{start:d,size:g}}));if(!m)return null;let v,b="",w=0,y=m.length;for(f>0&&(v=Math.min(o-i,a-f),b+=m.substr(w,v),w+=v+l);w<y;)v=Math.min(a,y-w),b+=m.substr(w,v),w+=v+l;return b}}const Ks=Ce;class Qs{constructor(t){this.url=t,this.chromosomeNames=[],this.chromosomes={}}async init(){return this.loadAll()}async getSequence(t,e,n){}async loadAll(){let t;if(ys(this.url)){let e=Ki(this.fastaURL);t="";for(let n of e)t+=String.fromCharCode(n)}else t=await go.load(this.url,{});this.chromosomeNames=[],this.chromosomes={};const e=Ks(t);let n=0;for(let t of e){const e=t.split("\t");this.chromosomeNames.push(e[0]);const r=Number.parseInt(e[1]),i=new Us(e[0],n++,0,r);this.chromosomes[e[0]]=i}}}const Js=function(t,e,n,r){this.start=t,this.end=e,this.name=n,this.stain=0,"acen"===r?this.type="c":(this.type=r.charAt(1),"p"===this.type&&(this.stain=parseInt(r.substring(4))))};function ta(){return"2.12.4"}const ea=Ce,na={loadGenome:async function(t){const e=t.cytobandURL,n=t.aliasURL,r=await async function(t){let e;return e="chromsizes"===t.format?new Qs(t.fastaURL):ys(t.fastaURL)||!1===t.indexed?new $s(t):new Ys(t),await e.init(),e}(t);let i,o;return e&&(i=await async function(t,e){let n;if(ys(t)){const e=Ki(t);n="";const r=e.length;for(let t=0;t<r;t++)n+=String.fromCharCode(e[t])}else n=await go.loadString(t,gs(e));const r={};let i,o=[];const s=ea(n);for(let t of s){var a=t.split("\t"),c=a[0];if(i||(i=c),c!==i&&(r[i]=o,o=[],i=c),5===a.length){var l=parseInt(a[1]),h=parseInt(a[2]),u=a[3],f=a[4];o.push(new Js(l,h,u,f))}}return r}(e,r.config)),n&&(o=await function(t,e){return go.loadString(t,gs(e)).then((function(t){var e=ea(t),n=[];return e.forEach((function(t){!t.startsWith("#")&&t.length>0&&n.push(t.split("\t"))})),n}))}(n,r.config)),new ra(t,r,i,o)},initializeGenomes:async function(t){if(!na.KNOWN_GENOMES){const n={};if(!1!==t.loadDefaultGenomes)try{const i=`https://igv.org/genomes/genomes.json?randomSeed=${Math.random().toString(36)}&version=2.12.4`;e(await go.loadJson(i,{timeout:5e3}))}catch(o){console.error(o);try{const s=`https://s3.amazonaws.com/igv.org.genomes/genomes.json?randomSeed=${Math.random().toString(36)}&version=2.12.4`;e(await go.loadJson(s,{}))}catch(a){console.error(a),console.warn("Errors loading default genome definitions.")}}const r=t.genomeList||t.genomes;if(r)if("string"==typeof r){e(await go.loadJson(r,{}))}else e(r);function e(t){return t.forEach((function(t){n[t.id]=t})),n}na.KNOWN_GENOMES=n}},isWholeGenomeView:function(t){return"all"===t.toLowerCase()},expandReference:function(t){if(_e(t)&&t.startsWith("{"))try{t=JSON.parse(t)}catch(t){}let e;if(_e(t)?e=t:t.genome?e=t.genome:void 0!==t.id&&void 0===t.fastaURL&&(e=t.id),e){const t=na.KNOWN_GENOMES[e];return t||Qo.presentAlert(new Error(`Unknown genome id: ${e}`),void 0),t}return t}};class ra{constructor(t,e,n,r){this.config=t,this.id=t.id||function(t){return void 0!==t.id?t.id:t.fastaURL&&_e(t.fastaURL)?t.fastaURL:t.fastaURL&&t.fastaURL.name?t.fastaURL.name:("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)}(t),this.sequence=e,this.chromosomeNames=e.chromosomeNames,this.chromosomes=e.chromosomes,this.ideograms=n,this.featureDB={},this.wholeGenomeView=void 0===t.wholeGenomeView||t.wholeGenomeView,this.wholeGenomeView&&Object.keys(e.chromosomes).length>1?function(t,e){let n;if(e.chromosomeOrder)Array.isArray(e.chromosomeOrder)?t.wgChromosomeNames=e.chromosomeOrder:t.wgChromosomeNames=e.chromosomeOrder.split(",").map((t=>t.trim())),n=t.wgChromosomeNames.map((e=>t.chromosomes[e])).filter((t=>void 0!==t));else{const e=Object.keys(t.chromosomes).map((e=>t.chromosomes[e].bpLength)).reduce(((t,e)=>Math.max(t,e)))/50;n=Object.values(t.chromosomes).filter((t=>t.bpLength>e));const r=n.filter((t=>i(t.name.replace("chr","")))),o=n.filter((t=>!i(t.name.replace("chr",""))));r.sort(((t,e)=>Number.parseInt(t.name.replace("chr",""))-Number.parseInt(e.name.replace("chr",""))));const s=r.map((t=>t.name));for(let t of o)s.push(t.name);t.wgChromosomeNames=s}const r=n.reduce(((t,e)=>t+e.bpLength),0);function i(t){return/^\d+$/.test(t)}t.chromosomes.all={name:"all",bpLength:r}}(this,t):this.wgChromosomeNames=e.chromosomeNames;var i={},o=this;i.all="all",this.chromosomeNames.forEach((function(t){var e=t.startsWith("chr")?t.substring(3):"chr"+t;i[e.toLowerCase()]=t,"chrM"===t&&(i.mt="chrM"),"MT"===t&&(i.chrm="MT"),i[t.toLowerCase()]=t})),r&&r.forEach((function(t){var e,n;for(n=0;n<t.length;n++)if(o.chromosomes[t[n]]){e=t[n];break}e&&t.forEach((function(t){t!==e&&(i[t.toLowerCase()]=e,i[t]=e)}))})),this.chrAliasTable=i}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(t){const e=t?this.chrAliasTable[t.toLowerCase()]:t;return e||t}getChromosome(t){return t=this.getChromosomeName(t),this.chromosomes[t]}getCytobands(t){return this.ideograms?this.ideograms[t]:null}getLongestChromosome(){var t,e=this.chromosomes;for(let r in e){if(e.hasOwnProperty(r)){var n=e[r];(void 0===t||n.bpLength>t.bpLength)&&(t=n)}return t}}getChromosomes(){return this.chromosomes}getGenomeCoordinate(t,e){var n=this.getCumulativeOffset(t);if(void 0!==n)return n+e}getChromosomeCoordinate(t){let e;void 0===this.cumulativeOffsets&&(this.cumulativeOffsets=computeCumulativeOffsets.call(this));let n=0;for(let r of this.wgChromosomeNames){const i=this.cumulativeOffsets[r];if(i>t){return{chr:e,position:t-n}}e=r,n=i}return{chr:this.wgChromosomeNames[this.wgChromosomeNames.length-1],position:0}}getCumulativeOffset(t){void 0===this.cumulativeOffsets&&(this.cumulativeOffsets=function(){let t=this,e={},n=0;for(let r of t.wgChromosomeNames){e[r]=Math.floor(n);n+=t.getChromosome(r).bpLength}return e}.call(this));const e=this.getChromosomeName(t);return this.cumulativeOffsets[e]}getGenomeLength(){let t=this;if(!this.bpLength){let e=0;t.wgChromosomeNames.forEach((function(n){let r=t.chromosomes[n];e+=r.bpLength})),this.bpLength=e}return this.bpLength}async getSequence(t,e,n){return t=this.getChromosomeName(t),this.sequence.getSequence(t,e,n)}}let ia,oa=0;class sa extends class{constructor(t,e,n,r){this.guid=be(),this.trackView=t,this.referenceFrame=n,this.browser=t.browser,this.$viewport=pe('<div class="igv-viewport">'),e.appendChild(this.$viewport.get(0)),t.track.height&&(this.$viewport.get(0).style.height=`${t.track.height}px`),t.track instanceof Ns&&(this.alert=new Yo(this.$viewport.get(0))),this.$content=pe("<div>",{class:"igv-viewport-content"}),this.$viewport.append(this.$content),this.$content.height(this.$viewport.height()),this.contentDiv=this.$content.get(0),this.$viewport.width(r),this.initializationHelper()}initializationHelper(){}showMessage(t){this.messageDiv||(this.messageDiv=document.createElement("div"),this.messageDiv.className="igv-viewport-message",this.contentDiv.append(this.messageDiv)),this.messageDiv.textContent=t,this.messageDiv.style.display="inline-block"}hideMessage(t){this.messageDiv&&(this.messageDiv.style.display="none")}setTrackLabel(t){}startSpinner(){}stopSpinner(){}checkZoomIn(){return!0}shift(){}setTop(t){const e=-t,n=e+this.$viewport.height();this.$content.css("top",`${t}px`),(void 0===this.canvasVerticalRange||this.canvasVerticalRange.bottom<n||this.canvasVerticalRange.top>e)&&this.repaint()}async loadFeatures(){}async repaint(){console.log("Viewport - repaint()")}draw(t,e,n){console.log("Viewport - draw(drawConfiguration, features, roiFeatures)")}checkContentHeight(t){let e=this.trackView.track;if(t=t||this.cachedFeatures,"FILL"===e.displayMode)this.setContentHeight(this.$viewport.height());else if("function"==typeof e.computePixelHeight&&t&&t.length>0){let n=e.computePixelHeight(t);n!==this.$content.height()&&this.setContentHeight(n)}}getContentHeight(){return this.$content.height()}setContentHeight(t){t=Math.min(t,32e3),this.$content.height(t)}isLoading(){return!1}saveSVG(){}isVisible(){return this.$viewport.width()}setWidth(t){this.$viewport.width(t)}getWidth(){return this.$viewport.width()}getContentTop(){return this.contentDiv.offsetTop}containsPosition(t,e){console.log("Viewport - containsPosition(chr, position)")}addMouseHandlers(){}removeMouseHandlers(){}dispose(){this.popover&&this.popover.dispose(),this.$viewport.get(0).remove();for(let t of Object.keys(this))this[t]=void 0}}{constructor(t,e,n,r){super(t,e,n,r)}initializationHelper(){this.$spinner=pe("<div>",{class:"igv-loading-spinner-container"}),this.$viewport.append(this.$spinner),this.$spinner.append(pe("<div>"));const t=this.trackView.track;"sequence"!==t.type&&(this.$zoomInNotice=this.createZoomInNotice(this.$content)),t.name&&"sequence"!==t.id&&(this.$trackLabel=pe('<div class="igv-track-label">'),this.$viewport.append(this.$trackLabel),this.setTrackLabel(t.name),!1===this.browser.trackLabelsVisible&&this.$trackLabel.hide()),this.stopSpinner(),this.addMouseHandlers()}setContentHeight(t){super.setContentHeight(t),this.featureCache&&(this.featureCache.redraw=!0)}setTrackLabel(t){this.$trackLabel.empty(),this.$trackLabel.html(t);const e=this.$trackLabel.text();this.$trackLabel.attr("title",e)}startSpinner(){this.$spinner.show()}stopSpinner(){this.$spinner&&this.$spinner.hide()}checkZoomIn(){if(this.trackView.track&&"sequence"===this.trackView.track.type&&this.referenceFrame.bpPerPixel>1)return pe(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 t=this.trackView.track.visibilityWindow;return void 0!==t&&t>0&&this.referenceFrame.bpPerPixel*this.$viewport.width()>t}return!0})()){if(this.canvas&&(pe(this.canvas).remove(),this.canvas=void 0),this.trackView.track.autoHeight){const t=this.trackView.minHeight||0;this.setContentHeight(t)}return this.$zoomInNotice&&this.$zoomInNotice.show(),!1}return this.$zoomInNotice&&this.$zoomInNotice.hide(),!0}shift(){const t=this.referenceFrame;if(this.canvas&&this.canvas._data&&this.canvas._data.chr===this.referenceFrame.chr&&this.canvas._data.bpPerPixel===t.bpPerPixel){const e=Math.round((this.canvas._data.startBP-t.start)/t.bpPerPixel);this.canvas.style.left=e+"px"}}async loadFeatures(){const t=this.referenceFrame,e=t.chr,n=this.browser.genome.getChromosome(e).bpLength,r=this.$content.width()*t.bpPerPixel,i=Math.floor(Math.max(0,t.start-r)),o=Math.ceil(Math.min(n,t.start+r+r));if(!this.loading||this.loading.start!==i||this.loading.end!==o){this.loading={start:i,end:o},this.startSpinner();try{const n=this.trackView.track,r=await this.getFeatures(n,e,i,o,t.bpPerPixel);let c=[];const l=(s=this.browser.roi,a=n.roi,s&&a?s.concat(a):s||a);if(l)for(let n of l){const r=await n.getFeatures(e,i,o,t.bpPerPixel);c.push({track:n,features:r})}const h=n&&("wig"===n.type||"merged"===n.type);return this.featureCache=new ca(e,i,o,t.bpPerPixel,r,c,h),this.loading=!1,this.hideMessage(),this.stopSpinner(),this.featureCache}catch(t){this.trackView&&!0!==this.trackView.disposed&&(this.showMessage("Error loading track data"),Qo.presentAlert(t),console.error(t))}finally{this.loading=!1,this.stopSpinner()}var s,a}}repaintDimensions(){const t=na.isWholeGenomeView(this.referenceFrame.chr),e=t?this.$viewport.width():3*this.$viewport.width(),n=this.referenceFrame.bpPerPixel;return{startBP:this.referenceFrame.start-(t?0:e/3*n),endBP:this.referenceFrame.end+(t?0:e/3*n),pixelWidth:e}}repaint(){if(void 0===this.featureCache)return;let{features:t,roiFeatures:e}=this.featureCache;na.isWholeGenomeView(this.referenceFrame.chr);const{startBP:n,endBP:r,pixelWidth:i}=this.repaintDimensions(),o=this.$viewport.height(),s=this.getContentHeight(),a=e?Math.max(s,o):s,c=Math.min(a,3*o);if(0===i||0===c)return void(this.canvas&&pe(this.canvas).remove());const l=Math.max(0,-this.$content.position().top-o),h=this.referenceFrame.bpPerPixel,u=Math.round((n-this.referenceFrame.start)/h),f=pe('<canvas class="igv-canvas">').get(0);f.style.width=i+"px",f.style.height=c+"px",f.style.left=u+"px",f.style.top=l+"px";const d="FILL"===this.trackView.track.displayMode||!1!==this.trackView.track.supportHiDPI?window.devicePixelRatio:1;f.width=d*i,f.height=d*c;const p=f.getContext("2d");p.scale(d,d),p.translate(0,-l);const g={context:p,pixelXOffset:u,pixelWidth:i,pixelHeight:c,pixelTop:l,bpStart:n,bpEnd:r,bpPerPixel:h,referenceFrame:this.referenceFrame,selection:this.selection,viewport:this,viewportWidth:this.$viewport.width()};this.draw(g,t,e),this.featureCache.canvasTop=l,this.featureCache.height=c,this.canvas&&pe(this.canvas).remove(),f._data={chr:this.featureCache.chr,bpPerPixel:h,startBP:n,endBP:r,pixelHeight:c,pixelTop:l},this.canvas=f,this.$content.append(pe(f))}draw(t,e,n){if(e&&(t.features=e,this.trackView.track.draw(t)),n)for(let e of n)t.features=e.features,e.track.draw(t)}containsPosition(t,e){return this.referenceFrame.chr===t&&e>=this.referenceFrame.start&&e<=this.referenceFrame.calculateEnd(this.getWidth())}isLoading(){return this.loading}savePNG(){if(!this.canvas)return;const t=this.featureCache,e=t?t.canvasTop:0,n=window.devicePixelRatio,r=this.$viewport.width()*n,i=this.$viewport.height()*n,o=-pe(this.canvas).position().left*n,s=(-this.$content.position().top-e)*n,a=this.canvas.getContext("2d").getImageData(o,s,r,i),c=document.createElement("canvas"),l=c.getContext("2d");c.width=a.width,c.height=a.height,l.putImageData(a,0,0);We((this.$trackLabel.text()?this.$trackLabel.text():"image")+".png",c.toDataURL("image/png"))}saveSVG(){const{width:t,height:e}=this.$viewport.get(0).getBoundingClientRect(),n={width:t,height:e,viewbox:{x:0,y:-this.$content.position().top,width:t,height:e}},r=new js(n),i=`${(this.trackView.track.name||this.trackView.track.id).replace(/\W/g,"")}_referenceFrame_${this.browser.referenceFrameList.indexOf(this.referenceFrame)}_guid_${be()}`;this.drawSVGWithContext(r,t,e,i,0,0,0);const o=r.getSerializedSvg(!0);We(`${i}.svg`,URL.createObjectURL(new Blob([o],{type:"application/octet-stream"})))}renderSVGContext(t,{deltaX:e,deltaY:n}){if(this.$zoomInNotice&&this.$zoomInNotice.is(":visible"))return;const r=`${(this.trackView.track.name||this.trackView.track.id).replace(/\W/g,"")}_referenceFrame_${this.browser.referenceFrameList.indexOf(this.referenceFrame)}_guid_${be()}`,{top:i}=this.$content.position(),{width:o,height:s}=this.$viewport.get(0).getBoundingClientRect();if(this.drawSVGWithContext(t,o,s,r,e,n+i,-i),this.$trackLabel&&!0===this.browser.trackLabelsVisible){const{x:r,y:i,width:o,height:s}=((t,e)=>{const{x:n,y:r,width:i,height:o}=t.getBoundingClientRect(),{x:s,y:a,width:c,height:l}=e.getBoundingClientRect();return{x:s-n,y:a-r,width:c,height:l}})(this.$viewport.get(0),this.$trackLabel.get(0));this.renderTrackLabelSVG(t,e+r,n+i,o,s)}}renderTrackLabelSVG(t,e,n,r,i){const o=`${(this.trackView.track.name||this.trackView.track.id).replace(/\W/g,"")}_track_label_guid_${be()}`;t.saveWithTranslationAndClipRect(o,e,n,r,i,0),t.fillStyle="white",t.fillRect(0,0,r,i),t.font="12px Arial",t.fillStyle="rgb(68, 68, 68)";const{width:s}=t.measureText(this.$trackLabel.text()),a=.25*(r-s),c=.7*(i-12);t.fillText(this.$trackLabel.text(),a,i-c),t.strokeStyle="rgb(68, 68, 68)",t.strokeRect(0,0,r,i),t.restore()}drawSVGWithContext(t,e,n,r,i,o,s){t.saveWithTranslationAndClipRect(r,i,o,e,n,s);let{start:a,bpPerPixel:c}=this.referenceFrame;const l={context:t,viewport:this,referenceFrame:this.referenceFrame,top:s,pixelTop:s,pixelWidth:e,pixelHeight:n,bpStart:a,bpEnd:a+e*c,bpPerPixel:c,viewportWidth:e,selection:this.selection},h=this.featureCache?this.featureCache.features:[],u=this.featureCache?this.featureCache.roiFeatures:void 0;this.draw(l,h,u),t.restore()}get cachedFeatures(){return this.featureCache?this.featureCache.features:[]}async getFeatures(t,e,n,r,i){if(this.featureCache&&this.featureCache.containsRange(e,n,r,i))return this.featureCache.features;if("function"==typeof t.getFeatures){const o=await t.getFeatures(e,n,r,i,this);return this.checkContentHeight(o),o}}needsRepaint(){if(!this.canvas)return!0;const t=this.canvas._data;return!t||this.referenceFrame.start<t.startBP||this.referenceFrame.end>t.endBP||this.referenceFrame.chr!==t.chr||this.referenceFrame.bpPerPixel!=t.bpPerPixel}needsReload(){if(!this.featureCache)return!0;const t=this.referenceFrame,e=this.referenceFrame.chr,n=t.bpPerPixel,{startBP:r,endBP:i}=this.repaintDimensions();return!this.featureCache.containsRange(e,r,i,n)}createZoomInNotice(t){const e=pe("<div>",{class:"igv-zoom-in-notice-container"});t.append(e);const n=pe("<div>");return e.append(n),n.text("Zoom in to see features"),e.hide(),e}viewIsReady(){return this.browser&&this.browser.referenceFrameList&&this.referenceFrame}addMouseHandlers(){const t=this.$viewport.get(0);this.addViewportContextMenuHandler(t);const e=t=>{this.enableClick=!0,this.browser.mouseDownOnViewport(t,this),ve(t)};t.addEventListener("mousedown",e),t.addEventListener("touchstart",e);const n=t=>{this.browser.dragObject||this.browser.isScrolling?(this.browser.cancelTrackPan(),this.enableClick=!1):(this.browser.cancelTrackPan(),this.browser.endTrackDrag())};t.addEventListener("mouseup",n),t.addEventListener("touchend",n),this.addViewportClickHandler(this.$viewport.get(0)),this.trackView.track.name&&"sequence"!==this.trackView.track.config.type&&this.addTrackLabelClickHandler(this.$trackLabel.get(0))}addViewportContextMenuHandler(t){t.addEventListener("contextmenu",(t=>{if(this.browser.dragObject)return!1;const e=aa(t,this);if(void 0===e)return!1;t.preventDefault();let n=[];if("function"==typeof this.trackView.track.contextMenuItemList){const t=this.trackView.track.contextMenuItemList(e);t&&(n=t)}n.length>0&&n.push({label:pe("<HR>")}),n.push({label:"Save Image (PNG)",click:()=>this.saveImage()}),n.push({label:"Save Image (SVG)",click:()=>this.saveSVG()}),this.browser.menuPopup.presentTrackContextMenu(t,n)}))}addViewportClickHandler(t){t.addEventListener("click",(t=>{if(this.enableClick&&this.canvas){if(3===t.which||t.ctrlKey)return;if(pe(".igv-popover").hide(),this.browser.dragObject||this.browser.isScrolling)return;t.preventDefault();const e=we(t,this.$viewport.get(0)).x,n=we(t,this.canvas).x,r=this.referenceFrame,i=Math.floor(r.start+r.toBP(n)),o=Date.now();if(o-oa<this.browser.constants.doubleClickDelay){ia&&(window.clearTimeout(ia),ia=void 0);const t=Math.round(r.start+r.toBP(e));let n;if("all"===this.referenceFrame.chr.toLowerCase()){const e=this.browser.genome.getChromosomeCoordinate(t).chr;if(1===this.browser.referenceFrameList.length)n=e;else{const t=this.browser.referenceFrameList.map((({locusSearchString:t})=>t));t[this.browser.referenceFrameList.indexOf(this.referenceFrame)]=e,n=t.join(" ")}this.browser.search(n)}else this.browser.zoomWithScaleFactor(.5,t,this.referenceFrame)}else t.shiftKey&&"function"==typeof this.trackView.track.shiftClick?this.trackView.track.shiftClick(i,t):"function"==typeof this.trackView.track.popupData&&(ia=setTimeout((()=>{const e=function(t,e){const n=aa(t,e);if(void 0===n)return;let r=e.trackView.track;const i=r.popupData(n),o=e.browser.fireEvent("trackclick",[r,i]);let s;void 0===o||!0===o?i&&i.length>0&&(s=i.map((t=>{if(t.name){const e=`<span>${t.name}</span>   ${t.value}`;return`<div title="${t.value}">${e}</div>`}return"<hr>"===t?t:t.html?t.html:`<div title="${t}">${t}</div>`})).join("")):"string"==typeof o&&(s=o);return s}(t,this);e&&(this.popover&&this.popover.dispose(),this.popover=new os(this.browser.columnContainer),this.popover.presentContentWithEvent(t,e)),window.clearTimeout(ia),ia=void 0}),this.browser.constants.doubleClickDelay));oa=o}}))}addTrackLabelClickHandler(t){t.addEventListener("click",(t=>{t.stopPropagation();const{track:e}=this.trackView;let n;"function"==typeof e.description?n=e.description():e.description&&(n=`<div>${e.description}</div>`),n&&(this.popover&&this.popover.dispose(),this.popover=new os(this.browser.columnContainer,e.name||""),this.popover.presentContentWithEvent(t,n))}))}}function aa(t,e){const n=e.referenceFrame,r=we(t,e.contentDiv),i=we(t,e.canvas),o=n.start+n.toBP(r.x);return{event:t,viewport:e,referenceFrame:n,genomicLocation:o,x:r.x,y:r.y,canvasX:i.x,canvasY:i.y}}class ca{constructor(t,e,n,r,i,o,s){this.chr=t,this.startBP=e,this.endBP=n,this.bpPerPixel=r,this.features=i,this.roiFeatures=o,this.multiresolution=s}containsRange(t,e,n,r){const i=this.multiresolution?this.bpPerPixel/r:1;return e>=this.startBP&&n<=this.endBP&&t===this.chr&&i>.5&&i<2}overlapsRange(t,e,n){return this.chr===t&&n>=this.startBP&&e<=this.endBP}}class la{constructor(t){this.rulerSweeper=ge({class:"igv-ruler-sweeper"}),t.contentDiv.appendChild(this.rulerSweeper),this.rulerViewport=t,this.isMouseHandlers=void 0,this.addBrowserObserver()}addBrowserObserver(){this.boundObserverHandler=function(){this.rulerViewport.referenceFrame&&(na.isWholeGenomeView(this.rulerViewport.referenceFrame.chr)?this.removeMouseHandlers():this.addMouseHandlers())}.bind(this),this.rulerViewport.browser.on("locuschange",this.boundObserverHandler)}removeBrowserObserver(){this.rulerViewport.browser.off("locuschange",this.boundObserverHandler)}addMouseHandlers(){if(!0===this.isMouseHandlers)return;let t,e,n,r,i,o;this.boundContentMouseDownHandler=function(o){t=!0,e=!0;const{x:s}=we(o,this.rulerViewport.contentDiv);r=n=s,i=1,this.rulerSweeper.style.display="block",this.rulerSweeper.style.left=`${r}px`,this.rulerSweeper.style.width=`${i}px`}.bind(this),this.rulerViewport.contentDiv.addEventListener("mousedown",this.boundContentMouseDownHandler),this.boundDocumentMouseMoveHandler=function(s){let a;if(t&&e){const{x:t}=we(s,this.rulerViewport.contentDiv);a=Math.max(Math.min(t,this.rulerViewport.contentDiv.clientWidth),0),o=a-n,i=Math.abs(o),this.rulerSweeper.style.width=`${i}px`,o<0&&(r=n+o,this.rulerSweeper.style.left=`${r}px`)}}.bind(this),document.addEventListener("mousemove",this.boundDocumentMouseMoveHandler),this.boundDocumentMouseUpHandler=function(n){let o;if(!0===t&&!0===e&&(t=e=void 0,this.rulerSweeper.style.display="none",i>1)){o={start:ha(this.rulerViewport.referenceFrame,r),end:ha(this.rulerViewport.referenceFrame,r+i)},vs(this.rulerViewport.browser.genome.getChromosome(this.rulerViewport.referenceFrame.chr).bpLength,o,this.rulerViewport.browser.minimumBases());const t=Math.round(o.start),e=Math.round(o.end);this.rulerViewport.referenceFrame.bpPerPixel=(e-t)/this.rulerViewport.contentDiv.clientWidth,this.rulerViewport.referenceFrame.start=t,this.rulerViewport.referenceFrame.end=e,this.rulerViewport.browser.updateViews()}}.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()}}function ha(t,e){return t.start+e*t.bpPerPixel}class ua{constructor(t){this.paired=!0,this.firstAlignment=t,this.chr=t.chr,this.readName=t.readName,t.start<t.mate.position?(this.start=t.start,this.scStart=t.scStart,this.connectingStart=t.start+t.lengthOnRef,this.connectingEnd=t.mate.position):(this.start=t.mate.position,this.scStart=this.start,this.connectingStart=t.mate.position,this.connectingEnd=t.start),this.end=Math.max(t.mate.position,t.start+t.lengthOnRef),this.lengthOnRef=this.end-this.start;let e=Math.max(this.end,t.scStart+t.scLengthOnRef);this.scLengthOnRef=e-this.scStart}setSecondAlignment(t){this.secondAlignment=t;const e=this.firstAlignment;t.start>e.start?this.connectingEnd=t.start:this.connectingStart=t.start+t.lengthOnRef,this.start=Math.min(e.start,t.start),this.end=Math.max(e.start+e.lengthOnRef,t.start+t.lengthOnRef),this.lengthOnRef=this.end-this.start,this.scStart=Math.min(e.scStart,t.scStart);const n=Math.max(e.scStart+e.scLengthOnRef,t.scStart+t.scLengthOnRef);this.scLengthOnRef=n-this.scStart}containsLocation(t,e){const n=e?this.scStart:this.start,r=e?this.scLengthOnRef:this.lengthOnRef;return t>=n&&t<=n+r}alignmentContaining(t,e){return this.firstAlignment.containsLocation(t,e)?this.firstAlignment:this.secondAlignment&&this.secondAlignment.containsLocation(t,e)?this.secondAlignment:void 0}popupData(t){let e=this.firstAlignment.popupData(t);return this.secondAlignment&&(e.push("-------------------------------"),e=e.concat(this.secondAlignment.popupData(t))),e}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(t){return this.firstAlignment.hasTag(t)||this.secondAlignment&&this.secondAlignment.hasTag(t)}}const fa=_e,da=function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)};class pa{constructor(){this.alignments=[],this.score=void 0}findAlignment(t){const e=(t,e)=>e>=t.start&&e<t.start+t.lengthOnRef;let n;for(let r=0;r<this.alignments.length;r++){const i=this.alignments[r];if(t>=i.start&&t<i.start+i.lengthOnRef){i.paired?i.firstAlignment&&e(i.firstAlignment,t)?n=i.firstAlignment:i.secondAlignment&&e(i.secondAlignment,t)&&(n=i.secondAlignment):n=i;break}}return n}updateScore(t,e){this.score=this.calculateScore(t,e)}calculateScore({position:t,option:e,direction:n,tag:r},i){e||(e="BASE");const o=this.findAlignment(t);if(void 0===o)return Number.MAX_VALUE*(n?1:-1);let s;switch(e){case"NUCLEOTIDE":case"BASE":return function(t,e,n){let r;const i=Math.floor(n)-e.start;i<e.sequence.length&&(r=e.sequence.charAt(i));if(!r)return 0;const o=t.readBaseAt(n),s=t.readBaseQualityAt(n),a=e.coverageMap,c=Math.floor(n-a.bpStart),l=a.coverage[c];let h=0;if(t.insertions)for(let e of t.insertions)e.start===n&&(h=-l.ins);if(o)if(r=r.toUpperCase(),"N"===o&&0===h)h=2;else if(r!==o&&"="!==o||0!==h){if("X"===o||r!==o){h-=l["pos"+o]+l["neg"+o]+s/1e3}}else h=4-s/1e3;else{const t=l.del;t>0?h-=t:0===h&&(h=1)}return h}(o,i,t);case"STRAND":return o.strand?1:-1;case"START":return o.start;case"TAG":{const t=o.tags()[r];return void 0!==t?fa(t)?da(t):t:Number.MAX_VALUE}case"READ_NAME":return da(o.readName);case"INSERT_SIZE":return-Math.abs(o.fragmentLength);case"GAP_SIZE":return-o.gapSizeAt(t);case"MATE_CHR":return s=o.mate,s?s.chr===o.chr?Number.MAX_VALUE-1:da(s.chr):Number.MAX_VALUE;case"MQ":return void 0===o.mq?Number.MAX_VALUE:-o.mq;default:return Number.MAX_VALUE}}}function ga(t){return t.isPaired()&&t.mate&&t.isMateMapped()&&t.chr===t.mate.chr&&(t.isFirstOfPair()||t.isSecondOfPair())&&!(t.isSecondary()||t.isSupplementary())}function ma(t){const e=[];for(let n of t)for(let t of n.alignments)t instanceof ua?(t.firstAlignment&&e.push(t.firstAlignment),t.secondAlignment&&e.push(t.secondAlignment)):e.push(t);return e}function va(t,e,n,r){if(t){if(0===t.length)return[];{t.sort((function(t,e){return r?t.scStart-e.scStart:t.start-e.start}));const i=t[0];let o=Math.max(e,r?i.scStart:i.start),s=o;const a=[];for(let e of t){const t=r?e.scStart:e.start,n=Math.max(0,t-o);void 0===a[n]&&(a[n]=[]),a[n].push(e)}let c=0,l=0;const h=[],u=2;try{for(;c<t.length;){const t=new pa;for(;s<=n;){let e,i;for(;!e&&s<=n;)i=s-o,void 0===a[i]?++s:e=a[i];if(!e)break;const l=e.pop();0===e.length&&(a[i]=void 0),t.alignments.push(l),s=r?l.scStart+l.scLengthOnRef+u:l.start+l.lengthOnRef+u,++c}if(t.alignments.length>0&&h.push(t),s=o,c===l)break;l=c}}catch(t){throw console.error(t),t}return h}}}class ba{constructor(t,e,n,{samplingWindowSize:r,samplingDepth:i,pairsSupported:o,alleleFreqThreshold:s}){this.chr=t,this.start=Math.floor(e),this.end=Math.ceil(n),this.length=n-e,this.alleleFreqThreshold=void 0===s?.2:s,this.coverageMap=new ya(t,e,n,this.alleleFreqThreshold),this.alignments=[],this.downsampledIntervals=[],this.samplingWindowSize=void 0===r?100:r,this.samplingDepth=void 0===i?1e3:i,this.pairsSupported=void 0===o||o,this.paired=!1,this.pairsCache={},this.downsampledReads=new Set,this.currentBucket=new wa(this.start,this.start+this.samplingWindowSize,this),this.filter=function(t){return t.isMapped()&&!t.isFailsVendorQualityCheck()}}push(t){!1!==this.filter(t)&&(this.coverageMap.incCounts(t),this.pairsSupported&&this.downsampledReads.has(t.readName)||(t.start>=this.currentBucket.end&&(this.finishBucket(),this.currentBucket=new wa(t.start,t.start+this.samplingWindowSize,this)),this.currentBucket.addAlignment(t)))}forEach(t){this.alignments.forEach(t)}finish(){void 0!==this.currentBucket&&this.finishBucket(),this.alignments.sort((function(t,e){return t.start-e.start})),this.pairsCache=void 0,this.downsampledReads=void 0}contains(t,e,n){return this.chr===t&&this.start<=e&&this.end>=n}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 ka(this.currentBucket.start,this.currentBucket.end,this.currentBucket.downsampledCount)),this.paired=this.paired||this.currentBucket.paired}setViewAsPairs(t){let e;e=t?function(t){const e={},n=[];for(let r of t)for(let t of r.alignments)if(ga(t)){let r=e[t.readName];r?(r.setSecondAlignment(t),e[t.readName]=void 0):(r=new ua(t),e[t.readName]=r,n.push(r))}else n.push(t);return n}(this.packedAlignmentRows):ma(this.packedAlignmentRows),this.packedAlignmentRows=va(e,this.start,this.end)}setShowSoftClips(t){const e=this.allAlignments();this.packedAlignmentRows=va(e,this.start,this.end,t)}repack(t,e){const n=this.allAlignments();this.packedAlignmentRows=va(n,this.start,this.end,e)}allAlignments(){const t=[];for(let e of this.packedAlignmentRows)for(let n of e.alignments)t.push(n);return t}getMax(t,e){return this.coverageMap.getMax(t,e)}}class wa{constructor(t,e,n){this.start=t,this.end=e,this.alignments=[],this.downsampledCount=0,this.samplingDepth=n.samplingDepth,this.pairsSupported=n.pairsSupported,this.downsampledReads=n.downsampledReads,this.pairsCache=n.pairsCache}addAlignment(t){var e,n,r;if(this.pairsSupported&&ga(t)&&(r=this.pairsCache[t.readName]))return r.setSecondAlignment(t),void(this.pairsCache[t.readName]=void 0);this.alignments.length<this.samplingDepth?this.pairsSupported&&ga(t)?(r=new ua(t),this.paired=!0,this.pairsCache[t.readName]=r,this.alignments.push(r)):this.alignments.push(t):((e=Math.floor(Math.random()*(this.samplingDepth+this.downsampledCount-1)))<this.samplingDepth?(n=this.alignments[e],this.pairsSupported&&ga(t)?(void 0!==this.pairsCache[n.readName]&&(this.pairsCache[n.readName]=void 0),r=new ua(t),this.paired=!0,this.pairsCache[t.readName]=r,this.alignments[e]=r):this.alignments[e]=t,this.downsampledReads.add(n.readName)):this.downsampledReads.add(t.readName),this.downsampledCount++)}}class ya{constructor(t,e,n,r){this.chr=t,this.bpStart=e,this.length=n-e,this.coverage=new Array(this.length),this.maximum=0,this.threshold=r,this.qualityWeight=!0}getMax(t,e){let n=0;const r=this.coverage.length;for(let i=0;i<r;i++){const r=this.bpStart+i;if(r>e)break;const o=this.coverage[i];r>=t&&o&&(n=Math.max(n,o.total))}return n}incCounts(t){var e=this;if(void 0===t.blocks?n(t):t.blocks.forEach((function(t){n(t)})),t.gaps)for(let n of t.gaps)if("D"===n.type){const t=n.start-e.bpStart;for(let r=t;r<t+n.len;r++)r<0||(this.coverage[r]||(this.coverage[r]=new xa(e.threshold)),this.coverage[r].del++)}if(t.insertions)for(let n of t.insertions){const t=n.start-this.bpStart;t<0||(this.coverage[t]||(this.coverage[t]=new xa(e.threshold)),this.coverage[t].ins++)}function n(n){if("S"===n.type)return;const r=t.seq,i=t.qual,o=n.seqOffset;for(let s=n.start-e.bpStart,a=0;a<n.len;s++,a++){e.coverage[s]||(e.coverage[s]=new xa(e.threshold));const n=null==r?"N":r.charAt(o+a),c=t.strand?"pos"+n:"neg"+n,l=i&&o+a<i.length?i[o+a]:30;e.coverage[s][c]+=1,e.coverage[s]["qual"+n]+=l,e.coverage[s].total+=1,e.coverage[s].qual+=l,e.maximum=Math.max(e.coverage[s].total,e.maximum)}}}}class xa{constructor(t){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=t}isMismatch(t){const e=this.threshold*(this.qualityWeight&&this.qual?this.qual:this.total);let n=0;for(let e of["A","T","C","G"])e!==t&&(n+=this.qualityWeight&&this.qual?this["qual"+e]:this["pos"+e]+this["neg"+e]);return n>=e}}class ka{constructor(t,e,n){this.start=t,this.end=e,this.counts=n}popupData(t){return[{name:"start",value:this.start+1},{name:"end",value:this.end},{name:"# downsampled:",value:this.counts}]}}class _a{constructor(t){const e=t.split(",");this.chr=e[0],this.start=parseInt(e[1]),this.strand=e[2].charAt(0),this.mapQ=parseInt(e[4]),this.numMismatches=parseInt(e[5]),this.lenOnRef=za.computeLengthOnReference(e[3])}printString(){return this.chr+":"+Se(this.start)+"-"+Se(this.start+this.lenOnRef)+" ("+this.strand+") = "+Se(this.lenOnRef)+"bp @MAPQ: "+this.mapQ+" NM: "+this.numMismatches}}function Sa(t){return t.split(";").filter((t=>t.length>0)).map((t=>new _a(t)))}const Ca={c:1,C:1,s:2,S:2,i:4,I:4,f:4};class Ea{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(t){return(this.tagDict||Ta(this.tagBA)).hasOwnProperty(t)}tags(){return this.tagDict||(this.tagBA?(this.tagDict=Ta(this.tagBA),this.tagBA=void 0):this.tagDict={}),this.tagDict}containsLocation(t,e){const n=e?this.scStart:this.start,r=e?this.scLengthOnRef:this.lengthOnRef;return t>=n&&t<=n+r}popupData(t){const e=[];if(t=Math.floor(t),this.insertions){const r=this.seq;for(let i of this.insertions){var n=i.start;if(t===n||t===n-1)return e.push({name:"Insertion",value:r.substr(i.seqOffset,i.len)}),e.push({name:"Location",value:n}),e}}e.push({name:"Read Name",value:this.readName}),e.push("<hr/>"),e.push({name:"Alignment Start",value:Se(1+this.start),borderTop:!0}),e.push({name:"Read Strand",value:!0===this.strand?"(+)":"(-)",borderTop:!0});let r=this.cigar;if(r&&r.length>50){const t=25;r=`${r.substring(0,t-2)} ... ${r.substring(r.length-t+2)}`}e.push({name:"Cigar",value:r}),e.push({name:"Mapping Quality",value:this.mq}),e.push({name:"Secondary",value:s(this.isSecondary())}),e.push({name:"Supplementary",value:s(this.isSupplementary())}),e.push({name:"Duplicate",value:s(this.isDuplicate())}),e.push({name:"Failed QC",value:s(this.isFailsVendorQualityCheck())}),this.isPaired()&&(e.push("<hr/>"),e.push({name:"First in Pair",value:!this.isSecondOfPair(),borderTop:!0}),e.push({name:"Mate is Mapped",value:s(this.isMateMapped())}),this.pairOrientation&&e.push({name:"Pair Orientation",value:this.pairOrientation}),this.isMateMapped()&&(e.push({name:"Mate Chromosome",value:this.mate.chr}),e.push({name:"Mate Start",value:this.mate.position+1}),e.push({name:"Mate Strand",value:!0===this.mate.strand?"(+)":"(-)"}),e.push({name:"Insert Size",value:this.fragmentLength})));const i=this.tags();if(i.hasOwnProperty("SA")){e.push("<hr/>"),e.push({name:"Supplementary Alignments",value:""});const t=Sa(i.SA);if(t){e.push("<ul>");for(let n of t)e.push(`<li>${n.printString()}</li>`);e.push("</ul>")}}const o=new Set(["SA","MD"]);e.push("<hr/>");for(let t in i)o.has(t)||e.push({name:t,value:i[t]});return e.push({name:"Hidden Tags",value:"SA, MD"}),e.push("<hr/>"),e.push({name:"Genomic Location: ",value:Se(1+t)}),e.push({name:"Read Base:",value:this.readBaseAt(t)}),e.push({name:"Base Quality:",value:this.readBaseQualityAt(t)}),e;function s(t){return t?"Yes":"No"}}readBaseAt(t){const e=Aa(this.blocks,t);if(e){if("*"===this.seq)return"*";{const n=e.seqIndexAt(t);return this.seq[n]}}}readBaseQualityAt(t){const e=Aa(this.blocks,t);if(e){if("*"===this.qual)return 30;{const n=e.seqIndexAt(t);return n>=0&&this.qual&&n<this.qual.length?this.qual[n]:30}}}gapSizeAt(t){if(this.gaps)for(let e of this.gaps)if(t>=e.start&&t<e.start+e.len)return e.len;return 0}}function Aa(t,e){for(let n=0;n<t.length;n++){const r=t[n];if(e>=r.start&&e<r.start+r.len)return r}}function Ta(t){let e=0;const n=t.length,r={};for(;e<n;){const n=String.fromCharCode(t[e])+String.fromCharCode(t[e+1]);e+=2;const o=String.fromCharCode(t[e++]);let s;if("A"===o)s=String.fromCharCode(t[e]),e++;else if("i"===o||"I"===o)s=La(t,e),e+=4;else if("c"===o)s=Ia(t,e),e++;else if("C"===o)s=Na(t,e),e++;else if("s"===o||"S"===o)s=Ma(t,e),e+=2;else if("f"===o)s=Ra(t,e),e+=4;else if("Z"===o)for(s="";;){var i=t[e++];if(0===i)break;s+=String.fromCharCode(i)}else{if("B"!==o){s="Error unknown type: "+o,r[n]=s;break}{const i=String.fromCharCode(t[e++]);let o=Ca[i];if(void 0===o){r[n]=`Error: unknown element type '${i}'`;break}e+=4+La(t,e)*o,s="[not shown]"}}r[n]=s}return r}function La(t,e){return t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}function Ma(t,e){return t[e+1]<<8|t[e]}function Ra(t,e){return new DataView(t.buffer).getFloat32(e)}function Ia(t,e){return new DataView(t.buffer).getInt8(e)}function Na(t,e){return new DataView(t.buffer).getUint8(e)}class Pa{constructor(t){t&&Object.assign(this,t)}seqIndexAt(t){return Math.floor(t)-this.start+this.seqOffset}}class Oa{constructor(t){t||(t={}),this.vendorFailed=void 0===t.vendorFailed||t.vendorFailed,this.duplicates=void 0===t.duplicates||t.duplicates,this.secondary=t.secondary||!1,this.supplementary=t.supplementary||!1,this.mqThreshold=void 0===t.mqThreshold?0:t.mqThreshold,t.readgroups&&(this.readgroups=new Set(t.readgroups))}pass(t){if(this.vendorFailed&&t.isFailsVendorQualityCheck())return!1;if(this.duplicates&&t.isDuplicate())return!1;if(this.secondary&&t.isSecondary())return!1;if(this.supplementary&&t.isSupplementary())return!1;if(t.mq<this.mqThreshold)return!1;if(this.readgroups){var e=t.tags().RG;return this.readgroups.has(e)}return!0}}const Fa=["=","A","C","x","G","x","x","x","T","x","x","x","x","x","x","N"],Da=["M","I","D","N","S","H","P","=","X","?","?","?","?","?","?","?"],Ba=Va(new Uint8Array([66,65,77,1]),0),za={readHeader:function(t,e,n){return go.loadArrayBuffer(t,e).then((function(t){var e;return e=$i(t),za.decodeBamHeader(e,n)}))},decodeBamHeader:function(t,e){var n,r,i,o,s;if((n=Va(t,0))!==Ba)throw new Error("BAM header errror: bad magic number. This could be caused by either a corrupt or missing file.");r=Va(t,4);for(var a=0;a<r;++a)String.fromCharCode(t[a+8]);var c=Va(t,r+8),l=r+12;for(i={},o=[],s={},a=0;a<c;++a){for(var h=Va(t,l),u="",f=0;f<h-1;++f)u+=String.fromCharCode(t[l+4+f]);Va(t,l+h+4),i[u]=a,o[a]=u,e&&(s[e.getChromosomeName(u)]=u),l=l+8+h}return{magicNumber:n,size:l,chrNames:o,chrToIndex:i,chrAliasTable:s}},bam_tag2cigar:function(t,e,n,r,i,o){function s(t){return"C"===t||"c"===t||"A"===t?1:"S"===t||"s"===t?2:"I"===t||"i"===t||"f"===t?4:0}if(1!==o.length||i.start<0)return!1;for(var a=n+(r+1>>1)+r;a+4<e;){if("CG"===String.fromCharCode(t[a])+String.fromCharCode(t[a+1]))break;var c=String.fromCharCode(t[a+2]);if("B"===c)a+=8+s(c=String.fromCharCode(t[a+3]))*Va(t,a+4);else if("Z"===c||"H"===c)for(a+=3;0!==t[a++];);else a+=3+s(c)}if(a>=e)return!1;if("B"!==String.fromCharCode(t[a+2])||"I"!==String.fromCharCode(t[a+3]))return!1;var l=Va(t,a+4),h=a+8;if(h+4*l>e)return!1;var u="",f=0;o.length=0,a=h;for(var d=0;d<l;++d,a+=4){var p=Va(t,a),g=p>>4,m=Da[15&p];"M"!==m&&"EQ"!==m&&"X"!==m&&"D"!==m&&"N"!==m&&"="!==m||(f+=g),u=u+g+m,o.push({len:g,ltr:m})}return i.cigar=u,i.lengthOnRef=f,!0},decodeBamRecords:function(t,e,n,r,i,o,s,a){for(;e<t.length;){const f=e+Va(t,e)+4,d=new Ea,p=Va(t,e+4),g=Va(t,e+8);if(f>t.length)return;if(p<0){e=f;continue}if(void 0!==i&&(p>i||g>s))return!0;if(void 0!==i&&p<i){e=f;continue}const m=Va(t,e+12),v=(65280&m)>>8,b=255&m,w=Va(t,e+16),y=(4294901760&w)>>16,x=65535&w,k=Va(t,e+20),_=Va(t,e+24),S=Va(t,e+28),C=Va(t,e+32);let E=[];for(let n=0;n<b-1;++n)E.push(String.fromCharCode(t[e+36+n]));E=E.join("");let A=0,T="",L=e+36+b;const M=[];let R;for(let e=0;e<x;++e){var c=Va(t,L),l=c>>4,h=Da[15&c];"M"!==h&&"EQ"!==h&&"X"!==h&&"D"!==h&&"N"!==h&&"="!==h||(A+=l),T=T+l+h,L+=4,R={len:l,ltr:h},M.push(R)}if(d.chr=r[p],d.start=g,d.flags=y,d.strand=!(16&y),d.readName=E,d.cigar=T,d.lengthOnRef=A,d.fragmentLength=C,d.mq=v,za.bam_tag2cigar(t,f,L,k,d,M),d.end=d.start+d.lengthOnRef,d.end<o){e=f;continue}let I=[];const N=k+1>>1;for(let e=0;e<N;++e){var u=t[L+e];I.push(Fa[(240&u)>>4]),I.push(Fa[15&u])}I=I.slice(0,k).join(""),L+=N;const P=[];for(let e=0;e<k;++e)P.push(t[L+e]);L+=k,_>=0&&(d.mate={chr:r[_],position:S,strand:!(32&y)}),d.seq=I,d.qual=P,d.tagBA=new Uint8Array(t.buffer.slice(L,f)),this.setPairOrientation(d),(void 0===a||a.pass(d))&&(Ha(d,M),n.push(d)),e=f}},decodeSamRecords:function(t,e,n,r,i,o){var s,a,c,l,h,u,f,d,p,g;for(l=(s=Ce(t)).length,!1,a=0;a<l;a++)if(h=s[a].split("\t"),(p=new Ea).chr=h[2],p.start=Number.parseInt(h[3])-1,p.flags=Number.parseInt(h[1]),p.readName=h[0],p.strand=!(16&p.flags),p.mq=Number.parseInt(h[4]),p.cigar=h[5],p.fragmentLength=Number.parseInt(h[8]),p.seq=h[9],"*"!==p.chr&&p.isMapped()&&p.chr===n){if(p.start>i)break;if(d=0,(g=ja(p.cigar)).forEach((function(t){var e=t.len,n=t.ltr;"M"!==n&&"EQ"!==n&&"X"!==n&&"D"!==n&&"N"!==n&&"="!==n||(d+=e)})),p.lengthOnRef=d,!(p.start+d<r)){for(u=h[10],p.qual=[],c=0;c<u.length;c++)p.qual[c]=u.charCodeAt(c)-33;p.tagDict=h.length<11?{}:Ua(h.slice(11)),p.isMateMapped()&&(f=h[6],p.mate={chr:"="===f?p.chr:f,position:Number.parseInt(h[7]),strand:!(32&p.flags)}),this.setPairOrientation(p),(void 0===o||o.pass(p))&&(Ha(p,g),e.push(p))}}},setReaderDefaults:function(t,e){t.filter=new Oa(e.filter),e.readgroup&&(t.filter.readgroups=new Set([e.readgroup])),t.alleleFreqThreshold=void 0===e.alleleFreqThreshold?.2:e.alleleFreqThreshold,t.samplingWindowSize=void 0===e.samplingWindowSize?100:e.samplingWindowSize,t.samplingDepth=void 0===e.samplingDepth?500:e.samplingDepth,t.samplingDepth>1e4&&(console.log("Warning: attempt to set sampling depth > maximum value of 10000"),t.samplingDepth=1e4),e.viewAsPairs?t.pairsSupported=!0:t.pairsSupported=void 0===e.pairsSupported||e.pairsSupported},setPairOrientation:function(t){if(t.isMapped()&&t.mate&&t.isMateMapped()&&t.mate.chr===t.chr){var e=t.strand?"F":"R",n=t.mate,r=n.strand?"F":"R",i=" ",o=" ";t.isFirstOfPair()?(i="1",o="2"):t.isSecondOfPair()&&(i="2",o="1");var s=[],a=t.fragmentLength,c=t.end-t.start;if(0===a)a=(t.start<n.position?n.position+c:n.position-c)-t.start;a>0?(s[0]=e,s[1]=i,s[2]=r,s[3]=o):(s[2]=e,s[3]=i,s[0]=r,s[1]=o),t.pairOrientation=s.join("")}},computeLengthOnReference:function(t){let e=0,n="";for(let r=0;r<t.length;r++){const i=t.charCodeAt(r);if(i>47&&i<58)n+=t.charAt(r);else{switch(i){case 78:case 68:case 77:case 61:case 88:e+=parseInt(n.toString())}n=""}}return e}};function Ha(t,e){const n=[];let r,i,o=0,s=t.start;t.scStart=t.start,t.scLengthOnRef=t.lengthOnRef;for(let a of e){let e;switch(a.ltr){case"H":case"P":break;case"S":e=s,t.scLengthOnRef+=a.len,0===n.length&&(t.scStart-=a.len,e-=a.len),n.push(new Pa({start:e,seqOffset:o,len:a.len,type:"S"})),o+=a.len;break;case"N":case"D":void 0===i&&(i=[]),i.push({start:s,len:a.len,type:a.ltr}),s+=a.len;break;case"I":void 0===r&&(r=[]),r.push(new Pa({start:s,len:a.len,seqOffset:o,type:"I"})),o+=a.len;break;case"M":case"EQ":case"=":case"X":n.push(new Pa({start:s,seqOffset:o,len:a.len,type:"M"})),o+=a.len,s+=a.len;break;default:console.log("Error processing cigar element: "+a.len+a.ltr)}}t.blocks=n,t.insertions=r,t.gaps=i}function Va(t,e){return t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}function ja(t){var e,n,r,i,o,s,a,c,l;for(e=[],n=[],o=null,i=t.length,r=0;r<i;r++)s=t.charAt(r),l=void 0,(l=s.charCodeAt(0))>=48&&l<=57?n.push(s):(a=s,c=Number.parseInt(n.join("")),n=[],null!==o&&o.ltr===a?o.len+=c:(o={len:c,ltr:a},e.push(o)));return e}function Ua(t){var e={};return t.forEach((function(t){var n=t.split(":");e[n[0]]=n[2]})),e}class qa{constructor(t,e){this.config=t,this.genome=e,this.bamPath=t.url,this.isDataUri=ys(t.url),za.setReaderDefaults(this,t)}async readAlignments(t,e,n){if(this.alignmentCache){const r=this.header,i=r.chrAliasTable.hasOwnProperty(t)?r.chrAliasTable[t]:t,o=this.alignmentCache.queryFeatures(i,e,n),s=new ba(t,e,n,this.config);for(let t of o)s.push(t);return s.finish(),s}if(this.isDataUri){const r=$i(function(t){const e=t.split(","),n=e[0].split(":")[1];let r=e[1];r=n.indexOf("base64")>=0?atob(r):decodeURI(r);const i=new Uint8Array(r.length);for(var o=0;o<r.length;o++)i[o]=r.charCodeAt(o);return i}(this.bamPath).buffer);return this.parseAlignments(r),this.fetchAlignments(t,e,n)}{const r=$i(await go.loadArrayBuffer(this.bamPath,gs(this.config)));return this.parseAlignments(r),this.fetchAlignments(t,e,n)}}parseAlignments(t){const e=[];this.header=za.decodeBamHeader(t),za.decodeBamRecords(t,this.header.size,e,this.header.chrNames),this.alignmentCache=new Mo(e,this.genome)}fetchAlignments(t,e,n){const r=this.header.chrAliasTable.hasOwnProperty(t)?this.header.chrAliasTable[t]:t,i=this.alignmentCache.queryFeatures(r,e,n),o=new ba(t,e,n,this.config);for(let t of i)o.push(t);return o.finish(),o}}class Wa{constructor(t,e){this.littleEndian=void 0===e||e,this.position=0,this.view=t,this.length=t.byteLength}available(){return this.length-this.position}remLength(){return this.length-this.position}hasNext(){return this.position<this.length-1}getByte(){var t=this.view.getUint8(this.position,this.littleEndian);return this.position++,t}getShort(){var t=this.view.getInt16(this.position,this.littleEndian);return this.position+=2,t}getUShort(){var t=this.view.getUint16(this.position,this.littleEndian);return this.position+=2,t}getInt(){var t=this.view.getInt32(this.position,this.littleEndian);return this.position+=4,t}getUInt(){var t=this.view.getUint32(this.position,this.littleEndian);return this.position+=4,t}getLong(){var t=[];t[0]=this.view.getUint8(this.position),t[1]=this.view.getUint8(this.position+1),t[2]=this.view.getUint8(this.position+2),t[3]=this.view.getUint8(this.position+3),t[4]=this.view.getUint8(this.position+4),t[5]=this.view.getUint8(this.position+5),t[6]=this.view.getUint8(this.position+6),t[7]=this.view.getUint8(this.position+7);var e=0;if(this.littleEndian)for(let n=t.length-1;n>=0;n--)e=256*e+t[n];else for(let n=0;n<t.length;n++)e=256*e+t[n];return this.position+=8,e}getString(t){for(var e,n="";0!==(e=this.view.getUint8(this.position++))&&(n+=String.fromCharCode(e),!t||n.length!==t););return n}getFixedLengthString(t){var e,n,r="";for(e=0;e<t;e++)(n=this.view.getUint8(this.position++))>0&&(r+=String.fromCharCode(n));return r}getFixedLengthTrimmedString(t){var e,n,r="";for(e=0;e<t;e++)(n=this.view.getUint8(this.position++))>32&&(r+=String.fromCharCode(n));return r}getFloat(){var t=this.view.getFloat32(this.position,this.littleEndian);return this.position+=4,t}getDouble(){var t=this.view.getFloat64(this.position,this.littleEndian);return this.position+=8,t}skip(t){return this.position+=t,this.position}getVPointer(){var t=this.position,e=this.view.getUint8(t+1)<<8|this.view.getUint8(t),n=4294967296*(255&this.view.getUint8(t+6))+16777216*(255&this.view.getUint8(t+5))+65536*(255&this.view.getUint8(t+4))+256*(255&this.view.getUint8(t+3))+(255&this.view.getUint8(t+2));return this.position+=8,new $a(n,e)}}class $a{constructor(t,e){this.block=t,this.offset=e}isLessThan(t){return this.block<t.block||this.block===t.block&&this.offset<t.offset}isGreaterThan(t){return this.block>t.block||this.block===t.block&&this.offset>t.offset}print(){return this.block+":"+this.offset}}class Ga{constructor(t){this.tabix=!0}parse(t,e){const n=new Wa(new DataView(t)),r=n.getInt();if(21582659!==r)throw 38359875===r?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=n.getInt(),this.depth=n.getInt();const i=[];let o=0;if(n.getInt()>=28){n.getInt(),n.getInt(),n.getInt(),n.getInt(),n.getInt(),n.getInt();const t=n.getInt(),r=n.position+t;let o=0;for(;n.position<r;){let t=n.getString();e&&(t=e.getChromosomeName(t)),this.sequenceIndexMap[t]=o,i[o]=t,o++}}const s=this.bin_limit()+1,a=n.getInt();for(let t=0;t<a;t++){const e=[],r=[],i=n.getInt();for(let t=0;t<i;t++){const t=n.getInt();if(r[t]=n.getVPointer(),t>s)n.getInt(),n.getVPointer(),n.getVPointer(),n.getLong(),n.getLong();else{e[t]=[];const r=n.getInt();for(let i=0;i<r;i++){const r=n.getVPointer(),i=n.getVPointer();r&&i&&(r.block<this.blockMin&&(this.blockMin=r.block),i.block>o&&(o=i.block),e[t].push([r,i]))}}}i>0&&(this.indices[t]={binIndex:e,loffset:r})}this.lastBlockPosition=o}get chromosomeNames(){return Object.keys(this.sequenceIndexMap)}blocksForRange(t,e,n){const r=this.indices[t];if(r){const t=this.reg2bins(e,n);if(0==t.length)return[];const i=[];for(let e of t)for(let t=e[0];t<=e[1];t++)if(r.binIndex[t]){const e=r.binIndex[t],n=e.length;for(let r=0;r<n;++r){const n=e[r][0],o=e[r][1];i.push({minv:n,maxv:o,bin:t})}}return function(t,e){const n=[];let r=null;return 0===t.length?t:(t.sort((function(t,e){const n=t.minv.block-e.minv.block;return 0!==n?n:t.minv.offset-e.minv.offset})),t.forEach((function(t){var i,o;e&&!t.maxv.isGreaterThan(e)||(null===r?(n.push(t),r=t):(i=r,(o=t).minv.block-i.maxv.block<65e3&&o.maxv.block-i.minv.block<5e6?t.maxv.isGreaterThan(r.maxv)&&(r.maxv=t.maxv):(n.push(t),r=t)))})),n)}(i,r.loffset[t[0]])}return[]}reg2bins(t,e){(t-=1)<1&&(t=1),e>2**50&&(e=2**34),e-=1;let n=0,r=0,i=this.minShift+3*this.depth;const o=[];for(;n<=this.depth;i-=3,r+=1<<3*n,n+=1){const n=r+(t>>i),s=r+(e>>i);if(s-n+o.length>this.maxBinNumber)throw new Error(`query ${t}-${e} is too large for current binning scheme (shift ${this.minShift}, depth ${this.depth}), try a smaller query or a coarser index binning scheme`);o.push([n,s])}return o}bin_limit(){return((1<<3*(this.depth+1))-1)/7}}class Za{constructor(){}async parse(t,e,n){const r=[];let i=Number.MAX_SAFE_INTEGER,o=0;const s=[],a=new Wa(new DataView(t)),c=a.getInt(),l={};if(!(21578050===c||e&&21578324===c))throw new Error(indexURL+" is not a "+(e?"tabix":"bai")+" file");{const t=a.getInt();if(e){a.getInt(),a.getInt(),a.getInt(),a.getInt(),a.getInt(),a.getInt(),a.getInt();for(let e=0;e<t;e++){let t=a.getString();n&&(t=n.getChromosomeName(t)),l[t]=e,s[e]=t}}for(let e=0;e<t;e++){const t={},n=[],s=a.getInt();for(let e=0;e<s;e++){const e=a.getInt();if(37450===e)a.getInt(),a.getVPointer(),a.getVPointer(),a.getLong(),a.getLong();else{t[e]=[];const n=a.getInt();for(let r=0;r<n;r++){const n=a.getVPointer(),r=a.getVPointer();n&&r&&(n.block<i&&(i=n.block),r.block>o&&(o=r.block),t[e].push([n,r]))}}}const c=a.getInt();for(let t=0;t<c;t++){const t=a.getVPointer();n.push(t)}s>0&&(r[e]={binIndex:t,linearIndex:n})}this.firstBlockPosition=i,this.lastBlockPosition=o,this.indices=r,this.sequenceIndexMap=l,this.tabix=e}}get chromosomeNames(){return Object.keys(this.sequenceIndexMap)}blocksForRange(t,e,n){const r=this.indices[t];if(r){const t=function(t,e){const n=[];e>=1<<29&&(e=1<<29);return--e,n.push([0,0]),n.push([1+(t>>26),1+(e>>26)]),n.push([9+(t>>23),9+(e>>23)]),n.push([73+(t>>20),73+(e>>20)]),n.push([585+(t>>17),585+(e>>17)]),n.push([4681+(t>>14),4681+(e>>14)]),n}(e,n),i=[];for(let e of t)for(let t=e[0];t<=e[1];t++)if(r.binIndex[t]){const e=r.binIndex[t],n=e.length;for(let r=0;r<n;++r){const n=e[r][0],o=e[r][1];i.push({minv:n,maxv:o,bin:t})}}const o=r.linearIndex.length;let s=null;const a=Math.min(e>>14,o-1),c=Math.min(n>>14,o-1);for(let t=a;t<=c;++t){const e=r.linearIndex[t];e&&(s&&!e.isLessThan(s)||(s=e))}return function(t,e){const n=[];let r=null;return 0===t.length?t:(t.sort((function(t,e){const n=t.minv.block-e.minv.block;return 0!==n?n:t.minv.offset-e.minv.offset})),t.forEach((function(t){e&&!t.maxv.isGreaterThan(e)||(null!==r&&function(t,e){const n=e.minv.block-t.maxv.block,r=e.maxv.block-t.minv.block;return n<3e4&&r<1e7}(r,t)?t.maxv.isGreaterThan(r.maxv)&&(r.maxv=t.maxv):(n.push(t),r=t))})),n)}(i,s)}return[]}}class Xa{constructor(){}async parse(t,e){let n=0;this.chrIndex={},this.lastBlockPosition=[];const r=new Wa(new DataView(t));!function(t){t.getInt(),t.getInt();const e=t.getInt();if(t.getString(),t.getLong(),t.getLong(),t.getString(),t.getInt(),e>=3){let e=t.getInt();for(;e-- >0;)t.getString(),t.getString()}}(r);let i=r.getInt();for(;i-- >0;){let t=r.getString();e&&(t=e.getChromosomeName(t));const i=r.getInt(),o=r.getInt(),s=r.getInt();r.getInt(),r.getInt();let a=r.getLong();const c=[];for(let t=0;t<o;t++){const t=r.getLong();c.push({min:a,max:t}),a=t,t>n&&(n=t)}this.chrIndex[t]={chr:t,blocks:c,longestFeature:s,binWidth:i}}this.lastBlockPosition=n}get chromosomeNames(){return Object.keys(this.chrIndex)}blocksForRange(t,e,n){const r=this.chrIndex[t];if(r){const t=r.blocks,i=r.longestFeature,o=r.binWidth,s=Math.max(e-i,0),a=Math.floor(s/o);if(a>=t.length)return[];{const e=Math.min(Math.floor((n-1)/o),t.length-1),r=t[a].min,i=t[e].max;if(0===i-r)return[];return[{minv:{block:r,offset:0},maxv:{block:i,offset:0}}]}}}}async function Ya(t,e,n){let r=await go.loadArrayBuffer(t,gs(e)),i=new DataView(r);if(31===i.getUint8(0)&&139===i.getUint8(1)){r=$i(r).buffer,i=new DataView(r)}switch(i.getInt32(0,!0)){case 21578050:return async function(t,e){const n=new Za;return await n.parse(t,!1,e),n}(r,n);case 21578324:return async function(t,e){const n=new Za;return await n.parse(t,!0,e),n}(r,n);case 21582659:return async function(t,e){const n=new Ga;return n.parse(t,e),n}(r,n);case 1480870228:return async function(t,e){const n=new Xa;return n.parse(t,e),n}(r,n);case 38359875:throw Error("CSI version 2 is not supported.");default:throw Error(`Unrecognized index type: ${t}`)}}class Ka{constructor(t,e){this.config=t,this.genome=e,this.bamPath=t.url,this.baiPath=t.indexURL,za.setReaderDefaults(this,t)}async readAlignments(t,e,n){const r=(await this.getChrIndex())[this.chrAliasTable.hasOwnProperty(t)?this.chrAliasTable[t]:t],i=new ba(t,e,n,this.config);if(void 0===r)return i;{const t=(await this.getIndex()).blocksForRange(r,e,n);if(!t||0===t.length)return i;for(let s of t){let t;if(0===s.maxv.offset)t=0;else{const e=gs(this.config,{range:{start:s.maxv.block,size:26}});t=Gi(await go.loadArrayBuffer(this.bamPath,e))}const a=s.minv.block,c={start:a,size:s.maxv.block+t-a+1};var o=$i(await go.loadArrayBuffer(this.bamPath,gs(this.config,{range:c})));if(za.decodeBamRecords(o,s.minv.offset,i,this.indexToChr,r,e,n,this.filter))break}return i.finish(),i}}async getHeader(){if(!this.header){const t=this.genome,e=await this.getIndex();let n;if(e.firstBlockPosition){const t=gs(this.config,{range:{start:e.firstBlockPosition,size:26}}),r=Gi(await go.loadArrayBuffer(this.bamPath,t));n=e.firstBlockPosition+r}else n=64e3;const r=gs(this.config,{range:{start:0,size:n}});this.header=await za.readHeader(this.bamPath,r,t)}return this.header}async getIndex(){const t=this.genome;return this.index||(this.index=await Ya(this.baiPath,this.config,t)),this.index}async getChrIndex(){if(this.chrToIndex)return this.chrToIndex;{const t=await this.getHeader();return this.chrToIndex=t.chrToIndex,this.indexToChr=t.chrNames,this.chrAliasTable=t.chrAliasTable,this.chrToIndex}}}class Qa{constructor(t,e){this.config=t,this.genome=e;const n={};t.sources.sequences.forEach((function(r){const i=e?e.getChromosomeName(r):r;n[i]=function(t,e,n){const r={url:t.sources.url.replace("$CHR",n)};t.sources.indexURL&&(r.indexURL=t.sources.indexURL.replace("$CHR",n));const i=Object.assign(t,r);return new Ka(i,e)}(t,e,r)})),this.bamReaders=n,za.setReaderDefaults(this,t)}async readAlignments(t,e,n){if(this.bamReaders.hasOwnProperty(t)){let r=this.bamReaders[t];return await r.readAlignments(t,e,n)}return new ba(t,e,n,this.config)}}const Ja=function(t,e){this.config=t,this.genome=e,za.setReaderDefaults(this,t)};function tc(){const t=this,e=this.genome;if(this.header)return Promise.resolve(this.header);{const n=this.config.url+"?file="+this.config.alignmentFile+"&options=-b,-H",r=gs(this.config);return za.readHeader(n,r,e).then((function(e){return t.header=e,e}))}}Ja.prototype.readAlignments=function(t,e,n){var r=this;return tc.call(r).then((function(i){var o,s;return o=i.chrAliasTable.hasOwnProperty(t)?i.chrAliasTable[t]:t,s=r.config.url+"?reference="+r.config.referenceFile+"&file="+r.config.alignmentFile+"®ion="+o+":"+e+"-"+n,go.loadString(s,gs(r.config)).then((function(s){var a;return i.chrToIndex[o],a=new ba(t,e,n,r.config),za.decodeSamRecords(s,a,o,e,n,r.filter),a}))}))};class ec{constructor(t,e){if(this.config=t,this.genome=e,this.format=t.format?t.format.toUpperCase():"BAM","BAM"!==this.format&&"VCF"!==this.format)throw Error(`htsget format ${t.format} is not supported`)}async readHeaderData(){const t=`${nc(this.config)}?class=header&format=${this.format}`,e=await go.loadJson(t,gs(this.config));return await this.loadUrls(e.htsget.urls)}async readData(t,e,n){const r=`${nc(this.config)}?format=${this.format}&referenceName=${t}&start=${Math.floor(e)}&end=${Math.ceil(n)}`,i=await go.loadJson(r,gs(this.config));return this.loadUrls(i.htsget.urls)}async loadUrls(t){const e=[];for(let n of t)if(n.url.startsWith("data:"))e.push(Promise.resolve(rc(n.url)));else{const t=gs(this.config||{});n.headers&&(t.headers=Object.assign(t.headers||{},n.headers)),e.push(go.loadArrayBuffer(n.url,t))}return function(t){let e=0;for(let n of t)e+=n.byteLength;let n=0;const r=new Uint8Array(e);for(let e of t){const t=new Uint8Array(e);r.set(t,n),n+=t.length}return r}(await Promise.all(e))}static async inferFormat(t){try{const e=nc(t),n=`${e}${e.includes("?")?"&":"?"}class=header`,r=await go.loadJson(n,gs(t));if(r.htsget){const e=r.htsget.format;if("BAM"!==e&&"VCF"!==e)throw Error(`htsget format ${e} is not supported`);t.format=e.toLowerCase(),t.sourceType="htsget",t.name||(t.name=await bs(t.url))}}catch(t){}}}function nc(t){if(t.url&&t.endpoint&&t.id)return t.url+t.endpoint+t.id;if(t.endpoint&&t.id)return t.endpoint+t.id;if(t.url)return t.url.startsWith("htsget://")?t.url.replace("htsget://","https://"):t.url;throw Error("Must specify either 'url', or 'endpoint' and 'id")}function rc(t){const e=t.split(","),n=e[0].split(":")[1];let r=e[1];r=n.indexOf("base64")>=0?atob(r):decodeURI(r);const i=new Uint8Array(r.length);for(var o=0;o<r.length;o++)i[o]=r.charCodeAt(o);return i}class ic extends ec{constructor(t,e){super(t,e),za.setReaderDefaults(this,t)}async readAlignments(t,e,n){if(!this.header){const t=$i((await this.readHeaderData()).buffer);this.header=za.decodeBamHeader(t,this.genome),this.chrAliasTable=new Map;for(let t of Object.keys(this.header.chrAliasTable))this.chrAliasTable.set(t,this.header.chrAliasTable[t])}let r=this.chrAliasTable.has(t)?this.chrAliasTable.get(t):t;const i=$i((await this.readData(r,e,n)).buffer),o=this.header.chrToIndex[t],s=new ba(t,e,n,this.config);return za.decodeBamRecords(i,this.header.size,s,this.header.chrNames,o,e,n),s.finish(),s}}const oc=eval,sc=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=163)}([function(t,e,n){var r=n(13),i=n(81).f,o=n(107),s=n(3),a=n(15),c=n(20),l=n(24),h=function(t){var e=function(e,n,r){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(e);case 2:return new t(e,n)}return new t(e,n,r)}return t.apply(this,arguments)};return e.prototype=t.prototype,e};t.exports=function(t,e){var n,u,f,d,p,g,m,v,b=t.target,w=t.global,y=t.stat,x=t.proto,k=w?r:y?r[b]:(r[b]||{}).prototype,_=w?s:s[b]||(s[b]={}),S=_.prototype;for(f in e)n=!o(w?f:b+(y?".":"#")+f,t.forced)&&k&&l(k,f),p=_[f],n&&(g=t.noTargetGet?(v=i(k,f))&&v.value:k[f]),d=n&&g?g:e[f],n&&typeof p==typeof d||(m=t.bind&&n?a(d,r):t.wrap&&n?h(d):x&&"function"==typeof d?a(Function.call,d):d,(t.sham||d&&d.sham||p&&p.sham)&&c(m,"sham",!0),_[f]=m,x&&(l(s,u=b+"Prototype")||c(s,u,{}),s[u][f]=d,t.real&&S&&!S[f]&&c(S,f,d)))}},function(t,e){t.exports=function(t){return t&&t.__esModule?t:{default:t}}},function(t,e,n){var r=n(14);t.exports=function(t){if(!r(t))throw TypeError(String(t)+" is not an object");return t}},function(t,e){t.exports={}},function(t,e){t.exports=!0},function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function");return t}},function(t,e,n){var r=n(13),i=n(61),o=n(64),s=n(110),a=r.Symbol,c=i("wks");t.exports=function(t){return c[t]||(c[t]=s&&a[t]||(s?a:o)("Symbol."+t))}},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e,n){var r=n(2),i=n(119),o=n(29),s=n(15),a=n(90),c=n(120),l=function(t,e){this.stopped=t,this.result=e};(t.exports=function(t,e,n,h,u){var f,d,p,g,m,v,b=s(e,n,h?2:1);if(u)f=t;else{if("function"!=typeof(d=a(t)))throw TypeError("Target is not iterable");if(i(d)){for(p=0,g=o(t.length);g>p;p++)if((m=h?b(r(v=t[p])[0],v[1]):b(t[p]))&&m instanceof l)return m;return new l(!1)}f=d.call(t)}for(;!(v=f.next()).done;)if((m=c(f,b,v.value,h))&&m instanceof l)return m;return new l(!1)}).stop=function(t){return new l(!0,t)}},function(t,e,n){var r=n(1),i=r(n(7)),o=r(n(32)),s=r(n(27)),a=r(n(33)),c=r(n(265)),l=function(t){function e(){return(0,i.default)(this,e),(0,o.default)(this,(0,s.default)(e).apply(this,arguments))}return(0,a.default)(e,t),e}((0,c.default)(Error)),h=function(t){function e(){return(0,i.default)(this,e),(0,o.default)(this,(0,s.default)(e).apply(this,arguments))}return(0,a.default)(e,t),e}((0,c.default)(Error)),u=function(t){function e(){return(0,i.default)(this,e),(0,o.default)(this,(0,s.default)(e).apply(this,arguments))}return(0,a.default)(e,t),e}(l),f=function(t){function e(){return(0,i.default)(this,e),(0,o.default)(this,(0,s.default)(e).apply(this,arguments))}return(0,a.default)(e,t),e}(u),d=function(t){function e(){return(0,i.default)(this,e),(0,o.default)(this,(0,s.default)(e).apply(this,arguments))}return(0,a.default)(e,t),e}(l),p=function(t){function e(){return(0,i.default)(this,e),(0,o.default)(this,(0,s.default)(e).apply(this,arguments))}return(0,a.default)(e,t),e}(l);t.exports={CramBufferOverrunError:f,CramMalformedError:u,CramUnimplementedError:h,CramSizeLimitError:d,CramArgumentError:p}},function(t,e,n){var r=n(196);function i(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),r(t,i.key,i)}}t.exports=function(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),t}},function(t,e,n){var r=n(3),i=n(24),o=n(95),s=n(21).f;t.exports=function(t){var e=r.Symbol||(r.Symbol={});i(e,t)||s(e,t,{value:o.f(t)})}},function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,e,n){(function(e){var n="object",r=function(t){return t&&t.Math==Math&&t};t.exports=r(typeof globalThis==n&&globalThis)||r(typeof window==n&&window)||r(typeof self==n&&self)||r(typeof e==n&&e)||Function("return this")()}).call(this,n(23))},function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,e,n){var r=n(5);t.exports=function(t,e,n){if(r(t),void 0===e)return t;switch(n){case 0:return function(){return t.call(e)};case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,i){return t.call(e,n,r,i)}}return function(){return t.apply(e,arguments)}}},function(t,e,n){t.exports=n(167)},function(t,e,n){var r=n(12);t.exports=!r((function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}))},function(t,e,n){var r=n(3);t.exports=function(t){return r[t+"Prototype"]}},function(t,e,n){(function(t){
|
|
39
|
+
function Ps(t,e){var n,r=Object.keys(e);for(n=0;n<r.length;n++)t=t.replace(new RegExp("\\{"+r[n]+"\\}","gi"),e[r[n]]);return t}function Os(t){var e,n,r;if(!t)throw new Error("cannot create a random attribute name for an undefined object");e="ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",n="";do{for(n="",r=0;r<12;r++)n+=e[Math.floor(Math.random()*e.length)]}while(t[n]);return n}function Fs(t){var e={alphabetic:"alphabetic",hanging:"hanging",top:"text-before-edge",bottom:"text-after-edge",middle:"central"};return e[t]||e.alphabetic}function Ds(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]);return[t[0]/e,t[1]/e]}const Bs=function(t,e){var n,r,i,o={};for(t=t.split(","),e=e||10,n=0;n<t.length;n+=2)r="&"+t[n+1]+";",i=parseInt(t[n],e),o[r]="&#"+i+";";return o["\\xa0"]=" ",o}("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),zs={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 Hs{constructor(t,e){this.__root=t,this.__ctx=e}addColorStop(t,e){var n,r=this.__ctx.__createElement("stop");r.setAttribute("offset",t),e&&-1!==e.indexOf("rgba")?(n=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi.exec(e),r.setAttribute("stop-color",Ps("rgb({r},{g},{b})",{r:n[1],g:n[2],b:n[3]})),r.setAttribute("stop-opacity",n[4])):r.setAttribute("stop-color",e),this.__root.appendChild(r)}}class Vs{constructor(t,e){this.__root=t,this.__ctx=e}}class js{constructor(t){if(!(this instanceof js))return new js(t);if(this.config=t,this.width=t.width,this.height=t.height,this.enableMirroring=t.enableMirroring||!1,this.canvas=this,this.__document=document,t.ctx?this.__ctx=t.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"),t.viewbox){const e=t.viewbox.x+" "+t.viewbox.y+" "+t.viewbox.width+" "+t.viewbox.height;this.__root.setAttribute("viewBox",e),this.viewbox=t.viewbox}this.__ids={},this.__defs=this.__createElement("defs"),this.__root.appendChild(this.__defs),this.multiLocusGap=t.multiLocusGap;let e={id:"svg_output_backdrop",width:"100%",height:"100%",fill:t.backdropColor||"white"},n=this.__createElement("rect",e);this.__root.appendChild(n),this.__rootGroup=this.__createElement("g",{id:"root-group"}),this.__root.appendChild(this.__rootGroup),this.__currentElement=this.__rootGroup}setWidth(t){this.width=t,this.__root.setAttribute("width",this.width);const e=this.config.viewbox.x+" "+this.config.viewbox.y+" "+t+" "+this.config.viewbox.height;this.__root.setAttribute("viewBox",e)}setHeight(t){this.height=t,this.__root.setAttribute("height",this.height);const e=this.config.viewbox.x+" "+this.config.viewbox.y+" "+this.config.viewbox.width+" "+t;this.__root.setAttribute("viewBox",e)}__createElement(t,e,n){void 0===e&&(e={});let r=this.__document.createElementNS("http://www.w3.org/2000/svg",t);n&&(r.setAttribute("fill","none"),r.setAttribute("stroke","none"));for(let t of Object.keys(e))r.setAttribute(t,e[t]);return r}__setDefaultStyles(){var t,e,n=Object.keys(zs);for(t=0;t<n.length;t++)this[e=n[t]]=zs[e].canvas}__applyStyleState(t){var e,n,r=Object.keys(t);for(e=0;e<r.length;e++)this[n=r[e]]=t[n]}__getStyleState(){var t,e,n={},r=Object.keys(zs);for(t=0;t<r.length;t++)n[e=r[t]]=this[e];return n}__applyStyleToCurrentElement(t){var e=this.__currentElement,n=this.__currentElementsToStyle;n&&(e.setAttribute(t,""),e=n.element,n.children.forEach((function(e){e.setAttribute(t,"")})));var r,i,o,s,a,c=Object.keys(zs);for(r=0;r<c.length;r++)if(i=zs[c[r]],o=this[c[r]],i.apply)if(o instanceof Vs){if(o.__ctx)for(;o.__ctx.__defs.childNodes.length;)s=o.__ctx.__defs.childNodes[0].getAttribute("id"),this.__ids[s]=s,this.__defs.appendChild(o.__ctx.__defs.childNodes[0]);e.setAttribute(i.apply,Ps("url(#{id})",{id:o.__root.getAttribute("id")}))}else if(o instanceof Hs)e.setAttribute(i.apply,Ps("url(#{id})",{id:o.__root.getAttribute("id")}));else if(i&&-1!==i.apply.indexOf(t)&&i.svg!==o)if("stroke"!==i.svgAttr&&"fill"!==i.svgAttr||!o||-1===o.indexOf("rgba")){var l=i.svgAttr;if("globalAlpha"===c[r]&&(l=t+"-"+i.svgAttr,e.getAttribute(l)))continue;e.setAttribute(l,o)}else{a=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi.exec(o),e.setAttribute(i.svgAttr,Ps("rgb({r},{g},{b})",{r:a[1],g:a[2],b:a[3]}));var h=a[4],u=this.globalAlpha;null!=u&&(h*=u),e.setAttribute(i.svgAttr+"-opacity",h)}}__closestGroupOrSvg(t){return"g"===(t=t||this.__currentElement).nodeName||"svg"===t.nodeName?t:this.__closestGroupOrSvg(t.parentNode)}getSerializedSvg(t){var e,n,r,i,o,s=(new XMLSerializer).serializeToString(this.__root);if(t)for(e=Object.keys(Bs),n=0;n<e.length;n++)r=e[n],i=Bs[r],(o=new RegExp(r,"gi")).test(s)&&(s=s.replace(o,i));return s}getSvg(){return this.__root}saveWithTranslationAndClipRect(t,e,n,r,i,o){const s=`${t}_clip_rect`;let a=this.__createElement("clipPath",{id:s});this.__defs.appendChild(a);const c={x:"0",y:o.toString(),width:r.toString(),height:i.toString()};a.appendChild(this.__createElement("rect",c));const l=this.__createElement("g");l.setAttribute("transform",Ps("translate({x},{y})",{x:e,y:n})),l.setAttribute("clip-path",Ps("url(#{id})",{id:s}));const h=this.__closestGroupOrSvg();h.appendChild(l),this.__groupStack.push(h),this.__currentElement=l,this.__stack.push(this.__getStyleState())}save(){var t=this.__createElement("g"),e=this.__closestGroupOrSvg();this.__groupStack.push(e),e.appendChild(t),this.__currentElement=t,this.__stack.push(this.__getStyleState())}restore(){this.__currentElement=this.__groupStack.pop(),this.__currentElementsToStyle=null,this.__currentElement||(this.__currentElement=this.__root.childNodes[1]);var t=this.__stack.pop();this.__applyStyleState(t)}__addTransform(t){var e=this.__closestGroupOrSvg();if(e.childNodes.length>0){"path"===this.__currentElement.nodeName&&(this.__currentElementsToStyle||(this.__currentElementsToStyle={element:e,children:[]}),this.__currentElementsToStyle.children.push(this.__currentElement),this.__applyCurrentDefaultPath());var n=this.__createElement("g");e.appendChild(n),this.__currentElement=n}var r=this.__currentElement.getAttribute("transform");r?r+=" ":r="",r+=t,this.__currentElement.setAttribute("transform",r)}addTrackGroupWithTranslationAndClipRect(t,e,n,r,i,o){const s=t+"_clip_rect";let a=this.__createElement("clipPath",{id:s});this.__defs.appendChild(a),a.appendChild(this.__createElement("rect",{x:"0",y:o.toString(),width:r.toString(),height:i.toString()}));let c=this.__createElement("g");this.__rootGroup.appendChild(c),c.setAttribute("transform",Ps("translate({x},{y})",{x:e,y:n})),c.setAttribute("id",t+"_group"),c.setAttribute("clip-path",Ps("url(#{id})",{id:s})),this.__currentElement=c}scale(t,e){void 0===e&&(e=t),this.__addTransform(Ps("scale({x},{y})",{x:t,y:e}))}rotate(t){var e=180*t/Math.PI;this.__addTransform(Ps("rotate({angle},{cx},{cy})",{angle:e,cx:0,cy:0}))}translate(t,e){this.__addTransform(Ps("translate({x},{y})",{x:t,y:e}))}transform(t,e,n,r,i,o){this.__addTransform(Ps("matrix({a},{b},{c},{d},{e},{f})",{a:t,b:e,c:n,d:r,e:i,f:o}))}beginPath(){var t;this.__currentDefaultPath="",this.__currentPosition={},t=this.__createElement("path",{},!0),this.__closestGroupOrSvg().appendChild(t),this.__currentElement=t}__applyCurrentDefaultPath(){var t=this.__currentElement;"path"===t.nodeName?t.setAttribute("d",this.__currentDefaultPath):console.error("Attempted to apply path command to node",t.nodeName)}__addPathCommand(t){this.__currentDefaultPath+=" ",this.__currentDefaultPath+=t}moveTo(t,e){"path"!==this.__currentElement.nodeName&&this.beginPath(),this.__currentPosition={x:t,y:e},this.__addPathCommand(Ps("M {x} {y}",{x:t,y:e}))}closePath(){this.__currentDefaultPath&&this.__addPathCommand("Z")}lineTo(t,e){this.__currentPosition={x:t,y:e},this.__currentDefaultPath&&this.__currentDefaultPath.indexOf("M")>-1?this.__addPathCommand(Ps("L {x} {y}",{x:t,y:e})):this.__addPathCommand(Ps("M {x} {y}",{x:t,y:e}))}bezierCurveTo(t,e,n,r,i,o){this.__currentPosition={x:i,y:o},this.__addPathCommand(Ps("C {cp1x} {cp1y} {cp2x} {cp2y} {x} {y}",{cp1x:t,cp1y:e,cp2x:n,cp2y:r,x:i,y:o}))}quadraticCurveTo(t,e,n,r){this.__currentPosition={x:n,y:r},this.__addPathCommand(Ps("Q {cpx} {cpy} {x} {y}",{cpx:t,cpy:e,x:n,y:r}))}arcTo(t,e,n,r,i){var o=this.__currentPosition&&this.__currentPosition.x,s=this.__currentPosition&&this.__currentPosition.y;if(void 0!==o&&void 0!==s){if(i<0)throw new Error("IndexSizeError: The radius provided ("+i+") is negative.");if(o===t&&s===e||t===n&&e===r||0===i)this.lineTo(t,e);else{var a=Ds([o-t,s-e]),c=Ds([n-t,r-e]);if(a[0]*c[1]!=a[1]*c[0]){var l=a[0]*c[0]+a[1]*c[1],h=Math.acos(Math.abs(l)),u=Ds([a[0]+c[0],a[1]+c[1]]),f=i/Math.sin(h/2),d=t+f*u[0],p=e+f*u[1],g=[-a[1],a[0]],m=[c[1],-c[0]],v=function(t){var e=t[0];return t[1]>=0?Math.acos(e):-Math.acos(e)},b=v(g),w=v(m);this.lineTo(d+g[0]*i,p+g[1]*i),this.arc(d,p,i,b,w)}else this.lineTo(t,e)}}}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(t,e,n,r){"path"!==this.__currentElement.nodeName&&this.beginPath(),this.moveTo(t,e),this.lineTo(t+n,e),this.lineTo(t+n,e+r),this.lineTo(t,e+r),this.lineTo(t,e),this.closePath()}fillRect(t,e,n,r){r<0&&(e+=r,r=-r),n<0&&(t+=n,n=-n);var i,o,s,a={x:t,y:e,width:n,height:r};(!this.viewbox||(i=this.viewbox,o=a,i.x<o.x+o.width&&i.x+i.width>o.x&&i.y<o.y+o.height&&i.y+i.height>o.y))&&(s=this.__createElement("rect",a,!0),this.__closestGroupOrSvg().appendChild(s),this.__currentElement=s,this.__applyStyleToCurrentElement("fill"))}strokeRect(t,e,n,r){var i;i=this.__createElement("rect",{x:t,y:e,width:n,height:r},!0),this.__closestGroupOrSvg().appendChild(i),this.__currentElement=i,this.__applyStyleToCurrentElement("stroke")}strokeEllipse(t,e,n,r,i,o,s,a){this.__ellipse(t,e,n,r,i,o,s,a,"stroke")}fillEllipse(t,e,n,r,i,o,s,a){this.__ellipse(t,e,n,r,i,o,s,a,"fill")}__ellipse(t,e,n,r,i,o,s,a,c){const l={cx:t,cy:e,rx:n,ry:r},h=this.__createElement("ellipse",l,!0);this.__closestGroupOrSvg().appendChild(h),this.__currentElement=h,this.__applyStyleToCurrentElement(c)}__clearCanvas(){for(var t=this.__closestGroupOrSvg().getAttribute("transform"),e=this.__root.childNodes[1],n=e.childNodes,r=n.length-1;r>=0;r--)n[r]&&e.removeChild(n[r]);this.__currentElement=e,this.__groupStack=[],t&&this.__addTransform(t)}clearRect(t,e,n,r){if(0!==t||0!==e||n!==this.width||r!==this.height){var i,o=this.__closestGroupOrSvg();i=this.__createElement("rect",{x:t,y:e,width:n,height:r,fill:"#FFFFFF"},!0),o.appendChild(i)}else this.__clearCanvas()}createLinearGradient(t,e,n,r){var i=this.__createElement("linearGradient",{id:Os(this.__ids),x1:t+"px",x2:n+"px",y1:e+"px",y2:r+"px",gradientUnits:"userSpaceOnUse"},!1);return this.__defs.appendChild(i),new Hs(i,this)}createRadialGradient(t,e,n,r,i,o){var s=this.__createElement("radialGradient",{id:Os(this.__ids),cx:r+"px",cy:i+"px",r:o+"px",fx:t+"px",fy:e+"px",gradientUnits:"userSpaceOnUse"},!1);return this.__defs.appendChild(s),new Hs(s,this)}__parseFont(){var t=/^\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),e={style:t[1]||"normal",size:t[4]||"10px",family:t[6]||"sans-serif",weight:t[3]||"normal",decoration:t[2]||"normal",href:null};return"underline"===this.__fontUnderline&&(e.decoration="underline"),this.__fontHref&&(e.href=this.__fontHref),e}__wrapTextLink(t,e){if(t.href){var n=this.__createElement("a");return n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",t.href),n.appendChild(e),n}return e}__applyText(t,e,n,r){var i,o,s=this.__parseFont(),a=this.__closestGroupOrSvg(),c=this.__createElement("text",{"font-family":s.family,"font-size":s.size,"font-style":s.style,"font-weight":s.weight,"text-decoration":s.decoration,x:e,y:n,"text-anchor":(i=this.textAlign,o={left:"start",right:"end",center:"middle",start:"start",end:"end"},o[i]||o.start),"dominant-baseline":Fs(this.textBaseline)},!0);c.appendChild(this.__document.createTextNode(t)),this.__currentElement=c,this.__applyStyleToCurrentElement(r),a.appendChild(this.__wrapTextLink(s,c))}fillText(t,e,n){this.__applyText(t,e,n,"fill")}strokeText(t,e,n){this.__applyText(t,e,n,"stroke")}measureText(t){return this.__ctx.font=this.font,this.__ctx.measureText(t)}arc(t,e,n,r,i,o){if(r!==i){(r%=2*Math.PI)===(i%=2*Math.PI)&&(i=(i+2*Math.PI-.001*(o?-1:1))%(2*Math.PI));var s=t+n*Math.cos(i),a=e+n*Math.sin(i),c=t+n*Math.cos(r),l=e+n*Math.sin(r),h=o?0:1,u=0,f=i-r;f<0&&(f+=2*Math.PI),u=o?f>Math.PI?0:1:f>Math.PI?1:0,this.lineTo(c,l),this.__addPathCommand(Ps("A {rx} {ry} {xAxisRotation} {largeArcFlag} {sweepFlag} {endX} {endY}",{rx:n,ry:n,xAxisRotation:0,largeArcFlag:u,sweepFlag:h,endX:s,endY:a})),this.__currentPosition={x:s,y:a}}}clip(){var t=this.__closestGroupOrSvg(),e=this.__createElement("clipPath"),n=Os(this.__ids),r=this.__createElement("g");this.__applyCurrentDefaultPath(),t.removeChild(this.__currentElement),e.setAttribute("id",n),e.appendChild(this.__currentElement),this.__defs.appendChild(e),t.setAttribute("clip-path",Ps("url(#{id})",{id:n})),t.appendChild(r),this.__currentElement=r}drawImage(){var t,e,n,r,i,o,s,a,c,l,h,u,f,d=Array.prototype.slice.call(arguments),p=d[0],g=0,m=0;if(3===d.length)t=d[1],e=d[2],n=i=p.width,r=o=p.height;else if(5===d.length)t=d[1],e=d[2],n=d[3],r=d[4],i=p.width,o=p.height;else{if(9!==d.length)throw new Error("Invalid number of arguments passed to drawImage: "+arguments.length);g=d[1],m=d[2],i=d[3],o=d[4],t=d[5],e=d[6],n=d[7],r=d[8]}s=this.__closestGroupOrSvg();var v="translate("+t+", "+e+")";if(p instanceof js){if((a=p.getSvg().cloneNode(!0)).childNodes&&a.childNodes.length>1){for(c=a.childNodes[0];c.childNodes.length;)f=c.childNodes[0].getAttribute("id"),this.__ids[f]=f,this.__defs.appendChild(c.childNodes[0]);if(l=a.childNodes[1]){var b,w=l.getAttribute("transform");b=w?w+" "+v:v,l.setAttribute("transform",b),s.appendChild(l)}}}else"CANVAS"!==p.nodeName&&"IMG"!==p.nodeName||((h=this.__createElement("image")).setAttribute("width",n),h.setAttribute("height",r),h.setAttribute("preserveAspectRatio","none"),(g||m||i!==p.width||o!==p.height)&&((u=this.__document.createElement("canvas")).width=n,u.height=r,u.getContext("2d").drawImage(p,g,m,i,o,0,0,n,r),p=u),h.setAttribute("transform",v),h.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href","CANVAS"===p.nodeName?p.toDataURL():p.getAttribute("src")),s.appendChild(h))}createPattern(t,e){let n,r=this.__document.__createElement("pattern"),i=Os(this.__ids);return r.setAttribute("id",i),r.setAttribute("width",t.width),r.setAttribute("height",t.height),"CANVAS"===t.nodeName||"IMG"===t.nodeName?(n=this.__createElement("image"),n.setAttribute("width",t.width),n.setAttribute("height",t.height),n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href","CANVAS"===t.nodeName?t.toDataURL():t.getAttribute("src")),r.appendChild(n),this.__defs.appendChild(r)):t instanceof js&&(r.appendChild(t.__root.childNodes[1]),this.__defs.appendChild(r)),new Vs(r,this)}setLineDash(t){t&&t.length>0?this.lineDash=t.join(","):this.lineDash=null}drawFocusRing(){}createImageData(){}getImageData(){}putImageData(){}globalCompositeOperation(){}setTransform(){}}const Us=function(t,e,n,r,i){this.name=t,this.order=e,this.bpStart=n,this.bpLength=r,this.rangeLocus=i},qs=Se,Ws=new Set(["fastaURL","indexURL","cytobandURL","indexed"]);class $s{constructor(t){this.fastaURL=t.fastaURL,this.withCredentials=t.withCredentials,this.chromosomeNames=[],this.chromosomes={},this.sequences=new Map,this.offsets={};const e={};for(let n in t)t.hasOwnProperty(n)&&!Ws.has(n)&&(e[n]=t[n]);this.config=e}async init(){return this.loadAll()}async getSequence(t,e,n){this.offsets[t]&&(e-=this.offsets[t],n-=this.offsets[t]);let r="";if(e<0)for(let t=e;t<Math.min(n,0);t++)r+="*";if(n<=0)return Promise.resolve(r);const i=this.sequences.get(t),o=Math.min(n,i.length);return r+i.substring(e,o)}async loadAll(){let t;if(ys(this.fastaURL)){let e=Yi(this.fastaURL);t="";for(let n of e)t+=String.fromCharCode(n)}else t=await go.load(this.fastaURL,gs(this.config));const e=qs(t),n=e.length;let r,i,o,s,a=0,c=0,l=0;for(;a<n;)if(o=e[a++].trim(),o.startsWith("#")||0===o.length);else if(o.startsWith(">")){r&&(this.chromosomeNames.push(s),this.sequences.set(s,r),this.chromosomes[s]=new Us(s,l++,c,c+r.length,i));const t=o.substr(1).split(/\s+/)[0].split(":");if(s=t[0],r="",c=0,i=void 0,t.length>1&&t[1].indexOf("-")>0){const e=t[1].split("-");2===e.length&&/^[0-9]+$/.test(e[0])&&/^[0-9]+$/.test(e[1]);const n=Number.parseInt(e[0]);Number.parseInt(e[1])>n&&(c=n-1,this.offsets[s]=c,i=t[1])}}else r+=o;r&&(this.chromosomeNames.push(s),this.sequences.set(s,r),this.chromosomes[s]=new Us(s,l++,c,c+r.length,i))}}const Gs=function(t,e,n,r){this.chr=t,this.start=e,this.end=n,this.features=r};Gs.prototype.contains=function(t,e,n){return this.chr===t&&this.start<=e&&this.end>=n},Gs.prototype.containsRange=function(t){return this.chr===t.chr&&this.start<=t.start&&this.end>=t.end};const Zs=Se,Xs=new Set(["fastaURL","indexURL","compressedIndexURL","cytobandURL","indexed"]);class Ys{constructor(t){this.file=t.fastaURL,this.indexFile=t.indexURL||t.indexFile||this.file+".fai",this.compressedIndexFile=t.compressedIndexURL||!1,this.withCredentials=t.withCredentials,this.chromosomeNames=[],this.chromosomes={},this.sequences={},this.offsets={};const e={};for(let n in t)t.hasOwnProperty(n)&&!Xs.has(n)&&(e[n]=t[n]);this.config=e}async init(){return this.getIndex()}async getSequence(t,e,n){if(!(this.interval&&this.interval.contains(t,e,n))){let r=e,i=n;if(n-e<5e4){const t=n-e,o=Math.round(e+t/2);r=Math.max(0,o-25e3),i=o+25e3}const o=await this.readSequence(t,r,i);this.interval=new Gs(t,r,i,o)}const r=e-this.interval.start,i=n-e;return this.interval.features?this.interval.features.substr(r,i):null}async getIndex(){if(this.index)return this.index;{const t=await go.load(this.indexFile,gs(this.config)),e=Zs(t),n=e.length;let r=0,i=0;for(this.index={};r<n;){const t=e[r++].split("\t");if(5===t.length){const e=t[0],n=parseInt(t[1]),r={size:n,position:parseInt(t[2]),basesPerLine:parseInt(t[3]),bytesPerLine:parseInt(t[4])};this.chromosomeNames.push(e),this.index[e]=r,this.chromosomes[e]=new Us(e,i++,0,n)}}return this.index}}async getCompressedIndex(){if(this.compressedIndex)return this.compressedIndex;if(!this.compressedIndexFile)return this.compressedIndex=[],this.compressedIndex;this.compressedIndex=[];const t=await go.loadArrayBuffer(this.compressedIndexFile,gs(this.config)),e=t.byteLength;if(e<8)return console.log("Cannot parse GZI index file: length ("+e+" bytes) is insufficient to determine content of index."),this.compressedIndex;const n=t.slice(0,8),r=Number(new DataView(n).getBigUint64(0,!0)),i=8+2*r*8;if(e!=i)return console.log("Incorrect file size of reference genome index. Expected : "+i+". Received : "+e),this.compressedIndex;this.compressedIndex.push([0,0]);for(let e=0;e<r;e++){const n=8+2*e*8,r=8+2*e*8+16,i=t.slice(n,r),o=new DataView(i),s=Number(o.getBigUint64(0,!0)),a=Number(o.getBigUint64(8,!0));this.compressedIndex.push([s,a])}return this.compressedIndex}async getRelevantCompressedBlockNumbers(t,e){if(t<0||e<0||e<t)return console.log("Incompatible query positions for reference-genome. Start:"+t+" | End:"+e),[];await this.getCompressedIndex();let n=[];const r=this.compressedIndex.length-1;if(0==this.compressedIndex.length)return console.log("Compressed index does not contain any content"),[];if(t>this.compressedIndex[r][1])return[r];let i=0,o=r,s=Math.floor(this.compressedIndex.length/2),a=this.compressedIndex.length+1,c=!1;for(let e=0;e<a;e++){const e=this.compressedIndex[s][1],n=s<this.compressedIndex.length-1?this.compressedIndex[s+1][1]:1/0;if(e<=t&&n>t){c=!0;break}e<t?i=s+1:o=s-1,s=Math.ceil((o-i)/2)+i}if(!c)return console.log("No blocks within compressed index found that correspond with query positions "+t+","+e),console.log(this.compressedIndex),[];n.push(s);for(let t=s+1;t<this.compressedIndex.length;t++){n.push(t);if(this.compressedIndex[t][1]>=e)break}const l=n[n.length-1];return l===this.compressedIndex.length-1&&this.compressedIndex[l][1]<e&&n.push(-1),n}async loadAndUncompressBlocks(t,e){if(await this.getCompressedIndex(),0==t.length)return"";let n=Array(t.length-1);for(let e=0;e<t.length-1;e++){const r=t[e],i=this.compressedIndex[r][0],o=t[e+1];let s=[];if(-1!=o){const t=this.compressedIndex[o][0]-i;s=await go.loadArrayBuffer(this.file,gs(this.config,{range:{start:i,size:t}}))}else s=await go.loadArrayBuffer(this.file,gs(this.config,{range:{start:i}}));const a=await Wi(s);n[e]=a}let r="";for(let t=0;t<n.length;t++)for(let e=0;e<n[t].length;e++){r+=String.fromCharCode(n[t][e])}const i=e-this.compressedIndex[t[0]][1];return r=r.substring(i),r}async readSequence(t,e,n){await this.getIndex(),await this.getCompressedIndex();const r=this.index[t];if(!r)return console.log("No index entry for chr: "+t),this.interval=new Gs(t,e,n,null),null;const i=Math.max(0,e),o=Math.min(r.size,n),s=r.bytesPerLine,a=r.basesPerLine,c=r.position,l=s-a,h=Math.floor(i/a),u=Math.floor(o/a),f=i-h*a,d=c+h*s+f,p=c+u*s+(o-u*a)-1,g=p-d+1;if(g<=0)return console.error("No sequence for "+t+":"+e+"-"+n),null;let m;if(this.compressedIndexFile){let t=await this.getRelevantCompressedBlockNumbers(d,p);if(0===t.length)return console.log("No blocks in the compressed index that correspond with the requested byte positions ("+d+","+p+")"),null;m=await this.loadAndUncompressBlocks(t,d)}else m=await go.load(this.file,gs(this.config,{range:{start:d,size:g}}));if(!m)return null;let v,b="",w=0,y=m.length;for(f>0&&(v=Math.min(o-i,a-f),b+=m.substr(w,v),w+=v+l);w<y;)v=Math.min(a,y-w),b+=m.substr(w,v),w+=v+l;return b}}const Ks=Se;class Qs{constructor(t){this.url=t,this.chromosomeNames=[],this.chromosomes={}}async init(){return this.loadAll()}async getSequence(t,e,n){}async loadAll(){let t;if(ys(this.url)){let e=Yi(this.fastaURL);t="";for(let n of e)t+=String.fromCharCode(n)}else t=await go.load(this.url,{});this.chromosomeNames=[],this.chromosomes={};const e=Ks(t);let n=0;for(let t of e){const e=t.split("\t");this.chromosomeNames.push(e[0]);const r=Number.parseInt(e[1]),i=new Us(e[0],n++,0,r);this.chromosomes[e[0]]=i}}}const Js=function(t,e,n,r){this.start=t,this.end=e,this.name=n,this.stain=0,"acen"===r?this.type="c":(this.type=r.charAt(1),"p"===this.type&&(this.stain=parseInt(r.substring(4))))};function ta(){return"2.12.5"}const ea=Se,na={loadGenome:async function(t){const e=t.cytobandURL,n=t.aliasURL,r=await async function(t){let e;return e="chromsizes"===t.format?new Qs(t.fastaURL):ys(t.fastaURL)||!1===t.indexed?new $s(t):new Ys(t),await e.init(),e}(t);let i,o;return e&&(i=await async function(t,e){let n;if(ys(t)){const e=Yi(t);n="";const r=e.length;for(let t=0;t<r;t++)n+=String.fromCharCode(e[t])}else n=await go.loadString(t,gs(e));const r={};let i,o=[];const s=ea(n);for(let t of s){var a=t.split("\t"),c=a[0];if(i||(i=c),c!==i&&(r[i]=o,o=[],i=c),5===a.length){var l=parseInt(a[1]),h=parseInt(a[2]),u=a[3],f=a[4];o.push(new Js(l,h,u,f))}}return r}(e,r.config)),n&&(o=await function(t,e){return go.loadString(t,gs(e)).then((function(t){var e=ea(t),n=[];return e.forEach((function(t){!t.startsWith("#")&&t.length>0&&n.push(t.split("\t"))})),n}))}(n,r.config)),new ra(t,r,i,o)},initializeGenomes:async function(t){if(!na.KNOWN_GENOMES){const n={};if(!1!==t.loadDefaultGenomes)try{const i=`https://igv.org/genomes/genomes.json?randomSeed=${Math.random().toString(36)}&version=2.12.5`;e(await go.loadJson(i,{timeout:5e3}))}catch(o){console.error(o);try{const s=`https://s3.amazonaws.com/igv.org.genomes/genomes.json?randomSeed=${Math.random().toString(36)}&version=2.12.5`;e(await go.loadJson(s,{}))}catch(a){console.error(a),console.warn("Errors loading default genome definitions.")}}const r=t.genomeList||t.genomes;if(r)if("string"==typeof r){e(await go.loadJson(r,{}))}else e(r);function e(t){return t.forEach((function(t){n[t.id]=t})),n}na.KNOWN_GENOMES=n}},isWholeGenomeView:function(t){return"all"===t.toLowerCase()},expandReference:function(t){if(ke(t)&&t.startsWith("{"))try{t=JSON.parse(t)}catch(t){}let e;if(ke(t)?e=t:t.genome?e=t.genome:void 0!==t.id&&void 0===t.fastaURL&&(e=t.id),e){const t=na.KNOWN_GENOMES[e];return t||Qo.presentAlert(new Error(`Unknown genome id: ${e}`),void 0),t}return t}};class ra{constructor(t,e,n,r){this.config=t,this.id=t.id||function(t){return void 0!==t.id?t.id:t.fastaURL&&ke(t.fastaURL)?t.fastaURL:t.fastaURL&&t.fastaURL.name?t.fastaURL.name:("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)}(t),this.sequence=e,this.chromosomeNames=e.chromosomeNames,this.chromosomes=e.chromosomes,this.ideograms=n,this.featureDB={},this.wholeGenomeView=void 0===t.wholeGenomeView||t.wholeGenomeView,this.wholeGenomeView&&Object.keys(e.chromosomes).length>1?function(t,e){let n;if(e.chromosomeOrder)Array.isArray(e.chromosomeOrder)?t.wgChromosomeNames=e.chromosomeOrder:t.wgChromosomeNames=e.chromosomeOrder.split(",").map((t=>t.trim())),n=t.wgChromosomeNames.map((e=>t.chromosomes[e])).filter((t=>void 0!==t));else{const e=Object.keys(t.chromosomes).map((e=>t.chromosomes[e].bpLength)).reduce(((t,e)=>Math.max(t,e)))/50;n=Object.values(t.chromosomes).filter((t=>t.bpLength>e));const r=n.filter((t=>i(t.name.replace("chr","")))),o=n.filter((t=>!i(t.name.replace("chr",""))));r.sort(((t,e)=>Number.parseInt(t.name.replace("chr",""))-Number.parseInt(e.name.replace("chr",""))));const s=r.map((t=>t.name));for(let t of o)s.push(t.name);t.wgChromosomeNames=s}const r=n.reduce(((t,e)=>t+e.bpLength),0);function i(t){return/^\d+$/.test(t)}t.chromosomes.all={name:"all",bpLength:r}}(this,t):this.wgChromosomeNames=e.chromosomeNames;var i={},o=this;i.all="all",this.chromosomeNames.forEach((function(t){var e=t.startsWith("chr")?t.substring(3):"chr"+t;i[e.toLowerCase()]=t,"chrM"===t&&(i.mt="chrM"),"MT"===t&&(i.chrm="MT"),i[t.toLowerCase()]=t})),r&&r.forEach((function(t){var e,n;for(n=0;n<t.length;n++)if(o.chromosomes[t[n]]){e=t[n];break}e&&t.forEach((function(t){t!==e&&(i[t.toLowerCase()]=e,i[t]=e)}))})),this.chrAliasTable=i}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(t){const e=t?this.chrAliasTable[t.toLowerCase()]:t;return e||t}getChromosome(t){return t=this.getChromosomeName(t),this.chromosomes[t]}getCytobands(t){return this.ideograms?this.ideograms[t]:null}getLongestChromosome(){var t,e=this.chromosomes;for(let r in e){if(e.hasOwnProperty(r)){var n=e[r];(void 0===t||n.bpLength>t.bpLength)&&(t=n)}return t}}getChromosomes(){return this.chromosomes}getGenomeCoordinate(t,e){var n=this.getCumulativeOffset(t);if(void 0!==n)return n+e}getChromosomeCoordinate(t){let e;void 0===this.cumulativeOffsets&&(this.cumulativeOffsets=computeCumulativeOffsets.call(this));let n=0;for(let r of this.wgChromosomeNames){const i=this.cumulativeOffsets[r];if(i>t){return{chr:e,position:t-n}}e=r,n=i}return{chr:this.wgChromosomeNames[this.wgChromosomeNames.length-1],position:0}}getCumulativeOffset(t){void 0===this.cumulativeOffsets&&(this.cumulativeOffsets=function(){let t=this,e={},n=0;for(let r of t.wgChromosomeNames){e[r]=Math.floor(n);n+=t.getChromosome(r).bpLength}return e}.call(this));const e=this.getChromosomeName(t);return this.cumulativeOffsets[e]}getGenomeLength(){let t=this;if(!this.bpLength){let e=0;t.wgChromosomeNames.forEach((function(n){let r=t.chromosomes[n];e+=r.bpLength})),this.bpLength=e}return this.bpLength}async getSequence(t,e,n){return t=this.getChromosomeName(t),this.sequence.getSequence(t,e,n)}}let ia,oa=0;class sa extends class{constructor(t,e,n,r){this.guid=ve(),this.trackView=t,this.referenceFrame=n,this.browser=t.browser,this.$viewport=de('<div class="igv-viewport">'),e.appendChild(this.$viewport.get(0)),t.track.height&&(this.$viewport.get(0).style.height=`${t.track.height}px`),t.track instanceof Ns&&(this.alert=new Yo(this.$viewport.get(0))),this.$content=de("<div>",{class:"igv-viewport-content"}),this.$viewport.append(this.$content),this.$content.height(this.$viewport.height()),this.contentDiv=this.$content.get(0),this.$viewport.width(r),this.initializationHelper()}initializationHelper(){}showMessage(t){this.messageDiv||(this.messageDiv=document.createElement("div"),this.messageDiv.className="igv-viewport-message",this.contentDiv.append(this.messageDiv)),this.messageDiv.textContent=t,this.messageDiv.style.display="inline-block"}hideMessage(t){this.messageDiv&&(this.messageDiv.style.display="none")}setTrackLabel(t){}startSpinner(){}stopSpinner(){}checkZoomIn(){return!0}shift(){}setTop(t){const e=-t,n=e+this.$viewport.height();this.$content.css("top",`${t}px`),(void 0===this.canvasVerticalRange||this.canvasVerticalRange.bottom<n||this.canvasVerticalRange.top>e)&&this.repaint()}async loadFeatures(){}async repaint(){console.log("Viewport - repaint()")}draw(t,e,n){console.log("Viewport - draw(drawConfiguration, features, roiFeatures)")}checkContentHeight(t){let e=this.trackView.track;if(t=t||this.cachedFeatures,"FILL"===e.displayMode)this.setContentHeight(this.$viewport.height());else if("function"==typeof e.computePixelHeight&&t&&t.length>0){let n=e.computePixelHeight(t);n!==this.$content.height()&&this.setContentHeight(n)}}getContentHeight(){return this.$content.height()}setContentHeight(t){t=Math.min(t,32e3),this.$content.height(t)}isLoading(){return!1}saveSVG(){}isVisible(){return this.$viewport.width()}setWidth(t){this.$viewport.width(t)}getWidth(){return this.$viewport.width()}getContentTop(){return this.contentDiv.offsetTop}containsPosition(t,e){console.log("Viewport - containsPosition(chr, position)")}addMouseHandlers(){}removeMouseHandlers(){}dispose(){this.popover&&this.popover.dispose(),this.$viewport.get(0).remove();for(let t of Object.keys(this))this[t]=void 0}}{constructor(t,e,n,r){super(t,e,n,r)}initializationHelper(){this.$spinner=de("<div>",{class:"igv-loading-spinner-container"}),this.$viewport.append(this.$spinner),this.$spinner.append(de("<div>"));const t=this.trackView.track;"sequence"!==t.type&&(this.$zoomInNotice=this.createZoomInNotice(this.$content)),t.name&&"sequence"!==t.id&&(this.$trackLabel=de('<div class="igv-track-label">'),this.$viewport.append(this.$trackLabel),this.setTrackLabel(t.name),!1===this.browser.trackLabelsVisible&&this.$trackLabel.hide()),this.stopSpinner(),this.addMouseHandlers()}setContentHeight(t){super.setContentHeight(t),this.featureCache&&(this.featureCache.redraw=!0)}setTrackLabel(t){this.$trackLabel.empty(),this.$trackLabel.html(t);const e=this.$trackLabel.text();this.$trackLabel.attr("title",e)}startSpinner(){this.$spinner.show()}stopSpinner(){this.$spinner&&this.$spinner.hide()}checkZoomIn(){if(this.trackView.track&&"sequence"===this.trackView.track.type&&this.referenceFrame.bpPerPixel>1)return de(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 t=this.trackView.track.visibilityWindow;return void 0!==t&&t>0&&this.referenceFrame.bpPerPixel*this.$viewport.width()>t}return!0})()){if(this.canvas&&(de(this.canvas).remove(),this.canvas=void 0),this.trackView.track.autoHeight){const t=this.trackView.minHeight||0;this.setContentHeight(t)}return this.$zoomInNotice&&this.$zoomInNotice.show(),!1}return this.$zoomInNotice&&this.$zoomInNotice.hide(),!0}shift(){const t=this.referenceFrame;if(this.canvas&&this.canvas._data&&this.canvas._data.chr===this.referenceFrame.chr&&this.canvas._data.bpPerPixel===t.bpPerPixel){const e=Math.round((this.canvas._data.startBP-t.start)/t.bpPerPixel);this.canvas.style.left=e+"px"}}async loadFeatures(){const t=this.referenceFrame,e=t.chr,n=this.browser.genome.getChromosome(e).bpLength,r=this.$content.width()*t.bpPerPixel,i=Math.floor(Math.max(0,t.start-r)),o=Math.ceil(Math.min(n,t.start+r+r));if(!this.loading||this.loading.start!==i||this.loading.end!==o){this.loading={start:i,end:o},this.startSpinner();try{const n=this.trackView.track,r=await this.getFeatures(n,e,i,o,t.bpPerPixel);let c=[];const l=(s=this.browser.roi,a=n.roi,s&&a?s.concat(a):s||a);if(l)for(let n of l){const r=await n.getFeatures(e,i,o,t.bpPerPixel);c.push({track:n,features:r})}const h=n&&("wig"===n.type||"merged"===n.type);return this.featureCache=new ca(e,i,o,t.bpPerPixel,r,c,h),this.loading=!1,this.hideMessage(),this.stopSpinner(),this.featureCache}catch(t){this.trackView&&!0!==this.trackView.disposed&&(this.showMessage("Error loading track data"),Qo.presentAlert(t),console.error(t))}finally{this.loading=!1,this.stopSpinner()}var s,a}}repaintDimensions(){const t=na.isWholeGenomeView(this.referenceFrame.chr),e=t?this.$viewport.width():3*this.$viewport.width(),n=this.referenceFrame.bpPerPixel;return{startBP:this.referenceFrame.start-(t?0:e/3*n),endBP:this.referenceFrame.end+(t?0:e/3*n),pixelWidth:e}}repaint(){if(void 0===this.featureCache)return;let{features:t,roiFeatures:e}=this.featureCache;na.isWholeGenomeView(this.referenceFrame.chr);const{startBP:n,endBP:r,pixelWidth:i}=this.repaintDimensions(),o=this.$viewport.height(),s=this.getContentHeight(),a=e?Math.max(s,o):s,c=Math.min(a,3*o);if(0===i||0===c)return void(this.canvas&&de(this.canvas).remove());const l=Math.max(0,-this.$content.position().top-o),h=this.referenceFrame.bpPerPixel,u=Math.round((n-this.referenceFrame.start)/h),f=de('<canvas class="igv-canvas">').get(0);f.style.width=i+"px",f.style.height=c+"px",f.style.left=u+"px",f.style.top=l+"px";const d="FILL"===this.trackView.track.displayMode||!1!==this.trackView.track.supportHiDPI?window.devicePixelRatio:1;f.width=d*i,f.height=d*c;const p=f.getContext("2d");p.scale(d,d),p.translate(0,-l);const g={context:p,pixelXOffset:u,pixelWidth:i,pixelHeight:c,pixelTop:l,bpStart:n,bpEnd:r,bpPerPixel:h,referenceFrame:this.referenceFrame,selection:this.selection,viewport:this,viewportWidth:this.$viewport.width()};this.draw(g,t,e),this.featureCache.canvasTop=l,this.featureCache.height=c,this.canvas&&de(this.canvas).remove(),f._data={chr:this.featureCache.chr,bpPerPixel:h,startBP:n,endBP:r,pixelHeight:c,pixelTop:l},this.canvas=f,this.$content.append(de(f))}draw(t,e,n){if(e&&(t.features=e,this.trackView.track.draw(t)),n)for(let e of n)t.features=e.features,e.track.draw(t)}containsPosition(t,e){return this.referenceFrame.chr===t&&e>=this.referenceFrame.start&&e<=this.referenceFrame.calculateEnd(this.getWidth())}isLoading(){return this.loading}savePNG(){if(!this.canvas)return;const t=this.featureCache,e=t?t.canvasTop:0,n=window.devicePixelRatio,r=this.$viewport.width()*n,i=this.$viewport.height()*n,o=-de(this.canvas).position().left*n,s=(-this.$content.position().top-e)*n,a=this.canvas.getContext("2d").getImageData(o,s,r,i),c=document.createElement("canvas"),l=c.getContext("2d");c.width=a.width,c.height=a.height,l.putImageData(a,0,0);qe((this.$trackLabel.text()?this.$trackLabel.text():"image")+".png",c.toDataURL("image/png"))}saveSVG(){const{width:t,height:e}=this.$viewport.get(0).getBoundingClientRect(),n={width:t,height:e,viewbox:{x:0,y:-this.$content.position().top,width:t,height:e}},r=new js(n),i=`${(this.trackView.track.name||this.trackView.track.id).replace(/\W/g,"")}_referenceFrame_${this.browser.referenceFrameList.indexOf(this.referenceFrame)}_guid_${ve()}`;this.drawSVGWithContext(r,t,e,i,0,0,0);const o=r.getSerializedSvg(!0);qe(`${i}.svg`,URL.createObjectURL(new Blob([o],{type:"application/octet-stream"})))}renderSVGContext(t,{deltaX:e,deltaY:n}){if(this.$zoomInNotice&&this.$zoomInNotice.is(":visible"))return;const r=`${(this.trackView.track.name||this.trackView.track.id).replace(/\W/g,"")}_referenceFrame_${this.browser.referenceFrameList.indexOf(this.referenceFrame)}_guid_${ve()}`,{top:i}=this.$content.position(),{width:o,height:s}=this.$viewport.get(0).getBoundingClientRect();if(this.drawSVGWithContext(t,o,s,r,e,n+i,-i),this.$trackLabel&&!0===this.browser.trackLabelsVisible){const{x:r,y:i,width:o,height:s}=((t,e)=>{const{x:n,y:r,width:i,height:o}=t.getBoundingClientRect(),{x:s,y:a,width:c,height:l}=e.getBoundingClientRect();return{x:s-n,y:a-r,width:c,height:l}})(this.$viewport.get(0),this.$trackLabel.get(0));this.renderTrackLabelSVG(t,e+r,n+i,o,s)}}renderTrackLabelSVG(t,e,n,r,i){const o=`${(this.trackView.track.name||this.trackView.track.id).replace(/\W/g,"")}_track_label_guid_${ve()}`;t.saveWithTranslationAndClipRect(o,e,n,r,i,0),t.fillStyle="white",t.fillRect(0,0,r,i),t.font="12px Arial",t.fillStyle="rgb(68, 68, 68)";const{width:s}=t.measureText(this.$trackLabel.text()),a=.25*(r-s),c=.7*(i-12);t.fillText(this.$trackLabel.text(),a,i-c),t.strokeStyle="rgb(68, 68, 68)",t.strokeRect(0,0,r,i),t.restore()}drawSVGWithContext(t,e,n,r,i,o,s){t.saveWithTranslationAndClipRect(r,i,o,e,n,s);let{start:a,bpPerPixel:c}=this.referenceFrame;const l={context:t,viewport:this,referenceFrame:this.referenceFrame,top:s,pixelTop:s,pixelWidth:e,pixelHeight:n,bpStart:a,bpEnd:a+e*c,bpPerPixel:c,viewportWidth:e,selection:this.selection},h=this.featureCache?this.featureCache.features:[],u=this.featureCache?this.featureCache.roiFeatures:void 0;this.draw(l,h,u),t.restore()}get cachedFeatures(){return this.featureCache?this.featureCache.features:[]}async getFeatures(t,e,n,r,i){if(this.featureCache&&this.featureCache.containsRange(e,n,r,i))return this.featureCache.features;if("function"==typeof t.getFeatures){const o=await t.getFeatures(e,n,r,i,this);return this.checkContentHeight(o),o}}needsRepaint(){if(!this.canvas)return!0;const t=this.canvas._data;return!t||this.referenceFrame.start<t.startBP||this.referenceFrame.end>t.endBP||this.referenceFrame.chr!==t.chr||this.referenceFrame.bpPerPixel!=t.bpPerPixel}needsReload(){if(!this.featureCache)return!0;const t=this.referenceFrame,e=this.referenceFrame.chr,n=t.bpPerPixel,{startBP:r,endBP:i}=this.repaintDimensions();return!this.featureCache.containsRange(e,r,i,n)}createZoomInNotice(t){const e=de("<div>",{class:"igv-zoom-in-notice-container"});t.append(e);const n=de("<div>");return e.append(n),n.text("Zoom in to see features"),e.hide(),e}viewIsReady(){return this.browser&&this.browser.referenceFrameList&&this.referenceFrame}addMouseHandlers(){const t=this.$viewport.get(0);this.addViewportContextMenuHandler(t);const e=t=>{this.enableClick=!0,this.browser.mouseDownOnViewport(t,this),me(t)};t.addEventListener("mousedown",e),t.addEventListener("touchstart",e);const n=t=>{this.browser.dragObject||this.browser.isScrolling?(this.browser.cancelTrackPan(),this.enableClick=!1):(this.browser.cancelTrackPan(),this.browser.endTrackDrag())};t.addEventListener("mouseup",n),t.addEventListener("touchend",n),this.addViewportClickHandler(this.$viewport.get(0)),this.trackView.track.name&&"sequence"!==this.trackView.track.config.type&&this.addTrackLabelClickHandler(this.$trackLabel.get(0))}addViewportContextMenuHandler(t){t.addEventListener("contextmenu",(t=>{if(this.browser.dragObject)return!1;const e=aa(t,this);if(void 0===e)return!1;t.preventDefault();let n=[];if("function"==typeof this.trackView.track.contextMenuItemList){const t=this.trackView.track.contextMenuItemList(e);t&&(n=t)}n.length>0&&n.push({label:de("<HR>")}),n.push({label:"Save Image (PNG)",click:()=>this.saveImage()}),n.push({label:"Save Image (SVG)",click:()=>this.saveSVG()}),this.browser.menuPopup.presentTrackContextMenu(t,n)}))}addViewportClickHandler(t){t.addEventListener("click",(t=>{if(this.enableClick&&this.canvas){if(3===t.which||t.ctrlKey)return;if(de(".igv-popover").hide(),this.browser.dragObject||this.browser.isScrolling)return;t.preventDefault();const e=be(t,this.$viewport.get(0)).x,n=be(t,this.canvas).x,r=this.referenceFrame,i=Math.floor(r.start+r.toBP(n)),o=Date.now();if(o-oa<this.browser.constants.doubleClickDelay){ia&&(window.clearTimeout(ia),ia=void 0);const t=Math.round(r.start+r.toBP(e));let n;if("all"===this.referenceFrame.chr.toLowerCase()){const e=this.browser.genome.getChromosomeCoordinate(t).chr;if(1===this.browser.referenceFrameList.length)n=e;else{const t=this.browser.referenceFrameList.map((({locusSearchString:t})=>t));t[this.browser.referenceFrameList.indexOf(this.referenceFrame)]=e,n=t.join(" ")}this.browser.search(n)}else this.browser.zoomWithScaleFactor(.5,t,this.referenceFrame)}else t.shiftKey&&"function"==typeof this.trackView.track.shiftClick?this.trackView.track.shiftClick(i,t):"function"==typeof this.trackView.track.popupData&&(ia=setTimeout((()=>{const e=function(t,e){const n=aa(t,e);if(void 0===n)return;let r=e.trackView.track;const i=r.popupData(n),o=e.browser.fireEvent("trackclick",[r,i]);let s;void 0===o||!0===o?i&&i.length>0&&(s=i.map((t=>{if(t.name){const e=`<span>${t.name}</span>   ${t.value}`;return`<div title="${t.value}">${e}</div>`}return"<hr>"===t?t:t.html?t.html:`<div title="${t}">${t}</div>`})).join("")):"string"==typeof o&&(s=o);return s}(t,this);e&&(this.popover&&this.popover.dispose(),this.popover=new os(this.browser.columnContainer),this.popover.presentContentWithEvent(t,e)),window.clearTimeout(ia),ia=void 0}),this.browser.constants.doubleClickDelay));oa=o}}))}addTrackLabelClickHandler(t){t.addEventListener("click",(t=>{t.stopPropagation();const{track:e}=this.trackView;let n;"function"==typeof e.description?n=e.description():e.description&&(n=`<div>${e.description}</div>`),n&&(this.popover&&this.popover.dispose(),this.popover=new os(this.browser.columnContainer,e.name||""),this.popover.presentContentWithEvent(t,n))}))}}function aa(t,e){const n=e.referenceFrame,r=be(t,e.contentDiv),i=be(t,e.canvas),o=n.start+n.toBP(r.x);return{event:t,viewport:e,referenceFrame:n,genomicLocation:o,x:r.x,y:r.y,canvasX:i.x,canvasY:i.y}}class ca{constructor(t,e,n,r,i,o,s){this.chr=t,this.startBP=e,this.endBP=n,this.bpPerPixel=r,this.features=i,this.roiFeatures=o,this.multiresolution=s}containsRange(t,e,n,r){const i=this.multiresolution?this.bpPerPixel/r:1;return e>=this.startBP&&n<=this.endBP&&t===this.chr&&i>.5&&i<2}overlapsRange(t,e,n){return this.chr===t&&n>=this.startBP&&e<=this.endBP}}class la{constructor(t){this.rulerSweeper=pe({class:"igv-ruler-sweeper"}),t.contentDiv.appendChild(this.rulerSweeper),this.rulerViewport=t,this.isMouseHandlers=void 0,this.addBrowserObserver()}addBrowserObserver(){this.boundObserverHandler=function(){this.rulerViewport.referenceFrame&&(na.isWholeGenomeView(this.rulerViewport.referenceFrame.chr)?this.removeMouseHandlers():this.addMouseHandlers())}.bind(this),this.rulerViewport.browser.on("locuschange",this.boundObserverHandler)}removeBrowserObserver(){this.rulerViewport.browser.off("locuschange",this.boundObserverHandler)}addMouseHandlers(){if(!0===this.isMouseHandlers)return;let t,e,n,r,i,o;this.boundContentMouseDownHandler=function(o){t=!0,e=!0;const{x:s}=be(o,this.rulerViewport.contentDiv);r=n=s,i=1,this.rulerSweeper.style.display="block",this.rulerSweeper.style.left=`${r}px`,this.rulerSweeper.style.width=`${i}px`}.bind(this),this.rulerViewport.contentDiv.addEventListener("mousedown",this.boundContentMouseDownHandler),this.boundDocumentMouseMoveHandler=function(s){let a;if(t&&e){const{x:t}=be(s,this.rulerViewport.contentDiv);a=Math.max(Math.min(t,this.rulerViewport.contentDiv.clientWidth),0),o=a-n,i=Math.abs(o),this.rulerSweeper.style.width=`${i}px`,o<0&&(r=n+o,this.rulerSweeper.style.left=`${r}px`)}}.bind(this),document.addEventListener("mousemove",this.boundDocumentMouseMoveHandler),this.boundDocumentMouseUpHandler=function(n){let o;if(!0===t&&!0===e&&(t=e=void 0,this.rulerSweeper.style.display="none",i>1)){o={start:ha(this.rulerViewport.referenceFrame,r),end:ha(this.rulerViewport.referenceFrame,r+i)},vs(this.rulerViewport.browser.genome.getChromosome(this.rulerViewport.referenceFrame.chr).bpLength,o,this.rulerViewport.browser.minimumBases());const t=Math.round(o.start),e=Math.round(o.end);this.rulerViewport.referenceFrame.bpPerPixel=(e-t)/this.rulerViewport.contentDiv.clientWidth,this.rulerViewport.referenceFrame.start=t,this.rulerViewport.referenceFrame.end=e,this.rulerViewport.browser.updateViews()}}.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()}}function ha(t,e){return t.start+e*t.bpPerPixel}class ua{constructor(t){this.paired=!0,this.firstAlignment=t,this.chr=t.chr,this.readName=t.readName,t.start<t.mate.position?(this.start=t.start,this.scStart=t.scStart,this.connectingStart=t.start+t.lengthOnRef,this.connectingEnd=t.mate.position):(this.start=t.mate.position,this.scStart=this.start,this.connectingStart=t.mate.position,this.connectingEnd=t.start),this.end=Math.max(t.mate.position,t.start+t.lengthOnRef),this.lengthOnRef=this.end-this.start;let e=Math.max(this.end,t.scStart+t.scLengthOnRef);this.scLengthOnRef=e-this.scStart}setSecondAlignment(t){this.secondAlignment=t;const e=this.firstAlignment;t.start>e.start?this.connectingEnd=t.start:this.connectingStart=t.start+t.lengthOnRef,this.start=Math.min(e.start,t.start),this.end=Math.max(e.start+e.lengthOnRef,t.start+t.lengthOnRef),this.lengthOnRef=this.end-this.start,this.scStart=Math.min(e.scStart,t.scStart);const n=Math.max(e.scStart+e.scLengthOnRef,t.scStart+t.scLengthOnRef);this.scLengthOnRef=n-this.scStart}containsLocation(t,e){const n=e?this.scStart:this.start,r=e?this.scLengthOnRef:this.lengthOnRef;return t>=n&&t<=n+r}alignmentContaining(t,e){return this.firstAlignment.containsLocation(t,e)?this.firstAlignment:this.secondAlignment&&this.secondAlignment.containsLocation(t,e)?this.secondAlignment:void 0}popupData(t){let e=this.firstAlignment.popupData(t);return this.secondAlignment&&(e.push("-------------------------------"),e=e.concat(this.secondAlignment.popupData(t))),e}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(t){return this.firstAlignment.hasTag(t)||this.secondAlignment&&this.secondAlignment.hasTag(t)}}const fa=ke,da=function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)};class pa{constructor(){this.alignments=[],this.score=void 0}findAlignment(t){const e=(t,e)=>e>=t.start&&e<t.start+t.lengthOnRef;let n;for(let r=0;r<this.alignments.length;r++){const i=this.alignments[r];if(t>=i.start&&t<i.start+i.lengthOnRef){i.paired?i.firstAlignment&&e(i.firstAlignment,t)?n=i.firstAlignment:i.secondAlignment&&e(i.secondAlignment,t)&&(n=i.secondAlignment):n=i;break}}return n}updateScore(t,e){this.score=this.calculateScore(t,e)}calculateScore({position:t,option:e,direction:n,tag:r},i){e||(e="BASE");const o=this.findAlignment(t);if(void 0===o)return Number.MAX_VALUE*(n?1:-1);let s;switch(e){case"NUCLEOTIDE":case"BASE":return function(t,e,n){let r;const i=Math.floor(n)-e.start;i<e.sequence.length&&(r=e.sequence.charAt(i));if(!r)return 0;const o=t.readBaseAt(n),s=t.readBaseQualityAt(n),a=e.coverageMap,c=Math.floor(n-a.bpStart),l=a.coverage[c];let h=0;if(t.insertions)for(let e of t.insertions)e.start===n&&(h=-l.ins);if(o)if(r=r.toUpperCase(),"N"===o&&0===h)h=2;else if(r!==o&&"="!==o||0!==h){if("X"===o||r!==o){h-=l["pos"+o]+l["neg"+o]+s/1e3}}else h=4-s/1e3;else{const t=l.del;t>0?h-=t:0===h&&(h=1)}return h}(o,i,t);case"STRAND":return o.strand?1:-1;case"START":return o.start;case"TAG":{const t=o.tags()[r];return void 0!==t?fa(t)?da(t):t:Number.MAX_VALUE}case"READ_NAME":return da(o.readName);case"INSERT_SIZE":return-Math.abs(o.fragmentLength);case"GAP_SIZE":return-o.gapSizeAt(t);case"MATE_CHR":return s=o.mate,s?s.chr===o.chr?Number.MAX_VALUE-1:da(s.chr):Number.MAX_VALUE;case"MQ":return void 0===o.mq?Number.MAX_VALUE:-o.mq;default:return Number.MAX_VALUE}}}function ga(t){return t.isPaired()&&t.mate&&t.isMateMapped()&&t.chr===t.mate.chr&&(t.isFirstOfPair()||t.isSecondOfPair())&&!(t.isSecondary()||t.isSupplementary())}function ma(t){const e=[];for(let n of t)for(let t of n.alignments)t instanceof ua?(t.firstAlignment&&e.push(t.firstAlignment),t.secondAlignment&&e.push(t.secondAlignment)):e.push(t);return e}function va(t,e,n,r){if(t){if(0===t.length)return[];{t.sort((function(t,e){return r?t.scStart-e.scStart:t.start-e.start}));const i=t[0];let o=Math.max(e,r?i.scStart:i.start),s=o;const a=[];for(let e of t){const t=r?e.scStart:e.start,n=Math.max(0,t-o);void 0===a[n]&&(a[n]=[]),a[n].push(e)}let c=0,l=0;const h=[],u=2;try{for(;c<t.length;){const t=new pa;for(;s<=n;){let e,i;for(;!e&&s<=n;)i=s-o,void 0===a[i]?++s:e=a[i];if(!e)break;const l=e.pop();0===e.length&&(a[i]=void 0),t.alignments.push(l),s=r?l.scStart+l.scLengthOnRef+u:l.start+l.lengthOnRef+u,++c}if(t.alignments.length>0&&h.push(t),s=o,c===l)break;l=c}}catch(t){throw console.error(t),t}return h}}}class ba{constructor(t,e,n,{samplingWindowSize:r,samplingDepth:i,pairsSupported:o,alleleFreqThreshold:s}){this.chr=t,this.start=Math.floor(e),this.end=Math.ceil(n),this.length=n-e,this.alleleFreqThreshold=void 0===s?.2:s,this.coverageMap=new ya(t,e,n,this.alleleFreqThreshold),this.alignments=[],this.downsampledIntervals=[],this.samplingWindowSize=void 0===r?100:r,this.samplingDepth=void 0===i?1e3:i,this.pairsSupported=void 0===o||o,this.paired=!1,this.pairsCache={},this.downsampledReads=new Set,this.currentBucket=new wa(this.start,this.start+this.samplingWindowSize,this),this.filter=function(t){return t.isMapped()&&!t.isFailsVendorQualityCheck()}}push(t){!1!==this.filter(t)&&(this.coverageMap.incCounts(t),this.pairsSupported&&this.downsampledReads.has(t.readName)||(t.start>=this.currentBucket.end&&(this.finishBucket(),this.currentBucket=new wa(t.start,t.start+this.samplingWindowSize,this)),this.currentBucket.addAlignment(t)))}forEach(t){this.alignments.forEach(t)}finish(){void 0!==this.currentBucket&&this.finishBucket(),this.alignments.sort((function(t,e){return t.start-e.start})),this.pairsCache=void 0,this.downsampledReads=void 0}contains(t,e,n){return this.chr===t&&this.start<=e&&this.end>=n}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 ka(this.currentBucket.start,this.currentBucket.end,this.currentBucket.downsampledCount)),this.paired=this.paired||this.currentBucket.paired}setViewAsPairs(t){let e;e=t?function(t){const e={},n=[];for(let r of t)for(let t of r.alignments)if(ga(t)){let r=e[t.readName];r?(r.setSecondAlignment(t),e[t.readName]=void 0):(r=new ua(t),e[t.readName]=r,n.push(r))}else n.push(t);return n}(this.packedAlignmentRows):ma(this.packedAlignmentRows),this.packedAlignmentRows=va(e,this.start,this.end)}setShowSoftClips(t){const e=this.allAlignments();this.packedAlignmentRows=va(e,this.start,this.end,t)}repack(t,e){const n=this.allAlignments();this.packedAlignmentRows=va(n,this.start,this.end,e)}allAlignments(){const t=[];for(let e of this.packedAlignmentRows)for(let n of e.alignments)t.push(n);return t}getMax(t,e){return this.coverageMap.getMax(t,e)}}class wa{constructor(t,e,n){this.start=t,this.end=e,this.alignments=[],this.downsampledCount=0,this.samplingDepth=n.samplingDepth,this.pairsSupported=n.pairsSupported,this.downsampledReads=n.downsampledReads,this.pairsCache=n.pairsCache}addAlignment(t){var e,n,r;if(this.pairsSupported&&ga(t)&&(r=this.pairsCache[t.readName]))return r.setSecondAlignment(t),void(this.pairsCache[t.readName]=void 0);this.alignments.length<this.samplingDepth?this.pairsSupported&&ga(t)?(r=new ua(t),this.paired=!0,this.pairsCache[t.readName]=r,this.alignments.push(r)):this.alignments.push(t):((e=Math.floor(Math.random()*(this.samplingDepth+this.downsampledCount-1)))<this.samplingDepth?(n=this.alignments[e],this.pairsSupported&&ga(t)?(void 0!==this.pairsCache[n.readName]&&(this.pairsCache[n.readName]=void 0),r=new ua(t),this.paired=!0,this.pairsCache[t.readName]=r,this.alignments[e]=r):this.alignments[e]=t,this.downsampledReads.add(n.readName)):this.downsampledReads.add(t.readName),this.downsampledCount++)}}class ya{constructor(t,e,n,r){this.chr=t,this.bpStart=e,this.length=n-e,this.coverage=new Array(this.length),this.maximum=0,this.threshold=r,this.qualityWeight=!0}getMax(t,e){let n=0;const r=this.coverage.length;for(let i=0;i<r;i++){const r=this.bpStart+i;if(r>e)break;const o=this.coverage[i];r>=t&&o&&(n=Math.max(n,o.total))}return n}incCounts(t){var e=this;if(void 0===t.blocks?n(t):t.blocks.forEach((function(t){n(t)})),t.gaps)for(let n of t.gaps)if("D"===n.type){const t=n.start-e.bpStart;for(let r=t;r<t+n.len;r++)r<0||(this.coverage[r]||(this.coverage[r]=new xa(e.threshold)),this.coverage[r].del++)}if(t.insertions)for(let n of t.insertions){const t=n.start-this.bpStart;t<0||(this.coverage[t]||(this.coverage[t]=new xa(e.threshold)),this.coverage[t].ins++)}function n(n){if("S"===n.type)return;const r=t.seq,i=t.qual,o=n.seqOffset;for(let s=n.start-e.bpStart,a=0;a<n.len;s++,a++){e.coverage[s]||(e.coverage[s]=new xa(e.threshold));const n=null==r?"N":r.charAt(o+a),c=t.strand?"pos"+n:"neg"+n,l=i&&o+a<i.length?i[o+a]:30;e.coverage[s][c]+=1,e.coverage[s]["qual"+n]+=l,e.coverage[s].total+=1,e.coverage[s].qual+=l,e.maximum=Math.max(e.coverage[s].total,e.maximum)}}}}class xa{constructor(t){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=t}isMismatch(t){const e=this.threshold*(this.qualityWeight&&this.qual?this.qual:this.total);let n=0;for(let e of["A","T","C","G"])e!==t&&(n+=this.qualityWeight&&this.qual?this["qual"+e]:this["pos"+e]+this["neg"+e]);return n>=e}}class ka{constructor(t,e,n){this.start=t,this.end=e,this.counts=n}popupData(t){return[{name:"start",value:this.start+1},{name:"end",value:this.end},{name:"# downsampled:",value:this.counts}]}}class _a{constructor(t){const e=t.split(",");this.chr=e[0],this.start=parseInt(e[1]),this.strand=e[2].charAt(0),this.mapQ=parseInt(e[4]),this.numMismatches=parseInt(e[5]),this.lenOnRef=za.computeLengthOnReference(e[3])}printString(){return this.chr+":"+_e(this.start)+"-"+_e(this.start+this.lenOnRef)+" ("+this.strand+") = "+_e(this.lenOnRef)+"bp @MAPQ: "+this.mapQ+" NM: "+this.numMismatches}}function Sa(t){return t.split(";").filter((t=>t.length>0)).map((t=>new _a(t)))}const Ca={c:1,C:1,s:2,S:2,i:4,I:4,f:4};class Ea{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(t){return(this.tagDict||Ta(this.tagBA)).hasOwnProperty(t)}tags(){return this.tagDict||(this.tagBA?(this.tagDict=Ta(this.tagBA),this.tagBA=void 0):this.tagDict={}),this.tagDict}containsLocation(t,e){const n=e?this.scStart:this.start,r=e?this.scLengthOnRef:this.lengthOnRef;return t>=n&&t<=n+r}popupData(t){const e=[];if(t=Math.floor(t),this.insertions){const r=this.seq;for(let i of this.insertions){var n=i.start;if(t===n||t===n-1)return e.push({name:"Insertion",value:r.substr(i.seqOffset,i.len)}),e.push({name:"Location",value:n}),e}}e.push({name:"Read Name",value:this.readName}),e.push("<hr/>"),e.push({name:"Alignment Start",value:_e(1+this.start),borderTop:!0}),e.push({name:"Read Strand",value:!0===this.strand?"(+)":"(-)",borderTop:!0});let r=this.cigar;if(r&&r.length>50){const t=25;r=`${r.substring(0,t-2)} ... ${r.substring(r.length-t+2)}`}e.push({name:"Cigar",value:r}),e.push({name:"Mapping Quality",value:this.mq}),e.push({name:"Secondary",value:s(this.isSecondary())}),e.push({name:"Supplementary",value:s(this.isSupplementary())}),e.push({name:"Duplicate",value:s(this.isDuplicate())}),e.push({name:"Failed QC",value:s(this.isFailsVendorQualityCheck())}),this.isPaired()&&(e.push("<hr/>"),e.push({name:"First in Pair",value:!this.isSecondOfPair(),borderTop:!0}),e.push({name:"Mate is Mapped",value:s(this.isMateMapped())}),this.pairOrientation&&e.push({name:"Pair Orientation",value:this.pairOrientation}),this.isMateMapped()&&(e.push({name:"Mate Chromosome",value:this.mate.chr}),e.push({name:"Mate Start",value:this.mate.position+1}),e.push({name:"Mate Strand",value:!0===this.mate.strand?"(+)":"(-)"}),e.push({name:"Insert Size",value:this.fragmentLength})));const i=this.tags();if(i.hasOwnProperty("SA")){e.push("<hr/>"),e.push({name:"Supplementary Alignments",value:""});const t=Sa(i.SA);if(t){e.push("<ul>");for(let n of t)e.push(`<li>${n.printString()}</li>`);e.push("</ul>")}}const o=new Set(["SA","MD"]);e.push("<hr/>");for(let t in i)o.has(t)||e.push({name:t,value:i[t]});return e.push({name:"Hidden Tags",value:"SA, MD"}),e.push("<hr/>"),e.push({name:"Genomic Location: ",value:_e(1+t)}),e.push({name:"Read Base:",value:this.readBaseAt(t)}),e.push({name:"Base Quality:",value:this.readBaseQualityAt(t)}),e;function s(t){return t?"Yes":"No"}}readBaseAt(t){const e=Aa(this.blocks,t);if(e){if("*"===this.seq)return"*";{const n=e.seqIndexAt(t);return this.seq[n]}}}readBaseQualityAt(t){const e=Aa(this.blocks,t);if(e){if("*"===this.qual)return 30;{const n=e.seqIndexAt(t);return n>=0&&this.qual&&n<this.qual.length?this.qual[n]:30}}}gapSizeAt(t){if(this.gaps)for(let e of this.gaps)if(t>=e.start&&t<e.start+e.len)return e.len;return 0}}function Aa(t,e){for(let n=0;n<t.length;n++){const r=t[n];if(e>=r.start&&e<r.start+r.len)return r}}function Ta(t){let e=0;const n=t.length,r={};for(;e<n;){const n=String.fromCharCode(t[e])+String.fromCharCode(t[e+1]);e+=2;const o=String.fromCharCode(t[e++]);let s;if("A"===o)s=String.fromCharCode(t[e]),e++;else if("i"===o||"I"===o)s=La(t,e),e+=4;else if("c"===o)s=Ia(t,e),e++;else if("C"===o)s=Na(t,e),e++;else if("s"===o||"S"===o)s=Ma(t,e),e+=2;else if("f"===o)s=Ra(t,e),e+=4;else if("Z"===o)for(s="";;){var i=t[e++];if(0===i)break;s+=String.fromCharCode(i)}else{if("B"!==o){s="Error unknown type: "+o,r[n]=s;break}{const i=String.fromCharCode(t[e++]);let o=Ca[i];if(void 0===o){r[n]=`Error: unknown element type '${i}'`;break}e+=4+La(t,e)*o,s="[not shown]"}}r[n]=s}return r}function La(t,e){return t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}function Ma(t,e){return t[e+1]<<8|t[e]}function Ra(t,e){return new DataView(t.buffer).getFloat32(e)}function Ia(t,e){return new DataView(t.buffer).getInt8(e)}function Na(t,e){return new DataView(t.buffer).getUint8(e)}class Pa{constructor(t){t&&Object.assign(this,t)}seqIndexAt(t){return Math.floor(t)-this.start+this.seqOffset}}class Oa{constructor(t){t||(t={}),this.vendorFailed=void 0===t.vendorFailed||t.vendorFailed,this.duplicates=void 0===t.duplicates||t.duplicates,this.secondary=t.secondary||!1,this.supplementary=t.supplementary||!1,this.mqThreshold=void 0===t.mqThreshold?0:t.mqThreshold,t.readgroups&&(this.readgroups=new Set(t.readgroups))}pass(t){if(this.vendorFailed&&t.isFailsVendorQualityCheck())return!1;if(this.duplicates&&t.isDuplicate())return!1;if(this.secondary&&t.isSecondary())return!1;if(this.supplementary&&t.isSupplementary())return!1;if(t.mq<this.mqThreshold)return!1;if(this.readgroups){var e=t.tags().RG;return this.readgroups.has(e)}return!0}}const Fa=["=","A","C","x","G","x","x","x","T","x","x","x","x","x","x","N"],Da=["M","I","D","N","S","H","P","=","X","?","?","?","?","?","?","?"],Ba=Va(new Uint8Array([66,65,77,1]),0),za={readHeader:function(t,e,n){return go.loadArrayBuffer(t,e).then((function(t){var e;return e=Wi(t),za.decodeBamHeader(e,n)}))},decodeBamHeader:function(t,e){var n,r,i,o,s;if((n=Va(t,0))!==Ba)throw new Error("BAM header errror: bad magic number. This could be caused by either a corrupt or missing file.");r=Va(t,4);for(var a=0;a<r;++a)String.fromCharCode(t[a+8]);var c=Va(t,r+8),l=r+12;for(i={},o=[],s={},a=0;a<c;++a){for(var h=Va(t,l),u="",f=0;f<h-1;++f)u+=String.fromCharCode(t[l+4+f]);Va(t,l+h+4),i[u]=a,o[a]=u,e&&(s[e.getChromosomeName(u)]=u),l=l+8+h}return{magicNumber:n,size:l,chrNames:o,chrToIndex:i,chrAliasTable:s}},bam_tag2cigar:function(t,e,n,r,i,o){function s(t){return"C"===t||"c"===t||"A"===t?1:"S"===t||"s"===t?2:"I"===t||"i"===t||"f"===t?4:0}if(1!==o.length||i.start<0)return!1;for(var a=n+(r+1>>1)+r;a+4<e;){if("CG"===String.fromCharCode(t[a])+String.fromCharCode(t[a+1]))break;var c=String.fromCharCode(t[a+2]);if("B"===c)a+=8+s(c=String.fromCharCode(t[a+3]))*Va(t,a+4);else if("Z"===c||"H"===c)for(a+=3;0!==t[a++];);else a+=3+s(c)}if(a>=e)return!1;if("B"!==String.fromCharCode(t[a+2])||"I"!==String.fromCharCode(t[a+3]))return!1;var l=Va(t,a+4),h=a+8;if(h+4*l>e)return!1;var u="",f=0;o.length=0,a=h;for(var d=0;d<l;++d,a+=4){var p=Va(t,a),g=p>>4,m=Da[15&p];"M"!==m&&"EQ"!==m&&"X"!==m&&"D"!==m&&"N"!==m&&"="!==m||(f+=g),u=u+g+m,o.push({len:g,ltr:m})}return i.cigar=u,i.lengthOnRef=f,!0},decodeBamRecords:function(t,e,n,r,i,o,s,a){for(;e<t.length;){const f=e+Va(t,e)+4,d=new Ea,p=Va(t,e+4),g=Va(t,e+8);if(f>t.length)return;if(p<0){e=f;continue}if(void 0!==i&&(p>i||g>s))return!0;if(void 0!==i&&p<i){e=f;continue}const m=Va(t,e+12),v=(65280&m)>>8,b=255&m,w=Va(t,e+16),y=(4294901760&w)>>16,x=65535&w,k=Va(t,e+20),_=Va(t,e+24),S=Va(t,e+28),C=Va(t,e+32);let E=[];for(let n=0;n<b-1;++n)E.push(String.fromCharCode(t[e+36+n]));E=E.join("");let A=0,T="",L=e+36+b;const M=[];let R;for(let e=0;e<x;++e){var c=Va(t,L),l=c>>4,h=Da[15&c];"M"!==h&&"EQ"!==h&&"X"!==h&&"D"!==h&&"N"!==h&&"="!==h||(A+=l),T=T+l+h,L+=4,R={len:l,ltr:h},M.push(R)}if(d.chr=r[p],d.start=g,d.flags=y,d.strand=!(16&y),d.readName=E,d.cigar=T,d.lengthOnRef=A,d.fragmentLength=C,d.mq=v,za.bam_tag2cigar(t,f,L,k,d,M),d.end=d.start+d.lengthOnRef,d.end<o){e=f;continue}let I=[];const N=k+1>>1;for(let e=0;e<N;++e){var u=t[L+e];I.push(Fa[(240&u)>>4]),I.push(Fa[15&u])}I=I.slice(0,k).join(""),L+=N;const P=[];for(let e=0;e<k;++e)P.push(t[L+e]);L+=k,_>=0&&(d.mate={chr:r[_],position:S,strand:!(32&y)}),d.seq=I,d.qual=P,d.tagBA=new Uint8Array(t.buffer.slice(L,f)),this.setPairOrientation(d),(void 0===a||a.pass(d))&&(Ha(d,M),n.push(d)),e=f}},decodeSamRecords:function(t,e,n,r,i,o){var s,a,c,l,h,u,f,d,p,g;for(l=(s=Se(t)).length,!1,a=0;a<l;a++)if(h=s[a].split("\t"),(p=new Ea).chr=h[2],p.start=Number.parseInt(h[3])-1,p.flags=Number.parseInt(h[1]),p.readName=h[0],p.strand=!(16&p.flags),p.mq=Number.parseInt(h[4]),p.cigar=h[5],p.fragmentLength=Number.parseInt(h[8]),p.seq=h[9],"*"!==p.chr&&p.isMapped()&&p.chr===n){if(p.start>i)break;if(d=0,(g=ja(p.cigar)).forEach((function(t){var e=t.len,n=t.ltr;"M"!==n&&"EQ"!==n&&"X"!==n&&"D"!==n&&"N"!==n&&"="!==n||(d+=e)})),p.lengthOnRef=d,!(p.start+d<r)){for(u=h[10],p.qual=[],c=0;c<u.length;c++)p.qual[c]=u.charCodeAt(c)-33;p.tagDict=h.length<11?{}:Ua(h.slice(11)),p.isMateMapped()&&(f=h[6],p.mate={chr:"="===f?p.chr:f,position:Number.parseInt(h[7]),strand:!(32&p.flags)}),this.setPairOrientation(p),(void 0===o||o.pass(p))&&(Ha(p,g),e.push(p))}}},setReaderDefaults:function(t,e){t.filter=new Oa(e.filter),e.readgroup&&(t.filter.readgroups=new Set([e.readgroup])),t.alleleFreqThreshold=void 0===e.alleleFreqThreshold?.2:e.alleleFreqThreshold,t.samplingWindowSize=void 0===e.samplingWindowSize?100:e.samplingWindowSize,t.samplingDepth=void 0===e.samplingDepth?500:e.samplingDepth,t.samplingDepth>1e4&&(console.log("Warning: attempt to set sampling depth > maximum value of 10000"),t.samplingDepth=1e4),e.viewAsPairs?t.pairsSupported=!0:t.pairsSupported=void 0===e.pairsSupported||e.pairsSupported},setPairOrientation:function(t){if(t.isMapped()&&t.mate&&t.isMateMapped()&&t.mate.chr===t.chr){var e=t.strand?"F":"R",n=t.mate,r=n.strand?"F":"R",i=" ",o=" ";t.isFirstOfPair()?(i="1",o="2"):t.isSecondOfPair()&&(i="2",o="1");var s=[],a=t.fragmentLength,c=t.end-t.start;if(0===a)a=(t.start<n.position?n.position+c:n.position-c)-t.start;a>0?(s[0]=e,s[1]=i,s[2]=r,s[3]=o):(s[2]=e,s[3]=i,s[0]=r,s[1]=o),t.pairOrientation=s.join("")}},computeLengthOnReference:function(t){let e=0,n="";for(let r=0;r<t.length;r++){const i=t.charCodeAt(r);if(i>47&&i<58)n+=t.charAt(r);else{switch(i){case 78:case 68:case 77:case 61:case 88:e+=parseInt(n.toString())}n=""}}return e}};function Ha(t,e){const n=[];let r,i,o=0,s=t.start;t.scStart=t.start,t.scLengthOnRef=t.lengthOnRef;for(let a of e){let e;switch(a.ltr){case"H":case"P":break;case"S":e=s,t.scLengthOnRef+=a.len,0===n.length&&(t.scStart-=a.len,e-=a.len),n.push(new Pa({start:e,seqOffset:o,len:a.len,type:"S"})),o+=a.len;break;case"N":case"D":void 0===i&&(i=[]),i.push({start:s,len:a.len,type:a.ltr}),s+=a.len;break;case"I":void 0===r&&(r=[]),r.push(new Pa({start:s,len:a.len,seqOffset:o,type:"I"})),o+=a.len;break;case"M":case"EQ":case"=":case"X":n.push(new Pa({start:s,seqOffset:o,len:a.len,type:"M"})),o+=a.len,s+=a.len;break;default:console.log("Error processing cigar element: "+a.len+a.ltr)}}t.blocks=n,t.insertions=r,t.gaps=i}function Va(t,e){return t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}function ja(t){var e,n,r,i,o,s,a,c,l;for(e=[],n=[],o=null,i=t.length,r=0;r<i;r++)s=t.charAt(r),l=void 0,(l=s.charCodeAt(0))>=48&&l<=57?n.push(s):(a=s,c=Number.parseInt(n.join("")),n=[],null!==o&&o.ltr===a?o.len+=c:(o={len:c,ltr:a},e.push(o)));return e}function Ua(t){var e={};return t.forEach((function(t){var n=t.split(":");e[n[0]]=n[2]})),e}class qa{constructor(t,e){this.config=t,this.genome=e,this.bamPath=t.url,this.isDataUri=ys(t.url),za.setReaderDefaults(this,t)}async readAlignments(t,e,n){if(this.alignmentCache){const r=this.header,i=r.chrAliasTable.hasOwnProperty(t)?r.chrAliasTable[t]:t,o=this.alignmentCache.queryFeatures(i,e,n),s=new ba(t,e,n,this.config);for(let t of o)s.push(t);return s.finish(),s}if(this.isDataUri){const r=Wi(function(t){const e=t.split(","),n=e[0].split(":")[1];let r=e[1];r=n.indexOf("base64")>=0?atob(r):decodeURI(r);const i=new Uint8Array(r.length);for(var o=0;o<r.length;o++)i[o]=r.charCodeAt(o);return i}(this.bamPath).buffer);return this.parseAlignments(r),this.fetchAlignments(t,e,n)}{const r=Wi(await go.loadArrayBuffer(this.bamPath,gs(this.config)));return this.parseAlignments(r),this.fetchAlignments(t,e,n)}}parseAlignments(t){const e=[];this.header=za.decodeBamHeader(t),za.decodeBamRecords(t,this.header.size,e,this.header.chrNames),this.alignmentCache=new Mo(e,this.genome)}fetchAlignments(t,e,n){const r=this.header.chrAliasTable.hasOwnProperty(t)?this.header.chrAliasTable[t]:t,i=this.alignmentCache.queryFeatures(r,e,n),o=new ba(t,e,n,this.config);for(let t of i)o.push(t);return o.finish(),o}}class Wa{constructor(t,e){this.littleEndian=void 0===e||e,this.position=0,this.view=t,this.length=t.byteLength}available(){return this.length-this.position}remLength(){return this.length-this.position}hasNext(){return this.position<this.length-1}getByte(){var t=this.view.getUint8(this.position,this.littleEndian);return this.position++,t}getShort(){var t=this.view.getInt16(this.position,this.littleEndian);return this.position+=2,t}getUShort(){var t=this.view.getUint16(this.position,this.littleEndian);return this.position+=2,t}getInt(){var t=this.view.getInt32(this.position,this.littleEndian);return this.position+=4,t}getUInt(){var t=this.view.getUint32(this.position,this.littleEndian);return this.position+=4,t}getLong(){var t=[];t[0]=this.view.getUint8(this.position),t[1]=this.view.getUint8(this.position+1),t[2]=this.view.getUint8(this.position+2),t[3]=this.view.getUint8(this.position+3),t[4]=this.view.getUint8(this.position+4),t[5]=this.view.getUint8(this.position+5),t[6]=this.view.getUint8(this.position+6),t[7]=this.view.getUint8(this.position+7);var e=0;if(this.littleEndian)for(let n=t.length-1;n>=0;n--)e=256*e+t[n];else for(let n=0;n<t.length;n++)e=256*e+t[n];return this.position+=8,e}getString(t){for(var e,n="";0!==(e=this.view.getUint8(this.position++))&&(n+=String.fromCharCode(e),!t||n.length!==t););return n}getFixedLengthString(t){var e,n,r="";for(e=0;e<t;e++)(n=this.view.getUint8(this.position++))>0&&(r+=String.fromCharCode(n));return r}getFixedLengthTrimmedString(t){var e,n,r="";for(e=0;e<t;e++)(n=this.view.getUint8(this.position++))>32&&(r+=String.fromCharCode(n));return r}getFloat(){var t=this.view.getFloat32(this.position,this.littleEndian);return this.position+=4,t}getDouble(){var t=this.view.getFloat64(this.position,this.littleEndian);return this.position+=8,t}skip(t){return this.position+=t,this.position}getVPointer(){var t=this.position,e=this.view.getUint8(t+1)<<8|this.view.getUint8(t),n=4294967296*(255&this.view.getUint8(t+6))+16777216*(255&this.view.getUint8(t+5))+65536*(255&this.view.getUint8(t+4))+256*(255&this.view.getUint8(t+3))+(255&this.view.getUint8(t+2));return this.position+=8,new $a(n,e)}}class $a{constructor(t,e){this.block=t,this.offset=e}isLessThan(t){return this.block<t.block||this.block===t.block&&this.offset<t.offset}isGreaterThan(t){return this.block>t.block||this.block===t.block&&this.offset>t.offset}print(){return this.block+":"+this.offset}}class Ga{constructor(t){this.tabix=!0}parse(t,e){const n=new Wa(new DataView(t)),r=n.getInt();if(21582659!==r)throw 38359875===r?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=n.getInt(),this.depth=n.getInt();const i=[];let o=0;if(n.getInt()>=28){n.getInt(),n.getInt(),n.getInt(),n.getInt(),n.getInt(),n.getInt();const t=n.getInt(),r=n.position+t;let o=0;for(;n.position<r;){let t=n.getString();e&&(t=e.getChromosomeName(t)),this.sequenceIndexMap[t]=o,i[o]=t,o++}}const s=this.bin_limit()+1,a=n.getInt();for(let t=0;t<a;t++){const e=[],r=[],i=n.getInt();for(let t=0;t<i;t++){const t=n.getInt();if(r[t]=n.getVPointer(),t>s)n.getInt(),n.getVPointer(),n.getVPointer(),n.getLong(),n.getLong();else{e[t]=[];const r=n.getInt();for(let i=0;i<r;i++){const r=n.getVPointer(),i=n.getVPointer();r&&i&&(r.block<this.blockMin&&(this.blockMin=r.block),i.block>o&&(o=i.block),e[t].push([r,i]))}}}i>0&&(this.indices[t]={binIndex:e,loffset:r})}this.lastBlockPosition=o}get chromosomeNames(){return Object.keys(this.sequenceIndexMap)}blocksForRange(t,e,n){const r=this.indices[t];if(r){const t=this.reg2bins(e,n);if(0==t.length)return[];const i=[];for(let e of t)for(let t=e[0];t<=e[1];t++)if(r.binIndex[t]){const e=r.binIndex[t],n=e.length;for(let r=0;r<n;++r){const n=e[r][0],o=e[r][1];i.push({minv:n,maxv:o,bin:t})}}return function(t,e){const n=[];let r=null;return 0===t.length?t:(t.sort((function(t,e){const n=t.minv.block-e.minv.block;return 0!==n?n:t.minv.offset-e.minv.offset})),t.forEach((function(t){var i,o;e&&!t.maxv.isGreaterThan(e)||(null===r?(n.push(t),r=t):(i=r,(o=t).minv.block-i.maxv.block<65e3&&o.maxv.block-i.minv.block<5e6?t.maxv.isGreaterThan(r.maxv)&&(r.maxv=t.maxv):(n.push(t),r=t)))})),n)}(i,r.loffset[t[0]])}return[]}reg2bins(t,e){(t-=1)<1&&(t=1),e>2**50&&(e=2**34),e-=1;let n=0,r=0,i=this.minShift+3*this.depth;const o=[];for(;n<=this.depth;i-=3,r+=1<<3*n,n+=1){const n=r+(t>>i),s=r+(e>>i);if(s-n+o.length>this.maxBinNumber)throw new Error(`query ${t}-${e} is too large for current binning scheme (shift ${this.minShift}, depth ${this.depth}), try a smaller query or a coarser index binning scheme`);o.push([n,s])}return o}bin_limit(){return((1<<3*(this.depth+1))-1)/7}}class Za{constructor(){}async parse(t,e,n){const r=[];let i=Number.MAX_SAFE_INTEGER,o=0;const s=[],a=new Wa(new DataView(t)),c=a.getInt(),l={};if(!(21578050===c||e&&21578324===c))throw new Error(indexURL+" is not a "+(e?"tabix":"bai")+" file");{const t=a.getInt();if(e){a.getInt(),a.getInt(),a.getInt(),a.getInt(),a.getInt(),a.getInt(),a.getInt();for(let e=0;e<t;e++){let t=a.getString();n&&(t=n.getChromosomeName(t)),l[t]=e,s[e]=t}}for(let e=0;e<t;e++){const t={},n=[],s=a.getInt();for(let e=0;e<s;e++){const e=a.getInt();if(37450===e)a.getInt(),a.getVPointer(),a.getVPointer(),a.getLong(),a.getLong();else{t[e]=[];const n=a.getInt();for(let r=0;r<n;r++){const n=a.getVPointer(),r=a.getVPointer();n&&r&&(n.block<i&&(i=n.block),r.block>o&&(o=r.block),t[e].push([n,r]))}}}const c=a.getInt();for(let t=0;t<c;t++){const t=a.getVPointer();n.push(t)}s>0&&(r[e]={binIndex:t,linearIndex:n})}this.firstBlockPosition=i,this.lastBlockPosition=o,this.indices=r,this.sequenceIndexMap=l,this.tabix=e}}get chromosomeNames(){return Object.keys(this.sequenceIndexMap)}blocksForRange(t,e,n){const r=this.indices[t];if(r){const t=function(t,e){const n=[];e>=1<<29&&(e=1<<29);return--e,n.push([0,0]),n.push([1+(t>>26),1+(e>>26)]),n.push([9+(t>>23),9+(e>>23)]),n.push([73+(t>>20),73+(e>>20)]),n.push([585+(t>>17),585+(e>>17)]),n.push([4681+(t>>14),4681+(e>>14)]),n}(e,n),i=[];for(let e of t)for(let t=e[0];t<=e[1];t++)if(r.binIndex[t]){const e=r.binIndex[t],n=e.length;for(let r=0;r<n;++r){const n=e[r][0],o=e[r][1];i.push({minv:n,maxv:o,bin:t})}}const o=r.linearIndex.length;let s=null;const a=Math.min(e>>14,o-1),c=Math.min(n>>14,o-1);for(let t=a;t<=c;++t){const e=r.linearIndex[t];e&&(s&&!e.isLessThan(s)||(s=e))}return function(t,e){const n=[];let r=null;return 0===t.length?t:(t.sort((function(t,e){const n=t.minv.block-e.minv.block;return 0!==n?n:t.minv.offset-e.minv.offset})),t.forEach((function(t){e&&!t.maxv.isGreaterThan(e)||(null!==r&&function(t,e){const n=e.minv.block-t.maxv.block,r=e.maxv.block-t.minv.block;return n<3e4&&r<1e7}(r,t)?t.maxv.isGreaterThan(r.maxv)&&(r.maxv=t.maxv):(n.push(t),r=t))})),n)}(i,s)}return[]}}class Xa{constructor(){}async parse(t,e){let n=0;this.chrIndex={},this.lastBlockPosition=[];const r=new Wa(new DataView(t));!function(t){t.getInt(),t.getInt();const e=t.getInt();if(t.getString(),t.getLong(),t.getLong(),t.getString(),t.getInt(),e>=3){let e=t.getInt();for(;e-- >0;)t.getString(),t.getString()}}(r);let i=r.getInt();for(;i-- >0;){let t=r.getString();e&&(t=e.getChromosomeName(t));const i=r.getInt(),o=r.getInt(),s=r.getInt();r.getInt(),r.getInt();let a=r.getLong();const c=[];for(let t=0;t<o;t++){const t=r.getLong();c.push({min:a,max:t}),a=t,t>n&&(n=t)}this.chrIndex[t]={chr:t,blocks:c,longestFeature:s,binWidth:i}}this.lastBlockPosition=n}get chromosomeNames(){return Object.keys(this.chrIndex)}blocksForRange(t,e,n){const r=this.chrIndex[t];if(r){const t=r.blocks,i=r.longestFeature,o=r.binWidth,s=Math.max(e-i,0),a=Math.floor(s/o);if(a>=t.length)return[];{const e=Math.min(Math.floor((n-1)/o),t.length-1),r=t[a].min,i=t[e].max;if(0===i-r)return[];return[{minv:{block:r,offset:0},maxv:{block:i,offset:0}}]}}}}async function Ya(t,e,n){let r=await go.loadArrayBuffer(t,gs(e)),i=new DataView(r);if(31===i.getUint8(0)&&139===i.getUint8(1)){r=Wi(r).buffer,i=new DataView(r)}switch(i.getInt32(0,!0)){case 21578050:return async function(t,e){const n=new Za;return await n.parse(t,!1,e),n}(r,n);case 21578324:return async function(t,e){const n=new Za;return await n.parse(t,!0,e),n}(r,n);case 21582659:return async function(t,e){const n=new Ga;return n.parse(t,e),n}(r,n);case 1480870228:return async function(t,e){const n=new Xa;return n.parse(t,e),n}(r,n);case 38359875:throw Error("CSI version 2 is not supported.");default:throw Error(`Unrecognized index type: ${t}`)}}class Ka{constructor(t,e){this.config=t,this.genome=e,this.bamPath=t.url,this.baiPath=t.indexURL,za.setReaderDefaults(this,t)}async readAlignments(t,e,n){const r=(await this.getChrIndex())[this.chrAliasTable.hasOwnProperty(t)?this.chrAliasTable[t]:t],i=new ba(t,e,n,this.config);if(void 0===r)return i;{const t=(await this.getIndex()).blocksForRange(r,e,n);if(!t||0===t.length)return i;for(let s of t){let t;if(0===s.maxv.offset)t=0;else{const e=gs(this.config,{range:{start:s.maxv.block,size:26}});t=$i(await go.loadArrayBuffer(this.bamPath,e))}const a=s.minv.block,c={start:a,size:s.maxv.block+t-a+1};var o=Wi(await go.loadArrayBuffer(this.bamPath,gs(this.config,{range:c})));if(za.decodeBamRecords(o,s.minv.offset,i,this.indexToChr,r,e,n,this.filter))break}return i.finish(),i}}async getHeader(){if(!this.header){const t=this.genome,e=await this.getIndex();let n;if(e.firstBlockPosition){const t=gs(this.config,{range:{start:e.firstBlockPosition,size:26}}),r=$i(await go.loadArrayBuffer(this.bamPath,t));n=e.firstBlockPosition+r}else n=64e3;const r=gs(this.config,{range:{start:0,size:n}});this.header=await za.readHeader(this.bamPath,r,t)}return this.header}async getIndex(){const t=this.genome;return this.index||(this.index=await Ya(this.baiPath,this.config,t)),this.index}async getChrIndex(){if(this.chrToIndex)return this.chrToIndex;{const t=await this.getHeader();return this.chrToIndex=t.chrToIndex,this.indexToChr=t.chrNames,this.chrAliasTable=t.chrAliasTable,this.chrToIndex}}}class Qa{constructor(t,e){this.config=t,this.genome=e;const n={};t.sources.sequences.forEach((function(r){const i=e?e.getChromosomeName(r):r;n[i]=function(t,e,n){const r={url:t.sources.url.replace("$CHR",n)};t.sources.indexURL&&(r.indexURL=t.sources.indexURL.replace("$CHR",n));const i=Object.assign(t,r);return new Ka(i,e)}(t,e,r)})),this.bamReaders=n,za.setReaderDefaults(this,t)}async readAlignments(t,e,n){if(this.bamReaders.hasOwnProperty(t)){let r=this.bamReaders[t];return await r.readAlignments(t,e,n)}return new ba(t,e,n,this.config)}}const Ja=function(t,e){this.config=t,this.genome=e,za.setReaderDefaults(this,t)};function tc(){const t=this,e=this.genome;if(this.header)return Promise.resolve(this.header);{const n=this.config.url+"?file="+this.config.alignmentFile+"&options=-b,-H",r=gs(this.config);return za.readHeader(n,r,e).then((function(e){return t.header=e,e}))}}Ja.prototype.readAlignments=function(t,e,n){var r=this;return tc.call(r).then((function(i){var o,s;return o=i.chrAliasTable.hasOwnProperty(t)?i.chrAliasTable[t]:t,s=r.config.url+"?reference="+r.config.referenceFile+"&file="+r.config.alignmentFile+"®ion="+o+":"+e+"-"+n,go.loadString(s,gs(r.config)).then((function(s){var a;return i.chrToIndex[o],a=new ba(t,e,n,r.config),za.decodeSamRecords(s,a,o,e,n,r.filter),a}))}))};class ec{constructor(t,e){if(this.config=t,this.genome=e,this.format=t.format?t.format.toUpperCase():"BAM","BAM"!==this.format&&"VCF"!==this.format)throw Error(`htsget format ${t.format} is not supported`)}async readHeaderData(){const t=`${nc(this.config)}?class=header&format=${this.format}`,e=await go.loadJson(t,gs(this.config));return await this.loadUrls(e.htsget.urls)}async readData(t,e,n){const r=`${nc(this.config)}?format=${this.format}&referenceName=${t}&start=${Math.floor(e)}&end=${Math.ceil(n)}`,i=await go.loadJson(r,gs(this.config));return this.loadUrls(i.htsget.urls)}async loadUrls(t){const e=[];for(let n of t)if(n.url.startsWith("data:"))e.push(Promise.resolve(rc(n.url)));else{const t=gs(this.config||{});n.headers&&(t.headers=Object.assign(t.headers||{},n.headers)),e.push(go.loadArrayBuffer(n.url,t))}return function(t){let e=0;for(let n of t)e+=n.byteLength;let n=0;const r=new Uint8Array(e);for(let e of t){const t=new Uint8Array(e);r.set(t,n),n+=t.length}return r}(await Promise.all(e))}static async inferFormat(t){try{const e=nc(t),n=`${e}${e.includes("?")?"&":"?"}class=header`,r=await go.loadJson(n,gs(t));if(r.htsget){const e=r.htsget.format;if("BAM"!==e&&"VCF"!==e)throw Error(`htsget format ${e} is not supported`);t.format=e.toLowerCase(),t.sourceType="htsget",t.name||(t.name=await bs(t.url))}}catch(t){}}}function nc(t){if(t.url&&t.endpoint&&t.id)return t.url+t.endpoint+t.id;if(t.endpoint&&t.id)return t.endpoint+t.id;if(t.url)return t.url.startsWith("htsget://")?t.url.replace("htsget://","https://"):t.url;throw Error("Must specify either 'url', or 'endpoint' and 'id")}function rc(t){const e=t.split(","),n=e[0].split(":")[1];let r=e[1];r=n.indexOf("base64")>=0?atob(r):decodeURI(r);const i=new Uint8Array(r.length);for(var o=0;o<r.length;o++)i[o]=r.charCodeAt(o);return i}class ic extends ec{constructor(t,e){super(t,e),za.setReaderDefaults(this,t)}async readAlignments(t,e,n){if(!this.header){const t=Wi((await this.readHeaderData()).buffer);this.header=za.decodeBamHeader(t,this.genome),this.chrAliasTable=new Map;for(let t of Object.keys(this.header.chrAliasTable))this.chrAliasTable.set(t,this.header.chrAliasTable[t])}let r=this.chrAliasTable.has(t)?this.chrAliasTable.get(t):t;const i=Wi((await this.readData(r,e,n)).buffer),o=this.header.chrToIndex[t],s=new ba(t,e,n,this.config);return za.decodeBamRecords(i,this.header.size,s,this.header.chrNames,o,e,n),s.finish(),s}}const oc=eval,sc=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=163)}([function(t,e,n){var r=n(13),i=n(81).f,o=n(107),s=n(3),a=n(15),c=n(20),l=n(24),h=function(t){var e=function(e,n,r){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(e);case 2:return new t(e,n)}return new t(e,n,r)}return t.apply(this,arguments)};return e.prototype=t.prototype,e};t.exports=function(t,e){var n,u,f,d,p,g,m,v,b=t.target,w=t.global,y=t.stat,x=t.proto,k=w?r:y?r[b]:(r[b]||{}).prototype,_=w?s:s[b]||(s[b]={}),S=_.prototype;for(f in e)n=!o(w?f:b+(y?".":"#")+f,t.forced)&&k&&l(k,f),p=_[f],n&&(g=t.noTargetGet?(v=i(k,f))&&v.value:k[f]),d=n&&g?g:e[f],n&&typeof p==typeof d||(m=t.bind&&n?a(d,r):t.wrap&&n?h(d):x&&"function"==typeof d?a(Function.call,d):d,(t.sham||d&&d.sham||p&&p.sham)&&c(m,"sham",!0),_[f]=m,x&&(l(s,u=b+"Prototype")||c(s,u,{}),s[u][f]=d,t.real&&S&&!S[f]&&c(S,f,d)))}},function(t,e){t.exports=function(t){return t&&t.__esModule?t:{default:t}}},function(t,e,n){var r=n(14);t.exports=function(t){if(!r(t))throw TypeError(String(t)+" is not an object");return t}},function(t,e){t.exports={}},function(t,e){t.exports=!0},function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function");return t}},function(t,e,n){var r=n(13),i=n(61),o=n(64),s=n(110),a=r.Symbol,c=i("wks");t.exports=function(t){return c[t]||(c[t]=s&&a[t]||(s?a:o)("Symbol."+t))}},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e,n){var r=n(2),i=n(119),o=n(29),s=n(15),a=n(90),c=n(120),l=function(t,e){this.stopped=t,this.result=e};(t.exports=function(t,e,n,h,u){var f,d,p,g,m,v,b=s(e,n,h?2:1);if(u)f=t;else{if("function"!=typeof(d=a(t)))throw TypeError("Target is not iterable");if(i(d)){for(p=0,g=o(t.length);g>p;p++)if((m=h?b(r(v=t[p])[0],v[1]):b(t[p]))&&m instanceof l)return m;return new l(!1)}f=d.call(t)}for(;!(v=f.next()).done;)if((m=c(f,b,v.value,h))&&m instanceof l)return m;return new l(!1)}).stop=function(t){return new l(!0,t)}},function(t,e,n){var r=n(1),i=r(n(7)),o=r(n(32)),s=r(n(27)),a=r(n(33)),c=r(n(265)),l=function(t){function e(){return(0,i.default)(this,e),(0,o.default)(this,(0,s.default)(e).apply(this,arguments))}return(0,a.default)(e,t),e}((0,c.default)(Error)),h=function(t){function e(){return(0,i.default)(this,e),(0,o.default)(this,(0,s.default)(e).apply(this,arguments))}return(0,a.default)(e,t),e}((0,c.default)(Error)),u=function(t){function e(){return(0,i.default)(this,e),(0,o.default)(this,(0,s.default)(e).apply(this,arguments))}return(0,a.default)(e,t),e}(l),f=function(t){function e(){return(0,i.default)(this,e),(0,o.default)(this,(0,s.default)(e).apply(this,arguments))}return(0,a.default)(e,t),e}(u),d=function(t){function e(){return(0,i.default)(this,e),(0,o.default)(this,(0,s.default)(e).apply(this,arguments))}return(0,a.default)(e,t),e}(l),p=function(t){function e(){return(0,i.default)(this,e),(0,o.default)(this,(0,s.default)(e).apply(this,arguments))}return(0,a.default)(e,t),e}(l);t.exports={CramBufferOverrunError:f,CramMalformedError:u,CramUnimplementedError:h,CramSizeLimitError:d,CramArgumentError:p}},function(t,e,n){var r=n(196);function i(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),r(t,i.key,i)}}t.exports=function(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),t}},function(t,e,n){var r=n(3),i=n(24),o=n(95),s=n(21).f;t.exports=function(t){var e=r.Symbol||(r.Symbol={});i(e,t)||s(e,t,{value:o.f(t)})}},function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,e,n){(function(e){var n="object",r=function(t){return t&&t.Math==Math&&t};t.exports=r(typeof globalThis==n&&globalThis)||r(typeof window==n&&window)||r(typeof self==n&&self)||r(typeof e==n&&e)||Function("return this")()}).call(this,n(23))},function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,e,n){var r=n(5);t.exports=function(t,e,n){if(r(t),void 0===e)return t;switch(n){case 0:return function(){return t.call(e)};case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,i){return t.call(e,n,r,i)}}return function(){return t.apply(e,arguments)}}},function(t,e,n){t.exports=n(167)},function(t,e,n){var r=n(12);t.exports=!r((function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}))},function(t,e,n){var r=n(3);t.exports=function(t){return r[t+"Prototype"]}},function(t,e,n){(function(t){
|
|
40
40
|
/*!
|
|
41
41
|
* The buffer module from node.js, for the browser.
|
|
42
42
|
*
|
|
@@ -61,12 +61,12 @@ var r=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.pr
|
|
|
61
61
|
*
|
|
62
62
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
63
63
|
* @license MIT
|
|
64
|
-
*/t.exports=function(t){return null!=t&&(n(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&n(t.slice(0,0))}(t)||!!t._isBuffer)}},function(t,e,n){var r,i=n(1),o=i(n(148)),s=i(n(76)),a=i(n(150)),c=i(n(37)),l=i(n(30)),h=i(n(31)),u=i(n(7)),f=i(n(10)),d=i(n(99)),p=i(n(16)),g=i(n(77)),m=i(n(59)),v=n(9),b=v.CramMalformedError,w=v.CramBufferOverrunError,y=v.CramArgumentError,x=n(58),k=x.parseItem,_=x.tinyMemoize,S=x.sequenceMD5,C=n(100),E=n(363);function A(t,e,n,r){if(!r)throw new b("could not resolve intra-slice mate pairs, file seems truncated or malformed");var i=!!(r.mate||void 0!==r.mateRecordNumber&&r.mateRecordNumber!==e);n.readName||(n.readName=String(n.uniqueId),r.readName=n.readName),n.mate={sequenceId:r.sequenceId,alignmentStart:r.alignmentStart,uniqueId:r.uniqueId},r.readName&&(n.mate.readName=r.readName),r.mate||void 0!==r.mateRecordNumber||(r.mate={sequenceId:n.sequenceId,alignmentStart:n.alignmentStart,uniqueId:n.uniqueId},n.readName&&(r.mate.readName=n.readName)),n.flags|=C.BAM_FPAIRED,(0,d.default)(r)&C.BAM_FUNMAP&&(n.flags|=C.BAM_FMUNMAP),(0,d.default)(n)&C.BAM_FUNMAP&&(r.flags|=C.BAM_FMUNMAP),(0,d.default)(r)&C.BAM_FREVERSE&&(n.flags|=C.BAM_FMREVERSE),(0,d.default)(n)&C.BAM_FREVERSE&&(r.flags|=C.BAM_FMREVERSE),void 0===n.templateLength&&(i?function(t,e,n){var r=function e(n){var r=[n];if(n.mateRecordNumber>=0){var i=t[n.mateRecordNumber];if(!i)throw new b("intra-slice mate record not found, this file seems malformed");r.push.apply(r,(0,m.default)(e(i)))}return r}(n),i=(0,g.default)(r).call(r,(function(t){return t.alignmentStart})),o=(0,g.default)(r).call(r,(function(t){return t.alignmentStart+t.readLength-1})),s=Math.max.apply(Math,(0,m.default)(o))-Math.min.apply(Math,(0,m.default)(i))+1;s>=0&&(0,p.default)(r).call(r,(function(t){if(void 0!==t.templateLength)throw new b("mate pair group has some members that have template lengths already, this file seems malformed");t.templateLength=s}))}(t,0,n):function(t,e){var n=Math.min(t.alignmentStart,e.alignmentStart),r=Math.max(t.alignmentStart+t.readLength-1,e.alignmentStart+e.readLength-1)-n+1;t.templateLength=r,e.templateLength=r}(n,r)),delete n.mateRecordNumber}var T=function(){function t(e,n){(0,u.default)(this,t),this.container=e,this.file=e.file,this.containerPosition=n}var e,n,r,i,d,m,v,x;return(0,f.default)(t,[{key:"getHeader",value:(x=(0,h.default)(l.default.mark((function t(){var e,n,r;return l.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.file.getSectionParsers();case 2:return e=t.sent,t.next=5,this.container.getHeader();case 5:return n=t.sent,t.next=8,this.file.readBlock(n._endPosition+this.containerPosition);case 8:if("MAPPED_SLICE_HEADER"!==(r=t.sent).contentType){t.next=13;break}r.content=k(r.content,e.cramMappedSliceHeader.parser,0,n._endPosition),t.next=18;break;case 13:if("UNMAPPED_SLICE_HEADER"!==r.contentType){t.next=17;break}r.content=k(r.content,e.cramUnmappedSliceHeader.parser,0,n._endPosition),t.next=18;break;case 17:throw new b("error reading slice header block, invalid content type ".concat(r._contentType));case 18:return t.abrupt("return",r);case 19:case"end":return t.stop()}}),t,this)}))),function(){return x.apply(this,arguments)})},{key:"getBlocks",value:(v=(0,h.default)(l.default.mark((function t(){var e,n,r,i;return l.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getHeader();case 2:e=t.sent,n=e._endPosition,r=new Array(e.content.numBlocks),i=0;case 6:if(!(i<r.length)){t.next=14;break}return t.next=9,this.file.readBlock(n);case 9:r[i]=t.sent,n=r[i]._endPosition;case 11:i+=1,t.next=6;break;case 14:return t.abrupt("return",r);case 15:case"end":return t.stop()}}),t,this)}))),function(){return v.apply(this,arguments)})},{key:"getCoreDataBlock",value:(m=(0,h.default)(l.default.mark((function t(){var e;return l.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getBlocks();case 2:return e=t.sent,t.abrupt("return",e[0]);case 4:case"end":return t.stop()}}),t,this)}))),function(){return m.apply(this,arguments)})},{key:"_getBlocksContentIdIndex",value:(d=(0,h.default)(l.default.mark((function t(){var e,n;return l.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getBlocks();case 2:return e=t.sent,n={},(0,p.default)(e).call(e,(function(t){"EXTERNAL_DATA"===t.contentType&&(n[t.contentId]=t)})),t.abrupt("return",n);case 6:case"end":return t.stop()}}),t,this)}))),function(){return d.apply(this,arguments)})},{key:"getBlockByContentId",value:(i=(0,h.default)(l.default.mark((function t(e){var n;return l.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getBlocksContentIdIndex();case 2:return n=t.sent,t.abrupt("return",n[e]);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"getReferenceRegion",value:(r=(0,h.default)(l.default.mark((function t(){var e,n,r,i;return l.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getHeader();case 2:if(!((e=t.sent.content).refSeqId<0)){t.next=5;break}return t.abrupt("return",void 0);case 5:return t.next=7,this.container.getCompressionScheme();case 7:if(n=t.sent,!(e.refBaseBlockId>=0)){t.next=15;break}if(r=this.getBlockByContentId(e.refBaseBlockId)){t.next=12;break}throw new b("embedded reference specified, but reference block does not exist");case 12:if(!(e.span>r.uncompressedSize)){t.next=14;break}throw new b("Embedded reference is too small");case 14:return t.abrupt("return",{seq:r.data.toString("utf8"),start:e.refSeqStart,end:e.refSeqStart+e.refSeqSpan-1,span:e.refSeqSpan});case 15:if(!n.referenceRequired&&!this.file.fetchReferenceSequenceCallback){t.next=24;break}if(this.file.fetchReferenceSequenceCallback){t.next=18;break}throw new Error("reference sequence not embedded, and seqFetch callback not provided, cannot fetch reference sequence");case 18:return t.next=20,this.file.fetchReferenceSequenceCallback(e.refSeqId,e.refSeqStart,e.refSeqStart+e.refSeqSpan-1);case 20:if((i=t.sent).length===e.refSeqSpan){t.next=23;break}throw new y("seqFetch callback returned a reference sequence of the wrong length");case 23:return t.abrupt("return",{seq:i,start:e.refSeqStart,end:e.refSeqStart+e.refSeqSpan-1,span:e.refSeqSpan});case 24:return t.abrupt("return",void 0);case 25:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"getAllRecords",value:function(){return this.getRecords((function(){return!0}))}},{key:"_fetchRecords",value:(n=(0,h.default)(l.default.mark((function t(){var e,n,r,i,o,s,h,u,f,d,p,m,v,y,x,k,_,C,T,L,M,R,I,N=this;return l.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.file.getDefinition();case 2:return e=t.sent,n=e.majorVersion,t.next=6,this.container.getCompressionScheme();case 6:return r=t.sent,t.next=9,this.getHeader();case 9:return i=t.sent,t.next=12,this._getBlocksContentIdIndex();case 12:if(o=t.sent,!(n>1&&this.file.options.checkSequenceMD5&&i.content.refSeqId>=0&&"0000000000000000"!==i.content.md5.join(""))){t.next=23;break}return t.next=16,this.getReferenceRegion();case 16:if(!(s=t.sent)){t.next=23;break}if(m=s.seq,v=s.start,y=s.end,x=S(m),k=(0,g.default)(h=i.content.md5).call(h,(function(t){return(t<16?"0":"")+t.toString(16)})).join(""),x===k){t.next=23;break}throw new b((0,c.default)(u=(0,c.default)(f=(0,c.default)(d=(0,c.default)(p="MD5 checksum reference mismatch for ref ".concat(i.content.refSeqId," pos ")).call(p,v,"..")).call(d,y,". recorded MD5: ")).call(f,k,", calculated MD5: ")).call(u,x));case 23:return t.next=25,this.getCoreDataBlock();case 25:_=t.sent,C={lastAlignmentStart:i.content.refSeqStart||0,coreBlock:{bitPosition:7,bytePosition:0},externalBlocks:{getCursor:function(t){return this[t]||(this[t]={bitPosition:7,bytePosition:0}),this[t]}}},T=function(t){var e=r.getCodecForDataSeries(t);if(!e)throw new b("no codec defined for ".concat(t," data series"));return e.decode(N,_,o,C)},L=new Array(i.content.numRecords),M=0;case 30:if(!(M<L.length)){t.next=48;break}t.prev=31,L[M]=E(this,T,r,i,_,o,C,n,M),L[M].uniqueId=i.contentPosition+i.content.recordCounter+M+1,t.next=45;break;case 36:if(t.prev=36,t.t0=t.catch(31),!(t.t0 instanceof w)){t.next=44;break}return console.warn("read attempted beyond end of buffer, file seems truncated."),L=(0,a.default)(L).call(L,(function(t){return!!t})),t.abrupt("break",48);case 44:throw t.t0;case 45:M+=1,t.next=30;break;case 48:for(R=0;R<L.length;R+=1)(I=L[R].mateRecordNumber)>=0&&A(L,R,L[R],L[I]);return t.abrupt("return",L);case 50:case"end":return t.stop()}}),t,this,[[31,36]])}))),function(){return n.apply(this,arguments)})},{key:"getRecords",value:(e=(0,h.default)(l.default.mark((function t(e){var n,r,i,c,u,f,d,p,m,v,b,w,y,x,k,_,S=this;return l.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.container.filePosition+this.containerPosition,(i=this.file.featureCache.get(r))||(i=this._fetchRecords(),this.file.featureCache.set(r,i)),t.t0=a.default,t.next=6,i;case 6:if(t.t1=n=t.sent,t.t2=n,t.t3=e,!(c=(0,t.t0)(t.t1).call(t.t2,t.t3)).length||!this.file.fetchReferenceSequenceCallback){t.next=24;break}return t.next=13,this.getHeader();case 13:if(!((u=t.sent).content.refSeqId>=0||-2===u.content.refSeqId)){t.next=24;break}return d=u.content.refSeqId>=0?u.content.refSeqId:void 0,t.next=18,this.container.getCompressionScheme();case 18:for(p=t.sent,m={},v=0;v<c.length;v+=1)b=void 0!==d?d:c[v].sequenceId,(w=m[b])||(w={id:b,start:c[v].alignmentStart,end:-1/0},m[b]=w),(y=c[v].alignmentStart+(c[v].lengthOnRef||c[v].readLength)-1)>w.end&&(w.end=y),c[v].alignmentStart<w.start&&(w.start=c[v].alignmentStart);return t.next=23,s.default.all((0,g.default)(f=(0,o.default)(m)).call(f,function(){var t=(0,h.default)(l.default.mark((function t(e){return l.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(-1!==e.id&&e.start<=e.end)){t.next=4;break}return t.next=3,S.file.fetchReferenceSequenceCallback(e.id,e.start,e.end);case 3:e.seq=t.sent;case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 23:for(x=0;x<c.length;x+=1)k=void 0!==d?d:c[x].sequenceId,(_=m[k])&&_.seq&&c[x].addReferenceSequence(_,p);case 24:return t.abrupt("return",c);case 25:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})}]),t}();(0,p.default)(r="getHeader getBlocks _getBlocksContentIdIndex".split(" ")).call(r,(function(t){return _(T,t)})),t.exports=T},function(t,e,n){t.exports=n(336)},function(t,e,n){n(337);var r=n(3);t.exports=r.Object.values},function(t,e,n){var r=n(0),i=n(149).values;r({target:"Object",stat:!0},{values:function(t){return i(t)}})},function(t,e,n){t.exports=n(339)},function(t,e,n){var r=n(340),i=Array.prototype;t.exports=function(t){var e=t.filter;return t===i||t instanceof Array&&e===i.filter?r:e}},function(t,e,n){n(341);var r=n(18);t.exports=r("Array").filter},function(t,e,n){var r=n(0),i=n(45).filter;r({target:"Array",proto:!0,forced:!n(68)("filter")},{filter:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}})},function(t,e,n){t.exports=n(343)},function(t,e,n){var r=n(344),i=RegExp.prototype;t.exports=function(t){return!(t===i||t instanceof RegExp)||"flags"in t?t.flags:r(t)}},function(t,e,n){n(345);var r=n(346);t.exports=function(t){return r.call(t)}},function(t,e){},function(t,e,n){var r=n(2);t.exports=function(){var t=r(this),e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.dotAll&&(e+="s"),t.unicode&&(e+="u"),t.sticky&&(e+="y"),e}},function(t,e,n){t.exports=n(348)},function(t,e,n){var r=n(349),i=Array.prototype;t.exports=function(t){var e=t.map;return t===i||t instanceof Array&&e===i.map?r:e}},function(t,e,n){n(350);var r=n(18);t.exports=r("Array").map},function(t,e,n){var r=n(0),i=n(45).map;r({target:"Array",proto:!0,forced:!n(68)("map")},{map:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}})},function(t,e,n){var r=n(151);t.exports=function(t){if(r(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}},function(t,e,n){t.exports=n(353)},function(t,e,n){n(354);var r=n(3);t.exports=r.Array.isArray},function(t,e,n){n(0)({target:"Array",stat:!0},{isArray:n(53)})},function(t,e,n){t.exports=n(356)},function(t,e,n){t.exports=n(357)},function(t,e,n){n(46),n(358);var r=n(3);t.exports=r.Array.from},function(t,e,n){var r=n(0),i=n(359);r({target:"Array",stat:!0,forced:!n(121)((function(t){Array.from(t)}))},{from:i})},function(t,e,n){var r=n(15),i=n(22),o=n(120),s=n(119),a=n(29),c=n(87),l=n(90);t.exports=function(t){var e,n,h,u,f=i(t),d="function"==typeof this?this:Array,p=arguments.length,g=p>1?arguments[1]:void 0,m=void 0!==g,v=0,b=l(f);if(m&&(g=r(g,p>2?arguments[2]:void 0,2)),null==b||d==Array&&s(b))for(n=new d(e=a(f.length));e>v;v++)c(n,v,m?g(f[v],v):f[v]);else for(u=b.call(f),n=new d;!(h=u.next()).done;v++)c(n,v,m?o(u,g,[h.value,v],!0):h.value);return n.length=v,n}},function(t,e,n){n(41),n(46),t.exports=n(361)},function(t,e,n){var r=n(67),i=n(6),o=n(35),s=i("iterator");t.exports=function(t){var e=Object(t);return void 0!==e[s]||"@@iterator"in e||o.hasOwnProperty(r(e))}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}},function(t,e,n){(function(e){var r=n(1),i=r(n(37)),o=r(n(364)),s=r(n(16)),a=r(n(99)),c=r(n(101)),l=r(n(59)),h=r(n(154)),u=r(n(376)),f=r(n(380)),d=r(n(48)),p=r(n(387)),g=n(146),m=n(9),v=m.CramMalformedError,b=m.CramUnimplementedError,w=n(389),y=n(100);function x(t){var e=(0,p.default)(t).call(t,0);return-1===e?t.toString("utf8"):t.toString("utf8",0,e)}function k(t,n){if(n.readInt32LE||(n=e.from(n)),"Z"===t)return x(n);if("A"===t)return String.fromCharCode(n[0]);if("I"===t){var r=g.fromBytesLE(n);if(r.greaterThan(f.default)||r.lessThan(u.default))throw new b("integer overflow");return r.toNumber()}if("i"===t)return n.readInt32LE(0);if("s"===t)return n.readInt16LE(0);if("S"===t)return n.readUInt16LE(0);if("c"===t)return n.readInt8(0);if("C"===t)return n.readUInt8(0);if("f"===t)return n.readFloatLE(0);if("H"===t){var i=x(n);return(0,h.default)(i.replace(/^0x/,""),16)}if("B"===t)return function(t){var e=String.fromCharCode(t[0]),n=t.readInt32LE(1),r={c:["readInt8",1],C:["readUInt8",1],s:["readInt16LE",2],S:["readUInt16LE",2],i:["readInt32LE",4],I:["readUInt32LE",4],f:["readFloatLE",4]}[e];if(!r)throw new v("invalid tag value array type '".concat(e,"'"));for(var i=(0,d.default)(r,2),o=i[0],s=i[1],a=new Array(n),c=5,l=0;l<n;l+=1)a[l]=t[o](c),c+=s;return a}(n);throw new v("Unrecognized tag type ".concat(t))}function _(t){if(t instanceof e)return x(t);if(t.length&&(0,p.default)(t)){if(!t[t.length-1]){var n=(0,p.default)(t).call(t,0);return String.fromCharCode.apply(String,(0,l.default)((0,c.default)(t).call(t,0,n)))}return String.fromCharCode.apply(String,(0,l.default)(t))}return String(t)}t.exports=function(t,e,n,r,c,l,h,u,f){var p=new w;if(p.flags=e("BF"),p.cramFlags=e("CF"),u>1&&-2===r.content.refSeqId?p.sequenceId=e("RI"):p.sequenceId=r.content.refSeqId,p.readLength=e("RL"),p.alignmentStart=e("AP"),n.APdelta&&(p.alignmentStart+=h.lastAlignmentStart),h.lastAlignmentStart=p.alignmentStart,p.readGroupId=e("RG"),n.readNamesIncluded&&(p.readName=_(e("RN"))),p.isDetached()){var g={};g.flags=e("MF"),n.readNamesIncluded||(g.readName=_(e("RN")),p.readName=g.readName),g.sequenceId=e("NS"),g.alignmentStart=e("NP"),((0,a.default)(g)||g.sequenceId>-1)&&(p.mate=g),p.templateSize=e("TS"),(0,a.default)(g)&y.CRAM_M_UNMAP&&(p.flags|=y.BAM_FMUNMAP),(0,a.default)(g)&y.CRAM_M_REVERSE&&(p.flags|=y.BAM_FMREVERSE)}else p.hasMateDownStream()&&(p.mateRecordNumber=e("NF")+f+1);var m=e("TL");if(m<0)throw new v("invalid TL index");for(var b=n.getTagNames(m),x=b.length,S=0;S<x;S+=1){var C=b[S],E=C.substr(0,2),A=C.substr(2,1),T=n.getCodecForTag(C);if(!T)throw new v("no codec defined for auxiliary tag ".concat(C));var L=T.decode(t,c,l,h);p.tags[E]=k(A,L)}if(p.isSegmentUnmapped())if(p.isUnknownBases())p.readBases=null,p.qualityScores=null;else{for(var M=new Array(p.readLength),R=0;R<M.length;R+=1)M[R]=e("BA");if(p.readBases=String.fromCharCode.apply(String,M),p.isPreservingQualityScores()){for(var I=0;I<M.length;I+=1)M[I]=e("QS");p.qualityScores=M}}else{var N,P=e("FN");P&&(p.readFeatures=function(t,e,n,r,i){var o=0,s=t.alignmentStart-1,a=new Array(e);function c(t){var e=(0,d.default)(t,2),r=e[0],i=e[1],o=n(i);return"character"===r?String.fromCharCode(o):"string"===r?o.toString("utf8"):"numArray"===r?o.toArray():o}for(var l=0;l<e;l+=1){var h=String.fromCharCode(n("FC")),u=n("FP"),f={code:h},p={B:["character","BA"],S:["string",i>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"]}[h];if(!p)throw new v('invalid read feature code "'.concat(h,'"'));f.data=c(p);var g={B:["number","QS"]}[h];g&&(f.data=[f.data,c(g)]),o+=u,f.pos=o,s+=u,f.refPos=s,"D"===h||"N"===h?s+=f.data:"I"===h||"S"===h?s-=f.data.length:"i"===h&&(s-=1),a[l]=f}return a}(p,P,e,0,u));var O,F=p.readLength;if(p.readFeatures&&(0,s.default)(N=p.readFeatures).call(N,(function(t){var e=t.code,n=t.data;"D"===e||"N"===e?F+=n:"I"===e||"S"===e?F-=n.length:"i"===e&&(F-=1)})),(0,o.default)(F)&&(console.warn("".concat(p.readName||(0,i.default)(O="".concat(p.sequenceId,":")).call(O,p.alignmentStart)," record has invalid read features")),F=p.readLength),p.lengthOnRef=F,p.mappingQuality=e("MQ"),p.isPreservingQualityScores()){for(var D=new Array(p.readLength),B=0;B<D.length;B+=1)D[B]=e("QS");p.qualityScores=D}}return p}}).call(this,n(19).Buffer)},function(t,e,n){t.exports=n(365)},function(t,e,n){t.exports=n(366)},function(t,e,n){n(367);var r=n(3);t.exports=r.Number.isNaN},function(t,e,n){n(0)({target:"Number",stat:!0},{isNaN:function(t){return t!=t}})},function(t,e,n){t.exports=n(369)},function(t,e,n){var r=n(370),i=Array.prototype;t.exports=function(t){var e=t.slice;return t===i||t instanceof Array&&e===i.slice?r:e}},function(t,e,n){n(371);var r=n(18);t.exports=r("Array").slice},function(t,e,n){var r=n(0),i=n(14),o=n(53),s=n(84),a=n(29),c=n(28),l=n(87),h=n(68),u=n(6)("species"),f=[].slice,d=Math.max;r({target:"Array",proto:!0,forced:!h("slice")},{slice:function(t,e){var n,r,h,p=c(this),g=a(p.length),m=s(t,g),v=s(void 0===e?g:e,g);if(o(p)&&("function"!=typeof(n=p.constructor)||n!==Array&&!o(n.prototype)?i(n)&&null===(n=n[u])&&(n=void 0):n=void 0,n===Array||void 0===n))return f.call(p,m,v);for(r=new(void 0===n?Array:n)(d(v-m,0)),h=0;m<v;m++,h++)m in p&&l(r,h,p[m]);return r.length=h,r}})},function(t,e,n){t.exports=n(373)},function(t,e,n){n(374);var r=n(3);t.exports=r.Number.parseInt},function(t,e,n){var r=n(0),i=n(155);r({target:"Number",stat:!0,forced:Number.parseInt!=i},{parseInt:i})},function(t,e,n){var r=n(49),i="["+n(156)+"]",o=RegExp("^"+i+i+"*"),s=RegExp(i+i+"*$"),a=function(t){return function(e){var n=String(r(e));return 1&t&&(n=n.replace(o,"")),2&t&&(n=n.replace(s,"")),n}};t.exports={start:a(1),end:a(2),trim:a(3)}},function(t,e,n){t.exports=n(377)},function(t,e,n){t.exports=n(378)},function(t,e,n){n(379),t.exports=-9007199254740991},function(t,e,n){n(0)({target:"Number",stat:!0},{MIN_SAFE_INTEGER:-9007199254740991})},function(t,e,n){t.exports=n(381)},function(t,e,n){t.exports=n(382)},function(t,e,n){n(383),t.exports=9007199254740991},function(t,e,n){n(0)({target:"Number",stat:!0},{MAX_SAFE_INTEGER:9007199254740991})},function(t,e,n){var r=n(385),i=n(153);t.exports=function(t,e){if(i(Object(t))||"[object Arguments]"===Object.prototype.toString.call(t)){var n=[],o=!0,s=!1,a=void 0;try{for(var c,l=r(t);!(o=(c=l.next()).done)&&(n.push(c.value),!e||n.length!==e);o=!0);}catch(t){s=!0,a=t}finally{try{o||null==l.return||l.return()}finally{if(s)throw a}}return n}}},function(t,e,n){t.exports=n(386)},function(t,e,n){n(41),n(46),t.exports=n(142)},function(t,e,n){t.exports=n(388)},function(t,e,n){t.exports=n(143)},function(t,e,n){var r=n(1),i=r(n(98)),o=r(n(16)),s=r(n(99)),a=r(n(7)),c=r(n(10)),l=r(n(59)),h=n(100),u={a:0,A:0,c:1,C:1,g:2,G:2,t:3,T:3,n:4,N:4},f=function(){function t(){(0,a.default)(this,t),this.tags={}}return(0,c.default)(t,[{key:"isPaired",value:function(){return!!((0,s.default)(this)&h.BAM_FPAIRED)}},{key:"isProperlyPaired",value:function(){return!!((0,s.default)(this)&h.BAM_FPROPER_PAIR)}},{key:"isSegmentUnmapped",value:function(){return!!((0,s.default)(this)&h.BAM_FUNMAP)}},{key:"isMateUnmapped",value:function(){return!!((0,s.default)(this)&h.BAM_FMUNMAP)}},{key:"isReverseComplemented",value:function(){return!!((0,s.default)(this)&h.BAM_FREVERSE)}},{key:"isMateReverseComplemented",value:function(){return!!((0,s.default)(this)&h.BAM_FMREVERSE)}},{key:"isRead1",value:function(){return!!((0,s.default)(this)&h.BAM_FREAD1)}},{key:"isRead2",value:function(){return!!((0,s.default)(this)&h.BAM_FREAD2)}},{key:"isSecondary",value:function(){return!!((0,s.default)(this)&h.BAM_FSECONDARY)}},{key:"isFailedQc",value:function(){return!!((0,s.default)(this)&h.BAM_FQCFAIL)}},{key:"isDuplicate",value:function(){return!!((0,s.default)(this)&h.BAM_FDUP)}},{key:"isSupplementary",value:function(){return!!((0,s.default)(this)&h.BAM_FSUPPLEMENTARY)}},{key:"isDetached",value:function(){return!!(this.cramFlags&h.CRAM_FLAG_DETACHED)}},{key:"hasMateDownStream",value:function(){return!!(this.cramFlags&h.CRAM_FLAG_MATE_DOWNSTREAM)}},{key:"isPreservingQualityScores",value:function(){return!!(this.cramFlags&h.CRAM_FLAG_PRESERVE_QUAL_SCORES)}},{key:"isUnknownBases",value:function(){return!!(this.cramFlags&h.CRAM_FLAG_NO_SEQ)}},{key:"getReadBases",value:function(){return!this.readBases&&this._refRegion&&(this.readBases=function(t,e){if((t.lengthOnRef||t.readLength)&&!t.isUnknownBases()){var n=t.alignmentStart-e.start;if(!t.readFeatures)return e.seq.substr(n,t.lengthOnRef).toUpperCase();for(var r="",i=n,o=0;r.length<t.readLength;)if(o<t.readFeatures.length){var s=t.readFeatures[o];if("Q"===s.code||"q"===s.code)o+=1;else if(s.pos===r.length+1)if(o+=1,"b"===s.code){var a=s.data.split(","),c=String.fromCharCode.apply(String,(0,l.default)(a));r+=c,i+=c.length}else"B"===s.code?(r+=s.data[0],i+=1):"X"===s.code?(r+=s.sub,i+=1):"I"===s.code?r+=s.data:"D"===s.code?i+=s.data:"i"===s.code?r+=s.data:"N"===s.code?i+=s.data:"S"===s.code?r+=s.data:"P"===s.code||s.code;else if(o<t.readFeatures.length){var h=e.seq.substr(i,t.readFeatures[o].pos-r.length-1);r+=h,i+=h.length}}else{var u=e.seq.substr(i,t.readLength-r.length);r+=u,i+=u.length}return r.toUpperCase()}}(this,this._refRegion)),this.readBases}},{key:"getPairOrientation",value:function(){if(!this.isSegmentUnmapped()&&this.isPaired()&&!this.isMateUnmapped()&&this.mate&&this.sequenceId===this.mate.sequenceId){var t=this.isReverseComplemented()?"R":"F",e=this.isMateReverseComplemented()?"R":"F",n=" ",r=" ";this.isRead1()?(n="1",r="2"):this.isRead2()&&(n="2",r="1");var i=[],o=this.templateLength||this.templateSize;return this.alignmentStart>this.mate.alignmentStart&&o>0&&(o=-o),o>0?(i[0]=t,i[1]=n,i[2]=e,i[3]=r):(i[2]=t,i[3]=n,i[0]=e,i[1]=r),i.join("")}return null}},{key:"addReferenceSequence",value:function(t,e){var n;this.readFeatures&&(0,o.default)(n=this.readFeatures).call(n,(function(n){"X"===n.code&&function(t,e,n,r){if(e){var i=r.refPos-e.start,o=e.seq.charAt(i);o&&(r.ref=o);var s=u[o];void 0===s&&(s=4);var a=n.substitutionMatrix[s][r.data];a&&(r.sub=a)}}(0,t,e,n)})),!this.readBases&&t.start<=this.alignmentStart&&t.end>=this.alignmentStart+(this.lengthOnRef||this.readLength)-1&&(this._refRegion=t)}},{key:"toJSON",value:function(){var t,e=this,n={};return(0,o.default)(t=(0,i.default)(this)).call(t,(function(t){"_"!==t.charAt(0)&&(n[t]=e[t])})),n.readBases=this.getReadBases(),n}}]),t}();t.exports=f},function(t,e,n){var r=n(1),i=r(n(98)),o=r(n(16)),s=r(n(75)),a=r(n(7)),c=r(n(10)),l=n(9).CramMalformedError,h=n(391).instantiateCodec,u={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",TM:"ignore",TV:"ignore"},f=function(){function t(e){(0,a.default)(this,t),(0,s.default)(this,e),this.readNamesIncluded=e.preservation.RN,this.APdelta=e.preservation.AP,this.referenceRequired=!!e.preservation.RR,this.tagIdsDictionary=e.preservation.TD,this.substitutionMatrix=function(t){for(var e=new Array(5),n=0;n<5;n+=1)e[n]=new Array(4);return e[0][t[0]>>6&3]="C",e[0][t[0]>>4&3]="G",e[0][t[0]>>2&3]="T",e[0][t[0]>>0&3]="N",e[1][t[1]>>6&3]="A",e[1][t[1]>>4&3]="G",e[1][t[1]>>2&3]="T",e[1][t[1]>>0&3]="N",e[2][t[2]>>6&3]="A",e[2][t[2]>>4&3]="C",e[2][t[2]>>2&3]="T",e[2][t[2]>>0&3]="N",e[3][t[3]>>6&3]="A",e[3][t[3]>>4&3]="C",e[3][t[3]>>2&3]="G",e[3][t[3]>>0&3]="N",e[4][t[4]>>6&3]="A",e[4][t[4]>>4&3]="C",e[4][t[4]>>2&3]="G",e[4][t[4]>>0&3]="T",e}(e.preservation.SM),this.dataSeriesCodecCache={},this.tagCodecCache={}}return(0,c.default)(t,[{key:"getCodecForTag",value:function(t){if(!this.tagCodecCache[t]){var e=this.tagEncoding[t];e&&(this.tagCodecCache[t]=h(e,"byteArray"))}return this.tagCodecCache[t]}},{key:"getTagNames",value:function(t){return this.tagIdsDictionary[t]}},{key:"getCodecForDataSeries",value:function(t){if(!this.dataSeriesCodecCache[t]){var e=this.dataSeriesEncoding[t];if(e){var n=u[t];if(!n)throw new l("data series name ".concat(t," not defined in file compression header"));this.dataSeriesCodecCache[t]=h(e,n)}}return this.dataSeriesCodecCache[t]}},{key:"toJSON",value:function(){var t,e=this,n={};return(0,o.default)(t=(0,i.default)(this)).call(t,(function(t){/Cache$/.test(t)||(n[t]=e[t])})),n}}]),t}();t.exports=f},function(t,e,n){var r=n(9).CramUnimplementedError,i=n(392),o=n(413),s=n(414),a=n(415),c=n(416),l=n(417),h={1:o,3:i,4:a,5:s,6:c,7:n(418),9:l};function u(t){return h[t]}t.exports={getCodecClassWithId:u,instantiateCodec:function t(e,n){var i=u("ignore"===n?0:e.codecId);if(!i)throw new r("no codec implemented for codec ID ".concat(e.codecId));return new i(e.parameters,n,t)}}},function(t,e,n){var r=n(1),i=r(n(97)),o=r(n(59)),s=r(n(77)),a=r(n(148)),c=r(n(159)),l=r(n(48)),h=r(n(102)),u=r(n(16)),f=r(n(103)),d=r(n(403)),p=r(n(7)),g=r(n(10)),m=r(n(32)),v=r(n(27)),b=r(n(33)),w=n(9).CramMalformedError,y=function(t){function e(){var t,n,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;if((0,p.default)(this,e),n=(0,m.default)(this,(0,v.default)(e).call(this,r,i)),!(0,d.default)(t=["byte","int"]).call(t,n.dataType))throw new TypeError("".concat(n.dataType," decoding not yet implemented by HUFFMAN_INT codec"));return n.buildCodeBook(),n.buildCodes(),n.buildCaches(),0===n.sortedCodes[0].bitLength&&(n._decode=n._decodeZeroLengthCode),n}return(0,b.default)(e,t),(0,g.default)(e,[{key:"buildCodeBook",value:function(){for(var t=this,e=new Array(this.parameters.numCodes),n=0;n<this.parameters.numCodes;n+=1)e[n]={symbol:this.parameters.symbols[n],bitLength:this.parameters.bitLengths[n]};e=(0,f.default)(e).call(e,(function(t,e){return t.bitLength-e.bitLength||t.symbol-e.symbol})),this.codeBook={},(0,u.default)(e).call(e,(function(e){t.codeBook[e.bitLength]||(t.codeBook[e.bitLength]=[]),t.codeBook[e.bitLength].push(e.symbol)}))}},{key:"buildCodes",value:function(){var t,e=this;this.codes={};var n=0,r=-1;(0,u.default)(t=(0,h.default)(this.codeBook)).call(t,(function(t){var i=(0,l.default)(t,2),o=i[0],s=i[1];o=(0,c.default)(o,10),(0,u.default)(s).call(s,(function(t){var i={bitLength:o,value:t};r+=1;var s,a,c=o-n;if(r<<=c,i.bitCode=r,n+=c,16843009*((a=(858993459&(a=(s=r)-(s>>1)&1431655765))+(a>>2&858993459))+(a>>4)&252645135)>>24>o)throw new w("Symbol out of range");e.codes[t]=i}))}))}},{key:"buildCaches",value:function(){var t,e,n,r,c,l;this.sortedCodes=(0,f.default)(t=(0,a.default)(this.codes)).call(t,(function(t,e){return t.bitLength-e.bitLength||t.bitCode-e.bitCode})),this.sortedByValue=(0,f.default)(e=(0,a.default)(this.codes)).call(e,(function(t,e){return t.value-e.value})),this.sortedValuesByBitCode=(0,s.default)(n=this.sortedCodes).call(n,(function(t){return t.value})),this.sortedBitCodes=(0,s.default)(r=this.sortedCodes).call(r,(function(t){return t.bitCode})),this.sortedBitLengthsByBitCode=(0,s.default)(c=this.sortedCodes).call(c,(function(t){return t.bitLength}));var h=Math.max.apply(Math,(0,o.default)(this.sortedBitCodes));this.bitCodeToValue=(0,i.default)(l=new Array(h+1)).call(l,-1);for(var u=0;u<this.sortedBitCodes.length;u+=1)this.bitCodeToValue[this.sortedCodes[u].bitCode]=u}},{key:"decode",value:function(t,e,n,r){return this._decode(t,e,r.coreBlock)}},{key:"_decodeZeroLengthCode",value:function(){return this.sortedCodes[0].value}},{key:"_decode",value:function(t,e,n){for(var r=e.content,i=0,o=0,s=0;s<this.sortedCodes.length;s+=1){var a=this.sortedCodes[s].bitLength;o<<=a-i,o|=this._getBits(r,n,a-i),i=a;var c=this.bitCodeToValue[o];if(c>-1&&this.sortedBitLengthsByBitCode[c]===a)return this.sortedValuesByBitCode[c];for(var l=s;this.sortedCodes[l+1].bitLength===a&&l<this.sortedCodes.length;l+=1)s+=1}throw new w("Huffman symbol not found.")}}]),e}(n(40));t.exports=y},function(t,e,n){t.exports=n(394)},function(t,e,n){n(395);var r=n(3);t.exports=r.parseInt},function(t,e,n){var r=n(0),i=n(155);r({global:!0,forced:parseInt!=i},{parseInt:i})},function(t,e,n){t.exports=n(397)},function(t,e,n){n(398);var r=n(3);t.exports=r.Object.entries},function(t,e,n){var r=n(0),i=n(149).entries;r({target:"Object",stat:!0},{entries:function(t){return i(t)}})},function(t,e,n){t.exports=n(400)},function(t,e,n){var r=n(401),i=Array.prototype;t.exports=function(t){var e=t.sort;return t===i||t instanceof Array&&e===i.sort?r:e}},function(t,e,n){n(402);var r=n(18);t.exports=r("Array").sort},function(t,e,n){var r=n(0),i=n(5),o=n(22),s=n(12),a=n(54),c=[].sort,l=[1,2,3],h=s((function(){l.sort(void 0)})),u=s((function(){l.sort(null)})),f=a("sort");r({target:"Array",proto:!0,forced:h||!u||f},{sort:function(t){return void 0===t?c.call(o(this)):c.call(o(this),i(t))}})},function(t,e,n){t.exports=n(404)},function(t,e,n){t.exports=n(405)},function(t,e,n){var r=n(406),i=n(408),o=Array.prototype,s=String.prototype;t.exports=function(t){var e=t.includes;return t===o||t instanceof Array&&e===o.includes?r:"string"==typeof t||t===s||t instanceof String&&e===s.includes?i:e}},function(t,e,n){n(407);var r=n(18);t.exports=r("Array").includes},function(t,e,n){var r=n(0),i=n(82).includes,o=n(78);r({target:"Array",proto:!0},{includes:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}}),o("includes")},function(t,e,n){n(409);var r=n(18);t.exports=r("String").includes},function(t,e,n){var r=n(0),i=n(410),o=n(49);r({target:"String",proto:!0,forced:!n(412)("includes")},{includes:function(t){return!!~String(o(this)).indexOf(i(t),arguments.length>1?arguments[1]:void 0)}})},function(t,e,n){var r=n(411);t.exports=function(t){if(r(t))throw TypeError("The method doesn't accept regular expressions");return t}},function(t,e,n){var r=n(14),i=n(34),o=n(6)("match");t.exports=function(t){var e;return r(t)&&(void 0!==(e=t[o])?!!e:"RegExp"==i(t))}},function(t,e,n){var r=n(6)("match");t.exports=function(t){var e=/./;try{"/./"[t](e)}catch(n){try{return e[r]=!1,"/./"[t](e)}catch(t){}}return!1}},function(t,e,n){var r=n(1),i=r(n(48)),o=r(n(7)),s=r(n(10)),a=r(n(32)),c=r(n(27)),l=r(n(33)),h=n(9),u=h.CramUnimplementedError,f=h.CramMalformedError,d=h.CramBufferOverrunError,p=n(40),g=n(58).parseItf8,m=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if((0,o.default)(this,e),"int"===(t=(0,a.default)(this,(0,c.default)(e).call(this,n,r))).dataType)t._decodeData=t._decodeInt;else{if("byte"!==t.dataType)throw new u("".concat(t.dataType," decoding not yet implemented by EXTERNAL codec"));t._decodeData=t._decodeByte}return t}return(0,l.default)(e,t),(0,s.default)(e,[{key:"decode",value:function(t,e,n,r){var i=this.parameters.blockContentId,o=n[i];if(!o)throw new f("no block found with content ID ".concat(i));var s=r.externalBlocks.getCursor(i);return this._decodeData(o,s)}},{key:"_decodeInt",value:function(t,e){var n=g(t.content,e.bytePosition),r=(0,i.default)(n,2),o=r[0],s=r[1];return e.bytePosition+=s,o}},{key:"_decodeByte",value:function(t,e){if(e.bytePosition>=t.content.length)throw new d("attempted to read beyond end of block. this file seems truncated.");var n=t.content[e.bytePosition];return e.bytePosition+=1,n}}]),e}(p);t.exports=m},function(t,e,n){var r=n(1),i=r(n(101)),o=r(n(7)),s=r(n(10)),a=r(n(32)),c=r(n(27)),l=r(n(33)),h=n(9),u=h.CramBufferOverrunError,f=h.CramMalformedError,d=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if((0,o.default)(this,e),t=(0,a.default)(this,(0,c.default)(e).call(this,n,r)),"byteArray"!==r)throw new TypeError("byteArrayStop codec does not support data type ".concat(r));return t._decode=t._decodeByteArray,t}return(0,l.default)(e,t),(0,s.default)(e,[{key:"decode",value:function(t,e,n,r){var i=this.parameters.blockContentId,o=n[i];if(!o)throw new f("no block found with content ID ".concat(i));var s=r.externalBlocks.getCursor(i);return this._decode(o,s)}},{key:"_decodeByteArray",value:function(t,e){for(var n=t.content,r=this.parameters.stopByte,o=e.bytePosition,s=e.bytePosition;n[s]!==r&&s<n.length;){if(s===n.length)throw new u("byteArrayStop reading beyond length of data buffer?");s+=1}return e.bytePosition=s+1,(0,i.default)(n).call(n,o,s)}}]),e}(n(40));t.exports=d},function(t,e,n){var r,i=n(1),o=i(n(16)),s=i(n(7)),a=i(n(10)),c=i(n(32)),l=i(n(27)),h=i(n(33)),u=n(58).tinyMemoize,f=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2?arguments[2]:void 0;if((0,s.default)(this,e),(t=(0,c.default)(this,(0,l.default)(e).call(this,n,r))).instantiateCodec=i,"byteArray"!==r)throw new TypeError("byteArrayLength does not support data type ".concat(r));return t}return(0,h.default)(e,t),(0,a.default)(e,[{key:"decode",value:function(t,e,n,r){for(var i=this._getLengthCodec().decode(t,e,n,r),o=this._getDataCodec(),s=new Array(i),a=0;a<i;a+=1)s[a]=o.decode(t,e,n,r);return s}},{key:"_getLengthCodec",value:function(){var t=this.parameters.lengthsEncoding;return this.instantiateCodec(t,"int")}},{key:"_getDataCodec",value:function(){var t=this.parameters.valuesEncoding;return this.instantiateCodec(t,"byte")}}]),e}(n(40));(0,o.default)(r="_getLengthCodec _getDataCodec".split(" ")).call(r,(function(t){return u(f,t)})),t.exports=f},function(t,e,n){var r=n(1),i=r(n(7)),o=r(n(10)),s=r(n(32)),a=r(n(27)),c=r(n(33)),l=n(9).CramUnimplementedError,h=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if((0,i.default)(this,e),"int"!==(t=(0,s.default)(this,(0,a.default)(e).call(this,n,r))).dataType)throw new l("".concat(t.dataType," decoding not yet implemented by BETA codec"));return t}return(0,c.default)(e,t),(0,o.default)(e,[{key:"decode",value:function(t,e,n,r){return this._getBits(e.content,r.coreBlock,this.parameters.length)-this.parameters.offset}}]),e}(n(40));t.exports=h},function(t,e,n){var r=n(1),i=r(n(7)),o=r(n(10)),s=r(n(32)),a=r(n(27)),c=r(n(33)),l=n(9).CramUnimplementedError,h=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if((0,i.default)(this,e),"int"!==(t=(0,s.default)(this,(0,a.default)(e).call(this,n,r))).dataType)throw new l("".concat(t.dataType," decoding not yet implemented by GAMMA codec"));return t}return(0,c.default)(e,t),(0,o.default)(e,[{key:"decode",value:function(t,e,n,r){for(var i=1;0===this._getBits(e.content,r.coreBlock,1);)i+=1;return(this._getBits(e.content,r.coreBlock,i-1)|1<<i-1)-this.parameters.offset}}]),e}(n(40));t.exports=h},function(t,e,n){var r=n(1),i=r(n(7)),o=r(n(10)),s=r(n(32)),a=r(n(27)),c=r(n(33)),l=n(9).CramUnimplementedError,h=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if((0,i.default)(this,e),"int"!==(t=(0,s.default)(this,(0,a.default)(e).call(this,n,r))).dataType)throw new l("".concat(t.dataType," decoding not yet implemented by SUBEXP codec"));return t}return(0,c.default)(e,t),(0,o.default)(e,[{key:"decode",value:function(t,e,n,r){for(var i,o,s=0;this._getBits(e.content,r.coreBlock,1);)s+=1;return 0===s?(i=this.parameters.K,o=this._getBits(e.content,r.coreBlock,i)):o=1<<(i=s+this.parameters.K-1)|this._getBits(e.content,r.coreBlock,i),o-this.parameters.offset}}]),e}(n(40));t.exports=h},function(t,e,n){var r=n(420),i=n(422);function o(){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}e.parse=w,e.resolve=function(t,e){return w(t,!1,!0).resolve(e)},e.resolveObject=function(t,e){return t?w(t,!1,!0).resolveObject(e):e},e.format=function(t){return i.isString(t)&&(t=w(t)),t instanceof o?t.format():o.prototype.format.call(t)},e.Url=o;var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,c=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,l=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),h=["'"].concat(l),u=["%","/","?",";","#"].concat(h),f=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:!0,"javascript:":!0},m={javascript:!0,"javascript:":!0},v={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},b=n(423);function w(t,e,n){if(t&&i.isObject(t)&&t instanceof o)return t;var r=new o;return r.parse(t,e,n),r}o.prototype.parse=function(t,e,n){if(!i.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var o=t.indexOf("?"),a=-1!==o&&o<t.indexOf("#")?"?":"#",l=t.split(a);l[0]=l[0].replace(/\\/g,"/");var w=t=l.join(a);if(w=w.trim(),!n&&1===t.split("#").length){var y=c.exec(w);if(y)return this.path=w,this.href=w,this.pathname=y[1],y[2]?(this.search=y[2],this.query=e?b.parse(this.search.substr(1)):this.search.substr(1)):e&&(this.search="",this.query={}),this}var x=s.exec(w);if(x){var k=(x=x[0]).toLowerCase();this.protocol=k,w=w.substr(x.length)}if(n||x||w.match(/^\/\/[^@\/]+@[^@\/]+/)){var _="//"===w.substr(0,2);!_||x&&m[x]||(w=w.substr(2),this.slashes=!0)}if(!m[x]&&(_||x&&!v[x])){for(var S,C,E=-1,A=0;A<f.length;A++)-1!==(T=w.indexOf(f[A]))&&(-1===E||T<E)&&(E=T);for(-1!==(C=-1===E?w.lastIndexOf("@"):w.lastIndexOf("@",E))&&(S=w.slice(0,C),w=w.slice(C+1),this.auth=decodeURIComponent(S)),E=-1,A=0;A<u.length;A++){var T;-1!==(T=w.indexOf(u[A]))&&(-1===E||T<E)&&(E=T)}-1===E&&(E=w.length),this.host=w.slice(0,E),w=w.slice(E),this.parseHost(),this.hostname=this.hostname||"";var L="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!L)for(var M=this.hostname.split(/\./),R=(A=0,M.length);A<R;A++){var I=M[A];if(I&&!I.match(d)){for(var N="",P=0,O=I.length;P<O;P++)I.charCodeAt(P)>127?N+="x":N+=I[P];if(!N.match(d)){var F=M.slice(0,A),D=M.slice(A+1),B=I.match(p);B&&(F.push(B[1]),D.unshift(B[2])),D.length&&(w="/"+D.join(".")+w),this.hostname=F.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),L||(this.hostname=r.toASCII(this.hostname));var z=this.port?":"+this.port:"",H=this.hostname||"";this.host=H+z,this.href+=this.host,L&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==w[0]&&(w="/"+w))}if(!g[k])for(A=0,R=h.length;A<R;A++){var V=h[A];if(-1!==w.indexOf(V)){var j=encodeURIComponent(V);j===V&&(j=escape(V)),w=w.split(V).join(j)}}var U=w.indexOf("#");-1!==U&&(this.hash=w.substr(U),w=w.slice(0,U));var q=w.indexOf("?");if(-1!==q?(this.search=w.substr(q),this.query=w.substr(q+1),e&&(this.query=b.parse(this.query)),w=w.slice(0,q)):e&&(this.search="",this.query={}),w&&(this.pathname=w),v[k]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){z=this.pathname||"";var W=this.search||"";this.path=z+W}return this.href=this.format(),this},o.prototype.format=function(){var t=this.auth||"";t&&(t=(t=encodeURIComponent(t)).replace(/%3A/i,":"),t+="@");var e=this.protocol||"",n=this.pathname||"",r=this.hash||"",o=!1,s="";this.host?o=t+this.host:this.hostname&&(o=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(o+=":"+this.port)),this.query&&i.isObject(this.query)&&Object.keys(this.query).length&&(s=b.stringify(this.query));var a=this.search||s&&"?"+s||"";return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||v[e])&&!1!==o?(o="//"+(o||""),n&&"/"!==n.charAt(0)&&(n="/"+n)):o||(o=""),r&&"#"!==r.charAt(0)&&(r="#"+r),a&&"?"!==a.charAt(0)&&(a="?"+a),e+o+(n=n.replace(/[?#]/g,(function(t){return encodeURIComponent(t)})))+(a=a.replace("#","%23"))+r},o.prototype.resolve=function(t){return this.resolveObject(w(t,!1,!0)).format()},o.prototype.resolveObject=function(t){if(i.isString(t)){var e=new o;e.parse(t,!1,!0),t=e}for(var n=new o,r=Object.keys(this),s=0;s<r.length;s++){var a=r[s];n[a]=this[a]}if(n.hash=t.hash,""===t.href)return n.href=n.format(),n;if(t.slashes&&!t.protocol){for(var c=Object.keys(t),l=0;l<c.length;l++){var h=c[l];"protocol"!==h&&(n[h]=t[h])}return v[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=n.format(),n}if(t.protocol&&t.protocol!==n.protocol){if(!v[t.protocol]){for(var u=Object.keys(t),f=0;f<u.length;f++){var d=u[f];n[d]=t[d]}return n.href=n.format(),n}if(n.protocol=t.protocol,t.host||m[t.protocol])n.pathname=t.pathname;else{for(var p=(t.pathname||"").split("/");p.length&&!(t.host=p.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==p[0]&&p.unshift(""),p.length<2&&p.unshift(""),n.pathname=p.join("/")}if(n.search=t.search,n.query=t.query,n.host=t.host||"",n.auth=t.auth,n.hostname=t.hostname||t.host,n.port=t.port,n.pathname||n.search){var g=n.pathname||"",b=n.search||"";n.path=g+b}return n.slashes=n.slashes||t.slashes,n.href=n.format(),n}var w=n.pathname&&"/"===n.pathname.charAt(0),y=t.host||t.pathname&&"/"===t.pathname.charAt(0),x=y||w||n.host&&t.pathname,k=x,_=n.pathname&&n.pathname.split("/")||[],S=(p=t.pathname&&t.pathname.split("/")||[],n.protocol&&!v[n.protocol]);if(S&&(n.hostname="",n.port=null,n.host&&(""===_[0]?_[0]=n.host:_.unshift(n.host)),n.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===p[0]?p[0]=t.host:p.unshift(t.host)),t.host=null),x=x&&(""===p[0]||""===_[0])),y)n.host=t.host||""===t.host?t.host:n.host,n.hostname=t.hostname||""===t.hostname?t.hostname:n.hostname,n.search=t.search,n.query=t.query,_=p;else if(p.length)_||(_=[]),_.pop(),_=_.concat(p),n.search=t.search,n.query=t.query;else if(!i.isNullOrUndefined(t.search))return S&&(n.hostname=n.host=_.shift(),(L=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=L.shift(),n.host=n.hostname=L.shift())),n.search=t.search,n.query=t.query,i.isNull(n.pathname)&&i.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n;if(!_.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var C=_.slice(-1)[0],E=(n.host||t.host||_.length>1)&&("."===C||".."===C)||""===C,A=0,T=_.length;T>=0;T--)"."===(C=_[T])?_.splice(T,1):".."===C?(_.splice(T,1),A++):A&&(_.splice(T,1),A--);if(!x&&!k)for(;A--;A)_.unshift("..");!x||""===_[0]||_[0]&&"/"===_[0].charAt(0)||_.unshift(""),E&&"/"!==_.join("/").substr(-1)&&_.push("");var L,M=""===_[0]||_[0]&&"/"===_[0].charAt(0);return S&&(n.hostname=n.host=M?"":_.length?_.shift():"",(L=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=L.shift(),n.host=n.hostname=L.shift())),(x=x||n.host&&_.length)&&!M&&_.unshift(""),_.length?n.pathname=_.join("/"):(n.pathname=null,n.path=null),i.isNull(n.pathname)&&i.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=t.auth||n.auth,n.slashes=n.slashes||t.slashes,n.href=n.format(),n},o.prototype.parseHost=function(){var t=this.host,e=a.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},function(t,e,n){(function(t,r){var i;/*! https://mths.be/punycode v1.4.1 by @mathias */!function(o){e&&e.nodeType,t&&t.nodeType;var s="object"==typeof r&&r;s.global!==s&&s.window!==s&&s.self;var a,c=2147483647,l=36,h=/^xn--/,u=/[^\x20-\x7E]/,f=/[\x2E\u3002\uFF0E\uFF61]/g,d={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},p=Math.floor,g=String.fromCharCode;function m(t){throw new RangeError(d[t])}function v(t,e){for(var n=t.length,r=[];n--;)r[n]=e(t[n]);return r}function b(t,e){var n=t.split("@"),r="";return n.length>1&&(r=n[0]+"@",t=n[1]),r+v((t=t.replace(f,".")).split("."),e).join(".")}function w(t){for(var e,n,r=[],i=0,o=t.length;i<o;)(e=t.charCodeAt(i++))>=55296&&e<=56319&&i<o?56320==(64512&(n=t.charCodeAt(i++)))?r.push(((1023&e)<<10)+(1023&n)+65536):(r.push(e),i--):r.push(e);return r}function y(t){return v(t,(function(t){var e="";return t>65535&&(e+=g((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+g(t)})).join("")}function x(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function k(t,e,n){var r=0;for(t=n?p(t/700):t>>1,t+=p(t/e);t>455;r+=l)t=p(t/35);return p(r+36*t/(t+38))}function _(t){var e,n,r,i,o,s,a,h,u,f,d,g=[],v=t.length,b=0,w=128,x=72;for((n=t.lastIndexOf("-"))<0&&(n=0),r=0;r<n;++r)t.charCodeAt(r)>=128&&m("not-basic"),g.push(t.charCodeAt(r));for(i=n>0?n+1:0;i<v;){for(o=b,s=1,a=l;i>=v&&m("invalid-input"),((h=(d=t.charCodeAt(i++))-48<10?d-22:d-65<26?d-65:d-97<26?d-97:l)>=l||h>p((c-b)/s))&&m("overflow"),b+=h*s,!(h<(u=a<=x?1:a>=x+26?26:a-x));a+=l)s>p(c/(f=l-u))&&m("overflow"),s*=f;x=k(b-o,e=g.length+1,0==o),p(b/e)>c-w&&m("overflow"),w+=p(b/e),b%=e,g.splice(b++,0,w)}return y(g)}function S(t){var e,n,r,i,o,s,a,h,u,f,d,v,b,y,_,S=[];for(v=(t=w(t)).length,e=128,n=0,o=72,s=0;s<v;++s)(d=t[s])<128&&S.push(g(d));for(r=i=S.length,i&&S.push("-");r<v;){for(a=c,s=0;s<v;++s)(d=t[s])>=e&&d<a&&(a=d);for(a-e>p((c-n)/(b=r+1))&&m("overflow"),n+=(a-e)*b,e=a,s=0;s<v;++s)if((d=t[s])<e&&++n>c&&m("overflow"),d==e){for(h=n,u=l;!(h<(f=u<=o?1:u>=o+26?26:u-o));u+=l)_=h-f,y=l-f,S.push(g(x(f+_%y,0))),h=p(_/y);S.push(g(x(h,0))),o=k(n,b,r==i),n=0,++r}++n,++e}return S.join("")}a={version:"1.4.1",ucs2:{decode:w,encode:y},decode:_,encode:S,toASCII:function(t){return b(t,(function(t){return u.test(t)?"xn--"+S(t):t}))},toUnicode:function(t){return b(t,(function(t){return h.test(t)?_(t.slice(4).toLowerCase()):t}))}},void 0===(i=function(){return a}.call(e,n,e,t))||(t.exports=i)}()}).call(this,n(421)(t),n(23))},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,n){t.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},function(t,e,n){e.decode=e.parse=n(424),e.encode=e.stringify=n(425)},function(t,e,n){function r(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,e,n,o){e=e||"&",n=n||"=";var s={};if("string"!=typeof t||0===t.length)return s;var a=/\+/g;t=t.split(e);var c=1e3;o&&"number"==typeof o.maxKeys&&(c=o.maxKeys);var l=t.length;c>0&&l>c&&(l=c);for(var h=0;h<l;++h){var u,f,d,p,g=t[h].replace(a,"%20"),m=g.indexOf(n);m>=0?(u=g.substr(0,m),f=g.substr(m+1)):(u=g,f=""),d=decodeURIComponent(u),p=decodeURIComponent(f),r(s,d)?i(s[d])?s[d].push(p):s[d]=[s[d],p]:s[d]=p}return s};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},function(t,e,n){var r=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};t.exports=function(t,e,n,a){return e=e||"&",n=n||"=",null===t&&(t=void 0),"object"==typeof t?o(s(t),(function(s){var a=encodeURIComponent(r(s))+n;return i(t[s])?o(t[s],(function(t){return a+encodeURIComponent(r(t))})).join(e):a+encodeURIComponent(r(t[s]))})).join(e):a?encodeURIComponent(r(a))+n+encodeURIComponent(r(t)):""};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function o(t,e){if(t.map)return t.map(e);for(var n=[],r=0;r<t.length;r++)n.push(e(t[r],r));return n}var s=Object.keys||function(t){var e=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.push(n);return e}},function(t,e,n){(function(e){var r=n(1),i=r(n(30)),o=r(n(159)),s=r(n(37)),a=r(n(31)),c=r(n(7)),l=r(n(10)),h=n(427),u=n(428),f=function(){function t(e){var n=this;(0,c.default)(this,t),this.position=0,this.url=e,this.cache=new u({fetch:function(t,e){return n._fetch(t,e)}})}var n,r,f;return(0,l.default)(t,[{key:"_fetch",value:(f=(0,a.default)(i.default.mark((function t(n,r){var a,c,l,u,f,d;return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return c={},r<1/0?c.range=(0,s.default)(l="bytes=".concat(n,"-")).call(l,n+r):r===1/0&&0!==n&&(c.range="bytes=".concat(n,"-")),t.next=4,h(this.url,{method:"GET",headers:c,redirect:"follow",mode:"cors"});case 4:if((200!==(u=t.sent).status||0!==n)&&206!==u.status){t.next=14;break}return t.t0=e,t.next=9,u.arrayBuffer();case 9:return t.t1=t.sent,f=t.t0.from.call(t.t0,t.t1),(d=/\/(\d+)$/.exec(u.headers.get("content-range")))[1]&&(this._stat={size:(0,o.default)(d[1],10)}),t.abrupt("return",f);case 14:throw new Error((0,s.default)(a="HTTP ".concat(u.status," fetching ")).call(a,this.url));case 15:case"end":return t.stop()}}),t,this)}))),function(t,e){return f.apply(this,arguments)})},{key:"read",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1/0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=r;return null===i&&(i=this.position,this.position+=n),this.cache.get(t,e,n,r)}},{key:"readFile",value:(r=(0,a.default)(i.default.mark((function t(){var n;return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,h(this.url,{method:"GET",redirect:"follow",mode:"cors"});case 2:return n=t.sent,t.t0=e,t.next=6,n.arrayBuffer();case 6:return t.t1=t.sent,t.abrupt("return",t.t0.from.call(t.t0,t.t1));case 8:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"stat",value:(n=(0,a.default)(i.default.mark((function t(){var n;return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._stat){t.next=6;break}return n=e.allocUnsafe(10),t.next=4,this.read(n,0,10,0);case 4:if(this._stat){t.next=6;break}throw new Error("unable to determine size of file at ".concat(this.url));case 6:return t.abrupt("return",this._stat);case 7:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})}]),t}();t.exports=f}).call(this,n(19).Buffer)},function(t,e){var n=function(t){function e(){this.fetch=!1,this.DOMException=t.DOMException}return e.prototype=t,new e}("undefined"!=typeof self?self:this);!function(t){!function(e){var n="URLSearchParams"in t,r="Symbol"in t&&"iterator"in Symbol,i="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),o="FormData"in t,s="ArrayBuffer"in t;if(s)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],c=ArrayBuffer.isView||function(t){return t&&a.indexOf(Object.prototype.toString.call(t))>-1};function l(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function h(t){return"string"!=typeof t&&(t=String(t)),t}function u(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return r&&(e[Symbol.iterator]=function(){return e}),e}function f(t){this.map={},t instanceof f?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function d(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function p(t){return new Promise((function(e,n){t.onload=function(){e(t.result)},t.onerror=function(){n(t.error)}}))}function g(t){var e=new FileReader,n=p(e);return e.readAsArrayBuffer(t),n}function m(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function v(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:i&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:o&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:n&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s&&i&&(e=t)&&DataView.prototype.isPrototypeOf(e)?(this._bodyArrayBuffer=m(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(t)||c(t))?this._bodyArrayBuffer=m(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):n&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var t=d(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?d(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(g)}),this.text=function(){var t,e,n,r=d(this);if(r)return r;if(this._bodyBlob)return t=this._bodyBlob,n=p(e=new FileReader),e.readAsText(t),n;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),n=new Array(e.length),r=0;r<e.length;r++)n[r]=String.fromCharCode(e[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o&&(this.formData=function(){return this.text().then(y)}),this.json=function(){return this.text().then(JSON.parse)},this}f.prototype.append=function(t,e){t=l(t),e=h(e);var n=this.map[t];this.map[t]=n?n+", "+e:e},f.prototype.delete=function(t){delete this.map[l(t)]},f.prototype.get=function(t){return t=l(t),this.has(t)?this.map[t]:null},f.prototype.has=function(t){return this.map.hasOwnProperty(l(t))},f.prototype.set=function(t,e){this.map[l(t)]=h(e)},f.prototype.forEach=function(t,e){for(var n in this.map)this.map.hasOwnProperty(n)&&t.call(e,this.map[n],n,this)},f.prototype.keys=function(){var t=[];return this.forEach((function(e,n){t.push(n)})),u(t)},f.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),u(t)},f.prototype.entries=function(){var t=[];return this.forEach((function(e,n){t.push([n,e])})),u(t)},r&&(f.prototype[Symbol.iterator]=f.prototype.entries);var b=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function w(t,e){var n,r,i=(e=e||{}).body;if(t instanceof w){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new f(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,i||null==t._bodyInit||(i=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new f(e.headers)),this.method=(r=(n=e.method||this.method||"GET").toUpperCase(),b.indexOf(r)>-1?r:n),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function y(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var n=t.split("="),r=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(r),decodeURIComponent(i))}})),e}function x(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new f(e.headers),this.url=e.url||"",this._initBody(t)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},v.call(w.prototype),v.call(x.prototype),x.prototype.clone=function(){return new x(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},x.error=function(){var t=new x(null,{status:0,statusText:""});return t.type="error",t};var k=[301,302,303,307,308];x.redirect=function(t,e){if(-1===k.indexOf(e))throw new RangeError("Invalid status code");return new x(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var n=Error(t);this.stack=n.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function _(t,n){return new Promise((function(r,o){var s=new w(t,n);if(s.signal&&s.signal.aborted)return o(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function c(){a.abort()}a.onload=function(){var t,e,n={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new f,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var n=t.split(":"),r=n.shift().trim();if(r){var i=n.join(":").trim();e.append(r,i)}})),e)};n.url="responseURL"in a?a.responseURL:n.headers.get("X-Request-URL");var i="response"in a?a.response:a.responseText;r(new x(i,n))},a.onerror=function(){o(new TypeError("Network request failed"))},a.ontimeout=function(){o(new TypeError("Network request failed"))},a.onabort=function(){o(new e.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&i&&(a.responseType="blob"),s.headers.forEach((function(t,e){a.setRequestHeader(e,t)})),s.signal&&(s.signal.addEventListener("abort",c),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",c)}),a.send(void 0===s._bodyInit?null:s._bodyInit)}))}_.polyfill=!0,t.fetch||(t.fetch=_,t.Headers=f,t.Request=w,t.Response=x),e.Headers=f,e.Request=w,e.Response=x,e.fetch=_}({})}(n),delete n.fetch.polyfill,(e=n.fetch).default=n.fetch,e.fetch=n.fetch,e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response,t.exports=e},function(t,e,n){var r=n(1),i=r(n(30)),o=r(n(16)),s=r(n(76)),a=r(n(31)),c=r(n(7)),l=r(n(10)),h=n(94),u=function(){function t(e){var n=e.fetch,r=e.size,i=void 0===r?1e7:r,o=e.chunkSize,s=void 0===o?32768:o;if((0,c.default)(this,t),!n)throw new Error("fetch function required");this.fetch=n,this.chunkSize=s,this.lruCache=new h({maxSize:Math.floor(i/s)})}var e;return(0,l.default)(t,[{key:"get",value:(e=(0,a.default)(i.default.mark((function t(e,n,r,a){var c,l,h,u,f,d,p,g=this;return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e.length<n+r)){t.next=2;break}throw new Error("output buffer not big enough for request");case 2:for(c=Math.floor(a/this.chunkSize),l=Math.floor((a+r)/this.chunkSize),h=new Array(l-c+1),u=function(t){h[t-c]=g._getChunk(t).then((function(e){return{data:e,chunkNumber:t}}))},f=c;f<=l;f+=1)u(f);return t.next=9,s.default.all(h);case 9:d=t.sent,p=a-d[0].chunkNumber*this.chunkSize,(0,o.default)(d).call(d,(function(t){var i=t.data,o=t.chunkNumber,s=o*g.chunkSize,h=0,u=g.chunkSize,f=n+(o-c)*g.chunkSize-p;o===c&&(f=n,h=p),o===l&&(u=a+r-s),i.copy(e,f,h,u)}));case 12:case"end":return t.stop()}}),t,this)}))),function(t,n,r,i){return e.apply(this,arguments)})},{key:"_getChunk",value:function(t){var e=this.lruCache.get(t);if(e)return e;var n=this.fetch(t*this.chunkSize,this.chunkSize);return this.lruCache.set(t,n),n}}]),t}();t.exports=u},function(t,e,n){var r=n(1),i=r(n(30)),o=r(n(31)),s=r(n(7)),a=r(n(10)),c=(n(161).promisify,null),l=function(){function t(e){(0,s.default)(this,t),this.position=0,this.filename=e,this.fd=c(this.filename,"r")}var e,n,r;return(0,a.default)(t,[{key:"read",value:(r=(0,o.default)(i.default.mark((function t(e){var n,r,o,s=arguments;return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=s.length>1&&void 0!==s[1]?s[1]:0,r=s.length>2?s[2]:void 0,null===(o=s.length>3?s[3]:void 0)&&(this.position,this.position+=r),t.t0=null,t.next=8,this.fd;case 8:return t.t1=t.sent,t.t2=e,t.t3=n,t.t4=r,t.t5=o,t.abrupt("return",(0,t.t0)(t.t1,t.t2,t.t3,t.t4,t.t5));case 14:case"end":return t.stop()}}),t,this)}))),function(t){return r.apply(this,arguments)})},{key:"readFile",value:(n=(0,o.default)(i.default.mark((function t(){return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=null,t.next=3,this.fd;case 3:return t.t1=t.sent,t.abrupt("return",(0,t.t0)(t.t1));case 5:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"stat",value:(e=(0,o.default)(i.default.mark((function t(){return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._stat){t.next=8;break}return t.t0=null,t.next=4,this.fd;case 4:return t.t1=t.sent,t.next=7,(0,t.t0)(t.t1);case 7:this._stat=t.sent;case 8:return t.abrupt("return",this._stat);case 9:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})}]),t}();t.exports=l},function(t,e,n){var r=n(1),i=r(n(48)),o=r(n(77)),s=r(n(101)),a=r(n(431)),c=r(n(16));t.exports={parseHeaderText:function(t){var e=t.split(/\r?\n/),n=[];return(0,c.default)(e).call(e,(function(t){var e=t.split(/\t/),r=(0,a.default)(e),c=r[0],l=(0,s.default)(r).call(r,1),h=(0,o.default)(l).call(l,(function(t){var e=t.split(":",2),n=(0,i.default)(e,2);return{tag:n[0],value:n[1]}}));c&&n.push({tag:c.substr(1),data:h})})),n}}},function(t,e,n){var r=n(157),i=n(152),o=n(158);t.exports=function(t){return r(t)||i(t)||o()}},function(t,e,n){var r=n(1),i=r(n(30)),o=r(n(103)),s=r(n(150)),a=r(n(48)),c=r(n(102)),l=r(n(16)),h=r(n(59)),u=r(n(76)),f=r(n(37)),d=r(n(77)),p=r(n(433)),g=r(n(31)),m=r(n(7)),v=r(n(10)),b=n(9),w=b.CramUnimplementedError,y=b.CramSizeLimitError,x=n(104),k=function(){function t(e){if((0,m.default)(this,t),e.cram?this.cram=e.cram:this.cram=new x({url:e.cramUrl,path:e.cramPath,filehandle:e.cramFilehandle,seqFetch:e.seqFetch,checkSequenceMD5:e.checkSequenceMD5,cacheSize:e.cacheSize}),!(this.cram instanceof x))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}var e;return(0,v.default)(t,[{key:"getRecordsForRange",value:(e=(0,g.default)(i.default.mark((function t(e,n,r){var g,m,v,b,x,k,_,S,C,E,A,T,L,M,R,I,N,P,O,F,D,B,z,H,V,j,U,q,W,$,G,Z,X,Y,K,Q=this,J=arguments;return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((k=J.length>3&&void 0!==J[3]?J[3]:{}).viewAsPairs=k.viewAsPairs||!1,k.pairAcrossChr=k.pairAcrossChr||!1,k.maxInsertSize=k.maxInsertSize||2e5,"string"!=typeof e){t.next=6;break}throw new w("string sequence names not yet supported");case 6:return _=e,t.next=9,this.index.getEntriesForRange(_,n,r);case 9:if(S=t.sent,!((C=(0,p.default)(g=(0,d.default)(S).call(S,(function(t){return t.sliceBytes}))).call(g,(function(t,e){return t+e}),0))>this.fetchSizeLimit)){t.next=13;break}throw new y((0,f.default)(m="data size of ".concat(C.toLocaleString()," bytes exceeded fetch size limit of ")).call(m,this.fetchSizeLimit.toLocaleString()," bytes"));case 13:return E=function(t){return t.sequenceId===e&&t.alignmentStart<=r&&t.alignmentStart+t.lengthOnRef-1>=n},t.next=16,u.default.all((0,d.default)(S).call(S,(function(t){return Q.getRecordsInSlice(t,E)})));case 16:if(A=t.sent,T=(b=(0,f.default)(v=Array.prototype)).call.apply(b,(0,f.default)(x=[v]).call(x,(0,h.default)(A))),!k.viewAsPairs){t.next=42;break}for(I={},N={},P=0;P<T.length;P+=1)O=T[P].readName,F=T[P].uniqueId,I[O]||(I[O]=0),I[O]+=1,N[F]=1;for(D={},(0,l.default)(L=(0,c.default)(I)).call(L,(function(t){var e=(0,a.default)(t,2),n=e[0];1===e[1]&&(D[n]=!0)})),B=[],z=0;z<T.length;z+=1)H=T[z].readName,D[H]&&T[z].mate&&(T[z].mate.sequenceId===_||k.pairAcrossChr)&&Math.abs(T[z].alignmentStart-T[z].mate.alignmentStart)<k.maxInsertSize&&(V=this.index.getEntriesForRange(T[z].mate.sequenceId,T[z].mate.alignmentStart,T[z].mate.alignmentStart+1),B.push(V));return t.next=28,u.default.all(B);case 28:for(j=t.sent,U=[],q=0;q<j.length;q+=1)(W=U).push.apply(W,(0,h.default)(j[q]));if(U=(0,s.default)(M=(0,o.default)(U).call(U,(function(t,e){return t.toString().localeCompare(e.toString())}))).call(M,(function(t,e,n){return!e||t.toString()!==n[e-1].toString()})),$=[],G=[],!((Z=(0,p.default)(R=(0,d.default)(U).call(U,(function(t){return t.sliceBytes}))).call(R,(function(t,e){return t+e}),0))>this.fetchSizeLimit)){t.next=37;break}throw new Error((0,f.default)(X="mate data size of ".concat(Z.toLocaleString()," bytes exceeded fetch size limit of ")).call(X,this.fetchSizeLimit.toLocaleString()," bytes"));case 37:return(0,l.default)(U).call(U,(function(t){var e=Q.cram.featureCache.get(t.toString());e||(e=Q.getRecordsInSlice(t,(function(){return!0})),Q.cram.featureCache.set(t.toString(),e)),$.push(e);var n=e.then((function(t){for(var e=[],n=0;n<t.length;n+=1){var r=t[n];D[r.readName]&&!N[r.uniqueId]&&e.push(r)}return e}));G.push(n)})),t.next=40,u.default.all(G);case 40:(Y=t.sent).length&&(K=(0,p.default)(Y).call(Y,(function(t,e){return(0,f.default)(t).call(t,e)})),T=(0,f.default)(T).call(T,K));case 42:return t.abrupt("return",T);case 43:case"end":return t.stop()}}),t,this)}))),function(t,n,r){return e.apply(this,arguments)})},{key:"getRecordsInSlice",value:function(t,e){var n=t.containerStart,r=t.sliceStart,i=t.sliceBytes;return this.cram.getContainerAtPosition(n).getSlice(r,i).getRecords(e)}},{key:"hasDataForReferenceSequence",value:function(t){return this.index.hasDataForReferenceSequence(t)}}]),t}();t.exports=k},function(t,e,n){t.exports=n(434)},function(t,e,n){t.exports=n(435)},function(t,e,n){var r=n(436),i=Array.prototype;t.exports=function(t){var e=t.reduce;return t===i||t instanceof Array&&e===i.reduce?r:e}},function(t,e,n){n(437);var r=n(18);t.exports=r("Array").reduce},function(t,e,n){var r=n(0),i=n(438).left;r({target:"Array",proto:!0,forced:n(54)("reduce")},{reduce:function(t){return i(this,t,arguments.length,arguments.length>1?arguments[1]:void 0)}})},function(t,e,n){var r=n(5),i=n(22),o=n(60),s=n(29),a=function(t){return function(e,n,a,c){r(n);var l=i(e),h=o(l),u=s(l.length),f=t?u-1:0,d=t?-1:1;if(a<2)for(;;){if(f in h){c=h[f],f+=d;break}if(f+=d,t?f<0:u<=f)throw TypeError("Reduce of empty array with no initial value")}for(;t?f>=0:u>f;f+=d)f in h&&(c=n(c,h[f],f,l));return c}};t.exports={left:a(!1),right:a(!0)}},function(t,e,n){var r=n(1),i=r(n(30)),o=r(n(31)),s=r(n(103)),a=r(n(102)),c=r(n(16)),l=r(n(154)),h=r(n(440)),u=r(n(48)),f=r(n(442)),d=r(n(37)),p=r(n(75)),g=r(n(7)),m=r(n(10)),v=n(447).default,b=n(94),w=(0,n(161).promisify)(n(126).gunzip),y=n(160).open,x=n(9).CramMalformedError,k=function(){function t(e){(0,g.default)(this,t),(0,p.default)(this,e)}return(0,m.default)(t,[{key:"toString",value:function(){var t,e,n,r;return(0,d.default)(t=(0,d.default)(e=(0,d.default)(n=(0,d.default)(r="".concat(this.start,":")).call(r,this.span,":")).call(n,this.containerStart,":")).call(e,this.sliceStart,":")).call(t,this.sliceBytes)}}]),t}();function _(t,e){if((0,f.default)(e).call(e,(function(t){return void 0===t})))throw new x("invalid .crai index file");var n=(0,u.default)(e,6),r=n[0],i=n[1],o=n[2],s=n[3],a=n[4],c=n[5];t[r]||(t[r]=[]),t[r].push(new k({start:i,span:o,containerStart:s,sliceStart:a,sliceBytes:c}))}var S=function(){function t(e){var n,r=this;(0,g.default)(this,t);var i=y(e.url,e.path,e.filehandle);this._parseCache=new v({cache:new b({maxSize:1}),fill:function(t,e){return r.parseIndex({signal:e})}}),this.readFile=(0,h.default)(n=i.readFile).call(n,i)}var e,n;return(0,m.default)(t,[{key:"parseIndex",value:function(){var t={};return this.readFile().then((function(t){return 31===t[0]&&139===t[1]?w(t):t})).then((function(e){var n;if(e.length>4&&21578050===e.readUInt32LE(0))throw new x("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");for(var r=[],i="",o=0;o<e.length;o+=1){var h=e[o];if(h>=48&&h<=57||!i&&45===h)i+=String.fromCharCode(h);else if(9===h)r.push((0,l.default)(i,10)),i="";else if(10===h)r.push((0,l.default)(i,10)),i="",_(t,r),r=[];else if(13!==h&&32!==h)throw new x("invalid .crai index file")}return i&&r.push((0,l.default)(i,10)),6===r.length&&_(t,r),(0,c.default)(n=(0,a.default)(t)).call(n,(function(e){var n=(0,u.default)(e,2),r=n[0],i=n[1];t[r]=(0,s.default)(i).call(i,(function(t,e){return t.start-e.start||t.span-e.span}))})),t}))}},{key:"getIndex",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._parseCache.get("index",null,t.signal)}},{key:"hasDataForReferenceSequence",value:(n=(0,o.default)(i.default.mark((function t(e){return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getIndex();case 2:return t.t0=e,t.abrupt("return",!!t.sent[t.t0]);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return n.apply(this,arguments)})},{key:"getEntriesForRange",value:(e=(0,o.default)(i.default.mark((function t(e,n,r){var o,s,a,c;return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getIndex();case 2:if(t.t0=e,o=t.sent[t.t0]){t.next=6;break}return t.abrupt("return",[]);case 6:for(s=function(t){var e=t.start,i=t.start+t.span;return e>=r?-1:i<=n?1:0},a=[],c=0;c<o.length;c+=1)0===s(o[c])&&a.push(o[c]);return t.abrupt("return",a);case 10:case"end":return t.stop()}}),t,this)}))),function(t,n,r){return e.apply(this,arguments)})}]),t}();t.exports=S},function(t,e,n){t.exports=n(441)},function(t,e,n){t.exports=n(144)},function(t,e,n){t.exports=n(443)},function(t,e,n){t.exports=n(444)},function(t,e,n){var r=n(445),i=Array.prototype;t.exports=function(t){var e=t.some;return t===i||t instanceof Array&&e===i.some?r:e}},function(t,e,n){n(446);var r=n(18);t.exports=r("Array").some},function(t,e,n){var r=n(0),i=n(45).some;r({target:"Array",proto:!0,forced:n(54)("some")},{some:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}})},function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var i=r(n(448));e.default=i.default},function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var i=n(162),o=r(n(450)),s=function(){function t(t){var e=t.fill,n=t.cache;if("function"!=typeof e)throw new TypeError("must pass a fill function");if("object"!=typeof n)throw new TypeError("must pass a cache object");if("function"!=typeof n.get||"function"!=typeof n.set||"function"!=typeof n.delete)throw new TypeError("cache must implement get(key), set(key, val), and and delete(key)");this.cache=n,this.fillCallback=e}return t.isAbortException=function(t){return"AbortError"===t.name||"ERR_ABORTED"===t.code||"AbortError: aborted"===t.message||"Error: aborted"===t.message},t.prototype.evict=function(t,e){this.cache.get(t)===e&&this.cache.delete(t)},t.prototype.fill=function(t,e,n){var r=this,i=new o.default,s={aborter:i,promise:this.fillCallback(e,i.signal),settled:!1,get aborted(){return this.aborter.signal.aborted}};s.aborter.addSignal(n),s.aborter.signal.addEventListener("abort",(function(){r.evict(t,s)})),s.promise.then((function(){s.settled=!0}),(function(e){s.settled=!0,r.evict(t,s)})).catch((function(t){throw console.error(t),t})),this.cache.set(t,s)},t.checkSinglePromise=function(t,e){function n(){if(e&&e.aborted)throw Object.assign(new Error("aborted"),{code:"ERR_ABORTED"})}return t.then((function(t){return n(),t}),(function(t){throw n(),t}))},t.prototype.has=function(t){return this.cache.has(t)},t.prototype.get=function(e,n,r){if(!r&&n instanceof i.AbortSignal)throw new TypeError("second get argument appears to be an AbortSignal, perhaps you meant to pass `null` for the fill data?");var o=this.cache.get(e);return o?o.aborted?(this.evict(e,o),this.get(e,n,r)):o.settled?o.promise:(o.aborter.addSignal(r),t.checkSinglePromise(o.promise,r)):(this.fill(e,n,r),t.checkSinglePromise(this.cache.get(e).promise,r))},t.prototype.delete=function(t){var e=this.cache.get(t);e&&(e.settled||e.aborter.abort(),this.cache.delete(t))},t.prototype.clear=function(){for(var t=this.cache.keys(),e=0,n=t.next();!n.done;n=t.next())this.delete(n.value),e+=1;return e},t}();e.default=s},function(t,e,n){function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function o(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),t}function s(t){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function a(t,e){return(a=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function l(t,e,n){return(l="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=s(t)););return t}(t,e);if(r){var i=Object.getOwnPropertyDescriptor(r,e);return i.get?i.get.call(n):i.value}})(t,e,n||t)}Object.defineProperty(e,"__esModule",{value:!0});var h=function(){function t(){r(this,t),Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}return o(t,[{key:"addEventListener",value:function(t,e){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push(e)}},{key:"removeEventListener",value:function(t,e){if(t in this.listeners)for(var n=this.listeners[t],r=0,i=n.length;r<i;r++)if(n[r]===e)return void n.splice(r,1)}},{key:"dispatchEvent",value:function(t){var e=this;if(t.type in this.listeners){for(var n=function(n){setTimeout((function(){return n.call(e,t)}))},r=this.listeners[t.type],i=0,o=r.length;i<o;i++)n(r[i]);return!t.defaultPrevented}}}]),t}(),u=function(t){function e(){var t;return r(this,e),(t=function(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?c(t):e}(this,s(e).call(this))).listeners||h.call(c(t)),Object.defineProperty(c(t),"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(c(t),"onabort",{value:null,writable:!0,configurable:!0}),t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&a(t,e)}(e,t),o(e,[{key:"toString",value:function(){return"[object AbortSignal]"}},{key:"dispatchEvent",value:function(t){"abort"===t.type&&(this.aborted=!0,"function"==typeof this.onabort&&this.onabort.call(this,t)),l(s(e.prototype),"dispatchEvent",this).call(this,t)}}]),e}(h),f=function(){function t(){r(this,t),Object.defineProperty(this,"signal",{value:new u,writable:!0,configurable:!0})}return o(t,[{key:"abort",value:function(){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}}this.signal.dispatchEvent(t)}},{key:"toString",value:function(){return"[object AbortController]"}}]),t}();"undefined"!=typeof Symbol&&Symbol.toStringTag&&(f.prototype[Symbol.toStringTag]="AbortController",u.prototype[Symbol.toStringTag]="AbortSignal"),e.AbortController=f,e.AbortSignal=u,e.abortableFetch=function(t){"function"==typeof t&&(t={fetch:t});var e=t,n=e.fetch,r=e.Request,i=void 0===r?n.Request:r,o=e.AbortController,s=e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL,a=void 0!==s&&s;if(!function(t){return t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):"function"==typeof t.Request&&!t.Request.prototype.hasOwnProperty("signal")||!t.AbortController}({fetch:n,Request:i,AbortController:o,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:a}))return{fetch:n,Request:c};var c=i;(c&&!c.prototype.hasOwnProperty("signal")||a)&&((c=function(t,e){var n;e&&e.signal&&(n=e.signal,delete e.signal);var r=new i(t,e);return n&&Object.defineProperty(r,"signal",{writable:!1,enumerable:!1,configurable:!0,value:n}),r}).prototype=i.prototype);var l=n;return{fetch:function(t,e){var n=c&&c.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(n){var r;try{r=new DOMException("Aborted","AbortError")}catch(t){(r=new Error("Aborted")).name="AbortError"}if(n.aborted)return Promise.reject(r);var i=new Promise((function(t,e){n.addEventListener("abort",(function(){return e(r)}),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([i,l(t,e)])}return l(t,e)},Request:c}}},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0});var r=n(162),i=function(){},o=function(){function t(){this.signals=new Set,this.abortController=new r.AbortController}return t.prototype.addSignal=function(t){var e=this;if(void 0===t&&(t=new i),this.signal.aborted)throw new Error("cannot add a signal, already aborted!");this.signals.add(t),t.aborted?this.handleAborted(t):"function"==typeof t.addEventListener&&t.addEventListener("abort",(function(){e.handleAborted(t)}))},t.prototype.handleAborted=function(t){this.signals.delete(t),0===this.signals.size&&this.abortController.abort()},Object.defineProperty(t.prototype,"signal",{get:function(){return this.abortController.signal},enumerable:!0,configurable:!0}),t.prototype.abort=function(){this.abortController.abort()},t}();e.default=o}]);class ac{constructor(t,e,n){this.config=t,this.browser=n,this.genome=e,this.cramFile=new sc.CramFile({filehandle:new cc(t.url,t),seqFetch:t.seqFetch||function(t,e,n){const r=this.genome.sequence,i=this.genome;return this.getHeader().then((function(o){const s=i.getChromosomeName(o.chrNames[t]);return r.getSequence(s,e-1,n)}))}.bind(this),checkSequenceMD5:void 0===t.checkSequenceMD5||t.checkSequenceMD5});const r=new cc(t.indexURL,t);this.indexedCramFile=new sc.IndexedCramFile({cram:this.cramFile,index:new sc.CraiIndex({filehandle:r}),fetchSizeLimit:3e7}),za.setReaderDefaults(this,t)}async getHeader(){if(!this.header){const t=this.genome,e=await this.cramFile.getSamHeader(),n={},r=[],i={},o=[];for(let s of e)if("SQ"===s.tag){for(let e of s.data)if("SN"===e.tag){const o=e.value;if(n[o]=r.length,r.push(o),t){i[t.getChromosomeName(o)]=o}break}}else"RG"===s.tag&&o.push(s.data);this.header={chrNames:r,chrToIndex:n,chrAliasTable:i,readGroups:o}}return this.header}async readAlignments(t,e,n){this.browser;const r=await this.getHeader(),i=r.chrAliasTable.hasOwnProperty(t)?r.chrAliasTable[t]:t,o=r.chrToIndex[i],s=new ba(t,e,n,this.config);if(void 0===o)return s;try{const t=await this.indexedCramFile.getRecordsForRange(o,e,n);for(let i of t){const t=i.sequenceId,c=i.alignmentStart,l=c+i.lengthOnRef;if(t<0)continue;if(t>o||c>n)return;if(t<o)continue;if(l<e)continue;const h=a(i,r.chrNames);this.filter.pass(h)&&s.push(h)}return s.finish(),s}catch(t){let e=t.message;throw e&&e.indexOf("MD5")>=0&&(e="Sequence mismatch. Is this the correct genome for the loaded CRAM?"),Qo.presentAlert(new Error(e)),t}function a(t,e){const n=new Ea;if(n.chr=e[t.sequenceId],n.start=t.alignmentStart-1,n.lengthOnRef=t.lengthOnRef,n.flags=t.flags,n.strand=!(16&t.flags),n.fragmentLength=t.templateLength||t.templateSize,n.mq=t.mappingQuality,n.end=t.alignmentStart+t.lengthOnRef,n.readGroupId=t.readGroupId,t.mate&&void 0!==t.mate.sequenceId){const r=void 0!==t.mate.flags?!(1&t.mate.flags):!(32&t.flags);n.mate={chr:e[t.mate.sequenceId],position:t.mate.alignmentStart,strand:r}}return n.seq=t.getReadBases(),n.qual=t.qualityScores,n.tagDict=t.tags,n.readName=t.readName,function(t,e){const n=[];let r,i,o=0,s="";if(e.scStart=e.start,e.scLengthOnRef=e.lengthOnRef,t.readFeatures)for(let a of t.readFeatures){const t=a.code,c=a.data,l=a.pos-1,h=a.refPos-1;switch(t){case"S":case"I":case"i":case"N":case"D":if(l>o){const t=l-o;n.push(new Pa({start:h-t,seqOffset:o,len:t,type:"M"})),o+=t,s+=t+"M"}if("S"===t){let r=h;e.scLengthOnRef+=c.length,0===l&&(e.scStart-=c.length,r-=c.length);const i=c.length;n.push(new Pa({start:r,seqOffset:o,len:i,type:"S"})),o+=i,s+=i+t}else if("I"===t||"i"===t){void 0===r&&(r=[]);const e="i"===t?1:c.length;r.push(new Pa({start:h,len:e,seqOffset:o,type:"I"})),o+=e,s+=e+t}else"D"!==t&&"N"!==t||(i||(i=[]),i.push({start:h,len:c,type:t}),s+=c+t);break;case"H":case"P":s+=c+t}}const a=t.readLength-o;a>0&&(n.push(new Pa({start:t.alignmentStart+t.lengthOnRef-a-1,seqOffset:o,len:a,type:"M"})),s+=a+"M");e.blocks=n,e.insertions=r,e.gaps=i,e.cigar=s}(t,n),n.mate&&n.start>n.mate.position&&n.fragmentLength>0&&(n.fragmentLength=-n.fragmentLength),za.setPairOrientation(n),n}}}class cc{constructor(t,e){this.position=0,this.url=t,this.config=e,this.cache=new lc({fetch:(t,e)=>this._fetch(t,e)})}async _fetch(t,e){const n={start:t,size:e};this._stat={size:void 0};const r=await go.loadArrayBuffer(this.url,gs(this.config,{range:n}));return Buffer.from(r)}async read(t,e=0,n=1/0,r=0){let i=r;return null===r&&(i=this.position,this.position+=n),this.cache.get(t,e,n,r)}async readFile(){const t=await go.loadArrayBuffer(this.url,gs(this.config));return Buffer.from(t)}async stat(){if(!this._stat){const t=Buffer.allocUnsafe(10);if(await this.read(t,0,10,0),!this._stat)throw new Error(`unable to determine size of file at ${this.url}`)}return this._stat}}class lc{constructor({fetch:t,size:e=1e7,chunkSize:n=32768}){this.fetch=t,this.chunkSize=n,this.lruCache=new hc({maxSize:Math.floor(e/n)})}async get(t,e,n,r){if(t.length<e+n)throw new Error("output buffer not big enough for request");const i=Math.floor(r/this.chunkSize),o=Math.floor((r+n)/this.chunkSize),s=new Array(o-i+1);for(let t=i;t<=o;t+=1)s[t-i]=this._getChunk(t).then((e=>({data:e,chunkNumber:t})));const a=await Promise.all(s),c=r-a[0].chunkNumber*this.chunkSize;a.forEach((({data:s,chunkNumber:a})=>{const l=a*this.chunkSize;let h=0,u=this.chunkSize,f=e+(a-i)*this.chunkSize-c;a===i&&(f=e,h=c),a===o&&(u=r+n-l),s.copy(t,f,h,u)}))}_getChunk(t){const e=this.lruCache.get(t);if(e)return e;const n=this.fetch(t*this.chunkSize,this.chunkSize);return this.lruCache.set(t,n),n}}class hc{constructor(t={}){if(!(t.maxSize&&t.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=t.maxSize,this.cache=new Map,this.oldCache=new Map,this._size=0}_set(t,e){this.cache.set(t,e),this._size++,this._size>=this.maxSize&&(this._size=0,this.oldCache=this.cache,this.cache=new Map)}get(t){if(this.cache.has(t))return this.cache.get(t);if(this.oldCache.has(t)){const e=this.oldCache.get(t);return this._set(t,e),e}}set(t,e){return this.cache.has(t)?this.cache.set(t,e):this._set(t,e),this}has(t){return this.cache.has(t)||this.oldCache.has(t)}peek(t){return this.cache.has(t)?this.cache.get(t):this.oldCache.has(t)?this.oldCache.get(t):void 0}delete(t){const e=this.cache.delete(t);return e&&this._size--,this.oldCache.delete(t)||e}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}*keys(){for(const[t]of this)yield t}*values(){for(const[,t]of this)yield t}*[Symbol.iterator](){for(const t of this.cache)yield t;for(const t of this.oldCache){const[e]=t;this.cache.has(e)||(yield t)}}get size(){let t=0;for(const e of this.oldCache.keys())this.cache.has(e)||t++;return this._size+t}}const uc=go.apiKey;function fc(t){var e=t.url+"/"+t.entity+"/"+t.entityId;return t.headers={"Cache-Control":"no-cache"},go.loadJson(e,t)}function dc(t){return new Promise((function(e,n){var r=t.results?t.results:[],i=t.url,o=t.body,s=t.decode,a="?",c=t.fields;return uc&&(i=i+a+"key="+uc,a="&"),c&&(i=i+a+"fields="+c),function t(a){a?o.pageToken=a:void 0!==o.pageToken&&delete o.pageToken;var c=JSON.stringify(o);go.loadJson(i,{sendData:c,contentType:"application/json",headers:{"Cache-Control":"no-cache"}}).then((function(n){var i,o;n?((o=s?s(n):n)&&o.forEach((function(t){r.push(t)})),(i=n.nextPageToken)?t(i):e(r)):e(r)})).catch((function(t){n(t)}))}()}))}var pc={ALIGNMENT_MATCH:"M",INSERT:"I",DELETE:"D",SKIP:"N",CLIP_SOFT:"S",CLIP_HARD:"H",PAD:"P",SEQUENCE_MATCH:"=",SEQUENCE_MISMATCH:"X"};const gc=function(t,e){this.config=t,this.genome=e,this.url=t.url,this.filter=new Oa(t.filter),this.readGroupSetIds=t.readGroupSetIds,this.authKey=t.authKey,this.samplingWindowSize=void 0===t.samplingWindowSize?100:t.samplingWindowSize,this.samplingDepth=void 0===t.samplingDepth?1e3:t.samplingDepth,t.viewAsPairs?this.pairsSupported=!0:this.pairsSupported=void 0===t.pairsSupported||t.pairsSupported};gc.prototype.readAlignments=function(t,e,n){const r=this.genome,i=this;return(i.chrAliasTable?Promise.resolve(i.chrAliasTable):i.readMetadata().then((function(t){if(i.chrAliasTable={},r&&t.readGroups&&t.readGroups.length>0){var e=t.readGroups[0].referenceSetId;return e?dc({url:i.url+"/references/search",body:{referenceSetId:e},decode:function(t){return t.references}}).then((function(t){return t.forEach((function(t){var e=t.name,n=r.getChromosomeName(e);i.chrAliasTable[n]=e})),i.chrAliasTable})):(function(t,e){var n;if("461916304629"===e||"337315832689"===e){for(n=1;n<23;n++)t["chr"+n]=n;t.chrX="X",t.chrY="Y",t.chrM="MT"}}(i.chrAliasTable,i.config.datasetId),i.chrAliasTable)}return i.chrAliasTable}))).then((function(r){var s=r.hasOwnProperty(t)?r[t]:t;return dc({url:i.url+"/reads/search",body:{readGroupSetIds:[i.readGroupSetIds],referenceName:s,start:e,end:n,pageSize:"10000"},decode:o,results:new ba(t,e,n,i.config)})}));function o(t){var e,n,o,s,a,c=t.alignments,l=c.length,h=[];for(e=0;e<l;e++){let t=c[e];(n=new Ea).readName=t.fragmentName,n.properPlacement=t.properPlacement,n.duplicateFragment=t.duplicateFragment,n.numberReads=t.numberReads,n.fragmentLength=t.fragmentLength,n.readNumber=t.readNumber,n.failedVendorQualityChecks=t.failedVendorQualityChecks,n.secondaryAlignment=t.secondaryAlignment,n.supplementaryAlignment=t.supplementaryAlignment,n.seq=t.alignedSequence,n.qual=t.alignedQuality,n.matePos=t.nextMatePosition,n.tagDict=t.info,n.flags=0,t.alignment?(n.mapped=!0,n.chr=t.alignment.position.referenceName,r&&(n.chr=r.getChromosomeName(n.chr)),n.start=parseInt(t.alignment.position.position),n.strand=!t.alignment.position.reverseStrand,n.mq=t.alignment.mappingQuality,n.cigar=u(t.alignment.cigar),o=f(t.alignment.cigar),n.lengthOnRef=o.lengthOnRef,a=d(n,o.array),n.blocks=a.blocks,n.insertions=a.insertions):n.mapped=!1,(s=t.nextMatePosition)&&(n.mate={chr:s.referenceFrame,position:parseInt(s.position),strand:!s.reverseStrand}),i.filter.pass(n)&&h.push(n)}return h;function u(t){var e="";return t.forEach((function(t){var n=pc[t.operation],r=t.operationLength;e+=r+n})),e}function f(t){var e,n,r,i,o=0,s=[];for(i=0;i<t.length;i++)e=t[i],r=pc[e.operation],n=parseInt(e.operationLength),"M"!==r&&"EQ"!==r&&"X"!==r&&"D"!==r&&"N"!==r&&"="!==r||(o+=n),s.push({len:n,ltr:r});return{lengthOnRef:o,array:s}}function d(t,e){for(var n,r,i,o=[],s=0,a=t.start,c=e.length,l=0;l<c;l++){var h=e[l];switch(h.ltr){case"H":case"P":break;case"S":s+=h.len,i="S";break;case"N":case"D":void 0===n&&(n=[]),n.push({start:a,len:h.len,type:h.ltr}),a+=h.len;break;case"I":void 0===r&&(r=[]),r.push(new Pa({start:a,len:h.len,seqOffset:s})),s+=h.len;break;case"M":case"EQ":case"=":case"X":o.push(new Pa({start:a,len:h.len,seqOffset:s,gapType:i})),s+=h.len,a+=h.len;break;default:console.log("Error processing cigar element: "+h.len+h.ltr)}}return{blocks:o,insertions:r,gaps:n}}}},gc.prototype.readMetadata=function(){return fc({url:this.url,entity:"readgroupsets",entityId:this.readGroupSetIds})};class mc{constructor(t,e){const n=e.genome;if(this.config=t,this.genome=n,ys(t.url)){if("cram"===t.format)throw"CRAM data uris are not supported";this.config.indexed=!1}if("ga4gh"===t.sourceType)this.bamReader=new gc(t,n);else if("pysam"===t.sourceType)this.bamReader=new Ja(t,n);else if("htsget"===t.sourceType)this.bamReader=new ic(t,n);else if("shardedBam"===t.sourceType)this.bamReader=new Qa(t,n);else if("cram"===t.format)this.bamReader=new ac(t,n,e);else{if(!this.config.indexURL&&!1!==t.indexed)if(_e(this.config.url)){const t=function(t,e){if(_e(t)){if(t.includes("?")){const n=t.indexOf("?");return t.substring(0,n)+"."+e+t.substring(n)}return t+"."+e}}(this.config.url,"bai");t?(console.error(`Warning: no indexURL specified for ${this.config.url}. Guessing ${this.baiPath}`),this.config.indexURL=t):(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 Ka(t,n):this.bamReader=new qa(t,n)}this.viewAsPairs=t.viewAsPairs,this.showSoftClips=t.showSoftClips}setViewAsPairs(t){this.viewAsPairs=t}setShowSoftClips(t){this.showSoftClips=t}async getAlignments(t,e,n){const r=this.genome,i=this.showSoftClips,o=await this.bamReader.readAlignments(t,e,n);let s=o.alignments;this.viewAsPairs||(s=ma([{alignments:s}]));const a=s.length>0;if(o.packedAlignmentRows=va(s,o.start,o.end,i),this.alignmentContainer=o,a){const e=await r.sequence.getSequence(t,o.start,o.end);if(e)return o.coverageMap.refSeq=e,o.sequence=e,o;console.error("No sequence for: "+t+":"+o.start+"-"+o.end)}return o}}const vc=t=>t.indexOf(",")>0&&!t.startsWith("rgb")?`rgb(${t})`:t;class bc{constructor(t,e){this.browser=e,this.init(t)}init(t){t.displayMode&&(t.displayMode=t.displayMode.toUpperCase()),this.config=t,this.url=t.url,this.type=t.type,this.supportHiDPI=void 0===t.supportHiDPI||t.supportHiDPI,t.name||t.label?this.name=t.name||t.label:Ue(t.url)?this.name=t.url.name:_e(t.url)&&!t.url.startsWith("data:")&&(this.name=je(t.url)),this.id=void 0===this.config.id?this.name:this.config.id,this.order=t.order,t.color&&(this.color=vc(t.color)),t.altColor&&(this.altColor=vc(t.altColor)),"civic-ws"===t.sourceType?this.defaultColor="rgb(155,20,20)":this.defaultColor="rgb(0,0,150)",this.autoscaleGroup=t.autoscaleGroup,this.removable=void 0===t.removable||t.removable,this.height=t.height||100,this.autoHeight=t.autoHeight,this.minHeight=t.minHeight||Math.min(25,this.height),this.maxHeight=t.maxHeight||Math.max(1e3,this.height),this.visibilityWindow=t.visibilityWindow,t.onclick&&(this.onclick=t.onclick,t.onclick=void 0),t.description&&("function"==typeof t.description?this.description=t.description:this.description=()=>t.description)}get name(){return this._name}set name(t){this._name=t,this.trackView&&this.trackView.setTrackLabelName(t)}updateConfig(t){this.init(t)}getState(){const t={};for(let e of Object.keys(this.config))e.startsWith("_")||"function"==typeof this.config[e]||void 0===this.config[e]||(t[e]=this.config[e]);for(let e of Object.keys(t)){if(e.startsWith("_"))continue;const n=this[e];n&&(ps(n)||"boolean"==typeof n||"metadata"===e)&&(t[e]=n)}this.color&&(t.color=this.color),this.altColor&&(t.altColor=this.altColor),!this.autoscale&&this.dataRange&&(t.min=this.dataRange.min,t.max=this.dataRange.max);for(let e of Object.keys(t)){const n=t[e];if("function"==typeof n)throw Error(`Property '${e}' of track '${this.name} is a function. Functions cannot be saved in sessions.`);if(n instanceof File){const t=`Track ${this.name} is a local file. Sessions cannot be saved with local file references.`;throw Error(t)}if(n instanceof Promise)throw Error(`Property '${e}' of track '${this.name} is a Promise. Promises cannot be saved in sessions.`)}return t}get supportsWholeGenome(){return!0===this.config.supportsWholeGenome}hasSamples(){return!1}getGenomeId(){return this.browser.genome?this.browser.genome.id:void 0}setTrackProperties(t){const e={};let n;for(let r of Object.keys(t))switch(r.toLowerCase()){case"usescore":e.useScore=1===t[r]||"1"===t[r]||"on"===t[r]||!0===t[r];break;case"visibility":switch(t[r]){case"2":case"3":case"pack":case"full":e.displayMode="EXPANDED";break;case"4":case"squish":e.displayMode="SQUISHED";break;case"1":case"dense":e.displayMode="COLLAPSED"}break;case"color":case"altcolor":e[r]=t[r].startsWith("rgb(")?t[r]:"rgb("+t[r]+")";break;case"featurevisiblitywindow":case"visibilitywindow":e.visibilityWindow=Number.parseInt(t[r]);break;case"maxheightpixels":n=t[r].split(":"),3===n.length&&(e.minHeight=Number.parseInt(n[2]),e.height=Number.parseInt(n[1]),e.maxHeight=Number.parseInt(n[0]));break;case"viewlimits":if(!this.config.autoscale){n=t[r].split(":");let i,o=0;1==n.length?i=Number(n[0]):2==n.length&&(o=Number(n[0]),i=Number(n[1])),e.autoscale=!1,e.dataRange={min:o,max:i}}case"name":e[r]=t[r];break;case"url":e.infoURL=t[r];break;case"type":const i=t[r];wc.has(i)?e[r]=wc.get(i):e[r]=i;break;case"graphtype":e.graphType=t[r];break;default:e[r]=t[r]}for(let t of Object.keys(e))if(!this.config.hasOwnProperty(t)||"name"===t&&this.config._derivedName){let n=e[t];if("true"===n&&(n=!0),"false"===n&&(n=!1),this[t]=n,"height"===t&&this.trackView)try{const t=Number.parseInt(n);this.trackView.setTrackHeight(t)}catch(t){console.error(t)}}}clickedFeatures(t,e){if(e||(e=t.viewport.cachedFeatures),!e||0===e.length)return[];const n=t.genomicLocation,r=t.referenceFrame.bpPerPixel>.2?3*t.referenceFrame.bpPerPixel:.2;return No(e,n-r,n+r)}extractPopupData(t,e){const n=new Set(["row","color","chr","start","end","cdStart","cdEnd","strand","alpha"]),r=[];let i,o;for(let e in t)if(t.hasOwnProperty(e)&&!n.has(e)&&ps(t[e])){let n=t[e];r.push({name:Ae(e),value:n}),"alleles"===e?i=t[e]:"alleleFreqs"===e&&(o=t[e])}if(i&&o){i.endsWith(",")&&(i=i.substr(0,i.length-1)),o.endsWith(",")&&(o=o.substr(0,o.length-1));let n=i.split(","),s=o.split(",");if(s.length>1){let i=[];for(let t=0;t<s.length;t++)i.push({a:n[t],af:Number(s[t])});i.sort((function(t,e){return t.af-e.af}));let o=i[i.length-1].a;if(1===o.length)for(let n=i.length-2;n>=0;n--){let s=i[n].a;if(1===s.length){e||(e=this.getGenomeId());const n=bc.getCravatLink(t.chr,t.start+1,o,s,e);console.log(n),n&&(r.push("<hr/>"),r.push({html:n}),r.push("<hr/>"))}}}}if(t.attributes)for(let e of Object.keys(t.attributes))r.push({name:e,value:t.attributes[e]});let s=`${t.chr}:${Se(t.start+1)}-${Se(t.end)}`;return t.strand&&(s+=` (${t.strand})`),r.push({name:"Location",value:s}),r}description(){const t=(t,e)=>`<div class="igv-track-label-popup-shim"><b>${t}: </b>${e}</div>`;let e='<div class="igv-track-label-popup">';if(this.url?Ue(this.url)?e+=t("Filename",this.url.name):e+=t("URL",this.url):e=this.name,this.config){if(this.config.metadata)for(let n of Object.keys(this.config.metadata)){e+=t(n,this.config.metadata[n])}for(let n of Object.keys(this.config)){if(n.startsWith("_"))continue;let r=n.substr(0,1);if(r!==r.toLowerCase()){const r=this.config[n];r&&ps(r)&&(e+=t(n,r))}}}return e+="</div>",e}static getCravatLink(t,e,n,r,i){if("hg38"===i||"GRCh38"===i){return`<a target="_blank" href="https://run.opencravat.org/result/nocache/variant.html?chrom=${t.startsWith("chr")?t:"chr"+t}&pos=${e}&ref_base=${n}&alt_base=${r}"><b>Cravat ${n}->${r}</b></a>`}}}const wc=new Map([["wiggle_0","wig"],["bed","bed"],["bigBed","bigBed"],["bigWig","bigWig"]]);function yc(t,e,n){var r,i,o,s,a,c,l,h={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 u=void 0!==this.flipAxis&&this.flipAxis;function f(t){return 0===t?"0":Math.abs(t)>=10?t.toFixed():Math.abs(t)>=1?t.toFixed(1):t.toFixed(2)}ls.fillRect(t,0,0,e,n,{fillStyle:"rgb(255, 255, 255)"}),r=(l=.95*e)-8,a={x:i=l,y:o=s=.01*n},ls.strokeLine(t,r,o,i,s,h),ls.fillText(t,f(u?this.dataRange.min:this.dataRange.max),r+4,o+12,h),c={x:i,y:o=s=.99*n},ls.strokeLine(t,r,o,i,s,h),ls.fillText(t,f(u?this.dataRange.max:this.dataRange.min),r+4,o-4,h),ls.strokeLine(t,a.x,a.y,c.x,c.y,h)}const xc={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 kc={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 _c{constructor(t){this.colors=kc[t],Array.isArray(this.colors)||(this.colors=[]),this.colorTable={},this.nextIdx=0,this.colorGenerator=new Cc}getColor(t){return this.colorTable.hasOwnProperty(t)||(this.nextIdx<this.colors.length?this.colorTable[t]=this.colors[this.nextIdx]:this.colorTable[t]=this.colorGenerator.get(),this.nextIdx++),this.colorTable[t]}}class Sc{constructor(t){this.colorTable=t||{},this.nextIdx=0,this.colorGenerator=new Cc}getColor(t){if(!this.colorTable.hasOwnProperty(t)){if(this.colorTable.hasOwnProperty("*"))return this.colorTable["*"];this.colorTable[t]=this.colorGenerator.get()}return this.colorTable[t]}}function Cc(){this.hue=Math.random(),this.goldenRatio=.618033988749895,this.hexwidth=2}Cc.prototype.hsvToRgb=function(t,e,n){var r=Math.floor(6*t),i=6*t-r,o=n*(1-e),s=n*(1-i*e),a=n*(1-(1-i)*e),c=255,l=255,h=255;switch(r){case 0:c=n,l=a,h=o;break;case 1:c=s,l=n,h=o;break;case 2:c=o,l=n,h=a;break;case 3:c=o,l=s,h=n;break;case 4:c=a,l=o,h=n;break;case 5:c=n,l=o,h=s}return[Math.floor(256*c),Math.floor(256*l),Math.floor(256*h)]},Cc.prototype.padHex=function(t){return t.length>this.hexwidth?t:new Array(this.hexwidth-t.length+1).join("0")+t},Cc.prototype.get=function(t,e){this.hue+=this.goldenRatio,this.hue%=1,"number"!=typeof t&&(t=.5),"number"!=typeof e&&(e=.95);var n=this.hsvToRgb(this.hue,t,e);return"#"+this.padHex(n[0].toString(16))+this.padHex(n[1].toString(16))+this.padHex(n[2].toString(16))};const Ec=new Cc;class Ac{constructor({chr:t,start:e,end:n}){this.chr=t,this.start=e,this.end=n}contains(t){return t.chr===this.chr&&t.start>=this.start&&t.end<=this.end}overlaps(t){return t.chr===this.chr&&!(t.end<this.start||t.start>this.end)}extend(t){t.chr===this.chr&&(this.start=Math.min(t.start,this.start),this.end=Math.max(t.end,this.end))}getLocusString(){if("all"===this.chr)return"all";{const t=Se(Math.floor(this.start)+1),e=Se(Math.round(this.end));return`${this.chr}:${t}-${e}`}}static fromLocusString(t){if("all"===t)return new Ac({chr:"all"});const e=t.split(":"),n=e[0],r=e[1].split("-"),i=Number.parseInt(r[0].replace(/,/g,""))-1,o=Number.parseInt(r[1].replace(/,/g,""));return new Ac({chr:n,start:i,end:o})}}
|
|
64
|
+
*/t.exports=function(t){return null!=t&&(n(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&n(t.slice(0,0))}(t)||!!t._isBuffer)}},function(t,e,n){var r,i=n(1),o=i(n(148)),s=i(n(76)),a=i(n(150)),c=i(n(37)),l=i(n(30)),h=i(n(31)),u=i(n(7)),f=i(n(10)),d=i(n(99)),p=i(n(16)),g=i(n(77)),m=i(n(59)),v=n(9),b=v.CramMalformedError,w=v.CramBufferOverrunError,y=v.CramArgumentError,x=n(58),k=x.parseItem,_=x.tinyMemoize,S=x.sequenceMD5,C=n(100),E=n(363);function A(t,e,n,r){if(!r)throw new b("could not resolve intra-slice mate pairs, file seems truncated or malformed");var i=!!(r.mate||void 0!==r.mateRecordNumber&&r.mateRecordNumber!==e);n.readName||(n.readName=String(n.uniqueId),r.readName=n.readName),n.mate={sequenceId:r.sequenceId,alignmentStart:r.alignmentStart,uniqueId:r.uniqueId},r.readName&&(n.mate.readName=r.readName),r.mate||void 0!==r.mateRecordNumber||(r.mate={sequenceId:n.sequenceId,alignmentStart:n.alignmentStart,uniqueId:n.uniqueId},n.readName&&(r.mate.readName=n.readName)),n.flags|=C.BAM_FPAIRED,(0,d.default)(r)&C.BAM_FUNMAP&&(n.flags|=C.BAM_FMUNMAP),(0,d.default)(n)&C.BAM_FUNMAP&&(r.flags|=C.BAM_FMUNMAP),(0,d.default)(r)&C.BAM_FREVERSE&&(n.flags|=C.BAM_FMREVERSE),(0,d.default)(n)&C.BAM_FREVERSE&&(r.flags|=C.BAM_FMREVERSE),void 0===n.templateLength&&(i?function(t,e,n){var r=function e(n){var r=[n];if(n.mateRecordNumber>=0){var i=t[n.mateRecordNumber];if(!i)throw new b("intra-slice mate record not found, this file seems malformed");r.push.apply(r,(0,m.default)(e(i)))}return r}(n),i=(0,g.default)(r).call(r,(function(t){return t.alignmentStart})),o=(0,g.default)(r).call(r,(function(t){return t.alignmentStart+t.readLength-1})),s=Math.max.apply(Math,(0,m.default)(o))-Math.min.apply(Math,(0,m.default)(i))+1;s>=0&&(0,p.default)(r).call(r,(function(t){if(void 0!==t.templateLength)throw new b("mate pair group has some members that have template lengths already, this file seems malformed");t.templateLength=s}))}(t,0,n):function(t,e){var n=Math.min(t.alignmentStart,e.alignmentStart),r=Math.max(t.alignmentStart+t.readLength-1,e.alignmentStart+e.readLength-1)-n+1;t.templateLength=r,e.templateLength=r}(n,r)),delete n.mateRecordNumber}var T=function(){function t(e,n){(0,u.default)(this,t),this.container=e,this.file=e.file,this.containerPosition=n}var e,n,r,i,d,m,v,x;return(0,f.default)(t,[{key:"getHeader",value:(x=(0,h.default)(l.default.mark((function t(){var e,n,r;return l.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.file.getSectionParsers();case 2:return e=t.sent,t.next=5,this.container.getHeader();case 5:return n=t.sent,t.next=8,this.file.readBlock(n._endPosition+this.containerPosition);case 8:if("MAPPED_SLICE_HEADER"!==(r=t.sent).contentType){t.next=13;break}r.content=k(r.content,e.cramMappedSliceHeader.parser,0,n._endPosition),t.next=18;break;case 13:if("UNMAPPED_SLICE_HEADER"!==r.contentType){t.next=17;break}r.content=k(r.content,e.cramUnmappedSliceHeader.parser,0,n._endPosition),t.next=18;break;case 17:throw new b("error reading slice header block, invalid content type ".concat(r._contentType));case 18:return t.abrupt("return",r);case 19:case"end":return t.stop()}}),t,this)}))),function(){return x.apply(this,arguments)})},{key:"getBlocks",value:(v=(0,h.default)(l.default.mark((function t(){var e,n,r,i;return l.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getHeader();case 2:e=t.sent,n=e._endPosition,r=new Array(e.content.numBlocks),i=0;case 6:if(!(i<r.length)){t.next=14;break}return t.next=9,this.file.readBlock(n);case 9:r[i]=t.sent,n=r[i]._endPosition;case 11:i+=1,t.next=6;break;case 14:return t.abrupt("return",r);case 15:case"end":return t.stop()}}),t,this)}))),function(){return v.apply(this,arguments)})},{key:"getCoreDataBlock",value:(m=(0,h.default)(l.default.mark((function t(){var e;return l.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getBlocks();case 2:return e=t.sent,t.abrupt("return",e[0]);case 4:case"end":return t.stop()}}),t,this)}))),function(){return m.apply(this,arguments)})},{key:"_getBlocksContentIdIndex",value:(d=(0,h.default)(l.default.mark((function t(){var e,n;return l.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getBlocks();case 2:return e=t.sent,n={},(0,p.default)(e).call(e,(function(t){"EXTERNAL_DATA"===t.contentType&&(n[t.contentId]=t)})),t.abrupt("return",n);case 6:case"end":return t.stop()}}),t,this)}))),function(){return d.apply(this,arguments)})},{key:"getBlockByContentId",value:(i=(0,h.default)(l.default.mark((function t(e){var n;return l.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getBlocksContentIdIndex();case 2:return n=t.sent,t.abrupt("return",n[e]);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"getReferenceRegion",value:(r=(0,h.default)(l.default.mark((function t(){var e,n,r,i;return l.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getHeader();case 2:if(!((e=t.sent.content).refSeqId<0)){t.next=5;break}return t.abrupt("return",void 0);case 5:return t.next=7,this.container.getCompressionScheme();case 7:if(n=t.sent,!(e.refBaseBlockId>=0)){t.next=15;break}if(r=this.getBlockByContentId(e.refBaseBlockId)){t.next=12;break}throw new b("embedded reference specified, but reference block does not exist");case 12:if(!(e.span>r.uncompressedSize)){t.next=14;break}throw new b("Embedded reference is too small");case 14:return t.abrupt("return",{seq:r.data.toString("utf8"),start:e.refSeqStart,end:e.refSeqStart+e.refSeqSpan-1,span:e.refSeqSpan});case 15:if(!n.referenceRequired&&!this.file.fetchReferenceSequenceCallback){t.next=24;break}if(this.file.fetchReferenceSequenceCallback){t.next=18;break}throw new Error("reference sequence not embedded, and seqFetch callback not provided, cannot fetch reference sequence");case 18:return t.next=20,this.file.fetchReferenceSequenceCallback(e.refSeqId,e.refSeqStart,e.refSeqStart+e.refSeqSpan-1);case 20:if((i=t.sent).length===e.refSeqSpan){t.next=23;break}throw new y("seqFetch callback returned a reference sequence of the wrong length");case 23:return t.abrupt("return",{seq:i,start:e.refSeqStart,end:e.refSeqStart+e.refSeqSpan-1,span:e.refSeqSpan});case 24:return t.abrupt("return",void 0);case 25:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"getAllRecords",value:function(){return this.getRecords((function(){return!0}))}},{key:"_fetchRecords",value:(n=(0,h.default)(l.default.mark((function t(){var e,n,r,i,o,s,h,u,f,d,p,m,v,y,x,k,_,C,T,L,M,R,I,N=this;return l.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.file.getDefinition();case 2:return e=t.sent,n=e.majorVersion,t.next=6,this.container.getCompressionScheme();case 6:return r=t.sent,t.next=9,this.getHeader();case 9:return i=t.sent,t.next=12,this._getBlocksContentIdIndex();case 12:if(o=t.sent,!(n>1&&this.file.options.checkSequenceMD5&&i.content.refSeqId>=0&&"0000000000000000"!==i.content.md5.join(""))){t.next=23;break}return t.next=16,this.getReferenceRegion();case 16:if(!(s=t.sent)){t.next=23;break}if(m=s.seq,v=s.start,y=s.end,x=S(m),k=(0,g.default)(h=i.content.md5).call(h,(function(t){return(t<16?"0":"")+t.toString(16)})).join(""),x===k){t.next=23;break}throw new b((0,c.default)(u=(0,c.default)(f=(0,c.default)(d=(0,c.default)(p="MD5 checksum reference mismatch for ref ".concat(i.content.refSeqId," pos ")).call(p,v,"..")).call(d,y,". recorded MD5: ")).call(f,k,", calculated MD5: ")).call(u,x));case 23:return t.next=25,this.getCoreDataBlock();case 25:_=t.sent,C={lastAlignmentStart:i.content.refSeqStart||0,coreBlock:{bitPosition:7,bytePosition:0},externalBlocks:{getCursor:function(t){return this[t]||(this[t]={bitPosition:7,bytePosition:0}),this[t]}}},T=function(t){var e=r.getCodecForDataSeries(t);if(!e)throw new b("no codec defined for ".concat(t," data series"));return e.decode(N,_,o,C)},L=new Array(i.content.numRecords),M=0;case 30:if(!(M<L.length)){t.next=48;break}t.prev=31,L[M]=E(this,T,r,i,_,o,C,n,M),L[M].uniqueId=i.contentPosition+i.content.recordCounter+M+1,t.next=45;break;case 36:if(t.prev=36,t.t0=t.catch(31),!(t.t0 instanceof w)){t.next=44;break}return console.warn("read attempted beyond end of buffer, file seems truncated."),L=(0,a.default)(L).call(L,(function(t){return!!t})),t.abrupt("break",48);case 44:throw t.t0;case 45:M+=1,t.next=30;break;case 48:for(R=0;R<L.length;R+=1)(I=L[R].mateRecordNumber)>=0&&A(L,R,L[R],L[I]);return t.abrupt("return",L);case 50:case"end":return t.stop()}}),t,this,[[31,36]])}))),function(){return n.apply(this,arguments)})},{key:"getRecords",value:(e=(0,h.default)(l.default.mark((function t(e){var n,r,i,c,u,f,d,p,m,v,b,w,y,x,k,_,S=this;return l.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.container.filePosition+this.containerPosition,(i=this.file.featureCache.get(r))||(i=this._fetchRecords(),this.file.featureCache.set(r,i)),t.t0=a.default,t.next=6,i;case 6:if(t.t1=n=t.sent,t.t2=n,t.t3=e,!(c=(0,t.t0)(t.t1).call(t.t2,t.t3)).length||!this.file.fetchReferenceSequenceCallback){t.next=24;break}return t.next=13,this.getHeader();case 13:if(!((u=t.sent).content.refSeqId>=0||-2===u.content.refSeqId)){t.next=24;break}return d=u.content.refSeqId>=0?u.content.refSeqId:void 0,t.next=18,this.container.getCompressionScheme();case 18:for(p=t.sent,m={},v=0;v<c.length;v+=1)b=void 0!==d?d:c[v].sequenceId,(w=m[b])||(w={id:b,start:c[v].alignmentStart,end:-1/0},m[b]=w),(y=c[v].alignmentStart+(c[v].lengthOnRef||c[v].readLength)-1)>w.end&&(w.end=y),c[v].alignmentStart<w.start&&(w.start=c[v].alignmentStart);return t.next=23,s.default.all((0,g.default)(f=(0,o.default)(m)).call(f,function(){var t=(0,h.default)(l.default.mark((function t(e){return l.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(-1!==e.id&&e.start<=e.end)){t.next=4;break}return t.next=3,S.file.fetchReferenceSequenceCallback(e.id,e.start,e.end);case 3:e.seq=t.sent;case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()));case 23:for(x=0;x<c.length;x+=1)k=void 0!==d?d:c[x].sequenceId,(_=m[k])&&_.seq&&c[x].addReferenceSequence(_,p);case 24:return t.abrupt("return",c);case 25:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})}]),t}();(0,p.default)(r="getHeader getBlocks _getBlocksContentIdIndex".split(" ")).call(r,(function(t){return _(T,t)})),t.exports=T},function(t,e,n){t.exports=n(336)},function(t,e,n){n(337);var r=n(3);t.exports=r.Object.values},function(t,e,n){var r=n(0),i=n(149).values;r({target:"Object",stat:!0},{values:function(t){return i(t)}})},function(t,e,n){t.exports=n(339)},function(t,e,n){var r=n(340),i=Array.prototype;t.exports=function(t){var e=t.filter;return t===i||t instanceof Array&&e===i.filter?r:e}},function(t,e,n){n(341);var r=n(18);t.exports=r("Array").filter},function(t,e,n){var r=n(0),i=n(45).filter;r({target:"Array",proto:!0,forced:!n(68)("filter")},{filter:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}})},function(t,e,n){t.exports=n(343)},function(t,e,n){var r=n(344),i=RegExp.prototype;t.exports=function(t){return!(t===i||t instanceof RegExp)||"flags"in t?t.flags:r(t)}},function(t,e,n){n(345);var r=n(346);t.exports=function(t){return r.call(t)}},function(t,e){},function(t,e,n){var r=n(2);t.exports=function(){var t=r(this),e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.dotAll&&(e+="s"),t.unicode&&(e+="u"),t.sticky&&(e+="y"),e}},function(t,e,n){t.exports=n(348)},function(t,e,n){var r=n(349),i=Array.prototype;t.exports=function(t){var e=t.map;return t===i||t instanceof Array&&e===i.map?r:e}},function(t,e,n){n(350);var r=n(18);t.exports=r("Array").map},function(t,e,n){var r=n(0),i=n(45).map;r({target:"Array",proto:!0,forced:!n(68)("map")},{map:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}})},function(t,e,n){var r=n(151);t.exports=function(t){if(r(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}},function(t,e,n){t.exports=n(353)},function(t,e,n){n(354);var r=n(3);t.exports=r.Array.isArray},function(t,e,n){n(0)({target:"Array",stat:!0},{isArray:n(53)})},function(t,e,n){t.exports=n(356)},function(t,e,n){t.exports=n(357)},function(t,e,n){n(46),n(358);var r=n(3);t.exports=r.Array.from},function(t,e,n){var r=n(0),i=n(359);r({target:"Array",stat:!0,forced:!n(121)((function(t){Array.from(t)}))},{from:i})},function(t,e,n){var r=n(15),i=n(22),o=n(120),s=n(119),a=n(29),c=n(87),l=n(90);t.exports=function(t){var e,n,h,u,f=i(t),d="function"==typeof this?this:Array,p=arguments.length,g=p>1?arguments[1]:void 0,m=void 0!==g,v=0,b=l(f);if(m&&(g=r(g,p>2?arguments[2]:void 0,2)),null==b||d==Array&&s(b))for(n=new d(e=a(f.length));e>v;v++)c(n,v,m?g(f[v],v):f[v]);else for(u=b.call(f),n=new d;!(h=u.next()).done;v++)c(n,v,m?o(u,g,[h.value,v],!0):h.value);return n.length=v,n}},function(t,e,n){n(41),n(46),t.exports=n(361)},function(t,e,n){var r=n(67),i=n(6),o=n(35),s=i("iterator");t.exports=function(t){var e=Object(t);return void 0!==e[s]||"@@iterator"in e||o.hasOwnProperty(r(e))}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}},function(t,e,n){(function(e){var r=n(1),i=r(n(37)),o=r(n(364)),s=r(n(16)),a=r(n(99)),c=r(n(101)),l=r(n(59)),h=r(n(154)),u=r(n(376)),f=r(n(380)),d=r(n(48)),p=r(n(387)),g=n(146),m=n(9),v=m.CramMalformedError,b=m.CramUnimplementedError,w=n(389),y=n(100);function x(t){var e=(0,p.default)(t).call(t,0);return-1===e?t.toString("utf8"):t.toString("utf8",0,e)}function k(t,n){if(n.readInt32LE||(n=e.from(n)),"Z"===t)return x(n);if("A"===t)return String.fromCharCode(n[0]);if("I"===t){var r=g.fromBytesLE(n);if(r.greaterThan(f.default)||r.lessThan(u.default))throw new b("integer overflow");return r.toNumber()}if("i"===t)return n.readInt32LE(0);if("s"===t)return n.readInt16LE(0);if("S"===t)return n.readUInt16LE(0);if("c"===t)return n.readInt8(0);if("C"===t)return n.readUInt8(0);if("f"===t)return n.readFloatLE(0);if("H"===t){var i=x(n);return(0,h.default)(i.replace(/^0x/,""),16)}if("B"===t)return function(t){var e=String.fromCharCode(t[0]),n=t.readInt32LE(1),r={c:["readInt8",1],C:["readUInt8",1],s:["readInt16LE",2],S:["readUInt16LE",2],i:["readInt32LE",4],I:["readUInt32LE",4],f:["readFloatLE",4]}[e];if(!r)throw new v("invalid tag value array type '".concat(e,"'"));for(var i=(0,d.default)(r,2),o=i[0],s=i[1],a=new Array(n),c=5,l=0;l<n;l+=1)a[l]=t[o](c),c+=s;return a}(n);throw new v("Unrecognized tag type ".concat(t))}function _(t){if(t instanceof e)return x(t);if(t.length&&(0,p.default)(t)){if(!t[t.length-1]){var n=(0,p.default)(t).call(t,0);return String.fromCharCode.apply(String,(0,l.default)((0,c.default)(t).call(t,0,n)))}return String.fromCharCode.apply(String,(0,l.default)(t))}return String(t)}t.exports=function(t,e,n,r,c,l,h,u,f){var p=new w;if(p.flags=e("BF"),p.cramFlags=e("CF"),u>1&&-2===r.content.refSeqId?p.sequenceId=e("RI"):p.sequenceId=r.content.refSeqId,p.readLength=e("RL"),p.alignmentStart=e("AP"),n.APdelta&&(p.alignmentStart+=h.lastAlignmentStart),h.lastAlignmentStart=p.alignmentStart,p.readGroupId=e("RG"),n.readNamesIncluded&&(p.readName=_(e("RN"))),p.isDetached()){var g={};g.flags=e("MF"),n.readNamesIncluded||(g.readName=_(e("RN")),p.readName=g.readName),g.sequenceId=e("NS"),g.alignmentStart=e("NP"),((0,a.default)(g)||g.sequenceId>-1)&&(p.mate=g),p.templateSize=e("TS"),(0,a.default)(g)&y.CRAM_M_UNMAP&&(p.flags|=y.BAM_FMUNMAP),(0,a.default)(g)&y.CRAM_M_REVERSE&&(p.flags|=y.BAM_FMREVERSE)}else p.hasMateDownStream()&&(p.mateRecordNumber=e("NF")+f+1);var m=e("TL");if(m<0)throw new v("invalid TL index");for(var b=n.getTagNames(m),x=b.length,S=0;S<x;S+=1){var C=b[S],E=C.substr(0,2),A=C.substr(2,1),T=n.getCodecForTag(C);if(!T)throw new v("no codec defined for auxiliary tag ".concat(C));var L=T.decode(t,c,l,h);p.tags[E]=k(A,L)}if(p.isSegmentUnmapped())if(p.isUnknownBases())p.readBases=null,p.qualityScores=null;else{for(var M=new Array(p.readLength),R=0;R<M.length;R+=1)M[R]=e("BA");if(p.readBases=String.fromCharCode.apply(String,M),p.isPreservingQualityScores()){for(var I=0;I<M.length;I+=1)M[I]=e("QS");p.qualityScores=M}}else{var N,P=e("FN");P&&(p.readFeatures=function(t,e,n,r,i){var o=0,s=t.alignmentStart-1,a=new Array(e);function c(t){var e=(0,d.default)(t,2),r=e[0],i=e[1],o=n(i);return"character"===r?String.fromCharCode(o):"string"===r?o.toString("utf8"):"numArray"===r?o.toArray():o}for(var l=0;l<e;l+=1){var h=String.fromCharCode(n("FC")),u=n("FP"),f={code:h},p={B:["character","BA"],S:["string",i>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"]}[h];if(!p)throw new v('invalid read feature code "'.concat(h,'"'));f.data=c(p);var g={B:["number","QS"]}[h];g&&(f.data=[f.data,c(g)]),o+=u,f.pos=o,s+=u,f.refPos=s,"D"===h||"N"===h?s+=f.data:"I"===h||"S"===h?s-=f.data.length:"i"===h&&(s-=1),a[l]=f}return a}(p,P,e,0,u));var O,F=p.readLength;if(p.readFeatures&&(0,s.default)(N=p.readFeatures).call(N,(function(t){var e=t.code,n=t.data;"D"===e||"N"===e?F+=n:"I"===e||"S"===e?F-=n.length:"i"===e&&(F-=1)})),(0,o.default)(F)&&(console.warn("".concat(p.readName||(0,i.default)(O="".concat(p.sequenceId,":")).call(O,p.alignmentStart)," record has invalid read features")),F=p.readLength),p.lengthOnRef=F,p.mappingQuality=e("MQ"),p.isPreservingQualityScores()){for(var D=new Array(p.readLength),B=0;B<D.length;B+=1)D[B]=e("QS");p.qualityScores=D}}return p}}).call(this,n(19).Buffer)},function(t,e,n){t.exports=n(365)},function(t,e,n){t.exports=n(366)},function(t,e,n){n(367);var r=n(3);t.exports=r.Number.isNaN},function(t,e,n){n(0)({target:"Number",stat:!0},{isNaN:function(t){return t!=t}})},function(t,e,n){t.exports=n(369)},function(t,e,n){var r=n(370),i=Array.prototype;t.exports=function(t){var e=t.slice;return t===i||t instanceof Array&&e===i.slice?r:e}},function(t,e,n){n(371);var r=n(18);t.exports=r("Array").slice},function(t,e,n){var r=n(0),i=n(14),o=n(53),s=n(84),a=n(29),c=n(28),l=n(87),h=n(68),u=n(6)("species"),f=[].slice,d=Math.max;r({target:"Array",proto:!0,forced:!h("slice")},{slice:function(t,e){var n,r,h,p=c(this),g=a(p.length),m=s(t,g),v=s(void 0===e?g:e,g);if(o(p)&&("function"!=typeof(n=p.constructor)||n!==Array&&!o(n.prototype)?i(n)&&null===(n=n[u])&&(n=void 0):n=void 0,n===Array||void 0===n))return f.call(p,m,v);for(r=new(void 0===n?Array:n)(d(v-m,0)),h=0;m<v;m++,h++)m in p&&l(r,h,p[m]);return r.length=h,r}})},function(t,e,n){t.exports=n(373)},function(t,e,n){n(374);var r=n(3);t.exports=r.Number.parseInt},function(t,e,n){var r=n(0),i=n(155);r({target:"Number",stat:!0,forced:Number.parseInt!=i},{parseInt:i})},function(t,e,n){var r=n(49),i="["+n(156)+"]",o=RegExp("^"+i+i+"*"),s=RegExp(i+i+"*$"),a=function(t){return function(e){var n=String(r(e));return 1&t&&(n=n.replace(o,"")),2&t&&(n=n.replace(s,"")),n}};t.exports={start:a(1),end:a(2),trim:a(3)}},function(t,e,n){t.exports=n(377)},function(t,e,n){t.exports=n(378)},function(t,e,n){n(379),t.exports=-9007199254740991},function(t,e,n){n(0)({target:"Number",stat:!0},{MIN_SAFE_INTEGER:-9007199254740991})},function(t,e,n){t.exports=n(381)},function(t,e,n){t.exports=n(382)},function(t,e,n){n(383),t.exports=9007199254740991},function(t,e,n){n(0)({target:"Number",stat:!0},{MAX_SAFE_INTEGER:9007199254740991})},function(t,e,n){var r=n(385),i=n(153);t.exports=function(t,e){if(i(Object(t))||"[object Arguments]"===Object.prototype.toString.call(t)){var n=[],o=!0,s=!1,a=void 0;try{for(var c,l=r(t);!(o=(c=l.next()).done)&&(n.push(c.value),!e||n.length!==e);o=!0);}catch(t){s=!0,a=t}finally{try{o||null==l.return||l.return()}finally{if(s)throw a}}return n}}},function(t,e,n){t.exports=n(386)},function(t,e,n){n(41),n(46),t.exports=n(142)},function(t,e,n){t.exports=n(388)},function(t,e,n){t.exports=n(143)},function(t,e,n){var r=n(1),i=r(n(98)),o=r(n(16)),s=r(n(99)),a=r(n(7)),c=r(n(10)),l=r(n(59)),h=n(100),u={a:0,A:0,c:1,C:1,g:2,G:2,t:3,T:3,n:4,N:4},f=function(){function t(){(0,a.default)(this,t),this.tags={}}return(0,c.default)(t,[{key:"isPaired",value:function(){return!!((0,s.default)(this)&h.BAM_FPAIRED)}},{key:"isProperlyPaired",value:function(){return!!((0,s.default)(this)&h.BAM_FPROPER_PAIR)}},{key:"isSegmentUnmapped",value:function(){return!!((0,s.default)(this)&h.BAM_FUNMAP)}},{key:"isMateUnmapped",value:function(){return!!((0,s.default)(this)&h.BAM_FMUNMAP)}},{key:"isReverseComplemented",value:function(){return!!((0,s.default)(this)&h.BAM_FREVERSE)}},{key:"isMateReverseComplemented",value:function(){return!!((0,s.default)(this)&h.BAM_FMREVERSE)}},{key:"isRead1",value:function(){return!!((0,s.default)(this)&h.BAM_FREAD1)}},{key:"isRead2",value:function(){return!!((0,s.default)(this)&h.BAM_FREAD2)}},{key:"isSecondary",value:function(){return!!((0,s.default)(this)&h.BAM_FSECONDARY)}},{key:"isFailedQc",value:function(){return!!((0,s.default)(this)&h.BAM_FQCFAIL)}},{key:"isDuplicate",value:function(){return!!((0,s.default)(this)&h.BAM_FDUP)}},{key:"isSupplementary",value:function(){return!!((0,s.default)(this)&h.BAM_FSUPPLEMENTARY)}},{key:"isDetached",value:function(){return!!(this.cramFlags&h.CRAM_FLAG_DETACHED)}},{key:"hasMateDownStream",value:function(){return!!(this.cramFlags&h.CRAM_FLAG_MATE_DOWNSTREAM)}},{key:"isPreservingQualityScores",value:function(){return!!(this.cramFlags&h.CRAM_FLAG_PRESERVE_QUAL_SCORES)}},{key:"isUnknownBases",value:function(){return!!(this.cramFlags&h.CRAM_FLAG_NO_SEQ)}},{key:"getReadBases",value:function(){return!this.readBases&&this._refRegion&&(this.readBases=function(t,e){if((t.lengthOnRef||t.readLength)&&!t.isUnknownBases()){var n=t.alignmentStart-e.start;if(!t.readFeatures)return e.seq.substr(n,t.lengthOnRef).toUpperCase();for(var r="",i=n,o=0;r.length<t.readLength;)if(o<t.readFeatures.length){var s=t.readFeatures[o];if("Q"===s.code||"q"===s.code)o+=1;else if(s.pos===r.length+1)if(o+=1,"b"===s.code){var a=s.data.split(","),c=String.fromCharCode.apply(String,(0,l.default)(a));r+=c,i+=c.length}else"B"===s.code?(r+=s.data[0],i+=1):"X"===s.code?(r+=s.sub,i+=1):"I"===s.code?r+=s.data:"D"===s.code?i+=s.data:"i"===s.code?r+=s.data:"N"===s.code?i+=s.data:"S"===s.code?r+=s.data:"P"===s.code||s.code;else if(o<t.readFeatures.length){var h=e.seq.substr(i,t.readFeatures[o].pos-r.length-1);r+=h,i+=h.length}}else{var u=e.seq.substr(i,t.readLength-r.length);r+=u,i+=u.length}return r.toUpperCase()}}(this,this._refRegion)),this.readBases}},{key:"getPairOrientation",value:function(){if(!this.isSegmentUnmapped()&&this.isPaired()&&!this.isMateUnmapped()&&this.mate&&this.sequenceId===this.mate.sequenceId){var t=this.isReverseComplemented()?"R":"F",e=this.isMateReverseComplemented()?"R":"F",n=" ",r=" ";this.isRead1()?(n="1",r="2"):this.isRead2()&&(n="2",r="1");var i=[],o=this.templateLength||this.templateSize;return this.alignmentStart>this.mate.alignmentStart&&o>0&&(o=-o),o>0?(i[0]=t,i[1]=n,i[2]=e,i[3]=r):(i[2]=t,i[3]=n,i[0]=e,i[1]=r),i.join("")}return null}},{key:"addReferenceSequence",value:function(t,e){var n;this.readFeatures&&(0,o.default)(n=this.readFeatures).call(n,(function(n){"X"===n.code&&function(t,e,n,r){if(e){var i=r.refPos-e.start,o=e.seq.charAt(i);o&&(r.ref=o);var s=u[o];void 0===s&&(s=4);var a=n.substitutionMatrix[s][r.data];a&&(r.sub=a)}}(0,t,e,n)})),!this.readBases&&t.start<=this.alignmentStart&&t.end>=this.alignmentStart+(this.lengthOnRef||this.readLength)-1&&(this._refRegion=t)}},{key:"toJSON",value:function(){var t,e=this,n={};return(0,o.default)(t=(0,i.default)(this)).call(t,(function(t){"_"!==t.charAt(0)&&(n[t]=e[t])})),n.readBases=this.getReadBases(),n}}]),t}();t.exports=f},function(t,e,n){var r=n(1),i=r(n(98)),o=r(n(16)),s=r(n(75)),a=r(n(7)),c=r(n(10)),l=n(9).CramMalformedError,h=n(391).instantiateCodec,u={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",TM:"ignore",TV:"ignore"},f=function(){function t(e){(0,a.default)(this,t),(0,s.default)(this,e),this.readNamesIncluded=e.preservation.RN,this.APdelta=e.preservation.AP,this.referenceRequired=!!e.preservation.RR,this.tagIdsDictionary=e.preservation.TD,this.substitutionMatrix=function(t){for(var e=new Array(5),n=0;n<5;n+=1)e[n]=new Array(4);return e[0][t[0]>>6&3]="C",e[0][t[0]>>4&3]="G",e[0][t[0]>>2&3]="T",e[0][t[0]>>0&3]="N",e[1][t[1]>>6&3]="A",e[1][t[1]>>4&3]="G",e[1][t[1]>>2&3]="T",e[1][t[1]>>0&3]="N",e[2][t[2]>>6&3]="A",e[2][t[2]>>4&3]="C",e[2][t[2]>>2&3]="T",e[2][t[2]>>0&3]="N",e[3][t[3]>>6&3]="A",e[3][t[3]>>4&3]="C",e[3][t[3]>>2&3]="G",e[3][t[3]>>0&3]="N",e[4][t[4]>>6&3]="A",e[4][t[4]>>4&3]="C",e[4][t[4]>>2&3]="G",e[4][t[4]>>0&3]="T",e}(e.preservation.SM),this.dataSeriesCodecCache={},this.tagCodecCache={}}return(0,c.default)(t,[{key:"getCodecForTag",value:function(t){if(!this.tagCodecCache[t]){var e=this.tagEncoding[t];e&&(this.tagCodecCache[t]=h(e,"byteArray"))}return this.tagCodecCache[t]}},{key:"getTagNames",value:function(t){return this.tagIdsDictionary[t]}},{key:"getCodecForDataSeries",value:function(t){if(!this.dataSeriesCodecCache[t]){var e=this.dataSeriesEncoding[t];if(e){var n=u[t];if(!n)throw new l("data series name ".concat(t," not defined in file compression header"));this.dataSeriesCodecCache[t]=h(e,n)}}return this.dataSeriesCodecCache[t]}},{key:"toJSON",value:function(){var t,e=this,n={};return(0,o.default)(t=(0,i.default)(this)).call(t,(function(t){/Cache$/.test(t)||(n[t]=e[t])})),n}}]),t}();t.exports=f},function(t,e,n){var r=n(9).CramUnimplementedError,i=n(392),o=n(413),s=n(414),a=n(415),c=n(416),l=n(417),h={1:o,3:i,4:a,5:s,6:c,7:n(418),9:l};function u(t){return h[t]}t.exports={getCodecClassWithId:u,instantiateCodec:function t(e,n){var i=u("ignore"===n?0:e.codecId);if(!i)throw new r("no codec implemented for codec ID ".concat(e.codecId));return new i(e.parameters,n,t)}}},function(t,e,n){var r=n(1),i=r(n(97)),o=r(n(59)),s=r(n(77)),a=r(n(148)),c=r(n(159)),l=r(n(48)),h=r(n(102)),u=r(n(16)),f=r(n(103)),d=r(n(403)),p=r(n(7)),g=r(n(10)),m=r(n(32)),v=r(n(27)),b=r(n(33)),w=n(9).CramMalformedError,y=function(t){function e(){var t,n,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;if((0,p.default)(this,e),n=(0,m.default)(this,(0,v.default)(e).call(this,r,i)),!(0,d.default)(t=["byte","int"]).call(t,n.dataType))throw new TypeError("".concat(n.dataType," decoding not yet implemented by HUFFMAN_INT codec"));return n.buildCodeBook(),n.buildCodes(),n.buildCaches(),0===n.sortedCodes[0].bitLength&&(n._decode=n._decodeZeroLengthCode),n}return(0,b.default)(e,t),(0,g.default)(e,[{key:"buildCodeBook",value:function(){for(var t=this,e=new Array(this.parameters.numCodes),n=0;n<this.parameters.numCodes;n+=1)e[n]={symbol:this.parameters.symbols[n],bitLength:this.parameters.bitLengths[n]};e=(0,f.default)(e).call(e,(function(t,e){return t.bitLength-e.bitLength||t.symbol-e.symbol})),this.codeBook={},(0,u.default)(e).call(e,(function(e){t.codeBook[e.bitLength]||(t.codeBook[e.bitLength]=[]),t.codeBook[e.bitLength].push(e.symbol)}))}},{key:"buildCodes",value:function(){var t,e=this;this.codes={};var n=0,r=-1;(0,u.default)(t=(0,h.default)(this.codeBook)).call(t,(function(t){var i=(0,l.default)(t,2),o=i[0],s=i[1];o=(0,c.default)(o,10),(0,u.default)(s).call(s,(function(t){var i={bitLength:o,value:t};r+=1;var s,a,c=o-n;if(r<<=c,i.bitCode=r,n+=c,16843009*((a=(858993459&(a=(s=r)-(s>>1)&1431655765))+(a>>2&858993459))+(a>>4)&252645135)>>24>o)throw new w("Symbol out of range");e.codes[t]=i}))}))}},{key:"buildCaches",value:function(){var t,e,n,r,c,l;this.sortedCodes=(0,f.default)(t=(0,a.default)(this.codes)).call(t,(function(t,e){return t.bitLength-e.bitLength||t.bitCode-e.bitCode})),this.sortedByValue=(0,f.default)(e=(0,a.default)(this.codes)).call(e,(function(t,e){return t.value-e.value})),this.sortedValuesByBitCode=(0,s.default)(n=this.sortedCodes).call(n,(function(t){return t.value})),this.sortedBitCodes=(0,s.default)(r=this.sortedCodes).call(r,(function(t){return t.bitCode})),this.sortedBitLengthsByBitCode=(0,s.default)(c=this.sortedCodes).call(c,(function(t){return t.bitLength}));var h=Math.max.apply(Math,(0,o.default)(this.sortedBitCodes));this.bitCodeToValue=(0,i.default)(l=new Array(h+1)).call(l,-1);for(var u=0;u<this.sortedBitCodes.length;u+=1)this.bitCodeToValue[this.sortedCodes[u].bitCode]=u}},{key:"decode",value:function(t,e,n,r){return this._decode(t,e,r.coreBlock)}},{key:"_decodeZeroLengthCode",value:function(){return this.sortedCodes[0].value}},{key:"_decode",value:function(t,e,n){for(var r=e.content,i=0,o=0,s=0;s<this.sortedCodes.length;s+=1){var a=this.sortedCodes[s].bitLength;o<<=a-i,o|=this._getBits(r,n,a-i),i=a;var c=this.bitCodeToValue[o];if(c>-1&&this.sortedBitLengthsByBitCode[c]===a)return this.sortedValuesByBitCode[c];for(var l=s;this.sortedCodes[l+1].bitLength===a&&l<this.sortedCodes.length;l+=1)s+=1}throw new w("Huffman symbol not found.")}}]),e}(n(40));t.exports=y},function(t,e,n){t.exports=n(394)},function(t,e,n){n(395);var r=n(3);t.exports=r.parseInt},function(t,e,n){var r=n(0),i=n(155);r({global:!0,forced:parseInt!=i},{parseInt:i})},function(t,e,n){t.exports=n(397)},function(t,e,n){n(398);var r=n(3);t.exports=r.Object.entries},function(t,e,n){var r=n(0),i=n(149).entries;r({target:"Object",stat:!0},{entries:function(t){return i(t)}})},function(t,e,n){t.exports=n(400)},function(t,e,n){var r=n(401),i=Array.prototype;t.exports=function(t){var e=t.sort;return t===i||t instanceof Array&&e===i.sort?r:e}},function(t,e,n){n(402);var r=n(18);t.exports=r("Array").sort},function(t,e,n){var r=n(0),i=n(5),o=n(22),s=n(12),a=n(54),c=[].sort,l=[1,2,3],h=s((function(){l.sort(void 0)})),u=s((function(){l.sort(null)})),f=a("sort");r({target:"Array",proto:!0,forced:h||!u||f},{sort:function(t){return void 0===t?c.call(o(this)):c.call(o(this),i(t))}})},function(t,e,n){t.exports=n(404)},function(t,e,n){t.exports=n(405)},function(t,e,n){var r=n(406),i=n(408),o=Array.prototype,s=String.prototype;t.exports=function(t){var e=t.includes;return t===o||t instanceof Array&&e===o.includes?r:"string"==typeof t||t===s||t instanceof String&&e===s.includes?i:e}},function(t,e,n){n(407);var r=n(18);t.exports=r("Array").includes},function(t,e,n){var r=n(0),i=n(82).includes,o=n(78);r({target:"Array",proto:!0},{includes:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}}),o("includes")},function(t,e,n){n(409);var r=n(18);t.exports=r("String").includes},function(t,e,n){var r=n(0),i=n(410),o=n(49);r({target:"String",proto:!0,forced:!n(412)("includes")},{includes:function(t){return!!~String(o(this)).indexOf(i(t),arguments.length>1?arguments[1]:void 0)}})},function(t,e,n){var r=n(411);t.exports=function(t){if(r(t))throw TypeError("The method doesn't accept regular expressions");return t}},function(t,e,n){var r=n(14),i=n(34),o=n(6)("match");t.exports=function(t){var e;return r(t)&&(void 0!==(e=t[o])?!!e:"RegExp"==i(t))}},function(t,e,n){var r=n(6)("match");t.exports=function(t){var e=/./;try{"/./"[t](e)}catch(n){try{return e[r]=!1,"/./"[t](e)}catch(t){}}return!1}},function(t,e,n){var r=n(1),i=r(n(48)),o=r(n(7)),s=r(n(10)),a=r(n(32)),c=r(n(27)),l=r(n(33)),h=n(9),u=h.CramUnimplementedError,f=h.CramMalformedError,d=h.CramBufferOverrunError,p=n(40),g=n(58).parseItf8,m=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if((0,o.default)(this,e),"int"===(t=(0,a.default)(this,(0,c.default)(e).call(this,n,r))).dataType)t._decodeData=t._decodeInt;else{if("byte"!==t.dataType)throw new u("".concat(t.dataType," decoding not yet implemented by EXTERNAL codec"));t._decodeData=t._decodeByte}return t}return(0,l.default)(e,t),(0,s.default)(e,[{key:"decode",value:function(t,e,n,r){var i=this.parameters.blockContentId,o=n[i];if(!o)throw new f("no block found with content ID ".concat(i));var s=r.externalBlocks.getCursor(i);return this._decodeData(o,s)}},{key:"_decodeInt",value:function(t,e){var n=g(t.content,e.bytePosition),r=(0,i.default)(n,2),o=r[0],s=r[1];return e.bytePosition+=s,o}},{key:"_decodeByte",value:function(t,e){if(e.bytePosition>=t.content.length)throw new d("attempted to read beyond end of block. this file seems truncated.");var n=t.content[e.bytePosition];return e.bytePosition+=1,n}}]),e}(p);t.exports=m},function(t,e,n){var r=n(1),i=r(n(101)),o=r(n(7)),s=r(n(10)),a=r(n(32)),c=r(n(27)),l=r(n(33)),h=n(9),u=h.CramBufferOverrunError,f=h.CramMalformedError,d=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if((0,o.default)(this,e),t=(0,a.default)(this,(0,c.default)(e).call(this,n,r)),"byteArray"!==r)throw new TypeError("byteArrayStop codec does not support data type ".concat(r));return t._decode=t._decodeByteArray,t}return(0,l.default)(e,t),(0,s.default)(e,[{key:"decode",value:function(t,e,n,r){var i=this.parameters.blockContentId,o=n[i];if(!o)throw new f("no block found with content ID ".concat(i));var s=r.externalBlocks.getCursor(i);return this._decode(o,s)}},{key:"_decodeByteArray",value:function(t,e){for(var n=t.content,r=this.parameters.stopByte,o=e.bytePosition,s=e.bytePosition;n[s]!==r&&s<n.length;){if(s===n.length)throw new u("byteArrayStop reading beyond length of data buffer?");s+=1}return e.bytePosition=s+1,(0,i.default)(n).call(n,o,s)}}]),e}(n(40));t.exports=d},function(t,e,n){var r,i=n(1),o=i(n(16)),s=i(n(7)),a=i(n(10)),c=i(n(32)),l=i(n(27)),h=i(n(33)),u=n(58).tinyMemoize,f=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2?arguments[2]:void 0;if((0,s.default)(this,e),(t=(0,c.default)(this,(0,l.default)(e).call(this,n,r))).instantiateCodec=i,"byteArray"!==r)throw new TypeError("byteArrayLength does not support data type ".concat(r));return t}return(0,h.default)(e,t),(0,a.default)(e,[{key:"decode",value:function(t,e,n,r){for(var i=this._getLengthCodec().decode(t,e,n,r),o=this._getDataCodec(),s=new Array(i),a=0;a<i;a+=1)s[a]=o.decode(t,e,n,r);return s}},{key:"_getLengthCodec",value:function(){var t=this.parameters.lengthsEncoding;return this.instantiateCodec(t,"int")}},{key:"_getDataCodec",value:function(){var t=this.parameters.valuesEncoding;return this.instantiateCodec(t,"byte")}}]),e}(n(40));(0,o.default)(r="_getLengthCodec _getDataCodec".split(" ")).call(r,(function(t){return u(f,t)})),t.exports=f},function(t,e,n){var r=n(1),i=r(n(7)),o=r(n(10)),s=r(n(32)),a=r(n(27)),c=r(n(33)),l=n(9).CramUnimplementedError,h=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if((0,i.default)(this,e),"int"!==(t=(0,s.default)(this,(0,a.default)(e).call(this,n,r))).dataType)throw new l("".concat(t.dataType," decoding not yet implemented by BETA codec"));return t}return(0,c.default)(e,t),(0,o.default)(e,[{key:"decode",value:function(t,e,n,r){return this._getBits(e.content,r.coreBlock,this.parameters.length)-this.parameters.offset}}]),e}(n(40));t.exports=h},function(t,e,n){var r=n(1),i=r(n(7)),o=r(n(10)),s=r(n(32)),a=r(n(27)),c=r(n(33)),l=n(9).CramUnimplementedError,h=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if((0,i.default)(this,e),"int"!==(t=(0,s.default)(this,(0,a.default)(e).call(this,n,r))).dataType)throw new l("".concat(t.dataType," decoding not yet implemented by GAMMA codec"));return t}return(0,c.default)(e,t),(0,o.default)(e,[{key:"decode",value:function(t,e,n,r){for(var i=1;0===this._getBits(e.content,r.coreBlock,1);)i+=1;return(this._getBits(e.content,r.coreBlock,i-1)|1<<i-1)-this.parameters.offset}}]),e}(n(40));t.exports=h},function(t,e,n){var r=n(1),i=r(n(7)),o=r(n(10)),s=r(n(32)),a=r(n(27)),c=r(n(33)),l=n(9).CramUnimplementedError,h=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if((0,i.default)(this,e),"int"!==(t=(0,s.default)(this,(0,a.default)(e).call(this,n,r))).dataType)throw new l("".concat(t.dataType," decoding not yet implemented by SUBEXP codec"));return t}return(0,c.default)(e,t),(0,o.default)(e,[{key:"decode",value:function(t,e,n,r){for(var i,o,s=0;this._getBits(e.content,r.coreBlock,1);)s+=1;return 0===s?(i=this.parameters.K,o=this._getBits(e.content,r.coreBlock,i)):o=1<<(i=s+this.parameters.K-1)|this._getBits(e.content,r.coreBlock,i),o-this.parameters.offset}}]),e}(n(40));t.exports=h},function(t,e,n){var r=n(420),i=n(422);function o(){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}e.parse=w,e.resolve=function(t,e){return w(t,!1,!0).resolve(e)},e.resolveObject=function(t,e){return t?w(t,!1,!0).resolveObject(e):e},e.format=function(t){return i.isString(t)&&(t=w(t)),t instanceof o?t.format():o.prototype.format.call(t)},e.Url=o;var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,c=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,l=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),h=["'"].concat(l),u=["%","/","?",";","#"].concat(h),f=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:!0,"javascript:":!0},m={javascript:!0,"javascript:":!0},v={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},b=n(423);function w(t,e,n){if(t&&i.isObject(t)&&t instanceof o)return t;var r=new o;return r.parse(t,e,n),r}o.prototype.parse=function(t,e,n){if(!i.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var o=t.indexOf("?"),a=-1!==o&&o<t.indexOf("#")?"?":"#",l=t.split(a);l[0]=l[0].replace(/\\/g,"/");var w=t=l.join(a);if(w=w.trim(),!n&&1===t.split("#").length){var y=c.exec(w);if(y)return this.path=w,this.href=w,this.pathname=y[1],y[2]?(this.search=y[2],this.query=e?b.parse(this.search.substr(1)):this.search.substr(1)):e&&(this.search="",this.query={}),this}var x=s.exec(w);if(x){var k=(x=x[0]).toLowerCase();this.protocol=k,w=w.substr(x.length)}if(n||x||w.match(/^\/\/[^@\/]+@[^@\/]+/)){var _="//"===w.substr(0,2);!_||x&&m[x]||(w=w.substr(2),this.slashes=!0)}if(!m[x]&&(_||x&&!v[x])){for(var S,C,E=-1,A=0;A<f.length;A++)-1!==(T=w.indexOf(f[A]))&&(-1===E||T<E)&&(E=T);for(-1!==(C=-1===E?w.lastIndexOf("@"):w.lastIndexOf("@",E))&&(S=w.slice(0,C),w=w.slice(C+1),this.auth=decodeURIComponent(S)),E=-1,A=0;A<u.length;A++){var T;-1!==(T=w.indexOf(u[A]))&&(-1===E||T<E)&&(E=T)}-1===E&&(E=w.length),this.host=w.slice(0,E),w=w.slice(E),this.parseHost(),this.hostname=this.hostname||"";var L="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!L)for(var M=this.hostname.split(/\./),R=(A=0,M.length);A<R;A++){var I=M[A];if(I&&!I.match(d)){for(var N="",P=0,O=I.length;P<O;P++)I.charCodeAt(P)>127?N+="x":N+=I[P];if(!N.match(d)){var F=M.slice(0,A),D=M.slice(A+1),B=I.match(p);B&&(F.push(B[1]),D.unshift(B[2])),D.length&&(w="/"+D.join(".")+w),this.hostname=F.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),L||(this.hostname=r.toASCII(this.hostname));var z=this.port?":"+this.port:"",H=this.hostname||"";this.host=H+z,this.href+=this.host,L&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==w[0]&&(w="/"+w))}if(!g[k])for(A=0,R=h.length;A<R;A++){var V=h[A];if(-1!==w.indexOf(V)){var j=encodeURIComponent(V);j===V&&(j=escape(V)),w=w.split(V).join(j)}}var U=w.indexOf("#");-1!==U&&(this.hash=w.substr(U),w=w.slice(0,U));var q=w.indexOf("?");if(-1!==q?(this.search=w.substr(q),this.query=w.substr(q+1),e&&(this.query=b.parse(this.query)),w=w.slice(0,q)):e&&(this.search="",this.query={}),w&&(this.pathname=w),v[k]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){z=this.pathname||"";var W=this.search||"";this.path=z+W}return this.href=this.format(),this},o.prototype.format=function(){var t=this.auth||"";t&&(t=(t=encodeURIComponent(t)).replace(/%3A/i,":"),t+="@");var e=this.protocol||"",n=this.pathname||"",r=this.hash||"",o=!1,s="";this.host?o=t+this.host:this.hostname&&(o=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(o+=":"+this.port)),this.query&&i.isObject(this.query)&&Object.keys(this.query).length&&(s=b.stringify(this.query));var a=this.search||s&&"?"+s||"";return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||v[e])&&!1!==o?(o="//"+(o||""),n&&"/"!==n.charAt(0)&&(n="/"+n)):o||(o=""),r&&"#"!==r.charAt(0)&&(r="#"+r),a&&"?"!==a.charAt(0)&&(a="?"+a),e+o+(n=n.replace(/[?#]/g,(function(t){return encodeURIComponent(t)})))+(a=a.replace("#","%23"))+r},o.prototype.resolve=function(t){return this.resolveObject(w(t,!1,!0)).format()},o.prototype.resolveObject=function(t){if(i.isString(t)){var e=new o;e.parse(t,!1,!0),t=e}for(var n=new o,r=Object.keys(this),s=0;s<r.length;s++){var a=r[s];n[a]=this[a]}if(n.hash=t.hash,""===t.href)return n.href=n.format(),n;if(t.slashes&&!t.protocol){for(var c=Object.keys(t),l=0;l<c.length;l++){var h=c[l];"protocol"!==h&&(n[h]=t[h])}return v[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=n.format(),n}if(t.protocol&&t.protocol!==n.protocol){if(!v[t.protocol]){for(var u=Object.keys(t),f=0;f<u.length;f++){var d=u[f];n[d]=t[d]}return n.href=n.format(),n}if(n.protocol=t.protocol,t.host||m[t.protocol])n.pathname=t.pathname;else{for(var p=(t.pathname||"").split("/");p.length&&!(t.host=p.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==p[0]&&p.unshift(""),p.length<2&&p.unshift(""),n.pathname=p.join("/")}if(n.search=t.search,n.query=t.query,n.host=t.host||"",n.auth=t.auth,n.hostname=t.hostname||t.host,n.port=t.port,n.pathname||n.search){var g=n.pathname||"",b=n.search||"";n.path=g+b}return n.slashes=n.slashes||t.slashes,n.href=n.format(),n}var w=n.pathname&&"/"===n.pathname.charAt(0),y=t.host||t.pathname&&"/"===t.pathname.charAt(0),x=y||w||n.host&&t.pathname,k=x,_=n.pathname&&n.pathname.split("/")||[],S=(p=t.pathname&&t.pathname.split("/")||[],n.protocol&&!v[n.protocol]);if(S&&(n.hostname="",n.port=null,n.host&&(""===_[0]?_[0]=n.host:_.unshift(n.host)),n.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===p[0]?p[0]=t.host:p.unshift(t.host)),t.host=null),x=x&&(""===p[0]||""===_[0])),y)n.host=t.host||""===t.host?t.host:n.host,n.hostname=t.hostname||""===t.hostname?t.hostname:n.hostname,n.search=t.search,n.query=t.query,_=p;else if(p.length)_||(_=[]),_.pop(),_=_.concat(p),n.search=t.search,n.query=t.query;else if(!i.isNullOrUndefined(t.search))return S&&(n.hostname=n.host=_.shift(),(L=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=L.shift(),n.host=n.hostname=L.shift())),n.search=t.search,n.query=t.query,i.isNull(n.pathname)&&i.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n;if(!_.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var C=_.slice(-1)[0],E=(n.host||t.host||_.length>1)&&("."===C||".."===C)||""===C,A=0,T=_.length;T>=0;T--)"."===(C=_[T])?_.splice(T,1):".."===C?(_.splice(T,1),A++):A&&(_.splice(T,1),A--);if(!x&&!k)for(;A--;A)_.unshift("..");!x||""===_[0]||_[0]&&"/"===_[0].charAt(0)||_.unshift(""),E&&"/"!==_.join("/").substr(-1)&&_.push("");var L,M=""===_[0]||_[0]&&"/"===_[0].charAt(0);return S&&(n.hostname=n.host=M?"":_.length?_.shift():"",(L=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=L.shift(),n.host=n.hostname=L.shift())),(x=x||n.host&&_.length)&&!M&&_.unshift(""),_.length?n.pathname=_.join("/"):(n.pathname=null,n.path=null),i.isNull(n.pathname)&&i.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=t.auth||n.auth,n.slashes=n.slashes||t.slashes,n.href=n.format(),n},o.prototype.parseHost=function(){var t=this.host,e=a.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},function(t,e,n){(function(t,r){var i;/*! https://mths.be/punycode v1.4.1 by @mathias */!function(o){e&&e.nodeType,t&&t.nodeType;var s="object"==typeof r&&r;s.global!==s&&s.window!==s&&s.self;var a,c=2147483647,l=36,h=/^xn--/,u=/[^\x20-\x7E]/,f=/[\x2E\u3002\uFF0E\uFF61]/g,d={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},p=Math.floor,g=String.fromCharCode;function m(t){throw new RangeError(d[t])}function v(t,e){for(var n=t.length,r=[];n--;)r[n]=e(t[n]);return r}function b(t,e){var n=t.split("@"),r="";return n.length>1&&(r=n[0]+"@",t=n[1]),r+v((t=t.replace(f,".")).split("."),e).join(".")}function w(t){for(var e,n,r=[],i=0,o=t.length;i<o;)(e=t.charCodeAt(i++))>=55296&&e<=56319&&i<o?56320==(64512&(n=t.charCodeAt(i++)))?r.push(((1023&e)<<10)+(1023&n)+65536):(r.push(e),i--):r.push(e);return r}function y(t){return v(t,(function(t){var e="";return t>65535&&(e+=g((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+g(t)})).join("")}function x(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function k(t,e,n){var r=0;for(t=n?p(t/700):t>>1,t+=p(t/e);t>455;r+=l)t=p(t/35);return p(r+36*t/(t+38))}function _(t){var e,n,r,i,o,s,a,h,u,f,d,g=[],v=t.length,b=0,w=128,x=72;for((n=t.lastIndexOf("-"))<0&&(n=0),r=0;r<n;++r)t.charCodeAt(r)>=128&&m("not-basic"),g.push(t.charCodeAt(r));for(i=n>0?n+1:0;i<v;){for(o=b,s=1,a=l;i>=v&&m("invalid-input"),((h=(d=t.charCodeAt(i++))-48<10?d-22:d-65<26?d-65:d-97<26?d-97:l)>=l||h>p((c-b)/s))&&m("overflow"),b+=h*s,!(h<(u=a<=x?1:a>=x+26?26:a-x));a+=l)s>p(c/(f=l-u))&&m("overflow"),s*=f;x=k(b-o,e=g.length+1,0==o),p(b/e)>c-w&&m("overflow"),w+=p(b/e),b%=e,g.splice(b++,0,w)}return y(g)}function S(t){var e,n,r,i,o,s,a,h,u,f,d,v,b,y,_,S=[];for(v=(t=w(t)).length,e=128,n=0,o=72,s=0;s<v;++s)(d=t[s])<128&&S.push(g(d));for(r=i=S.length,i&&S.push("-");r<v;){for(a=c,s=0;s<v;++s)(d=t[s])>=e&&d<a&&(a=d);for(a-e>p((c-n)/(b=r+1))&&m("overflow"),n+=(a-e)*b,e=a,s=0;s<v;++s)if((d=t[s])<e&&++n>c&&m("overflow"),d==e){for(h=n,u=l;!(h<(f=u<=o?1:u>=o+26?26:u-o));u+=l)_=h-f,y=l-f,S.push(g(x(f+_%y,0))),h=p(_/y);S.push(g(x(h,0))),o=k(n,b,r==i),n=0,++r}++n,++e}return S.join("")}a={version:"1.4.1",ucs2:{decode:w,encode:y},decode:_,encode:S,toASCII:function(t){return b(t,(function(t){return u.test(t)?"xn--"+S(t):t}))},toUnicode:function(t){return b(t,(function(t){return h.test(t)?_(t.slice(4).toLowerCase()):t}))}},void 0===(i=function(){return a}.call(e,n,e,t))||(t.exports=i)}()}).call(this,n(421)(t),n(23))},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,n){t.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},function(t,e,n){e.decode=e.parse=n(424),e.encode=e.stringify=n(425)},function(t,e,n){function r(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,e,n,o){e=e||"&",n=n||"=";var s={};if("string"!=typeof t||0===t.length)return s;var a=/\+/g;t=t.split(e);var c=1e3;o&&"number"==typeof o.maxKeys&&(c=o.maxKeys);var l=t.length;c>0&&l>c&&(l=c);for(var h=0;h<l;++h){var u,f,d,p,g=t[h].replace(a,"%20"),m=g.indexOf(n);m>=0?(u=g.substr(0,m),f=g.substr(m+1)):(u=g,f=""),d=decodeURIComponent(u),p=decodeURIComponent(f),r(s,d)?i(s[d])?s[d].push(p):s[d]=[s[d],p]:s[d]=p}return s};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},function(t,e,n){var r=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};t.exports=function(t,e,n,a){return e=e||"&",n=n||"=",null===t&&(t=void 0),"object"==typeof t?o(s(t),(function(s){var a=encodeURIComponent(r(s))+n;return i(t[s])?o(t[s],(function(t){return a+encodeURIComponent(r(t))})).join(e):a+encodeURIComponent(r(t[s]))})).join(e):a?encodeURIComponent(r(a))+n+encodeURIComponent(r(t)):""};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function o(t,e){if(t.map)return t.map(e);for(var n=[],r=0;r<t.length;r++)n.push(e(t[r],r));return n}var s=Object.keys||function(t){var e=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.push(n);return e}},function(t,e,n){(function(e){var r=n(1),i=r(n(30)),o=r(n(159)),s=r(n(37)),a=r(n(31)),c=r(n(7)),l=r(n(10)),h=n(427),u=n(428),f=function(){function t(e){var n=this;(0,c.default)(this,t),this.position=0,this.url=e,this.cache=new u({fetch:function(t,e){return n._fetch(t,e)}})}var n,r,f;return(0,l.default)(t,[{key:"_fetch",value:(f=(0,a.default)(i.default.mark((function t(n,r){var a,c,l,u,f,d;return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return c={},r<1/0?c.range=(0,s.default)(l="bytes=".concat(n,"-")).call(l,n+r):r===1/0&&0!==n&&(c.range="bytes=".concat(n,"-")),t.next=4,h(this.url,{method:"GET",headers:c,redirect:"follow",mode:"cors"});case 4:if((200!==(u=t.sent).status||0!==n)&&206!==u.status){t.next=14;break}return t.t0=e,t.next=9,u.arrayBuffer();case 9:return t.t1=t.sent,f=t.t0.from.call(t.t0,t.t1),(d=/\/(\d+)$/.exec(u.headers.get("content-range")))[1]&&(this._stat={size:(0,o.default)(d[1],10)}),t.abrupt("return",f);case 14:throw new Error((0,s.default)(a="HTTP ".concat(u.status," fetching ")).call(a,this.url));case 15:case"end":return t.stop()}}),t,this)}))),function(t,e){return f.apply(this,arguments)})},{key:"read",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1/0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=r;return null===i&&(i=this.position,this.position+=n),this.cache.get(t,e,n,r)}},{key:"readFile",value:(r=(0,a.default)(i.default.mark((function t(){var n;return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,h(this.url,{method:"GET",redirect:"follow",mode:"cors"});case 2:return n=t.sent,t.t0=e,t.next=6,n.arrayBuffer();case 6:return t.t1=t.sent,t.abrupt("return",t.t0.from.call(t.t0,t.t1));case 8:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"stat",value:(n=(0,a.default)(i.default.mark((function t(){var n;return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._stat){t.next=6;break}return n=e.allocUnsafe(10),t.next=4,this.read(n,0,10,0);case 4:if(this._stat){t.next=6;break}throw new Error("unable to determine size of file at ".concat(this.url));case 6:return t.abrupt("return",this._stat);case 7:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})}]),t}();t.exports=f}).call(this,n(19).Buffer)},function(t,e){var n=function(t){function e(){this.fetch=!1,this.DOMException=t.DOMException}return e.prototype=t,new e}("undefined"!=typeof self?self:this);!function(t){!function(e){var n="URLSearchParams"in t,r="Symbol"in t&&"iterator"in Symbol,i="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),o="FormData"in t,s="ArrayBuffer"in t;if(s)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],c=ArrayBuffer.isView||function(t){return t&&a.indexOf(Object.prototype.toString.call(t))>-1};function l(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function h(t){return"string"!=typeof t&&(t=String(t)),t}function u(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return r&&(e[Symbol.iterator]=function(){return e}),e}function f(t){this.map={},t instanceof f?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function d(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function p(t){return new Promise((function(e,n){t.onload=function(){e(t.result)},t.onerror=function(){n(t.error)}}))}function g(t){var e=new FileReader,n=p(e);return e.readAsArrayBuffer(t),n}function m(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function v(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:i&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:o&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:n&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s&&i&&(e=t)&&DataView.prototype.isPrototypeOf(e)?(this._bodyArrayBuffer=m(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(t)||c(t))?this._bodyArrayBuffer=m(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):n&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var t=d(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?d(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(g)}),this.text=function(){var t,e,n,r=d(this);if(r)return r;if(this._bodyBlob)return t=this._bodyBlob,n=p(e=new FileReader),e.readAsText(t),n;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),n=new Array(e.length),r=0;r<e.length;r++)n[r]=String.fromCharCode(e[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o&&(this.formData=function(){return this.text().then(y)}),this.json=function(){return this.text().then(JSON.parse)},this}f.prototype.append=function(t,e){t=l(t),e=h(e);var n=this.map[t];this.map[t]=n?n+", "+e:e},f.prototype.delete=function(t){delete this.map[l(t)]},f.prototype.get=function(t){return t=l(t),this.has(t)?this.map[t]:null},f.prototype.has=function(t){return this.map.hasOwnProperty(l(t))},f.prototype.set=function(t,e){this.map[l(t)]=h(e)},f.prototype.forEach=function(t,e){for(var n in this.map)this.map.hasOwnProperty(n)&&t.call(e,this.map[n],n,this)},f.prototype.keys=function(){var t=[];return this.forEach((function(e,n){t.push(n)})),u(t)},f.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),u(t)},f.prototype.entries=function(){var t=[];return this.forEach((function(e,n){t.push([n,e])})),u(t)},r&&(f.prototype[Symbol.iterator]=f.prototype.entries);var b=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function w(t,e){var n,r,i=(e=e||{}).body;if(t instanceof w){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new f(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,i||null==t._bodyInit||(i=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new f(e.headers)),this.method=(r=(n=e.method||this.method||"GET").toUpperCase(),b.indexOf(r)>-1?r:n),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function y(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var n=t.split("="),r=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(r),decodeURIComponent(i))}})),e}function x(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new f(e.headers),this.url=e.url||"",this._initBody(t)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},v.call(w.prototype),v.call(x.prototype),x.prototype.clone=function(){return new x(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},x.error=function(){var t=new x(null,{status:0,statusText:""});return t.type="error",t};var k=[301,302,303,307,308];x.redirect=function(t,e){if(-1===k.indexOf(e))throw new RangeError("Invalid status code");return new x(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var n=Error(t);this.stack=n.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function _(t,n){return new Promise((function(r,o){var s=new w(t,n);if(s.signal&&s.signal.aborted)return o(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function c(){a.abort()}a.onload=function(){var t,e,n={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new f,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var n=t.split(":"),r=n.shift().trim();if(r){var i=n.join(":").trim();e.append(r,i)}})),e)};n.url="responseURL"in a?a.responseURL:n.headers.get("X-Request-URL");var i="response"in a?a.response:a.responseText;r(new x(i,n))},a.onerror=function(){o(new TypeError("Network request failed"))},a.ontimeout=function(){o(new TypeError("Network request failed"))},a.onabort=function(){o(new e.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&i&&(a.responseType="blob"),s.headers.forEach((function(t,e){a.setRequestHeader(e,t)})),s.signal&&(s.signal.addEventListener("abort",c),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",c)}),a.send(void 0===s._bodyInit?null:s._bodyInit)}))}_.polyfill=!0,t.fetch||(t.fetch=_,t.Headers=f,t.Request=w,t.Response=x),e.Headers=f,e.Request=w,e.Response=x,e.fetch=_}({})}(n),delete n.fetch.polyfill,(e=n.fetch).default=n.fetch,e.fetch=n.fetch,e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response,t.exports=e},function(t,e,n){var r=n(1),i=r(n(30)),o=r(n(16)),s=r(n(76)),a=r(n(31)),c=r(n(7)),l=r(n(10)),h=n(94),u=function(){function t(e){var n=e.fetch,r=e.size,i=void 0===r?1e7:r,o=e.chunkSize,s=void 0===o?32768:o;if((0,c.default)(this,t),!n)throw new Error("fetch function required");this.fetch=n,this.chunkSize=s,this.lruCache=new h({maxSize:Math.floor(i/s)})}var e;return(0,l.default)(t,[{key:"get",value:(e=(0,a.default)(i.default.mark((function t(e,n,r,a){var c,l,h,u,f,d,p,g=this;return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e.length<n+r)){t.next=2;break}throw new Error("output buffer not big enough for request");case 2:for(c=Math.floor(a/this.chunkSize),l=Math.floor((a+r)/this.chunkSize),h=new Array(l-c+1),u=function(t){h[t-c]=g._getChunk(t).then((function(e){return{data:e,chunkNumber:t}}))},f=c;f<=l;f+=1)u(f);return t.next=9,s.default.all(h);case 9:d=t.sent,p=a-d[0].chunkNumber*this.chunkSize,(0,o.default)(d).call(d,(function(t){var i=t.data,o=t.chunkNumber,s=o*g.chunkSize,h=0,u=g.chunkSize,f=n+(o-c)*g.chunkSize-p;o===c&&(f=n,h=p),o===l&&(u=a+r-s),i.copy(e,f,h,u)}));case 12:case"end":return t.stop()}}),t,this)}))),function(t,n,r,i){return e.apply(this,arguments)})},{key:"_getChunk",value:function(t){var e=this.lruCache.get(t);if(e)return e;var n=this.fetch(t*this.chunkSize,this.chunkSize);return this.lruCache.set(t,n),n}}]),t}();t.exports=u},function(t,e,n){var r=n(1),i=r(n(30)),o=r(n(31)),s=r(n(7)),a=r(n(10)),c=(n(161).promisify,null),l=function(){function t(e){(0,s.default)(this,t),this.position=0,this.filename=e,this.fd=c(this.filename,"r")}var e,n,r;return(0,a.default)(t,[{key:"read",value:(r=(0,o.default)(i.default.mark((function t(e){var n,r,o,s=arguments;return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=s.length>1&&void 0!==s[1]?s[1]:0,r=s.length>2?s[2]:void 0,null===(o=s.length>3?s[3]:void 0)&&(this.position,this.position+=r),t.t0=null,t.next=8,this.fd;case 8:return t.t1=t.sent,t.t2=e,t.t3=n,t.t4=r,t.t5=o,t.abrupt("return",(0,t.t0)(t.t1,t.t2,t.t3,t.t4,t.t5));case 14:case"end":return t.stop()}}),t,this)}))),function(t){return r.apply(this,arguments)})},{key:"readFile",value:(n=(0,o.default)(i.default.mark((function t(){return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=null,t.next=3,this.fd;case 3:return t.t1=t.sent,t.abrupt("return",(0,t.t0)(t.t1));case 5:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"stat",value:(e=(0,o.default)(i.default.mark((function t(){return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._stat){t.next=8;break}return t.t0=null,t.next=4,this.fd;case 4:return t.t1=t.sent,t.next=7,(0,t.t0)(t.t1);case 7:this._stat=t.sent;case 8:return t.abrupt("return",this._stat);case 9:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})}]),t}();t.exports=l},function(t,e,n){var r=n(1),i=r(n(48)),o=r(n(77)),s=r(n(101)),a=r(n(431)),c=r(n(16));t.exports={parseHeaderText:function(t){var e=t.split(/\r?\n/),n=[];return(0,c.default)(e).call(e,(function(t){var e=t.split(/\t/),r=(0,a.default)(e),c=r[0],l=(0,s.default)(r).call(r,1),h=(0,o.default)(l).call(l,(function(t){var e=t.split(":",2),n=(0,i.default)(e,2);return{tag:n[0],value:n[1]}}));c&&n.push({tag:c.substr(1),data:h})})),n}}},function(t,e,n){var r=n(157),i=n(152),o=n(158);t.exports=function(t){return r(t)||i(t)||o()}},function(t,e,n){var r=n(1),i=r(n(30)),o=r(n(103)),s=r(n(150)),a=r(n(48)),c=r(n(102)),l=r(n(16)),h=r(n(59)),u=r(n(76)),f=r(n(37)),d=r(n(77)),p=r(n(433)),g=r(n(31)),m=r(n(7)),v=r(n(10)),b=n(9),w=b.CramUnimplementedError,y=b.CramSizeLimitError,x=n(104),k=function(){function t(e){if((0,m.default)(this,t),e.cram?this.cram=e.cram:this.cram=new x({url:e.cramUrl,path:e.cramPath,filehandle:e.cramFilehandle,seqFetch:e.seqFetch,checkSequenceMD5:e.checkSequenceMD5,cacheSize:e.cacheSize}),!(this.cram instanceof x))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}var e;return(0,v.default)(t,[{key:"getRecordsForRange",value:(e=(0,g.default)(i.default.mark((function t(e,n,r){var g,m,v,b,x,k,_,S,C,E,A,T,L,M,R,I,N,P,O,F,D,B,z,H,V,j,U,q,W,$,G,Z,X,Y,K,Q=this,J=arguments;return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((k=J.length>3&&void 0!==J[3]?J[3]:{}).viewAsPairs=k.viewAsPairs||!1,k.pairAcrossChr=k.pairAcrossChr||!1,k.maxInsertSize=k.maxInsertSize||2e5,"string"!=typeof e){t.next=6;break}throw new w("string sequence names not yet supported");case 6:return _=e,t.next=9,this.index.getEntriesForRange(_,n,r);case 9:if(S=t.sent,!((C=(0,p.default)(g=(0,d.default)(S).call(S,(function(t){return t.sliceBytes}))).call(g,(function(t,e){return t+e}),0))>this.fetchSizeLimit)){t.next=13;break}throw new y((0,f.default)(m="data size of ".concat(C.toLocaleString()," bytes exceeded fetch size limit of ")).call(m,this.fetchSizeLimit.toLocaleString()," bytes"));case 13:return E=function(t){return t.sequenceId===e&&t.alignmentStart<=r&&t.alignmentStart+t.lengthOnRef-1>=n},t.next=16,u.default.all((0,d.default)(S).call(S,(function(t){return Q.getRecordsInSlice(t,E)})));case 16:if(A=t.sent,T=(b=(0,f.default)(v=Array.prototype)).call.apply(b,(0,f.default)(x=[v]).call(x,(0,h.default)(A))),!k.viewAsPairs){t.next=42;break}for(I={},N={},P=0;P<T.length;P+=1)O=T[P].readName,F=T[P].uniqueId,I[O]||(I[O]=0),I[O]+=1,N[F]=1;for(D={},(0,l.default)(L=(0,c.default)(I)).call(L,(function(t){var e=(0,a.default)(t,2),n=e[0];1===e[1]&&(D[n]=!0)})),B=[],z=0;z<T.length;z+=1)H=T[z].readName,D[H]&&T[z].mate&&(T[z].mate.sequenceId===_||k.pairAcrossChr)&&Math.abs(T[z].alignmentStart-T[z].mate.alignmentStart)<k.maxInsertSize&&(V=this.index.getEntriesForRange(T[z].mate.sequenceId,T[z].mate.alignmentStart,T[z].mate.alignmentStart+1),B.push(V));return t.next=28,u.default.all(B);case 28:for(j=t.sent,U=[],q=0;q<j.length;q+=1)(W=U).push.apply(W,(0,h.default)(j[q]));if(U=(0,s.default)(M=(0,o.default)(U).call(U,(function(t,e){return t.toString().localeCompare(e.toString())}))).call(M,(function(t,e,n){return!e||t.toString()!==n[e-1].toString()})),$=[],G=[],!((Z=(0,p.default)(R=(0,d.default)(U).call(U,(function(t){return t.sliceBytes}))).call(R,(function(t,e){return t+e}),0))>this.fetchSizeLimit)){t.next=37;break}throw new Error((0,f.default)(X="mate data size of ".concat(Z.toLocaleString()," bytes exceeded fetch size limit of ")).call(X,this.fetchSizeLimit.toLocaleString()," bytes"));case 37:return(0,l.default)(U).call(U,(function(t){var e=Q.cram.featureCache.get(t.toString());e||(e=Q.getRecordsInSlice(t,(function(){return!0})),Q.cram.featureCache.set(t.toString(),e)),$.push(e);var n=e.then((function(t){for(var e=[],n=0;n<t.length;n+=1){var r=t[n];D[r.readName]&&!N[r.uniqueId]&&e.push(r)}return e}));G.push(n)})),t.next=40,u.default.all(G);case 40:(Y=t.sent).length&&(K=(0,p.default)(Y).call(Y,(function(t,e){return(0,f.default)(t).call(t,e)})),T=(0,f.default)(T).call(T,K));case 42:return t.abrupt("return",T);case 43:case"end":return t.stop()}}),t,this)}))),function(t,n,r){return e.apply(this,arguments)})},{key:"getRecordsInSlice",value:function(t,e){var n=t.containerStart,r=t.sliceStart,i=t.sliceBytes;return this.cram.getContainerAtPosition(n).getSlice(r,i).getRecords(e)}},{key:"hasDataForReferenceSequence",value:function(t){return this.index.hasDataForReferenceSequence(t)}}]),t}();t.exports=k},function(t,e,n){t.exports=n(434)},function(t,e,n){t.exports=n(435)},function(t,e,n){var r=n(436),i=Array.prototype;t.exports=function(t){var e=t.reduce;return t===i||t instanceof Array&&e===i.reduce?r:e}},function(t,e,n){n(437);var r=n(18);t.exports=r("Array").reduce},function(t,e,n){var r=n(0),i=n(438).left;r({target:"Array",proto:!0,forced:n(54)("reduce")},{reduce:function(t){return i(this,t,arguments.length,arguments.length>1?arguments[1]:void 0)}})},function(t,e,n){var r=n(5),i=n(22),o=n(60),s=n(29),a=function(t){return function(e,n,a,c){r(n);var l=i(e),h=o(l),u=s(l.length),f=t?u-1:0,d=t?-1:1;if(a<2)for(;;){if(f in h){c=h[f],f+=d;break}if(f+=d,t?f<0:u<=f)throw TypeError("Reduce of empty array with no initial value")}for(;t?f>=0:u>f;f+=d)f in h&&(c=n(c,h[f],f,l));return c}};t.exports={left:a(!1),right:a(!0)}},function(t,e,n){var r=n(1),i=r(n(30)),o=r(n(31)),s=r(n(103)),a=r(n(102)),c=r(n(16)),l=r(n(154)),h=r(n(440)),u=r(n(48)),f=r(n(442)),d=r(n(37)),p=r(n(75)),g=r(n(7)),m=r(n(10)),v=n(447).default,b=n(94),w=(0,n(161).promisify)(n(126).gunzip),y=n(160).open,x=n(9).CramMalformedError,k=function(){function t(e){(0,g.default)(this,t),(0,p.default)(this,e)}return(0,m.default)(t,[{key:"toString",value:function(){var t,e,n,r;return(0,d.default)(t=(0,d.default)(e=(0,d.default)(n=(0,d.default)(r="".concat(this.start,":")).call(r,this.span,":")).call(n,this.containerStart,":")).call(e,this.sliceStart,":")).call(t,this.sliceBytes)}}]),t}();function _(t,e){if((0,f.default)(e).call(e,(function(t){return void 0===t})))throw new x("invalid .crai index file");var n=(0,u.default)(e,6),r=n[0],i=n[1],o=n[2],s=n[3],a=n[4],c=n[5];t[r]||(t[r]=[]),t[r].push(new k({start:i,span:o,containerStart:s,sliceStart:a,sliceBytes:c}))}var S=function(){function t(e){var n,r=this;(0,g.default)(this,t);var i=y(e.url,e.path,e.filehandle);this._parseCache=new v({cache:new b({maxSize:1}),fill:function(t,e){return r.parseIndex({signal:e})}}),this.readFile=(0,h.default)(n=i.readFile).call(n,i)}var e,n;return(0,m.default)(t,[{key:"parseIndex",value:function(){var t={};return this.readFile().then((function(t){return 31===t[0]&&139===t[1]?w(t):t})).then((function(e){var n;if(e.length>4&&21578050===e.readUInt32LE(0))throw new x("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");for(var r=[],i="",o=0;o<e.length;o+=1){var h=e[o];if(h>=48&&h<=57||!i&&45===h)i+=String.fromCharCode(h);else if(9===h)r.push((0,l.default)(i,10)),i="";else if(10===h)r.push((0,l.default)(i,10)),i="",_(t,r),r=[];else if(13!==h&&32!==h)throw new x("invalid .crai index file")}return i&&r.push((0,l.default)(i,10)),6===r.length&&_(t,r),(0,c.default)(n=(0,a.default)(t)).call(n,(function(e){var n=(0,u.default)(e,2),r=n[0],i=n[1];t[r]=(0,s.default)(i).call(i,(function(t,e){return t.start-e.start||t.span-e.span}))})),t}))}},{key:"getIndex",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._parseCache.get("index",null,t.signal)}},{key:"hasDataForReferenceSequence",value:(n=(0,o.default)(i.default.mark((function t(e){return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getIndex();case 2:return t.t0=e,t.abrupt("return",!!t.sent[t.t0]);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return n.apply(this,arguments)})},{key:"getEntriesForRange",value:(e=(0,o.default)(i.default.mark((function t(e,n,r){var o,s,a,c;return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getIndex();case 2:if(t.t0=e,o=t.sent[t.t0]){t.next=6;break}return t.abrupt("return",[]);case 6:for(s=function(t){var e=t.start,i=t.start+t.span;return e>=r?-1:i<=n?1:0},a=[],c=0;c<o.length;c+=1)0===s(o[c])&&a.push(o[c]);return t.abrupt("return",a);case 10:case"end":return t.stop()}}),t,this)}))),function(t,n,r){return e.apply(this,arguments)})}]),t}();t.exports=S},function(t,e,n){t.exports=n(441)},function(t,e,n){t.exports=n(144)},function(t,e,n){t.exports=n(443)},function(t,e,n){t.exports=n(444)},function(t,e,n){var r=n(445),i=Array.prototype;t.exports=function(t){var e=t.some;return t===i||t instanceof Array&&e===i.some?r:e}},function(t,e,n){n(446);var r=n(18);t.exports=r("Array").some},function(t,e,n){var r=n(0),i=n(45).some;r({target:"Array",proto:!0,forced:n(54)("some")},{some:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}})},function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var i=r(n(448));e.default=i.default},function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var i=n(162),o=r(n(450)),s=function(){function t(t){var e=t.fill,n=t.cache;if("function"!=typeof e)throw new TypeError("must pass a fill function");if("object"!=typeof n)throw new TypeError("must pass a cache object");if("function"!=typeof n.get||"function"!=typeof n.set||"function"!=typeof n.delete)throw new TypeError("cache must implement get(key), set(key, val), and and delete(key)");this.cache=n,this.fillCallback=e}return t.isAbortException=function(t){return"AbortError"===t.name||"ERR_ABORTED"===t.code||"AbortError: aborted"===t.message||"Error: aborted"===t.message},t.prototype.evict=function(t,e){this.cache.get(t)===e&&this.cache.delete(t)},t.prototype.fill=function(t,e,n){var r=this,i=new o.default,s={aborter:i,promise:this.fillCallback(e,i.signal),settled:!1,get aborted(){return this.aborter.signal.aborted}};s.aborter.addSignal(n),s.aborter.signal.addEventListener("abort",(function(){r.evict(t,s)})),s.promise.then((function(){s.settled=!0}),(function(e){s.settled=!0,r.evict(t,s)})).catch((function(t){throw console.error(t),t})),this.cache.set(t,s)},t.checkSinglePromise=function(t,e){function n(){if(e&&e.aborted)throw Object.assign(new Error("aborted"),{code:"ERR_ABORTED"})}return t.then((function(t){return n(),t}),(function(t){throw n(),t}))},t.prototype.has=function(t){return this.cache.has(t)},t.prototype.get=function(e,n,r){if(!r&&n instanceof i.AbortSignal)throw new TypeError("second get argument appears to be an AbortSignal, perhaps you meant to pass `null` for the fill data?");var o=this.cache.get(e);return o?o.aborted?(this.evict(e,o),this.get(e,n,r)):o.settled?o.promise:(o.aborter.addSignal(r),t.checkSinglePromise(o.promise,r)):(this.fill(e,n,r),t.checkSinglePromise(this.cache.get(e).promise,r))},t.prototype.delete=function(t){var e=this.cache.get(t);e&&(e.settled||e.aborter.abort(),this.cache.delete(t))},t.prototype.clear=function(){for(var t=this.cache.keys(),e=0,n=t.next();!n.done;n=t.next())this.delete(n.value),e+=1;return e},t}();e.default=s},function(t,e,n){function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function o(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),t}function s(t){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function a(t,e){return(a=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function l(t,e,n){return(l="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=s(t)););return t}(t,e);if(r){var i=Object.getOwnPropertyDescriptor(r,e);return i.get?i.get.call(n):i.value}})(t,e,n||t)}Object.defineProperty(e,"__esModule",{value:!0});var h=function(){function t(){r(this,t),Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}return o(t,[{key:"addEventListener",value:function(t,e){t in this.listeners||(this.listeners[t]=[]),this.listeners[t].push(e)}},{key:"removeEventListener",value:function(t,e){if(t in this.listeners)for(var n=this.listeners[t],r=0,i=n.length;r<i;r++)if(n[r]===e)return void n.splice(r,1)}},{key:"dispatchEvent",value:function(t){var e=this;if(t.type in this.listeners){for(var n=function(n){setTimeout((function(){return n.call(e,t)}))},r=this.listeners[t.type],i=0,o=r.length;i<o;i++)n(r[i]);return!t.defaultPrevented}}}]),t}(),u=function(t){function e(){var t;return r(this,e),(t=function(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?c(t):e}(this,s(e).call(this))).listeners||h.call(c(t)),Object.defineProperty(c(t),"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(c(t),"onabort",{value:null,writable:!0,configurable:!0}),t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&a(t,e)}(e,t),o(e,[{key:"toString",value:function(){return"[object AbortSignal]"}},{key:"dispatchEvent",value:function(t){"abort"===t.type&&(this.aborted=!0,"function"==typeof this.onabort&&this.onabort.call(this,t)),l(s(e.prototype),"dispatchEvent",this).call(this,t)}}]),e}(h),f=function(){function t(){r(this,t),Object.defineProperty(this,"signal",{value:new u,writable:!0,configurable:!0})}return o(t,[{key:"abort",value:function(){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}}this.signal.dispatchEvent(t)}},{key:"toString",value:function(){return"[object AbortController]"}}]),t}();"undefined"!=typeof Symbol&&Symbol.toStringTag&&(f.prototype[Symbol.toStringTag]="AbortController",u.prototype[Symbol.toStringTag]="AbortSignal"),e.AbortController=f,e.AbortSignal=u,e.abortableFetch=function(t){"function"==typeof t&&(t={fetch:t});var e=t,n=e.fetch,r=e.Request,i=void 0===r?n.Request:r,o=e.AbortController,s=e.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL,a=void 0!==s&&s;if(!function(t){return t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):"function"==typeof t.Request&&!t.Request.prototype.hasOwnProperty("signal")||!t.AbortController}({fetch:n,Request:i,AbortController:o,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:a}))return{fetch:n,Request:c};var c=i;(c&&!c.prototype.hasOwnProperty("signal")||a)&&((c=function(t,e){var n;e&&e.signal&&(n=e.signal,delete e.signal);var r=new i(t,e);return n&&Object.defineProperty(r,"signal",{writable:!1,enumerable:!1,configurable:!0,value:n}),r}).prototype=i.prototype);var l=n;return{fetch:function(t,e){var n=c&&c.prototype.isPrototypeOf(t)?t.signal:e?e.signal:void 0;if(n){var r;try{r=new DOMException("Aborted","AbortError")}catch(t){(r=new Error("Aborted")).name="AbortError"}if(n.aborted)return Promise.reject(r);var i=new Promise((function(t,e){n.addEventListener("abort",(function(){return e(r)}),{once:!0})}));return e&&e.signal&&delete e.signal,Promise.race([i,l(t,e)])}return l(t,e)},Request:c}}},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0});var r=n(162),i=function(){},o=function(){function t(){this.signals=new Set,this.abortController=new r.AbortController}return t.prototype.addSignal=function(t){var e=this;if(void 0===t&&(t=new i),this.signal.aborted)throw new Error("cannot add a signal, already aborted!");this.signals.add(t),t.aborted?this.handleAborted(t):"function"==typeof t.addEventListener&&t.addEventListener("abort",(function(){e.handleAborted(t)}))},t.prototype.handleAborted=function(t){this.signals.delete(t),0===this.signals.size&&this.abortController.abort()},Object.defineProperty(t.prototype,"signal",{get:function(){return this.abortController.signal},enumerable:!0,configurable:!0}),t.prototype.abort=function(){this.abortController.abort()},t}();e.default=o}]);class ac{constructor(t,e,n){this.config=t,this.browser=n,this.genome=e,this.cramFile=new sc.CramFile({filehandle:new cc(t.url,t),seqFetch:t.seqFetch||function(t,e,n){const r=this.genome.sequence,i=this.genome;return this.getHeader().then((function(o){const s=i.getChromosomeName(o.chrNames[t]);return r.getSequence(s,e-1,n)}))}.bind(this),checkSequenceMD5:void 0===t.checkSequenceMD5||t.checkSequenceMD5});const r=new cc(t.indexURL,t);this.indexedCramFile=new sc.IndexedCramFile({cram:this.cramFile,index:new sc.CraiIndex({filehandle:r}),fetchSizeLimit:3e7}),za.setReaderDefaults(this,t)}async getHeader(){if(!this.header){const t=this.genome,e=await this.cramFile.getSamHeader(),n={},r=[],i={},o=[];for(let s of e)if("SQ"===s.tag){for(let e of s.data)if("SN"===e.tag){const o=e.value;if(n[o]=r.length,r.push(o),t){i[t.getChromosomeName(o)]=o}break}}else"RG"===s.tag&&o.push(s.data);this.header={chrNames:r,chrToIndex:n,chrAliasTable:i,readGroups:o}}return this.header}async readAlignments(t,e,n){this.browser;const r=await this.getHeader(),i=r.chrAliasTable.hasOwnProperty(t)?r.chrAliasTable[t]:t,o=r.chrToIndex[i],s=new ba(t,e,n,this.config);if(void 0===o)return s;try{const t=await this.indexedCramFile.getRecordsForRange(o,e,n);for(let i of t){const t=i.sequenceId,c=i.alignmentStart,l=c+i.lengthOnRef;if(t<0)continue;if(t>o||c>n)return;if(t<o)continue;if(l<e)continue;const h=a(i,r.chrNames);this.filter.pass(h)&&s.push(h)}return s.finish(),s}catch(t){let e=t.message;throw e&&e.indexOf("MD5")>=0&&(e="Sequence mismatch. Is this the correct genome for the loaded CRAM?"),Qo.presentAlert(new Error(e)),t}function a(t,e){const n=new Ea;if(n.chr=e[t.sequenceId],n.start=t.alignmentStart-1,n.lengthOnRef=t.lengthOnRef,n.flags=t.flags,n.strand=!(16&t.flags),n.fragmentLength=t.templateLength||t.templateSize,n.mq=t.mappingQuality,n.end=t.alignmentStart+t.lengthOnRef,n.readGroupId=t.readGroupId,t.mate&&void 0!==t.mate.sequenceId){const r=void 0!==t.mate.flags?!(1&t.mate.flags):!(32&t.flags);n.mate={chr:e[t.mate.sequenceId],position:t.mate.alignmentStart,strand:r}}return n.seq=t.getReadBases(),n.qual=t.qualityScores,n.tagDict=t.tags,n.readName=t.readName,function(t,e){const n=[];let r,i,o=0,s="";if(e.scStart=e.start,e.scLengthOnRef=e.lengthOnRef,t.readFeatures)for(let a of t.readFeatures){const t=a.code,c=a.data,l=a.pos-1,h=a.refPos-1;switch(t){case"S":case"I":case"i":case"N":case"D":if(l>o){const t=l-o;n.push(new Pa({start:h-t,seqOffset:o,len:t,type:"M"})),o+=t,s+=t+"M"}if("S"===t){let r=h;e.scLengthOnRef+=c.length,0===l&&(e.scStart-=c.length,r-=c.length);const i=c.length;n.push(new Pa({start:r,seqOffset:o,len:i,type:"S"})),o+=i,s+=i+t}else if("I"===t||"i"===t){void 0===r&&(r=[]);const e="i"===t?1:c.length;r.push(new Pa({start:h,len:e,seqOffset:o,type:"I"})),o+=e,s+=e+t}else"D"!==t&&"N"!==t||(i||(i=[]),i.push({start:h,len:c,type:t}),s+=c+t);break;case"H":case"P":s+=c+t}}const a=t.readLength-o;a>0&&(n.push(new Pa({start:t.alignmentStart+t.lengthOnRef-a-1,seqOffset:o,len:a,type:"M"})),s+=a+"M");e.blocks=n,e.insertions=r,e.gaps=i,e.cigar=s}(t,n),n.mate&&n.start>n.mate.position&&n.fragmentLength>0&&(n.fragmentLength=-n.fragmentLength),za.setPairOrientation(n),n}}}class cc{constructor(t,e){this.position=0,this.url=t,this.config=e,this.cache=new lc({fetch:(t,e)=>this._fetch(t,e)})}async _fetch(t,e){const n={start:t,size:e};this._stat={size:void 0};const r=await go.loadArrayBuffer(this.url,gs(this.config,{range:n}));return Buffer.from(r)}async read(t,e=0,n=1/0,r=0){let i=r;return null===r&&(i=this.position,this.position+=n),this.cache.get(t,e,n,r)}async readFile(){const t=await go.loadArrayBuffer(this.url,gs(this.config));return Buffer.from(t)}async stat(){if(!this._stat){const t=Buffer.allocUnsafe(10);if(await this.read(t,0,10,0),!this._stat)throw new Error(`unable to determine size of file at ${this.url}`)}return this._stat}}class lc{constructor({fetch:t,size:e=1e7,chunkSize:n=32768}){this.fetch=t,this.chunkSize=n,this.lruCache=new hc({maxSize:Math.floor(e/n)})}async get(t,e,n,r){if(t.length<e+n)throw new Error("output buffer not big enough for request");const i=Math.floor(r/this.chunkSize),o=Math.floor((r+n)/this.chunkSize),s=new Array(o-i+1);for(let t=i;t<=o;t+=1)s[t-i]=this._getChunk(t).then((e=>({data:e,chunkNumber:t})));const a=await Promise.all(s),c=r-a[0].chunkNumber*this.chunkSize;a.forEach((({data:s,chunkNumber:a})=>{const l=a*this.chunkSize;let h=0,u=this.chunkSize,f=e+(a-i)*this.chunkSize-c;a===i&&(f=e,h=c),a===o&&(u=r+n-l),s.copy(t,f,h,u)}))}_getChunk(t){const e=this.lruCache.get(t);if(e)return e;const n=this.fetch(t*this.chunkSize,this.chunkSize);return this.lruCache.set(t,n),n}}class hc{constructor(t={}){if(!(t.maxSize&&t.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=t.maxSize,this.cache=new Map,this.oldCache=new Map,this._size=0}_set(t,e){this.cache.set(t,e),this._size++,this._size>=this.maxSize&&(this._size=0,this.oldCache=this.cache,this.cache=new Map)}get(t){if(this.cache.has(t))return this.cache.get(t);if(this.oldCache.has(t)){const e=this.oldCache.get(t);return this._set(t,e),e}}set(t,e){return this.cache.has(t)?this.cache.set(t,e):this._set(t,e),this}has(t){return this.cache.has(t)||this.oldCache.has(t)}peek(t){return this.cache.has(t)?this.cache.get(t):this.oldCache.has(t)?this.oldCache.get(t):void 0}delete(t){const e=this.cache.delete(t);return e&&this._size--,this.oldCache.delete(t)||e}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}*keys(){for(const[t]of this)yield t}*values(){for(const[,t]of this)yield t}*[Symbol.iterator](){for(const t of this.cache)yield t;for(const t of this.oldCache){const[e]=t;this.cache.has(e)||(yield t)}}get size(){let t=0;for(const e of this.oldCache.keys())this.cache.has(e)||t++;return this._size+t}}const uc=go.apiKey;function fc(t){var e=t.url+"/"+t.entity+"/"+t.entityId;return t.headers={"Cache-Control":"no-cache"},go.loadJson(e,t)}function dc(t){return new Promise((function(e,n){var r=t.results?t.results:[],i=t.url,o=t.body,s=t.decode,a="?",c=t.fields;return uc&&(i=i+a+"key="+uc,a="&"),c&&(i=i+a+"fields="+c),function t(a){a?o.pageToken=a:void 0!==o.pageToken&&delete o.pageToken;var c=JSON.stringify(o);go.loadJson(i,{sendData:c,contentType:"application/json",headers:{"Cache-Control":"no-cache"}}).then((function(n){var i,o;n?((o=s?s(n):n)&&o.forEach((function(t){r.push(t)})),(i=n.nextPageToken)?t(i):e(r)):e(r)})).catch((function(t){n(t)}))}()}))}var pc={ALIGNMENT_MATCH:"M",INSERT:"I",DELETE:"D",SKIP:"N",CLIP_SOFT:"S",CLIP_HARD:"H",PAD:"P",SEQUENCE_MATCH:"=",SEQUENCE_MISMATCH:"X"};const gc=function(t,e){this.config=t,this.genome=e,this.url=t.url,this.filter=new Oa(t.filter),this.readGroupSetIds=t.readGroupSetIds,this.authKey=t.authKey,this.samplingWindowSize=void 0===t.samplingWindowSize?100:t.samplingWindowSize,this.samplingDepth=void 0===t.samplingDepth?1e3:t.samplingDepth,t.viewAsPairs?this.pairsSupported=!0:this.pairsSupported=void 0===t.pairsSupported||t.pairsSupported};gc.prototype.readAlignments=function(t,e,n){const r=this.genome,i=this;return(i.chrAliasTable?Promise.resolve(i.chrAliasTable):i.readMetadata().then((function(t){if(i.chrAliasTable={},r&&t.readGroups&&t.readGroups.length>0){var e=t.readGroups[0].referenceSetId;return e?dc({url:i.url+"/references/search",body:{referenceSetId:e},decode:function(t){return t.references}}).then((function(t){return t.forEach((function(t){var e=t.name,n=r.getChromosomeName(e);i.chrAliasTable[n]=e})),i.chrAliasTable})):(function(t,e){var n;if("461916304629"===e||"337315832689"===e){for(n=1;n<23;n++)t["chr"+n]=n;t.chrX="X",t.chrY="Y",t.chrM="MT"}}(i.chrAliasTable,i.config.datasetId),i.chrAliasTable)}return i.chrAliasTable}))).then((function(r){var s=r.hasOwnProperty(t)?r[t]:t;return dc({url:i.url+"/reads/search",body:{readGroupSetIds:[i.readGroupSetIds],referenceName:s,start:e,end:n,pageSize:"10000"},decode:o,results:new ba(t,e,n,i.config)})}));function o(t){var e,n,o,s,a,c=t.alignments,l=c.length,h=[];for(e=0;e<l;e++){let t=c[e];(n=new Ea).readName=t.fragmentName,n.properPlacement=t.properPlacement,n.duplicateFragment=t.duplicateFragment,n.numberReads=t.numberReads,n.fragmentLength=t.fragmentLength,n.readNumber=t.readNumber,n.failedVendorQualityChecks=t.failedVendorQualityChecks,n.secondaryAlignment=t.secondaryAlignment,n.supplementaryAlignment=t.supplementaryAlignment,n.seq=t.alignedSequence,n.qual=t.alignedQuality,n.matePos=t.nextMatePosition,n.tagDict=t.info,n.flags=0,t.alignment?(n.mapped=!0,n.chr=t.alignment.position.referenceName,r&&(n.chr=r.getChromosomeName(n.chr)),n.start=parseInt(t.alignment.position.position),n.strand=!t.alignment.position.reverseStrand,n.mq=t.alignment.mappingQuality,n.cigar=u(t.alignment.cigar),o=f(t.alignment.cigar),n.lengthOnRef=o.lengthOnRef,a=d(n,o.array),n.blocks=a.blocks,n.insertions=a.insertions):n.mapped=!1,(s=t.nextMatePosition)&&(n.mate={chr:s.referenceFrame,position:parseInt(s.position),strand:!s.reverseStrand}),i.filter.pass(n)&&h.push(n)}return h;function u(t){var e="";return t.forEach((function(t){var n=pc[t.operation],r=t.operationLength;e+=r+n})),e}function f(t){var e,n,r,i,o=0,s=[];for(i=0;i<t.length;i++)e=t[i],r=pc[e.operation],n=parseInt(e.operationLength),"M"!==r&&"EQ"!==r&&"X"!==r&&"D"!==r&&"N"!==r&&"="!==r||(o+=n),s.push({len:n,ltr:r});return{lengthOnRef:o,array:s}}function d(t,e){for(var n,r,i,o=[],s=0,a=t.start,c=e.length,l=0;l<c;l++){var h=e[l];switch(h.ltr){case"H":case"P":break;case"S":s+=h.len,i="S";break;case"N":case"D":void 0===n&&(n=[]),n.push({start:a,len:h.len,type:h.ltr}),a+=h.len;break;case"I":void 0===r&&(r=[]),r.push(new Pa({start:a,len:h.len,seqOffset:s})),s+=h.len;break;case"M":case"EQ":case"=":case"X":o.push(new Pa({start:a,len:h.len,seqOffset:s,gapType:i})),s+=h.len,a+=h.len;break;default:console.log("Error processing cigar element: "+h.len+h.ltr)}}return{blocks:o,insertions:r,gaps:n}}}},gc.prototype.readMetadata=function(){return fc({url:this.url,entity:"readgroupsets",entityId:this.readGroupSetIds})};class mc{constructor(t,e){const n=e.genome;if(this.config=t,this.genome=n,ys(t.url)){if("cram"===t.format)throw"CRAM data uris are not supported";this.config.indexed=!1}if("ga4gh"===t.sourceType)this.bamReader=new gc(t,n);else if("pysam"===t.sourceType)this.bamReader=new Ja(t,n);else if("htsget"===t.sourceType)this.bamReader=new ic(t,n);else if("shardedBam"===t.sourceType)this.bamReader=new Qa(t,n);else if("cram"===t.format)this.bamReader=new ac(t,n,e);else{if(!this.config.indexURL&&!1!==t.indexed)if(ke(this.config.url)){const t=function(t,e){if(ke(t)){if(t.includes("?")){const n=t.indexOf("?");return t.substring(0,n)+"."+e+t.substring(n)}return t+"."+e}}(this.config.url,"bai");t?(console.error(`Warning: no indexURL specified for ${this.config.url}. Guessing ${this.baiPath}`),this.config.indexURL=t):(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 Ka(t,n):this.bamReader=new qa(t,n)}this.viewAsPairs=t.viewAsPairs,this.showSoftClips=t.showSoftClips}setViewAsPairs(t){this.viewAsPairs=t}setShowSoftClips(t){this.showSoftClips=t}async getAlignments(t,e,n){const r=this.genome,i=this.showSoftClips,o=await this.bamReader.readAlignments(t,e,n);let s=o.alignments;this.viewAsPairs||(s=ma([{alignments:s}]));const a=s.length>0;if(o.packedAlignmentRows=va(s,o.start,o.end,i),this.alignmentContainer=o,a){const e=await r.sequence.getSequence(t,o.start,o.end);if(e)return o.coverageMap.refSeq=e,o.sequence=e,o;console.error("No sequence for: "+t+":"+o.start+"-"+o.end)}return o}}const vc=t=>ke(t)&&t.indexOf(",")>0&&!t.startsWith("rgb(")?`rgb(${t})`:t;class bc{constructor(t,e){this.browser=e,this.init(t)}init(t){t.displayMode&&(t.displayMode=t.displayMode.toUpperCase()),this.config=t,this.url=t.url,this.type=t.type,this.supportHiDPI=void 0===t.supportHiDPI||t.supportHiDPI,t.name||t.label?this.name=t.name||t.label:je(t.url)?this.name=t.url.name:ke(t.url)&&!t.url.startsWith("data:")&&(this.name=Ve(t.url)),this.id=void 0===this.config.id?this.name:this.config.id,this.order=t.order,t.color&&(this.color=vc(t.color)),t.altColor&&(this.altColor=vc(t.altColor)),"civic-ws"===t.sourceType?this.defaultColor="rgb(155,20,20)":this.defaultColor="rgb(0,0,150)",this.autoscaleGroup=t.autoscaleGroup,this.removable=void 0===t.removable||t.removable,this.height=t.height||100,this.autoHeight=t.autoHeight,this.minHeight=t.minHeight||Math.min(25,this.height),this.maxHeight=t.maxHeight||Math.max(1e3,this.height),this.visibilityWindow=t.visibilityWindow,t.onclick&&(this.onclick=t.onclick,t.onclick=void 0),t.description&&("function"==typeof t.description?this.description=t.description:this.description=()=>t.description)}get name(){return this._name}set name(t){this._name=t,this.trackView&&this.trackView.setTrackLabelName(t)}updateConfig(t){this.init(t)}getState(){const t={};for(let e of Object.keys(this.config))e.startsWith("_")||"function"==typeof this.config[e]||void 0===this.config[e]||(t[e]=this.config[e]);for(let e of Object.keys(t)){if(e.startsWith("_"))continue;const n=this[e];n&&(ps(n)||"boolean"==typeof n||"metadata"===e)&&(t[e]=n)}this.color&&(t.color=this.color),this.altColor&&(t.altColor=this.altColor),!this.autoscale&&this.dataRange&&(t.min=this.dataRange.min,t.max=this.dataRange.max);for(let e of Object.keys(t)){const n=t[e];if("function"==typeof n)throw Error(`Property '${e}' of track '${this.name} is a function. Functions cannot be saved in sessions.`);if(n instanceof File){const t=`Track ${this.name} is a local file. Sessions cannot be saved with local file references.`;throw Error(t)}if(n instanceof Promise)throw Error(`Property '${e}' of track '${this.name} is a Promise. Promises cannot be saved in sessions.`)}return t}get supportsWholeGenome(){return!0===this.config.supportsWholeGenome}hasSamples(){return!1}getGenomeId(){return this.browser.genome?this.browser.genome.id:void 0}setTrackProperties(t){const e={};let n;for(let r of Object.keys(t))switch(r.toLowerCase()){case"usescore":e.useScore=1===t[r]||"1"===t[r]||"on"===t[r]||!0===t[r];break;case"visibility":switch(t[r]){case"2":case"3":case"pack":case"full":e.displayMode="EXPANDED";break;case"4":case"squish":e.displayMode="SQUISHED";break;case"1":case"dense":e.displayMode="COLLAPSED"}break;case"color":case"altcolor":e[r]=t[r].startsWith("rgb(")?t[r]:"rgb("+t[r]+")";break;case"featurevisiblitywindow":case"visibilitywindow":e.visibilityWindow=Number.parseInt(t[r]);break;case"maxheightpixels":n=t[r].split(":"),3===n.length&&(e.minHeight=Number.parseInt(n[2]),e.height=Number.parseInt(n[1]),e.maxHeight=Number.parseInt(n[0]));break;case"viewlimits":if(!this.config.autoscale){n=t[r].split(":");let i,o=0;1==n.length?i=Number(n[0]):2==n.length&&(o=Number(n[0]),i=Number(n[1])),e.autoscale=!1,e.dataRange={min:o,max:i}}case"name":e[r]=t[r];break;case"url":e.infoURL=t[r];break;case"type":const i=t[r];wc.has(i)?e[r]=wc.get(i):e[r]=i;break;case"graphtype":e.graphType=t[r];break;default:e[r]=t[r]}for(let t of Object.keys(e))if(!this.config.hasOwnProperty(t)||"name"===t&&this.config._derivedName){let n=e[t];if("true"===n&&(n=!0),"false"===n&&(n=!1),this[t]=n,"height"===t&&this.trackView)try{const t=Number.parseInt(n);this.trackView.setTrackHeight(t)}catch(t){console.error(t)}}}clickedFeatures(t,e){if(e||(e=t.viewport.cachedFeatures),!e||0===e.length)return[];const n=t.genomicLocation,r=t.referenceFrame.bpPerPixel>.2?3*t.referenceFrame.bpPerPixel:.2;return No(e,n-r,n+r)}extractPopupData(t,e){const n=new Set(["row","color","chr","start","end","cdStart","cdEnd","strand","alpha"]),r=[];let i,o;for(let e in t)if(t.hasOwnProperty(e)&&!n.has(e)&&ps(t[e])){let n=t[e];r.push({name:Ee(e),value:n}),"alleles"===e?i=t[e]:"alleleFreqs"===e&&(o=t[e])}if(i&&o){i.endsWith(",")&&(i=i.substr(0,i.length-1)),o.endsWith(",")&&(o=o.substr(0,o.length-1));let n=i.split(","),s=o.split(",");if(s.length>1){let i=[];for(let t=0;t<s.length;t++)i.push({a:n[t],af:Number(s[t])});i.sort((function(t,e){return t.af-e.af}));let o=i[i.length-1].a;if(1===o.length)for(let n=i.length-2;n>=0;n--){let s=i[n].a;if(1===s.length){e||(e=this.getGenomeId());const n=bc.getCravatLink(t.chr,t.start+1,o,s,e);console.log(n),n&&(r.push("<hr/>"),r.push({html:n}),r.push("<hr/>"))}}}}if(t.attributes)for(let e of Object.keys(t.attributes))r.push({name:e,value:t.attributes[e]});let s=`${t.chr}:${_e(t.start+1)}-${_e(t.end)}`;return t.strand&&(s+=` (${t.strand})`),r.push({name:"Location",value:s}),r}description(){const t=(t,e)=>`<div class="igv-track-label-popup-shim"><b>${t}: </b>${e}</div>`;let e='<div class="igv-track-label-popup">';if(this.url?je(this.url)?e+=t("Filename",this.url.name):e+=t("URL",this.url):e=this.name,this.config){if(this.config.metadata)for(let n of Object.keys(this.config.metadata)){e+=t(n,this.config.metadata[n])}for(let n of Object.keys(this.config)){if(n.startsWith("_"))continue;let r=n.substr(0,1);if(r!==r.toLowerCase()){const r=this.config[n];r&&ps(r)&&(e+=t(n,r))}}}return e+="</div>",e}static getCravatLink(t,e,n,r,i){if("hg38"===i||"GRCh38"===i){return`<a target="_blank" href="https://run.opencravat.org/result/nocache/variant.html?chrom=${t.startsWith("chr")?t:"chr"+t}&pos=${e}&ref_base=${n}&alt_base=${r}"><b>Cravat ${n}->${r}</b></a>`}}}const wc=new Map([["wiggle_0","wig"],["bed","bed"],["bigBed","bigBed"],["bigWig","bigWig"]]);function yc(t,e,n){var r,i,o,s,a,c,l,h={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 u=void 0!==this.flipAxis&&this.flipAxis;function f(t){return 0===t?"0":Math.abs(t)>=10?t.toFixed():Math.abs(t)>=1?t.toFixed(1):t.toFixed(2)}ls.fillRect(t,0,0,e,n,{fillStyle:"rgb(255, 255, 255)"}),r=(l=.95*e)-8,a={x:i=l,y:o=s=.01*n},ls.strokeLine(t,r,o,i,s,h),ls.fillText(t,f(u?this.dataRange.min:this.dataRange.max),r+4,o+12,h),c={x:i,y:o=s=.99*n},ls.strokeLine(t,r,o,i,s,h),ls.fillText(t,f(u?this.dataRange.max:this.dataRange.min),r+4,o-4,h),ls.strokeLine(t,a.x,a.y,c.x,c.y,h)}const xc={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 kc={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 _c{constructor(t){this.colors=kc[t],Array.isArray(this.colors)||(this.colors=[]),this.colorTable={},this.nextIdx=0,this.colorGenerator=new Cc}getColor(t){return this.colorTable.hasOwnProperty(t)||(this.nextIdx<this.colors.length?this.colorTable[t]=this.colors[this.nextIdx]:this.colorTable[t]=this.colorGenerator.get(),this.nextIdx++),this.colorTable[t]}}class Sc{constructor(t){this.colorTable=t||{},this.nextIdx=0,this.colorGenerator=new Cc}getColor(t){if(!this.colorTable.hasOwnProperty(t)){if(this.colorTable.hasOwnProperty("*"))return this.colorTable["*"];this.colorTable[t]=this.colorGenerator.get()}return this.colorTable[t]}}function Cc(){this.hue=Math.random(),this.goldenRatio=.618033988749895,this.hexwidth=2}Cc.prototype.hsvToRgb=function(t,e,n){var r=Math.floor(6*t),i=6*t-r,o=n*(1-e),s=n*(1-i*e),a=n*(1-(1-i)*e),c=255,l=255,h=255;switch(r){case 0:c=n,l=a,h=o;break;case 1:c=s,l=n,h=o;break;case 2:c=o,l=n,h=a;break;case 3:c=o,l=s,h=n;break;case 4:c=a,l=o,h=n;break;case 5:c=n,l=o,h=s}return[Math.floor(256*c),Math.floor(256*l),Math.floor(256*h)]},Cc.prototype.padHex=function(t){return t.length>this.hexwidth?t:new Array(this.hexwidth-t.length+1).join("0")+t},Cc.prototype.get=function(t,e){this.hue+=this.goldenRatio,this.hue%=1,"number"!=typeof t&&(t=.5),"number"!=typeof e&&(e=.95);var n=this.hsvToRgb(this.hue,t,e);return"#"+this.padHex(n[0].toString(16))+this.padHex(n[1].toString(16))+this.padHex(n[2].toString(16))};const Ec=new Cc;class Ac{constructor({chr:t,start:e,end:n}){this.chr=t,this.start=e,this.end=n}contains(t){return t.chr===this.chr&&t.start>=this.start&&t.end<=this.end}overlaps(t){return t.chr===this.chr&&!(t.end<this.start||t.start>this.end)}extend(t){t.chr===this.chr&&(this.start=Math.min(t.start,this.start),this.end=Math.max(t.end,this.end))}getLocusString(){if("all"===this.chr)return"all";{const t=_e(Math.floor(this.start)+1),e=_e(Math.round(this.end));return`${this.chr}:${t}-${e}`}}static fromLocusString(t){if("all"===t)return new Ac({chr:"all"});const e=t.split(":"),n=e[0],r=e[1].split("-"),i=Number.parseInt(r[0].replace(/,/g,""))-1,o=Number.parseInt(r[1].replace(/,/g,""));return new Ac({chr:n,start:i,end:o})}}
|
|
65
65
|
/*!
|
|
66
66
|
* vanilla-picker v2.12.1
|
|
67
67
|
* https://vanilla-picker.js.org
|
|
68
68
|
*
|
|
69
69
|
* Copyright 2017-2021 Andreas Borgen (https://github.com/Sphinxxxx), Adam Brooks (https://github.com/dissimulate)
|
|
70
70
|
* Released under the ISC license.
|
|
71
|
-
*/var Tc=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},Lc=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),Mc=function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var s,a=t[Symbol.iterator]();!(r=(s=a.next()).done)&&(n.push(s.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{!r&&a.return&&a.return()}finally{if(i)throw o}}return n}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")};String.prototype.startsWith=String.prototype.startsWith||function(t){return 0===this.indexOf(t)},String.prototype.padStart=String.prototype.padStart||function(t,e){for(var n=this;n.length<t;)n=e+n;return n};var Rc={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 Ic(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=e>0?t.toFixed(e).replace(/0+$/,"").replace(/\.$/,""):t.toString();return n||"0"}var Nc=function(){function t(e,n,r,i){Tc(this,t);var o=this;if(void 0===e);else if(Array.isArray(e))this.rgba=e;else if(void 0===r){var s=e&&""+e;s&&function(e){if(e.startsWith("hsl")){var n=e.match(/([\-\d\.e]+)/g).map(Number),r=Mc(n,4),i=r[0],s=r[1],a=r[2],c=r[3];void 0===c&&(c=1),i/=360,s/=100,a/=100,o.hsla=[i,s,a,c]}else if(e.startsWith("rgb")){var l=e.match(/([\-\d\.e]+)/g).map(Number),h=Mc(l,4),u=h[0],f=h[1],d=h[2],p=h[3];void 0===p&&(p=1),o.rgba=[u,f,d,p]}else e.startsWith("#")?o.rgba=t.hexToRgb(e):o.rgba=t.nameToRgb(e)||t.hexToRgb(e)}(s.toLowerCase())}else this.rgba=[e,n,r,void 0===i?1:i]}return Lc(t,[{key:"printRGB",value:function(t){var e=(t?this.rgba:this.rgba.slice(0,3)).map((function(t,e){return Ic(t,3===e?3:0)}));return t?"rgba("+e+")":"rgb("+e+")"}},{key:"printHSL",value:function(t){var e=[360,100,100,1],n=["","%","%",""],r=(t?this.hsla:this.hsla.slice(0,3)).map((function(t,r){return Ic(t*e[r],3===r?3:1)+n[r]}));return t?"hsla("+r+")":"hsl("+r+")"}},{key:"printHex",value:function(t){var e=this.hex;return t?e:e.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=t.hslToRgb(this._hsla)},set:function(t){3===t.length&&(t[3]=1),this._rgba=t,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=t.rgbToHsl(this._rgba)},set:function(t){3===t.length&&(t[3]=1),this._hsla=t,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(t,e){return e<3?t.toString(16):Math.round(255*t).toString(16)})).map((function(t){return t.padStart(2,"0")})).join("")},set:function(e){this.rgba=t.hexToRgb(e)}}],[{key:"hexToRgb",value:function(t){var e=(t.startsWith("#")?t.slice(1):t).replace(/^(\w{3})$/,"$1F").replace(/^(\w)(\w)(\w)(\w)$/,"$1$1$2$2$3$3$4$4").replace(/^(\w{6})$/,"$1FF");if(!e.match(/^([0-9a-fA-F]{8})$/))throw new Error("Unknown hex color; "+t);var n=e.match(/^(\w\w)(\w\w)(\w\w)(\w\w)$/).slice(1).map((function(t){return parseInt(t,16)}));return n[3]=n[3]/255,n}},{key:"nameToRgb",value:function(e){var n=e.toLowerCase().replace("at","T").replace(/[aeiouyldf]/g,"").replace("ght","L").replace("rk","D").slice(-5,4),r=Rc[n];return void 0===r?r:t.hexToRgb(r.replace(/\-/g,"00").padStart(6,"f"))}},{key:"rgbToHsl",value:function(t){var e=Mc(t,4),n=e[0],r=e[1],i=e[2],o=e[3];n/=255,r/=255,i/=255;var s=Math.max(n,r,i),a=Math.min(n,r,i),c=void 0,l=void 0,h=(s+a)/2;if(s===a)c=l=0;else{var u=s-a;switch(l=h>.5?u/(2-s-a):u/(s+a),s){case n:c=(r-i)/u+(r<i?6:0);break;case r:c=(i-n)/u+2;break;case i:c=(n-r)/u+4}c/=6}return[c,l,h,o]}},{key:"hslToRgb",value:function(t){var e=Mc(t,4),n=e[0],r=e[1],i=e[2],o=e[3],s=void 0,a=void 0,c=void 0;if(0===r)s=a=c=i;else{var l=function(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t},h=i<.5?i*(1+r):i+r-i*r,u=2*i-h;s=l(u,h,n+1/3),a=l(u,h,n),c=l(u,h,n-1/3)}var f=[255*s,255*a,255*c].map(Math.round);return f[3]=o,f}}]),t}(),Pc=function(){function t(){Tc(this,t),this._events=[]}return Lc(t,[{key:"add",value:function(t,e,n){t.addEventListener(e,n,!1),this._events.push({target:t,type:e,handler:n})}},{key:"remove",value:function(e,n,r){this._events=this._events.filter((function(i){var o=!0;return e&&e!==i.target&&(o=!1),n&&n!==i.type&&(o=!1),r&&r!==i.handler&&(o=!1),o&&t._doRemove(i.target,i.type,i.handler),!o}))}},{key:"destroy",value:function(){this._events.forEach((function(e){return t._doRemove(e.target,e.type,e.handler)})),this._events=[]}}],[{key:"_doRemove",value:function(t,e,n){t.removeEventListener(e,n,!1)}}]),t}();function Oc(t,e,n){var r=!1;function i(t,e,n){return Math.max(e,Math.min(t,n))}function o(t,o,s){if(s&&(r=!0),r){t.preventDefault();var a=e.getBoundingClientRect(),c=a.width,l=a.height,h=o.clientX,u=o.clientY,f=i(h-a.left,0,c),d=i(u-a.top,0,l);n(f/c,d/l)}}function s(t,e){1===(void 0===t.buttons?t.which:t.buttons)?o(t,t,e):r=!1}function a(t,e){1===t.touches.length?o(t,t.touches[0],e):r=!1}t.add(e,"mousedown",(function(t){s(t,!0)})),t.add(e,"touchstart",(function(t){a(t,!0)})),t.add(window,"mousemove",s),t.add(e,"touchmove",a),t.add(window,"mouseup",(function(t){r=!1})),t.add(e,"touchend",(function(t){r=!1})),t.add(e,"touchcancel",(function(t){r=!1}))}function Fc(t,e){return(e||document).querySelector(t)}function Dc(t){t.preventDefault(),t.stopPropagation()}function Bc(t,e,n,r,i){t.add(e,"keydown",(function(t){n.indexOf(t.key)>=0&&(i&&Dc(t),r(t))}))}var zc=function(){function t(e){Tc(this,t),this.settings={popup:"right",layout:"default",alpha:!0,editor:!0,editorFormat:"hex",cancelButton:!1,defaultColor:"#0cf"},this._events=new Pc,this.onChange=null,this.onDone=null,this.onOpen=null,this.onClose=null,this.setOptions(e)}return Lc(t,[{key:"setOptions",value:function(t){var e=this;if(t){var n=this.settings;if(t instanceof HTMLElement)n.parent=t;else{n.parent&&t.parent&&n.parent!==t.parent&&(this._events.remove(n.parent),this._popupInited=!1),function(t,e,n){for(var r in t)n&&n.indexOf(r)>=0||(e[r]=t[r])}(t,n),t.onChange&&(this.onChange=t.onChange),t.onDone&&(this.onDone=t.onDone),t.onOpen&&(this.onOpen=t.onOpen),t.onClose&&(this.onClose=t.onClose);var r=t.color||t.colour;r&&this._setColor(r)}var i=n.parent;if(i&&n.popup&&!this._popupInited){var o=function(t){return e.openHandler(t)};this._events.add(i,"click",o),Bc(this._events,i,[" ","Spacebar","Enter"],o),this._popupInited=!0}else t.parent&&!n.popup&&this.show()}}},{key:"openHandler",value:function(t){if(this.show()){t&&t.preventDefault(),this.settings.parent.style.pointerEvents="none";var e=t&&"keydown"===t.type?this._domEdit:this.domElement;setTimeout((function(){return e.focus()}),100),this.onOpen&&this.onOpen(this.colour)}}},{key:"closeHandler",value:function(t){var e=t&&t.type,n=!1;if(t)if("mousedown"===e||"focusin"===e){var r=(this.__containedEvent||0)+100;t.timeStamp>r&&(n=!0)}else Dc(t),n=!0;else n=!0;n&&this.hide()&&(this.settings.parent.style.pointerEvents="","mousedown"!==e&&this.settings.parent.focus(),this.onClose&&this.onClose(this.colour))}},{key:"movePopup",value:function(t,e){this.closeHandler(),this.setOptions(t),e&&this.openHandler()}},{key:"setColor",value:function(t,e){this._setColor(t,{silent:e})}},{key:"_setColor",value:function(t,e){if("string"==typeof t&&(t=t.trim()),t){e=e||{};var n=void 0;try{n=new Nc(t)}catch(t){if(e.failSilently)return;throw t}if(!this.settings.alpha){var r=n.hsla;r[3]=1,n.hsla=r}this.colour=this.color=n,this._setHSLA(null,null,null,null,e)}}},{key:"setColour",value:function(t,e){this.setColor(t,e)}},{key:"show",value:function(){if(!this.settings.parent)return!1;if(this.domElement){var t=this._toggleDOM(!0);return this._setPosition(),t}var e=function(t){var e=document.createElement("div");return e.innerHTML=t,e.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=e,this._domH=Fc(".picker_hue",e),this._domSL=Fc(".picker_sl",e),this._domA=Fc(".picker_alpha",e),this._domEdit=Fc(".picker_editor input",e),this._domSample=Fc(".picker_sample",e),this._domOkay=Fc(".picker_done button",e),this._domCancel=Fc(".picker_cancel button",e),e.classList.add("layout_"+this.settings.layout),this.settings.alpha||e.classList.add("no_alpha"),this.settings.editor||e.classList.add("no_editor"),this.settings.cancelButton||e.classList.add("no_cancel"),this._ifPopup((function(){return e.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 t=this,e=this,n=this.domElement,r=this._events;function i(t,e,n){r.add(t,e,n)}i(n,"click",(function(t){return t.preventDefault()})),Oc(r,this._domH,(function(t,n){return e._setHSLA(t)})),Oc(r,this._domSL,(function(t,n){return e._setHSLA(null,t,1-n)})),this.settings.alpha&&Oc(r,this._domA,(function(t,n){return e._setHSLA(null,null,null,1-n)}));var o=this._domEdit;i(o,"input",(function(t){e._setColor(this.value,{fromEditor:!0,failSilently:!0})})),i(o,"focus",(function(t){var e=this;e.selectionStart===e.selectionEnd&&e.select()})),this._ifPopup((function(){var e=function(e){return t.closeHandler(e)};i(window,"mousedown",e),i(window,"focusin",e),Bc(r,n,["Esc","Escape"],e);var o=function(e){t.__containedEvent=e.timeStamp};i(n,"mousedown",o),i(n,"focusin",o),i(t._domCancel,"click",e)}));var s=function(e){t._ifPopup((function(){return t.closeHandler(e)})),t.onDone&&t.onDone(t.colour)};i(this._domOkay,"click",s),Bc(r,n,["Enter"],s)}},{key:"_setPosition",value:function(){var t=this.settings.parent,e=this.domElement;t!==e.parentNode&&t.appendChild(e),this._ifPopup((function(n){"static"===getComputedStyle(t).position&&(t.style.position="relative");var r=!0===n?"popup_right":"popup_"+n;["popup_top","popup_bottom","popup_left","popup_right"].forEach((function(t){t===r?e.classList.add(t):e.classList.remove(t)})),e.classList.add(r)}))}},{key:"_setHSLA",value:function(t,e,n,r,i){i=i||{};var o=this.colour,s=o.hsla;[t,e,n,r].forEach((function(t,e){(t||0===t)&&(s[e]=t)})),o.hsla=s,this._updateUI(i),this.onChange&&!i.silent&&this.onChange(o)}},{key:"_updateUI",value:function(t){if(this.domElement){t=t||{};var e=this.colour,n=e.hsla,r="hsl("+360*n[0]+", 100%, 50%)",i=e.hslString,o=e.hslaString,s=this._domH,a=this._domSL,c=this._domA,l=Fc(".picker_selector",s),h=Fc(".picker_selector",a),u=Fc(".picker_selector",c);b(0,l,n[0]),this._domSL.style.backgroundColor=this._domH.style.color=r,b(0,h,n[1]),w(0,h,1-n[2]),a.style.color=i,w(0,u,1-n[3]);var f=i,d=f.replace("hsl","hsla").replace(")",", 0)"),p="linear-gradient("+[f,d]+")";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",!t.fromEditor){var g=this.settings.editorFormat,m=this.settings.alpha,v=void 0;switch(g){case"rgb":v=e.printRGB(m);break;case"hsl":v=e.printHSL(m);break;default:v=e.printHex(m)}this._domEdit.value=v}this._domSample.style.color=o}function b(t,e,n){e.style.left=100*n+"%"}function w(t,e,n){e.style.top=100*n+"%"}}},{key:"_ifPopup",value:function(t,e){this.settings.parent&&this.settings.popup?t&&t(this.settings.popup):e&&e()}},{key:"_toggleDOM",value:function(t){var e=this.domElement;if(!e)return!1;var n=t?"":"none",r=e.style.display!==n;return r&&(e.style.display=n),r}}]),t}(),Hc=document.createElement("style");function Vc(t){if(jc[t])return jc[t];if(jc["chr"+t]){const e=jc["chr"+t];return jc[t]=e,e}{const i=(e=Math.round(255*Math.random()).toString(10),n=Math.round(255*Math.random()).toString(10),r=Math.round(255*Math.random()).toString(10),"rgb("+e+","+n+","+r+")");return jc[t]=i,i}var e,n,r}Hc.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(Hc),zc.StyleElement=Hc;const jc={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 Uc{constructor(t){this.tracks=[],this.chordSets=[]}addChordSet(t){this.chordSets=this.chordSets.filter((e=>e.name!==t.name)),this.chordSets.push(t);let e=this.tracks.find((e=>t.trackName===e.name));e&&(e.chordSets=e.chordSets.filter((e=>e.name!==t.name)),e.chordSets.push(t)),e||(e=new qc(t),this.tracks.push(e))}clearChords(){this.tracks=[],this.chordSets=[]}getTrack(t){return this.tracks.find((e=>t===e.name))}getChordSet(t){return this.chordSets.find((e=>t===e.name))}}class qc{constructor(t){this.name=t.trackName,this.color=t.trackColor,this.visible=!0,this.chordSets=[t],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 t=[];for(let e of this.chordSets)for(let n of e.chords)t.push(n);return t}}const Wc=Math.exp(5);class $c{static isInstalled(){return void 0!==window.JBrowseReactCircularGenomeView&&void 0!==window.React&&void 0!==window.ReactDOM}constructor(t,e){if(e=e||{},this.config=e,$c.isInstalled()){this.parent=t,this.groupByTrack=!0===e.groupByTrack,this.chordManager=new Uc(e);const n=document.createElement("div");n.className="igv-circview-container",t.appendChild(n),this.createControls(n),this.resetControlPanel();const r=document.createElement("div");r.className="igv-circview-circular-genome-view",n.appendChild(r),this.container=r,e.assembly&&this.setAssembly(e.assembly),this.width=e.width||500,this.height=e.height||500,this.setSize(this.width,this.height)}else console.error("JBrowse circular view is not installed")}createControls(t){const e=document.createElement("div");e.className="igv-circview-toolbar",t.appendChild(e),this.toolbar=e;const n=document.createElement("div");n.className="igv-circview-track-panel",t.appendChild(n),this.controlPanel=n,this.controlPanel.style.display="none";const r=document.createElement("div");r.className="igv-circview-toolbar-button-container",this.toolbar.appendChild(r),this.showControlsButton=document.createElement("div"),this.showControlsButton.className="igv-circview-button",r.appendChild(this.showControlsButton),this.showControlsButton.innerText="none"===this.controlPanel.style.display?"Show Controls":"Hide Controls",this.showControlsButton.addEventListener("click",(t=>{this.controlPanel.querySelectorAll("div").length>0&&("none"===this.controlPanel.style.display?(this.controlPanel.style.display="flex",t.target.innerText="Hide Controls"):(this.controlPanel.style.display="none",t.target.innerText="Show Controls"))}));let i=document.createElement("div");i.className="igv-circview-button",r.appendChild(i),i.innerText="Clear All",i.addEventListener("click",(()=>{this.clearChords()})),!1!==this.config.showCloseButton&&(i=document.createElement("div"),i.className="igv-circview-button",r.appendChild(i),i.innerText="Close",i.addEventListener("click",(()=>{this.visible=!1})))}resetControlPanel(){this.controlPanel.innerHTML="",this.controlPanel.appendChild(this.createGroupByCB());const t=this.groupByTrack?this.chordManager.tracks:this.chordManager.chordSets;for(let e of t)this.addToControlPanel(e)}createGroupByCB(){const t=document.createElement("input");t.type="checkbox",t.id="groupByCB",t.style.width="1.4em",t.style.height="1.4em",t.checked=this.groupByTrack,t.onclick=t=>{this.groupByTrack=t.target.checked,this.resetControlPanel(),this.render()};const e=document.createElement("label");e.for="groupByCB",e.innerText="Group by track",e.style.color="black",e.style.paddingLeft="10px";const n=document.createElement("div");return n.style.width="100%",n.style.paddingTop="5px",n.style.paddingBottom="5px",n.style.background="rgb(216, 230, 234)",n.appendChild(t),n.appendChild(e),n}addToControlPanel(t){const e=document.createElement("div");this.controlPanel.appendChild(e);const n=document.createElement("div");n.className="igv-circview-button",e.appendChild(n),n.innerText=!0===t.visible?"Hide":"Show",n.addEventListener("click",(e=>{!0===t.visible?(this.hideChordSet(t.name),e.target.innerText="Show"):(this.showChordSet(t.name),e.target.innerText="Hide")}));const r=document.createElement("input"),i=t=>200*Math.log(t*Wc),o=document.createElement("div");o.className="igv-circview-button",o.innerHTML=" ",e.appendChild(o),o.style.backgroundColor=Gc(t.color,1);const s={parent:o,popup:"right",editorFormat:"rgb",color:t.color,onChange:({rgbaString:e})=>{o.style.backgroundColor=Gc(e,1),this.setColor(t.name,e),r.value=i(Zc(t.color))}},a=new zc(s);r.setAttribute("title","Adjust transparency of arcs"),r.type="range",r.style.width="100px",r.style.marginRight="10px",r.setAttribute("class","range"),r.setAttribute("min","0"),r.setAttribute("max","1000"),r.value=i(Zc(t.color)),r.oninput=()=>{const e=(n=r.value,Math.exp(n/200)/Wc);var n;this.setColor(t.name,Gc(t.color,e)),a.setColor(t.color)},e.appendChild(r);const c=document.createElement("div");c.style.color="black",e.appendChild(c),c.innerText=c.title=t.name}setAssembly(t){const e=this.genomeId||Kc();if(this.genomeId===e)return;this.chordManager.clearChords(),this.genomeId=e,this.chrNames=new Set(t.chromosomes.map((t=>Xc(t.name))));const n=[],r=[];for(let e of t.chromosomes){const t=Xc(e.name);r.push(e.color||Vc(t)),n.push({refName:t,uniqueId:t,start:0,end:e.bpLength})}this.assembly={name:t.name,sequence:{trackId:e,type:"ReferenceSequenceTrack",adapter:{type:"FromConfigSequenceAdapter",features:n}},refNameColors:r},this.render()}addChords(t,e={}){const n=e.name||e.track||"*",r=n.split(" ")[0].replaceAll("%20"," "),i={name:n.replaceAll("%20"," "),trackName:r,chords:t,color:e.color||"black",trackColor:e.trackColor||e.color||"black",visible:!0,id:e.id||Kc()};this.chordManager.addChordSet(i),this.resetControlPanel(),this.render()}setSize(t,e){if(e=e||t,this.width=t,this.height=e,this.viewState){const n=this.viewState.session.view;n.setWidth(t),n.setHeight(e),n.setBpPerPx(n.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(t){this.parent.style.display=t?"block":"none"}hideChordSet(t){let e=this.getChordSet(t);e?(e.visible=!1,this.render()):console.warn(`No track with name: ${name}`)}showChordSet(t){let e=this.getChordSet(t);e?(e.visible=!0,this.render()):console.warn(`No track with name: ${t}`)}deleteTrack(t){let e=this.tracks.findIndex((e=>t===e.name));e>=0&&this.tracks.splice(e,1),this.render()}getChordSet(t){return this.groupByTrack?this.chordManager.getTrack(t):this.chordManager.getChordSet(t)}setColor(t,e){const n=this.getChordSet(t);if(n){n.color=e;const t=n.id;for(let n of this.viewState.config.tracks)if(t===n.trackId){n.displays[0].renderer.strokeColor.set(e);break}}}render(){const{createViewState:t,JBrowseCircularGenomeView:e}=JBrowseReactCircularGenomeView;ReactDOM.unmountComponentAtNode(this.container);const n=(this.groupByTrack?this.chordManager.tracks:this.chordManager.chordSets).filter((t=>t.visible)),r=[],i=[];for(let t of n)r.push({trackId:t.id,name:t.name,assemblyNames:["forIGV"],type:"VariantTrack",adapter:{type:"FromConfigAdapter",features:t.chords}}),i.push(t.color);this.viewState=t({assembly:this.assembly,tracks:r});for(let t=0;t<n.length;t++)this.viewState.config.tracks[t].displays[0].renderer.strokeColor.set(i[t]);this.element=React.createElement(e,{viewState:this.viewState}),this.setSize(this.width,this.height),ReactDOM.render(this.element,this.container);const o=this.config.onChordClick||Yc;for(let t=0;t<n.length;t++)this.viewState.session.view.showTrack(this.viewState.config.tracks[t].trackId),o&&(this.viewState.pluginManager.jexl.addFunction("onChordClick",o),this.viewState.config.tracks[t].displays[0].onChordClick.set("jexl:onChordClick(feature, track, pluginManager)"))}}function Gc(t,e){const[n,r,i,o]=t.split(",");return`${n},${r},${i},${e})`}function Zc(t){return t.startsWith("rgba(")?Number(t.split(",")[3].replace(")","")):1}function Xc(t){return t.startsWith("chr")?t.substring(3):t}function Yc(t,e,n){console.log(t)}function Kc(){return("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)}if("undefined"!=typeof document){function as(t){for(let e of document.styleSheets)if(e=e.href?e.href.replace(/^.*[\\\/]/,""):"",e===t)return!0;return!1}as("circular-view.css")||function(){const t=document.createElement("style");t.setAttribute("type","text/css"),t.innerHTML='.igv-circview-container {\n z-index: 2048;\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(t,document.head.childNodes[document.head.childNodes.length-1])}()}const Qc=t=>t.startsWith("chr")?t.substring(3):t;function Jc(t){const e=[],n=[];for(let r of t.wgChromosomeNames){const i=t.getChromosome(r);n.push(ll(i.name)),e.push({name:i.name,bpLength:i.bpLength})}return e}function tl(t,e,n,r){const i=ro.addAlpha("all"===n.chr?e.color:ll(n.chr),r),o=ro.addAlpha(e.color||"rgb(0,0,255)",r),s=e.name.replaceAll(" ","%20"),a="all"===n.chr?s:`${s} ${n.chr}:${n.start}-${n.end}`;e.browser.circularView.addChords(t,{track:a,color:i,trackColor:o}),e.browser.circularViewVisible||(e.browser.circularViewVisible=!0)}class el{constructor(t,{minTLENPercentile:e,maxTLENPercentile:n}){this.totalCount=0,this.frCount=0,this.rfCount=0,this.ffCount=0,this.sumF=0,this.sumF2=0,this.lp=void 0===e?.1:e,this.up=void 0===n?99.5:n,this.isizes=[],this.compute(t)}compute(t){for(let r of t)if(r.isProperPair()){var e=Math.abs(r.fragmentLength);this.sumF+=e,this.sumF2+=e*e,this.isizes.push(e);var n=r.pairOrientation;if("string"==typeof n&&4===n.length)switch(""+n.charAt(0)+n.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:nl(this.isizes,this.lp),this.maxTLEN=nl(this.isizes,this.up)}}function nl(t,e){if(0!==t.length){var n=Math.floor(t.length*(e/100));return t.sort((function(t,e){return t-e})),t[n]}}class rl extends bc{constructor(t,e){super(t,e)}init(t){super.init(t),this.type="alignment",void 0===t.alleleFreqThreshold&&(t.alleleFreqThreshold=.2),this.featureSource=new mc(t,this.browser),this.showCoverage=void 0===t.showCoverage||t.showCoverage,this.showAlignments=void 0===t.showAlignments||t.showAlignments,this.coverageTrack=new il(t,this),this.alignmentTrack=new ol(t,this),this.alignmentTrack.setTop(this.coverageTrack,this.showCoverage),this.visibilityWindow=t.visibilityWindow||3e4,this.viewAsPairs=t.viewAsPairs,this.pairsSupported=!1!==t.pairsSupported,this.showSoftClips=t.showSoftClips,this.showAllBases=t.showAllBases,this.showInsertions=!1!==t.showInsertions,this.showMismatches=!1!==t.showMismatches,this.color=t.color,this.coverageColor=t.coverageColor,t.sort&&(Array.isArray(t.sort)?this.assignSort(t.sort[0]):this.assignSort(t.sort)),this.height=void 0!==t.height?t.height:300}set height(t){this._height=t,this.coverageTrack&&this.showAlignments&&(this.alignmentTrack.height=this.showCoverage?t-this.coverageTrack.height:t)}get height(){return this._height}get minTemplateLength(){const t=void 0!==this.config.minTLEN?this.config.minTLEN:this.config.minFragmentLength;return void 0!==t?t:this._pairedEndStats?this._pairedEndStats.minTLEN:0}get maxTemplateLength(){const t=void 0!==this.config.maxTLEN?this.config.maxTLEN:this.config.maxFragmentLength;return void 0!==t?t:this._pairedEndStats?this._pairedEndStats.maxTLEN:1e3}sort(t){t=this.assignSort(t);for(let e of this.trackView.viewports)if(e.containsPosition(t.chr,t.position)){const n=e.cachedFeatures;n&&(sl(t,n),e.repaint())}}assignSort(t){if(t.locus){const e=function(t){const e=t.split(":"),n=e[1].split("-"),r={chr:e[0],start:Number.parseInt(n[0].replace(/,/g,""))-1};return n.length>1?r.end=Number.parseInt(n[1].replace(/,/g,"")):r.end=r.start+1,r}(t.locus);t.chr=e.chr,t.position=e.start}else t.position--;return t.direction="ASC"===t.direction||!0===t.direction,t.chr=this.browser.genome.getChromosomeName(t.chr),this.sortObject=t,this.sortObject}async getFeatures(t,e,n,r,i){const o=await this.featureSource.getAlignments(t,e,n);if(o.paired&&!this._pairedEndStats&&!this.config.maxFragmentLength){const t=new el(o.alignments,this.config);t.totalCount>99&&(this._pairedEndStats=t)}o.alignments=void 0;const s=this.sortObject;return s&&s.chr===t&&s.position>=e&&s.position<=n&&sl(s,o),o}computePixelHeight(t){return(this.showCoverage?this.coverageTrack.height:0)+(this.showAlignments?this.alignmentTrack.computePixelHeight(t):0)+15}draw(t){ls.fillRect(t.context,0,t.pixelTop,t.pixelWidth,t.pixelHeight,{fillStyle:"rgb(255, 255, 255)"}),!0===this.showCoverage&&this.coverageTrack.height>0?(this.trackView.axisCanvas.style.display="block",this.coverageTrack.draw(t)):this.trackView.axisCanvas.style.display="none",!0===this.showAlignments&&(this.alignmentTrack.setTop(this.coverageTrack,this.showCoverage),this.alignmentTrack.draw(t))}paintAxis(t,e,n){this.coverageTrack.paintAxis(t,e,this.coverageTrack.height)}contextMenuItemList(t){return this.alignmentTrack.contextMenuItemList(t)}popupData(t){return!0===this.showCoverage&&t.y>=this.coverageTrack.top&&t.y<this.coverageTrack.height?this.coverageTrack.popupData(t):this.alignmentTrack.popupData(t)}clickedFeatures(t){return!0===this.showCoverage&&t.y>=this.coverageTrack.top&&t.y<this.coverageTrack.height?[this.coverageTrack.getClickedObject(t)]:[this.alignmentTrack.getClickedObject(t)]}menuItemList(){let t=[];t=t.concat(Oo.numericDataMenuItems(this.trackView)),t.push("<hr/>");const e=pe('<div class="igv-track-menu-category">');e.text("Color by:"),t.push({name:void 0,object:e,click:void 0,init:void 0});const n=[{key:"strand",label:"read strand"}];this.alignmentTrack.hasPairs&&(n.push({key:"firstOfPairStrand",label:"first-of-pair strand"}),n.push({key:"pairOrientation",label:"pair orientation"}),n.push({key:"tlen",label:"insert size (TLEN)"}),n.push({key:"unexpectedPair",label:"pair orientation & insert size (TLEN)"}));const r="tag"+(this.alignmentTrack.colorByTag?" ("+this.alignmentTrack.colorByTag+")":"");n.push({key:"tag",label:r});for(let e of n){const n=this.alignmentTrack.colorBy===e.key;t.push(this.colorByCB(e,n))}const i=()=>{if(!this.autoHeight){const t=15+(this.showCoverage?this.coverageTrack.height:0)+(this.showAlignments?this.alignmentTrack.height:0);this.trackView.setTrackHeight(t)}};t.push("<hr/>"),t.push({object:pe(Po("Show Coverage",this.showCoverage)),click:()=>{this.showCoverage=!this.showCoverage,i(),this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),t.push({object:pe(Po("Show Alignments",this.showAlignments)),click:()=>{this.showAlignments=!this.showAlignments,i(),this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),t.push("<hr/>"),t.push({object:pe(Po("Show all bases",this.showAllBases)),click:()=>{this.showAllBases=!this.showAllBases,this.config.showAllBases=this.showAllBases,this.trackView.repaintViews()}}),t.push("<hr/>"),t.push({object:pe(Po("Show mismatches",this.showMismatches)),click:()=>{this.showMismatches=!this.showMismatches,this.config.showMismatches=this.showMismatches,this.trackView.repaintViews()}}),t.push({object:pe(Po("Show insertions",this.showInsertions)),click:()=>{this.showInsertions=!this.showInsertions,this.config.showInsertions=this.showInsertions,this.getCachedAlignmentContainers(),this.trackView.repaintViews()}}),t.push({object:pe(Po("Show soft clips",this.showSoftClips)),click:()=>{this.showSoftClips=!this.showSoftClips,this.config.showSoftClips=this.showSoftClips,this.featureSource.setShowSoftClips(this.showSoftClips);const t=this.getCachedAlignmentContainers();for(let e of t)e.setShowSoftClips(this.showSoftClips);this.trackView.repaintViews()}}),this.pairsSupported&&this.alignmentTrack.hasPairs&&(t.push("<hr/>"),t.push({object:pe(Po("View as pairs",this.viewAsPairs)),click:()=>{this.viewAsPairs=!this.viewAsPairs,this.config.viewAsPairs=this.viewAsPairs,this.featureSource.setViewAsPairs(this.viewAsPairs);const t=this.getCachedAlignmentContainers();for(let e of t)e.setViewAsPairs(this.viewAsPairs);this.trackView.repaintViews()}})),this.browser.circularView&&(this.alignmentTrack.hasPairs||this.alignmentTrack.hasSupplemental)&&(t.push("<hr/>"),this.alignmentTrack.hasPairs&&t.push({label:"Add discordant pairs to circular view",click:()=>{for(let t of this.trackView.viewports)this.addPairedChordsForViewport(t)}}),this.alignmentTrack.hasSupplemental&&t.push({label:"Add split reads to circular view",click:()=>{for(let t of this.trackView.viewports)this.addSplitChordsForViewport(t)}})),t.push("<hr/>");const o=pe('<div class="igv-track-menu-category">');return o.text("Display mode:"),t.push({name:void 0,object:o,click:void 0,init:void 0}),t.push({object:pe(Po("expand","EXPANDED"===this.alignmentTrack.displayMode)),click:()=>{this.alignmentTrack.displayMode="EXPANDED",this.config.displayMode="EXPANDED",this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),t.push({object:pe(Po("squish","SQUISHED"===this.alignmentTrack.displayMode)),click:()=>{this.alignmentTrack.displayMode="SQUISHED",this.config.displayMode="SQUISHED",this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),t}colorByCB(t,e){return{name:void 0,object:pe(Po(t.label,e)),click:e=>{"tag"!==t.key?t.key===this.alignmentTrack.colorBy?(this.alignmentTrack.colorBy="none",this.config.colorBy="none",this.trackView.repaintViews()):(this.alignmentTrack.colorBy=t.key,this.config.colorBy=t.key,this.trackView.repaintViews()):this.browser.inputDialog.present({label:"Tag Name",value:this.alignmentTrack.colorByTag?this.alignmentTrack.colorByTag:"",callback:t=>{t?(this.alignmentTrack.colorBy="tag",this.alignmentTrack.colorByTag=t,this.alignmentTrack.tagColors||(this.alignmentTrack.tagColors=new _c("Set1"))):(this.alignmentTrack.colorBy="none",this.alignmentTrack.colorByTag=""),this.trackView.repaintViews()}},e)},init:void 0}}dispose(){this.trackView=void 0}getState(){const t=super.getState();return this.sortObject&&(t.sort={chr:this.sortObject.chr,position:this.sortObject.position+1,option:this.sortObject.option,direction:this.sortObject.direction?"ASC":"DESC"}),t}getCachedAlignmentContainers(){return this.trackView.viewports.map((t=>t.cachedFeatures))}get dataRange(){return this.coverageTrack.dataRange}set dataRange(t){this.coverageTrack.dataRange=t}get logScale(){return this.coverageTrack.logScale}set logScale(t){this.coverageTrack.logScale=t}get autoscale(){return this.coverageTrack.autoscale}set autoscale(t){this.coverageTrack.autoscale=t}addPairedChordsForViewport(t){const e=this.maxTemplateLength,n=[],r=t.referenceFrame;for(let i of t.cachedFeatures.allAlignments())i.end>=r.start&&i.start<=r.end&&(i.paired?i.end-i.start>e&&n.push(i):i.mate&&i.mate.chr&&(i.mate.chr!==i.chr||Math.max(i.fragmentLength)>e)&&n.push(i));tl((t=>{const e=[];for(let n of t)if(n.paired)n.firstAlignment&&n.secondAlignment&&e.push({uniqueId:n.readName,refName:Qc(n.firstAlignment.chr),start:n.firstAlignment.start,end:n.firstAlignment.end,mate:{refName:Qc(n.secondAlignment.chr),start:n.secondAlignment.start,end:n.secondAlignment.end}});else{const t=n.mate;t&&t.chr&&t.position&&e.push({uniqueId:n.readName,refName:Qc(n.chr),start:n.start,end:n.end,mate:{refName:Qc(t.chr),start:t.position-1,end:t.position}})}return e})(n),this,r,.02)}addSplitChordsForViewport(t){const e=[],n=t.referenceFrame;for(let r of t.cachedFeatures.allAlignments()){const t=r.hasTag("SA");r.end>=n.start&&r.start<=n.end&&t&&e.push(r)}tl((t=>{const e=t=>{const e=Sa(t.tags().SA);let r=0;for(let i of e)i.start!==t.start&&n.push({uniqueId:`${t.readName}_${r++}`,refName:Qc(t.chr),start:t.start,end:t.end,mate:{refName:Qc(i.chr),start:i.start,end:i.start+i.lenOnRef}})},n=[];for(let n of t)n.paired?(e(n.firstAlignment),n.secondAlignment&&e(n.secondAlignment)):e(n);return n})(e),this,n,.02)}}class il{constructor(t,e){this.parent=e,this.featureSource=e.featureSource,this.height=void 0!==t.coverageTrackHeight?t.coverageTrackHeight:50,this.paintAxis=yc,this.top=0,this.autoscale=t.autoscale||void 0===t.max,this.autoscale||(this.dataRange={min:t.min||0,max:t.max})}draw(t){const e=t.pixelTop;t.pixelHeight;const n=this.parent.browser.nucleotideColors;if(e>this.height)return;const r=t.context,i=t.features.coverageMap;let o;i.refSeq&&(o=i.refSeq.toUpperCase());const s=t.bpPerPixel,a=t.bpStart,c=a+t.pixelWidth*s+1;let l;l=this.parent.coverageColor?this.parent.coverageColor:void 0!==this.parent.color?ro.darkenLighten(this.parent.color,-35):"rgb(150, 150, 150)",ls.setProperties(r,{fillStyle:l,strokeStyle:l});const h=Math.max(1,Math.ceil(1/s));for(let t=0,e=i.coverage.length;t<e;t++){const e=i.bpStart+t;if(e<a)continue;if(e>c)break;const n=i.coverage[t];if(!n)continue;const o=Math.round(n.total/this.dataRange.max*this.height),l=this.height-o,u=Math.floor((e-a)/s);ls.fillRect(r,u,l,h,o)}if(o)for(let t=0,e=i.coverage.length;t<e;t++){const e=i.bpStart+t;if(e<a)continue;if(e>c)break;const l=i.coverage[t];if(!l)continue;const u=l.total/this.dataRange.max*this.height;let f=this.height-u;const d=Math.floor((e-a)/s),p=o[t];if(l.isMismatch(p)){ls.setProperties(r,{fillStyle:n[p]}),ls.fillRect(r,d,f,h,u);let t=0;for(let e of["A","C","T","G"]){const i=(l["pos"+e]+l["neg"+e])/this.dataRange.max*this.height;f=this.height-i-t,t+=i,ls.setProperties(r,{fillStyle:n[e]}),ls.fillRect(r,d,f,h,i)}}}}getClickedObject(t){let e=t.viewport.cachedFeatures;if(!e||0===e.length)return;const n=Math.floor(t.genomicLocation),r=e.coverageMap,i=Math.floor(n-r.bpStart);return r.coverage[i]}popupData(t){const e=[],n=this.getClickedObject(t);if(n){const r=Math.floor(t.genomicLocation),i=t.viewport.referenceFrame;e.push(i.chr+":"+Se(1+r)),e.push({name:"Total Count",value:n.total});let o=n.posA+n.negA;o>0&&(o=o.toString()+" ("+Math.round(o/n.total*100)+"%, "+n.posA+"+, "+n.negA+"- )"),e.push({name:"A",value:o}),o=n.posC+n.negC,o>0&&(o=o.toString()+" ("+Math.round(o/n.total*100)+"%, "+n.posC+"+, "+n.negC+"- )"),e.push({name:"C",value:o}),o=n.posG+n.negG,o>0&&(o=o.toString()+" ("+Math.round(o/n.total*100)+"%, "+n.posG+"+, "+n.negG+"- )"),e.push({name:"G",value:o}),o=n.posT+n.negT,o>0&&(o=o.toString()+" ("+Math.round(o/n.total*100)+"%, "+n.posT+"+, "+n.negT+"- )"),e.push({name:"T",value:o}),o=n.posN+n.negN,o>0&&(o=o.toString()+" ("+Math.round(o/n.total*100)+"%, "+n.posN+"+, "+n.negN+"- )"),e.push({name:"N",value:o}),e.push("<HR/>"),e.push({name:"DEL",value:n.del.toString()}),e.push({name:"INS",value:n.ins.toString()})}return e}}class ol{constructor(t,e){this.parent=e,this.browser=e.browser,this.featureSource=e.featureSource,this.top=0===t.coverageTrackHeight?0:t.coverageTrackHeight+5,this.displayMode=t.displayMode||"EXPANDED",this.alignmentRowHeight=t.alignmentRowHeight||14,this.squishedRowHeight=t.squishedRowHeight||3,this.negStrandColor=t.negStrandColor||"rgba(150, 150, 230, 0.75)",this.posStrandColor=t.posStrandColor||"rgba(230, 150, 150, 0.75)",this.insertionColor=t.insertionColor||"rgb(138, 94, 161)",this.deletionColor=t.deletionColor||"black",this.skippedColor=t.skippedColor||"rgb(150, 170, 170)",this.pairConnectorColor=t.pairConnectorColor,this.smallTLENColor=t.smallTLENColor||t.smallFragmentLengthColor||"rgb(0, 0, 150)",this.largeTLENColor=t.largeTLENColor||t.largeFragmentLengthColor||"rgb(200, 0, 0)",this.pairOrientation=t.pairOrienation||"fr",this.pairColors={},this.pairColors.RL=t.rlColor||"rgb(0, 150, 0)",this.pairColors.RR=t.rrColor||"rgb(20, 50, 200)",this.pairColors.LL=t.llColor||"rgb(0, 150, 150)",this.colorBy=t.colorBy||"unexpectedPair",this.colorByTag=t.colorByTag?t.colorByTag.toUpperCase():void 0,this.bamColorTag=void 0===t.bamColorTag?"YC":t.bamColorTag,this.hideSmallIndels=t.hideSmallIndels,this.indelSizeThreshold=t.indelSizeThreshold||1,this.hasPairs=!1,this.hasSupplemental=!1}setTop(t,e){this.top=0===t.height||!1===e?0:5+t.height}computePixelHeight(t){if(t.packedAlignmentRows){return(t.hasDownsampledIntervals()?10:0)+("SQUISHED"===this.displayMode?this.squishedRowHeight:this.alignmentRowHeight)*t.packedAlignmentRows.length+5}return 0}draw(t){const e=t.features,n=t.context,r=t.bpPerPixel,i=t.bpStart,o=t.pixelWidth,s=i+o*r+1,a=this.parent.showSoftClips,c=this.parent.showAllBases,l=this.browser.nucleotideColors,h=e.packedAlignmentRows;n.save();let u=e.sequence;u&&(u=u.toUpperCase());let f=0,d=t.pixelTop;this.top&&n.translate(0,this.top);const p=d+t.pixelHeight;e.hasDownsampledIntervals()?(f=10,e.downsampledIntervals.forEach((function(t){var e=(t.start-i)/r,o=(t.end-i)/r;o-e>5&&(e+=1,o-=1),ls.fillRect(n,e,2,o-e,3,{fillStyle:"black"})}))):f=0,this.alignmentsYOffset=f;const g="SQUISHED"===this.displayMode?this.squishedRowHeight:this.alignmentRowHeight;if(h){const t=h.length;for(let e=0;e<t;e++){const t=h[e],n=f+g*e,r=g<=4?g:g-2;if(n>p)break;if(!(n+r<d))for(let e of t.alignments)if(this.hasPairs=this.hasPairs||e.isPaired(),this.browser.circularView&&(this.hasSupplemental=this.hasSupplemental||e.hasTag("SA")),!(e.start+e.lengthOnRef<i)){if(e.start>s)break;!0!==e.hidden&&(e instanceof ua?(m.call(this,e,n,r),v.call(this,e.firstAlignment,n,r),e.secondAlignment&&v.call(this,e.secondAlignment,n,r)):v.call(this,e,n,r))}}}function m(t,e,o){var a=this.getConnectorColor(t.firstAlignment),c=(t.connectingStart-i)/r,l=(t.connectingEnd-i)/r,h=e+o/2;t.connectingEnd<i||t.connectingStart>s||(t.mq<=0&&(a=ro.addAlpha(a,.15)),ls.setProperties(n,{fillStyle:a,strokeStyle:a}),ls.strokeLine(n,c,h,l,h))}function v(t,o,h){if(t.start+t.lengthOnRef<i||t.start>s)return;const f=a?t.blocks:t.blocks.filter((t=>"S"!==t.type));let d=this.getAlignmentColor(t);const p=d;t.mq<=0&&(d=ro.addAlpha(d,.15)),ls.setProperties(n,{fillStyle:d,strokeStyle:p});for(let t=0;t<f.length;t++){const e=f[t];if(!(t!==f.length-1&&f[t+1].start<i)&&(m.call(this,e,t),e.start+e.len>s))break}if(t.insertions&&this.parent.showInsertions){let e=-1;for(let a of t.insertions){if(this.hideSmallIndels&&a.len<=this.indelSizeThreshold)continue;if(a.start<i)continue;if(a.start>s)break;const t=(a.start-i)/r-1;if(t-e>2){const r=3;ls.fillRect(n,t,o-1,r,h+2,{fillStyle:this.insertionColor}),e=t}}}if(t.gaps){const e=o+h/2;for(let o of t.gaps){const t=(o.start-i)/r,s=(o.start+o.len-i)/r,a="D"===o.type?this.deletionColor:this.skippedColor;ls.strokeLine(n,t,e,s,e,{strokeStyle:a})}}function m(s,a){const m=s.start-e.start,b=(s.start-i)/r,w=(s.start+s.len-i)/r,y=Math.max(1,w-b),x=100/r,k=Math.min(g/2,x/6),_="S"===s.type,S=t.mq<=0||this.highlightedAlignmentReadNamed===t.readName||_;let C=p;this.highlightedAlignmentReadNamed===t.readName?C="red":_&&(C="rgb(50,50,50)");const E=!0===t.strand&&a===f.length-1,A=!1===t.strand&&0===a;if(E|A){let t,e;E?(t=[b,w,w+k,w,b,b],e=[o,o,o+h/2,o+h,o+h,o]):A&&(t=[w,b,b-k,b,w,w],e=[o,o,o+h/2,o+h,o+h,o]),ls.fillPolygon(n,t,e,{fillStyle:d}),S&&ls.strokePolygon(n,t,e,{strokeStyle:C})}else ls.fillRect(n,b,o,y,h,{fillStyle:d}),S&&(n.save(),n.strokeStyle=C,n.strokeRect(b,o,y,h),n.restore());if(_||c||this.parent.showMismatches&&u&&t.seq&&"*"!==t.seq){const e=t.seq?t.seq.toUpperCase():void 0,a=t.qual,f=s.seqOffset;for(let t=0,d=s.len;t<d;t++){if(m+t<0)continue;let d=e?e.charAt(f+t):"";const p=u.charAt(m+t);if("="===d&&(d=p),"X"===d||p!==d||_||c){let e;if(!_&&void 0!==a&&a.length>f+t){e=al(a[f+t],l[d])}else e=l[d];if(e){const a=(s.start+t-i)/r,c=Math.max(1,1/r);v(n,r,{x:a,y:o,width:c,height:h},e,d)}}}}}function v(t,e,n,r,i){var o;if(.1,e<=.1&&n.height>=8){const e=Math.min(10,n.height);t.font=e+"px sans-serif",o=n.x+n.width/2,ls.strokeText(t,i,o-t.measureText(i).width/2,e-1+n.y,{strokeStyle:r})}else ls.fillRect(t,n.x,n.y,n.width,n.height,{fillStyle:r})}}n.restore()}popupData(t){const e=this.getClickedObject(t);return e?e.popupData(t.genomicLocation):void 0}contextMenuItemList(t){const e=t.viewport,n=[],r=n=>{const r=this.parent.sortObject,i=!r||r.position!==Math.floor(t.genomicLocation)||!r.direction,o={chr:e.referenceFrame.chr,position:Math.floor(t.genomicLocation),option:n,direction:i};this.parent.sortObject=o,sl(o,e.cachedFeatures),e.repaint()};n.push("<b>Sort by...</b>"),n.push({label:" base",click:()=>r("BASE")}),n.push({label:" read strand",click:()=>r("STRAND")}),n.push({label:" insert size",click:()=>r("INSERT_SIZE")}),n.push({label:" gap size",click:()=>r("GAP_SIZE")}),n.push({label:" chromosome of mate",click:()=>r("MATE_CHR")}),n.push({label:" mapping quality",click:()=>r("MQ")}),n.push({label:" read name",click:()=>r("READ_NAME")}),n.push({label:" tag",click:()=>{const n=this.parent.sortObject,r=!n||n.position!==Math.floor(t.genomicLocation)||!n.direction,i={label:"Tag Name",value:this.sortByTag?this.sortByTag:"",callback:n=>{if(n){const i={chr:e.referenceFrame.chr,position:Math.floor(t.genomicLocation),option:"TAG",tag:n,direction:r};this.sortByTag=n,this.parent.sortObject=i,sl(i,e.cachedFeatures),e.repaint()}}};this.browser.inputDialog.present(i,t.event)}}),n.push("<hr/>");const i=this.getClickedObject(t);if(i){const e=this.parent.showSoftClips,r="function"==typeof i.alignmentContaining?i.alignmentContaining(t.genomicLocation,e):i;r&&(r.isPaired()&&r.isMateMapped()&&n.push({label:"View mate in split screen",click:()=>{if(r.mate){const e=t.viewport.referenceFrame;if(this.browser.genome.getChromosome(r.mate.chr)){this.highlightedAlignmentReadNamed=r.readName;const t=e.end-e.start,n=r.mate.position-t/2,i=r.mate.position+t/2;this.browser.addMultiLocusPanel(r.mate.chr,n,i,e)}else Qo.presentAlert(`Reference does not contain chromosome: ${r.mate.chr}`)}},init:void 0}),n.push({label:"View read sequence",click:()=>{const t=r.seq;t&&"*"!==t?Qo.presentAlert(t):Qo.presentAlert("Read sequence: *")}}),Ss()&&n.push({label:"Copy read sequence",click:async()=>{const t=r.seq;try{await navigator.clipboard.writeText(t)}catch(t){console.error(t),Qo.presentAlert(`error copying sequence to clipboard ${t}`)}}}),n.push("<hr/>"))}return this.browser.circularView&&(this.hasPairs||this.hasSupplemental)&&(this.hasPairs&&n.push({label:"Add discordant pairs to circular view",click:()=>{this.parent.addPairedChordsForViewport(e)}}),this.hasSupplemental&&n.push({label:"Add split reads to circular view",click:()=>{this.parent.addSplitChordsForViewport(e)}}),n.push("<hr/>")),n}getClickedObject(t){const e=t.viewport,n=t.y,r=t.genomicLocation,i=this.parent.showSoftClips;let o=e.cachedFeatures;if(!o||0===o.length)return;let s=o.packedAlignmentRows,a=o.downsampledIntervals;const c="SQUISHED"===this.displayMode?this.squishedRowHeight:this.alignmentRowHeight;let l=Math.floor((n-this.top-this.alignmentsYOffset)/c);if(l<0){for(let t=0;t<a.length;t++)if(a[t].start<=r&&a[t].end>=r)return a[t]}else if(l<s.length){const t=s[l].alignments.filter((t=>t.containsLocation(r,i)));if(t.length>0)return t[0]}}getConnectorColor(t){if(this.pairConnectorColor)return this.pairConnectorColor;switch(this.colorBy){case"strand":case"firstOfPairStrand":case"pairOrientation":case"tag":return this.parent.color||"rgb(200, 200, 200)";default:return this.getAlignmentColor(t)}}getAlignmentColor(t){let e=this.parent.color||"rgb(185, 185, 185)";const n=this.colorBy;switch(n){case"strand":e=t.strand?this.posStrandColor:this.negStrandColor;break;case"firstOfPairStrand":t instanceof ua?e=t.firstOfPairStrand()?this.posStrandColor:this.negStrandColor:t.isPaired()&&(t.isFirstOfPair()?e=t.strand?this.posStrandColor:this.negStrandColor:t.isSecondOfPair()?e=t.strand?this.negStrandColor:this.posStrandColor:console.error("ERROR. Paired alignments are either first or second."));break;case"unexpectedPair":case"pairOrientation":if(this.pairOrientation&&t.pairOrientation){const n=cl[this.pairOrientation];if(n){const r=this.pairColors[n[t.pairOrientation]];if(r){e=r;break}}}if("pairOrientation"===n)break;case"tlen":case"fragmentLength":t.mate&&t.isMateMapped()&&(t.mate.chr!==t.chr?e=ll(t.mate.chr):this.parent.minTemplateLength&&Math.abs(t.fragmentLength)<this.parent.minTemplateLength?e=this.smallTLENColor:this.parent.maxTemplateLength&&Math.abs(t.fragmentLength)>this.parent.maxTemplateLength&&(e=this.largeTLENColor));break;case"tag":const r=t.tags()[this.colorByTag];void 0!==r&&(this.bamColorTag===this.colorByTag?e="rgb("+r+")":(this.tagColors||(this.tagColors=new _c("Set1")),e=this.tagColors.getColor(r)));break;default:e=this.parent.color||"rgb(185, 185, 185)"}return e}}function sl(t,e){const n=t.direction;for(let n of e.packedAlignmentRows)n.updateScore(t,e);e.packedAlignmentRows.sort((function(t,e){const r=t.score>e.score?1:t.score<e.score?-1:0;return!0===n?r:-r}))}function al(t,e){let n;return n=t<5?.1:Math.max(.1,Math.min(1,.1+.9*(t-5)/15)),n=Math.round(10*n)/10,n<1&&(e=ro.addAlpha(e,n)),e}const cl={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 ll(t){if(hl[t])return hl[t];if(hl["chr"+t]){const e=hl["chr"+t];return hl[t]=e,e}{const e=ro.randomRGB(0,255);return hl[t]=e,e}}const hl={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 ul,fl;class dl extends sa{constructor(t,e,n,r){super(t,e,n,r)}initializationHelper(){this.rulerSweeper=new la(this),this.$multiLocusCloseButton=pe("<div>",{class:"igv-multi-locus-close-button"}),this.$viewport.append(this.$multiLocusCloseButton),this.$multiLocusCloseButton.get(0).appendChild(ye("times-circle")),this.$multiLocusCloseButton.click((()=>{this.browser.removeMultiLocusPanel(this.referenceFrame)})),this.$rulerLabel=pe("<div>",{class:"igv-multi-locus-ruler-label"}),this.$viewport.append(this.$rulerLabel),this.$rulerLabel.click((async()=>{await this.browser.gotoMultilocusPanel(this.referenceFrame)})),this.$tooltip=pe("<div>",{class:"igv-ruler-tooltip"}),this.$tooltip.height(this.$viewport.height()),this.$viewport.append(this.$tooltip),this.$tooltipContent=pe("<div>"),this.$tooltip.append(this.$tooltipContent),this.attachMouseHandlers(na.isWholeGenomeView(this.referenceFrame.chr)),this.$tooltip.hide(),this.dismissLocusLabel()}presentLocusLabel(t){this.$rulerLabel.get(0).innerHTML="",this.$rulerLabel.get(0).style.backgroundColor=ll(this.referenceFrame.chr),this.$rulerLabel.get(0).appendChild((()=>{const e=`<div>${this.referenceFrame.getMultiLocusLabel(t)}</div>`;return document.createRange().createContextualFragment(e).firstChild})()),this.$rulerLabel.show(),this.$multiLocusCloseButton.show()}presentLocusLabel_Square_Dot(t){this.$rulerLabel.get(0).innerHTML="",this.$rulerLabel.get(0).appendChild((()=>{const t=`<div>\n <?xml version="1.0" encoding="UTF-8"?>\n <svg width="14px" height="14px" viewBox="0 0 89 89" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">\n <g>\n <circle id="Oval" fill="${ll(this.referenceFrame.chr)}" cx="44.5" cy="44.5" r="44.5"></circle>\n </g>\n </svg>\n </div>`;return document.createRange().createContextualFragment(t).firstChild})()),this.$rulerLabel.get(0).appendChild((()=>{const e=`<div>${this.referenceFrame.getMultiLocusLabel(t)}</div>`;return document.createRange().createContextualFragment(e).firstChild})()),this.$rulerLabel.show(),this.$multiLocusCloseButton.show()}dismissLocusLabel(){this.$rulerLabel.hide(),this.$multiLocusCloseButton.hide()}attachMouseHandlers(t){if(this.namespace=`.ruler_track_viewport_${this.browser.referenceFrameList.indexOf(this.referenceFrame)}`,this.$viewport.off(this.namespace),!0===t){const t=this.browser.referenceFrameList.indexOf(this.referenceFrame),e=`click${this.namespace}`;this.$viewport.on(e,(e=>{const{x:n}=we(e,this.$viewport.get(0)),r=Math.round(this.referenceFrame.start+this.referenceFrame.toBP(n));let i;const{chr:o}=this.browser.genome.getChromosomeCoordinate(r);if(1===this.browser.referenceFrameList.length)i=o;else{let e=this.browser.referenceFrameList.map((({locusSearchString:t})=>t));e[t]=o,i=e.join(" ")}this.browser.search(i)})),this.$viewport.get(0).style.cursor="pointer"}else this.$viewport.get(0).style.cursor="default"}mouseMove(t){if(!0===this.browser.cursorGuideVisible){void 0===fl?(fl=this,this.$tooltip.show()):fl.guid!==this.guid?(fl.$tooltip&&fl.$tooltip.hide(),this.$tooltip.show(),fl=this):this.$tooltip.show();if(this.browser.isMultiLocusWholeGenomeView()||na.isWholeGenomeView(this.referenceFrame.chr))return void this.$tooltip.hide();const{x:e}=we(t,this.$viewport.get(0)),{start:n,bpPerPixel:r}=this.referenceFrame,i=Math.round(.5+n+Math.max(0,e)*r);this.$tooltipContent.text(Se(i));const{width:o}=this.$tooltipContent.get(0).getBoundingClientRect(),{width:s}=this.$viewport.get(0).getBoundingClientRect();this.$tooltip.css({left:`${Ji(e,0,s-o)}px`}),clearTimeout(ul),ul=setTimeout((()=>{this.$tooltip&&this.$tooltip.hide()}),1e4)}}startSpinner(){}stopSpinner(){}dispose(){this.rulerSweeper.dispose(),super.dispose()}}class pl extends sa{constructor(t,e,n,r){super(t,e,n,r)}initializationHelper(){this.canvas=document.createElement("canvas"),this.canvas.className="igv-ideogram-canvas",this.$content.append(pe(this.canvas)),this.ideogram_ctx=this.canvas.getContext("2d"),this.addMouseHandlers()}addMouseHandlers(){this.addViewportClickHandler(this.$viewport.get(0))}addViewportClickHandler(t){this.boundClickHandler=function(t){const{xNormalized:e,width:n}=we(t,this.ideogram_ctx.canvas),{bpLength:r}=this.browser.genome.getChromosome(this.referenceFrame.chr),i=this.referenceFrame.bpPerPixel*n/r;let o=e;o-i/2<0&&(o=i/2);o+i/2>1&&(o=1-i/2);const s=Math.round((o-i/2)*r),a=Math.round((o+i/2)*r);this.referenceFrame.start=s,this.referenceFrame.end=a,this.referenceFrame.bpPerPixel=(a-s)/n,this.browser.updateViews(this.referenceFrame,this.browser.trackViews,!0)}.bind(this),t.addEventListener("click",this.boundClickHandler)}setWidth(t){this.$viewport.width(t)}drawSVGWithContext(t,e,n,r,i,o,s){t.saveWithTranslationAndClipRect(r,i,o,e,n,s),this.trackView.track.draw({context:t,referenceFrame:this.referenceFrame,pixelWidth:e,pixelHeight:n}),t.restore()}repaint(){this.draw({referenceFrame:this.referenceFrame})}draw({referenceFrame:t}){ls.configureHighDPICanvas(this.ideogram_ctx,this.$viewport.width(),this.$viewport.height()),this.trackView.track.draw({context:this.ideogram_ctx,referenceFrame:t,pixelWidth:this.$viewport.width(),pixelHeight:this.$viewport.height()})}startSpinner(){}stopSpinner(){}}function gl(t,e,n,r){return"ruler"===t.track.type?new dl(t,e,n,r):"ideogram"===t.track.id?new pl(t,e,n,r):new sa(t,e,n,r)}const ml={textAlign:"start",textBaseline:"bottom",strokeStyle:"black",fillStyle:"black"};class vl{constructor(t,e,n,r){this.guid=be(),this.trackView=t,this.browser=t.browser,this.viewport=ge({class:"igv-viewport"}),e.appendChild(this.viewport),t.track.height&&(this.viewport.style.height=`${t.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(r),!1===this.browser.showSampleNames&&this.hide(),this.addMouseHandlers()}checkCanvas(){const t=window.devicePixelRatio,e=this.viewport.clientHeight,n=this.browser.sampleNameViewportWidth;if(this.canvas.width!==n*t||this.canvas.height!==e*t){const r=this.canvas;r.width=n*t,r.height=e*t,r.style.width=`${n}px`,r.style.height=`${e}px`,this.ctx=this.canvas.getContext("2d"),this.ctx.scale(t,t)}}setTop(t){if("function"==typeof this.trackView.track.getSamples){this.contentTop=t;const e=this.trackView.track.getSamples();this.repaint(e)}}setWidth(t){this.viewport.innerWidth=t,this.checkCanvas()}show(){this.viewport.style.display="block"}hide(){this.viewport.style.display="none"}async repaint(t){this.checkCanvas(),this.draw({context:this.ctx,samples:t})}draw({context:t,samples:e}){if(!e||0===e.names.length)return;!function(t,{textAlign:e,textBaseline:n,strokeStyle:r,fillStyle:i},o){const s=Math.min(o,10);t.font=`${s}px sans-serif`,t.textAlign=e,t.textBaseline=n,t.fillStyle=i}(t,ml,e.height);t.clearRect(0,0,t.canvas.width,t.canvas.height),t.fillStyle=function(t){const{r:e,g:n,b:r}=xc[t];return`rgb(${e},${n},${r})`}("lead");const n=this.viewport.getBoundingClientRect().height;let r=(e.yOffset||0)+this.contentTop;for(let i of e.names){if(r>n)break;if(r+e.height>0){const n=i,o=bl(t,n,r,e.height);t.fillText(n,4,o)}r+=e.height}}renderSVGContext(t,{deltaX:e,deltaY:n}){if("function"==typeof this.trackView.track.getSamples){const r=this.trackView.track.getSamples(),i=0,{width:o,height:s}=this.viewport.getBoundingClientRect(),a=`${(this.trackView.track.name||this.trackView.track.id).replace(/\W/g,"")}_sample_names_guid_${be()}`;t.saveWithTranslationAndClipRect(a,e,n+i,o,s,-i),this.draw({context:t,samples:r}),t.restore()}}addMouseHandlers(){this.addViewportContextMenuHandler(this.viewport)}removeMouseHandlers(){this.removeViewportContextMenuHandler(this.viewport)}addViewportContextMenuHandler(t){this.boundContextMenuHandler=function(t){t.preventDefault(),t.stopPropagation();const e={label:"Name Panel Width",value:this.browser.sampleNameViewportWidth,callback:t=>{this.browser.sampleNameViewportWidth=parseInt(t);for(let{sampleNameViewport:t}of this.browser.trackViews)t.setWidth(this.browser.sampleNameViewportWidth);this.browser.layoutChange()}};this.browser.inputDialog.present(e,t)}.bind(this),t.addEventListener("contextmenu",this.boundContextMenuHandler)}removeViewportContextMenuHandler(t){t.removeEventListener("contextmenu",this.boundContextMenuHandler)}dispose(){this.removeMouseHandlers(),this.viewport.remove()}}function bl(t,e,n,r){return n+r-function(t,e,n){const{actualBoundingBoxAscent:r,actualBoundingBoxDescent:i}=t.measureText(e);return(n-(r+i))/2}(t,e,r)}class wl extends es{constructor({parent:t,width:e}){super({parent:t,width:e,border:"1px solid gray"})}configure(t,e){this.colorHandlers=e,this.setActiveColorHandler("color"),this.createSwatches(t)}setActiveColorHandler(t){this.activeColorHandler=this.colorHandlers[t]}createSwatches(t){this.container.querySelectorAll(".igv-ui-color-swatch").forEach((t=>t.remove()));const e=Object.values(lo);for(let t of e){const e=ge({class:"igv-ui-color-swatch"});this.container.appendChild(e),this.decorateSwatch(e,t)}if(t)for(let e of t){const t=ge({class:"igv-ui-color-swatch"});this.container.appendChild(t),this.decorateSwatch(t,e)}}decorateSwatch(t,e){t.style.backgroundColor=e,t.addEventListener("mouseenter",(()=>t.style.borderColor=e)),t.addEventListener("mouseleave",(()=>t.style.borderColor="white")),t.addEventListener("click",(t=>{t.stopPropagation(),this.activeColorHandler(e)})),t.addEventListener("touchend",(t=>{t.stopPropagation(),this.activeColorHandler(e)}))}}const yl=function(t){this.popover=ge({class:"igv-menu-popup"}),t.appendChild(this.popover);const e=ge({class:"igv-menu-popup-header"});this.popover.appendChild(e),ke(e,(()=>this.hide())),this.popoverContent=ge(),this.popover.appendChild(this.popoverContent),oo(this.popover,e),e.addEventListener("click",(t=>{t.stopPropagation(),t.preventDefault()})),this.hide()};yl.prototype.hide=function(){this.popover.style.display="none"},yl.prototype.presentMenuList=function(t){if(xl(),t.length>0){this.popoverContent.innerHTML="",t=Oo.trackMenuItemListHelper(t,this);for(let e of t){e.init&&e.init();let n=e.object;0===t.indexOf(e)&&n.removeClass("igv-track-menu-border-top"),n.hasClass("igv-track-menu-border-top")||n.hasClass("igv-menu-popup-check-container")||n.is("div")&&n.addClass("igv-menu-popup-shim"),this.popoverContent.appendChild(n.get(0))}this.popover.style.display="flex";const{width:e}=this.popover.getBoundingClientRect();this.popover.style.left=-e+"px",this.popover.style.top="0px"}},yl.prototype.presentTrackContextMenu=function(t,e){this.popoverContent.innerHTML="";const n=(r=e,i=this.popover,r.map((t=>{let e;if("string"==typeof t&&"<hr/>"===t)e=document.createElement("hr");else if("string"==typeof t)e=ge({class:"context-menu"}),e.innerHTML=t;else if("Node"==typeof t)e=t;else{if("function"==typeof t.init&&t.init(),"checkbox"===t.type)e=Po("Show all bases",t.value);else if("color"===t.type){const r=new wl({parent:i.parentElement,width:364});r.configure(void 0,{color:e=>t.click(e)}),e=ge({class:"context-menu"}),"string"==typeof t.label&&(e.innerHTML=t.label);const o=t=>{r.show(),me(i),t.preventDefault(),t.stopPropagation()};e.addEventListener("click",o),e.addEventListener("touchend",o),e.addEventListener("mouseup",(function(t){t.preventDefault(),t.stopPropagation()}))}else e=ge({class:"context-menu"}),"string"==typeof t.label&&(e.innerHTML=t.label);if(t.click&&"color"!==t.type){function n(e){t.click(),me(i),e.preventDefault(),e.stopPropagation()}e.addEventListener("click",n),e.addEventListener("touchend",n),e.addEventListener("mouseup",(function(t){t.preventDefault(),t.stopPropagation()}))}}return{el:e,init:t.init}})));var r,i;for(let{el:t}of n)this.popoverContent.appendChild(t);!function(t,e){e.style.display="flex";const{x:n,y:r}=we(t,e.parentNode),{width:i}=e.getBoundingClientRect(),o=n+i,{width:s}=e.parentNode.getBoundingClientRect();e.style.left=`${o>s?n-(o-s):n}px`,e.style.top=`${r}px`}(t,this.popover)},yl.prototype.dispose=function(){this.popoverContent.innerHTML="",this.popover.innerHTML="",Object.keys(this).forEach((function(t){this[t]=void 0}))};const xl=()=>{const t=document.querySelectorAll(".igv-menu-popup");for(let e=0;e<t.length;e++)t[e].style.display="none"},kl=new Set(["ruler","sequence","ideogram"]),_l=new Set(["ruler","sequence","ideogram"]);class Sl{constructor(t,e,n){this.browser=t,this.track=n,n.trackView=this,this.addDOMToColumnContainer(t,e,t.referenceFrameList)}startSpinner(){this.viewports&&this.viewports.length>0&&this.viewports[0].startSpinner()}stopSpinner(){this.viewports&&this.viewports.length>0&&this.viewports[0].stopSpinner()}addDOMToColumnContainer(t,e,n){this.axis=this.createAxis(t,this.track),this.viewports=[];const r=t.calculateViewportWidth(n.length),i=e.querySelectorAll(".igv-column");for(let t=0;t<i.length;t++){const e=gl(this,i[t],n[t],r);this.viewports.push(e)}this.sampleNameViewport=new vl(this,t.columnContainer.querySelector(".igv-sample-name-column"),void 0,t.sampleNameViewportWidth),this.createTrackScrollbar(t),this.createTrackDragHandle(t),this.createTrackGearPopup(t)}createAxis(t,e){const n=ge();if(t.columnContainer.querySelector(".igv-axis-column").appendChild(n),n.style.height=`${e.height}px`,"function"==typeof e.paintAxis){e.dataRange&&n.addEventListener("click",(()=>{t.dataRangeDialog.configure(this),t.dataRangeDialog.present(pe(t.columnContainer))}));const{width:r,height:i}=n.getBoundingClientRect();this.axisCanvas=document.createElement("canvas"),this.axisCanvas.style.width=`${r}px`,this.axisCanvas.style.height=`${i}px`,n.appendChild(this.axisCanvas)}return n}resizeAxisCanvas(t,e){this.axis.style.width=`${t}px`,this.axis.style.height=`${e}px`,"function"==typeof this.track.paintAxis&&(this.axisCanvas.style.width=`${t}px`,this.axisCanvas.style.height=`${e}px`)}removeDOMFromColumnContainer(){this.boundAxisClickHander&&this.removeAxisEventListener(this.axis),this.axis.remove();for(let t of this.viewports)t.$viewport.remove();this.sampleNameViewport.dispose(),this.removeTrackScrollMouseHandlers(),this.outerScroll.remove(),this.removeTrackDragMouseHandlers(),this.dragHandle.remove(),this.removeTrackGearMouseHandlers(),this.gearContainer.remove()}renderSVGContext(t,{deltaX:e,deltaY:n}){!function(t,e,n,r,i){if("function"==typeof e.paintAxis){const{y:o,width:s,height:a}=n.getBoundingClientRect(),c=`${(e.name||e.id).replace(/\W/g,"")}_axis_guid_${be()}`;t.saveWithTranslationAndClipRect(c,r,o+i,s,a,0),e.paintAxis(t,s,a),t.restore()}}(t,this.track,this.axisCanvas,e,n);const{width:r}=this.axis.getBoundingClientRect(),{y:i}=this.viewports[0].$viewport.get(0).getBoundingClientRect();let o={deltaX:r+e,deltaY:i+n};for(let e of this.viewports){e.renderSVGContext(t,o);const{width:n}=e.$viewport.get(0).getBoundingClientRect();o.deltaX+=n}!0===this.browser.showSampleNames&&this.sampleNameViewport.renderSVGContext(t,o)}dataRange(){return this.track.dataRange?this.track.dataRange:void 0}setDataRange(t,e){void 0!==t&&(this.track.dataRange.min=t),void 0!==e&&(this.track.dataRange.max=e),this.track.autoscale=!1,this.repaintViews()}presentColorPicker(t){if(!1===_l.has(this.track.type)){const e=[],n=this.track.color||this.track.defaultColor;_e(n)&&e.push(n),this.track.altColor&&_e(this.track.altColor)&&e.push(this.track.altColor);const r=e.map((t=>t.startsWith("#")?t:t.startsWith("rgb(")?ro.rgbToHex(t):ro.colorNameToHex(t))),i={color:t=>{this.track.color=t,this.repaintViews()},altColor:t=>{this.track.altColor=t,this.repaintViews()}};this.browser.genericColorPicker.configure(r,i),this.browser.genericColorPicker.setActiveColorHandler(t),this.browser.genericColorPicker.show()}}setTrackHeight(t,e){e||(this.track.minHeight&&(t=Math.max(this.track.minHeight,t)),this.track.maxHeight&&(t=Math.min(this.track.maxHeight,t))),this.track.height=t,this.resizeAxisCanvas(this.axis.clientWidth,this.track.height),"function"==typeof this.track.paintAxis&&this.paintAxis();for(let{$viewport:e}of this.viewports)e.height(t);if(this.sampleNameViewport.viewport.style.height=`${t}px`,"function"!=typeof this.track.computePixelHeight)for(let e of this.viewports)e.setContentHeight(t);this.repaintViews(),!1===kl.has(this.track.type)&&this.updateScrollbar(),this.dragHandle.style.height=`${t}px`,this.gearContainer.style.height=`${t}px`}updateScrollbar(){const t=this.viewports[0].$viewport.height();this.outerScroll.style.height=`${t}px`;const e=Cl(this.viewports),n=Math.round(t/e*t);e>t?(this.innerScroll.style.display="block",this.innerScroll.style.height=`${n}px`):this.innerScroll.style.display="none"}moveScroller(t){const e=pe(this.innerScroll).position().top+t,n=Math.min(Math.max(0,e),this.outerScroll.clientHeight-this.innerScroll.clientHeight);pe(this.innerScroll).css("top",`${n}px`);const r=Cl(this.viewports),i=-Math.round(n*(r/this.viewports[0].$viewport.height()));for(let t of this.viewports)t.setTop(i);this.sampleNameViewport.trackScrollDelta=t,this.sampleNameViewport.setTop(i)}isLoading(){for(let t of this.viewports)if(t.isLoading())return!0}repaintViews(){for(let t of this.viewports)t.isVisible()&&t.repaint();"function"==typeof this.track.paintAxis&&this.paintAxis(),this.repaintSamples()}repaintSamples(){if("function"==typeof this.track.getSamples){const t=this.track.getSamples();this.sampleNameViewport.repaint(t)}}setTrackLabelName(t){this.viewports.forEach((e=>e.setTrackLabel(t)))}resize(t){for(let e of this.viewports)e.setWidth(t)}async updateViews(){if(!this.browser||!this.browser.referenceFrameList)return;const t=this.viewports.filter((t=>t.isVisible()));if(t.forEach((t=>t.shift())),this.browser.dragObject)return;let e=this.track.autoscale||this.track.autoscaleGroup||"ruler"===this.track.type?t:t.filter((t=>t.needsRepaint()));e=e.filter((t=>t.checkZoomIn()));const n=e.filter((t=>t.needsReload()));for(let t of n)await t.loadFeatures();if(!this.disposed){if(this.track&&"function"==typeof this.track.variantRowCount&&n.length>0){let t=0;for(let e of this.viewports)e.featureCache&&e.featureCache.features&&(t=Math.max(t,e.featureCache.features.reduce(((t,e)=>Math.max(t,e.row||0)),0)));if(this.track.nVariantRows!==t+1){this.track.variantRowCount(t+1);for(let t of this.viewports)t.checkContentHeight()}}if(this.track.autoscale){let e=[];for(let n of t){const t=n.referenceFrame,r=t.start,i=r+t.toBP(pe(n.contentDiv).width());if(n.featureCache&&n.featureCache.features)if("function"==typeof n.featureCache.features.getMax){const t=n.featureCache.features.getMax(r,i);e.push({value:t})}else e=e.concat(No(n.featureCache.features,r,i))}"function"==typeof this.track.doAutoscale?this.track.dataRange=this.track.doAutoscale(e):this.track.dataRange=ms(e)}for(let t of e)t.repaint();this.adjustTrackHeight(),this.repaintSamples(),this.updateRulerViewportLabels()}}updateRulerViewportLabels(){const t=this.browser.calculateViewportWidth(this.viewports.length);for(let e of this.viewports)"ruler"===this.track.type&&(this.viewports.length>1?e.presentLocusLabel(t):e.dismissLocusLabel())}async getInViewFeatures(){if(!this.browser||!this.browser.referenceFrameList)return[];let t=[];for(let e of this.viewports)if(e.needsReload()&&await e.loadFeatures(),e.featureCache&&e.featureCache.features){const n=e.referenceFrame,r=n.start,i=r+n.toBP(pe(e.contentDiv).width());if("function"==typeof e.featureCache.features.getMax){const n=e.featureCache.features.getMax(r,i);t.push({value:n})}else t=t.concat(No(e.featureCache.features,r,i))}return t}checkContentHeight(){for(let t of this.viewports)t.checkContentHeight();this.adjustTrackHeight()}adjustTrackHeight(){var t=Cl(this.viewports);if(this.track.autoHeight?this.setTrackHeight(t,!1):this.track.paintAxis&&this.paintAxis(),!1===kl.has(this.track.type)){const t=this.viewports[0].getContentTop(),e=this.viewports.map((t=>t.getContentHeight())),n=Math.min(...e),r=Math.min(0,this.viewports[0].$viewport.height()-n);if(t<r)for(let t of this.viewports)t.$content.css("top",`${r}px`);this.updateScrollbar()}}createTrackScrollbar(t){const e=ge();if(t.columnContainer.querySelector(".igv-scrollbar-column").appendChild(e),e.style.height=`${this.track.height}px`,this.outerScroll=e,!1===kl.has(this.track.type)){const n=ge();e.appendChild(n),this.innerScroll=n,this.addTrackScrollMouseHandlers(t)}}createTrackDragHandle(t){const e="ideogram"===this.track.type||"ruler"===this.track.type?"igv-track-drag-shim":"igv-track-drag-handle";this.dragHandle=ge({class:e}),t.columnContainer.querySelector(".igv-track-drag-column").appendChild(this.dragHandle),this.dragHandle.style.height=`${this.track.height}px`,this.addTrackDragMouseHandlers(t)}createTrackGearPopup(t){this.gearContainer=ge(),t.columnContainer.querySelector(".igv-gear-menu-column").appendChild(this.gearContainer),this.gearContainer.style.height=`${this.track.height}px`,!0===this.track.ignoreTrackMenu||(this.gear=ge(),this.gearContainer.appendChild(this.gear),this.gear.appendChild(ye("cog")),this.trackGearPopup=new yl(this.gear),this.addTrackGearMouseHandlers())}addAxisEventListener(t){this.boundAxisClickHander=function(t){this.browser.dataRangeDialog.configure(this),this.browser.dataRangeDialog.present(pe(this.browser.columnContainer))}.bind(this),t.addEventListener("click",this.boundAxisClickHander)}removeAxisEventListener(t){t.removeEventListener("click",this.boundAxisClickHander)}addTrackScrollMouseHandlers(t){this.boundTrackScrollMouseDownHandler=function(e){e.stopPropagation();const{y:n}=ve(e);pe(this.innerScroll).data("yDown",n.toString()),this.boundColumnContainerMouseMoveHandler=function(t){t.stopPropagation();const{y:e}=ve(t);this.moveScroller(e-parseInt(pe(this.innerScroll).data("yDown"))),pe(this.innerScroll).data("yDown",e.toString())}.bind(this),t.columnContainer.addEventListener("mousemove",this.boundColumnContainerMouseMoveHandler)}.bind(this),this.innerScroll.addEventListener("mousedown",this.boundTrackScrollMouseDownHandler),this.boundColumnContainerMouseUpHandler=function(e){t.columnContainer.removeEventListener("mousemove",this.boundColumnContainerMouseMoveHandler)}.bind(this),t.columnContainer.addEventListener("mouseup",this.boundColumnContainerMouseUpHandler)}removeTrackScrollMouseHandlers(){!1===kl.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(t){if("ideogram"===this.track.id||"ruler"===this.track.id);else{let e;function n(n){n.preventDefault(),e=n.target,e.classList.add("igv-track-drag-handle-hover"),t.startTrackDrag(this)}function r(n){t.endTrackDrag(),e&&n.target!==e&&e.classList.remove("igv-track-drag-handle-hover"),e=void 0}function i(n){n.preventDefault(),void 0===e&&n.target.classList.add("igv-track-drag-handle-hover"),t.updateTrackDrag(this)}function o(t){t.preventDefault(),void 0===e&&t.target.classList.remove("igv-track-drag-handle-hover")}this.boundTrackDragMouseDownHandler=n.bind(this),this.dragHandle.addEventListener("mousedown",this.boundTrackDragMouseDownHandler),this.boundDocumentTrackDragMouseUpHandler=r.bind(this),document.addEventListener("mouseup",this.boundDocumentTrackDragMouseUpHandler),this.boundTrackDragMouseEnterHandler=i.bind(this),this.dragHandle.addEventListener("mouseenter",this.boundTrackDragMouseEnterHandler),this.dragHandle.addEventListener("mouseout",(t=>{t.preventDefault(),void 0===e&&t.target.classList.remove("igv-track-drag-handle-hover")})),this.boundTrackDragMouseOutHandler=o.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 t(t){t.preventDefault(),t.stopPropagation(),this.trackGearPopup.presentMenuList(Oo.trackMenuItemList(this))}this.boundTrackGearClickHandler=t.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 t of this.viewports)t.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();const t=this.track;"function"==typeof t.dispose&&t.dispose();for(let e of Object.keys(t))t[e]=void 0;for(let t of Object.keys(this))this[t]=void 0;this.alert&&this.alert.container.remove(),this.disposed=!0}paintAxis(){if("function"==typeof this.track.paintAxis){const{width:t,height:e}=this.axisCanvas.getBoundingClientRect(),n=window.devicePixelRatio||1;this.axisCanvas.height=n*e,this.axisCanvas.width=n*t;const r=this.axisCanvas.getContext("2d");r.scale(n,n),this.track.paintAxis(r,t,e)}}}function Cl(t){const e=t.map((t=>t.getContentHeight()));return Math.max(...e)}function El(t,e){if(t.length<6)console.log("Skipping line: "+t.join(" "));else{var n={chr1:t[0],start1:Number.parseInt(t[1]),end1:Number.parseInt(t[2]),chr2:t[3],start2:Number.parseInt(t[4]),end2:Number.parseInt(t[5])};if(!(isNaN(n.start1)||isNaN(n.end1)||isNaN(n.start2)||isNaN(n.end2))){if(t.length>6&&"."!==t[6]&&(n.name=t[6]),t.length>7&&"."!==t[7]&&(n.score=Number(t[7])),t.length>8&&"."!==t[8]&&(n.strand1=t[8]),t.length>9&&"."!==t[9]&&(n.strand2=t[9]),e){const r=e.colorColumn;r&&r<t.length&&(n.color=ro.createColorString(t[r]));const i=e.thicknessColumn;i&&i<t.length&&(n.thickness=t[i]),t.length>10&&e.columnNames&&e.columnNames.length===t.length&&(n.extras=t.slice(10))}return n.chr1===n.chr2&&(n.chr=n.chr1,n.start=Math.min(n.start1,n.start2),n.end=Math.max(n.end1,n.end2)),n}}}function Al(t,e){if(!(t.length<8))return{chr:t[0],start:Number.parseInt(t[1]),end:Number.parseInt(t[2]),color:ro.createColorString(t[6]),value:Number(t[7])}}function Tl(t,e){if(!(t.length<6))return{chr:t[0],start:t[1],end:t[2],chr1:t[8],start1:Number.parseInt(t[9]),end1:Number.parseInt(t[10]),chr2:t[13],start2:Number.parseInt(t[14]),end2:Number.parseInt(t[15]),name:t[3],score:Number(t[4]),value:Number(t[5]),color:"."===t[7]?void 0:"0"===t[7]?"rgb(0,0,0)":t[7]};console.log("Skipping line: "+t.join(" "))}const Ll=new Set(["transcript","primary_transcript","processed_transcript","mRNA","mrna","lnc_RNA","miRNA","ncRNA","rRNA","scRNA","snRNA","snoRNA","tRNA"]),Ml=new Set(["CDS","cds"]),Rl=new Set(["start_codon","stop_codon"]),Il=new Set(["5UTR","3UTR","UTR","five_prime_UTR","three_prime_UTR","3'-UTR","5'-UTR"]),Nl=new Set(["exon","coding-exon"]),Pl=new Set;for(let ud of[Ml,Rl,Il,Nl])for(let fd of ud)Pl.add(fd);function Ol(t){return t.includes("intron")}function Fl(t){return Ml.has(t)||Rl.has(t)}function Dl(t){return Il.has(t)}function Bl(t){return Ll.has(t)||t.endsWith("RNA")||t.endsWith("transcript")}function zl(t){return Pl.has(t)||t.endsWith("RNA")||Ol(t)}const Hl=new Set(["id","parent","name"]);class Vl{constructor(t){Object.assign(this,t)}popupData(t){const e=this.geneObject?this.geneObject.popupData():[];if(this.geneObject&&e.push("<hr/>"),this.name&&e.push({name:"Name",value:this.name}),e.push({name:"Type",value:this.type}),e.push({name:"Source",value:this.source}),void 0!==this.score&&e.push({name:"Score",value:this.score}),this.attributeString){const t=$l(this.attributeString,this.delim);for(let[n,r]of t)void 0!==r&&r.length>0&&!Hl.has(n.toLowerCase())&&e.push({name:n+":",value:r})}return e.push({name:"Location",value:`${this.chr}:${Se(this.start+1)}-${Se(this.end)}`}),e}getAttributeValue(t){if(this.hasOwnProperty(t))return this[t];if(this._attributeCache||(this._attributeCache=new Map),this._attributeCache.has(t))return this._attributeCache.get(t);{const e=$l(this.attributeString,this.delim);let n;for(let[r,i]of e)if(r===t){n=i;break}return this._attributeCache.set(t,n),n}}}class jl extends Vl{constructor(t){super(t),this.exons=[],this.parts=[]}addExon(t){this.exons.push(t),this.start=Math.min(this.start,t.start),this.end=Math.max(this.end,t.end)}addPart(t){this.parts.push(t)}assembleParts(){if(0===this.parts.length)return;this.parts.sort((function(t,e){return t.start-e.start}));let t=this.parts[0].start,e=this.parts[0].end;for(let n=1;n<this.parts.length;n++){const r=this.parts[n];if(!Ol(r.type))if(r.start<=e)e=Math.max(e,r.end);else{this.findExonContaining({start:t,end:e})||this.exons.push({start:t,end:e,psuedo:!0}),t=r.start,e=r.end}}this.findExonContaining({start:t,end:e})||(this.exons.push({start:t,end:e,psuedo:!0}),this.start=Math.min(this.start,t),this.end=Math.max(this.end,e));for(let t of this.parts){const e=t.type;Fl(e)?this.addCDS(t):Dl(e)&&this.addUTR(t)}}findExonContaining({start:t,end:e}){for(let n of this.exons)if(n.end>=e&&n.start<=t)return n}addCDS(t){let e;const n=this.exons;for(let r of n)if(r.start<=t.start&&r.end>=t.end){e=r;break}e?(e.cdStart=e.cdStart?Math.min(t.start,e.cdStart):t.start,e.cdEnd=e.cdEnd?Math.max(t.end,e.cdEnd):t.end):console.error("No exon found spanning "+t.start+"-"+t.end),this.cdStart=this.cdStart?Math.min(t.start,this.cdStart):t.start,this.cdEnd=this.cdEnd?Math.max(t.end,this.cdEnd):t.end}addUTR(t){let e;const n=this.exons;for(let r=0;r<n.length;r++)if(n[r].start<=t.start&&n[r].end>=t.end){e=n[r];break}e?t.start===e.start&&t.end===e.end?e.utr=!0:(t.end<e.end&&(e.cdStart=t.end),t.start>e.start&&(e.cdEnd=t.start)):console.error("No exon found spanning "+cds.start+"-"+cds.end)}finish(){this.assembleParts();var t=this.cdStart,e=this.cdEnd;this.exons.sort((function(t,e){return t.start-e.start})),t&&this.exons.forEach((function(n){(n.end<t||n.start>e)&&(n.utr=!0)}))}popupData(t){const e=super.popupData(t);for(let n of this.exons)if(!n.pseudo&&t>=n.start&&t<n.end&&"function"==typeof n.popupData){e.push("<hr/>");const r=n.popupData(t);for(let t of r)e.push(t)}for(let n of this.parts)if(t>=n.start&&t<n.end&&"function"==typeof n.popupData){e.push("<hr/>");const r=n.popupData(t);for(let t of r)e.push(t)}return e}}function Ul(t,e){const n=e.format;if(t.length<9)return;const r="gff3"===n?"=":" ";return new Vl({source:t[1],type:t[2],chr:t[0],start:parseInt(t[3])-1,end:parseInt(t[4]),score:"."===t[5]?void 0:Number(t[5]),strand:t[6],phase:"."===t[7]?0:parseInt(t[7]),attributeString:t[8],delim:r})}function ql(t,e){const n=Ul(t,e);if(!n)return;const r=$l(n.attributeString,n.delim);for(let[t,e]of r){const r=t.toLowerCase();"color"===r||"colour"===r?n.color=ro.createColorString(e):"ID"===t?n.id=e:"Parent"===t&&(n.parent=e)}return n}function Wl(t,e){const n=Ul(t,e);if(!n)return;const r=$l(n.attributeString,n.delim);let i,o;switch(n.type){case"gene":i="gene_id";break;case"transcript":i="transcript_id",o="gene_id";break;default:o="transcript_id"}for(let[t,e]of r){const r=t.toLowerCase();"color"===r||"colour"===r?n.color=ro.createColorString(e):t===i?n.id=e:t===o&&(n.parent=e)}return n}function $l(t,e){var n=[];for(let r of t.split(";")){r=r.trim();const t=r.indexOf(e);if(t>0&&t<r.length-1){const e=r.substring(0,t);let i=Gl(decodeURIComponent(r.substring(t+1).trim()));n.push([e,i])}}return n}function Gl(t){return t.startsWith('"')&&t.endsWith('"')&&(t=t.substr(1,t.length-2)),t}class Zl{constructor(t){this.message=t}}function Xl(t,e){if(t.length<3)return;e&&e.gffTags;const n=t[0],r=parseInt(t[1]),i=t.length>2?parseInt(t[2]):r+1;if(isNaN(r)||isNaN(i))return new Zl("Unparsable bed record.");const o=new oh({chr:n,start:r,end:i,score:1e3});try{if(t.length>3){if(t[3].indexOf(";")>0&&t[3].indexOf("=")>0){const e=$l(t[3],"=");o.attributes={};for(let t of e)o.attributes[t[0]]=t[1]}o.name||(o.name="."===t[3]?"":t[3])}if(t.length>4&&(o.score="."===t[4]?0:Number(t[4]),isNaN(o.score)))return o;if(t.length>5&&(o.strand=t[5],"."!==o.strand&&"+"!==o.strand&&"-"!==o.strand))return o;if(t.length>6&&(o.cdStart=parseInt(t[6]),isNaN(o.cdStart)))return o;if(t.length>7&&(o.cdEnd=parseInt(t[7]),isNaN(o.cdEnd)))return o;if(t.length>8&&"."!==t[8]&&"0"!==t[8]&&(o.color=ro.createColorString(t[8])),t.length>11){const e=parseInt(t[9]);if(e>1e3)return o;const n=t[10].replace(/,$/,"").split(","),i=t[11].replace(/,$/,"").split(",");if(n.length!==i.length||e!==n.length)return o;const s=[];for(let t=0;t<e;t++){const e=r+parseInt(i[t]),o=e+parseInt(n[t]);s.push({start:e,end:o})}th(s,o.cdStart,o.cdEnd),o.exons=s}if(e){let n=e.thicknessColumn,r=e.colorColumn;r&&r<t.length&&(o.color=ro.createColorString(t[r])),n&&n<t.length&&(o.thickness=t[n])}}catch(t){}return o}function Yl(t,e){if(t.length<=15)return;return{swScore:Number.parseInt(t[1]),milliDiv:Number.parseInt(t[2]),milliDel:Number.parseInt(t[3]),milliIns:Number.parseInt(t[4]),chr:t[5],start:Number.parseInt(t[6]),end:Number.parseInt(t[7]),strand:t[9],repName:t[10],repClass:t[11],repFamily:t[12],repStart:Number.parseInt(t[13]),repEnd:Number.parseInt(t[14]),repLeft:Number.parseInt(t[15])}}function Kl(t,e){var n=void 0===e.shift?0:1;if(t.length<=9+n)return;const r=parseInt(t[5+n]),i=parseInt(t[6+n]);var o={name:t[0+n],chr:t[1+n],strand:t[2+n],start:parseInt(t[3+n]),end:parseInt(t[4+n]),cdStart:r,cdEnd:i,id:t[0+n]},s=parseInt(t[7+n]),a=t[8+n].split(","),c=t[9+n].split(","),l=[];for(let t=0;t<s;t++){const e=parseInt(a[t]),n=parseInt(c[t]);l.push({start:e,end:n})}return th(l,r,i),o.exons=l,o}function Ql(t,e){var n=void 0===e.shift?0:1;if(t.length<=11+n)return;const r=parseInt(t[5+n]),i=parseInt(t[6+n]),o={name:t[11+n],chr:t[1+n],strand:t[2+n],start:parseInt(t[3+n]),end:parseInt(t[4+n]),cdStart:r,cdEnd:i,id:t[0+n]},s=parseInt(t[7+n]),a=t[8+n].split(","),c=t[9+n].split(","),l=[];for(let t=0;t<s;t++){const e=parseInt(a[t]),n=parseInt(c[t]);l.push({start:e,end:n})}return th(l,r,i),o.exons=l,o}function Jl(t,e){var n=void 0===e.shift?0:1;if(t.length<=10+n)return;const r=parseInt(t[6+n]),i=parseInt(t[7+n]);var o={name:t[0+n],id:t[1+n],chr:t[2+n],strand:t[3+n],start:parseInt(t[4+n]),end:parseInt(t[5+n]),cdStart:r,cdEnd:i},s=parseInt(t[8+n]),a=t[9+n].split(","),c=t[10+n].split(","),l=[];for(let t=0;t<s;t++){const e=parseInt(a[t]),n=parseInt(c[t]);l.push({start:e,end:n})}return th(l,r,i),o.exons=l,o}function th(t,e,n){for(let r of t){const t=r.end,i=r.start;t<e||i>n?r.utr=!0:(e>=i&&e<=t&&(r.cdStart=e),n>=i&&n<=t&&(r.cdEnd=n))}}function eh(t,e){var n,r,i,o,s,a,c;if(!(t.length<9))return n=t[0],r=parseInt(t[1]),i=parseInt(t[2]),s=t[3],a=Number(t[4]),o=t[5].trim(),c=Number(t[6]),0===a&&(a=c),{chr:n,start:r,end:i,name:s,score:a,strand:o,signal:c,pValue:Number(t[7]),qValue:Number(t[8])}}function nh(t,e){if(t.length<=3)return;const n={chr:t[0],start:parseInt(t[1]),end:parseInt(t[2]),value:Number(t[3])};if(e){let r=e.colorColumn;r&&r<t.length&&(n.color=ro.createColorString(t[r]))}return n}function rh(t,e){const n=e.wig;if(n&&"fixedStep"===n.format){const e=n.index*n.step+n.start,r=e+n.span,i=Number(t[0]);return++n.index,isNaN(i)?null:{chr:n.chrom,start:e,end:r,value:i}}if(n&&"variableStep"===n.format){if(t.length<2)return null;const e=parseInt(t[0],10)-1,r=e+n.span,i=Number(t[1]);return isNaN(i)?null:{chr:n.chrom,start:e,end:r,value:i}}return nh(t)}function ih(t,e){if(t.length<6)return;const n=["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"],r={chr:t[1],start:Number.parseInt(t[2]),end:Number.parseInt(t[3]),name:t[4],score:Number.parseInt(t[5])},i=Math.min(t.length,n.length);for(let e=6;e<i;e++)r[n[e]]=t[e];return r}class oh{constructor(t){Object.assign(this,t)}getAttributeValue(t){return this.hasOwnProperty(t)?this[t]:this.attributes?this.attributes[t]:void 0}}function sh(t,e){if(!(t.length<7)){var n=t[0],r=t[1],i=parseInt(t[2]),o=parseInt(t[3]),s=parseInt(t[4]),a=parseInt(t[5]),c=t[6],l={chr:n,name:r,junction_left:i,junction_right:o,num_junction_reads:s,num_spanning_frags:a,spanning_frag_coords:[],start:-1,end:-1},h=i,u=o;if(a>0)for(var f=c.split(","),d=0;d<f.length;d++){var p=f[d].split("-"),g=p[0],m=p[1];g<h&&(h=g),m>u&&(u=m),l.spanning_frag_coords.push({left:g,right:m})}return l.start=h,l.end=u,l}}function ah(t,e){if(t.length<7)return null;const n={chr:t[0],start:parseInt(t[1])-1,end:parseInt(t[2]),"Strongest SNP-risk allele":t[3],"Disease/Phenotype":t[4],"P-value":t[5],"Odds ratio or beta":t[6]};return t.length>6&&(n.PUBMEDID=`<a target = "blank" href = "https://www.ncbi.nlm.nih.gov/pubmed/${t[7]}">${t[7]}</a>`),n}function ch(t,e){const n=e.customFormat;if(t.length<n.fields.length)return;const r=n.coords||0,i=t[n.chr],o=parseInt(t[n.start])-r,s={chr:i,start:o,end:void 0!==n.end?parseInt(t[n.end]):o+1};return n.fields&&n.fields.forEach((function(e,r){r!==n.chr&&r!==n.start&&r!==n.end&&(s[e]=t[r])})),s}function lh(t,e){const n=e.columnNames;if(!n)throw Error("Sample names are not defined. Missing column headers?");const r=n.length-3,i=t[0],o=parseInt(t[1]),s=parseInt(t[2]),a=t.slice(3).map(Number);return a.length==r?{chr:i,start:o,end:s,values:a}:void console.warn(`${i}:${o}-${s} row contains ${a.length} sample columns instead of the expected ${r} columns. Skipping...`)}class hh{constructor(t){this.config=t,this.header={},t.nameField&&(this.header.nameField=t.nameField),this.skipRows=0,t.decode?(this.decode=t.decode,this.delimiter=t.delimiter||"\t"):t.format&&(this.header.format=t.format.toLowerCase(),this.setDecoder(this.header.format)),this.delimiter||(this.delimiter="\t")}async parseHeader(t){let e,n,r=this.header;for(;void 0!==(n=await t.nextLine());)if(n.startsWith("track")||n.startsWith("#track")){let t=uh(n);Object.assign(r,t)}else if(n.startsWith("browser"));else if(n.startsWith("#columns")){let t=fh(n);Object.assign(r,t)}else if(n.startsWith("##gff-version 3"))r.format="gff3";else if(n.startsWith("#gffTags"))r.gffTags=!0;else{if(n.startsWith("fixedStep")||n.startsWith("variableStep"))break;if(n.startsWith("#")){const t=n.split(this.delimiter||"\t");t.length>1&&(e=t)}else{this.setDecoder(r.format);const t=n.split(this.delimiter||"\t");try{const n=Object.assign({columnNames:e},r);if(this.decode(t,n))break;t.length>1&&(e=t)}catch(n){t.length>1&&(e=t)}}}if(e){r.columnNames=e;for(let t=0;t<e.length;t++)"color"===e[t]||"colour"===e[t]?r.colorColumn=t:"thickness"===e[t]&&(r.thicknessColumn=t)}return this.header=r,r}async parseFeatures(t){const e=[],n=this.decode,r=this.header.format,i=this.delimiter||"\t";let o,s=0,a=0;for(;void 0!==(o=await t.nextLine());){if(s++,s<=this.skipRows)continue;if(!o||o.startsWith("track")||o.startsWith("#")||o.startsWith("browser"))continue;if("wig"===r&&o.startsWith("fixedStep")){this.header.wig=dh(o);continue}if("wig"===r&&o.startsWith("variableStep")){this.header.wig=ph(o);continue}const t=o.split(i);if(t.length<1)continue;const c=n(t,this.header);c instanceof Zl?(a++,a>0&&console.error(`Error parsing line '${o}': ${c.message}`)):c&&e.push(c)}return n===El&&function(t){if(0==t.length)return;const e=t[0];if(void 0===e.score&&void 0!==e.name){for(let e of t)if(!("number"==typeof(n=e.name)?n-n==0:"string"==typeof n&&""!==n.trim()&&(Number.isFinite?Number.isFinite(+n):isFinite(+n)))&&"."!==e.name)return;for(let e of t)e.score=Number(e.name),delete e.name}var n;const r=t.filter((t=>t.chr1!==t.chr2));for(let e of r){const n=Object.assign({},e);n.dup=!0,t.push(n),e.chr=e.chr1,e.start=e.start1,e.end=e.end1,n.chr=n.chr2,n.start=n.start2,n.end=n.end2}}(e),e}setDecoder(t){switch(t){case"narrowpeak":case"broadpeak":case"regionpeak":case"peaks":this.decode=eh,this.delimiter=this.config.delimiter||/\s+/;break;case"bedgraph":this.decode=nh,this.delimiter=/\s+/;break;case"wig":this.decode=rh,this.delimiter=this.config.delimiter||/\s+/;break;case"gff3":case"gff":this.decode=ql,this.delimiter="\t";break;case"gtf":this.decode=Wl,this.delimiter="\t";break;case"fusionjuncspan":this.decode=sh,this.delimiter=this.config.delimiter||/\s+/;break;case"gtexgwas":this.skipRows=1,this.decode=ah,this.delimiter="\t";break;case"refflat":this.decode=Jl,this.delimiter=this.config.delimiter||/\s+/;break;case"genepred":this.decode=Kl,this.delimiter=this.config.delimiter||/\s+/;break;case"genepredext":this.decode=Ql,this.delimiter=this.config.delimiter||/\s+/;break;case"ensgene":this.decode=Kl,this.header.shift=1,this.delimiter=this.config.delimiter||/\s+/;break;case"refgene":this.decode=Ql,this.delimiter=this.config.delimiter||/\s+/,this.header.shift=1;break;case"bed":this.decode=Xl,this.delimiter=this.config.delimiter||/\s+/;break;case"bedpe":this.decode=El,this.delimiter=this.config.delimiter||"\t";break;case"bedpe-domain":this.decode=Al,this.headerLine=!0,this.delimiter=this.config.delimiter||"\t";break;case"bedpe-loop":this.decode=El,this.delimiter=this.config.delimiter||"\t",this.header={colorColumn:7};break;case"interact":this.decode=Tl,this.delimiter=this.config.delimiter||/\s+/;break;case"snp":this.decode=ih,this.delimiter="\t";break;case"rmsk":this.decode=Yl,this.delimiter="\t";break;case"gcnv":this.decode=lh,this.delimiter="\t";break;default:const e=function(t){return us&&us[t]?function(t){const e=t.fields,n=["chr","start","end"];for(let r=0;r<e.length;r++)for(let i of n)i===e[r]&&(t[i]=r);return t}(us[t]):void 0}(t);void 0!==e?(this.decode=ch,this.header.customFormat=e,this.delimiter=e.delimiter||"\t"):(this.decode=Xl,this.delimiter=this.config.delimiter||/\s+/)}}}function uh(t){const e={},n=t.split(/(?:")([^"]+)(?:")|([^\s"]+)(?=\s+|$)/g);let r;const i=[];for(let t of n)t&&0!==t.trim().length&&(t.endsWith("=")?r=t:r?(i.push(r+t),r=void 0):i.push(t));for(let t of i){if(!t)return;var o=t.split("=",2);if(2===o.length){const t=o[0].trim(),n=o[1].trim();if(e.hasOwnProperty(t)){let r=e[t];Array.isArray(r)?r.push(n):e[t]=[r,n]}else e[t]=n}}return"interact"==e.type?e.format="interact":"gcnv"===e.type&&(e.format="gcnv"),e}function fh(t){let e={},n=t.split(/\s+/);if(2===n.length){n[1].split(";").forEach((function(t){let n=t.split("=");"color"===n[0]?e.colorColumn=Number.parseInt(n[1])-1:"thickness"===n[0]&&(e.thicknessColumn=Number.parseInt(n[1])-1)}))}return e}function dh(t){const e=t.split(/\s+/);return{format:"fixedStep",chrom:e[1].split("=")[1],start:parseInt(e[2].split("=")[1],10)-1,step:parseInt(e[3].split("=")[1],10),span:e.length>4?parseInt(e[4].split("=")[1],10):1,index:0}}function ph(t){const e=t.split(/\s+/);return{format:"variableStep",chrom:e[1].split("=")[1],span:e.length>2?parseInt(e[2].split("=")[1],10):1}}class gh{constructor(t){switch(this.type=t||"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(t){let e;for(;void 0!==(e=await t.nextLine());)if(!e.startsWith("#")){const t=e.split("\t");this.header={headings:t};break}return this.header}async parseFeatures(t){const e=[];let n;this.header||(this.header=await this.parseHeader(t)),"seg"===this.type&&(this.dataColumn=this.header.headings.length-1),this.header.headings.length>5&&(n=this.extractExtraColumns(this.header.headings));const r=this.header.headings[this.dataColumn];let i;for(;void 0!==(i=await t.nextLine());){const t=i.split("\t"),o="seg"===this.type?Number(t[this.dataColumn]):t[this.dataColumn];if(t.length>this.dataColumn){const i=new mh({sample:t[this.sampleColumn],chr:t[this.chrColumn],start:parseInt(t[this.startColumn])-1,end:parseInt(t[this.endColumn]),value:o,valueColumnName:r});if(n){const e=this.extractExtraColumns(t);i.setAttributes({names:n,values:e})}e.push(i)}}return e}extractExtraColumns(t){const e=[];for(let n=0;n<t.length;n++)n!==this.chrColumn&&n!==this.startColumn&&n!==this.endColumn&&n!==this.sampleColumn&&e.push(t[n]);return e}}class mh{constructor({sample:t,chr:e,start:n,end:r,value:i,valueColumnName:o}){this.sample=t,this.chr=e,this.start=n,this.end=r,this.value=i,this.valueColumnName=o}setAttributes({names:t,values:e}){this.attributeNames=t,this.attributeValues=e}getAttribute(t){if(this.attributeNames){const e=this.attributeNames.indexOf(t);if(e>=0)return this.attributeValues[e]}}popupData(t,e){const n=new Set(["chr","start","end","sample","value","row","color","sampleKey","uniqueSampleKey","sampleId","chromosome","uniquePatientKey"]),r=this.chr+":"+Se(this.start+1)+"-"+Se(this.end),i=[{name:"Sample",value:this.sample},{name:"Location",value:r},{name:this.valueColumnName?Ae(this.valueColumnName):"Value",value:this.value}];if("mut"===t&&"hg38"===e){const t=this.extractCravatLink(e);t&&(i.push("<hr/>"),i.push({html:t}),i.push("<hr/>"))}if(this.attributeNames&&this.attributeNames.length>0)for(let t=0;t<this.attributeNames.length;t++)!n.has(this.attributeNames[t])&this.valueColumnName!==this.attributeNames[t]&&i.push({name:Ae(this.attributeNames[t]),value:this.attributeValues[t]});return i}extractCravatLink(t){let e,n;if(this.attributeNames&&this.attributeNames.length>0)for(let r=0;r<this.attributeNames.length;r++)if(e||"Reference_Allele"!==this.attributeNames[r]||(e=this.attributeValues[r]),!n&&this.attributeNames[r].startsWith("Tumor_Seq_Allele")&&this.attributeValues[r]!==e&&(n=this.attributeValues[r]),e&&n)return bc.getCravatLink(this.chr,this.start+1,e,n,t)}}function vh(t){const e=new bh;e.chr=t[0],e.pos=parseInt(t[1]),e.names=t[2],e.referenceBases=t[3],e.alternateBases=t[4],e.quality=t[5],e.filter=t[6],e.info={};const n=t[7];if(n)for(let t of n.split(";")){var r=t.split("=");e.info[r[0]]=r[1]}return e.init(),e}class bh{init(){const t=this.referenceBases,e=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(t,e){const n=t.length;if(void 0===e)return"UNKNOWN";if(0===e.trim().length||"<NON_REF>"===e||"<*>"===e||"."===e)return"NONVARIANT";{const t=e.split(",").map((function(t){return 1===n&&1===t.length?"SNP":"<NON_REF>"===t?"NONVARIANT":"OTHER"}));let r=t[0];for(let e of t)if(e!==r)return"MIXED";return r}}(t,e)),"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+t.length;else{const n=e.split(",").filter((t=>t.length>0));this.alleles=[],this.start=void 0,this.end=void 0;for(let e of n)if(this.alleles.push(e),"SV"!==this.type&&yh(e)){let n=e.length,r=t.length;const i=Math.min(n,r);let o=0;for(;o<i&&t.charCodeAt(o)===e.charCodeAt(o);)o++,n--,r--;for(;n>0&&r>0;){const i=o+n-1,s=o+r-1;if(e.charCodeAt(i)!==t.charCodeAt(s))break;n--,r--}for(;n>0&&r>0;){const i=o,s=o;if(e.charCodeAt(i)!==t.charCodeAt(s))break;o++,n--,r--}const s=this.pos+o-1,a=s+r;this.start=void 0===this.start?s:Math.min(this.start,s),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(t,e){const n=`${Se(this.pos)}`,r=this.start===this.end?`${Se(this.start)} | ${Se(this.start+1)}`:`${Se(this.start+1)}-${Se(this.end)}`,i=[{name:"Chr",value:this.chr},{name:"Pos",value:n},{name:"Loc",value:r},{name:"Names",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 t=this.referenceBases;if(1===t.length){let n=this.alternateBases.split(",");for(let r of n)if(1===r.length){let n=bc.getCravatLink(this.chr,this.pos,t,r,e);n&&(i.push("<hr/>"),i.push({html:n}))}}}if(this.hasOwnProperty("heterozygosity")&&i.push({name:"Heterozygosity",value:this.heterozygosity}),this.info){i.push({html:'<hr style="border-top: dotted 1px;border-color: #c9c3ba" />'});for(let t of Object.keys(this.info))i.push({name:t,value:xh(decodeURIComponent(this.info[t]))})}return i}isRefBlock(){return"NONVARIANT"===this.type}}const wh=new Set(["A","C","T","G"].map((t=>t.charCodeAt(0))));function yh(t){for(let e=0;e<t.length;e++)if(!wh.has(t.charCodeAt(e)))return!1;return!0}function xh(t,e){return void 0===e&&(e=","),Array.isArray(t)?t.join(e):t}class kh{construtor(){}async parseHeader(t,e){const n={};n.chrAliasTable=new Map;let r=await t.nextLine();if(!r.startsWith("##fileformat"))throw new Error("Invalid VCF file: missing fileformat line");for(n.version=r.substr(13);void 0!==(r=await t.nextLine())&&r.startsWith("#");){let t;const o={};if(r.startsWith("##")){if(r.startsWith("##INFO")||r.startsWith("##FILTER")||r.startsWith("##FORMAT")){const e=r.indexOf("<"),s=r.lastIndexOf(">");if(!(e>2&&s>0)){console.log("Malformed VCF header line: "+r);continue}const a=r.substring(2,e-1);n[a]||(n[a]={});const c=Ee(r.substring(e+1,s-1),",");for(let e of c){var i=e.split("=");i.length>1&&("ID"===i[0]?t=i[1]:o[i[0]]=i[1])}t&&(n[a][t]=o)}else if(r.startsWith("##contig")&&e){const t=r.indexOf("<ID=");let i=r.indexOf(",",t);-1==i&&(i=r.indexOf(">",t));const o=r.substring(t+4,i),s=e.getChromosomeName(o);n.chrAliasTable.set(s,o)}}else if(r.startsWith("#CHROM")){const t=r.split("\t");if(t.length>8){n.callSets=[];for(let e=9;e<t.length;e++)n.callSets.push({id:e,name:t[e]})}}}return this.header=n,n}async parseFeatures(t){const e=[],n=this.header.callSets,r=8+(n?n.length+1:0);let i;for(;void 0!==(i=await t.nextLine());)if(i&&!i.startsWith("#")){const t=i.split("\t");if(t.length===r){const r=vh(t);if(r.header=this.header,e.push(r),t.length>9){const e=_h(t[8].split(":"));r.calls={};for(let i=9;i<t.length;i++){const o=t[i],s=n[i-9],a={callSetName:s.name,info:{}};r.calls[s.id]=a,o.split(":").forEach((function(t,n){if(n===e.genotypeIndex)a.genotype=[],t.split(/[\|\/]/).forEach((function(t){a.genotype.push("."===t?t:parseInt(t))}));else a.info[e.fields[n]]=t}))}}r.info&&r.info.CHR2&&r.info.END&&e.push(Sh(r))}}return e}}function _h(t){const e={genotypeIndex:-1,fields:t};for(let n=0;n<t.length;n++)"GT"===t[n]&&(e.genotypeIndex=n);return e}function Sh(t){const e=t.info.CHR2,n=Number.parseInt(t.info.END);return{chr:e,start:n-1,end:n,_f:t}}class Ch{constructor(t){if(this.config=t,t.columns){if(void 0===t.columns.chromosome||void 0===t.columns.position||void 0===t.columns.value)throw Error("columns property must define chrCol, posCol, and valueCol");this.posCol=t.columns.position-1,this.chrCol=t.columns.chromosome-1,this.pvalueCol=t.columns.value-1}else this.posCol=2,this.chrCol=1,this.pvalueCol=3}async parseHeader(t){const e=await t.nextLine();return this.parseHeaderLine(e)}parseHeaderLine(t){if(this.columns=t.split(/\t/),!this.config.columns)for(let t=0;t<this.columns.length;t++){switch(this.columns[t].toLowerCase()){case"chr":case"chromosome":case"chr_id":this.chrCol=t;break;case"bp":case"pos":case"position":case"chr_pos":this.posCol=t;break;case"p":case"pval":case"pvalue":case"p-value":case"p.value":this.valueCol=t}}return this.columns}async parseFeatures(t){const e=[],n=t.nextLine();let r;for(this.columns||this.parseHeaderLine(n);void 0!==(r=t.nextLine());){const t=r.split(/\t/);if(t.length===this.columns.length){const n=t[this.chrCol],i=parseInt(t[this.posCol])-1,o=i+1,s=Number(t[this.valueCol]);e.push(new Eh({chr:n,start:i,end:o,value:s,line:r,columns:this.columns}))}}return e}}class Eh{constructor({chr:t,start:e,end:n,value:r,line:i,columns:o}){this.chr=t,this.start=e,this.end=n,this.value=r,this.line=i,this.columns=o}popupData(){const t=this.line.split(/\t/);return this.columns.map((function(e,n){return{name:e,value:t[n]}}))}getAttribute(t){const e=this.line.split(/\t/);for(let n=0;n<this.columns.length;n++)if(this.columns[n]===t)return e[n]}}var Ah=new RegExp("([^:]*)\\(([^)]*)\\)"),Th=new RegExp("([^:]*):([^(]*)\\(([^)]*)\\)");class Lh{constructor(t){const e=t?t.decode:void 0;this.nameField=t?t.nameField:void 0,this.skipRows=0,this.decode=e||Oh,this.delimiter="\t"}async parseHeader(t){let e,n;for(;(e=await t.nextLine())&&(e.startsWith("track")||e.startsWith("#")||e.startsWith("browser"));)if(e.startsWith("track")||e.startsWith("#track")){let t=Ih(e);n?Object.assign(n,t):n=t}else if(e.startsWith("#columns")){let t=Nh(e);n?Object.assign(n,t):n=t}else e.startsWith("##gff-version 3")&&(this.format="gff3",n||(n={}),n.format="gff3");return this.header=n,n}async parseFeatures(t){const e=[],n=this.decode,r=this.delimiter||"\t";let i,o=0;for(;void 0!==(i=t.nextLine());){if(o++,o<=this.skipRows||i.startsWith("track")||i.startsWith("#")||i.startsWith("browser"))continue;let t=s();if(t.length<1)continue;if(!this.aed){this.aed=Rh(t);continue}const r=n.call(this,t,undefined);r&&e.push(r)}return e;function s(){for(var t,e,n=[],o="",s=!1;i||""===i;){for(t=0;t<i.length;t++)(e=i.charAt(t))===r?s?o+=e:(n.push(o),o=""):'"'===e?t+1<i.length&&'"'===i.charAt(t+1)?(s&&(o+='"'),t++):s=!s:o+=e;if(!s)break;o+="\n",i=nextLine()}return n.push(o),n}}}function Mh(t){var e=Th.exec(t);if(e)return{namespace:e[1],name:e[2],type:e[3]};if(e=Ah.exec(t))return{namespace:"?",name:e[1],type:e[2]};throw new Error("Error parsing the header row of AED file - column not in ns:name(ns:type) format")}function Rh(t){var e,n,r;for(e={columns:[],metadata:{}},n=0;n<t.length;n++)r=Mh(t[n]),e.columns.push(r);return e}function Ih(t){const e={},n=t.split(/(?:")([^"]+)(?:")|([^\s"]+)(?=\s+|$)/g);let r;const i=[];for(let t of n)t&&0!==t.trim().length&&(t.endsWith("=")>0?r=t:r?(i.push(r+t),r=void 0):i.push(t));for(let t of i){if(!t)return;var o=t.split("=",2);if(2===o.length){const t=o[0].trim(),n=o[1].trim();e[t]=n}}return e}function Nh(t){let e={},n=t.split(/\s+/);if(2===n.length){n[1].split(";").forEach((function(t){let n=t.split("=");"color"===n[0]?e.colorColumn=Number.parseInt(n[1])-1:"thickness"===n[0]&&(e.thicknessColumn=Number.parseInt(n[1])-1)}))}return e}function Ph(t,e){var n,r,i=t.columns;this.aed=t,this.allColumns=e,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 t=0;t<e.length;t++)if(n=e[t]){"aed:Integer"===(r=i[t]).type&&(n=parseInt(n));var o=[];if(r.namespace.length>0)for(let t=0;t<r.namespace.length;t++)o.push(r.namespace.charCodeAt(t));"bio"===r.namespace.trim()?"sequence"===r.name?this.chr=n:"start"===r.name?this.start=n:"end"===r.name?this.end=n:"cdsMin"===r.name?this.cdStart=n:"cdsMax"===r.name?this.cdEnd=n:"strand"===r.name&&(this.strand=n):"aed"===r.namespace?"name"===r.name&&(this.name=n):"style"===r.namespace&&"color"===r.name&&(this.color=ro.createColorString(n))}}function Oh(t,e){var n,r,i,o,s,a,c=0,l=this.aed.columns;if(t.length===l.length){for(a=0;a<t.length;a++)o=l[a],""!==(i=t[a])&&c++,"name"===o.name&&"aed"===o.namespace?n=i:"value"===o.name&&"aed"===o.namespace&&(r=i);if(2===c&&n&&r)return s=Mh(n),this.aed.metadata[s.namespace]||(this.aed.metadata[s.namespace]={}),void(this.aed.metadata[s.namespace][s.name]||(this.aed.metadata[s.namespace][s.name]={type:s.type,value:r}));var h=new Ph(this.aed,t);if(h.chr&&(h.start||0===h.start)&&h.end)return h;console.log("Cannot parse feature: "+t.join(","))}else console.log("Corrupted AED file row: "+t.join(","))}function Fh(t){return"string"==typeof t||t instanceof String?new Dh(t):new Bh(t)}Ph.prototype.popupData=function(){for(var t=[],e=this.aed,n=0;n<this.allColumns.length;n++){var r=this.allColumns[n],i=e.columns[n].name;"sequence"!==i&&"color"!==i&&r&&t.push({name:i,value:r})}return t};class Dh{constructor(t){this.data=t,this.ptr=0}nextLine(){var t=this.ptr,e=this.data.indexOf("\n",t),n=this.data;if(e>0)return this.ptr=e+1,e>t&&"\r"===n.charAt(e-1)?n.substring(t,e-1):n.substring(t,e);var r=n.length;return this.ptr=r,t>=r?void 0:n.substring(t)}}class Bh{constructor(t){this.data=t,this.length=this.data.length,this.ptr=0}nextLine(){var t,e;if(e="",!(this.ptr>=this.length)){for(var n=this.ptr;n<this.length;n++)if("\r"!==(t=String.fromCharCode(this.data[n]))){if("\n"===t)break;e+=t}return this.ptr=n+1,e}}}class zh{constructor(t){this.config=t,this.filePtr=0,this.bufferPtr=0,this.buffer}async nextLine(){let t;try{for(;;){const e=this.buffer?this.buffer.length:0;for(;this.bufferPtr<e;){const e=String.fromCharCode(this.buffer[this.bufferPtr++]);if("\r"!==e){if("\n"===e)return t;t=t?t+e:e}}if(this.eof)return t;await this.readNextBlock()}}catch(e){return console.warn(e),this.eof=!0,t}}async readNextBlock(){const t=gs(this.config,{range:{start:this.filePtr,size:26}}),e=Gi(await go.loadArrayBuffer(this.config.url,t));if(0===e)this.eof=!0,this.buffer=void 0;else{const t=gs(this.config,{range:{start:this.filePtr,size:e}}),n=await go.loadArrayBuffer(this.config.url,t);n.byteLength<e&&(this.eof=!0),this.buffer=$i(n),this.bufferPtr=0,this.filePtr+=n.byteLength}}}class Hh{constructor(t,e){var n;this.config=t||{},this.genome=e,this.indexURL=t.indexURL,this.indexed=t.indexed,Ue(this.config.url)?this.filename=this.config.url.name:ys(this.config.url)?(this.indexed=!1,this.dataURI=t.url):(n=He(this.config.url),this.filename=t.filename||n.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 t=await this.getIndex();if(t&&t.lastBlockPosition){let e=0;const n=1e4;for(let n of t.chromosomeNames){const t=this.genome.getChromosome(n);t&&(e+=t.bpLength)}return Math.round(e/t.lastBlockPosition*n)}}}async readFeatures(t,e,n){return await this.getIndex()?(this.indexed=!0,this.loadFeaturesWithIndex(t,e,n)):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 t=await this.getIndex();if(!t)throw new Error("Unable to load index: "+this.config.indexURL);let e;if(t.tabix)e=new zh(this.config);else{const n=Object.values(t.chrIndex).flatMap((t=>t.blocks)).map((t=>t.max)).reduce(((t,e)=>Math.min(t,e)),Number.MAX_SAFE_INTEGER),r=gs(this.config,{bgz:t.tabix,range:{start:0,size:n}});e=Fh(await go.loadString(this.config.url,r))}return this.header=await this.parser.parseHeader(e),this.header}{const t=gs(this.config),e=await go.loadString(this.config.url,t);let n=Fh(e);return this.header=await this.parser.parseHeader(n),n=Fh(e),this.features=await this.parser.parseFeatures(n),this.header}}getParser(t){switch(t.format){case"vcf":return new kh(t);case"seg":return new gh("seg");case"mut":return new gh("mut");case"maf":return new gh("maf");case"gwas":return new Ch(t);case"aed":return new Lh(t);default:return new hh(t)}}async loadFeaturesNoIndex(){if(this.features){const t=this.features;return delete this.features,t}{const t=gs(this.config),e=await go.loadString(this.config.url,t);if(!this.header){const t=Fh(e);this.header=await this.parser.parseHeader(t)}const n=Fh(e);return await this.parser.parseFeatures(n)}}async loadFeaturesWithIndex(t,e,n){const r=this.config,i=this.parser,o=this.index.tabix,s=o?this.index.sequenceIndexMap[t]:t;if(void 0===s)return[];const a=this.genome,c=this.index.blocksForRange(s,e,n);if(c&&0!==c.length){const s=[];for(let l of c){const c=l.minv.block,h=l.minv.offset,u=l.maxv.offset;let f;if(o){let t=0;if(u>0){const e=gs(r,{range:{start:l.maxv.block,size:26}});t=Gi(await go.loadArrayBuffer(r.url,e))}f=l.maxv.block+t}else f=l.maxv.block;const d=gs(r,{range:{start:c,size:f-c+1}});let p;if(o){p=$i(await go.loadArrayBuffer(r.url,d))}else p=await go.loadString(r.url,d);const g=Fh(h?p.slice(h):p);let m=await i.parseFeatures(g);m=m.filter((t=>void 0===t._f));let v=!1;for(let r=0;r<m.length;r++){const i=m[r];if((a?a.getChromosomeName(i.chr):i.chr)!==t){if(0===s.length)continue;break}if(i.start>n){s.push(i);break}i.end>=e&&i.start<=n&&(v||(v=!0,r>0&&s.push(m[r-1])),s.push(i))}}return s.sort((function(t,e){return t.start-e.start})),s}return[]}async getIndex(){return this.index?this.index:this.config.indexURL?(this.index=await this.loadIndex(),this.index):void 0}async loadIndex(){return Ya(this.config.indexURL,this.config,this.genome)}async loadFeaturesFromDataURI(){if(this.features){const t=this.features;return delete this.features,t}{const t=Ki(this.dataURI);let e=Fh(t);return this.header=await this.parser.parseHeader(e),this.header instanceof String&&this.header.startsWith("##gff-version 3")&&(this.format="gff3"),e=Fh(t),this.features=await this.parser.parseFeatures(e),this.features}}}const Vh=_e;class jh{constructor(t){this.config=t}async readFeatures(t,e,n){let r;r="function"==typeof this.config.url?this.config.url({chr:t,start:e,end:n}):this.config.url.replace("$CHR",t).replace("$START",e).replace("$END",n);let i,o=Object.assign({},this.config);void 0!==this.config.body&&("function"==typeof this.config.body?o.body=this.config.body({chr:t,start:e,end:n}):o.body=this.config.body.replace("$CHR",t).replace("$START",e).replace("$END",n));const s=await go.load(r,o);if(s&&(i="function"==typeof this.config.parser?this.config.parser(s):Vh(s)?JSON.parse(s):s),this.config.mappings){let t=Object.keys(this.config.mappings);for(let e of i)for(let n of t)e[n]=e[this.config.mappings[n]]}return i}}const Uh=function(t,e){this.config=t,this.genome=e,this.expandQueryInterval=!1};Uh.prototype.readFeatures=function(t,e,n){const r=Math.max(0,Math.floor(e));let i=Math.ceil(n);if(this.genome){const e=this.genome.getChromosome(t);e&&i>e.bpLength&&(i=e.bpLength)}const o=this.config.url+"?db="+this.config.db+"&table="+this.config.tableName+"&chr="+t+"&start="+r+"&end="+i;return go.loadJson(o,this.config).then((function(t){return t?(t.forEach((function(t){t.hasOwnProperty("exonStarts")&&t.hasOwnProperty("exonEnds")&&t.hasOwnProperty("exonCount")&&t.hasOwnProperty("cdsStart")&&t.hasOwnProperty("cdsEnd")&&function(t){var e,n,r,i,o,s;e=t.exonCount,n=t.exonStarts.split(","),r=t.exonEnds.split(","),i=[];for(var a=0;a<e;a++){var c={start:o=parseInt(n[a]),end:s=parseInt(r[a])};(t.cdsStart>s||t.cdsEnd<t.cdsStart)&&(c.utr=!0),t.cdsStart>=o&&t.cdsStart<=s&&(c.cdStart=t.cdsStart),t.cdsEnd>=o&&t.cdsEnd<=s&&(c.cdEnd=t.cdsEnd),i.push(c)}t.exons=i}(t)})),t):null}))};const qh=["Name","gene_name","gene","gene_id","alias","locus","name"];class Wh{constructor(t){this.format=t.format,this.nameField=t.nameField,this.filterTypes=void 0===t.filterTypes?new Set(["chromosome"]):new Set(t.filterTypes)}combineFeatures(t,e){let n;const r=this.filterTypes;if(t=t.filter((t=>void 0===r||!r.has(t.type))),"gff3"===this.format){const e=this.combineFeaturesById(t);n=this.combineFeaturesByType(e)}else n=this.combineFeaturesByType(t);return n.sort((function(t,e){return t.start-e.start})),this.numberExons(n,e),this.nameFeatures(n),n}combineFeaturesById(t){const e=new Map,n=[];for(let r of t)if(zl(r.type)||Bl(r.type)||!r.id)n.push(r);else{let t=e.get(r.chr);t||(t=new Map,e.set(r.chr,t));let n=t.get(r.id);n?n.push(r):t.set(r.id,[r])}for(let t of e.values())for(let e of t.values())if(e.length>1){const t=e[0];t.exons=[];for(let n of e)t.start=Math.min(t.start,n.start),t.end=Math.max(t.end,n.end),t.exons.push({start:n.start,end:n.end});n.push(t)}else n.push(e[0]);return n}combineFeaturesByType(t){const e=t.filter((t=>"gene"===t.type||t.type.endsWith("_gene"))),n=Object.create(null);for(let t of e)n[t.id]=t;const r=Object.create(null),i=[],o=new Set,s=this.filterTypes;t=t.filter((t=>void 0===s||!s.has(t.type)));for(let e of t)if("biological_region"===e.type&&console.log(),Bl(e.type)){const t=e.id;if(void 0!==t){const s=new jl(e);r[t]=s,i.push(s),o.add(e);const a=n[e.parent];a&&(s.geneObject=a,o.add(a))}}for(let e of t)if(zl(e.type)){const t=l(e);if(t)for(let n of t){let s=r[n];if(!s&&"gtf"===this.format){const t=Object.assign({},e);t.type="transcript",s=new jl(t),r[n]=s,i.push(s)}if(void 0!==s){if(a=e.type,Nl.has(a))if(t.length>1){const t=new Vl(e);s.addExon(t)}else s.addExon(e);else s.addPart(e);o.add(e)}}}var a;i.forEach((function(t){"function"==typeof t.finish&&t.finish()}));const c=t.filter((t=>!o.has(t)));for(let t of c)i.push(t);return i;function l(t){return t.parent&&""!==t.parent.trim()?t.parent.trim().split(","):null}}numberExons(t,e){for(let n of t)if(n.exons&&(!e||n.end<=e.end&&n.start>e.start))for(let t=0;t<n.exons.length;t++){n.exons[t].number="-"===n.strand?n.exons.length-t:t+1}}nameFeatures(t){for(let e of t)if(e.attributeString){const t="gff3"===this.format?"=":" ",n=$l(e.attributeString,t),r=new Map(n);if(this.nameField)e.name=r.get(this.nameField);else for(let t of qh)if(r.has(t)){e.name=r.get(t);break}}}}const $h=function(t){this.config=t,this.url=t.url,this.tissueId=t.tissueSiteDetailId,this.indexed=!0,this.datasetId=t.datasetId||"gtex_v8"};$h.prototype.readFeatures=async function(t,e,n){let r=t.startsWith("chr")?t:"chr"+t,i=Math.floor(e),o=Math.ceil(n),s=this.datasetId,a=this.url+"?chromosome="+r+"&start="+i+"&end="+o+"&tissueSiteDetailId="+this.tissueId+"&datasetId="+s;const c=await go.loadJson(a,{withCredentials:this.config.withCredentials});return c&&c.singleTissueEqtl?(c.singleTissueEqtl.forEach((function(t){t.chr=t.chromosome,t.position=t.pos,t.start=t.pos-1,t.end=t.start+1,t.snp=t.snpId,t.geneName=t.geneSymbol,t.geneId=t.gencodeId})),c.singleTissueEqtl):void 0};const Gh=function(t){this.config=t,this.url=t.url,this.cellConditionId=t.cellConditionId,this.valueThreshold=t.valueThreshold?t.valueThreshold:.05};Gh.prototype.readFeatures=function(t,e,n){var r=this,i=this.url+"?chromosome="+t+"&start="+e+"&end="+n+"&cell_condition_id="+this.cellConditionId;return new Promise((function(t,e){go.loadJson(i,{withCredentials:r.config.withCredentials}).then((function(e){e?(e.eqtls.forEach((function(t){t.chr=t.chromosome,t.start=t.position,t.end=t.position+1})),t(e.eqtls)):t(null)})).catch((function(t){e(t)}))}))};const Zh=function(t,e){this.config=t,this.genome=e,this.url=t.url,this.variantSetId=t.variantSetId,this.callSetIds=t.callSetIds,this.includeCalls=void 0===t.includeCalls||t.includeCalls};Zh.prototype.readHeader=function(){var t=this;return t.header?Promise.resolve(t.header):(t.header={},!1===t.includeCalls?Promise.resolve(t.header):dc({url:t.url+"/callsets/search",fields:"nextPageToken,callSets(id,name)",body:{variantSetIds:Array.isArray(t.variantSetId)?t.variantSetId:[t.variantSetId],pageSize:"10000"},decode:function(e){if(t.callSetIds){var n=[],r=new Set;return t.callSetIds.forEach((function(t){r.add(t)})),e.callSets.forEach((function(t){r.has(t.id)&&n.push(t)})),n}return e.callSets}}).then((function(e){return t.header.callSets=e,t.header})))},Zh.prototype.readFeatures=function(t,e,n){const r=this,i=this.genome;return r.readHeader().then((function(t){return new Promise((function(t,e){r.chrAliasTable?t(r.chrAliasTable):r.readMetadata().then((function(e){r.metadata=e.metadata,r.chrAliasTable={},e.referenceBounds&&i&&e.referenceBounds.forEach((function(t){var e=t.referenceName,n=i.getChromosomeName(e);r.chrAliasTable[n]=e})),t(r.chrAliasTable)}))}))})).then((function(i){var o=i.hasOwnProperty(t)?i[t]:t;return dc({url:r.url+"/variants/search",fields:r.includeCalls?void 0:"nextPageToken,variants(id,variantSetId,names,referenceName,start,end,referenceBases,alternateBases,quality,filter,info)",body:{variantSetIds:Array.isArray(r.variantSetId)?r.variantSetId:[r.variantSetId],callSetIds:r.callSetIds?r.callSetIds:void 0,referenceName:o,start:e.toString(),end:n.toString(),pageSize:"10000"},decode:function(t){var e,n=[];return t.variants.forEach((function(t){e=function(t){var e,n=new bh;return n.chr=t.referenceName,n.start=parseInt(t.start),n.end=parseInt(t.end),n.pos=n.start+1,n.names=xh(t.names,"; "),n.referenceBases=t.referenceBases,n.alternateBases=xh(t.alternateBases),n.quality=t.quality,n.filter=xh(t.filter),n.info={},t.info&&Object.keys(t.info).forEach((function(e){var r,i=t.info[e];r=Array.isArray(i)?i.join(","):i,n.info[e]=r})),n.calls={},t.calls&&t.calls.forEach((function(t){e=t.callSetId,n.calls[e]=t})),init(n),n}(t),e.isRefBlock()||n.push(e)})),n}})}))},Zh.prototype.readMetadata=function(){return fc({url:this.url,entity:"variantsets",entityId:this.variantSetId})};class Xh{constructor(t){this.config=t}async readFeatures(t,e,n){const r=(await go.loadJson(this.config.url+"/variants/?count=50000")).records,i=[];for(let t of r)if(t.coordinates){t.id;const e=t.coordinates;e.chromosome&&i.push(new Yh(e.chromosome,e.start-1,e.stop,t)),e.chromosome2&&i.push(new Yh(e.chromosome2,e.start2-1,e.stop2,t))}return i}}class Yh{constructor(t,e,n,r){if(this.chr=t,this.start=e,this.end=n,this.id=r.id,this.entrezName=r.entrez_name,this.name=r.name,this.actionabilityScore=r.civic_actionability_score,r.coordinates.reference_bases&&(this.refBases=r.coordinates.reference_bases),r.coordinates.variant_bases&&(this.altBases=r.coordinates.variant_bases),r.variant_types&&(this.variant_types=r.variant_types),this.locationString=this.chr+":"+Se(this.start+1)+"-"+Se(this.end),void 0!==this.actionabilityScore){let t;if(this.actionabilityScore<=10)t=.2;else{const e=Math.min(30,this.actionabilityScore);t=.2+.8*Math.log10((e-10)/2)}this.alpha=t}}popupData(){const t=n("CIViC","https://civicdb.org/links/variants/"+this.id);this.refBases!==this.altBases&&this.refBases&&1===this.refBases.length&&this.altBases&&this.altBases.length;const e=[t];if(e.push({name:"Entrez",value:n(this.entrezName,"https://ghr.nlm.nih.gov/gene/"+this.entrezName)}),e.push({name:"Name",value:this.name}),this.variant_types&&this.variant_types.length>0){const t=1===this.variant_types.length?"Type":"Types";let n;for(let t of this.variant_types)n?n+=", "+t.display_name:n=t.display_name;e.push({name:t,value:n})}return e.push({name:"Actionability",value:this.actionabilityScore}),e.push({name:"Location",value:this.locationString}),e;function n(t,e){return"<a target='_blank' href='"+e+"'>"+t+"</a>"}}}function Kh(t,e){e=e||Number.MAX_SAFE_INTEGER;const n=[];t.sort((function(t,e){return t.start-e.start})),n.push(-1e3);for(let r of t){let t=0;const i=Math.min(n.length,e);for(t=0;t<i;t++)if(r.start>=n[t]){r.row=t,n[t]=r.end;break}r.row=t,n[t]=r.end}}class Qh extends ec{constructor(t,e){super(t,e),this.parser=new kh}async readHeader(){if(!this.header){const t=Fh(await this.readHeaderData());this.header=await this.parser.parseHeader(t,this.genome),this.chrAliasTable=this.header.chrAliasTable}return this.header}async readFeatures(t,e,n){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 r=this.chrAliasTable.has(t)?this.chrAliasTable.get(t):t;const i=Fh(await this.readData(r,e,n));return this.parser.parseFeatures(i)}}class Jh{constructor(t,e){this.config=t||{},this.genome=e,this.sourceType=void 0===t.sourceType?"file":t.sourceType,this.maxWGCount=t.maxWGCount||1e4;const n=new Set(["bigwig","bw","bigbed","bb","biginteract","biggenepred","bignarrowpeak","tdf"]);if(t.features&&Array.isArray(t.features)){let n=function(t,e){if(!t||0===t.length)return[];if(void 0===t[0].chr&&void 0!==t[0].chr1){const n=[];for(let r of t)e&&(r.chr1=e.getChromosomeName(r.chr1),r.chr2=e.getChromosomeName(r.chr2)),r.chr1===r.chr2?(r.chr=r.chr1,r.start=Math.min(r.start1,r.start2),r.end=Math.max(r.end1,r.end2)):n.push(r);for(let e of n){const n=Object.assign({dup:!0},e);t.push(n),e.chr=e.chr1,e.start=e.start1,e.end=e.end1,n.chr=n.chr2,n.start=n.start2,n.end=n.end2}}else if(e)for(let n of t)n.chr=e.getChromosomeName(n.chr);return t}(t.features,e);tu(n),t.mappings&&function(t,e){let n=Object.keys(e);t.forEach((function(t){n.forEach((function(n){t[n]=t[e[n]]}))}))}(n,t.mappings),this.queryable=!1,this.featureCache=new Mo(n,e)}else t.reader?(this.reader=t.reader,this.queryable=!1!==t.queryable):"ga4gh"===t.sourceType?(this.reader=new Zh(t,e),this.queryable=!0):"immvar"===t.sourceType?(this.reader=new Gh(t),this.queryable=!0):"eqtl"===t.type&&"gtex-ws"===t.sourceType?(this.reader=new $h(t),this.queryable=!0):"htsget"===t.sourceType?this.reader=new Qh(t,e):"ucscservice"===t.sourceType?(this.reader=new Uh(t.source),this.queryable=!0):"custom"===t.sourceType?(this.reader=new jh(t.source),this.queryable=!1!==t.source.queryable):"civic-ws"===t.sourceType?(this.reader=new Xh(t),this.queryable=!1):(this.reader=new Hh(t,e),void 0!==t.queryable?this.queryable=t.queryable:(n.has(t.format)||this.reader.indexed)&&(this.queryable=!0))}async defaultVisibilityWindow(){if(this.reader&&"function"==typeof this.reader.defaultVisibilityWindow)return this.reader.defaultVisibilityWindow()}async trackType(){const t=await this.getHeader();return t?t.type:void 0}async getHeader(){if(!this.header)if(this.reader&&"function"==typeof this.reader.readHeader){const t=await this.reader.readHeader();t?(this.header=t,t.format&&(this.config.format=t.format)):this.header={}}else this.header={};return this.header}async getFeatures({chr:t,start:e,end:n,bpPerPixel:r,visibilityWindow:i}){const o=this.genome,s=o?o.getChromosomeName(t):t,a="all"===s.toLowerCase();return(a&&!this.getWGFeatures||this.config.disableCache||!this.featureCache||!this.featureCache.containsRange(new Gs(s,e,n)))&&await this.loadFeatures(s,e,n,i),a?(this.wgFeatures||(this.queryable?this.wgFeatures=[]:this.wgFeatures=this.getWGFeatures(this.featureCache.getAllFeatures())),this.wgFeatures):this.featureCache.queryFeatures(s,e,n)}getAllFeatures(){return this.queryable?[]:this.getWGFeatures(this.featureCache.getAllFeatures())}async loadFeatures(t,e,n,r){const i=this.reader;let o=e,s=n;if((!r||r<=0)&&!1!==this.config.expandQuery){const e=this.genome?this.genome.getChromosome(t):void 0;o=0,s=Math.max(e?e.bpLength:Number.MAX_SAFE_INTEGER,n)}else if(r>n-e&&!1!==this.config.expandQuery){const t=Math.min(4.1*(n-e),r);o=Math.max(0,(e+n)/2-t),s=e+t}let a=await i.readFeatures(t,o,s);void 0===this.queryable&&(this.queryable=i.indexed);const c=this.queryable?new Gs(t,o,s):void 0;if(a){if(!1===this.config.assembleGFF||"gtf"!==this.config.format&&"gff3"!==this.config.format&&"gff"!==this.config.format||(a=new Wh(this.config).combineFeatures(a,c)),"wig"!==this.config.format&&"junctions"!==this.config.type){tu(a,this.config.maxRows||Number.MAX_SAFE_INTEGER)}this.featureCache=new Mo(a,this.genome,c),(this.config.searchable||this.config.searchableFields)&&this.addFeaturesToDB(a)}else this.featureCache=new Mo([],c)}addFeaturesToDB(t){for(let e of t)if(e.name&&(this.genome.featureDB[e.name.toUpperCase()]=e),e.gene&&e.gene.name&&(this.genome.featureDB[e.gene.name.toUpperCase()]=e),this.config.searchableFields)for(let t of this.config.searchableFields){const n=e.getAttributeValue(t);n&&(n.indexOf(" ")>0?(this.genome.featureDB[n.replaceAll(" ","+").toUpperCase()]=e,this.genome.featureDB[n.replaceAll(" ","%20").toUpperCase()]=e):this.genome.featureDB[n.toUpperCase()]=e)}}getWGFeatures(t){const e=t=>{const e=Object.assign({},t);return e.chr="all",e.start=n.getGenomeCoordinate(t.chr,t.start),e.end=n.getGenomeCoordinate(t.chr,t.end),e._f=t,e.exons&&delete e.exons,e},n=this.genome,r=new Set(n.wgChromosomeNames),i=[];let o=0;const s=this.maxWGCount;for(let a of n.wgChromosomeNames){const c=t[a];if(c)for(let t of c){let a=n.getChromosomeName(t.chr);if(r.has(a))if(i.length<s)i.push(e(t));else{const n=s/(o+1);if(Math.random()<n){i[Math.floor(Math.random()*(s-1))]=e(t)}}o++}}return i.sort((function(t,e){return t.start-e.start})),i}}function tu(t,e){if(e=e||1e3,null==t||0===t.length)return;const n={},r=[];for(let e of t){const t=e.chr;let i=n[t];i||(i=[],n[t]=i,r.push(t)),i.push(e)}for(let t of r)Kh(n[t],e)}class eu{constructor(t,e,n){this.path=t.url,this.bufferSize=n||512e3,this.range={start:-1,size:-1},this.config=t}async dataViewForRange(t,e){if(!(this.data&&this.range.start<=t.start&&this.range.start+this.range.size>=t.start+t.size)){let e;e=t.size?Math.max(this.bufferSize,t.size):this.bufferSize;const n={start:t.start,size:e},r=await go.loadArrayBuffer(this.path,gs(this.config,{range:n}));this.data=r,this.range=n}const n=this.data.byteLength,r=t.start-this.range.start;return e?new Uint8Array(this.data,r,n-r):new DataView(this.data,r,n-r)}}class nu{constructor(t,e){this.path=t.url,this.format=t.format||"bigwig",this.genome=e,this.rpTreeCache={},this.config=t,this.loader=ys(this.path)?new du(this.path):go}async readWGFeatures(t,e){await this.loadHeader();const n=this.chromTree.idToChrom.length-1,r=this.chromTree.idToChrom[0],i=this.chromTree.idToChrom[n];return this.readFeatures(r,0,i,Number.MAX_VALUE,t,e)}async readFeatures(t,e,n,r,i,o){await this.loadHeader();const s=this.chromTree.chromToID[t],a=this.chromTree.chromToID[n];if(void 0===s||void 0===a)return[];let c,l;if("bigwig"===this.type){const t=await this.getZoomHeaders();let e=i?function(t,e){let n;for(let r=0;r<e.length;r++){const i=e[r];if(i.reductionLevel<t){n=i;break}}return n}(i,t):void 0;e?(c=e.indexOffset,l=fu):(c=this.header.fullIndexOffset,l=hu)}else c=this.header.fullIndexOffset,l=uu.call(this);const h=await this.loadRPTree(c),u=await h.findLeafItemsOverlapping(s,e,a,r);if(u&&0!==u.length){let t=Number.MAX_VALUE,n=0;for(let e of u)t=Math.min(t,e.dataOffset),n=Math.max(n,e.dataOffset+e.dataSize);const i=n-t,c=await this.loader.loadArrayBuffer(this.config.url,gs(this.config,{range:{start:t,size:i}})),h=[];for(let n of u){const i=new Uint8Array(c,n.dataOffset-t,n.dataSize);let u;u=this.header.uncompressBuffSize>0?Wi(i):i,l.call(this,new DataView(u.buffer),s,e,a,r,h,this.chromTree.idToChrom,o)}return h.sort((function(t,e){return t.start-e.start})),h}return[]}async getZoomHeaders(){return this.zoomLevelHeaders||await this.loadHeader(),this.zoomLevelHeaders}async loadHeader(){if(this.header)return this.header;{let t,e=await this.loader.loadArrayBuffer(this.path,gs(this.config,{range:{start:0,size:64}}));this.littleEndian=!0;let n=new Wa(new DataView(e)),r=n.getUInt();if(2291137574===r)this.type="bigwig";else if(2273964779===r)this.type="bigbed";else{this.littleEndian=!1,n.littleEndian=!1,n.position=0;let t=n.getUInt();654085990===t?this.type="bigwig":3958540679===t&&(this.type="bigbed")}t={bwVersion:n.getUShort(),nZoomLevels:n.getUShort(),chromTreeOffset:n.getLong(),fullDataOffset:n.getLong(),fullIndexOffset:n.getLong(),fieldCount:n.getUShort(),definedFieldCount:n.getUShort(),autoSqlOffset:n.getLong(),totalSummaryOffset:n.getLong(),uncompressBuffSize:n.getInt(),extensionOffset:n.getLong()};const i=64;let o={start:i,size:t.fullDataOffset-i+5};e=await this.loader.loadArrayBuffer(this.path,gs(this.config,{range:o}));const s=t.nZoomLevels;n=new Wa(new DataView(e)),this.zoomLevelHeaders=[],this.firstZoomDataOffset=Number.MAX_SAFE_INTEGER;for(let t=1;t<=s;t++){const e=s-t,r=new ru(e,n);this.firstZoomDataOffset=Math.min(r.dataOffset,this.firstZoomDataOffset),this.zoomLevelHeaders[e]=r}if(t.autoSqlOffset>0){n.position=t.autoSqlOffset-i;const e=n.getString();e&&(this.autoSql=function(t){let e;const n=[];let r=!1;const i=t.trim().split(/\s*[\r\n]+\s*/g);for(let t of i)if(t.startsWith("table"))e=t.split(/\s+/)[1].trim();else if(t.startsWith("("))r=!0;else if(t.startsWith(")"));else if(r&&t.length>0){const e=t.indexOf(";"),r=t.substr(0,e).split(/\s+/),i=t.substr(e+1).replace(/"/g,"").trim();n.push({type:r[0],name:r[1],description:i})}return{table:e,fields:n}}(e))}if(t.totalSummaryOffset>0&&(n.position=t.totalSummaryOffset-i,this.totalSummary=new cu(n)),!(t.chromTreeOffset>0))throw"BigWig chromosome tree offset <= 0";return n.position=t.chromTreeOffset-i,this.chromTree=new su(n,i,this.genome),n.position=t.fullDataOffset-i,t.dataCount=n.getInt(),this.setDefaultVisibilityWindow(t),this.header=t,this.header}}async loadRPTree(t){let e=this.rpTreeCache[t];return e||(e=new iu(t,this.config,this.littleEndian,this.loader),await e.load(),this.rpTreeCache[t]=e,e)}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(t){if("bigwig"===this.type)this.visibilityWindow=-1;else{let e=this.genome?this.genome.getGenomeLength():3088286401;this.visibilityWindow=t.dataCount<1e3?-1:e/t.dataCount*1e3}}}class ru{constructor(t,e){this.index=t,this.reductionLevel=e.getInt(),this.reserved=e.getInt(),this.dataOffset=e.getLong(),this.indexOffset=e.getLong()}}class iu{constructor(t,e,n,r){this.config=e,this.loader=r,this.fileOffset=t,this.path=e.url,this.littleEndian=n}async load(){const t=this.fileOffset+48,e=ys(this.path)?this.loader:new eu(this.config,512e3);return this.rootNode=await this.readNode(t,e),this}async readNode(t,e){let n=await e.dataViewForRange({start:t,size:4},!1),r=new Wa(n,this.littleEndian);const i=1===r.getByte();r.getByte();const o=r.getUShort();let s={start:t+=4,size:o*(i?32:24)};n=await e.dataViewForRange(s,!1);const a=new Array(o);if(r=new Wa(n),i){for(let t=0;t<o;t++){let e={isLeaf:!0,startChrom:r.getInt(),startBase:r.getInt(),endChrom:r.getInt(),endBase:r.getInt(),dataOffset:r.getLong(),dataSize:r.getLong()};a[t]=e}return new ou(a)}for(let t=0;t<o;t++){let e={isLeaf:!1,startChrom:r.getInt(),startBase:r.getInt(),endChrom:r.getInt(),endBase:r.getInt(),childOffset:r.getLong()};a[t]=e}return new ou(a)}async findLeafItemsOverlapping(t,e,n,r){let i=this;return new Promise((function(o,s){let a=[],c=new Set,l=ys(i.path)?i.loader:new eu(i.config,512e3);c.add(0),function h(u,f){if(au(u,t,e,n,r)){u.items.forEach((function(o){au(o,t,e,n,r)&&(o.isLeaf?a.push(o):o.childNode?h(o.childNode):(c.add(o.childOffset),i.readNode(o.childOffset,l).then((function(t){o.childNode=t,h(t,o.childOffset)})).catch(s)))}))}void 0!==f&&c.delete(f);0===c.size&&o(a)}(i.rootNode,0)}))}}class ou{constructor(t){this.items=t;let e,n,r=Number.MAX_SAFE_INTEGER,i=0,o=Number.MAX_SAFE_INTEGER,s=0;for(e=0;e<t.length;e++)n=t[e],r=Math.min(r,n.startChrom),i=Math.max(i,n.endChrom),o=Math.min(o,n.startBase),s=Math.max(s,n.endBase);this.startChrom=r,this.endChrom=i,this.startBase=o,this.endBase=s}}class su{constructor(t,e,n){let r=t.getInt(),i=t.getInt(),o=t.getInt(),s=t.getInt(),a=t.getLong(),c=t.getLong(),l={},h=[];this.header={magic:r,blockSize:i,keySize:o,valSize:s,itemCount:a,reserved:c},this.chromToID=l,this.idToChrom=h,function t(r,i){i>=0&&(r.position=i);let s=r.getByte();r.getByte();let a,c,u,f,d,p,g=r.getUShort();if(1===s)for(a=0;a<g;a++)c=r.getFixedLengthTrimmedString(o),u=r.getInt(),r.getInt(),n&&(c=n.getChromosomeName(c)),l[c]=u,h[u]=c;else for(a=0;a<g;a++)c=r.getFixedLengthTrimmedString(o),f=r.getLong(),d=f-e,p=r.position,t(r,d),r.position=p}(t,-1)}}function au(t,e,n,r,i){return t?(r>t.startChrom||r===t.startChrom&&i>=t.startBase)&&(e<t.endChrom||e===t.endChrom&&n<=t.endBase):(console.log("null item for "+e+" "+n+" "+i),!1)}class cu{constructor(t){t?(this.basesCovered=t.getLong(),this.minVal=t.getDouble(),this.maxVal=t.getDouble(),this.sumData=t.getDouble(),this.sumSquares=t.getDouble(),lu.call(this)):(this.basesCovered=0,this.minVal=0,this.maxVal=0,this.sumData=0,this.sumSquares=0,this.mean=0,this.stddev=0)}}function lu(){let t=this.basesCovered;if(t>0){this.mean=this.sumData/t,this.stddev=Math.sqrt(this.sumSquares/(t-1));let e=this.minVal<0?this.mean-2*this.stddev:0,n=this.maxVal>0?this.mean+2*this.stddev:0;this.defaultRange={min:e,max:n}}}function hu(t,e,n,r,i,o,s){const a=new Wa(t),c=a.getInt();let l=a.getInt(),h=a.getInt();const u=a.getInt(),f=a.getInt(),d=a.getByte();a.getByte();let p=a.getUShort();if(c>=e&&c<=r)for(;p-- >0;){let t;switch(d){case 1:l=a.getInt(),h=a.getInt(),t=a.getFloat();break;case 2:l=a.getInt(),t=a.getFloat(),h=l+f;break;case 3:t=a.getFloat(),h=l+f,l+=u}if(!(c<e||c===e&&h<n)){if(c>r||c===r&&l>=i)break;if(Number.isFinite(t)){const e=s[c];o.push({chr:e,start:l,end:h,value:t})}}}}function uu(){const t=function(t,e,n,r){if("biginteract"===r||n&&"chromatinInteract"===n.table||"interact"===n.table)return function(t,e){return t.chr1=e[5],t.start1=Number.parseInt(e[6]),t.end1=Number.parseInt(e[7]),t.chr2=e[10],t.start2=Number.parseInt(e[11]),t.end2=Number.parseInt(e[12]),t.name=e[0],t.score=Number(e[1]),t.value=Number(e[2]),t.color="."===e[4]?void 0:"0"===e[4]?"rgb(0,0,0)":e[4],t};{const r=t-3;return function(i,o){if(r>0&&(i.name=o[0]),r>1&&(i.score=Number(o[1])),r>2&&(i.strand=o[2]),r>3&&(i.cdStart=parseInt(o[3])),r>4&&(i.cdEnd=parseInt(o[4])),r>5&&"."!==o[5]&&"0"!==o[5]&&"-1"!==o[5]){const t=ro.createColorString(o[5]);i.color=t.startsWith("rgb")?t:void 0}if(r>8){const t=parseInt(o[6]),e=o[7].split(","),n=o[8].split(","),r=[];for(let o=0;o<t;o++){const t=i.start+parseInt(n[o]),s=t+parseInt(e[o]);r.push({start:t,end:s})}!function(t,e,n){for(let r of t){const t=r.end,i=r.start;t<e||i>n?r.utr=!0:(e>=i&&e<=t&&(r.cdStart=e),n>=i&&n<=t&&(r.cdEnd=n))}}(r,i.cdStart,i.cdEnd),i.exons=r}if(n)for(let r=t;r<e;r++)if(r<n.fields.length){const t=n.fields[r].name,e=o[r-3];i[t]=e}}}}(this.header.definedFieldCount,this.header.fieldCount,this.autoSql,this.format);return function(e,n,r,i,o,s,a){const c=new Wa(e);for(;c.remLength()>=13;){const e=c.getInt(),l=a[e],h=c.getInt(),u=c.getInt(),f=c.getString();if(!(e<n||e===n&&u<r)){if(e>i||e===i&&h>=o)break;if(u>0){const e={chr:l,start:h,end:u};s.push(e);const n=f.split("\t");t(e,n)}}}}}function fu(t,e,n,r,i,o,s,a){const c=new Wa(t);for(;c.remLength()>=32;){const t=c.getInt(),l=s[t],h=c.getInt(),u=c.getInt(),f=c.getInt(),d=c.getFloat(),p=c.getFloat(),g=c.getFloat();let m;switch(c.getFloat(),a){case"min":m=d;break;case"max":m=p;break;default:m=0===f?0:g/f}if(!(t<e||t===e&&u<n)){if(t>r||t===r&&h>=i)break;Number.isFinite(m)&&o.push({chr:l,start:h,end:u,value:m})}}}class du{constructor(t){this.data=Ki(t).buffer}loadArrayBuffer(t,e){const n=e.range;return n?this.data.slice(n.start,n.start+n.size):this.data}async dataViewForRange(t,e){const n=Math.min(this.data.byteLength-t.start,t.size);return e?new Uint8Array(this.data,t.start,n):new DataView(this.data,t.start,n)}}class pu{constructor(t,e){this.reader=new nu(t,e),this.genome=e,this.format=t.format||"bigwig",this.wgValues={}}async getFeatures({chr:t,start:e,end:n,bpPerPixel:r,windowFunction:i}){const o="all"===t.toLowerCase()?await this.getWGValues(i):await this.reader.readFeatures(t,e,t,n,r,i);return"bigwig"===this.reader.type||Kh(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(t){const e=this.genome;if(this.wgValues[t])return this.wgValues[t];{const n=e.getGenomeLength()/1e3,r=await this.reader.readWGFeatures(n,t);let i=[];for(let t of r){const n=t.chr,r=e.getCumulativeOffset(n),o=Object.assign({},t);o.chr="all",o.start=r+t.start,o.end=r+t.end,i.push(o)}return this.wgValues[t]=i,i}}supportsWholeGenome(){return"bigwig"===this.reader.type}async trackType(){return this.reader.getTrackType()}}class gu{constructor(t,e){this.config=t,this.genome=e,this.path=t.url,this.groupCache={},this.datasetCache={}}async readHeader(){if(void 0!==this.magic)return this;let t=await go.loadArrayBuffer(this.path,gs(this.config,{range:{start:0,size:64e3}})),e=new Wa(new DataView(t));if(this.magic=e.getInt(),this.version=e.getInt(),this.indexPos=e.getLong(),this.indexSize=e.getInt(),e.getInt(),this.version>=2){let t=e.getInt();for(this.windowFunctions=[];t-- >0;)this.windowFunctions.push(e.getString())}this.trackType=e.getString(),this.trackLine=e.getString();let n=e.getInt();for(this.trackNames=[];n-- >0;)this.trackNames.push(e.getString());this.genomeID=e.getString(),this.flags=e.getInt(),this.compressed=0!=(1&this.flags),t=await go.loadArrayBuffer(this.path,gs(this.config,{range:{start:this.indexPos,size:this.indexSize}})),e=new Wa(new DataView(t)),this.datasetIndex={};let r=e.getInt();for(;r-- >0;){const t=e.getString(),n=e.getLong(),r=e.getInt();this.datasetIndex[t]={position:n,size:r}}for(this.groupIndex={},r=e.getInt();r-- >0;){const t=e.getString(),n=e.getLong(),r=e.getInt();this.groupIndex[t]={position:n,size:r}}return this}async readDataset(t,e,n){const r=t+"_"+e+"_"+n;if(this.datasetCache[r])return this.datasetCache[r];{await this.readHeader();const i=this.version<2?"":"/"+e,o="all"===t.toLowerCase()||void 0===n?"0":n.toString();let s;s="raw"===e?"/"+t+"/raw":"/"+t+"/z"+o+i;const a=this.datasetIndex[s];if(void 0===a)return;const c=await go.loadArrayBuffer(this.path,gs(this.config,{range:{start:a.position,size:a.size}}));if(!c)return;const l=new Wa(new DataView(c));let h=l.getInt();const u={};for(;h-- >0;)u[l.getString()]=l.getString();const f=l.getString(),d=l.getFloat();let p=l.getInt();const g=[];for(;p-- >0;)g.push({position:l.getLong(),size:l.getInt()});const m={name:s,attributes:u,dataType:f,tileWidth:d,tiles:g};return this.datasetCache[r]=m,m}}async readRootGroup(){const t=this.genome,e=this.groupCache["/"];if(e)return e;{const e=await this.readGroup("/"),n=e.chromosomes,r=e.maxZoom;r&&(this.maxZoom=Number(r));const i=e.totalCount;i&&(e.totalCount=Number(i));const o={};return n&&n.split(",").forEach((function(e){const n=t.getChromosomeName(e);o[n]=e})),this.chrAliasTable=o,this.groupCache["/"]=e,e}}async readGroup(t){const e=this.groupCache[t];if(e)return e;{await this.readHeader();const e=this.groupIndex[t];if(void 0===e)return;const n=await go.loadArrayBuffer(this.path,gs(this.config,{range:{start:e.position,size:e.size}}));if(!n)return;const r=new Wa(new DataView(n)),i={name:t};let o=r.getInt();for(;o-- >0;){const t=r.getString(),e=r.getString();i[t]=e}return this.groupCache[t]=i,i}}async readTiles(t,e){if(t.sort((function(t,e){return t.position-e.position})),0===(t=t.filter((function(t){return t.size>0}))).length)return Promise.resolve([]);const n=t[0],r=t[t.length-1],i=n.position,o=r.position+r.size-i,s=await go.loadArrayBuffer(this.path,gs(this.config,{range:{start:i,size:o}})),a=[];for(let n of t){const t=n.position-i,r=n.size;if(r>0){let n;if(this.compressed){n=Wi(s.slice(t,t+r)).buffer}else n=s.slice(t,t+r);const i=new Wa(new DataView(n)),o=i.getString();let c;switch(o){case"fixedStep":c=mu(i,e);break;case"variableStep":c=vu(i,e);break;case"bed":case"bedWithName":c=bu(i,e,o);break;default:throw"Unknown tile type: "+o}a.push(c)}}return a}async readTile(t,e){let n=await go.loadArrayBuffer(this.path,gs(this.config,{range:{start:t.position,size:t.size}}));if(this.compressed){n=Wi(n).buffer}const r=new Wa(new DataView(n)),i=r.getString();switch(i){case"fixedStep":return mu(r,e);case"variableStep":return vu(r,e);case"bed":case"bedWithName":return bu(r,e,i);default:throw"Unknown tile type: "+i}}}function mu(t,e){const n=t.getInt(),r=t.getInt(),i=t.getFloat(),o=[];let s=e;for(;s-- >0;){let e=n;const r=[];for(;e-- >0;)r.push(t.getFloat());o.push(r)}return{type:"fixedStep",start:r,span:i,data:o,nTracks:e,nPositions:n}}function vu(t,e){const n=t.getInt(),r=t.getFloat(),i=t.getInt(),o=[];let s=i;for(;s-- >0;)o.push(t.getInt());t.getInt();const a=[];let c=e;for(;c-- >0;){s=i;const e=[];for(;s-- >0;)e.push(t.getFloat());a.push(e)}return{type:"variableStep",tileStart:n,span:r,start:o,data:a,nTracks:e,nPositions:i}}function bu(t,e,n){const r=t.getInt();let i=r;const o=[];for(;i-- >0;)o.push(t.getInt());i=r;const s=[];for(;i-- >0;)s.push(t.getInt());t.getInt();const a=[];let c=e;for(;c-- >0;){let e=r;const n=[];for(;e-- >0;)n.push(t.getFloat());a.push(n)}if("bedWithName"===n){i=r;const e=[];for(;i-- >0;)e.push(t.getString())}return{type:n,start:o,end:s,data:a,nTracks:e,nPositions:r}}class wu{constructor(t,e){this.genome=e,this.windowFunction=t.windowFunction||"mean",this.reader=new gu(t,e)}async getFeatures({chr:t,start:e,end:n,bpPerPixel:r}){if("all"===t.toLowerCase()){const t=[],e=this.genome;if(this.genome.wgChromosomeNames)for(let n of e.wgChromosomeNames){const i=e.getChromosome(n).bpLength;r=i/1e3;const o=await this._getFeatures(n,0,i,r);if(o)for(let n of o){const r=Object.assign({},n);r.chr="all",r.start=e.getGenomeCoordinate(n.chr,n.start),r.end=e.getGenomeCoordinate(n.chr,n.end),r._f=n,t.push(r)}}return t}return this._getFeatures(t,e,n,r)}async _getFeatures(t,e,n,r){const i=new Gs(t,e,n),o=this.genome;if(!this.rootGroup&&(this.rootGroup=await this.reader.readRootGroup(),!this.normalizationFactor)){const t=this.rootGroup.totalCount;t&&(this.normalizationFactor=1e6/t)}i.bpPerPixel=r;const s=function(t,e,n){var r=n.getChromosome(t).bpLength;return Math.ceil(Math.log(Math.max(0,r/(700*e)))/_u)}(t,r,o);let a=this.reader.chrAliasTable[t],c=this.reader.maxZoom;void 0===a&&(a=t),void 0===c&&(c=-1);const l=s>c?"raw":this.windowFunction,h=await this.reader.readDataset(a,l,s);if(null==h)return[];const u=h.tileWidth,f=Math.floor(e/u),d=Math.floor(n/u),p=await this.reader.readTiles(h.tiles.slice(f,d+1),1),g=[];for(let i of p)switch(i.type){case"bed":yu(i,t,e,n,r,g);break;case"variableStep":xu(i,t,e,n,r,g);break;case"fixedStep":ku(i,t,e,n,r,g);break;default:throw"Unknown tile type: "+i.type}return g.sort((function(t,e){return t.start-e.start})),g}get supportsWholeGenome(){return!0}}function yu(t,e,n,r,i,o){const s=t.nPositions,a=t.start,c=t.end,l=t.data[0];for(let t=0;t<s;t++){const i=a[t],s=c[t];if(!(s<n)){if(i>r)break;o.push({chr:e,start:i,end:s,value:l[t]})}}}function xu(t,e,n,r,i,o){const s=t.nPositions,a=t.start,c=t.span,l=t.data[0];for(let t=0;t<s;t++){const i=a[t],s=i+c;if(!(s<n)){if(i>r)break;o.push({chr:e,start:i,end:s,value:l[t]})}}}function ku(t,e,n,r,i,o){const s=t.nPositions;let a=t.start;const c=t.span,l=t.data[0];for(let t=0;t<s;t++){const i=a+c;if(a>r)break;i>=n&&(Number.isNaN(l[t])||o.push({chr:e,start:a,end:i,value:l[t]})),a=i}}var _u=Math.log(2);const Su=new Set(["bigwig","bw","bigbed","bb","biginteract","biggenepred","bignarrowpeak"]);function Cu(t,e){const n=t.format?t.format.toLowerCase():void 0;return Su.has(n)?new pu(t,e):"tdf"===n?new wu(t,e):new Jh(t,e)}const Eu={getTissueInfo:function(t,e){let n=(e=e||"https://gtexportal.org/rest/v1")+"/dataset/tissueInfo?datasetId="+(t=t||"gtex_v8");return go.loadJson(n,{})},trackConfiguration:function(t,e){return{type:"eqtl",sourceType:"gtex-ws",url:(e=e||"https://gtexportal.org/rest/v1")+"/association/singleTissueEqtlByLocation",tissueSiteDetailId:t.tissueSiteDetailId,name:t.tissueSiteDetailId.split("_").join(" "),visibilityWindow:25e4}}};function Au(t,e,n){let r=(t.start-e)/n,i=(t.end-e)/n,o=i-r;return o<3&&(o=3,r-=1.5),{px:r,px1:i,pw:o}}function Tu(t,e,n,r,i,o){try{i.save(),i.fillStyle=this.defaultColor,i.strokeStyle=this.defaultColor;const r=Mu.call(this,t);let s,a;i.fillStyle=r,i.strokeStyle=r,"SQUISHED"===this.displayMode&&void 0!==t.row?(s=this.featureHeight/2,a=this.margin+this.squishedRowHeight*t.row):"EXPANDED"===this.displayMode&&void 0!==t.row?(s=this.featureHeight,a=this.margin+this.expandedRowHeight*t.row):(s=this.featureHeight,a=this.margin);const c=o.pixelWidth,l=a+s/2,h=s/2,u=l-h/2,f=t.exons?t.exons.length:0,d=Au(t,e,n),p=this.arrowSpacing,g="+"===t.strand?1:"-"===t.strand?-1:0;if(0===f){const t=Math.max(0,d.px),e=Math.min(c,d.px1),n=e-t;if(i.fillRect(t,a,n,s),0!==g){i.fillStyle="white",i.strokeStyle="white";for(let n=t+p/2;n<e;n+=p)ls.strokeLine(i,n-2*g,l-2,n,l),ls.strokeLine(i,n-2*g,l+2,n,l);i.fillStyle=r,i.strokeStyle=r}}else{ls.strokeLine(i,d.px+1,l,d.px1-1,l);const o=Math.max(0,d.px)+p/2,m=Math.min(c,d.px1);for(let t=o;t<m;t+=p)ls.strokeLine(i,t-2*g,l-2,t,l),ls.strokeLine(i,t-2*g,l+2,t,l);for(let o=0;o<f;o++){const f=t.exons[o];let d,m=Math.round((f.start-e)/n),v=Math.round((f.end-e)/n),b=Math.max(1,v-m);if(!(m+b<0)){if(m>c)break;if(f.utr)i.fillRect(m,u,b,h);else if(f.cdStart&&(d=Math.round((f.cdStart-e)/n),i.fillRect(m,u,d-m,h),b-=d-m,m=d),f.cdEnd&&(d=Math.round((f.cdEnd-e)/n),i.fillRect(d,u,v-d,h),b-=v-d,v=d),b=Math.max(b,1),i.fillRect(m,a,b,s),b>p+5&&0!==g){i.fillStyle="white",i.strokeStyle="white";for(let t=m+p/2;t<v;t+=p)ls.strokeLine(i,t-2*g,l-2,t,l),ls.strokeLine(i,t-2*g,l+2,t,l);i.fillStyle=r,i.strokeStyle=r}}}}o.drawLabel&&"SQUISHED"!==this.displayMode&&Lu.call(this,i,t,d.px,d.px1,a,o.referenceFrame,o)}finally{i.restore()}}function Lu(t,e,n,r,i,o,s){try{t.save();let a=e.name;if(void 0===a&&e.gene&&(a=e.gene.name),void 0===a&&(a=e.id||e.ID),!a||"."===a)return;let c=s.pixelXOffset||0;const l=Math.max(n,-c),h=(l+Math.min(r,-c+s.viewportWidth))/2;let u;"COLLAPSED"===this.displayMode&&"SLANT"===this.labelDisplayMode&&(u={rotate:{angle:45}});const f=function(t,e){return e?t+20:t+25}(i,u);let d,p=Mu.call(this,e),g=!1;o.selection&&Eu.gtexLoaded&&(g=!0,d=o.selection.colorForGene(a));const m={textAlign:"SLANT"===this.labelDisplayMode?void 0:"center",fillStyle:d||p,strokeStyle:d||p},v=t.measureText(a),b=h-v.width/2,w=h+v.width/2;(s.labelAllFeatures||b>s.rowLastLabelX[e.row]||g)&&(s.rowLastLabelX[e.row]=w,ls.fillText(t,a,h,f,m,u))}finally{t.restore()}}function Mu(t){let e;if(this.altColor&&"-"===t.strand)e="function"==typeof this.altColor?this.altColor(t):this.altColor;else if(this.color)e="function"==typeof this.color?this.color(t):this.color;else if(this.colorBy){const n=t.getAttributeValue?t.getAttributeValue(this.colorBy):t[this.colorBy];e=this.colorTable.getColor(n)}else e=t.color?t.color:this.defaultColor;if(t.alpha&&1!==t.alpha)e=ro.addAlpha(e,t.alpha);else if(this.useScore&&t.score&&!Number.isNaN(t.score)){const n=function(t,e,n){const r=(e-t)/9,i=Math.floor((n-t)/r);return Math.min(1,.2+.8*i/9)}(this.config.min?this.config.min:0,this.config.max?this.config.max:1e3,t.score);t.alpha=n,e=ro.addAlpha(e,n)}return e}const Ru=new Set(["nonsense","missense","stop-loss","frameshift","cds-indel"]),Iu=new Set(["coding-synon"]),Nu=new Set(["splice-3","splice-5"]),Pu=new Set(["untranslated-5","untranslated-3"]);function Ou(t,e,n,r,i){var o,s,a,c,l=Au(t,e,n),h=this.margin,u=this.snpColors.length;switch(o="squished"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight,this.colorBy){case"function":c=t.func,s=c.split(",").map((function(t){return Ru.has(t)||Nu.has(t)?u-1:Iu.has(t)?u-2:Pu.has(t)?u-3:0})).reduce((function(t,e){return Math.max(t,e)}));break;case"class":s="deletion"===(a=t.class)?u-1:"mnp"===a?u-2:"microsatellite"===a||"named"===a?u-3:0}i.fillStyle=this.snpColors[s],i.fillRect(l.px,h,l.pw,o)}function Fu(t,e,n,r,i){const o="EXPANDED"===this.displayMode?this.expandedRowHeight:this.squishedRowHeight;let s=this.margin;"COLLAPSED"!==this.displayMode&&void 0!==t.row&&(s+=t.row*o);const a=s+.5*o,c=a-.5*o,l=a+.5*o,h=Math.round((t.junction_left-e)/n),u=Math.round((t.junction_right-e)/n);i.beginPath(),i.moveTo(h,a),i.bezierCurveTo(h,c,u,c,u,a),i.lineWidth=1+Math.log(t.num_junction_reads)/Math.log(2),i.strokeStyle="blue",i.stroke();const f=t.spanning_frag_coords;for(let t=0;t<f.length;t++){const r=f[t],o=Math.round((r.left-e)/n),s=Math.round((r.right-e)/n);i.beginPath(),i.moveTo(o,a),i.bezierCurveTo(o,l,s,l,s,a),i.lineWidth=1,i.strokeStyle="purple",i.stroke()}}class Du extends bc{constructor(t,e){super(t,e)}init(t){super.init(t),this.type=t.type||"annotation",this.maxRows=void 0===t.maxRows?1e3:t.maxRows,this.displayMode=t.displayMode||"EXPANDED",this.labelDisplayMode=t.labelDisplayMode,t._featureSource?(this.featureSource=t._featureSource,delete t._featureSource):this.featureSource=t.featureSource?t.featureSource:Cu(t,this.browser.genome),this.autoHeight=t.autoHeight,this.margin=void 0===t.margin?10:t.margin,this.featureHeight=t.featureHeight||14,"FusionJuncSpan"===t.type?(this.render=t.render||Fu,this.squishedRowHeight=t.squishedRowHeight||50,this.expandedRowHeight=t.expandedRowHeight||50,this.height=t.height||this.margin+2*this.expandedRowHeight):"snp"===t.type?(this.render=t.render||Ou,this.snpColors=["rgb(0,0,0)","rgb(0,0,255)","rgb(0,255,0)","rgb(255,0,0)"],this.colorBy="function",this.expandedRowHeight=t.expandedRowHeight||10,this.squishedRowHeight=t.squishedRowHeight||5,this.height=t.height||30):(this.render=t.render||Tu,this.arrowSpacing=30,function(t){t.browser.on&&(t.browser.on("trackdragend",e),t.browser.on("trackremoved",n));function e(){t.trackView&&"SQUISHED"!==t.displayMode&&t.trackView.repaintViews()}function n(r){t.browser.un&&t===r&&(t.browser.un("trackdragend",e),t.browser.un("trackremoved",n))}}(this),this.squishedRowHeight=t.squishedRowHeight||15,this.expandedRowHeight=t.expandedRowHeight||30,this.height=t.height||this.margin+2*this.expandedRowHeight,t.colorBy&&(t.colorBy.field&&(t.colorTable=t.colorBy.pallete||t.colorBy.palette,t.colorBy=t.colorBy.field),this.colorBy=t.colorBy,t.colorTable?this.colorTable=new Sc(t.colorTable):this.colorTable=new _c("Set1"))),this.useScore=t.useScore}async postInit(){return"function"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader()),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(t,e,n,r){const i=this.visibilityWindow;return this.featureSource.getFeatures({chr:t,start:e,end:n,bpPerPixel:r,visibilityWindow:i})}computePixelHeight(t){if("COLLAPSED"===this.displayMode)return this.margin+this.expandedRowHeight;{let e=0;if(t&&"function"==typeof t.forEach)for(let n of t)n.row&&n.row>e&&(e=n.row);return this.margin+(e+1)*("SQUISHED"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight)}}draw(t){const e=t.features,n=t.context,r=t.bpPerPixel,i=t.bpStart,o=t.pixelWidth,s=t.pixelHeight,a=i+o*r+1;if(this.config.isMergedTrack||ls.fillRect(n,0,t.pixelTop,o,s,{fillStyle:"rgb(255, 255, 255)"}),e){const c=[];t.rowLastX=[],t.rowLastLabelX=[];for(let n of e)if(n.start>i&&n.end<a){const e="COLLAPSED"===this.displayMode?0:n.row||0;void 0===c[e]?c[e]=1:c[e]++,t.rowLastX[e]=-Number.MAX_SAFE_INTEGER,t.rowLastLabelX[e]=-Number.MAX_SAFE_INTEGER}const l=o/Math.max(...c);let h=[];for(let o of e){if(o.end<i)continue;if(o.start>a)break;const e="COLLAPSED"===this.displayMode?0:o.row;t.drawLabel=t.labelAllFeatures||l>10;const c=Math.ceil((o.end-i)/r),u=h[e];if(!u||c>u){this.render.call(this,o,i,r,s,n,t);const a=Math.floor((o.start-i)/r);u&&a-u<=0&&(n.globalAlpha=.5,ls.strokeLine(n,a,0,a,s,{strokeStyle:"rgb(255, 255, 255)"}),n.globalAlpha=1),h[e]=c}}}else console.log("No feature list")}clickedFeatures(t,e){const n=t.y-this.margin,r=super.clickedFeatures(t,e);let i;switch(this.displayMode){case"SQUISHED":i=Math.floor(n/this.squishedRowHeight);break;case"EXPANDED":i=Math.floor(n/this.expandedRowHeight);break;default:i=void 0}return r.filter((function(t){return void 0===i||void 0===t.row||i===t.row}))}popupData(t,e){e=this.clickedFeatures(t,e);const n=t.genomicLocation,r=[];for(let t of e){const e=t._f||t,i="function"==typeof e.popupData?e.popupData(n):this.extractPopupData(e);if(i){r.length>0&&r.push("<hr/><hr/>");const o=this.infoURL||this.config.infoURL;for(let e of i)if(r.push(e),o&&e.name&&"name"===e.name.toLowerCase()&&e.value&&_e(e.value)&&!e.value.startsWith("<")){const n=o.replace("$$",t.name);e.value=`<a target=_blank href=${n}>${e.value}</a>`}const s="gff"===this.config.format||"gff3"===this.config.format||"gtf"===this.config.format;if(e.exons)for(let t=0;t<e.exons.length;t++){const i=e.exons[t];if(n>=i.start&&n<=i.end){const n=s?i.number:"-"===e.strand?e.exons.length-t:t+1;n&&(r.push("<hr/>"),r.push({name:"Exon Number",value:n}));break}}}}return r}menuItemList(){const t=[];if(this.render===Ou){t.push("<hr/>");for(let e of["function","class"])t.push({object:pe(Po("Color by "+e,e===this.colorBy)),click:()=>{this.colorBy=e,this.trackView.repaintViews()}})}t.push("<hr/>");for(let e of["COLLAPSED","SQUISHED","EXPANDED"]){const n={COLLAPSED:"Collapse",SQUISHED:"Squish",EXPANDED:"Expand"};t.push({object:pe(Po(n[e],e===this.displayMode)),click:()=>{this.displayMode=e,this.config.displayMode=e,this.trackView.checkContentHeight(),this.trackView.repaintViews()}})}return t}contextMenuItemList(t){const e=this.clickedFeatures(t);e.length>1&&e.sort(((t,e)=>e.end-e.start-(t.end-t.start)));const n=e[0];if(n.end-n.start<=1e6){const t=[{label:"View feature sequence",click:async()=>{let t=await this.browser.genome.getSequence(n.chr,n.start,n.end);"-"===n.strand&&(t=As(t)),t||(t="Unknown sequence"),Qo.presentAlert(t)}}];return Ss()&&void 0!==navigator.clipboard&&t.push({label:"Copy feature sequence",click:async()=>{let t=await this.browser.genome.getSequence(n.chr,n.start,n.end);"-"===n.strand&&(t=As(t));try{await navigator.clipboard.writeText(t)}catch(t){console.error(t),Qo.presentAlert(`error copying sequence to clipboard ${t}`)}}}),t.push("<hr/>"),t}}description(){if(Ou===this.render){let t="<html>"+this.name+"<hr/>";return t+="<em>Color By Function:</em><br>",t+='<span style="color:red">Red</span>: Coding-Non-Synonymous, Splice Site<br>',t+='<span style="color:green">Green</span>: Coding-Synonymous<br>',t+='<span style="color:blue">Blue</span>: Untranslated<br>',t+='<span style="color:black">Black</span>: Intron, Locus, Unknown<br><br>',t+="<em>Color By Class:</em><br>",t+='<span style="color:red">Red</span>: Deletion<br>',t+='<span style="color:green">Green</span>: MNP<br>',t+='<span style="color:blue">Blue</span>: Microsatellite, Named<br>',t+='<span style="color:black">Black</span>: Indel, Insertion, SNP',t+="</html>",t}return super.description()}dispose(){this.trackView=void 0}}class Bu extends bc{constructor(t,e){super(t,e)}init(t){super.init(t),this.type="wig",this.height=t.height||50,this.featureType="numeric",this.paintAxis=yc;const e=t.format?t.format.toLowerCase():t.format;this.flipAxis=!!t.flipAxis&&t.flipAxis,this.logScale=!!t.logScale&&t.logScale,this.featureSource="bigwig"===e?new pu(t,this.browser.genome):"tdf"===e?new wu(t,this.browser.genome):Cu(t,this.browser.genome),this.autoscale=t.autoscale||void 0===t.max,this.autoscale||(this.dataRange={min:t.min||0,max:t.max}),this.windowFunction=t.windowFunction||"mean",this.graphType=t.graphType||"bar",this.normalize=t.normalize,this.scaleFactor=t.scaleFactor}async postInit(){const t=await this.getHeader();t&&this.setTrackProperties(t)}async getFeatures(t,e,n,r){const i=await this.featureSource.getFeatures({chr:t,start:e,end:n,bpPerPixel:r,windowFunction:this.windowFunction});if(this.normalize&&this.featureSource.normalizationFactor){const t=this.featureSource.normalizationFactor;for(let e of i)e.value*=t}if(this.scaleFactor){const t=this.scaleFactor;for(let e of i)e.value*=t}return i}menuItemList(){let t=[];return void 0!==this.flipAxis&&t.push({label:"Flip y-axis",click:()=>{this.flipAxis=!this.flipAxis,this.trackView.repaintViews()}}),t=t.concat(Oo.numericDataMenuItems(this.trackView)),t}async getHeader(){return"function"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader()),this.header}getScaleFactor(t,e,n,r){return r?n/(Math.log10(e+1)-(t<=0?0:Math.log10(t+1))):n/(e-t)}computeYPixelValue(t,e){return(this.flipAxis?t-this.dataRange.min:this.dataRange.max-t)*e}computeYPixelValueInLogScale(t,e){let n=this.dataRange.max,r=this.dataRange.min;return n<=0?0:(r<=-1&&(r=0),r=r<=0?0:Math.log10(r+1),n=Math.log10(n+1),t=Math.log10(t+1),(this.flipAxis?t-r:n-t)*e)}draw(t){const e=t.features,n=t.context,r=t.bpPerPixel,i=t.bpStart,o=t.pixelWidth;t.pixelHeight;const s=i+o*r+1;let a=-1,c=-1;const l=this.color||"rgb(150,150,150)";let h;"string"==typeof l&&l.startsWith("rgb(")&&(h=ro.addAlpha(l,.1));const u=this.getScaleFactor(this.dataRange.min,this.dataRange.max,t.pixelHeight,this.logScale),f=t=>this.logScale?this.computeYPixelValueInLogScale(t,u):this.computeYPixelValue(t,u);if(e&&e.length>0&&(void 0===this.dataRange.min&&(this.dataRange.min=0),this.dataRange.max>this.dataRange.min)){const o=f(0);for(let t of e){if(t.end<i)continue;if(t.start>s)break;const e=Math.floor((t.start-i)/r);if(isNaN(e))continue;let h=f(t.value);const u=Math.ceil((t.end-i)/r),d=Math.max(1,u-e);let p=t.value<0&&this.altColor?this.altColor:l;const g="function"==typeof p?p(t.value):p;if("points"===this.graphType){const t=this.config.pointSize||3,r=e+d/2;ls.fillCircle(n,r,h,t/2,{fillStyle:g,strokeStyle:g})}else{let r=h-o;const i=e+d;(i>a||t.value>=0&&t.value>c||t.value<0&&t.value<1)&&ls.fillRect(n,e,o,d,r,{fillStyle:g}),c=t.value,a=i}}if(this.dataRange.min<0){const e=this.dataRange.max/(this.dataRange.max-this.dataRange.min)*t.pixelHeight;ls.strokeLine(n,0,e,t.pixelWidth,e,{strokeStyle:h})}}if(this.config.hasOwnProperty("guideLines"))for(let e of this.config.guideLines)if(e.hasOwnProperty("color")&&e.hasOwnProperty("y")&&e.hasOwnProperty("dotted")){let n=f(e.y),r={strokeStyle:e.color,strokeWidth:2};e.dotted?ls.dashedLine(t.context,0,n,t.pixelWidth,n,5,r):ls.strokeLine(t.context,0,n,t.pixelWidth,n,r)}}popupData(t,e){if((e=this.clickedFeatures(t,e))&&e.length>0){const n=t.genomicLocation,r=[];e.sort((function(t,e){return Math.abs((t.start+t.end)/2-n)-Math.abs((e.start+e.end)/2-n)}));const i=e.length>10?e.slice(0,10):e;i.sort((function(t,e){return t.start-e.start}));for(let t of i)if(t){r.length>0&&r.push("<hr/>");let e=t.end-t.start==1?Se(t.start+1):Se(t.start+1)+"-"+Se(t.end);r.push({name:"Position:",value:e}),r.push({name:"Value: ",value:Se(t.value)})}return i.length<e.length&&r.push("<hr/>..."),r}return[]}get supportsWholeGenome(){return!this.config.indexURL&&!1!==this.config.supportsWholeGenome}dispose(){this.trackView=void 0}getState(){const t=super.getState();return void 0!==this.flipAxis&&(t.flipAxis=this.flipAxis),void 0!==this.logScale&&(t.logScale=this.logScale),t}}function zu(t){this.thresholds=t.thresholds,this.colors=t.colors}function Hu(t){this.scale=t,this.lowColor="rgb("+t.lowR+","+t.lowG+","+t.lowB+")",this.highColor="rgb("+t.highR+","+t.highG+","+t.highB+")",this.diff=t.high-t.low}zu.prototype.getColor=function(t){for(let e of this.thresholds)if(t<e)return this.colors[this.thresholds.indexOf(e)];return this.colors[this.colors.length-1]},Hu.prototype.getColor=function(t){var e,n=this.scale;return t<=n.low?this.lowColor:t>=n.high?this.highColor:(e=(t-n.low)/this.diff,"rgb("+Math.floor(n.lowR+e*(n.highR-n.lowR))+","+Math.floor(n.lowG+e*(n.highG-n.lowG))+","+Math.floor(n.lowB+e*(n.highB-n.lowB))+")")};class Vu{constructor(t){this.color=t}getColor(){return this.color}}class ju extends bc{constructor(t,e){super(t,e)}init(t){if(super.init(t),this.type=t.type||"seg","maf"===this.type&&(this.type="mut"),this.isLog=t.isLog,this.displayMode=t.displayMode||"EXPANDED",this.height=t.height||300,this.maxHeight=t.maxHeight||500,this.squishedRowHeight=t.sampleSquishHeight||t.squishedRowHeight||2,this.expandedRowHeight=t.sampleExpandHeight||t.expandedRowHeight||13,this.sampleHeight=this.squishedRowHeight,t.color?this.color=t.color:(this.posColorScale=t.posColorScale||new Hu({low:.1,lowR:255,lowG:255,lowB:255,high:1.5,highR:255,highG:0,highB:0}),this.negColorScale=t.negColorScale||new Hu({low:-1.5,lowR:0,lowG:0,lowB:255,high:-.1,highR:255,highG:255,highB:255}),"mut"===this.type&&(this.colorTable=new Sc(t.colorTable||Uu))),this.sampleKeys=[],this.sampleNames=new Map,t.samples){for(let e of t.samples)this.sampleKeys.push(e),this.sampleNames.set(e,e);this.explicitSamples=!0}const e=Object.assign({},this.config);e.maxWGCount=e.maxWGCount||Number.MAX_SAFE_INTEGER,this.featureSource=Cu(e,this.browser.genome),this.initialSort=t.sort}async postInit(){"function"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader()),this.header&&this.setTrackProperties(this.header)}menuItemList(){const t=[],e={SQUISHED:"Squish",EXPANDED:"Expand",FILL:"Fill"};t.push("<hr/>"),t.push("DisplayMode:");const n="seg"===this.type?["SQUISHED","EXPANDED","FILL"]:["SQUISHED","EXPANDED"];for(let r of n){const n=Po(e[r],r===this.displayMode);t.push({object:pe(n),click:()=>{this.displayMode=r,this.config.displayMode=r,this.trackView.checkContentHeight(),this.trackView.repaintViews(),this.trackView.moveScroller(this.trackView.sampleNameViewport.trackScrollDelta)}})}return t}hasSamples(){return!0}getSamples(){return{names:this.sampleKeys.map((t=>this.sampleNames.get(t))),height:this.sampleHeight,yOffset:0}}async getFeatures(t,e,n){const r=await this.featureSource.getFeatures({chr:t,start:e,end:n});if(this.initialSort){const t=this.initialSort;this.sortSamples(t.chr,t.start,t.end,t.direction,r),this.initialSort=void 0}return r}draw({context:t,renderSVG:e,pixelTop:n,pixelWidth:r,pixelHeight:i,features:o,bpPerPixel:s,bpStart:a}){if(ls.fillRect(t,0,0,r,i,{fillStyle:"rgb(255, 255, 255)"}),o&&o.length>0){this.checkForLog(o),this.updateSampleKeys(o);const e={};let c;switch(this.sampleKeys.forEach((function(t,n){e[t]=n})),this.displayMode){case"FILL":this.sampleHeight=i/this.sampleKeys.length,c=0;break;case"SQUISHED":this.sampleHeight=this.squishedRowHeight,c=0;break;default:this.sampleHeight=this.expandedRowHeight,c=1}const l=this.sampleHeight;for(let t of o)t.pixelRect=void 0;const h=n+i,u=a+r*s+1,f=s;this.sampleYStart=void 0;for(let r of o){if(r.end<a)continue;if(r.start>u)break;const i=r.sampleKey||r.sample;r.row=e[i];const o=r.row*l+c;void 0===this.sampleYStart&&(this.sampleYStart=o);if(o+l<n||o>h)continue;const s=Math.max(r.start,a);let d=Math.round((s-a)/f);const p=Math.min(r.end,u),g=Math.round((p-a)/f);let m,v,b=Math.max(1,g-d);if(this.color?m="function"==typeof this.color?this.color(r):this.color:this.colorTable&&(m=this.colorTable.getColor(r.value.toLowerCase())),"mut"===this.type)v=l-2*c,b<3&&(b=3,d-=1);else{let t=r.value;this.isLog||(t=to(t/2)),m=t<-.1?this.negColorScale.getColor(t):t>.1?this.posColorScale.getColor(t):"white";let e=l;if(l<.25){const n=.1+2*Math.abs(t);e=Math.min(1,n*l)}v=e-2*c}r.pixelRect={x:d,y:o,w:b,h:v},t.fillStyle=m,t.fillRect(d,o,b,v)}}}checkForLog(t){if(void 0===this.isLog){this.isLog=!1;for(let e of t)if(e.value<0)return void(this.isLog=!0)}}computePixelHeight(t){if(!t)return 0;const e="SQUISHED"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight;return this.updateSampleKeys(t),this.sampleKeys.length*e}async sortSamples(t,e,n,r,i){if(i||(i=await this.featureSource.getFeatures({chr:t,start:e,end:n})),!i)return;this.updateSampleKeys(i);const o={},s="ASC"===r?1:-1,a=()=>{const t=n-e+1;for(let r of i){if(r.end<e)continue;if(r.start>n)break;const i=Math.max(e,r.start),s=(Math.min(n,r.end)-i)/t,a=r.sampleKey||r.sample,c=o[a]||0;o[a]=c+s*r.value}this.sampleKeys.sort((function(t,e){let n=o[t],r=o[e];return n||(n=s*Number.MAX_VALUE),r||(r=s*Number.MAX_VALUE),n===r?0:n>r?s:-1*s}))},c=()=>{for(let t of i){if(t.end<e)continue;if(t.start>n)break;const r=t.sampleKey||t.sample;(!o.hasOwnProperty(r)||t.value.localeCompare(o[r])>0)&&(o[r]=t.value)}this.sampleKeys.sort((function(t,e){let n=o[t]||"",r=o[e]||"";return s*n.localeCompare(r)}))};"mut"===this.type?c():a(),this.trackView.repaintViews()}clickedFeatures(t,e){const n=super.clickedFeatures(t,e),r=t.y;return n.filter((function(t){const e=t.pixelRect;return e&&r>=e.y&&r<=e.y+e.h}))}popupData(t,e){e=this.clickedFeatures(t);const n=[];for(let t of e){n.length>0&&(n.push("<hr/>"),n.push("<hr/>"));const e=t._f||t,r="function"==typeof e.popupData?e.popupData(this.type,this.browser.genome.id):this.extractPopupData(e);Array.prototype.push.apply(n,r)}return n}contextMenuItemList(t){const e=t.viewport.referenceFrame,n=t.genomicLocation,r=this.config.sort?"ASC"===this.config.sort.direction?"DESC":"ASC":"DESC",i=e.toBP(2.5),o=e=>{const n=t.viewport.cachedFeatures;this.sortSamples(e.chr,e.start,e.end,e.direction,n)};return[{label:"seg"===this.type?"Sort by value":"Sort by type",click:e=>{const s={direction:r,chr:t.viewport.referenceFrame.chr,start:n-i,end:n+i};o(s),this.config.sort=s}}]}get supportsWholeGenome(){return(!1===this.config.indexed||!this.config.indexURL)&&!1!==this.config.supportsWholeGenome}updateSampleKeys(t){if(!this.explicitSamples)for(let e of t){const t=e.sampleKey||e.sample;this.sampleNames.has(t)||(this.sampleNames.set(t,e.sample),this.sampleKeys.push(t))}}}const Uu={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 qu extends bc{constructor(t,e){super(t,e),this.type="merged",this.featureType="numeric",this.paintAxis=yc}init(t){if(!t.tracks)throw Error("Error: no tracks defined for merged track"+t);super.init(t)}async postInit(){this.tracks=[];const t=[];for(let e of this.config.tracks){e.isMergedTrack=!0;const n=await this.browser.createTrack(e);n?(n.autoscale=!1,this.tracks.push(n)):console.warn("Could not create track "+e),"function"==typeof n.postInit&&t.push(n.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 t of this.tracks)t.autoscale=!1,t.dataRange=this.dataRange;return this.height=this.config.height||50,Promise.all(t)}get height(){return this._height}set height(t){if(this._height=t,this.tracks)for(let e of this.tracks)e.height=t,e.config.height=t}menuItemList(){let t=[];return void 0!==this.flipAxis&&t.push({label:"Flip y-axis",click:()=>{this.flipAxis=!this.flipAxis,this.trackView.repaintViews()}}),t=t.concat(Oo.numericDataMenuItems(this.trackView)),t}async getFeatures(t,e,n,r){const i=this.tracks.map((i=>i.getFeatures(t,e,n,r)));return Promise.all(i)}draw(t){const e=t.features;this.autoscale&&(this.dataRange=function(t,e){let n=0,r=-Number.MAX_VALUE;for(let t of e)for(let e of t)void 0===e.value||Number.isNaN(e.value)||(n=Math.min(n,e.value),r=Math.max(r,e.value));return{min:n,max:r}}(t.referenceFrame.chr,e));for(let n=0,r=this.tracks.length;n<r;n++){const r=Object.assign({},t);r.features=e[n],this.tracks[n].dataRange=this.dataRange,this.tracks[n].flipAxis=this.flipAxis,this.tracks[n].logScale=this.logScale,this.tracks[n].graphType=this.graphType,this.tracks[n].draw(r)}}popupData(t,e){const n=e||t.viewport.cachedFeatures;if(n&&n.length===this.tracks.length){const e=[];for(let r=0;r<this.tracks.length;r++){r>0&&e.push("<hr/>"),e.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[r].name}</div>`);const i=this.tracks[r].popupData(t,n[r]);e.push(...i)}return e}}get supportsWholeGenome(){return this.tracks.every((t=>t.supportsWholeGenome()))}}class Wu extends bc{constructor(t,e){super(t,e)}init(t){super.init(t),this.theta=t.theta||Math.PI/4,this.sinTheta=Math.sin(this.theta),this.cosTheta=Math.cos(this.theta),this.height=t.height||250,this.arcType=function(t){if(!t.arcType)return"nested";switch(t.arcType){case"chiapet":return"inView";case"chiapetoutbound":return"partialInView";default:return t.arcType}}(t),this.arcOrientation=void 0===t.arcOrientation||t.arcOrientation,this.showBlocks=void 0===t.showBlocks||t.showBlocks,this.blockHeight=t.blockHeight||3,this.thickness=t.thickness||1,this.color=t.color||"rgb(180,25,137)",this.alpha=t.alpha||.02,this.painter={flipAxis:!this.arcOrientation,dataRange:this.dataRange,paintAxis:yc},t.valueColumn?(this.valueColumn=t.valueColumn,this.hasValue=!0):t.useScore&&(this.hasValue=!0,this.valueColumn="score"),this.logScale=!1!==t.logScale,t.max?(this.dataRange={min:t.min||0,max:t.max},this.autoscale=!1):this.autoscale=!0,this.featureSource=Cu(t,this.browser.genome),this.featureSource.getWGFeatures=Yu}async postInit(){return"function"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader()),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(t,e,n){const r=this.visibilityWindow,i=await this.featureSource.getFeatures({chr:t,start:e,end:n,visibilityWindow:r});return void 0===this.hasValue&&i&&i.length>0&&(this.hasValue=void 0!==i[0].score),i}draw(t){"proportional"===this.arcType||"inView"===this.arcType||"partialInView"===this.arcType?this.drawProportional(t):this.drawNested(t)}drawNested(t){const e=t.context,n=t.pixelWidth,r=t.pixelHeight,i=t.viewportWidth,o=t.bpPerPixel,s=t.bpStart,a=o;ls.fillRect(e,0,t.pixelTop,n,r,{fillStyle:"rgb(255, 255, 255)"});const c=t.features;if(c){(function(){let t=0;for(let e of c){let r=(e.start-s)/a,i=(e.end-s)/a;i>=0&&r<=n&&(t=Math.max(t,i-r))}let e=Math.min(i,t)/2;if(t>0){let t=(r-10)/e;this.theta=function(t){let e,n=[.01570925532366355,.15838444032453644,.3249196962329063,.5095254494944288,.7265425280053609,.9999999999999999],r=[.031415926535897934,.3141592653589793,.6283185307179586,.9424777960769379,1.2566370614359172,1.5707963267948966];for(e=0;e<n.length&&!(n[e]>t);e++);let i=0===e?0:n[e-1],o=e<n.length?n[e]:1,s=(t-i)/(o-i),a=0===e?0:r[e-1],c=e<r.length?r[e]:Math.PI/2;return a+s*(c-a)}(t),this.sinTheta=Math.sin(this.theta),this.cosTheta=Math.cos(this.theta)}}).call(this);const o=this.arcOrientation?t.pixelHeight:0,h=this.arcOrientation;e.font="8px sans-serif",e.textAlign="center";for(let t of c){t.drawState=void 0;let r=t.color||this.color;if(r&&this.config.useScore&&(r=Xu(r,(l=t.score,Math.min(1,.11+l/779*.89).toString()))),e.lineWidth=t.thickness||this.thickness||1,t.chr1===t.chr2||"all"===t.chr){const{m1:c,m2:l}=$u(t,this.browser.genome);let u=Math.round((c-s)/a),f=Math.round((l-s)/a);if(f<0||u>n)continue;let d=f-u;d<3&&(d=3,u--);const p=d/2,g=p/this.sinTheta,m=this.cosTheta*g,v=u+p;let b,w,y;if(h?(b=this.height+m,w=Math.PI+Math.PI/2-this.theta,y=Math.PI+Math.PI/2+this.theta):(b=-m,w=Math.PI/2-this.theta,y=Math.PI/2+this.theta),this.showBlocks&&"all"!==t.chr){const n=(t.start1-s)/a,r=(t.end1-s)/a,i=(t.start2-s)/a,c=(t.end2-s)/a,l=this.arcOrientation?-this.blockHeight:this.blockHeight;e.fillRect(n,o,r-n,l),e.fillRect(i,o,c-i,l)}r&&!this.config.useScore&&d>i&&(r=Xu(r,this.alpha)),e.strokeStyle=r,e.fillStyle=r,e.beginPath(),e.arc(v,b,g,w,y,!1),e.stroke(),t.drawState={xc:v,yc:b,r:g}}else{let i=Math.round((t.start-s)/a),o=Math.round((t.end-s)/a);if(o<0||i>n)continue;let c=o-i;c<3&&(c=3,i--);const l=t.chr===t.chr1?t.chr2:t.chr1;e.strokeStyle=r,e.fillStyle=Xu(ll(l),.5),h?(e.fillRect(i,this.height/2,c,this.height/2),e.fillText(l,i+c/2,this.height/2-5),t.drawState={x:i,y:this.height/2,w:c,h:this.height/2}):(e.fillRect(i,0,c,this.height/2),e.fillText(l,i+c/2,this.height/2+13),t.drawState={x:i,y:0,w:c,h:this.height/2})}}}var l}getScaleFactor(t,e,n,r){return r?n/(Math.log10(e+1)-(t<=0?0:Math.log10(t+1))):n/(e-t)}drawProportional(t){const e=t.context,n=t.pixelWidth,r=t.pixelHeight,i=t.bpPerPixel,o=t.bpStart,s=i,a=t.referenceFrame.start,c=t.referenceFrame.end;ls.fillRect(e,0,t.pixelTop,n,r,{fillStyle:"rgb(255, 255, 255)"});const l=t.features;if(l&&l.length>0){const r=0,i=this.getScaleFactor(r,this.dataRange.max,t.pixelHeight-1,this.logScale),h=this.arcOrientation?t.pixelHeight:0;for(let t of l){t.drawState=void 0;const r=this.valueColumn?t[this.valueColumn]:t.score;if(void 0===r||Number.isNaN(r))continue;const l=Math.round((this.logScale?Math.log10(r+1):r)*i);if(t.chr1===t.chr2||"all"===t.chr){const{m1:n,m2:i}=$u(t,this.browser.genome);let u=Math.round((n-o)/s),f=Math.round((i-o)/s)-u;if(f<3&&(f=3,u--),r<this.dataRange.min||r>this.dataRange.max)continue;if("proportional"!==this.arcType){const t="partialInView"===this.arcType,e=n>=a&&i<=c;let r=!1,o=!1;if(!e&&t&&(r=a<=n&&n<=c,r||(o=a<=i&&i<=c)),!(e||r||o))continue}const d=f/2,p=u+f/2;t.drawState={xc:p,yc:h,radiusX:d,radiusY:l};const g=!!this.arcOrientation,m=t.color||this.color;if(e.strokeStyle=m,e.lineWidth=t.thickness||this.thickness||1,!0===e.isSVG?e.strokeEllipse(p,h,d,l,0,0,Math.PI,g):(e.beginPath(),e.ellipse(p,h,d,l,0,0,Math.PI,g),e.stroke()),this.alpha&&(e.fillStyle=Xu(m,this.alpha),!0===e.isSVG?e.fillEllipse(p,h,d,l,0,0,Math.PI,g):e.fill()),this.showBlocks&&"all"!==t.chr){e.fillStyle=m;const n=(t.start1-o)/s,r=(t.end1-o)/s,i=(t.start2-o)/s,a=(t.end2-o)/s,c=this.arcOrientation?-this.blockHeight:this.blockHeight;e.fillRect(n,h,r-n,c),e.fillRect(i,h,a-i,c)}}else{let i=Math.round((t.start-o)/s),a=Math.round((t.end-o)/s);if(a<0||i>n||r<this.dataRange.min||r>this.dataRange.max)continue;const c=Math.min(l,this.height-13);let h=a-i;h<3&&(h=3,i--);const u=t.chr===t.chr1?t.chr2:t.chr1;if(e.font="8px sans-serif",e.textAlign="center",e.fillStyle=Xu(ll(u),.5),this.arcOrientation){const n=this.height-c;e.fillRect(i,n,h,c),e.fillText(u,i+h/2,n-5),t.drawState={x:i,y:n,w:h,h:c}}else e.fillRect(i,0,h,c),e.fillText(u,i+h/2,c+13),t.drawState={x:i,y:0,w:h,h:c}}}}}clearAxis(t,e,n){ls.fillRect(t,0,0,e,n,{fillStyle:"rgb(255, 255, 255)"})}paintAxis(t,e,n){const r={min:0,max:this.dataRange.max};"proportional"===this.arcType||"inView"===this.arcType||"partialInView"===this.arcType?(this.painter.flipAxis=!this.arcOrientation,this.painter.dataRange=r,this.painter.paintAxis(t,e,n)):this.clearAxis(t,e,n)}menuItemList(){let t=[{name:"Set track color",click:()=>{this.trackView.presentColorPicker()}},"<hr/>"];if(this.hasValue){const e={nested:"Nested",proportional:"Proportional - All",inView:"Proportional - Both Ends in View",partialInView:"Proportional - One End in View"};t.push("<b>Arc Type</b>");for(let n of["nested","proportional","inView","partialInView"])t.push({object:pe(Po(e[n],n===this.arcType)),click:()=>{this.arcType=n,this.trackView.repaintViews()}})}return t.push("<hr/>"),t.push({name:"Toggle arc direction",click:()=>{this.arcOrientation=!this.arcOrientation,this.trackView.repaintViews()}}),t.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||(t=t.concat(Oo.numericDataMenuItems(this.trackView))),this.browser.circularView&&(t.push("<hr/>"),t.push({label:"Add interactions to circular view",click:()=>{for(let t of this.trackView.viewports)this.addChordsForViewport(t.referenceFrame)}})),t}contextMenuItemList(t){if(this.browser.circularView){const e=t.viewport,n=[];return n.push({label:"Add interactions to circular view",click:()=>{const t=e.referenceFrame;this.addChordsForViewport(t)}}),n.push("<hr/>"),n}}addChordsForViewport(t){const e=("all"===t.chr?this.featureSource.getAllFeatures():this.featureSource.featureCache.queryFeatures(t.chr,t.start,t.end)).filter((t=>t.drawState));if(0===e.length)return;tl(e.map((t=>{const e=t._f||t;return{uniqueId:`${e.chr1}:${e.start1}-${e.end1}_${e.chr2}:${e.start2}-${e.end2}`,refName:Qc(e.chr1),start:e.start1,end:e.end1,mate:{refName:Qc(e.chr2),start:e.start2,end:e.end2}}})),this,t,.5)}doAutoscale(t){let e=0;if(t)for(let n of t){const t=this.valueColumn?n[this.valueColumn]:n.score;Number.isNaN(t)||(e=Math.max(e,t))}return{min:0,max:e}}popupData(t,e){e=this.clickedFeatures(t);const n=[];for(let t of e){const e=t._||t;if(n.push({name:"Region 1",value:Gu(e.chr1,e.start1,e.end1,e.strand1)}),n.push({name:"Region 2",value:Gu(e.chr2,e.start2,e.end2,e.strand2)}),e.name&&n.push({name:"Name",value:e.name}),void 0!==e.value&&n.push({name:"Value",value:e.value}),void 0!==e.score&&n.push({name:"Score",value:e.score}),e.extras&&this.header&&this.header.columnNames){const t=this.header.columnNames;for(let r=10;r<t.length;r++)"info"===t[r]?Ku(n,e.extras[r-10]):n.push({name:t[r],value:e.extras[r-10]})}break}return n}clickedFeatures(t,e){const n=e||t.viewport.cachedFeatures,r=[];if(n){const e="proportional"===this.arcType||"inView"===this.arcType||"partialInView"===this.arcType;for(let i of n)if(i.drawState)if(i.chr1===i.chr2||"all"===i.chr)if(e){const{xc:e,yc:n,radiusX:o,radiusY:s}=i.drawState,a=t.canvasX-e,c=t.canvasY-n,l=a/o*(a/o)+c/s*(c/s);l<=1&&r.push({score:1/l,feature:i})}else{const{xc:e,yc:n,r:o}=i.drawState,s=t.canvasX-e,a=t.canvasY-n,c=Math.abs(Math.sqrt(s*s+a*a)-o);c<5&&r.push({score:c,feature:i})}else{const{x:e,y:n,w:o,h:s}=i.drawState,a=5;if(t.canvasX>=e-a&&t.canvasX<=e+o+a&&t.canvasY>=n&&t.canvasY<=n+s){const n=-Math.abs(t.canvasX-(e+o/2));r.push({score:n,feature:i});break}}}return r.length>1&&r.sort(((t,e)=>t.score-e.score)),r.map((t=>t.feature))}getState(){const t=super.getState();return void 0!==this.arcType&&(t.arcType=this.arcType),void 0!==this.arcOrientation&&(t.arcOrientation=this.arcOrientation),void 0!==this.showBlocks&&(t.showBlocks=this.showBlocks),void 0!==this.blockHeight&&(t.blockHeight=this.blockHeight),void 0!==this.thickness&&(t.thickness=this.thickness),void 0!==this.alpha&&(t.alpha=this.alpha),t}}function $u(t,e){let n=(t.start1+t.end1)/2,r=(t.start2+t.end2)/2;if("all"===t.chr&&(n=e.getGenomeCoordinate(t.chr1,n),r=e.getGenomeCoordinate(t.chr2,r)),n>r){const t=n;n=r,r=t}return{m1:n,m2:r}}function Gu(t,e,n,r){return r&&"."!==r?`${t}:${Se(e+1)}-${Se(n)} (${r})`:`${t}:${Se(e+1)}-${Se(n)}`}const Zu=new Map;function Xu(t,e){const n=`${t}_${e}`;let r=Zu.get(n);return r||(r=ro.addAlpha(t,e),Zu.set(n,r)),r}function Yu(t){const e=t=>{const e=Object.assign({},t);return e.chr="all",e.start=n.getGenomeCoordinate(t.chr1,t.start1),e.end=n.getGenomeCoordinate(t.chr2,t.end2),e},n=this.genome;let r,i=0;for(let e of n.wgChromosomeNames){let n=t[e];if(n)for(let t of n)t.dup||(i++,t.score&&(!r||t.score>r.score)&&(r=t))}const o=this.maxWGCount,s=r&&r.score>0&&i>o?5:1,a=Math.floor(o/s),c=r&&r.score>0?Math.log(r.score)/s:Number.MAX_SAFE_INTEGER;let l,h=[],u=[];for(let t=0;t<s;t++)u.push([0]),h.push([]);for(let r of n.wgChromosomeNames){let n=t[r];if(n)for(let t of n)if(!t.dup){const n=t.score?Math.min(s-1,Math.floor(Math.log(t.score)/c)):0;if(h[n].length<a)h[n].push(e(t));else{const r=a/(u[n]+1);if(Math.random()<r){const r=Math.floor(Math.random()*(a-1));h[n][r]=e(t)}}u[n]++}}if(1===s)l=h[0];else{l=[];for(let t of h)for(let e of t)l.push(e);r&&l.push(e(r)),l.sort((function(t,e){return t.start-e.start})),console.log(l.length)}return l}function Ku(t,e){const n=e.split(";");for(let e of n){const n=e.split("=");2===n.length&&t.push({name:n[0],value:n[1]})}}const Qu=_e;class Ju extends bc{constructor(t,e){super(t,e)}init(t){super.init(t),this.visibilityWindow=t.visibilityWindow,this.displayMode=t.displayMode||"EXPANDED",this.labelDisplayMode=t.labelDisplayMode,this.expandedVariantHeight=t.expandedVariantHeight||t.variantHeight||10,this.squishedVariantHeight=t.squishedVariantHeight||2,this.squishedCallHeight=t.squishedCallHeight||1,this.expandedCallHeight=t.expandedCallHeight||10,this.expandedVGap=void 0!==t.expandedVGap?t.expandedVGap:2,this.squishedVGap=void 0!==t.squishedVGap?t.squishedVGap:1,this.expandedGroupGap=t.expandedGroupGap||10,this.squishedGroupGap=t.squishedGroupGap||5,this.featureHeight=t.featureHeight||14,this.visibilityWindow=t.visibilityWindow,this.featureSource=Cu(t,this.browser.genome),this.noGenotypeColor=t.noGenotypeColor||"rgb(200,180,180)",this.noCallColor=t.noCallColor||"rgb(225, 225, 225)",this.nonRefColor=t.nonRefColor||"rgb(200, 200, 215)",this.mixedColor=t.mixedColor||"rgb(200, 220, 200)",this.homrefColor=t.homrefColor||"rgb(200, 200, 200)",this.homvarColor=t.homvarColor||"rgb(17,248,254)",this.hetvarColor=t.hetvarColor||"rgb(34,12,253)",this.sortDirection="ASC",this.type=t.type||"variant",this.colorBy=t.colorBy,this._initColorBy=t.colorBy,t.colorTable&&(this.colorTables=new Map,this.colorTables.set(t.colorBy,new Sc(t.colorTable))),this._color=t.color,this.showGenotypes=void 0===t.showGenotypes||t.showGenotypes,this.variantRowCount(1)}async postInit(){if(this.header=await this.getHeader(),void 0===this.visibilityWindow&&!1!==this.config.indexed){const t=Ue(this.config.url)?this.config.url.name:this.config.url;Qu(t)&&t.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(t){this._color=t,this.colorBy=void 0}async getHeader(){if(!this.header){if("function"==typeof this.featureSource.getHeader){const t=await this.featureSource.getHeader();t&&(this.callSets=t.callSets||[]),this.header=t}this.sampleNames=this.callSets?this.callSets.map((t=>t.name)):[]}return this.header}getCallsetsLength(){return this.callSets?this.callSets.length:0}async getFeatures(t,e,n,r){return void 0===this.header&&(this.header=await this.getHeader()),this.featureSource.getFeatures({chr:t,start:e,end:n,bpPerPixel:r,visibilityWindow:this.visibilityWindow})}hasSamples(){return this.getCallsetsLength()>0}getSamples(){return{yOffset:this.sampleYOffset,names:this.sampleNames,height:this.sampleHeight}}computePixelHeight(t){if(!t||0==t.length)return 10;const e="COLLAPSED"===this.displayMode?1:this.nVariantRows,n="SQUISHED"===this.displayMode?this.squishedVGap:this.expandedVGap,r="SQUISHED"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,i="SQUISHED"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight;return 10+e*(r+n)+n+((!1===this.showGenotypes?0:this.getCallsetsLength()*e)+1)*(i+n)}variantRowCount(t){this.nVariantRows=t}draw({context:t,pixelWidth:e,pixelHeight:n,bpPerPixel:r,bpStart:i,pixelTop:o,features:s}){ls.fillRect(t,0,o,e,n,{fillStyle:"rgb(255, 255, 255)"});const a="SQUISHED"===this.displayMode?this.squishedVGap:this.expandedVGap,c="COLLAPSED"===this.displayMode?1:this.nVariantRows,l="SQUISHED"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight;this.variantBandHeight=10+c*(l+a);const h=this.callSets,u=this.getCallsetsLength();if(h&&u>0&&!1!==this.showGenotypes&&ls.strokeLine(t,0,this.variantBandHeight,e,this.variantBandHeight,{strokeStyle:"rgb(224,224,224) "}),s){const n="SQUISHED"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight,o="SQUISHED"===this.displayMode?this.squishedVGap:this.expandedVGap,a=i+e*r+1;for(let e of s){if(e.end<i)continue;if(e.start>a)break;const s="SQUISHED"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,c=10+("COLLAPSED"===this.displayMode?0:e.row*(s+o)),l=s;let f=Math.round((e.start-i)/r),d=Math.round((e.end-i)/r),p=Math.max(1,d-f);if(p<3?(p=3,f-=1):p>5&&(f+=1,p-=2),t.fillStyle=this.getVariantColor(e),t.fillRect(f,c,p,l),e.pixelRect={x:f,y:c,w:p,h:l},u>0&&!1!==this.showGenotypes){const r="COLLAPSED"===this.displayMode?1:this.nVariantRows;this.sampleYOffset=this.variantBandHeight+o,this.sampleHeight=r*(n+o);let i=0;for(let r of h){const s=e.calls[r.id];if(s){const a="COLLAPSED"===this.displayMode?0:e.row,c=this.sampleYOffset+i*this.sampleHeight+a*(n+o);let l=!0,h=!0,u=!1;if(s.genotype)for(let t of s.genotype){if("."===t){u=!0;break}0!==t&&(h=!1),0===t&&(l=!1)}s.genotype?t.fillStyle=u?this.noCallColor:h?this.homrefColor:l?this.homvarColor:this.hetvarColor:t.fillStyle=this.noGenotypeColor,t.fillRect(f,c,p,n),r.pixelRect={x:f,y:c,w:p,h:n}}i++}}}}else console.log("No feature list")}getVariantColor(t){const e=t._f||t;let n;if(this.colorBy){const t=e.info[this.colorBy];n=this.getVariantColorTable(this.colorBy).getColor(t),n||(n="gray")}else n=this._color?this.color:"NONVARIANT"===e.type?this.nonRefColor:"MIXED"===e.type?this.mixedColor:this.defaultColor;return n}get color(){return this._color?"function"==typeof this._color?this._color(v):this._color:this.defaultColor}clickedFeatures(t,e){let n=super.clickedFeatures(t,e);const r="EXPANDED"===this.displayMode?this.expandedVGap:this.squishedVGap,i=r+("SQUISHED"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight),o=t.y;if(o<=this.variantBandHeight){const t="SQUISHED"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,e=Math.floor((o-10)/(t+r));"COLLAPSED"!==this.displayMode&&(n=n.filter((t=>t.row===e)))}else if(this.callSets){const t=this.callSets,e=o-this.variantBandHeight,r=Math.floor(e/this.sampleHeight);if(r>=0&&r<t.length){const o=Math.floor((e-r*this.sampleHeight)/i),s="COLLAPSED"===this.displayMode?n:n.filter((t=>t.row===o)),a=t[r];n=s.map((t=>{const e=t.calls[a.id];return function(t,e){if(t.genotype){let n="";if("."===e.alternateBases)n="No Call";else{const r=e.alternateBases.split(",");for(let i of t.genotype)if(n.length>0&&(n+="|"),"."===i)n+=".";else if(0===i)n+=e.referenceBases;else{n+=r[i-1].replace("<","<")}}t.genotypeName=n}}(e,t),e}))}}return n}popupData(t,e){const n=this.clickedFeatures(t,e),r=t.genomicLocation,i=this.browser.genome.id,o=this.browser.sampleInformation;let s=[];for(let t of n){const e=t._f||t;if(s.length>0&&s.push({html:'<hr style="border-top-width:2px ;border-color: #c9c3ba" />'}),"function"==typeof e.popupData){const t=e.popupData(r,i);Array.prototype.push.apply(s,t)}else{const t=e;if(void 0!==t.callSetName&&s.push({name:"Name",value:t.callSetName}),t.genotypeName&&s.push({name:"Genotype",value:t.genotypeName}),void 0!==t.phaseset&&s.push({name:"Phase set",value:t.phaseset}),void 0!==t.genotypeLikelihood&&s.push({name:"genotypeLikelihood",value:t.genotypeLikelihood.toString()}),o){var a=o.getAttributes(t.callSetName);a&&Object.keys(a).forEach((function(t){var e=t.replace(/([A-Z])/g," $1");e=e.charAt(0).toUpperCase()+e.slice(1),s.push({name:e,value:a[t]})}))}var c=Object.keys(t.info);c.length&&s.push("<hr/>"),c.forEach((function(e){s.push({name:e,value:decodeURIComponent(t.info[e])})}))}}return s}menuItemList(){const t=[];if(this.header.INFO&&this.header.INFO){const e=this.header.INFO.SVTYPE?["SVTYPE"]:[];if(this._initColorBy&&"SVTYPE"!==this._initColorBy&&e.push(this._initColorBy),e.length>0){t.push("<hr/>");const n=pe('<div class="igv-track-menu-category igv-track-menu-border-top">');n.text("Color by:"),t.push({name:void 0,object:n,click:void 0,init:void 0}),e.sort();for(let n of e){const e=this.colorBy===n,r=n||"None";t.push(this.colorByCB({key:n,label:r},e))}t.push(this.colorByCB({key:void 0,label:"None"},void 0===this.colorBy)),t.push("<hr/>")}}this.getCallsetsLength()>0&&(t.push({object:pe('<div class="igv-track-menu-border-top">')}),t.push({object:pe(Po("Show Genotypes",this.showGenotypes)),click:()=>{this.showGenotypes=!this.showGenotypes,this.trackView.checkContentHeight(),this.trackView.repaintViews()}})),t.push({object:pe('<div class="igv-track-menu-border-top">')});for(let e of["COLLAPSED","SQUISHED","EXPANDED"]){t.push({object:pe(Po({COLLAPSED:"Collapse",SQUISHED:"Squish",EXPANDED:"Expand"}[e],e===this.displayMode)),click:()=>{this.displayMode=e,this.trackView.checkContentHeight(),this.trackView.repaintViews()}})}return this.browser.circularView&&(t.push("<hr>"),t.push({label:"Add SVs to circular view",click:()=>{for(let t of this.trackView.viewports)this.sendChordsForViewport(t)}})),t}contextMenuItemList(t){if(this.browser.circularView){const e=t.viewport,n=[];return n.push({label:"Add SVs to Circular View",click:()=>{this.sendChordsForViewport(e)}}),n.push("<hr/>"),n}}sendChordsForViewport(t){const e=t.referenceFrame,n="all"===e.chr?this.featureSource.getAllFeatures():this.featureSource.featureCache.queryFeatures(e.chr,e.start,e.end);tl(n.filter((t=>{const e=t._f||t;return e.info&&e.info.CHR2&&e.info.END&&(e.info.CHR2!==e.chr||Math.abs(Number.parseInt(e.info.END)-e.pos)>1e6)})).map((t=>{const e=t._f||t,n=Number.parseInt(e.info.END),r=n-100,i=n+100;return{uniqueId:`${e.chr}:${e.start}-${e.end}_${e.info.CHR2}:${e.info.END}`,refName:Qc(e.chr),start:e.start,end:e.end,mate:{refName:Qc(e.info.CHR2),start:r,end:i}}})),this,e,.5)}colorByCB(t,e){return{name:void 0,object:pe(Po(t.label,e)),click:()=>{t.key===this.colorBy?(this.colorBy=void 0,delete this.config.colorBy,this.trackView.repaintViews()):(this.colorBy=t.key,this.config.colorBy=t.key,this.trackView.repaintViews())},init:void 0}}getState(){const t=super.getState();return this._color&&"function"!=typeof this._color&&(t.color=this._color),t}getVariantColorTable(t){if(this.colorTables||(this.colorTables=new Map),!this.colorTables.has(t)){let e;if("SVTYPE"===t)e=tf;else e=new _c("Set1");this.colorTables.set(t,e)}return this.colorTables.get(t)}}const tf=new Sc({DEL:"#ff2101",INS:"#001888",DUP:"#028401",INV:"#008688",CNV:"#8931ff",BND:"#891100","*":"#002eff"});class ef extends bc{constructor(t,e){super(t,e)}init(t){super.init(t),this.name=t.name,this.pValueField=t.pValueField||"pValue",this.geneField=t.geneField||"geneSymbol",this.snpField=t.snpField||"snp";const e=t.minLogP||t.min,n=t.maxLogP||t.max;this.dataRange={min:e||3.5,max:n||25},this.autoscale=!n||t.autoscale,this.autoscalePercentile=void 0===t.autoscalePercentile?98:t.autoscalePercentile,this.background=t.background,this.divider=t.divider||"rgb(225,225,225)",this.dotSize=t.dotSize||2,this.height=t.height||100,this.autoHeight=!1,this.disableButtons=t.disableButtons,this.visibilityWindow=void 0===t.visibilityWindow?2e6:t.visibilityWindow>=0?Math.min(2e6,t.visibilityWindow):2e6,this.featureSource=Cu(t,this.browser.genome),Eu.gtexLoaded=!0}paintAxis(t,e,n){const r=(this.dataRange.max-this.dataRange.min)/n,i={font:"normal 10px Arial",textAlign:"right",strokeStyle:"black"};ls.fillRect(t,0,0,e,n,{fillStyle:"rgb(255, 255, 255)"});const o=Math.ceil(10*(this.dataRange.max-this.dataRange.min)/n);for(let s=4;s<=this.dataRange.max;s+=o){const o=.85*e,a=o-5,c=o,l=n-(s-this.dataRange.min)/r;ls.strokeLine(t,a,l,c,l,i),l>8&&ls.fillText(t,s,a-1,l+2,i)}i.textAlign="center",ls.fillText(t,"-log10(pvalue)",e/4,n/2,i,{rotate:{angle:-90}})}async getFeatures(t,e,n){const r=this.pValueField,i=this.visibilityWindow,o=await this.featureSource.getFeatures({chr:t,start:e,end:n,visibilityWindow:i});return o.forEach((function(t){t.value=t[r]})),o}draw(t){const e=t.context,n=t.pixelWidth,r=t.pixelHeight;this.background&&ls.fillRect(e,0,0,n,r,{fillStyle:this.background}),ls.strokeLine(e,0,r-1,n,r-1,{strokeStyle:this.divider});const i=i=>{const o=i?2*this.dotSize:this.dotSize,s=t.bpStart,a=(this.dataRange.max-this.dataRange.min)/r,c=t.referenceFrame.selection;for(let h of t.features){const u=(h.start-s+.5)/t.bpPerPixel;if(u<0)continue;if(u>n)break;const f=h.snp.toUpperCase(),d=h[this.geneField].toUpperCase(),p=c&&(c.snp===f||c.gene===d);if(!i||p){c&&c.snp===f&&c.addGene(d);var l=-Math.log(h[this.pValueField])/Math.LN10;if(l>=this.dataRange.min){let t;l>this.dataRange.max?(l=this.dataRange.max,t=!0):t=!1;const n=Math.max(0+o,r-Math.round((l-this.dataRange.min)/a));let s;h.px=u,h.py=n,h.radius=o,i&&c?(s=c.colorForGene(d),ls.setProperties(e,{fillStyle:s,strokeStyle:"black"})):(s=t?"rgb(150, 150, 150)":"rgb(180, 180, 180)",ls.setProperties(e,{fillStyle:s,strokeStyle:s})),ls.fillCircle(e,u,n,o),ls.strokeCircle(e,u,n,o)}}}};i(!1),i(!0)}popupData(t){let e=t.viewport.cachedFeatures;if(!e||0===e.length)return[];const n=this.name,r=[];for(let i of e)Math.abs(i.px-t.canvasX)<i.radius+3&&Math.abs(i.py-t.canvasY)<i.radius+3&&(r.length>0&&r.push("<hr/>"),r.push({name:"snp id",value:i.snp},{name:"gene id",value:i.geneId},{name:"gene name",value:i.geneName},{name:"p value",value:i.pValue},{name:"tissue",value:n}));return r}menuItemList(){return Oo.numericDataMenuItems(this.trackView)}doAutoscale(t){if(t.length>0){var e=t.map((function(t){return-Math.log(t.value)/Math.LN10}));this.dataRange.max=Qi(e,this.autoscalePercentile)}else{const t=this.config.maxLogP||this.config.max;this.dataRange.max=t||25}return this.dataRange}}const nf={X:"rgb(204, 153, 0)",Y:"rgb(153, 204, 0)",Un:"darkGray)",1:"rgb(80, 80, 255)",I:"rgb(139, 155, 187)",2:"rgb(206, 61, 50)",II:"rgb(206, 61, 50)","2a":"rgb(210, 65, 55)","2b":"rgb(215, 70, 60)",3:"rgb(116, 155, 88)",III:"rgb(116, 155, 88)",4:"rgb(240, 230, 133)",IV:"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 dd of Object.keys(nf)){nf["chr"+dd]=nf[dd]}class rf extends bc{constructor(t,e){super(t,e)}init(t){super.init(t),this.useChrColors=void 0===t.useChrColors||t.useChrColors,this.trait=t.trait,this.posteriorProbability=t.posteriorProbability,this.valueProperty="bed"===t.format?"score":"value",this.height=t.height||100,this.autoscale=t.autoscale,this.autoscalePercentile=void 0===t.autoscalePercentile?98:t.autoscalePercentile,this.background=t.background,this.divider=t.divider||"rgb(225,225,225)",this.dotSize=t.dotSize||3,this.popoverWindow=void 0===t.popoverWindow?1e8:t.popoverWindow,this.colorScales=t.color?new Vu(t.color):{"*":new zu(t.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=Cu(t,this.browser.genome)}async postInit(){return"function"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader()),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(t,e,n){const r=this.visibilityWindow;return this.featureSource.getFeatures({chr:t,start:e,end:n,visibilityWindow:r})}draw(t){const e=t.features,n=t.context,r=t.pixelWidth,i=t.pixelHeight;if(this.background&&ls.fillRect(n,0,0,r,i,{fillStyle:this.background}),ls.strokeLine(n,0,i-1,r,i-1,{strokeStyle:this.divider}),e){const o=t.bpPerPixel,s=t.bpStart,a=s+r*o+1;for(let t of e){const e=t.start;if(e<s)continue;if(e>a)break;const r=this.getColorScale(t._f?t._f.chr:t.chr);let c,l;if(this.posteriorProbability)l=t[this.valueProperty],c=r.getColor(l);else{const e=t[this.valueProperty];if(!e)continue;l=-Math.log10(e),c=r.getColor(l)}const h=(this.dataRange.max-this.dataRange.min)/i,u=Math.round((e-s)/o),f=Math.max(this.dotSize,i-Math.round((l-this.dataRange.min)/h));c&&ls.setProperties(n,{fillStyle:c,strokeStyle:"black"}),ls.fillCircle(n,u,f,this.dotSize),t.px=u,t.py=f}}}getColorScale(t){if(this.useChrColors){let e=this.colorScales[t];if(!e){const n=nf[t]||Ec.get();e=new Vu(n),this.colorScales[t]=e}return e}return this.colorScales("*")}paintAxis(t,e,n){ls.fillRect(t,0,0,e,n,{fillStyle:"rgb(255, 255, 255)"});var r={font:"normal 10px Arial",textAlign:"right",strokeStyle:"black"};const i=(this.dataRange.max-this.dataRange.min)/n;if(this.posteriorProbability){const e=.1;for(let o=this.dataRange.min;o<this.dataRange.max;o+=e){const e=n-Math.round((o-this.dataRange.min)/i);ls.strokeLine(t,45,e-2,50,e-2,r),ls.fillText(t,o.toFixed(1),44,e+2,r)}}else{const e=Math.ceil(10*(this.dataRange.max-this.dataRange.min)/n);for(let o=this.dataRange.min;o<this.dataRange.max;o+=e){const e=n-Math.round((o-this.dataRange.min)/i);ls.strokeLine(t,45,e,50,e,r),ls.fillText(t,Math.floor(o),44,e+4,r)}}r.textAlign="center",this.posteriorProbability?ls.fillText(t,"PPA",e/2,n/2,r,{rotate:{angle:-90}}):ls.fillText(t,"-log10(pvalue)",e/2,n/2,r,{rotate:{angle:-90}})}popupData(t){let e=[];const n=t.viewport.trackView.track,r=t.viewport.cachedFeatures;if(r){let i=0;for(let o of r){const r=Math.abs(t.canvasX-o.px),s=Math.abs(t.canvasY-o.py),a=o[this.valueProperty];if(r<this.dotSize&&s<this.dotSize){if(i>0&&e.push("<HR/>"),5==i){e.push("...");break}if("function"==typeof o.popupData)e=e.concat(o.popupData());else{const t=o.realChr||o.chr,r=(o.realStart||o.start)+1;e.push({name:"chromosome",value:t}),e.push({name:"position",value:r}),e.push({name:"name",value:o.name}),n.posteriorProbability?e.push({name:"posterior probability",value:a}):e.push({name:"pValue",value:a})}i++}}}return e}menuItemList(){return Oo.numericDataMenuItems(this.trackView)}doAutoscale(t){if(t.length>0){const e=this.valueProperty,n=this.posteriorProbability,r=t.map((function(t){const r=t[e];return{value:n?r:-Math.log(r)/Math.LN10}}));this.dataRange=ms(r)}else this.posteriorProbability?(this.dataRange.min=this.config.min||0,this.dataRange.max=this.config.max||1):(this.dataRange.max=this.config.max||25,this.dataRange.min=this.config.min||0);return this.dataRange}}class of extends bc{constructor(t,e){super(t,e)}init(t){super.init(t),this.autoscale=t.autoscale||void 0===t.max,this.dataRange={min:t.min||0,max:t.max},this.windowFunction=t.windowFunction||"mean",this.paintAxis=yc,this.graphType=t.graphType||"bar",t._featureSource?(this.featureSource=t._featureSource,delete t._featureSource):this.featureSource=Cu(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.sampleNames=this.header.columnNames.slice(3),this.setTrackProperties(this.header),this.header.hasOwnProperty("clickToHighlight")){let t=this.header.clickToHighlight;this.config.clickToHighlight=t,this.config.samplesClickedToHighlight={}}if(this.header.hasOwnProperty("highlight")){this.config.highlightSamples={};let t=this.header.highlight;Array.isArray(t)||(t=[t]);for(let e of t){const t=e.split(";");2===t.length&&(this.config.highlightSamples[t[0]]=t[1])}}}}menuItemList(){return Oo.numericDataMenuItems(this.trackView)}async getFeatures(t,e,n){const r=await this.featureSource.getFeatures({chr:t,start:0,end:Number.MAX_SAFE_INTEGER,visibilityWindow:this.visibilityWindow});let i,o;for(let t=1;t<r.length-1;t++)if(void 0===i&&r[t].end>e&&(i=t-1),void 0===o&&r[t].start>n){o=t+1;break}return void 0===i&&(i=0),void 0===o&&(o=r.length),r.slice(i,o)}draw(t){const{features:e,context:n,bpPerPixel:r,bpStart:i,pixelWidth:o,pixelHeight:s}=t,a=t=>(this.dataRange.max-t)/(this.dataRange.max-this.dataRange.min)*s,c=function(t){let e=Math.floor((t-i)/r);return isNaN(e)&&console.warn("isNaN(x). feature start "+Se(t)+" bp start "+Se(i)),e};if(e&&e.length>0&&(void 0===this.dataRange.min&&(this.dataRange.min=0),this.dataRange.max>this.dataRange.min)){const t=this.config.highlightSamples,r=this.config.onlyHandleClicksForHighlightedSamples,i=this.config.clickToHighlight;let o=-1,s={},l=[],h=[];this.clickDetectorCache={};for(let u of e){const e=c(u.start),f=c(u.end),d=o>=0?c(o):e;if(!isNaN(e)&&!isNaN(f)){this.clickDetectorCache[e]=[],this.clickDetectorCache[f]=[];for(let o=0;o<u.values.length;o++){const c=this.sampleNames[o],p=u.values[o],g=a(p);if(e-d>=1){const o=s[c],h=a(o),u=t&&t[c];u?l.push([d,h,e,g,u]):i&&c in this.config.samplesClickedToHighlight?l.push([d,h,e,g,this.config.samplesClickedToHighlight[c]]):ls.strokeLine(n,d,h,e,g,{strokeStyle:"#D9D9D9"}),r&&!(c in t)||this.clickDetectorCache[e].push([d,h,e,g,c,u||"gray"])}if(f-e>=1){const o=t&&t[c];o?h.push([e,g,f,g,o]):i&&c in this.config.samplesClickedToHighlight?h.push([e,g,f,g,this.config.samplesClickedToHighlight[c]]):ls.strokeLine(n,e,g,f,g,{strokeStyle:"gray"}),r&&!(c in t)||this.clickDetectorCache[f].push([e,g,f,g,c,o||"gray"])}s[c]=p}o=u.end}}for(let t of l)ls.strokeLine(n,t[0],t[1],t[2],t[3],{strokeStyle:t[4],lineWidth:1.3});for(let t of h)ls.strokeLine(n,t[0],t[1],t[2],t[3],{strokeStyle:t[4],lineWidth:2})}(t=>{if(this.config.hasOwnProperty("guideLines"))for(let e of this.config.guideLines)if(e.hasOwnProperty("color")&&e.hasOwnProperty("y")&&e.hasOwnProperty("dotted")){let n=a(e.y),r={strokeStyle:e.color,strokeWidth:2};e.dotted?ls.dashedLine(t.context,0,n,t.pixelWidth,n,5,r):ls.strokeLine(t.context,0,n,t.pixelWidth,n,r)}})(t)}doAutoscale(t){let e,n;return t.length>0?(e=Number.MAX_VALUE,n=-Number.MAX_VALUE,t.forEach((function(t){e=Math.min(e,...t.values),n=Math.max(n,...t.values)})),e-=.01,n+=.01):(e=0,n=100),{min:e,max:n}}clickedFeatures(t){const e=t.canvasX,n=t.canvasY;let r=null;for(r of Object.keys(this.clickDetectorCache))if(r=parseInt(r),r>=e)break;if(r){let t=Number.MAX_VALUE,s=[];const a=this.clickDetectorCache[r];for(let r of a){const i=r[0],o=r[2];if(e<i||e>o)return[];const a=r[1],c=r[3];if(n<Math.min(a,c)-10||n>Math.max(a,c)+10)continue;const l=sf(e,n,i,a,o,c);l<t&&(s=[{name:r[4],color:r[5]}],t=l)}if(t<5){if(this.config.clickToHighlight){if(s[0].name in this.config.samplesClickedToHighlight)delete this.config.samplesClickedToHighlight[s[0].name];else if("any"===this.config.clickToHighlight){var i=["red","darkblue","green","teal","olivedrab","orange","maroon","purple","blue","gold"],o=i[Math.floor(Math.random()*(i.length+1))];this.config.samplesClickedToHighlight[s[0].name]=o}else this.config.samplesClickedToHighlight[s[0].name]=this.config.clickToHighlight;this.trackView.repaintViews()}return s}}return[]}popupData(t,e){e=this.clickedFeatures(t,e);const n=[];return e.forEach((function(t){for(let e of Object.keys(t))ps(t[e])&&n.push({name:e,value:t[e]})})),n}get supportsWholeGenome(){return!1}}function sf(t,e,n,r,i,o){const s=i-n,a=o-r,c=Math.abs(s*(r-e)-(n-t)*a),l=Math.sqrt(s*s+a*a);return l>0?c/l:0}class af extends bc{constructor(t,e){super(t,e),t.height||(this.height=300),this.arcOrientation=!1,this.theta=Math.PI/2,"bp"===t.format?this.featureSource=new lf(t,e.genome):this.featureSource=new Jh(t,e.genome)}async getFeatures(t,e,n){const r=this.visibilityWindow;return this.featureSource.getFeatures({chr:t,start:e,end:n,visibilityWindow:r})}draw(t){const e=t.context,n=Math.PI/2,r=t.pixelWidth,i=t.pixelHeight;t.viewportWidth;const o=t.bpPerPixel,s=t.bpStart,a=o,c=this.arcOrientation;ls.fillRect(e,0,t.pixelTop,r,i,{fillStyle:"rgb(255, 255, 255)"});const l=t.features;if(l){cf(l,1);for(let t of l)if(t.startLeft){let r=Math.round((t.startLeft-s)/a),i=Math.round((t.startRight-s)/a),o=Math.round((t.endLeft-s)/a),l=Math.round((t.endRight-s)/a);e.fillStyle=t.color,e.strokeStyle=t.color,e.beginPath();let h=(r+l)/2,u=(l-r)/2,f=this.height,d=Math.PI+(Math.PI/2-n),p=2*Math.PI-(Math.PI/2-n);c?(f=0,e.arc(h,f,u,p,d),e.lineTo(l,f)):(e.arc(h,f,u,d,p),e.lineTo(o,f));const g=(i+o)/2,m=(o-i)/2,v=f;c?(e.arc(g,v,m,d,p,!0),e.lineTo(o,v)):(e.arc(g,v,m,p,d,!0),e.lineTo(r,v)),e.stroke(),e.fill(),t.drawState={x1:h,y1:f,r1:u,x2:g,y2:v,r2:m,sa:d,ea:p}}else{let r=Math.round((t.start-s)/a),i=Math.round((t.end-s)/a);e.strokeStyle=t.color,e.beginPath();let o=(r+i)/2,l=(i-r)/2,h=this.height,u=Math.PI+(Math.PI/2-n),f=2*Math.PI-(Math.PI/2-n);c?(h=0,e.arc(o,h,l,f,u)):e.arc(o,h,l,u,f),e.stroke(),t.drawState={x1:o,y1:h,r1:l,sa:u,ea:f}}}}clickedFeatures(t,e){const n=[];cf(e=super.clickedFeatures(t,e),-1);for(let r of e){const e=r.drawState,i=t.canvasX-e.x1,o=t.canvasY-e.y1,s=Math.sqrt(i*i+o*o),a=e.r1+3;let c,l;if(void 0===e.x2)c=s,l=e.r1-3;else{const n=t.canvasX-e.x2,r=t.canvasY-e.y2;c=Math.sqrt(n*n+r*r),l=e.r2-3}if(s<a&&c>l){n.push(r);break}}return n}popupData(t,e){if((e=this.clickedFeatures(t,e))&&e.length>0)return bc.extractPopupData(e[0],this.getGenomeId())}menuItemList(){var t=this;return[{name:"Toggle arc direction",click:function(){t.arcOrientation=!t.arcOrientation,t.trackView.repaintViews()}}]}}function cf(t,e){t.sort((function(t,n){const r=void 0===t.score?-Number.MAX_VALUE:t.score,i=void 0===n.score?-Number.MAX_VALUE:n.score;return(void 0===e?1:e)*(r-i)}))}class lf{constructor(t,e){this.config=t,this.genome=e}async getFeatures({chr:t,start:e,end:n,bpPerPixel:r,visibilityWindow:i}){const o=this.genome;if(this.featureCache)return this.featureCache.queryFeatures(t,e,n);{const r=gs(this.config),i=await go.loadString(this.config.url,r);return this.featureCache=new Mo(function(t){if(!t)return null;const e=Fh(t);let n,r=!0;const i=[],o=[],s=[];for(;void 0!==(n=e.nextLine());){const t=n.split("\t");if(r&&n.startsWith("color:")){const e="rgb("+t[1]+","+t[2]+","+t[3]+")";i.push(e),t.length>4&&o.push(t[4])}else{r=!1;const e=t[0],n=Number.parseInt(t[1])-1,c=Number.parseInt(t[2])-1,l=Number.parseInt(t[3]),h=Number.parseInt(t[4]);var a=Number.parseInt(t[5]);const u=i[a];let f;f=n<=h?{chr:e,startLeft:Math.min(n,c),startRight:Math.max(n,c),endLeft:Math.min(l,h),endRight:Math.max(l,h),color:u,score:a}:{chr:e,startLeft:Math.min(l,h),startRight:Math.max(l,h),endLeft:Math.min(n,c),endRight:Math.max(n,c),color:u,score:a},f.start=f.startLeft,f.end=f.endRight,o.length>a&&(f.description=o[a]),s.push(f)}}return s}(i),o),this.featureCache.queryFeatures(t,e,n)}}}class hf{constructor(t){this.browser=t,this.type="ideogram",this.height=16,this.order=Number.MIN_SAFE_INTEGER,this.disableButtons=!0,this.ignoreTrackMenu=!0}async getFeatures(t,e,n){return[]}computePixelHeight(t){return this.height}draw({context:t,referenceFrame:e,pixelWidth:n,pixelHeight:r}){const i=e.chr,o=e.genome.getChromosome(i);if(void 0===o||n<=0||r<=0||"all"===i.toLowerCase())return;!function({ctx:t,chr:e,referenceFrame:n,genome:r,width:i,height:o,stainColors:s}){const a=1,c=.5*a,l=0;if(void 0===r)return;ls.fillRect(t,0,0,i,o,{fillStyle:ro.greyScale(255)});const h=r.getCytobands(e);if(h){const e=l+o/2,n=[],r=[];if(0===h.length)return;const u=i/h[h.length-1].end;t.beginPath(),ls.roundRect(t,c,c+l,i-2*c,o-2*c,(o-2*c)/2,0,1),t.clip();for(let i=0;i<h.length;i++){const c=h[i],f=u*c.start,d=u*c.end;"c"===c.type?("p"===c.name.charAt(0)?(n[0]=f,r[0]=o+l,n[1]=f,r[1]=l,n[2]=d,r[2]=e):(n[0]=d,r[0]=o+l,n[1]=d,r[1]=l,n[2]=f,r[2]=e),t.fillStyle="rgb(150, 0, 0)",t.strokeStyle="rgb(150, 0, 0)",ls.polygon(t,n,r,1,0)):(t.fillStyle=uf(s,c),ls.fillRect(t,f,a+l,d-f,o-2*a))}}t.strokeStyle=ro.greyScale(41),ls.roundRect(t,c,c+l,i-2*c,o-2*c,(o-2*c)/2,0,1)}({ctx:t,chr:i,referenceFrame:e,genome:e.genome,width:n,height:r,stainColors:[]});const s=Math.round(e.bpPerPixel*n),a=e.start;let c=o.bpLength;const l=e.genome.getCytobands(i);if(l&&l.length>0&&l[l.length-1].end&&(c=Math.max(c,l[l.length-1].end),o.bpLength=c),s<c){const e=s/c,i=a/c;let o=Math.floor(i*n),l=Math.floor(e*n);o=Math.max(0,o),o=Math.min(n-l,o),t.save(),t.strokeStyle="red",t.lineWidth=l<2?1:2;const h=o+t.lineWidth/2;l=l<2?1:l-t.lineWidth;const u=t.lineWidth/2,f=r-t.lineWidth;t.strokeRect(h,u,l,f),t.restore()}}dispose(){this.trackView=void 0}}function uf(t,e){if("c"===e.type)return"rgb(150, 10, 10)";var n=e.stain,r=230;"p"===e.type&&(r=Math.floor(230-n/100*230));var i=t[r];return i||(i="rgb("+r+","+r+","+r+")",t[r]=i),i}let ff=new _c("Dark2");["GT/AG","CT/AC","GC/AG","CT/GC","AT/AC","GT/AT","non-canonical"].forEach((t=>{ff.getColor(t)}));const df={};class pf extends bc{constructor(t,e){super(t,e)}init(t){super.init(t),this.type=t.type||"junctions",t._featureSource?(this.featureSource=t._featureSource,delete t._featureSource):this.featureSource=t.featureSource?t.featureSource:Cu(t,this.browser.genome),this.margin=void 0===t.margin?10:t.margin,this.height||(this.height=100),void 0===t.colorByNumReadsThreshold&&(t.colorByNumReadsThreshold=5)}async postInit(){return"function"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader()),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(t,e,n,r){const i=this.visibilityWindow;return this.featureSource.getFeatures({chr:t,start:e,end:n,bpPerPixel:r,visibilityWindow:i})}computePixelHeight(t){return this.height}draw(t){const e=t.features,n=t.context,r=t.bpPerPixel,i=t.bpStart,o=t.pixelWidth,s=t.pixelHeight,a=i+o*r+1;if(this.config.isMergedTrack||ls.fillRect(n,0,t.pixelTop,o,s,{fillStyle:"rgb(255, 255, 255)"}),e){df.referenceFrame=t.viewport.referenceFrame,df.referenceFrameStart=df.referenceFrame.start,df.referenceFrameEnd=df.referenceFrameStart+df.referenceFrame.toBP(pe(t.viewport.contentDiv).width()),df.featureZoomOutTracker={};for(let t of e)if(!(t.end<i)){if(t.start>a)break;this.renderJunction(t,i,r,s,n)}}else console.log("No feature list")}renderJunction(t,e,n,r,i){t.isVisible=!1;const o=Math.round((t.start-e)/n),s=Math.round((t.end-e)/n),a=(o+s)/2;if(s-o<=3){if(a in df.featureZoomOutTracker)return;df.featureZoomOutTracker[a]=!0}if(this.config.hideAnnotatedJunctions&&"true"===t.attributes.annotated_junction)return;if(this.config.hideUnannotatedJunctions&&"false"===t.attributes.annotated_junction)return;if(this.config.hideMotifs&&this.config.hideMotifs.includes(t.attributes.motif))return;if(this.config.hideStrand===t.strand)return;if(this.config.minJunctionEndsVisible){let e=0;if(t.start>=df.referenceFrameStart&&t.start<=df.referenceFrameEnd&&(e+=1),t.end>=df.referenceFrameStart&&t.end<=df.referenceFrameEnd&&(e+=1),e<this.config.minJunctionEndsVisible)return}let c,l,h,u;if(t.attributes.uniquely_mapped){if(c=parseInt(t.attributes.uniquely_mapped),c<this.config.minUniquelyMappedReads)return;if(l=parseInt(t.attributes.multi_mapped),h=c+l,h<this.config.minTotalReads)return;if(h>0&&l/h>this.config.maxFractionMultiMappedReads)return;if(t.attributes.maximum_spliced_alignment_overhang&&parseInt(t.attributes.maximum_spliced_alignment_overhang)<this.config.minSplicedAlignmentOverhang)return}if(t.attributes.num_samples_with_this_junction){if(u=parseInt(t.attributes.num_samples_with_this_junction),this.config.minSamplesWithThisJunction&&u<this.config.minSamplesWithThisJunction)return;if(this.config.maxSamplesWithThisJunction&&u>this.config.maxSamplesWithThisJunction)return;if(t.attributes.num_samples_total&&(t.attributes.percent_samples_with_this_junction=100*u/Number(t.attributes.num_samples_total),this.config.minPercentSamplesWithThisJunction&&(t.attributes.percent_samples_with_this_junction<this.config.minPercentSamplesWithThisJunction||t.attributes.percent_samples_with_this_junction>this.config.maxPercentSamplesWithThisJunction)))return}const f=this.margin,d=this.height,p=f+.5*d;let g=f;const m=f+d-10,v=(o+a)/2,b=(a+s)/2;let w,y,x=1;t.attributes.line_width?x=Number(t.attributes.line_width):(void 0===this.config.thicknessBasedOn||"numUniqueReads"===this.config.thicknessBasedOn?x=c:"numReads"===this.config.thicknessBasedOn?x=h:"numSamplesWithThisJunction"===this.config.thicknessBasedOn&&void 0!==u&&(x=u),x=1+Math.log(x+1)/Math.log(12)),void 0===this.config.bounceHeightBasedOn||"random"===this.config.bounceHeightBasedOn?w=(t.start+t.end)%7:"distance"===this.config.bounceHeightBasedOn?w=6*(t.end-t.start)/(df.referenceFrameEnd-df.referenceFrameStart):"thickness"===this.config.bounceHeightBasedOn&&(w=2*x),g+=d*Math.max(7-w,0)/10,y=t.attributes.color?t.attributes.color:void 0===this.config.colorBy||"numUniqueReads"===this.config.colorBy?c>this.config.colorByNumReadsThreshold?"blue":"#AAAAAA":"numReads"===this.config.colorBy?h>this.config.colorByNumReadsThreshold?"blue":"#AAAAAA":"isAnnotatedJunction"===this.config.colorBy?"true"===t.attributes.annotated_junction?"#b0b0ec":"orange":"strand"===this.config.colorBy?"+"===t.strand?"#b0b0ec":"#ecb0b0":"motif"===this.config.colorBy?ff.getColor(t.attributes.motif):"#AAAAAA";let k="";t.attributes.label?k=t.attributes.label.replace(/_/g," "):void 0===this.config.labelWith||"uniqueReadCount"===this.config.labelWith?k=c:"totalReadCount"===this.config.labelWith?k=h:"numSamplesWithThisJunction"===this.config.labelWith?void 0!==u&&(k=u):"percentSamplesWithThisJunction"===this.config.labelWith?void 0!==t.attributes.percent_samples_with_this_junction&&(k=t.attributes.percent_samples_with_this_junction.toFixed(0)+"%"):"motif"===this.config.labelWith&&void 0!==t.attributes.motif&&(k+=t.attributes.motif),"uniqueReadCount"===this.config.labelWithInParen?k+=" ("+c+")":"totalReadCount"===this.config.labelWithInParen?k+=" ("+h+")":"multiMappedReadCount"===this.config.labelWithInParen?l>0&&(k+=" (+"+l+")"):"numSamplesWithThisJunction"===this.config.labelWithInParen?void 0!==u&&(k+=" ("+u+")"):"percentSamplesWithThisJunction"===this.config.labelWithInParen?void 0!==t.attributes.percent_samples_with_this_junction&&(k+=" ("+t.attributes.percent_samples_with_this_junction.toFixed(0)+"%)"):"motif"===this.config.labelWithInParen&&void 0!==t.attributes.motif&&(k+=` ${t.attributes.motif}`),t.isVisible=!0,i.beginPath(),i.moveTo(o,m),i.bezierCurveTo(v,g,b,g,s,m),i.lineWidth=x,i.strokeStyle=y,i.stroke();const _=(t,e,n,r)=>{t.beginPath(),t.moveTo(e,n),t.lineTo(e-r/2,n-r),t.lineTo(e+r/2,n-r),t.lineTo(e,n),t.closePath(),t.fill()};if(t.attributes.left_shape||t.attributes.right_shape){i.fillStyle=y;const e=i.lineWidth>2?10:7;t.attributes.left_shape&&_(i,o,m,e),t.attributes.right_shape&&_(i,s,m,e)}i.fillText(k,a-i.measureText(k).width/2,(7*g+p)/8)}clickedFeatures(t,e){return super.clickedFeatures(t,e).filter((function(t){return t.isVisible&&t.attributes}))}popupData(t,e){e=this.clickedFeatures(t,e);const n=t.genomicLocation,r=[];for(let t of e){const e="function"==typeof t.popupData?t.popupData(n):this.extractPopupData(t._f||t,this.getGenomeId());e&&(r.length>0&&r.push("<hr/><hr/>"),Array.prototype.push.apply(r,e))}return r}dispose(){this.trackView=void 0}}const gf=new Map([["ideogram",(t,e)=>new hf(t,e)],["sequence",(t,e)=>new Ns(t,e)],["feature",(t,e)=>new Du(t,e)],["seg",(t,e)=>new ju(t,e)],["mut",(t,e)=>new ju(t,e)],["maf",(t,e)=>new ju(t,e)],["wig",(t,e)=>new Bu(t,e)],["merged",(t,e)=>new qu(t,e)],["alignment",(t,e)=>new rl(t,e)],["interaction",(t,e)=>new Wu(t,e)],["interact",(t,e)=>new Wu(t,e)],["variant",(t,e)=>new Ju(t,e)],["eqtl",(t,e)=>new ef(t,e)],["gwas",(t,e)=>new rf(t,e)],["arc",(t,e)=>new af(t,e)],["gcnv",(t,e)=>new of(t,e)],["junction",(t,e)=>new pf(t,e)]]);var mf=function(t,e){gf.set(t,e)},vf=function(t,e,n){let r;switch(t){case"annotation":case"genes":case"fusionjuncspan":case"snp":r="feature";break;case"seg":case"maf":case"mut":r="seg";break;case"junctions":case"splicejunctions":r="junction";break;default:r=t}return gf.has(r)?gf.get(r)(e,n):void 0};class bf{constructor(t,e){this.config=t,this.name=t.name,this.roiSource=Cu(t,e),this.color=t.color||"rgba(68, 134, 247, 0.25)"}async getFeatures(t,e,n){return this.roiSource.getFeatures({chr:t,start:e,end:n})}draw(t){var e,n,r,i;if(i=t.features){e=t.bpStart+(t.pixelWidth*t.bpPerPixel+1);for(var o=0,s=i.length;o<s;o++)if(!((n=i[o]).end<t.bpStart)){if(n.start>e)break;r=wf(n,t.bpStart,t.bpPerPixel),ls.fillRect(t.context,r.x,t.pixelTop,r.width,t.pixelHeight,{fillStyle:this.color})}}}}function wf(t,e,n){var r,i;return r=Math.round((t.start-e)/n),(i=Math.round((t.end-e)/n)-r)<3&&(i=3,r-=1),{x:r,width:i}}class yf{constructor(t,e){const n=(new DOMParser).parseFromString(t,"text/xml");this.processRootNode(n,e);const r=n.getElementsByTagName("Resource"),i=n.getElementsByTagName("Track"),o=i&&i.length>0,s=[];this.tracks=s;const a=new Map;Array.from(r).forEach((function(t,e){var n={url:t.getAttribute("path"),indexURL:t.getAttribute("index"),order:e};a.set(n.url,n),o||s.push(n)})),o&&Array.from(i).forEach((function(t){const e=t.getElementsByTagName("Track");if(e&&e.length>0){const n={type:"merged",tracks:[]};xf(t,n),s.push(n),Array.from(e).forEach((function(t){t.processed=!0;const e=t.getAttribute("id"),r=a.get(e);r&&(n.tracks.push(r),xf(t,r),r.autoscale=!1,n.height=r.height)}))}else if(!t.processed){const e=t.getAttribute("id"),n=a.get(e);n&&(s.push(n),xf(t,n))}}))}processRootNode(t,e){const n=t.getElementsByTagName("Session");!n||n.length;const r=n.item(0),i=r.getAttribute("genome"),o=r.getAttribute("locus"),s=r.getAttribute("ucscID");e&&e.hasOwnProperty(i)?this.genome=i:(this.reference={fastaURL:i},s&&(this.reference.id=s)),o&&(this.locus=o)}}function xf(t,e){e.name=t.getAttribute("name");const n=t.getAttribute("color");n&&(e.color="rgb("+n+")");const r=t.getAttribute("altColor");n&&(e.altColor="rgb("+r+")");const i=t.getAttribute("height");i&&(e.height=parseInt(i));const o=t.getAttribute("autoScale");o&&(e.autoscale="true"===o);const s=t.getAttribute("autoscaleGroup");s&&(e.autoscaleGroup=s);const a=t.getAttribute("windowFunction");a&&(e.windowFunction=a);const c=t.getAttribute("visibilityWindow")||t.getAttribute("featureVisibilityWindow");c&&(e.visibilityWindow=c);const l=t.getAttribute("indexed");l&&(e.indexed="true"===l);const h=t.getAttribute("normalize");h&&(e.normalize="true"===h);const u=t.getElementsByTagName("DataRange");if(u.length>0){const t=u.item(0);e.min=Number(t.getAttribute("minimum")),e.max=Number(t.getAttribute("maximum")),e.logScale="LOG"===t.getAttribute("type")}}const kf=Ce;class _f{constructor(){this.attributes={},this.plinkLoaded=!1}async loadPlinkFile(t,e){e||(e={});var n=gs(e);const r=await go.loadString(t,n);var i=kf(r);for(let t of i){var o=t.split(" ");this.attributes[o[1]]={familyId:o[0],fatherId:o[2],motherId:o[3],sex:o[4],phenotype:o[5]}}return this.plinkLoaded=!0,this}getAttributes(t){return this.attributes[t]}getAttributeNames(){return this.hasAttributes()?Object.keys(this.attributes[Object.keys(this.attributes)[0]]):[]}hasAttributes(){return Object.keys(this.attributes).length>0}}class Sf{constructor(t,e){this.geneColors={},this.gene=null,this.snp=null,this.genesCount=0,t&&(this.gene=t.toUpperCase(),this.geneColors[this.gene]=Cf[this.genesCount++]),e&&(this.snp=e.toUpperCase())}addGene(t){this.geneColors[t.toUpperCase()]||(this.geneColors[t.toUpperCase()]=Cf[this.genesCount++])}colorForGene(t){return this.geneColors[t.toUpperCase()]}}var Cf=[];Cf.push("rgb(228,26,28)"),Cf.push("rgb(55,126,184)"),Cf.push("rgb(77,175,74)"),Cf.push("rgb(166,86,40)"),Cf.push("rgb(152,78,163)"),Cf.push("rgb(255,127,0)"),Cf.push("rgb(247,129,191)"),Cf.push("rgb(153,153,153)"),Cf.push("rgb(255,255,51)"),Cf.push("rgb(102, 194, 165"),Cf.push("rgb(252, 141, 98"),Cf.push("rgb(141, 160, 203"),Cf.push("rgb(231, 138, 195"),Cf.push("rgb(166, 216, 84"),Cf.push("rgb(255, 217, 47"),Cf.push("rgb(229, 196, 148"),Cf.push("rgb(179, 179, 179"),Cf.push("rgb( 141, 211, 199"),Cf.push("rgb(255, 255, 179"),Cf.push("rgb(190, 186, 218"),Cf.push("rgb(251, 128, 114"),Cf.push("rgb(128, 177, 211"),Cf.push("rgb(253, 180, 98"),Cf.push("rgb(179, 222, 105"),Cf.push("rgb(252, 205, 229"),Cf.push("rgb(217, 217, 217"),Cf.push("rgb(188, 128, 189"),Cf.push("rgb(204, 235, 197"),Cf.push("rgb(255, 237, 111");class Ef{constructor(t,e,n,r,i){this.genome=t,this.chr=e,this.start=n,this.end=r,this.bpPerPixel=i,this.id=be()}extend(t){const e=Math.min(t.start,this.start),n=Math.max(t.end,this.end),r=(n-e)/(this.end-this.start);this.start=e,this.end=n,this.bpPerPixel*=r}calculateEnd(t){return this.start+this.bpPerPixel*t}calculateBPP(t,e){return(t-this.start)/e}set(t){this.chr=t.chr,this.start=t.start,this.bpPerPixel=t.bpPerPixel}toPixels(t){return t/this.bpPerPixel}toBP(t){return this.bpPerPixel*t}shiftPixels(t,e){const n=this.start,r=t*this.bpPerPixel;this.start+=r,this.clampStart(e),this.end+=r;const{bpLength:i}=this.genome.getChromosome(this.chr);return this.end=Math.min(i,this.end),n!==this.start}clampStart(t){const e=this.genome.getChromosome(this.chr).bpStart||0;if(this.start=Math.max(e,this.start),t){const{bpLength:e}=this.genome.getChromosome(this.chr),n=e-t*this.bpPerPixel;this.start>n&&(this.start=n)}}async zoomWithScaleFactor(t,e,n,r){const i=void 0===r?this.start+this.toBP(n/2):r,{start:o,bpPerPixel:s}=this.start,{bpLength:a}=this.getChromosome(),c=e<1?t.minimumBases()/n:a/n;this.bpPerPixel=e<1?Math.max(this.bpPerPixel*e,c):Math.min(this.bpPerPixel*e,c);const l=this.bpPerPixel*n;this.start=i-.5*l,this.clampStart(n),this.end=this.start+l;(o!==this.start||s!==this.bpPerPixel)&&await t.updateViews(!0)}getChromosome(){return this.genome.getChromosome(this.chr)}getMultiLocusLabel(t){const e=Math.floor(this.start)+1,n=Math.round(this.start+this.bpPerPixel*t);return` ${this.chr}     ${ws(n-e)} `}getPresentationLocusComponents(t){if("all"===this.chr)return{chr:this.chr};{const e=Se(Math.floor(this.start)+1),n=Se(Math.round(this.start+this.bpPerPixel*t));return{chr:this.chr,start:e,end:n}}}getLocusString(){if("all"===this.chr)return"all";{const t=Se(Math.floor(this.start)+1),e=Se(Math.round(this.end));return`${this.chr}:${t}-${e}`}}description(t){console.log(` ${t||""} referenceFrame - ${this.chr} bpp ${this.bpPerPixel.toFixed(3)} start ${Se(Math.round(this.start))} end ${Se(Math.round(this.end))} `)}}const Af={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)"},Tf={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 Lf(t,e){if(void 0===e||""===e.trim())return;(e&&"all"===e.trim().toLowerCase()||"*"===e)&&(e="all");const n=e.split(" ");let r=t.searchConfig||Tf,i=[];const o=async n=>{let i=function(t,e){const n=e.split(":"),r=n[0];if("all"===r&&t.genome.getChromosome(r))return{chr:r,start:0,end:t.genome.getChromosome(r).bpLength};if(void 0===t.genome.getChromosome(r))return;{const e={chr:t.genome.getChromosomeName(r),start:0,end:t.genome.getChromosome(r).bpLength};if(n.length>1){const t=n[1].split("-");if(t.length>2)return;{let n;if(n=t[0].replace(/,/g,""),isNaN(n))return;if(e.start=parseInt(n,10)-1,e.end=e.start+1,1===t.length&&(e.start-=20,e.end+=20),2===t.length){if(n=t[1].replace(/,/g,""),isNaN(n))return;e.end=parseInt(n,10)}}}return e}}(t,n);if(!i){const r=t.genome.featureDB[n.toUpperCase()];r&&(i={chr:r.chr,start:r.start,end:r.end,gene:r.name,locusSearchString:e})}if(!i&&t.config&&!1!==t.config.search)try{i=await async function(t,e,n){let r=n.url.replace("$FEATURE$",e.toUpperCase());r.indexOf("$GENOME$")>-1&&(r=r.replace("$GENOME$",t.genome.id?t.genome.id:"hg19"));const i=n.timeout?{timeout:n.timeout}:void 0,o=await go.loadString(r,i),s=function(t,e,n){let r;r="plain"===n.type?function(t,e){const n=[],r=[];return Ce(e).forEach((function(t){""===t||n.push(t)})),n.forEach((function(e){var n,i,o,s,a=e.split("\t");a.length>=3&&(o=(i=a[1].split(":"))[1].split("-"),n=a[2].trim(),s={gene:a[0],chromosome:t.genome.getChromosomeName(i[0].trim()),start:parseInt(o[0].replace(/,/g,"")),end:parseInt(o[1].replace(/,/g,"")),type:"gtex"===n?"snp":"gene"},r.push(s))})),r}(t,e):JSON.parse(e);n.resultsField&&(r=r[n.resultsField]);if(r&&0!==r.length){const e=n.chromosomeField||"chromosome",i=n.startField||"start",o=n.endField||"end",s=n.coords||1;let a;a=Array.isArray(r)?r[0]:r,a.hasOwnProperty(e)&&a.hasOwnProperty(i)||console.error("Search service results must include chromosome and start fields: "+a);const c=a[e],l=t.genome.getChromosome(c);if(!l)return;const h=l.name;let u=a[i]-s,f=a[o];void 0===f&&(f=u+1);const d={chr:h,start:u,end:f},p=a.type?a.type:"gene";return n.geneField&&"gene"===p&&(d.gene=a[n.geneField]),n.snpField&&"snp"===p&&(d.snp=a[n.snpField]),d}return}(t,o,n);s&&(s.locusSearchString=e);return s}(t,n,r)}catch(t){throw console.error(t),Error("Search service currently unavailable.")}return i};for(let t of n){const e=await o(t);e&&(e.locusSearchString=t,i.push(e))}if(0===i.length){const t=await o(e);t&&(t.locusSearchString=e,i.push(t))}return 0===i.length?void 0:i}class Mf{constructor(t){this.browser=t}navbarDidResize(t,e){this.updateNavbar(this.createResponsiveClassSchedule(t,e))}updateNavbar(t){this.browser.$toggle_button_container.removeClass(),this.browser.$toggle_button_container.addClass(t.$toggle_button_container),pe(this.browser.zoomWidget.zoomContainer).removeClass(),pe(this.browser.zoomWidget.zoomContainer).addClass(t.zoomContainer)}createResponsiveClassSchedule(t,e){let n={};return e?this.browser.windowSizePanel.hide():this.browser.windowSizePanel.show(),t>990?(n.$toggle_button_container="igv-navbar-toggle-button-container",n.zoomContainer="igv-zoom-widget"):t>860?(n.$toggle_button_container="igv-navbar-toggle-button-container",n.zoomContainer="igv-zoom-widget-900"):t>540?(n.$toggle_button_container="igv-navbar-toggle-button-container-750",n.zoomContainer="igv-zoom-widget-900"):(n.$toggle_button_container="igv-navbar-toggle-button-container-750",n.zoomContainer="igv-zoom-widget-900",this.browser.windowSizePanel.hide()),e&&(n.zoomContainer="igv-zoom-widget-hidden"),n}}const Rf=function(t,e){this.container=ge({class:"igv-chromosome-select-widget-container"}),e.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&&t.search(this.select.value)})),this.showAllChromosomes=!1!==t.config.showAllChromosomes};Rf.prototype.show=function(){this.container.style.display="flex"},Rf.prototype.hide=function(){this.container.style.display="none"},Rf.prototype.update=function(t){const e=this.showAllChromosomes?t.chromosomeNames.slice():t.wgChromosomeNames.slice();t.showWholeGenomeView()&&(e.unshift("all"),e.unshift("")),this.select.innerHTML="";for(let t of e){const e=document.createElement("option");e.setAttribute("value",t),e.innerText=t,this.select.appendChild(e)}};class If{constructor(t,e){this.container=ge({class:"igv-windowsize-panel-container"}),t.appendChild(this.container),e.on("locuschange",(t=>{this.updatePanel(t)})),this.browser=e}show(){this.container.style.display="block"}hide(){this.container.style.display="none"}updatePanel(t){const e=this.browser.calculateViewportWidth(this.browser.referenceFrameList.length);this.container.innerText=1===t.length?ws(Math.round(e*t[0].bpPerPixel)):""}}class Nf{constructor(t,e){this.browser=e,this.columnContainer=t,this.horizontalGuide=ge({class:"igv-cursor-guide-horizontal"}),t.appendChild(this.horizontalGuide),this.verticalGuide=ge({class:"igv-cursor-guide-vertical"}),t.appendChild(this.verticalGuide),this.addMouseHandler(e),this.setVisibility(e.config.showCursorGuide)}addMouseHandler(t){this.boundMouseMoveHandler=function(e){const{x:n,y:r}=we(e,this.columnContainer);this.horizontalGuide.style.top=`${r}px`;const i=document.elementFromPoint(e.clientX,e.clientY);let o;if(i.parentElement&&(i.parentElement.classList.contains("igv-viewport-content")?o=i.parentElement.parentElement:i.parentElement.classList.contains("igv-viewport")&&i.classList.contains("igv-viewport-content")&&(o=i.parentElement),o&&t.getRulerTrackView())){this.verticalGuide.style.left=`${n}px`;const r=t.root.querySelectorAll(".igv-column");let i;const s=o.parentElement;for(let t=0;t<r.length;t++)void 0===i&&s===r[t]&&(i=t);const a=t.getRulerTrackView().viewports[i].mouseMove(e);if(a){const{start:t,bp:e,end:n}=a,r=(e-t)/(n-t);this.customMouseHandler&&this.customMouseHandler({start:t,bp:e,end:n,interpolant:r})}}}.bind(this),this.columnContainer.addEventListener("mousemove",this.boundMouseMoveHandler)}removeMouseHandler(){this.columnContainer.removeEventListener("mousemove",this.boundMouseMoveHandler)}setVisibility(t){!0===t?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 t of this.browser.getRulerTrackView().viewports)t.$tooltip.hide()}}class Pf{constructor(t,e){this.browser=t,this.button=ge({class:"igv-navbar-button"}),e.appendChild(this.button),this.button.textContent="cursor guide",this.button.addEventListener("click",(()=>{t.cursorGuideVisible=!t.cursorGuideVisible,t.setCursorGuideVisibility(t.cursorGuideVisible),this.setButtonState(t.cursorGuideVisible)})),this.setButtonState(t.cursorGuideVisible),t.config.showCursorTrackingGuideButton?this.show():this.hide()}setButtonState(t){!0===t?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 Of{constructor(t,e){this.browser=t,this.button=ge({class:"igv-navbar-button"}),e.appendChild(this.button),this.button.textContent="center line",this.button.addEventListener("click",(()=>{t.isCenterLineVisible=!t.isCenterLineVisible,t.setCenterLineVisibility(t.isCenterLineVisible),this.setButtonState(t.isCenterLineVisible)})),this.setButtonState(t.isCenterLineVisible),t.config.showCenterGuideButton?this.show():this.hide()}setButtonState(t){!0===t?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 Ff{constructor(t,e){this.button=ge({class:"igv-navbar-button"}),t.appendChild(this.button),this.button.textContent="track labels",this.button.addEventListener("click",(()=>{e.trackLabelsVisible=!e.trackLabelsVisible,this.setState(e.trackLabelsVisible),e.setTrackLabelVisibility(e.trackLabelsVisible)})),this.browser=e,this.setVisibility(e.config.showTrackLabelButton),this.setState(e.trackLabelsVisible)}setVisibility(t){!0===t?this.show():this.hide()}setState(t){!0===t?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 Df{constructor(t,e){this.button=ge({class:"igv-navbar-button"}),t.appendChild(this.button),this.button.innerText="Sample Names",this.setState(e.showSampleNames),this.setVisibility(e.showSampleNameButton),this.button.addEventListener("click",(()=>{e.showSampleNames=!e.showSampleNames,this.setState(e.showSampleNames);for(let{sampleNameViewport:t}of e.trackViews)!1===e.showSampleNames?t.hide():t.show();e.layoutChange()}))}setVisibility(t){!0===t?this.show():this.hide()}setState(t){!0===t?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 Bf=23,zf=0;const Hf=function(t,e){this.browser=t,this.zoomContainer=ge({class:"igv-zoom-widget"}),e.appendChild(this.zoomContainer),this.zoomOutButton=ge(),this.zoomContainer.appendChild(this.zoomOutButton),this.zoomOutButton.appendChild(ye("minus-circle")),this.zoomOutButton.addEventListener("click",(()=>{t.zoomOut()}));const n=ge();this.zoomContainer.appendChild(n),this.slider=document.createElement("input"),this.slider.type="range",this.slider.min="0",this.slider.max=`${Bf}`,n.appendChild(this.slider),this.slider.addEventListener("change",(e=>{e.preventDefault(),e.stopPropagation();const n=t.referenceFrameList[0],{bpLength:r}=n.genome.getChromosome(n.chr),{end:i,start:o}=n,s=i-o,a=r/Math.pow(2,e.target.valueAsNumber);t.zoomWithScaleFactor(a/s)})),this.zoomInButton=ge(),this.zoomContainer.appendChild(this.zoomInButton),this.zoomInButton.appendChild(ye("plus-circle")),this.zoomInButton.addEventListener("click",(()=>{t.zoomIn()})),t.on("locuschange",(t=>{this.browser.isMultiLocusMode()?this.disable():(this.enable(),this.update(t))}))};Hf.prototype.update=function(t){const e=t[0],{bpLength:n}=e.genome.getChromosome(e.chr),{start:r,end:i}=e;Bf=Math.ceil(Math.log2(n/this.browser.minimumBases())),this.slider.max=`${Bf}`;const o=n/(i-r);zf=Math.log2(o),this.slider.value=`${Math.round(zf)}`},Hf.prototype.enable=function(){this.slider.disabled=!1},Hf.prototype.disable=function(){this.slider.disabled=!0},Hf.prototype.hide=function(){this.zoomContainer.style.display="none"},Hf.prototype.show=function(){this.zoomContainer.style.display="block"},Hf.prototype.hideSlider=function(){this.slider.style.display="none"},Hf.prototype.showSlider=function(){this.slider.style.display="block"};const Vf=function(t,e){const n=ge({class:"igv-navbar-button"});t.append(n),n.textContent="Save SVG",n.addEventListener("click",(()=>e.saveSVGtoFile({})))},jf=(t,e)=>{const n=0===t?e.nextElementSibling:e.previousElementSibling;e.remove(),n.remove()},Uf=t=>{const e=ge({class:"igv-column-shim"});_s(e,t);const n=ge({class:"igv-column"});return _s(n,e),n},qf=(t,e)=>{for(let n=0;n<e;n++){const r=ge({class:"igv-column"});if(ks(r,t),e>1&&n>0){ks(ge({class:"igv-column-shim"}),r)}}};class Wf{constructor(t,e,n){this.browser=t,this.referenceFrame=e,this.column=n,this.container=ge({class:"igv-center-line"}),n.appendChild(this.container),t.isCenterLineVisible?this.show():this.hide()}repaint(){const t=Math.floor(this.browser.calculateViewportWidth(this.browser.referenceFrameList.length)/2);if(this.referenceFrame){1/this.referenceFrame.bpPerPixel>1?(this.container.style.left=`${t}px`,this.container.style.width=`${Math.floor(this.referenceFrame.toPixels(1))}px`,this.container.classList.remove("igv-center-line-thin"),this.container.classList.add("igv-center-line-wide")):(this.container.style.left=`${t}px`,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 $f=Se;class Gf{constructor(t){this.browser=t,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(t,e,n){return[]}computePixelHeight(t){return this.height}draw({context:t,referenceFrame:e,pixelWidth:n,pixelHeight:r,bpPerPixel:i,bpStart:o}){na.isWholeGenomeView(e.chr)?this.drawWholeGenome({context:t,pixelWidth:n,pixelHeight:r,bpPerPixel:i}):this.doDraw({context:t,referenceFrame:e,pixelWidth:n,pixelHeight:r,bpStart:o})}drawWholeGenome({context:t,pixelWidth:e,pixelHeight:n,bpPerPixel:r}){t.save(),ls.fillRect(t,0,0,e,n,{fillStyle:"white"});for(let e of this.browser.genome.wgChromosomeNames){let i=this.browser.genome.getCumulativeOffset(e),o=this.browser.genome.getChromosome(e).bpLength,s=Math.round(i/r),a=Math.round(o/r);this.renderChromosomeRect(t,s,0,a,n,e)}t.restore()}doDraw({context:t,referenceFrame:e,pixelWidth:n,pixelHeight:r,bpStart:i}){t.clearRect(0,0,n,r);const o=function(t,e){if(t<10)return new Zf(1,"bp",1);const n=Math.floor(Math.log10(t));let r="bp",i=1;n>9?(r="gb",i=1e9):n>6?(r="mb",i=1e6):n>3&&(r="kb",i=1e3);const o=Math.pow(10,n-1),s=t/o,a=75,c=Math.pow(10,n-1),l=Math.pow(10,n)/2;return new Zf(s<a&&!0!==e?c:l,r,i)}(Math.floor(e.toBP(n)),t.isSVG);let s=Math.floor(i/o.majorTick)-1;const{tickDelta:a,labelLength:c}=function(t,e,n,r,i){const o=l(e,c(1+r,i),n)-l(e,c(r,i),n),s=`${Se(Math.floor(c(r,i)/i.unitMultiplier))} ${i.majorUnit}`,a=Math.floor(t.measureText(s).width);return{tickDelta:o,labelLength:a};function c(t,e){return Math.floor(t*e.majorTick)}function l(t,e,n){return Math.round(t.toPixels(e-1-n+.5))}}(t,e,i,s,o);let l,h;this.browser.referenceFrameList.indexOf(e);let u=a;const f=.25*c;do{h=Math.floor(s*o.majorTick);const n=`${Se(Math.floor(h/o.unitMultiplier))} ${o.majorUnit}`;l=Math.round(e.toPixels(h-1-i+.5));const r=Math.round(l-t.measureText(n).width/2);r>0&&f+c<=u&&(ls.fillText(t,n,r,this.height-8),u=0),l>0&&ls.strokeLine(t,l,this.height-6,l,this.height-2),h=Math.floor((1+s)*o.majorTick);let d=l+(Math.round(e.toPixels(h-1-i+.5))-l)/2;d>0&&ls.strokeLine(t,d,this.height-6,d,this.height-2),++s,u+=a}while(l<n);ls.strokeLine(t,0,this.height-2,n,this.height-2)}renderChromosomeRect(t,e,n,r,i,o){t.textAlign="center",t.textBaseline="middle",t.font="12px sans-serif",ls.strokeLine(t,e+r,n,e+r,n+i,{strokeStyle:ro.greyScale(191)});const s=o.startsWith("chr")?o.substring(3):o;r>t.measureText(s).width&&ls.fillText(t,s,e+r/2,n+i/2,{fillStyle:ro.greyScale(68)})}get supportsWholeGenome(){return!0}dispose(){}}class Zf{constructor(t,e,n){this.majorTick=t,this.minorTick=t/10,this.majorUnit=e,this.unitMultiplier=n}description(t){console.log((t||"")+" tick "+$f(this.majorTick)+" label width "+$f(this.labelWidthBP)+" multiplier "+this.unitMultiplier)}}const Xf=function(t,e){this.button=ge({class:"igv-navbar-button"}),t.appendChild(this.button),this.button.textContent="circular view",this.button.addEventListener("click",(()=>{e.circularViewVisible=!e.circularViewVisible})),this.browser=e,this.setVisibility(e.config.showCircularViewButton),this.setState(e.circularViewVisible)};Xf.prototype.setVisibility=function(t){!0===t?this.show():this.hide()},Xf.prototype.setState=function(t){!0===t?this.button.classList.add("igv-navbar-button-clicked"):this.button.classList.remove("igv-navbar-button-clicked")},Xf.prototype.show=function(){this.button.style.display="block",this.setState(this.browser.circularViewVisible)},Xf.prototype.hide=function(){this.button.style.display="none"};const Yf=function(t,e,n){const r=ge({class:"igv-navbar-button"});t.append(r),r.textContent=n.label,r.addEventListener("click",(()=>n.callback(e)))};class Kf{constructor(t,e){this.config=t,this.guid=be(),this.namespace=".browser_"+this.guid,this.parent=e,this.root=ge({class:"igv-container"}),e.appendChild(this.root),Qo.init(this.root),this.columnContainer=ge({class:"igv-column-container"}),this.root.appendChild(this.columnContainer),this.menuPopup=new yl(this.columnContainer),this.initialize(t),this.trackViews=[],this.constants={dragThreshold:3,scrollThreshold:5,defaultColor:"rgb(0,0,150)",doubleClickDelay:t.doubleClickDelay||500},this.eventHandlers={},this.addMouseHandlers(),this.setControls(t)}initialize(t){t.gtex&&(Eu.gtexLoaded=!0),this.flanking=t.flanking,this.crossDomainProxy=t.crossDomainProxy,this.formats=t.formats,this.trackDefaults=t.trackDefaults,this.nucleotideColors=t.nucleotideColors||Af;for(let t of Object.keys(this.nucleotideColors))this.nucleotideColors[t.toLowerCase()]=this.nucleotideColors[t];this.trackLabelsVisible=t.showTrackLabels,this.isCenterLineVisible=t.showCenterGuide,this.cursorGuideVisible=t.showCursorGuide,this.showSampleNames=t.showSampleNames,this.showSampleNameButton=t.showSampleNameButton,this.sampleNameViewportWidth=t.sampleNameViewportWidth||200,t.search&&(this.searchConfig={type:"json",url:t.search.url,coords:void 0===t.search.coords?1:t.search.coords,chromosomeField:t.search.chromosomeField||"chromosome",startField:t.search.startField||"start",endField:t.search.endField||"end",geneField:t.search.geneField||"gene",snpField:t.search.snpField||"snp",resultsField:t.search.resultsField})}setControls(t){const e=this.createStandardControls(t);e.insertBefore(pe(this.columnContainer)),this.$navigation=e,!1===t.showControls&&e.hide()}createStandardControls(t){this.navbarManager=new Mf(this);const e=pe("<div>",{class:"igv-navbar"});this.$navigation=e;const n=pe("<div>",{class:"igv-navbar-left-container"});e.append(n);const r=pe("<div>",{class:"igv-logo"});n.append(r);const i=pe('<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>');i.css("width","34px"),i.css("height","32px"),r.append(i),this.$current_genome=pe("<div>",{class:"igv-current-genome"}),n.append(this.$current_genome),this.$current_genome.text("");const o=pe("<div>",{class:"igv-navbar-genomic-location"});n.append(o),this.chromosomeSelectWidget=new Rf(this,o.get(0)),void 0===t.showChromosomeWidget&&(t.showChromosomeWidget=!0),!0===t.showChromosomeWidget?this.chromosomeSelectWidget.show():this.chromosomeSelectWidget.hide();const s=pe("<div>",{class:"igv-locus-size-group"});o.append(s);const a=pe("<div>",{class:"igv-search-container"});s.append(a),this.$searchInput=pe("<input>",{class:"igv-search-input",type:"text",placeholder:"Locus Search"}),a.append(this.$searchInput),this.$searchInput.change((()=>this.doSearch(this.$searchInput.val())));const c=ge({class:"igv-search-icon-container"});a.append(pe(c)),c.appendChild(ye("search")),c.addEventListener("click",(()=>this.doSearch(this.$searchInput.val()))),this.windowSizePanel=new If(s.get(0),this);const l=pe("<div>",{class:"igv-navbar-right-container"});e.append(l);const h=pe('<div class="igv-navbar-toggle-button-container">');if(l.append(h),this.$toggle_button_container=h,this.cursorGuide=new Nf(this.columnContainer,this),this.cursorGuideButton=new Pf(this,h.get(0)),this.centerLineButton=new Of(this,h.get(0)),this.setTrackLabelVisibility(t.showTrackLabels),this.trackLabelControl=new Ff(h.get(0),this),this.sampleNameControl=new Df(h.get(0),this),!0===t.showSVGButton&&(this.svgSaveControl=new Vf(h.get(0),this)),t.customButtons)for(let e of t.customButtons)new Yf(h.get(0),this,e);return this.zoomWidget=new Hf(this,l.get(0)),!1===t.showNavigation&&this.$navigation.hide(),this.inputDialog=new Jo(this.root),this.inputDialog.container.id=`igv-input-dialog-${be()}`,this.dataRangeDialog=new cs(pe(this.root)),this.dataRangeDialog.$container.get(0).id=`igv-data-range-dialog-${be()}`,this.genericColorPicker=new wl({parent:this.columnContainer,width:432}),this.genericColorPicker.container.id=`igv-track-color-picker-${be()}`,e}getSampleNameViewportWidth(){return!1===this.showSampleNames?0:this.sampleNameViewportWidth}isMultiLocusMode(){return this.referenceFrameList&&this.referenceFrameList.length>1}addTrackToFactory(t,e){mf(t,e)}isMultiLocusWholeGenomeView(){if(void 0===this.referenceFrameList||1===this.referenceFrameList.length)return!1;for(let t of this.referenceFrameList)if("all"===t.chr.toLowerCase())return!0;return!1}toSVG(){let{x:t,y:e,width:n,height:r}=this.columnContainer.getBoundingClientRect();let i=new js({width:n,height:8e3,backdropColor:"white",multiLocusGap:0,viewbox:{x:0,y:0,width:n,height:8e3}});for(let t of this.trackViews)t.renderSVGContext(i,{deltaX:0,deltaY:-e});return i.setHeight(r),i.getSerializedSvg(!0)}renderSVG(t){const e=this.toSVG();return t.empty(),t.append(e),e}saveSVGtoFile(t){let e=this.toSVG();t.$container&&(t.$container.empty(),t.$container.append(e));We(t.filename||"igvjs.svg",URL.createObjectURL(new Blob([e],{type:"application/octet-stream"})))}async loadSession(t){let e;return this.roi=[],e=t.url||t.file?await async function(t){const e=t.url||t.file;if(t.url&&(t.url.startsWith("blob:")||t.url.startsWith("data:"))){const e=Kf.uncompressSession(t.url);return JSON.parse(e)}{let n=t.filename;if(n||(n=t.url?await bs(t.url):t.file.name),n.endsWith(".xml")){const t=na.KNOWN_GENOMES,n=await go.loadString(e);return new yf(n,t)}return n.endsWith(".json")?go.loadJson(e):void 0}}(t):t,this.loadSessionObject(e)}async loadSessionObject(t){this.cleanHouseForSession(),this.showSampleNames=t.showSampleNames||!1,this.sampleNameControl.setState(!0===this.showSampleNames),t.sampleNameViewportWidth&&(this.sampleNameViewportWidth=t.sampleNameViewportWidth),xs(this.columnContainer,"igv-axis-column"),xs(this.columnContainer,"igv-sample-name-column"),xs(this.columnContainer,"igv-scrollbar-column"),xs(this.columnContainer,"igv-track-drag-column"),xs(this.columnContainer,"igv-gear-menu-column");const e=await na.expandReference(t.reference||t.genome);if(await this.loadReference(e,t.locus),this.centerLineList=this.createCenterLineList(this.columnContainer),!1!==t.showIdeogram){const t=new hf(this);t.id="ideogram",this.trackViews.push(new Sl(this,this.columnContainer,t))}if(!1!==t.showRuler&&this.trackViews.push(new Sl(this,this.columnContainer,new Gf(this))),t.gtexSelections)for(let e of this.referenceFrameList)for(let n of Object.keys(t.gtexSelections)){const r=t.gtexSelections[n].gene,i=t.gtexSelections[n].snp;e.selection=new Sf(r,i)}if(t.roi){this.roi=[];for(let e of t.roi)this.roi.push(new bf(e,this.genome))}const n=e.tracks||[],r=t.tracks?n.concat(t.tracks):n;0===r.filter((t=>"sequence"===t.type)).length&&r.push({type:"sequence",order:Ts});let i=1;for(let t of r)void 0===t.order&&(t.order=i++);await this.loadTrackList(r);for(let t of this.trackViews.filter((t=>"ruler"===t.track.type||"ideogram"===t.track.type)))t.updateViews();this.updateUIWithReferenceFrameList()}createCenterLineList(t){const e=t.querySelectorAll(".igv-center-line");for(let t=0;t<e.length;t++)e[t].remove();const n=[],r=t.querySelectorAll(".igv-column");for(let t=0;t<r.length;t++)n.push(new Wf(this,this.referenceFrameList[t],r[t]));return n}async loadReference(t,e){const n=await na.loadGenome(t),r=void 0===this.genome||this.genome.id!==n.id;this.genome=n,this.updateNavbarDOMWithGenome(n),r&&this.removeAllTracks();let i=function(t,e){return t?Array.isArray(t)?t.join(" "):t:e.getHomeChromosomeName()}(e,n);if(!await this.search(i,!0)){console.log("Initial locus not found: "+i),i=n.getHomeChromosomeName();if(!await this.search(i,!0))throw new Error("Cannot set initial locus")}r&&this.circularView&&this.circularView.setAssembly({name:this.genome.id,id:this.genome.id,chromosomes:Jc(this.genome)})}cleanHouseForSession(){for(let t of this.trackViews)t.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((t=>t.remove())),this.trackViews=[],this.circularView&&this.circularView.clearChords()}updateNavbarDOMWithGenome(t){this.$current_genome.text(t.id||""),this.$current_genome.attr("title",t.id||""),this.chromosomeSelectWidget.update(t)}async loadGenome(t){const e=await na.expandReference(t);await this.loadReference(e,void 0);const n=e.tracks||[];return 0===n.filter((t=>"sequence"===t.type)).length&&n.push({type:"sequence",order:Ts}),await this.loadTrackList(n),await this.updateViews(),this.genome}updateUIWithReferenceFrameList(){const t=this.referenceFrameList;this.updateLocusSearchWidget();const e=this.isMultiLocusWholeGenomeView()||na.isWholeGenomeView(t[0].chr);this.navbarManager.navbarDidResize(this.$navigation.width(),e),ed(this.trackViews,this.trackLabelsVisible),this.setCenterLineAndCenterLineButtonVisibility(!na.isWholeGenomeView(t[0].chr))}setTrackLabelVisibility(t){ed(this.trackViews,t)}setCursorGuideVisibility(t){t?this.cursorGuide.show():this.cursorGuide.hide()}setCustomCursorGuideMouseHandler(t){this.cursorGuide.customMouseHandler=t}setCenterLineVisibility(t){for(let e of this.centerLineList)!0===t?(e.show(),e.repaint()):e.hide()}setCenterLineAndCenterLineButtonVisibility(t){for(let e of this.centerLineList){t&&e.isVisible?e.show():e.container.style.display="none"}t&&this.centerLineButton.isVisible?this.centerLineButton.show():this.centerLineButton.button.style.display="none"}async loadTrackList(t){const e=[];for(let n of t)e.push(this.loadTrack(n));const n=await Promise.all(e);return this.trackViews.filter((function(t){return t.track.autoscaleGroup})).length>0&&this.updateViews(),n}async loadROI(t){if(this.roi||(this.roi=[]),Array.isArray(t))for(let e of t)this.roi.push(new bf(e,this.genome));else this.roi.push(new bf(t,this.genome));await this.updateViews(!0)}removeROI(t){for(let e=0;e<this.roi.length;e++)if(this.roi[e].name===t.name){this.roi.splice(e,1);break}for(let t of this.trackViews)t.repaintViews()}clearROIs(){this.roi=[];for(let t of this.trackViews)t.repaintViews()}getRulerTrackView(){const t=this.trackViews.filter((({track:t})=>"ruler"===t.id));return t.length>0?t[0]:void 0}async loadTrack(t){_e(t)&&(t=JSON.parse(t));try{const e=await this.createTrack(t);if(void 0===e)return Qo.presentAlert(new Error(`Unknown file type: ${t.url||t}`),void 0),e;void 0===e.order&&(e.order=this.trackViews.length);const n=new Sl(this,this.columnContainer,e);if(this.trackViews.push(n),ed(this.trackViews,this.trackLabelsVisible),this.reorderTracks(),this.fireEvent("trackorderchanged",[this.getTrackOrder()]),"function"==typeof e.postInit)try{n.startSpinner(),await e.postInit()}finally{n.stopSpinner()}return e.autoscaleGroup||(t.sync?await n.updateViews():n.updateViews()),"function"==typeof e.hasSamples&&e.hasSamples()&&!1!==this.config.showSampleNameButton&&this.sampleNameControl.show(),e}catch(e){const n={401:"Access unauthorized",403:"Access forbidden",404:"Not found"};console.error(e);let r=e.message||e.error||e.toString();n.hasOwnProperty(r)&&(r=n[r]),r+=": "+t.url,Qo.presentAlert(new Error(r),void 0)}}async createTrack(t){let e=await async function(t){return"function"==typeof t?t():t}(t.url);if(_e(e)&&(e=e.trim()),e)if(t.format)t.format=t.format.toLowerCase();else{let n=t.filename;n||(n=await bs(e)),t.format=function(t){var e,n;if((t=t.toLowerCase()).endsWith("refgene.txt.gz")||t.endsWith("refgene.txt.bgz")||t.endsWith("refgene.txt")||t.endsWith("refgene.sorted.txt.gz")||t.endsWith("refgene.sorted.txt.bgz"))return"refgene";switch((e=t.indexOf("?"))>0&&(t=t.substr(0,e)),t.endsWith(".gz")&&(t=t.substr(0,t.length-3)),(t.endsWith(".txt")||t.endsWith(".tab")||t.endsWith(".bgz"))&&(t=t.substr(0,t.length-4)),n=(e=t.lastIndexOf("."))<0?t:t.substr(e+1)){case"bw":return"bigwig";case"bb":return"bigbed";default:return fs.has(n)?n:void 0}}(n),t.format||void 0!==t.sourceType&&"htsget"!==t.sourceType||await ec.inferFormat(t)}let n=t.type?t.type.toLowerCase():void 0;if(!n){if(n=ds(t),"bedtype"===n){const e=Cu(t,this.genome);t._featureSource=e;const r=await e.trackType();n=r||"annotation"}t.type=n}if(this.trackDefaults&&n){const e=this.trackDefaults[n];if(e)for(let n in e)e.hasOwnProperty(n)&&void 0===t[n]&&(t[n]=e[n])}const r=vf(n,t,this);if(r&&t.roi){r.roi=[];for(let e of t.roi)r.roi.push(new bf(e,this.genome))}return r}reorderTracks(){this.trackViews.sort((function(t,e){const n=t=>"ideogram"===t.track.id?1:"ruler"===t.track.id?2:3,r=n(t),i=n(e);if(r===i){return(t.track.order||0)-(e.track.order||0)}return r-i}));for(let{axis:t,viewports:e,sampleNameViewport:n,outerScroll:r,dragHandle:i,gearContainer:o}of this.trackViews){t.remove();for(let{$viewport:t}of e)t.detach();n.viewport.remove(),r.remove(),i.remove(),o.remove()}const t=this.columnContainer.querySelectorAll(".igv-column");for(let{axis:e,viewports:n,sampleNameViewport:r,outerScroll:i,dragHandle:o,gearContainer:s}of this.trackViews){this.columnContainer.querySelector(".igv-axis-column").appendChild(e);for(let e=0;e<t.length;e++){const{$viewport:r}=n[e];t[e].appendChild(r.get(0))}this.columnContainer.querySelector(".igv-sample-name-column").appendChild(r.viewport),this.columnContainer.querySelector(".igv-scrollbar-column").appendChild(i),this.columnContainer.querySelector(".igv-track-drag-column").appendChild(o),this.columnContainer.querySelector(".igv-gear-menu-column").appendChild(s)}}getTrackOrder(){return this.trackViews.filter((t=>t.track&&t.track.name)).map((t=>t.track.name))}removeTrackByName(t){const e=this.trackViews.slice();for(let n of e)t===n.track.name&&this.removeTrack(n.track)}removeTrack(t){this.trackViews.splice(this.trackViews.indexOf(t.trackView),1),this.fireEvent("trackremoved",[t]),this.fireEvent("trackorderchanged",[this.getTrackOrder()]),t.trackView.dispose()}removeAllTracks(){const t=[];for(let e of this.trackViews)"ruler"!==e.track.id&&"ideogram"!==e.track.id?(this.fireEvent("trackremoved",[e.track]),e.dispose()):t.push(e);this.trackViews=t}findTracks(t,e){let n="function"==typeof t?e=>t(e.track):n=>e===n.track[t];return this.trackViews.filter(n).map((t=>t.track))}setTrackHeight(t){this.trackHeight=t,this.trackViews.forEach((function(e){e.setTrackHeight(t)}))}async visibilityChange(){this.layoutChange()}async layoutChange(){if(this.referenceFrameList.find((t=>t.bpPerPixel<0))){const t=this.calculateViewportWidth(this.referenceFrameList.length);for(let e of this.referenceFrameList)e.bpPerPixel=(e.end-e.start)/t}if(this.referenceFrameList){const t=this.isMultiLocusWholeGenomeView()||na.isWholeGenomeView(this.referenceFrameList[0].chr);this.navbarManager.navbarDidResize(this.$navigation.width(),t)}Qf.call(this),await this.updateViews()}async updateViews(){const t=this.trackViews;this.updateLocusSearchWidget();for(let t of this.centerLineList)t.repaint();if(this.dragObject)for(let e of t)await e.updateViews();else{const i={},o=[];for(let n of t){const t=n.track.autoscaleGroup;if(t){var e=i[t];e||(e=[],i[t]=e),e.push(n)}else o.push(n)}if(Object.entries(i).length>0){const t=Object.keys(i);for(let e of t){const t=i[e],o=[];for(let e of t)o.push(e.getInViewFeatures());const s=await Promise.all(o);var n,r=[];for(let t of s)r=r.concat(t);n=ms(r);const a=[];for(let e of t)e.track.dataRange=n,e.track.autoscale=!1,a.push(e.updateViews());await Promise.all(a)}}await Promise.all(o.map((t=>t.updateViews())))}}repaintViews(){for(let t of this.trackViews)t.repaintViews()}updateLocusSearchWidget(){const t=this.referenceFrameList,e=this.calculateViewportWidth(this.referenceFrameList.length);for(let n of t)n.end=n.start+n.bpPerPixel*e;this.chromosomeSelectWidget.select.value=1===t.length?this.referenceFrameList[0].chr:"";const n=this.referenceFrameList.map((t=>t.getLocusString())).join(" ");this.$searchInput.val(n),this.fireEvent("locuschange",[this.referenceFrameList])}calculateViewportWidth(t){let{width:e}=this.columnContainer.getBoundingClientRect();return e-=50+this.getSampleNameViewportWidth()+14+12+28,e-=5*(t-1),Math.floor(e/t)}getCenterLineXOffset(){let{width:t}=this.columnContainer.getBoundingClientRect();return t-=50+this.getSampleNameViewportWidth()+14+12+28,Math.floor(t/2+50)}minimumBases(){return this.config.minimumBases}zoomIn(){this.zoomWithScaleFactor(.5)}zoomOut(){this.zoomWithScaleFactor(2)}async zoomWithScaleFactor(t,e,n){const r=this.calculateViewportWidth(this.referenceFrameList.length);let i=n?[n]:this.referenceFrameList;for(let n of i)n.zoomWithScaleFactor(this,t,r,e)}async addMultiLocusPanel(t,e,n,r){const i=this.calculateViewportWidth(1+this.referenceFrameList.length),o=this.calculateViewportWidth(this.referenceFrameList.length)/this.calculateViewportWidth(1+this.referenceFrameList.length);for(let t of this.referenceFrameList)t.bpPerPixel*=o;const s=(n-e)/i,a=new Ef(this.genome,t,e,n,s),c=r?this.referenceFrameList.indexOf(r):this.referenceFrameList.length-1,l=1+c,{$viewport:h}=this.trackViews[0].viewports[c],u=Uf(h.get(0).parentElement);if(l===this.referenceFrameList.length){this.referenceFrameList.push(a);for(let t of this.trackViews){const e=gl(t,u,a);t.viewports.push(e)}}else{this.referenceFrameList.splice(l,0,a);for(let t of this.trackViews){const e=gl(t,u,a);t.viewports.splice(l,0,e)}}this.centerLineList=this.createCenterLineList(this.columnContainer),Qf.call(this),await this.updateViews(!0)}async removeMultiLocusPanel(t){const e=this.referenceFrameList.indexOf(t),{$viewport:n}=this.trackViews[0].viewports[e];jf(e,n.parent().get(0));for(let{viewports:t}of this.trackViews)t[e].dispose(),t.splice(e,1);if(this.referenceFrameList.splice(e,1),1===this.referenceFrameList.length&&this.getRulerTrackView())for(let t of this.getRulerTrackView().viewports)t.dismissLocusLabel();const r=this.calculateViewportWidth(1+this.referenceFrameList.length)/this.calculateViewportWidth(this.referenceFrameList.length);await this.rescaleForMultiLocus(r)}async gotoMultilocusPanel(t){const e=this.referenceFrameList.indexOf(t);this.columnContainer.querySelectorAll(".igv-column").forEach(((t,n)=>{n===e||t.remove()})),this.columnContainer.querySelectorAll(".igv-column-shim").forEach((t=>t.remove()));for(let t of this.trackViews){const n=t.viewports[e];t.viewports.filter(((t,n)=>n!==e)).forEach((t=>t.dispose())),t.viewports=[n]}const n=this.calculateViewportWidth(1);t.bpPerPixel=(t.end-t.start)/n,this.referenceFrameList=[t],this.trackViews.forEach((({viewports:t})=>t.forEach((t=>t.setWidth(n))))),this.centerLineList=this.createCenterLineList(this.columnContainer),this.updateUIWithReferenceFrameList(),await this.updateViews(!0)}async rescaleForMultiLocus(t){const e=this.calculateViewportWidth(this.referenceFrameList.length);for(let e of this.referenceFrameList)e.bpPerPixel*=t;for(let{viewports:t}of this.trackViews)for(let n of t)n.setWidth(e);this.centerLineList=this.createCenterLineList(this.columnContainer),this.updateUIWithReferenceFrameList(),await this.updateViews()}async goto(t,e,n){await this.search(t+":"+e+"-"+n)}async doSearch(t,e){const n=await this.search(t,e);return n||Qo.presentAlert(new Error(`Unrecognized locus: <b> ${t} </b>`)),n}async search(t,e){const n=await Lf(this,t);if(n&&n.length>0){this.referenceFrameList=function(t,e,n,r,i){return t.map((t=>{n&&t.gene&&(t.start=Math.max(0,t.start-n),t.end+=n);const o=e.getChromosome(t.chr);vs(o.bpLength,t,r);const s=new Ef(e,t.chr,t.start,t.end,(t.end-t.start)/i);return s.locusSearchString=t.locusSearchString,(t.gene||t.snp)&&(s.selection=new Sf(t.gene,t.snp)),s}))}(n,this.genome,this.flanking,this.minimumBases(),this.calculateViewportWidth(n.length));for(let t of this.trackViews)t.removeDOMFromColumnContainer();this.columnContainer.querySelectorAll(".igv-column-shim, .igv-column").forEach((t=>t.remove())),qf(this.columnContainer.querySelector(".igv-sample-name-column"),this.referenceFrameList.length),this.centerLineList=this.createCenterLineList(this.columnContainer);for(let t of this.trackViews)t.addDOMToColumnContainer(this,this.columnContainer,this.referenceFrameList);return this.updateUIWithReferenceFrameList(),e||await this.updateViews(),!0}return!1}async loadSampleInformation(t){var e=t;Ue(t)&&(e=t.name),"fam"===e.substr(e.lastIndexOf(".")+1)&&(this.sampleInformation=await function(t,e){return(new _f).loadPlinkFile(t,e)}(t))}on(t,e){this.eventHandlers[t]||(this.eventHandlers[t]=[]),this.eventHandlers[t].push(e)}un(t,e){this.off(t,e)}off(t,e){if(t)if(e){const n=this.eventHandlers[t];if(n&&0!==n.length){const r=n.indexOf(e);-1!==r&&this.eventHandlers[t].splice(r,1)}else console.warn("No handlers to remove for event: "+t)}else this.eventHandlers[t]=[];else this.eventHandlers={}}fireEvent(t,e,n){const r=this.eventHandlers[t];if(void 0===r||0===r.length)return;const i=n||window;return r.map((function(t){return t.apply(i,e)}))[0]}dispose(){this.removeMouseHandlers();for(let t of this.trackViews)t.dispose()}toJSON(){const t={version:"2.12.4"};if(void 0!==this.showSampleNames&&(t.showSampleNames=this.showSampleNames),200!==this.sampleNameViewportWidth&&(t.sampleNameViewportWidth=this.sampleNameViewportWidth),t.reference=this.genome.toJSON(),qe(t.reference.fastaURL))throw new Error(`Error. Sessions cannot include local file references ${t.reference.fastaURL.name}.`);if(qe(t.reference.indexURL))throw new Error(`Error. Sessions cannot include local file references ${t.reference.indexURL.name}.`);const e=[],n={};let r=!1,i=this.trackViews[0];for(let{referenceFrame:t}of i.viewports){const i=t.getLocusString();if(e.push(i),t.selection){const e={gene:t.selection.gene,snp:t.selection.snp};n[i]=e,r=!0}}t.locus=1===e.length?e[0]:e,r&&(t.gtexSelections=n);const o=[],s=[];for(let{track:t}of this.trackViews)try{let e;e="function"==typeof t.getState?t.getState():t.config,e&&(e.browser&&delete e.browser,e.order=t.order,o.push(e))}catch(e){console.error(`Track: ${t.name}: ${e}`),s.push(`Track: ${t.name}: ${e}`)}if(s.length>0){let t=1,e="Errors encountered saving session: </br>";for(let n of s)e+=` (${t++}) ${n.toString()} <br/>`;throw Error(e)}return t.tracks=o,t}compressedSession(){return function(t){const e=new Uint8Array(t.length);for(var n=0;n<t.length;n++)e[n]=t.charCodeAt(n);const r=new qi.deflateRaw(e),i=String.fromCharCode.apply(null,r);return btoa(i).replace(/\+/g,".").replace(/\//g,"_").replace(/=/g,"-")}(JSON.stringify(this.toJSON()))}sessionURL(){const t=window.location.href.slice(),e=t.indexOf("?");return(e>0?t.substring(0,e):t)+"?sessionURL=blob:"+this.compressedSession()}mouseDownOnViewport(t,e){var n;n=ve(t),this.vpMouseDown={viewport:e,lastMouseX:n.x,mouseDownX:n.x,lastMouseY:n.y,mouseDownY:n.y,referenceFrame:e.referenceFrame}}cancelTrackPan(){const t=this.dragObject;this.dragObject=void 0,this.isScrolling=!1,this.vpMouseDown=void 0,t&&t.viewport.referenceFrame.start!==t.start&&(this.updateViews(),this.fireEvent("trackdragend"))}startTrackDrag(t){this.dragTrack=t}updateTrackDrag(t){if(t&&this.dragTrack){const e=this.dragTrack,n=this.trackViews.indexOf(t),r=this.trackViews.indexOf(e),i=this.trackViews;i[n]=e,i[r]=t;const o=this.trackViews[n].track.order;this.trackViews[r].track.order=o;const s=i.length;let a=o;if(n<r)for(let t=n+1;t<s;t++){const e=i[t].track;if(!(e.order<=a))break;e.order=Math.min(Number.MAX_SAFE_INTEGER,a+1),a=e.order}else for(let t=n-1;t>0;t--){const e=i[t].track;if(!(e.order>=a))break;e.order=Math.max(-Number.MAX_SAFE_INTEGER,a-1),a=e.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=Qf.bind(this),window.addEventListener("resize",this.boundWindowResizeHandler)}removeWindowResizeHandler(){window.removeEventListener("resize",this.boundWindowResizeHandler)}addRootMouseUpHandler(){this.boundRootMouseUpHandler=td.bind(this),this.root.addEventListener("mouseup",this.boundRootMouseUpHandler)}removeRootMouseUpHandler(){this.root.removeEventListener("mouseup",this.boundRootMouseUpHandler)}addRootMouseLeaveHandler(){this.boundRootMouseLeaveHandler=td.bind(this),this.root.addEventListener("mouseleave",this.boundRootMouseLeaveHandler)}removeRootMouseLeaveHandler(){this.root.removeEventListener("mouseleave",this.boundRootMouseLeaveHandler)}addColumnContainerEventHandlers(){this.boundColumnContainerMouseMoveHandler=Jf.bind(this),this.boundColumnContainerTouchMoveHandler=Jf.bind(this),this.boundColumnContainerMouseLeaveHandler=td.bind(this),this.boundColumnContainerMouseUpHandler=td.bind(this),this.boundColumnContainerTouchEndHandler=td.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)}async getDriveFileInfo(t){const e="https://www.googleapis.com/drive/v3/files/"+Ne(t)+"?supportsTeamDrives=true";return go.loadJson(e,gs({}))}static uncompressSession(t){let e;if(t.indexOf("/gzip;base64")>0){e=Ki(t);let n="";for(let t of e)n+=String.fromCharCode(t);return n}return function(t){t=t.replace(/\./g,"+").replace(/_/g,"/").replace(/-/g,"=");const e=atob(t),n=[];for(let t=0;t<e.length;t++)n.push(e.charCodeAt(t));const r=qi.inflateRaw(n);let i="";for(let t of r)i+=String.fromCharCode(t);return i}(t.substring(5))}createCircularView(t,e){var n;return e=!0===e,this.circularView=(n=this,new $c(t,{onChordClick:(t,e,r)=>{const i=t.data,o=i.mate;function s(t){t.chr=n.genome.getChromosomeName(t.refName);let e=!1;for(let r of n.referenceFrameList){const n=Ac.fromLocusString(r.getLocusString());if(n.contains(t)){e=!0;break}if(n.overlaps(t)){r.extend(t),e=!0;break}}if(!e){const e=2e3,r=(t.start+t.end)/2;n.addMultiLocusPanel(t.chr,r-e,r+e)}}s(i),s(o)}})),this.circularViewControl=new Xf(this.$toggle_button_container.get(0),this),this.circularView.setAssembly({name:this.genome.id,id:this.genome.id,chromosomes:Jc(this.genome)}),this.circularViewVisible=e,this.circularView}get circularViewVisible(){return void 0!==this.circularView&&this.circularView.visible}set circularViewVisible(t){this.circularView&&(this.circularView.visible=t,this.circularViewControl.setState(t))}}async function Qf(){const t=this.calculateViewportWidth(this.referenceFrameList.length);for(let e of this.referenceFrameList){const n=this.referenceFrameList.indexOf(e),{chr:r,genome:i}=e,{bpLength:o}=i.getChromosome(e.chr),s=e.toBP(t);na.isWholeGenomeView(r)||s>o?e.bpPerPixel=o/t:e.end=e.start+e.toBP(t);for(let{viewports:e}of this.trackViews)e[n].setWidth(t)}this.updateUIWithReferenceFrameList(),await this.updateViews(!0)}function Jf(t){t.preventDefault();const{x:e,y:n}=ve(t);if(this.vpMouseDown){const{viewport:t,referenceFrame:r}=this.vpMouseDown,i=Math.abs(e-this.vpMouseDown.mouseDownX)>Math.abs(n-this.vpMouseDown.mouseDownY);if(!this.dragObject&&!this.isScrolling)if(i)this.vpMouseDown.mouseDownX&&Math.abs(e-this.vpMouseDown.mouseDownX)>this.constants.dragThreshold&&(this.dragObject={viewport:t,start:r.start});else if(this.vpMouseDown.mouseDownY&&Math.abs(n-this.vpMouseDown.mouseDownY)>this.constants.scrollThreshold){this.isScrolling=!0;const e=t.$viewport.height(),n=Cl(t.trackView.viewports);this.vpMouseDown.r=e/n}if(this.dragObject){r.shiftPixels(this.vpMouseDown.lastMouseX-e,t.$viewport.width())&&this.updateViews(),this.fireEvent("trackdrag")}if(this.isScrolling){const e=this.vpMouseDown.r*(this.vpMouseDown.lastMouseY-n);t.trackView.moveScroller(e)}this.vpMouseDown.lastMouseX=e,this.vpMouseDown.lastMouseY=n}}function td(t){this.cancelTrackPan(),this.endTrackDrag()}function ed(t,e){for(let{viewports:n}of t)for(let t of n)t.$trackLabel&&(0===n.indexOf(t)&&!0===e?t.$trackLabel.show():t.$trackLabel.hide())}let nd=[];const rd=go.setApiKey;!function(){var t=document.createElement("style");t.setAttribute("type","text/css"),t.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 .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 .igv-navbar .igv-navbar-left-container .igv-logo {\n width: 34px;\n height: 32px;\n margin-right: 8px; }\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 .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 .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 .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 .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 .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 .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 .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 .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 .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 .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 .igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container div {\n margin-left: 0;\n margin-right: 4px; }\n .igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container div:last-child {\n margin-left: 0;\n margin-right: 0; }\n .igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container-750 {\n display: none; }\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 .igv-navbar .igv-navbar-right-container .igv-zoom-widget div {\n cursor: pointer;\n margin-left: unset;\n margin-right: unset; }\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 .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 .igv-navbar .igv-navbar-right-container .igv-zoom-widget div:nth-child(even) {\n display: block;\n height: fit-content; }\n .igv-navbar .igv-navbar-right-container .igv-zoom-widget input {\n display: block;\n width: 125px; }\n .igv-navbar .igv-navbar-right-container .igv-zoom-widget svg {\n display: block; }\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 .igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div {\n cursor: pointer;\n margin-left: unset;\n margin-right: unset; }\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 .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 .igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div:nth-child(even) {\n width: 0;\n height: 0;\n display: none; }\n .igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 input {\n width: 0;\n height: 0;\n display: none; }\n .igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 svg {\n display: block; }\n .igv-navbar .igv-navbar-right-container .igv-zoom-widget-hidden {\n display: none; }\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.igv-navbar-button-clicked {\n color: white;\n background-color: #737373; }\n\n.igv-navbar-button:hover {\n cursor: pointer; }\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 .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.igv-zoom-in-notice {\n position: absolute;\n top: 10px;\n left: 50%; }\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.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.igv-multi-locus-close-button {\n position: absolute;\n top: 2px;\n right: 0;\n padding-left: 2px;\n padding-right: 2px;\n width: 18px;\n height: 18px;\n color: #666666;\n background-color: white;\n z-index: 1000; }\n .igv-multi-locus-close-button > svg {\n vertical-align: top; }\n\n.igv-multi-locus-close-button:hover {\n cursor: pointer;\n color: #434343; }\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: 14px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: center;\n align-items: center; }\n .igv-multi-locus-ruler-label div {\n font-family: "Open Sans", sans-serif;\n font-size: 14px;\n font-weight: 400;\n color: #101010;\n background-color: white; }\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 .igv-multi-locus-ruler-label-square-dot > div:first-child {\n width: 14px;\n height: 14px; }\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: #101010; }\n\n.igv-multi-locus-ruler-label:hover {\n cursor: pointer; }\n\n.igv-ruler-sweeper {\n display: none;\n pointer-events: none;\n position: absolute;\n top: 0;\n left: 0;\n width: 0;\n height: 100%;\n z-index: 99999;\n background-color: rgba(68, 134, 247, 0.25); }\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 .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.igv-track-label {\n position: absolute;\n left: 8px;\n top: 8px;\n width: auto;\n height: auto;\n max-width: 200px;\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.igv-track-label:hover,\n.igv-track-label:focus,\n.igv-track-label:active {\n background-color: #e8e8e8; }\n\n.igv-track-label-popup-shim {\n padding-left: 8px;\n padding-right: 8px;\n padding-top: 4px; }\n\n.igv-center-line {\n display: none;\n pointer-events: none;\n position: absolute;\n top: 0;\n bottom: 0;\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.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.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.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.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.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 .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 .igv-user-feedback div:first-child div {\n position: absolute;\n top: 2px;\n width: 16px;\n height: 16px;\n background-color: transparent; }\n .igv-user-feedback div:first-child div:first-child {\n left: 8px; }\n .igv-user-feedback div:first-child div:last-child {\n cursor: pointer;\n right: 8px; }\n .igv-user-feedback div:last-child {\n width: 100%;\n height: calc(100% - 24px);\n border-width: 0; }\n .igv-user-feedback div:last-child div {\n width: auto;\n height: auto;\n margin: 8px; }\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 .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 .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 .igv-generic-dialog-container .igv-generic-dialog-header div:hover {\n cursor: pointer;\n color: #444; }\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 .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 .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 .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 .igv-generic-dialog-container .igv-generic-dialog-label-input input {\n width: 50%;\n font-size: 16px; }\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 .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 .igv-generic-dialog-container .igv-generic-dialog-input input {\n font-size: 16px; }\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 .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 .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 .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 .igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:first-child:hover {\n cursor: pointer;\n background-color: #3b5c7f; }\n .igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:last-child:hover {\n cursor: pointer;\n background-color: #7f7f7f; }\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 .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 .igv-generic-dialog-container .igv-generic-dialog-ok div:hover {\n cursor: pointer;\n background-color: #25597f; }\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 .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 .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.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 .igv-menu-popup > div:not(:first-child) {\n width: 100%; }\n .igv-menu-popup > div:not(:first-child) > div {\n background: white; }\n .igv-menu-popup > div:not(:first-child) > div.context-menu {\n padding-left: 4px;\n padding-right: 4px; }\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 .igv-menu-popup > div:not(:first-child) > div:hover {\n background: #efefef; }\n\n.igv-menu-popup-shim {\n padding-left: 8px;\n padding-right: 8px;\n padding-bottom: 1px;\n padding-top: 1px; }\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 .igv-menu-popup-header div {\n margin-right: 4px;\n height: 12px;\n width: 12px;\n color: #7F7F7F; }\n .igv-menu-popup-header div:hover {\n cursor: pointer;\n color: #444; }\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 .igv-menu-popup-check-container div {\n padding-top: 2px;\n padding-left: 8px; }\n .igv-menu-popup-check-container div:first-child {\n position: relative;\n width: 12px;\n height: 12px; }\n .igv-menu-popup-check-container div:first-child svg {\n position: absolute;\n width: 12px;\n height: 12px; }\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 .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 .igv-user-feedback div:first-child div {\n position: absolute;\n top: 2px;\n width: 16px;\n height: 16px;\n background-color: transparent; }\n .igv-user-feedback div:first-child div:first-child {\n left: 8px; }\n .igv-user-feedback div:first-child div:last-child {\n cursor: pointer;\n right: 8px; }\n .igv-user-feedback div:last-child {\n width: 100%;\n height: calc(100% - 24px);\n border-width: 0; }\n .igv-user-feedback div:last-child div {\n width: auto;\n height: auto;\n margin: 8px; }\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 .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: white;\n animation: spin 1s ease-in-out infinite;\n -webkit-animation: spin 1s ease-in-out infinite; }\n\n@keyframes spin {\n to {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg); } }\n@-webkit-keyframes spin {\n to {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg); } }\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.igv-viewport {\n position: relative;\n margin-top: 5px;\n overflow-x: hidden;\n overflow-y: hidden; }\n\n.igv-viewport-content {\n position: relative;\n width: 100%; }\n .igv-viewport-content > canvas {\n position: relative;\n display: block; }\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.igv-column-shim {\n width: 1px;\n margin-left: 2px;\n margin-right: 2px;\n background-color: #545453; }\n\n.igv-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.igv-axis-column {\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 .igv-axis-column > div {\n margin-top: 5px;\n width: 100%; }\n\n.igv-sample-name-column {\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.igv-scrollbar-column {\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 .igv-scrollbar-column > div {\n position: relative;\n margin-top: 5px;\n width: 14px; }\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 .igv-scrollbar-column > div > div:hover {\n background-color: #c4c4c4; }\n\n.igv-track-drag-column {\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 .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 .igv-track-drag-column .igv-track-drag-handle-hover {\n background-color: #787878; }\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.igv-gear-menu-column {\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 .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 .igv-gear-menu-column > div > div {\n position: relative;\n margin-top: 4px;\n width: 16px;\n height: 16px;\n color: #7F7F7F; }\n .igv-gear-menu-column > div > div:hover {\n cursor: pointer;\n color: #444; }\n\n/*# sourceMappingURL=dom.css.map */\n',document.head.insertBefore(t,document.head.childNodes[document.head.childNodes.length-1])}();var id={IGVGraphics:ls,MenuUtils:Oo,DataRangeDialog:cs,createTrack:async function(t,e){return await Kf.prototype.createTrack.call(e,t)},createBrowser:async function(t,e){void 0===e&&(e={}),na.KNOWN_GENOMES||await na.initializeGenomes(e),function(t){void 0===t.minimumBases&&(t.minimumBases=40);void 0===t.showIdeogram&&(t.showIdeogram=!0);void 0===t.showCircularView&&(t.showCircularView=!1);void 0===t.showCircularViewButton&&(t.showCircularViewButton=!1);void 0===t.showTrackLabelButton&&(t.showTrackLabelButton=!0);void 0===t.showTrackLabels&&(t.showTrackLabels=!0);void 0===t.showCursorTrackingGuideButton&&(t.showCursorTrackingGuideButton=!0);void 0===t.showCursorGuide&&(t.showCursorGuide=t.showCursorTrackingGuide||!1);void 0===t.showCenterGuideButton&&(t.showCenterGuideButton=!0);void 0===t.showCenterGuide&&(t.showCenterGuide=!1);void 0===t.showSampleNames&&(t.showSampleNames=!1);void 0===t.showSVGButton&&(t.showSVGButton=!0);void 0===t.showControls&&(t.showControls=!0);void 0===t.showNavigation&&(t.showNavigation=!0);void 0===t.showRuler&&(t.showRuler=!0);void 0===t.flanking&&(t.flanking=1e3);void 0===t.pairsSupported&&(t.pairsSupported=!0);t.tracks||(t.tracks=[])}(e),e.queryParametersSupported&&function(t){var e,n,r,i,o,s,a,c,l;let h,u,f;if(a=window.location.href,o={},e=a.indexOf("?"),n=a.lastIndexOf("#"),e>=0)for(n<0&&(n=a.length),r=e+1;r<n;)(i=a.indexOf("&",r))<0&&(i=n),2===(s=a.substring(r,i).split("=",2)).length?(c=s[0],l=decodeURIComponent(s[1]),"file"===c?h=l.split(","):"index"===c?u=l.split(","):"name"===c?f=l.split(","):"genome"!==c||!l.startsWith("https://")&&!l.startsWith("http://")||l.endsWith(".json")?t[c]=l:t.reference={fastaURL:l,indexURL:l+".fai"},r=i+1):r++;if(h){t.tracks||(t.tracks=[]);for(let e=0;e<h.length;e++){if(h[e].endsWith(".xml")||h[e].endsWith(".json")){t.sessionURL=h[e];break}const n={url:h[e]};u&&u.length>e&&(n.indexURL=u[e]),f&&f.length>e&&(n.name=f[e]),t.tracks.push(n)}}}(e),e.apiKey&&go.setApiKey(e.apiKey),e.oauthToken&&ho.setToken(e.oauthToken),e.clientId&&!Fe()&&await Oe({clientId:e.clientId,apiKey:e.apiKey,scope:"https://www.googleapis.com/auth/userinfo.profile"});const n=new Kf(e,t);nd.push(n),e.sessionURL?await n.loadSession({url:e.sessionURL}):await n.loadSessionObject(e);const r=n.isMultiLocusWholeGenomeView()||na.isWholeGenomeView(n.referenceFrameList[0].chr);return n.navbarManager.navbarDidResize(n.$navigation.width(),r),n},removeBrowser:function(t){t.dispose(),t.root.remove(),nd=nd.filter((e=>e!==t))},removeAllBrowsers:function(){for(let t of nd)t.dispose(),t.root.remove();nd=[]},visibilityChange:async function(){for(let t of nd)await t.visibilityChange()},setGoogleOauthToken:function(t){return ho.setToken(t)},setOauthToken:function(t,e){return ho.setToken(t,e)},oauth:ho,version:ta,setApiKey:rd,doAutoscale:ms,TrackView:Sl};export{id as default};
|
|
71
|
+
*/var Tc=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},Lc=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),Mc=function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var s,a=t[Symbol.iterator]();!(r=(s=a.next()).done)&&(n.push(s.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{!r&&a.return&&a.return()}finally{if(i)throw o}}return n}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")};String.prototype.startsWith=String.prototype.startsWith||function(t){return 0===this.indexOf(t)},String.prototype.padStart=String.prototype.padStart||function(t,e){for(var n=this;n.length<t;)n=e+n;return n};var Rc={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 Ic(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=e>0?t.toFixed(e).replace(/0+$/,"").replace(/\.$/,""):t.toString();return n||"0"}var Nc=function(){function t(e,n,r,i){Tc(this,t);var o=this;if(void 0===e);else if(Array.isArray(e))this.rgba=e;else if(void 0===r){var s=e&&""+e;s&&function(e){if(e.startsWith("hsl")){var n=e.match(/([\-\d\.e]+)/g).map(Number),r=Mc(n,4),i=r[0],s=r[1],a=r[2],c=r[3];void 0===c&&(c=1),i/=360,s/=100,a/=100,o.hsla=[i,s,a,c]}else if(e.startsWith("rgb")){var l=e.match(/([\-\d\.e]+)/g).map(Number),h=Mc(l,4),u=h[0],f=h[1],d=h[2],p=h[3];void 0===p&&(p=1),o.rgba=[u,f,d,p]}else e.startsWith("#")?o.rgba=t.hexToRgb(e):o.rgba=t.nameToRgb(e)||t.hexToRgb(e)}(s.toLowerCase())}else this.rgba=[e,n,r,void 0===i?1:i]}return Lc(t,[{key:"printRGB",value:function(t){var e=(t?this.rgba:this.rgba.slice(0,3)).map((function(t,e){return Ic(t,3===e?3:0)}));return t?"rgba("+e+")":"rgb("+e+")"}},{key:"printHSL",value:function(t){var e=[360,100,100,1],n=["","%","%",""],r=(t?this.hsla:this.hsla.slice(0,3)).map((function(t,r){return Ic(t*e[r],3===r?3:1)+n[r]}));return t?"hsla("+r+")":"hsl("+r+")"}},{key:"printHex",value:function(t){var e=this.hex;return t?e:e.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=t.hslToRgb(this._hsla)},set:function(t){3===t.length&&(t[3]=1),this._rgba=t,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=t.rgbToHsl(this._rgba)},set:function(t){3===t.length&&(t[3]=1),this._hsla=t,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(t,e){return e<3?t.toString(16):Math.round(255*t).toString(16)})).map((function(t){return t.padStart(2,"0")})).join("")},set:function(e){this.rgba=t.hexToRgb(e)}}],[{key:"hexToRgb",value:function(t){var e=(t.startsWith("#")?t.slice(1):t).replace(/^(\w{3})$/,"$1F").replace(/^(\w)(\w)(\w)(\w)$/,"$1$1$2$2$3$3$4$4").replace(/^(\w{6})$/,"$1FF");if(!e.match(/^([0-9a-fA-F]{8})$/))throw new Error("Unknown hex color; "+t);var n=e.match(/^(\w\w)(\w\w)(\w\w)(\w\w)$/).slice(1).map((function(t){return parseInt(t,16)}));return n[3]=n[3]/255,n}},{key:"nameToRgb",value:function(e){var n=e.toLowerCase().replace("at","T").replace(/[aeiouyldf]/g,"").replace("ght","L").replace("rk","D").slice(-5,4),r=Rc[n];return void 0===r?r:t.hexToRgb(r.replace(/\-/g,"00").padStart(6,"f"))}},{key:"rgbToHsl",value:function(t){var e=Mc(t,4),n=e[0],r=e[1],i=e[2],o=e[3];n/=255,r/=255,i/=255;var s=Math.max(n,r,i),a=Math.min(n,r,i),c=void 0,l=void 0,h=(s+a)/2;if(s===a)c=l=0;else{var u=s-a;switch(l=h>.5?u/(2-s-a):u/(s+a),s){case n:c=(r-i)/u+(r<i?6:0);break;case r:c=(i-n)/u+2;break;case i:c=(n-r)/u+4}c/=6}return[c,l,h,o]}},{key:"hslToRgb",value:function(t){var e=Mc(t,4),n=e[0],r=e[1],i=e[2],o=e[3],s=void 0,a=void 0,c=void 0;if(0===r)s=a=c=i;else{var l=function(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t},h=i<.5?i*(1+r):i+r-i*r,u=2*i-h;s=l(u,h,n+1/3),a=l(u,h,n),c=l(u,h,n-1/3)}var f=[255*s,255*a,255*c].map(Math.round);return f[3]=o,f}}]),t}(),Pc=function(){function t(){Tc(this,t),this._events=[]}return Lc(t,[{key:"add",value:function(t,e,n){t.addEventListener(e,n,!1),this._events.push({target:t,type:e,handler:n})}},{key:"remove",value:function(e,n,r){this._events=this._events.filter((function(i){var o=!0;return e&&e!==i.target&&(o=!1),n&&n!==i.type&&(o=!1),r&&r!==i.handler&&(o=!1),o&&t._doRemove(i.target,i.type,i.handler),!o}))}},{key:"destroy",value:function(){this._events.forEach((function(e){return t._doRemove(e.target,e.type,e.handler)})),this._events=[]}}],[{key:"_doRemove",value:function(t,e,n){t.removeEventListener(e,n,!1)}}]),t}();function Oc(t,e,n){var r=!1;function i(t,e,n){return Math.max(e,Math.min(t,n))}function o(t,o,s){if(s&&(r=!0),r){t.preventDefault();var a=e.getBoundingClientRect(),c=a.width,l=a.height,h=o.clientX,u=o.clientY,f=i(h-a.left,0,c),d=i(u-a.top,0,l);n(f/c,d/l)}}function s(t,e){1===(void 0===t.buttons?t.which:t.buttons)?o(t,t,e):r=!1}function a(t,e){1===t.touches.length?o(t,t.touches[0],e):r=!1}t.add(e,"mousedown",(function(t){s(t,!0)})),t.add(e,"touchstart",(function(t){a(t,!0)})),t.add(window,"mousemove",s),t.add(e,"touchmove",a),t.add(window,"mouseup",(function(t){r=!1})),t.add(e,"touchend",(function(t){r=!1})),t.add(e,"touchcancel",(function(t){r=!1}))}function Fc(t,e){return(e||document).querySelector(t)}function Dc(t){t.preventDefault(),t.stopPropagation()}function Bc(t,e,n,r,i){t.add(e,"keydown",(function(t){n.indexOf(t.key)>=0&&(i&&Dc(t),r(t))}))}var zc=function(){function t(e){Tc(this,t),this.settings={popup:"right",layout:"default",alpha:!0,editor:!0,editorFormat:"hex",cancelButton:!1,defaultColor:"#0cf"},this._events=new Pc,this.onChange=null,this.onDone=null,this.onOpen=null,this.onClose=null,this.setOptions(e)}return Lc(t,[{key:"setOptions",value:function(t){var e=this;if(t){var n=this.settings;if(t instanceof HTMLElement)n.parent=t;else{n.parent&&t.parent&&n.parent!==t.parent&&(this._events.remove(n.parent),this._popupInited=!1),function(t,e,n){for(var r in t)n&&n.indexOf(r)>=0||(e[r]=t[r])}(t,n),t.onChange&&(this.onChange=t.onChange),t.onDone&&(this.onDone=t.onDone),t.onOpen&&(this.onOpen=t.onOpen),t.onClose&&(this.onClose=t.onClose);var r=t.color||t.colour;r&&this._setColor(r)}var i=n.parent;if(i&&n.popup&&!this._popupInited){var o=function(t){return e.openHandler(t)};this._events.add(i,"click",o),Bc(this._events,i,[" ","Spacebar","Enter"],o),this._popupInited=!0}else t.parent&&!n.popup&&this.show()}}},{key:"openHandler",value:function(t){if(this.show()){t&&t.preventDefault(),this.settings.parent.style.pointerEvents="none";var e=t&&"keydown"===t.type?this._domEdit:this.domElement;setTimeout((function(){return e.focus()}),100),this.onOpen&&this.onOpen(this.colour)}}},{key:"closeHandler",value:function(t){var e=t&&t.type,n=!1;if(t)if("mousedown"===e||"focusin"===e){var r=(this.__containedEvent||0)+100;t.timeStamp>r&&(n=!0)}else Dc(t),n=!0;else n=!0;n&&this.hide()&&(this.settings.parent.style.pointerEvents="","mousedown"!==e&&this.settings.parent.focus(),this.onClose&&this.onClose(this.colour))}},{key:"movePopup",value:function(t,e){this.closeHandler(),this.setOptions(t),e&&this.openHandler()}},{key:"setColor",value:function(t,e){this._setColor(t,{silent:e})}},{key:"_setColor",value:function(t,e){if("string"==typeof t&&(t=t.trim()),t){e=e||{};var n=void 0;try{n=new Nc(t)}catch(t){if(e.failSilently)return;throw t}if(!this.settings.alpha){var r=n.hsla;r[3]=1,n.hsla=r}this.colour=this.color=n,this._setHSLA(null,null,null,null,e)}}},{key:"setColour",value:function(t,e){this.setColor(t,e)}},{key:"show",value:function(){if(!this.settings.parent)return!1;if(this.domElement){var t=this._toggleDOM(!0);return this._setPosition(),t}var e=function(t){var e=document.createElement("div");return e.innerHTML=t,e.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=e,this._domH=Fc(".picker_hue",e),this._domSL=Fc(".picker_sl",e),this._domA=Fc(".picker_alpha",e),this._domEdit=Fc(".picker_editor input",e),this._domSample=Fc(".picker_sample",e),this._domOkay=Fc(".picker_done button",e),this._domCancel=Fc(".picker_cancel button",e),e.classList.add("layout_"+this.settings.layout),this.settings.alpha||e.classList.add("no_alpha"),this.settings.editor||e.classList.add("no_editor"),this.settings.cancelButton||e.classList.add("no_cancel"),this._ifPopup((function(){return e.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 t=this,e=this,n=this.domElement,r=this._events;function i(t,e,n){r.add(t,e,n)}i(n,"click",(function(t){return t.preventDefault()})),Oc(r,this._domH,(function(t,n){return e._setHSLA(t)})),Oc(r,this._domSL,(function(t,n){return e._setHSLA(null,t,1-n)})),this.settings.alpha&&Oc(r,this._domA,(function(t,n){return e._setHSLA(null,null,null,1-n)}));var o=this._domEdit;i(o,"input",(function(t){e._setColor(this.value,{fromEditor:!0,failSilently:!0})})),i(o,"focus",(function(t){var e=this;e.selectionStart===e.selectionEnd&&e.select()})),this._ifPopup((function(){var e=function(e){return t.closeHandler(e)};i(window,"mousedown",e),i(window,"focusin",e),Bc(r,n,["Esc","Escape"],e);var o=function(e){t.__containedEvent=e.timeStamp};i(n,"mousedown",o),i(n,"focusin",o),i(t._domCancel,"click",e)}));var s=function(e){t._ifPopup((function(){return t.closeHandler(e)})),t.onDone&&t.onDone(t.colour)};i(this._domOkay,"click",s),Bc(r,n,["Enter"],s)}},{key:"_setPosition",value:function(){var t=this.settings.parent,e=this.domElement;t!==e.parentNode&&t.appendChild(e),this._ifPopup((function(n){"static"===getComputedStyle(t).position&&(t.style.position="relative");var r=!0===n?"popup_right":"popup_"+n;["popup_top","popup_bottom","popup_left","popup_right"].forEach((function(t){t===r?e.classList.add(t):e.classList.remove(t)})),e.classList.add(r)}))}},{key:"_setHSLA",value:function(t,e,n,r,i){i=i||{};var o=this.colour,s=o.hsla;[t,e,n,r].forEach((function(t,e){(t||0===t)&&(s[e]=t)})),o.hsla=s,this._updateUI(i),this.onChange&&!i.silent&&this.onChange(o)}},{key:"_updateUI",value:function(t){if(this.domElement){t=t||{};var e=this.colour,n=e.hsla,r="hsl("+360*n[0]+", 100%, 50%)",i=e.hslString,o=e.hslaString,s=this._domH,a=this._domSL,c=this._domA,l=Fc(".picker_selector",s),h=Fc(".picker_selector",a),u=Fc(".picker_selector",c);b(0,l,n[0]),this._domSL.style.backgroundColor=this._domH.style.color=r,b(0,h,n[1]),w(0,h,1-n[2]),a.style.color=i,w(0,u,1-n[3]);var f=i,d=f.replace("hsl","hsla").replace(")",", 0)"),p="linear-gradient("+[f,d]+")";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",!t.fromEditor){var g=this.settings.editorFormat,m=this.settings.alpha,v=void 0;switch(g){case"rgb":v=e.printRGB(m);break;case"hsl":v=e.printHSL(m);break;default:v=e.printHex(m)}this._domEdit.value=v}this._domSample.style.color=o}function b(t,e,n){e.style.left=100*n+"%"}function w(t,e,n){e.style.top=100*n+"%"}}},{key:"_ifPopup",value:function(t,e){this.settings.parent&&this.settings.popup?t&&t(this.settings.popup):e&&e()}},{key:"_toggleDOM",value:function(t){var e=this.domElement;if(!e)return!1;var n=t?"":"none",r=e.style.display!==n;return r&&(e.style.display=n),r}}]),t}(),Hc=document.createElement("style");function Vc(t){if(jc[t])return jc[t];if(jc["chr"+t]){const e=jc["chr"+t];return jc[t]=e,e}{const i=(e=Math.round(255*Math.random()).toString(10),n=Math.round(255*Math.random()).toString(10),r=Math.round(255*Math.random()).toString(10),"rgb("+e+","+n+","+r+")");return jc[t]=i,i}var e,n,r}Hc.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(Hc),zc.StyleElement=Hc;const jc={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 Uc{constructor(t){this.tracks=[],this.chordSets=[]}addChordSet(t){this.chordSets=this.chordSets.filter((e=>e.name!==t.name)),this.chordSets.push(t);let e=this.tracks.find((e=>t.trackName===e.name));e&&(e.chordSets=e.chordSets.filter((e=>e.name!==t.name)),e.chordSets.push(t)),e||(e=new qc(t),this.tracks.push(e))}clearChords(){this.tracks=[],this.chordSets=[]}getTrack(t){return this.tracks.find((e=>t===e.name))}getChordSet(t){return this.chordSets.find((e=>t===e.name))}}class qc{constructor(t){this.name=t.trackName,this.color=t.trackColor,this.visible=!0,this.chordSets=[t],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 t=[];for(let e of this.chordSets)for(let n of e.chords)t.push(n);return t}}const Wc=Math.exp(5);class $c{static isInstalled(){return void 0!==window.JBrowseReactCircularGenomeView&&void 0!==window.React&&void 0!==window.ReactDOM}constructor(t,e){if(e=e||{},this.config=e,$c.isInstalled()){this.parent=t,this.groupByTrack=!0===e.groupByTrack,this.chordManager=new Uc(e);const n=document.createElement("div");n.className="igv-circview-container",t.appendChild(n),this.createControls(n),this.resetControlPanel();const r=document.createElement("div");r.className="igv-circview-circular-genome-view",n.appendChild(r),this.container=r,e.assembly&&this.setAssembly(e.assembly),this.width=e.width||500,this.height=e.height||500,this.setSize(this.width,this.height)}else console.error("JBrowse circular view is not installed")}createControls(t){const e=document.createElement("div");e.className="igv-circview-toolbar",t.appendChild(e),this.toolbar=e;const n=document.createElement("div");n.className="igv-circview-track-panel",t.appendChild(n),this.controlPanel=n,this.controlPanel.style.display="none";const r=document.createElement("div");r.className="igv-circview-toolbar-button-container",this.toolbar.appendChild(r),this.showControlsButton=document.createElement("div"),this.showControlsButton.className="igv-circview-button",r.appendChild(this.showControlsButton),this.showControlsButton.innerText="none"===this.controlPanel.style.display?"Show Controls":"Hide Controls",this.showControlsButton.addEventListener("click",(t=>{this.controlPanel.querySelectorAll("div").length>0&&("none"===this.controlPanel.style.display?(this.controlPanel.style.display="flex",t.target.innerText="Hide Controls"):(this.controlPanel.style.display="none",t.target.innerText="Show Controls"))}));let i=document.createElement("div");i.className="igv-circview-button",r.appendChild(i),i.innerText="Clear All",i.addEventListener("click",(()=>{this.clearChords()})),!1!==this.config.showCloseButton&&(i=document.createElement("div"),i.className="igv-circview-button",r.appendChild(i),i.innerText="Close",i.addEventListener("click",(()=>{this.visible=!1})))}resetControlPanel(){this.controlPanel.innerHTML="",this.controlPanel.appendChild(this.createGroupByCB());const t=this.groupByTrack?this.chordManager.tracks:this.chordManager.chordSets;for(let e of t)this.addToControlPanel(e)}createGroupByCB(){const t=document.createElement("input");t.type="checkbox",t.id="groupByCB",t.style.width="1.4em",t.style.height="1.4em",t.checked=this.groupByTrack,t.onclick=t=>{this.groupByTrack=t.target.checked,this.resetControlPanel(),this.render()};const e=document.createElement("label");e.for="groupByCB",e.innerText="Group by track",e.style.color="black",e.style.paddingLeft="10px";const n=document.createElement("div");return n.style.width="100%",n.style.paddingTop="5px",n.style.paddingBottom="5px",n.style.background="rgb(216, 230, 234)",n.appendChild(t),n.appendChild(e),n}addToControlPanel(t){const e=document.createElement("div");this.controlPanel.appendChild(e);const n=document.createElement("div");n.className="igv-circview-button",e.appendChild(n),n.innerText=!0===t.visible?"Hide":"Show",n.addEventListener("click",(e=>{!0===t.visible?(this.hideChordSet(t.name),e.target.innerText="Show"):(this.showChordSet(t.name),e.target.innerText="Hide")}));const r=document.createElement("input"),i=t=>200*Math.log(t*Wc),o=document.createElement("div");o.className="igv-circview-button",o.innerHTML=" ",e.appendChild(o),o.style.backgroundColor=Gc(t.color,1);const s={parent:o,popup:"right",editorFormat:"rgb",color:t.color,onChange:({rgbaString:e})=>{o.style.backgroundColor=Gc(e,1),this.setColor(t.name,e),r.value=i(Zc(t.color))}},a=new zc(s);r.setAttribute("title","Adjust transparency of arcs"),r.type="range",r.style.width="100px",r.style.marginRight="10px",r.setAttribute("class","range"),r.setAttribute("min","0"),r.setAttribute("max","1000"),r.value=i(Zc(t.color)),r.oninput=()=>{const e=(n=r.value,Math.exp(n/200)/Wc);var n;this.setColor(t.name,Gc(t.color,e)),a.setColor(t.color)},e.appendChild(r);const c=document.createElement("div");c.style.color="black",e.appendChild(c),c.innerText=c.title=t.name}setAssembly(t){const e=this.genomeId||Kc();if(this.genomeId===e)return;this.chordManager.clearChords(),this.genomeId=e,this.chrNames=new Set(t.chromosomes.map((t=>Xc(t.name))));const n=[],r=[];for(let e of t.chromosomes){const t=Xc(e.name);r.push(e.color||Vc(t)),n.push({refName:t,uniqueId:t,start:0,end:e.bpLength})}this.assembly={name:t.name,sequence:{trackId:e,type:"ReferenceSequenceTrack",adapter:{type:"FromConfigSequenceAdapter",features:n}},refNameColors:r},this.render()}addChords(t,e={}){const n=e.name||e.track||"*",r=n.split(" ")[0].replaceAll("%20"," "),i={name:n.replaceAll("%20"," "),trackName:r,chords:t,color:e.color||"black",trackColor:e.trackColor||e.color||"black",visible:!0,id:e.id||Kc()};this.chordManager.addChordSet(i),this.resetControlPanel(),this.render()}setSize(t,e){if(e=e||t,this.width=t,this.height=e,this.viewState){const n=this.viewState.session.view;n.setWidth(t),n.setHeight(e),n.setBpPerPx(n.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(t){this.parent.style.display=t?"block":"none"}hideChordSet(t){let e=this.getChordSet(t);e?(e.visible=!1,this.render()):console.warn(`No track with name: ${name}`)}showChordSet(t){let e=this.getChordSet(t);e?(e.visible=!0,this.render()):console.warn(`No track with name: ${t}`)}deleteTrack(t){let e=this.tracks.findIndex((e=>t===e.name));e>=0&&this.tracks.splice(e,1),this.render()}getChordSet(t){return this.groupByTrack?this.chordManager.getTrack(t):this.chordManager.getChordSet(t)}setColor(t,e){const n=this.getChordSet(t);if(n){n.color=e;const t=n.id;for(let n of this.viewState.config.tracks)if(t===n.trackId){n.displays[0].renderer.strokeColor.set(e);break}}}render(){const{createViewState:t,JBrowseCircularGenomeView:e}=JBrowseReactCircularGenomeView;ReactDOM.unmountComponentAtNode(this.container);const n=(this.groupByTrack?this.chordManager.tracks:this.chordManager.chordSets).filter((t=>t.visible)),r=[],i=[];for(let t of n)r.push({trackId:t.id,name:t.name,assemblyNames:["forIGV"],type:"VariantTrack",adapter:{type:"FromConfigAdapter",features:t.chords}}),i.push(t.color);this.viewState=t({assembly:this.assembly,tracks:r});for(let t=0;t<n.length;t++)this.viewState.config.tracks[t].displays[0].renderer.strokeColor.set(i[t]);this.element=React.createElement(e,{viewState:this.viewState}),this.setSize(this.width,this.height),ReactDOM.render(this.element,this.container);const o=this.config.onChordClick||Yc;for(let t=0;t<n.length;t++)this.viewState.session.view.showTrack(this.viewState.config.tracks[t].trackId),o&&(this.viewState.pluginManager.jexl.addFunction("onChordClick",o),this.viewState.config.tracks[t].displays[0].onChordClick.set("jexl:onChordClick(feature, track, pluginManager)"))}}function Gc(t,e){const[n,r,i,o]=t.split(",");return`${n},${r},${i},${e})`}function Zc(t){return t.startsWith("rgba(")?Number(t.split(",")[3].replace(")","")):1}function Xc(t){return t.startsWith("chr")?t.substring(3):t}function Yc(t,e,n){console.log(t)}function Kc(){return("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)}if("undefined"!=typeof document){function as(t){for(let e of document.styleSheets)if(e=e.href?e.href.replace(/^.*[\\\/]/,""):"",e===t)return!0;return!1}as("circular-view.css")||function(){const t=document.createElement("style");t.setAttribute("type","text/css"),t.innerHTML='.igv-circview-container {\n z-index: 2048;\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(t,document.head.childNodes[document.head.childNodes.length-1])}()}const Qc=t=>t.startsWith("chr")?t.substring(3):t;function Jc(t){const e=[],n=[];for(let r of t.wgChromosomeNames){const i=t.getChromosome(r);n.push(ll(i.name)),e.push({name:i.name,bpLength:i.bpLength})}return e}function tl(t,e,n,r){const i=no.addAlpha("all"===n.chr?e.color:ll(n.chr),r),o=no.addAlpha(e.color||"rgb(0,0,255)",r),s=e.name.replaceAll(" ","%20"),a="all"===n.chr?s:`${s} ${n.chr}:${n.start}-${n.end}`;e.browser.circularView.addChords(t,{track:a,color:i,trackColor:o}),e.browser.circularViewVisible||(e.browser.circularViewVisible=!0)}class el{constructor(t,{minTLENPercentile:e,maxTLENPercentile:n}){this.totalCount=0,this.frCount=0,this.rfCount=0,this.ffCount=0,this.sumF=0,this.sumF2=0,this.lp=void 0===e?.1:e,this.up=void 0===n?99.5:n,this.isizes=[],this.compute(t)}compute(t){for(let r of t)if(r.isProperPair()){var e=Math.abs(r.fragmentLength);this.sumF+=e,this.sumF2+=e*e,this.isizes.push(e);var n=r.pairOrientation;if("string"==typeof n&&4===n.length)switch(""+n.charAt(0)+n.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:nl(this.isizes,this.lp),this.maxTLEN=nl(this.isizes,this.up)}}function nl(t,e){if(0!==t.length){var n=Math.floor(t.length*(e/100));return t.sort((function(t,e){return t-e})),t[n]}}class rl extends bc{constructor(t,e){super(t,e)}init(t){super.init(t),this.type="alignment",void 0===t.alleleFreqThreshold&&(t.alleleFreqThreshold=.2),this.featureSource=new mc(t,this.browser),this.showCoverage=void 0===t.showCoverage||t.showCoverage,this.showAlignments=void 0===t.showAlignments||t.showAlignments,this.coverageTrack=new il(t,this),this.alignmentTrack=new ol(t,this),this.alignmentTrack.setTop(this.coverageTrack,this.showCoverage),this.visibilityWindow=t.visibilityWindow||3e4,this.viewAsPairs=t.viewAsPairs,this.pairsSupported=!1!==t.pairsSupported,this.showSoftClips=t.showSoftClips,this.showAllBases=t.showAllBases,this.showInsertions=!1!==t.showInsertions,this.showMismatches=!1!==t.showMismatches,this.color=t.color,this.coverageColor=t.coverageColor,t.sort&&(Array.isArray(t.sort)?this.assignSort(t.sort[0]):this.assignSort(t.sort)),this.height=void 0!==t.height?t.height:300}set height(t){this._height=t,this.coverageTrack&&this.showAlignments&&(this.alignmentTrack.height=this.showCoverage?t-this.coverageTrack.height:t)}get height(){return this._height}get minTemplateLength(){const t=void 0!==this.config.minTLEN?this.config.minTLEN:this.config.minFragmentLength;return void 0!==t?t:this._pairedEndStats?this._pairedEndStats.minTLEN:0}get maxTemplateLength(){const t=void 0!==this.config.maxTLEN?this.config.maxTLEN:this.config.maxFragmentLength;return void 0!==t?t:this._pairedEndStats?this._pairedEndStats.maxTLEN:1e3}sort(t){t=this.assignSort(t);for(let e of this.trackView.viewports)if(e.containsPosition(t.chr,t.position)){const n=e.cachedFeatures;n&&(sl(t,n),e.repaint())}}assignSort(t){if(t.locus){const e=function(t){const e=t.split(":"),n=e[1].split("-"),r={chr:e[0],start:Number.parseInt(n[0].replace(/,/g,""))-1};return n.length>1?r.end=Number.parseInt(n[1].replace(/,/g,"")):r.end=r.start+1,r}(t.locus);t.chr=e.chr,t.position=e.start}else t.position--;return t.direction="ASC"===t.direction||!0===t.direction,t.chr=this.browser.genome.getChromosomeName(t.chr),this.sortObject=t,this.sortObject}async getFeatures(t,e,n,r,i){const o=await this.featureSource.getAlignments(t,e,n);if(o.paired&&!this._pairedEndStats&&!this.config.maxFragmentLength){const t=new el(o.alignments,this.config);t.totalCount>99&&(this._pairedEndStats=t)}o.alignments=void 0;const s=this.sortObject;return s&&s.chr===t&&s.position>=e&&s.position<=n&&sl(s,o),o}computePixelHeight(t){return(this.showCoverage?this.coverageTrack.height:0)+(this.showAlignments?this.alignmentTrack.computePixelHeight(t):0)+15}draw(t){ls.fillRect(t.context,0,t.pixelTop,t.pixelWidth,t.pixelHeight,{fillStyle:"rgb(255, 255, 255)"}),!0===this.showCoverage&&this.coverageTrack.height>0?(this.trackView.axisCanvas.style.display="block",this.coverageTrack.draw(t)):this.trackView.axisCanvas.style.display="none",!0===this.showAlignments&&(this.alignmentTrack.setTop(this.coverageTrack,this.showCoverage),this.alignmentTrack.draw(t))}paintAxis(t,e,n){this.coverageTrack.paintAxis(t,e,this.coverageTrack.height)}contextMenuItemList(t){return this.alignmentTrack.contextMenuItemList(t)}popupData(t){return!0===this.showCoverage&&t.y>=this.coverageTrack.top&&t.y<this.coverageTrack.height?this.coverageTrack.popupData(t):this.alignmentTrack.popupData(t)}clickedFeatures(t){return!0===this.showCoverage&&t.y>=this.coverageTrack.top&&t.y<this.coverageTrack.height?[this.coverageTrack.getClickedObject(t)]:[this.alignmentTrack.getClickedObject(t)]}menuItemList(){let t=[];t=t.concat(Oo.numericDataMenuItems(this.trackView)),t.push("<hr/>");const e=de('<div class="igv-track-menu-category">');e.text("Color by:"),t.push({name:void 0,object:e,click:void 0,init:void 0});const n=[{key:"strand",label:"read strand"}];this.alignmentTrack.hasPairs&&(n.push({key:"firstOfPairStrand",label:"first-of-pair strand"}),n.push({key:"pairOrientation",label:"pair orientation"}),n.push({key:"tlen",label:"insert size (TLEN)"}),n.push({key:"unexpectedPair",label:"pair orientation & insert size (TLEN)"}));const r="tag"+(this.alignmentTrack.colorByTag?" ("+this.alignmentTrack.colorByTag+")":"");n.push({key:"tag",label:r});for(let e of n){const n=this.alignmentTrack.colorBy===e.key;t.push(this.colorByCB(e,n))}const i=()=>{if(!this.autoHeight){const t=15+(this.showCoverage?this.coverageTrack.height:0)+(this.showAlignments?this.alignmentTrack.height:0);this.trackView.setTrackHeight(t)}};t.push("<hr/>"),t.push({object:de(Po("Show Coverage",this.showCoverage)),click:()=>{this.showCoverage=!this.showCoverage,i(),this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),t.push({object:de(Po("Show Alignments",this.showAlignments)),click:()=>{this.showAlignments=!this.showAlignments,i(),this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),t.push("<hr/>"),t.push({object:de(Po("Show all bases",this.showAllBases)),click:()=>{this.showAllBases=!this.showAllBases,this.config.showAllBases=this.showAllBases,this.trackView.repaintViews()}}),t.push("<hr/>"),t.push({object:de(Po("Show mismatches",this.showMismatches)),click:()=>{this.showMismatches=!this.showMismatches,this.config.showMismatches=this.showMismatches,this.trackView.repaintViews()}}),t.push({object:de(Po("Show insertions",this.showInsertions)),click:()=>{this.showInsertions=!this.showInsertions,this.config.showInsertions=this.showInsertions,this.getCachedAlignmentContainers(),this.trackView.repaintViews()}}),t.push({object:de(Po("Show soft clips",this.showSoftClips)),click:()=>{this.showSoftClips=!this.showSoftClips,this.config.showSoftClips=this.showSoftClips,this.featureSource.setShowSoftClips(this.showSoftClips);const t=this.getCachedAlignmentContainers();for(let e of t)e.setShowSoftClips(this.showSoftClips);this.trackView.repaintViews()}}),this.pairsSupported&&this.alignmentTrack.hasPairs&&(t.push("<hr/>"),t.push({object:de(Po("View as pairs",this.viewAsPairs)),click:()=>{this.viewAsPairs=!this.viewAsPairs,this.config.viewAsPairs=this.viewAsPairs,this.featureSource.setViewAsPairs(this.viewAsPairs);const t=this.getCachedAlignmentContainers();for(let e of t)e.setViewAsPairs(this.viewAsPairs);this.trackView.repaintViews()}})),this.browser.circularView&&(this.alignmentTrack.hasPairs||this.alignmentTrack.hasSupplemental)&&(t.push("<hr/>"),this.alignmentTrack.hasPairs&&t.push({label:"Add discordant pairs to circular view",click:()=>{for(let t of this.trackView.viewports)this.addPairedChordsForViewport(t)}}),this.alignmentTrack.hasSupplemental&&t.push({label:"Add split reads to circular view",click:()=>{for(let t of this.trackView.viewports)this.addSplitChordsForViewport(t)}})),t.push("<hr/>");const o=de('<div class="igv-track-menu-category">');return o.text("Display mode:"),t.push({name:void 0,object:o,click:void 0,init:void 0}),t.push({object:de(Po("expand","EXPANDED"===this.alignmentTrack.displayMode)),click:()=>{this.alignmentTrack.displayMode="EXPANDED",this.config.displayMode="EXPANDED",this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),t.push({object:de(Po("squish","SQUISHED"===this.alignmentTrack.displayMode)),click:()=>{this.alignmentTrack.displayMode="SQUISHED",this.config.displayMode="SQUISHED",this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),t}colorByCB(t,e){return{name:void 0,object:de(Po(t.label,e)),click:e=>{"tag"!==t.key?t.key===this.alignmentTrack.colorBy?(this.alignmentTrack.colorBy="none",this.config.colorBy="none",this.trackView.repaintViews()):(this.alignmentTrack.colorBy=t.key,this.config.colorBy=t.key,this.trackView.repaintViews()):this.browser.inputDialog.present({label:"Tag Name",value:this.alignmentTrack.colorByTag?this.alignmentTrack.colorByTag:"",callback:t=>{t?(this.alignmentTrack.colorBy="tag",this.alignmentTrack.colorByTag=t,this.alignmentTrack.tagColors||(this.alignmentTrack.tagColors=new _c("Set1"))):(this.alignmentTrack.colorBy="none",this.alignmentTrack.colorByTag=""),this.trackView.repaintViews()}},e)},init:void 0}}dispose(){this.trackView=void 0}getState(){const t=super.getState();return this.sortObject&&(t.sort={chr:this.sortObject.chr,position:this.sortObject.position+1,option:this.sortObject.option,direction:this.sortObject.direction?"ASC":"DESC"}),t}getCachedAlignmentContainers(){return this.trackView.viewports.map((t=>t.cachedFeatures))}get dataRange(){return this.coverageTrack.dataRange}set dataRange(t){this.coverageTrack.dataRange=t}get logScale(){return this.coverageTrack.logScale}set logScale(t){this.coverageTrack.logScale=t}get autoscale(){return this.coverageTrack.autoscale}set autoscale(t){this.coverageTrack.autoscale=t}addPairedChordsForViewport(t){const e=this.maxTemplateLength,n=[],r=t.referenceFrame;for(let i of t.cachedFeatures.allAlignments())i.end>=r.start&&i.start<=r.end&&(i.paired?i.end-i.start>e&&n.push(i):i.mate&&i.mate.chr&&(i.mate.chr!==i.chr||Math.max(i.fragmentLength)>e)&&n.push(i));tl((t=>{const e=[];for(let n of t)if(n.paired)n.firstAlignment&&n.secondAlignment&&e.push({uniqueId:n.readName,refName:Qc(n.firstAlignment.chr),start:n.firstAlignment.start,end:n.firstAlignment.end,mate:{refName:Qc(n.secondAlignment.chr),start:n.secondAlignment.start,end:n.secondAlignment.end}});else{const t=n.mate;t&&t.chr&&t.position&&e.push({uniqueId:n.readName,refName:Qc(n.chr),start:n.start,end:n.end,mate:{refName:Qc(t.chr),start:t.position-1,end:t.position}})}return e})(n),this,r,.02)}addSplitChordsForViewport(t){const e=[],n=t.referenceFrame;for(let r of t.cachedFeatures.allAlignments()){const t=r.hasTag("SA");r.end>=n.start&&r.start<=n.end&&t&&e.push(r)}tl((t=>{const e=t=>{const e=Sa(t.tags().SA);let r=0;for(let i of e)i.start!==t.start&&n.push({uniqueId:`${t.readName}_${r++}`,refName:Qc(t.chr),start:t.start,end:t.end,mate:{refName:Qc(i.chr),start:i.start,end:i.start+i.lenOnRef}})},n=[];for(let n of t)n.paired?(e(n.firstAlignment),n.secondAlignment&&e(n.secondAlignment)):e(n);return n})(e),this,n,.02)}}class il{constructor(t,e){this.parent=e,this.featureSource=e.featureSource,this.height=void 0!==t.coverageTrackHeight?t.coverageTrackHeight:50,this.paintAxis=yc,this.top=0,this.autoscale=t.autoscale||void 0===t.max,this.autoscale||(this.dataRange={min:t.min||0,max:t.max})}draw(t){const e=t.pixelTop;t.pixelHeight;const n=this.parent.browser.nucleotideColors;if(e>this.height)return;const r=t.context,i=t.features.coverageMap;let o;i.refSeq&&(o=i.refSeq.toUpperCase());const s=t.bpPerPixel,a=t.bpStart,c=a+t.pixelWidth*s+1;let l;l=this.parent.coverageColor?this.parent.coverageColor:void 0!==this.parent.color?no.darkenLighten(this.parent.color,-35):"rgb(150, 150, 150)",ls.setProperties(r,{fillStyle:l,strokeStyle:l});const h=Math.max(1,Math.ceil(1/s));for(let t=0,e=i.coverage.length;t<e;t++){const e=i.bpStart+t;if(e<a)continue;if(e>c)break;const n=i.coverage[t];if(!n)continue;const o=Math.round(n.total/this.dataRange.max*this.height),l=this.height-o,u=Math.floor((e-a)/s);ls.fillRect(r,u,l,h,o)}if(o)for(let t=0,e=i.coverage.length;t<e;t++){const e=i.bpStart+t;if(e<a)continue;if(e>c)break;const l=i.coverage[t];if(!l)continue;const u=l.total/this.dataRange.max*this.height;let f=this.height-u;const d=Math.floor((e-a)/s),p=o[t];if(l.isMismatch(p)){ls.setProperties(r,{fillStyle:n[p]}),ls.fillRect(r,d,f,h,u);let t=0;for(let e of["A","C","T","G"]){const i=(l["pos"+e]+l["neg"+e])/this.dataRange.max*this.height;f=this.height-i-t,t+=i,ls.setProperties(r,{fillStyle:n[e]}),ls.fillRect(r,d,f,h,i)}}}}getClickedObject(t){let e=t.viewport.cachedFeatures;if(!e||0===e.length)return;const n=Math.floor(t.genomicLocation),r=e.coverageMap,i=Math.floor(n-r.bpStart);return r.coverage[i]}popupData(t){const e=[],n=this.getClickedObject(t);if(n){const r=Math.floor(t.genomicLocation),i=t.viewport.referenceFrame;e.push(i.chr+":"+_e(1+r)),e.push({name:"Total Count",value:n.total});let o=n.posA+n.negA;o>0&&(o=o.toString()+" ("+Math.round(o/n.total*100)+"%, "+n.posA+"+, "+n.negA+"- )"),e.push({name:"A",value:o}),o=n.posC+n.negC,o>0&&(o=o.toString()+" ("+Math.round(o/n.total*100)+"%, "+n.posC+"+, "+n.negC+"- )"),e.push({name:"C",value:o}),o=n.posG+n.negG,o>0&&(o=o.toString()+" ("+Math.round(o/n.total*100)+"%, "+n.posG+"+, "+n.negG+"- )"),e.push({name:"G",value:o}),o=n.posT+n.negT,o>0&&(o=o.toString()+" ("+Math.round(o/n.total*100)+"%, "+n.posT+"+, "+n.negT+"- )"),e.push({name:"T",value:o}),o=n.posN+n.negN,o>0&&(o=o.toString()+" ("+Math.round(o/n.total*100)+"%, "+n.posN+"+, "+n.negN+"- )"),e.push({name:"N",value:o}),e.push("<HR/>"),e.push({name:"DEL",value:n.del.toString()}),e.push({name:"INS",value:n.ins.toString()})}return e}}class ol{constructor(t,e){this.parent=e,this.browser=e.browser,this.featureSource=e.featureSource,this.top=0===t.coverageTrackHeight?0:t.coverageTrackHeight+5,this.displayMode=t.displayMode||"EXPANDED",this.alignmentRowHeight=t.alignmentRowHeight||14,this.squishedRowHeight=t.squishedRowHeight||3,this.negStrandColor=t.negStrandColor||"rgba(150, 150, 230, 0.75)",this.posStrandColor=t.posStrandColor||"rgba(230, 150, 150, 0.75)",this.insertionColor=t.insertionColor||"rgb(138, 94, 161)",this.deletionColor=t.deletionColor||"black",this.skippedColor=t.skippedColor||"rgb(150, 170, 170)",this.pairConnectorColor=t.pairConnectorColor,this.smallTLENColor=t.smallTLENColor||t.smallFragmentLengthColor||"rgb(0, 0, 150)",this.largeTLENColor=t.largeTLENColor||t.largeFragmentLengthColor||"rgb(200, 0, 0)",this.pairOrientation=t.pairOrienation||"fr",this.pairColors={},this.pairColors.RL=t.rlColor||"rgb(0, 150, 0)",this.pairColors.RR=t.rrColor||"rgb(20, 50, 200)",this.pairColors.LL=t.llColor||"rgb(0, 150, 150)",this.colorBy=t.colorBy||"unexpectedPair",this.colorByTag=t.colorByTag?t.colorByTag.toUpperCase():void 0,this.bamColorTag=void 0===t.bamColorTag?"YC":t.bamColorTag,this.hideSmallIndels=t.hideSmallIndels,this.indelSizeThreshold=t.indelSizeThreshold||1,this.hasPairs=!1,this.hasSupplemental=!1}setTop(t,e){this.top=0===t.height||!1===e?0:5+t.height}computePixelHeight(t){if(t.packedAlignmentRows){return(t.hasDownsampledIntervals()?10:0)+("SQUISHED"===this.displayMode?this.squishedRowHeight:this.alignmentRowHeight)*t.packedAlignmentRows.length+5}return 0}draw(t){const e=t.features,n=t.context,r=t.bpPerPixel,i=t.bpStart,o=t.pixelWidth,s=i+o*r+1,a=this.parent.showSoftClips,c=this.parent.showAllBases,l=this.browser.nucleotideColors,h=e.packedAlignmentRows;n.save();let u=e.sequence;u&&(u=u.toUpperCase());let f=0,d=t.pixelTop;this.top&&n.translate(0,this.top);const p=d+t.pixelHeight;e.hasDownsampledIntervals()?(f=10,e.downsampledIntervals.forEach((function(t){var e=(t.start-i)/r,o=(t.end-i)/r;o-e>5&&(e+=1,o-=1),ls.fillRect(n,e,2,o-e,3,{fillStyle:"black"})}))):f=0,this.alignmentsYOffset=f;const g="SQUISHED"===this.displayMode?this.squishedRowHeight:this.alignmentRowHeight;if(h){const t=h.length;for(let e=0;e<t;e++){const t=h[e],n=f+g*e,r=g<=4?g:g-2;if(n>p)break;if(!(n+r<d))for(let e of t.alignments)if(this.hasPairs=this.hasPairs||e.isPaired(),this.browser.circularView&&(this.hasSupplemental=this.hasSupplemental||e.hasTag("SA")),!(e.start+e.lengthOnRef<i)){if(e.start>s)break;!0!==e.hidden&&(e instanceof ua?(m.call(this,e,n,r),v.call(this,e.firstAlignment,n,r),e.secondAlignment&&v.call(this,e.secondAlignment,n,r)):v.call(this,e,n,r))}}}function m(t,e,o){var a=this.getConnectorColor(t.firstAlignment),c=(t.connectingStart-i)/r,l=(t.connectingEnd-i)/r,h=e+o/2;t.connectingEnd<i||t.connectingStart>s||(t.mq<=0&&(a=no.addAlpha(a,.15)),ls.setProperties(n,{fillStyle:a,strokeStyle:a}),ls.strokeLine(n,c,h,l,h))}function v(t,o,h){if(t.start+t.lengthOnRef<i||t.start>s)return;const f=a?t.blocks:t.blocks.filter((t=>"S"!==t.type));let d=this.getAlignmentColor(t);const p=d;t.mq<=0&&(d=no.addAlpha(d,.15)),ls.setProperties(n,{fillStyle:d,strokeStyle:p});for(let t=0;t<f.length;t++){const e=f[t];if(!(t!==f.length-1&&f[t+1].start<i)&&(m.call(this,e,t),e.start+e.len>s))break}if(t.insertions&&this.parent.showInsertions){let e=-1;for(let a of t.insertions){if(this.hideSmallIndels&&a.len<=this.indelSizeThreshold)continue;if(a.start<i)continue;if(a.start>s)break;const t=(a.start-i)/r-1;if(t-e>2){const r=3;ls.fillRect(n,t,o-1,r,h+2,{fillStyle:this.insertionColor}),e=t}}}if(t.gaps){const e=o+h/2;for(let o of t.gaps){const t=(o.start-i)/r,s=(o.start+o.len-i)/r,a="D"===o.type?this.deletionColor:this.skippedColor;ls.strokeLine(n,t,e,s,e,{strokeStyle:a})}}function m(s,a){const m=s.start-e.start,b=(s.start-i)/r,w=(s.start+s.len-i)/r,y=Math.max(1,w-b),x=100/r,k=Math.min(g/2,x/6),_="S"===s.type,S=t.mq<=0||this.highlightedAlignmentReadNamed===t.readName||_;let C=p;this.highlightedAlignmentReadNamed===t.readName?C="red":_&&(C="rgb(50,50,50)");const E=!0===t.strand&&a===f.length-1,A=!1===t.strand&&0===a;if(E|A){let t,e;E?(t=[b,w,w+k,w,b,b],e=[o,o,o+h/2,o+h,o+h,o]):A&&(t=[w,b,b-k,b,w,w],e=[o,o,o+h/2,o+h,o+h,o]),ls.fillPolygon(n,t,e,{fillStyle:d}),S&&ls.strokePolygon(n,t,e,{strokeStyle:C})}else ls.fillRect(n,b,o,y,h,{fillStyle:d}),S&&(n.save(),n.strokeStyle=C,n.strokeRect(b,o,y,h),n.restore());if(_||c||this.parent.showMismatches&&u&&t.seq&&"*"!==t.seq){const e=t.seq?t.seq.toUpperCase():void 0,a=t.qual,f=s.seqOffset;for(let t=0,d=s.len;t<d;t++){if(m+t<0)continue;let d=e?e.charAt(f+t):"";const p=u.charAt(m+t);if("="===d&&(d=p),"X"===d||p!==d||_||c){let e;if(!_&&void 0!==a&&a.length>f+t){e=al(a[f+t],l[d])}else e=l[d];if(e){const a=(s.start+t-i)/r,c=Math.max(1,1/r);v(n,r,{x:a,y:o,width:c,height:h},e,d)}}}}}function v(t,e,n,r,i){var o;if(.1,e<=.1&&n.height>=8){const e=Math.min(10,n.height);t.font=e+"px sans-serif",o=n.x+n.width/2,ls.strokeText(t,i,o-t.measureText(i).width/2,e-1+n.y,{strokeStyle:r})}else ls.fillRect(t,n.x,n.y,n.width,n.height,{fillStyle:r})}}n.restore()}popupData(t){const e=this.getClickedObject(t);return e?e.popupData(t.genomicLocation):void 0}contextMenuItemList(t){const e=t.viewport,n=[],r=n=>{const r=this.parent.sortObject,i=!r||r.position!==Math.floor(t.genomicLocation)||!r.direction,o={chr:e.referenceFrame.chr,position:Math.floor(t.genomicLocation),option:n,direction:i};this.parent.sortObject=o,sl(o,e.cachedFeatures),e.repaint()};n.push("<b>Sort by...</b>"),n.push({label:" base",click:()=>r("BASE")}),n.push({label:" read strand",click:()=>r("STRAND")}),n.push({label:" insert size",click:()=>r("INSERT_SIZE")}),n.push({label:" gap size",click:()=>r("GAP_SIZE")}),n.push({label:" chromosome of mate",click:()=>r("MATE_CHR")}),n.push({label:" mapping quality",click:()=>r("MQ")}),n.push({label:" read name",click:()=>r("READ_NAME")}),n.push({label:" tag",click:()=>{const n=this.parent.sortObject,r=!n||n.position!==Math.floor(t.genomicLocation)||!n.direction,i={label:"Tag Name",value:this.sortByTag?this.sortByTag:"",callback:n=>{if(n){const i={chr:e.referenceFrame.chr,position:Math.floor(t.genomicLocation),option:"TAG",tag:n,direction:r};this.sortByTag=n,this.parent.sortObject=i,sl(i,e.cachedFeatures),e.repaint()}}};this.browser.inputDialog.present(i,t.event)}}),n.push("<hr/>");const i=this.getClickedObject(t);if(i){const e=this.parent.showSoftClips,r="function"==typeof i.alignmentContaining?i.alignmentContaining(t.genomicLocation,e):i;r&&(r.isPaired()&&r.isMateMapped()&&n.push({label:"View mate in split screen",click:()=>{if(r.mate){const e=t.viewport.referenceFrame;if(this.browser.genome.getChromosome(r.mate.chr)){this.highlightedAlignmentReadNamed=r.readName;const t=e.end-e.start,n=r.mate.position-t/2,i=r.mate.position+t/2;this.browser.addMultiLocusPanel(r.mate.chr,n,i,e)}else Qo.presentAlert(`Reference does not contain chromosome: ${r.mate.chr}`)}},init:void 0}),n.push({label:"View read sequence",click:()=>{const t=r.seq;t&&"*"!==t?Qo.presentAlert(t):Qo.presentAlert("Read sequence: *")}}),Ss()&&n.push({label:"Copy read sequence",click:async()=>{const t=r.seq;try{await navigator.clipboard.writeText(t)}catch(t){console.error(t),Qo.presentAlert(`error copying sequence to clipboard ${t}`)}}}),n.push("<hr/>"))}return this.browser.circularView&&(this.hasPairs||this.hasSupplemental)&&(this.hasPairs&&n.push({label:"Add discordant pairs to circular view",click:()=>{this.parent.addPairedChordsForViewport(e)}}),this.hasSupplemental&&n.push({label:"Add split reads to circular view",click:()=>{this.parent.addSplitChordsForViewport(e)}}),n.push("<hr/>")),n}getClickedObject(t){const e=t.viewport,n=t.y,r=t.genomicLocation,i=this.parent.showSoftClips;let o=e.cachedFeatures;if(!o||0===o.length)return;let s=o.packedAlignmentRows,a=o.downsampledIntervals;const c="SQUISHED"===this.displayMode?this.squishedRowHeight:this.alignmentRowHeight;let l=Math.floor((n-this.top-this.alignmentsYOffset)/c);if(l<0){for(let t=0;t<a.length;t++)if(a[t].start<=r&&a[t].end>=r)return a[t]}else if(l<s.length){const t=s[l].alignments.filter((t=>t.containsLocation(r,i)));if(t.length>0)return t[0]}}getConnectorColor(t){if(this.pairConnectorColor)return this.pairConnectorColor;switch(this.colorBy){case"strand":case"firstOfPairStrand":case"pairOrientation":case"tag":return this.parent.color||"rgb(200, 200, 200)";default:return this.getAlignmentColor(t)}}getAlignmentColor(t){let e=this.parent.color||"rgb(185, 185, 185)";const n=this.colorBy;switch(n){case"strand":e=t.strand?this.posStrandColor:this.negStrandColor;break;case"firstOfPairStrand":t instanceof ua?e=t.firstOfPairStrand()?this.posStrandColor:this.negStrandColor:t.isPaired()&&(t.isFirstOfPair()?e=t.strand?this.posStrandColor:this.negStrandColor:t.isSecondOfPair()?e=t.strand?this.negStrandColor:this.posStrandColor:console.error("ERROR. Paired alignments are either first or second."));break;case"unexpectedPair":case"pairOrientation":if(this.pairOrientation&&t.pairOrientation){const n=cl[this.pairOrientation];if(n){const r=this.pairColors[n[t.pairOrientation]];if(r){e=r;break}}}if("pairOrientation"===n)break;case"tlen":case"fragmentLength":t.mate&&t.isMateMapped()&&(t.mate.chr!==t.chr?e=ll(t.mate.chr):this.parent.minTemplateLength&&Math.abs(t.fragmentLength)<this.parent.minTemplateLength?e=this.smallTLENColor:this.parent.maxTemplateLength&&Math.abs(t.fragmentLength)>this.parent.maxTemplateLength&&(e=this.largeTLENColor));break;case"tag":const r=t.tags()[this.colorByTag];void 0!==r&&(this.bamColorTag===this.colorByTag?e="rgb("+r+")":(this.tagColors||(this.tagColors=new _c("Set1")),e=this.tagColors.getColor(r)));break;default:e=this.parent.color||"rgb(185, 185, 185)"}return e}}function sl(t,e){const n=t.direction;for(let n of e.packedAlignmentRows)n.updateScore(t,e);e.packedAlignmentRows.sort((function(t,e){const r=t.score>e.score?1:t.score<e.score?-1:0;return!0===n?r:-r}))}function al(t,e){let n;return n=t<5?.1:Math.max(.1,Math.min(1,.1+.9*(t-5)/15)),n=Math.round(10*n)/10,n<1&&(e=no.addAlpha(e,n)),e}const cl={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 ll(t){if(hl[t])return hl[t];if(hl["chr"+t]){const e=hl["chr"+t];return hl[t]=e,e}{const e=no.randomRGB(0,255);return hl[t]=e,e}}const hl={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 ul,fl;class dl extends sa{constructor(t,e,n,r){super(t,e,n,r)}initializationHelper(){this.rulerSweeper=new la(this),this.$multiLocusCloseButton=de("<div>",{class:"igv-multi-locus-close-button"}),this.$viewport.append(this.$multiLocusCloseButton),this.$multiLocusCloseButton.get(0).appendChild(we("times-circle")),this.$multiLocusCloseButton.click((()=>{this.browser.removeMultiLocusPanel(this.referenceFrame)})),this.$rulerLabel=de("<div>",{class:"igv-multi-locus-ruler-label"}),this.$viewport.append(this.$rulerLabel),this.$rulerLabel.click((async()=>{await this.browser.gotoMultilocusPanel(this.referenceFrame)})),this.$tooltip=de("<div>",{class:"igv-ruler-tooltip"}),this.$tooltip.height(this.$viewport.height()),this.$viewport.append(this.$tooltip),this.$tooltipContent=de("<div>"),this.$tooltip.append(this.$tooltipContent),this.attachMouseHandlers(na.isWholeGenomeView(this.referenceFrame.chr)),this.$tooltip.hide(),this.dismissLocusLabel()}presentLocusLabel(t){this.$rulerLabel.get(0).innerHTML="",this.$rulerLabel.get(0).style.backgroundColor=ll(this.referenceFrame.chr),this.$rulerLabel.get(0).appendChild((()=>{const e=`<div>${this.referenceFrame.getMultiLocusLabel(t)}</div>`;return document.createRange().createContextualFragment(e).firstChild})()),this.$rulerLabel.show(),this.$multiLocusCloseButton.show()}presentLocusLabel_Square_Dot(t){this.$rulerLabel.get(0).innerHTML="",this.$rulerLabel.get(0).appendChild((()=>{const t=`<div>\n <?xml version="1.0" encoding="UTF-8"?>\n <svg width="14px" height="14px" viewBox="0 0 89 89" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">\n <g>\n <circle id="Oval" fill="${ll(this.referenceFrame.chr)}" cx="44.5" cy="44.5" r="44.5"></circle>\n </g>\n </svg>\n </div>`;return document.createRange().createContextualFragment(t).firstChild})()),this.$rulerLabel.get(0).appendChild((()=>{const e=`<div>${this.referenceFrame.getMultiLocusLabel(t)}</div>`;return document.createRange().createContextualFragment(e).firstChild})()),this.$rulerLabel.show(),this.$multiLocusCloseButton.show()}dismissLocusLabel(){this.$rulerLabel.hide(),this.$multiLocusCloseButton.hide()}attachMouseHandlers(t){if(this.namespace=`.ruler_track_viewport_${this.browser.referenceFrameList.indexOf(this.referenceFrame)}`,this.$viewport.off(this.namespace),!0===t){const t=this.browser.referenceFrameList.indexOf(this.referenceFrame),e=`click${this.namespace}`;this.$viewport.on(e,(e=>{const{x:n}=be(e,this.$viewport.get(0)),r=Math.round(this.referenceFrame.start+this.referenceFrame.toBP(n));let i;const{chr:o}=this.browser.genome.getChromosomeCoordinate(r);if(1===this.browser.referenceFrameList.length)i=o;else{let e=this.browser.referenceFrameList.map((({locusSearchString:t})=>t));e[t]=o,i=e.join(" ")}this.browser.search(i)})),this.$viewport.get(0).style.cursor="pointer"}else this.$viewport.get(0).style.cursor="default"}mouseMove(t){if(!0===this.browser.cursorGuideVisible){void 0===fl?(fl=this,this.$tooltip.show()):fl.guid!==this.guid?(fl.$tooltip&&fl.$tooltip.hide(),this.$tooltip.show(),fl=this):this.$tooltip.show();if(this.browser.isMultiLocusWholeGenomeView()||na.isWholeGenomeView(this.referenceFrame.chr))return void this.$tooltip.hide();const{x:e}=be(t,this.$viewport.get(0)),{start:n,bpPerPixel:r}=this.referenceFrame,i=Math.round(.5+n+Math.max(0,e)*r);this.$tooltipContent.text(_e(i));const{width:o}=this.$tooltipContent.get(0).getBoundingClientRect(),{width:s}=this.$viewport.get(0).getBoundingClientRect();this.$tooltip.css({left:`${Qi(e,0,s-o)}px`}),clearTimeout(ul),ul=setTimeout((()=>{this.$tooltip&&this.$tooltip.hide()}),1e4)}}startSpinner(){}stopSpinner(){}dispose(){this.rulerSweeper.dispose(),super.dispose()}}class pl extends sa{constructor(t,e,n,r){super(t,e,n,r)}initializationHelper(){this.canvas=document.createElement("canvas"),this.canvas.className="igv-ideogram-canvas",this.$content.append(de(this.canvas)),this.ideogram_ctx=this.canvas.getContext("2d"),this.addMouseHandlers()}addMouseHandlers(){this.addViewportClickHandler(this.$viewport.get(0))}addViewportClickHandler(t){this.boundClickHandler=function(t){const{xNormalized:e,width:n}=be(t,this.ideogram_ctx.canvas),{bpLength:r}=this.browser.genome.getChromosome(this.referenceFrame.chr),i=this.referenceFrame.bpPerPixel*n/r;let o=e;o-i/2<0&&(o=i/2);o+i/2>1&&(o=1-i/2);const s=Math.round((o-i/2)*r),a=Math.round((o+i/2)*r);this.referenceFrame.start=s,this.referenceFrame.end=a,this.referenceFrame.bpPerPixel=(a-s)/n,this.browser.updateViews(this.referenceFrame,this.browser.trackViews,!0)}.bind(this),t.addEventListener("click",this.boundClickHandler)}setWidth(t){this.$viewport.width(t)}drawSVGWithContext(t,e,n,r,i,o,s){t.saveWithTranslationAndClipRect(r,i,o,e,n,s),this.trackView.track.draw({context:t,referenceFrame:this.referenceFrame,pixelWidth:e,pixelHeight:n}),t.restore()}repaint(){this.draw({referenceFrame:this.referenceFrame})}draw({referenceFrame:t}){ls.configureHighDPICanvas(this.ideogram_ctx,this.$viewport.width(),this.$viewport.height()),this.trackView.track.draw({context:this.ideogram_ctx,referenceFrame:t,pixelWidth:this.$viewport.width(),pixelHeight:this.$viewport.height()})}startSpinner(){}stopSpinner(){}}function gl(t,e,n,r){return"ruler"===t.track.type?new dl(t,e,n,r):"ideogram"===t.track.id?new pl(t,e,n,r):new sa(t,e,n,r)}const ml={textAlign:"start",textBaseline:"bottom",strokeStyle:"black",fillStyle:"black"};class vl{constructor(t,e,n,r){this.guid=ve(),this.trackView=t,this.browser=t.browser,this.viewport=pe({class:"igv-viewport"}),e.appendChild(this.viewport),t.track.height&&(this.viewport.style.height=`${t.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(r),!1===this.browser.showSampleNames&&this.hide(),this.addMouseHandlers()}checkCanvas(){const t=window.devicePixelRatio,e=this.viewport.clientHeight,n=this.browser.sampleNameViewportWidth;if(this.canvas.width!==n*t||this.canvas.height!==e*t){const r=this.canvas;r.width=n*t,r.height=e*t,r.style.width=`${n}px`,r.style.height=`${e}px`,this.ctx=this.canvas.getContext("2d"),this.ctx.scale(t,t)}}setTop(t){if("function"==typeof this.trackView.track.getSamples){this.contentTop=t;const e=this.trackView.track.getSamples();this.repaint(e)}}setWidth(t){this.viewport.innerWidth=t,this.checkCanvas()}show(){this.viewport.style.display="block"}hide(){this.viewport.style.display="none"}async repaint(t){this.checkCanvas(),this.draw({context:this.ctx,samples:t})}draw({context:t,samples:e}){if(!e||0===e.names.length)return;!function(t,{textAlign:e,textBaseline:n,strokeStyle:r,fillStyle:i},o){const s=Math.min(o,10);t.font=`${s}px sans-serif`,t.textAlign=e,t.textBaseline=n,t.fillStyle=i}(t,ml,e.height);t.clearRect(0,0,t.canvas.width,t.canvas.height),t.fillStyle=function(t){const{r:e,g:n,b:r}=xc[t];return`rgb(${e},${n},${r})`}("lead");const n=this.viewport.getBoundingClientRect().height;let r=(e.yOffset||0)+this.contentTop;for(let i of e.names){if(r>n)break;if(r+e.height>0){const n=i,o=bl(t,n,r,e.height);t.fillText(n,4,o)}r+=e.height}}renderSVGContext(t,{deltaX:e,deltaY:n}){if("function"==typeof this.trackView.track.getSamples){const r=this.trackView.track.getSamples(),i=0,{width:o,height:s}=this.viewport.getBoundingClientRect(),a=`${(this.trackView.track.name||this.trackView.track.id).replace(/\W/g,"")}_sample_names_guid_${ve()}`;t.saveWithTranslationAndClipRect(a,e,n+i,o,s,-i),this.draw({context:t,samples:r}),t.restore()}}addMouseHandlers(){this.addViewportContextMenuHandler(this.viewport)}removeMouseHandlers(){this.removeViewportContextMenuHandler(this.viewport)}addViewportContextMenuHandler(t){this.boundContextMenuHandler=function(t){t.preventDefault(),t.stopPropagation();const e={label:"Name Panel Width",value:this.browser.sampleNameViewportWidth,callback:t=>{this.browser.sampleNameViewportWidth=parseInt(t);for(let{sampleNameViewport:t}of this.browser.trackViews)t.setWidth(this.browser.sampleNameViewportWidth);this.browser.layoutChange()}};this.browser.inputDialog.present(e,t)}.bind(this),t.addEventListener("contextmenu",this.boundContextMenuHandler)}removeViewportContextMenuHandler(t){t.removeEventListener("contextmenu",this.boundContextMenuHandler)}dispose(){this.removeMouseHandlers(),this.viewport.remove()}}function bl(t,e,n,r){return n+r-function(t,e,n){const{actualBoundingBoxAscent:r,actualBoundingBoxDescent:i}=t.measureText(e);return(n-(r+i))/2}(t,e,r)}class wl extends es{constructor({parent:t,width:e}){super({parent:t,width:e,border:"1px solid gray"})}configure(t,e){this.colorHandlers=e,this.setActiveColorHandler("color"),this.createSwatches(t)}setActiveColorHandler(t){this.activeColorHandler=this.colorHandlers[t]}createSwatches(t){this.container.querySelectorAll(".igv-ui-color-swatch").forEach((t=>t.remove()));const e=Object.values(lo);for(let t of e){const e=pe({class:"igv-ui-color-swatch"});this.container.appendChild(e),this.decorateSwatch(e,t)}if(t)for(let e of t){const t=pe({class:"igv-ui-color-swatch"});this.container.appendChild(t),this.decorateSwatch(t,e)}}decorateSwatch(t,e){t.style.backgroundColor=e,t.addEventListener("mouseenter",(()=>t.style.borderColor=e)),t.addEventListener("mouseleave",(()=>t.style.borderColor="white")),t.addEventListener("click",(t=>{t.stopPropagation(),this.activeColorHandler(e)})),t.addEventListener("touchend",(t=>{t.stopPropagation(),this.activeColorHandler(e)}))}}const yl=function(t){this.popover=pe({class:"igv-menu-popup"}),t.appendChild(this.popover);const e=pe({class:"igv-menu-popup-header"});this.popover.appendChild(e),xe(e,(()=>this.hide())),this.popoverContent=pe(),this.popover.appendChild(this.popoverContent),oo(this.popover,e),e.addEventListener("click",(t=>{t.stopPropagation(),t.preventDefault()})),this.hide()};yl.prototype.hide=function(){this.popover.style.display="none"},yl.prototype.presentMenuList=function(t){if(xl(),t.length>0){this.popoverContent.innerHTML="",t=Oo.trackMenuItemListHelper(t,this);for(let e of t){e.init&&e.init();let n=e.object;0===t.indexOf(e)&&n.removeClass("igv-track-menu-border-top"),n.hasClass("igv-track-menu-border-top")||n.hasClass("igv-menu-popup-check-container")||n.is("div")&&n.addClass("igv-menu-popup-shim"),this.popoverContent.appendChild(n.get(0))}this.popover.style.display="flex";const{width:e}=this.popover.getBoundingClientRect();this.popover.style.left=-e+"px",this.popover.style.top="0px"}},yl.prototype.presentTrackContextMenu=function(t,e){this.popoverContent.innerHTML="";const n=(r=e,i=this.popover,r.map((t=>{let e;if("string"==typeof t&&"<hr/>"===t)e=document.createElement("hr");else if("string"==typeof t)e=pe({class:"context-menu"}),e.innerHTML=t;else if("Node"==typeof t)e=t;else{if("function"==typeof t.init&&t.init(),"checkbox"===t.type)e=Po("Show all bases",t.value);else if("color"===t.type){const r=new wl({parent:i.parentElement,width:364});r.configure(void 0,{color:e=>t.click(e)}),e=pe({class:"context-menu"}),"string"==typeof t.label&&(e.innerHTML=t.label);const o=t=>{r.show(),ge(i),t.preventDefault(),t.stopPropagation()};e.addEventListener("click",o),e.addEventListener("touchend",o),e.addEventListener("mouseup",(function(t){t.preventDefault(),t.stopPropagation()}))}else e=pe({class:"context-menu"}),"string"==typeof t.label&&(e.innerHTML=t.label);if(t.click&&"color"!==t.type){function n(e){t.click(),ge(i),e.preventDefault(),e.stopPropagation()}e.addEventListener("click",n),e.addEventListener("touchend",n),e.addEventListener("mouseup",(function(t){t.preventDefault(),t.stopPropagation()}))}}return{el:e,init:t.init}})));var r,i;for(let{el:t}of n)this.popoverContent.appendChild(t);!function(t,e){e.style.display="flex";const{x:n,y:r}=be(t,e.parentNode),{width:i}=e.getBoundingClientRect(),o=n+i,{width:s}=e.parentNode.getBoundingClientRect();e.style.left=`${o>s?n-(o-s):n}px`,e.style.top=`${r}px`}(t,this.popover)},yl.prototype.dispose=function(){this.popoverContent.innerHTML="",this.popover.innerHTML="",Object.keys(this).forEach((function(t){this[t]=void 0}))};const xl=()=>{const t=document.querySelectorAll(".igv-menu-popup");for(let e=0;e<t.length;e++)t[e].style.display="none"},kl=new Set(["ruler","sequence","ideogram"]),_l=new Set(["ruler","sequence","ideogram"]);class Sl{constructor(t,e,n){this.browser=t,this.track=n,n.trackView=this,this.addDOMToColumnContainer(t,e,t.referenceFrameList)}startSpinner(){this.viewports&&this.viewports.length>0&&this.viewports[0].startSpinner()}stopSpinner(){this.viewports&&this.viewports.length>0&&this.viewports[0].stopSpinner()}addDOMToColumnContainer(t,e,n){this.axis=this.createAxis(t,this.track),this.viewports=[];const r=t.calculateViewportWidth(n.length),i=e.querySelectorAll(".igv-column");for(let t=0;t<i.length;t++){const e=gl(this,i[t],n[t],r);this.viewports.push(e)}this.sampleNameViewport=new vl(this,t.columnContainer.querySelector(".igv-sample-name-column"),void 0,t.sampleNameViewportWidth),this.createTrackScrollbar(t),this.createTrackDragHandle(t),this.createTrackGearPopup(t)}createAxis(t,e){const n=pe();if(t.columnContainer.querySelector(".igv-axis-column").appendChild(n),n.style.height=`${e.height}px`,"function"==typeof e.paintAxis){e.dataRange&&n.addEventListener("click",(()=>{t.dataRangeDialog.configure(this),t.dataRangeDialog.present(de(t.columnContainer))}));const{width:r,height:i}=n.getBoundingClientRect();this.axisCanvas=document.createElement("canvas"),this.axisCanvas.style.width=`${r}px`,this.axisCanvas.style.height=`${i}px`,n.appendChild(this.axisCanvas)}return n}resizeAxisCanvas(t,e){this.axis.style.width=`${t}px`,this.axis.style.height=`${e}px`,"function"==typeof this.track.paintAxis&&(this.axisCanvas.style.width=`${t}px`,this.axisCanvas.style.height=`${e}px`)}removeDOMFromColumnContainer(){this.boundAxisClickHander&&this.removeAxisEventListener(this.axis),this.axis.remove();for(let t of this.viewports)t.$viewport.remove();this.sampleNameViewport.dispose(),this.removeTrackScrollMouseHandlers(),this.outerScroll.remove(),this.removeTrackDragMouseHandlers(),this.dragHandle.remove(),this.removeTrackGearMouseHandlers(),this.gearContainer.remove()}renderSVGContext(t,{deltaX:e,deltaY:n}){!function(t,e,n,r,i){if("function"==typeof e.paintAxis){const{y:o,width:s,height:a}=n.getBoundingClientRect(),c=`${(e.name||e.id).replace(/\W/g,"")}_axis_guid_${ve()}`;t.saveWithTranslationAndClipRect(c,r,o+i,s,a,0),e.paintAxis(t,s,a),t.restore()}}(t,this.track,this.axisCanvas,e,n);const{width:r}=this.axis.getBoundingClientRect(),{y:i}=this.viewports[0].$viewport.get(0).getBoundingClientRect();let o={deltaX:r+e,deltaY:i+n};for(let e of this.viewports){e.renderSVGContext(t,o);const{width:n}=e.$viewport.get(0).getBoundingClientRect();o.deltaX+=n}!0===this.browser.showSampleNames&&this.sampleNameViewport.renderSVGContext(t,o)}dataRange(){return this.track.dataRange?this.track.dataRange:void 0}setDataRange(t,e){void 0!==t&&(this.track.dataRange.min=t),void 0!==e&&(this.track.dataRange.max=e),this.track.autoscale=!1,this.repaintViews()}presentColorPicker(t){if(!1===_l.has(this.track.type)){const e=[],n=this.track.color||this.track.defaultColor;ke(n)&&e.push(n),this.track.altColor&&ke(this.track.altColor)&&e.push(this.track.altColor);const r=e.map((t=>t.startsWith("#")?t:t.startsWith("rgb(")?no.rgbToHex(t):no.colorNameToHex(t))),i={color:t=>{this.track.color=t,this.repaintViews()},altColor:t=>{this.track.altColor=t,this.repaintViews()}};this.browser.genericColorPicker.configure(r,i),this.browser.genericColorPicker.setActiveColorHandler(t),this.browser.genericColorPicker.show()}}setTrackHeight(t,e){e||(this.track.minHeight&&(t=Math.max(this.track.minHeight,t)),this.track.maxHeight&&(t=Math.min(this.track.maxHeight,t))),this.track.height=t,this.resizeAxisCanvas(this.axis.clientWidth,this.track.height),"function"==typeof this.track.paintAxis&&this.paintAxis();for(let{$viewport:e}of this.viewports)e.height(t);if(this.sampleNameViewport.viewport.style.height=`${t}px`,"function"!=typeof this.track.computePixelHeight)for(let e of this.viewports)e.setContentHeight(t);this.repaintViews(),!1===kl.has(this.track.type)&&this.updateScrollbar(),this.dragHandle.style.height=`${t}px`,this.gearContainer.style.height=`${t}px`}updateScrollbar(){const t=this.viewports[0].$viewport.height();this.outerScroll.style.height=`${t}px`;const e=Cl(this.viewports),n=Math.round(t/e*t);e>t?(this.innerScroll.style.display="block",this.innerScroll.style.height=`${n}px`):this.innerScroll.style.display="none"}moveScroller(t){const e=de(this.innerScroll).position().top+t,n=Math.min(Math.max(0,e),this.outerScroll.clientHeight-this.innerScroll.clientHeight);de(this.innerScroll).css("top",`${n}px`);const r=Cl(this.viewports),i=-Math.round(n*(r/this.viewports[0].$viewport.height()));for(let t of this.viewports)t.setTop(i);this.sampleNameViewport.trackScrollDelta=t,this.sampleNameViewport.setTop(i)}isLoading(){for(let t of this.viewports)if(t.isLoading())return!0}repaintViews(){for(let t of this.viewports)t.isVisible()&&t.repaint();"function"==typeof this.track.paintAxis&&this.paintAxis(),this.repaintSamples()}repaintSamples(){if("function"==typeof this.track.getSamples){const t=this.track.getSamples();this.sampleNameViewport.repaint(t)}}setTrackLabelName(t){this.viewports.forEach((e=>e.setTrackLabel(t)))}resize(t){for(let e of this.viewports)e.setWidth(t)}async updateViews(){if(!this.browser||!this.browser.referenceFrameList)return;const t=this.viewports.filter((t=>t.isVisible()));if(t.forEach((t=>t.shift())),this.browser.dragObject)return;let e=this.track.autoscale||this.track.autoscaleGroup||"ruler"===this.track.type?t:t.filter((t=>t.needsRepaint()));e=e.filter((t=>t.checkZoomIn()));const n=e.filter((t=>t.needsReload()));for(let t of n)await t.loadFeatures();if(!this.disposed){if(this.track&&"function"==typeof this.track.variantRowCount&&n.length>0){let t=0;for(let e of this.viewports)e.featureCache&&e.featureCache.features&&(t=Math.max(t,e.featureCache.features.reduce(((t,e)=>Math.max(t,e.row||0)),0)));if(this.track.nVariantRows!==t+1){this.track.variantRowCount(t+1);for(let t of this.viewports)t.checkContentHeight()}}if(this.track.autoscale){let e=[];for(let n of t){const t=n.referenceFrame,r=t.start,i=r+t.toBP(de(n.contentDiv).width());if(n.featureCache&&n.featureCache.features)if("function"==typeof n.featureCache.features.getMax){const t=n.featureCache.features.getMax(r,i);e.push({value:t})}else e=e.concat(No(n.featureCache.features,r,i))}"function"==typeof this.track.doAutoscale?this.track.dataRange=this.track.doAutoscale(e):this.track.dataRange=ms(e)}for(let t of e)t.repaint();this.adjustTrackHeight(),this.repaintSamples(),this.updateRulerViewportLabels()}}updateRulerViewportLabels(){const t=this.browser.calculateViewportWidth(this.viewports.length);for(let e of this.viewports)"ruler"===this.track.type&&(this.viewports.length>1?e.presentLocusLabel(t):e.dismissLocusLabel())}async getInViewFeatures(){if(!this.browser||!this.browser.referenceFrameList)return[];let t=[];for(let e of this.viewports)if(e.needsReload()&&await e.loadFeatures(),e.featureCache&&e.featureCache.features){const n=e.referenceFrame,r=n.start,i=r+n.toBP(de(e.contentDiv).width());if("function"==typeof e.featureCache.features.getMax){const n=e.featureCache.features.getMax(r,i);t.push({value:n})}else t=t.concat(No(e.featureCache.features,r,i))}return t}checkContentHeight(){for(let t of this.viewports)t.checkContentHeight();this.adjustTrackHeight()}adjustTrackHeight(){var t=Cl(this.viewports);if(this.track.autoHeight?this.setTrackHeight(t,!1):this.track.paintAxis&&this.paintAxis(),!1===kl.has(this.track.type)){const t=this.viewports[0].getContentTop(),e=this.viewports.map((t=>t.getContentHeight())),n=Math.min(...e),r=Math.min(0,this.viewports[0].$viewport.height()-n);if(t<r)for(let t of this.viewports)t.$content.css("top",`${r}px`);this.updateScrollbar()}}createTrackScrollbar(t){const e=pe();if(t.columnContainer.querySelector(".igv-scrollbar-column").appendChild(e),e.style.height=`${this.track.height}px`,this.outerScroll=e,!1===kl.has(this.track.type)){const n=pe();e.appendChild(n),this.innerScroll=n,this.addTrackScrollMouseHandlers(t)}}createTrackDragHandle(t){const e="ideogram"===this.track.type||"ruler"===this.track.type?"igv-track-drag-shim":"igv-track-drag-handle";this.dragHandle=pe({class:e}),t.columnContainer.querySelector(".igv-track-drag-column").appendChild(this.dragHandle),this.dragHandle.style.height=`${this.track.height}px`,this.addTrackDragMouseHandlers(t)}createTrackGearPopup(t){this.gearContainer=pe(),t.columnContainer.querySelector(".igv-gear-menu-column").appendChild(this.gearContainer),this.gearContainer.style.height=`${this.track.height}px`,!0===this.track.ignoreTrackMenu||(this.gear=pe(),this.gearContainer.appendChild(this.gear),this.gear.appendChild(we("cog")),this.trackGearPopup=new yl(this.gear),this.addTrackGearMouseHandlers())}addAxisEventListener(t){this.boundAxisClickHander=function(t){this.browser.dataRangeDialog.configure(this),this.browser.dataRangeDialog.present(de(this.browser.columnContainer))}.bind(this),t.addEventListener("click",this.boundAxisClickHander)}removeAxisEventListener(t){t.removeEventListener("click",this.boundAxisClickHander)}addTrackScrollMouseHandlers(t){this.boundTrackScrollMouseDownHandler=function(e){e.stopPropagation();const{y:n}=me(e);de(this.innerScroll).data("yDown",n.toString()),this.boundColumnContainerMouseMoveHandler=function(t){t.stopPropagation();const{y:e}=me(t);this.moveScroller(e-parseInt(de(this.innerScroll).data("yDown"))),de(this.innerScroll).data("yDown",e.toString())}.bind(this),t.columnContainer.addEventListener("mousemove",this.boundColumnContainerMouseMoveHandler)}.bind(this),this.innerScroll.addEventListener("mousedown",this.boundTrackScrollMouseDownHandler),this.boundColumnContainerMouseUpHandler=function(e){t.columnContainer.removeEventListener("mousemove",this.boundColumnContainerMouseMoveHandler)}.bind(this),t.columnContainer.addEventListener("mouseup",this.boundColumnContainerMouseUpHandler)}removeTrackScrollMouseHandlers(){!1===kl.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(t){if("ideogram"===this.track.id||"ruler"===this.track.id);else{let e;function n(n){n.preventDefault(),e=n.target,e.classList.add("igv-track-drag-handle-hover"),t.startTrackDrag(this)}function r(n){t.endTrackDrag(),e&&n.target!==e&&e.classList.remove("igv-track-drag-handle-hover"),e=void 0}function i(n){n.preventDefault(),void 0===e&&n.target.classList.add("igv-track-drag-handle-hover"),t.updateTrackDrag(this)}function o(t){t.preventDefault(),void 0===e&&t.target.classList.remove("igv-track-drag-handle-hover")}this.boundTrackDragMouseDownHandler=n.bind(this),this.dragHandle.addEventListener("mousedown",this.boundTrackDragMouseDownHandler),this.boundDocumentTrackDragMouseUpHandler=r.bind(this),document.addEventListener("mouseup",this.boundDocumentTrackDragMouseUpHandler),this.boundTrackDragMouseEnterHandler=i.bind(this),this.dragHandle.addEventListener("mouseenter",this.boundTrackDragMouseEnterHandler),this.dragHandle.addEventListener("mouseout",(t=>{t.preventDefault(),void 0===e&&t.target.classList.remove("igv-track-drag-handle-hover")})),this.boundTrackDragMouseOutHandler=o.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 t(t){t.preventDefault(),t.stopPropagation(),this.trackGearPopup.presentMenuList(Oo.trackMenuItemList(this))}this.boundTrackGearClickHandler=t.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 t of this.viewports)t.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();const t=this.track;"function"==typeof t.dispose&&t.dispose();for(let e of Object.keys(t))t[e]=void 0;for(let t of Object.keys(this))this[t]=void 0;this.alert&&this.alert.container.remove(),this.disposed=!0}paintAxis(){if("function"==typeof this.track.paintAxis){const{width:t,height:e}=this.axisCanvas.getBoundingClientRect(),n=window.devicePixelRatio||1;this.axisCanvas.height=n*e,this.axisCanvas.width=n*t;const r=this.axisCanvas.getContext("2d");r.scale(n,n),this.track.paintAxis(r,t,e)}}}function Cl(t){const e=t.map((t=>t.getContentHeight()));return Math.max(...e)}function El(t,e){if(t.length<6)console.log("Skipping line: "+t.join(" "));else{var n={chr1:t[0],start1:Number.parseInt(t[1]),end1:Number.parseInt(t[2]),chr2:t[3],start2:Number.parseInt(t[4]),end2:Number.parseInt(t[5])};if(!(isNaN(n.start1)||isNaN(n.end1)||isNaN(n.start2)||isNaN(n.end2))){if(t.length>6&&"."!==t[6]&&(n.name=t[6]),t.length>7&&"."!==t[7]&&(n.score=Number(t[7])),t.length>8&&"."!==t[8]&&(n.strand1=t[8]),t.length>9&&"."!==t[9]&&(n.strand2=t[9]),e){const r=e.colorColumn;r&&r<t.length&&(n.color=no.createColorString(t[r]));const i=e.thicknessColumn;i&&i<t.length&&(n.thickness=t[i]),t.length>10&&e.columnNames&&e.columnNames.length===t.length&&(n.extras=t.slice(10))}return n.chr1===n.chr2&&(n.chr=n.chr1,n.start=Math.min(n.start1,n.start2),n.end=Math.max(n.end1,n.end2)),n}}}function Al(t,e){if(!(t.length<8))return{chr:t[0],start:Number.parseInt(t[1]),end:Number.parseInt(t[2]),color:no.createColorString(t[6]),value:Number(t[7])}}function Tl(t,e){if(!(t.length<6))return{chr:t[0],start:t[1],end:t[2],chr1:t[8],start1:Number.parseInt(t[9]),end1:Number.parseInt(t[10]),chr2:t[13],start2:Number.parseInt(t[14]),end2:Number.parseInt(t[15]),name:t[3],score:Number(t[4]),value:Number(t[5]),color:"."===t[7]?void 0:"0"===t[7]?"rgb(0,0,0)":t[7]};console.log("Skipping line: "+t.join(" "))}const Ll=new Set(["transcript","primary_transcript","processed_transcript","mRNA","mrna","lnc_RNA","miRNA","ncRNA","rRNA","scRNA","snRNA","snoRNA","tRNA"]),Ml=new Set(["CDS","cds"]),Rl=new Set(["start_codon","stop_codon"]),Il=new Set(["5UTR","3UTR","UTR","five_prime_UTR","three_prime_UTR","3'-UTR","5'-UTR"]),Nl=new Set(["exon","coding-exon"]),Pl=new Set;for(let fd of[Ml,Rl,Il,Nl])for(let dd of fd)Pl.add(dd);function Ol(t){return t.includes("intron")}function Fl(t){return Ml.has(t)||Rl.has(t)}function Dl(t){return Il.has(t)}function Bl(t){return Ll.has(t)||t.endsWith("RNA")||t.endsWith("transcript")}function zl(t){return Pl.has(t)||t.endsWith("RNA")||Ol(t)}const Hl=new Set(["id","parent","name"]);class Vl{constructor(t){Object.assign(this,t)}popupData(t){const e=this.geneObject?this.geneObject.popupData():[];if(this.geneObject&&e.push("<hr/>"),this.name&&e.push({name:"Name",value:this.name}),e.push({name:"Type",value:this.type}),e.push({name:"Source",value:this.source}),void 0!==this.score&&e.push({name:"Score",value:this.score}),this.attributeString){const t=$l(this.attributeString,this.delim);for(let[n,r]of t)void 0!==r&&r.length>0&&!Hl.has(n.toLowerCase())&&e.push({name:n+":",value:r})}return e.push({name:"Location",value:`${this.chr}:${_e(this.start+1)}-${_e(this.end)}`}),e}getAttributeValue(t){if(this.hasOwnProperty(t))return this[t];if(this._attributeCache||(this._attributeCache=new Map),this._attributeCache.has(t))return this._attributeCache.get(t);{const e=$l(this.attributeString,this.delim);let n;for(let[r,i]of e)if(r===t){n=i;break}return this._attributeCache.set(t,n),n}}}class jl extends Vl{constructor(t){super(t),this.exons=[],this.parts=[]}addExon(t){this.exons.push(t),this.start=Math.min(this.start,t.start),this.end=Math.max(this.end,t.end)}addPart(t){this.parts.push(t)}assembleParts(){if(0===this.parts.length)return;this.parts.sort((function(t,e){return t.start-e.start}));let t=this.parts[0].start,e=this.parts[0].end;for(let n=1;n<this.parts.length;n++){const r=this.parts[n];if(!Ol(r.type))if(r.start<=e)e=Math.max(e,r.end);else{this.findExonContaining({start:t,end:e})||this.exons.push({start:t,end:e,psuedo:!0}),t=r.start,e=r.end}}this.findExonContaining({start:t,end:e})||(this.exons.push({start:t,end:e,psuedo:!0}),this.start=Math.min(this.start,t),this.end=Math.max(this.end,e));for(let t of this.parts){const e=t.type;Fl(e)?this.addCDS(t):Dl(e)&&this.addUTR(t)}}findExonContaining({start:t,end:e}){for(let n of this.exons)if(n.end>=e&&n.start<=t)return n}addCDS(t){let e;const n=this.exons;for(let r of n)if(r.start<=t.start&&r.end>=t.end){e=r;break}e?(e.cdStart=e.cdStart?Math.min(t.start,e.cdStart):t.start,e.cdEnd=e.cdEnd?Math.max(t.end,e.cdEnd):t.end):console.error("No exon found spanning "+t.start+"-"+t.end),this.cdStart=this.cdStart?Math.min(t.start,this.cdStart):t.start,this.cdEnd=this.cdEnd?Math.max(t.end,this.cdEnd):t.end}addUTR(t){let e;const n=this.exons;for(let r=0;r<n.length;r++)if(n[r].start<=t.start&&n[r].end>=t.end){e=n[r];break}e?t.start===e.start&&t.end===e.end?e.utr=!0:(t.end<e.end&&(e.cdStart=t.end),t.start>e.start&&(e.cdEnd=t.start)):console.error("No exon found spanning "+cds.start+"-"+cds.end)}finish(){this.assembleParts();var t=this.cdStart,e=this.cdEnd;this.exons.sort((function(t,e){return t.start-e.start})),t&&this.exons.forEach((function(n){(n.end<t||n.start>e)&&(n.utr=!0)}))}popupData(t){const e=super.popupData(t);for(let n of this.exons)if(!n.pseudo&&t>=n.start&&t<n.end&&"function"==typeof n.popupData){e.push("<hr/>");const r=n.popupData(t);for(let t of r)e.push(t)}for(let n of this.parts)if(t>=n.start&&t<n.end&&"function"==typeof n.popupData){e.push("<hr/>");const r=n.popupData(t);for(let t of r)e.push(t)}return e}}function Ul(t,e){const n=e.format;if(t.length<9)return;const r="gff3"===n?"=":" ";return new Vl({source:t[1],type:t[2],chr:t[0],start:parseInt(t[3])-1,end:parseInt(t[4]),score:"."===t[5]?void 0:Number(t[5]),strand:t[6],phase:"."===t[7]?0:parseInt(t[7]),attributeString:t[8],delim:r})}function ql(t,e){const n=Ul(t,e);if(!n)return;const r=$l(n.attributeString,n.delim);for(let[t,e]of r){const r=t.toLowerCase();"color"===r||"colour"===r?n.color=no.createColorString(e):"ID"===t?n.id=e:"Parent"===t&&(n.parent=e)}return n}function Wl(t,e){const n=Ul(t,e);if(!n)return;const r=$l(n.attributeString,n.delim);let i,o;switch(n.type){case"gene":i="gene_id";break;case"transcript":i="transcript_id",o="gene_id";break;default:o="transcript_id"}for(let[t,e]of r){const r=t.toLowerCase();"color"===r||"colour"===r?n.color=no.createColorString(e):t===i?n.id=e:t===o&&(n.parent=e)}return n}function $l(t,e){var n=[];for(let r of t.split(";")){r=r.trim();const t=r.indexOf(e);if(t>0&&t<r.length-1){const e=r.substring(0,t);let i=Gl(decodeURIComponent(r.substring(t+1).trim()));n.push([e,i])}}return n}function Gl(t){return t.startsWith('"')&&t.endsWith('"')&&(t=t.substr(1,t.length-2)),t}class Zl{constructor(t){this.message=t}}function Xl(t,e){if(t.length<3)return;e&&e.gffTags;const n=t[0],r=parseInt(t[1]),i=t.length>2?parseInt(t[2]):r+1;if(isNaN(r)||isNaN(i))return new Zl("Unparsable bed record.");const o=new oh({chr:n,start:r,end:i,score:1e3});try{if(t.length>3){if(t[3].indexOf(";")>0&&t[3].indexOf("=")>0){const e=$l(t[3],"=");o.attributes={};for(let t of e)o.attributes[t[0]]=t[1]}o.name||(o.name="."===t[3]?"":t[3])}if(t.length>4&&(o.score="."===t[4]?0:Number(t[4]),isNaN(o.score)))return o;if(t.length>5&&(o.strand=t[5],"."!==o.strand&&"+"!==o.strand&&"-"!==o.strand))return o;if(t.length>6&&(o.cdStart=parseInt(t[6]),isNaN(o.cdStart)))return o;if(t.length>7&&(o.cdEnd=parseInt(t[7]),isNaN(o.cdEnd)))return o;if(t.length>8&&"."!==t[8]&&"0"!==t[8]&&(o.color=no.createColorString(t[8])),t.length>11){const e=parseInt(t[9]);if(e>1e3)return o;const n=t[10].replace(/,$/,"").split(","),i=t[11].replace(/,$/,"").split(",");if(n.length!==i.length||e!==n.length)return o;const s=[];for(let t=0;t<e;t++){const e=r+parseInt(i[t]),o=e+parseInt(n[t]);s.push({start:e,end:o})}th(s,o.cdStart,o.cdEnd),o.exons=s}if(e){let n=e.thicknessColumn,r=e.colorColumn;r&&r<t.length&&(o.color=no.createColorString(t[r])),n&&n<t.length&&(o.thickness=t[n])}}catch(t){}return o}function Yl(t,e){if(t.length<=15)return;return{swScore:Number.parseInt(t[1]),milliDiv:Number.parseInt(t[2]),milliDel:Number.parseInt(t[3]),milliIns:Number.parseInt(t[4]),chr:t[5],start:Number.parseInt(t[6]),end:Number.parseInt(t[7]),strand:t[9],repName:t[10],repClass:t[11],repFamily:t[12],repStart:Number.parseInt(t[13]),repEnd:Number.parseInt(t[14]),repLeft:Number.parseInt(t[15])}}function Kl(t,e){var n=void 0===e.shift?0:1;if(t.length<=9+n)return;const r=parseInt(t[5+n]),i=parseInt(t[6+n]);var o={name:t[0+n],chr:t[1+n],strand:t[2+n],start:parseInt(t[3+n]),end:parseInt(t[4+n]),cdStart:r,cdEnd:i,id:t[0+n]},s=parseInt(t[7+n]),a=t[8+n].split(","),c=t[9+n].split(","),l=[];for(let t=0;t<s;t++){const e=parseInt(a[t]),n=parseInt(c[t]);l.push({start:e,end:n})}return th(l,r,i),o.exons=l,o}function Ql(t,e){var n=void 0===e.shift?0:1;if(t.length<=11+n)return;const r=parseInt(t[5+n]),i=parseInt(t[6+n]),o={name:t[11+n],chr:t[1+n],strand:t[2+n],start:parseInt(t[3+n]),end:parseInt(t[4+n]),cdStart:r,cdEnd:i,id:t[0+n]},s=parseInt(t[7+n]),a=t[8+n].split(","),c=t[9+n].split(","),l=[];for(let t=0;t<s;t++){const e=parseInt(a[t]),n=parseInt(c[t]);l.push({start:e,end:n})}return th(l,r,i),o.exons=l,o}function Jl(t,e){var n=void 0===e.shift?0:1;if(t.length<=10+n)return;const r=parseInt(t[6+n]),i=parseInt(t[7+n]);var o={name:t[0+n],id:t[1+n],chr:t[2+n],strand:t[3+n],start:parseInt(t[4+n]),end:parseInt(t[5+n]),cdStart:r,cdEnd:i},s=parseInt(t[8+n]),a=t[9+n].split(","),c=t[10+n].split(","),l=[];for(let t=0;t<s;t++){const e=parseInt(a[t]),n=parseInt(c[t]);l.push({start:e,end:n})}return th(l,r,i),o.exons=l,o}function th(t,e,n){for(let r of t){const t=r.end,i=r.start;t<e||i>n?r.utr=!0:(e>=i&&e<=t&&(r.cdStart=e),n>=i&&n<=t&&(r.cdEnd=n))}}function eh(t,e){var n,r,i,o,s,a,c;if(!(t.length<9))return n=t[0],r=parseInt(t[1]),i=parseInt(t[2]),s=t[3],a=Number(t[4]),o=t[5].trim(),c=Number(t[6]),0===a&&(a=c),{chr:n,start:r,end:i,name:s,score:a,strand:o,signal:c,pValue:Number(t[7]),qValue:Number(t[8])}}function nh(t,e){if(t.length<=3)return;const n={chr:t[0],start:parseInt(t[1]),end:parseInt(t[2]),value:Number(t[3])};if(e){let r=e.colorColumn;r&&r<t.length&&(n.color=no.createColorString(t[r]))}return n}function rh(t,e){const n=e.wig;if(n&&"fixedStep"===n.format){const e=n.index*n.step+n.start,r=e+n.span,i=Number(t[0]);return++n.index,isNaN(i)?null:{chr:n.chrom,start:e,end:r,value:i}}if(n&&"variableStep"===n.format){if(t.length<2)return null;const e=parseInt(t[0],10)-1,r=e+n.span,i=Number(t[1]);return isNaN(i)?null:{chr:n.chrom,start:e,end:r,value:i}}return nh(t)}function ih(t,e){if(t.length<6)return;const n=["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"],r={chr:t[1],start:Number.parseInt(t[2]),end:Number.parseInt(t[3]),name:t[4],score:Number.parseInt(t[5])},i=Math.min(t.length,n.length);for(let e=6;e<i;e++)r[n[e]]=t[e];return r}class oh{constructor(t){Object.assign(this,t)}getAttributeValue(t){return this.hasOwnProperty(t)?this[t]:this.attributes?this.attributes[t]:void 0}}function sh(t,e){if(!(t.length<7)){var n=t[0],r=t[1],i=parseInt(t[2]),o=parseInt(t[3]),s=parseInt(t[4]),a=parseInt(t[5]),c=t[6],l={chr:n,name:r,junction_left:i,junction_right:o,num_junction_reads:s,num_spanning_frags:a,spanning_frag_coords:[],start:-1,end:-1},h=i,u=o;if(a>0)for(var f=c.split(","),d=0;d<f.length;d++){var p=f[d].split("-"),g=p[0],m=p[1];g<h&&(h=g),m>u&&(u=m),l.spanning_frag_coords.push({left:g,right:m})}return l.start=h,l.end=u,l}}function ah(t,e){if(t.length<7)return null;const n={chr:t[0],start:parseInt(t[1])-1,end:parseInt(t[2]),"Strongest SNP-risk allele":t[3],"Disease/Phenotype":t[4],"P-value":t[5],"Odds ratio or beta":t[6]};return t.length>6&&(n.PUBMEDID=`<a target = "blank" href = "https://www.ncbi.nlm.nih.gov/pubmed/${t[7]}">${t[7]}</a>`),n}function ch(t,e){const n=e.customFormat;if(t.length<n.fields.length)return;const r=n.coords||0,i=t[n.chr],o=parseInt(t[n.start])-r,s={chr:i,start:o,end:void 0!==n.end?parseInt(t[n.end]):o+1};return n.fields&&n.fields.forEach((function(e,r){r!==n.chr&&r!==n.start&&r!==n.end&&(s[e]=t[r])})),s}function lh(t,e){const n=e.columnNames;if(!n)throw Error("Sample names are not defined. Missing column headers?");const r=n.length-3,i=t[0],o=parseInt(t[1]),s=parseInt(t[2]),a=t.slice(3).map(Number);return a.length==r?{chr:i,start:o,end:s,values:a}:void console.warn(`${i}:${o}-${s} row contains ${a.length} sample columns instead of the expected ${r} columns. Skipping...`)}class hh{constructor(t){this.config=t,this.header={},t.nameField&&(this.header.nameField=t.nameField),this.skipRows=0,t.decode?(this.decode=t.decode,this.delimiter=t.delimiter||"\t"):t.format&&(this.header.format=t.format.toLowerCase(),this.setDecoder(this.header.format)),this.delimiter||(this.delimiter="\t")}async parseHeader(t){let e,n,r=this.header;for(;void 0!==(n=await t.nextLine());)if(n.startsWith("track")||n.startsWith("#track")){let t=uh(n);Object.assign(r,t)}else if(n.startsWith("browser"));else if(n.startsWith("#columns")){let t=fh(n);Object.assign(r,t)}else if(n.startsWith("##gff-version 3"))r.format="gff3";else if(n.startsWith("#gffTags"))r.gffTags=!0;else{if(n.startsWith("fixedStep")||n.startsWith("variableStep"))break;if(n.startsWith("#")){const t=n.split(this.delimiter||"\t");t.length>1&&(e=t)}else{this.setDecoder(r.format);const t=n.split(this.delimiter||"\t");try{const n=Object.assign({columnNames:e},r);if(this.decode(t,n))break;t.length>1&&(e=t)}catch(n){t.length>1&&(e=t)}}}if(e){r.columnNames=e;for(let t=0;t<e.length;t++)"color"===e[t]||"colour"===e[t]?r.colorColumn=t:"thickness"===e[t]&&(r.thicknessColumn=t)}return this.header=r,r}async parseFeatures(t){const e=[],n=this.decode,r=this.header.format,i=this.delimiter||"\t";let o,s=0,a=0;for(;void 0!==(o=await t.nextLine());){if(s++,s<=this.skipRows)continue;if(!o||o.startsWith("track")||o.startsWith("#")||o.startsWith("browser"))continue;if("wig"===r&&o.startsWith("fixedStep")){this.header.wig=dh(o);continue}if("wig"===r&&o.startsWith("variableStep")){this.header.wig=ph(o);continue}const t=o.split(i);if(t.length<1)continue;const c=n(t,this.header);c instanceof Zl?(a++,a>0&&console.error(`Error parsing line '${o}': ${c.message}`)):c&&e.push(c)}return n===El&&function(t){if(0==t.length)return;const e=t[0];if(void 0===e.score&&void 0!==e.name){for(let e of t)if(!("number"==typeof(n=e.name)?n-n==0:"string"==typeof n&&""!==n.trim()&&(Number.isFinite?Number.isFinite(+n):isFinite(+n)))&&"."!==e.name)return;for(let e of t)e.score=Number(e.name),delete e.name}var n;const r=t.filter((t=>t.chr1!==t.chr2));for(let e of r){const n=Object.assign({},e);n.dup=!0,t.push(n),e.chr=e.chr1,e.start=e.start1,e.end=e.end1,n.chr=n.chr2,n.start=n.start2,n.end=n.end2}}(e),e}setDecoder(t){switch(t){case"narrowpeak":case"broadpeak":case"regionpeak":case"peaks":this.decode=eh,this.delimiter=this.config.delimiter||/\s+/;break;case"bedgraph":this.decode=nh,this.delimiter=/\s+/;break;case"wig":this.decode=rh,this.delimiter=this.config.delimiter||/\s+/;break;case"gff3":case"gff":this.decode=ql,this.delimiter="\t";break;case"gtf":this.decode=Wl,this.delimiter="\t";break;case"fusionjuncspan":this.decode=sh,this.delimiter=this.config.delimiter||/\s+/;break;case"gtexgwas":this.skipRows=1,this.decode=ah,this.delimiter="\t";break;case"refflat":this.decode=Jl,this.delimiter=this.config.delimiter||/\s+/;break;case"genepred":this.decode=Kl,this.delimiter=this.config.delimiter||/\s+/;break;case"genepredext":this.decode=Ql,this.delimiter=this.config.delimiter||/\s+/;break;case"ensgene":this.decode=Kl,this.header.shift=1,this.delimiter=this.config.delimiter||/\s+/;break;case"refgene":this.decode=Ql,this.delimiter=this.config.delimiter||/\s+/,this.header.shift=1;break;case"bed":this.decode=Xl,this.delimiter=this.config.delimiter||/\s+/;break;case"bedpe":this.decode=El,this.delimiter=this.config.delimiter||"\t";break;case"bedpe-domain":this.decode=Al,this.headerLine=!0,this.delimiter=this.config.delimiter||"\t";break;case"bedpe-loop":this.decode=El,this.delimiter=this.config.delimiter||"\t",this.header={colorColumn:7};break;case"interact":this.decode=Tl,this.delimiter=this.config.delimiter||/\s+/;break;case"snp":this.decode=ih,this.delimiter="\t";break;case"rmsk":this.decode=Yl,this.delimiter="\t";break;case"gcnv":this.decode=lh,this.delimiter="\t";break;default:const e=function(t){return us&&us[t]?function(t){const e=t.fields,n=["chr","start","end"];for(let r=0;r<e.length;r++)for(let i of n)i===e[r]&&(t[i]=r);return t}(us[t]):void 0}(t);void 0!==e?(this.decode=ch,this.header.customFormat=e,this.delimiter=e.delimiter||"\t"):(this.decode=Xl,this.delimiter=this.config.delimiter||/\s+/)}}}function uh(t){const e={},n=t.split(/(?:")([^"]+)(?:")|([^\s"]+)(?=\s+|$)/g);let r;const i=[];for(let t of n)t&&0!==t.trim().length&&(t.endsWith("=")?r=t:r?(i.push(r+t),r=void 0):i.push(t));for(let t of i){if(!t)return;var o=t.split("=",2);if(2===o.length){const t=o[0].trim(),n=o[1].trim();if(e.hasOwnProperty(t)){let r=e[t];Array.isArray(r)?r.push(n):e[t]=[r,n]}else e[t]=n}}return"interact"==e.type?e.format="interact":"gcnv"===e.type&&(e.format="gcnv"),e}function fh(t){let e={},n=t.split(/\s+/);if(2===n.length){n[1].split(";").forEach((function(t){let n=t.split("=");"color"===n[0]?e.colorColumn=Number.parseInt(n[1])-1:"thickness"===n[0]&&(e.thicknessColumn=Number.parseInt(n[1])-1)}))}return e}function dh(t){const e=t.split(/\s+/);return{format:"fixedStep",chrom:e[1].split("=")[1],start:parseInt(e[2].split("=")[1],10)-1,step:parseInt(e[3].split("=")[1],10),span:e.length>4?parseInt(e[4].split("=")[1],10):1,index:0}}function ph(t){const e=t.split(/\s+/);return{format:"variableStep",chrom:e[1].split("=")[1],span:e.length>2?parseInt(e[2].split("=")[1],10):1}}class gh{constructor(t){switch(this.type=t||"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(t){let e;for(;void 0!==(e=await t.nextLine());)if(!e.startsWith("#")){const t=e.split("\t");this.header={headings:t};break}return this.header}async parseFeatures(t){const e=[];let n;this.header||(this.header=await this.parseHeader(t)),"seg"===this.type&&(this.dataColumn=this.header.headings.length-1),this.header.headings.length>5&&(n=this.extractExtraColumns(this.header.headings));const r=this.header.headings[this.dataColumn];let i;for(;void 0!==(i=await t.nextLine());){const t=i.split("\t"),o="seg"===this.type?Number(t[this.dataColumn]):t[this.dataColumn];if(t.length>this.dataColumn){const i=new mh({sample:t[this.sampleColumn],chr:t[this.chrColumn],start:parseInt(t[this.startColumn])-1,end:parseInt(t[this.endColumn]),value:o,valueColumnName:r});if(n){const e=this.extractExtraColumns(t);i.setAttributes({names:n,values:e})}e.push(i)}}return e}extractExtraColumns(t){const e=[];for(let n=0;n<t.length;n++)n!==this.chrColumn&&n!==this.startColumn&&n!==this.endColumn&&n!==this.sampleColumn&&e.push(t[n]);return e}}class mh{constructor({sample:t,chr:e,start:n,end:r,value:i,valueColumnName:o}){this.sample=t,this.chr=e,this.start=n,this.end=r,this.value=i,this.valueColumnName=o}setAttributes({names:t,values:e}){this.attributeNames=t,this.attributeValues=e}getAttribute(t){if(this.attributeNames){const e=this.attributeNames.indexOf(t);if(e>=0)return this.attributeValues[e]}}popupData(t,e){const n=new Set(["chr","start","end","sample","value","row","color","sampleKey","uniqueSampleKey","sampleId","chromosome","uniquePatientKey"]),r=this.chr+":"+_e(this.start+1)+"-"+_e(this.end),i=[{name:"Sample",value:this.sample},{name:"Location",value:r},{name:this.valueColumnName?Ee(this.valueColumnName):"Value",value:this.value}];if("mut"===t&&"hg38"===e){const t=this.extractCravatLink(e);t&&(i.push("<hr/>"),i.push({html:t}),i.push("<hr/>"))}if(this.attributeNames&&this.attributeNames.length>0)for(let t=0;t<this.attributeNames.length;t++)!n.has(this.attributeNames[t])&this.valueColumnName!==this.attributeNames[t]&&i.push({name:Ee(this.attributeNames[t]),value:this.attributeValues[t]});return i}extractCravatLink(t){let e,n;if(this.attributeNames&&this.attributeNames.length>0)for(let r=0;r<this.attributeNames.length;r++)if(e||"Reference_Allele"!==this.attributeNames[r]||(e=this.attributeValues[r]),!n&&this.attributeNames[r].startsWith("Tumor_Seq_Allele")&&this.attributeValues[r]!==e&&(n=this.attributeValues[r]),e&&n)return bc.getCravatLink(this.chr,this.start+1,e,n,t)}}function vh(t){const e=new bh;e.chr=t[0],e.pos=parseInt(t[1]),e.names=t[2],e.referenceBases=t[3],e.alternateBases=t[4],e.quality=t[5],e.filter=t[6],e.info={};const n=t[7];if(n)for(let t of n.split(";")){var r=t.split("=");e.info[r[0]]=r[1]}return e.init(),e}class bh{init(){const t=this.referenceBases,e=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(t,e){const n=t.length;if(void 0===e)return"UNKNOWN";if(0===e.trim().length||"<NON_REF>"===e||"<*>"===e||"."===e)return"NONVARIANT";{const t=e.split(",").map((function(t){return 1===n&&1===t.length?"SNP":"<NON_REF>"===t?"NONVARIANT":"OTHER"}));let r=t[0];for(let e of t)if(e!==r)return"MIXED";return r}}(t,e)),"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+t.length;else{const n=e.split(",").filter((t=>t.length>0));this.alleles=[],this.start=void 0,this.end=void 0;for(let e of n)if(this.alleles.push(e),"SV"!==this.type&&yh(e)){let n=e.length,r=t.length;const i=Math.min(n,r);let o=0;for(;o<i&&t.charCodeAt(o)===e.charCodeAt(o);)o++,n--,r--;for(;n>0&&r>0;){const i=o+n-1,s=o+r-1;if(e.charCodeAt(i)!==t.charCodeAt(s))break;n--,r--}for(;n>0&&r>0;){const i=o,s=o;if(e.charCodeAt(i)!==t.charCodeAt(s))break;o++,n--,r--}const s=this.pos+o-1,a=s+r;this.start=void 0===this.start?s:Math.min(this.start,s),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(t,e){const n=`${_e(this.pos)}`,r=this.start===this.end?`${_e(this.start)} | ${_e(this.start+1)}`:`${_e(this.start+1)}-${_e(this.end)}`,i=[{name:"Chr",value:this.chr},{name:"Pos",value:n},{name:"Loc",value:r},{name:"Names",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 t=this.referenceBases;if(1===t.length){let n=this.alternateBases.split(",");for(let r of n)if(1===r.length){let n=bc.getCravatLink(this.chr,this.pos,t,r,e);n&&(i.push("<hr/>"),i.push({html:n}))}}}if(this.hasOwnProperty("heterozygosity")&&i.push({name:"Heterozygosity",value:this.heterozygosity}),this.info){i.push({html:'<hr style="border-top: dotted 1px;border-color: #c9c3ba" />'});for(let t of Object.keys(this.info))i.push({name:t,value:xh(decodeURIComponent(this.info[t]))})}return i}isRefBlock(){return"NONVARIANT"===this.type}}const wh=new Set(["A","C","T","G"].map((t=>t.charCodeAt(0))));function yh(t){for(let e=0;e<t.length;e++)if(!wh.has(t.charCodeAt(e)))return!1;return!0}function xh(t,e){return void 0===e&&(e=","),Array.isArray(t)?t.join(e):t}class kh{construtor(){}async parseHeader(t,e){const n={};n.chrAliasTable=new Map;let r=await t.nextLine();if(!r.startsWith("##fileformat"))throw new Error("Invalid VCF file: missing fileformat line");for(n.version=r.substr(13);void 0!==(r=await t.nextLine())&&r.startsWith("#");){let t;const o={};if(r.startsWith("##")){if(r.startsWith("##INFO")||r.startsWith("##FILTER")||r.startsWith("##FORMAT")){const e=r.indexOf("<"),s=r.lastIndexOf(">");if(!(e>2&&s>0)){console.log("Malformed VCF header line: "+r);continue}const a=r.substring(2,e-1);n[a]||(n[a]={});const c=Ce(r.substring(e+1,s-1),",");for(let e of c){var i=e.split("=");i.length>1&&("ID"===i[0]?t=i[1]:o[i[0]]=i[1])}t&&(n[a][t]=o)}else if(r.startsWith("##contig")&&e){const t=r.indexOf("<ID=");let i=r.indexOf(",",t);-1==i&&(i=r.indexOf(">",t));const o=r.substring(t+4,i),s=e.getChromosomeName(o);n.chrAliasTable.set(s,o)}}else if(r.startsWith("#CHROM")){const t=r.split("\t");if(t.length>8){n.callSets=[];for(let e=9;e<t.length;e++)n.callSets.push({id:e,name:t[e]})}}}return this.header=n,n}async parseFeatures(t){const e=[],n=this.header.callSets,r=8+(n?n.length+1:0);let i;for(;void 0!==(i=await t.nextLine());)if(i&&!i.startsWith("#")){const t=i.split("\t");if(t.length===r){const r=vh(t);if(r.header=this.header,e.push(r),t.length>9){const e=_h(t[8].split(":"));r.calls={};for(let i=9;i<t.length;i++){const o=t[i],s=n[i-9],a={callSetName:s.name,info:{}};r.calls[s.id]=a,o.split(":").forEach((function(t,n){if(n===e.genotypeIndex)a.genotype=[],t.split(/[\|\/]/).forEach((function(t){a.genotype.push("."===t?t:parseInt(t))}));else a.info[e.fields[n]]=t}))}}r.info&&r.info.CHR2&&r.info.END&&e.push(Sh(r))}}return e}}function _h(t){const e={genotypeIndex:-1,fields:t};for(let n=0;n<t.length;n++)"GT"===t[n]&&(e.genotypeIndex=n);return e}function Sh(t){const e=t.info.CHR2,n=Number.parseInt(t.info.END);return{chr:e,start:n-1,end:n,_f:t}}class Ch{constructor(t){if(this.config=t,t.columns){if(void 0===t.columns.chromosome||void 0===t.columns.position||void 0===t.columns.value)throw Error("columns property must define chrCol, posCol, and valueCol");this.posCol=t.columns.position-1,this.chrCol=t.columns.chromosome-1,this.pvalueCol=t.columns.value-1}else this.posCol=2,this.chrCol=1,this.pvalueCol=3}async parseHeader(t){const e=await t.nextLine();return this.parseHeaderLine(e)}parseHeaderLine(t){if(this.columns=t.split(/\t/),!this.config.columns)for(let t=0;t<this.columns.length;t++){switch(this.columns[t].toLowerCase()){case"chr":case"chromosome":case"chr_id":this.chrCol=t;break;case"bp":case"pos":case"position":case"chr_pos":this.posCol=t;break;case"p":case"pval":case"pvalue":case"p-value":case"p.value":this.valueCol=t}}return this.columns}async parseFeatures(t){const e=[],n=t.nextLine();let r;for(this.columns||this.parseHeaderLine(n);void 0!==(r=t.nextLine());){const t=r.split(/\t/);if(t.length===this.columns.length){const n=t[this.chrCol],i=parseInt(t[this.posCol])-1,o=i+1,s=Number(t[this.valueCol]);e.push(new Eh({chr:n,start:i,end:o,value:s,line:r,columns:this.columns}))}}return e}}class Eh{constructor({chr:t,start:e,end:n,value:r,line:i,columns:o}){this.chr=t,this.start=e,this.end=n,this.value=r,this.line=i,this.columns=o}popupData(){const t=this.line.split(/\t/);return this.columns.map((function(e,n){return{name:e,value:t[n]}}))}getAttribute(t){const e=this.line.split(/\t/);for(let n=0;n<this.columns.length;n++)if(this.columns[n]===t)return e[n]}}var Ah=new RegExp("([^:]*)\\(([^)]*)\\)"),Th=new RegExp("([^:]*):([^(]*)\\(([^)]*)\\)");class Lh{constructor(t){const e=t?t.decode:void 0;this.nameField=t?t.nameField:void 0,this.skipRows=0,this.decode=e||Oh,this.delimiter="\t"}async parseHeader(t){let e,n;for(;(e=await t.nextLine())&&(e.startsWith("track")||e.startsWith("#")||e.startsWith("browser"));)if(e.startsWith("track")||e.startsWith("#track")){let t=Ih(e);n?Object.assign(n,t):n=t}else if(e.startsWith("#columns")){let t=Nh(e);n?Object.assign(n,t):n=t}else e.startsWith("##gff-version 3")&&(this.format="gff3",n||(n={}),n.format="gff3");return this.header=n,n}async parseFeatures(t){const e=[],n=this.decode,r=this.delimiter||"\t";let i,o=0;for(;void 0!==(i=t.nextLine());){if(o++,o<=this.skipRows||i.startsWith("track")||i.startsWith("#")||i.startsWith("browser"))continue;let t=s();if(t.length<1)continue;if(!this.aed){this.aed=Rh(t);continue}const r=n.call(this,t,undefined);r&&e.push(r)}return e;function s(){for(var t,e,n=[],o="",s=!1;i||""===i;){for(t=0;t<i.length;t++)(e=i.charAt(t))===r?s?o+=e:(n.push(o),o=""):'"'===e?t+1<i.length&&'"'===i.charAt(t+1)?(s&&(o+='"'),t++):s=!s:o+=e;if(!s)break;o+="\n",i=nextLine()}return n.push(o),n}}}function Mh(t){var e=Th.exec(t);if(e)return{namespace:e[1],name:e[2],type:e[3]};if(e=Ah.exec(t))return{namespace:"?",name:e[1],type:e[2]};throw new Error("Error parsing the header row of AED file - column not in ns:name(ns:type) format")}function Rh(t){var e,n,r;for(e={columns:[],metadata:{}},n=0;n<t.length;n++)r=Mh(t[n]),e.columns.push(r);return e}function Ih(t){const e={},n=t.split(/(?:")([^"]+)(?:")|([^\s"]+)(?=\s+|$)/g);let r;const i=[];for(let t of n)t&&0!==t.trim().length&&(t.endsWith("=")>0?r=t:r?(i.push(r+t),r=void 0):i.push(t));for(let t of i){if(!t)return;var o=t.split("=",2);if(2===o.length){const t=o[0].trim(),n=o[1].trim();e[t]=n}}return e}function Nh(t){let e={},n=t.split(/\s+/);if(2===n.length){n[1].split(";").forEach((function(t){let n=t.split("=");"color"===n[0]?e.colorColumn=Number.parseInt(n[1])-1:"thickness"===n[0]&&(e.thicknessColumn=Number.parseInt(n[1])-1)}))}return e}function Ph(t,e){var n,r,i=t.columns;this.aed=t,this.allColumns=e,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 t=0;t<e.length;t++)if(n=e[t]){"aed:Integer"===(r=i[t]).type&&(n=parseInt(n));var o=[];if(r.namespace.length>0)for(let t=0;t<r.namespace.length;t++)o.push(r.namespace.charCodeAt(t));"bio"===r.namespace.trim()?"sequence"===r.name?this.chr=n:"start"===r.name?this.start=n:"end"===r.name?this.end=n:"cdsMin"===r.name?this.cdStart=n:"cdsMax"===r.name?this.cdEnd=n:"strand"===r.name&&(this.strand=n):"aed"===r.namespace?"name"===r.name&&(this.name=n):"style"===r.namespace&&"color"===r.name&&(this.color=no.createColorString(n))}}function Oh(t,e){var n,r,i,o,s,a,c=0,l=this.aed.columns;if(t.length===l.length){for(a=0;a<t.length;a++)o=l[a],""!==(i=t[a])&&c++,"name"===o.name&&"aed"===o.namespace?n=i:"value"===o.name&&"aed"===o.namespace&&(r=i);if(2===c&&n&&r)return s=Mh(n),this.aed.metadata[s.namespace]||(this.aed.metadata[s.namespace]={}),void(this.aed.metadata[s.namespace][s.name]||(this.aed.metadata[s.namespace][s.name]={type:s.type,value:r}));var h=new Ph(this.aed,t);if(h.chr&&(h.start||0===h.start)&&h.end)return h;console.log("Cannot parse feature: "+t.join(","))}else console.log("Corrupted AED file row: "+t.join(","))}function Fh(t){return"string"==typeof t||t instanceof String?new Dh(t):new Bh(t)}Ph.prototype.popupData=function(){for(var t=[],e=this.aed,n=0;n<this.allColumns.length;n++){var r=this.allColumns[n],i=e.columns[n].name;"sequence"!==i&&"color"!==i&&r&&t.push({name:i,value:r})}return t};class Dh{constructor(t){this.data=t,this.ptr=0}nextLine(){var t=this.ptr,e=this.data.indexOf("\n",t),n=this.data;if(e>0)return this.ptr=e+1,e>t&&"\r"===n.charAt(e-1)?n.substring(t,e-1):n.substring(t,e);var r=n.length;return this.ptr=r,t>=r?void 0:n.substring(t)}}class Bh{constructor(t){this.data=t,this.length=this.data.length,this.ptr=0}nextLine(){var t,e;if(e="",!(this.ptr>=this.length)){for(var n=this.ptr;n<this.length;n++)if("\r"!==(t=String.fromCharCode(this.data[n]))){if("\n"===t)break;e+=t}return this.ptr=n+1,e}}}class zh{constructor(t){this.config=t,this.filePtr=0,this.bufferPtr=0,this.buffer}async nextLine(){let t;try{for(;;){const e=this.buffer?this.buffer.length:0;for(;this.bufferPtr<e;){const e=String.fromCharCode(this.buffer[this.bufferPtr++]);if("\r"!==e){if("\n"===e)return t;t=t?t+e:e}}if(this.eof)return t;await this.readNextBlock()}}catch(e){return console.warn(e),this.eof=!0,t}}async readNextBlock(){const t=gs(this.config,{range:{start:this.filePtr,size:26}}),e=$i(await go.loadArrayBuffer(this.config.url,t));if(0===e)this.eof=!0,this.buffer=void 0;else{const t=gs(this.config,{range:{start:this.filePtr,size:e}}),n=await go.loadArrayBuffer(this.config.url,t);n.byteLength<e&&(this.eof=!0),this.buffer=Wi(n),this.bufferPtr=0,this.filePtr+=n.byteLength}}}class Hh{constructor(t,e){var n;this.config=t||{},this.genome=e,this.indexURL=t.indexURL,this.indexed=t.indexed,je(this.config.url)?this.filename=this.config.url.name:ys(this.config.url)?(this.indexed=!1,this.dataURI=t.url):(n=ze(this.config.url),this.filename=t.filename||n.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 t=await this.getIndex();if(t&&t.lastBlockPosition){let e=0;const n=1e4;for(let n of t.chromosomeNames){const t=this.genome.getChromosome(n);t&&(e+=t.bpLength)}return Math.round(e/t.lastBlockPosition*n)}}}async readFeatures(t,e,n){return await this.getIndex()?(this.indexed=!0,this.loadFeaturesWithIndex(t,e,n)):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 t=await this.getIndex();if(!t)throw new Error("Unable to load index: "+this.config.indexURL);let e;if(t.tabix)e=new zh(this.config);else{const n=Object.values(t.chrIndex).flatMap((t=>t.blocks)).map((t=>t.max)).reduce(((t,e)=>Math.min(t,e)),Number.MAX_SAFE_INTEGER),r=gs(this.config,{bgz:t.tabix,range:{start:0,size:n}});e=Fh(await go.loadString(this.config.url,r))}return this.header=await this.parser.parseHeader(e),this.header}{const t=gs(this.config),e=await go.loadString(this.config.url,t);let n=Fh(e);return this.header=await this.parser.parseHeader(n),n=Fh(e),this.features=await this.parser.parseFeatures(n),this.header}}getParser(t){switch(t.format){case"vcf":return new kh(t);case"seg":return new gh("seg");case"mut":return new gh("mut");case"maf":return new gh("maf");case"gwas":return new Ch(t);case"aed":return new Lh(t);default:return new hh(t)}}async loadFeaturesNoIndex(){if(this.features){const t=this.features;return delete this.features,t}{const t=gs(this.config),e=await go.loadString(this.config.url,t);if(!this.header){const t=Fh(e);this.header=await this.parser.parseHeader(t)}const n=Fh(e);return await this.parser.parseFeatures(n)}}async loadFeaturesWithIndex(t,e,n){const r=this.config,i=this.parser,o=this.index.tabix,s=o?this.index.sequenceIndexMap[t]:t;if(void 0===s)return[];const a=this.genome,c=this.index.blocksForRange(s,e,n);if(c&&0!==c.length){const s=[];for(let l of c){const c=l.minv.block,h=l.minv.offset,u=l.maxv.offset;let f;if(o){let t=0;if(u>0){const e=gs(r,{range:{start:l.maxv.block,size:26}});t=$i(await go.loadArrayBuffer(r.url,e))}f=l.maxv.block+t}else f=l.maxv.block;const d=gs(r,{range:{start:c,size:f-c+1}});let p;if(o){p=Wi(await go.loadArrayBuffer(r.url,d))}else p=await go.loadString(r.url,d);const g=Fh(h?p.slice(h):p);let m=await i.parseFeatures(g);m=m.filter((t=>void 0===t._f));let v=!1;for(let r=0;r<m.length;r++){const i=m[r];if((a?a.getChromosomeName(i.chr):i.chr)!==t){if(0===s.length)continue;break}if(i.start>n){s.push(i);break}i.end>=e&&i.start<=n&&(v||(v=!0,r>0&&s.push(m[r-1])),s.push(i))}}return s.sort((function(t,e){return t.start-e.start})),s}return[]}async getIndex(){return this.index?this.index:this.config.indexURL?(this.index=await this.loadIndex(),this.index):void 0}async loadIndex(){return Ya(this.config.indexURL,this.config,this.genome)}async loadFeaturesFromDataURI(){if(this.features){const t=this.features;return delete this.features,t}{const t=Yi(this.dataURI);let e=Fh(t);return this.header=await this.parser.parseHeader(e),this.header instanceof String&&this.header.startsWith("##gff-version 3")&&(this.format="gff3"),e=Fh(t),this.features=await this.parser.parseFeatures(e),this.features}}}const Vh=ke;class jh{constructor(t){this.config=t}async readFeatures(t,e,n){let r;r="function"==typeof this.config.url?this.config.url({chr:t,start:e,end:n}):this.config.url.replace("$CHR",t).replace("$START",e).replace("$END",n);let i,o=Object.assign({},this.config);void 0!==this.config.body&&("function"==typeof this.config.body?o.body=this.config.body({chr:t,start:e,end:n}):o.body=this.config.body.replace("$CHR",t).replace("$START",e).replace("$END",n));const s=await go.load(r,o);if(s&&(i="function"==typeof this.config.parser?this.config.parser(s):Vh(s)?JSON.parse(s):s),this.config.mappings){let t=Object.keys(this.config.mappings);for(let e of i)for(let n of t)e[n]=e[this.config.mappings[n]]}return i}}const Uh=function(t,e){this.config=t,this.genome=e,this.expandQueryInterval=!1};Uh.prototype.readFeatures=function(t,e,n){const r=Math.max(0,Math.floor(e));let i=Math.ceil(n);if(this.genome){const e=this.genome.getChromosome(t);e&&i>e.bpLength&&(i=e.bpLength)}const o=this.config.url+"?db="+this.config.db+"&table="+this.config.tableName+"&chr="+t+"&start="+r+"&end="+i;return go.loadJson(o,this.config).then((function(t){return t?(t.forEach((function(t){t.hasOwnProperty("exonStarts")&&t.hasOwnProperty("exonEnds")&&t.hasOwnProperty("exonCount")&&t.hasOwnProperty("cdsStart")&&t.hasOwnProperty("cdsEnd")&&function(t){var e,n,r,i,o,s;e=t.exonCount,n=t.exonStarts.split(","),r=t.exonEnds.split(","),i=[];for(var a=0;a<e;a++){var c={start:o=parseInt(n[a]),end:s=parseInt(r[a])};(t.cdsStart>s||t.cdsEnd<t.cdsStart)&&(c.utr=!0),t.cdsStart>=o&&t.cdsStart<=s&&(c.cdStart=t.cdsStart),t.cdsEnd>=o&&t.cdsEnd<=s&&(c.cdEnd=t.cdsEnd),i.push(c)}t.exons=i}(t)})),t):null}))};const qh=["Name","gene_name","gene","gene_id","alias","locus","name"];class Wh{constructor(t){this.format=t.format,this.nameField=t.nameField,this.filterTypes=void 0===t.filterTypes?new Set(["chromosome"]):new Set(t.filterTypes)}combineFeatures(t,e){let n;const r=this.filterTypes;if(t=t.filter((t=>void 0===r||!r.has(t.type))),"gff3"===this.format){const e=this.combineFeaturesById(t);n=this.combineFeaturesByType(e)}else n=this.combineFeaturesByType(t);return n.sort((function(t,e){return t.start-e.start})),this.numberExons(n,e),this.nameFeatures(n),n}combineFeaturesById(t){const e=new Map,n=[];for(let r of t)if(zl(r.type)||Bl(r.type)||!r.id)n.push(r);else{let t=e.get(r.chr);t||(t=new Map,e.set(r.chr,t));let n=t.get(r.id);n?n.push(r):t.set(r.id,[r])}for(let t of e.values())for(let e of t.values())if(e.length>1){const t=e[0];t.exons=[];for(let n of e)t.start=Math.min(t.start,n.start),t.end=Math.max(t.end,n.end),t.exons.push({start:n.start,end:n.end});n.push(t)}else n.push(e[0]);return n}combineFeaturesByType(t){const e=t.filter((t=>"gene"===t.type||t.type.endsWith("_gene"))),n=Object.create(null);for(let t of e)n[t.id]=t;const r=Object.create(null),i=[],o=new Set,s=this.filterTypes;t=t.filter((t=>void 0===s||!s.has(t.type)));for(let e of t)if("biological_region"===e.type&&console.log(),Bl(e.type)){const t=e.id;if(void 0!==t){const s=new jl(e);r[t]=s,i.push(s),o.add(e);const a=n[e.parent];a&&(s.geneObject=a,o.add(a))}}for(let e of t)if(zl(e.type)){const t=l(e);if(t)for(let n of t){let s=r[n];if(!s&&"gtf"===this.format){const t=Object.assign({},e);t.type="transcript",s=new jl(t),r[n]=s,i.push(s)}if(void 0!==s){if(a=e.type,Nl.has(a))if(t.length>1){const t=new Vl(e);s.addExon(t)}else s.addExon(e);else s.addPart(e);o.add(e)}}}var a;i.forEach((function(t){"function"==typeof t.finish&&t.finish()}));const c=t.filter((t=>!o.has(t)));for(let t of c)i.push(t);return i;function l(t){return t.parent&&""!==t.parent.trim()?t.parent.trim().split(","):null}}numberExons(t,e){for(let n of t)if(n.exons&&(!e||n.end<=e.end&&n.start>e.start))for(let t=0;t<n.exons.length;t++){n.exons[t].number="-"===n.strand?n.exons.length-t:t+1}}nameFeatures(t){for(let e of t)if(e.attributeString){const t="gff3"===this.format?"=":" ",n=$l(e.attributeString,t),r=new Map(n);if(this.nameField)e.name=r.get(this.nameField);else for(let t of qh)if(r.has(t)){e.name=r.get(t);break}}}}const $h=function(t){this.config=t,this.url=t.url,this.tissueId=t.tissueSiteDetailId,this.indexed=!0,this.datasetId=t.datasetId||"gtex_v8"};$h.prototype.readFeatures=async function(t,e,n){let r=t.startsWith("chr")?t:"chr"+t,i=Math.floor(e),o=Math.ceil(n),s=this.datasetId,a=this.url+"?chromosome="+r+"&start="+i+"&end="+o+"&tissueSiteDetailId="+this.tissueId+"&datasetId="+s;const c=await go.loadJson(a,{withCredentials:this.config.withCredentials});return c&&c.singleTissueEqtl?(c.singleTissueEqtl.forEach((function(t){t.chr=t.chromosome,t.position=t.pos,t.start=t.pos-1,t.end=t.start+1,t.snp=t.snpId,t.geneName=t.geneSymbol,t.geneId=t.gencodeId})),c.singleTissueEqtl):void 0};const Gh=function(t){this.config=t,this.url=t.url,this.cellConditionId=t.cellConditionId,this.valueThreshold=t.valueThreshold?t.valueThreshold:.05};Gh.prototype.readFeatures=function(t,e,n){var r=this,i=this.url+"?chromosome="+t+"&start="+e+"&end="+n+"&cell_condition_id="+this.cellConditionId;return new Promise((function(t,e){go.loadJson(i,{withCredentials:r.config.withCredentials}).then((function(e){e?(e.eqtls.forEach((function(t){t.chr=t.chromosome,t.start=t.position,t.end=t.position+1})),t(e.eqtls)):t(null)})).catch((function(t){e(t)}))}))};const Zh=function(t,e){this.config=t,this.genome=e,this.url=t.url,this.variantSetId=t.variantSetId,this.callSetIds=t.callSetIds,this.includeCalls=void 0===t.includeCalls||t.includeCalls};Zh.prototype.readHeader=function(){var t=this;return t.header?Promise.resolve(t.header):(t.header={},!1===t.includeCalls?Promise.resolve(t.header):dc({url:t.url+"/callsets/search",fields:"nextPageToken,callSets(id,name)",body:{variantSetIds:Array.isArray(t.variantSetId)?t.variantSetId:[t.variantSetId],pageSize:"10000"},decode:function(e){if(t.callSetIds){var n=[],r=new Set;return t.callSetIds.forEach((function(t){r.add(t)})),e.callSets.forEach((function(t){r.has(t.id)&&n.push(t)})),n}return e.callSets}}).then((function(e){return t.header.callSets=e,t.header})))},Zh.prototype.readFeatures=function(t,e,n){const r=this,i=this.genome;return r.readHeader().then((function(t){return new Promise((function(t,e){r.chrAliasTable?t(r.chrAliasTable):r.readMetadata().then((function(e){r.metadata=e.metadata,r.chrAliasTable={},e.referenceBounds&&i&&e.referenceBounds.forEach((function(t){var e=t.referenceName,n=i.getChromosomeName(e);r.chrAliasTable[n]=e})),t(r.chrAliasTable)}))}))})).then((function(i){var o=i.hasOwnProperty(t)?i[t]:t;return dc({url:r.url+"/variants/search",fields:r.includeCalls?void 0:"nextPageToken,variants(id,variantSetId,names,referenceName,start,end,referenceBases,alternateBases,quality,filter,info)",body:{variantSetIds:Array.isArray(r.variantSetId)?r.variantSetId:[r.variantSetId],callSetIds:r.callSetIds?r.callSetIds:void 0,referenceName:o,start:e.toString(),end:n.toString(),pageSize:"10000"},decode:function(t){var e,n=[];return t.variants.forEach((function(t){e=function(t){var e,n=new bh;return n.chr=t.referenceName,n.start=parseInt(t.start),n.end=parseInt(t.end),n.pos=n.start+1,n.names=xh(t.names,"; "),n.referenceBases=t.referenceBases,n.alternateBases=xh(t.alternateBases),n.quality=t.quality,n.filter=xh(t.filter),n.info={},t.info&&Object.keys(t.info).forEach((function(e){var r,i=t.info[e];r=Array.isArray(i)?i.join(","):i,n.info[e]=r})),n.calls={},t.calls&&t.calls.forEach((function(t){e=t.callSetId,n.calls[e]=t})),init(n),n}(t),e.isRefBlock()||n.push(e)})),n}})}))},Zh.prototype.readMetadata=function(){return fc({url:this.url,entity:"variantsets",entityId:this.variantSetId})};class Xh{constructor(t){this.config=t}async readFeatures(t,e,n){const r=(await go.loadJson(this.config.url+"/variants/?count=50000")).records,i=[];for(let t of r)if(t.coordinates){t.id;const e=t.coordinates;e.chromosome&&i.push(new Yh(e.chromosome,e.start-1,e.stop,t)),e.chromosome2&&i.push(new Yh(e.chromosome2,e.start2-1,e.stop2,t))}return i}}class Yh{constructor(t,e,n,r){if(this.chr=t,this.start=e,this.end=n,this.id=r.id,this.entrezName=r.entrez_name,this.name=r.name,this.actionabilityScore=r.civic_actionability_score,r.coordinates.reference_bases&&(this.refBases=r.coordinates.reference_bases),r.coordinates.variant_bases&&(this.altBases=r.coordinates.variant_bases),r.variant_types&&(this.variant_types=r.variant_types),this.locationString=this.chr+":"+_e(this.start+1)+"-"+_e(this.end),void 0!==this.actionabilityScore){let t;if(this.actionabilityScore<=10)t=.2;else{const e=Math.min(30,this.actionabilityScore);t=.2+.8*Math.log10((e-10)/2)}this.alpha=t}}popupData(){const t=n("CIViC","https://civicdb.org/links/variants/"+this.id);this.refBases!==this.altBases&&this.refBases&&1===this.refBases.length&&this.altBases&&this.altBases.length;const e=[t];if(e.push({name:"Entrez",value:n(this.entrezName,"https://ghr.nlm.nih.gov/gene/"+this.entrezName)}),e.push({name:"Name",value:this.name}),this.variant_types&&this.variant_types.length>0){const t=1===this.variant_types.length?"Type":"Types";let n;for(let t of this.variant_types)n?n+=", "+t.display_name:n=t.display_name;e.push({name:t,value:n})}return e.push({name:"Actionability",value:this.actionabilityScore}),e.push({name:"Location",value:this.locationString}),e;function n(t,e){return"<a target='_blank' href='"+e+"'>"+t+"</a>"}}}function Kh(t,e){e=e||Number.MAX_SAFE_INTEGER;const n=[];t.sort((function(t,e){return t.start-e.start})),n.push(-1e3);for(let r of t){let t=0;const i=Math.min(n.length,e);for(t=0;t<i;t++)if(r.start>=n[t]){r.row=t,n[t]=r.end;break}r.row=t,n[t]=r.end}}class Qh extends ec{constructor(t,e){super(t,e),this.parser=new kh}async readHeader(){if(!this.header){const t=Fh(await this.readHeaderData());this.header=await this.parser.parseHeader(t,this.genome),this.chrAliasTable=this.header.chrAliasTable}return this.header}async readFeatures(t,e,n){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 r=this.chrAliasTable.has(t)?this.chrAliasTable.get(t):t;const i=Fh(await this.readData(r,e,n));return this.parser.parseFeatures(i)}}class Jh{constructor(t,e){this.config=t||{},this.genome=e,this.sourceType=void 0===t.sourceType?"file":t.sourceType,this.maxWGCount=t.maxWGCount||1e4;const n=new Set(["bigwig","bw","bigbed","bb","biginteract","biggenepred","bignarrowpeak","tdf"]);if(t.features&&Array.isArray(t.features)){let n=function(t,e){if(!t||0===t.length)return[];if(void 0===t[0].chr&&void 0!==t[0].chr1){const n=[];for(let r of t)e&&(r.chr1=e.getChromosomeName(r.chr1),r.chr2=e.getChromosomeName(r.chr2)),r.chr1===r.chr2?(r.chr=r.chr1,r.start=Math.min(r.start1,r.start2),r.end=Math.max(r.end1,r.end2)):n.push(r);for(let e of n){const n=Object.assign({dup:!0},e);t.push(n),e.chr=e.chr1,e.start=e.start1,e.end=e.end1,n.chr=n.chr2,n.start=n.start2,n.end=n.end2}}else if(e)for(let n of t)n.chr=e.getChromosomeName(n.chr);return t}(t.features,e);tu(n),t.mappings&&function(t,e){let n=Object.keys(e);t.forEach((function(t){n.forEach((function(n){t[n]=t[e[n]]}))}))}(n,t.mappings),this.queryable=!1,this.featureCache=new Mo(n,e)}else t.reader?(this.reader=t.reader,this.queryable=!1!==t.queryable):"ga4gh"===t.sourceType?(this.reader=new Zh(t,e),this.queryable=!0):"immvar"===t.sourceType?(this.reader=new Gh(t),this.queryable=!0):"eqtl"===t.type&&"gtex-ws"===t.sourceType?(this.reader=new $h(t),this.queryable=!0):"htsget"===t.sourceType?this.reader=new Qh(t,e):"ucscservice"===t.sourceType?(this.reader=new Uh(t.source),this.queryable=!0):"custom"===t.sourceType?(this.reader=new jh(t.source),this.queryable=!1!==t.source.queryable):"civic-ws"===t.sourceType?(this.reader=new Xh(t),this.queryable=!1):(this.reader=new Hh(t,e),void 0!==t.queryable?this.queryable=t.queryable:(n.has(t.format)||this.reader.indexed)&&(this.queryable=!0))}async defaultVisibilityWindow(){if(this.reader&&"function"==typeof this.reader.defaultVisibilityWindow)return this.reader.defaultVisibilityWindow()}async trackType(){const t=await this.getHeader();return t?t.type:void 0}async getHeader(){if(!this.header)if(this.reader&&"function"==typeof this.reader.readHeader){const t=await this.reader.readHeader();t?(this.header=t,t.format&&(this.config.format=t.format)):this.header={}}else this.header={};return this.header}async getFeatures({chr:t,start:e,end:n,bpPerPixel:r,visibilityWindow:i}){const o=this.genome,s=o?o.getChromosomeName(t):t,a="all"===s.toLowerCase();return(a&&!this.getWGFeatures||this.config.disableCache||!this.featureCache||!this.featureCache.containsRange(new Gs(s,e,n)))&&await this.loadFeatures(s,e,n,i),a?(this.wgFeatures||(this.queryable?this.wgFeatures=[]:this.wgFeatures=this.getWGFeatures(this.featureCache.getAllFeatures())),this.wgFeatures):this.featureCache.queryFeatures(s,e,n)}getAllFeatures(){return this.queryable?[]:this.getWGFeatures(this.featureCache.getAllFeatures())}async loadFeatures(t,e,n,r){const i=this.reader;let o=e,s=n;if((!r||r<=0)&&!1!==this.config.expandQuery){const e=this.genome?this.genome.getChromosome(t):void 0;o=0,s=Math.max(e?e.bpLength:Number.MAX_SAFE_INTEGER,n)}else if(r>n-e&&!1!==this.config.expandQuery){const t=Math.min(4.1*(n-e),r);o=Math.max(0,(e+n)/2-t),s=e+t}let a=await i.readFeatures(t,o,s);void 0===this.queryable&&(this.queryable=i.indexed);const c=this.queryable?new Gs(t,o,s):void 0;if(a){if(!1===this.config.assembleGFF||"gtf"!==this.config.format&&"gff3"!==this.config.format&&"gff"!==this.config.format||(a=new Wh(this.config).combineFeatures(a,c)),"wig"!==this.config.format&&"junctions"!==this.config.type){tu(a,this.config.maxRows||Number.MAX_SAFE_INTEGER)}this.featureCache=new Mo(a,this.genome,c),(this.config.searchable||this.config.searchableFields)&&this.addFeaturesToDB(a)}else this.featureCache=new Mo([],c)}addFeaturesToDB(t){for(let e of t)if(e.name&&(this.genome.featureDB[e.name.toUpperCase()]=e),e.gene&&e.gene.name&&(this.genome.featureDB[e.gene.name.toUpperCase()]=e),this.config.searchableFields)for(let t of this.config.searchableFields){const n=e.getAttributeValue(t);n&&(n.indexOf(" ")>0?(this.genome.featureDB[n.replaceAll(" ","+").toUpperCase()]=e,this.genome.featureDB[n.replaceAll(" ","%20").toUpperCase()]=e):this.genome.featureDB[n.toUpperCase()]=e)}}getWGFeatures(t){const e=t=>{const e=Object.assign({},t);return e.chr="all",e.start=n.getGenomeCoordinate(t.chr,t.start),e.end=n.getGenomeCoordinate(t.chr,t.end),e._f=t,e.exons&&delete e.exons,e},n=this.genome,r=new Set(n.wgChromosomeNames),i=[];let o=0;const s=this.maxWGCount;for(let a of n.wgChromosomeNames){const c=t[a];if(c)for(let t of c){let a=n.getChromosomeName(t.chr);if(r.has(a))if(i.length<s)i.push(e(t));else{const n=s/(o+1);if(Math.random()<n){i[Math.floor(Math.random()*(s-1))]=e(t)}}o++}}return i.sort((function(t,e){return t.start-e.start})),i}}function tu(t,e){if(e=e||1e3,null==t||0===t.length)return;const n={},r=[];for(let e of t){const t=e.chr;let i=n[t];i||(i=[],n[t]=i,r.push(t)),i.push(e)}for(let t of r)Kh(n[t],e)}class eu{constructor(t,e,n){this.path=t.url,this.bufferSize=n||512e3,this.range={start:-1,size:-1},this.config=t}async dataViewForRange(t,e){if(!(this.data&&this.range.start<=t.start&&this.range.start+this.range.size>=t.start+t.size)){let e;e=t.size?Math.max(this.bufferSize,t.size):this.bufferSize;const n={start:t.start,size:e},r=await go.loadArrayBuffer(this.path,gs(this.config,{range:n}));this.data=r,this.range=n}const n=this.data.byteLength,r=t.start-this.range.start;return e?new Uint8Array(this.data,r,n-r):new DataView(this.data,r,n-r)}}class nu{constructor(t,e){this.path=t.url,this.format=t.format||"bigwig",this.genome=e,this.rpTreeCache={},this.config=t,this.loader=ys(this.path)?new du(this.path):go}async readWGFeatures(t,e){await this.loadHeader();const n=this.chromTree.idToChrom.length-1,r=this.chromTree.idToChrom[0],i=this.chromTree.idToChrom[n];return this.readFeatures(r,0,i,Number.MAX_VALUE,t,e)}async readFeatures(t,e,n,r,i,o){await this.loadHeader();const s=this.chromTree.chromToID[t],a=this.chromTree.chromToID[n];if(void 0===s||void 0===a)return[];let c,l;if("bigwig"===this.type){const t=await this.getZoomHeaders();let e=i?function(t,e){let n;for(let r=0;r<e.length;r++){const i=e[r];if(i.reductionLevel<t){n=i;break}}return n}(i,t):void 0;e?(c=e.indexOffset,l=fu):(c=this.header.fullIndexOffset,l=hu)}else c=this.header.fullIndexOffset,l=uu.call(this);const h=await this.loadRPTree(c),u=await h.findLeafItemsOverlapping(s,e,a,r);if(u&&0!==u.length){let t=Number.MAX_VALUE,n=0;for(let e of u)t=Math.min(t,e.dataOffset),n=Math.max(n,e.dataOffset+e.dataSize);const i=n-t,c=await this.loader.loadArrayBuffer(this.config.url,gs(this.config,{range:{start:t,size:i}})),h=[];for(let n of u){const i=new Uint8Array(c,n.dataOffset-t,n.dataSize);let u;u=this.header.uncompressBuffSize>0?qi(i):i,l.call(this,new DataView(u.buffer),s,e,a,r,h,this.chromTree.idToChrom,o)}return h.sort((function(t,e){return t.start-e.start})),h}return[]}async getZoomHeaders(){return this.zoomLevelHeaders||await this.loadHeader(),this.zoomLevelHeaders}async loadHeader(){if(this.header)return this.header;{let t,e=await this.loader.loadArrayBuffer(this.path,gs(this.config,{range:{start:0,size:64}}));this.littleEndian=!0;let n=new Wa(new DataView(e)),r=n.getUInt();if(2291137574===r)this.type="bigwig";else if(2273964779===r)this.type="bigbed";else{this.littleEndian=!1,n.littleEndian=!1,n.position=0;let t=n.getUInt();654085990===t?this.type="bigwig":3958540679===t&&(this.type="bigbed")}t={bwVersion:n.getUShort(),nZoomLevels:n.getUShort(),chromTreeOffset:n.getLong(),fullDataOffset:n.getLong(),fullIndexOffset:n.getLong(),fieldCount:n.getUShort(),definedFieldCount:n.getUShort(),autoSqlOffset:n.getLong(),totalSummaryOffset:n.getLong(),uncompressBuffSize:n.getInt(),extensionOffset:n.getLong()};const i=64;let o={start:i,size:t.fullDataOffset-i+5};e=await this.loader.loadArrayBuffer(this.path,gs(this.config,{range:o}));const s=t.nZoomLevels;n=new Wa(new DataView(e)),this.zoomLevelHeaders=[],this.firstZoomDataOffset=Number.MAX_SAFE_INTEGER;for(let t=1;t<=s;t++){const e=s-t,r=new ru(e,n);this.firstZoomDataOffset=Math.min(r.dataOffset,this.firstZoomDataOffset),this.zoomLevelHeaders[e]=r}if(t.autoSqlOffset>0){n.position=t.autoSqlOffset-i;const e=n.getString();e&&(this.autoSql=function(t){let e;const n=[];let r=!1;const i=t.trim().split(/\s*[\r\n]+\s*/g);for(let t of i)if(t.startsWith("table"))e=t.split(/\s+/)[1].trim();else if(t.startsWith("("))r=!0;else if(t.startsWith(")"));else if(r&&t.length>0){const e=t.indexOf(";"),r=t.substr(0,e).split(/\s+/),i=t.substr(e+1).replace(/"/g,"").trim();n.push({type:r[0],name:r[1],description:i})}return{table:e,fields:n}}(e))}if(t.totalSummaryOffset>0&&(n.position=t.totalSummaryOffset-i,this.totalSummary=new cu(n)),!(t.chromTreeOffset>0))throw"BigWig chromosome tree offset <= 0";return n.position=t.chromTreeOffset-i,this.chromTree=new su(n,i,this.genome),n.position=t.fullDataOffset-i,t.dataCount=n.getInt(),this.setDefaultVisibilityWindow(t),this.header=t,this.header}}async loadRPTree(t){let e=this.rpTreeCache[t];return e||(e=new iu(t,this.config,this.littleEndian,this.loader),await e.load(),this.rpTreeCache[t]=e,e)}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(t){if("bigwig"===this.type)this.visibilityWindow=-1;else{let e=this.genome?this.genome.getGenomeLength():3088286401;this.visibilityWindow=t.dataCount<1e3?-1:e/t.dataCount*1e3}}}class ru{constructor(t,e){this.index=t,this.reductionLevel=e.getInt(),this.reserved=e.getInt(),this.dataOffset=e.getLong(),this.indexOffset=e.getLong()}}class iu{constructor(t,e,n,r){this.config=e,this.loader=r,this.fileOffset=t,this.path=e.url,this.littleEndian=n}async load(){const t=this.fileOffset+48,e=ys(this.path)?this.loader:new eu(this.config,512e3);return this.rootNode=await this.readNode(t,e),this}async readNode(t,e){let n=await e.dataViewForRange({start:t,size:4},!1),r=new Wa(n,this.littleEndian);const i=1===r.getByte();r.getByte();const o=r.getUShort();let s={start:t+=4,size:o*(i?32:24)};n=await e.dataViewForRange(s,!1);const a=new Array(o);if(r=new Wa(n),i){for(let t=0;t<o;t++){let e={isLeaf:!0,startChrom:r.getInt(),startBase:r.getInt(),endChrom:r.getInt(),endBase:r.getInt(),dataOffset:r.getLong(),dataSize:r.getLong()};a[t]=e}return new ou(a)}for(let t=0;t<o;t++){let e={isLeaf:!1,startChrom:r.getInt(),startBase:r.getInt(),endChrom:r.getInt(),endBase:r.getInt(),childOffset:r.getLong()};a[t]=e}return new ou(a)}async findLeafItemsOverlapping(t,e,n,r){let i=this;return new Promise((function(o,s){let a=[],c=new Set,l=ys(i.path)?i.loader:new eu(i.config,512e3);c.add(0),function h(u,f){if(au(u,t,e,n,r)){u.items.forEach((function(o){au(o,t,e,n,r)&&(o.isLeaf?a.push(o):o.childNode?h(o.childNode):(c.add(o.childOffset),i.readNode(o.childOffset,l).then((function(t){o.childNode=t,h(t,o.childOffset)})).catch(s)))}))}void 0!==f&&c.delete(f);0===c.size&&o(a)}(i.rootNode,0)}))}}class ou{constructor(t){this.items=t;let e,n,r=Number.MAX_SAFE_INTEGER,i=0,o=Number.MAX_SAFE_INTEGER,s=0;for(e=0;e<t.length;e++)n=t[e],r=Math.min(r,n.startChrom),i=Math.max(i,n.endChrom),o=Math.min(o,n.startBase),s=Math.max(s,n.endBase);this.startChrom=r,this.endChrom=i,this.startBase=o,this.endBase=s}}class su{constructor(t,e,n){let r=t.getInt(),i=t.getInt(),o=t.getInt(),s=t.getInt(),a=t.getLong(),c=t.getLong(),l={},h=[];this.header={magic:r,blockSize:i,keySize:o,valSize:s,itemCount:a,reserved:c},this.chromToID=l,this.idToChrom=h,function t(r,i){i>=0&&(r.position=i);let s=r.getByte();r.getByte();let a,c,u,f,d,p,g=r.getUShort();if(1===s)for(a=0;a<g;a++)c=r.getFixedLengthTrimmedString(o),u=r.getInt(),r.getInt(),n&&(c=n.getChromosomeName(c)),l[c]=u,h[u]=c;else for(a=0;a<g;a++)c=r.getFixedLengthTrimmedString(o),f=r.getLong(),d=f-e,p=r.position,t(r,d),r.position=p}(t,-1)}}function au(t,e,n,r,i){return t?(r>t.startChrom||r===t.startChrom&&i>=t.startBase)&&(e<t.endChrom||e===t.endChrom&&n<=t.endBase):(console.log("null item for "+e+" "+n+" "+i),!1)}class cu{constructor(t){t?(this.basesCovered=t.getLong(),this.minVal=t.getDouble(),this.maxVal=t.getDouble(),this.sumData=t.getDouble(),this.sumSquares=t.getDouble(),lu.call(this)):(this.basesCovered=0,this.minVal=0,this.maxVal=0,this.sumData=0,this.sumSquares=0,this.mean=0,this.stddev=0)}}function lu(){let t=this.basesCovered;if(t>0){this.mean=this.sumData/t,this.stddev=Math.sqrt(this.sumSquares/(t-1));let e=this.minVal<0?this.mean-2*this.stddev:0,n=this.maxVal>0?this.mean+2*this.stddev:0;this.defaultRange={min:e,max:n}}}function hu(t,e,n,r,i,o,s){const a=new Wa(t),c=a.getInt();let l=a.getInt(),h=a.getInt();const u=a.getInt(),f=a.getInt(),d=a.getByte();a.getByte();let p=a.getUShort();if(c>=e&&c<=r)for(;p-- >0;){let t;switch(d){case 1:l=a.getInt(),h=a.getInt(),t=a.getFloat();break;case 2:l=a.getInt(),t=a.getFloat(),h=l+f;break;case 3:t=a.getFloat(),h=l+f,l+=u}if(!(c<e||c===e&&h<n)){if(c>r||c===r&&l>=i)break;if(Number.isFinite(t)){const e=s[c];o.push({chr:e,start:l,end:h,value:t})}}}}function uu(){const t=function(t,e,n,r){if("biginteract"===r||n&&"chromatinInteract"===n.table||"interact"===n.table)return function(t,e){return t.chr1=e[5],t.start1=Number.parseInt(e[6]),t.end1=Number.parseInt(e[7]),t.chr2=e[10],t.start2=Number.parseInt(e[11]),t.end2=Number.parseInt(e[12]),t.name=e[0],t.score=Number(e[1]),t.value=Number(e[2]),t.color="."===e[4]?void 0:"0"===e[4]?"rgb(0,0,0)":e[4],t};{const r=t-3;return function(i,o){if(r>0&&(i.name=o[0]),r>1&&(i.score=Number(o[1])),r>2&&(i.strand=o[2]),r>3&&(i.cdStart=parseInt(o[3])),r>4&&(i.cdEnd=parseInt(o[4])),r>5&&"."!==o[5]&&"0"!==o[5]&&"-1"!==o[5]){const t=no.createColorString(o[5]);i.color=t.startsWith("rgb")?t:void 0}if(r>8){const t=parseInt(o[6]),e=o[7].split(","),n=o[8].split(","),r=[];for(let o=0;o<t;o++){const t=i.start+parseInt(n[o]),s=t+parseInt(e[o]);r.push({start:t,end:s})}!function(t,e,n){for(let r of t){const t=r.end,i=r.start;t<e||i>n?r.utr=!0:(e>=i&&e<=t&&(r.cdStart=e),n>=i&&n<=t&&(r.cdEnd=n))}}(r,i.cdStart,i.cdEnd),i.exons=r}if(n)for(let r=t;r<e;r++)if(r<n.fields.length){const t=n.fields[r].name,e=o[r-3];i[t]=e}}}}(this.header.definedFieldCount,this.header.fieldCount,this.autoSql,this.format);return function(e,n,r,i,o,s,a){const c=new Wa(e);for(;c.remLength()>=13;){const e=c.getInt(),l=a[e],h=c.getInt(),u=c.getInt(),f=c.getString();if(!(e<n||e===n&&u<r)){if(e>i||e===i&&h>=o)break;if(u>0){const e={chr:l,start:h,end:u};s.push(e);const n=f.split("\t");t(e,n)}}}}}function fu(t,e,n,r,i,o,s,a){const c=new Wa(t);for(;c.remLength()>=32;){const t=c.getInt(),l=s[t],h=c.getInt(),u=c.getInt(),f=c.getInt(),d=c.getFloat(),p=c.getFloat(),g=c.getFloat();let m;switch(c.getFloat(),a){case"min":m=d;break;case"max":m=p;break;default:m=0===f?0:g/f}if(!(t<e||t===e&&u<n)){if(t>r||t===r&&h>=i)break;Number.isFinite(m)&&o.push({chr:l,start:h,end:u,value:m})}}}class du{constructor(t){this.data=Yi(t).buffer}loadArrayBuffer(t,e){const n=e.range;return n?this.data.slice(n.start,n.start+n.size):this.data}async dataViewForRange(t,e){const n=Math.min(this.data.byteLength-t.start,t.size);return e?new Uint8Array(this.data,t.start,n):new DataView(this.data,t.start,n)}}class pu{constructor(t,e){this.reader=new nu(t,e),this.genome=e,this.format=t.format||"bigwig",this.wgValues={}}async getFeatures({chr:t,start:e,end:n,bpPerPixel:r,windowFunction:i}){const o="all"===t.toLowerCase()?await this.getWGValues(i):await this.reader.readFeatures(t,e,t,n,r,i);return"bigwig"===this.reader.type||Kh(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(t){const e=this.genome;if(this.wgValues[t])return this.wgValues[t];{const n=e.getGenomeLength()/1e3,r=await this.reader.readWGFeatures(n,t);let i=[];for(let t of r){const n=t.chr,r=e.getCumulativeOffset(n),o=Object.assign({},t);o.chr="all",o.start=r+t.start,o.end=r+t.end,i.push(o)}return this.wgValues[t]=i,i}}supportsWholeGenome(){return"bigwig"===this.reader.type}async trackType(){return this.reader.getTrackType()}}class gu{constructor(t,e){this.config=t,this.genome=e,this.path=t.url,this.groupCache={},this.datasetCache={}}async readHeader(){if(void 0!==this.magic)return this;let t=await go.loadArrayBuffer(this.path,gs(this.config,{range:{start:0,size:64e3}})),e=new Wa(new DataView(t));if(this.magic=e.getInt(),this.version=e.getInt(),this.indexPos=e.getLong(),this.indexSize=e.getInt(),e.getInt(),this.version>=2){let t=e.getInt();for(this.windowFunctions=[];t-- >0;)this.windowFunctions.push(e.getString())}this.trackType=e.getString(),this.trackLine=e.getString();let n=e.getInt();for(this.trackNames=[];n-- >0;)this.trackNames.push(e.getString());this.genomeID=e.getString(),this.flags=e.getInt(),this.compressed=0!=(1&this.flags),t=await go.loadArrayBuffer(this.path,gs(this.config,{range:{start:this.indexPos,size:this.indexSize}})),e=new Wa(new DataView(t)),this.datasetIndex={};let r=e.getInt();for(;r-- >0;){const t=e.getString(),n=e.getLong(),r=e.getInt();this.datasetIndex[t]={position:n,size:r}}for(this.groupIndex={},r=e.getInt();r-- >0;){const t=e.getString(),n=e.getLong(),r=e.getInt();this.groupIndex[t]={position:n,size:r}}return this}async readDataset(t,e,n){const r=t+"_"+e+"_"+n;if(this.datasetCache[r])return this.datasetCache[r];{await this.readHeader();const i=this.version<2?"":"/"+e,o="all"===t.toLowerCase()||void 0===n?"0":n.toString();let s;s="raw"===e?"/"+t+"/raw":"/"+t+"/z"+o+i;const a=this.datasetIndex[s];if(void 0===a)return;const c=await go.loadArrayBuffer(this.path,gs(this.config,{range:{start:a.position,size:a.size}}));if(!c)return;const l=new Wa(new DataView(c));let h=l.getInt();const u={};for(;h-- >0;)u[l.getString()]=l.getString();const f=l.getString(),d=l.getFloat();let p=l.getInt();const g=[];for(;p-- >0;)g.push({position:l.getLong(),size:l.getInt()});const m={name:s,attributes:u,dataType:f,tileWidth:d,tiles:g};return this.datasetCache[r]=m,m}}async readRootGroup(){const t=this.genome,e=this.groupCache["/"];if(e)return e;{const e=await this.readGroup("/"),n=e.chromosomes,r=e.maxZoom;r&&(this.maxZoom=Number(r));const i=e.totalCount;i&&(e.totalCount=Number(i));const o={};return n&&n.split(",").forEach((function(e){const n=t.getChromosomeName(e);o[n]=e})),this.chrAliasTable=o,this.groupCache["/"]=e,e}}async readGroup(t){const e=this.groupCache[t];if(e)return e;{await this.readHeader();const e=this.groupIndex[t];if(void 0===e)return;const n=await go.loadArrayBuffer(this.path,gs(this.config,{range:{start:e.position,size:e.size}}));if(!n)return;const r=new Wa(new DataView(n)),i={name:t};let o=r.getInt();for(;o-- >0;){const t=r.getString(),e=r.getString();i[t]=e}return this.groupCache[t]=i,i}}async readTiles(t,e){if(t.sort((function(t,e){return t.position-e.position})),0===(t=t.filter((function(t){return t.size>0}))).length)return Promise.resolve([]);const n=t[0],r=t[t.length-1],i=n.position,o=r.position+r.size-i,s=await go.loadArrayBuffer(this.path,gs(this.config,{range:{start:i,size:o}})),a=[];for(let n of t){const t=n.position-i,r=n.size;if(r>0){let n;if(this.compressed){n=qi(s.slice(t,t+r)).buffer}else n=s.slice(t,t+r);const i=new Wa(new DataView(n)),o=i.getString();let c;switch(o){case"fixedStep":c=mu(i,e);break;case"variableStep":c=vu(i,e);break;case"bed":case"bedWithName":c=bu(i,e,o);break;default:throw"Unknown tile type: "+o}a.push(c)}}return a}async readTile(t,e){let n=await go.loadArrayBuffer(this.path,gs(this.config,{range:{start:t.position,size:t.size}}));if(this.compressed){n=qi(n).buffer}const r=new Wa(new DataView(n)),i=r.getString();switch(i){case"fixedStep":return mu(r,e);case"variableStep":return vu(r,e);case"bed":case"bedWithName":return bu(r,e,i);default:throw"Unknown tile type: "+i}}}function mu(t,e){const n=t.getInt(),r=t.getInt(),i=t.getFloat(),o=[];let s=e;for(;s-- >0;){let e=n;const r=[];for(;e-- >0;)r.push(t.getFloat());o.push(r)}return{type:"fixedStep",start:r,span:i,data:o,nTracks:e,nPositions:n}}function vu(t,e){const n=t.getInt(),r=t.getFloat(),i=t.getInt(),o=[];let s=i;for(;s-- >0;)o.push(t.getInt());t.getInt();const a=[];let c=e;for(;c-- >0;){s=i;const e=[];for(;s-- >0;)e.push(t.getFloat());a.push(e)}return{type:"variableStep",tileStart:n,span:r,start:o,data:a,nTracks:e,nPositions:i}}function bu(t,e,n){const r=t.getInt();let i=r;const o=[];for(;i-- >0;)o.push(t.getInt());i=r;const s=[];for(;i-- >0;)s.push(t.getInt());t.getInt();const a=[];let c=e;for(;c-- >0;){let e=r;const n=[];for(;e-- >0;)n.push(t.getFloat());a.push(n)}if("bedWithName"===n){i=r;const e=[];for(;i-- >0;)e.push(t.getString())}return{type:n,start:o,end:s,data:a,nTracks:e,nPositions:r}}class wu{constructor(t,e){this.genome=e,this.windowFunction=t.windowFunction||"mean",this.reader=new gu(t,e)}async getFeatures({chr:t,start:e,end:n,bpPerPixel:r}){if("all"===t.toLowerCase()){const t=[],e=this.genome;if(this.genome.wgChromosomeNames)for(let n of e.wgChromosomeNames){const i=e.getChromosome(n).bpLength;r=i/1e3;const o=await this._getFeatures(n,0,i,r);if(o)for(let n of o){const r=Object.assign({},n);r.chr="all",r.start=e.getGenomeCoordinate(n.chr,n.start),r.end=e.getGenomeCoordinate(n.chr,n.end),r._f=n,t.push(r)}}return t}return this._getFeatures(t,e,n,r)}async _getFeatures(t,e,n,r){const i=new Gs(t,e,n),o=this.genome;if(!this.rootGroup&&(this.rootGroup=await this.reader.readRootGroup(),!this.normalizationFactor)){const t=this.rootGroup.totalCount;t&&(this.normalizationFactor=1e6/t)}i.bpPerPixel=r;const s=function(t,e,n){var r=n.getChromosome(t).bpLength;return Math.ceil(Math.log(Math.max(0,r/(700*e)))/_u)}(t,r,o);let a=this.reader.chrAliasTable[t],c=this.reader.maxZoom;void 0===a&&(a=t),void 0===c&&(c=-1);const l=s>c?"raw":this.windowFunction,h=await this.reader.readDataset(a,l,s);if(null==h)return[];const u=h.tileWidth,f=Math.floor(e/u),d=Math.floor(n/u),p=await this.reader.readTiles(h.tiles.slice(f,d+1),1),g=[];for(let i of p)switch(i.type){case"bed":yu(i,t,e,n,r,g);break;case"variableStep":xu(i,t,e,n,r,g);break;case"fixedStep":ku(i,t,e,n,r,g);break;default:throw"Unknown tile type: "+i.type}return g.sort((function(t,e){return t.start-e.start})),g}get supportsWholeGenome(){return!0}}function yu(t,e,n,r,i,o){const s=t.nPositions,a=t.start,c=t.end,l=t.data[0];for(let t=0;t<s;t++){const i=a[t],s=c[t];if(!(s<n)){if(i>r)break;o.push({chr:e,start:i,end:s,value:l[t]})}}}function xu(t,e,n,r,i,o){const s=t.nPositions,a=t.start,c=t.span,l=t.data[0];for(let t=0;t<s;t++){const i=a[t],s=i+c;if(!(s<n)){if(i>r)break;o.push({chr:e,start:i,end:s,value:l[t]})}}}function ku(t,e,n,r,i,o){const s=t.nPositions;let a=t.start;const c=t.span,l=t.data[0];for(let t=0;t<s;t++){const i=a+c;if(a>r)break;i>=n&&(Number.isNaN(l[t])||o.push({chr:e,start:a,end:i,value:l[t]})),a=i}}var _u=Math.log(2);const Su=new Set(["bigwig","bw","bigbed","bb","biginteract","biggenepred","bignarrowpeak"]);function Cu(t,e){const n=t.format?t.format.toLowerCase():void 0;return Su.has(n)?new pu(t,e):"tdf"===n?new wu(t,e):new Jh(t,e)}const Eu={getTissueInfo:function(t,e){let n=(e=e||"https://gtexportal.org/rest/v1")+"/dataset/tissueInfo?datasetId="+(t=t||"gtex_v8");return go.loadJson(n,{})},trackConfiguration:function(t,e){return{type:"eqtl",sourceType:"gtex-ws",url:(e=e||"https://gtexportal.org/rest/v1")+"/association/singleTissueEqtlByLocation",tissueSiteDetailId:t.tissueSiteDetailId,name:t.tissueSiteDetailId.split("_").join(" "),visibilityWindow:25e4}}};function Au(t,e,n){let r=(t.start-e)/n,i=(t.end-e)/n,o=i-r;return o<3&&(o=3,r-=1.5),{px:r,px1:i,pw:o}}function Tu(t,e,n,r,i,o){try{i.save(),i.fillStyle=this.defaultColor,i.strokeStyle=this.defaultColor;const r=Mu.call(this,t);let s,a;i.fillStyle=r,i.strokeStyle=r,"SQUISHED"===this.displayMode&&void 0!==t.row?(s=this.featureHeight/2,a=this.margin+this.squishedRowHeight*t.row):"EXPANDED"===this.displayMode&&void 0!==t.row?(s=this.featureHeight,a=this.margin+this.expandedRowHeight*t.row):(s=this.featureHeight,a=this.margin);const c=o.pixelWidth,l=a+s/2,h=s/2,u=l-h/2,f=t.exons?t.exons.length:0,d=Au(t,e,n),p=this.arrowSpacing,g="+"===t.strand?1:"-"===t.strand?-1:0;if(0===f){const t=Math.max(0,d.px),e=Math.min(c,d.px1),n=e-t;if(i.fillRect(t,a,n,s),0!==g){i.fillStyle="white",i.strokeStyle="white";for(let n=t+p/2;n<e;n+=p)ls.strokeLine(i,n-2*g,l-2,n,l),ls.strokeLine(i,n-2*g,l+2,n,l);i.fillStyle=r,i.strokeStyle=r}}else{ls.strokeLine(i,d.px+1,l,d.px1-1,l);const o=Math.max(0,d.px)+p/2,m=Math.min(c,d.px1);for(let t=o;t<m;t+=p)ls.strokeLine(i,t-2*g,l-2,t,l),ls.strokeLine(i,t-2*g,l+2,t,l);for(let o=0;o<f;o++){const f=t.exons[o];let d,m=Math.round((f.start-e)/n),v=Math.round((f.end-e)/n),b=Math.max(1,v-m);if(!(m+b<0)){if(m>c)break;if(f.utr)i.fillRect(m,u,b,h);else if(f.cdStart&&(d=Math.round((f.cdStart-e)/n),i.fillRect(m,u,d-m,h),b-=d-m,m=d),f.cdEnd&&(d=Math.round((f.cdEnd-e)/n),i.fillRect(d,u,v-d,h),b-=v-d,v=d),b=Math.max(b,1),i.fillRect(m,a,b,s),b>p+5&&0!==g){i.fillStyle="white",i.strokeStyle="white";for(let t=m+p/2;t<v;t+=p)ls.strokeLine(i,t-2*g,l-2,t,l),ls.strokeLine(i,t-2*g,l+2,t,l);i.fillStyle=r,i.strokeStyle=r}}}}o.drawLabel&&"SQUISHED"!==this.displayMode&&Lu.call(this,i,t,d.px,d.px1,a,o.referenceFrame,o)}finally{i.restore()}}function Lu(t,e,n,r,i,o,s){try{t.save();let a=e.name;if(void 0===a&&e.gene&&(a=e.gene.name),void 0===a&&(a=e.id||e.ID),!a||"."===a)return;let c=s.pixelXOffset||0;const l=Math.max(n,-c),h=(l+Math.min(r,-c+s.viewportWidth))/2;let u;"COLLAPSED"===this.displayMode&&"SLANT"===this.labelDisplayMode&&(u={rotate:{angle:45}});const f=function(t,e){return e?t+20:t+25}(i,u);let d,p=Mu.call(this,e),g=!1;o.selection&&Eu.gtexLoaded&&(g=!0,d=o.selection.colorForGene(a));const m={textAlign:"SLANT"===this.labelDisplayMode?void 0:"center",fillStyle:d||p,strokeStyle:d||p},v=t.measureText(a),b=h-v.width/2,w=h+v.width/2;(s.labelAllFeatures||b>s.rowLastLabelX[e.row]||g)&&(s.rowLastLabelX[e.row]=w,ls.fillText(t,a,h,f,m,u))}finally{t.restore()}}function Mu(t){let e;if(this.altColor&&"-"===t.strand)e="function"==typeof this.altColor?this.altColor(t):this.altColor;else if(this.color)e="function"==typeof this.color?this.color(t):this.color;else if(this.colorBy){const n=t.getAttributeValue?t.getAttributeValue(this.colorBy):t[this.colorBy];e=this.colorTable.getColor(n)}else e=t.color?t.color:this.defaultColor;if(t.alpha&&1!==t.alpha)e=no.addAlpha(e,t.alpha);else if(this.useScore&&t.score&&!Number.isNaN(t.score)){const n=function(t,e,n){const r=(e-t)/9,i=Math.floor((n-t)/r);return Math.min(1,.2+.8*i/9)}(this.config.min?this.config.min:0,this.config.max?this.config.max:1e3,t.score);t.alpha=n,e=no.addAlpha(e,n)}return e}const Ru=new Set(["nonsense","missense","stop-loss","frameshift","cds-indel"]),Iu=new Set(["coding-synon"]),Nu=new Set(["splice-3","splice-5"]),Pu=new Set(["untranslated-5","untranslated-3"]);function Ou(t,e,n,r,i){var o,s,a,c,l=Au(t,e,n),h=this.margin,u=this.snpColors.length;switch(o="squished"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight,this.colorBy){case"function":c=t.func,s=c.split(",").map((function(t){return Ru.has(t)||Nu.has(t)?u-1:Iu.has(t)?u-2:Pu.has(t)?u-3:0})).reduce((function(t,e){return Math.max(t,e)}));break;case"class":s="deletion"===(a=t.class)?u-1:"mnp"===a?u-2:"microsatellite"===a||"named"===a?u-3:0}i.fillStyle=this.snpColors[s],i.fillRect(l.px,h,l.pw,o)}function Fu(t,e,n,r,i){const o="EXPANDED"===this.displayMode?this.expandedRowHeight:this.squishedRowHeight;let s=this.margin;"COLLAPSED"!==this.displayMode&&void 0!==t.row&&(s+=t.row*o);const a=s+.5*o,c=a-.5*o,l=a+.5*o,h=Math.round((t.junction_left-e)/n),u=Math.round((t.junction_right-e)/n);i.beginPath(),i.moveTo(h,a),i.bezierCurveTo(h,c,u,c,u,a),i.lineWidth=1+Math.log(t.num_junction_reads)/Math.log(2),i.strokeStyle="blue",i.stroke();const f=t.spanning_frag_coords;for(let t=0;t<f.length;t++){const r=f[t],o=Math.round((r.left-e)/n),s=Math.round((r.right-e)/n);i.beginPath(),i.moveTo(o,a),i.bezierCurveTo(o,l,s,l,s,a),i.lineWidth=1,i.strokeStyle="purple",i.stroke()}}class Du extends bc{constructor(t,e){super(t,e)}init(t){super.init(t),this.type=t.type||"annotation",this.maxRows=void 0===t.maxRows?1e3:t.maxRows,this.displayMode=t.displayMode||"EXPANDED",this.labelDisplayMode=t.labelDisplayMode,t._featureSource?(this.featureSource=t._featureSource,delete t._featureSource):this.featureSource=t.featureSource?t.featureSource:Cu(t,this.browser.genome),this.autoHeight=t.autoHeight,this.margin=void 0===t.margin?10:t.margin,this.featureHeight=t.featureHeight||14,"FusionJuncSpan"===t.type?(this.render=t.render||Fu,this.squishedRowHeight=t.squishedRowHeight||50,this.expandedRowHeight=t.expandedRowHeight||50,this.height=t.height||this.margin+2*this.expandedRowHeight):"snp"===t.type?(this.render=t.render||Ou,this.snpColors=["rgb(0,0,0)","rgb(0,0,255)","rgb(0,255,0)","rgb(255,0,0)"],this.colorBy="function",this.expandedRowHeight=t.expandedRowHeight||10,this.squishedRowHeight=t.squishedRowHeight||5,this.height=t.height||30):(this.render=t.render||Tu,this.arrowSpacing=30,function(t){t.browser.on&&(t.browser.on("trackdragend",e),t.browser.on("trackremoved",n));function e(){t.trackView&&"SQUISHED"!==t.displayMode&&t.trackView.repaintViews()}function n(r){t.browser.un&&t===r&&(t.browser.un("trackdragend",e),t.browser.un("trackremoved",n))}}(this),this.squishedRowHeight=t.squishedRowHeight||15,this.expandedRowHeight=t.expandedRowHeight||30,this.height=t.height||this.margin+2*this.expandedRowHeight,t.colorBy&&(t.colorBy.field&&(t.colorTable=t.colorBy.pallete||t.colorBy.palette,t.colorBy=t.colorBy.field),this.colorBy=t.colorBy,t.colorTable?this.colorTable=new Sc(t.colorTable):this.colorTable=new _c("Set1"))),this.useScore=t.useScore}async postInit(){return"function"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader()),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(t,e,n,r){const i=this.visibilityWindow;return this.featureSource.getFeatures({chr:t,start:e,end:n,bpPerPixel:r,visibilityWindow:i})}computePixelHeight(t){if("COLLAPSED"===this.displayMode)return this.margin+this.expandedRowHeight;{let e=0;if(t&&"function"==typeof t.forEach)for(let n of t)n.row&&n.row>e&&(e=n.row);return this.margin+(e+1)*("SQUISHED"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight)}}draw(t){const e=t.features,n=t.context,r=t.bpPerPixel,i=t.bpStart,o=t.pixelWidth,s=t.pixelHeight,a=i+o*r+1;if(this.config.isMergedTrack||ls.fillRect(n,0,t.pixelTop,o,s,{fillStyle:"rgb(255, 255, 255)"}),e){const c=[];t.rowLastX=[],t.rowLastLabelX=[];for(let n of e)if(n.start>i&&n.end<a){const e="COLLAPSED"===this.displayMode?0:n.row||0;void 0===c[e]?c[e]=1:c[e]++,t.rowLastX[e]=-Number.MAX_SAFE_INTEGER,t.rowLastLabelX[e]=-Number.MAX_SAFE_INTEGER}const l=o/Math.max(...c);let h=[];for(let o of e){if(o.end<i)continue;if(o.start>a)break;const e="COLLAPSED"===this.displayMode?0:o.row;t.drawLabel=t.labelAllFeatures||l>10;const c=Math.ceil((o.end-i)/r),u=h[e];if(!u||c>u){this.render.call(this,o,i,r,s,n,t);const a=Math.floor((o.start-i)/r);u&&a-u<=0&&(n.globalAlpha=.5,ls.strokeLine(n,a,0,a,s,{strokeStyle:"rgb(255, 255, 255)"}),n.globalAlpha=1),h[e]=c}}}else console.log("No feature list")}clickedFeatures(t,e){const n=t.y-this.margin,r=super.clickedFeatures(t,e);let i;switch(this.displayMode){case"SQUISHED":i=Math.floor(n/this.squishedRowHeight);break;case"EXPANDED":i=Math.floor(n/this.expandedRowHeight);break;default:i=void 0}return r.filter((function(t){return void 0===i||void 0===t.row||i===t.row}))}popupData(t,e){e=this.clickedFeatures(t,e);const n=t.genomicLocation,r=[];for(let t of e){const e=t._f||t,i="function"==typeof e.popupData?e.popupData(n):this.extractPopupData(e);if(i){r.length>0&&r.push("<hr/><hr/>");const o=this.infoURL||this.config.infoURL;for(let e of i)if(r.push(e),o&&e.name&&"name"===e.name.toLowerCase()&&e.value&&ke(e.value)&&!e.value.startsWith("<")){const n=o.replace("$$",t.name);e.value=`<a target=_blank href=${n}>${e.value}</a>`}const s="gff"===this.config.format||"gff3"===this.config.format||"gtf"===this.config.format;if(e.exons)for(let t=0;t<e.exons.length;t++){const i=e.exons[t];if(n>=i.start&&n<=i.end){const n=s?i.number:"-"===e.strand?e.exons.length-t:t+1;n&&(r.push("<hr/>"),r.push({name:"Exon Number",value:n}));break}}}}return r}menuItemList(){const t=[];if(this.render===Ou){t.push("<hr/>");for(let e of["function","class"])t.push({object:de(Po("Color by "+e,e===this.colorBy)),click:()=>{this.colorBy=e,this.trackView.repaintViews()}})}t.push("<hr/>");for(let e of["COLLAPSED","SQUISHED","EXPANDED"]){const n={COLLAPSED:"Collapse",SQUISHED:"Squish",EXPANDED:"Expand"};t.push({object:de(Po(n[e],e===this.displayMode)),click:()=>{this.displayMode=e,this.config.displayMode=e,this.trackView.checkContentHeight(),this.trackView.repaintViews()}})}return t}contextMenuItemList(t){const e=this.clickedFeatures(t);e.length>1&&e.sort(((t,e)=>e.end-e.start-(t.end-t.start)));const n=e[0];if(n.end-n.start<=1e6){const t=[{label:"View feature sequence",click:async()=>{let t=await this.browser.genome.getSequence(n.chr,n.start,n.end);"-"===n.strand&&(t=As(t)),t||(t="Unknown sequence"),Qo.presentAlert(t)}}];return Ss()&&void 0!==navigator.clipboard&&t.push({label:"Copy feature sequence",click:async()=>{let t=await this.browser.genome.getSequence(n.chr,n.start,n.end);"-"===n.strand&&(t=As(t));try{await navigator.clipboard.writeText(t)}catch(t){console.error(t),Qo.presentAlert(`error copying sequence to clipboard ${t}`)}}}),t.push("<hr/>"),t}}description(){if(Ou===this.render){let t="<html>"+this.name+"<hr/>";return t+="<em>Color By Function:</em><br>",t+='<span style="color:red">Red</span>: Coding-Non-Synonymous, Splice Site<br>',t+='<span style="color:green">Green</span>: Coding-Synonymous<br>',t+='<span style="color:blue">Blue</span>: Untranslated<br>',t+='<span style="color:black">Black</span>: Intron, Locus, Unknown<br><br>',t+="<em>Color By Class:</em><br>",t+='<span style="color:red">Red</span>: Deletion<br>',t+='<span style="color:green">Green</span>: MNP<br>',t+='<span style="color:blue">Blue</span>: Microsatellite, Named<br>',t+='<span style="color:black">Black</span>: Indel, Insertion, SNP',t+="</html>",t}return super.description()}dispose(){this.trackView=void 0}}class Bu extends bc{constructor(t,e){super(t,e)}init(t){super.init(t),this.type="wig",this.height=t.height||50,this.featureType="numeric",this.paintAxis=yc;const e=t.format?t.format.toLowerCase():t.format;this.flipAxis=!!t.flipAxis&&t.flipAxis,this.logScale=!!t.logScale&&t.logScale,this.featureSource="bigwig"===e?new pu(t,this.browser.genome):"tdf"===e?new wu(t,this.browser.genome):Cu(t,this.browser.genome),this.autoscale=t.autoscale||void 0===t.max,this.autoscale||(this.dataRange={min:t.min||0,max:t.max}),this.windowFunction=t.windowFunction||"mean",this.graphType=t.graphType||"bar",this.normalize=t.normalize,this.scaleFactor=t.scaleFactor}async postInit(){const t=await this.getHeader();t&&this.setTrackProperties(t)}async getFeatures(t,e,n,r){const i=await this.featureSource.getFeatures({chr:t,start:e,end:n,bpPerPixel:r,windowFunction:this.windowFunction});if(this.normalize&&this.featureSource.normalizationFactor){const t=this.featureSource.normalizationFactor;for(let e of i)e.value*=t}if(this.scaleFactor){const t=this.scaleFactor;for(let e of i)e.value*=t}return i}menuItemList(){let t=[];return void 0!==this.flipAxis&&t.push({label:"Flip y-axis",click:()=>{this.flipAxis=!this.flipAxis,this.trackView.repaintViews()}}),t=t.concat(Oo.numericDataMenuItems(this.trackView)),t}async getHeader(){return"function"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader()),this.header}getScaleFactor(t,e,n,r){return r?n/(Math.log10(e+1)-(t<=0?0:Math.log10(t+1))):n/(e-t)}computeYPixelValue(t,e){return(this.flipAxis?t-this.dataRange.min:this.dataRange.max-t)*e}computeYPixelValueInLogScale(t,e){let n=this.dataRange.max,r=this.dataRange.min;return n<=0?0:(r<=-1&&(r=0),r=r<=0?0:Math.log10(r+1),n=Math.log10(n+1),t=Math.log10(t+1),(this.flipAxis?t-r:n-t)*e)}draw(t){const e=t.features,n=t.context,r=t.bpPerPixel,i=t.bpStart,o=t.pixelWidth;t.pixelHeight;const s=i+o*r+1;let a=-1,c=-1;const l=this.color||"rgb(150,150,150)";let h;"string"==typeof l&&l.startsWith("rgb(")&&(h=no.addAlpha(l,.1));const u=this.getScaleFactor(this.dataRange.min,this.dataRange.max,t.pixelHeight,this.logScale),f=t=>this.logScale?this.computeYPixelValueInLogScale(t,u):this.computeYPixelValue(t,u);if(e&&e.length>0&&(void 0===this.dataRange.min&&(this.dataRange.min=0),this.dataRange.max>this.dataRange.min)){const o=f(0);for(let t of e){if(t.end<i)continue;if(t.start>s)break;const e=Math.floor((t.start-i)/r);if(isNaN(e))continue;let h=f(t.value);const u=Math.ceil((t.end-i)/r),d=Math.max(1,u-e);let p=t.value<0&&this.altColor?this.altColor:l;const g="function"==typeof p?p(t.value):p;if("points"===this.graphType){const t=this.config.pointSize||3,r=e+d/2;ls.fillCircle(n,r,h,t/2,{fillStyle:g,strokeStyle:g})}else{let r=h-o;const i=e+d;(i>a||t.value>=0&&t.value>c||t.value<0&&t.value<1)&&ls.fillRect(n,e,o,d,r,{fillStyle:g}),c=t.value,a=i}}if(this.dataRange.min<0){const e=this.dataRange.max/(this.dataRange.max-this.dataRange.min)*t.pixelHeight;ls.strokeLine(n,0,e,t.pixelWidth,e,{strokeStyle:h})}}if(this.config.hasOwnProperty("guideLines"))for(let e of this.config.guideLines)if(e.hasOwnProperty("color")&&e.hasOwnProperty("y")&&e.hasOwnProperty("dotted")){let n=f(e.y),r={strokeStyle:e.color,strokeWidth:2};e.dotted?ls.dashedLine(t.context,0,n,t.pixelWidth,n,5,r):ls.strokeLine(t.context,0,n,t.pixelWidth,n,r)}}popupData(t,e){if((e=this.clickedFeatures(t,e))&&e.length>0){const n=t.genomicLocation,r=[];e.sort((function(t,e){return Math.abs((t.start+t.end)/2-n)-Math.abs((e.start+e.end)/2-n)}));const i=e.length>10?e.slice(0,10):e;i.sort((function(t,e){return t.start-e.start}));for(let t of i)if(t){r.length>0&&r.push("<hr/>");let e=t.end-t.start==1?_e(t.start+1):_e(t.start+1)+"-"+_e(t.end);r.push({name:"Position:",value:e}),r.push({name:"Value: ",value:_e(t.value)})}return i.length<e.length&&r.push("<hr/>..."),r}return[]}get supportsWholeGenome(){return!this.config.indexURL&&!1!==this.config.supportsWholeGenome}dispose(){this.trackView=void 0}getState(){const t=super.getState();return void 0!==this.flipAxis&&(t.flipAxis=this.flipAxis),void 0!==this.logScale&&(t.logScale=this.logScale),t}}function zu(t){this.thresholds=t.thresholds,this.colors=t.colors}function Hu(t){this.scale=t,this.lowColor="rgb("+t.lowR+","+t.lowG+","+t.lowB+")",this.highColor="rgb("+t.highR+","+t.highG+","+t.highB+")",this.diff=t.high-t.low}zu.prototype.getColor=function(t){for(let e of this.thresholds)if(t<e)return this.colors[this.thresholds.indexOf(e)];return this.colors[this.colors.length-1]},Hu.prototype.getColor=function(t){var e,n=this.scale;return t<=n.low?this.lowColor:t>=n.high?this.highColor:(e=(t-n.low)/this.diff,"rgb("+Math.floor(n.lowR+e*(n.highR-n.lowR))+","+Math.floor(n.lowG+e*(n.highG-n.lowG))+","+Math.floor(n.lowB+e*(n.highB-n.lowB))+")")};class Vu{constructor(t){this.color=t}getColor(){return this.color}}class ju extends bc{constructor(t,e){super(t,e)}init(t){if(super.init(t),this.type=t.type||"seg","maf"===this.type&&(this.type="mut"),this.isLog=t.isLog,this.displayMode=t.displayMode||"EXPANDED",this.height=t.height||300,this.maxHeight=t.maxHeight||500,this.squishedRowHeight=t.sampleSquishHeight||t.squishedRowHeight||2,this.expandedRowHeight=t.sampleExpandHeight||t.expandedRowHeight||13,this.sampleHeight=this.squishedRowHeight,t.color?this.color=t.color:(this.posColorScale=t.posColorScale||new Hu({low:.1,lowR:255,lowG:255,lowB:255,high:1.5,highR:255,highG:0,highB:0}),this.negColorScale=t.negColorScale||new Hu({low:-1.5,lowR:0,lowG:0,lowB:255,high:-.1,highR:255,highG:255,highB:255}),"mut"===this.type&&(this.colorTable=new Sc(t.colorTable||Uu))),this.sampleKeys=[],this.sampleNames=new Map,t.samples){for(let e of t.samples)this.sampleKeys.push(e),this.sampleNames.set(e,e);this.explicitSamples=!0}const e=Object.assign({},this.config);e.maxWGCount=e.maxWGCount||Number.MAX_SAFE_INTEGER,this.featureSource=Cu(e,this.browser.genome),this.initialSort=t.sort}async postInit(){"function"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader()),this.header&&this.setTrackProperties(this.header)}menuItemList(){const t=[],e={SQUISHED:"Squish",EXPANDED:"Expand",FILL:"Fill"};t.push("<hr/>"),t.push("DisplayMode:");const n="seg"===this.type?["SQUISHED","EXPANDED","FILL"]:["SQUISHED","EXPANDED"];for(let r of n){const n=Po(e[r],r===this.displayMode);t.push({object:de(n),click:()=>{this.displayMode=r,this.config.displayMode=r,this.trackView.checkContentHeight(),this.trackView.repaintViews(),this.trackView.moveScroller(this.trackView.sampleNameViewport.trackScrollDelta)}})}return t}hasSamples(){return!0}getSamples(){return{names:this.sampleKeys.map((t=>this.sampleNames.get(t))),height:this.sampleHeight,yOffset:0}}async getFeatures(t,e,n){const r=await this.featureSource.getFeatures({chr:t,start:e,end:n});if(this.initialSort){const t=this.initialSort;this.sortSamples(t.chr,t.start,t.end,t.direction,r),this.initialSort=void 0}return r}draw({context:t,renderSVG:e,pixelTop:n,pixelWidth:r,pixelHeight:i,features:o,bpPerPixel:s,bpStart:a}){if(ls.fillRect(t,0,0,r,i,{fillStyle:"rgb(255, 255, 255)"}),o&&o.length>0){this.checkForLog(o),this.updateSampleKeys(o);const e={};let c;switch(this.sampleKeys.forEach((function(t,n){e[t]=n})),this.displayMode){case"FILL":this.sampleHeight=i/this.sampleKeys.length,c=0;break;case"SQUISHED":this.sampleHeight=this.squishedRowHeight,c=0;break;default:this.sampleHeight=this.expandedRowHeight,c=1}const l=this.sampleHeight;for(let t of o)t.pixelRect=void 0;const h=n+i,u=a+r*s+1,f=s;this.sampleYStart=void 0;for(let r of o){if(r.end<a)continue;if(r.start>u)break;const i=r.sampleKey||r.sample;r.row=e[i];const o=r.row*l+c;void 0===this.sampleYStart&&(this.sampleYStart=o);if(o+l<n||o>h)continue;const s=Math.max(r.start,a);let d=Math.round((s-a)/f);const p=Math.min(r.end,u),g=Math.round((p-a)/f);let m,v,b=Math.max(1,g-d);if(this.color?m="function"==typeof this.color?this.color(r):this.color:this.colorTable&&(m=this.colorTable.getColor(r.value.toLowerCase())),"mut"===this.type)v=l-2*c,b<3&&(b=3,d-=1);else{let t=r.value;this.isLog||(t=Ji(t/2)),m=t<-.1?this.negColorScale.getColor(t):t>.1?this.posColorScale.getColor(t):"white";let e=l;if(l<.25){const n=.1+2*Math.abs(t);e=Math.min(1,n*l)}v=e-2*c}r.pixelRect={x:d,y:o,w:b,h:v},t.fillStyle=m,t.fillRect(d,o,b,v)}}}checkForLog(t){if(void 0===this.isLog){this.isLog=!1;for(let e of t)if(e.value<0)return void(this.isLog=!0)}}computePixelHeight(t){if(!t)return 0;const e="SQUISHED"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight;return this.updateSampleKeys(t),this.sampleKeys.length*e}async sortSamples(t,e,n,r,i){if(i||(i=await this.featureSource.getFeatures({chr:t,start:e,end:n})),!i)return;this.updateSampleKeys(i);const o={},s="ASC"===r?1:-1,a=()=>{const t=n-e+1;for(let r of i){if(r.end<e)continue;if(r.start>n)break;const i=Math.max(e,r.start),s=(Math.min(n,r.end)-i)/t,a=r.sampleKey||r.sample,c=o[a]||0;o[a]=c+s*r.value}this.sampleKeys.sort((function(t,e){let n=o[t],r=o[e];return n||(n=s*Number.MAX_VALUE),r||(r=s*Number.MAX_VALUE),n===r?0:n>r?s:-1*s}))},c=()=>{for(let t of i){if(t.end<e)continue;if(t.start>n)break;const r=t.sampleKey||t.sample;(!o.hasOwnProperty(r)||t.value.localeCompare(o[r])>0)&&(o[r]=t.value)}this.sampleKeys.sort((function(t,e){let n=o[t]||"",r=o[e]||"";return s*n.localeCompare(r)}))};"mut"===this.type?c():a(),this.trackView.repaintViews()}clickedFeatures(t,e){const n=super.clickedFeatures(t,e),r=t.y;return n.filter((function(t){const e=t.pixelRect;return e&&r>=e.y&&r<=e.y+e.h}))}popupData(t,e){e=this.clickedFeatures(t);const n=[];for(let t of e){n.length>0&&(n.push("<hr/>"),n.push("<hr/>"));const e=t._f||t,r="function"==typeof e.popupData?e.popupData(this.type,this.browser.genome.id):this.extractPopupData(e);Array.prototype.push.apply(n,r)}return n}contextMenuItemList(t){const e=t.viewport.referenceFrame,n=t.genomicLocation,r=this.config.sort?"ASC"===this.config.sort.direction?"DESC":"ASC":"DESC",i=e.toBP(2.5),o=e=>{const n=t.viewport.cachedFeatures;this.sortSamples(e.chr,e.start,e.end,e.direction,n)};return[{label:"seg"===this.type?"Sort by value":"Sort by type",click:e=>{const s={direction:r,chr:t.viewport.referenceFrame.chr,start:n-i,end:n+i};o(s),this.config.sort=s}}]}get supportsWholeGenome(){return(!1===this.config.indexed||!this.config.indexURL)&&!1!==this.config.supportsWholeGenome}updateSampleKeys(t){if(!this.explicitSamples)for(let e of t){const t=e.sampleKey||e.sample;this.sampleNames.has(t)||(this.sampleNames.set(t,e.sample),this.sampleKeys.push(t))}}}const Uu={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 qu extends bc{constructor(t,e){super(t,e),this.type="merged",this.featureType="numeric",this.paintAxis=yc}init(t){if(!t.tracks)throw Error("Error: no tracks defined for merged track"+t);super.init(t)}async postInit(){this.tracks=[];const t=[];for(let e of this.config.tracks){e.isMergedTrack=!0;const n=await this.browser.createTrack(e);n?(n.autoscale=!1,this.tracks.push(n)):console.warn("Could not create track "+e),"function"==typeof n.postInit&&t.push(n.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 t of this.tracks)t.autoscale=!1,t.dataRange=this.dataRange;return this.height=this.config.height||50,Promise.all(t)}get height(){return this._height}set height(t){if(this._height=t,this.tracks)for(let e of this.tracks)e.height=t,e.config.height=t}menuItemList(){let t=[];return void 0!==this.flipAxis&&t.push({label:"Flip y-axis",click:()=>{this.flipAxis=!this.flipAxis,this.trackView.repaintViews()}}),t=t.concat(Oo.numericDataMenuItems(this.trackView)),t}async getFeatures(t,e,n,r){const i=this.tracks.map((i=>i.getFeatures(t,e,n,r)));return Promise.all(i)}draw(t){const e=t.features;this.autoscale&&(this.dataRange=function(t,e){let n=0,r=-Number.MAX_VALUE;for(let t of e)for(let e of t)void 0===e.value||Number.isNaN(e.value)||(n=Math.min(n,e.value),r=Math.max(r,e.value));return{min:n,max:r}}(t.referenceFrame.chr,e));for(let n=0,r=this.tracks.length;n<r;n++){const r=Object.assign({},t);r.features=e[n],this.tracks[n].dataRange=this.dataRange,this.tracks[n].flipAxis=this.flipAxis,this.tracks[n].logScale=this.logScale,this.tracks[n].graphType=this.graphType,this.tracks[n].draw(r)}}popupData(t,e){const n=e||t.viewport.cachedFeatures;if(n&&n.length===this.tracks.length){const e=[];for(let r=0;r<this.tracks.length;r++){r>0&&e.push("<hr/>"),e.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[r].name}</div>`);const i=this.tracks[r].popupData(t,n[r]);e.push(...i)}return e}}get supportsWholeGenome(){return this.tracks.every((t=>t.supportsWholeGenome()))}}class Wu extends bc{constructor(t,e){super(t,e)}init(t){super.init(t),this.theta=t.theta||Math.PI/4,this.sinTheta=Math.sin(this.theta),this.cosTheta=Math.cos(this.theta),this.height=t.height||250,this.arcType=function(t){if(!t.arcType)return"nested";switch(t.arcType){case"chiapet":return"inView";case"chiapetoutbound":return"partialInView";default:return t.arcType}}(t),this.arcOrientation=void 0===t.arcOrientation||t.arcOrientation,this.showBlocks=void 0===t.showBlocks||t.showBlocks,this.blockHeight=t.blockHeight||3,this.thickness=t.thickness||1,this.color=t.color||"rgb(180,25,137)",this.alpha=t.alpha||.02,this.painter={flipAxis:!this.arcOrientation,dataRange:this.dataRange,paintAxis:yc},t.valueColumn?(this.valueColumn=t.valueColumn,this.hasValue=!0):t.useScore&&(this.hasValue=!0,this.valueColumn="score"),this.logScale=!1!==t.logScale,t.max?(this.dataRange={min:t.min||0,max:t.max},this.autoscale=!1):this.autoscale=!0,this.featureSource=Cu(t,this.browser.genome),this.featureSource.getWGFeatures=Yu}async postInit(){return"function"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader()),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(t,e,n){const r=this.visibilityWindow,i=await this.featureSource.getFeatures({chr:t,start:e,end:n,visibilityWindow:r});return void 0===this.hasValue&&i&&i.length>0&&(this.hasValue=void 0!==i[0].score),i}draw(t){"proportional"===this.arcType||"inView"===this.arcType||"partialInView"===this.arcType?this.drawProportional(t):this.drawNested(t)}drawNested(t){const e=t.context,n=t.pixelWidth,r=t.pixelHeight,i=t.viewportWidth,o=t.bpPerPixel,s=t.bpStart,a=o;ls.fillRect(e,0,t.pixelTop,n,r,{fillStyle:"rgb(255, 255, 255)"});const c=t.features;if(c){(function(){let t=0;for(let e of c){let r=(e.start-s)/a,i=(e.end-s)/a;i>=0&&r<=n&&(t=Math.max(t,i-r))}let e=Math.min(i,t)/2;if(t>0){let t=(r-10)/e;this.theta=function(t){let e,n=[.01570925532366355,.15838444032453644,.3249196962329063,.5095254494944288,.7265425280053609,.9999999999999999],r=[.031415926535897934,.3141592653589793,.6283185307179586,.9424777960769379,1.2566370614359172,1.5707963267948966];for(e=0;e<n.length&&!(n[e]>t);e++);let i=0===e?0:n[e-1],o=e<n.length?n[e]:1,s=(t-i)/(o-i),a=0===e?0:r[e-1],c=e<r.length?r[e]:Math.PI/2;return a+s*(c-a)}(t),this.sinTheta=Math.sin(this.theta),this.cosTheta=Math.cos(this.theta)}}).call(this);const o=this.arcOrientation?t.pixelHeight:0,h=this.arcOrientation;e.font="8px sans-serif",e.textAlign="center";for(let t of c){t.drawState=void 0;let r=t.color||this.color;if(r&&this.config.useScore&&(r=Xu(r,(l=t.score,Math.min(1,.11+l/779*.89).toString()))),e.lineWidth=t.thickness||this.thickness||1,t.chr1===t.chr2||"all"===t.chr){const{m1:c,m2:l}=$u(t,this.browser.genome);let u=Math.round((c-s)/a),f=Math.round((l-s)/a);if(f<0||u>n)continue;let d=f-u;d<3&&(d=3,u--);const p=d/2,g=p/this.sinTheta,m=this.cosTheta*g,v=u+p;let b,w,y;if(h?(b=this.height+m,w=Math.PI+Math.PI/2-this.theta,y=Math.PI+Math.PI/2+this.theta):(b=-m,w=Math.PI/2-this.theta,y=Math.PI/2+this.theta),this.showBlocks&&"all"!==t.chr){const n=(t.start1-s)/a,r=(t.end1-s)/a,i=(t.start2-s)/a,c=(t.end2-s)/a,l=this.arcOrientation?-this.blockHeight:this.blockHeight;e.fillRect(n,o,r-n,l),e.fillRect(i,o,c-i,l)}r&&!this.config.useScore&&d>i&&(r=Xu(r,this.alpha)),e.strokeStyle=r,e.fillStyle=r,e.beginPath(),e.arc(v,b,g,w,y,!1),e.stroke(),t.drawState={xc:v,yc:b,r:g}}else{let i=Math.round((t.start-s)/a),o=Math.round((t.end-s)/a);if(o<0||i>n)continue;let c=o-i;c<3&&(c=3,i--);const l=t.chr===t.chr1?t.chr2:t.chr1;e.strokeStyle=r,e.fillStyle=Xu(ll(l),.5),h?(e.fillRect(i,this.height/2,c,this.height/2),e.fillText(l,i+c/2,this.height/2-5),t.drawState={x:i,y:this.height/2,w:c,h:this.height/2}):(e.fillRect(i,0,c,this.height/2),e.fillText(l,i+c/2,this.height/2+13),t.drawState={x:i,y:0,w:c,h:this.height/2})}}}var l}getScaleFactor(t,e,n,r){return r?n/(Math.log10(e+1)-(t<=0?0:Math.log10(t+1))):n/(e-t)}drawProportional(t){const e=t.context,n=t.pixelWidth,r=t.pixelHeight,i=t.bpPerPixel,o=t.bpStart,s=i,a=t.referenceFrame.start,c=t.referenceFrame.end;ls.fillRect(e,0,t.pixelTop,n,r,{fillStyle:"rgb(255, 255, 255)"});const l=t.features;if(l&&l.length>0){const r=0,i=this.getScaleFactor(r,this.dataRange.max,t.pixelHeight-1,this.logScale),h=this.arcOrientation?t.pixelHeight:0;for(let t of l){t.drawState=void 0;const r=this.valueColumn?t[this.valueColumn]:t.score;if(void 0===r||Number.isNaN(r))continue;const l=Math.round((this.logScale?Math.log10(r+1):r)*i);if(t.chr1===t.chr2||"all"===t.chr){const{m1:n,m2:i}=$u(t,this.browser.genome);let u=Math.round((n-o)/s),f=Math.round((i-o)/s)-u;if(f<3&&(f=3,u--),r<this.dataRange.min||r>this.dataRange.max)continue;if("proportional"!==this.arcType){const t="partialInView"===this.arcType,e=n>=a&&i<=c;let r=!1,o=!1;if(!e&&t&&(r=a<=n&&n<=c,r||(o=a<=i&&i<=c)),!(e||r||o))continue}const d=f/2,p=u+f/2;t.drawState={xc:p,yc:h,radiusX:d,radiusY:l};const g=!!this.arcOrientation,m=t.color||this.color;if(e.strokeStyle=m,e.lineWidth=t.thickness||this.thickness||1,!0===e.isSVG?e.strokeEllipse(p,h,d,l,0,0,Math.PI,g):(e.beginPath(),e.ellipse(p,h,d,l,0,0,Math.PI,g),e.stroke()),this.alpha&&(e.fillStyle=Xu(m,this.alpha),!0===e.isSVG?e.fillEllipse(p,h,d,l,0,0,Math.PI,g):e.fill()),this.showBlocks&&"all"!==t.chr){e.fillStyle=m;const n=(t.start1-o)/s,r=(t.end1-o)/s,i=(t.start2-o)/s,a=(t.end2-o)/s,c=this.arcOrientation?-this.blockHeight:this.blockHeight;e.fillRect(n,h,r-n,c),e.fillRect(i,h,a-i,c)}}else{let i=Math.round((t.start-o)/s),a=Math.round((t.end-o)/s);if(a<0||i>n||r<this.dataRange.min||r>this.dataRange.max)continue;const c=Math.min(l,this.height-13);let h=a-i;h<3&&(h=3,i--);const u=t.chr===t.chr1?t.chr2:t.chr1;if(e.font="8px sans-serif",e.textAlign="center",e.fillStyle=Xu(ll(u),.5),this.arcOrientation){const n=this.height-c;e.fillRect(i,n,h,c),e.fillText(u,i+h/2,n-5),t.drawState={x:i,y:n,w:h,h:c}}else e.fillRect(i,0,h,c),e.fillText(u,i+h/2,c+13),t.drawState={x:i,y:0,w:h,h:c}}}}}clearAxis(t,e,n){ls.fillRect(t,0,0,e,n,{fillStyle:"rgb(255, 255, 255)"})}paintAxis(t,e,n){const r={min:0,max:this.dataRange.max};"proportional"===this.arcType||"inView"===this.arcType||"partialInView"===this.arcType?(this.painter.flipAxis=!this.arcOrientation,this.painter.dataRange=r,this.painter.paintAxis(t,e,n)):this.clearAxis(t,e,n)}menuItemList(){let t=[{name:"Set track color",click:()=>{this.trackView.presentColorPicker()}},"<hr/>"];if(this.hasValue){const e={nested:"Nested",proportional:"Proportional - All",inView:"Proportional - Both Ends in View",partialInView:"Proportional - One End in View"};t.push("<b>Arc Type</b>");for(let n of["nested","proportional","inView","partialInView"])t.push({object:de(Po(e[n],n===this.arcType)),click:()=>{this.arcType=n,this.trackView.repaintViews()}})}return t.push("<hr/>"),t.push({name:"Toggle arc direction",click:()=>{this.arcOrientation=!this.arcOrientation,this.trackView.repaintViews()}}),t.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||(t=t.concat(Oo.numericDataMenuItems(this.trackView))),this.browser.circularView&&(t.push("<hr/>"),t.push({label:"Add interactions to circular view",click:()=>{for(let t of this.trackView.viewports)this.addChordsForViewport(t.referenceFrame)}})),t}contextMenuItemList(t){if(this.browser.circularView){const e=t.viewport,n=[];return n.push({label:"Add interactions to circular view",click:()=>{const t=e.referenceFrame;this.addChordsForViewport(t)}}),n.push("<hr/>"),n}}addChordsForViewport(t){const e=("all"===t.chr?this.featureSource.getAllFeatures():this.featureSource.featureCache.queryFeatures(t.chr,t.start,t.end)).filter((t=>t.drawState));if(0===e.length)return;tl(e.map((t=>{const e=t._f||t;return{uniqueId:`${e.chr1}:${e.start1}-${e.end1}_${e.chr2}:${e.start2}-${e.end2}`,refName:Qc(e.chr1),start:e.start1,end:e.end1,mate:{refName:Qc(e.chr2),start:e.start2,end:e.end2}}})),this,t,.5)}doAutoscale(t){let e=0;if(t)for(let n of t){const t=this.valueColumn?n[this.valueColumn]:n.score;Number.isNaN(t)||(e=Math.max(e,t))}return{min:0,max:e}}popupData(t,e){e=this.clickedFeatures(t);const n=[];for(let t of e){const e=t._||t;if(n.push({name:"Region 1",value:Gu(e.chr1,e.start1,e.end1,e.strand1)}),n.push({name:"Region 2",value:Gu(e.chr2,e.start2,e.end2,e.strand2)}),e.name&&n.push({name:"Name",value:e.name}),void 0!==e.value&&n.push({name:"Value",value:e.value}),void 0!==e.score&&n.push({name:"Score",value:e.score}),e.extras&&this.header&&this.header.columnNames){const t=this.header.columnNames;for(let r=10;r<t.length;r++)"info"===t[r]?Ku(n,e.extras[r-10]):n.push({name:t[r],value:e.extras[r-10]})}break}return n}clickedFeatures(t,e){const n=e||t.viewport.cachedFeatures,r=[];if(n){const e="proportional"===this.arcType||"inView"===this.arcType||"partialInView"===this.arcType;for(let i of n)if(i.drawState)if(i.chr1===i.chr2||"all"===i.chr)if(e){const{xc:e,yc:n,radiusX:o,radiusY:s}=i.drawState,a=t.canvasX-e,c=t.canvasY-n,l=a/o*(a/o)+c/s*(c/s);l<=1&&r.push({score:1/l,feature:i})}else{const{xc:e,yc:n,r:o}=i.drawState,s=t.canvasX-e,a=t.canvasY-n,c=Math.abs(Math.sqrt(s*s+a*a)-o);c<5&&r.push({score:c,feature:i})}else{const{x:e,y:n,w:o,h:s}=i.drawState,a=5;if(t.canvasX>=e-a&&t.canvasX<=e+o+a&&t.canvasY>=n&&t.canvasY<=n+s){const n=-Math.abs(t.canvasX-(e+o/2));r.push({score:n,feature:i});break}}}return r.length>1&&r.sort(((t,e)=>t.score-e.score)),r.map((t=>t.feature))}getState(){const t=super.getState();return void 0!==this.arcType&&(t.arcType=this.arcType),void 0!==this.arcOrientation&&(t.arcOrientation=this.arcOrientation),void 0!==this.showBlocks&&(t.showBlocks=this.showBlocks),void 0!==this.blockHeight&&(t.blockHeight=this.blockHeight),void 0!==this.thickness&&(t.thickness=this.thickness),void 0!==this.alpha&&(t.alpha=this.alpha),t}}function $u(t,e){let n=(t.start1+t.end1)/2,r=(t.start2+t.end2)/2;if("all"===t.chr&&(n=e.getGenomeCoordinate(t.chr1,n),r=e.getGenomeCoordinate(t.chr2,r)),n>r){const t=n;n=r,r=t}return{m1:n,m2:r}}function Gu(t,e,n,r){return r&&"."!==r?`${t}:${_e(e+1)}-${_e(n)} (${r})`:`${t}:${_e(e+1)}-${_e(n)}`}const Zu=new Map;function Xu(t,e){const n=`${t}_${e}`;let r=Zu.get(n);return r||(r=no.addAlpha(t,e),Zu.set(n,r)),r}function Yu(t){const e=t=>{const e=Object.assign({},t);return e.chr="all",e.start=n.getGenomeCoordinate(t.chr1,t.start1),e.end=n.getGenomeCoordinate(t.chr2,t.end2),e},n=this.genome;let r,i=0;for(let e of n.wgChromosomeNames){let n=t[e];if(n)for(let t of n)t.dup||(i++,t.score&&(!r||t.score>r.score)&&(r=t))}const o=this.maxWGCount,s=r&&r.score>0&&i>o?5:1,a=Math.floor(o/s),c=r&&r.score>0?Math.log(r.score)/s:Number.MAX_SAFE_INTEGER;let l,h=[],u=[];for(let t=0;t<s;t++)u.push([0]),h.push([]);for(let r of n.wgChromosomeNames){let n=t[r];if(n)for(let t of n)if(!t.dup){const n=t.score?Math.min(s-1,Math.floor(Math.log(t.score)/c)):0;if(h[n].length<a)h[n].push(e(t));else{const r=a/(u[n]+1);if(Math.random()<r){const r=Math.floor(Math.random()*(a-1));h[n][r]=e(t)}}u[n]++}}if(1===s)l=h[0];else{l=[];for(let t of h)for(let e of t)l.push(e);r&&l.push(e(r)),l.sort((function(t,e){return t.start-e.start})),console.log(l.length)}return l}function Ku(t,e){const n=e.split(";");for(let e of n){const n=e.split("=");2===n.length&&t.push({name:n[0],value:n[1]})}}const Qu=ke,Ju=new Map([["REF","referenceBases"],["ALT","alternateBases"],["QUAL","quality"],["FILTER","filter"]]);class tf extends bc{constructor(t,e){super(t,e)}init(t){super.init(t),this.visibilityWindow=t.visibilityWindow,this.displayMode=t.displayMode||"EXPANDED",this.labelDisplayMode=t.labelDisplayMode,this.expandedVariantHeight=t.expandedVariantHeight||t.variantHeight||10,this.squishedVariantHeight=t.squishedVariantHeight||2,this.squishedCallHeight=t.squishedCallHeight||1,this.expandedCallHeight=t.expandedCallHeight||10,this.expandedVGap=void 0!==t.expandedVGap?t.expandedVGap:2,this.squishedVGap=void 0!==t.squishedVGap?t.squishedVGap:1,this.expandedGroupGap=t.expandedGroupGap||10,this.squishedGroupGap=t.squishedGroupGap||5,this.featureHeight=t.featureHeight||14,this.visibilityWindow=t.visibilityWindow,this.featureSource=Cu(t,this.browser.genome),this.noGenotypeColor=t.noGenotypeColor||"rgb(200,180,180)",this.noCallColor=t.noCallColor||"rgb(225, 225, 225)",this.nonRefColor=t.nonRefColor||"rgb(200, 200, 215)",this.mixedColor=t.mixedColor||"rgb(200, 220, 200)",this.homrefColor=t.homrefColor||"rgb(200, 200, 200)",this.homvarColor=t.homvarColor||"rgb(17,248,254)",this.hetvarColor=t.hetvarColor||"rgb(34,12,253)",this.sortDirection="ASC",this.type=t.type||"variant",this.colorBy=t.colorBy,this._initColorBy=t.colorBy,t.colorTable&&(this.colorTables=new Map,this.colorTables.set(t.colorBy,new Sc(t.colorTable))),this.showGenotypes=void 0===t.showGenotypes||t.showGenotypes,this.variantRowCount(1)}async postInit(){if(this.header=await this.getHeader(),void 0===this.visibilityWindow&&!1!==this.config.indexed){const t=je(this.config.url)?this.config.url.name:this.config.url;Qu(t)&&t.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(t){this._color=t,this.colorBy=void 0}async getHeader(){if(!this.header){if("function"==typeof this.featureSource.getHeader){const t=await this.featureSource.getHeader();t&&(this.callSets=t.callSets||[]),this.header=t}this.sampleNames=this.callSets?this.callSets.map((t=>t.name)):[]}return this.header}getCallsetsLength(){return this.callSets?this.callSets.length:0}async getFeatures(t,e,n,r){return void 0===this.header&&(this.header=await this.getHeader()),this.featureSource.getFeatures({chr:t,start:e,end:n,bpPerPixel:r,visibilityWindow:this.visibilityWindow})}hasSamples(){return this.getCallsetsLength()>0}getSamples(){return{yOffset:this.sampleYOffset,names:this.sampleNames,height:this.sampleHeight}}computePixelHeight(t){if(!t||0==t.length)return 10;const e="COLLAPSED"===this.displayMode?1:this.nVariantRows,n="SQUISHED"===this.displayMode?this.squishedVGap:this.expandedVGap,r="SQUISHED"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,i="SQUISHED"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight;return 10+e*(r+n)+n+((!1===this.showGenotypes?0:this.getCallsetsLength()*e)+1)*(i+n)}variantRowCount(t){this.nVariantRows=t}draw({context:t,pixelWidth:e,pixelHeight:n,bpPerPixel:r,bpStart:i,pixelTop:o,features:s}){ls.fillRect(t,0,o,e,n,{fillStyle:"rgb(255, 255, 255)"});const a="SQUISHED"===this.displayMode?this.squishedVGap:this.expandedVGap,c="COLLAPSED"===this.displayMode?1:this.nVariantRows,l="SQUISHED"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight;this.variantBandHeight=10+c*(l+a);const h=this.callSets,u=this.getCallsetsLength();if(h&&u>0&&!1!==this.showGenotypes&&ls.strokeLine(t,0,this.variantBandHeight,e,this.variantBandHeight,{strokeStyle:"rgb(224,224,224) "}),s){const n="SQUISHED"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight,o="SQUISHED"===this.displayMode?this.squishedVGap:this.expandedVGap,a=i+e*r+1;for(let e of s){if(e.end<i)continue;if(e.start>a)break;const s="SQUISHED"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,c=10+("COLLAPSED"===this.displayMode?0:e.row*(s+o)),l=s;let f=Math.round((e.start-i)/r),d=Math.round((e.end-i)/r),p=Math.max(1,d-f);if(p<3?(p=3,f-=1):p>5&&(f+=1,p-=2),t.fillStyle=this.getVariantColor(e),t.fillRect(f,c,p,l),e.pixelRect={x:f,y:c,w:p,h:l},u>0&&!1!==this.showGenotypes){const r="COLLAPSED"===this.displayMode?1:this.nVariantRows;this.sampleYOffset=this.variantBandHeight+o,this.sampleHeight=r*(n+o);let i=0;for(let r of h){const s=e.calls[r.id];if(s){const a="COLLAPSED"===this.displayMode?0:e.row,c=this.sampleYOffset+i*this.sampleHeight+a*(n+o);let l=!0,h=!0,u=!1;if(s.genotype)for(let t of s.genotype){if("."===t){u=!0;break}0!==t&&(h=!1),0===t&&(l=!1)}s.genotype?t.fillStyle=u?this.noCallColor:h?this.homrefColor:l?this.homvarColor:this.hetvarColor:t.fillStyle=this.noGenotypeColor,t.fillRect(f,c,p,n),r.pixelRect={x:f,y:c,w:p,h:n}}i++}}}}else console.log("No feature list")}getVariantColor(t){const e=t._f||t;let n;if(this.colorBy){const t=this.colorBy;let r;if(e.info.hasOwnProperty(t))r=e.info[t];else if(Ju.has(t)){r=e[Ju.get(t)]}n=this.getVariantColorTable(t).getColor(r),n||(n="gray")}else n=this._color?"function"==typeof this._color?this._color(t):this._color:"NONVARIANT"===e.type?this.nonRefColor:"MIXED"===e.type?this.mixedColor:this.defaultColor;return n}clickedFeatures(t,e){let n=super.clickedFeatures(t,e);const r="EXPANDED"===this.displayMode?this.expandedVGap:this.squishedVGap,i=r+("SQUISHED"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight),o=t.y;if(o<=this.variantBandHeight){const t="SQUISHED"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,e=Math.floor((o-10)/(t+r));"COLLAPSED"!==this.displayMode&&(n=n.filter((t=>t.row===e)))}else if(this.callSets){const t=this.callSets,e=o-this.variantBandHeight,r=Math.floor(e/this.sampleHeight);if(r>=0&&r<t.length){const o=Math.floor((e-r*this.sampleHeight)/i),s="COLLAPSED"===this.displayMode?n:n.filter((t=>t.row===o)),a=t[r];n=s.map((t=>{const e=t.calls[a.id];return function(t,e){if(t.genotype){let n="";if("."===e.alternateBases)n="No Call";else{const r=e.alternateBases.split(",");for(let i of t.genotype)if(n.length>0&&(n+="|"),"."===i)n+=".";else if(0===i)n+=e.referenceBases;else{n+=r[i-1].replace("<","<")}}t.genotypeName=n}}(e,t),e}))}}return n}popupData(t,e){const n=this.clickedFeatures(t,e),r=t.genomicLocation,i=this.browser.genome.id,o=this.browser.sampleInformation;let s=[];for(let t of n){const e=t._f||t;if(s.length>0&&s.push({html:'<hr style="border-top-width:2px ;border-color: #c9c3ba" />'}),"function"==typeof e.popupData){const t=e.popupData(r,i);Array.prototype.push.apply(s,t)}else{const t=e;if(void 0!==t.callSetName&&s.push({name:"Name",value:t.callSetName}),t.genotypeName&&s.push({name:"Genotype",value:t.genotypeName}),void 0!==t.phaseset&&s.push({name:"Phase set",value:t.phaseset}),void 0!==t.genotypeLikelihood&&s.push({name:"genotypeLikelihood",value:t.genotypeLikelihood.toString()}),o){var a=o.getAttributes(t.callSetName);a&&Object.keys(a).forEach((function(t){var e=t.replace(/([A-Z])/g," $1");e=e.charAt(0).toUpperCase()+e.slice(1),s.push({name:e,value:a[t]})}))}var c=Object.keys(t.info);c.length&&s.push("<hr/>"),c.forEach((function(e){s.push({name:e,value:decodeURIComponent(t.info[e])})}))}}return s}menuItemList(){const t=[];if(this.header.INFO&&this.header.INFO){const e=this.header.INFO.SVTYPE?["SVTYPE"]:[];if(this._initColorBy&&"SVTYPE"!==this._initColorBy&&e.push(this._initColorBy),e.length>0){t.push("<hr/>");const n=de('<div class="igv-track-menu-category igv-track-menu-border-top">');n.text("Color by:"),t.push({name:void 0,object:n,click:void 0,init:void 0}),e.sort();for(let n of e){const e=this.colorBy===n,r=n||"None";t.push(this.colorByCB({key:n,label:r},e))}t.push(this.colorByCB({key:void 0,label:"None"},void 0===this.colorBy)),t.push("<hr/>")}}this.getCallsetsLength()>0&&(t.push({object:de('<div class="igv-track-menu-border-top">')}),t.push({object:de(Po("Show Genotypes",this.showGenotypes)),click:()=>{this.showGenotypes=!this.showGenotypes,this.trackView.checkContentHeight(),this.trackView.repaintViews()}})),t.push({object:de('<div class="igv-track-menu-border-top">')});for(let e of["COLLAPSED","SQUISHED","EXPANDED"]){t.push({object:de(Po({COLLAPSED:"Collapse",SQUISHED:"Squish",EXPANDED:"Expand"}[e],e===this.displayMode)),click:()=>{this.displayMode=e,this.trackView.checkContentHeight(),this.trackView.repaintViews()}})}return this.browser.circularView&&(t.push("<hr>"),t.push({label:"Add SVs to circular view",click:()=>{for(let t of this.trackView.viewports)this.sendChordsForViewport(t)}})),t}contextMenuItemList(t){if(this.browser.circularView){const e=t.viewport,n=[];return n.push({label:"Add SVs to Circular View",click:()=>{this.sendChordsForViewport(e)}}),n.push("<hr/>"),n}}sendChordsForViewport(t){const e=t.referenceFrame,n="all"===e.chr?this.featureSource.getAllFeatures():this.featureSource.featureCache.queryFeatures(e.chr,e.start,e.end);tl(n.filter((t=>{const e=t._f||t;return e.info&&e.info.CHR2&&e.info.END&&(e.info.CHR2!==e.chr||Math.abs(Number.parseInt(e.info.END)-e.pos)>1e6)})).map((t=>{const e=t._f||t,n=Number.parseInt(e.info.END),r=n-100,i=n+100;return{uniqueId:`${e.chr}:${e.start}-${e.end}_${e.info.CHR2}:${e.info.END}`,refName:Qc(e.chr),start:e.start,end:e.end,mate:{refName:Qc(e.info.CHR2),start:r,end:i}}})),this,e,.5)}colorByCB(t,e){return{name:void 0,object:de(Po(t.label,e)),click:()=>{t.key===this.colorBy?(this.colorBy=void 0,delete this.config.colorBy,this.trackView.repaintViews()):(this.colorBy=t.key,this.config.colorBy=t.key,this.trackView.repaintViews())},init:void 0}}getState(){const t=super.getState();return this._color&&"function"!=typeof this._color&&(t.color=this._color),t}getVariantColorTable(t){if(this.colorTables||(this.colorTables=new Map),!this.colorTables.has(t)){let e;if("SVTYPE"===t)e=ef;else e=new _c("Set1");this.colorTables.set(t,e)}return this.colorTables.get(t)}}const ef=new Sc({DEL:"#ff2101",INS:"#001888",DUP:"#028401",INV:"#008688",CNV:"#8931ff",BND:"#891100","*":"#002eff"});class nf extends bc{constructor(t,e){super(t,e)}init(t){super.init(t),this.name=t.name,this.pValueField=t.pValueField||"pValue",this.geneField=t.geneField||"geneSymbol",this.snpField=t.snpField||"snp";const e=t.minLogP||t.min,n=t.maxLogP||t.max;this.dataRange={min:e||3.5,max:n||25},this.autoscale=!n||t.autoscale,this.autoscalePercentile=void 0===t.autoscalePercentile?98:t.autoscalePercentile,this.background=t.background,this.divider=t.divider||"rgb(225,225,225)",this.dotSize=t.dotSize||2,this.height=t.height||100,this.autoHeight=!1,this.disableButtons=t.disableButtons,this.visibilityWindow=void 0===t.visibilityWindow?2e6:t.visibilityWindow>=0?Math.min(2e6,t.visibilityWindow):2e6,this.featureSource=Cu(t,this.browser.genome),Eu.gtexLoaded=!0}paintAxis(t,e,n){const r=(this.dataRange.max-this.dataRange.min)/n,i={font:"normal 10px Arial",textAlign:"right",strokeStyle:"black"};ls.fillRect(t,0,0,e,n,{fillStyle:"rgb(255, 255, 255)"});const o=Math.ceil(10*(this.dataRange.max-this.dataRange.min)/n);for(let s=4;s<=this.dataRange.max;s+=o){const o=.85*e,a=o-5,c=o,l=n-(s-this.dataRange.min)/r;ls.strokeLine(t,a,l,c,l,i),l>8&&ls.fillText(t,s,a-1,l+2,i)}i.textAlign="center",ls.fillText(t,"-log10(pvalue)",e/4,n/2,i,{rotate:{angle:-90}})}async getFeatures(t,e,n){const r=this.pValueField,i=this.visibilityWindow,o=await this.featureSource.getFeatures({chr:t,start:e,end:n,visibilityWindow:i});return o.forEach((function(t){t.value=t[r]})),o}draw(t){const e=t.context,n=t.pixelWidth,r=t.pixelHeight;this.background&&ls.fillRect(e,0,0,n,r,{fillStyle:this.background}),ls.strokeLine(e,0,r-1,n,r-1,{strokeStyle:this.divider});const i=i=>{const o=i?2*this.dotSize:this.dotSize,s=t.bpStart,a=(this.dataRange.max-this.dataRange.min)/r,c=t.referenceFrame.selection;for(let h of t.features){const u=(h.start-s+.5)/t.bpPerPixel;if(u<0)continue;if(u>n)break;const f=h.snp.toUpperCase(),d=h[this.geneField].toUpperCase(),p=c&&(c.snp===f||c.gene===d);if(!i||p){c&&c.snp===f&&c.addGene(d);var l=-Math.log(h[this.pValueField])/Math.LN10;if(l>=this.dataRange.min){let t;l>this.dataRange.max?(l=this.dataRange.max,t=!0):t=!1;const n=Math.max(0+o,r-Math.round((l-this.dataRange.min)/a));let s;h.px=u,h.py=n,h.radius=o,i&&c?(s=c.colorForGene(d),ls.setProperties(e,{fillStyle:s,strokeStyle:"black"})):(s=t?"rgb(150, 150, 150)":"rgb(180, 180, 180)",ls.setProperties(e,{fillStyle:s,strokeStyle:s})),ls.fillCircle(e,u,n,o),ls.strokeCircle(e,u,n,o)}}}};i(!1),i(!0)}popupData(t){let e=t.viewport.cachedFeatures;if(!e||0===e.length)return[];const n=this.name,r=[];for(let i of e)Math.abs(i.px-t.canvasX)<i.radius+3&&Math.abs(i.py-t.canvasY)<i.radius+3&&(r.length>0&&r.push("<hr/>"),r.push({name:"snp id",value:i.snp},{name:"gene id",value:i.geneId},{name:"gene name",value:i.geneName},{name:"p value",value:i.pValue},{name:"tissue",value:n}));return r}menuItemList(){return Oo.numericDataMenuItems(this.trackView)}doAutoscale(t){if(t.length>0){var e=t.map((function(t){return-Math.log(t.value)/Math.LN10}));this.dataRange.max=Ki(e,this.autoscalePercentile)}else{const t=this.config.maxLogP||this.config.max;this.dataRange.max=t||25}return this.dataRange}}const rf={X:"rgb(204, 153, 0)",Y:"rgb(153, 204, 0)",Un:"darkGray)",1:"rgb(80, 80, 255)",I:"rgb(139, 155, 187)",2:"rgb(206, 61, 50)",II:"rgb(206, 61, 50)","2a":"rgb(210, 65, 55)","2b":"rgb(215, 70, 60)",3:"rgb(116, 155, 88)",III:"rgb(116, 155, 88)",4:"rgb(240, 230, 133)",IV:"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 pd of Object.keys(rf)){rf["chr"+pd]=rf[pd]}class of extends bc{constructor(t,e){super(t,e)}init(t){super.init(t),this.useChrColors=void 0===t.useChrColors||t.useChrColors,this.trait=t.trait,this.posteriorProbability=t.posteriorProbability,this.valueProperty="bed"===t.format?"score":"value",this.height=t.height||100,this.autoscale=t.autoscale,this.autoscalePercentile=void 0===t.autoscalePercentile?98:t.autoscalePercentile,this.background=t.background,this.divider=t.divider||"rgb(225,225,225)",this.dotSize=t.dotSize||3,this.popoverWindow=void 0===t.popoverWindow?1e8:t.popoverWindow,this.colorScales=t.color?new Vu(t.color):{"*":new zu(t.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=Cu(t,this.browser.genome)}async postInit(){return"function"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader()),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(t,e,n){const r=this.visibilityWindow;return this.featureSource.getFeatures({chr:t,start:e,end:n,visibilityWindow:r})}draw(t){const e=t.features,n=t.context,r=t.pixelWidth,i=t.pixelHeight;if(this.background&&ls.fillRect(n,0,0,r,i,{fillStyle:this.background}),ls.strokeLine(n,0,i-1,r,i-1,{strokeStyle:this.divider}),e){const o=t.bpPerPixel,s=t.bpStart,a=s+r*o+1;for(let t of e){const e=t.start;if(e<s)continue;if(e>a)break;const r=this.getColorScale(t._f?t._f.chr:t.chr);let c,l;if(this.posteriorProbability)l=t[this.valueProperty],c=r.getColor(l);else{const e=t[this.valueProperty];if(!e)continue;l=-Math.log10(e),c=r.getColor(l)}const h=(this.dataRange.max-this.dataRange.min)/i,u=Math.round((e-s)/o),f=Math.max(this.dotSize,i-Math.round((l-this.dataRange.min)/h));c&&ls.setProperties(n,{fillStyle:c,strokeStyle:"black"}),ls.fillCircle(n,u,f,this.dotSize),t.px=u,t.py=f}}}getColorScale(t){if(this.useChrColors){let e=this.colorScales[t];if(!e){const n=rf[t]||Ec.get();e=new Vu(n),this.colorScales[t]=e}return e}return this.colorScales("*")}paintAxis(t,e,n){ls.fillRect(t,0,0,e,n,{fillStyle:"rgb(255, 255, 255)"});var r={font:"normal 10px Arial",textAlign:"right",strokeStyle:"black"};const i=(this.dataRange.max-this.dataRange.min)/n;if(this.posteriorProbability){const e=.1;for(let o=this.dataRange.min;o<this.dataRange.max;o+=e){const e=n-Math.round((o-this.dataRange.min)/i);ls.strokeLine(t,45,e-2,50,e-2,r),ls.fillText(t,o.toFixed(1),44,e+2,r)}}else{const e=Math.ceil(10*(this.dataRange.max-this.dataRange.min)/n);for(let o=this.dataRange.min;o<this.dataRange.max;o+=e){const e=n-Math.round((o-this.dataRange.min)/i);ls.strokeLine(t,45,e,50,e,r),ls.fillText(t,Math.floor(o),44,e+4,r)}}r.textAlign="center",this.posteriorProbability?ls.fillText(t,"PPA",e/2,n/2,r,{rotate:{angle:-90}}):ls.fillText(t,"-log10(pvalue)",e/2,n/2,r,{rotate:{angle:-90}})}popupData(t){let e=[];const n=t.viewport.trackView.track,r=t.viewport.cachedFeatures;if(r){let i=0;for(let o of r){const r=Math.abs(t.canvasX-o.px),s=Math.abs(t.canvasY-o.py),a=o[this.valueProperty];if(r<this.dotSize&&s<this.dotSize){if(i>0&&e.push("<HR/>"),5==i){e.push("...");break}if("function"==typeof o.popupData)e=e.concat(o.popupData());else{const t=o.realChr||o.chr,r=(o.realStart||o.start)+1;e.push({name:"chromosome",value:t}),e.push({name:"position",value:r}),e.push({name:"name",value:o.name}),n.posteriorProbability?e.push({name:"posterior probability",value:a}):e.push({name:"pValue",value:a})}i++}}}return e}menuItemList(){return Oo.numericDataMenuItems(this.trackView)}doAutoscale(t){if(t.length>0){const e=this.valueProperty,n=this.posteriorProbability,r=t.map((function(t){const r=t[e];return{value:n?r:-Math.log(r)/Math.LN10}}));this.dataRange=ms(r)}else this.posteriorProbability?(this.dataRange.min=this.config.min||0,this.dataRange.max=this.config.max||1):(this.dataRange.max=this.config.max||25,this.dataRange.min=this.config.min||0);return this.dataRange}}class sf extends bc{constructor(t,e){super(t,e)}init(t){super.init(t),this.autoscale=t.autoscale||void 0===t.max,this.dataRange={min:t.min||0,max:t.max},this.windowFunction=t.windowFunction||"mean",this.paintAxis=yc,this.graphType=t.graphType||"bar",t._featureSource?(this.featureSource=t._featureSource,delete t._featureSource):this.featureSource=Cu(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.sampleNames=this.header.columnNames.slice(3),this.setTrackProperties(this.header),this.header.hasOwnProperty("clickToHighlight")){let t=this.header.clickToHighlight;this.config.clickToHighlight=t,this.config.samplesClickedToHighlight={}}if(this.header.hasOwnProperty("highlight")){this.config.highlightSamples={};let t=this.header.highlight;Array.isArray(t)||(t=[t]);for(let e of t){const t=e.split(";");2===t.length&&(this.config.highlightSamples[t[0]]=t[1])}}}}menuItemList(){return Oo.numericDataMenuItems(this.trackView)}async getFeatures(t,e,n){const r=await this.featureSource.getFeatures({chr:t,start:0,end:Number.MAX_SAFE_INTEGER,visibilityWindow:this.visibilityWindow});let i,o;for(let t=1;t<r.length-1;t++)if(void 0===i&&r[t].end>e&&(i=t-1),void 0===o&&r[t].start>n){o=t+1;break}return void 0===i&&(i=0),void 0===o&&(o=r.length),r.slice(i,o)}draw(t){const{features:e,context:n,bpPerPixel:r,bpStart:i,pixelWidth:o,pixelHeight:s}=t,a=t=>(this.dataRange.max-t)/(this.dataRange.max-this.dataRange.min)*s,c=function(t){let e=Math.floor((t-i)/r);return isNaN(e)&&console.warn("isNaN(x). feature start "+_e(t)+" bp start "+_e(i)),e};if(e&&e.length>0&&(void 0===this.dataRange.min&&(this.dataRange.min=0),this.dataRange.max>this.dataRange.min)){const t=this.config.highlightSamples,r=this.config.onlyHandleClicksForHighlightedSamples,i=this.config.clickToHighlight;let o=-1,s={},l=[],h=[];this.clickDetectorCache={};for(let u of e){const e=c(u.start),f=c(u.end),d=o>=0?c(o):e;if(!isNaN(e)&&!isNaN(f)){this.clickDetectorCache[e]=[],this.clickDetectorCache[f]=[];for(let o=0;o<u.values.length;o++){const c=this.sampleNames[o],p=u.values[o],g=a(p);if(e-d>=1){const o=s[c],h=a(o),u=t&&t[c];u?l.push([d,h,e,g,u]):i&&c in this.config.samplesClickedToHighlight?l.push([d,h,e,g,this.config.samplesClickedToHighlight[c]]):ls.strokeLine(n,d,h,e,g,{strokeStyle:"#D9D9D9"}),r&&!(c in t)||this.clickDetectorCache[e].push([d,h,e,g,c,u||"gray"])}if(f-e>=1){const o=t&&t[c];o?h.push([e,g,f,g,o]):i&&c in this.config.samplesClickedToHighlight?h.push([e,g,f,g,this.config.samplesClickedToHighlight[c]]):ls.strokeLine(n,e,g,f,g,{strokeStyle:"gray"}),r&&!(c in t)||this.clickDetectorCache[f].push([e,g,f,g,c,o||"gray"])}s[c]=p}o=u.end}}for(let t of l)ls.strokeLine(n,t[0],t[1],t[2],t[3],{strokeStyle:t[4],lineWidth:1.3});for(let t of h)ls.strokeLine(n,t[0],t[1],t[2],t[3],{strokeStyle:t[4],lineWidth:2})}(t=>{if(this.config.hasOwnProperty("guideLines"))for(let e of this.config.guideLines)if(e.hasOwnProperty("color")&&e.hasOwnProperty("y")&&e.hasOwnProperty("dotted")){let n=a(e.y),r={strokeStyle:e.color,strokeWidth:2};e.dotted?ls.dashedLine(t.context,0,n,t.pixelWidth,n,5,r):ls.strokeLine(t.context,0,n,t.pixelWidth,n,r)}})(t)}doAutoscale(t){let e,n;return t.length>0?(e=Number.MAX_VALUE,n=-Number.MAX_VALUE,t.forEach((function(t){e=Math.min(e,...t.values),n=Math.max(n,...t.values)})),e-=.01,n+=.01):(e=0,n=100),{min:e,max:n}}clickedFeatures(t){const e=t.canvasX,n=t.canvasY;let r=null;for(r of Object.keys(this.clickDetectorCache))if(r=parseInt(r),r>=e)break;if(r){let t=Number.MAX_VALUE,s=[];const a=this.clickDetectorCache[r];for(let r of a){const i=r[0],o=r[2];if(e<i||e>o)return[];const a=r[1],c=r[3];if(n<Math.min(a,c)-10||n>Math.max(a,c)+10)continue;const l=af(e,n,i,a,o,c);l<t&&(s=[{name:r[4],color:r[5]}],t=l)}if(t<5){if(this.config.clickToHighlight){if(s[0].name in this.config.samplesClickedToHighlight)delete this.config.samplesClickedToHighlight[s[0].name];else if("any"===this.config.clickToHighlight){var i=["red","darkblue","green","teal","olivedrab","orange","maroon","purple","blue","gold"],o=i[Math.floor(Math.random()*(i.length+1))];this.config.samplesClickedToHighlight[s[0].name]=o}else this.config.samplesClickedToHighlight[s[0].name]=this.config.clickToHighlight;this.trackView.repaintViews()}return s}}return[]}popupData(t,e){e=this.clickedFeatures(t,e);const n=[];return e.forEach((function(t){for(let e of Object.keys(t))ps(t[e])&&n.push({name:e,value:t[e]})})),n}get supportsWholeGenome(){return!1}}function af(t,e,n,r,i,o){const s=i-n,a=o-r,c=Math.abs(s*(r-e)-(n-t)*a),l=Math.sqrt(s*s+a*a);return l>0?c/l:0}class cf extends bc{constructor(t,e){super(t,e),t.height||(this.height=300),this.arcOrientation=!1,this.theta=Math.PI/2,"bp"===t.format?this.featureSource=new hf(t,e.genome):this.featureSource=new Jh(t,e.genome)}async getFeatures(t,e,n){const r=this.visibilityWindow;return this.featureSource.getFeatures({chr:t,start:e,end:n,visibilityWindow:r})}draw(t){const e=t.context,n=Math.PI/2,r=t.pixelWidth,i=t.pixelHeight;t.viewportWidth;const o=t.bpPerPixel,s=t.bpStart,a=o,c=this.arcOrientation;ls.fillRect(e,0,t.pixelTop,r,i,{fillStyle:"rgb(255, 255, 255)"});const l=t.features;if(l){lf(l,1);for(let t of l)if(t.startLeft){let r=Math.round((t.startLeft-s)/a),i=Math.round((t.startRight-s)/a),o=Math.round((t.endLeft-s)/a),l=Math.round((t.endRight-s)/a);e.fillStyle=t.color,e.strokeStyle=t.color,e.beginPath();let h=(r+l)/2,u=(l-r)/2,f=this.height,d=Math.PI+(Math.PI/2-n),p=2*Math.PI-(Math.PI/2-n);c?(f=0,e.arc(h,f,u,p,d),e.lineTo(l,f)):(e.arc(h,f,u,d,p),e.lineTo(o,f));const g=(i+o)/2,m=(o-i)/2,v=f;c?(e.arc(g,v,m,d,p,!0),e.lineTo(o,v)):(e.arc(g,v,m,p,d,!0),e.lineTo(r,v)),e.stroke(),e.fill(),t.drawState={x1:h,y1:f,r1:u,x2:g,y2:v,r2:m,sa:d,ea:p}}else{let r=Math.round((t.start-s)/a),i=Math.round((t.end-s)/a);e.strokeStyle=t.color,e.beginPath();let o=(r+i)/2,l=(i-r)/2,h=this.height,u=Math.PI+(Math.PI/2-n),f=2*Math.PI-(Math.PI/2-n);c?(h=0,e.arc(o,h,l,f,u)):e.arc(o,h,l,u,f),e.stroke(),t.drawState={x1:o,y1:h,r1:l,sa:u,ea:f}}}}clickedFeatures(t,e){const n=[];lf(e=super.clickedFeatures(t,e),-1);for(let r of e){const e=r.drawState,i=t.canvasX-e.x1,o=t.canvasY-e.y1,s=Math.sqrt(i*i+o*o),a=e.r1+3;let c,l;if(void 0===e.x2)c=s,l=e.r1-3;else{const n=t.canvasX-e.x2,r=t.canvasY-e.y2;c=Math.sqrt(n*n+r*r),l=e.r2-3}if(s<a&&c>l){n.push(r);break}}return n}popupData(t,e){if((e=this.clickedFeatures(t,e))&&e.length>0)return bc.extractPopupData(e[0],this.getGenomeId())}menuItemList(){var t=this;return[{name:"Toggle arc direction",click:function(){t.arcOrientation=!t.arcOrientation,t.trackView.repaintViews()}}]}}function lf(t,e){t.sort((function(t,n){const r=void 0===t.score?-Number.MAX_VALUE:t.score,i=void 0===n.score?-Number.MAX_VALUE:n.score;return(void 0===e?1:e)*(r-i)}))}class hf{constructor(t,e){this.config=t,this.genome=e}async getFeatures({chr:t,start:e,end:n,bpPerPixel:r,visibilityWindow:i}){const o=this.genome;if(this.featureCache)return this.featureCache.queryFeatures(t,e,n);{const r=gs(this.config),i=await go.loadString(this.config.url,r);return this.featureCache=new Mo(function(t){if(!t)return null;const e=Fh(t);let n,r=!0;const i=[],o=[],s=[];for(;void 0!==(n=e.nextLine());){const t=n.split("\t");if(r&&n.startsWith("color:")){const e="rgb("+t[1]+","+t[2]+","+t[3]+")";i.push(e),t.length>4&&o.push(t[4])}else{r=!1;const e=t[0],n=Number.parseInt(t[1])-1,c=Number.parseInt(t[2])-1,l=Number.parseInt(t[3]),h=Number.parseInt(t[4]);var a=Number.parseInt(t[5]);const u=i[a];let f;f=n<=h?{chr:e,startLeft:Math.min(n,c),startRight:Math.max(n,c),endLeft:Math.min(l,h),endRight:Math.max(l,h),color:u,score:a}:{chr:e,startLeft:Math.min(l,h),startRight:Math.max(l,h),endLeft:Math.min(n,c),endRight:Math.max(n,c),color:u,score:a},f.start=f.startLeft,f.end=f.endRight,o.length>a&&(f.description=o[a]),s.push(f)}}return s}(i),o),this.featureCache.queryFeatures(t,e,n)}}}class uf{constructor(t){this.browser=t,this.type="ideogram",this.height=16,this.order=Number.MIN_SAFE_INTEGER,this.disableButtons=!0,this.ignoreTrackMenu=!0}async getFeatures(t,e,n){return[]}computePixelHeight(t){return this.height}draw({context:t,referenceFrame:e,pixelWidth:n,pixelHeight:r}){const i=e.chr,o=e.genome.getChromosome(i);if(void 0===o||n<=0||r<=0||"all"===i.toLowerCase())return;!function({ctx:t,chr:e,referenceFrame:n,genome:r,width:i,height:o,stainColors:s}){const a=1,c=.5*a,l=0;if(void 0===r)return;ls.fillRect(t,0,0,i,o,{fillStyle:no.greyScale(255)});const h=r.getCytobands(e);if(h){const e=l+o/2,n=[],r=[];if(0===h.length)return;const u=i/h[h.length-1].end;t.beginPath(),ls.roundRect(t,c,c+l,i-2*c,o-2*c,(o-2*c)/2,0,1),t.clip();for(let i=0;i<h.length;i++){const c=h[i],f=u*c.start,d=u*c.end;"c"===c.type?("p"===c.name.charAt(0)?(n[0]=f,r[0]=o+l,n[1]=f,r[1]=l,n[2]=d,r[2]=e):(n[0]=d,r[0]=o+l,n[1]=d,r[1]=l,n[2]=f,r[2]=e),t.fillStyle="rgb(150, 0, 0)",t.strokeStyle="rgb(150, 0, 0)",ls.polygon(t,n,r,1,0)):(t.fillStyle=ff(s,c),ls.fillRect(t,f,a+l,d-f,o-2*a))}}t.strokeStyle=no.greyScale(41),ls.roundRect(t,c,c+l,i-2*c,o-2*c,(o-2*c)/2,0,1)}({ctx:t,chr:i,referenceFrame:e,genome:e.genome,width:n,height:r,stainColors:[]});const s=Math.round(e.bpPerPixel*n),a=e.start;let c=o.bpLength;const l=e.genome.getCytobands(i);if(l&&l.length>0&&l[l.length-1].end&&(c=Math.max(c,l[l.length-1].end),o.bpLength=c),s<c){const e=s/c,i=a/c;let o=Math.floor(i*n),l=Math.floor(e*n);o=Math.max(0,o),o=Math.min(n-l,o),t.save(),t.strokeStyle="red",t.lineWidth=l<2?1:2;const h=o+t.lineWidth/2;l=l<2?1:l-t.lineWidth;const u=t.lineWidth/2,f=r-t.lineWidth;t.strokeRect(h,u,l,f),t.restore()}}dispose(){this.trackView=void 0}}function ff(t,e){if("c"===e.type)return"rgb(150, 10, 10)";var n=e.stain,r=230;"p"===e.type&&(r=Math.floor(230-n/100*230));var i=t[r];return i||(i="rgb("+r+","+r+","+r+")",t[r]=i),i}let df=new _c("Dark2");["GT/AG","CT/AC","GC/AG","CT/GC","AT/AC","GT/AT","non-canonical"].forEach((t=>{df.getColor(t)}));const pf={};class gf extends bc{constructor(t,e){super(t,e)}init(t){super.init(t),this.type=t.type||"junctions",t._featureSource?(this.featureSource=t._featureSource,delete t._featureSource):this.featureSource=t.featureSource?t.featureSource:Cu(t,this.browser.genome),this.margin=void 0===t.margin?10:t.margin,this.height||(this.height=100),void 0===t.colorByNumReadsThreshold&&(t.colorByNumReadsThreshold=5)}async postInit(){return"function"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader()),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(t,e,n,r){const i=this.visibilityWindow;return this.featureSource.getFeatures({chr:t,start:e,end:n,bpPerPixel:r,visibilityWindow:i})}computePixelHeight(t){return this.height}draw(t){const e=t.features,n=t.context,r=t.bpPerPixel,i=t.bpStart,o=t.pixelWidth,s=t.pixelHeight,a=i+o*r+1;if(this.config.isMergedTrack||ls.fillRect(n,0,t.pixelTop,o,s,{fillStyle:"rgb(255, 255, 255)"}),e){pf.referenceFrame=t.viewport.referenceFrame,pf.referenceFrameStart=pf.referenceFrame.start,pf.referenceFrameEnd=pf.referenceFrameStart+pf.referenceFrame.toBP(de(t.viewport.contentDiv).width()),pf.featureZoomOutTracker={};for(let t of e)if(!(t.end<i)){if(t.start>a)break;this.renderJunction(t,i,r,s,n)}}else console.log("No feature list")}renderJunction(t,e,n,r,i){t.isVisible=!1;const o=Math.round((t.start-e)/n),s=Math.round((t.end-e)/n),a=(o+s)/2;if(s-o<=3){if(a in pf.featureZoomOutTracker)return;pf.featureZoomOutTracker[a]=!0}if(this.config.hideAnnotatedJunctions&&"true"===t.attributes.annotated_junction)return;if(this.config.hideUnannotatedJunctions&&"false"===t.attributes.annotated_junction)return;if(this.config.hideMotifs&&this.config.hideMotifs.includes(t.attributes.motif))return;if(this.config.hideStrand===t.strand)return;if(this.config.minJunctionEndsVisible){let e=0;if(t.start>=pf.referenceFrameStart&&t.start<=pf.referenceFrameEnd&&(e+=1),t.end>=pf.referenceFrameStart&&t.end<=pf.referenceFrameEnd&&(e+=1),e<this.config.minJunctionEndsVisible)return}let c,l,h,u;if(t.attributes.uniquely_mapped){if(c=parseInt(t.attributes.uniquely_mapped),c<this.config.minUniquelyMappedReads)return;if(l=parseInt(t.attributes.multi_mapped),h=c+l,h<this.config.minTotalReads)return;if(h>0&&l/h>this.config.maxFractionMultiMappedReads)return;if(t.attributes.maximum_spliced_alignment_overhang&&parseInt(t.attributes.maximum_spliced_alignment_overhang)<this.config.minSplicedAlignmentOverhang)return}if(t.attributes.num_samples_with_this_junction){if(u=parseInt(t.attributes.num_samples_with_this_junction),this.config.minSamplesWithThisJunction&&u<this.config.minSamplesWithThisJunction)return;if(this.config.maxSamplesWithThisJunction&&u>this.config.maxSamplesWithThisJunction)return;if(t.attributes.num_samples_total&&(t.attributes.percent_samples_with_this_junction=100*u/Number(t.attributes.num_samples_total),this.config.minPercentSamplesWithThisJunction&&(t.attributes.percent_samples_with_this_junction<this.config.minPercentSamplesWithThisJunction||t.attributes.percent_samples_with_this_junction>this.config.maxPercentSamplesWithThisJunction)))return}const f=this.margin,d=this.height,p=f+.5*d;let g=f;const m=f+d-10,v=(o+a)/2,b=(a+s)/2;let w,y,x=1;t.attributes.line_width?x=Number(t.attributes.line_width):(void 0===this.config.thicknessBasedOn||"numUniqueReads"===this.config.thicknessBasedOn?x=c:"numReads"===this.config.thicknessBasedOn?x=h:"numSamplesWithThisJunction"===this.config.thicknessBasedOn&&void 0!==u&&(x=u),x=1+Math.log(x+1)/Math.log(12)),void 0===this.config.bounceHeightBasedOn||"random"===this.config.bounceHeightBasedOn?w=(t.start+t.end)%7:"distance"===this.config.bounceHeightBasedOn?w=6*(t.end-t.start)/(pf.referenceFrameEnd-pf.referenceFrameStart):"thickness"===this.config.bounceHeightBasedOn&&(w=2*x),g+=d*Math.max(7-w,0)/10,y=t.attributes.color?t.attributes.color:void 0===this.config.colorBy||"numUniqueReads"===this.config.colorBy?c>this.config.colorByNumReadsThreshold?"blue":"#AAAAAA":"numReads"===this.config.colorBy?h>this.config.colorByNumReadsThreshold?"blue":"#AAAAAA":"isAnnotatedJunction"===this.config.colorBy?"true"===t.attributes.annotated_junction?"#b0b0ec":"orange":"strand"===this.config.colorBy?"+"===t.strand?"#b0b0ec":"#ecb0b0":"motif"===this.config.colorBy?df.getColor(t.attributes.motif):"#AAAAAA";let k="";t.attributes.label?k=t.attributes.label.replace(/_/g," "):void 0===this.config.labelWith||"uniqueReadCount"===this.config.labelWith?k=c:"totalReadCount"===this.config.labelWith?k=h:"numSamplesWithThisJunction"===this.config.labelWith?void 0!==u&&(k=u):"percentSamplesWithThisJunction"===this.config.labelWith?void 0!==t.attributes.percent_samples_with_this_junction&&(k=t.attributes.percent_samples_with_this_junction.toFixed(0)+"%"):"motif"===this.config.labelWith&&void 0!==t.attributes.motif&&(k+=t.attributes.motif),"uniqueReadCount"===this.config.labelWithInParen?k+=" ("+c+")":"totalReadCount"===this.config.labelWithInParen?k+=" ("+h+")":"multiMappedReadCount"===this.config.labelWithInParen?l>0&&(k+=" (+"+l+")"):"numSamplesWithThisJunction"===this.config.labelWithInParen?void 0!==u&&(k+=" ("+u+")"):"percentSamplesWithThisJunction"===this.config.labelWithInParen?void 0!==t.attributes.percent_samples_with_this_junction&&(k+=" ("+t.attributes.percent_samples_with_this_junction.toFixed(0)+"%)"):"motif"===this.config.labelWithInParen&&void 0!==t.attributes.motif&&(k+=` ${t.attributes.motif}`),t.isVisible=!0,i.beginPath(),i.moveTo(o,m),i.bezierCurveTo(v,g,b,g,s,m),i.lineWidth=x,i.strokeStyle=y,i.stroke();const _=(t,e,n,r)=>{t.beginPath(),t.moveTo(e,n),t.lineTo(e-r/2,n-r),t.lineTo(e+r/2,n-r),t.lineTo(e,n),t.closePath(),t.fill()};if(t.attributes.left_shape||t.attributes.right_shape){i.fillStyle=y;const e=i.lineWidth>2?10:7;t.attributes.left_shape&&_(i,o,m,e),t.attributes.right_shape&&_(i,s,m,e)}i.fillText(k,a-i.measureText(k).width/2,(7*g+p)/8)}clickedFeatures(t,e){return super.clickedFeatures(t,e).filter((function(t){return t.isVisible&&t.attributes}))}popupData(t,e){e=this.clickedFeatures(t,e);const n=t.genomicLocation,r=[];for(let t of e){const e="function"==typeof t.popupData?t.popupData(n):this.extractPopupData(t._f||t,this.getGenomeId());e&&(r.length>0&&r.push("<hr/><hr/>"),Array.prototype.push.apply(r,e))}return r}dispose(){this.trackView=void 0}}const mf=new Map([["ideogram",(t,e)=>new uf(t,e)],["sequence",(t,e)=>new Ns(t,e)],["feature",(t,e)=>new Du(t,e)],["seg",(t,e)=>new ju(t,e)],["mut",(t,e)=>new ju(t,e)],["maf",(t,e)=>new ju(t,e)],["wig",(t,e)=>new Bu(t,e)],["merged",(t,e)=>new qu(t,e)],["alignment",(t,e)=>new rl(t,e)],["interaction",(t,e)=>new Wu(t,e)],["interact",(t,e)=>new Wu(t,e)],["variant",(t,e)=>new tf(t,e)],["eqtl",(t,e)=>new nf(t,e)],["gwas",(t,e)=>new of(t,e)],["arc",(t,e)=>new cf(t,e)],["gcnv",(t,e)=>new sf(t,e)],["junction",(t,e)=>new gf(t,e)]]);var vf=function(t,e){mf.set(t,e)},bf=function(t,e,n){let r;switch(t){case"annotation":case"genes":case"fusionjuncspan":case"snp":r="feature";break;case"seg":case"maf":case"mut":r="seg";break;case"junctions":case"splicejunctions":r="junction";break;default:r=t}return mf.has(r)?mf.get(r)(e,n):void 0};class wf{constructor(t,e){this.config=t,this.name=t.name,this.roiSource=Cu(t,e),this.color=t.color||"rgba(68, 134, 247, 0.25)"}async getFeatures(t,e,n){return this.roiSource.getFeatures({chr:t,start:e,end:n})}draw(t){var e,n,r,i;if(i=t.features){e=t.bpStart+(t.pixelWidth*t.bpPerPixel+1);for(var o=0,s=i.length;o<s;o++)if(!((n=i[o]).end<t.bpStart)){if(n.start>e)break;r=yf(n,t.bpStart,t.bpPerPixel),ls.fillRect(t.context,r.x,t.pixelTop,r.width,t.pixelHeight,{fillStyle:this.color})}}}}function yf(t,e,n){var r,i;return r=Math.round((t.start-e)/n),(i=Math.round((t.end-e)/n)-r)<3&&(i=3,r-=1),{x:r,width:i}}class xf{constructor(t,e){const n=(new DOMParser).parseFromString(t,"text/xml");this.processRootNode(n,e);const r=n.getElementsByTagName("Resource"),i=n.getElementsByTagName("Track"),o=i&&i.length>0,s=[];this.tracks=s;const a=new Map;Array.from(r).forEach((function(t,e){var n={url:t.getAttribute("path"),indexURL:t.getAttribute("index"),order:e};a.set(n.url,n),o||s.push(n)})),o&&Array.from(i).forEach((function(t){const e=t.getElementsByTagName("Track");if(e&&e.length>0){const n={type:"merged",tracks:[]};kf(t,n),s.push(n),Array.from(e).forEach((function(t){t.processed=!0;const e=t.getAttribute("id"),r=a.get(e);r&&(n.tracks.push(r),kf(t,r),r.autoscale=!1,n.height=r.height)}))}else if(!t.processed){const e=t.getAttribute("id"),n=a.get(e);n&&(s.push(n),kf(t,n))}}))}processRootNode(t,e){const n=t.getElementsByTagName("Session");!n||n.length;const r=n.item(0),i=r.getAttribute("genome"),o=r.getAttribute("locus"),s=r.getAttribute("ucscID");e&&e.hasOwnProperty(i)?this.genome=i:(this.reference={fastaURL:i},s&&(this.reference.id=s)),o&&(this.locus=o)}}function kf(t,e){e.name=t.getAttribute("name");const n=t.getAttribute("color");n&&(e.color="rgb("+n+")");const r=t.getAttribute("altColor");n&&(e.altColor="rgb("+r+")");const i=t.getAttribute("height");i&&(e.height=parseInt(i));const o=t.getAttribute("autoScale");o&&(e.autoscale="true"===o);const s=t.getAttribute("autoscaleGroup");s&&(e.autoscaleGroup=s);const a=t.getAttribute("windowFunction");a&&(e.windowFunction=a);const c=t.getAttribute("visibilityWindow")||t.getAttribute("featureVisibilityWindow");c&&(e.visibilityWindow=c);const l=t.getAttribute("indexed");l&&(e.indexed="true"===l);const h=t.getAttribute("normalize");h&&(e.normalize="true"===h);const u=t.getElementsByTagName("DataRange");if(u.length>0){const t=u.item(0);e.min=Number(t.getAttribute("minimum")),e.max=Number(t.getAttribute("maximum")),e.logScale="LOG"===t.getAttribute("type")}}const _f=Se;class Sf{constructor(){this.attributes={},this.plinkLoaded=!1}async loadPlinkFile(t,e){e||(e={});var n=gs(e);const r=await go.loadString(t,n);var i=_f(r);for(let t of i){var o=t.split(" ");this.attributes[o[1]]={familyId:o[0],fatherId:o[2],motherId:o[3],sex:o[4],phenotype:o[5]}}return this.plinkLoaded=!0,this}getAttributes(t){return this.attributes[t]}getAttributeNames(){return this.hasAttributes()?Object.keys(this.attributes[Object.keys(this.attributes)[0]]):[]}hasAttributes(){return Object.keys(this.attributes).length>0}}class Cf{constructor(t,e){this.geneColors={},this.gene=null,this.snp=null,this.genesCount=0,t&&(this.gene=t.toUpperCase(),this.geneColors[this.gene]=Ef[this.genesCount++]),e&&(this.snp=e.toUpperCase())}addGene(t){this.geneColors[t.toUpperCase()]||(this.geneColors[t.toUpperCase()]=Ef[this.genesCount++])}colorForGene(t){return this.geneColors[t.toUpperCase()]}}var Ef=[];Ef.push("rgb(228,26,28)"),Ef.push("rgb(55,126,184)"),Ef.push("rgb(77,175,74)"),Ef.push("rgb(166,86,40)"),Ef.push("rgb(152,78,163)"),Ef.push("rgb(255,127,0)"),Ef.push("rgb(247,129,191)"),Ef.push("rgb(153,153,153)"),Ef.push("rgb(255,255,51)"),Ef.push("rgb(102, 194, 165"),Ef.push("rgb(252, 141, 98"),Ef.push("rgb(141, 160, 203"),Ef.push("rgb(231, 138, 195"),Ef.push("rgb(166, 216, 84"),Ef.push("rgb(255, 217, 47"),Ef.push("rgb(229, 196, 148"),Ef.push("rgb(179, 179, 179"),Ef.push("rgb( 141, 211, 199"),Ef.push("rgb(255, 255, 179"),Ef.push("rgb(190, 186, 218"),Ef.push("rgb(251, 128, 114"),Ef.push("rgb(128, 177, 211"),Ef.push("rgb(253, 180, 98"),Ef.push("rgb(179, 222, 105"),Ef.push("rgb(252, 205, 229"),Ef.push("rgb(217, 217, 217"),Ef.push("rgb(188, 128, 189"),Ef.push("rgb(204, 235, 197"),Ef.push("rgb(255, 237, 111");class Af{constructor(t,e,n,r,i){this.genome=t,this.chr=e,this.start=n,this.end=r,this.bpPerPixel=i,this.id=ve()}extend(t){const e=Math.min(t.start,this.start),n=Math.max(t.end,this.end),r=(n-e)/(this.end-this.start);this.start=e,this.end=n,this.bpPerPixel*=r}calculateEnd(t){return this.start+this.bpPerPixel*t}calculateBPP(t,e){return(t-this.start)/e}set(t){this.chr=t.chr,this.start=t.start,this.bpPerPixel=t.bpPerPixel}toPixels(t){return t/this.bpPerPixel}toBP(t){return this.bpPerPixel*t}shiftPixels(t,e){const n=this.start,r=t*this.bpPerPixel;this.start+=r,this.clampStart(e),this.end+=r;const{bpLength:i}=this.genome.getChromosome(this.chr);return this.end=Math.min(i,this.end),n!==this.start}clampStart(t){const e=this.genome.getChromosome(this.chr).bpStart||0;if(this.start=Math.max(e,this.start),t){const{bpLength:e}=this.genome.getChromosome(this.chr),n=e-t*this.bpPerPixel;this.start>n&&(this.start=n)}}async zoomWithScaleFactor(t,e,n,r){const i=void 0===r?this.start+this.toBP(n/2):r,{start:o,bpPerPixel:s}=this.start,{bpLength:a}=this.getChromosome(),c=e<1?t.minimumBases()/n:a/n;this.bpPerPixel=e<1?Math.max(this.bpPerPixel*e,c):Math.min(this.bpPerPixel*e,c);const l=this.bpPerPixel*n;this.start=i-.5*l,this.clampStart(n),this.end=this.start+l;(o!==this.start||s!==this.bpPerPixel)&&await t.updateViews(!0)}getChromosome(){return this.genome.getChromosome(this.chr)}getMultiLocusLabel(t){const e=Math.floor(this.start)+1,n=Math.round(this.start+this.bpPerPixel*t);return` ${this.chr}     ${ws(n-e)} `}getPresentationLocusComponents(t){if("all"===this.chr)return{chr:this.chr};{const e=_e(Math.floor(this.start)+1),n=_e(Math.round(this.start+this.bpPerPixel*t));return{chr:this.chr,start:e,end:n}}}getLocusString(){if("all"===this.chr)return"all";{const t=_e(Math.floor(this.start)+1),e=_e(Math.round(this.end));return`${this.chr}:${t}-${e}`}}description(t){console.log(` ${t||""} referenceFrame - ${this.chr} bpp ${this.bpPerPixel.toFixed(3)} start ${_e(Math.round(this.start))} end ${_e(Math.round(this.end))} `)}}const Tf={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)"},Lf={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 Mf(t,e){if(void 0===e||""===e.trim())return;(e&&"all"===e.trim().toLowerCase()||"*"===e)&&(e="all");const n=e.split(" ");let r=t.searchConfig||Lf,i=[];const o=async n=>{let i=function(t,e){const n=e.split(":"),r=n[0];if("all"===r&&t.genome.getChromosome(r))return{chr:r,start:0,end:t.genome.getChromosome(r).bpLength};if(void 0===t.genome.getChromosome(r))return;{const e={chr:t.genome.getChromosomeName(r),start:0,end:t.genome.getChromosome(r).bpLength};if(n.length>1){const t=n[1].split("-");if(t.length>2)return;{let n;if(n=t[0].replace(/,/g,""),isNaN(n))return;if(e.start=parseInt(n,10)-1,e.end=e.start+1,1===t.length&&(e.start-=20,e.end+=20),2===t.length){if(n=t[1].replace(/,/g,""),isNaN(n))return;e.end=parseInt(n,10)}}}return e}}(t,n);if(!i){const r=t.genome.featureDB[n.toUpperCase()];r&&(i={chr:r.chr,start:r.start,end:r.end,gene:r.name,locusSearchString:e})}if(!i&&t.config&&!1!==t.config.search)try{i=await async function(t,e,n){let r=n.url.replace("$FEATURE$",e.toUpperCase());r.indexOf("$GENOME$")>-1&&(r=r.replace("$GENOME$",t.genome.id?t.genome.id:"hg19"));const i=n.timeout?{timeout:n.timeout}:void 0,o=await go.loadString(r,i),s=function(t,e,n){let r;r="plain"===n.type?function(t,e){const n=[],r=[];return Se(e).forEach((function(t){""===t||n.push(t)})),n.forEach((function(e){var n,i,o,s,a=e.split("\t");a.length>=3&&(o=(i=a[1].split(":"))[1].split("-"),n=a[2].trim(),s={gene:a[0],chromosome:t.genome.getChromosomeName(i[0].trim()),start:parseInt(o[0].replace(/,/g,"")),end:parseInt(o[1].replace(/,/g,"")),type:"gtex"===n?"snp":"gene"},r.push(s))})),r}(t,e):JSON.parse(e);n.resultsField&&(r=r[n.resultsField]);if(r&&0!==r.length){const e=n.chromosomeField||"chromosome",i=n.startField||"start",o=n.endField||"end",s=n.coords||1;let a;a=Array.isArray(r)?r[0]:r,a.hasOwnProperty(e)&&a.hasOwnProperty(i)||console.error("Search service results must include chromosome and start fields: "+a);const c=a[e],l=t.genome.getChromosome(c);if(!l)return;const h=l.name;let u=a[i]-s,f=a[o];void 0===f&&(f=u+1);const d={chr:h,start:u,end:f},p=a.type?a.type:"gene";return n.geneField&&"gene"===p&&(d.gene=a[n.geneField]),n.snpField&&"snp"===p&&(d.snp=a[n.snpField]),d}return}(t,o,n);s&&(s.locusSearchString=e);return s}(t,n,r)}catch(t){throw console.error(t),Error("Search service currently unavailable.")}return i};for(let t of n){const e=await o(t);e&&(e.locusSearchString=t,i.push(e))}if(0===i.length){const t=await o(e);t&&(t.locusSearchString=e,i.push(t))}return 0===i.length?void 0:i}class Rf{constructor(t){this.browser=t}navbarDidResize(t,e){this.updateNavbar(this.createResponsiveClassSchedule(t,e))}updateNavbar(t){this.browser.$toggle_button_container.removeClass(),this.browser.$toggle_button_container.addClass(t.$toggle_button_container),de(this.browser.zoomWidget.zoomContainer).removeClass(),de(this.browser.zoomWidget.zoomContainer).addClass(t.zoomContainer)}createResponsiveClassSchedule(t,e){let n={};return e?this.browser.windowSizePanel.hide():this.browser.windowSizePanel.show(),t>990?(n.$toggle_button_container="igv-navbar-toggle-button-container",n.zoomContainer="igv-zoom-widget"):t>860?(n.$toggle_button_container="igv-navbar-toggle-button-container",n.zoomContainer="igv-zoom-widget-900"):t>540?(n.$toggle_button_container="igv-navbar-toggle-button-container-750",n.zoomContainer="igv-zoom-widget-900"):(n.$toggle_button_container="igv-navbar-toggle-button-container-750",n.zoomContainer="igv-zoom-widget-900",this.browser.windowSizePanel.hide()),e&&(n.zoomContainer="igv-zoom-widget-hidden"),n}}const If=function(t,e){this.container=pe({class:"igv-chromosome-select-widget-container"}),e.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&&t.search(this.select.value)})),this.showAllChromosomes=!1!==t.config.showAllChromosomes};If.prototype.show=function(){this.container.style.display="flex"},If.prototype.hide=function(){this.container.style.display="none"},If.prototype.update=function(t){const e=this.showAllChromosomes?t.chromosomeNames.slice():t.wgChromosomeNames.slice();t.showWholeGenomeView()&&(e.unshift("all"),e.unshift("")),this.select.innerHTML="";for(let t of e){const e=document.createElement("option");e.setAttribute("value",t),e.innerText=t,this.select.appendChild(e)}};class Nf{constructor(t,e){this.container=pe({class:"igv-windowsize-panel-container"}),t.appendChild(this.container),e.on("locuschange",(t=>{this.updatePanel(t)})),this.browser=e}show(){this.container.style.display="block"}hide(){this.container.style.display="none"}updatePanel(t){const e=this.browser.calculateViewportWidth(this.browser.referenceFrameList.length);this.container.innerText=1===t.length?ws(Math.round(e*t[0].bpPerPixel)):""}}class Pf{constructor(t,e){this.browser=e,this.columnContainer=t,this.horizontalGuide=pe({class:"igv-cursor-guide-horizontal"}),t.appendChild(this.horizontalGuide),this.verticalGuide=pe({class:"igv-cursor-guide-vertical"}),t.appendChild(this.verticalGuide),this.addMouseHandler(e),this.setVisibility(e.config.showCursorGuide)}addMouseHandler(t){this.boundMouseMoveHandler=function(e){const{x:n,y:r}=be(e,this.columnContainer);this.horizontalGuide.style.top=`${r}px`;const i=document.elementFromPoint(e.clientX,e.clientY);let o;if(i.parentElement&&(i.parentElement.classList.contains("igv-viewport-content")?o=i.parentElement.parentElement:i.parentElement.classList.contains("igv-viewport")&&i.classList.contains("igv-viewport-content")&&(o=i.parentElement),o&&t.getRulerTrackView())){this.verticalGuide.style.left=`${n}px`;const r=t.root.querySelectorAll(".igv-column");let i;const s=o.parentElement;for(let t=0;t<r.length;t++)void 0===i&&s===r[t]&&(i=t);const a=t.getRulerTrackView().viewports[i].mouseMove(e);if(a){const{start:t,bp:e,end:n}=a,r=(e-t)/(n-t);this.customMouseHandler&&this.customMouseHandler({start:t,bp:e,end:n,interpolant:r})}}}.bind(this),this.columnContainer.addEventListener("mousemove",this.boundMouseMoveHandler)}removeMouseHandler(){this.columnContainer.removeEventListener("mousemove",this.boundMouseMoveHandler)}setVisibility(t){!0===t?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 t of this.browser.getRulerTrackView().viewports)t.$tooltip.hide()}}class Of{constructor(t,e){this.browser=t,this.button=pe({class:"igv-navbar-button"}),e.appendChild(this.button),this.button.textContent="cursor guide",this.button.addEventListener("click",(()=>{t.cursorGuideVisible=!t.cursorGuideVisible,t.setCursorGuideVisibility(t.cursorGuideVisible),this.setButtonState(t.cursorGuideVisible)})),this.setButtonState(t.cursorGuideVisible),t.config.showCursorTrackingGuideButton?this.show():this.hide()}setButtonState(t){!0===t?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 Ff{constructor(t,e){this.browser=t,this.button=pe({class:"igv-navbar-button"}),e.appendChild(this.button),this.button.textContent="center line",this.button.addEventListener("click",(()=>{t.isCenterLineVisible=!t.isCenterLineVisible,t.setCenterLineVisibility(t.isCenterLineVisible),this.setButtonState(t.isCenterLineVisible)})),this.setButtonState(t.isCenterLineVisible),t.config.showCenterGuideButton?this.show():this.hide()}setButtonState(t){!0===t?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 Df{constructor(t,e){this.button=pe({class:"igv-navbar-button"}),t.appendChild(this.button),this.button.textContent="track labels",this.button.addEventListener("click",(()=>{e.trackLabelsVisible=!e.trackLabelsVisible,this.setState(e.trackLabelsVisible),e.setTrackLabelVisibility(e.trackLabelsVisible)})),this.browser=e,this.setVisibility(e.config.showTrackLabelButton),this.setState(e.trackLabelsVisible)}setVisibility(t){!0===t?this.show():this.hide()}setState(t){!0===t?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 Bf{constructor(t,e){this.button=pe({class:"igv-navbar-button"}),t.appendChild(this.button),this.button.innerText="Sample Names",this.setState(e.showSampleNames),this.setVisibility(e.showSampleNameButton),this.button.addEventListener("click",(()=>{e.showSampleNames=!e.showSampleNames,this.setState(e.showSampleNames);for(let{sampleNameViewport:t}of e.trackViews)!1===e.showSampleNames?t.hide():t.show();e.layoutChange()}))}setVisibility(t){!0===t?this.show():this.hide()}setState(t){!0===t?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 zf=23,Hf=0;const Vf=function(t,e){this.browser=t,this.zoomContainer=pe({class:"igv-zoom-widget"}),e.appendChild(this.zoomContainer),this.zoomOutButton=pe(),this.zoomContainer.appendChild(this.zoomOutButton),this.zoomOutButton.appendChild(we("minus-circle")),this.zoomOutButton.addEventListener("click",(()=>{t.zoomOut()}));const n=pe();this.zoomContainer.appendChild(n),this.slider=document.createElement("input"),this.slider.type="range",this.slider.min="0",this.slider.max=`${zf}`,n.appendChild(this.slider),this.slider.addEventListener("change",(e=>{e.preventDefault(),e.stopPropagation();const n=t.referenceFrameList[0],{bpLength:r}=n.genome.getChromosome(n.chr),{end:i,start:o}=n,s=i-o,a=r/Math.pow(2,e.target.valueAsNumber);t.zoomWithScaleFactor(a/s)})),this.zoomInButton=pe(),this.zoomContainer.appendChild(this.zoomInButton),this.zoomInButton.appendChild(we("plus-circle")),this.zoomInButton.addEventListener("click",(()=>{t.zoomIn()})),t.on("locuschange",(t=>{this.browser.isMultiLocusMode()?this.disable():(this.enable(),this.update(t))}))};Vf.prototype.update=function(t){const e=t[0],{bpLength:n}=e.genome.getChromosome(e.chr),{start:r,end:i}=e;zf=Math.ceil(Math.log2(n/this.browser.minimumBases())),this.slider.max=`${zf}`;const o=n/(i-r);Hf=Math.log2(o),this.slider.value=`${Math.round(Hf)}`},Vf.prototype.enable=function(){this.slider.disabled=!1},Vf.prototype.disable=function(){this.slider.disabled=!0},Vf.prototype.hide=function(){this.zoomContainer.style.display="none"},Vf.prototype.show=function(){this.zoomContainer.style.display="block"},Vf.prototype.hideSlider=function(){this.slider.style.display="none"},Vf.prototype.showSlider=function(){this.slider.style.display="block"};const jf=function(t,e){const n=pe({class:"igv-navbar-button"});t.append(n),n.textContent="Save SVG",n.addEventListener("click",(()=>e.saveSVGtoFile({})))},Uf=(t,e)=>{const n=0===t?e.nextElementSibling:e.previousElementSibling;e.remove(),n.remove()},qf=t=>{const e=pe({class:"igv-column-shim"});_s(e,t);const n=pe({class:"igv-column"});return _s(n,e),n},Wf=(t,e)=>{for(let n=0;n<e;n++){const r=pe({class:"igv-column"});if(ks(r,t),e>1&&n>0){ks(pe({class:"igv-column-shim"}),r)}}};class $f{constructor(t,e,n){this.browser=t,this.referenceFrame=e,this.column=n,this.container=pe({class:"igv-center-line"}),n.appendChild(this.container),t.isCenterLineVisible?this.show():this.hide()}repaint(){const t=Math.floor(this.browser.calculateViewportWidth(this.browser.referenceFrameList.length)/2);if(this.referenceFrame){1/this.referenceFrame.bpPerPixel>1?(this.container.style.left=`${t}px`,this.container.style.width=`${Math.floor(this.referenceFrame.toPixels(1))}px`,this.container.classList.remove("igv-center-line-thin"),this.container.classList.add("igv-center-line-wide")):(this.container.style.left=`${t}px`,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 Gf=_e;class Zf{constructor(t){this.browser=t,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(t,e,n){return[]}computePixelHeight(t){return this.height}draw({context:t,referenceFrame:e,pixelWidth:n,pixelHeight:r,bpPerPixel:i,bpStart:o}){na.isWholeGenomeView(e.chr)?this.drawWholeGenome({context:t,pixelWidth:n,pixelHeight:r,bpPerPixel:i}):this.doDraw({context:t,referenceFrame:e,pixelWidth:n,pixelHeight:r,bpStart:o})}drawWholeGenome({context:t,pixelWidth:e,pixelHeight:n,bpPerPixel:r}){t.save(),ls.fillRect(t,0,0,e,n,{fillStyle:"white"});for(let e of this.browser.genome.wgChromosomeNames){let i=this.browser.genome.getCumulativeOffset(e),o=this.browser.genome.getChromosome(e).bpLength,s=Math.round(i/r),a=Math.round(o/r);this.renderChromosomeRect(t,s,0,a,n,e)}t.restore()}doDraw({context:t,referenceFrame:e,pixelWidth:n,pixelHeight:r,bpStart:i}){t.clearRect(0,0,n,r);const o=function(t,e){if(t<10)return new Xf(1,"bp",1);const n=Math.floor(Math.log10(t));let r="bp",i=1;n>9?(r="gb",i=1e9):n>6?(r="mb",i=1e6):n>3&&(r="kb",i=1e3);const o=Math.pow(10,n-1),s=t/o,a=75,c=Math.pow(10,n-1),l=Math.pow(10,n)/2;return new Xf(s<a&&!0!==e?c:l,r,i)}(Math.floor(e.toBP(n)),t.isSVG);let s=Math.floor(i/o.majorTick)-1;const{tickDelta:a,labelLength:c}=function(t,e,n,r,i){const o=l(e,c(1+r,i),n)-l(e,c(r,i),n),s=`${_e(Math.floor(c(r,i)/i.unitMultiplier))} ${i.majorUnit}`,a=Math.floor(t.measureText(s).width);return{tickDelta:o,labelLength:a};function c(t,e){return Math.floor(t*e.majorTick)}function l(t,e,n){return Math.round(t.toPixels(e-1-n+.5))}}(t,e,i,s,o);let l,h;this.browser.referenceFrameList.indexOf(e);let u=a;const f=.25*c;do{h=Math.floor(s*o.majorTick);const n=`${_e(Math.floor(h/o.unitMultiplier))} ${o.majorUnit}`;l=Math.round(e.toPixels(h-1-i+.5));const r=Math.round(l-t.measureText(n).width/2);r>0&&f+c<=u&&(ls.fillText(t,n,r,this.height-8),u=0),l>0&&ls.strokeLine(t,l,this.height-6,l,this.height-2),h=Math.floor((1+s)*o.majorTick);let d=l+(Math.round(e.toPixels(h-1-i+.5))-l)/2;d>0&&ls.strokeLine(t,d,this.height-6,d,this.height-2),++s,u+=a}while(l<n);ls.strokeLine(t,0,this.height-2,n,this.height-2)}renderChromosomeRect(t,e,n,r,i,o){t.textAlign="center",t.textBaseline="middle",t.font="12px sans-serif",ls.strokeLine(t,e+r,n,e+r,n+i,{strokeStyle:no.greyScale(191)});const s=o.startsWith("chr")?o.substring(3):o;r>t.measureText(s).width&&ls.fillText(t,s,e+r/2,n+i/2,{fillStyle:no.greyScale(68)})}get supportsWholeGenome(){return!0}dispose(){}}class Xf{constructor(t,e,n){this.majorTick=t,this.minorTick=t/10,this.majorUnit=e,this.unitMultiplier=n}description(t){console.log((t||"")+" tick "+Gf(this.majorTick)+" label width "+Gf(this.labelWidthBP)+" multiplier "+this.unitMultiplier)}}const Yf=function(t,e){this.button=pe({class:"igv-navbar-button"}),t.appendChild(this.button),this.button.textContent="circular view",this.button.addEventListener("click",(()=>{e.circularViewVisible=!e.circularViewVisible})),this.browser=e,this.setVisibility(e.config.showCircularViewButton),this.setState(e.circularViewVisible)};Yf.prototype.setVisibility=function(t){!0===t?this.show():this.hide()},Yf.prototype.setState=function(t){!0===t?this.button.classList.add("igv-navbar-button-clicked"):this.button.classList.remove("igv-navbar-button-clicked")},Yf.prototype.show=function(){this.button.style.display="block",this.setState(this.browser.circularViewVisible)},Yf.prototype.hide=function(){this.button.style.display="none"};const Kf=function(t,e,n){const r=pe({class:"igv-navbar-button"});t.append(r),r.textContent=n.label,r.addEventListener("click",(()=>n.callback(e)))};class Qf{constructor(t,e){this.config=t,this.guid=ve(),this.namespace=".browser_"+this.guid,this.parent=e,this.root=pe({class:"igv-container"}),e.appendChild(this.root),Qo.init(this.root),this.columnContainer=pe({class:"igv-column-container"}),this.root.appendChild(this.columnContainer),this.menuPopup=new yl(this.columnContainer),this.initialize(t),this.trackViews=[],this.constants={dragThreshold:3,scrollThreshold:5,defaultColor:"rgb(0,0,150)",doubleClickDelay:t.doubleClickDelay||500},this.eventHandlers={},this.addMouseHandlers(),this.setControls(t)}initialize(t){t.gtex&&(Eu.gtexLoaded=!0),this.flanking=t.flanking,this.crossDomainProxy=t.crossDomainProxy,this.formats=t.formats,this.trackDefaults=t.trackDefaults,this.nucleotideColors=t.nucleotideColors||Tf;for(let t of Object.keys(this.nucleotideColors))this.nucleotideColors[t.toLowerCase()]=this.nucleotideColors[t];this.trackLabelsVisible=t.showTrackLabels,this.isCenterLineVisible=t.showCenterGuide,this.cursorGuideVisible=t.showCursorGuide,this.showSampleNames=t.showSampleNames,this.showSampleNameButton=t.showSampleNameButton,this.sampleNameViewportWidth=t.sampleNameViewportWidth||200,t.search&&(this.searchConfig={type:"json",url:t.search.url,coords:void 0===t.search.coords?1:t.search.coords,chromosomeField:t.search.chromosomeField||"chromosome",startField:t.search.startField||"start",endField:t.search.endField||"end",geneField:t.search.geneField||"gene",snpField:t.search.snpField||"snp",resultsField:t.search.resultsField})}setControls(t){const e=this.createStandardControls(t);e.insertBefore(de(this.columnContainer)),this.$navigation=e,!1===t.showControls&&e.hide()}createStandardControls(t){this.navbarManager=new Rf(this);const e=de("<div>",{class:"igv-navbar"});this.$navigation=e;const n=de("<div>",{class:"igv-navbar-left-container"});e.append(n);const r=de("<div>",{class:"igv-logo"});n.append(r);const i=de('<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>');i.css("width","34px"),i.css("height","32px"),r.append(i),this.$current_genome=de("<div>",{class:"igv-current-genome"}),n.append(this.$current_genome),this.$current_genome.text("");const o=de("<div>",{class:"igv-navbar-genomic-location"});n.append(o),this.chromosomeSelectWidget=new If(this,o.get(0)),void 0===t.showChromosomeWidget&&(t.showChromosomeWidget=!0),!0===t.showChromosomeWidget?this.chromosomeSelectWidget.show():this.chromosomeSelectWidget.hide();const s=de("<div>",{class:"igv-locus-size-group"});o.append(s);const a=de("<div>",{class:"igv-search-container"});s.append(a),this.$searchInput=de("<input>",{class:"igv-search-input",type:"text",placeholder:"Locus Search"}),a.append(this.$searchInput),this.$searchInput.change((()=>this.doSearch(this.$searchInput.val())));const c=pe({class:"igv-search-icon-container"});a.append(de(c)),c.appendChild(we("search")),c.addEventListener("click",(()=>this.doSearch(this.$searchInput.val()))),this.windowSizePanel=new Nf(s.get(0),this);const l=de("<div>",{class:"igv-navbar-right-container"});e.append(l);const h=de('<div class="igv-navbar-toggle-button-container">');if(l.append(h),this.$toggle_button_container=h,this.cursorGuide=new Pf(this.columnContainer,this),this.cursorGuideButton=new Of(this,h.get(0)),this.centerLineButton=new Ff(this,h.get(0)),this.setTrackLabelVisibility(t.showTrackLabels),this.trackLabelControl=new Df(h.get(0),this),this.sampleNameControl=new Bf(h.get(0),this),!0===t.showSVGButton&&(this.svgSaveControl=new jf(h.get(0),this)),t.customButtons)for(let e of t.customButtons)new Kf(h.get(0),this,e);return this.zoomWidget=new Vf(this,l.get(0)),!1===t.showNavigation&&this.$navigation.hide(),this.inputDialog=new Jo(this.root),this.inputDialog.container.id=`igv-input-dialog-${ve()}`,this.dataRangeDialog=new cs(de(this.root)),this.dataRangeDialog.$container.get(0).id=`igv-data-range-dialog-${ve()}`,this.genericColorPicker=new wl({parent:this.columnContainer,width:432}),this.genericColorPicker.container.id=`igv-track-color-picker-${ve()}`,e}getSampleNameViewportWidth(){return!1===this.showSampleNames?0:this.sampleNameViewportWidth}isMultiLocusMode(){return this.referenceFrameList&&this.referenceFrameList.length>1}addTrackToFactory(t,e){vf(t,e)}isMultiLocusWholeGenomeView(){if(void 0===this.referenceFrameList||1===this.referenceFrameList.length)return!1;for(let t of this.referenceFrameList)if("all"===t.chr.toLowerCase())return!0;return!1}toSVG(){let{x:t,y:e,width:n,height:r}=this.columnContainer.getBoundingClientRect();let i=new js({width:n,height:8e3,backdropColor:"white",multiLocusGap:0,viewbox:{x:0,y:0,width:n,height:8e3}});for(let t of this.trackViews)t.renderSVGContext(i,{deltaX:0,deltaY:-e});return i.setHeight(r),i.getSerializedSvg(!0)}renderSVG(t){const e=this.toSVG();return t.empty(),t.append(e),e}saveSVGtoFile(t){let e=this.toSVG();t.$container&&(t.$container.empty(),t.$container.append(e));qe(t.filename||"igvjs.svg",URL.createObjectURL(new Blob([e],{type:"application/octet-stream"})))}async loadSession(t){let e;return this.roi=[],e=t.url||t.file?await async function(t){const e=t.url||t.file;if(t.url&&(t.url.startsWith("blob:")||t.url.startsWith("data:"))){const e=Qf.uncompressSession(t.url);return JSON.parse(e)}{let n=t.filename;if(n||(n=t.url?await bs(t.url):t.file.name),n.endsWith(".xml")){const t=na.KNOWN_GENOMES,n=await go.loadString(e);return new xf(n,t)}return n.endsWith(".json")?go.loadJson(e):void 0}}(t):t,this.loadSessionObject(e)}async loadSessionObject(t){this.cleanHouseForSession(),this.showSampleNames=t.showSampleNames||!1,this.sampleNameControl.setState(!0===this.showSampleNames),t.sampleNameViewportWidth&&(this.sampleNameViewportWidth=t.sampleNameViewportWidth),xs(this.columnContainer,"igv-axis-column"),xs(this.columnContainer,"igv-sample-name-column"),xs(this.columnContainer,"igv-scrollbar-column"),xs(this.columnContainer,"igv-track-drag-column"),xs(this.columnContainer,"igv-gear-menu-column");const e=await na.expandReference(t.reference||t.genome);if(await this.loadReference(e,t.locus),this.centerLineList=this.createCenterLineList(this.columnContainer),!1!==t.showIdeogram){const t=new uf(this);t.id="ideogram",this.trackViews.push(new Sl(this,this.columnContainer,t))}if(!1!==t.showRuler&&this.trackViews.push(new Sl(this,this.columnContainer,new Zf(this))),t.gtexSelections)for(let e of this.referenceFrameList)for(let n of Object.keys(t.gtexSelections)){const r=t.gtexSelections[n].gene,i=t.gtexSelections[n].snp;e.selection=new Cf(r,i)}if(t.roi){this.roi=[];for(let e of t.roi)this.roi.push(new wf(e,this.genome))}const n=e.tracks||[],r=t.tracks?n.concat(t.tracks):n;0===r.filter((t=>"sequence"===t.type)).length&&r.push({type:"sequence",order:Ts});let i=1;for(let t of r)void 0===t.order&&(t.order=i++);await this.loadTrackList(r);for(let t of this.trackViews.filter((t=>"ruler"===t.track.type||"ideogram"===t.track.type)))t.updateViews();this.updateUIWithReferenceFrameList()}createCenterLineList(t){const e=t.querySelectorAll(".igv-center-line");for(let t=0;t<e.length;t++)e[t].remove();const n=[],r=t.querySelectorAll(".igv-column");for(let t=0;t<r.length;t++)n.push(new $f(this,this.referenceFrameList[t],r[t]));return n}async loadReference(t,e){const n=await na.loadGenome(t),r=void 0===this.genome||this.genome.id!==n.id;this.genome=n,this.updateNavbarDOMWithGenome(n),r&&this.removeAllTracks();let i=function(t,e){return t?Array.isArray(t)?t.join(" "):t:e.getHomeChromosomeName()}(e,n);if(!await this.search(i,!0)){console.log("Initial locus not found: "+i),i=n.getHomeChromosomeName();if(!await this.search(i,!0))throw new Error("Cannot set initial locus")}r&&this.circularView&&this.circularView.setAssembly({name:this.genome.id,id:this.genome.id,chromosomes:Jc(this.genome)})}cleanHouseForSession(){for(let t of this.trackViews)t.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((t=>t.remove())),this.trackViews=[],this.circularView&&this.circularView.clearChords()}updateNavbarDOMWithGenome(t){this.$current_genome.text(t.id||""),this.$current_genome.attr("title",t.id||""),this.chromosomeSelectWidget.update(t)}async loadGenome(t){const e=await na.expandReference(t);await this.loadReference(e,void 0);const n=e.tracks||[];return 0===n.filter((t=>"sequence"===t.type)).length&&n.push({type:"sequence",order:Ts}),await this.loadTrackList(n),await this.updateViews(),this.genome}updateUIWithReferenceFrameList(){const t=this.referenceFrameList;this.updateLocusSearchWidget();const e=this.isMultiLocusWholeGenomeView()||na.isWholeGenomeView(t[0].chr);this.navbarManager.navbarDidResize(this.$navigation.width(),e),nd(this.trackViews,this.trackLabelsVisible),this.setCenterLineAndCenterLineButtonVisibility(!na.isWholeGenomeView(t[0].chr))}setTrackLabelVisibility(t){nd(this.trackViews,t)}setCursorGuideVisibility(t){t?this.cursorGuide.show():this.cursorGuide.hide()}setCustomCursorGuideMouseHandler(t){this.cursorGuide.customMouseHandler=t}setCenterLineVisibility(t){for(let e of this.centerLineList)!0===t?(e.show(),e.repaint()):e.hide()}setCenterLineAndCenterLineButtonVisibility(t){for(let e of this.centerLineList){t&&e.isVisible?e.show():e.container.style.display="none"}t&&this.centerLineButton.isVisible?this.centerLineButton.show():this.centerLineButton.button.style.display="none"}async loadTrackList(t){const e=[];for(let n of t)e.push(this.loadTrack(n));const n=await Promise.all(e);return this.trackViews.filter((function(t){return t.track.autoscaleGroup})).length>0&&this.updateViews(),n}async loadROI(t){if(this.roi||(this.roi=[]),Array.isArray(t))for(let e of t)this.roi.push(new wf(e,this.genome));else this.roi.push(new wf(t,this.genome));await this.updateViews(!0)}removeROI(t){for(let e=0;e<this.roi.length;e++)if(this.roi[e].name===t.name){this.roi.splice(e,1);break}for(let t of this.trackViews)t.repaintViews()}clearROIs(){this.roi=[];for(let t of this.trackViews)t.repaintViews()}getRulerTrackView(){const t=this.trackViews.filter((({track:t})=>"ruler"===t.id));return t.length>0?t[0]:void 0}async loadTrack(t){ke(t)&&(t=JSON.parse(t));try{const e=await this.createTrack(t);if(void 0===e)return Qo.presentAlert(new Error(`Unknown file type: ${t.url||t}`),void 0),e;void 0===e.order&&(e.order=this.trackViews.length);const n=new Sl(this,this.columnContainer,e);if(this.trackViews.push(n),nd(this.trackViews,this.trackLabelsVisible),this.reorderTracks(),this.fireEvent("trackorderchanged",[this.getTrackOrder()]),"function"==typeof e.postInit)try{n.startSpinner(),await e.postInit()}finally{n.stopSpinner()}return e.autoscaleGroup||(t.sync?await n.updateViews():n.updateViews()),"function"==typeof e.hasSamples&&e.hasSamples()&&!1!==this.config.showSampleNameButton&&this.sampleNameControl.show(),e}catch(e){const n={401:"Access unauthorized",403:"Access forbidden",404:"Not found"};console.error(e);let r=e.message||e.error||e.toString();n.hasOwnProperty(r)&&(r=n[r]),r+=": "+t.url,Qo.presentAlert(new Error(r),void 0)}}async createTrack(t){let e=await async function(t){return"function"==typeof t?t():t}(t.url);if(ke(e)&&(e=e.trim()),e)if(t.format)t.format=t.format.toLowerCase();else{let n=t.filename;n||(n=await bs(e)),t.format=function(t){var e,n;if((t=t.toLowerCase()).endsWith("refgene.txt.gz")||t.endsWith("refgene.txt.bgz")||t.endsWith("refgene.txt")||t.endsWith("refgene.sorted.txt.gz")||t.endsWith("refgene.sorted.txt.bgz"))return"refgene";switch((e=t.indexOf("?"))>0&&(t=t.substr(0,e)),t.endsWith(".gz")&&(t=t.substr(0,t.length-3)),(t.endsWith(".txt")||t.endsWith(".tab")||t.endsWith(".bgz"))&&(t=t.substr(0,t.length-4)),n=(e=t.lastIndexOf("."))<0?t:t.substr(e+1)){case"bw":return"bigwig";case"bb":return"bigbed";default:return fs.has(n)?n:void 0}}(n),t.format||void 0!==t.sourceType&&"htsget"!==t.sourceType||await ec.inferFormat(t)}let n=t.type?t.type.toLowerCase():void 0;if(!n){if(n=ds(t),"bedtype"===n){const e=Cu(t,this.genome);t._featureSource=e;const r=await e.trackType();n=r||"annotation"}t.type=n}if(this.trackDefaults&&n){const e=this.trackDefaults[n];if(e)for(let n in e)e.hasOwnProperty(n)&&void 0===t[n]&&(t[n]=e[n])}const r=bf(n,t,this);if(r&&t.roi){r.roi=[];for(let e of t.roi)r.roi.push(new wf(e,this.genome))}return r}reorderTracks(){this.trackViews.sort((function(t,e){const n=t=>"ideogram"===t.track.id?1:"ruler"===t.track.id?2:3,r=n(t),i=n(e);if(r===i){return(t.track.order||0)-(e.track.order||0)}return r-i}));for(let{axis:t,viewports:e,sampleNameViewport:n,outerScroll:r,dragHandle:i,gearContainer:o}of this.trackViews){t.remove();for(let{$viewport:t}of e)t.detach();n.viewport.remove(),r.remove(),i.remove(),o.remove()}const t=this.columnContainer.querySelectorAll(".igv-column");for(let{axis:e,viewports:n,sampleNameViewport:r,outerScroll:i,dragHandle:o,gearContainer:s}of this.trackViews){this.columnContainer.querySelector(".igv-axis-column").appendChild(e);for(let e=0;e<t.length;e++){const{$viewport:r}=n[e];t[e].appendChild(r.get(0))}this.columnContainer.querySelector(".igv-sample-name-column").appendChild(r.viewport),this.columnContainer.querySelector(".igv-scrollbar-column").appendChild(i),this.columnContainer.querySelector(".igv-track-drag-column").appendChild(o),this.columnContainer.querySelector(".igv-gear-menu-column").appendChild(s)}}getTrackOrder(){return this.trackViews.filter((t=>t.track&&t.track.name)).map((t=>t.track.name))}removeTrackByName(t){const e=this.trackViews.slice();for(let n of e)t===n.track.name&&this.removeTrack(n.track)}removeTrack(t){this.trackViews.splice(this.trackViews.indexOf(t.trackView),1),this.fireEvent("trackremoved",[t]),this.fireEvent("trackorderchanged",[this.getTrackOrder()]),t.trackView.dispose()}removeAllTracks(){const t=[];for(let e of this.trackViews)"ruler"!==e.track.id&&"ideogram"!==e.track.id?(this.fireEvent("trackremoved",[e.track]),e.dispose()):t.push(e);this.trackViews=t}findTracks(t,e){let n="function"==typeof t?e=>t(e.track):n=>e===n.track[t];return this.trackViews.filter(n).map((t=>t.track))}setTrackHeight(t){this.trackHeight=t,this.trackViews.forEach((function(e){e.setTrackHeight(t)}))}async visibilityChange(){this.layoutChange()}async layoutChange(){if(this.referenceFrameList.find((t=>t.bpPerPixel<0))){const t=this.calculateViewportWidth(this.referenceFrameList.length);for(let e of this.referenceFrameList)e.bpPerPixel=(e.end-e.start)/t}if(this.referenceFrameList){const t=this.isMultiLocusWholeGenomeView()||na.isWholeGenomeView(this.referenceFrameList[0].chr);this.navbarManager.navbarDidResize(this.$navigation.width(),t)}Jf.call(this),await this.updateViews()}async updateViews(){const t=this.trackViews;this.updateLocusSearchWidget();for(let t of this.centerLineList)t.repaint();if(this.dragObject)for(let e of t)await e.updateViews();else{const i={},o=[];for(let n of t){const t=n.track.autoscaleGroup;if(t){var e=i[t];e||(e=[],i[t]=e),e.push(n)}else o.push(n)}if(Object.entries(i).length>0){const t=Object.keys(i);for(let e of t){const t=i[e],o=[];for(let e of t)o.push(e.getInViewFeatures());const s=await Promise.all(o);var n,r=[];for(let t of s)r=r.concat(t);n=ms(r);const a=[];for(let e of t)e.track.dataRange=n,e.track.autoscale=!1,a.push(e.updateViews());await Promise.all(a)}}await Promise.all(o.map((t=>t.updateViews())))}}repaintViews(){for(let t of this.trackViews)t.repaintViews()}updateLocusSearchWidget(){const t=this.referenceFrameList,e=this.calculateViewportWidth(this.referenceFrameList.length);for(let n of t)n.end=n.start+n.bpPerPixel*e;this.chromosomeSelectWidget.select.value=1===t.length?this.referenceFrameList[0].chr:"";const n=this.referenceFrameList.map((t=>t.getLocusString())).join(" ");this.$searchInput.val(n),this.fireEvent("locuschange",[this.referenceFrameList])}calculateViewportWidth(t){let{width:e}=this.columnContainer.getBoundingClientRect();return e-=50+this.getSampleNameViewportWidth()+14+12+28,e-=5*(t-1),Math.floor(e/t)}getCenterLineXOffset(){let{width:t}=this.columnContainer.getBoundingClientRect();return t-=50+this.getSampleNameViewportWidth()+14+12+28,Math.floor(t/2+50)}minimumBases(){return this.config.minimumBases}zoomIn(){this.zoomWithScaleFactor(.5)}zoomOut(){this.zoomWithScaleFactor(2)}async zoomWithScaleFactor(t,e,n){const r=this.calculateViewportWidth(this.referenceFrameList.length);let i=n?[n]:this.referenceFrameList;for(let n of i)n.zoomWithScaleFactor(this,t,r,e)}async addMultiLocusPanel(t,e,n,r){const i=this.calculateViewportWidth(1+this.referenceFrameList.length),o=this.calculateViewportWidth(this.referenceFrameList.length)/this.calculateViewportWidth(1+this.referenceFrameList.length);for(let t of this.referenceFrameList)t.bpPerPixel*=o;const s=(n-e)/i,a=new Af(this.genome,t,e,n,s),c=r?this.referenceFrameList.indexOf(r):this.referenceFrameList.length-1,l=1+c,{$viewport:h}=this.trackViews[0].viewports[c],u=qf(h.get(0).parentElement);if(l===this.referenceFrameList.length){this.referenceFrameList.push(a);for(let t of this.trackViews){const e=gl(t,u,a);t.viewports.push(e)}}else{this.referenceFrameList.splice(l,0,a);for(let t of this.trackViews){const e=gl(t,u,a);t.viewports.splice(l,0,e)}}this.centerLineList=this.createCenterLineList(this.columnContainer),Jf.call(this),await this.updateViews(!0)}async removeMultiLocusPanel(t){const e=this.referenceFrameList.indexOf(t),{$viewport:n}=this.trackViews[0].viewports[e];Uf(e,n.parent().get(0));for(let{viewports:t}of this.trackViews)t[e].dispose(),t.splice(e,1);if(this.referenceFrameList.splice(e,1),1===this.referenceFrameList.length&&this.getRulerTrackView())for(let t of this.getRulerTrackView().viewports)t.dismissLocusLabel();const r=this.calculateViewportWidth(1+this.referenceFrameList.length)/this.calculateViewportWidth(this.referenceFrameList.length);await this.rescaleForMultiLocus(r)}async gotoMultilocusPanel(t){const e=this.referenceFrameList.indexOf(t);this.columnContainer.querySelectorAll(".igv-column").forEach(((t,n)=>{n===e||t.remove()})),this.columnContainer.querySelectorAll(".igv-column-shim").forEach((t=>t.remove()));for(let t of this.trackViews){const n=t.viewports[e];t.viewports.filter(((t,n)=>n!==e)).forEach((t=>t.dispose())),t.viewports=[n]}const n=this.calculateViewportWidth(1);t.bpPerPixel=(t.end-t.start)/n,this.referenceFrameList=[t],this.trackViews.forEach((({viewports:t})=>t.forEach((t=>t.setWidth(n))))),this.centerLineList=this.createCenterLineList(this.columnContainer),this.updateUIWithReferenceFrameList(),await this.updateViews(!0)}async rescaleForMultiLocus(t){const e=this.calculateViewportWidth(this.referenceFrameList.length);for(let e of this.referenceFrameList)e.bpPerPixel*=t;for(let{viewports:t}of this.trackViews)for(let n of t)n.setWidth(e);this.centerLineList=this.createCenterLineList(this.columnContainer),this.updateUIWithReferenceFrameList(),await this.updateViews()}async goto(t,e,n){await this.search(t+":"+e+"-"+n)}async doSearch(t,e){const n=await this.search(t,e);return n||Qo.presentAlert(new Error(`Unrecognized locus: <b> ${t} </b>`)),n}async search(t,e){const n=await Mf(this,t);if(n&&n.length>0){this.referenceFrameList=function(t,e,n,r,i){return t.map((t=>{n&&t.gene&&(t.start=Math.max(0,t.start-n),t.end+=n);const o=e.getChromosome(t.chr);vs(o.bpLength,t,r);const s=new Af(e,t.chr,t.start,t.end,(t.end-t.start)/i);return s.locusSearchString=t.locusSearchString,(t.gene||t.snp)&&(s.selection=new Cf(t.gene,t.snp)),s}))}(n,this.genome,this.flanking,this.minimumBases(),this.calculateViewportWidth(n.length));for(let t of this.trackViews)t.removeDOMFromColumnContainer();this.columnContainer.querySelectorAll(".igv-column-shim, .igv-column").forEach((t=>t.remove())),Wf(this.columnContainer.querySelector(".igv-sample-name-column"),this.referenceFrameList.length),this.centerLineList=this.createCenterLineList(this.columnContainer);for(let t of this.trackViews)t.addDOMToColumnContainer(this,this.columnContainer,this.referenceFrameList);return this.updateUIWithReferenceFrameList(),e||await this.updateViews(),!0}return!1}async loadSampleInformation(t){var e=t;je(t)&&(e=t.name),"fam"===e.substr(e.lastIndexOf(".")+1)&&(this.sampleInformation=await function(t,e){return(new Sf).loadPlinkFile(t,e)}(t))}on(t,e){this.eventHandlers[t]||(this.eventHandlers[t]=[]),this.eventHandlers[t].push(e)}un(t,e){this.off(t,e)}off(t,e){if(t)if(e){const n=this.eventHandlers[t];if(n&&0!==n.length){const r=n.indexOf(e);-1!==r&&this.eventHandlers[t].splice(r,1)}else console.warn("No handlers to remove for event: "+t)}else this.eventHandlers[t]=[];else this.eventHandlers={}}fireEvent(t,e,n){const r=this.eventHandlers[t];if(void 0===r||0===r.length)return;const i=n||window;return r.map((function(t){return t.apply(i,e)}))[0]}dispose(){this.removeMouseHandlers();for(let t of this.trackViews)t.dispose()}toJSON(){const t={version:"2.12.5"};if(void 0!==this.showSampleNames&&(t.showSampleNames=this.showSampleNames),200!==this.sampleNameViewportWidth&&(t.sampleNameViewportWidth=this.sampleNameViewportWidth),t.reference=this.genome.toJSON(),Ue(t.reference.fastaURL))throw new Error(`Error. Sessions cannot include local file references ${t.reference.fastaURL.name}.`);if(Ue(t.reference.indexURL))throw new Error(`Error. Sessions cannot include local file references ${t.reference.indexURL.name}.`);const e=[],n={};let r=!1,i=this.trackViews[0];for(let{referenceFrame:t}of i.viewports){const i=t.getLocusString();if(e.push(i),t.selection){const e={gene:t.selection.gene,snp:t.selection.snp};n[i]=e,r=!0}}t.locus=1===e.length?e[0]:e,r&&(t.gtexSelections=n);const o=[],s=[];for(let{track:t}of this.trackViews)try{let e;e="function"==typeof t.getState?t.getState():t.config,e&&(e.browser&&delete e.browser,e.order=t.order,o.push(e))}catch(e){console.error(`Track: ${t.name}: ${e}`),s.push(`Track: ${t.name}: ${e}`)}if(s.length>0){let t=1,e="Errors encountered saving session: </br>";for(let n of s)e+=` (${t++}) ${n.toString()} <br/>`;throw Error(e)}return t.tracks=o,t}compressedSession(){return function(t){const e=new Uint8Array(t.length);for(var n=0;n<t.length;n++)e[n]=t.charCodeAt(n);const r=new Ui.deflateRaw(e),i=String.fromCharCode.apply(null,r);return btoa(i).replace(/\+/g,".").replace(/\//g,"_").replace(/=/g,"-")}(JSON.stringify(this.toJSON()))}sessionURL(){const t=window.location.href.slice(),e=t.indexOf("?");return(e>0?t.substring(0,e):t)+"?sessionURL=blob:"+this.compressedSession()}mouseDownOnViewport(t,e){var n;n=me(t),this.vpMouseDown={viewport:e,lastMouseX:n.x,mouseDownX:n.x,lastMouseY:n.y,mouseDownY:n.y,referenceFrame:e.referenceFrame}}cancelTrackPan(){const t=this.dragObject;this.dragObject=void 0,this.isScrolling=!1,this.vpMouseDown=void 0,t&&t.viewport.referenceFrame.start!==t.start&&(this.updateViews(),this.fireEvent("trackdragend"))}startTrackDrag(t){this.dragTrack=t}updateTrackDrag(t){if(t&&this.dragTrack){const e=this.dragTrack,n=this.trackViews.indexOf(t),r=this.trackViews.indexOf(e),i=this.trackViews;i[n]=e,i[r]=t;const o=this.trackViews[n].track.order;this.trackViews[r].track.order=o;const s=i.length;let a=o;if(n<r)for(let t=n+1;t<s;t++){const e=i[t].track;if(!(e.order<=a))break;e.order=Math.min(Number.MAX_SAFE_INTEGER,a+1),a=e.order}else for(let t=n-1;t>0;t--){const e=i[t].track;if(!(e.order>=a))break;e.order=Math.max(-Number.MAX_SAFE_INTEGER,a-1),a=e.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=Jf.bind(this),window.addEventListener("resize",this.boundWindowResizeHandler)}removeWindowResizeHandler(){window.removeEventListener("resize",this.boundWindowResizeHandler)}addRootMouseUpHandler(){this.boundRootMouseUpHandler=ed.bind(this),this.root.addEventListener("mouseup",this.boundRootMouseUpHandler)}removeRootMouseUpHandler(){this.root.removeEventListener("mouseup",this.boundRootMouseUpHandler)}addRootMouseLeaveHandler(){this.boundRootMouseLeaveHandler=ed.bind(this),this.root.addEventListener("mouseleave",this.boundRootMouseLeaveHandler)}removeRootMouseLeaveHandler(){this.root.removeEventListener("mouseleave",this.boundRootMouseLeaveHandler)}addColumnContainerEventHandlers(){this.boundColumnContainerMouseMoveHandler=td.bind(this),this.boundColumnContainerTouchMoveHandler=td.bind(this),this.boundColumnContainerMouseLeaveHandler=ed.bind(this),this.boundColumnContainerMouseUpHandler=ed.bind(this),this.boundColumnContainerTouchEndHandler=ed.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)}async getDriveFileInfo(t){const e="https://www.googleapis.com/drive/v3/files/"+Ie(t)+"?supportsTeamDrives=true";return go.loadJson(e,gs({}))}static uncompressSession(t){let e;if(t.indexOf("/gzip;base64")>0){e=Yi(t);let n="";for(let t of e)n+=String.fromCharCode(t);return n}return function(t){t=t.replace(/\./g,"+").replace(/_/g,"/").replace(/-/g,"=");const e=atob(t),n=[];for(let t=0;t<e.length;t++)n.push(e.charCodeAt(t));const r=Ui.inflateRaw(n);let i="";for(let t of r)i+=String.fromCharCode(t);return i}(t.substring(5))}createCircularView(t,e){var n;return e=!0===e,this.circularView=(n=this,new $c(t,{onChordClick:(t,e,r)=>{const i=t.data,o=i.mate;function s(t){t.chr=n.genome.getChromosomeName(t.refName);let e=!1;for(let r of n.referenceFrameList){const n=Ac.fromLocusString(r.getLocusString());if(n.contains(t)){e=!0;break}if(n.overlaps(t)){r.extend(t),e=!0;break}}if(!e){const e=2e3,r=(t.start+t.end)/2;n.addMultiLocusPanel(t.chr,r-e,r+e)}}s(i),s(o)}})),this.circularViewControl=new Yf(this.$toggle_button_container.get(0),this),this.circularView.setAssembly({name:this.genome.id,id:this.genome.id,chromosomes:Jc(this.genome)}),this.circularViewVisible=e,this.circularView}get circularViewVisible(){return void 0!==this.circularView&&this.circularView.visible}set circularViewVisible(t){this.circularView&&(this.circularView.visible=t,this.circularViewControl.setState(t))}}async function Jf(){const t=this.calculateViewportWidth(this.referenceFrameList.length);for(let e of this.referenceFrameList){const n=this.referenceFrameList.indexOf(e),{chr:r,genome:i}=e,{bpLength:o}=i.getChromosome(e.chr),s=e.toBP(t);na.isWholeGenomeView(r)||s>o?e.bpPerPixel=o/t:e.end=e.start+e.toBP(t);for(let{viewports:e}of this.trackViews)e[n].setWidth(t)}this.updateUIWithReferenceFrameList(),await this.updateViews(!0)}function td(t){t.preventDefault();const{x:e,y:n}=me(t);if(this.vpMouseDown){const{viewport:t,referenceFrame:r}=this.vpMouseDown,i=Math.abs(e-this.vpMouseDown.mouseDownX)>Math.abs(n-this.vpMouseDown.mouseDownY);if(!this.dragObject&&!this.isScrolling)if(i)this.vpMouseDown.mouseDownX&&Math.abs(e-this.vpMouseDown.mouseDownX)>this.constants.dragThreshold&&(this.dragObject={viewport:t,start:r.start});else if(this.vpMouseDown.mouseDownY&&Math.abs(n-this.vpMouseDown.mouseDownY)>this.constants.scrollThreshold){this.isScrolling=!0;const e=t.$viewport.height(),n=Cl(t.trackView.viewports);this.vpMouseDown.r=e/n}if(this.dragObject){r.shiftPixels(this.vpMouseDown.lastMouseX-e,t.$viewport.width())&&this.updateViews(),this.fireEvent("trackdrag")}if(this.isScrolling){const e=this.vpMouseDown.r*(this.vpMouseDown.lastMouseY-n);t.trackView.moveScroller(e)}this.vpMouseDown.lastMouseX=e,this.vpMouseDown.lastMouseY=n}}function ed(t){this.cancelTrackPan(),this.endTrackDrag()}function nd(t,e){for(let{viewports:n}of t)for(let t of n)t.$trackLabel&&(0===n.indexOf(t)&&!0===e?t.$trackLabel.show():t.$trackLabel.hide())}let rd=[];const id=go.setApiKey;!function(){var t=document.createElement("style");t.setAttribute("type","text/css"),t.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 .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 .igv-navbar .igv-navbar-left-container .igv-logo {\n width: 34px;\n height: 32px;\n margin-right: 8px; }\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 .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 .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 .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 .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 .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 .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 .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 .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 .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 .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 .igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container div {\n margin-left: 0;\n margin-right: 4px; }\n .igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container div:last-child {\n margin-left: 0;\n margin-right: 0; }\n .igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container-750 {\n display: none; }\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 .igv-navbar .igv-navbar-right-container .igv-zoom-widget div {\n cursor: pointer;\n margin-left: unset;\n margin-right: unset; }\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 .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 .igv-navbar .igv-navbar-right-container .igv-zoom-widget div:nth-child(even) {\n display: block;\n height: fit-content; }\n .igv-navbar .igv-navbar-right-container .igv-zoom-widget input {\n display: block;\n width: 125px; }\n .igv-navbar .igv-navbar-right-container .igv-zoom-widget svg {\n display: block; }\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 .igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div {\n cursor: pointer;\n margin-left: unset;\n margin-right: unset; }\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 .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 .igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div:nth-child(even) {\n width: 0;\n height: 0;\n display: none; }\n .igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 input {\n width: 0;\n height: 0;\n display: none; }\n .igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 svg {\n display: block; }\n .igv-navbar .igv-navbar-right-container .igv-zoom-widget-hidden {\n display: none; }\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.igv-navbar-button-clicked {\n color: white;\n background-color: #737373; }\n\n.igv-navbar-button:hover {\n cursor: pointer; }\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 .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.igv-zoom-in-notice {\n position: absolute;\n top: 10px;\n left: 50%; }\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.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.igv-multi-locus-close-button {\n position: absolute;\n top: 2px;\n right: 0;\n padding-left: 2px;\n padding-right: 2px;\n width: 18px;\n height: 18px;\n color: #666666;\n background-color: white;\n z-index: 1000; }\n .igv-multi-locus-close-button > svg {\n vertical-align: top; }\n\n.igv-multi-locus-close-button:hover {\n cursor: pointer;\n color: #434343; }\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: 14px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: center;\n align-items: center; }\n .igv-multi-locus-ruler-label div {\n font-family: "Open Sans", sans-serif;\n font-size: 14px;\n font-weight: 400;\n color: #101010;\n background-color: white; }\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 .igv-multi-locus-ruler-label-square-dot > div:first-child {\n width: 14px;\n height: 14px; }\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: #101010; }\n\n.igv-multi-locus-ruler-label:hover {\n cursor: pointer; }\n\n.igv-ruler-sweeper {\n display: none;\n pointer-events: none;\n position: absolute;\n top: 0;\n left: 0;\n width: 0;\n height: 100%;\n z-index: 99999;\n background-color: rgba(68, 134, 247, 0.25); }\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 .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.igv-track-label {\n position: absolute;\n left: 8px;\n top: 8px;\n width: auto;\n height: auto;\n max-width: 200px;\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.igv-track-label:hover,\n.igv-track-label:focus,\n.igv-track-label:active {\n background-color: #e8e8e8; }\n\n.igv-track-label-popup-shim {\n padding-left: 8px;\n padding-right: 8px;\n padding-top: 4px; }\n\n.igv-center-line {\n display: none;\n pointer-events: none;\n position: absolute;\n top: 0;\n bottom: 0;\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.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.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.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.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.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 .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 .igv-user-feedback div:first-child div {\n position: absolute;\n top: 2px;\n width: 16px;\n height: 16px;\n background-color: transparent; }\n .igv-user-feedback div:first-child div:first-child {\n left: 8px; }\n .igv-user-feedback div:first-child div:last-child {\n cursor: pointer;\n right: 8px; }\n .igv-user-feedback div:last-child {\n width: 100%;\n height: calc(100% - 24px);\n border-width: 0; }\n .igv-user-feedback div:last-child div {\n width: auto;\n height: auto;\n margin: 8px; }\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 .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 .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 .igv-generic-dialog-container .igv-generic-dialog-header div:hover {\n cursor: pointer;\n color: #444; }\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 .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 .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 .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 .igv-generic-dialog-container .igv-generic-dialog-label-input input {\n width: 50%;\n font-size: 16px; }\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 .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 .igv-generic-dialog-container .igv-generic-dialog-input input {\n font-size: 16px; }\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 .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 .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 .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 .igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:first-child:hover {\n cursor: pointer;\n background-color: #3b5c7f; }\n .igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:last-child:hover {\n cursor: pointer;\n background-color: #7f7f7f; }\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 .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 .igv-generic-dialog-container .igv-generic-dialog-ok div:hover {\n cursor: pointer;\n background-color: #25597f; }\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 .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 .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.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 .igv-menu-popup > div:not(:first-child) {\n width: 100%; }\n .igv-menu-popup > div:not(:first-child) > div {\n background: white; }\n .igv-menu-popup > div:not(:first-child) > div.context-menu {\n padding-left: 4px;\n padding-right: 4px; }\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 .igv-menu-popup > div:not(:first-child) > div:hover {\n background: #efefef; }\n\n.igv-menu-popup-shim {\n padding-left: 8px;\n padding-right: 8px;\n padding-bottom: 1px;\n padding-top: 1px; }\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 .igv-menu-popup-header div {\n margin-right: 4px;\n height: 12px;\n width: 12px;\n color: #7F7F7F; }\n .igv-menu-popup-header div:hover {\n cursor: pointer;\n color: #444; }\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 .igv-menu-popup-check-container div {\n padding-top: 2px;\n padding-left: 8px; }\n .igv-menu-popup-check-container div:first-child {\n position: relative;\n width: 12px;\n height: 12px; }\n .igv-menu-popup-check-container div:first-child svg {\n position: absolute;\n width: 12px;\n height: 12px; }\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 .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 .igv-user-feedback div:first-child div {\n position: absolute;\n top: 2px;\n width: 16px;\n height: 16px;\n background-color: transparent; }\n .igv-user-feedback div:first-child div:first-child {\n left: 8px; }\n .igv-user-feedback div:first-child div:last-child {\n cursor: pointer;\n right: 8px; }\n .igv-user-feedback div:last-child {\n width: 100%;\n height: calc(100% - 24px);\n border-width: 0; }\n .igv-user-feedback div:last-child div {\n width: auto;\n height: auto;\n margin: 8px; }\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 .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: white;\n animation: spin 1s ease-in-out infinite;\n -webkit-animation: spin 1s ease-in-out infinite; }\n\n@keyframes spin {\n to {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg); } }\n@-webkit-keyframes spin {\n to {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg); } }\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.igv-viewport {\n position: relative;\n margin-top: 5px;\n overflow-x: hidden;\n overflow-y: hidden; }\n\n.igv-viewport-content {\n position: relative;\n width: 100%; }\n .igv-viewport-content > canvas {\n position: relative;\n display: block; }\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.igv-column-shim {\n width: 1px;\n margin-left: 2px;\n margin-right: 2px;\n background-color: #545453; }\n\n.igv-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.igv-axis-column {\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 .igv-axis-column > div {\n margin-top: 5px;\n width: 100%; }\n\n.igv-sample-name-column {\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.igv-scrollbar-column {\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 .igv-scrollbar-column > div {\n position: relative;\n margin-top: 5px;\n width: 14px; }\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 .igv-scrollbar-column > div > div:hover {\n background-color: #c4c4c4; }\n\n.igv-track-drag-column {\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 .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 .igv-track-drag-column .igv-track-drag-handle-hover {\n background-color: #787878; }\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.igv-gear-menu-column {\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 .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 .igv-gear-menu-column > div > div {\n position: relative;\n margin-top: 4px;\n width: 16px;\n height: 16px;\n color: #7F7F7F; }\n .igv-gear-menu-column > div > div:hover {\n cursor: pointer;\n color: #444; }\n\n/*# sourceMappingURL=dom.css.map */\n',document.head.insertBefore(t,document.head.childNodes[document.head.childNodes.length-1])}();var od={IGVGraphics:ls,MenuUtils:Oo,DataRangeDialog:cs,createTrack:async function(t,e){return await Qf.prototype.createTrack.call(e,t)},createBrowser:async function(t,e){void 0===e&&(e={}),na.KNOWN_GENOMES||await na.initializeGenomes(e),function(t){void 0===t.minimumBases&&(t.minimumBases=40);void 0===t.showIdeogram&&(t.showIdeogram=!0);void 0===t.showCircularView&&(t.showCircularView=!1);void 0===t.showCircularViewButton&&(t.showCircularViewButton=!1);void 0===t.showTrackLabelButton&&(t.showTrackLabelButton=!0);void 0===t.showTrackLabels&&(t.showTrackLabels=!0);void 0===t.showCursorTrackingGuideButton&&(t.showCursorTrackingGuideButton=!0);void 0===t.showCursorGuide&&(t.showCursorGuide=t.showCursorTrackingGuide||!1);void 0===t.showCenterGuideButton&&(t.showCenterGuideButton=!0);void 0===t.showCenterGuide&&(t.showCenterGuide=!1);void 0===t.showSampleNames&&(t.showSampleNames=!1);void 0===t.showSVGButton&&(t.showSVGButton=!0);void 0===t.showControls&&(t.showControls=!0);void 0===t.showNavigation&&(t.showNavigation=!0);void 0===t.showRuler&&(t.showRuler=!0);void 0===t.flanking&&(t.flanking=1e3);void 0===t.pairsSupported&&(t.pairsSupported=!0);t.tracks||(t.tracks=[])}(e),e.queryParametersSupported&&function(t){var e,n,r,i,o,s,a,c,l;let h,u,f;if(a=window.location.href,o={},e=a.indexOf("?"),n=a.lastIndexOf("#"),e>=0)for(n<0&&(n=a.length),r=e+1;r<n;)(i=a.indexOf("&",r))<0&&(i=n),2===(s=a.substring(r,i).split("=",2)).length?(c=s[0],l=decodeURIComponent(s[1]),"file"===c?h=l.split(","):"index"===c?u=l.split(","):"name"===c?f=l.split(","):"genome"!==c||!l.startsWith("https://")&&!l.startsWith("http://")||l.endsWith(".json")?t[c]=l:t.reference={fastaURL:l,indexURL:l+".fai"},r=i+1):r++;if(h){t.tracks||(t.tracks=[]);for(let e=0;e<h.length;e++){if(h[e].endsWith(".xml")||h[e].endsWith(".json")){t.sessionURL=h[e];break}const n={url:h[e]};u&&u.length>e&&(n.indexURL=u[e]),f&&f.length>e&&(n.name=f[e]),t.tracks.push(n)}}}(e),e.apiKey&&go.setApiKey(e.apiKey),e.oauthToken&&ho.setToken(e.oauthToken),e.clientId&&!Oe()&&await Pe({clientId:e.clientId,apiKey:e.apiKey,scope:"https://www.googleapis.com/auth/userinfo.profile"});const n=new Qf(e,t);rd.push(n),e.sessionURL?await n.loadSession({url:e.sessionURL}):await n.loadSessionObject(e);const r=n.isMultiLocusWholeGenomeView()||na.isWholeGenomeView(n.referenceFrameList[0].chr);return n.navbarManager.navbarDidResize(n.$navigation.width(),r),n},removeBrowser:function(t){t.dispose(),t.root.remove(),rd=rd.filter((e=>e!==t))},removeAllBrowsers:function(){for(let t of rd)t.dispose(),t.root.remove();rd=[]},visibilityChange:async function(){for(let t of rd)await t.visibilityChange()},setGoogleOauthToken:function(t){return ho.setToken(t)},setOauthToken:function(t,e){return ho.setToken(t,e)},oauth:ho,version:ta,setApiKey:id,doAutoscale:ms,TrackView:Sl};export{od as default};
|
|
72
72
|
//# sourceMappingURL=igv.esm.min.js.map
|