igv 2.13.9 → 2.13.11
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 +45 -29
- package/dist/igv.esm.min.js +5 -5
- package/dist/igv.esm.min.js.map +1 -1
- package/dist/igv.js +91 -71
- package/dist/igv.min.js +3 -3
- package/dist/igv.min.js.map +1 -1
- package/package.json +1 -1
package/dist/igv.min.js
CHANGED
|
@@ -35,7 +35,7 @@ function(t){var e,n,r,i,o,s,a,l,c,h,u,f,d,p,g,m,v,b,w,y="sizzle"+1*new Date,x=t.
|
|
|
35
35
|
* Kerry Liu
|
|
36
36
|
*
|
|
37
37
|
* Copyright (c) 2014 Gliffy Inc.
|
|
38
|
-
*/function wa(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 ya(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 xa(t){var e={alphabetic:"alphabetic",hanging:"hanging",top:"text-before-edge",bottom:"text-after-edge",middle:"central"};return e[t]||e.alphabetic}function _a(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]);return[t[0]/e,t[1]/e]}const ka=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),Sa={strokeStyle:{svgAttr:"stroke",canvas:"#000000",svg:"none",apply:"stroke"},fillStyle:{svgAttr:"fill",canvas:"#000000",svg:null,apply:"fill"},lineCap:{svgAttr:"stroke-linecap",canvas:"butt",svg:"butt",apply:"stroke"},lineJoin:{svgAttr:"stroke-linejoin",canvas:"miter",svg:"miter",apply:"stroke"},miterLimit:{svgAttr:"stroke-miterlimit",canvas:10,svg:4,apply:"stroke"},lineWidth:{svgAttr:"stroke-width",canvas:1,svg:1,apply:"stroke"},globalAlpha:{svgAttr:"opacity",canvas:1,svg:1,apply:"fill stroke"},font:{canvas:"10px sans-serif"},shadowColor:{canvas:"#000000"},shadowOffsetX:{canvas:0},shadowOffsetY:{canvas:0},shadowBlur:{canvas:0},textAlign:{canvas:"start"},textBaseline:{canvas:"alphabetic"},lineDash:{svgAttr:"stroke-dasharray",canvas:[],svg:null,apply:"stroke"}};class Ca{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",wa("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 Ea{constructor(t,e){this.__root=t,this.__ctx=e}}class Ta{constructor(t){if(!(this instanceof Ta))return new Ta(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(Sa);for(t=0;t<n.length;t++)this[e=n[t]]=Sa[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(Sa);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,l=Object.keys(Sa);for(r=0;r<l.length;r++)if(i=Sa[l[r]],o=this[l[r]],i.apply)if(o instanceof Ea){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,wa("url(#{id})",{id:o.__root.getAttribute("id")}))}else if(o instanceof Ca)e.setAttribute(i.apply,wa("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 c=i.svgAttr;if("globalAlpha"===l[r]&&(c=t+"-"+i.svgAttr,e.getAttribute(c)))continue;e.setAttribute(c,o)}else{a=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi.exec(o),e.setAttribute(i.svgAttr,wa("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(ka),n=0;n<e.length;n++)r=e[n],i=ka[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 l={x:"0",y:o.toString(),width:r.toString(),height:i.toString()};a.appendChild(this.__createElement("rect",l));const c=this.__createElement("g");c.setAttribute("transform",wa("translate({x},{y})",{x:e,y:n})),c.setAttribute("clip-path",wa("url(#{id})",{id:s}));const h=this.__closestGroupOrSvg();h.appendChild(c),this.__groupStack.push(h),this.__currentElement=c,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 l=this.__createElement("g");this.__rootGroup.appendChild(l),l.setAttribute("transform",wa("translate({x},{y})",{x:e,y:n})),l.setAttribute("id",t+"_group"),l.setAttribute("clip-path",wa("url(#{id})",{id:s})),this.__currentElement=l}scale(t,e){void 0===e&&(e=t),this.__addTransform(wa("scale({x},{y})",{x:t,y:e}))}rotate(t){var e=180*t/Math.PI;this.__addTransform(wa("rotate({angle},{cx},{cy})",{angle:e,cx:0,cy:0}))}translate(t,e){this.__addTransform(wa("translate({x},{y})",{x:t,y:e}))}transform(t,e,n,r,i,o){this.__addTransform(wa("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(wa("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(wa("L {x} {y}",{x:t,y:e})):this.__addPathCommand(wa("M {x} {y}",{x:t,y:e}))}bezierCurveTo(t,e,n,r,i,o){this.__currentPosition={x:i,y:o},this.__addPathCommand(wa("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(wa("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=_a([o-t,s-e]),l=_a([n-t,r-e]);if(a[0]*l[1]!=a[1]*l[0]){var c=a[0]*l[0]+a[1]*l[1],h=Math.acos(Math.abs(c)),u=_a([a[0]+l[0],a[1]+l[1]]),f=i/Math.sin(h/2),d=t+f*u[0],p=e+f*u[1],g=[-a[1],a[0]],m=[l[1],-l[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,l){const c={cx:t,cy:e,rx:n,ry:r},h=this.__createElement("ellipse",c,!0);this.__closestGroupOrSvg().appendChild(h),this.__currentElement=h,this.__applyStyleToCurrentElement(l)}__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:ya(this.__ids),x1:t+"px",x2:n+"px",y1:e+"px",y2:r+"px",gradientUnits:"userSpaceOnUse"},!1);return this.__defs.appendChild(i),new Ca(i,this)}createRadialGradient(t,e,n,r,i,o){var s=this.__createElement("radialGradient",{id:ya(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 Ca(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(),l=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":xa(this.textBaseline)},!0);l.appendChild(this.__document.createTextNode(t)),this.__currentElement=l,this.__applyStyleToCurrentElement(r),a.appendChild(this.__wrapTextLink(s,l))}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),l=t+n*Math.cos(r),c=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(l,c),this.__addPathCommand(wa("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=ya(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",wa("url(#{id})",{id:n})),t.appendChild(r),this.__currentElement=r}drawImage(){var t,e,n,r,i,o,s,a,l,c,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(),this.__currentElement;var v="translate("+t+", "+e+")";if(p instanceof Ta){if((a=p.getSvg().cloneNode(!0)).childNodes&&a.childNodes.length>1){for(l=a.childNodes[0];l.childNodes.length;)f=l.childNodes[0].getAttribute("id"),this.__ids[f]=f,this.__defs.appendChild(l.childNodes[0]);if(c=a.childNodes[1]){var b,w=c.getAttribute("transform");b=w?w+" "+v:v,c.setAttribute("transform",b),s.appendChild(c)}}}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=ya(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 Ta&&(r.appendChild(t.__root.childNodes[1]),this.__defs.appendChild(r)),new Ea(r,this)}setLineDash(t){t&&t.length>0?this.lineDash=t.join(","):this.lineDash=null}drawFocusRing(){}createImageData(){}getImageData(){}putImageData(){}globalCompositeOperation(){}setTransform(){}}const Aa=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 La(){return"2.13.9"}const Ma=Ce,Ra={loadGenome:async function(t){const e=t.cytobandURL,n=t.aliasURL,r=await la(t);let i;n&&(i=await function(t,e){return To.loadString(t,Is(e)).then((function(t){var e=Ma(t),n=[];return e.forEach((function(t){!t.startsWith("#")&&t.length>0&&n.push(t.split("\t"))})),n}))}(n,r.config));const o=new Ia(t,r,i);return e&&(o.cytobands=await async function(t,e,n){let r;if(Ds(t)){const e=ho(t);r="";const n=e.length;for(let t=0;t<n;t++)r+=String.fromCharCode(e[t])}else r=await To.loadString(t,Is(e));const i={};let o,s=[];const a=Ma(r);for(let t of a){var l=t.split("\t"),c=n.getChromosomeName(l[0]);if(o||(o=c),c!==o&&(i[o]=s,s=[],o=c),5===l.length){var h=parseInt(l[1]),u=parseInt(l[2]),f=l[3],d=l[4];s.push(new Aa(h,u,f,d))}}return i}(e,r.config,o)),o},initializeGenomes:async function(t){if(!Ra.KNOWN_GENOMES){const e={};if(!1!==t.loadDefaultGenomes)try{const i=`https://igv.org/genomes/genomes.json?randomSeed=${Math.random().toString(36)}&version=2.13.9`;r(await To.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.13.9`;r(await To.loadJson(s,{}))}catch(a){console.error(a),console.warn("Errors loading default genome definitions.")}}const n=t.genomeList||t.genomes;if(n)if("string"==typeof n){r(await To.loadJson(n,{}))}else r(n);function r(t){return t.forEach((function(t){e[t.id]=t})),e}Ra.KNOWN_GENOMES=e}},isWholeGenomeView:function(t){return"all"===t.toLowerCase()},expandReference:function(t,e){if(ke(e)&&e.startsWith("{"))try{e=JSON.parse(e)}catch(t){}let n;if(ke(e)?n=e:e.genome?n=e.genome:void 0!==e.id&&void 0===e.fastaURL&&(n=e.id),n){const e=Ra.KNOWN_GENOMES[n];return e||t.present(new Error(`Unknown genome id: ${n}`),void 0),e}return e}};class Ia{constructor(t,e,n){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.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 r={},i=this;r.all="all",this.chromosomeNames.forEach((function(t){var e=t.startsWith("chr")?t.substring(3):"chr"+t;r[e.toLowerCase()]=t,"chrM"===t&&(r.mt="chrM"),"MT"===t&&(r.chrm="MT"),r[t.toLowerCase()]=t})),n&&n.forEach((function(t){var e,n;for(n=0;n<t.length;n++)if(i.chromosomes[t[n]]){e=t[n];break}e&&t.forEach((function(t){t!==e&&(r[t.toLowerCase()]=e,r[t]=e)}))})),this.chrAliasTable=r}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.cytobands?this.cytobands[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 Na,Oa=0,Pa=0;class Fa extends ba{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.$viewport)),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>10)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.referenceFrame.chr===this.referenceFrame.chr&&this.canvas._data.bpPerPixel===t.bpPerPixel){const e=Math.round((this.canvas._data.bpStart-t.start)/t.bpPerPixel);this.canvas.style.left=e+"px"}}setTop(t){if(super.setTop(t),this.canvas){const e=this.$viewport.height(),n=t+this.canvas._data.canvasTop,r=t+this.canvas._data.canvasBottom;(n>0||r<e)&&this.repaint()}else this.repaint();let e=t+this.canvas._data.canvasTop;this.canvas.style.top=`${e}px`}async loadFeatures(){const t=this.referenceFrame,e=t.chr,n=this.browser.genome.getChromosome(e).bpLength,r=this.$viewport.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 s=[];if(n.roiSets&&n.roiSets.length>0)for(let r of n.roiSets){const n=await r.getFeatures(e,i,o,t.bpPerPixel);s.push({track:r,features:n})}const a=n&&("wig"===n.type||"merged"===n.type);return this.featureCache=new Da(e,i,o,t.bpPerPixel,r,s,a),this.loading=!1,this.hideMessage(),this.stopSpinner(),this.featureCache}catch(t){this.trackView&&!0!==this.trackView.disposed&&(this.showMessage("Error loading track data"),this.browser.alert.present(t),console.error(t))}finally{this.loading=!1,this.stopSpinner()}}}repaintDimensions(){const t=Ra.isWholeGenomeView(this.referenceFrame.chr),e=t?this.$viewport.width():3*this.$viewport.width(),n=this.referenceFrame.bpPerPixel;return{bpStart:this.referenceFrame.start-(t?0:e/3*n),bpEnd:this.referenceFrame.end+(t?0:e/3*n),pixelWidth:e}}repaint(){if(void 0===this.featureCache)return;const{features:t,roiFeatures:e}=this.featureCache,{bpStart:n,bpEnd:r,pixelWidth:i}=this.repaintDimensions(),o=this.$viewport.height(),s=this.getContentHeight(),a=e?Math.max(s,o):s,l=Math.min(a,3*o);if(0===i||0===l)return void(this.canvas&&pe(this.canvas).remove());const c=Math.max(0,-this.contentTop-o),h=this.referenceFrame.bpPerPixel,u=Math.round((n-this.referenceFrame.start)/h),f=document.createElement("canvas");f.style.position="relative",f.style.display="block",f.style.width=i+"px",f.style.height=l+"px",f.style.left=u+"px",f.style.top=c+"px";const d="FILL"===this.trackView.track.displayMode||!1!==this.trackView.track.supportHiDPI?window.devicePixelRatio:1;f.width=d*i,f.height=d*l;const p=f.getContext("2d");p.scale(d,d),p.translate(0,-c);const g={context:p,pixelXOffset:u,pixelWidth:i,pixelHeight:l,pixelTop:c,bpStart:n,bpEnd:r,bpPerPixel:h,canvasTop:c,canvasBottom:c+l,referenceFrame:this.referenceFrame,selection:this.selection,viewport:this,viewportWidth:this.$viewport.width()};this.draw(g,t,e),this.canvas&&pe(this.canvas).remove(),f._data=g,this.canvas=f,this.$viewport.append(pe(f))}refresh(){if(!this.canvas||!this.featureCache)return;const t=this.canvas._data;t.context.clearRect(0,0,this.canvas.width,this.canvas.height);const{features:e,roiFeatures:n}=this.featureCache;this.draw(t,e,n)}draw(t,e,n){if(e&&(t.features=e,this.trackView.track.draw(t)),n&&n.length>0)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.canvas._data,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.contentTop-e)*n,a=this.canvas.getContext("2d").getImageData(o,s,r,i),l=document.createElement("canvas"),c=l.getContext("2d");l.width=a.width,l.height=a.height,c.putImageData(a,0,0);We((this.$trackLabel.text()?this.$trackLabel.text():"image")+".png",l.toDataURL("image/png"))}saveSVG(){let{width:t,height:e}=this.browser.columnContainer.getBoundingClientRect();const n=new Ta({width:t,height:8e3,backdropColor:"white",multiLocusGap:0,viewbox:{x:0,y:0,width:t,height:8e3}}),r={deltaX:32,deltaY:32};this.renderViewportToSVG(n,r),n.setHeight(e);const i=(this.trackView.track.name||this.trackView.track.id).replace(/\W/g,""),o=this.browser.referenceFrameList.indexOf(this.referenceFrame),s=n.getSerializedSvg(!0),a=URL.createObjectURL(new Blob([s],{type:"application/octet-stream"}));We(`${`${i}_referenceFrame_${o}_guid_${be()}`}.svg`,a)}renderViewportToSVG(t,e){let{deltaX:n,deltaY:r}=e;if(this.$zoomInNotice&&this.$zoomInNotice.is(":visible"))return;const{width:i,height:o}=this.$viewport.get(0).getBoundingClientRect(),s=`${(this.trackView.track.name||this.trackView.track.id).replace(/\W/g,"")}_referenceFrame_${this.browser.referenceFrameList.indexOf(this.referenceFrame)}_guid_${be()}`;this.drawSVGWithContext(t,i,o,s,n,r+this.contentTop,-this.contentTop)}renderSVGContext(t,e){let{deltaX:n,deltaY:r}=e;if(this.renderViewportToSVG(t,{deltaX:n,deltaY:r}),(!this.$zoomInNotice||!this.$zoomInNotice.is(":visible"))&&this.$trackLabel&&!0===this.browser.trackLabelsVisible){const{x:e,y:i,width:o,height:s}=((t,e)=>{const{x:n,y:r,width:i,height:o}=t.getBoundingClientRect(),{x:s,y:a,width:l,height:c}=e.getBoundingClientRect();return{x:s-n,y:a-r,width:l,height:c}})(this.$viewport.get(0),this.$trackLabel.get(0));this.renderTrackLabelSVG(t,n+e,r+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),l=.7*(i-12);t.fillText(this.$trackLabel.text(),a,i-l),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:l}=this.referenceFrame;const c={context:t,viewport:this,referenceFrame:this.referenceFrame,top:s,pixelTop:s,pixelWidth:e,pixelHeight:n,bpStart:a,bpEnd:a+e*l,bpPerPixel:l,viewportWidth:e,selection:this.selection},h=this.featureCache?this.featureCache.features:void 0,u=this.featureCache?this.featureCache.roiFeatures:void 0;this.draw(c,h,u),t.restore()}get cachedFeatures(){return this.featureCache?this.featureCache.features:[]}clearCache(){this.featureCache=void 0,this.canvas&&(this.canvas._data=void 0)}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.bpStart||this.referenceFrame.end>t.bpEnd||this.referenceFrame.chr!==t.referenceFrame.chr||this.referenceFrame.bpPerPixel!=t.bpPerPixel}needsReload(){if(!this.featureCache)return!0;const{chr:t,bpPerPixel:e}=this.referenceFrame,{bpStart:n,bpEnd:r}=this.repaintDimensions();return!this.featureCache.containsRange(t,n,r,e)}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),"function"==typeof this.trackView.track.hoverText&&t.addEventListener("mousemove",(t=>{if(0===t.buttons&&Date.now()-Pa>100){Pa=Date.now();const e=this.createClickState(t);if(e){const t=this.trackView.track.hoverText(e);t?this.$viewport[0].setAttribute("title",t):this.$viewport[0].removeAttribute("title")}}})),this.addViewportClickHandler(this.$viewport.get(0)),this.trackView.track.name&&"sequence"!==this.trackView.track.config.type&&this.addTrackLabelClickHandler(this.$trackLabel.get(0))}addViewportContextMenuHandler(t){t.addEventListener("contextmenu",(t=>{if(this.browser.dragObject)return!1;const e=this.createClickState(t);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.savePNG()}),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){Na&&(window.clearTimeout(Na),Na=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((t=>{let{locusSearchString:e}=t;return e}));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&&(Na=setTimeout((()=>{const e=this.getPopupContent(t);e&&(this.popover&&this.popover.dispose(),this.popover=new ks(this.browser.columnContainer),this.popover.presentContentWithEvent(t,e)),window.clearTimeout(Na),Na=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 ks(this.browser.columnContainer,e.name||""),this.popover.presentContentWithEvent(t,n))}))}createClickState(t){if(!this.canvas)return;const e=this.referenceFrame,n=we(t,this.$viewport.get(0)),r=we(t,this.canvas),i=e.start+e.toBP(n.x);return{event:t,viewport:this,referenceFrame:e,genomicLocation:i,y:n.y-this.contentTop,canvasX:r.x,canvasY:r.y}}getPopupContent(t){const e=this.createClickState(t);if(void 0===e)return;let n=this.trackView.track;const r=n.popupData(e),i=this.browser.fireEvent("trackclick",[n,r]);let o;return void 0===i||!0===i?r&&r.length>0&&(o=r.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 i&&(o=i),o}}class Da{constructor(t,e,n,r,i,o,s){this.chr=t,this.bpStart=e,this.bpEnd=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.bpStart&&n<=this.bpEnd&&t===this.chr&&i>.5&&i<2}overlapsRange(t,e,n){return this.chr===t&&n>=this.bpStart&&e<=this.bpEnd}}function Ba(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 za=new Set(["transcript","primary_transcript","processed_transcript","mRNA","mrna","lnc_RNA","miRNA","ncRNA","rRNA","scRNA","snRNA","snoRNA","tRNA"]),Ha=new Set(["CDS","cds"]),Va=new Set(["start_codon","stop_codon"]),ja=new Set(["5UTR","3UTR","UTR","five_prime_UTR","three_prime_UTR","3'-UTR","5'-UTR"]),Ua=new Set(["exon","coding-exon"]),qa=new Set;for(let Lv of[Ha,Va,ja,Ua])for(let Mv of Lv)qa.add(Mv);function Wa(t){return t.includes("intron")}function $a(t){return Ha.has(t)||Va.has(t)}function Ga(t){return ja.has(t)}function Za(t){return za.has(t)||t.endsWith("RNA")||t.endsWith("transcript")}function Xa(t){return qa.has(t)||t.endsWith("RNA")||Wa(t)}const Ya=new Set(["id","parent","name"]);class Ka{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=nl(this.attributeString,this.delim);for(let[n,r]of t)void 0!==r&&r.length>0&&!Ya.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=nl(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 Qa extends Ka{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(!Wa(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;$a(e)?this.addCDS(t):Ga(e)&&this.addUTR(t)}}findExonContaining(t){let{start:e,end:n}=t;for(let t of this.exons)if(t.end>=n&&t.start<=e)return t}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 Ja(t,e){const n=e.format;if(t.length<9)return;const r="gff3"===n?"=":" ";return new Ka({source:ol(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 tl(t,e){const n=Ja(t,e);if(!n)return;const r=nl(n.attributeString,n.delim);for(let[t,e]of r){const r=t.toLowerCase();"color"===r||"colour"===r?n.color=vo.createColorString(e):"ID"===t?n.id=e:"Parent"===t&&(n.parent=e)}return n}function el(t,e){const n=Ja(t,e);if(!n)return;const r=nl(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=vo.createColorString(e):t===i?n.id=e:t===o&&(n.parent=e)}return n}function nl(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=rl(ol(r.substring(t+1).trim()));n.push([e,i])}}return n}function rl(t){return t.startsWith('"')&&t.endsWith('"')&&(t=t.substr(1,t.length-2)),t}const il=new Map([["%09","\t"],["%0A","\n"],["%0D","\r"],["%25","%"],["%3B",";"],["%3D","="],["%26","&"],["%2C",","]]);function ol(t){if(!t.includes("%"))return t;let e="";for(let n=0;n<t.length;n++)if(37===t.charCodeAt(n)&&n<t.length-2){const r=t.substring(n,n+3);il.has(r)?e+=il.get(r):e+=r,n+=2}else e+=t.charAt(n);return e}class sl{constructor(t){this.message=t}}function al(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 sl("Unparsable bed record.");const o=new vl({chr:n,start:r,end:i,score:1e3});try{if(t.length>3){if(t[3].indexOf(";")>0&&t[3].indexOf("=")>0){const n=nl(t[3],"=");o.attributes={};for(let t of n)o.attributes[t[0]]=t[1],null!=e.nameField&&t[0]===e.nameField&&(o.name=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=vo.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})}fl(s,o.cdStart,o.cdEnd),o.exons=s}if(e){let n=e.thicknessColumn,r=e.colorColumn;r&&r<t.length&&(o.color=vo.createColorString(t[r])),n&&n<t.length&&(o.thickness=t[n])}}catch(t){}return o}function ll(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 cl(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(","),l=t[9+n].split(","),c=[];for(let t=0;t<s;t++){const e=parseInt(a[t]),n=parseInt(l[t]);c.push({start:e,end:n})}return fl(c,r,i),o.exons=c,o}function hl(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(","),l=t[9+n].split(","),c=[];for(let t=0;t<s;t++){const e=parseInt(a[t]),n=parseInt(l[t]);c.push({start:e,end:n})}return fl(c,r,i),o.exons=c,o}function ul(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(","),l=t[10+n].split(","),c=[];for(let t=0;t<s;t++){const e=parseInt(a[t]),n=parseInt(l[t]);c.push({start:e,end:n})}return fl(c,r,i),o.exons=c,o}function fl(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 dl(t,e){var n,r,i,o,s,a,l;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(),l=Number(t[6]),0===a&&(a=l),{chr:n,start:r,end:i,name:s,score:a,strand:o,signal:l,pValue:Number(t[7]),qValue:Number(t[8])}}function pl(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=vo.createColorString(t[r]))}return n}function gl(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 pl(t)}function ml(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 vl{constructor(t){Object.assign(this,t)}getAttributeValue(t){return this.hasOwnProperty(t)?this[t]:this.attributes?this.attributes[t]:void 0}}function bl(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]),l=t[6],c={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=l.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),c.spanning_frag_coords.push({left:g,right:m})}return c.start=h,c.end=u,c}}function wl(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 yl(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 xl(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 _l{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=kl(n);Object.assign(r,t)}else if(n.startsWith("browser"));else if(n.startsWith("#columns")){let t=Sl(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=Cl(o);continue}if("wig"===r&&o.startsWith("variableStep")){this.header.wig=El(o);continue}const t=o.split(i);if(t.length<1)continue;const l=n(t,this.header);l instanceof sl?(a++,a>0&&console.error(`Error parsing line '${o}': ${l.message}`)):l&&e.push(l)}return n===js&&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=dl,this.delimiter=this.config.delimiter||/\s+/;break;case"bedgraph":this.decode=pl,this.delimiter=/\s+/;break;case"wig":this.decode=gl,this.delimiter=this.config.delimiter||/\s+/;break;case"gff3":case"gff":this.decode=tl,this.delimiter="\t";break;case"gtf":this.decode=el,this.delimiter="\t";break;case"fusionjuncspan":this.decode=bl,this.delimiter=this.config.delimiter||/\s+/;break;case"gtexgwas":this.skipRows=1,this.decode=wl,this.delimiter="\t";break;case"refflat":this.decode=ul,this.delimiter=this.config.delimiter||/\s+/;break;case"genepred":this.decode=cl,this.delimiter=this.config.delimiter||/\s+/;break;case"genepredext":this.decode=hl,this.delimiter=this.config.delimiter||/\s+/;break;case"ensgene":this.decode=cl,this.header.shift=1,this.delimiter=this.config.delimiter||/\s+/;break;case"refgene":this.decode=hl,this.delimiter=this.config.delimiter||/\s+/,this.header.shift=1;break;case"bed":this.decode=al,this.delimiter=this.config.delimiter||/\s+/;break;case"bedpe":case"hiccups":this.decode=js,this.delimiter=this.config.delimiter||"\t";break;case"bedpe-domain":this.decode=Us,this.headerLine=!0,this.delimiter=this.config.delimiter||"\t";break;case"bedpe-loop":this.decode=js,this.delimiter=this.config.delimiter||"\t",this.header={colorColumn:7};break;case"interact":this.decode=Ba,this.delimiter=this.config.delimiter||/\s+/;break;case"snp":this.decode=ml,this.delimiter="\t";break;case"rmsk":this.decode=ll,this.delimiter="\t";break;case"gcnv":this.decode=xl,this.delimiter="\t";break;default:const e=function(t){return Ms&&Ms[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}(Ms[t]):void 0}(t);void 0!==e?(this.decode=yl,this.header.customFormat=e,this.delimiter=e.delimiter||"\t"):(this.decode=al,this.delimiter=this.config.delimiter||/\s+/)}}}function kl(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 Sl(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 Cl(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 El(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}}const Tl=t=>ke(t)&&t.indexOf(",")>0&&!t.startsWith("rgb(")&&!t.startsWith("rgba(")?`rgb(${t})`:t;class Al{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:ke(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=Tl(t.color)),t.altColor&&(this.altColor=Tl(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),t.hoverTextFields?this.hoverText=Ll.bind(this):"function"==typeof this.config.hoverText&&(this.hoverText=this.config.hoverText)}get name(){return this._name}set name(t){this._name=t,this.trackView&&this.trackView.setTrackLabelName(t)}updateConfig(t){this.init(t)}clearCachedFeatures(){this.trackView&&this.trackView.clearCachedFeatures()}updateViews(){this.trackView&&this.trackView.updateViews()}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&&(Rs(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){if(this.disposed)return;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];Ml.has(i)?e[r]=Ml.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){const e=t.viewport.cachedFeatures;if(!e||!Array.isArray(e)||0===e.length)return[];const n=t.genomicLocation,r=t.referenceFrame.bpPerPixel>.2?3*t.referenceFrame.bpPerPixel:.2;return qo(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)&&Rs(t[e])){let n=t[e];r.push({name:Te(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=Al.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&&Rs(r)&&(e+=t(n,r))}}}return e+="</div>",e}dispose(){this.disposed=!0;for(let t of Object.keys(this))this[t]=void 0}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>`}}}function Ll(t){if(!this.hoverTextFields)return;const e=this.clickedFeatures(t);if(e&&e.length>0){let t="";for(let n=0;n<e.length;n++){if(10===n){t+="; ...";break}if(!e[n])continue;const r=e[n]._f||e[n];t.length>0&&(t+="\n"),t="";for(let e of this.hoverTextFields)t.length>0&&(t+="\n"),r.hasOwnProperty(e)?t+=r[e]:"function"==typeof r.getAttribute&&(t+=r.getAttribute(e))}return t}}const Ml=new Map([["wiggle_0","wig"],["bed","bed"],["bigBed","bigBed"],["bigWig","bigWig"]]);class Rl{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 Il({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 Il{constructor(t){let{sample:e,chr:n,start:r,end:i,value:o,valueColumnName:s}=t;this.sample=e,this.chr=n,this.start=r,this.end=i,this.value=o,this.valueColumnName=s}setAttributes(t){let{names:e,values:n}=t;this.attributeNames=e,this.attributeValues=n}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?Te(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:Te(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 Al.getCravatLink(this.chr,this.start+1,e,n,t)}}function Nl(t){const e=new Ol;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 Ol{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&&Fl(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:"ID",value:this.names?this.names:""},{name:"Ref",value:this.referenceBases},{name:"Alt",value:this.alternateBases.replace("<","<")},{name:"Qual",value:this.quality},{name:"Filter",value:this.filter}];if("SNP"===this.type){let t=this.referenceBases;if(1===t.length){let n=this.alternateBases.split(",");for(let r of n)if(1===r.length){let n=Al.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:Dl(decodeURIComponent(this.info[t]))})}return i}getInfo(t){return this.info?this.info[t]:void 0}isRefBlock(){return"NONVARIANT"===this.type}}const Pl=new Set(["A","C","T","G"].map((t=>t.charCodeAt(0))));function Fl(t){for(let e=0;e<t.length;e++)if(!Pl.has(t.charCodeAt(e)))return!1;return!0}function Dl(t,e){return void 0===e&&(e=","),Array.isArray(t)?t.join(e):t}class Bl{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 l=Ee(r.substring(e+1,s-1),",");for(let e of l){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=Nl(t);if(r.header=this.header,e.push(r),t.length>9){const e=zl(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(Hl(r))}}return e}}function zl(t){const e={genotypeIndex:-1,fields:t};for(let n=0;n<t.length;n++)"GT"===t[n]&&(e.genotypeIndex=n);return e}function Hl(t){const e=t.info.CHR2,n=Number.parseInt(t.info.END);return{chr:e,start:n-1,end:n,_f:t}}class Vl{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.valueCol=t.columns.value-1}else this.posCol=2,this.chrCol=1,this.valueCol=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 jl({chr:n,start:i,end:o,value:s,line:r,columns:this.columns}))}}return e}}class jl{constructor(t){let{chr:e,start:n,end:r,value:i,line:o,columns:s}=t;this.chr=e,this.start=n,this.end=r,this.value=i,this.line=o,this.columns=s}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 Ul=new RegExp("([^:]*)\\(([^)]*)\\)"),ql=new RegExp("([^:]*):([^(]*)\\(([^)]*)\\)");class Wl{constructor(t){const e=t?t.decode:void 0;this.nameField=t?t.nameField:void 0,this.skipRows=0,this.decode=e||Kl,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=Zl(e);n?Object.assign(n,t):n=t}else if(e.startsWith("#columns")){let t=Xl(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=Gl(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 $l(t){var e=ql.exec(t);if(e)return{namespace:e[1],name:e[2],type:e[3]};if(e=Ul.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 Gl(t){var e,n,r;for(e={columns:[],metadata:{}},n=0;n<t.length;n++)r=$l(t[n]),e.columns.push(r);return e}function Zl(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 Xl(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 Yl(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=vo.createColorString(n))}}function Kl(t,e){var n,r,i,o,s,a,l=0,c=this.aed.columns;if(t.length===c.length){for(a=0;a<t.length;a++)o=c[a],""!==(i=t[a])&&l++,"name"===o.name&&"aed"===o.namespace?n=i:"value"===o.name&&"aed"===o.namespace&&(r=i);if(2===l&&n&&r)return s=$l(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 Yl(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(","))}Yl.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 Ql{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 Jl(n,e)}}class Jl{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}isEqualTo(t){return this.block===t.block&&this.offset===t.offset}print(){return this.block+":"+this.offset}}function tc(t,e){if(0===t.length)return t;if(t.sort((function(t,e){const n=t.minv.block-e.minv.block;return 0!==n?n:t.minv.offset-e.minv.offset})),t.length<=1)return t;e&&(t=t.filter((t=>t.maxv.isGreaterThan(e))));const n=[];let r;for(let e of t)r&&ec(r,e)?e.maxv.isGreaterThan(r.maxv)&&(r.maxv=e.maxv):(n.push(e),r=e);return n}function ec(t,e){const n=e.minv.block-t.maxv.block,r=t.maxv.block-t.minv.block;return n<65e3&&r<5e6}class nc{constructor(t){this.tabix=!0}parse(t,e){const n=new Ql(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)}chunksForRange(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];for(let n of e){const e=n[0],r=n[1];i.push({minv:e,maxv:r,bin:t})}}return tc(i,r.loffset[t[0]])}return[]}reg2bins(t,e){(t-=1)<1&&(t=1),e>2**34&&(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);o.push([n,s])}return o}bin_limit(){return((1<<3*(this.depth+1))-1)/7}}class rc{constructor(){}async parse(t,e,n){const r=[];let i=Number.MAX_SAFE_INTEGER,o=0;const s=new Ql(new DataView(t)),a=s.getInt(),l={};if(!(21578050===a||e&&21578324===a))throw new Error(indexURL+" is not a "+(e?"tabix":"bai")+" file");{const t=s.getInt();if(e){s.getInt(),s.getInt(),s.getInt(),s.getInt(),s.getInt(),s.getInt(),s.getInt();for(let e=0;e<t;e++){let t=s.getString();n&&(t=n.getChromosomeName(t)),l[t]=e}}for(let e=0;e<t;e++){const t={},n=[],a=s.getInt();for(let e=0;e<a;e++){const e=s.getInt();if(37450===e)s.getInt(),s.getVPointer(),s.getVPointer(),s.getLong(),s.getLong();else{t[e]=[];const n=s.getInt();for(let r=0;r<n;r++){const n=s.getVPointer(),r=s.getVPointer();n&&r&&(n.block<i&&(i=n.block),r.block>o&&(o=r.block),t[e].push([n,r]))}}}const l=s.getInt();for(let t=0;t<l;t++){const t=s.getVPointer();n.push(t)}a>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)}chunksForRange(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];for(let t of e){const e=t[0],n=t[1];i.push({minv:e,maxv:n})}}const o=r.linearIndex.length;let s;const a=Math.min(e>>14,o-1),l=Math.min(n>>14,o-1);for(let t=a;t<=l;t++){const e=r.linearIndex[t];if(e){s=e;break}}return tc(i,s)}return[]}}class ic{constructor(){}async parse(t,e){let n=0;this.chrIndex={},this.lastBlockPosition=[];const r=new Ql(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 l=[];for(let t=0;t<o;t++){const t=r.getLong();l.push({min:a,max:t}),a=t,t>n&&(n=t)}this.chrIndex[t]={chr:t,blocks:l,longestFeature:s,binWidth:i}}this.lastBlockPosition=n}get chromosomeNames(){return Object.keys(this.chrIndex)}chunksForRange(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 oc(t,e,n){let r=await To.loadArrayBuffer(t,Is(e)),i=new DataView(r);if(31===i.getUint8(0)&&139===i.getUint8(1)){r=oo(r).buffer,i=new DataView(r)}switch(i.getInt32(0,!0)){case 21578050:return async function(t,e){const n=new rc;return await n.parse(t,!1,e),n}(r,n);case 21578324:return async function(t,e){const n=new rc;return await n.parse(t,!0,e),n}(r,n);case 21582659:return async function(t,e){const n=new nc;return n.parse(t,e),n}(r,n);case 1480870228:return async function(t,e){const n=new ic;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}`)}}function sc(t){return"string"==typeof t||t instanceof String?new ac(t):new lc(t)}class ac{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 lc{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 cc{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=Is(this.config,{range:{start:this.filePtr,size:26}}),e=so(await To.loadArrayBuffer(this.config.url,t));if(0===e)this.eof=!0,this.buffer=void 0;else{const t=Is(this.config,{range:{start:this.filePtr,size:e}}),n=await To.loadArrayBuffer(this.config.url,t);n.byteLength<e&&(this.eof=!0),this.buffer=oo(n),this.bufferPtr=0,this.filePtr+=n.byteLength}}}const hc=t=>{const e=ArrayBuffer.isView(t)?t:new Uint8Array(t);return 1+(e[17]<<8|e[16])};class uc{constructor(t){this.config=t,this.cacheBlocks=0!=t.cacheBlocks,this.cache=void 0}async getData(t,e){const n=await this.getInflatedBlocks(t,e);if(1===n.length)return n[0];let r=0;for(const t of n)r+=t.byteLength;const i=new Uint8Array(r);let o=0;for(const t of n)i.set(t,o),o+=t.byteLength;return i}async getInflatedBlocks(t,e){if(this.cacheBlocks){const n=this.cache;if(n&&n.startBlock<=t&&n.endBlock>=e){const r=t-n.startBlock,i=e-n.startBlock;return fc(n.buffer,r,i)}{let r;if(!n||n.startBlock>e||n.endBlock<t)r=await this.loadBLockData(t,e);else{const i=[];if(t<n.startBlock){const e=await this.loadBLockData(t,n.startBlock,{skipEnd:!0});i.push(e)}let o;if(t<=n.startBlock&&e>=n.endBlock)o=n.buffer;else{const r=Math.max(0,t-n.startBlock);let i;if(e>=n.endBlock)i=n.buffer.byteLength;else{const t=function(t){const e=t.byteLength;let n=0;const r=[0];for(;n<e;){const i=new Uint8Array(t,n);n+=1+(i[17]<<8|i[16]),n<e&&r.push(n)}return r}(n.buffer);for(let r=0;r<t.length-1;r++)if(n.startBlock+t[r]===e){i=t[r+1];break}}o=n.buffer.slice(r,i)}if(i.push(o),e>n.endBlock){const t=await this.loadBLockData(n.endBlock,e,{skipStart:!0});i.push(t)}r=function(t){if(1===t.length)return t[0];let e=0;for(const n of t)e+=n.byteLength;const n=new Uint8Array(e);let r=0;for(const e of t)n.set(new Uint8Array(e),r),r+=e.byteLength;return n.buffer}(i)}return this.cache={startBlock:t,endBlock:e,buffer:r},fc(r)}}return fc(await this.loadBLockData(t,e))}async loadBLockData(t,e,n){const r=this.config,i=n&&n.skipStart;let o=0;if(!(n&&n.skipEnd)){const t=Is(r,{range:{start:e,size:26}}),n=await To.loadArrayBuffer(r.url,t);o=hc(n)}if(i){const e=Is(r,{range:{start:t,size:26}}),n=await To.loadArrayBuffer(r.url,e);t+=hc(n)}const s=Is(r,{range:{start:t,size:e+o-t}});return To.loadArrayBuffer(r.url,s)}}function fc(t,e,n){const r=[];let i=e=e||0;const o=t.byteLength-18;for(;i<o;)try{const e=new Uint8Array(t,i,18),o=e[11]<<8|e[10],s=e[17]<<8|e[16],a=12+o+i,l=t.byteLength-a,c=s-o-18;if(l<c||c<=0)break;const h=new Uint8Array(t,a,c),u=ro(h);if(r.push(u),n===i)break;i+=s+1}catch(t){console.error(t);break}return r}class dc{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:Ds(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)this._blockLoader=new uc(this.config),e=new cc(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=Is(this.config,{bgz:t.tabix,range:{start:0,size:n}});e=sc(await To.loadString(this.config.url,r))}return this.header=await this.parser.parseHeader(e),this.header}{const t=Is(this.config),e=await To.loadString(this.config.url,t);let n=sc(e);return this.header=await this.parser.parseHeader(n),n=sc(e),this.features=await this.parser.parseFeatures(n),this.header}}getParser(t){switch(t.format){case"vcf":return new Bl(t);case"seg":return new Rl("seg");case"mut":return new Rl("mut");case"maf":return new Rl("maf");case"gwas":return new Vl(t);case"aed":return new Wl(t);default:return new _l(t)}}async loadFeaturesNoIndex(){if(this.features){const t=this.features;return delete this.features,t}{const t=Is(this.config),e=await To.loadString(this.config.url,t);if(!this.header){const t=sc(e);this.header=await this.parser.parseHeader(t)}const n=sc(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,l=this.index.chunksForRange(s,e,n);if(l&&0!==l.length){const s=[];for(let c of l){let l;if(o)l=await this._blockLoader.getData(c.minv.block,c.maxv.block);else{const t=Is(r,{range:{start:c.minv.block,size:c.maxv.block-c.minv.block+1}});l=await To.loadString(r.url,t)}const h=sc(c.minv.offset?l.slice(c.minv.offset):l);let u=await i.parseFeatures(h);u=u.filter((t=>void 0===t._f));let f=!1;for(let r=0;r<u.length;r++){const i=u[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&&(f||(f=!0,r>0&&s.push(u[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 oc(this.config.indexURL,this.config,this.genome)}async loadFeaturesFromDataURI(){if(this.features){const t=this.features;return delete this.features,t}{const t=ho(this.dataURI);let e=sc(t);return this.header=await this.parser.parseHeader(e),this.header instanceof String&&this.header.startsWith("##gff-version 3")&&(this.format="gff3"),e=sc(t),this.features=await this.parser.parseFeatures(e),this.features}}}const pc=ke;class gc{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 To.load(r,o);if(s&&(i="function"==typeof this.config.parser?this.config.parser(s):pc(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 mc=function(t,e){this.config=t,this.genome=e,this.expandQueryInterval=!1};mc.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 To.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 l={start:o=parseInt(n[a]),end:s=parseInt(r[a])};(t.cdsStart>s||t.cdsEnd<t.cdsStart)&&(l.utr=!0),t.cdsStart>=o&&t.cdsStart<=s&&(l.cdStart=t.cdsStart),t.cdsEnd>=o&&t.cdsEnd<=s&&(l.cdEnd=t.cdsEnd),i.push(l)}t.exons=i}(t)})),t):null}))};const vc=["Name","gene_name","gene","gene_id","alias","locus","name"];class bc{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(Xa(r.type)||Za(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(),Za(e.type)){const t=e.id;if(void 0!==t){const s=new Qa(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(Xa(e.type)){const t=c(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 Qa(t),r[n]=s,i.push(s)}if(void 0!==s){if(a=e.type,Ua.has(a))if(t.length>1){const t=new Ka(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 l=t.filter((t=>!o.has(t)));for(let t of l)i.push(t);return i;function c(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=nl(e.attributeString,t),r=new Map(n);if(this.nameField)e.name=r.get(this.nameField);else for(let t of vc)if(r.has(t)){e.name=r.get(t);break}}}}const wc=function(t){this.config=t,this.url=t.url,this.tissueId=t.tissueSiteDetailId,this.indexed=!0,this.datasetId=t.datasetId||"gtex_v8"};wc.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 l=await To.loadJson(a,{withCredentials:this.config.withCredentials});return l&&l.singleTissueEqtl?(l.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})),l.singleTissueEqtl):void 0};const yc=function(t){this.config=t,this.url=t.url,this.cellConditionId=t.cellConditionId,this.valueThreshold=t.valueThreshold?t.valueThreshold:.05};yc.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){To.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 xc=To.apiKey;function _c(t){var e=t.url+"/"+t.entity+"/"+t.entityId;return t.headers={"Cache-Control":"no-cache"},To.loadJson(e,t)}function kc(t){return new Promise((function(e,n){var r=t.results?t.results:[],i=t.url,o=t.body,s=t.decode,a="?",l=t.fields;return xc&&(i=i+a+"key="+xc,a="&"),l&&(i=i+a+"fields="+l),function t(a){a?o.pageToken=a:void 0!==o.pageToken&&delete o.pageToken;var l=JSON.stringify(o);To.loadJson(i,{sendData:l,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)}))}()}))}const Sc=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};Sc.prototype.readHeader=function(){var t=this;return t.header?Promise.resolve(t.header):(t.header={},!1===t.includeCalls?Promise.resolve(t.header):kc({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})))},Sc.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 kc({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 Ol;return n.chr=t.referenceName,n.start=parseInt(t.start),n.end=parseInt(t.end),n.pos=n.start+1,n.names=Dl(t.names,"; "),n.referenceBases=t.referenceBases,n.alternateBases=Dl(t.alternateBases),n.quality=t.quality,n.filter=Dl(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}})}))},Sc.prototype.readMetadata=function(){return _c({url:this.url,entity:"variantsets",entityId:this.variantSetId})};class Cc{constructor(t){this.config=t}async readFeatures(t,e,n){const r=(await To.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 Ec(e.chromosome,e.start-1,e.stop,t)),e.chromosome2&&i.push(new Ec(e.chromosome2,e.start2-1,e.stop2,t))}return i}}class Ec{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>"}}}class Tc{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=`${Ac(this.config)}?class=header&format=${this.format}`,e=await To.loadJson(t,Is(this.config));return await this.loadUrls(e.htsget.urls)}async readData(t,e,n){const r=`${Ac(this.config)}?format=${this.format}&referenceName=${t}&start=${Math.floor(e)}&end=${Math.ceil(n)}`,i=await To.loadJson(r,Is(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(Lc(n.url)));else{const t=Is(this.config||{});n.headers&&(t.headers=Object.assign(t.headers||{},n.headers)),e.push(To.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=Ac(t),n=`${e}${e.includes("?")?"&":"?"}class=header`,r=await To.loadJson(n,Is(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 Ps(t.url))}}catch(t){}}}function Ac(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 Lc(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 Mc extends Tc{constructor(t,e){super(t,e),this.parser=new Bl}async readHeader(){if(!this.header){const t=sc(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=sc(await this.readData(r,e,n));return this.parser.parseFeatures(i)}}function Rc(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}}function Ic(t,e,n){const r=n||1e4,i=t=>{const n=Object.assign({},t);return n.chr="all",n.start=e.getGenomeCoordinate(t.chr,t.start),n.end=e.getGenomeCoordinate(t.chr,t.end),n._f=t,n.exons&&delete n.exons,n},o=new Set(e.wgChromosomeNames),s=[];let a=0;for(let n of e.wgChromosomeNames){if(Array.isArray(t)){const n={};for(let r of t){const t=e.getChromosomeName(r.chr);n.hasOwnProperty(t)||(n[t]=[]),n[t].push(r)}t=n}const l=t[n];if(l)for(let t of l){let n=e.getChromosomeName(t.chr);if(o.has(n))if(s.length<r)s.push(i(t));else{const e=r/(a+1);if(Math.random()<e){s[Math.floor(Math.random()*(r-1))]=i(t)}}a++}}return s.sort((function(t,e){return t.start-e.start})),s}function Nc(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)Rc(n[t],e)}class Oc{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"]);t.reader?(this.reader=t.reader,this.queryable=!1!==t.queryable):"ga4gh"===t.sourceType?(this.reader=new Sc(t,e),this.queryable=!0):"immvar"===t.sourceType?(this.reader=new yc(t),this.queryable=!0):"eqtl"===t.type&&"gtex-ws"===t.sourceType?(this.reader=new wc(t),this.queryable=!0):"htsget"===t.sourceType?this.reader=new Mc(t,e):"ucscservice"===t.sourceType?(this.reader=new mc(t.source),this.queryable=!0):"custom"===t.sourceType?(this.reader=new gc(t.source),this.queryable=!1!==t.source.queryable):"civic-ws"===t.sourceType?(this.reader=new Cc(t),this.queryable=!1):(this.reader=new dc(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(t){let{chr:e,start:n,end:r,bpPerPixel:i,visibilityWindow:o}=t;const s=this.genome,a=s?s.getChromosomeName(e):e,l="all"===a.toLowerCase();return(l&&!this.wgFeatures&&this.supportsWholeGenome()||this.config.disableCache||!this.featureCache||!this.featureCache.containsRange(new na(a,n,r)))&&await this.loadFeatures(a,n,r,o),l?(this.wgFeatures||(this.supportsWholeGenome()?this.wgFeatures=Ic(this.featureCache.getAllFeatures(),this.genome,this.maxWGCount):this.wgFeatures=[]),this.wgFeatures):this.featureCache.queryFeatures(a,n,r)}supportsWholeGenome(){return!this.queryable}getAllFeatures(){return this.queryable||!this.featureCache?[]: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 l=this.queryable?new na(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 bc(this.config).combineFeatures(a,l)),"wig"!==this.config.format&&"junctions"!==this.config.type){Nc(a,this.config.maxRows||Number.MAX_SAFE_INTEGER)}this.featureCache=new Vo(a,this.genome,l),(this.config.searchable||this.config.searchableFields)&&this.addFeaturesToDB(a)}else this.featureCache=new Vo([],l)}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)}}}class Pc{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 To.loadArrayBuffer(this.path,Is(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)}}let Fc=512e3;class Dc{constructor(t,e){this.path=t.url,this.format=t.format||"bigwig",this.genome=e,this.rpTreeCache={},this.config=t,this.loader=Ds(this.path)?new Zc(this.path):To}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 l,c;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?(l=e.indexOffset,c=Gc):(l=this.header.fullIndexOffset,c=Wc)}else l=this.header.fullIndexOffset,c=$c.call(this);const h=await this.loadRPTree(l),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,l=await this.loader.loadArrayBuffer(this.config.url,Is(this.config,{range:{start:t,size:i}})),h=[];for(let n of u){const i=new Uint8Array(l,n.dataOffset-t,n.dataSize);let u;u=this.header.uncompressBuffSize>0?io(i):i,c.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,Is(this.config,{range:{start:0,size:64}}));this.littleEndian=!0;let n=new Ql(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,Is(this.config,{range:o}));const s=t.nZoomLevels;n=new Ql(new DataView(e)),this.zoomLevelHeaders=[],this.firstZoomDataOffset=Number.MAX_SAFE_INTEGER;for(let t=1;t<=s;t++){const e=s-t,r=new Bc(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 Uc(n)),!(t.chromTreeOffset>0))throw"BigWig chromosome tree offset <= 0";return n.position=t.chromTreeOffset-i,this.chromTree=new Vc(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 zc(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 Bc{constructor(t,e){this.index=t,this.reductionLevel=e.getInt(),this.reserved=e.getInt(),this.dataOffset=e.getLong(),this.indexOffset=e.getLong()}}class zc{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=Ds(this.path)?this.loader:new Pc(this.config,Fc);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 Ql(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 Ql(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 Hc(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 Hc(a)}async findLeafItemsOverlapping(t,e,n,r){let i=this;return new Promise((function(o,s){let a=[],l=new Set,c=Ds(i.path)?i.loader:new Pc(i.config,Fc);l.add(0),function h(u,f){if(jc(u,t,e,n,r)){u.items.forEach((function(o){jc(o,t,e,n,r)&&(o.isLeaf?a.push(o):o.childNode?h(o.childNode):(l.add(o.childOffset),i.readNode(o.childOffset,c).then((function(t){o.childNode=t,h(t,o.childOffset)})).catch(s)))}))}void 0!==f&&l.delete(f);0===l.size&&o(a)}(i.rootNode,0)}))}}class Hc{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 Vc{constructor(t,e,n){let r=t.getInt(),i=t.getInt(),o=t.getInt(),s=t.getInt(),a=t.getLong(),l=t.getLong(),c={},h=[];this.header={magic:r,blockSize:i,keySize:o,valSize:s,itemCount:a,reserved:l},this.chromToID=c,this.idToChrom=h,function t(r,i){i>=0&&(r.position=i);let s=r.getByte();r.getByte();let a,l,u,f,d,p,g=r.getUShort();if(1===s)for(a=0;a<g;a++)l=r.getFixedLengthTrimmedString(o),u=r.getInt(),r.getInt(),n&&(l=n.getChromosomeName(l)),c[l]=u,h[u]=l;else for(a=0;a<g;a++)l=r.getFixedLengthTrimmedString(o),f=r.getLong(),d=f-e,p=r.position,t(r,d),r.position=p}(t,-1)}}function jc(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 Uc{constructor(t){t?(this.basesCovered=t.getLong(),this.minVal=t.getDouble(),this.maxVal=t.getDouble(),this.sumData=t.getDouble(),this.sumSquares=t.getDouble(),qc.call(this)):(this.basesCovered=0,this.minVal=0,this.maxVal=0,this.sumData=0,this.sumSquares=0,this.mean=0,this.stddev=0)}}function qc(){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 Wc(t,e,n,r,i,o,s){const a=new Ql(t),l=a.getInt();let c=a.getInt(),h=a.getInt();const u=a.getInt(),f=a.getInt(),d=a.getByte();a.getByte();let p=a.getUShort();if(l>=e&&l<=r)for(;p-- >0;){let t;switch(d){case 1:c=a.getInt(),h=a.getInt(),t=a.getFloat();break;case 2:c=a.getInt(),t=a.getFloat(),h=c+f;break;case 3:t=a.getFloat(),h=c+f,c+=u}if(!(l<e||l===e&&h<n)){if(l>r||l===r&&c>=i)break;if(Number.isFinite(t)){const e=s[l];o.push({chr:e,start:c,end:h,value:t})}}}}function $c(){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=vo.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 l=new Ql(e);for(;l.remLength()>=13;){const e=l.getInt(),c=a[e],h=l.getInt(),u=l.getInt(),f=l.getString();if(!(e<n||e===n&&u<r)){if(e>i||e===i&&h>=o)break;if(u>0){const e={chr:c,start:h,end:u};s.push(e);const n=f.split("\t");t(e,n)}}}}}function Gc(t,e,n,r,i,o,s,a){const l=new Ql(t);for(;l.remLength()>=32;){const t=l.getInt(),c=s[t],h=l.getInt(),u=l.getInt(),f=l.getInt(),d=l.getFloat(),p=l.getFloat(),g=l.getFloat();let m;switch(l.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:c,start:h,end:u,value:m})}}}class Zc{constructor(t){this.data=ho(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 Xc{constructor(t,e){this.reader=new Dc(t,e),this.genome=e,this.format=t.format||"bigwig",this.wgValues={}}async getFeatures(t){let{chr:e,start:n,end:r,bpPerPixel:i,windowFunction:o}=t;const s="bigwig"===this.reader.type,a="all"===e.toLowerCase()?s?await this.getWGValues(o):[]:await this.reader.readFeatures(e,n,e,r,i,o);return s||Rc(a),a}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()}}var Yc="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Kc(t){var e={exports:{}};return t(e,e.exports),e.exports}var Qc=function(t){return t&&t.Math==Math&&t},Jc=Qc("object"==typeof globalThis&&globalThis)||Qc("object"==typeof window&&window)||Qc("object"==typeof self&&self)||Qc("object"==typeof Yc&&Yc)||function(){return this}()||Function("return this")(),th=function(t){try{return!!t()}catch(t){return!0}},eh=!th((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),nh="object"==typeof document&&document.all,rh={all:nh,IS_HTMLDDA:void 0===nh&&void 0!==nh},ih=rh.all,oh=rh.IS_HTMLDDA?function(t){return"function"==typeof t||t===ih}:function(t){return"function"==typeof t},sh=!th((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")})),ah=Function.prototype,lh=ah.call,ch=sh&&ah.bind.bind(lh,lh),hh=sh?ch:function(t){return function(){return lh.apply(t,arguments)}},uh=function(t){return null==t},fh=TypeError,dh=function(t){if(uh(t))throw fh("Can't call method on "+t);return t},ph=Object,gh=hh({}.hasOwnProperty),mh=Object.hasOwn||function(t,e){return gh(ph(dh(t)),e)},vh=Function.prototype,bh=eh&&Object.getOwnPropertyDescriptor,wh=mh(vh,"name"),yh={EXISTS:wh,PROPER:wh&&"something"===function(){}.name,CONFIGURABLE:wh&&(!eh||eh&&bh(vh,"name").configurable)},xh=Object.defineProperty,_h=function(t,e){try{xh(Jc,t,{value:e,configurable:!0,writable:!0})}catch(n){Jc[t]=e}return e},kh="__core-js_shared__",Sh=Jc[kh]||_h(kh,{}),Ch=hh(Function.toString);oh(Sh.inspectSource)||(Sh.inspectSource=function(t){return Ch(t)});var Eh,Th,Ah=Sh.inspectSource,Lh=Jc.WeakMap,Mh=oh(Lh)&&/native code/.test(String(Lh)),Rh=rh.all,Ih=rh.IS_HTMLDDA?function(t){return"object"==typeof t?null!==t:oh(t)||t===Rh}:function(t){return"object"==typeof t?null!==t:oh(t)},Nh=Jc.document,Oh=Ih(Nh)&&Ih(Nh.createElement),Ph=function(t){return Oh?Nh.createElement(t):{}},Fh=!eh&&!th((function(){return 7!=Object.defineProperty(Ph("div"),"a",{get:function(){return 7}}).a})),Dh=eh&&th((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Bh=String,zh=TypeError,Hh=function(t){if(Ih(t))return t;throw zh(Bh(t)+" is not an object")},Vh=Function.prototype.call,jh=sh?Vh.bind(Vh):function(){return Vh.apply(Vh,arguments)},Uh=function(t){return oh(t)?t:void 0},qh=function(t,e){return arguments.length<2?Uh(Jc[t]):Jc[t]&&Jc[t][e]},Wh=hh({}.isPrototypeOf),$h=qh("navigator","userAgent")||"",Gh=Jc.process,Zh=Jc.Deno,Xh=Gh&&Gh.versions||Zh&&Zh.version,Yh=Xh&&Xh.v8;Yh&&(Th=(Eh=Yh.split("."))[0]>0&&Eh[0]<4?1:+(Eh[0]+Eh[1])),!Th&&$h&&(!(Eh=$h.match(/Edge\/(\d+)/))||Eh[1]>=74)&&(Eh=$h.match(/Chrome\/(\d+)/))&&(Th=+Eh[1]);var Kh,Qh,Jh,tu,eu=Th,nu=!!Object.getOwnPropertySymbols&&!th((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&eu&&eu<41})),ru=nu&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,iu=Object,ou=ru?function(t){return"symbol"==typeof t}:function(t){var e=qh("Symbol");return oh(e)&&Wh(e.prototype,iu(t))},su=String,au=TypeError,lu=function(t){if(oh(t))return t;throw au(function(t){try{return su(t)}catch(t){return"Object"}}(t)+" is not a function")},cu=TypeError,hu=Kc((function(t){(t.exports=function(t,e){return Sh[t]||(Sh[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.27.1",mode:"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.27.1/LICENSE",source:"https://github.com/zloirock/core-js"})})),uu=0,fu=Math.random(),du=hh(1..toString),pu=function(t){return"Symbol("+(void 0===t?"":t)+")_"+du(++uu+fu,36)},gu=hu("wks"),mu=Jc.Symbol,vu=mu&&mu.for,bu=ru?mu:mu&&mu.withoutSetter||pu,wu=TypeError,yu=function(t){if(!mh(gu,t)||!nu&&"string"!=typeof gu[t]){var e="Symbol."+t;nu&&mh(mu,t)?gu[t]=mu[t]:gu[t]=ru&&vu?vu(e):bu(e)}return gu[t]}("toPrimitive"),xu=function(t,e){if(!Ih(t)||ou(t))return t;var n,r,i=(n=t[yu],uh(n)?void 0:lu(n));if(i){if(void 0===e&&(e="default"),r=jh(i,t,e),!Ih(r)||ou(r))return r;throw wu("Can't convert object to primitive value")}return void 0===e&&(e="number"),function(t,e){var n,r;if("string"===e&&oh(n=t.toString)&&!Ih(r=jh(n,t)))return r;if(oh(n=t.valueOf)&&!Ih(r=jh(n,t)))return r;if("string"!==e&&oh(n=t.toString)&&!Ih(r=jh(n,t)))return r;throw cu("Can't convert object to primitive value")}(t,e)},_u=function(t){var e=xu(t,"string");return ou(e)?e:e+""},ku=TypeError,Su=Object.defineProperty,Cu=Object.getOwnPropertyDescriptor,Eu="enumerable",Tu="configurable",Au="writable",Lu={f:eh?Dh?function(t,e,n){if(Hh(t),e=_u(e),Hh(n),"function"==typeof t&&"prototype"===e&&"value"in n&&Au in n&&!n[Au]){var r=Cu(t,e);r&&r[Au]&&(t[e]=n.value,n={configurable:Tu in n?n[Tu]:r[Tu],enumerable:Eu in n?n[Eu]:r[Eu],writable:!1})}return Su(t,e,n)}:Su:function(t,e,n){if(Hh(t),e=_u(e),Hh(n),Fh)try{return Su(t,e,n)}catch(t){}if("get"in n||"set"in n)throw ku("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},Mu=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},Ru=eh?function(t,e,n){return Lu.f(t,e,Mu(1,n))}:function(t,e,n){return t[e]=n,t},Iu=hu("keys"),Nu={},Ou="Object already initialized",Pu=Jc.TypeError,Fu=Jc.WeakMap;if(Mh||Sh.state){var Du=Sh.state||(Sh.state=new Fu);Du.get=Du.get,Du.has=Du.has,Du.set=Du.set,Kh=function(t,e){if(Du.has(t))throw Pu(Ou);return e.facade=t,Du.set(t,e),e},Qh=function(t){return Du.get(t)||{}},Jh=function(t){return Du.has(t)}}else{var Bu=Iu[tu="state"]||(Iu[tu]=pu(tu));Nu[Bu]=!0,Kh=function(t,e){if(mh(t,Bu))throw Pu(Ou);return e.facade=t,Ru(t,Bu,e),e},Qh=function(t){return mh(t,Bu)?t[Bu]:{}},Jh=function(t){return mh(t,Bu)}}var zu={set:Kh,get:Qh,has:Jh,enforce:function(t){return Jh(t)?Qh(t):Kh(t,{})},getterFor:function(t){return function(e){var n;if(!Ih(e)||(n=Qh(e)).type!==t)throw Pu("Incompatible receiver, "+t+" required");return n}}},Hu=Kc((function(t){var e=yh.CONFIGURABLE,n=zu.enforce,r=zu.get,i=Object.defineProperty,o=eh&&!th((function(){return 8!==i((function(){}),"length",{value:8}).length})),s=String(String).split("String"),a=t.exports=function(t,r,a){"Symbol("===String(r).slice(0,7)&&(r="["+String(r).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),a&&a.getter&&(r="get "+r),a&&a.setter&&(r="set "+r),(!mh(t,"name")||e&&t.name!==r)&&(eh?i(t,"name",{value:r,configurable:!0}):t.name=r),o&&a&&mh(a,"arity")&&t.length!==a.arity&&i(t,"length",{value:a.arity});try{a&&mh(a,"constructor")&&a.constructor?eh&&i(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(t){}var l=n(t);return mh(l,"source")||(l.source=s.join("string"==typeof r?r:"")),t};Function.prototype.toString=a((function(){return oh(this)&&r(this).source||Ah(this)}),"toString")})),Vu=Jc.RegExp,ju=Vu.prototype,Uu=eh&&th((function(){var t=!0;try{Vu(".","d")}catch(e){t=!1}var e={},n="",r=t?"dgimsy":"gimsy",i=function(t,r){Object.defineProperty(e,t,{get:function(){return n+=r,!0}})},o={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var s in t&&(o.hasIndices="d"),o)i(s,o[s]);return Object.getOwnPropertyDescriptor(ju,"flags").get.call(e)!==r||n!==r}));Uu&&function(t,e,n){n.get&&Hu(n.get,e,{getter:!0}),n.set&&Hu(n.set,e,{setter:!0}),Lu.f(t,e,n)}(ju,"flags",{configurable:!0,get:function(){var t=Hh(this),e="";return t.hasIndices&&(e+="d"),t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.dotAll&&(e+="s"),t.unicode&&(e+="u"),t.unicodeSets&&(e+="v"),t.sticky&&(e+="y"),e}});class qu{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 To.loadArrayBuffer(this.path,Is(this.config,{range:{start:0,size:64e3}})),e=new Ql(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 To.loadArrayBuffer(this.path,Is(this.config,{range:{start:this.indexPos,size:this.indexSize}})),e=new Ql(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 l=await To.loadArrayBuffer(this.path,Is(this.config,{range:{start:a.position,size:a.size}}));if(!l)return;const c=new Ql(new DataView(l));let h=c.getInt();const u={};for(;h-- >0;)u[c.getString()]=c.getString();const f=c.getString(),d=c.getFloat();let p=c.getInt();const g=[];for(;p-- >0;)g.push({position:c.getLong(),size:c.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 To.loadArrayBuffer(this.path,Is(this.config,{range:{start:e.position,size:e.size}}));if(!n)return;const r=new Ql(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 To.loadArrayBuffer(this.path,Is(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=io(s.slice(t,t+r)).buffer}else n=s.slice(t,t+r);const i=new Ql(new DataView(n)),o=i.getString();let l;switch(o){case"fixedStep":l=Wu(i,e);break;case"variableStep":l=$u(i,e);break;case"bed":case"bedWithName":l=Gu(i,e,o);break;default:throw"Unknown tile type: "+o}a.push(l)}}return a}async readTile(t,e){let n=await To.loadArrayBuffer(this.path,Is(this.config,{range:{start:t.position,size:t.size}}));if(this.compressed){n=io(n).buffer}const r=new Ql(new DataView(n)),i=r.getString();switch(i){case"fixedStep":return Wu(r,e);case"variableStep":return $u(r,e);case"bed":case"bedWithName":return Gu(r,e,i);default:throw"Unknown tile type: "+i}}}function Wu(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 $u(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 l=e;for(;l-- >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 Gu(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 l=e;for(;l-- >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 Zu{constructor(t,e){this.genome=e,this.windowFunction=t.windowFunction||"mean",this.reader=new qu(t,e)}async getFeatures(t){let{chr:e,start:n,end:r,bpPerPixel:i}=t;if("all"===e.toLowerCase()){const t=[],e=this.genome;if(this.genome.wgChromosomeNames)for(let n of e.wgChromosomeNames){const r=e.getChromosome(n).bpLength;i=r/1e3;const o=await this._getFeatures(n,0,r,i);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(e,n,r,i)}async _getFeatures(t,e,n,r){const i=new na(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)))/Qu)}(t,r,o);let a=this.reader.chrAliasTable[t],l=this.reader.maxZoom;void 0===a&&(a=t),void 0===l&&(l=-1);const c=s>l?"raw":this.windowFunction,h=await this.reader.readDataset(a,c,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":Xu(i,t,e,n,r,g);break;case"variableStep":Yu(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 Xu(t,e,n,r,i,o){const s=t.nPositions,a=t.start,l=t.end,c=t.data[0];for(let t=0;t<s;t++){const i=a[t],s=l[t];if(!(s<n)){if(i>r)break;o.push({chr:e,start:i,end:s,value:c[t]})}}}function Yu(t,e,n,r,i,o){const s=t.nPositions,a=t.start,l=t.span,c=t.data[0];for(let t=0;t<s;t++){const i=a[t],s=i+l;if(!(s<n)){if(i>r)break;o.push({chr:e,start:i,end:s,value:c[t]})}}}function Ku(t,e,n,r,i,o){const s=t.nPositions;let a=t.start;const l=t.span,c=t.data[0];for(let t=0;t<s;t++){const i=a+l;if(a>r)break;i>=n&&(Number.isNaN(c[t])||o.push({chr:e,start:a,end:i,value:c[t]})),a=i}}var Qu=Math.log(2);class Ju{constructor(t,e){this.config=t,this.genome=e,this.queryable=!1,this.updateFeatures(t.features)}updateFeatures(t){Nc(t=function(t,e){if(e)for(let n of t)n.chr=e.getChromosomeName(n.chr);return t}(t,this.genome)),this.config.mappings&&function(t,e){let n=Object.keys(e);t.forEach((function(t){n.forEach((function(n){t[n]=t[e[n]]}))}))}(t,this.config.mappings),this.featureCache=new Vo(t,this.genome)}async getFeatures(t){let{chr:e,start:n,end:r,bpPerPixel:i,visibilityWindow:o}=t;const s=this.genome,a=s?s.getChromosomeName(e):e;return"all"===a.toLowerCase()?Ic(this.featureCache.getAllFeatures(),this.genome,this.maxWGCount):this.featureCache.queryFeatures(a,n,r)}getAllFeatures(){return this.featureCache.getAllFeatures()}supportsWholeGenome(){return!0}}const tf=new Set(["bigwig","bw","bigbed","bb","biginteract","biggenepred","bignarrowpeak"]);function ef(t,e){const n=t.format?t.format.toLowerCase():void 0;return t.features?new Ju(t,e):tf.has(n)?new Xc(t,e):"tdf"===n?new Zu(t,e):new Oc(t,e)}const nf=function(t,e){const{r:n,g:r,b:i}=Yo[t];return`rgba(${n},${r},${i},${e})`}("nickel",2/16),rf=nf;class of{constructor(t,e){if(this.url=t.url,t.name?this.name=t.name:t.url&&Ue(t.url)?this.name=t.url.name:t.url&&ke(t.url)&&!t.url.startsWith("data:")&&(this.name=je(t.url)),this.isUserDefined=t.isUserDefined,t.features)this.featureSource=new af(t.features,e);else{if(t.format)t.format=t.format.toLowerCase();else{const e=je(t.url);t.format=$s(e)}this.featureSource=t.featureSource||ef(t,e)}!0===this.isUserDefined?(this.color=t.color||rf,this.headerColor="rgba(155,185,129)"):(this.color=t.color||nf,this.headerColor="rgb(190,190,190)")}async getFeatures(t,e,n){return this.featureSource.getFeatures({chr:t,start:e,end:n})}async getAllFeatures(){return"function"==typeof this.featureSource.getAllFeatures?await this.featureSource.getAllFeatures():{}}addFeature(t){this.isUserDefined?this.featureSource.addFeature(t):console.error("Attempt to add ROI to non user-defined set")}removeFeature(t){this.isUserDefined?this.featureSource.removeFeature(t):console.error("Attempt to remove ROI from non user-defined set")}toJSON(){if(this.url)return{name:this.name,color:this.color,url:this.url,isUserDefined:this.isUserDefined};{const t=this.featureSource.getAllFeatures(),e=[];for(let n of Object.keys(t))for(let r of t[n])e.push(r);return{name:this.name,color:this.color,features:e,isUserDefined:this.isUserDefined}}}dispose(){for(let t of Object.keys(this))this[t]=void 0}}function sf(t,e,n,r){let i=Math.round((t-n)/r);let o=Math.round((e-n)/r)-i;return o<3&&(o=3,i-=1),{x:i,width:o}}class af{constructor(t,e){this.featureMap={},this.genome=e;for(let n of t){const t=e?e.getChromosomeName(n.chr):n.chr;let r=this.featureMap[t];r||(r=[],this.featureMap[t]=r),r.push(n)}for(let t of Object.keys(this.featureMap))this.featureMap[t].sort(((t,e)=>t.start-e.start))}getFeatures(t){let{chr:e,start:n,end:r}=t;if("all"===e.toLowerCase())return Ic(this.featureMap,this.genome);{const t=this.featureMap[e];return t?t.filter((t=>t.end>n&&t.start<r)):[]}}getAllFeatures(){return this.featureMap}supportsWholeGenome(){return!0}addFeature(t){let e=this.featureMap[t.chr];e||(e=[],this.featureMap[t.chr]=e),e.push(t),e.sort(((t,e)=>t.start-e.start))}removeFeature(t){let{chr:e,start:n,end:r}=t;if(this.featureMap[e]){const t=`${e}-${n}-${r}`;this.featureMap[e]=this.featureMap[e].filter((e=>t!==`${e.chr}-${e.start}-${e.end}`))}}}class lf{constructor(t,e,n,r){this.rulerViewport=t,this.rulerSweeper=ge({class:"igv-ruler-sweeper"}),e.appendChild(this.rulerSweeper),this.browser=n,this.referenceFrame=r,this.isMouseHandlers=void 0,this.addBrowserObserver()}addBrowserObserver(){this.boundObserverHandler=(()=>{this.referenceFrame&&(Ra.isWholeGenomeView(this.referenceFrame.chr)?this.removeMouseHandlers():this.addMouseHandlers())}).bind(this),this.browser.on("locuschange",this.boundObserverHandler)}removeBrowserObserver(){this.browser.off("locuschange",this.boundObserverHandler)}addMouseHandlers(){if(!0===this.isMouseHandlers)return;let 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.backgroundColor=!0===o.shiftKey?rf:"rgba(68, 134, 247, 0.25)",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:Math.floor(this.referenceFrame.calculateEnd(r)),end:Math.floor(this.referenceFrame.calculateEnd(r+i))};!0===n.shiftKey?this.browser.roiManager.updateUserDefinedROISet(Object.assign({chr:this.referenceFrame.chr},o)):(Os(this.browser.genome.getChromosome(this.referenceFrame.chr).bpLength,o,this.browser.minimumBases()),function(t,e,n){t.start=Math.round(e.start),t.end=Math.round(e.end),t.bpPerPixel=(t.end-t.start)/n}(this.referenceFrame,o,this.rulerViewport.contentDiv.clientWidth),this.browser.updateViews(this.referenceFrame))}}.bind(this),document.addEventListener("mouseup",this.boundDocumentMouseUpHandler),this.isMouseHandlers=!0}removeMouseHandlers(){this.rulerViewport.contentDiv.removeEventListener("mousedown",this.boundContentMouseDownHandler),document.removeEventListener("mousemove",this.boundDocumentMouseMoveHandler),document.removeEventListener("mouseup",this.boundDocumentMouseUpHandler),this.isMouseHandlers=!1}dispose(){this.removeBrowserObserver(),this.removeMouseHandlers(),this.rulerSweeper.remove()}}class cf{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)}}class hf{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}getSortValue(t,e){let{position:n,option:r,tag:i}=t;r||(r="BASE");const o=this.findAlignment(n);if(void 0===o)return Number.MAX_VALUE;switch(r){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,l=Math.floor(n-a.bpStart),c=a.coverage[l];let h=0;if(t.insertions)for(let e of t.insertions)e.start===n&&(h=-c.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-=c["pos"+o]+c["neg"+o]+s/1e3}}else h=4-s/1e3;else{const t=c.del;t>0?h-=t:0===h&&(h=1)}return h}(o,e,n);case"STRAND":return o.strand?1:-1;case"START":return o.start;case"TAG":return o.tags()[i];case"READ_NAME":return o.readName;case"INSERT_SIZE":return-Math.abs(o.fragmentLength);case"GAP_SIZE":return-o.gapSizeAt(n);case"MATE_CHR":return o.mate;case"MQ":return void 0===o.mq?Number.MAX_VALUE:-o.mq;case"ALIGNED_READ_LENGTH":return-o.lengthOnRef;default:return Number.MAX_VALUE}}}function uf(t){return t.isPaired()&&t.mate&&t.isMateMapped()&&t.chr===t.mate.chr&&(t.isFirstOfPair()||t.isSecondOfPair())&&!(t.isSecondary()||t.isSupplementary())}function ff(t){const e=[];for(let n of t)for(let t of n.alignments)t instanceof cf?(t.firstAlignment&&e.push(t.firstAlignment),t.secondAlignment&&e.push(t.secondAlignment)):e.push(t);return e}function df(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 l=0,c=0;const h=[],u=2;try{for(;l<t.length;){const t=new hf;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 c=e.pop();0===e.length&&(a[i]=void 0),t.alignments.push(c),s=r?c.scStart+c.scLengthOnRef+u:c.start+c.lengthOnRef+u,++l}if(t.alignments.length>0&&h.push(t),s=o,l===c)break;c=l}}catch(t){throw console.error(t),t}return h}}}class pf{constructor(t,e,n,r){let{samplingWindowSize:i,samplingDepth:o,pairsSupported:s,alleleFreqThreshold:a}=r;this.chr=t,this.start=Math.floor(e),this.end=Math.ceil(n),this.length=n-e,this.alleleFreqThreshold=void 0===a?.2:a,this.coverageMap=new mf(t,e,n,this.alleleFreqThreshold),this.alignments=[],this.downsampledIntervals=[],this.samplingWindowSize=void 0===i?100:i,this.samplingDepth=void 0===o?1e3:o,this.pairsSupported=void 0===s||s,this.paired=!1,this.pairsCache={},this.downsampledReads=new Set,this.currentBucket=new gf(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 gf(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 bf(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(uf(t)){let r=e[t.readName];r?(r.setSecondAlignment(t),e[t.readName]=void 0):(r=new cf(t),e[t.readName]=r,n.push(r))}else n.push(t);return n}(this.packedAlignmentRows):ff(this.packedAlignmentRows),this.packedAlignmentRows=df(e,this.start,this.end)}setShowSoftClips(t){const e=this.allAlignments();this.packedAlignmentRows=df(e,this.start,this.end,t)}repack(t,e){const n=this.allAlignments();this.packedAlignmentRows=df(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)}sortRows(t){const e=[],n=[];for(let r of this.packedAlignmentRows){void 0!==r.findAlignment(t.position)?e.push(r):n.push(r)}e.sort(((e,n)=>{const r=t.direction,i=e.getSortValue(t,this),o=n.getSortValue(t,this);if(void 0===o&&void 0!==o)return 1;if(void 0!==i&&void 0===o)return-1;const s=i>o?1:i<o?-1:0;return!0===r?s:-s}));for(let t of n)e.push(t);this.packedAlignmentRows=e}}class gf{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&&uf(t)&&(r=this.pairsCache[t.readName]))return r.setSecondAlignment(t),void(this.pairsCache[t.readName]=void 0);this.alignments.length<this.samplingDepth?this.pairsSupported&&uf(t)?(r=new cf(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&&uf(t)?(void 0!==this.pairsCache[n.readName]&&(this.pairsCache[n.readName]=void 0),r=new cf(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 mf{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 vf(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 vf(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 vf(e.threshold));const n=null==r?"N":r.charAt(o+a),l=t.strand?"pos"+n:"neg"+n,c=i&&o+a<i.length?i[o+a]:30;e.coverage[s][l]+=1,e.coverage[s]["qual"+n]+=c,e.coverage[s].total+=1,e.coverage[s].qual+=c,e.maximum=Math.max(e.coverage[s].total,e.maximum)}}}}class vf{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}hoverText(){const t=this.posA+this.posT+this.posC+this.posG+this.posN,e=this.negA+this.negT+this.negC+this.negG+this.negN;return`${this.total} (${t}+, ${e}-)`}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 bf{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 wf{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=Ff.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 yf(t){return t.split(";").filter((t=>t.length>0)).map((t=>new wf(t)))}const xf={c:1,C:1,s:2,S:2,i:4,I:4,f:4};class _f{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||Sf(this.tagBA)).hasOwnProperty(t)}tags(){return this.tagDict||(this.tagBA?(this.tagDict=Sf(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=yf(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=kf(this.blocks,t);if(e){if("*"===this.seq)return"*";{const n=e.seqIndexAt(t);return this.seq[n]}}}readBaseQualityAt(t){const e=kf(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 kf(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 Sf(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=Cf(t,e),e+=4;else if("c"===o)s=Af(t,e),e++;else if("C"===o)s=Lf(t,e),e++;else if("s"===o||"S"===o)s=Ef(t,e),e+=2;else if("f"===o)s=Tf(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=xf[i];if(void 0===o){r[n]=`Error: unknown element type '${i}'`;break}e+=4+Cf(t,e)*o,s="[not shown]"}}r[n]=s}return r}function Cf(t,e){return t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}function Ef(t,e){return t[e+1]<<8|t[e]}function Tf(t,e){return new DataView(t.buffer).getFloat32(e)}function Af(t,e){return new DataView(t.buffer).getInt8(e)}function Lf(t,e){return new DataView(t.buffer).getUint8(e)}class Mf{constructor(t){t&&Object.assign(this,t)}seqIndexAt(t){return Math.floor(t)-this.start+this.seqOffset}}class Rf{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 If=["=","A","C","x","G","x","x","x","T","x","x","x","x","x","x","N"],Nf=["M","I","D","N","S","H","P","=","X","?","?","?","?","?","?","?"],Of=Bf(new Uint8Array([66,65,77,1]),0),Pf=1e4,Ff={readHeader:function(t,e,n){return To.loadArrayBuffer(t,e).then((function(t){var e;return e=oo(t),Ff.decodeBamHeader(e,n)}))},decodeBamHeader:function(t,e){var n,r,i,o,s;if((n=Bf(t,0))!==Of)throw new Error("BAM header errror: bad magic number. This could be caused by either a corrupt or missing file.");r=Bf(t,4);for(var a=0;a<r;++a)String.fromCharCode(t[a+8]);var l=Bf(t,r+8),c=r+12;for(i={},o=[],s={},a=0;a<l;++a){for(var h=Bf(t,c),u="",f=0;f<h-1;++f)u+=String.fromCharCode(t[c+4+f]);Bf(t,c+h+4),i[u]=a,o[a]=u,e&&(s[e.getChromosomeName(u)]=u),c=c+8+h}return{magicNumber:n,size:c,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 l=String.fromCharCode(t[a+2]);if("B"===l)a+=8+s(l=String.fromCharCode(t[a+3]))*Bf(t,a+4);else if("Z"===l||"H"===l)for(a+=3;0!==t[a++];);else a+=3+s(l)}if(a>=e)return!1;if("B"!==String.fromCharCode(t[a+2])||"I"!==String.fromCharCode(t[a+3]))return!1;var c=Bf(t,a+4),h=a+8;if(h+4*c>e)return!1;var u="",f=0;o.length=0,a=h;for(var d=0;d<c;++d,a+=4){var p=Bf(t,a),g=p>>4,m=Nf[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+Bf(t,e)+4,d=new _f,p=Bf(t,e+4),g=Bf(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=Bf(t,e+12),v=(65280&m)>>8,b=255&m,w=Bf(t,e+16),y=(4294901760&w)>>16,x=65535&w,_=Bf(t,e+20),k=Bf(t,e+24),S=Bf(t,e+28),C=Bf(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 T=0,A="",L=e+36+b;const M=[];let R;for(let e=0;e<x;++e){var l=Bf(t,L),c=l>>4,h=Nf[15&l];"M"!==h&&"EQ"!==h&&"X"!==h&&"D"!==h&&"N"!==h&&"="!==h||(T+=c),A=A+c+h,L+=4,R={len:c,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=A,d.lengthOnRef=T,d.fragmentLength=C,d.mq=v,Ff.bam_tag2cigar(t,f,L,_,d,M),d.end=d.start+d.lengthOnRef,d.end<o){e=f;continue}let I=[];const N=_+1>>1;for(let e=0;e<N;++e){var u=t[L+e];I.push(If[(240&u)>>4]),I.push(If[15&u])}I=I.slice(0,_).join(""),L+=N;const O=[];for(let e=0;e<_;++e)O.push(t[L+e]);L+=_,k>=0&&(d.mate={chr:r[k],position:S,strand:!(32&y)}),d.seq=I,d.qual=O,d.tagBA=new Uint8Array(t.buffer.slice(L,f)),this.setPairOrientation(d),(void 0===a||a.pass(d))&&(Df(d,M),n.push(d)),e=f}},decodeSamRecords:function(t,e,n,r,i,o){var s,a,l,c,h,u,f,d,p,g;for(c=(s=Ce(t)).length,!1,a=0;a<c;a++)if(h=s[a].split("\t"),(p=new _f).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=zf(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=[],l=0;l<u.length;l++)p.qual[l]=u.charCodeAt(l)-33;p.tagDict=h.length<11?{}:Hf(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))&&(Df(p,g),e.push(p))}}},setReaderDefaults:function(t,e){t.filter=new Rf(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>Pf&&(console.log("Warning: attempt to set sampling depth > maximum value of "+Pf),t.samplingDepth=Pf),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,l=t.end-t.start;if(0===a)a=(t.start<n.position?n.position+l:n.position-l)-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 Df(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 Mf({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 Mf({start:s,len:a.len,seqOffset:o,type:"I"})),o+=a.len;break;case"M":case"EQ":case"=":case"X":n.push(new Mf({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 Bf(t,e){return t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}function zf(t){var e,n,r,i,o,s,a,l,c;for(e=[],n=[],o=null,i=t.length,r=0;r<i;r++)s=t.charAt(r),c=void 0,(c=s.charCodeAt(0))>=48&&c<=57?n.push(s):(a=s,l=Number.parseInt(n.join("")),n=[],null!==o&&o.ltr===a?o.len+=l:(o={len:l,ltr:a},e.push(o)));return e}function Hf(t){var e={};return t.forEach((function(t){var n=t.split(":");e[n[0]]=n[2]})),e}class Vf{constructor(t,e){this.config=t,this.genome=e,this.bamPath=t.url,this.isDataUri=Ds(t.url),Ff.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 pf(t,e,n,this.config);for(let t of o)s.push(t);return s.finish(),s}if(this.isDataUri){const r=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),i=oo(r.buffer);return this.parseAlignments(i),this.fetchAlignments(t,e,n)}{const r=oo(await To.loadArrayBuffer(this.bamPath,Is(this.config)));return this.parseAlignments(r),this.fetchAlignments(t,e,n)}}parseAlignments(t){const e=[];this.header=Ff.decodeBamHeader(t),Ff.decodeBamRecords(t,this.header.size,e,this.header.chrNames),this.alignmentCache=new Vo(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 pf(t,e,n,this.config);for(let t of i)o.push(t);return o.finish(),o}}class jf{constructor(t,e){this.config=t,this.genome=e,this.bamPath=t.url,this.baiPath=t.indexURL,Ff.setReaderDefaults(this,t),this._blockLoader=new uc(t)}async readAlignments(t,e,n){const r=(await this.getChrIndex())[this.chrAliasTable.hasOwnProperty(t)?this.chrAliasTable[t]:t],i=new pf(t,e,n,this.config);if(void 0===r)return i;{const t=(await this.getIndex()).chunksForRange(r,e,n);if(!t||0===t.length)return i;for(let o of t){const t=await this._blockLoader.getData(o.minv.block,o.maxv.block);if(Ff.decodeBamRecords(t,o.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=Is(this.config,{range:{start:e.firstBlockPosition,size:26}}),r=so(await To.loadArrayBuffer(this.bamPath,t));n=e.firstBlockPosition+r}else n=64e3;const r=Is(this.config,{range:{start:0,size:n}});this.header=await Ff.readHeader(this.bamPath,r,t)}return this.header}async getIndex(){const t=this.genome;return this.index||(this.index=await oc(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 Uf{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 jf(i,e)}(t,e,r)})),this.bamReaders=n,Ff.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 pf(t,e,n,this.config)}}const qf=function(t,e){this.config=t,this.genome=e,Ff.setReaderDefaults(this,t)};function Wf(){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=Is(this.config);return Ff.readHeader(n,r,e).then((function(e){return t.header=e,e}))}}qf.prototype.readAlignments=function(t,e,n){var r=this;return Wf.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,To.loadString(s,Is(r.config)).then((function(s){var a;return i.chrToIndex[o],a=new pf(t,e,n,r.config),Ff.decodeSamRecords(s,a,o,e,n,r.filter),a}))}))};class $f extends Tc{constructor(t,e){super(t,e),Ff.setReaderDefaults(this,t)}async readAlignments(t,e,n){if(!this.header){const t=oo((await this.readHeaderData()).buffer);this.header=Ff.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=oo((await this.readData(r,e,n)).buffer),o=this.header.chrToIndex[t],s=new pf(t,e,n,this.config);return Ff.decodeBamRecords(i,this.header.size,s,this.header.chrNames,o,e,n),s.finish(),s}}var Gf,Zf,Xf,Yf,Kf={}.propertyIsEnumerable,Qf=Object.getOwnPropertyDescriptor,Jf={f:Qf&&!Kf.call({1:2},1)?function(t){var e=Qf(this,t);return!!e&&e.enumerable}:Kf},td=hh({}.toString),ed=hh("".slice),nd=function(t){return ed(td(t),8,-1)},rd=Object,id=hh("".split),od=th((function(){return!rd("z").propertyIsEnumerable(0)}))?function(t){return"String"==nd(t)?id(t,""):rd(t)}:rd,sd=function(t){return od(dh(t))},ad=Object.getOwnPropertyDescriptor,ld={f:eh?ad:function(t,e){if(t=sd(t),e=_u(e),Fh)try{return ad(t,e)}catch(t){}if(mh(t,e))return Mu(!jh(Jf.f,t,e),t[e])}},cd=function(t,e,n,r){r||(r={});var i=r.enumerable,o=void 0!==r.name?r.name:e;if(oh(n)&&Hu(n,o,r),r.global)i?t[e]=n:_h(e,n);else{try{r.unsafe?t[e]&&(i=!0):delete t[e]}catch(t){}i?t[e]=n:Lu.f(t,e,{value:n,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return t},hd=Math.ceil,ud=Math.floor,fd=Math.trunc||function(t){var e=+t;return(e>0?ud:hd)(e)},dd=function(t){var e=+t;return e!=e||0===e?0:fd(e)},pd=Math.max,gd=Math.min,md=Math.min,vd=function(t){return(e=t.length)>0?md(dd(e),9007199254740991):0;var e},bd=function(t){return function(e,n,r){var i,o=sd(e),s=vd(o),a=function(t,e){var n=dd(t);return n<0?pd(n+e,0):gd(n,e)}(r,s);if(t&&n!=n){for(;s>a;)if((i=o[a++])!=i)return!0}else for(;s>a;a++)if((t||a in o)&&o[a]===n)return t||a||0;return!t&&-1}},wd={includes:bd(!0),indexOf:bd(!1)}.indexOf,yd=hh([].push),xd=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"].concat("length","prototype"),_d=Object.getOwnPropertyNames||function(t){return function(t,e){var n,r=sd(t),i=0,o=[];for(n in r)!mh(Nu,n)&&mh(r,n)&&yd(o,n);for(;e.length>i;)mh(r,n=e[i++])&&(~wd(o,n)||yd(o,n));return o}(t,xd)},kd={f:_d},Sd={f:Object.getOwnPropertySymbols},Cd=hh([].concat),Ed=qh("Reflect","ownKeys")||function(t){var e=kd.f(Hh(t)),n=Sd.f;return n?Cd(e,n(t)):e},Td=function(t,e,n){for(var r=Ed(e),i=Lu.f,o=ld.f,s=0;s<r.length;s++){var a=r[s];mh(t,a)||n&&mh(n,a)||i(t,a,o(e,a))}},Ad=/#|\.prototype\./,Ld=function(t,e){var n=Rd[Md(t)];return n==Nd||n!=Id&&(oh(e)?th(e):!!e)},Md=Ld.normalize=function(t){return String(t).replace(Ad,".").toLowerCase()},Rd=Ld.data={},Id=Ld.NATIVE="N",Nd=Ld.POLYFILL="P",Od=Ld,Pd=ld.f,Fd=function(t,e){var n,r,i,o,s,a=t.target,l=t.global,c=t.stat;if(n=l?Jc:c?Jc[a]||_h(a,{}):(Jc[a]||{}).prototype)for(r in e){if(o=e[r],i=t.dontCallGetSet?(s=Pd(n,r))&&s.value:n[r],!Od(l?r:a+(c?".":"#")+r,t.forced)&&void 0!==i){if(typeof o==typeof i)continue;Td(o,i)}(t.sham||i&&i.sham)&&Ru(o,"sham",!0),cd(n,r,o,t)}},Dd=Function.prototype,Bd=Dd.apply,zd=Dd.call,Hd="object"==typeof Reflect&&Reflect.apply||(sh?zd.bind(Bd):function(){return zd.apply(Bd,arguments)}),Vd=function(t){if("Function"===nd(t))return hh(t)},jd=Vd(Vd.bind),Ud=qh("document","documentElement"),qd=hh([].slice),Wd=TypeError,$d=function(t,e){if(t<e)throw Wd("Not enough arguments");return t},Gd=/(?:ipad|iphone|ipod).*applewebkit/i.test($h),Zd="process"==nd(Jc.process),Xd=Jc.setImmediate,Yd=Jc.clearImmediate,Kd=Jc.process,Qd=Jc.Dispatch,Jd=Jc.Function,tp=Jc.MessageChannel,ep=Jc.String,np=0,rp={},ip="onreadystatechange";try{Gf=Jc.location}catch(Rv){}var op,sp,ap=function(t){if(mh(rp,t)){var e=rp[t];delete rp[t],e()}},lp=function(t){return function(){ap(t)}},cp=function(t){ap(t.data)},hp=function(t){Jc.postMessage(ep(t),Gf.protocol+"//"+Gf.host)};Xd&&Yd||(Xd=function(t){$d(arguments.length,1);var e=oh(t)?t:Jd(t),n=qd(arguments,1);return rp[++np]=function(){Hd(e,void 0,n)},Zf(np),np},Yd=function(t){delete rp[t]},Zd?Zf=function(t){Kd.nextTick(lp(t))}:Qd&&Qd.now?Zf=function(t){Qd.now(lp(t))}:tp&&!Gd?(Yf=(Xf=new tp).port2,Xf.port1.onmessage=cp,op=Yf.postMessage,sp=Yf,lu(op),Zf=void 0===sp?op:sh?jd(op,sp):function(){return op.apply(sp,arguments)}):Jc.addEventListener&&oh(Jc.postMessage)&&!Jc.importScripts&&Gf&&"file:"!==Gf.protocol&&!th(hp)?(Zf=hp,Jc.addEventListener("message",cp,!1)):Zf=ip in Ph("script")?function(t){Ud.appendChild(Ph("script"))[ip]=function(){Ud.removeChild(this),ap(t)}}:function(t){setTimeout(lp(t),0)});var up={set:Xd,clear:Yd},fp=up.clear;Fd({global:!0,bind:!0,enumerable:!0,forced:Jc.clearImmediate!==fp},{clearImmediate:fp});var dp,pp,gp,mp="function"==typeof Bun&&Bun&&"string"==typeof Bun.version,vp=Jc.Function,bp=/MSIE .\./.test($h)||mp&&function(){var t=Jc.Bun.version.split(".");return t.length<3||0==t[0]&&(t[1]<3||3==t[1]&&0==t[2])}(),wp=up.set,yp=Jc.setImmediate?(dp=wp,gp=(pp=!1)?2:1,bp?function(t,e){var n=$d(arguments.length,1)>gp,r=oh(t)?t:vp(t),i=n?qd(arguments,gp):[],o=n?function(){Hd(r,this,i)}:r;return pp?dp(o,e):dp(o)}:dp):wp;Fd({global:!0,bind:!0,enumerable:!0,forced:Jc.setImmediate!==yp},{setImmediate:yp});const xp=eval,_p=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),l=n(20),c=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,_=w?r:y?r[b]:(r[b]||{}).prototype,k=w?s:s[b]||(s[b]={}),S=k.prototype;for(f in e)n=!o(w?f:b+(y?".":"#")+f,t.forced)&&_&&c(_,f),p=k[f],n&&(g=t.noTargetGet?(v=i(_,f))&&v.value:_[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)&&l(m,"sham",!0),k[f]=m,x&&(c(s,u=b+"Prototype")||l(s,u,{}),s[u][f]=d,t.real&&S&&!S[f]&&l(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,l=i("wks");t.exports=function(t){return l[t]||(l[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),l=n(120),c=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 c)return m;return new c(!1)}f=d.call(t)}for(;!(v=f.next()).done;)if((m=l(f,b,v.value,h))&&m instanceof c)return m;return new c(!1)}).stop=function(t){return new c(!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)),l=r(n(265)),c=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,l.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,l.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}(c),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}(c),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}(c);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){
|
|
38
|
+
*/function wa(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 ya(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 xa(t){var e={alphabetic:"alphabetic",hanging:"hanging",top:"text-before-edge",bottom:"text-after-edge",middle:"central"};return e[t]||e.alphabetic}function _a(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]);return[t[0]/e,t[1]/e]}const ka=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),Sa={strokeStyle:{svgAttr:"stroke",canvas:"#000000",svg:"none",apply:"stroke"},fillStyle:{svgAttr:"fill",canvas:"#000000",svg:null,apply:"fill"},lineCap:{svgAttr:"stroke-linecap",canvas:"butt",svg:"butt",apply:"stroke"},lineJoin:{svgAttr:"stroke-linejoin",canvas:"miter",svg:"miter",apply:"stroke"},miterLimit:{svgAttr:"stroke-miterlimit",canvas:10,svg:4,apply:"stroke"},lineWidth:{svgAttr:"stroke-width",canvas:1,svg:1,apply:"stroke"},globalAlpha:{svgAttr:"opacity",canvas:1,svg:1,apply:"fill stroke"},font:{canvas:"10px sans-serif"},shadowColor:{canvas:"#000000"},shadowOffsetX:{canvas:0},shadowOffsetY:{canvas:0},shadowBlur:{canvas:0},textAlign:{canvas:"start"},textBaseline:{canvas:"alphabetic"},lineDash:{svgAttr:"stroke-dasharray",canvas:[],svg:null,apply:"stroke"}};class Ca{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",wa("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 Ea{constructor(t,e){this.__root=t,this.__ctx=e}}class Ta{constructor(t){if(!(this instanceof Ta))return new Ta(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(Sa);for(t=0;t<n.length;t++)this[e=n[t]]=Sa[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(Sa);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,l=Object.keys(Sa);for(r=0;r<l.length;r++)if(i=Sa[l[r]],o=this[l[r]],i.apply)if(o instanceof Ea){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,wa("url(#{id})",{id:o.__root.getAttribute("id")}))}else if(o instanceof Ca)e.setAttribute(i.apply,wa("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 c=i.svgAttr;if("globalAlpha"===l[r]&&(c=t+"-"+i.svgAttr,e.getAttribute(c)))continue;e.setAttribute(c,o)}else{a=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi.exec(o),e.setAttribute(i.svgAttr,wa("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(ka),n=0;n<e.length;n++)r=e[n],i=ka[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 l={x:"0",y:o.toString(),width:r.toString(),height:i.toString()};a.appendChild(this.__createElement("rect",l));const c=this.__createElement("g");c.setAttribute("transform",wa("translate({x},{y})",{x:e,y:n})),c.setAttribute("clip-path",wa("url(#{id})",{id:s}));const h=this.__closestGroupOrSvg();h.appendChild(c),this.__groupStack.push(h),this.__currentElement=c,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 l=this.__createElement("g");this.__rootGroup.appendChild(l),l.setAttribute("transform",wa("translate({x},{y})",{x:e,y:n})),l.setAttribute("id",t+"_group"),l.setAttribute("clip-path",wa("url(#{id})",{id:s})),this.__currentElement=l}scale(t,e){void 0===e&&(e=t),this.__addTransform(wa("scale({x},{y})",{x:t,y:e}))}rotate(t){var e=180*t/Math.PI;this.__addTransform(wa("rotate({angle},{cx},{cy})",{angle:e,cx:0,cy:0}))}translate(t,e){this.__addTransform(wa("translate({x},{y})",{x:t,y:e}))}transform(t,e,n,r,i,o){this.__addTransform(wa("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(wa("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(wa("L {x} {y}",{x:t,y:e})):this.__addPathCommand(wa("M {x} {y}",{x:t,y:e}))}bezierCurveTo(t,e,n,r,i,o){this.__currentPosition={x:i,y:o},this.__addPathCommand(wa("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(wa("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=_a([o-t,s-e]),l=_a([n-t,r-e]);if(a[0]*l[1]!=a[1]*l[0]){var c=a[0]*l[0]+a[1]*l[1],h=Math.acos(Math.abs(c)),u=_a([a[0]+l[0],a[1]+l[1]]),f=i/Math.sin(h/2),d=t+f*u[0],p=e+f*u[1],g=[-a[1],a[0]],m=[l[1],-l[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,l){const c={cx:t,cy:e,rx:n,ry:r},h=this.__createElement("ellipse",c,!0);this.__closestGroupOrSvg().appendChild(h),this.__currentElement=h,this.__applyStyleToCurrentElement(l)}__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:ya(this.__ids),x1:t+"px",x2:n+"px",y1:e+"px",y2:r+"px",gradientUnits:"userSpaceOnUse"},!1);return this.__defs.appendChild(i),new Ca(i,this)}createRadialGradient(t,e,n,r,i,o){var s=this.__createElement("radialGradient",{id:ya(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 Ca(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(),l=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":xa(this.textBaseline)},!0);l.appendChild(this.__document.createTextNode(t)),this.__currentElement=l,this.__applyStyleToCurrentElement(r),a.appendChild(this.__wrapTextLink(s,l))}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),l=t+n*Math.cos(r),c=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(l,c),this.__addPathCommand(wa("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=ya(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",wa("url(#{id})",{id:n})),t.appendChild(r),this.__currentElement=r}drawImage(){var t,e,n,r,i,o,s,a,l,c,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(),this.__currentElement;var v="translate("+t+", "+e+")";if(p instanceof Ta){if((a=p.getSvg().cloneNode(!0)).childNodes&&a.childNodes.length>1){for(l=a.childNodes[0];l.childNodes.length;)f=l.childNodes[0].getAttribute("id"),this.__ids[f]=f,this.__defs.appendChild(l.childNodes[0]);if(c=a.childNodes[1]){var b,w=c.getAttribute("transform");b=w?w+" "+v:v,c.setAttribute("transform",b),s.appendChild(c)}}}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=ya(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 Ta&&(r.appendChild(t.__root.childNodes[1]),this.__defs.appendChild(r)),new Ea(r,this)}setLineDash(t){t&&t.length>0?this.lineDash=t.join(","):this.lineDash=null}drawFocusRing(){}createImageData(){}getImageData(){}putImageData(){}globalCompositeOperation(){}setTransform(){}}const Aa=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 La(){return"2.13.11"}const Ma=Ce,Ra={loadGenome:async function(t){const e=t.cytobandURL,n=t.aliasURL,r=await la(t);let i;n&&(i=await function(t,e){return To.loadString(t,Is(e)).then((function(t){var e=Ma(t),n=[];return e.forEach((function(t){!t.startsWith("#")&&t.length>0&&n.push(t.split("\t"))})),n}))}(n,r.config));const o=new Ia(t,r,i);return e&&(o.cytobands=await async function(t,e,n){let r;if(Ds(t)){const e=ho(t);r="";const n=e.length;for(let t=0;t<n;t++)r+=String.fromCharCode(e[t])}else r=await To.loadString(t,Is(e));const i={};let o,s=[];const a=Ma(r);for(let t of a){var l=t.split("\t"),c=n.getChromosomeName(l[0]);if(o||(o=c),c!==o&&(i[o]=s,s=[],o=c),5===l.length){var h=parseInt(l[1]),u=parseInt(l[2]),f=l[3],d=l[4];s.push(new Aa(h,u,f,d))}}return i}(e,r.config,o)),o},initializeGenomes:async function(t){if(!Ra.KNOWN_GENOMES){const e={};if(!1!==t.loadDefaultGenomes)try{const i=`https://igv.org/genomes/genomes.json?randomSeed=${Math.random().toString(36)}&version=2.13.11`;r(await To.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.13.11`;r(await To.loadJson(s,{}))}catch(a){console.error(a),console.warn("Errors loading default genome definitions.")}}const n=t.genomeList||t.genomes;if(n)if("string"==typeof n){r(await To.loadJson(n,{}))}else r(n);function r(t){return t.forEach((function(t){e[t.id]=t})),e}Ra.KNOWN_GENOMES=e}},isWholeGenomeView:function(t){return"all"===t.toLowerCase()},expandReference:function(t,e){if(ke(e)&&e.startsWith("{"))try{e=JSON.parse(e)}catch(t){}let n;if(ke(e)?n=e:e.genome?n=e.genome:void 0!==e.id&&void 0===e.fastaURL&&(n=e.id),n){const e=Ra.KNOWN_GENOMES[n];return e||t.present(new Error(`Unknown genome id: ${n}`),void 0),e}return e}};class Ia{constructor(t,e,n){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.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 r={},i=this;r.all="all",this.chromosomeNames.forEach((function(t){var e=t.startsWith("chr")?t.substring(3):"chr"+t;r[e.toLowerCase()]=t,"chrM"===t&&(r.mt="chrM"),"MT"===t&&(r.chrm="MT"),r[t.toLowerCase()]=t})),n&&n.forEach((function(t){var e,n;for(n=0;n<t.length;n++)if(i.chromosomes[t[n]]){e=t[n];break}e&&t.forEach((function(t){t!==e&&(r[t.toLowerCase()]=e,r[t]=e)}))})),this.chrAliasTable=r}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.cytobands?this.cytobands[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 Na,Oa=0,Pa=0;class Fa extends ba{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.$viewport)),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>10)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.referenceFrame.chr===this.referenceFrame.chr&&this.canvas._data.bpPerPixel===t.bpPerPixel){const e=Math.round((this.canvas._data.bpStart-t.start)/t.bpPerPixel);this.canvas.style.left=e+"px"}}setTop(t){if(super.setTop(t),this.canvas){const e=this.$viewport.height(),n=t+this.canvas._data.canvasTop,r=t+this.canvas._data.canvasBottom;(n>0||r<e)&&this.repaint()}else this.repaint();let e=t+this.canvas._data.canvasTop;this.canvas.style.top=`${e}px`}async loadFeatures(){const t=this.referenceFrame,e=t.chr,n=this.browser.genome.getChromosome(e).bpLength,r=this.$viewport.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 s=[];if(n.roiSets&&n.roiSets.length>0)for(let r of n.roiSets){const n=await r.getFeatures(e,i,o,t.bpPerPixel);s.push({track:r,features:n})}const a=n&&("wig"===n.type||"merged"===n.type);return this.featureCache=new Da(e,i,o,t.bpPerPixel,r,s,a),this.loading=!1,this.hideMessage(),this.stopSpinner(),this.featureCache}catch(t){this.trackView&&!0!==this.trackView.disposed&&(this.showMessage("Error loading track data"),this.browser.alert.present(t),console.error(t))}finally{this.loading=!1,this.stopSpinner()}}}repaintDimensions(){const t=Ra.isWholeGenomeView(this.referenceFrame.chr),e=t?this.$viewport.width():3*this.$viewport.width(),n=this.referenceFrame.bpPerPixel;return{bpStart:this.referenceFrame.start-(t?0:e/3*n),bpEnd:this.referenceFrame.end+(t?0:e/3*n),pixelWidth:e}}repaint(){if(void 0===this.featureCache)return;const{features:t,roiFeatures:e}=this.featureCache,{bpStart:n,bpEnd:r,pixelWidth:i}=this.repaintDimensions(),o=this.$viewport.height(),s=this.getContentHeight(),a=e?Math.max(s,o):s,l=Math.min(a,3*o);if(0===i||0===l)return void(this.canvas&&pe(this.canvas).remove());const c=Math.max(0,-this.contentTop-o),h=this.referenceFrame.bpPerPixel,u=Math.round((n-this.referenceFrame.start)/h),f=document.createElement("canvas");f.style.position="relative",f.style.display="block",f.style.width=i+"px",f.style.height=l+"px",f.style.left=u+"px",f.style.top=c+"px";const d="FILL"===this.trackView.track.displayMode||!1!==this.trackView.track.supportHiDPI?window.devicePixelRatio:1;f.width=d*i,f.height=d*l;const p=f.getContext("2d");p.scale(d,d),p.translate(0,-c);const g={context:p,pixelXOffset:u,pixelWidth:i,pixelHeight:l,pixelTop:c,bpStart:n,bpEnd:r,bpPerPixel:h,canvasTop:c,canvasBottom:c+l,referenceFrame:this.referenceFrame,selection:this.selection,viewport:this,viewportWidth:this.$viewport.width()};this.draw(g,t,e),this.canvas&&pe(this.canvas).remove(),f._data=g,this.canvas=f,this.$viewport.append(pe(f))}refresh(){if(!this.canvas||!this.featureCache)return;const t=this.canvas._data;t.context.clearRect(0,0,this.canvas.width,this.canvas.height);const{features:e,roiFeatures:n}=this.featureCache;this.draw(t,e,n)}draw(t,e,n){if(e&&(t.features=e,this.trackView.track.draw(t)),n&&n.length>0)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.canvas._data,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.contentTop-e)*n,a=this.canvas.getContext("2d").getImageData(o,s,r,i),l=document.createElement("canvas"),c=l.getContext("2d");l.width=a.width,l.height=a.height,c.putImageData(a,0,0);We((this.$trackLabel.text()?this.$trackLabel.text():"image")+".png",l.toDataURL("image/png"))}saveSVG(){let{width:t,height:e}=this.browser.columnContainer.getBoundingClientRect();const n=new Ta({width:t,height:8e3,backdropColor:"white",multiLocusGap:0,viewbox:{x:0,y:0,width:t,height:8e3}}),r={deltaX:32,deltaY:32};this.renderViewportToSVG(n,r),n.setHeight(e);const i=(this.trackView.track.name||this.trackView.track.id).replace(/\W/g,""),o=this.browser.referenceFrameList.indexOf(this.referenceFrame),s=n.getSerializedSvg(!0),a=URL.createObjectURL(new Blob([s],{type:"application/octet-stream"}));We(`${`${i}_referenceFrame_${o}_guid_${be()}`}.svg`,a)}renderViewportToSVG(t,e){let{deltaX:n,deltaY:r}=e;if(this.$zoomInNotice&&this.$zoomInNotice.is(":visible"))return;const{width:i,height:o}=this.$viewport.get(0).getBoundingClientRect(),s=`${(this.trackView.track.name||this.trackView.track.id).replace(/\W/g,"")}_referenceFrame_${this.browser.referenceFrameList.indexOf(this.referenceFrame)}_guid_${be()}`;this.drawSVGWithContext(t,i,o,s,n,r+this.contentTop,-this.contentTop)}renderSVGContext(t,e){let{deltaX:n,deltaY:r}=e;if(this.renderViewportToSVG(t,{deltaX:n,deltaY:r}),(!this.$zoomInNotice||!this.$zoomInNotice.is(":visible"))&&this.$trackLabel&&!0===this.browser.trackLabelsVisible){const{x:e,y:i,width:o,height:s}=((t,e)=>{const{x:n,y:r,width:i,height:o}=t.getBoundingClientRect(),{x:s,y:a,width:l,height:c}=e.getBoundingClientRect();return{x:s-n,y:a-r,width:l,height:c}})(this.$viewport.get(0),this.$trackLabel.get(0));this.renderTrackLabelSVG(t,n+e,r+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),l=.7*(i-12);t.fillText(this.$trackLabel.text(),a,i-l),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:l}=this.referenceFrame;const c={context:t,viewport:this,referenceFrame:this.referenceFrame,top:s,pixelTop:s,pixelWidth:e,pixelHeight:n,bpStart:a,bpEnd:a+e*l,bpPerPixel:l,viewportWidth:e,selection:this.selection},h=this.featureCache?this.featureCache.features:void 0,u=this.featureCache?this.featureCache.roiFeatures:void 0;this.draw(c,h,u),t.restore()}get cachedFeatures(){return this.featureCache?this.featureCache.features:[]}clearCache(){this.featureCache=void 0,this.canvas&&(this.canvas._data=void 0)}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.bpStart||this.referenceFrame.end>t.bpEnd||this.referenceFrame.chr!==t.referenceFrame.chr||this.referenceFrame.bpPerPixel!=t.bpPerPixel}needsReload(){if(!this.featureCache)return!0;const{chr:t,bpPerPixel:e}=this.referenceFrame,{bpStart:n,bpEnd:r}=this.repaintDimensions();return!this.featureCache.containsRange(t,n,r,e)}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),"function"==typeof this.trackView.track.hoverText&&t.addEventListener("mousemove",(t=>{if(0===t.buttons&&Date.now()-Pa>100){Pa=Date.now();const e=this.createClickState(t);if(e){const t=this.trackView.track.hoverText(e);t?this.$viewport[0].setAttribute("title",t):this.$viewport[0].removeAttribute("title")}}})),this.addViewportClickHandler(this.$viewport.get(0)),this.trackView.track.name&&"sequence"!==this.trackView.track.config.type&&this.addTrackLabelClickHandler(this.$trackLabel.get(0))}addViewportContextMenuHandler(t){t.addEventListener("contextmenu",(t=>{if(this.browser.dragObject)return!1;const e=this.createClickState(t);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.savePNG()}),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){Na&&(window.clearTimeout(Na),Na=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((t=>{let{locusSearchString:e}=t;return e}));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&&(Na=setTimeout((()=>{const e=this.getPopupContent(t);e&&(this.popover&&this.popover.dispose(),this.popover=new ks(this.browser.columnContainer),this.popover.presentContentWithEvent(t,e)),window.clearTimeout(Na),Na=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 ks(this.browser.columnContainer,e.name||""),this.popover.presentContentWithEvent(t,n))}))}createClickState(t){if(!this.canvas)return;const e=this.referenceFrame,n=we(t,this.$viewport.get(0)),r=we(t,this.canvas),i=e.start+e.toBP(n.x);return{event:t,viewport:this,referenceFrame:e,genomicLocation:i,y:n.y-this.contentTop,canvasX:r.x,canvasY:r.y}}getPopupContent(t){const e=this.createClickState(t);if(void 0===e)return;let n=this.trackView.track;const r=n.popupData(e),i=this.browser.fireEvent("trackclick",[n,r]);let o;return void 0===i||!0===i?r&&r.length>0&&(o=r.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 i&&(o=i),o}}class Da{constructor(t,e,n,r,i,o,s){this.chr=t,this.bpStart=e,this.bpEnd=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.bpStart&&n<=this.bpEnd&&t===this.chr&&i>.5&&i<2}overlapsRange(t,e,n){return this.chr===t&&n>=this.bpStart&&e<=this.bpEnd}}function Ba(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 za=new Set(["transcript","primary_transcript","processed_transcript","mRNA","mrna","lnc_RNA","miRNA","ncRNA","rRNA","scRNA","snRNA","snoRNA","tRNA"]),Ha=new Set(["CDS","cds"]),Va=new Set(["start_codon","stop_codon"]),ja=new Set(["5UTR","3UTR","UTR","five_prime_UTR","three_prime_UTR","3'-UTR","5'-UTR"]),Ua=new Set(["exon","coding-exon"]),qa=new Set;for(let Lv of[Ha,Va,ja,Ua])for(let Mv of Lv)qa.add(Mv);function Wa(t){return t.includes("intron")}function $a(t){return Ha.has(t)||Va.has(t)}function Ga(t){return ja.has(t)}function Za(t){return za.has(t)||t.endsWith("RNA")||t.endsWith("transcript")}function Xa(t){return qa.has(t)||t.endsWith("RNA")||Wa(t)}const Ya=new Set(["id","parent","name"]);class Ka{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=nl(this.attributeString,this.delim);for(let[n,r]of t)void 0!==r&&r.length>0&&!Ya.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=nl(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 Qa extends Ka{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(!Wa(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;$a(e)?this.addCDS(t):Ga(e)&&this.addUTR(t)}}findExonContaining(t){let{start:e,end:n}=t;for(let t of this.exons)if(t.end>=n&&t.start<=e)return t}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 Ja(t,e){const n=e.format;if(t.length<9)return;const r="gff3"===n?"=":" ";return new Ka({source:ol(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 tl(t,e){const n=Ja(t,e);if(!n)return;const r=nl(n.attributeString,n.delim);for(let[t,e]of r){const r=t.toLowerCase();"color"===r||"colour"===r?n.color=vo.createColorString(e):"ID"===t?n.id=e:"Parent"===t&&(n.parent=e)}return n}function el(t,e){const n=Ja(t,e);if(!n)return;const r=nl(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=vo.createColorString(e):t===i?n.id=e:t===o&&(n.parent=e)}return n}function nl(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=rl(ol(r.substring(t+1).trim()));n.push([e,i])}}return n}function rl(t){return t.startsWith('"')&&t.endsWith('"')&&(t=t.substr(1,t.length-2)),t}const il=new Map([["%09","\t"],["%0A","\n"],["%0D","\r"],["%25","%"],["%3B",";"],["%3D","="],["%26","&"],["%2C",","]]);function ol(t){if(!t.includes("%"))return t;let e="";for(let n=0;n<t.length;n++)if(37===t.charCodeAt(n)&&n<t.length-2){const r=t.substring(n,n+3);il.has(r)?e+=il.get(r):e+=r,n+=2}else e+=t.charAt(n);return e}class sl{constructor(t){this.message=t}}function al(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 sl("Unparsable bed record.");const o=new vl({chr:n,start:r,end:i,score:1e3});try{if(t.length>3){if(t[3].indexOf(";")>0&&t[3].indexOf("=")>0){const n=nl(t[3],"=");o.attributes={};for(let t of n)o.attributes[t[0]]=t[1],null!=e.nameField&&t[0]===e.nameField&&(o.name=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=vo.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})}fl(s,o.cdStart,o.cdEnd),o.exons=s}if(e){let n=e.thicknessColumn,r=e.colorColumn;r&&r<t.length&&(o.color=vo.createColorString(t[r])),n&&n<t.length&&(o.thickness=t[n])}}catch(t){}return o}function ll(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 cl(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(","),l=t[9+n].split(","),c=[];for(let t=0;t<s;t++){const e=parseInt(a[t]),n=parseInt(l[t]);c.push({start:e,end:n})}return fl(c,r,i),o.exons=c,o}function hl(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(","),l=t[9+n].split(","),c=[];for(let t=0;t<s;t++){const e=parseInt(a[t]),n=parseInt(l[t]);c.push({start:e,end:n})}return fl(c,r,i),o.exons=c,o}function ul(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(","),l=t[10+n].split(","),c=[];for(let t=0;t<s;t++){const e=parseInt(a[t]),n=parseInt(l[t]);c.push({start:e,end:n})}return fl(c,r,i),o.exons=c,o}function fl(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 dl(t,e){var n,r,i,o,s,a,l;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(),l=Number(t[6]),0===a&&(a=l),{chr:n,start:r,end:i,name:s,score:a,strand:o,signal:l,pValue:Number(t[7]),qValue:Number(t[8])}}function pl(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=vo.createColorString(t[r]))}return n}function gl(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 pl(t)}function ml(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 vl{constructor(t){Object.assign(this,t)}getAttributeValue(t){return this.hasOwnProperty(t)?this[t]:this.attributes?this.attributes[t]:void 0}}function bl(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]),l=t[6],c={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=l.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),c.spanning_frag_coords.push({left:g,right:m})}return c.start=h,c.end=u,c}}function wl(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 yl(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 xl(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 _l{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=kl(n);Object.assign(r,t)}else if(n.startsWith("browser"));else if(n.startsWith("#columns")){let t=Sl(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=Cl(o);continue}if("wig"===r&&o.startsWith("variableStep")){this.header.wig=El(o);continue}const t=o.split(i);if(t.length<1)continue;const l=n(t,this.header);l instanceof sl?(a++,a>0&&console.error(`Error parsing line '${o}': ${l.message}`)):l&&e.push(l)}return n===js&&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=dl,this.delimiter=this.config.delimiter||/\s+/;break;case"bedgraph":this.decode=pl,this.delimiter=/\s+/;break;case"wig":this.decode=gl,this.delimiter=this.config.delimiter||/\s+/;break;case"gff3":case"gff":this.decode=tl,this.delimiter="\t";break;case"gtf":this.decode=el,this.delimiter="\t";break;case"fusionjuncspan":this.decode=bl,this.delimiter=this.config.delimiter||/\s+/;break;case"gtexgwas":this.skipRows=1,this.decode=wl,this.delimiter="\t";break;case"refflat":this.decode=ul,this.delimiter=this.config.delimiter||/\s+/;break;case"genepred":this.decode=cl,this.delimiter=this.config.delimiter||/\s+/;break;case"genepredext":this.decode=hl,this.delimiter=this.config.delimiter||/\s+/;break;case"ensgene":this.decode=cl,this.header.shift=1,this.delimiter=this.config.delimiter||/\s+/;break;case"refgene":this.decode=hl,this.delimiter=this.config.delimiter||/\s+/,this.header.shift=1;break;case"bed":this.decode=al,this.delimiter=this.config.delimiter||/\s+/;break;case"bedpe":case"hiccups":this.decode=js,this.delimiter=this.config.delimiter||"\t";break;case"bedpe-domain":this.decode=Us,this.headerLine=!0,this.delimiter=this.config.delimiter||"\t";break;case"bedpe-loop":this.decode=js,this.delimiter=this.config.delimiter||"\t",this.header={colorColumn:7};break;case"interact":this.decode=Ba,this.delimiter=this.config.delimiter||/\s+/;break;case"snp":this.decode=ml,this.delimiter="\t";break;case"rmsk":this.decode=ll,this.delimiter="\t";break;case"gcnv":this.decode=xl,this.delimiter="\t";break;default:const e=function(t){return Ms&&Ms[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}(Ms[t]):void 0}(t);void 0!==e?(this.decode=yl,this.header.customFormat=e,this.delimiter=e.delimiter||"\t"):(this.decode=al,this.delimiter=this.config.delimiter||/\s+/)}}}function kl(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 Sl(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 Cl(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 El(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}}const Tl=t=>ke(t)&&t.indexOf(",")>0&&!t.startsWith("rgb(")&&!t.startsWith("rgba(")?`rgb(${t})`:t;class Al{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:ke(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=Tl(t.color)),t.altColor&&(this.altColor=Tl(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),t.hoverTextFields?this.hoverText=Ll.bind(this):"function"==typeof this.config.hoverText&&(this.hoverText=this.config.hoverText)}get name(){return this._name}set name(t){this._name=t,this.trackView&&this.trackView.setTrackLabelName(t)}updateConfig(t){this.init(t)}clearCachedFeatures(){this.trackView&&this.trackView.clearCachedFeatures()}updateViews(){this.trackView&&this.trackView.updateViews()}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&&(Rs(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){if(this.disposed)return;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];Ml.has(i)?e[r]=Ml.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){const e=t.viewport.cachedFeatures;if(!e||!Array.isArray(e)||0===e.length)return[];const n=t.genomicLocation,r=t.referenceFrame.bpPerPixel>.2?3*t.referenceFrame.bpPerPixel:.2;return qo(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)&&Rs(t[e])){let n=t[e];r.push({name:Te(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=Al.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&&Rs(r)&&(e+=t(n,r))}}}return e+="</div>",e}dispose(){this.disposed=!0;for(let t of Object.keys(this))this[t]=void 0}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>`}}}function Ll(t){if(!this.hoverTextFields)return;const e=this.clickedFeatures(t);if(e&&e.length>0){let t="";for(let n=0;n<e.length;n++){if(10===n){t+="; ...";break}if(!e[n])continue;const r=e[n]._f||e[n];t.length>0&&(t+="\n"),t="";for(let e of this.hoverTextFields)t.length>0&&(t+="\n"),r.hasOwnProperty(e)?t+=r[e]:"function"==typeof r.getAttribute&&(t+=r.getAttribute(e))}return t}}const Ml=new Map([["wiggle_0","wig"],["bed","bed"],["bigBed","bigBed"],["bigWig","bigWig"]]);class Rl{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 Il({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 Il{constructor(t){let{sample:e,chr:n,start:r,end:i,value:o,valueColumnName:s}=t;this.sample=e,this.chr=n,this.start=r,this.end=i,this.value=o,this.valueColumnName=s}setAttributes(t){let{names:e,values:n}=t;this.attributeNames=e,this.attributeValues=n}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?Te(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:Te(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 Al.getCravatLink(this.chr,this.start+1,e,n,t)}}function Nl(t){const e=new Ol;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 Ol{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&&Fl(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:"ID",value:this.names?this.names:""},{name:"Ref",value:this.referenceBases},{name:"Alt",value:this.alternateBases.replace("<","<")},{name:"Qual",value:this.quality},{name:"Filter",value:this.filter}];if("SNP"===this.type){let t=this.referenceBases;if(1===t.length){let n=this.alternateBases.split(",");for(let r of n)if(1===r.length){let n=Al.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:Dl(decodeURIComponent(this.info[t]))})}return i}getInfo(t){return this.info?this.info[t]:void 0}isRefBlock(){return"NONVARIANT"===this.type}}const Pl=new Set(["A","C","T","G"].map((t=>t.charCodeAt(0))));function Fl(t){for(let e=0;e<t.length;e++)if(!Pl.has(t.charCodeAt(e)))return!1;return!0}function Dl(t,e){return void 0===e&&(e=","),Array.isArray(t)?t.join(e):t}class Bl{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 l=Ee(r.substring(e+1,s-1),",");for(let e of l){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=Nl(t);if(r.header=this.header,e.push(r),t.length>9){const e=zl(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(Hl(r))}}return e}}function zl(t){const e={genotypeIndex:-1,fields:t};for(let n=0;n<t.length;n++)"GT"===t[n]&&(e.genotypeIndex=n);return e}function Hl(t){const e=t.info.CHR2,n=Number.parseInt(t.info.END);return{chr:e,start:n-1,end:n,_f:t}}class Vl{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.valueCol=t.columns.value-1}else this.posCol=2,this.chrCol=1,this.valueCol=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 jl({chr:n,start:i,end:o,value:s,line:r,columns:this.columns}))}}return e}}class jl{constructor(t){let{chr:e,start:n,end:r,value:i,line:o,columns:s}=t;this.chr=e,this.start=n,this.end=r,this.value=i,this.line=o,this.columns=s}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 Ul=new RegExp("([^:]*)\\(([^)]*)\\)"),ql=new RegExp("([^:]*):([^(]*)\\(([^)]*)\\)");class Wl{constructor(t){const e=t?t.decode:void 0;this.nameField=t?t.nameField:void 0,this.skipRows=0,this.decode=e||Kl,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=Zl(e);n?Object.assign(n,t):n=t}else if(e.startsWith("#columns")){let t=Xl(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=Gl(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 $l(t){var e=ql.exec(t);if(e)return{namespace:e[1],name:e[2],type:e[3]};if(e=Ul.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 Gl(t){var e,n,r;for(e={columns:[],metadata:{}},n=0;n<t.length;n++)r=$l(t[n]),e.columns.push(r);return e}function Zl(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 Xl(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 Yl(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=vo.createColorString(n))}}function Kl(t,e){var n,r,i,o,s,a,l=0,c=this.aed.columns;if(t.length===c.length){for(a=0;a<t.length;a++)o=c[a],""!==(i=t[a])&&l++,"name"===o.name&&"aed"===o.namespace?n=i:"value"===o.name&&"aed"===o.namespace&&(r=i);if(2===l&&n&&r)return s=$l(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 Yl(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(","))}Yl.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 Ql{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 Jl(n,e)}}class Jl{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}isEqualTo(t){return this.block===t.block&&this.offset===t.offset}print(){return this.block+":"+this.offset}}function tc(t,e){if(0===t.length)return t;if(t.sort((function(t,e){const n=t.minv.block-e.minv.block;return 0!==n?n:t.minv.offset-e.minv.offset})),t.length<=1)return t;e&&(t=t.filter((t=>t.maxv.isGreaterThan(e))));const n=[];let r;for(let e of t)r&&ec(r,e)?e.maxv.isGreaterThan(r.maxv)&&(r.maxv=e.maxv):(n.push(e),r=e);return n}function ec(t,e){const n=e.minv.block-t.maxv.block,r=t.maxv.block-t.minv.block;return n<65e3&&r<5e6}class nc{constructor(t){this.tabix=!0}parse(t,e){const n=new Ql(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)}chunksForRange(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];for(let n of e){const e=n[0],r=n[1];i.push({minv:e,maxv:r,bin:t})}}return tc(i,r.loffset[t[0]])}return[]}reg2bins(t,e){(t-=1)<1&&(t=1),e>2**34&&(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);o.push([n,s])}return o}bin_limit(){return((1<<3*(this.depth+1))-1)/7}}class rc{constructor(){}async parse(t,e,n){const r=[];let i=Number.MAX_SAFE_INTEGER,o=0;const s=new Ql(new DataView(t)),a=s.getInt(),l={};if(!(21578050===a||e&&21578324===a))throw new Error(indexURL+" is not a "+(e?"tabix":"bai")+" file");{const t=s.getInt();if(e){s.getInt(),s.getInt(),s.getInt(),s.getInt(),s.getInt(),s.getInt(),s.getInt();for(let e=0;e<t;e++){let t=s.getString();n&&(t=n.getChromosomeName(t)),l[t]=e}}for(let e=0;e<t;e++){const t={},n=[],a=s.getInt();for(let e=0;e<a;e++){const e=s.getInt();if(37450===e)s.getInt(),s.getVPointer(),s.getVPointer(),s.getLong(),s.getLong();else{t[e]=[];const n=s.getInt();for(let r=0;r<n;r++){const n=s.getVPointer(),r=s.getVPointer();n&&r&&(n.block<i&&(i=n.block),r.block>o&&(o=r.block),t[e].push([n,r]))}}}const l=s.getInt();for(let t=0;t<l;t++){const t=s.getVPointer();n.push(t)}a>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)}chunksForRange(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];for(let t of e){const e=t[0],n=t[1];i.push({minv:e,maxv:n})}}const o=r.linearIndex.length;let s;const a=Math.min(e>>14,o-1),l=Math.min(n>>14,o-1);for(let t=a;t<=l;t++){const e=r.linearIndex[t];if(e){s=e;break}}return tc(i,s)}return[]}}class ic{constructor(){}async parse(t,e){let n=0;this.chrIndex={},this.lastBlockPosition=[];const r=new Ql(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 l=[];for(let t=0;t<o;t++){const t=r.getLong();l.push({min:a,max:t}),a=t,t>n&&(n=t)}this.chrIndex[t]={chr:t,blocks:l,longestFeature:s,binWidth:i}}this.lastBlockPosition=n}get chromosomeNames(){return Object.keys(this.chrIndex)}chunksForRange(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 oc(t,e,n){let r=await To.loadArrayBuffer(t,Is(e)),i=new DataView(r);if(31===i.getUint8(0)&&139===i.getUint8(1)){r=oo(r).buffer,i=new DataView(r)}switch(i.getInt32(0,!0)){case 21578050:return async function(t,e){const n=new rc;return await n.parse(t,!1,e),n}(r,n);case 21578324:return async function(t,e){const n=new rc;return await n.parse(t,!0,e),n}(r,n);case 21582659:return async function(t,e){const n=new nc;return n.parse(t,e),n}(r,n);case 1480870228:return async function(t,e){const n=new ic;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}`)}}function sc(t){return"string"==typeof t||t instanceof String?new ac(t):new lc(t)}class ac{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 lc{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 cc{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=Is(this.config,{range:{start:this.filePtr,size:26}}),e=so(await To.loadArrayBuffer(this.config.url,t));if(0===e)this.eof=!0,this.buffer=void 0;else{const t=Is(this.config,{range:{start:this.filePtr,size:e}}),n=await To.loadArrayBuffer(this.config.url,t);n.byteLength<e&&(this.eof=!0),this.buffer=oo(n),this.bufferPtr=0,this.filePtr+=n.byteLength}}}const hc=t=>{const e=ArrayBuffer.isView(t)?t:new Uint8Array(t);return 1+(e[17]<<8|e[16])};class uc{constructor(t){this.config=t,this.cacheBlocks=0!=t.cacheBlocks,this.cache=void 0}async getData(t,e){const n=t.block,r=e.block,i=0===e.offset,o=await this.getInflatedBlocks(n,r,i);if(1===o.length)return o[0];let s=0;for(const t of o)s+=t.byteLength;const a=new Uint8Array(s);let l=0;for(const t of o)a.set(t,l),l+=t.byteLength;return a}async getInflatedBlocks(t,e,n){if(this.cacheBlocks){const r=this.cache;if(r&&r.startBlock<=t&&(r.endBlock>=e||n&&r.nextEndBlock===e)){console.log("Complete overlap");const n=t-r.startBlock,i=e-r.startBlock;return dc(r.buffer,n,i)}{let i;if(!r||r.startBlock>e||r.endBlock<t)i=await this.loadBLockData(t,e,{skipEnd:n});else{const o=[];if(t<r.startBlock){const e=await this.loadBLockData(t,r.startBlock,{skipEnd:!0});o.push(e)}let s;if(t<=r.startBlock&&e>=r.endBlock)s=r.buffer;else{const n=Math.max(0,t-r.startBlock);let i;if(e>=r.endBlock)i=r.buffer.byteLength;else{const t=fc(r.buffer);for(let n=0;n<t.length-1;n++)if(r.startBlock+t[n]===e){i=t[n+1];break}}s=r.buffer.slice(n,i)}if(o.push(s),e>r.endBlock){const t=await this.loadBLockData(r.endBlock,e,{skipStart:!0,skipEnd:n});o.push(t)}i=function(t){if(1===t.length)return t[0];let e=0;for(const n of t)e+=n.byteLength;const n=new Uint8Array(e);let r=0;for(const e of t)n.set(new Uint8Array(e),r),r+=e.byteLength;return n.buffer}(o)}let o=e;if(n){const t=fc(i);e=t[t.length-1]}return this.cache={startBlock:t,endBlock:e,nextEndBlock:o,buffer:i},dc(i)}}return dc(await this.loadBLockData(t,e,{skipEnd:n}))}async loadBLockData(t,e,n){const r=this.config,i=n&&n.skipStart;let o=0;if(!(n&&n.skipEnd)){const t=Is(r,{range:{start:e,size:26}}),n=await To.loadArrayBuffer(r.url,t);o=hc(n)}if(i){const e=Is(r,{range:{start:t,size:26}}),n=await To.loadArrayBuffer(r.url,e);t+=hc(n)}const s=Is(r,{range:{start:t,size:e+o-t}});return To.loadArrayBuffer(r.url,s)}}function fc(t){const e=t.byteLength;let n=0;const r=[0];for(;n<e;){const i=new Uint8Array(t,n);n+=1+(i[17]<<8|i[16]),n<e&&r.push(n)}return r}function dc(t,e,n){const r=[];let i=e=e||0;const o=t.byteLength-18;for(;i<o;)try{const e=new Uint8Array(t,i,18),o=e[11]<<8|e[10],s=e[17]<<8|e[16],a=12+o+i,l=t.byteLength-a,c=s-o-18;if(l<c||c<=0)break;const h=new Uint8Array(t,a,c),u=ro(h);if(r.push(u),n===i)break;i+=s+1}catch(t){console.error(t);break}return r}class pc{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:Ds(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)this._blockLoader=new uc(this.config),e=new cc(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=Is(this.config,{bgz:t.tabix,range:{start:0,size:n}});e=sc(await To.loadString(this.config.url,r))}return this.header=await this.parser.parseHeader(e),this.header}{const t=Is(this.config),e=await To.loadString(this.config.url,t);let n=sc(e);return this.header=await this.parser.parseHeader(n),n=sc(e),this.features=await this.parser.parseFeatures(n),this.header}}getParser(t){switch(t.format){case"vcf":return new Bl(t);case"seg":return new Rl("seg");case"mut":return new Rl("mut");case"maf":return new Rl("maf");case"gwas":return new Vl(t);case"aed":return new Wl(t);default:return new _l(t)}}async loadFeaturesNoIndex(){if(this.features){const t=this.features;return delete this.features,t}{const t=Is(this.config),e=await To.loadString(this.config.url,t);if(!this.header){const t=sc(e);this.header=await this.parser.parseHeader(t)}const n=sc(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,l=this.index.chunksForRange(s,e,n);if(l&&0!==l.length){const s=[];for(let c of l){let l;if(o)l=await this._blockLoader.getData(c.minv,c.maxv);else{const t=Is(r,{range:{start:c.minv.block,size:c.maxv.block-c.minv.block+1}});l=await To.loadString(r.url,t)}const h=sc(c.minv.offset?l.slice(c.minv.offset):l);let u=await i.parseFeatures(h);u=u.filter((t=>void 0===t._f));let f=!1;for(let r=0;r<u.length;r++){const i=u[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&&(f||(f=!0,r>0&&s.push(u[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 oc(this.config.indexURL,this.config,this.genome)}async loadFeaturesFromDataURI(){if(this.features){const t=this.features;return delete this.features,t}{const t=ho(this.dataURI);let e=sc(t);return this.header=await this.parser.parseHeader(e),this.header instanceof String&&this.header.startsWith("##gff-version 3")&&(this.format="gff3"),e=sc(t),this.features=await this.parser.parseFeatures(e),this.features}}}const gc=ke;class mc{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 To.load(r,o);if(s&&(i="function"==typeof this.config.parser?this.config.parser(s):gc(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 vc=function(t,e){this.config=t,this.genome=e,this.expandQueryInterval=!1};vc.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 To.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 l={start:o=parseInt(n[a]),end:s=parseInt(r[a])};(t.cdsStart>s||t.cdsEnd<t.cdsStart)&&(l.utr=!0),t.cdsStart>=o&&t.cdsStart<=s&&(l.cdStart=t.cdsStart),t.cdsEnd>=o&&t.cdsEnd<=s&&(l.cdEnd=t.cdsEnd),i.push(l)}t.exons=i}(t)})),t):null}))};const bc=["Name","gene_name","gene","gene_id","alias","locus","name"];class wc{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(Xa(r.type)||Za(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(),Za(e.type)){const t=e.id;if(void 0!==t){const s=new Qa(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(Xa(e.type)){const t=c(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 Qa(t),r[n]=s,i.push(s)}if(void 0!==s){if(a=e.type,Ua.has(a))if(t.length>1){const t=new Ka(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 l=t.filter((t=>!o.has(t)));for(let t of l)i.push(t);return i;function c(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=nl(e.attributeString,t),r=new Map(n);if(this.nameField)e.name=r.get(this.nameField);else for(let t of bc)if(r.has(t)){e.name=r.get(t);break}}}}const yc=function(t){this.config=t,this.url=t.url,this.tissueId=t.tissueSiteDetailId,this.indexed=!0,this.datasetId=t.datasetId||"gtex_v8"};yc.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 l=await To.loadJson(a,{withCredentials:this.config.withCredentials});return l&&l.singleTissueEqtl?(l.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})),l.singleTissueEqtl):void 0};const xc=function(t){this.config=t,this.url=t.url,this.cellConditionId=t.cellConditionId,this.valueThreshold=t.valueThreshold?t.valueThreshold:.05};xc.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){To.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 _c=To.apiKey;function kc(t){var e=t.url+"/"+t.entity+"/"+t.entityId;return t.headers={"Cache-Control":"no-cache"},To.loadJson(e,t)}function Sc(t){return new Promise((function(e,n){var r=t.results?t.results:[],i=t.url,o=t.body,s=t.decode,a="?",l=t.fields;return _c&&(i=i+a+"key="+_c,a="&"),l&&(i=i+a+"fields="+l),function t(a){a?o.pageToken=a:void 0!==o.pageToken&&delete o.pageToken;var l=JSON.stringify(o);To.loadJson(i,{sendData:l,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)}))}()}))}const Cc=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};Cc.prototype.readHeader=function(){var t=this;return t.header?Promise.resolve(t.header):(t.header={},!1===t.includeCalls?Promise.resolve(t.header):Sc({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})))},Cc.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 Sc({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 Ol;return n.chr=t.referenceName,n.start=parseInt(t.start),n.end=parseInt(t.end),n.pos=n.start+1,n.names=Dl(t.names,"; "),n.referenceBases=t.referenceBases,n.alternateBases=Dl(t.alternateBases),n.quality=t.quality,n.filter=Dl(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}})}))},Cc.prototype.readMetadata=function(){return kc({url:this.url,entity:"variantsets",entityId:this.variantSetId})};class Ec{constructor(t){this.config=t}async readFeatures(t,e,n){const r=(await To.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 Tc(e.chromosome,e.start-1,e.stop,t)),e.chromosome2&&i.push(new Tc(e.chromosome2,e.start2-1,e.stop2,t))}return i}}class Tc{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>"}}}class Ac{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=`${Lc(this.config)}?class=header&format=${this.format}`,e=await To.loadJson(t,Is(this.config));return await this.loadUrls(e.htsget.urls)}async readData(t,e,n){const r=`${Lc(this.config)}?format=${this.format}&referenceName=${t}&start=${Math.floor(e)}&end=${Math.ceil(n)}`,i=await To.loadJson(r,Is(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(Mc(n.url)));else{const t=Is(this.config||{});n.headers&&(t.headers=Object.assign(t.headers||{},n.headers)),e.push(To.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=Lc(t),n=`${e}${e.includes("?")?"&":"?"}class=header`,r=await To.loadJson(n,Is(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 Ps(t.url))}}catch(t){}}}function Lc(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 Mc(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 Rc extends Ac{constructor(t,e){super(t,e),this.parser=new Bl}async readHeader(){if(!this.header){const t=sc(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=sc(await this.readData(r,e,n));return this.parser.parseFeatures(i)}}function Ic(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}}function Nc(t,e,n){const r=n||1e4,i=t=>{const n=Object.assign({},t);return n.chr="all",n.start=e.getGenomeCoordinate(t.chr,t.start),n.end=e.getGenomeCoordinate(t.chr,t.end),n._f=t,n.exons&&delete n.exons,n},o=new Set(e.wgChromosomeNames),s=[];let a=0;for(let n of e.wgChromosomeNames){if(Array.isArray(t)){const n={};for(let r of t){const t=e.getChromosomeName(r.chr);n.hasOwnProperty(t)||(n[t]=[]),n[t].push(r)}t=n}const l=t[n];if(l)for(let t of l){let n=e.getChromosomeName(t.chr);if(o.has(n))if(s.length<r)s.push(i(t));else{const e=r/(a+1);if(Math.random()<e){s[Math.floor(Math.random()*(r-1))]=i(t)}}a++}}return s.sort((function(t,e){return t.start-e.start})),s}function Oc(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)Ic(n[t],e)}class Pc{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"]);t.reader?(this.reader=t.reader,this.queryable=!1!==t.queryable):"ga4gh"===t.sourceType?(this.reader=new Cc(t,e),this.queryable=!0):"immvar"===t.sourceType?(this.reader=new xc(t),this.queryable=!0):"eqtl"===t.type&&"gtex-ws"===t.sourceType?(this.reader=new yc(t),this.queryable=!0):"htsget"===t.sourceType?this.reader=new Rc(t,e):"ucscservice"===t.sourceType?(this.reader=new vc(t.source),this.queryable=!0):"custom"===t.sourceType?(this.reader=new mc(t.source),this.queryable=!1!==t.source.queryable):"civic-ws"===t.sourceType?(this.reader=new Ec(t),this.queryable=!1):(this.reader=new pc(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(t){let{chr:e,start:n,end:r,bpPerPixel:i,visibilityWindow:o}=t;const s=this.genome,a=s?s.getChromosomeName(e):e,l="all"===a.toLowerCase();return(l&&!this.wgFeatures&&this.supportsWholeGenome()||this.config.disableCache||!this.featureCache||!this.featureCache.containsRange(new na(a,n,r)))&&await this.loadFeatures(a,n,r,o),l?(this.wgFeatures||(this.supportsWholeGenome()?this.wgFeatures=Nc(this.featureCache.getAllFeatures(),this.genome,this.maxWGCount):this.wgFeatures=[]),this.wgFeatures):this.featureCache.queryFeatures(a,n,r)}supportsWholeGenome(){return!this.queryable}getAllFeatures(){return this.queryable||!this.featureCache?[]: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 l=this.queryable?new na(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 wc(this.config).combineFeatures(a,l)),"wig"!==this.config.format&&"junctions"!==this.config.type){Oc(a,this.config.maxRows||Number.MAX_SAFE_INTEGER)}this.featureCache=new Vo(a,this.genome,l),(this.config.searchable||this.config.searchableFields)&&this.addFeaturesToDB(a)}else this.featureCache=new Vo([],l)}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)}}}class Fc{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 To.loadArrayBuffer(this.path,Is(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)}}let Dc=512e3;class Bc{constructor(t,e){this.path=t.url,this.format=t.format||"bigwig",this.genome=e,this.rpTreeCache={},this.config=t,this.loader=Ds(this.path)?new Xc(this.path):To}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 l,c;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?(l=e.indexOffset,c=Zc):(l=this.header.fullIndexOffset,c=$c)}else l=this.header.fullIndexOffset,c=Gc.call(this);const h=await this.loadRPTree(l),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,l=await this.loader.loadArrayBuffer(this.config.url,Is(this.config,{range:{start:t,size:i}})),h=[];for(let n of u){const i=new Uint8Array(l,n.dataOffset-t,n.dataSize);let u;u=this.header.uncompressBuffSize>0?io(i):i,c.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,Is(this.config,{range:{start:0,size:64}}));this.littleEndian=!0;let n=new Ql(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,Is(this.config,{range:o}));const s=t.nZoomLevels;n=new Ql(new DataView(e)),this.zoomLevelHeaders=[],this.firstZoomDataOffset=Number.MAX_SAFE_INTEGER;for(let t=1;t<=s;t++){const e=s-t,r=new zc(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 qc(n)),!(t.chromTreeOffset>0))throw"BigWig chromosome tree offset <= 0";return n.position=t.chromTreeOffset-i,this.chromTree=new jc(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 Hc(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 zc{constructor(t,e){this.index=t,this.reductionLevel=e.getInt(),this.reserved=e.getInt(),this.dataOffset=e.getLong(),this.indexOffset=e.getLong()}}class Hc{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=Ds(this.path)?this.loader:new Fc(this.config,Dc);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 Ql(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 Ql(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 Vc(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 Vc(a)}async findLeafItemsOverlapping(t,e,n,r){let i=this;return new Promise((function(o,s){let a=[],l=new Set,c=Ds(i.path)?i.loader:new Fc(i.config,Dc);l.add(0),function h(u,f){if(Uc(u,t,e,n,r)){u.items.forEach((function(o){Uc(o,t,e,n,r)&&(o.isLeaf?a.push(o):o.childNode?h(o.childNode):(l.add(o.childOffset),i.readNode(o.childOffset,c).then((function(t){o.childNode=t,h(t,o.childOffset)})).catch(s)))}))}void 0!==f&&l.delete(f);0===l.size&&o(a)}(i.rootNode,0)}))}}class Vc{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 jc{constructor(t,e,n){let r=t.getInt(),i=t.getInt(),o=t.getInt(),s=t.getInt(),a=t.getLong(),l=t.getLong(),c={},h=[];this.header={magic:r,blockSize:i,keySize:o,valSize:s,itemCount:a,reserved:l},this.chromToID=c,this.idToChrom=h,function t(r,i){i>=0&&(r.position=i);let s=r.getByte();r.getByte();let a,l,u,f,d,p,g=r.getUShort();if(1===s)for(a=0;a<g;a++)l=r.getFixedLengthTrimmedString(o),u=r.getInt(),r.getInt(),n&&(l=n.getChromosomeName(l)),c[l]=u,h[u]=l;else for(a=0;a<g;a++)l=r.getFixedLengthTrimmedString(o),f=r.getLong(),d=f-e,p=r.position,t(r,d),r.position=p}(t,-1)}}function Uc(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 qc{constructor(t){t?(this.basesCovered=t.getLong(),this.minVal=t.getDouble(),this.maxVal=t.getDouble(),this.sumData=t.getDouble(),this.sumSquares=t.getDouble(),Wc.call(this)):(this.basesCovered=0,this.minVal=0,this.maxVal=0,this.sumData=0,this.sumSquares=0,this.mean=0,this.stddev=0)}}function Wc(){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 $c(t,e,n,r,i,o,s){const a=new Ql(t),l=a.getInt();let c=a.getInt(),h=a.getInt();const u=a.getInt(),f=a.getInt(),d=a.getByte();a.getByte();let p=a.getUShort();if(l>=e&&l<=r)for(;p-- >0;){let t;switch(d){case 1:c=a.getInt(),h=a.getInt(),t=a.getFloat();break;case 2:c=a.getInt(),t=a.getFloat(),h=c+f;break;case 3:t=a.getFloat(),h=c+f,c+=u}if(!(l<e||l===e&&h<n)){if(l>r||l===r&&c>=i)break;if(Number.isFinite(t)){const e=s[l];o.push({chr:e,start:c,end:h,value:t})}}}}function Gc(){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=vo.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 l=new Ql(e);for(;l.remLength()>=13;){const e=l.getInt(),c=a[e],h=l.getInt(),u=l.getInt(),f=l.getString();if(!(e<n||e===n&&u<r)){if(e>i||e===i&&h>=o)break;if(u>0){const e={chr:c,start:h,end:u};s.push(e);const n=f.split("\t");t(e,n)}}}}}function Zc(t,e,n,r,i,o,s,a){const l=new Ql(t);for(;l.remLength()>=32;){const t=l.getInt(),c=s[t],h=l.getInt(),u=l.getInt(),f=l.getInt(),d=l.getFloat(),p=l.getFloat(),g=l.getFloat();let m;switch(l.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:c,start:h,end:u,value:m})}}}class Xc{constructor(t){this.data=ho(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 Yc{constructor(t,e){this.reader=new Bc(t,e),this.genome=e,this.format=t.format||"bigwig",this.wgValues={}}async getFeatures(t){let{chr:e,start:n,end:r,bpPerPixel:i,windowFunction:o}=t;const s="bigwig"===this.reader.type,a="all"===e.toLowerCase()?s?await this.getWGValues(o):[]:await this.reader.readFeatures(e,n,e,r,i,o);return s||Ic(a),a}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()}}var Kc="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Qc(t){var e={exports:{}};return t(e,e.exports),e.exports}var Jc=function(t){return t&&t.Math==Math&&t},th=Jc("object"==typeof globalThis&&globalThis)||Jc("object"==typeof window&&window)||Jc("object"==typeof self&&self)||Jc("object"==typeof Kc&&Kc)||function(){return this}()||Function("return this")(),eh=function(t){try{return!!t()}catch(t){return!0}},nh=!eh((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),rh=!eh((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")})),ih=Function.prototype,oh=ih.call,sh=rh&&ih.bind.bind(oh,oh),ah=rh?sh:function(t){return function(){return oh.apply(t,arguments)}},lh="object"==typeof document&&document.all,ch={all:lh,IS_HTMLDDA:void 0===lh&&void 0!==lh},hh=ch.all,uh=ch.IS_HTMLDDA?function(t){return"function"==typeof t||t===hh}:function(t){return"function"==typeof t},fh=function(t){return null==t},dh=TypeError,ph=function(t){if(fh(t))throw dh("Can't call method on "+t);return t},gh=Object,mh=ah({}.hasOwnProperty),vh=Object.hasOwn||function(t,e){return mh(gh(ph(t)),e)},bh=Function.prototype,wh=nh&&Object.getOwnPropertyDescriptor,yh=vh(bh,"name"),xh={EXISTS:yh,PROPER:yh&&"something"===function(){}.name,CONFIGURABLE:yh&&(!nh||nh&&wh(bh,"name").configurable)},_h=Object.defineProperty,kh=function(t,e){try{_h(th,t,{value:e,configurable:!0,writable:!0})}catch(n){th[t]=e}return e},Sh="__core-js_shared__",Ch=th[Sh]||kh(Sh,{}),Eh=ah(Function.toString);uh(Ch.inspectSource)||(Ch.inspectSource=function(t){return Eh(t)});var Th,Ah,Lh=Ch.inspectSource,Mh=th.WeakMap,Rh=uh(Mh)&&/native code/.test(String(Mh)),Ih=ch.all,Nh=ch.IS_HTMLDDA?function(t){return"object"==typeof t?null!==t:uh(t)||t===Ih}:function(t){return"object"==typeof t?null!==t:uh(t)},Oh=th.document,Ph=Nh(Oh)&&Nh(Oh.createElement),Fh=function(t){return Ph?Oh.createElement(t):{}},Dh=!nh&&!eh((function(){return 7!=Object.defineProperty(Fh("div"),"a",{get:function(){return 7}}).a})),Bh=nh&&eh((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),zh=String,Hh=TypeError,Vh=function(t){if(Nh(t))return t;throw Hh(zh(t)+" is not an object")},jh=Function.prototype.call,Uh=rh?jh.bind(jh):function(){return jh.apply(jh,arguments)},qh=function(t){return uh(t)?t:void 0},Wh=function(t,e){return arguments.length<2?qh(th[t]):th[t]&&th[t][e]},$h=ah({}.isPrototypeOf),Gh="undefined"!=typeof navigator&&String(navigator.userAgent)||"",Zh=th.process,Xh=th.Deno,Yh=Zh&&Zh.versions||Xh&&Xh.version,Kh=Yh&&Yh.v8;Kh&&(Ah=(Th=Kh.split("."))[0]>0&&Th[0]<4?1:+(Th[0]+Th[1])),!Ah&&Gh&&(!(Th=Gh.match(/Edge\/(\d+)/))||Th[1]>=74)&&(Th=Gh.match(/Chrome\/(\d+)/))&&(Ah=+Th[1]);var Qh,Jh,tu,eu,nu=Ah,ru=!!Object.getOwnPropertySymbols&&!eh((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&nu&&nu<41})),iu=ru&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ou=Object,su=iu?function(t){return"symbol"==typeof t}:function(t){var e=Wh("Symbol");return uh(e)&&$h(e.prototype,ou(t))},au=String,lu=TypeError,cu=function(t){if(uh(t))return t;throw lu(function(t){try{return au(t)}catch(t){return"Object"}}(t)+" is not a function")},hu=TypeError,uu=Qc((function(t){(t.exports=function(t,e){return Ch[t]||(Ch[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.27.2",mode:"global",copyright:"© 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.27.2/LICENSE",source:"https://github.com/zloirock/core-js"})})),fu=0,du=Math.random(),pu=ah(1..toString),gu=function(t){return"Symbol("+(void 0===t?"":t)+")_"+pu(++fu+du,36)},mu=th.Symbol,vu=uu("wks"),bu=iu?mu.for||mu:mu&&mu.withoutSetter||gu,wu=TypeError,yu=function(t){return vh(vu,t)||(vu[t]=ru&&vh(mu,t)?mu[t]:bu("Symbol."+t)),vu[t]}("toPrimitive"),xu=function(t,e){if(!Nh(t)||su(t))return t;var n,r,i=(n=t[yu],fh(n)?void 0:cu(n));if(i){if(void 0===e&&(e="default"),r=Uh(i,t,e),!Nh(r)||su(r))return r;throw wu("Can't convert object to primitive value")}return void 0===e&&(e="number"),function(t,e){var n,r;if("string"===e&&uh(n=t.toString)&&!Nh(r=Uh(n,t)))return r;if(uh(n=t.valueOf)&&!Nh(r=Uh(n,t)))return r;if("string"!==e&&uh(n=t.toString)&&!Nh(r=Uh(n,t)))return r;throw hu("Can't convert object to primitive value")}(t,e)},_u=function(t){var e=xu(t,"string");return su(e)?e:e+""},ku=TypeError,Su=Object.defineProperty,Cu=Object.getOwnPropertyDescriptor,Eu="enumerable",Tu="configurable",Au="writable",Lu={f:nh?Bh?function(t,e,n){if(Vh(t),e=_u(e),Vh(n),"function"==typeof t&&"prototype"===e&&"value"in n&&Au in n&&!n[Au]){var r=Cu(t,e);r&&r[Au]&&(t[e]=n.value,n={configurable:Tu in n?n[Tu]:r[Tu],enumerable:Eu in n?n[Eu]:r[Eu],writable:!1})}return Su(t,e,n)}:Su:function(t,e,n){if(Vh(t),e=_u(e),Vh(n),Dh)try{return Su(t,e,n)}catch(t){}if("get"in n||"set"in n)throw ku("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},Mu=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},Ru=nh?function(t,e,n){return Lu.f(t,e,Mu(1,n))}:function(t,e,n){return t[e]=n,t},Iu=uu("keys"),Nu={},Ou="Object already initialized",Pu=th.TypeError,Fu=th.WeakMap;if(Rh||Ch.state){var Du=Ch.state||(Ch.state=new Fu);Du.get=Du.get,Du.has=Du.has,Du.set=Du.set,Qh=function(t,e){if(Du.has(t))throw Pu(Ou);return e.facade=t,Du.set(t,e),e},Jh=function(t){return Du.get(t)||{}},tu=function(t){return Du.has(t)}}else{var Bu=Iu[eu="state"]||(Iu[eu]=gu(eu));Nu[Bu]=!0,Qh=function(t,e){if(vh(t,Bu))throw Pu(Ou);return e.facade=t,Ru(t,Bu,e),e},Jh=function(t){return vh(t,Bu)?t[Bu]:{}},tu=function(t){return vh(t,Bu)}}var zu={set:Qh,get:Jh,has:tu,enforce:function(t){return tu(t)?Jh(t):Qh(t,{})},getterFor:function(t){return function(e){var n;if(!Nh(e)||(n=Jh(e)).type!==t)throw Pu("Incompatible receiver, "+t+" required");return n}}},Hu=Qc((function(t){var e=xh.CONFIGURABLE,n=zu.enforce,r=zu.get,i=String,o=Object.defineProperty,s=ah("".slice),a=ah("".replace),l=ah([].join),c=nh&&!eh((function(){return 8!==o((function(){}),"length",{value:8}).length})),h=String(String).split("String"),u=t.exports=function(t,r,u){"Symbol("===s(i(r),0,7)&&(r="["+a(i(r),/^Symbol\(([^)]*)\)/,"$1")+"]"),u&&u.getter&&(r="get "+r),u&&u.setter&&(r="set "+r),(!vh(t,"name")||e&&t.name!==r)&&(nh?o(t,"name",{value:r,configurable:!0}):t.name=r),c&&u&&vh(u,"arity")&&t.length!==u.arity&&o(t,"length",{value:u.arity});try{u&&vh(u,"constructor")&&u.constructor?nh&&o(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(t){}var f=n(t);return vh(f,"source")||(f.source=l(h,"string"==typeof r?r:"")),t};Function.prototype.toString=u((function(){return uh(this)&&r(this).source||Lh(this)}),"toString")})),Vu=th.RegExp,ju=Vu.prototype,Uu=nh&&eh((function(){var t=!0;try{Vu(".","d")}catch(e){t=!1}var e={},n="",r=t?"dgimsy":"gimsy",i=function(t,r){Object.defineProperty(e,t,{get:function(){return n+=r,!0}})},o={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var s in t&&(o.hasIndices="d"),o)i(s,o[s]);return Object.getOwnPropertyDescriptor(ju,"flags").get.call(e)!==r||n!==r}));Uu&&function(t,e,n){n.get&&Hu(n.get,e,{getter:!0}),n.set&&Hu(n.set,e,{setter:!0}),Lu.f(t,e,n)}(ju,"flags",{configurable:!0,get:function(){var t=Vh(this),e="";return t.hasIndices&&(e+="d"),t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.dotAll&&(e+="s"),t.unicode&&(e+="u"),t.unicodeSets&&(e+="v"),t.sticky&&(e+="y"),e}});class qu{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 To.loadArrayBuffer(this.path,Is(this.config,{range:{start:0,size:64e3}})),e=new Ql(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 To.loadArrayBuffer(this.path,Is(this.config,{range:{start:this.indexPos,size:this.indexSize}})),e=new Ql(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 l=await To.loadArrayBuffer(this.path,Is(this.config,{range:{start:a.position,size:a.size}}));if(!l)return;const c=new Ql(new DataView(l));let h=c.getInt();const u={};for(;h-- >0;)u[c.getString()]=c.getString();const f=c.getString(),d=c.getFloat();let p=c.getInt();const g=[];for(;p-- >0;)g.push({position:c.getLong(),size:c.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 To.loadArrayBuffer(this.path,Is(this.config,{range:{start:e.position,size:e.size}}));if(!n)return;const r=new Ql(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 To.loadArrayBuffer(this.path,Is(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=io(s.slice(t,t+r)).buffer}else n=s.slice(t,t+r);const i=new Ql(new DataView(n)),o=i.getString();let l;switch(o){case"fixedStep":l=Wu(i,e);break;case"variableStep":l=$u(i,e);break;case"bed":case"bedWithName":l=Gu(i,e,o);break;default:throw"Unknown tile type: "+o}a.push(l)}}return a}async readTile(t,e){let n=await To.loadArrayBuffer(this.path,Is(this.config,{range:{start:t.position,size:t.size}}));if(this.compressed){n=io(n).buffer}const r=new Ql(new DataView(n)),i=r.getString();switch(i){case"fixedStep":return Wu(r,e);case"variableStep":return $u(r,e);case"bed":case"bedWithName":return Gu(r,e,i);default:throw"Unknown tile type: "+i}}}function Wu(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 $u(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 l=e;for(;l-- >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 Gu(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 l=e;for(;l-- >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 Zu{constructor(t,e){this.genome=e,this.windowFunction=t.windowFunction||"mean",this.reader=new qu(t,e)}async getFeatures(t){let{chr:e,start:n,end:r,bpPerPixel:i}=t;if("all"===e.toLowerCase()){const t=[],e=this.genome;if(this.genome.wgChromosomeNames)for(let n of e.wgChromosomeNames){const r=e.getChromosome(n).bpLength;i=r/1e3;const o=await this._getFeatures(n,0,r,i);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(e,n,r,i)}async _getFeatures(t,e,n,r){const i=new na(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)))/Qu)}(t,r,o);let a=this.reader.chrAliasTable[t],l=this.reader.maxZoom;void 0===a&&(a=t),void 0===l&&(l=-1);const c=s>l?"raw":this.windowFunction,h=await this.reader.readDataset(a,c,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":Xu(i,t,e,n,r,g);break;case"variableStep":Yu(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 Xu(t,e,n,r,i,o){const s=t.nPositions,a=t.start,l=t.end,c=t.data[0];for(let t=0;t<s;t++){const i=a[t],s=l[t];if(!(s<n)){if(i>r)break;o.push({chr:e,start:i,end:s,value:c[t]})}}}function Yu(t,e,n,r,i,o){const s=t.nPositions,a=t.start,l=t.span,c=t.data[0];for(let t=0;t<s;t++){const i=a[t],s=i+l;if(!(s<n)){if(i>r)break;o.push({chr:e,start:i,end:s,value:c[t]})}}}function Ku(t,e,n,r,i,o){const s=t.nPositions;let a=t.start;const l=t.span,c=t.data[0];for(let t=0;t<s;t++){const i=a+l;if(a>r)break;i>=n&&(Number.isNaN(c[t])||o.push({chr:e,start:a,end:i,value:c[t]})),a=i}}var Qu=Math.log(2);class Ju{constructor(t,e){this.config=t,this.genome=e,this.queryable=!1,this.updateFeatures(t.features)}updateFeatures(t){Oc(t=function(t,e){if(e)for(let n of t)n.chr=e.getChromosomeName(n.chr);return t}(t,this.genome)),this.config.mappings&&function(t,e){let n=Object.keys(e);t.forEach((function(t){n.forEach((function(n){t[n]=t[e[n]]}))}))}(t,this.config.mappings),this.featureCache=new Vo(t,this.genome)}async getFeatures(t){let{chr:e,start:n,end:r,bpPerPixel:i,visibilityWindow:o}=t;const s=this.genome,a=s?s.getChromosomeName(e):e;return"all"===a.toLowerCase()?Nc(this.featureCache.getAllFeatures(),this.genome,this.maxWGCount):this.featureCache.queryFeatures(a,n,r)}getAllFeatures(){return this.featureCache.getAllFeatures()}supportsWholeGenome(){return!0}}const tf=new Set(["bigwig","bw","bigbed","bb","biginteract","biggenepred","bignarrowpeak"]);function ef(t,e){const n=t.format?t.format.toLowerCase():void 0;return t.features?new Ju(t,e):tf.has(n)?new Yc(t,e):"tdf"===n?new Zu(t,e):new Pc(t,e)}const nf=function(t,e){const{r:n,g:r,b:i}=Yo[t];return`rgba(${n},${r},${i},${e})`}("nickel",2/16),rf=nf;class of{constructor(t,e){if(this.url=t.url,t.name?this.name=t.name:t.url&&Ue(t.url)?this.name=t.url.name:t.url&&ke(t.url)&&!t.url.startsWith("data:")&&(this.name=je(t.url)),this.isUserDefined=t.isUserDefined,t.features)this.featureSource=new af(t.features,e);else{if(t.format)t.format=t.format.toLowerCase();else{const e=je(t.url);t.format=$s(e)}this.featureSource=t.featureSource||ef(t,e)}!0===this.isUserDefined?(this.color=t.color||rf,this.headerColor="rgba(155,185,129)"):(this.color=t.color||nf,this.headerColor="rgb(190,190,190)")}async getFeatures(t,e,n){return this.featureSource.getFeatures({chr:t,start:e,end:n})}async getAllFeatures(){return"function"==typeof this.featureSource.getAllFeatures?await this.featureSource.getAllFeatures():{}}addFeature(t){this.isUserDefined?this.featureSource.addFeature(t):console.error("Attempt to add ROI to non user-defined set")}removeFeature(t){this.isUserDefined?this.featureSource.removeFeature(t):console.error("Attempt to remove ROI from non user-defined set")}toJSON(){if(this.url)return{name:this.name,color:this.color,url:this.url,isUserDefined:this.isUserDefined};{const t=this.featureSource.getAllFeatures(),e=[];for(let n of Object.keys(t))for(let r of t[n])e.push(r);return{name:this.name,color:this.color,features:e,isUserDefined:this.isUserDefined}}}dispose(){for(let t of Object.keys(this))this[t]=void 0}}function sf(t,e,n,r){let i=Math.round((t-n)/r);let o=Math.round((e-n)/r)-i;return o<3&&(o=3,i-=1),{x:i,width:o}}class af{constructor(t,e){this.featureMap={},this.genome=e;for(let n of t){const t=e?e.getChromosomeName(n.chr):n.chr;let r=this.featureMap[t];r||(r=[],this.featureMap[t]=r),r.push(n)}for(let t of Object.keys(this.featureMap))this.featureMap[t].sort(((t,e)=>t.start-e.start))}getFeatures(t){let{chr:e,start:n,end:r}=t;if("all"===e.toLowerCase())return Nc(this.featureMap,this.genome);{const t=this.featureMap[e];return t?t.filter((t=>t.end>n&&t.start<r)):[]}}getAllFeatures(){return this.featureMap}supportsWholeGenome(){return!0}addFeature(t){let e=this.featureMap[t.chr];e||(e=[],this.featureMap[t.chr]=e),e.push(t),e.sort(((t,e)=>t.start-e.start))}removeFeature(t){let{chr:e,start:n,end:r}=t;if(this.featureMap[e]){const t=`${e}-${n}-${r}`;this.featureMap[e]=this.featureMap[e].filter((e=>t!==`${e.chr}-${e.start}-${e.end}`))}}}class lf{constructor(t,e,n,r){this.rulerViewport=t,this.rulerSweeper=ge({class:"igv-ruler-sweeper"}),e.appendChild(this.rulerSweeper),this.browser=n,this.referenceFrame=r,this.isMouseHandlers=void 0,this.addBrowserObserver()}addBrowserObserver(){this.boundObserverHandler=(()=>{this.referenceFrame&&(Ra.isWholeGenomeView(this.referenceFrame.chr)?this.removeMouseHandlers():this.addMouseHandlers())}).bind(this),this.browser.on("locuschange",this.boundObserverHandler)}removeBrowserObserver(){this.browser.off("locuschange",this.boundObserverHandler)}addMouseHandlers(){if(!0===this.isMouseHandlers)return;let 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.backgroundColor=!0===o.shiftKey?rf:"rgba(68, 134, 247, 0.25)",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:Math.floor(this.referenceFrame.calculateEnd(r)),end:Math.floor(this.referenceFrame.calculateEnd(r+i))};!0===n.shiftKey?this.browser.roiManager.updateUserDefinedROISet(Object.assign({chr:this.referenceFrame.chr},o)):(Os(this.browser.genome.getChromosome(this.referenceFrame.chr).bpLength,o,this.browser.minimumBases()),function(t,e,n){t.start=Math.round(e.start),t.end=Math.round(e.end),t.bpPerPixel=(t.end-t.start)/n}(this.referenceFrame,o,this.rulerViewport.contentDiv.clientWidth),this.browser.updateViews(this.referenceFrame))}}.bind(this),document.addEventListener("mouseup",this.boundDocumentMouseUpHandler),this.isMouseHandlers=!0}removeMouseHandlers(){this.rulerViewport.contentDiv.removeEventListener("mousedown",this.boundContentMouseDownHandler),document.removeEventListener("mousemove",this.boundDocumentMouseMoveHandler),document.removeEventListener("mouseup",this.boundDocumentMouseUpHandler),this.isMouseHandlers=!1}dispose(){this.removeBrowserObserver(),this.removeMouseHandlers(),this.rulerSweeper.remove()}}class cf{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)}}class hf{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}getSortValue(t,e){let{position:n,option:r,tag:i}=t;r||(r="BASE");const o=this.findAlignment(n);if(void 0===o)return Number.MAX_VALUE;switch(r){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,l=Math.floor(n-a.bpStart),c=a.coverage[l];let h=0;if(t.insertions)for(let e of t.insertions)e.start===n&&(h=-c.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-=c["pos"+o]+c["neg"+o]+s/1e3}}else h=4-s/1e3;else{const t=c.del;t>0?h-=t:0===h&&(h=1)}return h}(o,e,n);case"STRAND":return o.strand?1:-1;case"START":return o.start;case"TAG":return o.tags()[i];case"READ_NAME":return o.readName;case"INSERT_SIZE":return-Math.abs(o.fragmentLength);case"GAP_SIZE":return-o.gapSizeAt(n);case"MATE_CHR":return o.mate;case"MQ":return void 0===o.mq?Number.MAX_VALUE:-o.mq;case"ALIGNED_READ_LENGTH":return-o.lengthOnRef;default:return Number.MAX_VALUE}}}function uf(t){return t.isPaired()&&t.mate&&t.isMateMapped()&&t.chr===t.mate.chr&&(t.isFirstOfPair()||t.isSecondOfPair())&&!(t.isSecondary()||t.isSupplementary())}function ff(t){const e=[];for(let n of t)for(let t of n.alignments)t instanceof cf?(t.firstAlignment&&e.push(t.firstAlignment),t.secondAlignment&&e.push(t.secondAlignment)):e.push(t);return e}function df(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 l=0,c=0;const h=[],u=2;try{for(;l<t.length;){const t=new hf;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 c=e.pop();0===e.length&&(a[i]=void 0),t.alignments.push(c),s=r?c.scStart+c.scLengthOnRef+u:c.start+c.lengthOnRef+u,++l}if(t.alignments.length>0&&h.push(t),s=o,l===c)break;c=l}}catch(t){throw console.error(t),t}return h}}}class pf{constructor(t,e,n,r){let{samplingWindowSize:i,samplingDepth:o,pairsSupported:s,alleleFreqThreshold:a}=r;this.chr=t,this.start=Math.floor(e),this.end=Math.ceil(n),this.length=n-e,this.alleleFreqThreshold=void 0===a?.2:a,this.coverageMap=new mf(t,e,n,this.alleleFreqThreshold),this.alignments=[],this.downsampledIntervals=[],this.samplingWindowSize=void 0===i?100:i,this.samplingDepth=void 0===o?1e3:o,this.pairsSupported=void 0===s||s,this.paired=!1,this.pairsCache={},this.downsampledReads=new Set,this.currentBucket=new gf(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 gf(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 bf(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(uf(t)){let r=e[t.readName];r?(r.setSecondAlignment(t),e[t.readName]=void 0):(r=new cf(t),e[t.readName]=r,n.push(r))}else n.push(t);return n}(this.packedAlignmentRows):ff(this.packedAlignmentRows),this.packedAlignmentRows=df(e,this.start,this.end)}setShowSoftClips(t){const e=this.allAlignments();this.packedAlignmentRows=df(e,this.start,this.end,t)}repack(t,e){const n=this.allAlignments();this.packedAlignmentRows=df(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)}sortRows(t){const e=[],n=[];for(let r of this.packedAlignmentRows){void 0!==r.findAlignment(t.position)?e.push(r):n.push(r)}e.sort(((e,n)=>{const r=t.direction,i=e.getSortValue(t,this),o=n.getSortValue(t,this);if(void 0===o&&void 0!==o)return 1;if(void 0!==i&&void 0===o)return-1;const s=i>o?1:i<o?-1:0;return!0===r?s:-s}));for(let t of n)e.push(t);this.packedAlignmentRows=e}}class gf{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&&uf(t)&&(r=this.pairsCache[t.readName]))return r.setSecondAlignment(t),void(this.pairsCache[t.readName]=void 0);this.alignments.length<this.samplingDepth?this.pairsSupported&&uf(t)?(r=new cf(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&&uf(t)?(void 0!==this.pairsCache[n.readName]&&(this.pairsCache[n.readName]=void 0),r=new cf(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 mf{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 vf(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 vf(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 vf(e.threshold));const n=null==r?"N":r.charAt(o+a),l=t.strand?"pos"+n:"neg"+n,c=i&&o+a<i.length?i[o+a]:30;e.coverage[s][l]+=1,e.coverage[s]["qual"+n]+=c,e.coverage[s].total+=1,e.coverage[s].qual+=c,e.maximum=Math.max(e.coverage[s].total,e.maximum)}}}}class vf{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}hoverText(){const t=this.posA+this.posT+this.posC+this.posG+this.posN,e=this.negA+this.negT+this.negC+this.negG+this.negN;return`${this.total} (${t}+, ${e}-)`}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 bf{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 wf{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=Ff.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 yf(t){return t.split(";").filter((t=>t.length>0)).map((t=>new wf(t)))}const xf={c:1,C:1,s:2,S:2,i:4,I:4,f:4};class _f{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||Sf(this.tagBA)).hasOwnProperty(t)}tags(){return this.tagDict||(this.tagBA?(this.tagDict=Sf(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=yf(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=kf(this.blocks,t);if(e){if("*"===this.seq)return"*";{const n=e.seqIndexAt(t);return this.seq[n]}}}readBaseQualityAt(t){const e=kf(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 kf(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 Sf(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=Cf(t,e),e+=4;else if("c"===o)s=Af(t,e),e++;else if("C"===o)s=Lf(t,e),e++;else if("s"===o||"S"===o)s=Ef(t,e),e+=2;else if("f"===o)s=Tf(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=xf[i];if(void 0===o){r[n]=`Error: unknown element type '${i}'`;break}e+=4+Cf(t,e)*o,s="[not shown]"}}r[n]=s}return r}function Cf(t,e){return t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}function Ef(t,e){return t[e+1]<<8|t[e]}function Tf(t,e){return new DataView(t.buffer).getFloat32(e)}function Af(t,e){return new DataView(t.buffer).getInt8(e)}function Lf(t,e){return new DataView(t.buffer).getUint8(e)}class Mf{constructor(t){t&&Object.assign(this,t)}seqIndexAt(t){return Math.floor(t)-this.start+this.seqOffset}}class Rf{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 If=["=","A","C","x","G","x","x","x","T","x","x","x","x","x","x","N"],Nf=["M","I","D","N","S","H","P","=","X","?","?","?","?","?","?","?"],Of=Bf(new Uint8Array([66,65,77,1]),0),Pf=1e4,Ff={readHeader:function(t,e,n){return To.loadArrayBuffer(t,e).then((function(t){var e;return e=oo(t),Ff.decodeBamHeader(e,n)}))},decodeBamHeader:function(t,e){var n,r,i,o,s;if((n=Bf(t,0))!==Of)throw new Error("BAM header errror: bad magic number. This could be caused by either a corrupt or missing file.");r=Bf(t,4);for(var a=0;a<r;++a)String.fromCharCode(t[a+8]);var l=Bf(t,r+8),c=r+12;for(i={},o=[],s={},a=0;a<l;++a){for(var h=Bf(t,c),u="",f=0;f<h-1;++f)u+=String.fromCharCode(t[c+4+f]);Bf(t,c+h+4),i[u]=a,o[a]=u,e&&(s[e.getChromosomeName(u)]=u),c=c+8+h}return{magicNumber:n,size:c,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 l=String.fromCharCode(t[a+2]);if("B"===l)a+=8+s(l=String.fromCharCode(t[a+3]))*Bf(t,a+4);else if("Z"===l||"H"===l)for(a+=3;0!==t[a++];);else a+=3+s(l)}if(a>=e)return!1;if("B"!==String.fromCharCode(t[a+2])||"I"!==String.fromCharCode(t[a+3]))return!1;var c=Bf(t,a+4),h=a+8;if(h+4*c>e)return!1;var u="",f=0;o.length=0,a=h;for(var d=0;d<c;++d,a+=4){var p=Bf(t,a),g=p>>4,m=Nf[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+Bf(t,e)+4,d=new _f,p=Bf(t,e+4),g=Bf(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=Bf(t,e+12),v=(65280&m)>>8,b=255&m,w=Bf(t,e+16),y=(4294901760&w)>>16,x=65535&w,_=Bf(t,e+20),k=Bf(t,e+24),S=Bf(t,e+28),C=Bf(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 T=0,A="",L=e+36+b;const M=[];let R;for(let e=0;e<x;++e){var l=Bf(t,L),c=l>>4,h=Nf[15&l];"M"!==h&&"EQ"!==h&&"X"!==h&&"D"!==h&&"N"!==h&&"="!==h||(T+=c),A=A+c+h,L+=4,R={len:c,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=A,d.lengthOnRef=T,d.fragmentLength=C,d.mq=v,Ff.bam_tag2cigar(t,f,L,_,d,M),d.end=d.start+d.lengthOnRef,d.end<o){e=f;continue}let I=[];const N=_+1>>1;for(let e=0;e<N;++e){var u=t[L+e];I.push(If[(240&u)>>4]),I.push(If[15&u])}I=I.slice(0,_).join(""),L+=N;const O=[];for(let e=0;e<_;++e)O.push(t[L+e]);L+=_,k>=0&&(d.mate={chr:r[k],position:S,strand:!(32&y)}),d.seq=I,d.qual=O,d.tagBA=new Uint8Array(t.buffer.slice(L,f)),this.setPairOrientation(d),(void 0===a||a.pass(d))&&(Df(d,M),n.push(d)),e=f}},decodeSamRecords:function(t,e,n,r,i,o){var s,a,l,c,h,u,f,d,p,g;for(c=(s=Ce(t)).length,!1,a=0;a<c;a++)if(h=s[a].split("\t"),(p=new _f).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=zf(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=[],l=0;l<u.length;l++)p.qual[l]=u.charCodeAt(l)-33;p.tagDict=h.length<11?{}:Hf(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))&&(Df(p,g),e.push(p))}}},setReaderDefaults:function(t,e){t.filter=new Rf(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>Pf&&(console.log("Warning: attempt to set sampling depth > maximum value of "+Pf),t.samplingDepth=Pf),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,l=t.end-t.start;if(0===a)a=(t.start<n.position?n.position+l:n.position-l)-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 Df(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 Mf({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 Mf({start:s,len:a.len,seqOffset:o,type:"I"})),o+=a.len;break;case"M":case"EQ":case"=":case"X":n.push(new Mf({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 Bf(t,e){return t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}function zf(t){var e,n,r,i,o,s,a,l,c;for(e=[],n=[],o=null,i=t.length,r=0;r<i;r++)s=t.charAt(r),c=void 0,(c=s.charCodeAt(0))>=48&&c<=57?n.push(s):(a=s,l=Number.parseInt(n.join("")),n=[],null!==o&&o.ltr===a?o.len+=l:(o={len:l,ltr:a},e.push(o)));return e}function Hf(t){var e={};return t.forEach((function(t){var n=t.split(":");e[n[0]]=n[2]})),e}class Vf{constructor(t,e){this.config=t,this.genome=e,this.bamPath=t.url,this.isDataUri=Ds(t.url),Ff.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 pf(t,e,n,this.config);for(let t of o)s.push(t);return s.finish(),s}if(this.isDataUri){const r=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),i=oo(r.buffer);return this.parseAlignments(i),this.fetchAlignments(t,e,n)}{const r=oo(await To.loadArrayBuffer(this.bamPath,Is(this.config)));return this.parseAlignments(r),this.fetchAlignments(t,e,n)}}parseAlignments(t){const e=[];this.header=Ff.decodeBamHeader(t),Ff.decodeBamRecords(t,this.header.size,e,this.header.chrNames),this.alignmentCache=new Vo(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 pf(t,e,n,this.config);for(let t of i)o.push(t);return o.finish(),o}}class jf{constructor(t,e){this.config=t,this.genome=e,this.bamPath=t.url,this.baiPath=t.indexURL,Ff.setReaderDefaults(this,t),this._blockLoader=new uc(t)}async readAlignments(t,e,n){const r=(await this.getChrIndex())[this.chrAliasTable.hasOwnProperty(t)?this.chrAliasTable[t]:t],i=new pf(t,e,n,this.config);if(void 0===r)return i;{const t=(await this.getIndex()).chunksForRange(r,e,n);if(!t||0===t.length)return i;for(let o of t){const t=await this._blockLoader.getData(o.minv,o.maxv);if(Ff.decodeBamRecords(t,o.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=Is(this.config,{range:{start:e.firstBlockPosition,size:26}}),r=so(await To.loadArrayBuffer(this.bamPath,t));n=e.firstBlockPosition+r}else n=64e3;const r=Is(this.config,{range:{start:0,size:n}});this.header=await Ff.readHeader(this.bamPath,r,t)}return this.header}async getIndex(){const t=this.genome;return this.index||(this.index=await oc(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 Uf{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 jf(i,e)}(t,e,r)})),this.bamReaders=n,Ff.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 pf(t,e,n,this.config)}}const qf=function(t,e){this.config=t,this.genome=e,Ff.setReaderDefaults(this,t)};function Wf(){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=Is(this.config);return Ff.readHeader(n,r,e).then((function(e){return t.header=e,e}))}}qf.prototype.readAlignments=function(t,e,n){var r=this;return Wf.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,To.loadString(s,Is(r.config)).then((function(s){var a;return i.chrToIndex[o],a=new pf(t,e,n,r.config),Ff.decodeSamRecords(s,a,o,e,n,r.filter),a}))}))};class $f extends Ac{constructor(t,e){super(t,e),Ff.setReaderDefaults(this,t)}async readAlignments(t,e,n){if(!this.header){const t=oo((await this.readHeaderData()).buffer);this.header=Ff.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=oo((await this.readData(r,e,n)).buffer),o=this.header.chrToIndex[t],s=new pf(t,e,n,this.config);return Ff.decodeBamRecords(i,this.header.size,s,this.header.chrNames,o,e,n),s.finish(),s}}var Gf,Zf,Xf,Yf,Kf={}.propertyIsEnumerable,Qf=Object.getOwnPropertyDescriptor,Jf={f:Qf&&!Kf.call({1:2},1)?function(t){var e=Qf(this,t);return!!e&&e.enumerable}:Kf},td=ah({}.toString),ed=ah("".slice),nd=function(t){return ed(td(t),8,-1)},rd=Object,id=ah("".split),od=eh((function(){return!rd("z").propertyIsEnumerable(0)}))?function(t){return"String"==nd(t)?id(t,""):rd(t)}:rd,sd=function(t){return od(ph(t))},ad=Object.getOwnPropertyDescriptor,ld={f:nh?ad:function(t,e){if(t=sd(t),e=_u(e),Dh)try{return ad(t,e)}catch(t){}if(vh(t,e))return Mu(!Uh(Jf.f,t,e),t[e])}},cd=function(t,e,n,r){r||(r={});var i=r.enumerable,o=void 0!==r.name?r.name:e;if(uh(n)&&Hu(n,o,r),r.global)i?t[e]=n:kh(e,n);else{try{r.unsafe?t[e]&&(i=!0):delete t[e]}catch(t){}i?t[e]=n:Lu.f(t,e,{value:n,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return t},hd=Math.ceil,ud=Math.floor,fd=Math.trunc||function(t){var e=+t;return(e>0?ud:hd)(e)},dd=function(t){var e=+t;return e!=e||0===e?0:fd(e)},pd=Math.max,gd=Math.min,md=Math.min,vd=function(t){return(e=t.length)>0?md(dd(e),9007199254740991):0;var e},bd=function(t){return function(e,n,r){var i,o=sd(e),s=vd(o),a=function(t,e){var n=dd(t);return n<0?pd(n+e,0):gd(n,e)}(r,s);if(t&&n!=n){for(;s>a;)if((i=o[a++])!=i)return!0}else for(;s>a;a++)if((t||a in o)&&o[a]===n)return t||a||0;return!t&&-1}},wd={includes:bd(!0),indexOf:bd(!1)}.indexOf,yd=ah([].push),xd=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"].concat("length","prototype"),_d=Object.getOwnPropertyNames||function(t){return function(t,e){var n,r=sd(t),i=0,o=[];for(n in r)!vh(Nu,n)&&vh(r,n)&&yd(o,n);for(;e.length>i;)vh(r,n=e[i++])&&(~wd(o,n)||yd(o,n));return o}(t,xd)},kd={f:_d},Sd={f:Object.getOwnPropertySymbols},Cd=ah([].concat),Ed=Wh("Reflect","ownKeys")||function(t){var e=kd.f(Vh(t)),n=Sd.f;return n?Cd(e,n(t)):e},Td=function(t,e,n){for(var r=Ed(e),i=Lu.f,o=ld.f,s=0;s<r.length;s++){var a=r[s];vh(t,a)||n&&vh(n,a)||i(t,a,o(e,a))}},Ad=/#|\.prototype\./,Ld=function(t,e){var n=Rd[Md(t)];return n==Nd||n!=Id&&(uh(e)?eh(e):!!e)},Md=Ld.normalize=function(t){return String(t).replace(Ad,".").toLowerCase()},Rd=Ld.data={},Id=Ld.NATIVE="N",Nd=Ld.POLYFILL="P",Od=Ld,Pd=ld.f,Fd=function(t,e){var n,r,i,o,s,a=t.target,l=t.global,c=t.stat;if(n=l?th:c?th[a]||kh(a,{}):(th[a]||{}).prototype)for(r in e){if(o=e[r],i=t.dontCallGetSet?(s=Pd(n,r))&&s.value:n[r],!Od(l?r:a+(c?".":"#")+r,t.forced)&&void 0!==i){if(typeof o==typeof i)continue;Td(o,i)}(t.sham||i&&i.sham)&&Ru(o,"sham",!0),cd(n,r,o,t)}},Dd=Function.prototype,Bd=Dd.apply,zd=Dd.call,Hd="object"==typeof Reflect&&Reflect.apply||(rh?zd.bind(Bd):function(){return zd.apply(Bd,arguments)}),Vd=function(t){if("Function"===nd(t))return ah(t)},jd=Vd(Vd.bind),Ud=Wh("document","documentElement"),qd=ah([].slice),Wd=TypeError,$d=function(t,e){if(t<e)throw Wd("Not enough arguments");return t},Gd=/(?:ipad|iphone|ipod).*applewebkit/i.test(Gh),Zd="undefined"!=typeof process&&"process"==nd(process),Xd=th.setImmediate,Yd=th.clearImmediate,Kd=th.process,Qd=th.Dispatch,Jd=th.Function,tp=th.MessageChannel,ep=th.String,np=0,rp={},ip="onreadystatechange";eh((function(){Gf=th.location}));var op,sp,ap=function(t){if(vh(rp,t)){var e=rp[t];delete rp[t],e()}},lp=function(t){return function(){ap(t)}},cp=function(t){ap(t.data)},hp=function(t){th.postMessage(ep(t),Gf.protocol+"//"+Gf.host)};Xd&&Yd||(Xd=function(t){$d(arguments.length,1);var e=uh(t)?t:Jd(t),n=qd(arguments,1);return rp[++np]=function(){Hd(e,void 0,n)},Zf(np),np},Yd=function(t){delete rp[t]},Zd?Zf=function(t){Kd.nextTick(lp(t))}:Qd&&Qd.now?Zf=function(t){Qd.now(lp(t))}:tp&&!Gd?(Yf=(Xf=new tp).port2,Xf.port1.onmessage=cp,op=Yf.postMessage,sp=Yf,cu(op),Zf=void 0===sp?op:rh?jd(op,sp):function(){return op.apply(sp,arguments)}):th.addEventListener&&uh(th.postMessage)&&!th.importScripts&&Gf&&"file:"!==Gf.protocol&&!eh(hp)?(Zf=hp,th.addEventListener("message",cp,!1)):Zf=ip in Fh("script")?function(t){Ud.appendChild(Fh("script"))[ip]=function(){Ud.removeChild(this),ap(t)}}:function(t){setTimeout(lp(t),0)});var up={set:Xd,clear:Yd},fp=up.clear;Fd({global:!0,bind:!0,enumerable:!0,forced:th.clearImmediate!==fp},{clearImmediate:fp});var dp,pp,gp,mp="function"==typeof Bun&&Bun&&"string"==typeof Bun.version,vp=th.Function,bp=/MSIE .\./.test(Gh)||mp&&function(){var t=th.Bun.version.split(".");return t.length<3||0==t[0]&&(t[1]<3||3==t[1]&&0==t[2])}(),wp=up.set,yp=th.setImmediate?(dp=wp,gp=(pp=!1)?2:1,bp?function(t,e){var n=$d(arguments.length,1)>gp,r=uh(t)?t:vp(t),i=n?qd(arguments,gp):[],o=n?function(){Hd(r,this,i)}:r;return pp?dp(o,e):dp(o)}:dp):wp;Fd({global:!0,bind:!0,enumerable:!0,forced:th.setImmediate!==yp},{setImmediate:yp});const xp=eval,_p=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),l=n(20),c=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,_=w?r:y?r[b]:(r[b]||{}).prototype,k=w?s:s[b]||(s[b]={}),S=k.prototype;for(f in e)n=!o(w?f:b+(y?".":"#")+f,t.forced)&&_&&c(_,f),p=k[f],n&&(g=t.noTargetGet?(v=i(_,f))&&v.value:_[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)&&l(m,"sham",!0),k[f]=m,x&&(c(s,u=b+"Prototype")||l(s,u,{}),s[u][f]=d,t.real&&S&&!S[f]&&l(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,l=i("wks");t.exports=function(t){return l[t]||(l[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),l=n(120),c=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 c)return m;return new c(!1)}f=d.call(t)}for(;!(v=f.next()).done;)if((m=l(f,b,v.value,h))&&m instanceof c)return m;return new c(!1)}).stop=function(t){return new c(!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)),l=r(n(265)),c=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,l.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,l.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}(c),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}(c),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}(c);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
39
|
/*!
|
|
40
40
|
* The buffer module from node.js, for the browser.
|
|
41
41
|
*
|
|
@@ -60,12 +60,12 @@ var r=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.pr
|
|
|
60
60
|
*
|
|
61
61
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
62
62
|
* @license MIT
|
|
63
|
-
*/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)),l=i(n(37)),c=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),_=x.parseItem,k=x.tinyMemoize,S=x.sequenceMD5,C=n(100),E=n(363);function T(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 A=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)(c.default.mark((function t(){var e,n,r;return c.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=_(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=_(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)(c.default.mark((function t(){var e,n,r,i;return c.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)(c.default.mark((function t(){var e;return c.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)(c.default.mark((function t(){var e,n;return c.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)(c.default.mark((function t(e){var n;return c.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)(c.default.mark((function t(){var e,n,r,i;return c.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)(c.default.mark((function t(){var e,n,r,i,o,s,h,u,f,d,p,m,v,y,x,_,k,C,A,L,M,R,I,N=this;return c.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),_=(0,g.default)(h=i.content.md5).call(h,(function(t){return(t<16?"0":"")+t.toString(16)})).join(""),x===_){t.next=23;break}throw new b((0,l.default)(u=(0,l.default)(f=(0,l.default)(d=(0,l.default)(p="MD5 checksum reference mismatch for ref ".concat(i.content.refSeqId," pos ")).call(p,v,"..")).call(d,y,". recorded MD5: ")).call(f,_,", calculated MD5: ")).call(u,x));case 23:return t.next=25,this.getCoreDataBlock();case 25:k=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]}}},A=function(t){var e=r.getCodecForDataSeries(t);if(!e)throw new b("no codec defined for ".concat(t," data series"));return e.decode(N,k,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,A,r,i,k,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&&T(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)(c.default.mark((function t(e){var n,r,i,l,u,f,d,p,m,v,b,w,y,x,_,k,S=this;return c.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,!(l=(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<l.length;v+=1)b=void 0!==d?d:l[v].sequenceId,(w=m[b])||(w={id:b,start:l[v].alignmentStart,end:-1/0},m[b]=w),(y=l[v].alignmentStart+(l[v].lengthOnRef||l[v].readLength)-1)>w.end&&(w.end=y),l[v].alignmentStart<w.start&&(w.start=l[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)(c.default.mark((function t(e){return c.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<l.length;x+=1)_=void 0!==d?d:l[x].sequenceId,(k=m[_])&&k.seq&&l[x].addReferenceSequence(k,p);case 24:return t.abrupt("return",l);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 k(A,t)})),t.exports=A},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),l=n(87),c=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=c(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++)l(n,v,m?g(f[v],v):f[v]);else for(u=b.call(f),n=new d;!(h=u.next()).done;v++)l(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)),l=r(n(101)),c=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 _(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),l=5,c=0;c<n;c+=1)a[c]=t[o](l),l+=s;return a}(n);throw new v("Unrecognized tag type ".concat(t))}function k(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,c.default)((0,l.default)(t).call(t,0,n)))}return String.fromCharCode.apply(String,(0,c.default)(t))}return String(t)}t.exports=function(t,e,n,r,l,c,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=k(e("RN"))),p.isDetached()){var g={};g.flags=e("MF"),n.readNamesIncluded||(g.readName=k(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),T=C.substr(2,1),A=n.getCodecForTag(C);if(!A)throw new v("no codec defined for auxiliary tag ".concat(C));var L=A.decode(t,l,c,h);p.tags[E]=_(T,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,O=e("FN");O&&(p.readFeatures=function(t,e,n,r,i){var o=0,s=t.alignmentStart-1,a=new Array(e);function l(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 c=0;c<e;c+=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=l(p);var g={B:["number","QS"]}[h];g&&(f.data=[f.data,l(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[c]=f}return a}(p,O,e,0,u));var P,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)(P="".concat(p.sequenceId,":")).call(P,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),l=n(28),c=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=l(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&&c(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 l,c=r(t);!(o=(l=c.next()).done)&&(n.push(l.value),!e||n.length!==e);o=!0);}catch(t){s=!0,a=t}finally{try{o||null==c.return||c.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)),l=r(n(10)),c=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,l.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(","),l=String.fromCharCode.apply(String,(0,c.default)(a));r+=l,i+=l.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)),l=r(n(10)),c=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,l.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 c("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),l=n(416),c=n(417),h={1:o,3:i,4:a,5:s,6:l,7:n(418),9:c};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)),l=r(n(159)),c=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,c.default)(t,2),o=i[0],s=i[1];o=(0,l.default)(o,10),(0,u.default)(s).call(s,(function(t){var i={bitLength:o,value:t};r+=1;var s,a,l=o-n;if(r<<=l,i.bitCode=r,n+=l,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,l,c;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)(l=this.sortedCodes).call(l,(function(t){return t.bitLength}));var h=Math.max.apply(Math,(0,o.default)(this.sortedBitCodes));this.bitCodeToValue=(0,i.default)(c=new Array(h+1)).call(c,-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 l=this.bitCodeToValue[o];if(l>-1&&this.sortedBitLengthsByBitCode[l]===a)return this.sortedValuesByBitCode[l];for(var c=s;this.sortedCodes[c+1].bitLength===a&&c<this.sortedCodes.length;c+=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),l=[].sort,c=[1,2,3],h=s((function(){c.sort(void 0)})),u=s((function(){c.sort(null)})),f=a("sort");r({target:"Array",proto:!0,forced:h||!u||f},{sort:function(t){return void 0===t?l.call(o(this)):l.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)),l=r(n(27)),c=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,l.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,c.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)),l=r(n(27)),c=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,l.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,c.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)),l=i(n(32)),c=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,l.default)(this,(0,c.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)),l=r(n(33)),c=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 c("".concat(t.dataType," decoding not yet implemented by BETA codec"));return t}return(0,l.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)),l=r(n(33)),c=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 c("".concat(t.dataType," decoding not yet implemented by GAMMA codec"));return t}return(0,l.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)),l=r(n(33)),c=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 c("".concat(t.dataType," decoding not yet implemented by SUBEXP codec"));return t}return(0,l.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]*$/,l=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,c=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),h=["'"].concat(c),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("#")?"?":"#",c=t.split(a);c[0]=c[0].replace(/\\/g,"/");var w=t=c.join(a);if(w=w.trim(),!n&&1===t.split("#").length){var y=l.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 _=(x=x[0]).toLowerCase();this.protocol=_,w=w.substr(x.length)}if(n||x||w.match(/^\/\/[^@\/]+@[^@\/]+/)){var k="//"===w.substr(0,2);!k||x&&m[x]||(w=w.substr(2),this.slashes=!0)}if(!m[x]&&(k||x&&!v[x])){for(var S,C,E=-1,T=0;T<f.length;T++)-1!==(A=w.indexOf(f[T]))&&(-1===E||A<E)&&(E=A);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,T=0;T<u.length;T++){var A;-1!==(A=w.indexOf(u[T]))&&(-1===E||A<E)&&(E=A)}-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=(T=0,M.length);T<R;T++){var I=M[T];if(I&&!I.match(d)){for(var N="",O=0,P=I.length;O<P;O++)I.charCodeAt(O)>127?N+="x":N+=I[O];if(!N.match(d)){var F=M.slice(0,T),D=M.slice(T+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[_])for(T=0,R=h.length;T<R;T++){var V=h[T];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[_]&&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 l=Object.keys(t),c=0;c<l.length;c++){var h=l[c];"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,_=x,k=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&&(""===k[0]?k[0]=n.host:k.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]||""===k[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,k=p;else if(p.length)k||(k=[]),k.pop(),k=k.concat(p),n.search=t.search,n.query=t.query;else if(!i.isNullOrUndefined(t.search))return S&&(n.hostname=n.host=k.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(!k.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var C=k.slice(-1)[0],E=(n.host||t.host||k.length>1)&&("."===C||".."===C)||""===C,T=0,A=k.length;A>=0;A--)"."===(C=k[A])?k.splice(A,1):".."===C?(k.splice(A,1),T++):T&&(k.splice(A,1),T--);if(!x&&!_)for(;T--;T)k.unshift("..");!x||""===k[0]||k[0]&&"/"===k[0].charAt(0)||k.unshift(""),E&&"/"!==k.join("/").substr(-1)&&k.push("");var L,M=""===k[0]||k[0]&&"/"===k[0].charAt(0);return S&&(n.hostname=n.host=M?"":k.length?k.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&&k.length)&&!M&&k.unshift(""),k.length?n.pathname=k.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,l=2147483647,c=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 _(t,e,n){var r=0;for(t=n?p(t/700):t>>1,t+=p(t/e);t>455;r+=c)t=p(t/35);return p(r+36*t/(t+38))}function k(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=c;i>=v&&m("invalid-input"),((h=(d=t.charCodeAt(i++))-48<10?d-22:d-65<26?d-65:d-97<26?d-97:c)>=c||h>p((l-b)/s))&&m("overflow"),b+=h*s,!(h<(u=a<=x?1:a>=x+26?26:a-x));a+=c)s>p(l/(f=c-u))&&m("overflow"),s*=f;x=_(b-o,e=g.length+1,0==o),p(b/e)>l-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,k,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=l,s=0;s<v;++s)(d=t[s])>=e&&d<a&&(a=d);for(a-e>p((l-n)/(b=r+1))&&m("overflow"),n+=(a-e)*b,e=a,s=0;s<v;++s)if((d=t[s])<e&&++n>l&&m("overflow"),d==e){for(h=n,u=c;!(h<(f=u<=o?1:u>=o+26?26:u-o));u+=c)k=h-f,y=c-f,S.push(g(x(f+k%y,0))),h=p(k/y);S.push(g(x(h,0))),o=_(n,b,r==i),n=0,++r}++n,++e}return S.join("")}a={version:"1.4.1",ucs2:{decode:w,encode:y},decode:k,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)?k(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 l=1e3;o&&"number"==typeof o.maxKeys&&(l=o.maxKeys);var c=t.length;l>0&&c>l&&(c=l);for(var h=0;h<c;++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)),l=r(n(7)),c=r(n(10)),h=n(427),u=n(428),f=function(){function t(e){var n=this;(0,l.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,c.default)(t,[{key:"_fetch",value:(f=(0,a.default)(i.default.mark((function t(n,r){var a,l,c,u,f,d;return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return l={},r<1/0?l.range=(0,s.default)(c="bytes=".concat(n,"-")).call(c,n+r):r===1/0&&0!==n&&(l.range="bytes=".concat(n,"-")),t.next=4,h(this.url,{method:"GET",headers:l,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]"],l=ArrayBuffer.isView||function(t){return t&&a.indexOf(Object.prototype.toString.call(t))>-1};function c(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)||l(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=c(t),e=h(e);var n=this.map[t];this.map[t]=n?n+", "+e:e},f.prototype.delete=function(t){delete this.map[c(t)]},f.prototype.get=function(t){return t=c(t),this.has(t)?this.map[t]:null},f.prototype.has=function(t){return this.map.hasOwnProperty(c(t))},f.prototype.set=function(t,e){this.map[c(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 _=[301,302,303,307,308];x.redirect=function(t,e){if(-1===_.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 k(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 l(){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",l),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",l)}),a.send(void 0===s._bodyInit?null:s._bodyInit)}))}k.polyfill=!0,t.fetch||(t.fetch=k,t.Headers=f,t.Request=w,t.Response=x),e.Headers=f,e.Request=w,e.Response=x,e.fetch=k}({})}(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)),l=r(n(7)),c=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,l.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,c.default)(t,[{key:"get",value:(e=(0,a.default)(i.default.mark((function t(e,n,r,a){var l,c,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(l=Math.floor(a/this.chunkSize),c=Math.floor((a+r)/this.chunkSize),h=new Array(c-l+1),u=function(t){h[t-l]=g._getChunk(t).then((function(e){return{data:e,chunkNumber:t}}))},f=l;f<=c;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-l)*g.chunkSize-p;o===l&&(f=n,h=p),o===c&&(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)),l=(n(161).promisify,null),c=function(){function t(e){(0,s.default)(this,t),this.position=0,this.filename=e,this.fd=l(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=c},function(t,e,n){var r=n(1),i=r(n(48)),o=r(n(77)),s=r(n(101)),a=r(n(431)),l=r(n(16));t.exports={parseHeaderText:function(t){var e=t.split(/\r?\n/),n=[];return(0,l.default)(e).call(e,(function(t){var e=t.split(/\t/),r=(0,a.default)(e),l=r[0],c=(0,s.default)(r).call(r,1),h=(0,o.default)(c).call(c,(function(t){var e=t.split(":",2),n=(0,i.default)(e,2);return{tag:n[0],value:n[1]}}));l&&n.push({tag:l.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)),l=r(n(102)),c=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),_=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,T,A,L,M,R,I,N,O,P,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((_=J.length>3&&void 0!==J[3]?J[3]:{}).viewAsPairs=_.viewAsPairs||!1,_.pairAcrossChr=_.pairAcrossChr||!1,_.maxInsertSize=_.maxInsertSize||2e5,"string"!=typeof e){t.next=6;break}throw new w("string sequence names not yet supported");case 6:return k=e,t.next=9,this.index.getEntriesForRange(k,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(T=t.sent,A=(b=(0,f.default)(v=Array.prototype)).call.apply(b,(0,f.default)(x=[v]).call(x,(0,h.default)(T))),!_.viewAsPairs){t.next=42;break}for(I={},N={},O=0;O<A.length;O+=1)P=A[O].readName,F=A[O].uniqueId,I[P]||(I[P]=0),I[P]+=1,N[F]=1;for(D={},(0,c.default)(L=(0,l.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<A.length;z+=1)H=A[z].readName,D[H]&&A[z].mate&&(A[z].mate.sequenceId===k||_.pairAcrossChr)&&Math.abs(A[z].alignmentStart-A[z].mate.alignmentStart)<_.maxInsertSize&&(V=this.index.getEntriesForRange(A[z].mate.sequenceId,A[z].mate.alignmentStart,A[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,c.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)})),A=(0,f.default)(A).call(A,K));case 42:return t.abrupt("return",A);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=_},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,l){r(n);var c=i(e),h=o(c),u=s(c.length),f=t?u-1:0,d=t?-1:1;if(a<2)for(;;){if(f in h){l=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&&(l=n(l,h[f],f,c));return l}};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)),l=r(n(16)),c=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,_=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 k(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],l=n[5];t[r]||(t[r]=[]),t[r].push(new _({start:i,span:o,containerStart:s,sliceStart:a,sliceBytes:l}))}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,c.default)(i,10)),i="";else if(10===h)r.push((0,c.default)(i,10)),i="",k(t,r),r=[];else if(13!==h&&32!==h)throw new x("invalid .crai index file")}return i&&r.push((0,c.default)(i,10)),6===r.length&&k(t,r),(0,l.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,l;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=[],l=0;l<o.length;l+=1)0===s(o[l])&&a.push(o[l]);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 l(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function c(t,e,n){return(c="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?l(t):e}(this,s(e).call(this))).listeners||h.call(l(t)),Object.defineProperty(l(t),"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(l(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)),c(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:l};var l=i;(l&&!l.prototype.hasOwnProperty("signal")||a)&&((l=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 c=n;return{fetch:function(t,e){var n=l&&l.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,c(t,e)])}return c(t,e)},Request:l}}},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 kp{constructor(t,e,n){this.config=t,this.browser=n,this.genome=e,this.cramFile=new _p.CramFile({filehandle:new Sp(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 Sp(t.indexURL,t);this.indexedCramFile=new _p.IndexedCramFile({cram:this.cramFile,index:new _p.CraiIndex({filehandle:r}),fetchSizeLimit:3e7}),Ff.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 pf(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,l=i.alignmentStart,c=l+i.lengthOnRef;if(t<0)continue;if(t>o||l>n)return;if(t<o)continue;if(c<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?"),this.browser.alert.present(new Error(e)),t}function a(t,e){const n=new _f;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,l=a.data,c=a.pos-1,h=a.refPos-1;switch(t){case"S":case"I":case"i":case"N":case"D":if(c>o){const t=c-o;n.push(new Mf({start:h-t,seqOffset:o,len:t,type:"M"})),o+=t,s+=t+"M"}if("S"===t){let r=h;e.scLengthOnRef+=l.length,0===c&&(e.scStart-=l.length,r-=l.length);const i=l.length;n.push(new Mf({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:l.length;r.push(new Mf({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:l,type:t}),s+=l+t);break;case"H":case"P":s+=l+t}}const a=t.readLength-o;a>0&&(n.push(new Mf({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),Ff.setPairOrientation(n),n}}}class Sp{constructor(t,e){this.position=0,this.url=t,this.config=e,this.cache=new Cp({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 To.loadArrayBuffer(this.url,Is(this.config,{range:n}));return Buffer.from(r)}async read(t){let 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===r&&(i=this.position,this.position+=n),this.cache.get(t,e,n,r)}async readFile(){const t=await To.loadArrayBuffer(this.url,Is(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 Cp{constructor(t){let{fetch:e,size:n=1e7,chunkSize:r=32768}=t;this.fetch=e,this.chunkSize=r,this.lruCache=new Ep({maxSize:Math.floor(n/r)})}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),l=r-a[0].chunkNumber*this.chunkSize;a.forEach((s=>{let{data:a,chunkNumber:c}=s;const h=c*this.chunkSize;let u=0,f=this.chunkSize,d=e+(c-i)*this.chunkSize-l;c===i&&(d=e,u=l),c===o&&(f=r+n-h),a.copy(t,d,u,f)}))}_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 Ep{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};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}}var Tp={ALIGNMENT_MATCH:"M",INSERT:"I",DELETE:"D",SKIP:"N",CLIP_SOFT:"S",CLIP_HARD:"H",PAD:"P",SEQUENCE_MATCH:"=",SEQUENCE_MISMATCH:"X"};const Ap=function(t,e){this.config=t,this.genome=e,this.url=t.url,this.filter=new Rf(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};Ap.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?kc({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 kc({url:i.url+"/reads/search",body:{readGroupSetIds:[i.readGroupSetIds],referenceName:s,start:e,end:n,pageSize:"10000"},decode:o,results:new pf(t,e,n,i.config)})}));function o(t){var e,n,o,s,a,l=t.alignments,c=l.length,h=[];for(e=0;e<c;e++){let t=l[e];(n=new _f).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=Tp[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=Tp[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,l=e.length,c=0;c<l;c++){var h=e[c];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 Mf({start:a,len:h.len,seqOffset:s})),s+=h.len;break;case"M":case"EQ":case"=":case"X":o.push(new Mf({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}}}},Ap.prototype.readMetadata=function(){return _c({url:this.url,entity:"readgroupsets",entityId:this.readGroupSetIds})};class Lp{constructor(t,e){const n=e.genome;if(this.config=t,this.genome=n,Ds(t.url)&&(this.config.indexed=!1),"ga4gh"===t.sourceType)this.bamReader=new Ap(t,n);else if("pysam"===t.sourceType)this.bamReader=new qf(t,n);else if("htsget"===t.sourceType)this.bamReader=new $f(t,n);else if("shardedBam"===t.sourceType)this.bamReader=new Uf(t,n);else if("cram"===t.format)this.bamReader=new kp(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 jf(t,n):this.bamReader=new Vf(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=ff([{alignments:s}]));const a=s.length>0;if(o.packedAlignmentRows=df(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}}function Mp(t,e,n){var r,i,o,s,a,l,c,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)}ns.fillRect(t,0,0,e,n,{fillStyle:"rgb(255, 255, 255)"}),r=(c=.95*e)-8,a={x:i=c,y:o=s=.01*n},ns.strokeLine(t,r,o,i,s,h),ns.fillText(t,f(u?this.dataRange.min:this.dataRange.max),r+4,o+12,h),l={x:i,y:o=s=.99*n},ns.strokeLine(t,r,o,i,s,h),ns.fillText(t,f(u?this.dataRange.max:this.dataRange.min),r+4,o-4,h),ns.strokeLine(t,a.x,a.y,l.x,l.y,h)}class Rp{constructor(t){let{chr:e,start:n,end:r}=t;this.chr=e,this.start=n,this.end=r}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 Rp({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 Rp({chr:n,start:i,end:o})}}
|
|
63
|
+
*/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)),l=i(n(37)),c=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),_=x.parseItem,k=x.tinyMemoize,S=x.sequenceMD5,C=n(100),E=n(363);function T(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 A=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)(c.default.mark((function t(){var e,n,r;return c.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=_(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=_(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)(c.default.mark((function t(){var e,n,r,i;return c.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)(c.default.mark((function t(){var e;return c.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)(c.default.mark((function t(){var e,n;return c.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)(c.default.mark((function t(e){var n;return c.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)(c.default.mark((function t(){var e,n,r,i;return c.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)(c.default.mark((function t(){var e,n,r,i,o,s,h,u,f,d,p,m,v,y,x,_,k,C,A,L,M,R,I,N=this;return c.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),_=(0,g.default)(h=i.content.md5).call(h,(function(t){return(t<16?"0":"")+t.toString(16)})).join(""),x===_){t.next=23;break}throw new b((0,l.default)(u=(0,l.default)(f=(0,l.default)(d=(0,l.default)(p="MD5 checksum reference mismatch for ref ".concat(i.content.refSeqId," pos ")).call(p,v,"..")).call(d,y,". recorded MD5: ")).call(f,_,", calculated MD5: ")).call(u,x));case 23:return t.next=25,this.getCoreDataBlock();case 25:k=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]}}},A=function(t){var e=r.getCodecForDataSeries(t);if(!e)throw new b("no codec defined for ".concat(t," data series"));return e.decode(N,k,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,A,r,i,k,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&&T(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)(c.default.mark((function t(e){var n,r,i,l,u,f,d,p,m,v,b,w,y,x,_,k,S=this;return c.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,!(l=(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<l.length;v+=1)b=void 0!==d?d:l[v].sequenceId,(w=m[b])||(w={id:b,start:l[v].alignmentStart,end:-1/0},m[b]=w),(y=l[v].alignmentStart+(l[v].lengthOnRef||l[v].readLength)-1)>w.end&&(w.end=y),l[v].alignmentStart<w.start&&(w.start=l[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)(c.default.mark((function t(e){return c.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<l.length;x+=1)_=void 0!==d?d:l[x].sequenceId,(k=m[_])&&k.seq&&l[x].addReferenceSequence(k,p);case 24:return t.abrupt("return",l);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 k(A,t)})),t.exports=A},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),l=n(87),c=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=c(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++)l(n,v,m?g(f[v],v):f[v]);else for(u=b.call(f),n=new d;!(h=u.next()).done;v++)l(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)),l=r(n(101)),c=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 _(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),l=5,c=0;c<n;c+=1)a[c]=t[o](l),l+=s;return a}(n);throw new v("Unrecognized tag type ".concat(t))}function k(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,c.default)((0,l.default)(t).call(t,0,n)))}return String.fromCharCode.apply(String,(0,c.default)(t))}return String(t)}t.exports=function(t,e,n,r,l,c,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=k(e("RN"))),p.isDetached()){var g={};g.flags=e("MF"),n.readNamesIncluded||(g.readName=k(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),T=C.substr(2,1),A=n.getCodecForTag(C);if(!A)throw new v("no codec defined for auxiliary tag ".concat(C));var L=A.decode(t,l,c,h);p.tags[E]=_(T,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,O=e("FN");O&&(p.readFeatures=function(t,e,n,r,i){var o=0,s=t.alignmentStart-1,a=new Array(e);function l(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 c=0;c<e;c+=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=l(p);var g={B:["number","QS"]}[h];g&&(f.data=[f.data,l(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[c]=f}return a}(p,O,e,0,u));var P,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)(P="".concat(p.sequenceId,":")).call(P,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),l=n(28),c=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=l(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&&c(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 l,c=r(t);!(o=(l=c.next()).done)&&(n.push(l.value),!e||n.length!==e);o=!0);}catch(t){s=!0,a=t}finally{try{o||null==c.return||c.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)),l=r(n(10)),c=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,l.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(","),l=String.fromCharCode.apply(String,(0,c.default)(a));r+=l,i+=l.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)),l=r(n(10)),c=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,l.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 c("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),l=n(416),c=n(417),h={1:o,3:i,4:a,5:s,6:l,7:n(418),9:c};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)),l=r(n(159)),c=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,c.default)(t,2),o=i[0],s=i[1];o=(0,l.default)(o,10),(0,u.default)(s).call(s,(function(t){var i={bitLength:o,value:t};r+=1;var s,a,l=o-n;if(r<<=l,i.bitCode=r,n+=l,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,l,c;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)(l=this.sortedCodes).call(l,(function(t){return t.bitLength}));var h=Math.max.apply(Math,(0,o.default)(this.sortedBitCodes));this.bitCodeToValue=(0,i.default)(c=new Array(h+1)).call(c,-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 l=this.bitCodeToValue[o];if(l>-1&&this.sortedBitLengthsByBitCode[l]===a)return this.sortedValuesByBitCode[l];for(var c=s;this.sortedCodes[c+1].bitLength===a&&c<this.sortedCodes.length;c+=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),l=[].sort,c=[1,2,3],h=s((function(){c.sort(void 0)})),u=s((function(){c.sort(null)})),f=a("sort");r({target:"Array",proto:!0,forced:h||!u||f},{sort:function(t){return void 0===t?l.call(o(this)):l.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)),l=r(n(27)),c=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,l.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,c.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)),l=r(n(27)),c=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,l.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,c.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)),l=i(n(32)),c=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,l.default)(this,(0,c.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)),l=r(n(33)),c=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 c("".concat(t.dataType," decoding not yet implemented by BETA codec"));return t}return(0,l.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)),l=r(n(33)),c=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 c("".concat(t.dataType," decoding not yet implemented by GAMMA codec"));return t}return(0,l.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)),l=r(n(33)),c=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 c("".concat(t.dataType," decoding not yet implemented by SUBEXP codec"));return t}return(0,l.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]*$/,l=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,c=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),h=["'"].concat(c),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("#")?"?":"#",c=t.split(a);c[0]=c[0].replace(/\\/g,"/");var w=t=c.join(a);if(w=w.trim(),!n&&1===t.split("#").length){var y=l.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 _=(x=x[0]).toLowerCase();this.protocol=_,w=w.substr(x.length)}if(n||x||w.match(/^\/\/[^@\/]+@[^@\/]+/)){var k="//"===w.substr(0,2);!k||x&&m[x]||(w=w.substr(2),this.slashes=!0)}if(!m[x]&&(k||x&&!v[x])){for(var S,C,E=-1,T=0;T<f.length;T++)-1!==(A=w.indexOf(f[T]))&&(-1===E||A<E)&&(E=A);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,T=0;T<u.length;T++){var A;-1!==(A=w.indexOf(u[T]))&&(-1===E||A<E)&&(E=A)}-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=(T=0,M.length);T<R;T++){var I=M[T];if(I&&!I.match(d)){for(var N="",O=0,P=I.length;O<P;O++)I.charCodeAt(O)>127?N+="x":N+=I[O];if(!N.match(d)){var F=M.slice(0,T),D=M.slice(T+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[_])for(T=0,R=h.length;T<R;T++){var V=h[T];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[_]&&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 l=Object.keys(t),c=0;c<l.length;c++){var h=l[c];"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,_=x,k=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&&(""===k[0]?k[0]=n.host:k.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]||""===k[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,k=p;else if(p.length)k||(k=[]),k.pop(),k=k.concat(p),n.search=t.search,n.query=t.query;else if(!i.isNullOrUndefined(t.search))return S&&(n.hostname=n.host=k.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(!k.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var C=k.slice(-1)[0],E=(n.host||t.host||k.length>1)&&("."===C||".."===C)||""===C,T=0,A=k.length;A>=0;A--)"."===(C=k[A])?k.splice(A,1):".."===C?(k.splice(A,1),T++):T&&(k.splice(A,1),T--);if(!x&&!_)for(;T--;T)k.unshift("..");!x||""===k[0]||k[0]&&"/"===k[0].charAt(0)||k.unshift(""),E&&"/"!==k.join("/").substr(-1)&&k.push("");var L,M=""===k[0]||k[0]&&"/"===k[0].charAt(0);return S&&(n.hostname=n.host=M?"":k.length?k.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&&k.length)&&!M&&k.unshift(""),k.length?n.pathname=k.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,l=2147483647,c=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 _(t,e,n){var r=0;for(t=n?p(t/700):t>>1,t+=p(t/e);t>455;r+=c)t=p(t/35);return p(r+36*t/(t+38))}function k(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=c;i>=v&&m("invalid-input"),((h=(d=t.charCodeAt(i++))-48<10?d-22:d-65<26?d-65:d-97<26?d-97:c)>=c||h>p((l-b)/s))&&m("overflow"),b+=h*s,!(h<(u=a<=x?1:a>=x+26?26:a-x));a+=c)s>p(l/(f=c-u))&&m("overflow"),s*=f;x=_(b-o,e=g.length+1,0==o),p(b/e)>l-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,k,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=l,s=0;s<v;++s)(d=t[s])>=e&&d<a&&(a=d);for(a-e>p((l-n)/(b=r+1))&&m("overflow"),n+=(a-e)*b,e=a,s=0;s<v;++s)if((d=t[s])<e&&++n>l&&m("overflow"),d==e){for(h=n,u=c;!(h<(f=u<=o?1:u>=o+26?26:u-o));u+=c)k=h-f,y=c-f,S.push(g(x(f+k%y,0))),h=p(k/y);S.push(g(x(h,0))),o=_(n,b,r==i),n=0,++r}++n,++e}return S.join("")}a={version:"1.4.1",ucs2:{decode:w,encode:y},decode:k,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)?k(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 l=1e3;o&&"number"==typeof o.maxKeys&&(l=o.maxKeys);var c=t.length;l>0&&c>l&&(c=l);for(var h=0;h<c;++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)),l=r(n(7)),c=r(n(10)),h=n(427),u=n(428),f=function(){function t(e){var n=this;(0,l.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,c.default)(t,[{key:"_fetch",value:(f=(0,a.default)(i.default.mark((function t(n,r){var a,l,c,u,f,d;return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return l={},r<1/0?l.range=(0,s.default)(c="bytes=".concat(n,"-")).call(c,n+r):r===1/0&&0!==n&&(l.range="bytes=".concat(n,"-")),t.next=4,h(this.url,{method:"GET",headers:l,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]"],l=ArrayBuffer.isView||function(t){return t&&a.indexOf(Object.prototype.toString.call(t))>-1};function c(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)||l(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=c(t),e=h(e);var n=this.map[t];this.map[t]=n?n+", "+e:e},f.prototype.delete=function(t){delete this.map[c(t)]},f.prototype.get=function(t){return t=c(t),this.has(t)?this.map[t]:null},f.prototype.has=function(t){return this.map.hasOwnProperty(c(t))},f.prototype.set=function(t,e){this.map[c(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 _=[301,302,303,307,308];x.redirect=function(t,e){if(-1===_.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 k(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 l(){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",l),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",l)}),a.send(void 0===s._bodyInit?null:s._bodyInit)}))}k.polyfill=!0,t.fetch||(t.fetch=k,t.Headers=f,t.Request=w,t.Response=x),e.Headers=f,e.Request=w,e.Response=x,e.fetch=k}({})}(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)),l=r(n(7)),c=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,l.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,c.default)(t,[{key:"get",value:(e=(0,a.default)(i.default.mark((function t(e,n,r,a){var l,c,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(l=Math.floor(a/this.chunkSize),c=Math.floor((a+r)/this.chunkSize),h=new Array(c-l+1),u=function(t){h[t-l]=g._getChunk(t).then((function(e){return{data:e,chunkNumber:t}}))},f=l;f<=c;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-l)*g.chunkSize-p;o===l&&(f=n,h=p),o===c&&(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)),l=(n(161).promisify,null),c=function(){function t(e){(0,s.default)(this,t),this.position=0,this.filename=e,this.fd=l(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=c},function(t,e,n){var r=n(1),i=r(n(48)),o=r(n(77)),s=r(n(101)),a=r(n(431)),l=r(n(16));t.exports={parseHeaderText:function(t){var e=t.split(/\r?\n/),n=[];return(0,l.default)(e).call(e,(function(t){var e=t.split(/\t/),r=(0,a.default)(e),l=r[0],c=(0,s.default)(r).call(r,1),h=(0,o.default)(c).call(c,(function(t){var e=t.split(":",2),n=(0,i.default)(e,2);return{tag:n[0],value:n[1]}}));l&&n.push({tag:l.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)),l=r(n(102)),c=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),_=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,T,A,L,M,R,I,N,O,P,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((_=J.length>3&&void 0!==J[3]?J[3]:{}).viewAsPairs=_.viewAsPairs||!1,_.pairAcrossChr=_.pairAcrossChr||!1,_.maxInsertSize=_.maxInsertSize||2e5,"string"!=typeof e){t.next=6;break}throw new w("string sequence names not yet supported");case 6:return k=e,t.next=9,this.index.getEntriesForRange(k,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(T=t.sent,A=(b=(0,f.default)(v=Array.prototype)).call.apply(b,(0,f.default)(x=[v]).call(x,(0,h.default)(T))),!_.viewAsPairs){t.next=42;break}for(I={},N={},O=0;O<A.length;O+=1)P=A[O].readName,F=A[O].uniqueId,I[P]||(I[P]=0),I[P]+=1,N[F]=1;for(D={},(0,c.default)(L=(0,l.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<A.length;z+=1)H=A[z].readName,D[H]&&A[z].mate&&(A[z].mate.sequenceId===k||_.pairAcrossChr)&&Math.abs(A[z].alignmentStart-A[z].mate.alignmentStart)<_.maxInsertSize&&(V=this.index.getEntriesForRange(A[z].mate.sequenceId,A[z].mate.alignmentStart,A[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,c.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)})),A=(0,f.default)(A).call(A,K));case 42:return t.abrupt("return",A);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=_},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,l){r(n);var c=i(e),h=o(c),u=s(c.length),f=t?u-1:0,d=t?-1:1;if(a<2)for(;;){if(f in h){l=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&&(l=n(l,h[f],f,c));return l}};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)),l=r(n(16)),c=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,_=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 k(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],l=n[5];t[r]||(t[r]=[]),t[r].push(new _({start:i,span:o,containerStart:s,sliceStart:a,sliceBytes:l}))}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,c.default)(i,10)),i="";else if(10===h)r.push((0,c.default)(i,10)),i="",k(t,r),r=[];else if(13!==h&&32!==h)throw new x("invalid .crai index file")}return i&&r.push((0,c.default)(i,10)),6===r.length&&k(t,r),(0,l.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,l;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=[],l=0;l<o.length;l+=1)0===s(o[l])&&a.push(o[l]);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 l(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function c(t,e,n){return(c="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?l(t):e}(this,s(e).call(this))).listeners||h.call(l(t)),Object.defineProperty(l(t),"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(l(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)),c(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:l};var l=i;(l&&!l.prototype.hasOwnProperty("signal")||a)&&((l=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 c=n;return{fetch:function(t,e){var n=l&&l.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,c(t,e)])}return c(t,e)},Request:l}}},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 kp{constructor(t,e,n){this.config=t,this.browser=n,this.genome=e,this.cramFile=new _p.CramFile({filehandle:new Sp(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 Sp(t.indexURL,t);this.indexedCramFile=new _p.IndexedCramFile({cram:this.cramFile,index:new _p.CraiIndex({filehandle:r}),fetchSizeLimit:3e7}),Ff.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 pf(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,l=i.alignmentStart,c=l+i.lengthOnRef;if(t<0)continue;if(t>o||l>n)return;if(t<o)continue;if(c<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?"),this.browser.alert.present(new Error(e)),t}function a(t,e){const n=new _f;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,l=a.data,c=a.pos-1,h=a.refPos-1;switch(t){case"S":case"I":case"i":case"N":case"D":if(c>o){const t=c-o;n.push(new Mf({start:h-t,seqOffset:o,len:t,type:"M"})),o+=t,s+=t+"M"}if("S"===t){let r=h;e.scLengthOnRef+=l.length,0===c&&(e.scStart-=l.length,r-=l.length);const i=l.length;n.push(new Mf({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:l.length;r.push(new Mf({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:l,type:t}),s+=l+t);break;case"H":case"P":s+=l+t}}const a=t.readLength-o;a>0&&(n.push(new Mf({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),Ff.setPairOrientation(n),n}}}class Sp{constructor(t,e){this.position=0,this.url=t,this.config=e,this.cache=new Cp({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 To.loadArrayBuffer(this.url,Is(this.config,{range:n}));return Buffer.from(r)}async read(t){let 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===r&&(i=this.position,this.position+=n),this.cache.get(t,e,n,r)}async readFile(){const t=await To.loadArrayBuffer(this.url,Is(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 Cp{constructor(t){let{fetch:e,size:n=1e7,chunkSize:r=32768}=t;this.fetch=e,this.chunkSize=r,this.lruCache=new Ep({maxSize:Math.floor(n/r)})}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),l=r-a[0].chunkNumber*this.chunkSize;a.forEach((s=>{let{data:a,chunkNumber:c}=s;const h=c*this.chunkSize;let u=0,f=this.chunkSize,d=e+(c-i)*this.chunkSize-l;c===i&&(d=e,u=l),c===o&&(f=r+n-h),a.copy(t,d,u,f)}))}_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 Ep{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};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}}var Tp={ALIGNMENT_MATCH:"M",INSERT:"I",DELETE:"D",SKIP:"N",CLIP_SOFT:"S",CLIP_HARD:"H",PAD:"P",SEQUENCE_MATCH:"=",SEQUENCE_MISMATCH:"X"};const Ap=function(t,e){this.config=t,this.genome=e,this.url=t.url,this.filter=new Rf(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};Ap.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?Sc({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 Sc({url:i.url+"/reads/search",body:{readGroupSetIds:[i.readGroupSetIds],referenceName:s,start:e,end:n,pageSize:"10000"},decode:o,results:new pf(t,e,n,i.config)})}));function o(t){var e,n,o,s,a,l=t.alignments,c=l.length,h=[];for(e=0;e<c;e++){let t=l[e];(n=new _f).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=Tp[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=Tp[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,l=e.length,c=0;c<l;c++){var h=e[c];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 Mf({start:a,len:h.len,seqOffset:s})),s+=h.len;break;case"M":case"EQ":case"=":case"X":o.push(new Mf({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}}}},Ap.prototype.readMetadata=function(){return kc({url:this.url,entity:"readgroupsets",entityId:this.readGroupSetIds})};class Lp{constructor(t,e){const n=e.genome;if(this.config=t,this.genome=n,Ds(t.url)&&(this.config.indexed=!1),"ga4gh"===t.sourceType)this.bamReader=new Ap(t,n);else if("pysam"===t.sourceType)this.bamReader=new qf(t,n);else if("htsget"===t.sourceType)this.bamReader=new $f(t,n);else if("shardedBam"===t.sourceType)this.bamReader=new Uf(t,n);else if("cram"===t.format)this.bamReader=new kp(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 jf(t,n):this.bamReader=new Vf(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=ff([{alignments:s}]));const a=s.length>0;if(o.packedAlignmentRows=df(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}}function Mp(t,e,n){var r,i,o,s,a,l,c,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)}ns.fillRect(t,0,0,e,n,{fillStyle:"rgb(255, 255, 255)"}),r=(c=.95*e)-8,a={x:i=c,y:o=s=.01*n},ns.strokeLine(t,r,o,i,s,h),ns.fillText(t,f(u?this.dataRange.min:this.dataRange.max),r+4,o+12,h),l={x:i,y:o=s=.99*n},ns.strokeLine(t,r,o,i,s,h),ns.fillText(t,f(u?this.dataRange.max:this.dataRange.min),r+4,o-4,h),ns.strokeLine(t,a.x,a.y,l.x,l.y,h)}class Rp{constructor(t){let{chr:e,start:n,end:r}=t;this.chr=e,this.start=n,this.end=r}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 Rp({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 Rp({chr:n,start:i,end:o})}}
|
|
64
64
|
/*!
|
|
65
65
|
* vanilla-picker v2.12.1
|
|
66
66
|
* https://vanilla-picker.js.org
|
|
67
67
|
*
|
|
68
68
|
* Copyright 2017-2021 Andreas Borgen (https://github.com/Sphinxxxx), Adam Brooks (https://github.com/dissimulate)
|
|
69
69
|
* Released under the ISC license.
|
|
70
|
-
*/var Ip=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},Np=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}}(),Op=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 Pp={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 Fp(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 Dp=function(){function t(e,n,r,i){Ip(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=Op(n,4),i=r[0],s=r[1],a=r[2],l=r[3];void 0===l&&(l=1),i/=360,s/=100,a/=100,o.hsla=[i,s,a,l]}else if(e.startsWith("rgb")){var c=e.match(/([\-\d\.e]+)/g).map(Number),h=Op(c,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 Np(t,[{key:"printRGB",value:function(t){var e=(t?this.rgba:this.rgba.slice(0,3)).map((function(t,e){return Fp(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 Fp(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=Pp[n];return void 0===r?r:t.hexToRgb(r.replace(/\-/g,"00").padStart(6,"f"))}},{key:"rgbToHsl",value:function(t){var e=Op(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),l=void 0,c=void 0,h=(s+a)/2;if(s===a)l=c=0;else{var u=s-a;switch(c=h>.5?u/(2-s-a):u/(s+a),s){case n:l=(r-i)/u+(r<i?6:0);break;case r:l=(i-n)/u+2;break;case i:l=(n-r)/u+4}l/=6}return[l,c,h,o]}},{key:"hslToRgb",value:function(t){var e=Op(t,4),n=e[0],r=e[1],i=e[2],o=e[3],s=void 0,a=void 0,l=void 0;if(0===r)s=a=l=i;else{var c=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=c(u,h,n+1/3),a=c(u,h,n),l=c(u,h,n-1/3)}var f=[255*s,255*a,255*l].map(Math.round);return f[3]=o,f}}]),t}(),Bp=function(){function t(){Ip(this,t),this._events=[]}return Np(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 zp(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(),l=a.width,c=a.height,h=o.clientX,u=o.clientY,f=i(h-a.left,0,l),d=i(u-a.top,0,c);n(f/l,d/c)}}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}))}var Hp="keydown",Vp="mousedown",jp="focusin";function Up(t,e){return(e||document).querySelector(t)}function qp(t){t.preventDefault(),t.stopPropagation()}function Wp(t,e,n,r,i){t.add(e,Hp,(function(t){n.indexOf(t.key)>=0&&(i&&qp(t),r(t))}))}var $p=function(){function t(e){Ip(this,t),this.settings={popup:"right",layout:"default",alpha:!0,editor:!0,editorFormat:"hex",cancelButton:!1,defaultColor:"#0cf"},this._events=new Bp,this.onChange=null,this.onDone=null,this.onOpen=null,this.onClose=null,this.setOptions(e)}return Np(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),Wp(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&&t.type===Hp?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(e===Vp||e===jp){var r=(this.__containedEvent||0)+100;t.timeStamp>r&&(n=!0)}else qp(t),n=!0;else n=!0;n&&this.hide()&&(this.settings.parent.style.pointerEvents="",e!==Vp&&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 Dp(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=Up(".picker_hue",e),this._domSL=Up(".picker_sl",e),this._domA=Up(".picker_alpha",e),this._domEdit=Up(".picker_editor input",e),this._domSample=Up(".picker_sample",e),this._domOkay=Up(".picker_done button",e),this._domCancel=Up(".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()})),zp(r,this._domH,(function(t,n){return e._setHSLA(t)})),zp(r,this._domSL,(function(t,n){return e._setHSLA(null,t,1-n)})),this.settings.alpha&&zp(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,Vp,e),i(window,jp,e),Wp(r,n,["Esc","Escape"],e);var o=function(e){t.__containedEvent=e.timeStamp};i(n,Vp,o),i(n,jp,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),Wp(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,l=this._domA,c=Up(".picker_selector",s),h=Up(".picker_selector",a),u=Up(".picker_selector",l);b(0,c,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}(),Gp=document.createElement("style");function Zp(t){if(Xp[t])return Xp[t];if(Xp["chr"+t]){const e=Xp["chr"+t];return Xp[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 Xp[t]=i,i}var e,n,r}Gp.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(Gp),$p.StyleElement=Gp;const Xp={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 Yp{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 Kp(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 Kp{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 Qp=Math.exp(5);class Jp{static isInstalled(){return void 0!==window.JBrowseReactCircularGenomeView&&void 0!==window.React&&void 0!==window.ReactDOM}constructor(t,e){if(e=e||{},this.config=e,Jp.isInstalled()){this.parent=t,this.groupByTrack=!0===e.groupByTrack,this.chordManager=new Yp(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*Qp),o=document.createElement("div");o.className="igv-circview-button",o.innerHTML=" ",e.appendChild(o),o.style.backgroundColor=tg(t.color,1);const s={parent:o,popup:"right",editorFormat:"rgb",color:t.color,onChange:({rgbaString:e})=>{o.style.backgroundColor=tg(e,1),this.setColor(t.name,e),r.value=i(eg(t.color))}},a=new $p(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(eg(t.color)),r.oninput=()=>{const e=(n=r.value,Math.exp(n/200)/Qp);var n;this.setColor(t.name,tg(t.color,e)),a.setColor(t.color)},e.appendChild(r);const l=document.createElement("div");l.style.color="black",e.appendChild(l),l.innerText=l.title=t.name}setAssembly(t){const e=this.genomeId||ig();if(this.genomeId===e)return;this.chordManager.clearChords(),this.genomeId=e,this.chrNames=new Set(t.chromosomes.map((t=>ng(t.name))));const n=[],r=[];for(let e of t.chromosomes){const t=ng(e.name);r.push(e.color||Zp(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||ig()};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||rg;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 tg(t,e){const[n,r,i,o]=t.split(",");return`${n},${r},${i},${e})`}function eg(t){return t.startsWith("rgba(")?Number(t.split(",")[3].replace(")","")):1}function ng(t){return t.startsWith("chr")?t.substring(3):t}function rg(t,e,n){console.log(t)}function ig(){return("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)}if("undefined"!=typeof document){function Iv(t){for(let e of document.styleSheets)if(e=e.href?e.href.replace(/^.*[\\\/]/,""):"",e===t)return!0;return!1}Iv("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 og=t=>t.startsWith("chr")?t.substring(3):t;function sg(t){const e=[],n=[];for(let r of t.wgChromosomeNames){const i=t.getChromosome(r);n.push(gg(i.name)),e.push({name:i.name,bpLength:i.bpLength})}return e}function ag(t,e,n,r){const i=vo.addAlpha("all"===n.chr?e.color:gg(n.chr),r),o=vo.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 lg{constructor(t,e){let{minTLENPercentile:n,maxTLENPercentile:r}=e;this.totalCount=0,this.frCount=0,this.rfCount=0,this.ffCount=0,this.sumF=0,this.sumF2=0,this.lp=void 0===n?.1:n,this.up=void 0===r?99.5:r,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:cg(this.isizes,this.lp),this.maxTLEN=cg(this.isizes,this.up)}}function cg(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 hg extends Al{constructor(t,e){super(t,e)}init(t){super.init(t),this.type="alignment",void 0===t.alleleFreqThreshold&&(t.alleleFreqThreshold=.2),this.featureSource=new Lp(t,this.browser),this.showCoverage=void 0===t.showCoverage||t.showCoverage,this.showAlignments=void 0===t.showAlignments||t.showAlignments,this.coverageTrack=new ug(t,this),this.alignmentTrack=new fg(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&&(n.sortRows(t),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 lg(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&&o.sortRows(s),o}computePixelHeight(t){return(this.showCoverage?this.coverageTrack.height:0)+(this.showAlignments?this.alignmentTrack.computePixelHeight(t):0)+15}draw(t){ns.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){let e;return e=!0===this.showCoverage&&t.y>=this.coverageTrack.top&&t.y<this.coverageTrack.height?this.coverageTrack.getClickedObject(t):this.alignmentTrack.getClickedObject(t),e?[e]:void 0}hoverText(t){if(!0===this.showCoverage&&t.y>=this.coverageTrack.top&&t.y<this.coverageTrack.height){const e=this.coverageTrack.getClickedObject(t);if(e)return e.hoverText()}}menuItemList(){let t=[];t=t.concat($o.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(Wo("Show Coverage",this.showCoverage)),click:()=>{this.showCoverage=!this.showCoverage,i(),this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),t.push({object:pe(Wo("Show Alignments",this.showAlignments)),click:()=>{this.showAlignments=!this.showAlignments,i(),this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),t.push("<hr/>"),t.push({object:pe(Wo("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(Wo("Show mismatches",this.showMismatches)),click:()=>{this.showMismatches=!this.showMismatches,this.config.showMismatches=this.showMismatches,this.trackView.repaintViews()}}),t.push({object:pe(Wo("Show insertions",this.showInsertions)),click:()=>{this.showInsertions=!this.showInsertions,this.config.showInsertions=this.showInsertions,this.getCachedAlignmentContainers(),this.trackView.repaintViews()}}),t.push({object:pe(Wo("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(Wo("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(Wo("expand","EXPANDED"===this.alignmentTrack.displayMode)),click:()=>{this.alignmentTrack.displayMode="EXPANDED",this.config.displayMode="EXPANDED",this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),t.push({object:pe(Wo("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(Wo(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 Qo("Set1"))):(this.alignmentTrack.colorBy="none",this.alignmentTrack.colorByTag=""),this.trackView.repaintViews()}},e)},init: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));ag((t=>{const e=[];for(let n of t)if(n.paired)n.firstAlignment&&n.secondAlignment&&e.push({uniqueId:n.readName,refName:og(n.firstAlignment.chr),start:n.firstAlignment.start,end:n.firstAlignment.end,mate:{refName:og(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:og(n.chr),start:n.start,end:n.end,mate:{refName:og(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)}ag((t=>{const e=t=>{const e=yf(t.tags().SA);let r=0;for(let i of e)i.start!==t.start&&n.push({uniqueId:`${t.readName}_${r++}`,refName:og(t.chr),start:t.start,end:t.end,mate:{refName:og(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 ug{constructor(t,e){this.parent=e,this.featureSource=e.featureSource,this.height=void 0!==t.coverageTrackHeight?t.coverageTrackHeight:50,this.paintAxis=Mp,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,l=a+t.pixelWidth*s+1;let c;c=this.parent.coverageColor?this.parent.coverageColor:void 0!==this.parent.color&&"function"!=typeof this.parent.color?vo.darkenLighten(this.parent.color,-35):"rgb(150, 150, 150)",ns.setProperties(r,{fillStyle:c,strokeStyle:c});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>l)break;const n=i.coverage[t];if(!n)continue;const o=Math.round(n.total/this.dataRange.max*this.height),c=this.height-o,u=Math.floor((e-a)/s);ns.fillRect(r,u,c,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>l)break;const c=i.coverage[t];if(!c)continue;const u=c.total/this.dataRange.max*this.height;let f=this.height-u;const d=Math.floor((e-a)/s),p=o[t];if(c.isMismatch(p)){ns.setProperties(r,{fillStyle:n[p]}),ns.fillRect(r,d,f,h,u);let t=0;for(let e of["A","C","T","G"]){const i=(c["pos"+e]+c["neg"+e])/this.dataRange.max*this.height;f=this.height-i-t,t+=i,ns.setProperties(r,{fillStyle:n[e]}),ns.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 fg{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.insertionTextColor=t.insertionTextColor||"white",this.showInsertionText=void 0!==t.showInsertionText&&!!t.showInsertionText,this.deletionColor=t.deletionColor||"black",this.deletionTextColor=t.deletionTextColor||"black",this.showDeletionText=void 0!==t.showDeletionText&&!!t.showDeletionText,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,l=this.parent.showAllBases,c=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),ns.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 cf?(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),l=(t.connectingStart-i)/r,c=(t.connectingEnd-i)/r,h=e+o/2;t.connectingEnd<i||t.connectingStart>s||(t.mq<=0&&(a=vo.addAlpha(a,.15)),ns.setProperties(n,{fillStyle:a,strokeStyle:a}),ns.strokeLine(n,l,h,c,h))}function v(t,h,f){if(t.start+t.lengthOnRef<i||t.start>s)return;const d=a?t.blocks:t.blocks.filter((t=>"S"!==t.type));let p=this.getAlignmentColor(t);const m=p;t.mq<=0&&(p=vo.addAlpha(p,.15)),ns.setProperties(n,{fillStyle:p,strokeStyle:m});const v=[];for(let t=0;t<d.length;t++){const e=d[t];if(!(t!==d.length-1&&d[t+1].start<i)&&(v.push(...b.call(this,e,t)),e.start+e.len>s))break}if(t.gaps){const e=h+f/2;for(let o of t.gaps){const t=(o.start-i)/r,s=(o.start+o.len-i)/r,a=s-t,l=o.len.toString(),c=6*l.length,u=t+a/2,f="D"===o.type?this.deletionColor:this.skippedColor;if(ns.strokeLine(n,t,e,s,e,{strokeStyle:f,lineWidth:2}),this.showDeletionText&&o.len>1&&a>=c+8){const t=u-c/2;ns.fillRect(n,t-1,h-1,c+2,12,{fillStyle:"white"}),ns.fillText(n,l,t,h+10,{font:"normal 10px monospace",fillStyle:this.deletionTextColor})}}}if(t.insertions&&this.parent.showInsertions){let e=-1;for(let o of t.insertions){if(this.hideSmallIndels&&o.len<=this.indelSizeThreshold)continue;if(o.start<i)continue;if(o.start>s)break;const t=o.start-i,a=o.len.toString(),l=2+6*a.length,c=this.showInsertionText&&1!==o.len?Math.round(o.len/r):2,u=Math.max(Math.min(l,c),2),d=t/r-u/2;if(d-e>2){const t={fillStyle:this.insertionColor};ns.fillRect(n,d-2,h,u+4,2,t),ns.fillRect(n,d,h+2,u,f-4,t),ns.fillRect(n,d-2,h+f-2,u+4,2,t),this.showInsertionText&&o.len>1&&c>l&&ns.fillText(n,a,d+1,h+10,{font:"normal 10px monospace",fillStyle:this.insertionTextColor}),e=d}}}function b(s,a){const v=[],b=s.start-e.start,w=(s.start-i)/r,y=(s.start+s.len-i)/r,x=Math.max(1,y-w),_=100/r,k=Math.min(g/2,_/6),S="S"===s.type,C=t.mq<=0||this.highlightedAlignmentReadNamed===t.readName||S;let E=m;this.highlightedAlignmentReadNamed===t.readName?E="red":S&&(E="rgb(50,50,50)");const T=!0===t.strand&&a===d.length-1,A=!1===t.strand&&0===a;if(T|A){let t,e;T?(t=[w,y,y+k,y,w,w],e=[h,h,h+f/2,h+f,h+f,h]):A&&(t=[y,w,w-k,w,y,y],e=[h,h,h+f/2,h+f,h+f,h]),ns.fillPolygon(n,t,e,{fillStyle:p}),C&&ns.strokePolygon(n,t,e,{strokeStyle:E})}else ns.fillRect(n,w,h,x,f,{fillStyle:p}),C&&(n.save(),n.strokeStyle=E,n.strokeRect(w,h,x,f),n.restore());if(S||l||this.parent.showMismatches&&u&&t.seq&&"*"!==t.seq){const e=t.seq?t.seq.toUpperCase():void 0,n=t.qual,a=s.seqOffset,d=Math.max(1,1/r);for(let t=0,p=s.len;t<p;t++){const p=(s.start+t-i)/r;if(p+d<0)continue;if(p>o)break;let g=e?e.charAt(a+t):"";const m=b+t>=0?u.charAt(b+t):"";if("="===g&&(g=m),"X"===g||m!==g||S||l){let e;if(!S&&void 0!==n&&n.length>a+t){e=dg(n[a+t],c[g])}else e=c[g];e&&v.push({bbox:{x:p,y:h,width:d,height:f},baseColor:e,readChar:g})}}}return v}v.forEach((t=>{let{bbox:e,baseColor:i,readChar:o}=t;!function(t,e,n,r,i){var o;if(e<=.1&&n.height>=8){const e=Math.min(10,n.height);t.font=e+"px sans-serif",o=n.x+n.width/2,ns.strokeText(t,i,o-t.measureText(i).width/2,e-1+n.y,{strokeStyle:r})}else ns.fillRect(t,n.x,n.y,n.width,n.height,{fillStyle:r})}(n,r,e,i,o)}))}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,e.cachedFeatures.sortRows(o),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:" aligned read length",click:()=>r("ALIGNED_READ_LENGTH")}),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,e.cachedFeatures.sortRows(i),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 this.browser.alert.present(`Reference does not contain chromosome: ${r.mate.chr}`)}},init:void 0}),n.push({label:"View read sequence",click:()=>{const t=r.seq;t&&"*"!==t?this.browser.alert.present(t):this.browser.alert.present("Read sequence: *")}}),Vs()&&n.push({label:"Copy read sequence",click:async()=>{const t=r.seq;try{await navigator.clipboard.writeText(t)}catch(t){console.error(t),this.browser.alert.present(`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 l="SQUISHED"===this.displayMode?this.squishedRowHeight:this.alignmentRowHeight;let c=Math.floor((n-this.top-this.alignmentsYOffset)/l);if(c<0){for(let t=0;t<a.length;t++)if(a[t].start<=r&&a[t].end>=r)return a[t]}else if(c<s.length){const t=s[c].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?"function"==typeof this.parent.color?this.parent.color(t):this.parent.color:"rgb(200, 200, 200)";default:return this.getAlignmentColor(t)}}getAlignmentColor(t){let e="rgb(185, 185, 185)";this.parent.color&&(e="function"==typeof this.parent.color?this.parent.color(t):this.parent.color);const n=this.colorBy;switch(n){case"strand":e=t.strand?this.posStrandColor:this.negStrandColor;break;case"firstOfPairStrand":t instanceof cf?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=pg[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=gg(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 Qo("Set1")),e=this.tagColors.getColor(r)))}return e}}function dg(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=vo.addAlpha(e,n)),e}const pg={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 gg(t){if(mg[t])return mg[t];if(mg["chr"+t]){const e=mg["chr"+t];return mg[t]=e,e}{const e=vo.randomRGB(0,255);return mg[t]=e,e}}const mg={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 vg,bg;class wg extends Fa{constructor(t,e,n,r){super(t,e,n,r)}get contentDiv(){return this.$viewport.get(0)}initializationHelper(){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.rulerSweeper=new lf(this,this.$viewport.get(0).parentElement,this.browser,this.referenceFrame),this.attachMouseHandlers(Ra.isWholeGenomeView(this.referenceFrame.chr)),this.$tooltip.hide(),this.dismissLocusLabel()}presentLocusLabel(t){this.$rulerLabel.get(0).innerHTML="",this.$rulerLabel.get(0).style.backgroundColor=gg(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="${gg(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((t=>{let{locusSearchString:e}=t;return e}));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===bg?(bg=this,this.$tooltip.show()):bg.guid!==this.guid?(bg.$tooltip&&bg.$tooltip.hide(),this.$tooltip.show(),bg=this):this.$tooltip.show();if(this.browser.isMultiLocusWholeGenomeView()||Ra.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:`${fo(e,0,s-o)}px`}),clearTimeout(vg),vg=setTimeout((()=>{this.$tooltip&&this.$tooltip.hide()}),1e4)}}startSpinner(){}stopSpinner(){}dispose(){this.rulerSweeper.dispose(),super.dispose()}}class yg extends Fa{constructor(t,e,n,r){super(t,e,n,r)}initializationHelper(){this.canvas=document.createElement("canvas"),this.canvas.className="igv-ideogram-canvas",this.$viewport.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(t){let{referenceFrame:e}=t;ns.configureHighDPICanvas(this.ideogram_ctx,this.$viewport.width(),this.$viewport.height()),this.trackView.track.draw({context:this.ideogram_ctx,referenceFrame:e,pixelWidth:this.$viewport.width(),pixelHeight:this.$viewport.height()})}startSpinner(){}stopSpinner(){}}function xg(t,e,n,r){if("ruler"===t.track.type)return new wg(t,e,n,r);if("ideogram"===t.track.id)return new yg(t,e,n,r);return new Fa(t,e,n,r)}const _g={textAlign:"start",textBaseline:"bottom",strokeStyle:"black",fillStyle:"black"};class kg{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(t){let{context:e,samples:n}=t;if(!n||0===n.names.length)return;!function(t,e,n){let{textAlign:r,textBaseline:i,strokeStyle:o,fillStyle:s}=e;const a=Math.min(n,10);t.font=`${a}px sans-serif`,t.textAlign=r,t.textBaseline=i,t.fillStyle=s}(e,_g,n.height);e.clearRect(0,0,e.canvas.width,e.canvas.height),e.fillStyle=function(t){const{r:e,g:n,b:r}=Yo[t];return`rgb(${e},${n},${r})`}("lead");const r=this.viewport.getBoundingClientRect().height;let i=(n.yOffset||0)+this.contentTop;for(let t of n.names){if(i>r)break;if(i+n.height>0){const r=t,o=Sg(e,r,i,n.height);e.fillText(r,4,o)}i+=n.height}}renderSVGContext(t,e){let{deltaX:n,deltaY:r}=e;if("function"==typeof this.trackView.track.getSamples){const e=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,n,r+i,o,s,-i),this.draw({context:t,samples:e}),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 Sg(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)}const Cg=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),_e(e,(()=>this.hide())),this.popoverContent=ge(),this.popover.appendChild(this.popoverContent),wo(this.popover,e),e.addEventListener("click",(t=>{t.stopPropagation(),t.preventDefault()})),this.hide()};Cg.prototype.hide=function(){this.popover.style.display="none"},Cg.prototype.presentMenuList=function(t){if(Eg(),t.length>0){this.popoverContent.innerHTML="",t=$o.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"}},Cg.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=Wo("Show all bases",t.value);else if("color"===t.type){const n=new As({parent:i.parentElement,width:364});n.configure(void 0,{color:e=>t.click(e)}),e=ge({class:"context-menu"}),"string"==typeof t.label&&(e.innerHTML=t.label);const r=t=>{n.show(),me(i),t.preventDefault(),t.stopPropagation()};e.addEventListener("click",r),e.addEventListener("touchend",r),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 o(e){t.click(),me(i),e.preventDefault(),e.stopPropagation()}e.addEventListener("click",o),e.addEventListener("touchend",o),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)},Cg.prototype.dispose=function(){this.popoverContent.innerHTML="",this.popover.innerHTML="",Object.keys(this).forEach((function(t){this[t]=void 0}))};const Eg=()=>{const t=document.querySelectorAll(".igv-menu-popup");for(let e=0;e<t.length;e++)t[e].style.display="none"},Tg=new Set(["ruler","ideogram"]),Ag=new Set(["ruler","sequence","ideogram"]);class Lg{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=xg(this,i[t],n[t],r);this.viewports.push(e)}this.sampleNameViewport=new kg(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,e){let{deltaX:n,deltaY:r}=e;!function(t,e,n,r,i){if("function"==typeof e.paintAxis){const{y:o,width:s,height:a}=n.getBoundingClientRect(),l=`${(e.name||e.id).replace(/\W/g,"")}_axis_guid_${be()}`;t.saveWithTranslationAndClipRect(l,r,o+i,s,a,0),e.paintAxis(t,s,a),t.restore()}}(t,this.track,this.axisCanvas,n,r);const{width:i}=this.axis.getBoundingClientRect(),{y:o}=this.viewports[0].$viewport.get(0).getBoundingClientRect();let s={deltaX:i+n,deltaY:o+r};for(let e of this.viewports){e.renderSVGContext(t,s);const{width:n}=e.$viewport.get(0).getBoundingClientRect();s.deltaX+=n}!0===this.browser.showSampleNames&&this.sampleNameViewport.renderSVGContext(t,s)}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===Ag.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(")?vo.rgbToHex(t):vo.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===Tg.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=Mg(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=Mg(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;const e=t.filter((t=>t.needsRepaint())).filter((t=>t.checkZoomIn())),n=e.filter((t=>t.needsReload()));for(let t of n)await t.loadFeatures();if(this.disposed)return;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(n.getWidth());if(n.featureCache&&n.featureCache.features)if("function"==typeof n.featureCache.features.getMax){e=[{value:n.featureCache.features.getMax(r,i)}]}else{const t=qo(n.featureCache.features,r,i);if(e)for(let n of t)e.push(n);else e=t}}"function"==typeof this.track.doAutoscale?this.track.dataRange=this.track.doAutoscale(e):this.track.dataRange=Ns(e)}const r=this.track.autoscale||this.track.autoscaleGroup||"ruler"===this.track.type;for(let n of t)e.includes(n)?n.repaint():r&&n.refresh();this.adjustTrackHeight(),this.repaintSamples(),this.updateRulerViewportLabels()}clearCachedFeatures(){for(let t of this.viewports)t.clearCache()}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=[];const e=this.viewports.filter((t=>t.isVisible()));for(let n of e){const e=n.referenceFrame,{chr:r,start:i,bpPerPixel:o}=n.referenceFrame,s=i+e.toBP(n.getWidth());if((!n.featureCache||!n.featureCache.containsRange(r,i,s,o))&&await n.loadFeatures(),n.featureCache&&n.featureCache.features)if("function"==typeof n.featureCache.features.getMax){const e=n.featureCache.features.getMax(i,s);t.push({value:e})}else{const e="function"==typeof n.featureCache.queryFeatures?n.featureCache.queryFeatures(r,i,s):qo(n.featureCache.features,i,s);t=t.concat(e)}}return t}checkContentHeight(){for(let t of this.viewports)t.checkContentHeight();this.adjustTrackHeight()}adjustTrackHeight(){var t=Mg(this.viewports);if(this.track.autoHeight?this.setTrackHeight(t,!1):this.track.paintAxis&&this.paintAxis(),!1===Tg.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===Tg.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 Cg(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===Tg.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($o.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();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 Mg(t){const e=t.map((t=>t.getContentHeight()));return Math.max(...e)}const Rg={getTissueInfo:function(t,e){let n=(e=e||"https://gtexportal.org/rest/v1")+"/dataset/tissueInfo?datasetId="+(t=t||"gtex_v8");return To.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 Ig(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 Ng(t,e,n,r,i,o){try{i.save(),i.fillStyle=this.defaultColor,i.strokeStyle=this.defaultColor;const r=Pg.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 l=o.pixelWidth,c=a+s/2,h=s/2,u=c-h/2,f=t.exons?t.exons.length:0,d=Ig(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(l,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)ns.strokeLine(i,n-2*g,c-2,n,c),ns.strokeLine(i,n-2*g,c+2,n,c);i.fillStyle=r,i.strokeStyle=r}}else{ns.strokeLine(i,d.px+1,c,d.px1-1,c);const o=Math.max(0,d.px)+p/2,m=Math.min(l,d.px1);for(let t=o;t<m;t+=p)ns.strokeLine(i,t-2*g,c-2,t,c),ns.strokeLine(i,t-2*g,c+2,t,c);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>l)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)ns.strokeLine(i,t-2*g,c-2,t,c),ns.strokeLine(i,t-2*g,c+2,t,c);i.fillStyle=r,i.strokeStyle=r}}}}o.drawLabel&&"SQUISHED"!==this.displayMode&&Og.call(this,i,t,d.px,d.px1,a,o.referenceFrame,o)}finally{i.restore()}}function Og(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 l=s.pixelXOffset||0;const c=Math.max(n,-l);let h,u=(c+Math.min(r,-l+s.viewportWidth))/2;"COLLAPSED"===this.displayMode&&"SLANT"===this.labelDisplayMode&&(h={rotate:{angle:45}});const f=function(t,e){return e?t+20:t+25}(i,h);let d,p=Pg.call(this,e),g=!1;o.selection&&Rg.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=u-v.width/2,w=u+v.width/2,y=s.rowLastLabelX[e.row]||-Number.MAX_SAFE_INTEGER;(s.labelAllFeatures||b>y||g)&&(s.rowLastLabelX[e.row]=w,"y"===s.axis?(t.save(),ns.labelTransformWithContext(t,u),ns.fillText(t,a,u,f,m,h),t.restore()):ns.fillText(t,a,u,f,m,h))}finally{t.restore()}}function Pg(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=vo.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=vo.addAlpha(e,n)}return e}const Fg=new Set(["nonsense","missense","stop-loss","frameshift","cds-indel"]),Dg=new Set(["coding-synon"]),Bg=new Set(["splice-3","splice-5"]),zg=new Set(["untranslated-5","untranslated-3"]);function Hg(t,e,n,r,i){var o,s,a,l,c=Ig(t,e,n),h=this.margin,u=this.snpColors.length;switch(o="squished"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight,this.colorBy){case"function":l=t.func,s=l.split(",").map((function(t){return Fg.has(t)||Bg.has(t)?u-1:Dg.has(t)?u-2:zg.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(c.px,h,c.pw,o)}function Vg(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,l=a-.5*o,c=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,l,u,l,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,c,s,c,s,a),i.lineWidth=1,i.strokeStyle="purple",i.stroke()}}class jg extends Al{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:ef(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||Vg,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||Hg,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||Ng,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 Jo(t.colorTable):this.colorTable=new Qo("Set1"))),this.useScore=t.useScore}async postInit(){if("function"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),void 0===this.visibilityWindow&&"function"==typeof this.featureSource.defaultVisibilityWindow&&(this.visibilityWindow=await this.featureSource.defaultVisibilityWindow()),this}get supportsWholeGenome(){return void 0!==this.config.supportsWholeGenome?this.config.supportsWholeGenome:this.featureSource&&"function"==typeof this.featureSource.supportsWholeGenome?this.featureSource.supportsWholeGenome():!(void 0!==this.visibilityWindow||!1!==this.config.indexed&&this.config.indexURL)||void 0}async getFeatures(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||ns.fillRect(n,0,t.pixelTop,o,s,{fillStyle:"rgb(255, 255, 255)"}),e){const l=[];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===l[e]?l[e]=1:l[e]++,t.rowLastX[e]=-Number.MAX_SAFE_INTEGER,t.rowLastLabelX[e]=-Number.MAX_SAFE_INTEGER}const c=o/Math.max(1,Math.max(...l));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||c>10;const l=Math.ceil((o.end-i)/r),u=h[e];if(!u||l>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,ns.strokeLine(n,a,0,a,s,{strokeStyle:"rgb(255, 255, 255)"}),n.globalAlpha=1),h[e]=l}}}else console.log("No feature list")}clickedFeatures(t){const e=t.y-this.margin,n=super.clickedFeatures(t);let r;switch(this.displayMode){case"SQUISHED":r=Math.floor(e/this.squishedRowHeight);break;case"EXPANDED":r=Math.floor(e/this.expandedRowHeight);break;default:r=void 0}return n.filter((function(t){return void 0===r||void 0===t.row||r===t.row}))}popupData(t,e){void 0===e&&(e=this.clickedFeatures(t));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===Hg){t.push("<hr/>");for(let e of["function","class"])t.push({object:pe(Wo("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(Wo(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);if(void 0===e||0===e.length)return;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);t?"-"===n.strand&&(t=Ys(t)):t="Unknown sequence",this.browser.alert.present(t)}}];return Vs()&&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);t?"-"===n.strand&&(t=Ys(t)):t="Unknown sequence";try{await navigator.clipboard.writeText(t)}catch(t){console.error(t),this.browser.alert.present(`error copying sequence to clipboard ${t}`)}}}),t.push("<hr/>"),t}}description(){if(Hg===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 Ug extends Al{constructor(t,e){super(t,e)}init(t){super.init(t),this.type="wig",this.height=t.height||50,this.featureType="numeric",this.paintAxis=Mp;const e=t.format?t.format.toLowerCase():t.format;this.flipAxis=!!t.flipAxis&&t.flipAxis,this.logScale=!!t.logScale&&t.logScale,t.featureSource?(this.featureSource=t.featureSource,delete t.featureSource):this.featureSource="bigwig"===e?new Xc(t,this.browser.genome):"tdf"===e?new Zu(t,this.browser.genome):ef(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();this.disposed||t&&this.setTrackProperties(t)}async getFeatures(t,e,n,r){const i=await this.featureSource.getFeatures({chr:t,start:e,end:n,bpPerPixel:r,visibilityWindow:this.visibilityWindow,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("<hr>"),t.push({label:"Flip y-axis",click:()=>{this.flipAxis=!this.flipAxis,this.trackView.repaintViews()}})),t=t.concat($o.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,l=-1;const c=this.color||"rgb(150,150,150)";let h;"string"==typeof c&&c.startsWith("rgb(")&&(h=vo.addAlpha(c,.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:c;const g="function"==typeof p?p(t.value):p;if("points"===this.graphType){const t=this.config.pointSize||3,r=e+d/2;ns.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>l||t.value<0&&t.value<1)&&ns.fillRect(n,e,o,d,r,{fillStyle:g}),l=t.value,a=i}}if(this.dataRange.min<0){const e=this.dataRange.max/(this.dataRange.max-this.dataRange.min)*t.pixelHeight;ns.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?ns.dashedLine(t.context,0,n,t.pixelWidth,n,5,r):ns.strokeLine(t.context,0,n,t.pixelWidth,n,r)}}popupData(t,e){if(void 0===e&&(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 qg(t){this.thresholds=t.thresholds,this.colors=t.colors}function Wg(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}qg.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]},Wg.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 $g{constructor(t){this.color=t}getColor(){return this.color}}class Gg extends Al{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 Wg({low:.1,lowR:255,lowG:255,lowB:255,high:1.5,highR:255,highG:0,highB:0}),this.negColorScale=t.negColorScale||new Wg({low:-1.5,lowR:0,lowG:0,lowB:255,high:-.1,highR:255,highG:255,highB:255}),"mut"===this.type&&(this.colorTable=new Jo(t.colorTable||Zg))),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=ef(e,this.browser.genome),this.initialSort=t.sort}async postInit(){"function"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader(),this.disposed)||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=Wo(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(t){let{context:e,renderSVG:n,pixelTop:r,pixelWidth:i,pixelHeight:o,features:s,bpPerPixel:a,bpStart:l}=t;if(ns.fillRect(e,0,r,i,o,{fillStyle:"rgb(255, 255, 255)"}),s&&s.length>0){this.checkForLog(s),this.updateSampleKeys(s);const t={};let n;switch(this.sampleKeys.forEach((function(e,n){t[e]=n})),this.displayMode){case"FILL":this.sampleHeight=o/this.sampleKeys.length,n=0;break;case"SQUISHED":this.sampleHeight=this.squishedRowHeight,n=0;break;default:this.sampleHeight=this.expandedRowHeight,n=1}const c=this.sampleHeight;for(let t of s)t.pixelRect=void 0;const h=r+o,u=l+i*a+1,f=a;this.sampleYStart=void 0;for(let i of s){if(i.end<l)continue;if(i.start>u)break;const o=i.sampleKey||i.sample;i.row=t[o];const s=i.row*c+n;void 0===this.sampleYStart&&(this.sampleYStart=s);if(s+c<r||s>h)continue;const a=Math.max(i.start,l);let d=Math.round((a-l)/f);const p=Math.min(i.end,u),g=Math.round((p-l)/f);let m,v,b=Math.max(1,g-d);if(this.color?m="function"==typeof this.color?this.color(i):this.color:this.colorTable&&(m=this.colorTable.getColor(i.value.toLowerCase())),"mut"===this.type)v=c-2*n,b<3&&(b=3,d-=1);else{let t=i.value;this.isLog||(t=po(t/2)),m=t<-.1?this.negColorScale.getColor(t):t>.1?this.posColorScale.getColor(t):"white";let e=c;if(c<.25){const n=.1+2*Math.abs(t);e=Math.min(1,n*c)}v=e-2*n}i.pixelRect={x:d,y:s,w:b,h:v},e.fillStyle=m,e.fillRect(d,s,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,l=o[a]||0;o[a]=l+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}))},l=()=>{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?l():a(),this.trackView.repaintViews()}clickedFeatures(t){const e=super.clickedFeatures(t),n=t.y;return e.filter((function(t){const e=t.pixelRect;return e&&n>=e.y&&n<=e.y+e.h}))}hoverText(t){const e=this.clickedFeatures(t);if(e&&e.length>0)return`${e[0].sample}: ${e[0].value}`}popupData(t,e){void 0===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 Zg={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 Xg extends Al{constructor(t,e){super(t,e),this.type="merged",this.featureType="numeric",this.paintAxis=Mp,this.graphType=t.graphType}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($o.numericDataMenuItems(this.trackView)),t}async getFeatures(t,e,n,r){const i=this.tracks.map((i=>i.getFeatures(t,e,n,r))),o=await Promise.all(i);return new Yg(o)}draw(t){const e=t.features;for(let n=0,r=this.tracks.length;n<r;n++){const r=Object.assign({},t);r.features=e.featureArrays[n],this.tracks[n].dataRange=this.dataRange,this.tracks[n].flipAxis=this.flipAxis,this.tracks[n].logScale=this.logScale,this.graphType&&(this.tracks[n].graphType=this.graphType),this.tracks[n].draw(r)}}popupData(t){if(t.viewport&&t.viewport.cachedFeatures){const e=t.viewport.cachedFeatures.featureArrays;if(e&&e.length===this.tracks.length){const n=[];for(let r=0;r<this.tracks.length;r++){r>0&&n.push("<hr/>"),n.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,e[r]);n.push(...i)}return n}}}clickedFeatures(t){const e=t.viewport.cachedFeatures;if(!e)return[];const n=t.genomicLocation,r=[];for(let i of e.featureArrays){const e=t.referenceFrame.bpPerPixel>.2?3*t.referenceFrame.bpPerPixel:.2,o=qo(i,n-e,n+e);for(let t of o)r.push(t)}return r}get supportsWholeGenome(){return this.tracks.every((t=>t.supportsWholeGenome))}}class Yg{constructor(t){this.featureArrays=t}getMax(t,e){let n=-Number.MAX_VALUE;for(let r of this.featureArrays)for(let i of r)if(void 0!==i.value&&!Number.isNaN(i.value)){if(i.end<t)continue;if(i.start>e)break;n=Math.max(n,i.value)}return n}}class Kg extends Al{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,this.alpha=t.alpha||.02,this.painter={flipAxis:!this.arcOrientation,dataRange:this.dataRange,paintAxis:Mp},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,t.featureSource?(this.featureSource=t.featureSource,delete t._featureSource):(this.featureSource=ef(t,this.browser.genome),this.featureSource.getWGFeatures=nm)}async postInit(){if("function"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),void 0===this.visibilityWindow&&"function"==typeof this.featureSource.defaultVisibilityWindow&&(this.visibilityWindow=await this.featureSource.defaultVisibilityWindow(),this.featureSource.visibilityWindow=this.visibilityWindow),this}get supportsWholeGenome(){return!0}async getFeatures(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;ns.fillRect(e,0,t.pixelTop,n,r,{fillStyle:"rgb(255, 255, 255)"});const l=t.features;if(l){(function(){let t=0;for(let e of l){let r=(e.start-s)/a,i=(e.end-s)/a;r>=0&&i<=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],l=e<r.length?r[e]:Math.PI/2;return Math.min(Math.PI/2,a+s*(l-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 l){let r;if(t.drawState=void 0,"function"==typeof this.color?r=this.color(t):(r=this.color||t.color||"rgb(180,25,137)",r&&this.config.useScore&&(r=em(r,(c=t.score,Math.min(1,.11+c/779*.89).toString())))),e.lineWidth=t.thickness||this.thickness||1,t.chr1===t.chr2||"all"===t.chr){const{m1:l,m2:c}=Qg(t,this.browser.genome);let u=Math.round((l-s)/a),f=Math.round((c-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,l=(t.end2-s)/a,c=this.arcOrientation?-this.blockHeight:this.blockHeight;e.fillRect(n,o,r-n,c),e.fillRect(i,o,l-i,c)}r&&!this.config.useScore&&d>i&&(r=em(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 l=o-i;l<3&&(l=3,i--);const c=t.chr===t.chr1?t.chr2:t.chr1;e.strokeStyle=r,e.fillStyle=em(gg(c),.5),h?(e.fillRect(i,this.height/2,l,this.height/2),e.fillText(c,i+l/2,this.height/2-5),t.drawState={x:i,y:this.height/2,w:l,h:this.height/2}):(e.fillRect(i,0,l,this.height/2),e.fillText(c,i+l/2,this.height/2+13),t.drawState={x:i,y:0,w:l,h:this.height/2})}}}var c}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,l=t.referenceFrame.end;ns.fillRect(e,0,t.pixelTop,n,r,{fillStyle:"rgb(255, 255, 255)"});const c=t.features;if(c&&c.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 c){t.drawState=void 0;const r=this.valueColumn?t[this.valueColumn]:t.score;if(void 0===r||Number.isNaN(r))continue;const c=Math.round((this.logScale?Math.log10(r+1):r)*i);if(t.chr1===t.chr2||"all"===t.chr){const{m1:n,m2:i}=Qg(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<=l;let r=!1,o=!1;if(!e&&t&&(r=a<=n&&n<=l,r||(o=a<=i&&i<=l)),!(e||r||o))continue}const d=f/2,p=u+f/2;t.drawState={xc:p,yc:h,radiusX:d,radiusY:c};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,c,0,0,Math.PI,g):(e.beginPath(),e.ellipse(p,h,d,c,0,0,Math.PI,g),e.stroke()),this.alpha&&(e.fillStyle=em(m,this.alpha),!0===e.isSVG?e.fillEllipse(p,h,d,c,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,l=this.arcOrientation?-this.blockHeight:this.blockHeight;e.fillRect(n,h,r-n,l),e.fillRect(i,h,a-i,l)}}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 l=Math.min(c,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=em(gg(u),.5),this.arcOrientation){const n=this.height-l;e.fillRect(i,n,h,l),e.fillText(u,i+h/2,n-5),t.drawState={x:i,y:n,w:h,h:l}}else e.fillRect(i,0,h,l),e.fillText(u,i+h/2,l+13),t.drawState={x:i,y:0,w:h,h:l}}}}}clearAxis(t,e,n){ns.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=[];if(this.hasValue){t.push("<hr/>");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(Wo(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($o.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;const n=e.map((t=>{const e=t._f||t;return{uniqueId:`${e.chr1}:${e.start1}-${e.end1}_${e.chr2}:${e.start2}-${e.end2}`,refName:og(e.chr1),start:e.start1,end:e.end1,mate:{refName:og(e.chr2),start:e.start2,end:e.end2}}}));ag(n,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){void 0===e&&(e=this.clickedFeatures(t));const n=[];for(let t of e){const e=t._||t;if(n.push({name:"Region 1",value:Jg(e.chr1,e.start1,e.end1,e.strand1)}),n.push({name:"Region 2",value:Jg(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,r=this.header.hiccups?6:10;for(let i=r;i<t.length;i++)this.header.colorColumn!==i&&("info"===t[i]?rm(n,e.extras[i-r]):n.push({name:t[i],value:e.extras[i-r]}))}break}return n}clickedFeatures(t){const e=t.viewport.cachedFeatures,n=[];if(e){const r="proportional"===this.arcType||"inView"===this.arcType||"partialInView"===this.arcType;for(let i of e)if(i.drawState)if(i.chr1===i.chr2||"all"===i.chr)if(r){const{xc:e,yc:r,radiusX:o,radiusY:s}=i.drawState,a=t.canvasX-e,l=t.canvasY-r,c=a/o*(a/o)+l/s*(l/s);c<=1&&n.push({score:1/c,feature:i})}else{const{xc:e,yc:r,r:o}=i.drawState,s=t.canvasX-e,a=t.canvasY-r,l=Math.abs(Math.sqrt(s*s+a*a)-o);l<5&&n.push({score:l,feature:i})}else{const{x:e,y:r,w:o,h:s}=i.drawState,a=5;if(t.canvasX>=e-a&&t.canvasX<=e+o+a&&t.canvasY>=r&&t.canvasY<=r+s){const r=-Math.abs(t.canvasX-(e+o/2));n.push({score:r,feature:i});break}}}return n.length>1&&n.sort(((t,e)=>t.score-e.score)),n.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 Qg(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 Jg(t,e,n,r){return r&&"."!==r?`${t}:${Se(e+1)}-${Se(n)} (${r})`:`${t}:${Se(e+1)}-${Se(n)}`}const tm=new Map;function em(t,e){const n=`${t}_${e}`;let r=tm.get(n);return r||(r=vo.addAlpha(t,e),tm.set(n,r)),r}function nm(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),l=r&&r.score>0?Math.log(r.score)/s:Number.MAX_SAFE_INTEGER;let c,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.max(0,Math.min(s-1,Math.floor(Math.log(t.score)/l))):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)c=h[0];else{c=[];for(let t of h)for(let e of t)c.push(e);r&&c.push(e(r)),c.sort((function(t,e){return t.start-e.start})),console.log(c.length)}return c}function rm(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 im=ke,om=new Map([["REF","referenceBases"],["ALT","alternateBases"],["QUAL","quality"],["FILTER","filter"]]);class sm extends Al{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=ef(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 Jo(t.colorTable))),this._strokecolor=t.strokecolor,this._context_hook=t.context_hook,this.showGenotypes=void 0===t.showGenotypes||t.showGenotypes,this.variantRowCount(1)}async postInit(){if(this.header=await this.getHeader(),!this.disposed){if(void 0===this.visibilityWindow&&!1!==this.config.indexed){const t=Ue(this.config.url)?this.config.url.name:this.config.url;im(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(t){let{context:e,pixelWidth:n,pixelHeight:r,bpPerPixel:i,bpStart:o,pixelTop:s,features:a}=t;ns.fillRect(e,0,s,n,r,{fillStyle:"rgb(255, 255, 255)"});const l="SQUISHED"===this.displayMode?this.squishedVGap:this.expandedVGap,c="COLLAPSED"===this.displayMode?1:this.nVariantRows,h="SQUISHED"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight;this.variantBandHeight=10+c*(h+l);let u=this.callSets;!u&&this._f&&(u=this._f.callSets);const f=this.getCallsetsLength();if(u&&f>0&&!1!==this.showGenotypes&&ns.strokeLine(e,0,this.variantBandHeight,n,this.variantBandHeight,{strokeStyle:"rgb(224,224,224) "}),a){const t="SQUISHED"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight,r="SQUISHED"===this.displayMode?this.squishedVGap:this.expandedVGap,s=o+n*i+1;for(let n of a){if(n.end<o)continue;if(n.start>s)break;const a="SQUISHED"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,l=10+("COLLAPSED"===this.displayMode?0:n.row*(a+r)),c=a;let h=Math.round((n.start-o)/i),d=Math.round((n.end-o)/i),p=Math.max(1,d-h);p<3?(p=3,h-=1):p>5&&(h+=1,p-=2),e.fillStyle=this.getVariantColor(n),e.fillRect(h,l,p,c);let g=this.getVariantStrokecolor(n);if(g&&(e.strokeStyle=g,e.strokeRect(h,l,p,c)),this.callContextHook(n,e,h,l,p,c),n.pixelRect={x:h,y:l,w:p,h:c},f>0&&!1!==this.showGenotypes){const i="COLLAPSED"===this.displayMode?1:this.nVariantRows;this.sampleYOffset=this.variantBandHeight+r,this.sampleHeight=i*(t+r);let o=0;if(u&&n.calls)for(let i of u){const s=n.calls[i.id];if(s){const a="COLLAPSED"===this.displayMode?0:n.row,l=this.sampleYOffset+o*this.sampleHeight+a*(t+r);let c=!0,u=!0,f=!1;if(s.genotype)for(let t of s.genotype){if("."===t){f=!0;break}0!==t&&(u=!1),0===t&&(c=!1)}s.genotype?e.fillStyle=f?this.noCallColor:u?this.homrefColor:c?this.homvarColor:this.hetvarColor:e.fillStyle=this.noGenotypeColor,e.fillRect(h,l,p,t),i.pixelRect={x:h,y:l,w:p,h:t}}o++}}}}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(om.has(t)){r=e[om.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}getVariantStrokecolor(t){const e=t._f||t;let n;return n=this._strokecolor?"function"==typeof this._strokecolor?this._strokecolor(e):this._strokecolor:void 0,n}callContextHook(t,e,n,r,i,o){if(this._context_hook&&"function"==typeof this._context_hook){const s=t._f||t;e.save(),this._context_hook(s,e,n,r,i,o),e.restore()}}clickedFeatures(t){let e=super.clickedFeatures(t);const n="EXPANDED"===this.displayMode?this.expandedVGap:this.squishedVGap,r=n+("SQUISHED"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight),i=t.y;if(i<=this.variantBandHeight){const t="SQUISHED"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,r=Math.floor((i-10)/(t+n));"COLLAPSED"!==this.displayMode&&(e=e.filter((t=>t.row===r)))}else if(this.callSets){const t=this.callSets,n=i-this.variantBandHeight,o=Math.floor(n/this.sampleHeight);if(o>=0&&o<t.length){const i=Math.floor((n-o*this.sampleHeight)/r),s="COLLAPSED"===this.displayMode?e:e.filter((t=>t.row===i)),a=t[o];e=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 e}popupData(t,e){void 0===e&&(e=this.clickedFeatures(t));const n=t.genomicLocation,r=this.browser.genome.id,i=this.browser.sampleInformation;let o=[];for(let t of e){const e=t._f||t;if(o.length>0&&o.push({html:'<hr style="border-top-width:2px ;border-color: #c9c3ba" />'}),"function"==typeof e.popupData){const t=e.popupData(n,r);Array.prototype.push.apply(o,t)}else{const t=e;if(void 0!==t.callSetName&&o.push({name:"Name",value:t.callSetName}),t.genotypeName&&o.push({name:"Genotype",value:t.genotypeName}),void 0!==t.phaseset&&o.push({name:"Phase set",value:t.phaseset}),void 0!==t.genotypeLikelihood&&o.push({name:"genotypeLikelihood",value:t.genotypeLikelihood.toString()}),i){var s=i.getAttributes(t.callSetName);s&&Object.keys(s).forEach((function(t){var e=t.replace(/([A-Z])/g," $1");e=e.charAt(0).toUpperCase()+e.slice(1),o.push({name:e,value:s[t]})}))}var a=Object.keys(t.info);a.length&&o.push("<hr/>"),a.forEach((function(e){o.push({name:e,value:decodeURIComponent(t.info[e])})}))}}return o}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(Wo("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(Wo({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=(t=>{const e=t.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)}));return e.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:og(e.chr),start:e.start,end:e.end,mate:{refName:og(e.info.CHR2),start:r,end:i}}}))})("all"===e.chr?this.featureSource.getAllFeatures():this.featureSource.featureCache.queryFeatures(e.chr,e.start,e.end));ag(n,this,e,.5)}colorByCB(t,e){return{name:void 0,object:pe(Wo(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=am;else e=new Qo("Set1");this.colorTables.set(t,e)}return this.colorTables.get(t)}}const am=new Jo({DEL:"#ff2101",INS:"#001888",DUP:"#028401",INV:"#008688",CNV:"#8931ff",BND:"#891100","*":"#002eff"});class lm extends Al{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=ef(t,this.browser.genome),Rg.gtexLoaded=!0}paintAxis(t,e,n){const r=(this.dataRange.max-this.dataRange.min)/n,i={font:"normal 10px Arial",textAlign:"right",strokeStyle:"black"};ns.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,l=o,c=n-(s-this.dataRange.min)/r;ns.strokeLine(t,a,c,l,c,i),c>8&&ns.fillText(t,s,a-1,c+2,i)}i.textAlign="center",ns.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&&ns.fillRect(e,0,0,n,r,{fillStyle:this.background}),ns.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,l=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=l&&(l.snp===f||l.gene===d);if(!i||p){l&&l.snp===f&&l.addGene(d);var c=-Math.log(h[this.pValueField])/Math.LN10;if(c>=this.dataRange.min){let t;c>this.dataRange.max?(c=this.dataRange.max,t=!0):t=!1;const n=Math.max(0+o,r-Math.round((c-this.dataRange.min)/a));let s;h.px=u,h.py=n,h.radius=o,i&&l?(s=l.colorForGene(d),ns.setProperties(e,{fillStyle:s,strokeStyle:"black"})):(s=t?"rgb(150, 150, 150)":"rgb(180, 180, 180)",ns.setProperties(e,{fillStyle:s,strokeStyle:s})),ns.fillCircle(e,u,n,o),ns.strokeCircle(e,u,n,o)}}}};i(!1),i(!0)}popupData(t,e){if(void 0===e&&(e=t.viewport.cachedFeatures),!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 $o.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=uo(e,this.autoscalePercentile)}else{const t=this.config.maxLogP||this.config.max;this.dataRange.max=t||25}return this.dataRange}}const cm={X:"rgb(204, 153, 0)",Y:"rgb(153, 204, 0)",Un:"darkGray)",1:"rgb(80, 80, 255)",2:"rgb(206, 61, 50)","2a":"rgb(210, 65, 55)","2b":"rgb(215, 70, 60)",3:"rgb(116, 155, 88)",4:"rgb(240, 230, 133)",5:"rgb(70, 105, 131)",6:"rgb(186, 99, 56)",7:"rgb(93, 177, 221)",8:"rgb(128, 34, 104)",9:"rgb(107, 215, 107)",10:"rgb(213, 149, 167)",11:"rgb(146, 72, 34)",12:"rgb(131, 123, 141)",13:"rgb(199, 81, 39)",14:"rgb(213, 143, 92)",15:"rgb(122, 101, 165)",16:"rgb(228, 175, 105)",17:"rgb(59, 27, 83)",18:"rgb(205, 222, 183)",19:"rgb(97, 42, 121)",20:"rgb(174, 31, 99)",21:"rgb(231, 199, 111)",22:"rgb(90, 101, 94)",23:"rgb(204, 153, 0)",24:"rgb(153, 204, 0)",25:"rgb(51, 204, 0)",26:"rgb(0, 204, 51)",27:"rgb(0, 204, 153)",28:"rgb(0, 153, 204)",29:"rgb(10, 71, 255)",30:"rgb(71, 117, 255)",31:"rgb(255, 194, 10)",32:"rgb(255, 209, 71)",33:"rgb(153, 0, 51)",34:"rgb(153, 26, 0)",35:"rgb(153, 102, 0)",36:"rgb(128, 153, 0)",37:"rgb(51, 153, 0)",38:"rgb(0, 153, 26)",39:"rgb(0, 153, 102)",40:"rgb(0, 128, 153)",41:"rgb(0, 51, 153)",42:"rgb(26, 0, 153)",43:"rgb(102, 0, 153)",44:"rgb(153, 0, 128)",45:"rgb(214, 0, 71)",46:"rgb(255, 20, 99)",47:"rgb(0, 214, 143)",48:"rgb(20, 255, 177)"};for(let Nv of Object.keys(cm)){cm["chr"+Nv]=cm[Nv]}for(let Ov=1;Ov<=48;Ov++){if(10===Ov)continue;const Pv=hm(Ov);cm[Pv]=cm[Ov.toString()]}function hm(t){if(!+t)return!1;for(var e=String(+t).split(""),n=["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM","","X","XX","XXX","XL","L","LX","LXX","LXXX","XC","","I","II","III","IV","V","VI","VII","VIII","IX"],r="",i=3;i--;)r=(n[+e.pop()+10*i]||"")+r;return Array(+e.join("")+1).join("M")+r}class um extends Al{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.useChrColors?this.colorScale=new Jo(t.colorTable||cm):t.color?this.colorScale=new $g(t.color):this.colorScale=new qg(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=ef(t,this.browser.genome)}async postInit(){if("function"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),this.autoscale||(this.posteriorProbability?this.dataRange={min:void 0===this.config.min?0:this.config.min,max:void 0===this.config.max?1:this.config.max}:this.dataRange={min:void 0===this.config.min?0:this.config.min,max:void 0===this.config.max?25:this.config.max}),this}get supportsWholeGenome(){return!0}async getFeatures(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&&ns.fillRect(n,0,0,r,i,{fillStyle:this.background}),ns.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;let r;if(this.posteriorProbability)r=t[this.valueProperty];else{const e=t[this.valueProperty];if(!e)continue;r=-Math.log10(e)}const l=this.useChrColors?t._f?t._f.chr:t.chr:r,c=this.colorScale.getColor(l),h=(this.dataRange.max-this.dataRange.min)/i,u=Math.round((e-s)/o),f=Math.max(this.dotSize,i-Math.round((r-this.dataRange.min)/h));c&&ns.setProperties(n,{fillStyle:c,strokeStyle:"black"}),ns.fillCircle(n,u,f,this.dotSize),t.px=u,t.py=f}}}paintAxis(t,e,n){ns.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);ns.strokeLine(t,45,e-2,50,e-2,r),ns.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);ns.strokeLine(t,45,e,50,e,r),ns.fillText(t,Math.floor(o),44,e+4,r)}}r.textAlign="center",this.posteriorProbability?ns.fillText(t,"PPA",e/2,n/2,r,{rotate:{angle:-90}}):ns.fillText(t,"-log10(pvalue)",e/2,n/2,r,{rotate:{angle:-90}})}popupData(t,e){void 0===e&&(e=t.viewport.cachedFeatures);let n=[];const r=t.viewport.trackView.track;if(e){let i=0;for(let o of e){const e=Math.abs(t.canvasX-o.px),s=Math.abs(t.canvasY-o.py),a=o[this.valueProperty];if(e<this.dotSize&&s<this.dotSize){if(i>0&&n.push("<HR/>"),5==i){n.push("...");break}if("function"==typeof o.popupData)n=n.concat(o.popupData());else{const t=o.realChr||o.chr,e=(o.realStart||o.start)+1;n.push({name:"chromosome",value:t}),n.push({name:"position",value:e}),n.push({name:"name",value:o.name}),r.posteriorProbability?n.push({name:"posterior probability",value:a}):n.push({name:"pValue",value:a})}i++}}}return n}menuItemList(){return $o.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=Ns(r)}else this.posteriorProbability?this.dataRange={min:this.config.min||0,max:this.config.max||1}:this.dataRange={min:this.config.max||25,max:this.config.min||0};return this.dataRange}}class fm extends Al{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=Mp,this.graphType=t.graphType||"bar",t._featureSource?(this.featureSource=t._featureSource,delete t._featureSource):this.featureSource=ef(this.config,this.browser.genome),this.visibilityWindow=-1,this.featureSource.visibilityWindow=this.visibilityWindow}async postInit(){if("function"==typeof this.featureSource.getHeader){if(this.header=await this.featureSource.getHeader(),this.disposed)return;if(this.sampleNames=this.header.columnNames.slice(3),this.setTrackProperties(this.header),this.header.hasOwnProperty("clickToHighlight")){let 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 $o.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,l=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={},c=[],h=[];this.clickDetectorCache={};for(let u of e){const e=l(u.start),f=l(u.end),d=o>=0?l(o):e;if(!isNaN(e)&&!isNaN(f)){this.clickDetectorCache[e]=[],this.clickDetectorCache[f]=[];for(let o=0;o<u.values.length;o++){const l=this.sampleNames[o],p=u.values[o],g=a(p);if(e-d>=1){const o=s[l],h=a(o),u=t&&t[l];u?c.push([d,h,e,g,u]):i&&l in this.config.samplesClickedToHighlight?c.push([d,h,e,g,this.config.samplesClickedToHighlight[l]]):ns.strokeLine(n,d,h,e,g,{strokeStyle:"#D9D9D9"}),r&&!(l in t)||this.clickDetectorCache[e].push([d,h,e,g,l,u||"gray"])}if(f-e>=1){const o=t&&t[l];o?h.push([e,g,f,g,o]):i&&l in this.config.samplesClickedToHighlight?h.push([e,g,f,g,this.config.samplesClickedToHighlight[l]]):ns.strokeLine(n,e,g,f,g,{strokeStyle:"gray"}),r&&!(l in t)||this.clickDetectorCache[f].push([e,g,f,g,l,o||"gray"])}s[l]=p}o=u.end}}for(let t of c)ns.strokeLine(n,t[0],t[1],t[2],t[3],{strokeStyle:t[4],lineWidth:1.3});for(let t of h)ns.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?ns.dashedLine(t.context,0,n,t.pixelWidth,n,5,r):ns.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],l=r[3];if(n<Math.min(a,l)-10||n>Math.max(a,l)+10)continue;const c=dm(e,n,i,a,o,l);c<t&&(s=[{name:r[4],color:r[5]}],t=c)}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){void 0===e&&(e=this.clickedFeatures(t));const n=[];return e.forEach((function(t){for(let e of Object.keys(t))Rs(t[e])&&n.push({name:e,value:t[e]})})),n}get supportsWholeGenome(){return!1}}function dm(t,e,n,r,i,o){const s=i-n,a=o-r,l=Math.abs(s*(r-e)-(n-t)*a),c=Math.sqrt(s*s+a*a);return c>0?l/c:0}class pm extends Al{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 mm(t,e.genome):this.featureSource=new Oc(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,l=this.arcOrientation;ns.fillRect(e,0,t.pixelTop,r,i,{fillStyle:"rgb(255, 255, 255)"});const c=t.features;if(c){gm(c,1);for(let t of c)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),c=Math.round((t.endRight-s)/a);e.fillStyle=t.color,e.strokeStyle=t.color,e.beginPath();let h=(r+c)/2,u=(c-r)/2,f=this.height,d=Math.PI+(Math.PI/2-n),p=2*Math.PI-(Math.PI/2-n);l?(f=0,e.arc(h,f,u,p,d),e.lineTo(c,f)):(e.arc(h,f,u,d,p),e.lineTo(o,f));const g=(i+o)/2,m=(o-i)/2,v=f;l?(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,c=(i-r)/2,h=this.height,u=Math.PI+(Math.PI/2-n),f=2*Math.PI-(Math.PI/2-n);l?(h=0,e.arc(o,h,c,f,u)):e.arc(o,h,c,u,f),e.stroke(),t.drawState={x1:o,y1:h,r1:c,sa:u,ea:f}}}}clickedFeatures(t){const e=super.clickedFeatures(t),n=[];gm(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 l,c;if(void 0===e.x2)l=s,c=e.r1-3;else{const n=t.canvasX-e.x2,r=t.canvasY-e.y2;l=Math.sqrt(n*n+r*r),c=e.r2-3}if(s<a&&l>c){n.push(r);break}}return n}popupData(t,e){if(void 0===e&&(e=this.clickedFeatures(t)),e&&e.length>0)return this.extractPopupData(e[0],this.getGenomeId())}menuItemList(){var t=this;return[{name:"Toggle arc direction",click:function(){t.arcOrientation=!t.arcOrientation,t.trackView.repaintViews()}}]}}function gm(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 mm{constructor(t,e){this.config=t,this.genome=e}async getFeatures(t){let{chr:e,start:n,end:r,bpPerPixel:i,visibilityWindow:o}=t;const s=this.genome;if(this.featureCache)return this.featureCache.queryFeatures(e,n,r);{const t=Is(this.config),i=await To.loadString(this.config.url,t);return this.featureCache=new Vo(function(t){if(!t)return null;const e=sc(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,l=Number.parseInt(t[2])-1,c=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,l),startRight:Math.max(n,l),endLeft:Math.min(c,h),endRight:Math.max(c,h),color:u,score:a}:{chr:e,startLeft:Math.min(c,h),startRight:Math.max(c,h),endLeft:Math.min(n,l),endRight:Math.max(n,l),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),s),this.featureCache.queryFeatures(e,n,r)}}}class vm{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(t){let{context:e,referenceFrame:n,pixelWidth:r,pixelHeight:i}=t;const o=n.chr,s=n.genome.getChromosome(o);if(void 0===s||r<=0||i<=0||"all"===o.toLowerCase())return;!function(t){let{ctx:e,chr:n,referenceFrame:r,genome:i,width:o,height:s,stainColors:a}=t;const l=1,c=.5*l,h=0;if(void 0===i)return;ns.fillRect(e,0,0,o,s,{fillStyle:vo.greyScale(255)});const u=i.getCytobands(n);if(u){const t=h+s/2,n=[],r=[];if(0===u.length)return;const i=o/u[u.length-1].end;e.beginPath(),ns.roundRect(e,c,c+h,o-2*c,s-2*c,(s-2*c)/2,0,1),e.clip();for(let o=0;o<u.length;o++){const c=u[o],f=i*c.start,d=i*c.end;"c"===c.type?("p"===c.name.charAt(0)?(n[0]=f,r[0]=s+h,n[1]=f,r[1]=h,n[2]=d,r[2]=t):(n[0]=d,r[0]=s+h,n[1]=d,r[1]=h,n[2]=f,r[2]=t),e.fillStyle="rgb(150, 0, 0)",e.strokeStyle="rgb(150, 0, 0)",ns.polygon(e,n,r,1,0)):(e.fillStyle=bm(a,c),ns.fillRect(e,f,l+h,d-f,s-2*l))}}e.strokeStyle=vo.greyScale(41),ns.roundRect(e,c,c+h,o-2*c,s-2*c,(s-2*c)/2,0,1)}({ctx:e,chr:o,referenceFrame:n,genome:n.genome,width:r,height:i,stainColors:[]});const a=Math.round(n.bpPerPixel*r),l=n.start;let c=s.bpLength;const h=n.genome.getCytobands(o);if(h&&h.length>0&&h[h.length-1].end&&(c=Math.max(c,h[h.length-1].end),s.bpLength=c),a<c){const t=a/c,n=l/c;let o=Math.floor(n*r),s=Math.floor(t*r);o=Math.max(0,o),o=Math.min(r-s,o),e.save(),e.strokeStyle="red",e.lineWidth=s<2?1:2;const h=o+e.lineWidth/2;s=s<2?1:s-e.lineWidth;const u=e.lineWidth/2,f=i-e.lineWidth;e.strokeRect(h,u,s,f),e.restore()}}dispose(){this.trackView=void 0}}function bm(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 wm=new Qo("Dark2");["GT/AG","CT/AC","GC/AG","CT/GC","AT/AC","GT/AT","non-canonical"].forEach((t=>{wm.getColor(t)}));const ym={};class xm extends Al{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:ef(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(){if("function"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),void 0===this.visibilityWindow&&"function"==typeof this.featureSource.defaultVisibilityWindow&&(this.visibilityWindow=await this.featureSource.defaultVisibilityWindow()),this}get supportsWholeGenome(){return!1}async getFeatures(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||ns.fillRect(n,0,t.pixelTop,o,s,{fillStyle:"rgb(255, 255, 255)"}),e){ym.referenceFrame=t.viewport.referenceFrame,ym.referenceFrameStart=ym.referenceFrame.start,ym.referenceFrameEnd=ym.referenceFrameStart+ym.referenceFrame.toBP(t.viewport.getWidth()),ym.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 ym.featureZoomOutTracker)return;ym.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>=ym.referenceFrameStart&&t.start<=ym.referenceFrameEnd&&(e+=1),t.end>=ym.referenceFrameStart&&t.end<=ym.referenceFrameEnd&&(e+=1),e<this.config.minJunctionEndsVisible)return}let l,c,h,u;if(t.attributes.uniquely_mapped){if(l=parseInt(t.attributes.uniquely_mapped),l<this.config.minUniquelyMappedReads)return;if(c=parseInt(t.attributes.multi_mapped),h=l+c,h<this.config.minTotalReads)return;if(h>0&&c/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=l:"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)/(ym.referenceFrameEnd-ym.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?l>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?wm.getColor(t.attributes.motif):"#AAAAAA";let _="";t.attributes.label?_=t.attributes.label.replace(/_/g," "):void 0===this.config.labelWith||"uniqueReadCount"===this.config.labelWith?_=l:"totalReadCount"===this.config.labelWith?_=h:"numSamplesWithThisJunction"===this.config.labelWith?void 0!==u&&(_=u):"percentSamplesWithThisJunction"===this.config.labelWith?void 0!==t.attributes.percent_samples_with_this_junction&&(_=t.attributes.percent_samples_with_this_junction.toFixed(0)+"%"):"motif"===this.config.labelWith&&void 0!==t.attributes.motif&&(_+=t.attributes.motif),"uniqueReadCount"===this.config.labelWithInParen?_+=" ("+l+")":"totalReadCount"===this.config.labelWithInParen?_+=" ("+h+")":"multiMappedReadCount"===this.config.labelWithInParen?c>0&&(_+=" (+"+c+")"):"numSamplesWithThisJunction"===this.config.labelWithInParen?void 0!==u&&(_+=" ("+u+")"):"percentSamplesWithThisJunction"===this.config.labelWithInParen?void 0!==t.attributes.percent_samples_with_this_junction&&(_+=" ("+t.attributes.percent_samples_with_this_junction.toFixed(0)+"%)"):"motif"===this.config.labelWithInParen&&void 0!==t.attributes.motif&&(_+=` ${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 k=(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&&k(i,o,m,e),t.attributes.right_shape&&k(i,s,m,e)}i.fillText(_,a-i.measureText(_).width/2,(7*g+p)/8)}clickedFeatures(t){return super.clickedFeatures(t).filter((function(t){return t.isVisible&&t.attributes}))}popupData(t,e){void 0===e&&(e=this.clickedFeatures(t));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 _m=new Map([["ideogram",(t,e)=>new vm(t,e)],["sequence",(t,e)=>new ma(t,e)],["feature",(t,e)=>new jg(t,e)],["seg",(t,e)=>new Gg(t,e)],["mut",(t,e)=>new Gg(t,e)],["maf",(t,e)=>new Gg(t,e)],["wig",(t,e)=>new Ug(t,e)],["merged",(t,e)=>new Xg(t,e)],["alignment",(t,e)=>new hg(t,e)],["interaction",(t,e)=>new Kg(t,e)],["interact",(t,e)=>new Kg(t,e)],["variant",(t,e)=>new sm(t,e)],["eqtl",(t,e)=>new lm(t,e)],["gwas",(t,e)=>new um(t,e)],["arc",(t,e)=>new pm(t,e)],["gcnv",(t,e)=>new fm(t,e)],["junction",(t,e)=>new xm(t,e)]]);var km=function(t,e){_m.set(t,e)},Sm=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 _m.has(r)?_m.get(r)(e,n):void 0};class Cm{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:[]};Em(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),Em(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),Em(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 Em(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 l=t.getAttribute("visibilityWindow")||t.getAttribute("featureVisibilityWindow");l&&(e.visibilityWindow=l);const c=t.getAttribute("indexed");c&&(e.indexed="true"===c);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 Tm=Ce;class Am{constructor(){this.attributes={},this.plinkLoaded=!1}async loadPlinkFile(t,e){e||(e={});var n=Is(e);const r=await To.loadString(t,n);var i=Tm(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 Lm{constructor(t,e){this.geneColors={},this.gene=null,this.snp=null,this.genesCount=0,t&&(this.gene=t.toUpperCase(),this.geneColors[this.gene]=Mm[this.genesCount++]),e&&(this.snp=e.toUpperCase())}addGene(t){this.geneColors[t.toUpperCase()]||(this.geneColors[t.toUpperCase()]=Mm[this.genesCount++])}colorForGene(t){return this.geneColors[t.toUpperCase()]}}var Mm=[];Mm.push("rgb(228,26,28)"),Mm.push("rgb(55,126,184)"),Mm.push("rgb(77,175,74)"),Mm.push("rgb(166,86,40)"),Mm.push("rgb(152,78,163)"),Mm.push("rgb(255,127,0)"),Mm.push("rgb(247,129,191)"),Mm.push("rgb(153,153,153)"),Mm.push("rgb(255,255,51)"),Mm.push("rgb(102, 194, 165"),Mm.push("rgb(252, 141, 98"),Mm.push("rgb(141, 160, 203"),Mm.push("rgb(231, 138, 195"),Mm.push("rgb(166, 216, 84"),Mm.push("rgb(255, 217, 47"),Mm.push("rgb(229, 196, 148"),Mm.push("rgb(179, 179, 179"),Mm.push("rgb( 141, 211, 199"),Mm.push("rgb(255, 255, 179"),Mm.push("rgb(190, 186, 218"),Mm.push("rgb(251, 128, 114"),Mm.push("rgb(128, 177, 211"),Mm.push("rgb(253, 180, 98"),Mm.push("rgb(179, 222, 105"),Mm.push("rgb(252, 205, 229"),Mm.push("rgb(217, 217, 217"),Mm.push("rgb(188, 128, 189"),Mm.push("rgb(204, 235, 197"),Mm.push("rgb(255, 237, 111");class Rm{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,n){const r=this.start,i=t*this.bpPerPixel;return this.start+=i,n&&this.clampStart(e),this.end=this.start+e*this.bpPerPixel,r!==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(),l=e<1?t.minimumBases()/n:a/n;this.bpPerPixel=e<1?Math.max(this.bpPerPixel*e,l):Math.min(this.bpPerPixel*e,l);const c=this.bpPerPixel*n;this.start=i-.5*c,this.clampStart(n),this.end=this.start+c;(o!==this.start||s!==this.bpPerPixel)&&await t.updateViews(!0)}getChromosome(){return this.genome.getChromosome(this.chr)}getMultiLocusLabel(t){const e=" ",n=Math.floor(this.start)+1,r=Math.round(this.start+this.bpPerPixel*t);return`${e}${this.chr}     ${Fs(r-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 Im={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 Nm(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||Im,i=[];const o=async n=>{let i=function(t,e){const n=e.split("\t");if(n.length>=3)try{const e=t.genome.getChromosomeName(n[0]),r=parseInt(n[1].replace(/,/g,""),10)-1,i=parseInt(n[2].replace(/,/g,""),10);if(!isNaN(r)&&!isNaN(i))return{chr:e,start:r,end:i}}catch(t){}const r=e.split(":"),i=r[0];if("all"===i&&t.genome.getChromosome(i))return{chr:i,start:0,end:t.genome.getChromosome(i).bpLength};if(void 0===t.genome.getChromosome(i))return;{const e={chr:t.genome.getChromosomeName(i),start:0,end:t.genome.getChromosome(i).bpLength};if(r.length>1){let n,i=r[1].split("-");if(i.length>2){if(!r[1].startsWith("-"))return;{const t=r[1].indexOf("-",1);if(t>0){i=[r[1].substring(0,t),r[1].substring(t+1)]}}}if(n=i[0].replace(/,/g,""),isNaN(n))return;if(e.start=parseInt(n,10)-1,e.end=e.start+1,1===i.length&&(e.start-=20,e.end+=20),2===i.length){if(n=i[1].replace(/,/g,""),isNaN(n))return;if(e.end=parseInt(n,10),e.start<0&&!t.isSoftclipped()){const t=-e.start;e.start+=t,e.end+=t}}}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 To.loadString(r,i),s=function(t,e,n){let r;r="plain"===n.type?function(t,e){const n=[],r=[],i=Ce(e);return i.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 l=a[e],c=t.genome.getChromosome(l);if(!c)return;const h=c.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 Om{constructor(t){this.browser=t}navbarDidResize(t){this.updateNavbar(this.createResponsiveClassSchedule(t))}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){let e={};const n=this.browser.isMultiLocusWholeGenomeView()||this.browser.referenceFrameList&&Ra.isWholeGenomeView(this.browser.referenceFrameList[0].chr);return n?this.browser.windowSizePanel.hide():this.browser.windowSizePanel.show(),t>990?(e.$toggle_button_container="igv-navbar-toggle-button-container",e.zoomContainer="igv-zoom-widget"):t>860?(e.$toggle_button_container="igv-navbar-toggle-button-container",e.zoomContainer="igv-zoom-widget-900"):t>540?(e.$toggle_button_container="igv-navbar-toggle-button-container-750",e.zoomContainer="igv-zoom-widget-900"):(e.$toggle_button_container="igv-navbar-toggle-button-container-750",e.zoomContainer="igv-zoom-widget-900",this.browser.windowSizePanel.hide()),n&&(e.zoomContainer="igv-zoom-widget-hidden"),e}}const Pm=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};Pm.prototype.show=function(){this.container.style.display="flex"},Pm.prototype.hide=function(){this.container.style.display="none"},Pm.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 Fm{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?Fs(Math.round(e*t[0].bpPerPixel)):""}}class Dm{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=function(t,e){for(;t.parentElement;){if(t.parentElement.classList.contains(e))return t.parentElement;t=t.parentElement}return}(document.elementFromPoint(e.clientX,e.clientY),"igv-viewport");if(i&&t.getRulerTrackView()){this.verticalGuide.style.left=`${n}px`;const r=t.root.querySelectorAll(".igv-column");let o;const s=i.parentElement;for(let t=0;t<r.length;t++)void 0===o&&s===r[t]&&(o=t);const a=t.getRulerTrackView().viewports[o].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 Bm{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 zm{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 Hm{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 Vm{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 jm=23,Um=0;const qm=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=`${jm}`,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))}))};qm.prototype.update=function(t){const e=t[0],{bpLength:n}=e.genome.getChromosome(e.chr),{start:r,end:i}=e;jm=Math.ceil(Math.log2(n/this.browser.minimumBases())),this.slider.max=`${jm}`;const o=n/(i-r);Um=Math.log2(o),this.slider.value=`${Math.round(Um)}`},qm.prototype.enable=function(){this.slider.disabled=!1},qm.prototype.disable=function(){this.slider.disabled=!0},qm.prototype.hide=function(){this.zoomContainer.style.display="none"},qm.prototype.show=function(){this.zoomContainer.style.display="block"},qm.prototype.hideSlider=function(){this.slider.style.display="none"},qm.prototype.showSlider=function(){this.slider.style.display="block"};const Wm=function(t,e){const n=ge({class:"igv-navbar-button"});t.append(n),n.textContent="Save SVG",n.addEventListener("click",(()=>e.saveSVGtoFile({})))},$m=(t,e)=>{const n=0===t?e.nextElementSibling:e.previousElementSibling;e.remove(),n.remove()},Gm=t=>{const e=ge({class:"igv-column-shim"});Hs(e,t);const n=ge({class:"igv-column"});return Hs(n,e),n},Zm=(t,e)=>{for(let n=0;n<e;n++){const r=ge({class:"igv-column"});if(zs(r,t),e>1&&n>0){zs(ge({class:"igv-column-shim"}),r)}}};class Xm{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(){if(this.referenceFrame){if(1/this.referenceFrame.bpPerPixel>1){const t=Math.floor(this.referenceFrame.toPixels(1));this.container.style.width=`${t}px`,this.container.classList.remove("igv-center-line-thin"),this.container.classList.add("igv-center-line-wide")}else this.container.style.width="1px",this.container.classList.remove("igv-center-line-wide"),this.container.classList.add("igv-center-line-thin")}}show(){this.isVisible=!0,this.container.style.display="block",this.repaint()}hide(){this.isVisible=!1,this.container.style.display="none"}resize(){this.repaint()}}const Ym=Se;class Km{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(t){let{context:e,referenceFrame:n,pixelWidth:r,pixelHeight:i,bpPerPixel:o,bpStart:s}=t;Ra.isWholeGenomeView(n.chr)?this.drawWholeGenome({context:e,pixelWidth:r,pixelHeight:i,bpPerPixel:o}):this.doDraw({context:e,referenceFrame:n,pixelWidth:r,pixelHeight:i,bpStart:s})}drawWholeGenome(t){let{context:e,pixelWidth:n,pixelHeight:r,bpPerPixel:i}=t;e.save(),ns.fillRect(e,0,0,n,r,{fillStyle:"white"});for(let t of this.browser.genome.wgChromosomeNames){let n=this.browser.genome.getCumulativeOffset(t),o=this.browser.genome.getChromosome(t).bpLength,s=Math.round(n/i),a=Math.round(o/i);this.renderChromosomeRect(e,s,0,a,r,t)}e.restore()}doDraw(t){let{context:e,referenceFrame:n,pixelWidth:r,pixelHeight:i,bpStart:o}=t;e.clearRect(0,0,r,i);const s=function(t,e){if(t<10)return new Qm(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,l=Math.pow(10,n-1),c=Math.pow(10,n)/2;return new Qm(s<a&&!0!==e?l:c,r,i)}(Math.floor(n.toBP(r)),e.isSVG);let a=Math.floor(o/s.majorTick)-1;const{tickDelta:l,labelLength:c}=function(t,e,n,r,i){const o=c(e,l(1+r,i),n)-c(e,l(r,i),n),s=`${Se(Math.floor(l(r,i)/i.unitMultiplier))} ${i.majorUnit}`,a=Math.floor(t.measureText(s).width);return{tickDelta:o,labelLength:a};function l(t,e){return Math.floor(t*e.majorTick)}function c(t,e,n){return Math.round(t.toPixels(e-1-n+.5))}}(e,n,o,a,s);let h,u;this.browser.referenceFrameList.indexOf(n);let f=l;const d=.25*c;do{u=Math.floor(a*s.majorTick);const t=`${Se(Math.floor(u/s.unitMultiplier))} ${s.majorUnit}`;h=Math.round(n.toPixels(u-1-o+.5));const r=Math.round(h-e.measureText(t).width/2);r>0&&d+c<=f&&(ns.fillText(e,t,r,this.height-8),f=0),h>0&&ns.strokeLine(e,h,this.height-6,h,this.height-2),u=Math.floor((1+a)*s.majorTick);let i=h+(Math.round(n.toPixels(u-1-o+.5))-h)/2;i>0&&ns.strokeLine(e,i,this.height-6,i,this.height-2),++a,f+=l}while(h<r);ns.strokeLine(e,0,this.height-2,r,this.height-2)}renderChromosomeRect(t,e,n,r,i,o){t.textAlign="center",t.textBaseline="middle",t.font="12px sans-serif",ns.strokeLine(t,e+r,n,e+r,n+i,{strokeStyle:vo.greyScale(191)});const s=o.startsWith("chr")?o.substring(3):o;r>t.measureText(s).width&&ns.fillText(t,s,e+r/2,n+i/2,{fillStyle:vo.greyScale(68)})}get supportsWholeGenome(){return!0}dispose(){}}class Qm{constructor(t,e,n){this.majorTick=t,this.minorTick=t/10,this.majorUnit=e,this.unitMultiplier=n}description(t){console.log((t||"")+" tick "+Ym(this.majorTick)+" label width "+Ym(this.labelWidthBP)+" multiplier "+this.unitMultiplier)}}const Jm=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)};Jm.prototype.setVisibility=function(t){!0===t?this.show():this.hide()},Jm.prototype.setState=function(t){!0===t?this.button.classList.add("igv-navbar-button-clicked"):this.button.classList.remove("igv-navbar-button-clicked")},Jm.prototype.show=function(){this.button.style.display="block",this.setState(this.browser.circularViewVisible)},Jm.prototype.hide=function(){this.button.style.display="none"};const tv=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 ev{constructor(t,e,n,r,i){this.browser=t,this.roiMenu=e,this.roiTable=n,this.top=r,this.roiSets=i||[],this.boundLocusChangeHandler=nv.bind(this),t.on("locuschange",this.boundLocusChangeHandler)}async initialize(){this.roiSets.length>0&&(this.browser.showROITableButton=!0,this.browser.roiTableControl.setVisibility(this.browser.showROITableButton));const t=this.roiSets.map((t=>this.renderROISet({browser:this.browser,pixelTop:this.top,roiSet:t})));t.length>0&&await Promise.all(t);const e=await this.getTableRecords();this.roiTable.renderTable(e)}async loadROI(t,e){const n=Array.isArray(t)?t:[t];for(let t of n)this.roiSets.push(new of(t,e));await this.initialize()}clearROIs(){this.roiTable.clearTable();const t=this.browser.columnContainer.querySelectorAll(".igv-roi-region");for(let e of t)e.remove();for(let t of this.roiSets)t.dispose();this.roiSets=[]}async getTableRecords(){const t=[];for(let e of this.roiSets){const n=e.isUserDefined?"":e.name||"",r=await e.getAllFeatures();for(let e of Object.keys(r))for(let i of r[e])t.push({setName:n,feature:i})}return t}presentTable(){this.roiTable.present()}async repaintTable(){const t=await this.getTableRecords();this.roiTable.renderTable(t)}dismissTable(){this.roiTable.dismiss()}async updateUserDefinedROISet(t){let e=await this.getUserDefinedROISet();void 0===e&&(e=this.initializeUserDefinedROISet()),e.addFeature(t),!1===this.browser.showROITableButton&&this.setROITableButtonVisibility(!0),await this.renderROISet({browser:this.browser,pixelTop:this.top,roiSet:e});const n=await this.getTableRecords();this.roiTable.renderTable(n)}setROITableButtonVisibility(t){this.browser.showROITableButton=t,this.browser.roiTableControl.setVisibility(this.browser.showROITableButton)}async renderAllROISets(){for(let t of this.roiSets)await this.renderROISet({browser:this.browser,pixelTop:this.top,roiSet:t})}async renderROISet(t){let{browser:e,pixelTop:n,roiSet:r}=t;const i=e.columnContainer.querySelectorAll(".igv-column");for(let t=0;t<i.length;t++){let{chr:o,start:s,end:a,bpPerPixel:l}=e.referenceFrameList[t];const c=i[t].querySelectorAll(".igv-roi-region");for(let t of c){const e=t.dataset.region,{chr:n,start:r,end:i}=ov(e);(n!==o||i<s||r>a)&&t.remove()}const h=await r.getFeatures(o,s,a);if(h)for(let c of h){const h=rv(o,c.start,c.end),{x:u,width:f}=sf(Math.max(s,c.start),Math.min(a,c.end),s,l),d=i[t].querySelector(iv(h));if(d)d.style.left=`${u}px`,d.style.width=`${f}px`;else{const o=this.createRegionElement(e.columnContainer,n,u,f,r,h,c.name);i[t].appendChild(o)}}}}createRegionElement(t,e,n,r,i,o,s){const a=ge({class:"igv-roi-region"});a.style.top=`${e}px`,a.style.left=`${n}px`,a.style.width=`${r}px`,a.style.backgroundColor=i.color,a.dataset.region=o;const l=ge();return a.appendChild(l),l.style.backgroundColor=i.headerColor,!0===i.isUserDefined?l.addEventListener("click",(e=>{e.preventDefault(),e.stopPropagation();const{x:n,y:r}=we(e,t);this.roiMenu.present(n,r,this,t,a)})):s?l.addEventListener("click",(e=>{e.preventDefault(),e.stopPropagation(),this.popover&&this.popover.dispose(),this.popover=new ks(t,i.name),this.popover.presentContentWithEvent(e,s)})):l.style.pointerEvents="none",a}async getUserDefinedROISet(){return this.roiSets.find((t=>!0===t.isUserDefined))}initializeUserDefinedROISet(){const t=new of({isUserDefined:!0,features:[]},this.browser.genome);return this.roiSets.push(t),t}async deleteUserDefinedRegionWithKey(t,e){e.querySelectorAll(iv(t)).forEach((t=>t.remove()));const n=await this.findUserDefinedRegionWithKey(t),r=await this.getUserDefinedROISet();r&&r.removeFeature(n);0===(await this.getTableRecords()).length&&(this.browser.roiTableControl.buttonHandler(!1),this.setROITableButtonVisibility(!1))}async findUserDefinedRegionWithKey(t){const{chr:e,start:n,end:r}=ov(t),i=await this.getUserDefinedROISet();if(i){const t=await i.getFeatures(e,n,r);for(let i of t)if(i.chr===e&&i.start>=n&&i.end<=r)return i}}toJSON(){return this.roiSets.map((t=>t.toJSON()))}dispose(){this.browser.off("locuschange",this.boundLocusChangeHandler);const t=this.browser.columnContainer.querySelectorAll(".igv-roi-region");for(let e of t)e.remove();this.roiMenu&&this.roiMenu.dispose(),this.roiTable&&this.roiTable.dispose();for(let t of this.roiSets)t.dispose();for(let t of Object.keys(this))this[t]=void 0}}function nv(){this.renderAllROISets()}function rv(t,e,n){return`${t}-${e}-${n}`}function iv(t){return`[data-region="${t}"]`}function ov(t){let[e,n,r]=t.split("-");return n=parseInt(n),r=parseInt(r),{chr:e,start:n,end:r,locus:`${e}:${n}-${r}`,bedRecord:`${e}\t${n}\t${r}`}}const sv=[];class av{constructor(t,e,n){this.browser=t,this.container=ge({class:n?"igv-roi-table":"igv-roi-table-four-column"}),e.appendChild(this.container),this.hasROISetNames=n;const r=this.createHeaderDOM(this.container);this.columnTitleDOM=function(t,e){const n=ge({class:"igv-roi-table-column-titles"});t.appendChild(n);let r=["Chr","Start","End","Description","ROI Set"];!1===e&&(r=r.slice(0,4));for(let t of r){const e=ge();e.innerText=t,n.appendChild(e)}return n}(this.container,n),this.tableRowContainerDOM=this.createTableRowContainerDOM(this.container),this.footerDOM=this.createFooterDOM(this.container);const{y:i}=t.root.getBoundingClientRect(),{y:o}=e.getBoundingClientRect(),s=-(o-i);wo(this.container,r,{minX:0,minY:s}),this.container.style.display="none"}clearTable(){const t=this.tableRowContainerDOM.querySelectorAll(".igv-roi-table-row");for(let e of t)e.remove()}present(){this.container.style.left="0px",this.container.style.top="0px",this.container.style.display="flex"}dismiss(){this.container.style.display="none"}renderTable(t){if(Array.from(this.tableRowContainerDOM.querySelectorAll(".igv-roi-table-row")).forEach((t=>t.remove())),t.length>0){const e=t.sort(((t,e)=>t.feature.chr.localeCompare(e.feature.chr)||t.feature.start-e.feature.start||t.feature.end-e.feature.end));for(let t of e){const e=this.createTableRowDOM(t);this.tableRowContainerDOM.appendChild(e)}}}createHeaderDOM(t){const e=ge();t.appendChild(e);const n=ge();e.appendChild(n),n.innerText="Regions of Interest";const r=ge();return e.appendChild(r),r.appendChild(ye("times")),r.addEventListener("click",(t=>{t.stopPropagation(),this.browser.roiTableControl.buttonHandler(!1)})),e}createTableRowContainerDOM(t){const e=ge({class:"igv-roi-table-row-container"});return t.appendChild(e),e}createTableRowDOM(t){const e=ge({class:"igv-roi-table-row"}),{setName:n,feature:r}=t;e.dataset.region=rv(r.chr,r.start,r.end);let i=[r.chr,Se(r.start),Se(r.end),r.name||"",n];!1===this.hasROISetNames&&(i=i.slice(0,4));for(let t of i){const n=ge();n.innerText=t,e.appendChild(n)}return e.addEventListener("mousedown",(t=>{t.stopPropagation(),e.classList.toggle("igv-roi-table-row-selected"),e.classList.contains("igv-roi-table-row-selected")?e.classList.remove("igv-roi-table-row-hover"):e.classList.add("igv-roi-table-row-hover"),this.setButtonState(e.classList.contains("igv-roi-table-row-selected"))})),e.addEventListener("mouseover",(t=>{e.classList.contains("igv-roi-table-row-selected")?e.classList.remove("igv-roi-table-row-hover"):e.classList.add("igv-roi-table-row-hover")})),e.addEventListener("mouseout",(t=>{e.classList.remove("igv-roi-table-row-hover")})),e}createFooterDOM(t){const e=ge();t.appendChild(e);const n=ge({class:"igv-roi-table-button"});return e.appendChild(n),n.id="igv-roi-table-view-button",n.textContent="Go To",n.style.pointerEvents="none",n.addEventListener("click",(e=>{e.stopPropagation();const n=t.querySelectorAll(".igv-roi-table-row-selected"),r=[];for(let t of n){const{locus:e}=ov(t.dataset.region);r.push(e)}for(let e of t.querySelectorAll(".igv-roi-table-row"))e.classList.remove("igv-roi-table-row-selected");this.setButtonState(!1),r.length>0&&this.browser.search(r.join(" "))})),e}setButtonState(t){t?sv.push(1):sv.pop();this.footerDOM.querySelector("#igv-roi-table-view-button").style.pointerEvents=sv.length>0?"auto":"none"}dispose(){this.browser.roiTableControl.buttonHandler(!1),this.container.innerHTML="";for(let t of Object.keys(this))this[t]=void 0}}class lv{constructor(t,e){this.browser=t,this.container=ge({class:"igv-roi-menu-next-gen"}),e.appendChild(this.container);const n=ge();this.container.appendChild(n),_e(n,(()=>this.container.style.display="none")),this.body=ge(),this.container.appendChild(this.body),this.container.style.display="none"}async present(t,e,n,r,i){cv(this.body);const o=await this.browser.roiManager.findUserDefinedRegionWithKey(i.dataset.region),s=ge();this.body.appendChild(s);const a="Description",l=o.name||a;s.innerText=l,s.setAttribute("title",l),a===l?s.classList.add("igv-roi-placeholder"):s.classList.remove("igv-roi-placeholder");const c=ge();this.body.appendChild(c),c.innerText="Set Description",c.addEventListener("click",(t=>{t.stopPropagation(),this.container.style.display="none";const e={label:"Description",value:o.name||"",callback:()=>{const t=this.browser.inputDialog.input.value||"";o.name=t.trim(),this.container.style.display="none",this.browser.roiManager.repaintTable()}};this.browser.inputDialog.present(e,t)}));const h=ge();this.body.appendChild(h),h.innerText="Delete Region",h.addEventListener("click",(t=>{t.stopPropagation(),this.container.style.display="none",this.browser.roiManager.deleteUserDefinedRegionWithKey(i.dataset.region,this.browser.columnContainer)})),this.container.style.left=`${t}px`,this.container.style.top=`${e}px`,this.container.style.display="flex"}async __present(t,e,n,r,i){cv(this.container);const o=await this.browser.roiManager.findUserDefinedRegionWithKey(i.dataset.region);let s;s=ge({class:"igv-roi-menu-row-edit-description"}),this.container.appendChild(s),s.addEventListener("click",(t=>{t.stopPropagation()}));const a="description-input",l=document.createElement("label");s.appendChild(l),l.setAttribute("for",a),l.innerText="Description:";const c=document.createElement("input");s.appendChild(c),c.setAttribute("type","text"),c.setAttribute("name",a),c.setAttribute("placeholder",""),c.value=o.name||"",c.addEventListener("change",(async t=>{t.stopPropagation();(await this.browser.roiManager.findUserDefinedRegionWithKey(i.dataset.region)).name=c.value,c.blur(),this.container.style.display="none",await this.browser.roiManager.repaintTable()})),s=ge({class:"igv-roi-menu-row"}),s.innerText="Delete region",this.container.appendChild(s),s.addEventListener("click",(t=>{t.stopPropagation(),this.container.style.display="none",this.browser.roiManager.deleteUserDefinedRegionWithKey(i.dataset.region,this.browser.columnContainer)})),this.container.style.left=`${t}px`,this.container.style.top=`${e}px`,this.container.style.display="flex",r.addEventListener("click",(t=>{t.stopPropagation(),this.container.style.display="none"}))}dispose(){this.container.innerHTML=""}}function cv(t){for(;t.firstChild;)t.removeChild(t.firstChild)}class hv{constructor(t,e){this.name=t.name,this.featureSource=t.featureSource||ef(t,e),this.color=t.color||nf}async getFeatures(t,e,n){return this.featureSource.getFeatures({chr:t,start:e,end:n})}draw(t){const{context:e,bpPerPixel:n,bpStart:r,pixelTop:i,pixelHeight:o,pixelWidth:s,features:a}=t;if(!a)return;const l=r+s*n+1;for(let{start:t,end:s}of a){if(s<r)continue;if(t>l)break;const{x:a,width:c}=sf(t,s,r,n);ns.fillRect(e,a,i,c,o,{fillStyle:this.color})}}}class uv{constructor(t,e){this.browser=e,this.button=ge({class:"igv-navbar-button"}),t.appendChild(this.button),this.button.textContent="ROI Table",this.button.addEventListener("click",(()=>{this.buttonHandler(!e.roiTableVisible)})),this.browser=e,this.setVisibility(e.showROITableButton),this.setState(e.roiTableVisible)}buttonHandler(t){this.browser.roiTableVisible=t,this.setState(this.browser.roiTableVisible),this.browser.setROITableVisibility(this.browser.roiTableVisible)}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.roiTableVisible)}hide(){this.button.style.display="none"}}class fv{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),this.alert=new Ls(this.root),this.columnContainer=ge({class:"igv-column-container"}),this.root.appendChild(this.columnContainer),this.menuPopup=new Cg(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&&(Rg.gtexLoaded=!0),this.flanking=t.flanking,this.crossDomainProxy=t.crossDomainProxy,this.formats=t.formats,this.trackDefaults=t.trackDefaults,this.nucleotideColors=t.nucleotideColors||ca;for(let t of Object.keys(this.nucleotideColors))this.nucleotideColors[t.toLowerCase()]=this.nucleotideColors[t];this.trackLabelsVisible=t.showTrackLabels,this.roiTableVisible=t.showROITable,this.showROITableButton=t.showROITableButton,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 Om(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 Pm(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 l=ge({class:"igv-search-icon-container"});a.append(pe(l)),l.appendChild(ye("search")),l.addEventListener("click",(()=>this.doSearch(this.$searchInput.val()))),this.windowSizePanel=new Fm(s.get(0),this);const c=pe("<div>",{class:"igv-navbar-right-container"});e.append(c);const h=pe('<div class="igv-navbar-toggle-button-container">');if(c.append(h),this.$toggle_button_container=h,this.cursorGuide=new Dm(this.columnContainer,this),this.cursorGuideButton=new Bm(this,h.get(0)),this.centerLineButton=new zm(this,h.get(0)),this.setTrackLabelVisibility(t.showTrackLabels),this.trackLabelControl=new Hm(h.get(0),this),this.roiTableControl=new uv(h.get(0),this),this.sampleNameControl=new Vm(h.get(0),this),!0===t.showSVGButton&&(this.svgSaveControl=new Wm(h.get(0),this)),t.customButtons)for(let e of t.customButtons)new tv(h.get(0),this,e);return this.zoomWidget=new qm(this,c.get(0)),!1===t.showNavigation&&this.$navigation.hide(),this.inputDialog=new vs(this.root),this.inputDialog.container.id=`igv-input-dialog-${be()}`,this.dataRangeDialog=new Xo(this,pe(this.root)),this.dataRangeDialog.$container.get(0).id=`igv-data-range-dialog-${be()}`,this.genericColorPicker=new As({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){km(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}currentLoci(){const t=t=>`${t.chr}:${t.start+1}-${t.end}`;return void 0===this.referenceFrameList||0===this.referenceFrameList.length?"":1===this.referenceFrameList.length?t(this.referenceFrameList[0]):this.referenceFrameList.map((e=>t(e)))}toSVG(){const{y:t,width:e,height:n}=this.columnContainer.getBoundingClientRect(),r=new Ta({width:e,height:8e3,backdropColor:"white",multiLocusGap:0,viewbox:{x:0,y:0,width:e,height:8e3}});for(let e of this.trackViews)e.renderSVGContext(r,{deltaX:0,deltaY:-t});return r.setHeight(n),r.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.roiSets=[],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=fv.uncompressSession(t.url);return JSON.parse(e)}{let n=t.filename;if(n||(n=t.url?await Ps(t.url):t.file.name),n.endsWith(".xml")){const t=Ra.KNOWN_GENOMES,n=await To.loadString(e);return new Cm(n,t)}return n.endsWith(".json")?To.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),Bs(this.columnContainer,"igv-axis-column"),Bs(this.columnContainer,"igv-sample-name-column"),Bs(this.columnContainer,"igv-scrollbar-column"),Bs(this.columnContainer,"igv-track-drag-column"),Bs(this.columnContainer,"igv-gear-menu-column");const e=t.reference||t.genome;if(!e)return void console.warn("No genome or reference object specified");const n=await Ra.expandReference(this.alert,e);await this.loadReference(n,t.locus),this.centerLineList=this.createCenterLineList(this.columnContainer);let r=0;if(!1!==t.showIdeogram){const t=new vm(this);t.id="ideogram";const e=new Lg(this,this.columnContainer,t),{$viewport:n}=e.viewports[0];r=function(t){t="string"==typeof t?document.querySelector(t):t;const e=window.getComputedStyle(t),n=parseFloat(e.marginTop)+parseFloat(e.marginBottom),r=t.offsetHeight;return Math.ceil(n+r)}(n.get(0)),this.trackViews.push(e)}if(!1!==t.showRuler&&this.trackViews.push(new Lg(this,this.columnContainer,new Km(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 Lm(r,i)}this.roiManager&&this.roiManager.dispose();const i=new lv(this,this.columnContainer);if(t.roi){const e=t.roi.map((t=>new of(t,this.genome))),n=e.filter((t=>{let{name:e}=t;return void 0!==e&&e.length>0})),o=new av(this,this.columnContainer,n.length>0);this.roiManager=new ev(this,i,o,r,e)}else{const t=new av(this,this.columnContainer,!1);this.roiManager=new ev(this,i,t,r,void 0)}await this.roiManager.initialize();const o=n.tracks||[],s=t.tracks?o.concat(t.tracks):o;0===s.filter((t=>"sequence"===t.type&&!t.url&&!t.fastaURL)).length&&s.push({type:"sequence",order:ha});let a=1;for(let t of s)void 0===t.order&&(t.order=a++);await this.loadTrackList(s);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 Xm(this,this.referenceFrameList[t],r[t]));return n}async loadReference(t,e){const n=await Ra.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:sg(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){let e=t.id&&t.id.length<10?t.id:"";this.$current_genome.text(e),this.$current_genome.attr("title",t.id||""),this.chromosomeSelectWidget.update(t)}async loadGenome(t){const e=await Ra.expandReference(this.alert,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:ha}),await this.loadTrackList(n),await this.updateViews(),this.genome}updateUIWithReferenceFrameList(){const t=this.referenceFrameList;this.updateLocusSearchWidget();const e=this.isMultiLocusWholeGenomeView()||Ra.isWholeGenomeView(t[0].chr);this.navbarManager.navbarDidResize(this.$navigation.width(),e),mv(this.trackViews,this.trackLabelsVisible),this.setCenterLineAndCenterLineButtonVisibility(!Ra.isWholeGenomeView(t[0].chr))}setTrackLabelVisibility(t){mv(this.trackViews,t)}setROITableVisibility(t){!0===t?this.roiManager.presentTable():this.roiManager.dismissTable()}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 loadTrack(t){const e=this._loadTrack(t);return t.autoscaleGroup&&(await e,this.updateViews()),e}async _loadTrack(t){ke(t)&&(t=JSON.parse(t));try{const e=await this.createTrack(t);if(void 0===e)return;void 0===e.order&&(e.order=this.trackViews.length);const n=new Lg(this,this.columnContainer,e);if(this.trackViews.push(n),mv(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,this.alert.present(new Error(r),void 0)}}async loadROI(t){await this.roiManager.loadROI(t,this.genome)}clearROIs(){this.roiManager.clearROIs()}async getUserDefinedROIs(){if(this.roiManager){const t=await this.roiManager.getUserDefinedROISet();if(void 0===t)return[];const e=await t.getAllFeatures(),n=[];for(let t of Object.values(e))n.push(...t);return n}return[]}getRulerTrackView(){const t=this.trackViews.filter((t=>{let{track:e}=t;return"ruler"===e.id}));return t.length>0?t[0]:void 0}async createTrack(t){let e=await async function(t){return"function"==typeof t?t():t}(t.url||t.fastaURL);if(ke(e)&&(e=e.trim()),e)if(t.format)t.format=t.format.toLowerCase();else if(t.fastaURL)t.format="fasta";else{let n=t.filename;n||(n=await Ps(e));const r=$s(n);"tsv"===r?t.format=await async function(t){if(t.url){const e=await To.loadString(t.url,Is(t,{range:{start:0,size:1e3}}));if(e&&qs(e.split("\n")[0].split("\t")))return"hiccups"}}(t):r?t.format=r:"htsget"===t.sourceType&&await Tc.inferFormat(t)}let n=t.type?t.type.toLowerCase():void 0;if(!n){if(n=Gs(t),"bedtype"===n){const e=ef(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=Sm(n,t,this);if(void 0!==r)return t.roi&&t.roi.length>0&&(r.roiSets=t.roi.map((t=>new hv(t,this.genome)))),r;this.alert.present(new Error(`Error creating track. Could not determine track type for file: ${t.url||t}`),void 0)}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){for(let e of this.trackViews)if(t===e.track){this._removeTrack(e.track);break}}_removeTrack(t){t.disposed||(this.trackViews.splice(this.trackViews.indexOf(t.trackView),1),this.fireEvent("trackremoved",[t]),this.fireEvent("trackorderchanged",[this.getTrackOrder()]),t.trackView&&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()||Ra.isWholeGenomeView(this.referenceFrameList[0].chr);this.navbarManager.navbarDidResize(this.$navigation.width(),t)}dv.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=Ns(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 Rm(this.genome,t,e,n,s),l=r?this.referenceFrameList.indexOf(r):this.referenceFrameList.length-1,c=1+l,{$viewport:h}=this.trackViews[0].viewports[l],u=Gm(h.get(0).parentElement);if(c===this.referenceFrameList.length){this.referenceFrameList.push(a);for(let t of this.trackViews){const e=xg(t,u,a);t.viewports.push(e)}}else{this.referenceFrameList.splice(c,0,a);for(let t of this.trackViews){const e=xg(t,u,a);t.viewports.splice(c,0,e)}}this.centerLineList=this.createCenterLineList(this.columnContainer),dv.call(this),await this.updateViews(!0)}async removeMultiLocusPanel(t){const e=this.referenceFrameList.indexOf(t),{$viewport:n}=this.trackViews[0].viewports[e];$m(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((t=>{let{viewports:e}=t;return e.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||this.alert.present(new Error(`Unrecognized locus: <b> ${t} </b>`)),n}async search(t,e){const n=await Nm(this,t);if(n&&n.length>0){this.referenceFrameList=function(t,e,n,r,i,o){return t.map((t=>{if(n&&t.gene&&(t.start=Math.max(0,t.start-n),t.end+=n),!o){const n=e.getChromosome(t.chr);Os(n.bpLength,t,r)}const s=new Rm(e,t.chr,t.start,t.end,(t.end-t.start)/i);return s.locusSearchString=t.locusSearchString,(t.gene||t.snp)&&(s.selection=new Lm(t.gene,t.snp)),s}))}(n,this.genome,this.flanking,this.minimumBases(),this.calculateViewportWidth(n.length),this.isSoftclipped());for(let t of this.trackViews)t.removeDOMFromColumnContainer();this.columnContainer.querySelectorAll(".igv-column-shim, .igv-column").forEach((t=>t.remove())),Zm(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 Am).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.13.9"};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),t.roi=this.roiManager.toJSON();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 no.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"))}isTrackPanning(){return this.dragObject}isSoftclipped(){return void 0!==this.trackViews.find((t=>!0===t.track.showSoftClips))}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=dv.bind(this),window.addEventListener("resize",this.boundWindowResizeHandler)}removeWindowResizeHandler(){window.removeEventListener("resize",this.boundWindowResizeHandler)}addRootMouseUpHandler(){this.boundRootMouseUpHandler=gv.bind(this),this.root.addEventListener("mouseup",this.boundRootMouseUpHandler)}removeRootMouseUpHandler(){this.root.removeEventListener("mouseup",this.boundRootMouseUpHandler)}addRootMouseLeaveHandler(){this.boundRootMouseLeaveHandler=gv.bind(this),this.root.addEventListener("mouseleave",this.boundRootMouseLeaveHandler)}removeRootMouseLeaveHandler(){this.root.removeEventListener("mouseleave",this.boundRootMouseLeaveHandler)}addColumnContainerEventHandlers(){this.boundColumnContainerMouseMoveHandler=pv.bind(this),this.boundColumnContainerTouchMoveHandler=pv.bind(this),this.boundColumnContainerMouseLeaveHandler=gv.bind(this),this.boundColumnContainerMouseUpHandler=gv.bind(this),this.boundColumnContainerTouchEndHandler=gv.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 To.loadJson(e,Is({}))}static uncompressSession(t){let e;if(t.indexOf("/gzip;base64")>0){e=ho(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=no.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 Jp(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=Rp.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 Jm(this.$toggle_button_container.get(0),this),this.circularView.setAssembly({name:this.genome.id,id:this.genome.id,chromosomes:sg(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 dv(){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);Ra.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 pv(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=Mg(t.trackView.viewports);this.vpMouseDown.r=e/n}if(this.dragObject){const n=!this.isSoftclipped();let i=this.vpMouseDown.lastMouseX-e;r.shiftPixels(i,t.$viewport.width(),n)&&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 gv(t){this.cancelTrackPan(),this.endTrackDrag()}function mv(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 vv=[];const bv=To.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}\n.igv-navbar .igv-navbar-left-container {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n height: 32px;\n line-height: 32px;\n}\n.igv-navbar .igv-navbar-left-container .igv-logo {\n width: 34px;\n height: 32px;\n margin-right: 8px;\n}\n.igv-navbar .igv-navbar-left-container .igv-current-genome {\n height: 32px;\n margin-left: 4px;\n margin-right: 4px;\n user-select: none;\n line-height: 32px;\n vertical-align: middle;\n text-align: center;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n height: 100%;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-chromosome-select-widget-container {\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n height: 100%;\n width: 125px;\n margin-right: 4px;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-chromosome-select-widget-container select {\n display: block;\n cursor: pointer;\n width: 100px;\n height: 75%;\n outline: none;\n font-size: 12px;\n font-family: "Open Sans", sans-serif;\n font-weight: 400;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n margin-left: 8px;\n height: 22px;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-search-container {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n width: 210px;\n height: 22px;\n line-height: 22px;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-search-container input.igv-search-input {\n cursor: text;\n width: 85%;\n height: 22px;\n line-height: 22px;\n font-size: 12px;\n font-family: "Open Sans", sans-serif;\n font-weight: 400;\n text-align: left;\n padding-left: 8px;\n margin-right: 8px;\n outline: none;\n border-style: solid;\n border-radius: 3px;\n border-width: thin;\n border-color: #bfbfbf;\n background-color: white;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-search-container .igv-search-icon-container {\n cursor: pointer;\n height: 16px;\n width: 16px;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-windowsize-panel-container {\n margin-left: 4px;\n user-select: none;\n}\n.igv-navbar .igv-navbar-right-container {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n height: 32px;\n line-height: 32px;\n}\n.igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n height: 100%;\n}\n.igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container div {\n margin-left: 0;\n margin-right: 4px;\n}\n.igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container div:last-child {\n margin-left: 0;\n margin-right: 0;\n}\n.igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container-750 {\n display: none;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget {\n color: #737373;\n font-size: 18px;\n height: 32px;\n line-height: 32px;\n margin-left: 8px;\n user-select: none;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div {\n cursor: pointer;\n margin-left: unset;\n margin-right: unset;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div:first-child {\n height: 24px;\n width: 24px;\n margin-left: unset;\n margin-right: 8px;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div:last-child {\n height: 24px;\n width: 24px;\n margin-left: 8px;\n margin-right: unset;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div:nth-child(even) {\n display: block;\n height: fit-content;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget input {\n display: block;\n width: 125px;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget svg {\n display: block;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 {\n color: #737373;\n font-size: 18px;\n height: 32px;\n line-height: 32px;\n margin-left: 8px;\n user-select: none;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div {\n cursor: pointer;\n margin-left: unset;\n margin-right: unset;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div:first-child {\n height: 24px;\n width: 24px;\n margin-left: unset;\n margin-right: 8px;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div:last-child {\n height: 24px;\n width: 24px;\n margin-left: 8px;\n margin-right: unset;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div:nth-child(even) {\n width: 0;\n height: 0;\n display: none;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 input {\n width: 0;\n height: 0;\n display: none;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 svg {\n display: block;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-hidden {\n display: none;\n}\n\n.igv-navbar-button {\n display: block;\n box-sizing: unset;\n padding-left: 6px;\n padding-right: 6px;\n height: 18px;\n text-transform: capitalize;\n user-select: none;\n line-height: 18px;\n text-align: center;\n vertical-align: middle;\n font-family: "Open Sans", sans-serif;\n font-size: 11px;\n font-weight: 200;\n color: #737373;\n background-color: #f3f3f3;\n border-color: #737373;\n border-style: solid;\n border-width: thin;\n border-radius: 6px;\n}\n\n.igv-navbar-button-clicked {\n color: white;\n background-color: #737373;\n}\n\n.igv-navbar-button:hover {\n cursor: pointer;\n}\n\n.igv-zoom-in-notice-container {\n z-index: 1024;\n position: absolute;\n top: 8px;\n left: 50%;\n transform: translate(-50%, 0%);\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n justify-content: center;\n align-items: center;\n background-color: white;\n}\n.igv-zoom-in-notice-container > div {\n padding-left: 4px;\n padding-right: 4px;\n padding-top: 2px;\n padding-bottom: 2px;\n width: 100%;\n height: 100%;\n font-family: "Open Sans", sans-serif;\n font-size: 14px;\n font-weight: 400;\n color: #3f3f3f;\n}\n\n.igv-zoom-in-notice {\n position: absolute;\n top: 10px;\n left: 50%;\n}\n.igv-zoom-in-notice div {\n position: relative;\n left: -50%;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n color: #3f3f3f;\n background-color: rgba(255, 255, 255, 0.51);\n z-index: 64;\n}\n\n.igv-container-spinner {\n position: absolute;\n top: 90%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 1024;\n width: 24px;\n height: 24px;\n pointer-events: none;\n color: #737373;\n}\n\n.igv-multi-locus-close-button {\n position: absolute;\n top: 2px;\n right: 0;\n padding-left: 2px;\n padding-right: 2px;\n width: 18px;\n height: 18px;\n color: #666666;\n background-color: white;\n z-index: 1000;\n}\n.igv-multi-locus-close-button > svg {\n vertical-align: top;\n}\n\n.igv-multi-locus-close-button:hover {\n cursor: pointer;\n color: #434343;\n}\n\n.igv-multi-locus-ruler-label {\n z-index: 64;\n position: absolute;\n top: 2px;\n left: 0;\n width: 100%;\n height: 14px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: center;\n align-items: center;\n}\n.igv-multi-locus-ruler-label div {\n font-family: "Open Sans", sans-serif;\n font-size: 14px;\n font-weight: 400;\n color: rgb(16, 16, 16);\n background-color: white;\n}\n\n.igv-multi-locus-ruler-label-square-dot {\n z-index: 64;\n position: absolute;\n left: 50%;\n top: 5%;\n transform: translate(-50%, 0%);\n background-color: white;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-multi-locus-ruler-label-square-dot > div:first-child {\n width: 14px;\n height: 14px;\n}\n.igv-multi-locus-ruler-label-square-dot > div:last-child {\n margin-left: 16px;\n font-family: "Open Sans", sans-serif;\n font-size: 14px;\n font-weight: 400;\n color: rgb(16, 16, 16);\n}\n\n.igv-multi-locus-ruler-label:hover {\n cursor: pointer;\n}\n\n.igv-ruler-sweeper {\n display: none;\n pointer-events: none;\n position: absolute;\n top: 26px;\n bottom: 0;\n left: 0;\n width: 0;\n z-index: 99999;\n background-color: rgba(68, 134, 247, 0.25);\n}\n\n.igv-ruler-tooltip {\n pointer-events: none;\n z-index: 128;\n position: absolute;\n top: 0;\n left: 0;\n width: 1px;\n height: 32px;\n background-color: transparent;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-ruler-tooltip > div {\n pointer-events: none;\n width: 128px;\n height: auto;\n padding: 1px;\n color: #373737;\n font-size: 10px;\n font-family: "Open Sans", sans-serif;\n font-weight: 400;\n background-color: white;\n border-style: solid;\n border-width: thin;\n border-color: #373737;\n}\n\n.igv-track-label {\n position: absolute;\n left: 8px;\n top: 8px;\n width: auto;\n height: auto;\n max-width: 50%;\n padding-left: 4px;\n padding-right: 4px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n font-family: "Open Sans", sans-serif;\n font-size: small;\n font-weight: 400;\n text-align: center;\n user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n border-color: #444;\n border-radius: 2px;\n border-style: solid;\n border-width: thin;\n background-color: white;\n z-index: 128;\n cursor: pointer;\n}\n\n.igv-track-label:hover,\n.igv-track-label:focus,\n.igv-track-label:active {\n background-color: #e8e8e8;\n}\n\n.igv-track-label-popup-shim {\n padding-left: 8px;\n padding-right: 8px;\n padding-top: 4px;\n}\n\n.igv-center-line {\n display: none;\n pointer-events: none;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 50%;\n transform: translateX(-50%);\n z-index: 8;\n user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n border-left-style: dashed;\n border-left-width: thin;\n border-right-style: dashed;\n border-right-width: thin;\n}\n\n.igv-center-line-wide {\n background-color: rgba(0, 0, 0, 0);\n border-left-color: rgba(127, 127, 127, 0.51);\n border-right-color: rgba(127, 127, 127, 0.51);\n}\n\n.igv-center-line-thin {\n background-color: rgba(0, 0, 0, 0);\n border-left-color: rgba(127, 127, 127, 0.51);\n border-right-color: rgba(0, 0, 0, 0);\n}\n\n.igv-cursor-guide-horizontal {\n display: none;\n pointer-events: none;\n user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n position: absolute;\n left: 0;\n right: 0;\n top: 50%;\n height: 1px;\n z-index: 1;\n margin-left: 50px;\n margin-right: 54px;\n border-top-style: dotted;\n border-top-width: thin;\n border-top-color: rgba(127, 127, 127, 0.76);\n}\n\n.igv-cursor-guide-vertical {\n pointer-events: none;\n user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 50%;\n width: 1px;\n z-index: 1;\n border-left-style: dotted;\n border-left-width: thin;\n border-left-color: rgba(127, 127, 127, 0.76);\n display: none;\n}\n\n.igv-user-feedback {\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 512px;\n height: 360px;\n z-index: 2048;\n background-color: white;\n border-color: #a2a2a2;\n border-style: solid;\n border-width: thin;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n color: #444;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-user-feedback div:first-child {\n position: relative;\n height: 24px;\n width: 100%;\n background-color: white;\n border-bottom-color: #a2a2a2;\n border-bottom-style: solid;\n border-bottom-width: thin;\n}\n.igv-user-feedback div:first-child div {\n position: absolute;\n top: 2px;\n width: 16px;\n height: 16px;\n background-color: transparent;\n}\n.igv-user-feedback div:first-child div:first-child {\n left: 8px;\n}\n.igv-user-feedback div:first-child div:last-child {\n cursor: pointer;\n right: 8px;\n}\n.igv-user-feedback div:last-child {\n width: 100%;\n height: calc(100% - 24px);\n border-width: 0;\n}\n.igv-user-feedback div:last-child div {\n width: auto;\n height: auto;\n margin: 8px;\n}\n\n.igv-generic-dialog-container {\n position: absolute;\n top: 0;\n left: 0;\n width: 300px;\n height: 200px;\n border-color: #7F7F7F;\n border-radius: 4px;\n border-style: solid;\n border-width: thin;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n z-index: 2048;\n background-color: white;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-generic-dialog-container .igv-generic-dialog-header {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n width: 100%;\n height: 24px;\n cursor: move;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-bottom-color: #7F7F7F;\n border-bottom-style: solid;\n border-bottom-width: thin;\n background-color: #eee;\n}\n.igv-generic-dialog-container .igv-generic-dialog-header div {\n margin-right: 4px;\n margin-bottom: 2px;\n height: 12px;\n width: 12px;\n color: #7F7F7F;\n}\n.igv-generic-dialog-container .igv-generic-dialog-header div:hover {\n cursor: pointer;\n color: #444;\n}\n.igv-generic-dialog-container .igv-generic-dialog-one-liner {\n color: #373737;\n width: 95%;\n height: 24px;\n line-height: 24px;\n text-align: left;\n margin-top: 8px;\n padding-left: 8px;\n overflow-wrap: break-word;\n background-color: white;\n}\n.igv-generic-dialog-container .igv-generic-dialog-label-input {\n margin-top: 8px;\n width: 95%;\n height: 24px;\n color: #373737;\n line-height: 24px;\n padding-left: 8px;\n background-color: white;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-generic-dialog-container .igv-generic-dialog-label-input div {\n width: 30%;\n height: 100%;\n font-size: 16px;\n text-align: right;\n padding-right: 8px;\n background-color: white;\n}\n.igv-generic-dialog-container .igv-generic-dialog-label-input input {\n display: block;\n height: 100%;\n width: 100%;\n padding-left: 4px;\n font-family: "Open Sans", sans-serif;\n font-weight: 400;\n color: #373737;\n text-align: left;\n outline: none;\n border-style: solid;\n border-width: thin;\n border-color: #7F7F7F;\n background-color: white;\n}\n.igv-generic-dialog-container .igv-generic-dialog-label-input input {\n width: 50%;\n font-size: 16px;\n}\n.igv-generic-dialog-container .igv-generic-dialog-input {\n margin-top: 8px;\n width: calc(100% - 16px);\n height: 24px;\n color: #373737;\n line-height: 24px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n.igv-generic-dialog-container .igv-generic-dialog-input input {\n display: block;\n height: 100%;\n width: 100%;\n padding-left: 4px;\n font-family: "Open Sans", sans-serif;\n font-weight: 400;\n color: #373737;\n text-align: left;\n outline: none;\n border-style: solid;\n border-width: thin;\n border-color: #7F7F7F;\n background-color: white;\n}\n.igv-generic-dialog-container .igv-generic-dialog-input input {\n font-size: 16px;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel {\n width: 100%;\n height: 28px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div {\n margin-top: 32px;\n color: white;\n font-family: "Open Sans", sans-serif;\n font-size: 14px;\n font-weight: 400;\n width: 75px;\n height: 28px;\n line-height: 28px;\n text-align: center;\n border-color: transparent;\n border-style: solid;\n border-width: thin;\n border-radius: 2px;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:first-child {\n margin-left: 32px;\n margin-right: 0;\n background-color: #5ea4e0;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:last-child {\n margin-left: 0;\n margin-right: 32px;\n background-color: #c4c4c4;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:first-child:hover {\n cursor: pointer;\n background-color: #3b5c7f;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:last-child:hover {\n cursor: pointer;\n background-color: #7f7f7f;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok {\n width: 100%;\n height: 36px;\n margin-top: 32px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok div {\n width: 98px;\n height: 36px;\n line-height: 36px;\n text-align: center;\n color: white;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n border-color: white;\n border-style: solid;\n border-width: thin;\n border-radius: 4px;\n background-color: #2B81AF;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok div:hover {\n cursor: pointer;\n background-color: #25597f;\n}\n\n.igv-generic-container {\n position: absolute;\n top: 0;\n left: 0;\n z-index: 2048;\n background-color: white;\n cursor: pointer;\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-generic-container div:first-child {\n cursor: move;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n height: 24px;\n width: 100%;\n background-color: #dddddd;\n}\n.igv-generic-container div:first-child i {\n display: block;\n color: #5f5f5f;\n cursor: pointer;\n width: 14px;\n height: 14px;\n margin-right: 8px;\n margin-bottom: 4px;\n}\n\n.igv-menu-popup {\n position: absolute;\n top: 0;\n left: 0;\n width: max-content;\n z-index: 4096;\n cursor: pointer;\n font-family: "Open Sans", sans-serif;\n font-size: small;\n font-weight: 400;\n color: #4b4b4b;\n background: white;\n border-radius: 4px;\n border-color: #7F7F7F;\n border-style: solid;\n border-width: thin;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-end;\n text-align: left;\n}\n.igv-menu-popup > div:not(:first-child) {\n width: 100%;\n}\n.igv-menu-popup > div:not(:first-child) > div {\n background: white;\n}\n.igv-menu-popup > div:not(:first-child) > div.context-menu {\n padding-left: 4px;\n padding-right: 4px;\n}\n.igv-menu-popup > div:not(:first-child) > div:last-child {\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n border-bottom-color: transparent;\n border-bottom-style: solid;\n border-bottom-width: thin;\n}\n.igv-menu-popup > div:not(:first-child) > div:hover {\n background: #efefef;\n}\n\n.igv-menu-popup-shim {\n padding-left: 8px;\n padding-right: 8px;\n padding-bottom: 1px;\n padding-top: 1px;\n}\n\n.igv-menu-popup-header {\n position: relative;\n width: 100%;\n height: 24px;\n cursor: move;\n border-top-color: transparent;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-bottom-color: #7F7F7F;\n border-bottom-style: solid;\n border-bottom-width: thin;\n background-color: #eee;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n}\n.igv-menu-popup-header div {\n margin-right: 4px;\n height: 12px;\n width: 12px;\n color: #7F7F7F;\n}\n.igv-menu-popup-header div:hover {\n cursor: pointer;\n color: #444;\n}\n\n.igv-menu-popup-check-container {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n width: 100%;\n height: 20px;\n margin-right: 4px;\n background-color: transparent;\n}\n.igv-menu-popup-check-container div {\n padding-top: 2px;\n padding-left: 8px;\n}\n.igv-menu-popup-check-container div:first-child {\n position: relative;\n width: 12px;\n height: 12px;\n}\n.igv-menu-popup-check-container div:first-child svg {\n position: absolute;\n width: 12px;\n height: 12px;\n}\n\n.igv-user-feedback {\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 512px;\n height: 360px;\n z-index: 2048;\n background-color: white;\n border-color: #a2a2a2;\n border-style: solid;\n border-width: thin;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n color: #444;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-user-feedback div:first-child {\n position: relative;\n height: 24px;\n width: 100%;\n background-color: white;\n border-bottom-color: #a2a2a2;\n border-bottom-style: solid;\n border-bottom-width: thin;\n}\n.igv-user-feedback div:first-child div {\n position: absolute;\n top: 2px;\n width: 16px;\n height: 16px;\n background-color: transparent;\n}\n.igv-user-feedback div:first-child div:first-child {\n left: 8px;\n}\n.igv-user-feedback div:first-child div:last-child {\n cursor: pointer;\n right: 8px;\n}\n.igv-user-feedback div:last-child {\n width: 100%;\n height: calc(100% - 24px);\n border-width: 0;\n}\n.igv-user-feedback div:last-child div {\n width: auto;\n height: auto;\n margin: 8px;\n}\n\n.igv-loading-spinner-container {\n z-index: 1024;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 32px;\n height: 32px;\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n justify-content: center;\n align-items: center;\n}\n.igv-loading-spinner-container > div {\n box-sizing: border-box;\n width: 100%;\n height: 100%;\n border-radius: 50%;\n border: 4px solid rgba(128, 128, 128, 0.5);\n border-top-color: rgb(255, 255, 255);\n animation: spin 1s ease-in-out infinite;\n -webkit-animation: spin 1s ease-in-out infinite;\n}\n\n@keyframes spin {\n to {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n@-webkit-keyframes spin {\n to {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n.igv-roi-menu-next-gen {\n position: absolute;\n z-index: 512;\n font-family: "Open Sans", sans-serif;\n font-size: small;\n font-weight: 400;\n color: #4b4b4b;\n background-color: white;\n width: 192px;\n border-radius: 4px;\n border-color: #7F7F7F;\n border-style: solid;\n border-width: thin;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n}\n.igv-roi-menu-next-gen > div:first-child {\n height: 24px;\n border-top-color: transparent;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-bottom-color: #7F7F7F;\n border-bottom-style: solid;\n border-bottom-width: thin;\n background-color: #eee;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n}\n.igv-roi-menu-next-gen > div:first-child > div {\n margin-right: 4px;\n height: 12px;\n width: 12px;\n color: #7F7F7F;\n}\n.igv-roi-menu-next-gen > div:first-child > div:hover {\n cursor: pointer;\n color: #444;\n}\n.igv-roi-menu-next-gen > div:last-child {\n background-color: white;\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n border-bottom-color: transparent;\n border-bottom-style: solid;\n border-bottom-width: 0;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n text-align: start;\n vertical-align: middle;\n cursor: pointer;\n}\n.igv-roi-menu-next-gen > div:last-child > div {\n height: 24px;\n padding-left: 4px;\n border-bottom-style: solid;\n border-bottom-width: thin;\n border-bottom-color: #7f7f7f;\n}\n.igv-roi-menu-next-gen > div:last-child > div:not(:first-child):hover {\n background-color: rgba(127, 127, 127, 0.1);\n}\n.igv-roi-menu-next-gen > div:last-child div:first-child {\n cursor: default;\n font-style: italic;\n text-align: center;\n padding-right: 4px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.igv-roi-menu-next-gen > div:last-child > div:last-child {\n border-bottom-width: 0;\n border-bottom-color: transparent;\n}\n\n.igv-roi-placeholder {\n font-style: normal;\n color: rgba(75, 75, 75, 0.6);\n}\n\n.igv-roi-table {\n position: absolute;\n z-index: 1024;\n width: fit-content;\n border-color: #7f7f7f;\n border-radius: 4px;\n border-style: solid;\n border-width: thin;\n font-family: "Open Sans", sans-serif;\n font-size: 12px;\n font-weight: 400;\n background-color: white;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n}\n.igv-roi-table > div {\n height: 24px;\n font-size: 14px;\n text-align: start;\n vertical-align: middle;\n line-height: 24px;\n}\n.igv-roi-table > div:first-child {\n border-color: transparent;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-top-width: 0;\n border-bottom-color: #7f7f7f;\n border-bottom-style: solid;\n border-bottom-width: thin;\n background-color: #eee;\n cursor: move;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n}\n.igv-roi-table > div:first-child > div:first-child {\n text-align: center;\n width: calc(100% - 4px - 12px);\n}\n.igv-roi-table > div:first-child > div:last-child {\n margin-right: 4px;\n margin-bottom: 2px;\n height: 12px;\n width: 12px;\n color: #7f7f7f;\n}\n.igv-roi-table > div:first-child > div:last-child > svg {\n display: block;\n}\n.igv-roi-table > div:first-child > div:last-child:hover {\n cursor: pointer;\n color: #444;\n}\n.igv-roi-table > .igv-roi-table-column-titles {\n height: 24px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: stretch;\n align-items: stretch;\n padding-right: 16px;\n background-color: white;\n border-bottom-color: #7f7f7f;\n border-bottom-style: solid;\n border-bottom-width: thin;\n}\n.igv-roi-table > .igv-roi-table-column-titles > div {\n font-size: 14px;\n vertical-align: middle;\n line-height: 24px;\n text-align: center;\n margin-left: 4px;\n margin-right: 4px;\n height: 24px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.igv-roi-table > .igv-roi-table-column-titles > div:nth-child(1) {\n width: 20%;\n}\n.igv-roi-table > .igv-roi-table-column-titles > div:nth-child(2) {\n width: 15%;\n}\n.igv-roi-table > .igv-roi-table-column-titles > div:nth-child(3) {\n width: 15%;\n}\n.igv-roi-table > .igv-roi-table-column-titles > div:nth-child(4) {\n width: 30%;\n}\n.igv-roi-table > .igv-roi-table-column-titles > div:nth-child(5) {\n width: 20%;\n}\n.igv-roi-table > .igv-roi-table-row-container {\n resize: both;\n overflow: scroll;\n min-width: 512px;\n min-height: 72px;\n height: 144px;\n max-height: 480px;\n background-color: white;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n}\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row {\n height: 24px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: stretch;\n align-items: stretch;\n}\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row > div {\n font-size: 14px;\n vertical-align: middle;\n line-height: 24px;\n text-align: center;\n margin-left: 4px;\n margin-right: 4px;\n height: 24px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row > div:nth-child(1) {\n width: 20%;\n}\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row > div:nth-child(2) {\n width: 15%;\n}\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row > div:nth-child(3) {\n width: 15%;\n}\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row > div:nth-child(4) {\n width: 30%;\n}\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row > div:nth-child(5) {\n width: 20%;\n}\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row-hover {\n background-color: rgba(0, 0, 0, 0.04);\n}\n.igv-roi-table > div:last-child {\n height: 32px;\n line-height: 32px;\n border-top-color: #7f7f7f;\n border-top-style: solid;\n border-top-width: thin;\n border-bottom-color: transparent;\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n border-bottom-width: 0;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n\n.igv-roi-table-four-column {\n position: absolute;\n z-index: 1024;\n width: fit-content;\n border-color: #7f7f7f;\n border-radius: 4px;\n border-style: solid;\n border-width: thin;\n font-family: "Open Sans", sans-serif;\n font-size: 12px;\n font-weight: 400;\n background-color: white;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n}\n.igv-roi-table-four-column > div {\n height: 24px;\n font-size: 14px;\n text-align: start;\n vertical-align: middle;\n line-height: 24px;\n}\n.igv-roi-table-four-column > div:first-child {\n border-color: transparent;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-top-width: 0;\n border-bottom-color: #7f7f7f;\n border-bottom-style: solid;\n border-bottom-width: thin;\n background-color: #eee;\n cursor: move;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n}\n.igv-roi-table-four-column > div:first-child > div:first-child {\n text-align: center;\n width: calc(100% - 4px - 12px);\n}\n.igv-roi-table-four-column > div:first-child > div:last-child {\n margin-right: 4px;\n margin-bottom: 2px;\n height: 12px;\n width: 12px;\n color: #7f7f7f;\n}\n.igv-roi-table-four-column > div:first-child > div:last-child > svg {\n display: block;\n}\n.igv-roi-table-four-column > div:first-child > div:last-child:hover {\n cursor: pointer;\n color: #444;\n}\n.igv-roi-table-four-column > .igv-roi-table-column-titles {\n height: 24px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: stretch;\n align-items: stretch;\n padding-right: 16px;\n background-color: white;\n border-bottom-color: #7f7f7f;\n border-bottom-style: solid;\n border-bottom-width: thin;\n}\n.igv-roi-table-four-column > .igv-roi-table-column-titles > div {\n font-size: 14px;\n vertical-align: middle;\n line-height: 24px;\n text-align: center;\n margin-left: 4px;\n margin-right: 4px;\n height: 24px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.igv-roi-table-four-column > .igv-roi-table-column-titles > div:nth-child(1) {\n width: 25%;\n}\n.igv-roi-table-four-column > .igv-roi-table-column-titles > div:nth-child(2) {\n width: 20%;\n}\n.igv-roi-table-four-column > .igv-roi-table-column-titles > div:nth-child(3) {\n width: 20%;\n}\n.igv-roi-table-four-column > .igv-roi-table-column-titles > div:nth-child(4) {\n width: 35%;\n}\n.igv-roi-table-four-column > .igv-roi-table-row-container {\n resize: both;\n overflow: scroll;\n min-width: 512px;\n min-height: 72px;\n height: 144px;\n max-height: 480px;\n background-color: white;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n}\n.igv-roi-table-four-column > .igv-roi-table-row-container > .igv-roi-table-row {\n height: 24px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: stretch;\n align-items: stretch;\n}\n.igv-roi-table-four-column > .igv-roi-table-row-container > .igv-roi-table-row > div {\n font-size: 14px;\n vertical-align: middle;\n line-height: 24px;\n text-align: center;\n margin-left: 4px;\n margin-right: 4px;\n height: 24px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.igv-roi-table-four-column > .igv-roi-table-row-container > .igv-roi-table-row > div:nth-child(1) {\n width: 25%;\n}\n.igv-roi-table-four-column > .igv-roi-table-row-container > .igv-roi-table-row > div:nth-child(2) {\n width: 20%;\n}\n.igv-roi-table-four-column > .igv-roi-table-row-container > .igv-roi-table-row > div:nth-child(3) {\n width: 20%;\n}\n.igv-roi-table-four-column > .igv-roi-table-row-container > .igv-roi-table-row > div:nth-child(4) {\n width: 35%;\n}\n.igv-roi-table-four-column > .igv-roi-table-row-container > .igv-roi-table-row-hover {\n background-color: rgba(0, 0, 0, 0.04);\n}\n.igv-roi-table-four-column > div:last-child {\n height: 32px;\n line-height: 32px;\n border-top-color: #7f7f7f;\n border-top-style: solid;\n border-top-width: thin;\n border-bottom-color: transparent;\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n border-bottom-width: 0;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n\n.igv-roi-table-row-selected {\n background-color: rgba(0, 0, 0, 0.125);\n}\n\n.igv-roi-table-button {\n height: 20px;\n user-select: none;\n line-height: 20px;\n text-align: center;\n vertical-align: middle;\n font-family: "Open Sans", sans-serif;\n font-size: 13px;\n font-weight: 400;\n color: black;\n padding-left: 6px;\n padding-right: 6px;\n background-color: rgb(239, 239, 239);\n border-color: black;\n border-style: solid;\n border-width: thin;\n border-radius: 3px;\n}\n\n.igv-roi-table-button:hover {\n cursor: pointer;\n font-weight: 400;\n background-color: rgba(0, 0, 0, 0.13);\n}\n\n.igv-roi-region {\n z-index: 64;\n position: absolute;\n top: 0;\n bottom: 0;\n pointer-events: none;\n overflow: visible;\n margin-top: 44px;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n}\n.igv-roi-region > div {\n position: relative;\n width: 100%;\n height: 8px;\n cursor: pointer;\n pointer-events: auto;\n}\n\n.igv-roi-menu {\n position: absolute;\n z-index: 1024;\n width: 144px;\n border-color: #7f7f7f;\n border-radius: 4px;\n border-style: solid;\n border-width: thin;\n font-family: "Open Sans", sans-serif;\n background-color: white;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n}\n.igv-roi-menu > div:not(:last-child) {\n border-bottom-color: rgba(128, 128, 128, 0.5);\n border-bottom-style: solid;\n border-bottom-width: thin;\n}\n.igv-roi-menu > div:first-child {\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-top-color: transparent;\n border-top-style: solid;\n border-top-width: 0;\n}\n.igv-roi-menu > div:last-child {\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n border-bottom-color: transparent;\n border-bottom-style: solid;\n border-bottom-width: 0;\n}\n\n.igv-roi-menu-row {\n height: 24px;\n padding-left: 8px;\n font-size: small;\n text-align: start;\n vertical-align: middle;\n line-height: 24px;\n background-color: white;\n}\n\n.igv-roi-menu-row-edit-description {\n width: -webkit-fill-available;\n font-size: small;\n text-align: start;\n vertical-align: middle;\n background-color: white;\n padding-left: 4px;\n padding-right: 4px;\n padding-bottom: 4px;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: stretch;\n align-items: stretch;\n}\n.igv-roi-menu-row-edit-description > label {\n margin-left: 2px;\n margin-bottom: 0;\n display: block;\n width: -webkit-fill-available;\n}\n.igv-roi-menu-row-edit-description > input {\n display: block;\n margin-left: 2px;\n margin-right: 2px;\n margin-bottom: 1px;\n width: -webkit-fill-available;\n}\n\n.igv-container {\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n padding-top: 4px;\n user-select: none;\n -webkit-user-select: none;\n -ms-user-select: none;\n}\n\n.igv-viewport {\n position: relative;\n margin-top: 5px;\n line-height: 1;\n overflow-x: hidden;\n overflow-y: hidden;\n}\n\n.igv-viewport-content {\n position: relative;\n width: 100%;\n}\n.igv-viewport-content > canvas {\n position: relative;\n display: block;\n}\n\n.igv-column-container {\n position: relative;\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n width: 100%;\n}\n\n.igv-column-shim {\n width: 1px;\n margin-left: 2px;\n margin-right: 2px;\n background-color: #545453;\n}\n\n.igv-column {\n position: relative;\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n box-sizing: border-box;\n height: 100%;\n}\n\n.igv-axis-column {\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n box-sizing: border-box;\n height: 100%;\n width: 50px;\n}\n.igv-axis-column > div {\n margin-top: 5px;\n width: 100%;\n}\n\n.igv-sample-name-column {\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n box-sizing: border-box;\n height: 100%;\n}\n\n.igv-scrollbar-column {\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n box-sizing: border-box;\n height: 100%;\n width: 14px;\n}\n.igv-scrollbar-column > div {\n position: relative;\n margin-top: 5px;\n width: 14px;\n}\n.igv-scrollbar-column > div > div {\n cursor: pointer;\n position: absolute;\n top: 0;\n left: 2px;\n width: 8px;\n border-width: 1px;\n border-style: solid;\n border-color: #c4c4c4;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n}\n.igv-scrollbar-column > div > div:hover {\n background-color: #c4c4c4;\n}\n\n.igv-track-drag-column {\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n box-sizing: border-box;\n height: 100%;\n width: 12px;\n background-color: white;\n}\n.igv-track-drag-column > .igv-track-drag-handle {\n z-index: 512;\n position: relative;\n cursor: pointer;\n margin-top: 5px;\n width: 100%;\n border-style: solid;\n border-width: 0;\n border-top-right-radius: 6px;\n border-bottom-right-radius: 6px;\n background-color: #c4c4c4;\n}\n.igv-track-drag-column .igv-track-drag-handle-hover {\n background-color: #787878;\n}\n.igv-track-drag-column > .igv-track-drag-shim {\n position: relative;\n margin-top: 5px;\n width: 100%;\n border-style: solid;\n border-width: 0;\n}\n\n.igv-gear-menu-column {\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n box-sizing: border-box;\n height: 100%;\n width: 28px;\n}\n.igv-gear-menu-column > div {\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n margin-top: 5px;\n width: 100%;\n background: white;\n}\n.igv-gear-menu-column > div > div {\n position: relative;\n margin-top: 4px;\n width: 16px;\n height: 16px;\n color: #7F7F7F;\n}\n.igv-gear-menu-column > div > div:hover {\n cursor: pointer;\n color: #444;\n}\n\n/*# sourceMappingURL=dom.css.map */\n',document.head.insertBefore(t,document.head.childNodes[document.head.childNodes.length-1])}();var wv={IGVGraphics:ns,MenuUtils:$o,DataRangeDialog:Xo,createTrack:async function(t,e){return await fv.prototype.createTrack.call(e,t)},createBrowser:async function(t,e){void 0===e&&(e={}),Ra.KNOWN_GENOMES||await Ra.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.showROITableButton&&(t.showROITableButton=!1);void 0===t.showROITable&&(t.showROITable=!1);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,l,c;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?(l=s[0],c=decodeURIComponent(s[1]),"file"===l?h=c.split(","):"index"===l?u=c.split(","):"name"===l?f=c.split(","):"genome"!==l||!c.startsWith("https://")&&!c.startsWith("http://")||c.endsWith(".json")?t[l]=c:t.reference={fastaURL:c,indexURL:c+".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&&To.setApiKey(e.apiKey),e.oauthToken&&ko.setToken(e.oauthToken),e.clientId&&!Fe()&&await Pe({clientId:e.clientId,apiKey:e.apiKey,scope:"https://www.googleapis.com/auth/userinfo.profile"});const n=new fv(e,t);return vv.push(n),e.sessionURL?await n.loadSession({url:e.sessionURL}):await n.loadSessionObject(e),n.navbarManager.navbarDidResize(n.$navigation.width()),n},removeBrowser:function(t){t.dispose(),t.root.remove(),vv=vv.filter((e=>e!==t))},removeAllBrowsers:function(){for(let t of vv)t.dispose(),t.root.remove();vv=[]},visibilityChange:async function(){for(let t of vv)await t.visibilityChange()},setGoogleOauthToken:function(t){return ko.setToken(t)},setOauthToken:function(t,e){return ko.setToken(t,e)},oauth:ko,version:La,setApiKey:bv};return wv}));
|
|
70
|
+
*/var Ip=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},Np=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}}(),Op=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 Pp={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 Fp(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 Dp=function(){function t(e,n,r,i){Ip(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=Op(n,4),i=r[0],s=r[1],a=r[2],l=r[3];void 0===l&&(l=1),i/=360,s/=100,a/=100,o.hsla=[i,s,a,l]}else if(e.startsWith("rgb")){var c=e.match(/([\-\d\.e]+)/g).map(Number),h=Op(c,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 Np(t,[{key:"printRGB",value:function(t){var e=(t?this.rgba:this.rgba.slice(0,3)).map((function(t,e){return Fp(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 Fp(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=Pp[n];return void 0===r?r:t.hexToRgb(r.replace(/\-/g,"00").padStart(6,"f"))}},{key:"rgbToHsl",value:function(t){var e=Op(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),l=void 0,c=void 0,h=(s+a)/2;if(s===a)l=c=0;else{var u=s-a;switch(c=h>.5?u/(2-s-a):u/(s+a),s){case n:l=(r-i)/u+(r<i?6:0);break;case r:l=(i-n)/u+2;break;case i:l=(n-r)/u+4}l/=6}return[l,c,h,o]}},{key:"hslToRgb",value:function(t){var e=Op(t,4),n=e[0],r=e[1],i=e[2],o=e[3],s=void 0,a=void 0,l=void 0;if(0===r)s=a=l=i;else{var c=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=c(u,h,n+1/3),a=c(u,h,n),l=c(u,h,n-1/3)}var f=[255*s,255*a,255*l].map(Math.round);return f[3]=o,f}}]),t}(),Bp=function(){function t(){Ip(this,t),this._events=[]}return Np(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 zp(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(),l=a.width,c=a.height,h=o.clientX,u=o.clientY,f=i(h-a.left,0,l),d=i(u-a.top,0,c);n(f/l,d/c)}}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}))}var Hp="keydown",Vp="mousedown",jp="focusin";function Up(t,e){return(e||document).querySelector(t)}function qp(t){t.preventDefault(),t.stopPropagation()}function Wp(t,e,n,r,i){t.add(e,Hp,(function(t){n.indexOf(t.key)>=0&&(i&&qp(t),r(t))}))}var $p=function(){function t(e){Ip(this,t),this.settings={popup:"right",layout:"default",alpha:!0,editor:!0,editorFormat:"hex",cancelButton:!1,defaultColor:"#0cf"},this._events=new Bp,this.onChange=null,this.onDone=null,this.onOpen=null,this.onClose=null,this.setOptions(e)}return Np(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),Wp(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&&t.type===Hp?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(e===Vp||e===jp){var r=(this.__containedEvent||0)+100;t.timeStamp>r&&(n=!0)}else qp(t),n=!0;else n=!0;n&&this.hide()&&(this.settings.parent.style.pointerEvents="",e!==Vp&&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 Dp(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=Up(".picker_hue",e),this._domSL=Up(".picker_sl",e),this._domA=Up(".picker_alpha",e),this._domEdit=Up(".picker_editor input",e),this._domSample=Up(".picker_sample",e),this._domOkay=Up(".picker_done button",e),this._domCancel=Up(".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()})),zp(r,this._domH,(function(t,n){return e._setHSLA(t)})),zp(r,this._domSL,(function(t,n){return e._setHSLA(null,t,1-n)})),this.settings.alpha&&zp(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,Vp,e),i(window,jp,e),Wp(r,n,["Esc","Escape"],e);var o=function(e){t.__containedEvent=e.timeStamp};i(n,Vp,o),i(n,jp,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),Wp(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,l=this._domA,c=Up(".picker_selector",s),h=Up(".picker_selector",a),u=Up(".picker_selector",l);b(0,c,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}(),Gp=document.createElement("style");function Zp(t){if(Xp[t])return Xp[t];if(Xp["chr"+t]){const e=Xp["chr"+t];return Xp[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 Xp[t]=i,i}var e,n,r}Gp.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(Gp),$p.StyleElement=Gp;const Xp={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 Yp{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 Kp(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 Kp{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 Qp=Math.exp(5);class Jp{static isInstalled(){return void 0!==window.JBrowseReactCircularGenomeView&&void 0!==window.React&&void 0!==window.ReactDOM}constructor(t,e){if(e=e||{},this.config=e,Jp.isInstalled()){this.parent=t,this.groupByTrack=!0===e.groupByTrack,this.chordManager=new Yp(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*Qp),o=document.createElement("div");o.className="igv-circview-button",o.innerHTML=" ",e.appendChild(o),o.style.backgroundColor=tg(t.color,1);const s={parent:o,popup:"right",editorFormat:"rgb",color:t.color,onChange:({rgbaString:e})=>{o.style.backgroundColor=tg(e,1),this.setColor(t.name,e),r.value=i(eg(t.color))}},a=new $p(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(eg(t.color)),r.oninput=()=>{const e=(n=r.value,Math.exp(n/200)/Qp);var n;this.setColor(t.name,tg(t.color,e)),a.setColor(t.color)},e.appendChild(r);const l=document.createElement("div");l.style.color="black",e.appendChild(l),l.innerText=l.title=t.name}setAssembly(t){const e=this.genomeId||ig();if(this.genomeId===e)return;this.chordManager.clearChords(),this.genomeId=e,this.chrNames=new Set(t.chromosomes.map((t=>ng(t.name))));const n=[],r=[];for(let e of t.chromosomes){const t=ng(e.name);r.push(e.color||Zp(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||ig()};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||rg;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 tg(t,e){const[n,r,i,o]=t.split(",");return`${n},${r},${i},${e})`}function eg(t){return t.startsWith("rgba(")?Number(t.split(",")[3].replace(")","")):1}function ng(t){return t.startsWith("chr")?t.substring(3):t}function rg(t,e,n){console.log(t)}function ig(){return("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)}if("undefined"!=typeof document){function Rv(t){for(let e of document.styleSheets)if(e=e.href?e.href.replace(/^.*[\\\/]/,""):"",e===t)return!0;return!1}Rv("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 og=t=>t.startsWith("chr")?t.substring(3):t;function sg(t){const e=[],n=[];for(let r of t.wgChromosomeNames){const i=t.getChromosome(r);n.push(gg(i.name)),e.push({name:i.name,bpLength:i.bpLength})}return e}function ag(t,e,n,r){const i=vo.addAlpha("all"===n.chr?e.color:gg(n.chr),r),o=vo.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 lg{constructor(t,e){let{minTLENPercentile:n,maxTLENPercentile:r}=e;this.totalCount=0,this.frCount=0,this.rfCount=0,this.ffCount=0,this.sumF=0,this.sumF2=0,this.lp=void 0===n?.1:n,this.up=void 0===r?99.5:r,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:cg(this.isizes,this.lp),this.maxTLEN=cg(this.isizes,this.up)}}function cg(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 hg extends Al{constructor(t,e){super(t,e)}init(t){super.init(t),this.type="alignment",void 0===t.alleleFreqThreshold&&(t.alleleFreqThreshold=.2),this.featureSource=new Lp(t,this.browser),this.showCoverage=void 0===t.showCoverage||t.showCoverage,this.showAlignments=void 0===t.showAlignments||t.showAlignments,this.coverageTrack=new ug(t,this),this.alignmentTrack=new fg(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&&(n.sortRows(t),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 lg(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&&o.sortRows(s),o}computePixelHeight(t){return(this.showCoverage?this.coverageTrack.height:0)+(this.showAlignments?this.alignmentTrack.computePixelHeight(t):0)+15}draw(t){ns.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){let e;return e=!0===this.showCoverage&&t.y>=this.coverageTrack.top&&t.y<this.coverageTrack.height?this.coverageTrack.getClickedObject(t):this.alignmentTrack.getClickedObject(t),e?[e]:void 0}hoverText(t){if(!0===this.showCoverage&&t.y>=this.coverageTrack.top&&t.y<this.coverageTrack.height){const e=this.coverageTrack.getClickedObject(t);if(e)return e.hoverText()}}menuItemList(){let t=[];t=t.concat($o.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(Wo("Show Coverage",this.showCoverage)),click:()=>{this.showCoverage=!this.showCoverage,i(),this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),t.push({object:pe(Wo("Show Alignments",this.showAlignments)),click:()=>{this.showAlignments=!this.showAlignments,i(),this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),t.push("<hr/>"),t.push({object:pe(Wo("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(Wo("Show mismatches",this.showMismatches)),click:()=>{this.showMismatches=!this.showMismatches,this.config.showMismatches=this.showMismatches,this.trackView.repaintViews()}}),t.push({object:pe(Wo("Show insertions",this.showInsertions)),click:()=>{this.showInsertions=!this.showInsertions,this.config.showInsertions=this.showInsertions,this.getCachedAlignmentContainers(),this.trackView.repaintViews()}}),t.push({object:pe(Wo("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(Wo("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(Wo("expand","EXPANDED"===this.alignmentTrack.displayMode)),click:()=>{this.alignmentTrack.displayMode="EXPANDED",this.config.displayMode="EXPANDED",this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),t.push({object:pe(Wo("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(Wo(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 Qo("Set1"))):(this.alignmentTrack.colorBy="none",this.alignmentTrack.colorByTag=""),this.trackView.repaintViews()}},e)},init: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));ag((t=>{const e=[];for(let n of t)if(n.paired)n.firstAlignment&&n.secondAlignment&&e.push({uniqueId:n.readName,refName:og(n.firstAlignment.chr),start:n.firstAlignment.start,end:n.firstAlignment.end,mate:{refName:og(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:og(n.chr),start:n.start,end:n.end,mate:{refName:og(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)}ag((t=>{const e=t=>{const e=yf(t.tags().SA);let r=0;for(let i of e)i.start!==t.start&&n.push({uniqueId:`${t.readName}_${r++}`,refName:og(t.chr),start:t.start,end:t.end,mate:{refName:og(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 ug{constructor(t,e){this.parent=e,this.featureSource=e.featureSource,this.height=void 0!==t.coverageTrackHeight?t.coverageTrackHeight:50,this.paintAxis=Mp,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,l=a+t.pixelWidth*s+1;let c;c=this.parent.coverageColor?this.parent.coverageColor:void 0!==this.parent.color&&"function"!=typeof this.parent.color?vo.darkenLighten(this.parent.color,-35):"rgb(150, 150, 150)",ns.setProperties(r,{fillStyle:c,strokeStyle:c});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>l)break;const n=i.coverage[t];if(!n)continue;const o=Math.round(n.total/this.dataRange.max*this.height),c=this.height-o,u=Math.floor((e-a)/s);ns.fillRect(r,u,c,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>l)break;const c=i.coverage[t];if(!c)continue;const u=c.total/this.dataRange.max*this.height;let f=this.height-u;const d=Math.floor((e-a)/s),p=o[t];if(c.isMismatch(p)){ns.setProperties(r,{fillStyle:n[p]}),ns.fillRect(r,d,f,h,u);let t=0;for(let e of["A","C","T","G"]){const i=(c["pos"+e]+c["neg"+e])/this.dataRange.max*this.height;f=this.height-i-t,t+=i,ns.setProperties(r,{fillStyle:n[e]}),ns.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 fg{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.insertionTextColor=t.insertionTextColor||"white",this.showInsertionText=void 0!==t.showInsertionText&&!!t.showInsertionText,this.deletionColor=t.deletionColor||"black",this.deletionTextColor=t.deletionTextColor||"black",this.showDeletionText=void 0!==t.showDeletionText&&!!t.showDeletionText,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,l=this.parent.showAllBases,c=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),ns.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 cf?(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),l=(t.connectingStart-i)/r,c=(t.connectingEnd-i)/r,h=e+o/2;t.connectingEnd<i||t.connectingStart>s||(t.mq<=0&&(a=vo.addAlpha(a,.15)),ns.setProperties(n,{fillStyle:a,strokeStyle:a}),ns.strokeLine(n,l,h,c,h))}function v(t,h,f){if(t.start+t.lengthOnRef<i||t.start>s)return;const d=a?t.blocks:t.blocks.filter((t=>"S"!==t.type));let p=this.getAlignmentColor(t);const m=p;t.mq<=0&&(p=vo.addAlpha(p,.15)),ns.setProperties(n,{fillStyle:p,strokeStyle:m});const v=[];for(let t=0;t<d.length;t++){const e=d[t];if(!(t!==d.length-1&&d[t+1].start<i)&&(v.push(...b.call(this,e,t)),e.start+e.len>s))break}if(t.gaps){const e=h+f/2;for(let o of t.gaps){const t=(o.start-i)/r,s=(o.start+o.len-i)/r,a=s-t,l=o.len.toString(),c=6*l.length,u=t+a/2,f="D"===o.type?this.deletionColor:this.skippedColor;if(ns.strokeLine(n,t,e,s,e,{strokeStyle:f,lineWidth:2}),this.showDeletionText&&o.len>1&&a>=c+8){const t=u-c/2;ns.fillRect(n,t-1,h-1,c+2,12,{fillStyle:"white"}),ns.fillText(n,l,t,h+10,{font:"normal 10px monospace",fillStyle:this.deletionTextColor})}}}if(t.insertions&&this.parent.showInsertions){let e=-1;for(let o of t.insertions){if(this.hideSmallIndels&&o.len<=this.indelSizeThreshold)continue;if(o.start<i)continue;if(o.start>s)break;const t=o.start-i,a=o.len.toString(),l=2+6*a.length,c=this.showInsertionText&&1!==o.len?Math.round(o.len/r):2,u=Math.max(Math.min(l,c),2),d=t/r-u/2;if(d-e>2){const t={fillStyle:this.insertionColor};ns.fillRect(n,d-2,h,u+4,2,t),ns.fillRect(n,d,h+2,u,f-4,t),ns.fillRect(n,d-2,h+f-2,u+4,2,t),this.showInsertionText&&o.len>1&&c>l&&ns.fillText(n,a,d+1,h+10,{font:"normal 10px monospace",fillStyle:this.insertionTextColor}),e=d}}}function b(s,a){const v=[],b=s.start-e.start,w=(s.start-i)/r,y=(s.start+s.len-i)/r,x=Math.max(1,y-w),_=100/r,k=Math.min(g/2,_/6),S="S"===s.type,C=t.mq<=0||this.highlightedAlignmentReadNamed===t.readName||S;let E=m;this.highlightedAlignmentReadNamed===t.readName?E="red":S&&(E="rgb(50,50,50)");const T=!0===t.strand&&a===d.length-1,A=!1===t.strand&&0===a;if(T|A){let t,e;T?(t=[w,y,y+k,y,w,w],e=[h,h,h+f/2,h+f,h+f,h]):A&&(t=[y,w,w-k,w,y,y],e=[h,h,h+f/2,h+f,h+f,h]),ns.fillPolygon(n,t,e,{fillStyle:p}),C&&ns.strokePolygon(n,t,e,{strokeStyle:E})}else ns.fillRect(n,w,h,x,f,{fillStyle:p}),C&&(n.save(),n.strokeStyle=E,n.strokeRect(w,h,x,f),n.restore());if(S||l||this.parent.showMismatches&&u&&t.seq&&"*"!==t.seq){const e=t.seq?t.seq.toUpperCase():void 0,n=t.qual,a=s.seqOffset,d=Math.max(1,1/r);for(let t=0,p=s.len;t<p;t++){const p=(s.start+t-i)/r;if(p+d<0)continue;if(p>o)break;let g=e?e.charAt(a+t):"";const m=b+t>=0?u.charAt(b+t):"";if("="===g&&(g=m),"X"===g||m!==g||S||l){let e;if(!S&&void 0!==n&&n.length>a+t){e=dg(n[a+t],c[g])}else e=c[g];e&&v.push({bbox:{x:p,y:h,width:d,height:f},baseColor:e,readChar:g})}}}return v}v.forEach((t=>{let{bbox:e,baseColor:i,readChar:o}=t;!function(t,e,n,r,i){var o;if(e<=.1&&n.height>=8){const e=Math.min(10,n.height);t.font=e+"px sans-serif",o=n.x+n.width/2,ns.strokeText(t,i,o-t.measureText(i).width/2,e-1+n.y,{strokeStyle:r})}else ns.fillRect(t,n.x,n.y,n.width,n.height,{fillStyle:r})}(n,r,e,i,o)}))}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,e.cachedFeatures.sortRows(o),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:" aligned read length",click:()=>r("ALIGNED_READ_LENGTH")}),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,e.cachedFeatures.sortRows(i),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 this.browser.alert.present(`Reference does not contain chromosome: ${r.mate.chr}`)}},init:void 0}),n.push({label:"View read sequence",click:()=>{const t=r.seq;t&&"*"!==t?this.browser.alert.present(t):this.browser.alert.present("Read sequence: *")}}),Vs()&&n.push({label:"Copy read sequence",click:async()=>{const t=r.seq;try{await navigator.clipboard.writeText(t)}catch(t){console.error(t),this.browser.alert.present(`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 l="SQUISHED"===this.displayMode?this.squishedRowHeight:this.alignmentRowHeight;let c=Math.floor((n-this.top-this.alignmentsYOffset)/l);if(c<0){for(let t=0;t<a.length;t++)if(a[t].start<=r&&a[t].end>=r)return a[t]}else if(c<s.length){const t=s[c].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?"function"==typeof this.parent.color?this.parent.color(t):this.parent.color:"rgb(200, 200, 200)";default:return this.getAlignmentColor(t)}}getAlignmentColor(t){let e="rgb(185, 185, 185)";this.parent.color&&(e="function"==typeof this.parent.color?this.parent.color(t):this.parent.color);const n=this.colorBy;switch(n){case"strand":e=t.strand?this.posStrandColor:this.negStrandColor;break;case"firstOfPairStrand":t instanceof cf?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=pg[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=gg(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 Qo("Set1")),e=this.tagColors.getColor(r)))}return e}}function dg(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=vo.addAlpha(e,n)),e}const pg={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 gg(t){if(mg[t])return mg[t];if(mg["chr"+t]){const e=mg["chr"+t];return mg[t]=e,e}{const e=vo.randomRGB(0,255);return mg[t]=e,e}}const mg={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 vg,bg;class wg extends Fa{constructor(t,e,n,r){super(t,e,n,r)}get contentDiv(){return this.$viewport.get(0)}initializationHelper(){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.rulerSweeper=new lf(this,this.$viewport.get(0).parentElement,this.browser,this.referenceFrame),this.attachMouseHandlers(Ra.isWholeGenomeView(this.referenceFrame.chr)),this.$tooltip.hide(),this.dismissLocusLabel()}presentLocusLabel(t){this.$rulerLabel.get(0).innerHTML="",this.$rulerLabel.get(0).style.backgroundColor=gg(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="${gg(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((t=>{let{locusSearchString:e}=t;return e}));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===bg?(bg=this,this.$tooltip.show()):bg.guid!==this.guid?(bg.$tooltip&&bg.$tooltip.hide(),this.$tooltip.show(),bg=this):this.$tooltip.show();if(this.browser.isMultiLocusWholeGenomeView()||Ra.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:`${fo(e,0,s-o)}px`}),clearTimeout(vg),vg=setTimeout((()=>{this.$tooltip&&this.$tooltip.hide()}),1e4)}}startSpinner(){}stopSpinner(){}dispose(){this.rulerSweeper.dispose(),super.dispose()}}class yg extends Fa{constructor(t,e,n,r){super(t,e,n,r)}initializationHelper(){this.canvas=document.createElement("canvas"),this.canvas.className="igv-ideogram-canvas",this.$viewport.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(t){let{referenceFrame:e}=t;ns.configureHighDPICanvas(this.ideogram_ctx,this.$viewport.width(),this.$viewport.height()),this.trackView.track.draw({context:this.ideogram_ctx,referenceFrame:e,pixelWidth:this.$viewport.width(),pixelHeight:this.$viewport.height()})}startSpinner(){}stopSpinner(){}}function xg(t,e,n,r){if("ruler"===t.track.type)return new wg(t,e,n,r);if("ideogram"===t.track.id)return new yg(t,e,n,r);return new Fa(t,e,n,r)}const _g={textAlign:"start",textBaseline:"bottom",strokeStyle:"black",fillStyle:"black"};class kg{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(t){let{context:e,samples:n}=t;if(!n||0===n.names.length)return;!function(t,e,n){let{textAlign:r,textBaseline:i,strokeStyle:o,fillStyle:s}=e;const a=Math.min(n,10);t.font=`${a}px sans-serif`,t.textAlign=r,t.textBaseline=i,t.fillStyle=s}(e,_g,n.height);e.clearRect(0,0,e.canvas.width,e.canvas.height),e.fillStyle=function(t){const{r:e,g:n,b:r}=Yo[t];return`rgb(${e},${n},${r})`}("lead");const r=this.viewport.getBoundingClientRect().height;let i=(n.yOffset||0)+this.contentTop;for(let t of n.names){if(i>r)break;if(i+n.height>0){const r=t,o=Sg(e,r,i,n.height);e.fillText(r,4,o)}i+=n.height}}renderSVGContext(t,e){let{deltaX:n,deltaY:r}=e;if("function"==typeof this.trackView.track.getSamples){const e=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,n,r+i,o,s,-i),this.draw({context:t,samples:e}),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 Sg(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)}const Cg=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),_e(e,(()=>this.hide())),this.popoverContent=ge(),this.popover.appendChild(this.popoverContent),wo(this.popover,e),e.addEventListener("click",(t=>{t.stopPropagation(),t.preventDefault()})),this.hide()};Cg.prototype.hide=function(){this.popover.style.display="none"},Cg.prototype.presentMenuList=function(t){if(Eg(),t.length>0){this.popoverContent.innerHTML="",t=$o.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"}},Cg.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=Wo("Show all bases",t.value);else if("color"===t.type){const n=new As({parent:i.parentElement,width:364});n.configure(void 0,{color:e=>t.click(e)}),e=ge({class:"context-menu"}),"string"==typeof t.label&&(e.innerHTML=t.label);const r=t=>{n.show(),me(i),t.preventDefault(),t.stopPropagation()};e.addEventListener("click",r),e.addEventListener("touchend",r),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 o(e){t.click(),me(i),e.preventDefault(),e.stopPropagation()}e.addEventListener("click",o),e.addEventListener("touchend",o),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)},Cg.prototype.dispose=function(){this.popoverContent.innerHTML="",this.popover.innerHTML="",Object.keys(this).forEach((function(t){this[t]=void 0}))};const Eg=()=>{const t=document.querySelectorAll(".igv-menu-popup");for(let e=0;e<t.length;e++)t[e].style.display="none"},Tg=new Set(["ruler","ideogram"]),Ag=new Set(["ruler","sequence","ideogram"]);class Lg{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=xg(this,i[t],n[t],r);this.viewports.push(e)}this.sampleNameViewport=new kg(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,e){let{deltaX:n,deltaY:r}=e;!function(t,e,n,r,i){if("function"==typeof e.paintAxis){const{y:o,width:s,height:a}=n.getBoundingClientRect(),l=`${(e.name||e.id).replace(/\W/g,"")}_axis_guid_${be()}`;t.saveWithTranslationAndClipRect(l,r,o+i,s,a,0),e.paintAxis(t,s,a),t.restore()}}(t,this.track,this.axisCanvas,n,r);const{width:i}=this.axis.getBoundingClientRect(),{y:o}=this.viewports[0].$viewport.get(0).getBoundingClientRect();let s={deltaX:i+n,deltaY:o+r};for(let e of this.viewports){e.renderSVGContext(t,s);const{width:n}=e.$viewport.get(0).getBoundingClientRect();s.deltaX+=n}!0===this.browser.showSampleNames&&this.sampleNameViewport.renderSVGContext(t,s)}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===Ag.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(")?vo.rgbToHex(t):vo.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===Tg.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=Mg(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=Mg(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;const e=t.filter((t=>t.needsRepaint())).filter((t=>t.checkZoomIn())),n=e.filter((t=>t.needsReload()));for(let t of n)await t.loadFeatures();if(this.disposed)return;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(n.getWidth());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{const t=qo(n.featureCache.features,r,i);for(let n of t)e.push(n)}}"function"==typeof this.track.doAutoscale?this.track.dataRange=this.track.doAutoscale(e):this.track.dataRange=Ns(e)}const r=this.track.autoscale||this.track.autoscaleGroup||"ruler"===this.track.type;for(let n of t)e.includes(n)?n.repaint():r&&n.refresh();this.adjustTrackHeight(),this.repaintSamples(),this.updateRulerViewportLabels()}clearCachedFeatures(){for(let t of this.viewports)t.clearCache()}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=[];const e=this.viewports.filter((t=>t.isVisible()));for(let n of e){const e=n.referenceFrame,{chr:r,start:i,bpPerPixel:o}=n.referenceFrame,s=i+e.toBP(n.getWidth());if((!n.featureCache||!n.featureCache.containsRange(r,i,s,o))&&await n.loadFeatures(),n.featureCache&&n.featureCache.features)if("function"==typeof n.featureCache.features.getMax){const e=n.featureCache.features.getMax(i,s);t.push({value:e})}else{const e="function"==typeof n.featureCache.queryFeatures?n.featureCache.queryFeatures(r,i,s):qo(n.featureCache.features,i,s);t=t.concat(e)}}return t}checkContentHeight(){for(let t of this.viewports)t.checkContentHeight();this.adjustTrackHeight()}adjustTrackHeight(){var t=Mg(this.viewports);if(this.track.autoHeight?this.setTrackHeight(t,!1):this.track.paintAxis&&this.paintAxis(),!1===Tg.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===Tg.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 Cg(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===Tg.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($o.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();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 Mg(t){const e=t.map((t=>t.getContentHeight()));return Math.max(...e)}const Rg={getTissueInfo:function(t,e){let n=(e=e||"https://gtexportal.org/rest/v1")+"/dataset/tissueInfo?datasetId="+(t=t||"gtex_v8");return To.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 Ig(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 Ng(t,e,n,r,i,o){try{i.save(),i.fillStyle=this.defaultColor,i.strokeStyle=this.defaultColor;const r=Pg.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 l=o.pixelWidth,c=a+s/2,h=s/2,u=c-h/2,f=t.exons?t.exons.length:0,d=Ig(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(l,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)ns.strokeLine(i,n-2*g,c-2,n,c),ns.strokeLine(i,n-2*g,c+2,n,c);i.fillStyle=r,i.strokeStyle=r}}else{ns.strokeLine(i,d.px+1,c,d.px1-1,c);const o=Math.max(0,d.px)+p/2,m=Math.min(l,d.px1);for(let t=o;t<m;t+=p)ns.strokeLine(i,t-2*g,c-2,t,c),ns.strokeLine(i,t-2*g,c+2,t,c);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>l)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)ns.strokeLine(i,t-2*g,c-2,t,c),ns.strokeLine(i,t-2*g,c+2,t,c);i.fillStyle=r,i.strokeStyle=r}}}}o.drawLabel&&"SQUISHED"!==this.displayMode&&Og.call(this,i,t,d.px,d.px1,a,o.referenceFrame,o)}finally{i.restore()}}function Og(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 l=s.pixelXOffset||0;const c=Math.max(n,-l);let h,u=(c+Math.min(r,-l+s.viewportWidth))/2;"COLLAPSED"===this.displayMode&&"SLANT"===this.labelDisplayMode&&(h={rotate:{angle:45}});const f=function(t,e){return e?t+20:t+25}(i,h);let d,p=Pg.call(this,e),g=!1;o.selection&&Rg.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=u-v.width/2,w=u+v.width/2,y=s.rowLastLabelX[e.row]||-Number.MAX_SAFE_INTEGER;(s.labelAllFeatures||b>y||g)&&(s.rowLastLabelX[e.row]=w,"y"===s.axis?(t.save(),ns.labelTransformWithContext(t,u),ns.fillText(t,a,u,f,m,h),t.restore()):ns.fillText(t,a,u,f,m,h))}finally{t.restore()}}function Pg(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=vo.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=vo.addAlpha(e,n)}return e}const Fg=new Set(["nonsense","missense","stop-loss","frameshift","cds-indel"]),Dg=new Set(["coding-synon"]),Bg=new Set(["splice-3","splice-5"]),zg=new Set(["untranslated-5","untranslated-3"]);function Hg(t,e,n,r,i){var o,s,a,l,c=Ig(t,e,n),h=this.margin,u=this.snpColors.length;switch(o="squished"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight,this.colorBy){case"function":l=t.func,s=l.split(",").map((function(t){return Fg.has(t)||Bg.has(t)?u-1:Dg.has(t)?u-2:zg.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(c.px,h,c.pw,o)}function Vg(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,l=a-.5*o,c=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,l,u,l,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,c,s,c,s,a),i.lineWidth=1,i.strokeStyle="purple",i.stroke()}}class jg extends Al{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:ef(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||Vg,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||Hg,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||Ng,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 Jo(t.colorTable):this.colorTable=new Qo("Set1"))),this.useScore=t.useScore}async postInit(){if("function"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),void 0===this.visibilityWindow&&"function"==typeof this.featureSource.defaultVisibilityWindow&&(this.visibilityWindow=await this.featureSource.defaultVisibilityWindow()),this}get supportsWholeGenome(){return void 0!==this.config.supportsWholeGenome?this.config.supportsWholeGenome:this.featureSource&&"function"==typeof this.featureSource.supportsWholeGenome?this.featureSource.supportsWholeGenome():!(void 0!==this.visibilityWindow||!1!==this.config.indexed&&this.config.indexURL)||void 0}async getFeatures(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||ns.fillRect(n,0,t.pixelTop,o,s,{fillStyle:"rgb(255, 255, 255)"}),e){const l=[];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===l[e]?l[e]=1:l[e]++,t.rowLastX[e]=-Number.MAX_SAFE_INTEGER,t.rowLastLabelX[e]=-Number.MAX_SAFE_INTEGER}const c=o/Math.max(1,Math.max(...l));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||c>10;const l=Math.ceil((o.end-i)/r),u=h[e];if(!u||l>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,ns.strokeLine(n,a,0,a,s,{strokeStyle:"rgb(255, 255, 255)"}),n.globalAlpha=1),h[e]=l}}}else console.log("No feature list")}clickedFeatures(t){const e=t.y-this.margin,n=super.clickedFeatures(t);let r;switch(this.displayMode){case"SQUISHED":r=Math.floor(e/this.squishedRowHeight);break;case"EXPANDED":r=Math.floor(e/this.expandedRowHeight);break;default:r=void 0}return n.filter((function(t){return void 0===r||void 0===t.row||r===t.row}))}popupData(t,e){void 0===e&&(e=this.clickedFeatures(t));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===Hg){t.push("<hr/>");for(let e of["function","class"])t.push({object:pe(Wo("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(Wo(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);if(void 0===e||0===e.length)return;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);t?"-"===n.strand&&(t=Ys(t)):t="Unknown sequence",this.browser.alert.present(t)}}];return Vs()&&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);t?"-"===n.strand&&(t=Ys(t)):t="Unknown sequence";try{await navigator.clipboard.writeText(t)}catch(t){console.error(t),this.browser.alert.present(`error copying sequence to clipboard ${t}`)}}}),t.push("<hr/>"),t}}description(){if(Hg===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 Ug extends Al{constructor(t,e){super(t,e)}init(t){super.init(t),this.type="wig",this.height=t.height||50,this.featureType="numeric",this.paintAxis=Mp;const e=t.format?t.format.toLowerCase():t.format;this.flipAxis=!!t.flipAxis&&t.flipAxis,this.logScale=!!t.logScale&&t.logScale,t.featureSource?(this.featureSource=t.featureSource,delete t.featureSource):this.featureSource="bigwig"===e?new Yc(t,this.browser.genome):"tdf"===e?new Zu(t,this.browser.genome):ef(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();this.disposed||t&&this.setTrackProperties(t)}async getFeatures(t,e,n,r){const i=await this.featureSource.getFeatures({chr:t,start:e,end:n,bpPerPixel:r,visibilityWindow:this.visibilityWindow,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("<hr>"),t.push({label:"Flip y-axis",click:()=>{this.flipAxis=!this.flipAxis,this.trackView.repaintViews()}})),t=t.concat($o.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,a=this.color||"rgb(150,150,150)";let l;"string"==typeof a&&a.startsWith("rgb(")&&(l=vo.addAlpha(a,.1));const c=this.getScaleFactor(this.dataRange.min,this.dataRange.max,t.pixelHeight,this.logScale),h=t=>this.logScale?this.computeYPixelValueInLogScale(t,c):this.computeYPixelValue(t,c);if(e&&e.length>0&&(void 0===this.dataRange.min&&(this.dataRange.min=0),this.dataRange.max>this.dataRange.min)){let o,c=-1,u=-1;const f=h(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 l=h(t.value);const d=Math.ceil((t.end-i)/r),p=Math.max(1,d-e);let g=t.value<0&&this.altColor?this.altColor:a;const m="function"==typeof g?g(t.value):g;if("points"===this.graphType){const t=this.config.pointSize||3,r=e+p/2;ns.fillCircle(n,r,l,t/2,{fillStyle:m,strokeStyle:m})}else if("line"===this.graphType)null!=o&&ns.strokeLine(n,c,o,e,l,{fillStyle:m,strokeStyle:m}),ns.strokeLine(n,e,l,e+p,l,{fillStyle:m,strokeStyle:m});else{let r=l-f;(e+p>c||t.value>=0&&t.value>u||t.value<0&&t.value<lastNegValue)&&ns.fillRect(n,e,f,p,r,{fillStyle:m})}c=e+p,u=t.value,o=l}if(this.dataRange.min<0){const e=this.dataRange.max/(this.dataRange.max-this.dataRange.min)*t.pixelHeight;ns.strokeLine(n,0,e,t.pixelWidth,e,{strokeStyle:l})}}if(this.config.hasOwnProperty("guideLines"))for(let e of this.config.guideLines)if(e.hasOwnProperty("color")&&e.hasOwnProperty("y")&&e.hasOwnProperty("dotted")){let n=h(e.y),r={strokeStyle:e.color,strokeWidth:2};e.dotted?ns.dashedLine(t.context,0,n,t.pixelWidth,n,5,r):ns.strokeLine(t.context,0,n,t.pixelWidth,n,r)}}popupData(t,e){if(void 0===e&&(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 qg(t){this.thresholds=t.thresholds,this.colors=t.colors}function Wg(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}qg.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]},Wg.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 $g{constructor(t){this.color=t}getColor(){return this.color}}class Gg extends Al{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 Wg({low:.1,lowR:255,lowG:255,lowB:255,high:1.5,highR:255,highG:0,highB:0}),this.negColorScale=t.negColorScale||new Wg({low:-1.5,lowR:0,lowG:0,lowB:255,high:-.1,highR:255,highG:255,highB:255}),"mut"===this.type&&(this.colorTable=new Jo(t.colorTable||Zg))),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=ef(e,this.browser.genome),this.initialSort=t.sort}async postInit(){"function"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader(),this.disposed)||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=Wo(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(t){let{context:e,renderSVG:n,pixelTop:r,pixelWidth:i,pixelHeight:o,features:s,bpPerPixel:a,bpStart:l}=t;if(ns.fillRect(e,0,r,i,o,{fillStyle:"rgb(255, 255, 255)"}),s&&s.length>0){this.checkForLog(s),this.updateSampleKeys(s);const t={};let n;switch(this.sampleKeys.forEach((function(e,n){t[e]=n})),this.displayMode){case"FILL":this.sampleHeight=o/this.sampleKeys.length,n=0;break;case"SQUISHED":this.sampleHeight=this.squishedRowHeight,n=0;break;default:this.sampleHeight=this.expandedRowHeight,n=1}const c=this.sampleHeight;for(let t of s)t.pixelRect=void 0;const h=r+o,u=l+i*a+1,f=a;this.sampleYStart=void 0;for(let i of s){if(i.end<l)continue;if(i.start>u)break;const o=i.sampleKey||i.sample;i.row=t[o];const s=i.row*c+n;void 0===this.sampleYStart&&(this.sampleYStart=s);if(s+c<r||s>h)continue;const a=Math.max(i.start,l);let d=Math.round((a-l)/f);const p=Math.min(i.end,u),g=Math.round((p-l)/f);let m,v,b=Math.max(1,g-d);if(this.color?m="function"==typeof this.color?this.color(i):this.color:this.colorTable&&(m=this.colorTable.getColor(i.value.toLowerCase())),"mut"===this.type)v=c-2*n,b<3&&(b=3,d-=1);else{let t=i.value;this.isLog||(t=po(t/2)),m=t<-.1?this.negColorScale.getColor(t):t>.1?this.posColorScale.getColor(t):"white";let e=c;if(c<.25){const n=.1+2*Math.abs(t);e=Math.min(1,n*c)}v=e-2*n}i.pixelRect={x:d,y:s,w:b,h:v},e.fillStyle=m,e.fillRect(d,s,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,l=o[a]||0;o[a]=l+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}))},l=()=>{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?l():a(),this.trackView.repaintViews()}clickedFeatures(t){const e=super.clickedFeatures(t),n=t.y;return e.filter((function(t){const e=t.pixelRect;return e&&n>=e.y&&n<=e.y+e.h}))}hoverText(t){const e=this.clickedFeatures(t);if(e&&e.length>0)return`${e[0].sample}: ${e[0].value}`}popupData(t,e){void 0===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 Zg={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 Xg extends Al{constructor(t,e){super(t,e),this.type="merged",this.featureType="numeric",this.paintAxis=Mp,this.graphType=t.graphType}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($o.numericDataMenuItems(this.trackView)),t}async getFeatures(t,e,n,r){const i=this.tracks.map((i=>i.getFeatures(t,e,n,r))),o=await Promise.all(i);return new Yg(o)}draw(t){const e=t.features;for(let n=0,r=this.tracks.length;n<r;n++){const r=Object.assign({},t);r.features=e.featureArrays[n],this.tracks[n].dataRange=this.dataRange,this.tracks[n].flipAxis=this.flipAxis,this.tracks[n].logScale=this.logScale,this.graphType&&(this.tracks[n].graphType=this.graphType),this.tracks[n].draw(r)}}popupData(t){if(t.viewport&&t.viewport.cachedFeatures){const e=t.viewport.cachedFeatures.featureArrays;if(e&&e.length===this.tracks.length){const n=[];for(let r=0;r<this.tracks.length;r++){r>0&&n.push("<hr/>"),n.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,e[r]);n.push(...i)}return n}}}clickedFeatures(t){const e=t.viewport.cachedFeatures;if(!e)return[];const n=t.genomicLocation,r=[];for(let i of e.featureArrays){const e=t.referenceFrame.bpPerPixel>.2?3*t.referenceFrame.bpPerPixel:.2,o=qo(i,n-e,n+e);for(let t of o)r.push(t)}return r}get supportsWholeGenome(){return this.tracks.every((t=>t.supportsWholeGenome))}}class Yg{constructor(t){this.featureArrays=t}getMax(t,e){let n=-Number.MAX_VALUE;for(let r of this.featureArrays)for(let i of r)if(void 0!==i.value&&!Number.isNaN(i.value)){if(i.end<t)continue;if(i.start>e)break;n=Math.max(n,i.value)}return n}}class Kg extends Al{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,this.alpha=t.alpha||.02,this.painter={flipAxis:!this.arcOrientation,dataRange:this.dataRange,paintAxis:Mp},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,t.featureSource?(this.featureSource=t.featureSource,delete t._featureSource):(this.featureSource=ef(t,this.browser.genome),this.featureSource.getWGFeatures=nm)}async postInit(){if("function"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),void 0===this.visibilityWindow&&"function"==typeof this.featureSource.defaultVisibilityWindow&&(this.visibilityWindow=await this.featureSource.defaultVisibilityWindow(),this.featureSource.visibilityWindow=this.visibilityWindow),this}get supportsWholeGenome(){return!0}async getFeatures(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;ns.fillRect(e,0,t.pixelTop,n,r,{fillStyle:"rgb(255, 255, 255)"});const l=t.features;if(l){(function(){let t=0;for(let e of l){let r=(e.start-s)/a,i=(e.end-s)/a;r>=0&&i<=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],l=e<r.length?r[e]:Math.PI/2;return Math.min(Math.PI/2,a+s*(l-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 l){let r;if(t.drawState=void 0,"function"==typeof this.color?r=this.color(t):(r=this.color||t.color||"rgb(180,25,137)",r&&this.config.useScore&&(r=em(r,(c=t.score,Math.min(1,.11+c/779*.89).toString())))),e.lineWidth=t.thickness||this.thickness||1,t.chr1===t.chr2||"all"===t.chr){const{m1:l,m2:c}=Qg(t,this.browser.genome);let u=Math.round((l-s)/a),f=Math.round((c-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,l=(t.end2-s)/a,c=this.arcOrientation?-this.blockHeight:this.blockHeight;e.fillRect(n,o,r-n,c),e.fillRect(i,o,l-i,c)}r&&!this.config.useScore&&d>i&&(r=em(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 l=o-i;l<3&&(l=3,i--);const c=t.chr===t.chr1?t.chr2:t.chr1;e.strokeStyle=r,e.fillStyle=em(gg(c),.5),h?(e.fillRect(i,this.height/2,l,this.height/2),e.fillText(c,i+l/2,this.height/2-5),t.drawState={x:i,y:this.height/2,w:l,h:this.height/2}):(e.fillRect(i,0,l,this.height/2),e.fillText(c,i+l/2,this.height/2+13),t.drawState={x:i,y:0,w:l,h:this.height/2})}}}var c}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,l=t.referenceFrame.end;ns.fillRect(e,0,t.pixelTop,n,r,{fillStyle:"rgb(255, 255, 255)"});const c=t.features;if(c&&c.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 c){t.drawState=void 0;const r=this.valueColumn?t[this.valueColumn]:t.score;if(void 0===r||Number.isNaN(r))continue;const c=Math.round((this.logScale?Math.log10(r+1):r)*i);if(t.chr1===t.chr2||"all"===t.chr){const{m1:n,m2:i}=Qg(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<=l;let r=!1,o=!1;if(!e&&t&&(r=a<=n&&n<=l,r||(o=a<=i&&i<=l)),!(e||r||o))continue}const d=f/2,p=u+f/2;t.drawState={xc:p,yc:h,radiusX:d,radiusY:c};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,c,0,0,Math.PI,g):(e.beginPath(),e.ellipse(p,h,d,c,0,0,Math.PI,g),e.stroke()),this.alpha&&(e.fillStyle=em(m,this.alpha),!0===e.isSVG?e.fillEllipse(p,h,d,c,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,l=this.arcOrientation?-this.blockHeight:this.blockHeight;e.fillRect(n,h,r-n,l),e.fillRect(i,h,a-i,l)}}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 l=Math.min(c,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=em(gg(u),.5),this.arcOrientation){const n=this.height-l;e.fillRect(i,n,h,l),e.fillText(u,i+h/2,n-5),t.drawState={x:i,y:n,w:h,h:l}}else e.fillRect(i,0,h,l),e.fillText(u,i+h/2,l+13),t.drawState={x:i,y:0,w:h,h:l}}}}}clearAxis(t,e,n){ns.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=[];if(this.hasValue){t.push("<hr/>");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(Wo(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($o.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;const n=e.map((t=>{const e=t._f||t;return{uniqueId:`${e.chr1}:${e.start1}-${e.end1}_${e.chr2}:${e.start2}-${e.end2}`,refName:og(e.chr1),start:e.start1,end:e.end1,mate:{refName:og(e.chr2),start:e.start2,end:e.end2}}}));ag(n,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){void 0===e&&(e=this.clickedFeatures(t));const n=[];for(let t of e){const e=t._||t;if(n.push({name:"Region 1",value:Jg(e.chr1,e.start1,e.end1,e.strand1)}),n.push({name:"Region 2",value:Jg(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,r=this.header.hiccups?6:10;for(let i=r;i<t.length;i++)this.header.colorColumn!==i&&("info"===t[i]?rm(n,e.extras[i-r]):n.push({name:t[i],value:e.extras[i-r]}))}break}return n}clickedFeatures(t){const e=t.viewport.cachedFeatures,n=[];if(e){const r="proportional"===this.arcType||"inView"===this.arcType||"partialInView"===this.arcType;for(let i of e)if(i.drawState)if(i.chr1===i.chr2||"all"===i.chr)if(r){const{xc:e,yc:r,radiusX:o,radiusY:s}=i.drawState,a=t.canvasX-e,l=t.canvasY-r,c=a/o*(a/o)+l/s*(l/s);c<=1&&n.push({score:1/c,feature:i})}else{const{xc:e,yc:r,r:o}=i.drawState,s=t.canvasX-e,a=t.canvasY-r,l=Math.abs(Math.sqrt(s*s+a*a)-o);l<5&&n.push({score:l,feature:i})}else{const{x:e,y:r,w:o,h:s}=i.drawState,a=5;if(t.canvasX>=e-a&&t.canvasX<=e+o+a&&t.canvasY>=r&&t.canvasY<=r+s){const r=-Math.abs(t.canvasX-(e+o/2));n.push({score:r,feature:i});break}}}return n.length>1&&n.sort(((t,e)=>t.score-e.score)),n.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 Qg(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 Jg(t,e,n,r){return r&&"."!==r?`${t}:${Se(e+1)}-${Se(n)} (${r})`:`${t}:${Se(e+1)}-${Se(n)}`}const tm=new Map;function em(t,e){const n=`${t}_${e}`;let r=tm.get(n);return r||(r=vo.addAlpha(t,e),tm.set(n,r)),r}function nm(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),l=r&&r.score>0?Math.log(r.score)/s:Number.MAX_SAFE_INTEGER;let c,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.max(0,Math.min(s-1,Math.floor(Math.log(t.score)/l))):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)c=h[0];else{c=[];for(let t of h)for(let e of t)c.push(e);r&&c.push(e(r)),c.sort((function(t,e){return t.start-e.start})),console.log(c.length)}return c}function rm(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 im=ke,om=new Map([["REF","referenceBases"],["ALT","alternateBases"],["QUAL","quality"],["FILTER","filter"]]);class sm extends Al{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=ef(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 Jo(t.colorTable))),this._strokecolor=t.strokecolor,this._context_hook=t.context_hook,this.showGenotypes=void 0===t.showGenotypes||t.showGenotypes,this.variantRowCount(1)}async postInit(){if(this.header=await this.getHeader(),!this.disposed){if(void 0===this.visibilityWindow&&!1!==this.config.indexed){const t=Ue(this.config.url)?this.config.url.name:this.config.url;im(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(t){let{context:e,pixelWidth:n,pixelHeight:r,bpPerPixel:i,bpStart:o,pixelTop:s,features:a}=t;ns.fillRect(e,0,s,n,r,{fillStyle:"rgb(255, 255, 255)"});const l="SQUISHED"===this.displayMode?this.squishedVGap:this.expandedVGap,c="COLLAPSED"===this.displayMode?1:this.nVariantRows,h="SQUISHED"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight;this.variantBandHeight=10+c*(h+l);let u=this.callSets;!u&&this._f&&(u=this._f.callSets);const f=this.getCallsetsLength();if(u&&f>0&&!1!==this.showGenotypes&&ns.strokeLine(e,0,this.variantBandHeight,n,this.variantBandHeight,{strokeStyle:"rgb(224,224,224) "}),a){const t="SQUISHED"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight,r="SQUISHED"===this.displayMode?this.squishedVGap:this.expandedVGap,s=o+n*i+1;for(let n of a){if(n.end<o)continue;if(n.start>s)break;const a="SQUISHED"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,l=10+("COLLAPSED"===this.displayMode?0:n.row*(a+r)),c=a;let h=Math.round((n.start-o)/i),d=Math.round((n.end-o)/i),p=Math.max(1,d-h);p<3?(p=3,h-=1):p>5&&(h+=1,p-=2),e.fillStyle=this.getVariantColor(n),e.fillRect(h,l,p,c);let g=this.getVariantStrokecolor(n);if(g&&(e.strokeStyle=g,e.strokeRect(h,l,p,c)),this.callContextHook(n,e,h,l,p,c),n.pixelRect={x:h,y:l,w:p,h:c},f>0&&!1!==this.showGenotypes){const i="COLLAPSED"===this.displayMode?1:this.nVariantRows;this.sampleYOffset=this.variantBandHeight+r,this.sampleHeight=i*(t+r);let o=0;if(u&&n.calls)for(let i of u){const s=n.calls[i.id];if(s){const a="COLLAPSED"===this.displayMode?0:n.row,l=this.sampleYOffset+o*this.sampleHeight+a*(t+r);let c=!0,u=!0,f=!1;if(s.genotype)for(let t of s.genotype){if("."===t){f=!0;break}0!==t&&(u=!1),0===t&&(c=!1)}s.genotype?e.fillStyle=f?this.noCallColor:u?this.homrefColor:c?this.homvarColor:this.hetvarColor:e.fillStyle=this.noGenotypeColor,e.fillRect(h,l,p,t),i.pixelRect={x:h,y:l,w:p,h:t}}o++}}}}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(om.has(t)){r=e[om.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}getVariantStrokecolor(t){const e=t._f||t;let n;return n=this._strokecolor?"function"==typeof this._strokecolor?this._strokecolor(e):this._strokecolor:void 0,n}callContextHook(t,e,n,r,i,o){if(this._context_hook&&"function"==typeof this._context_hook){const s=t._f||t;e.save(),this._context_hook(s,e,n,r,i,o),e.restore()}}clickedFeatures(t){let e=super.clickedFeatures(t);const n="EXPANDED"===this.displayMode?this.expandedVGap:this.squishedVGap,r=n+("SQUISHED"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight),i=t.y;if(i<=this.variantBandHeight){const t="SQUISHED"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,r=Math.floor((i-10)/(t+n));"COLLAPSED"!==this.displayMode&&(e=e.filter((t=>t.row===r)))}else if(this.callSets){const t=this.callSets,n=i-this.variantBandHeight,o=Math.floor(n/this.sampleHeight);if(o>=0&&o<t.length){const i=Math.floor((n-o*this.sampleHeight)/r),s="COLLAPSED"===this.displayMode?e:e.filter((t=>t.row===i)),a=t[o];e=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 e}popupData(t,e){void 0===e&&(e=this.clickedFeatures(t));const n=t.genomicLocation,r=this.browser.genome.id,i=this.browser.sampleInformation;let o=[];for(let t of e){const e=t._f||t;if(o.length>0&&o.push({html:'<hr style="border-top-width:2px ;border-color: #c9c3ba" />'}),"function"==typeof e.popupData){const t=e.popupData(n,r);Array.prototype.push.apply(o,t)}else{const t=e;if(void 0!==t.callSetName&&o.push({name:"Name",value:t.callSetName}),t.genotypeName&&o.push({name:"Genotype",value:t.genotypeName}),void 0!==t.phaseset&&o.push({name:"Phase set",value:t.phaseset}),void 0!==t.genotypeLikelihood&&o.push({name:"genotypeLikelihood",value:t.genotypeLikelihood.toString()}),i){var s=i.getAttributes(t.callSetName);s&&Object.keys(s).forEach((function(t){var e=t.replace(/([A-Z])/g," $1");e=e.charAt(0).toUpperCase()+e.slice(1),o.push({name:e,value:s[t]})}))}var a=Object.keys(t.info);a.length&&o.push("<hr/>"),a.forEach((function(e){o.push({name:e,value:decodeURIComponent(t.info[e])})}))}}return o}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(Wo("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(Wo({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=(t=>{const e=t.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)}));return e.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:og(e.chr),start:e.start,end:e.end,mate:{refName:og(e.info.CHR2),start:r,end:i}}}))})("all"===e.chr?this.featureSource.getAllFeatures():this.featureSource.featureCache.queryFeatures(e.chr,e.start,e.end));ag(n,this,e,.5)}colorByCB(t,e){return{name:void 0,object:pe(Wo(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=am;else e=new Qo("Set1");this.colorTables.set(t,e)}return this.colorTables.get(t)}}const am=new Jo({DEL:"#ff2101",INS:"#001888",DUP:"#028401",INV:"#008688",CNV:"#8931ff",BND:"#891100","*":"#002eff"});class lm extends Al{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=ef(t,this.browser.genome),Rg.gtexLoaded=!0}paintAxis(t,e,n){const r=(this.dataRange.max-this.dataRange.min)/n,i={font:"normal 10px Arial",textAlign:"right",strokeStyle:"black"};ns.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,l=o,c=n-(s-this.dataRange.min)/r;ns.strokeLine(t,a,c,l,c,i),c>8&&ns.fillText(t,s,a-1,c+2,i)}i.textAlign="center",ns.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&&ns.fillRect(e,0,0,n,r,{fillStyle:this.background}),ns.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,l=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=l&&(l.snp===f||l.gene===d);if(!i||p){l&&l.snp===f&&l.addGene(d);var c=-Math.log(h[this.pValueField])/Math.LN10;if(c>=this.dataRange.min){let t;c>this.dataRange.max?(c=this.dataRange.max,t=!0):t=!1;const n=Math.max(0+o,r-Math.round((c-this.dataRange.min)/a));let s;h.px=u,h.py=n,h.radius=o,i&&l?(s=l.colorForGene(d),ns.setProperties(e,{fillStyle:s,strokeStyle:"black"})):(s=t?"rgb(150, 150, 150)":"rgb(180, 180, 180)",ns.setProperties(e,{fillStyle:s,strokeStyle:s})),ns.fillCircle(e,u,n,o),ns.strokeCircle(e,u,n,o)}}}};i(!1),i(!0)}popupData(t,e){if(void 0===e&&(e=t.viewport.cachedFeatures),!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 $o.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=uo(e,this.autoscalePercentile)}else{const t=this.config.maxLogP||this.config.max;this.dataRange.max=t||25}return this.dataRange}}const cm={X:"rgb(204, 153, 0)",Y:"rgb(153, 204, 0)",Un:"darkGray)",1:"rgb(80, 80, 255)",2:"rgb(206, 61, 50)","2a":"rgb(210, 65, 55)","2b":"rgb(215, 70, 60)",3:"rgb(116, 155, 88)",4:"rgb(240, 230, 133)",5:"rgb(70, 105, 131)",6:"rgb(186, 99, 56)",7:"rgb(93, 177, 221)",8:"rgb(128, 34, 104)",9:"rgb(107, 215, 107)",10:"rgb(213, 149, 167)",11:"rgb(146, 72, 34)",12:"rgb(131, 123, 141)",13:"rgb(199, 81, 39)",14:"rgb(213, 143, 92)",15:"rgb(122, 101, 165)",16:"rgb(228, 175, 105)",17:"rgb(59, 27, 83)",18:"rgb(205, 222, 183)",19:"rgb(97, 42, 121)",20:"rgb(174, 31, 99)",21:"rgb(231, 199, 111)",22:"rgb(90, 101, 94)",23:"rgb(204, 153, 0)",24:"rgb(153, 204, 0)",25:"rgb(51, 204, 0)",26:"rgb(0, 204, 51)",27:"rgb(0, 204, 153)",28:"rgb(0, 153, 204)",29:"rgb(10, 71, 255)",30:"rgb(71, 117, 255)",31:"rgb(255, 194, 10)",32:"rgb(255, 209, 71)",33:"rgb(153, 0, 51)",34:"rgb(153, 26, 0)",35:"rgb(153, 102, 0)",36:"rgb(128, 153, 0)",37:"rgb(51, 153, 0)",38:"rgb(0, 153, 26)",39:"rgb(0, 153, 102)",40:"rgb(0, 128, 153)",41:"rgb(0, 51, 153)",42:"rgb(26, 0, 153)",43:"rgb(102, 0, 153)",44:"rgb(153, 0, 128)",45:"rgb(214, 0, 71)",46:"rgb(255, 20, 99)",47:"rgb(0, 214, 143)",48:"rgb(20, 255, 177)"};for(let Iv of Object.keys(cm)){cm["chr"+Iv]=cm[Iv]}for(let Nv=1;Nv<=48;Nv++){if(10===Nv)continue;const Ov=hm(Nv);cm[Ov]=cm[Nv.toString()]}function hm(t){if(!+t)return!1;for(var e=String(+t).split(""),n=["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM","","X","XX","XXX","XL","L","LX","LXX","LXXX","XC","","I","II","III","IV","V","VI","VII","VIII","IX"],r="",i=3;i--;)r=(n[+e.pop()+10*i]||"")+r;return Array(+e.join("")+1).join("M")+r}class um extends Al{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.useChrColors?this.colorScale=new Jo(t.colorTable||cm):t.color?this.colorScale=new $g(t.color):this.colorScale=new qg(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=ef(t,this.browser.genome)}async postInit(){if("function"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),this.autoscale||(this.posteriorProbability?this.dataRange={min:void 0===this.config.min?0:this.config.min,max:void 0===this.config.max?1:this.config.max}:this.dataRange={min:void 0===this.config.min?0:this.config.min,max:void 0===this.config.max?25:this.config.max}),this}get supportsWholeGenome(){return!0}async getFeatures(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&&ns.fillRect(n,0,0,r,i,{fillStyle:this.background}),ns.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;let r;if(this.posteriorProbability)r=t[this.valueProperty];else{const e=t[this.valueProperty];if(!e)continue;r=-Math.log10(e)}const l=this.useChrColors?t._f?t._f.chr:t.chr:r,c=this.colorScale.getColor(l),h=(this.dataRange.max-this.dataRange.min)/i,u=Math.round((e-s)/o),f=Math.max(this.dotSize,i-Math.round((r-this.dataRange.min)/h));c&&ns.setProperties(n,{fillStyle:c,strokeStyle:"black"}),ns.fillCircle(n,u,f,this.dotSize),t.px=u,t.py=f}}}paintAxis(t,e,n){ns.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);ns.strokeLine(t,45,e-2,50,e-2,r),ns.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);ns.strokeLine(t,45,e,50,e,r),ns.fillText(t,Math.floor(o),44,e+4,r)}}r.textAlign="center",this.posteriorProbability?ns.fillText(t,"PPA",e/2,n/2,r,{rotate:{angle:-90}}):ns.fillText(t,"-log10(pvalue)",e/2,n/2,r,{rotate:{angle:-90}})}popupData(t,e){void 0===e&&(e=t.viewport.cachedFeatures);let n=[];const r=t.viewport.trackView.track;if(e){let i=0;for(let o of e){const e=Math.abs(t.canvasX-o.px),s=Math.abs(t.canvasY-o.py),a=o[this.valueProperty];if(e<this.dotSize&&s<this.dotSize){if(i>0&&n.push("<HR/>"),5==i){n.push("...");break}if("function"==typeof o.popupData)n=n.concat(o.popupData());else{const t=o.realChr||o.chr,e=(o.realStart||o.start)+1;n.push({name:"chromosome",value:t}),n.push({name:"position",value:e}),n.push({name:"name",value:o.name}),r.posteriorProbability?n.push({name:"posterior probability",value:a}):n.push({name:"pValue",value:a})}i++}}}return n}menuItemList(){return $o.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=Ns(r)}else this.posteriorProbability?this.dataRange={min:this.config.min||0,max:this.config.max||1}:this.dataRange={min:this.config.max||25,max:this.config.min||0};return this.dataRange}}class fm extends Al{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=Mp,this.graphType=t.graphType||"bar",t._featureSource?(this.featureSource=t._featureSource,delete t._featureSource):this.featureSource=ef(this.config,this.browser.genome),this.visibilityWindow=-1,this.featureSource.visibilityWindow=this.visibilityWindow}async postInit(){if("function"==typeof this.featureSource.getHeader){if(this.header=await this.featureSource.getHeader(),this.disposed)return;if(this.sampleNames=this.header.columnNames.slice(3),this.setTrackProperties(this.header),this.header.hasOwnProperty("clickToHighlight")){let 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 $o.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,l=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={},c=[],h=[];this.clickDetectorCache={};for(let u of e){const e=l(u.start),f=l(u.end),d=o>=0?l(o):e;if(!isNaN(e)&&!isNaN(f)){this.clickDetectorCache[e]=[],this.clickDetectorCache[f]=[];for(let o=0;o<u.values.length;o++){const l=this.sampleNames[o],p=u.values[o],g=a(p);if(e-d>=1){const o=s[l],h=a(o),u=t&&t[l];u?c.push([d,h,e,g,u]):i&&l in this.config.samplesClickedToHighlight?c.push([d,h,e,g,this.config.samplesClickedToHighlight[l]]):ns.strokeLine(n,d,h,e,g,{strokeStyle:"#D9D9D9"}),r&&!(l in t)||this.clickDetectorCache[e].push([d,h,e,g,l,u||"gray"])}if(f-e>=1){const o=t&&t[l];o?h.push([e,g,f,g,o]):i&&l in this.config.samplesClickedToHighlight?h.push([e,g,f,g,this.config.samplesClickedToHighlight[l]]):ns.strokeLine(n,e,g,f,g,{strokeStyle:"gray"}),r&&!(l in t)||this.clickDetectorCache[f].push([e,g,f,g,l,o||"gray"])}s[l]=p}o=u.end}}for(let t of c)ns.strokeLine(n,t[0],t[1],t[2],t[3],{strokeStyle:t[4],lineWidth:1.3});for(let t of h)ns.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?ns.dashedLine(t.context,0,n,t.pixelWidth,n,5,r):ns.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],l=r[3];if(n<Math.min(a,l)-10||n>Math.max(a,l)+10)continue;const c=dm(e,n,i,a,o,l);c<t&&(s=[{name:r[4],color:r[5]}],t=c)}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){void 0===e&&(e=this.clickedFeatures(t));const n=[];return e.forEach((function(t){for(let e of Object.keys(t))Rs(t[e])&&n.push({name:e,value:t[e]})})),n}get supportsWholeGenome(){return!1}}function dm(t,e,n,r,i,o){const s=i-n,a=o-r,l=Math.abs(s*(r-e)-(n-t)*a),c=Math.sqrt(s*s+a*a);return c>0?l/c:0}class pm extends Al{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 mm(t,e.genome):this.featureSource=new Pc(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,l=this.arcOrientation;ns.fillRect(e,0,t.pixelTop,r,i,{fillStyle:"rgb(255, 255, 255)"});const c=t.features;if(c){gm(c,1);for(let t of c)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),c=Math.round((t.endRight-s)/a);e.fillStyle=t.color,e.strokeStyle=t.color,e.beginPath();let h=(r+c)/2,u=(c-r)/2,f=this.height,d=Math.PI+(Math.PI/2-n),p=2*Math.PI-(Math.PI/2-n);l?(f=0,e.arc(h,f,u,p,d),e.lineTo(c,f)):(e.arc(h,f,u,d,p),e.lineTo(o,f));const g=(i+o)/2,m=(o-i)/2,v=f;l?(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,c=(i-r)/2,h=this.height,u=Math.PI+(Math.PI/2-n),f=2*Math.PI-(Math.PI/2-n);l?(h=0,e.arc(o,h,c,f,u)):e.arc(o,h,c,u,f),e.stroke(),t.drawState={x1:o,y1:h,r1:c,sa:u,ea:f}}}}clickedFeatures(t){const e=super.clickedFeatures(t),n=[];gm(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 l,c;if(void 0===e.x2)l=s,c=e.r1-3;else{const n=t.canvasX-e.x2,r=t.canvasY-e.y2;l=Math.sqrt(n*n+r*r),c=e.r2-3}if(s<a&&l>c){n.push(r);break}}return n}popupData(t,e){if(void 0===e&&(e=this.clickedFeatures(t)),e&&e.length>0)return this.extractPopupData(e[0],this.getGenomeId())}menuItemList(){var t=this;return[{name:"Toggle arc direction",click:function(){t.arcOrientation=!t.arcOrientation,t.trackView.repaintViews()}}]}}function gm(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 mm{constructor(t,e){this.config=t,this.genome=e}async getFeatures(t){let{chr:e,start:n,end:r,bpPerPixel:i,visibilityWindow:o}=t;const s=this.genome;if(this.featureCache)return this.featureCache.queryFeatures(e,n,r);{const t=Is(this.config),i=await To.loadString(this.config.url,t);return this.featureCache=new Vo(function(t){if(!t)return null;const e=sc(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,l=Number.parseInt(t[2])-1,c=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,l),startRight:Math.max(n,l),endLeft:Math.min(c,h),endRight:Math.max(c,h),color:u,score:a}:{chr:e,startLeft:Math.min(c,h),startRight:Math.max(c,h),endLeft:Math.min(n,l),endRight:Math.max(n,l),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),s),this.featureCache.queryFeatures(e,n,r)}}}class vm{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(t){let{context:e,referenceFrame:n,pixelWidth:r,pixelHeight:i}=t;const o=n.chr,s=n.genome.getChromosome(o);if(void 0===s||r<=0||i<=0||"all"===o.toLowerCase())return;!function(t){let{ctx:e,chr:n,referenceFrame:r,genome:i,width:o,height:s,stainColors:a}=t;const l=1,c=.5*l,h=0;if(void 0===i)return;ns.fillRect(e,0,0,o,s,{fillStyle:vo.greyScale(255)});const u=i.getCytobands(n);if(u){const t=h+s/2,n=[],r=[];if(0===u.length)return;const i=o/u[u.length-1].end;e.beginPath(),ns.roundRect(e,c,c+h,o-2*c,s-2*c,(s-2*c)/2,0,1),e.clip();for(let o=0;o<u.length;o++){const c=u[o],f=i*c.start,d=i*c.end;"c"===c.type?("p"===c.name.charAt(0)?(n[0]=f,r[0]=s+h,n[1]=f,r[1]=h,n[2]=d,r[2]=t):(n[0]=d,r[0]=s+h,n[1]=d,r[1]=h,n[2]=f,r[2]=t),e.fillStyle="rgb(150, 0, 0)",e.strokeStyle="rgb(150, 0, 0)",ns.polygon(e,n,r,1,0)):(e.fillStyle=bm(a,c),ns.fillRect(e,f,l+h,d-f,s-2*l))}}e.strokeStyle=vo.greyScale(41),ns.roundRect(e,c,c+h,o-2*c,s-2*c,(s-2*c)/2,0,1)}({ctx:e,chr:o,referenceFrame:n,genome:n.genome,width:r,height:i,stainColors:[]});const a=Math.round(n.bpPerPixel*r),l=n.start;let c=s.bpLength;const h=n.genome.getCytobands(o);if(h&&h.length>0&&h[h.length-1].end&&(c=Math.max(c,h[h.length-1].end),s.bpLength=c),a<c){const t=a/c,n=l/c;let o=Math.floor(n*r),s=Math.floor(t*r);o=Math.max(0,o),o=Math.min(r-s,o),e.save(),e.strokeStyle="red",e.lineWidth=s<2?1:2;const h=o+e.lineWidth/2;s=s<2?1:s-e.lineWidth;const u=e.lineWidth/2,f=i-e.lineWidth;e.strokeRect(h,u,s,f),e.restore()}}dispose(){this.trackView=void 0}}function bm(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 wm=new Qo("Dark2");["GT/AG","CT/AC","GC/AG","CT/GC","AT/AC","GT/AT","non-canonical"].forEach((t=>{wm.getColor(t)}));const ym={};class xm extends Al{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:ef(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(){if("function"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),void 0===this.visibilityWindow&&"function"==typeof this.featureSource.defaultVisibilityWindow&&(this.visibilityWindow=await this.featureSource.defaultVisibilityWindow()),this}get supportsWholeGenome(){return!1}async getFeatures(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||ns.fillRect(n,0,t.pixelTop,o,s,{fillStyle:"rgb(255, 255, 255)"}),e){ym.referenceFrame=t.viewport.referenceFrame,ym.referenceFrameStart=ym.referenceFrame.start,ym.referenceFrameEnd=ym.referenceFrameStart+ym.referenceFrame.toBP(t.viewport.getWidth()),ym.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 ym.featureZoomOutTracker)return;ym.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>=ym.referenceFrameStart&&t.start<=ym.referenceFrameEnd&&(e+=1),t.end>=ym.referenceFrameStart&&t.end<=ym.referenceFrameEnd&&(e+=1),e<this.config.minJunctionEndsVisible)return}let l,c,h,u;if(t.attributes.uniquely_mapped){if(l=parseInt(t.attributes.uniquely_mapped),l<this.config.minUniquelyMappedReads)return;if(c=parseInt(t.attributes.multi_mapped),h=l+c,h<this.config.minTotalReads)return;if(h>0&&c/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=l:"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)/(ym.referenceFrameEnd-ym.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?l>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?wm.getColor(t.attributes.motif):"#AAAAAA";let _="";t.attributes.label?_=t.attributes.label.replace(/_/g," "):void 0===this.config.labelWith||"uniqueReadCount"===this.config.labelWith?_=l:"totalReadCount"===this.config.labelWith?_=h:"numSamplesWithThisJunction"===this.config.labelWith?void 0!==u&&(_=u):"percentSamplesWithThisJunction"===this.config.labelWith?void 0!==t.attributes.percent_samples_with_this_junction&&(_=t.attributes.percent_samples_with_this_junction.toFixed(0)+"%"):"motif"===this.config.labelWith&&void 0!==t.attributes.motif&&(_+=t.attributes.motif),"uniqueReadCount"===this.config.labelWithInParen?_+=" ("+l+")":"totalReadCount"===this.config.labelWithInParen?_+=" ("+h+")":"multiMappedReadCount"===this.config.labelWithInParen?c>0&&(_+=" (+"+c+")"):"numSamplesWithThisJunction"===this.config.labelWithInParen?void 0!==u&&(_+=" ("+u+")"):"percentSamplesWithThisJunction"===this.config.labelWithInParen?void 0!==t.attributes.percent_samples_with_this_junction&&(_+=" ("+t.attributes.percent_samples_with_this_junction.toFixed(0)+"%)"):"motif"===this.config.labelWithInParen&&void 0!==t.attributes.motif&&(_+=` ${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 k=(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&&k(i,o,m,e),t.attributes.right_shape&&k(i,s,m,e)}i.fillText(_,a-i.measureText(_).width/2,(7*g+p)/8)}clickedFeatures(t){return super.clickedFeatures(t).filter((function(t){return t.isVisible&&t.attributes}))}popupData(t,e){void 0===e&&(e=this.clickedFeatures(t));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 _m=new Map([["ideogram",(t,e)=>new vm(t,e)],["sequence",(t,e)=>new ma(t,e)],["feature",(t,e)=>new jg(t,e)],["seg",(t,e)=>new Gg(t,e)],["mut",(t,e)=>new Gg(t,e)],["maf",(t,e)=>new Gg(t,e)],["wig",(t,e)=>new Ug(t,e)],["merged",(t,e)=>new Xg(t,e)],["alignment",(t,e)=>new hg(t,e)],["interaction",(t,e)=>new Kg(t,e)],["interact",(t,e)=>new Kg(t,e)],["variant",(t,e)=>new sm(t,e)],["eqtl",(t,e)=>new lm(t,e)],["gwas",(t,e)=>new um(t,e)],["arc",(t,e)=>new pm(t,e)],["gcnv",(t,e)=>new fm(t,e)],["junction",(t,e)=>new xm(t,e)]]);var km=function(t,e){_m.set(t,e)},Sm=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 _m.has(r)?_m.get(r)(e,n):void 0};class Cm{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:[]};Em(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),Em(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),Em(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 Em(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 l=t.getAttribute("visibilityWindow")||t.getAttribute("featureVisibilityWindow");l&&(e.visibilityWindow=l);const c=t.getAttribute("indexed");c&&(e.indexed="true"===c);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 Tm=Ce;class Am{constructor(){this.attributes={},this.plinkLoaded=!1}async loadPlinkFile(t,e){e||(e={});var n=Is(e);const r=await To.loadString(t,n);var i=Tm(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 Lm{constructor(t,e){this.geneColors={},this.gene=null,this.snp=null,this.genesCount=0,t&&(this.gene=t.toUpperCase(),this.geneColors[this.gene]=Mm[this.genesCount++]),e&&(this.snp=e.toUpperCase())}addGene(t){this.geneColors[t.toUpperCase()]||(this.geneColors[t.toUpperCase()]=Mm[this.genesCount++])}colorForGene(t){return this.geneColors[t.toUpperCase()]}}var Mm=[];Mm.push("rgb(228,26,28)"),Mm.push("rgb(55,126,184)"),Mm.push("rgb(77,175,74)"),Mm.push("rgb(166,86,40)"),Mm.push("rgb(152,78,163)"),Mm.push("rgb(255,127,0)"),Mm.push("rgb(247,129,191)"),Mm.push("rgb(153,153,153)"),Mm.push("rgb(255,255,51)"),Mm.push("rgb(102, 194, 165"),Mm.push("rgb(252, 141, 98"),Mm.push("rgb(141, 160, 203"),Mm.push("rgb(231, 138, 195"),Mm.push("rgb(166, 216, 84"),Mm.push("rgb(255, 217, 47"),Mm.push("rgb(229, 196, 148"),Mm.push("rgb(179, 179, 179"),Mm.push("rgb( 141, 211, 199"),Mm.push("rgb(255, 255, 179"),Mm.push("rgb(190, 186, 218"),Mm.push("rgb(251, 128, 114"),Mm.push("rgb(128, 177, 211"),Mm.push("rgb(253, 180, 98"),Mm.push("rgb(179, 222, 105"),Mm.push("rgb(252, 205, 229"),Mm.push("rgb(217, 217, 217"),Mm.push("rgb(188, 128, 189"),Mm.push("rgb(204, 235, 197"),Mm.push("rgb(255, 237, 111");class Rm{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,n){const r=this.start,i=t*this.bpPerPixel;return this.start+=i,n&&this.clampStart(e),this.end=this.start+e*this.bpPerPixel,r!==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(),l=e<1?t.minimumBases()/n:a/n;this.bpPerPixel=e<1?Math.max(this.bpPerPixel*e,l):Math.min(this.bpPerPixel*e,l);const c=this.bpPerPixel*n;this.start=i-.5*c,this.clampStart(n),this.end=this.start+c;(o!==this.start||s!==this.bpPerPixel)&&await t.updateViews(!0)}getChromosome(){return this.genome.getChromosome(this.chr)}getMultiLocusLabel(t){const e=" ",n=Math.floor(this.start)+1,r=Math.round(this.start+this.bpPerPixel*t);return`${e}${this.chr}     ${Fs(r-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 Im={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 Nm(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||Im,i=[];const o=async n=>{let i=function(t,e){const n=e.split("\t");if(n.length>=3)try{const e=t.genome.getChromosomeName(n[0]),r=parseInt(n[1].replace(/,/g,""),10)-1,i=parseInt(n[2].replace(/,/g,""),10);if(!isNaN(r)&&!isNaN(i))return{chr:e,start:r,end:i}}catch(t){}const r=e.split(":"),i=r[0];if("all"===i&&t.genome.getChromosome(i))return{chr:i,start:0,end:t.genome.getChromosome(i).bpLength};if(void 0===t.genome.getChromosome(i))return;{const e={chr:t.genome.getChromosomeName(i),start:0,end:t.genome.getChromosome(i).bpLength};if(r.length>1){let n,i=r[1].split("-");if(i.length>2){if(!r[1].startsWith("-"))return;{const t=r[1].indexOf("-",1);if(t>0){i=[r[1].substring(0,t),r[1].substring(t+1)]}}}if(n=i[0].replace(/,/g,""),isNaN(n))return;if(e.start=parseInt(n,10)-1,e.end=e.start+1,1===i.length&&(e.start-=20,e.end+=20),2===i.length){if(n=i[1].replace(/,/g,""),isNaN(n))return;if(e.end=parseInt(n,10),e.start<0&&!t.isSoftclipped()){const t=-e.start;e.start+=t,e.end+=t}}}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 To.loadString(r,i),s=function(t,e,n){let r;r="plain"===n.type?function(t,e){const n=[],r=[],i=Ce(e);return i.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 l=a[e],c=t.genome.getChromosome(l);if(!c)return;const h=c.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 Om{constructor(t){this.browser=t}navbarDidResize(t){this.updateNavbar(this.createResponsiveClassSchedule(t))}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){let e={};const n=this.browser.isMultiLocusWholeGenomeView()||this.browser.referenceFrameList&&Ra.isWholeGenomeView(this.browser.referenceFrameList[0].chr);return n?this.browser.windowSizePanel.hide():this.browser.windowSizePanel.show(),t>990?(e.$toggle_button_container="igv-navbar-toggle-button-container",e.zoomContainer="igv-zoom-widget"):t>860?(e.$toggle_button_container="igv-navbar-toggle-button-container",e.zoomContainer="igv-zoom-widget-900"):t>540?(e.$toggle_button_container="igv-navbar-toggle-button-container-750",e.zoomContainer="igv-zoom-widget-900"):(e.$toggle_button_container="igv-navbar-toggle-button-container-750",e.zoomContainer="igv-zoom-widget-900",this.browser.windowSizePanel.hide()),n&&(e.zoomContainer="igv-zoom-widget-hidden"),e}}const Pm=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};Pm.prototype.show=function(){this.container.style.display="flex"},Pm.prototype.hide=function(){this.container.style.display="none"},Pm.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 Fm{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?Fs(Math.round(e*t[0].bpPerPixel)):""}}class Dm{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=function(t,e){for(;t.parentElement;){if(t.parentElement.classList.contains(e))return t.parentElement;t=t.parentElement}return}(document.elementFromPoint(e.clientX,e.clientY),"igv-viewport");if(i&&t.getRulerTrackView()){this.verticalGuide.style.left=`${n}px`;const r=t.root.querySelectorAll(".igv-column");let o;const s=i.parentElement;for(let t=0;t<r.length;t++)void 0===o&&s===r[t]&&(o=t);const a=t.getRulerTrackView().viewports[o].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 Bm{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 zm{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 Hm{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 Vm{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 jm=23,Um=0;const qm=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=`${jm}`,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))}))};qm.prototype.update=function(t){const e=t[0],{bpLength:n}=e.genome.getChromosome(e.chr),{start:r,end:i}=e;jm=Math.ceil(Math.log2(n/this.browser.minimumBases())),this.slider.max=`${jm}`;const o=n/(i-r);Um=Math.log2(o),this.slider.value=`${Math.round(Um)}`},qm.prototype.enable=function(){this.slider.disabled=!1},qm.prototype.disable=function(){this.slider.disabled=!0},qm.prototype.hide=function(){this.zoomContainer.style.display="none"},qm.prototype.show=function(){this.zoomContainer.style.display="block"},qm.prototype.hideSlider=function(){this.slider.style.display="none"},qm.prototype.showSlider=function(){this.slider.style.display="block"};const Wm=function(t,e){const n=ge({class:"igv-navbar-button"});t.append(n),n.textContent="Save SVG",n.addEventListener("click",(()=>e.saveSVGtoFile({})))},$m=(t,e)=>{const n=0===t?e.nextElementSibling:e.previousElementSibling;e.remove(),n.remove()},Gm=t=>{const e=ge({class:"igv-column-shim"});Hs(e,t);const n=ge({class:"igv-column"});return Hs(n,e),n},Zm=(t,e)=>{for(let n=0;n<e;n++){const r=ge({class:"igv-column"});if(zs(r,t),e>1&&n>0){zs(ge({class:"igv-column-shim"}),r)}}};class Xm{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(){if(this.referenceFrame){if(1/this.referenceFrame.bpPerPixel>1){const t=Math.floor(this.referenceFrame.toPixels(1));this.container.style.width=`${t}px`,this.container.classList.remove("igv-center-line-thin"),this.container.classList.add("igv-center-line-wide")}else this.container.style.width="1px",this.container.classList.remove("igv-center-line-wide"),this.container.classList.add("igv-center-line-thin")}}show(){this.isVisible=!0,this.container.style.display="block",this.repaint()}hide(){this.isVisible=!1,this.container.style.display="none"}resize(){this.repaint()}}const Ym=Se;class Km{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(t){let{context:e,referenceFrame:n,pixelWidth:r,pixelHeight:i,bpPerPixel:o,bpStart:s}=t;Ra.isWholeGenomeView(n.chr)?this.drawWholeGenome({context:e,pixelWidth:r,pixelHeight:i,bpPerPixel:o}):this.doDraw({context:e,referenceFrame:n,pixelWidth:r,pixelHeight:i,bpStart:s})}drawWholeGenome(t){let{context:e,pixelWidth:n,pixelHeight:r,bpPerPixel:i}=t;e.save(),ns.fillRect(e,0,0,n,r,{fillStyle:"white"});for(let t of this.browser.genome.wgChromosomeNames){let n=this.browser.genome.getCumulativeOffset(t),o=this.browser.genome.getChromosome(t).bpLength,s=Math.round(n/i),a=Math.round(o/i);this.renderChromosomeRect(e,s,0,a,r,t)}e.restore()}doDraw(t){let{context:e,referenceFrame:n,pixelWidth:r,pixelHeight:i,bpStart:o}=t;e.clearRect(0,0,r,i);const s=function(t,e){if(t<10)return new Qm(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,l=Math.pow(10,n-1),c=Math.pow(10,n)/2;return new Qm(s<a&&!0!==e?l:c,r,i)}(Math.floor(n.toBP(r)),e.isSVG);let a=Math.floor(o/s.majorTick)-1;const{tickDelta:l,labelLength:c}=function(t,e,n,r,i){const o=c(e,l(1+r,i),n)-c(e,l(r,i),n),s=`${Se(Math.floor(l(r,i)/i.unitMultiplier))} ${i.majorUnit}`,a=Math.floor(t.measureText(s).width);return{tickDelta:o,labelLength:a};function l(t,e){return Math.floor(t*e.majorTick)}function c(t,e,n){return Math.round(t.toPixels(e-1-n+.5))}}(e,n,o,a,s);let h,u;this.browser.referenceFrameList.indexOf(n);let f=l;const d=.25*c;do{u=Math.floor(a*s.majorTick);const t=`${Se(Math.floor(u/s.unitMultiplier))} ${s.majorUnit}`;h=Math.round(n.toPixels(u-1-o+.5));const r=Math.round(h-e.measureText(t).width/2);r>0&&d+c<=f&&(ns.fillText(e,t,r,this.height-8),f=0),h>0&&ns.strokeLine(e,h,this.height-6,h,this.height-2),u=Math.floor((1+a)*s.majorTick);let i=h+(Math.round(n.toPixels(u-1-o+.5))-h)/2;i>0&&ns.strokeLine(e,i,this.height-6,i,this.height-2),++a,f+=l}while(h<r);ns.strokeLine(e,0,this.height-2,r,this.height-2)}renderChromosomeRect(t,e,n,r,i,o){t.textAlign="center",t.textBaseline="middle",t.font="12px sans-serif",ns.strokeLine(t,e+r,n,e+r,n+i,{strokeStyle:vo.greyScale(191)});const s=o.startsWith("chr")?o.substring(3):o;r>t.measureText(s).width&&ns.fillText(t,s,e+r/2,n+i/2,{fillStyle:vo.greyScale(68)})}get supportsWholeGenome(){return!0}dispose(){}}class Qm{constructor(t,e,n){this.majorTick=t,this.minorTick=t/10,this.majorUnit=e,this.unitMultiplier=n}description(t){console.log((t||"")+" tick "+Ym(this.majorTick)+" label width "+Ym(this.labelWidthBP)+" multiplier "+this.unitMultiplier)}}const Jm=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)};Jm.prototype.setVisibility=function(t){!0===t?this.show():this.hide()},Jm.prototype.setState=function(t){!0===t?this.button.classList.add("igv-navbar-button-clicked"):this.button.classList.remove("igv-navbar-button-clicked")},Jm.prototype.show=function(){this.button.style.display="block",this.setState(this.browser.circularViewVisible)},Jm.prototype.hide=function(){this.button.style.display="none"};const tv=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 ev{constructor(t,e,n,r,i){this.browser=t,this.roiMenu=e,this.roiTable=n,this.top=r,this.roiSets=i||[],this.boundLocusChangeHandler=nv.bind(this),t.on("locuschange",this.boundLocusChangeHandler)}async initialize(){this.roiSets.length>0&&(this.browser.showROITableButton=!0,this.browser.roiTableControl.setVisibility(this.browser.showROITableButton));const t=this.roiSets.map((t=>this.renderROISet({browser:this.browser,pixelTop:this.top,roiSet:t})));t.length>0&&await Promise.all(t);const e=await this.getTableRecords();this.roiTable.renderTable(e)}async loadROI(t,e){const n=Array.isArray(t)?t:[t];for(let t of n)this.roiSets.push(new of(t,e));await this.initialize()}clearROIs(){this.roiTable.clearTable();const t=this.browser.columnContainer.querySelectorAll(".igv-roi-region");for(let e of t)e.remove();for(let t of this.roiSets)t.dispose();this.roiSets=[]}async getTableRecords(){const t=[];for(let e of this.roiSets){const n=e.isUserDefined?"":e.name||"",r=await e.getAllFeatures();for(let e of Object.keys(r))for(let i of r[e])t.push({setName:n,feature:i})}return t}presentTable(){this.roiTable.present()}async repaintTable(){const t=await this.getTableRecords();this.roiTable.renderTable(t)}dismissTable(){this.roiTable.dismiss()}async updateUserDefinedROISet(t){let e=await this.getUserDefinedROISet();void 0===e&&(e=this.initializeUserDefinedROISet()),e.addFeature(t),!1===this.browser.showROITableButton&&this.setROITableButtonVisibility(!0),await this.renderROISet({browser:this.browser,pixelTop:this.top,roiSet:e});const n=await this.getTableRecords();this.roiTable.renderTable(n)}setROITableButtonVisibility(t){this.browser.showROITableButton=t,this.browser.roiTableControl.setVisibility(this.browser.showROITableButton)}async renderAllROISets(){for(let t of this.roiSets)await this.renderROISet({browser:this.browser,pixelTop:this.top,roiSet:t})}async renderROISet(t){let{browser:e,pixelTop:n,roiSet:r}=t;const i=e.columnContainer.querySelectorAll(".igv-column");for(let t=0;t<i.length;t++){let{chr:o,start:s,end:a,bpPerPixel:l}=e.referenceFrameList[t];const c=i[t].querySelectorAll(".igv-roi-region");for(let t of c){const e=t.dataset.region,{chr:n,start:r,end:i}=ov(e);(n!==o||i<s||r>a)&&t.remove()}const h=await r.getFeatures(o,s,a);if(h)for(let c of h){const h=rv(o,c.start,c.end),{x:u,width:f}=sf(Math.max(s,c.start),Math.min(a,c.end),s,l),d=i[t].querySelector(iv(h));if(d)d.style.left=`${u}px`,d.style.width=`${f}px`;else{const o=this.createRegionElement(e.columnContainer,n,u,f,r,h,c.name);i[t].appendChild(o)}}}}createRegionElement(t,e,n,r,i,o,s){const a=ge({class:"igv-roi-region"});a.style.top=`${e}px`,a.style.left=`${n}px`,a.style.width=`${r}px`,a.style.backgroundColor=i.color,a.dataset.region=o;const l=ge();return a.appendChild(l),l.style.backgroundColor=i.headerColor,!0===i.isUserDefined?l.addEventListener("click",(e=>{e.preventDefault(),e.stopPropagation();const{x:n,y:r}=we(e,t);this.roiMenu.present(n,r,this,t,a)})):s?l.addEventListener("click",(e=>{e.preventDefault(),e.stopPropagation(),this.popover&&this.popover.dispose(),this.popover=new ks(t,i.name),this.popover.presentContentWithEvent(e,s)})):l.style.pointerEvents="none",a}async getUserDefinedROISet(){return this.roiSets.find((t=>!0===t.isUserDefined))}initializeUserDefinedROISet(){const t=new of({isUserDefined:!0,features:[]},this.browser.genome);return this.roiSets.push(t),t}async deleteUserDefinedRegionWithKey(t,e){e.querySelectorAll(iv(t)).forEach((t=>t.remove()));const n=await this.findUserDefinedRegionWithKey(t),r=await this.getUserDefinedROISet();r&&r.removeFeature(n);0===(await this.getTableRecords()).length&&(this.browser.roiTableControl.buttonHandler(!1),this.setROITableButtonVisibility(!1))}async findUserDefinedRegionWithKey(t){const{chr:e,start:n,end:r}=ov(t),i=await this.getUserDefinedROISet();if(i){const t=await i.getFeatures(e,n,r);for(let i of t)if(i.chr===e&&i.start>=n&&i.end<=r)return i}}toJSON(){return this.roiSets.map((t=>t.toJSON()))}dispose(){this.browser.off("locuschange",this.boundLocusChangeHandler);const t=this.browser.columnContainer.querySelectorAll(".igv-roi-region");for(let e of t)e.remove();this.roiMenu&&this.roiMenu.dispose(),this.roiTable&&this.roiTable.dispose();for(let t of this.roiSets)t.dispose();for(let t of Object.keys(this))this[t]=void 0}}function nv(){this.renderAllROISets()}function rv(t,e,n){return`${t}-${e}-${n}`}function iv(t){return`[data-region="${t}"]`}function ov(t){let[e,n,r]=t.split("-");return n=parseInt(n),r=parseInt(r),{chr:e,start:n,end:r,locus:`${e}:${n}-${r}`,bedRecord:`${e}\t${n}\t${r}`}}const sv=[];class av{constructor(t,e,n){this.browser=t,this.container=ge({class:n?"igv-roi-table":"igv-roi-table-four-column"}),e.appendChild(this.container),this.hasROISetNames=n;const r=this.createHeaderDOM(this.container);this.columnTitleDOM=function(t,e){const n=ge({class:"igv-roi-table-column-titles"});t.appendChild(n);let r=["Chr","Start","End","Description","ROI Set"];!1===e&&(r=r.slice(0,4));for(let t of r){const e=ge();e.innerText=t,n.appendChild(e)}return n}(this.container,n),this.tableRowContainerDOM=this.createTableRowContainerDOM(this.container),this.footerDOM=this.createFooterDOM(this.container);const{y:i}=t.root.getBoundingClientRect(),{y:o}=e.getBoundingClientRect(),s=-(o-i);wo(this.container,r,{minX:0,minY:s}),this.container.style.display="none"}clearTable(){const t=this.tableRowContainerDOM.querySelectorAll(".igv-roi-table-row");for(let e of t)e.remove()}present(){this.container.style.left="0px",this.container.style.top="0px",this.container.style.display="flex"}dismiss(){this.container.style.display="none"}renderTable(t){if(Array.from(this.tableRowContainerDOM.querySelectorAll(".igv-roi-table-row")).forEach((t=>t.remove())),t.length>0){const e=t.sort(((t,e)=>t.feature.chr.localeCompare(e.feature.chr)||t.feature.start-e.feature.start||t.feature.end-e.feature.end));for(let t of e){const e=this.createTableRowDOM(t);this.tableRowContainerDOM.appendChild(e)}}}createHeaderDOM(t){const e=ge();t.appendChild(e);const n=ge();e.appendChild(n),n.innerText="Regions of Interest";const r=ge();return e.appendChild(r),r.appendChild(ye("times")),r.addEventListener("click",(t=>{t.stopPropagation(),this.browser.roiTableControl.buttonHandler(!1)})),e}createTableRowContainerDOM(t){const e=ge({class:"igv-roi-table-row-container"});return t.appendChild(e),e}createTableRowDOM(t){const e=ge({class:"igv-roi-table-row"}),{setName:n,feature:r}=t;e.dataset.region=rv(r.chr,r.start,r.end);let i=[r.chr,Se(r.start),Se(r.end),r.name||"",n];!1===this.hasROISetNames&&(i=i.slice(0,4));for(let t of i){const n=ge();n.innerText=t,e.appendChild(n)}return e.addEventListener("mousedown",(t=>{t.stopPropagation(),e.classList.toggle("igv-roi-table-row-selected"),e.classList.contains("igv-roi-table-row-selected")?e.classList.remove("igv-roi-table-row-hover"):e.classList.add("igv-roi-table-row-hover"),this.setButtonState(e.classList.contains("igv-roi-table-row-selected"))})),e.addEventListener("mouseover",(t=>{e.classList.contains("igv-roi-table-row-selected")?e.classList.remove("igv-roi-table-row-hover"):e.classList.add("igv-roi-table-row-hover")})),e.addEventListener("mouseout",(t=>{e.classList.remove("igv-roi-table-row-hover")})),e}createFooterDOM(t){const e=ge();t.appendChild(e);const n=ge({class:"igv-roi-table-button"});return e.appendChild(n),n.id="igv-roi-table-view-button",n.textContent="Go To",n.style.pointerEvents="none",n.addEventListener("click",(e=>{e.stopPropagation();const n=t.querySelectorAll(".igv-roi-table-row-selected"),r=[];for(let t of n){const{locus:e}=ov(t.dataset.region);r.push(e)}for(let e of t.querySelectorAll(".igv-roi-table-row"))e.classList.remove("igv-roi-table-row-selected");this.setButtonState(!1),r.length>0&&this.browser.search(r.join(" "))})),e}setButtonState(t){t?sv.push(1):sv.pop();this.footerDOM.querySelector("#igv-roi-table-view-button").style.pointerEvents=sv.length>0?"auto":"none"}dispose(){this.browser.roiTableControl.buttonHandler(!1),this.container.innerHTML="";for(let t of Object.keys(this))this[t]=void 0}}class lv{constructor(t,e){this.browser=t,this.container=ge({class:"igv-roi-menu-next-gen"}),e.appendChild(this.container);const n=ge();this.container.appendChild(n),_e(n,(()=>this.container.style.display="none")),this.body=ge(),this.container.appendChild(this.body),this.container.style.display="none"}async present(t,e,n,r,i){cv(this.body);const o=await this.browser.roiManager.findUserDefinedRegionWithKey(i.dataset.region),s=ge();this.body.appendChild(s);const a="Description",l=o.name||a;s.innerText=l,s.setAttribute("title",l),a===l?s.classList.add("igv-roi-placeholder"):s.classList.remove("igv-roi-placeholder");const c=ge();this.body.appendChild(c),c.innerText="Set Description",c.addEventListener("click",(t=>{t.stopPropagation(),this.container.style.display="none";const e={label:"Description",value:o.name||"",callback:()=>{const t=this.browser.inputDialog.input.value||"";o.name=t.trim(),this.container.style.display="none",this.browser.roiManager.repaintTable()}};this.browser.inputDialog.present(e,t)}));const h=ge();this.body.appendChild(h),h.innerText="Delete Region",h.addEventListener("click",(t=>{t.stopPropagation(),this.container.style.display="none",this.browser.roiManager.deleteUserDefinedRegionWithKey(i.dataset.region,this.browser.columnContainer)})),this.container.style.left=`${t}px`,this.container.style.top=`${e}px`,this.container.style.display="flex"}async __present(t,e,n,r,i){cv(this.container);const o=await this.browser.roiManager.findUserDefinedRegionWithKey(i.dataset.region);let s;s=ge({class:"igv-roi-menu-row-edit-description"}),this.container.appendChild(s),s.addEventListener("click",(t=>{t.stopPropagation()}));const a="description-input",l=document.createElement("label");s.appendChild(l),l.setAttribute("for",a),l.innerText="Description:";const c=document.createElement("input");s.appendChild(c),c.setAttribute("type","text"),c.setAttribute("name",a),c.setAttribute("placeholder",""),c.value=o.name||"",c.addEventListener("change",(async t=>{t.stopPropagation();(await this.browser.roiManager.findUserDefinedRegionWithKey(i.dataset.region)).name=c.value,c.blur(),this.container.style.display="none",await this.browser.roiManager.repaintTable()})),s=ge({class:"igv-roi-menu-row"}),s.innerText="Delete region",this.container.appendChild(s),s.addEventListener("click",(t=>{t.stopPropagation(),this.container.style.display="none",this.browser.roiManager.deleteUserDefinedRegionWithKey(i.dataset.region,this.browser.columnContainer)})),this.container.style.left=`${t}px`,this.container.style.top=`${e}px`,this.container.style.display="flex",r.addEventListener("click",(t=>{t.stopPropagation(),this.container.style.display="none"}))}dispose(){this.container.innerHTML=""}}function cv(t){for(;t.firstChild;)t.removeChild(t.firstChild)}class hv{constructor(t,e){this.name=t.name,this.featureSource=t.featureSource||ef(t,e),this.color=t.color||nf}async getFeatures(t,e,n){return this.featureSource.getFeatures({chr:t,start:e,end:n})}draw(t){const{context:e,bpPerPixel:n,bpStart:r,pixelTop:i,pixelHeight:o,pixelWidth:s,features:a}=t;if(!a)return;const l=r+s*n+1;for(let{start:t,end:s}of a){if(s<r)continue;if(t>l)break;const{x:a,width:c}=sf(t,s,r,n);ns.fillRect(e,a,i,c,o,{fillStyle:this.color})}}}class uv{constructor(t,e){this.browser=e,this.button=ge({class:"igv-navbar-button"}),t.appendChild(this.button),this.button.textContent="ROI Table",this.button.addEventListener("click",(()=>{this.buttonHandler(!e.roiTableVisible)})),this.browser=e,this.setVisibility(e.showROITableButton),this.setState(e.roiTableVisible)}buttonHandler(t){this.browser.roiTableVisible=t,this.setState(this.browser.roiTableVisible),this.browser.setROITableVisibility(this.browser.roiTableVisible)}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.roiTableVisible)}hide(){this.button.style.display="none"}}class fv{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),this.alert=new Ls(this.root),this.columnContainer=ge({class:"igv-column-container"}),this.root.appendChild(this.columnContainer),this.menuPopup=new Cg(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&&(Rg.gtexLoaded=!0),this.flanking=t.flanking,this.crossDomainProxy=t.crossDomainProxy,this.formats=t.formats,this.trackDefaults=t.trackDefaults,this.nucleotideColors=t.nucleotideColors||ca;for(let t of Object.keys(this.nucleotideColors))this.nucleotideColors[t.toLowerCase()]=this.nucleotideColors[t];this.trackLabelsVisible=t.showTrackLabels,this.roiTableVisible=t.showROITable,this.showROITableButton=t.showROITableButton,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 Om(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 Pm(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 l=ge({class:"igv-search-icon-container"});a.append(pe(l)),l.appendChild(ye("search")),l.addEventListener("click",(()=>this.doSearch(this.$searchInput.val()))),this.windowSizePanel=new Fm(s.get(0),this);const c=pe("<div>",{class:"igv-navbar-right-container"});e.append(c);const h=pe('<div class="igv-navbar-toggle-button-container">');if(c.append(h),this.$toggle_button_container=h,this.cursorGuide=new Dm(this.columnContainer,this),this.cursorGuideButton=new Bm(this,h.get(0)),this.centerLineButton=new zm(this,h.get(0)),this.setTrackLabelVisibility(t.showTrackLabels),this.trackLabelControl=new Hm(h.get(0),this),this.roiTableControl=new uv(h.get(0),this),this.sampleNameControl=new Vm(h.get(0),this),!0===t.showSVGButton&&(this.svgSaveControl=new Wm(h.get(0),this)),t.customButtons)for(let e of t.customButtons)new tv(h.get(0),this,e);return this.zoomWidget=new qm(this,c.get(0)),!1===t.showNavigation&&this.$navigation.hide(),this.inputDialog=new vs(this.root),this.inputDialog.container.id=`igv-input-dialog-${be()}`,this.dataRangeDialog=new Xo(this,pe(this.root)),this.dataRangeDialog.$container.get(0).id=`igv-data-range-dialog-${be()}`,this.genericColorPicker=new As({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){km(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}currentLoci(){const t=t=>`${t.chr}:${t.start+1}-${t.end}`;return void 0===this.referenceFrameList||0===this.referenceFrameList.length?"":1===this.referenceFrameList.length?t(this.referenceFrameList[0]):this.referenceFrameList.map((e=>t(e)))}toSVG(){const{y:t,width:e,height:n}=this.columnContainer.getBoundingClientRect(),r=new Ta({width:e,height:8e3,backdropColor:"white",multiLocusGap:0,viewbox:{x:0,y:0,width:e,height:8e3}});for(let e of this.trackViews)e.renderSVGContext(r,{deltaX:0,deltaY:-t});return r.setHeight(n),r.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.roiSets=[],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=fv.uncompressSession(t.url);return JSON.parse(e)}{let n=t.filename;if(n||(n=t.url?await Ps(t.url):t.file.name),n.endsWith(".xml")){const t=Ra.KNOWN_GENOMES,n=await To.loadString(e);return new Cm(n,t)}return n.endsWith(".json")?To.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),Bs(this.columnContainer,"igv-axis-column"),Bs(this.columnContainer,"igv-sample-name-column"),Bs(this.columnContainer,"igv-scrollbar-column"),Bs(this.columnContainer,"igv-track-drag-column"),Bs(this.columnContainer,"igv-gear-menu-column");const e=t.reference||t.genome;if(!e)return void console.warn("No genome or reference object specified");const n=await Ra.expandReference(this.alert,e);await this.loadReference(n,t.locus),this.centerLineList=this.createCenterLineList(this.columnContainer);let r=0;if(!1!==t.showIdeogram){const t=new vm(this);t.id="ideogram";const e=new Lg(this,this.columnContainer,t),{$viewport:n}=e.viewports[0];r=function(t){t="string"==typeof t?document.querySelector(t):t;const e=window.getComputedStyle(t),n=parseFloat(e.marginTop)+parseFloat(e.marginBottom),r=t.offsetHeight;return Math.ceil(n+r)}(n.get(0)),this.trackViews.push(e)}if(!1!==t.showRuler&&this.trackViews.push(new Lg(this,this.columnContainer,new Km(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 Lm(r,i)}this.roiManager&&this.roiManager.dispose();const i=new lv(this,this.columnContainer);if(t.roi){const e=t.roi.map((t=>new of(t,this.genome))),n=e.filter((t=>{let{name:e}=t;return void 0!==e&&e.length>0})),o=new av(this,this.columnContainer,n.length>0);this.roiManager=new ev(this,i,o,r,e)}else{const t=new av(this,this.columnContainer,!1);this.roiManager=new ev(this,i,t,r,void 0)}await this.roiManager.initialize();const o=n.tracks||[],s=t.tracks?o.concat(t.tracks):o;0===s.filter((t=>"sequence"===t.type&&!t.url&&!t.fastaURL)).length&&s.push({type:"sequence",order:ha});let a=1;for(let t of s)void 0===t.order&&(t.order=a++);await this.loadTrackList(s);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 Xm(this,this.referenceFrameList[t],r[t]));return n}async loadReference(t,e){const n=await Ra.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:sg(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){let e=t.id&&t.id.length<10?t.id:"";this.$current_genome.text(e),this.$current_genome.attr("title",t.id||""),this.chromosomeSelectWidget.update(t)}async loadGenome(t){const e=await Ra.expandReference(this.alert,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:ha}),await this.loadTrackList(n),await this.updateViews(),this.genome}updateUIWithReferenceFrameList(){const t=this.referenceFrameList;this.updateLocusSearchWidget();const e=this.isMultiLocusWholeGenomeView()||Ra.isWholeGenomeView(t[0].chr);this.navbarManager.navbarDidResize(this.$navigation.width(),e),mv(this.trackViews,this.trackLabelsVisible),this.setCenterLineAndCenterLineButtonVisibility(!Ra.isWholeGenomeView(t[0].chr))}setTrackLabelVisibility(t){mv(this.trackViews,t)}setROITableVisibility(t){!0===t?this.roiManager.presentTable():this.roiManager.dismissTable()}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 loadTrack(t){const e=this._loadTrack(t);return t.autoscaleGroup&&(await e,this.updateViews()),e}async _loadTrack(t){ke(t)&&(t=JSON.parse(t));try{const e=await this.createTrack(t);if(void 0===e)return;void 0===e.order&&(e.order=this.trackViews.length);const n=new Lg(this,this.columnContainer,e);if(this.trackViews.push(n),mv(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,this.alert.present(new Error(r),void 0)}}async loadROI(t){await this.roiManager.loadROI(t,this.genome)}clearROIs(){this.roiManager.clearROIs()}async getUserDefinedROIs(){if(this.roiManager){const t=await this.roiManager.getUserDefinedROISet();if(void 0===t)return[];const e=await t.getAllFeatures(),n=[];for(let t of Object.values(e))n.push(...t);return n}return[]}getRulerTrackView(){const t=this.trackViews.filter((t=>{let{track:e}=t;return"ruler"===e.id}));return t.length>0?t[0]:void 0}async createTrack(t){let e=await async function(t){return"function"==typeof t?t():t}(t.url||t.fastaURL);if(ke(e)&&(e=e.trim()),e)if(t.format)t.format=t.format.toLowerCase();else if(t.fastaURL)t.format="fasta";else{let n=t.filename;n||(n=await Ps(e));const r=$s(n);"tsv"===r?t.format=await async function(t){if(t.url){const e=await To.loadString(t.url,Is(t,{range:{start:0,size:1e3}}));if(e&&qs(e.split("\n")[0].split("\t")))return"hiccups"}}(t):r?t.format=r:"htsget"===t.sourceType&&await Ac.inferFormat(t)}let n=t.type?t.type.toLowerCase():void 0;if(!n){if(n=Gs(t),"bedtype"===n){const e=ef(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=Sm(n,t,this);if(void 0!==r)return t.roi&&t.roi.length>0&&(r.roiSets=t.roi.map((t=>new hv(t,this.genome)))),r;this.alert.present(new Error(`Error creating track. Could not determine track type for file: ${t.url||t}`),void 0)}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){for(let e of this.trackViews)if(t===e.track){this._removeTrack(e.track);break}}_removeTrack(t){t.disposed||(this.trackViews.splice(this.trackViews.indexOf(t.trackView),1),this.fireEvent("trackremoved",[t]),this.fireEvent("trackorderchanged",[this.getTrackOrder()]),t.trackView&&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()||Ra.isWholeGenomeView(this.referenceFrameList[0].chr);this.navbarManager.navbarDidResize(this.$navigation.width(),t)}dv.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=Ns(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 Rm(this.genome,t,e,n,s),l=r?this.referenceFrameList.indexOf(r):this.referenceFrameList.length-1,c=1+l,{$viewport:h}=this.trackViews[0].viewports[l],u=Gm(h.get(0).parentElement);if(c===this.referenceFrameList.length){this.referenceFrameList.push(a);for(let t of this.trackViews){const e=xg(t,u,a);t.viewports.push(e)}}else{this.referenceFrameList.splice(c,0,a);for(let t of this.trackViews){const e=xg(t,u,a);t.viewports.splice(c,0,e)}}this.centerLineList=this.createCenterLineList(this.columnContainer),dv.call(this),await this.updateViews(!0)}async removeMultiLocusPanel(t){const e=this.referenceFrameList.indexOf(t),{$viewport:n}=this.trackViews[0].viewports[e];$m(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((t=>{let{viewports:e}=t;return e.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||this.alert.present(new Error(`Unrecognized locus: <b> ${t} </b>`)),n}async search(t,e){const n=await Nm(this,t);if(n&&n.length>0){this.referenceFrameList=function(t,e,n,r,i,o){return t.map((t=>{if(n&&t.gene&&(t.start=Math.max(0,t.start-n),t.end+=n),!o){const n=e.getChromosome(t.chr);Os(n.bpLength,t,r)}const s=new Rm(e,t.chr,t.start,t.end,(t.end-t.start)/i);return s.locusSearchString=t.locusSearchString,(t.gene||t.snp)&&(s.selection=new Lm(t.gene,t.snp)),s}))}(n,this.genome,this.flanking,this.minimumBases(),this.calculateViewportWidth(n.length),this.isSoftclipped());for(let t of this.trackViews)t.removeDOMFromColumnContainer();this.columnContainer.querySelectorAll(".igv-column-shim, .igv-column").forEach((t=>t.remove())),Zm(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 Am).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.13.11"};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),t.roi=this.roiManager.toJSON();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 no.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"))}isTrackPanning(){return this.dragObject}isSoftclipped(){return void 0!==this.trackViews.find((t=>!0===t.track.showSoftClips))}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=dv.bind(this),window.addEventListener("resize",this.boundWindowResizeHandler)}removeWindowResizeHandler(){window.removeEventListener("resize",this.boundWindowResizeHandler)}addRootMouseUpHandler(){this.boundRootMouseUpHandler=gv.bind(this),this.root.addEventListener("mouseup",this.boundRootMouseUpHandler)}removeRootMouseUpHandler(){this.root.removeEventListener("mouseup",this.boundRootMouseUpHandler)}addRootMouseLeaveHandler(){this.boundRootMouseLeaveHandler=gv.bind(this),this.root.addEventListener("mouseleave",this.boundRootMouseLeaveHandler)}removeRootMouseLeaveHandler(){this.root.removeEventListener("mouseleave",this.boundRootMouseLeaveHandler)}addColumnContainerEventHandlers(){this.boundColumnContainerMouseMoveHandler=pv.bind(this),this.boundColumnContainerTouchMoveHandler=pv.bind(this),this.boundColumnContainerMouseLeaveHandler=gv.bind(this),this.boundColumnContainerMouseUpHandler=gv.bind(this),this.boundColumnContainerTouchEndHandler=gv.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 To.loadJson(e,Is({}))}static uncompressSession(t){let e;if(t.indexOf("/gzip;base64")>0){e=ho(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=no.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 Jp(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=Rp.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 Jm(this.$toggle_button_container.get(0),this),this.circularView.setAssembly({name:this.genome.id,id:this.genome.id,chromosomes:sg(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 dv(){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);Ra.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 pv(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=Mg(t.trackView.viewports);this.vpMouseDown.r=e/n}if(this.dragObject){const n=!this.isSoftclipped();let i=this.vpMouseDown.lastMouseX-e;r.shiftPixels(i,t.$viewport.width(),n)&&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 gv(t){this.cancelTrackPan(),this.endTrackDrag()}function mv(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 vv=[];const bv=To.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}\n.igv-navbar .igv-navbar-left-container {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n height: 32px;\n line-height: 32px;\n}\n.igv-navbar .igv-navbar-left-container .igv-logo {\n width: 34px;\n height: 32px;\n margin-right: 8px;\n}\n.igv-navbar .igv-navbar-left-container .igv-current-genome {\n height: 32px;\n margin-left: 4px;\n margin-right: 4px;\n user-select: none;\n line-height: 32px;\n vertical-align: middle;\n text-align: center;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n height: 100%;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-chromosome-select-widget-container {\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n height: 100%;\n width: 125px;\n margin-right: 4px;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-chromosome-select-widget-container select {\n display: block;\n cursor: pointer;\n width: 100px;\n height: 75%;\n outline: none;\n font-size: 12px;\n font-family: "Open Sans", sans-serif;\n font-weight: 400;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n margin-left: 8px;\n height: 22px;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-search-container {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n width: 210px;\n height: 22px;\n line-height: 22px;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-search-container input.igv-search-input {\n cursor: text;\n width: 85%;\n height: 22px;\n line-height: 22px;\n font-size: 12px;\n font-family: "Open Sans", sans-serif;\n font-weight: 400;\n text-align: left;\n padding-left: 8px;\n margin-right: 8px;\n outline: none;\n border-style: solid;\n border-radius: 3px;\n border-width: thin;\n border-color: #bfbfbf;\n background-color: white;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-search-container .igv-search-icon-container {\n cursor: pointer;\n height: 16px;\n width: 16px;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-windowsize-panel-container {\n margin-left: 4px;\n user-select: none;\n}\n.igv-navbar .igv-navbar-right-container {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n height: 32px;\n line-height: 32px;\n}\n.igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n height: 100%;\n}\n.igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container div {\n margin-left: 0;\n margin-right: 4px;\n}\n.igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container div:last-child {\n margin-left: 0;\n margin-right: 0;\n}\n.igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container-750 {\n display: none;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget {\n color: #737373;\n font-size: 18px;\n height: 32px;\n line-height: 32px;\n margin-left: 8px;\n user-select: none;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div {\n cursor: pointer;\n margin-left: unset;\n margin-right: unset;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div:first-child {\n height: 24px;\n width: 24px;\n margin-left: unset;\n margin-right: 8px;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div:last-child {\n height: 24px;\n width: 24px;\n margin-left: 8px;\n margin-right: unset;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div:nth-child(even) {\n display: block;\n height: fit-content;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget input {\n display: block;\n width: 125px;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget svg {\n display: block;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 {\n color: #737373;\n font-size: 18px;\n height: 32px;\n line-height: 32px;\n margin-left: 8px;\n user-select: none;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div {\n cursor: pointer;\n margin-left: unset;\n margin-right: unset;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div:first-child {\n height: 24px;\n width: 24px;\n margin-left: unset;\n margin-right: 8px;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div:last-child {\n height: 24px;\n width: 24px;\n margin-left: 8px;\n margin-right: unset;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div:nth-child(even) {\n width: 0;\n height: 0;\n display: none;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 input {\n width: 0;\n height: 0;\n display: none;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 svg {\n display: block;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-hidden {\n display: none;\n}\n\n.igv-navbar-button {\n display: block;\n box-sizing: unset;\n padding-left: 6px;\n padding-right: 6px;\n height: 18px;\n text-transform: capitalize;\n user-select: none;\n line-height: 18px;\n text-align: center;\n vertical-align: middle;\n font-family: "Open Sans", sans-serif;\n font-size: 11px;\n font-weight: 200;\n color: #737373;\n background-color: #f3f3f3;\n border-color: #737373;\n border-style: solid;\n border-width: thin;\n border-radius: 6px;\n}\n\n.igv-navbar-button-clicked {\n color: white;\n background-color: #737373;\n}\n\n.igv-navbar-button:hover {\n cursor: pointer;\n}\n\n.igv-zoom-in-notice-container {\n z-index: 1024;\n position: absolute;\n top: 8px;\n left: 50%;\n transform: translate(-50%, 0%);\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n justify-content: center;\n align-items: center;\n background-color: white;\n}\n.igv-zoom-in-notice-container > div {\n padding-left: 4px;\n padding-right: 4px;\n padding-top: 2px;\n padding-bottom: 2px;\n width: 100%;\n height: 100%;\n font-family: "Open Sans", sans-serif;\n font-size: 14px;\n font-weight: 400;\n color: #3f3f3f;\n}\n\n.igv-zoom-in-notice {\n position: absolute;\n top: 10px;\n left: 50%;\n}\n.igv-zoom-in-notice div {\n position: relative;\n left: -50%;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n color: #3f3f3f;\n background-color: rgba(255, 255, 255, 0.51);\n z-index: 64;\n}\n\n.igv-container-spinner {\n position: absolute;\n top: 90%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 1024;\n width: 24px;\n height: 24px;\n pointer-events: none;\n color: #737373;\n}\n\n.igv-multi-locus-close-button {\n position: absolute;\n top: 2px;\n right: 0;\n padding-left: 2px;\n padding-right: 2px;\n width: 18px;\n height: 18px;\n color: #666666;\n background-color: white;\n z-index: 1000;\n}\n.igv-multi-locus-close-button > svg {\n vertical-align: top;\n}\n\n.igv-multi-locus-close-button:hover {\n cursor: pointer;\n color: #434343;\n}\n\n.igv-multi-locus-ruler-label {\n z-index: 64;\n position: absolute;\n top: 2px;\n left: 0;\n width: 100%;\n height: 14px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: center;\n align-items: center;\n}\n.igv-multi-locus-ruler-label div {\n font-family: "Open Sans", sans-serif;\n font-size: 14px;\n font-weight: 400;\n color: rgb(16, 16, 16);\n background-color: white;\n}\n\n.igv-multi-locus-ruler-label-square-dot {\n z-index: 64;\n position: absolute;\n left: 50%;\n top: 5%;\n transform: translate(-50%, 0%);\n background-color: white;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-multi-locus-ruler-label-square-dot > div:first-child {\n width: 14px;\n height: 14px;\n}\n.igv-multi-locus-ruler-label-square-dot > div:last-child {\n margin-left: 16px;\n font-family: "Open Sans", sans-serif;\n font-size: 14px;\n font-weight: 400;\n color: rgb(16, 16, 16);\n}\n\n.igv-multi-locus-ruler-label:hover {\n cursor: pointer;\n}\n\n.igv-ruler-sweeper {\n display: none;\n pointer-events: none;\n position: absolute;\n top: 26px;\n bottom: 0;\n left: 0;\n width: 0;\n z-index: 99999;\n background-color: rgba(68, 134, 247, 0.25);\n}\n\n.igv-ruler-tooltip {\n pointer-events: none;\n z-index: 128;\n position: absolute;\n top: 0;\n left: 0;\n width: 1px;\n height: 32px;\n background-color: transparent;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-ruler-tooltip > div {\n pointer-events: none;\n width: 128px;\n height: auto;\n padding: 1px;\n color: #373737;\n font-size: 10px;\n font-family: "Open Sans", sans-serif;\n font-weight: 400;\n background-color: white;\n border-style: solid;\n border-width: thin;\n border-color: #373737;\n}\n\n.igv-track-label {\n position: absolute;\n left: 8px;\n top: 8px;\n width: auto;\n height: auto;\n max-width: 50%;\n padding-left: 4px;\n padding-right: 4px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n font-family: "Open Sans", sans-serif;\n font-size: small;\n font-weight: 400;\n text-align: center;\n user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n border-color: #444;\n border-radius: 2px;\n border-style: solid;\n border-width: thin;\n background-color: white;\n z-index: 128;\n cursor: pointer;\n}\n\n.igv-track-label:hover,\n.igv-track-label:focus,\n.igv-track-label:active {\n background-color: #e8e8e8;\n}\n\n.igv-track-label-popup-shim {\n padding-left: 8px;\n padding-right: 8px;\n padding-top: 4px;\n}\n\n.igv-center-line {\n display: none;\n pointer-events: none;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 50%;\n transform: translateX(-50%);\n z-index: 8;\n user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n border-left-style: dashed;\n border-left-width: thin;\n border-right-style: dashed;\n border-right-width: thin;\n}\n\n.igv-center-line-wide {\n background-color: rgba(0, 0, 0, 0);\n border-left-color: rgba(127, 127, 127, 0.51);\n border-right-color: rgba(127, 127, 127, 0.51);\n}\n\n.igv-center-line-thin {\n background-color: rgba(0, 0, 0, 0);\n border-left-color: rgba(127, 127, 127, 0.51);\n border-right-color: rgba(0, 0, 0, 0);\n}\n\n.igv-cursor-guide-horizontal {\n display: none;\n pointer-events: none;\n user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n position: absolute;\n left: 0;\n right: 0;\n top: 50%;\n height: 1px;\n z-index: 1;\n margin-left: 50px;\n margin-right: 54px;\n border-top-style: dotted;\n border-top-width: thin;\n border-top-color: rgba(127, 127, 127, 0.76);\n}\n\n.igv-cursor-guide-vertical {\n pointer-events: none;\n user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 50%;\n width: 1px;\n z-index: 1;\n border-left-style: dotted;\n border-left-width: thin;\n border-left-color: rgba(127, 127, 127, 0.76);\n display: none;\n}\n\n.igv-user-feedback {\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 512px;\n height: 360px;\n z-index: 2048;\n background-color: white;\n border-color: #a2a2a2;\n border-style: solid;\n border-width: thin;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n color: #444;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-user-feedback div:first-child {\n position: relative;\n height: 24px;\n width: 100%;\n background-color: white;\n border-bottom-color: #a2a2a2;\n border-bottom-style: solid;\n border-bottom-width: thin;\n}\n.igv-user-feedback div:first-child div {\n position: absolute;\n top: 2px;\n width: 16px;\n height: 16px;\n background-color: transparent;\n}\n.igv-user-feedback div:first-child div:first-child {\n left: 8px;\n}\n.igv-user-feedback div:first-child div:last-child {\n cursor: pointer;\n right: 8px;\n}\n.igv-user-feedback div:last-child {\n width: 100%;\n height: calc(100% - 24px);\n border-width: 0;\n}\n.igv-user-feedback div:last-child div {\n width: auto;\n height: auto;\n margin: 8px;\n}\n\n.igv-generic-dialog-container {\n position: absolute;\n top: 0;\n left: 0;\n width: 300px;\n height: 200px;\n border-color: #7F7F7F;\n border-radius: 4px;\n border-style: solid;\n border-width: thin;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n z-index: 2048;\n background-color: white;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-generic-dialog-container .igv-generic-dialog-header {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n width: 100%;\n height: 24px;\n cursor: move;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-bottom-color: #7F7F7F;\n border-bottom-style: solid;\n border-bottom-width: thin;\n background-color: #eee;\n}\n.igv-generic-dialog-container .igv-generic-dialog-header div {\n margin-right: 4px;\n margin-bottom: 2px;\n height: 12px;\n width: 12px;\n color: #7F7F7F;\n}\n.igv-generic-dialog-container .igv-generic-dialog-header div:hover {\n cursor: pointer;\n color: #444;\n}\n.igv-generic-dialog-container .igv-generic-dialog-one-liner {\n color: #373737;\n width: 95%;\n height: 24px;\n line-height: 24px;\n text-align: left;\n margin-top: 8px;\n padding-left: 8px;\n overflow-wrap: break-word;\n background-color: white;\n}\n.igv-generic-dialog-container .igv-generic-dialog-label-input {\n margin-top: 8px;\n width: 95%;\n height: 24px;\n color: #373737;\n line-height: 24px;\n padding-left: 8px;\n background-color: white;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-generic-dialog-container .igv-generic-dialog-label-input div {\n width: 30%;\n height: 100%;\n font-size: 16px;\n text-align: right;\n padding-right: 8px;\n background-color: white;\n}\n.igv-generic-dialog-container .igv-generic-dialog-label-input input {\n display: block;\n height: 100%;\n width: 100%;\n padding-left: 4px;\n font-family: "Open Sans", sans-serif;\n font-weight: 400;\n color: #373737;\n text-align: left;\n outline: none;\n border-style: solid;\n border-width: thin;\n border-color: #7F7F7F;\n background-color: white;\n}\n.igv-generic-dialog-container .igv-generic-dialog-label-input input {\n width: 50%;\n font-size: 16px;\n}\n.igv-generic-dialog-container .igv-generic-dialog-input {\n margin-top: 8px;\n width: calc(100% - 16px);\n height: 24px;\n color: #373737;\n line-height: 24px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n.igv-generic-dialog-container .igv-generic-dialog-input input {\n display: block;\n height: 100%;\n width: 100%;\n padding-left: 4px;\n font-family: "Open Sans", sans-serif;\n font-weight: 400;\n color: #373737;\n text-align: left;\n outline: none;\n border-style: solid;\n border-width: thin;\n border-color: #7F7F7F;\n background-color: white;\n}\n.igv-generic-dialog-container .igv-generic-dialog-input input {\n font-size: 16px;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel {\n width: 100%;\n height: 28px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div {\n margin-top: 32px;\n color: white;\n font-family: "Open Sans", sans-serif;\n font-size: 14px;\n font-weight: 400;\n width: 75px;\n height: 28px;\n line-height: 28px;\n text-align: center;\n border-color: transparent;\n border-style: solid;\n border-width: thin;\n border-radius: 2px;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:first-child {\n margin-left: 32px;\n margin-right: 0;\n background-color: #5ea4e0;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:last-child {\n margin-left: 0;\n margin-right: 32px;\n background-color: #c4c4c4;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:first-child:hover {\n cursor: pointer;\n background-color: #3b5c7f;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:last-child:hover {\n cursor: pointer;\n background-color: #7f7f7f;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok {\n width: 100%;\n height: 36px;\n margin-top: 32px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok div {\n width: 98px;\n height: 36px;\n line-height: 36px;\n text-align: center;\n color: white;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n border-color: white;\n border-style: solid;\n border-width: thin;\n border-radius: 4px;\n background-color: #2B81AF;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok div:hover {\n cursor: pointer;\n background-color: #25597f;\n}\n\n.igv-generic-container {\n position: absolute;\n top: 0;\n left: 0;\n z-index: 2048;\n background-color: white;\n cursor: pointer;\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-generic-container div:first-child {\n cursor: move;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n height: 24px;\n width: 100%;\n background-color: #dddddd;\n}\n.igv-generic-container div:first-child i {\n display: block;\n color: #5f5f5f;\n cursor: pointer;\n width: 14px;\n height: 14px;\n margin-right: 8px;\n margin-bottom: 4px;\n}\n\n.igv-menu-popup {\n position: absolute;\n top: 0;\n left: 0;\n width: max-content;\n z-index: 4096;\n cursor: pointer;\n font-family: "Open Sans", sans-serif;\n font-size: small;\n font-weight: 400;\n color: #4b4b4b;\n background: white;\n border-radius: 4px;\n border-color: #7F7F7F;\n border-style: solid;\n border-width: thin;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-end;\n text-align: left;\n}\n.igv-menu-popup > div:not(:first-child) {\n width: 100%;\n}\n.igv-menu-popup > div:not(:first-child) > div {\n background: white;\n}\n.igv-menu-popup > div:not(:first-child) > div.context-menu {\n padding-left: 4px;\n padding-right: 4px;\n}\n.igv-menu-popup > div:not(:first-child) > div:last-child {\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n border-bottom-color: transparent;\n border-bottom-style: solid;\n border-bottom-width: thin;\n}\n.igv-menu-popup > div:not(:first-child) > div:hover {\n background: #efefef;\n}\n\n.igv-menu-popup-shim {\n padding-left: 8px;\n padding-right: 8px;\n padding-bottom: 1px;\n padding-top: 1px;\n}\n\n.igv-menu-popup-header {\n position: relative;\n width: 100%;\n height: 24px;\n cursor: move;\n border-top-color: transparent;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-bottom-color: #7F7F7F;\n border-bottom-style: solid;\n border-bottom-width: thin;\n background-color: #eee;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n}\n.igv-menu-popup-header div {\n margin-right: 4px;\n height: 12px;\n width: 12px;\n color: #7F7F7F;\n}\n.igv-menu-popup-header div:hover {\n cursor: pointer;\n color: #444;\n}\n\n.igv-menu-popup-check-container {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n width: 100%;\n height: 20px;\n margin-right: 4px;\n background-color: transparent;\n}\n.igv-menu-popup-check-container div {\n padding-top: 2px;\n padding-left: 8px;\n}\n.igv-menu-popup-check-container div:first-child {\n position: relative;\n width: 12px;\n height: 12px;\n}\n.igv-menu-popup-check-container div:first-child svg {\n position: absolute;\n width: 12px;\n height: 12px;\n}\n\n.igv-user-feedback {\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 512px;\n height: 360px;\n z-index: 2048;\n background-color: white;\n border-color: #a2a2a2;\n border-style: solid;\n border-width: thin;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n color: #444;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-user-feedback div:first-child {\n position: relative;\n height: 24px;\n width: 100%;\n background-color: white;\n border-bottom-color: #a2a2a2;\n border-bottom-style: solid;\n border-bottom-width: thin;\n}\n.igv-user-feedback div:first-child div {\n position: absolute;\n top: 2px;\n width: 16px;\n height: 16px;\n background-color: transparent;\n}\n.igv-user-feedback div:first-child div:first-child {\n left: 8px;\n}\n.igv-user-feedback div:first-child div:last-child {\n cursor: pointer;\n right: 8px;\n}\n.igv-user-feedback div:last-child {\n width: 100%;\n height: calc(100% - 24px);\n border-width: 0;\n}\n.igv-user-feedback div:last-child div {\n width: auto;\n height: auto;\n margin: 8px;\n}\n\n.igv-loading-spinner-container {\n z-index: 1024;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 32px;\n height: 32px;\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n justify-content: center;\n align-items: center;\n}\n.igv-loading-spinner-container > div {\n box-sizing: border-box;\n width: 100%;\n height: 100%;\n border-radius: 50%;\n border: 4px solid rgba(128, 128, 128, 0.5);\n border-top-color: rgb(255, 255, 255);\n animation: spin 1s ease-in-out infinite;\n -webkit-animation: spin 1s ease-in-out infinite;\n}\n\n@keyframes spin {\n to {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n@-webkit-keyframes spin {\n to {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n.igv-roi-menu-next-gen {\n position: absolute;\n z-index: 512;\n font-family: "Open Sans", sans-serif;\n font-size: small;\n font-weight: 400;\n color: #4b4b4b;\n background-color: white;\n width: 192px;\n border-radius: 4px;\n border-color: #7F7F7F;\n border-style: solid;\n border-width: thin;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n}\n.igv-roi-menu-next-gen > div:first-child {\n height: 24px;\n border-top-color: transparent;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-bottom-color: #7F7F7F;\n border-bottom-style: solid;\n border-bottom-width: thin;\n background-color: #eee;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n}\n.igv-roi-menu-next-gen > div:first-child > div {\n margin-right: 4px;\n height: 12px;\n width: 12px;\n color: #7F7F7F;\n}\n.igv-roi-menu-next-gen > div:first-child > div:hover {\n cursor: pointer;\n color: #444;\n}\n.igv-roi-menu-next-gen > div:last-child {\n background-color: white;\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n border-bottom-color: transparent;\n border-bottom-style: solid;\n border-bottom-width: 0;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n text-align: start;\n vertical-align: middle;\n cursor: pointer;\n}\n.igv-roi-menu-next-gen > div:last-child > div {\n height: 24px;\n padding-left: 4px;\n border-bottom-style: solid;\n border-bottom-width: thin;\n border-bottom-color: #7f7f7f;\n}\n.igv-roi-menu-next-gen > div:last-child > div:not(:first-child):hover {\n background-color: rgba(127, 127, 127, 0.1);\n}\n.igv-roi-menu-next-gen > div:last-child div:first-child {\n cursor: default;\n font-style: italic;\n text-align: center;\n padding-right: 4px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.igv-roi-menu-next-gen > div:last-child > div:last-child {\n border-bottom-width: 0;\n border-bottom-color: transparent;\n}\n\n.igv-roi-placeholder {\n font-style: normal;\n color: rgba(75, 75, 75, 0.6);\n}\n\n.igv-roi-table {\n position: absolute;\n z-index: 1024;\n width: fit-content;\n border-color: #7f7f7f;\n border-radius: 4px;\n border-style: solid;\n border-width: thin;\n font-family: "Open Sans", sans-serif;\n font-size: 12px;\n font-weight: 400;\n background-color: white;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n}\n.igv-roi-table > div {\n height: 24px;\n font-size: 14px;\n text-align: start;\n vertical-align: middle;\n line-height: 24px;\n}\n.igv-roi-table > div:first-child {\n border-color: transparent;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-top-width: 0;\n border-bottom-color: #7f7f7f;\n border-bottom-style: solid;\n border-bottom-width: thin;\n background-color: #eee;\n cursor: move;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n}\n.igv-roi-table > div:first-child > div:first-child {\n text-align: center;\n width: calc(100% - 4px - 12px);\n}\n.igv-roi-table > div:first-child > div:last-child {\n margin-right: 4px;\n margin-bottom: 2px;\n height: 12px;\n width: 12px;\n color: #7f7f7f;\n}\n.igv-roi-table > div:first-child > div:last-child > svg {\n display: block;\n}\n.igv-roi-table > div:first-child > div:last-child:hover {\n cursor: pointer;\n color: #444;\n}\n.igv-roi-table > .igv-roi-table-column-titles {\n height: 24px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: stretch;\n align-items: stretch;\n padding-right: 16px;\n background-color: white;\n border-bottom-color: #7f7f7f;\n border-bottom-style: solid;\n border-bottom-width: thin;\n}\n.igv-roi-table > .igv-roi-table-column-titles > div {\n font-size: 14px;\n vertical-align: middle;\n line-height: 24px;\n text-align: center;\n margin-left: 4px;\n margin-right: 4px;\n height: 24px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.igv-roi-table > .igv-roi-table-column-titles > div:nth-child(1) {\n width: 20%;\n}\n.igv-roi-table > .igv-roi-table-column-titles > div:nth-child(2) {\n width: 15%;\n}\n.igv-roi-table > .igv-roi-table-column-titles > div:nth-child(3) {\n width: 15%;\n}\n.igv-roi-table > .igv-roi-table-column-titles > div:nth-child(4) {\n width: 30%;\n}\n.igv-roi-table > .igv-roi-table-column-titles > div:nth-child(5) {\n width: 20%;\n}\n.igv-roi-table > .igv-roi-table-row-container {\n resize: both;\n overflow: scroll;\n min-width: 512px;\n min-height: 72px;\n height: 144px;\n max-height: 480px;\n background-color: white;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n}\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row {\n height: 24px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: stretch;\n align-items: stretch;\n}\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row > div {\n font-size: 14px;\n vertical-align: middle;\n line-height: 24px;\n text-align: center;\n margin-left: 4px;\n margin-right: 4px;\n height: 24px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row > div:nth-child(1) {\n width: 20%;\n}\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row > div:nth-child(2) {\n width: 15%;\n}\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row > div:nth-child(3) {\n width: 15%;\n}\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row > div:nth-child(4) {\n width: 30%;\n}\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row > div:nth-child(5) {\n width: 20%;\n}\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row-hover {\n background-color: rgba(0, 0, 0, 0.04);\n}\n.igv-roi-table > div:last-child {\n height: 32px;\n line-height: 32px;\n border-top-color: #7f7f7f;\n border-top-style: solid;\n border-top-width: thin;\n border-bottom-color: transparent;\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n border-bottom-width: 0;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n\n.igv-roi-table-four-column {\n position: absolute;\n z-index: 1024;\n width: fit-content;\n border-color: #7f7f7f;\n border-radius: 4px;\n border-style: solid;\n border-width: thin;\n font-family: "Open Sans", sans-serif;\n font-size: 12px;\n font-weight: 400;\n background-color: white;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n}\n.igv-roi-table-four-column > div {\n height: 24px;\n font-size: 14px;\n text-align: start;\n vertical-align: middle;\n line-height: 24px;\n}\n.igv-roi-table-four-column > div:first-child {\n border-color: transparent;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-top-width: 0;\n border-bottom-color: #7f7f7f;\n border-bottom-style: solid;\n border-bottom-width: thin;\n background-color: #eee;\n cursor: move;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n}\n.igv-roi-table-four-column > div:first-child > div:first-child {\n text-align: center;\n width: calc(100% - 4px - 12px);\n}\n.igv-roi-table-four-column > div:first-child > div:last-child {\n margin-right: 4px;\n margin-bottom: 2px;\n height: 12px;\n width: 12px;\n color: #7f7f7f;\n}\n.igv-roi-table-four-column > div:first-child > div:last-child > svg {\n display: block;\n}\n.igv-roi-table-four-column > div:first-child > div:last-child:hover {\n cursor: pointer;\n color: #444;\n}\n.igv-roi-table-four-column > .igv-roi-table-column-titles {\n height: 24px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: stretch;\n align-items: stretch;\n padding-right: 16px;\n background-color: white;\n border-bottom-color: #7f7f7f;\n border-bottom-style: solid;\n border-bottom-width: thin;\n}\n.igv-roi-table-four-column > .igv-roi-table-column-titles > div {\n font-size: 14px;\n vertical-align: middle;\n line-height: 24px;\n text-align: center;\n margin-left: 4px;\n margin-right: 4px;\n height: 24px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.igv-roi-table-four-column > .igv-roi-table-column-titles > div:nth-child(1) {\n width: 25%;\n}\n.igv-roi-table-four-column > .igv-roi-table-column-titles > div:nth-child(2) {\n width: 20%;\n}\n.igv-roi-table-four-column > .igv-roi-table-column-titles > div:nth-child(3) {\n width: 20%;\n}\n.igv-roi-table-four-column > .igv-roi-table-column-titles > div:nth-child(4) {\n width: 35%;\n}\n.igv-roi-table-four-column > .igv-roi-table-row-container {\n resize: both;\n overflow: scroll;\n min-width: 512px;\n min-height: 72px;\n height: 144px;\n max-height: 480px;\n background-color: white;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n}\n.igv-roi-table-four-column > .igv-roi-table-row-container > .igv-roi-table-row {\n height: 24px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: stretch;\n align-items: stretch;\n}\n.igv-roi-table-four-column > .igv-roi-table-row-container > .igv-roi-table-row > div {\n font-size: 14px;\n vertical-align: middle;\n line-height: 24px;\n text-align: center;\n margin-left: 4px;\n margin-right: 4px;\n height: 24px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.igv-roi-table-four-column > .igv-roi-table-row-container > .igv-roi-table-row > div:nth-child(1) {\n width: 25%;\n}\n.igv-roi-table-four-column > .igv-roi-table-row-container > .igv-roi-table-row > div:nth-child(2) {\n width: 20%;\n}\n.igv-roi-table-four-column > .igv-roi-table-row-container > .igv-roi-table-row > div:nth-child(3) {\n width: 20%;\n}\n.igv-roi-table-four-column > .igv-roi-table-row-container > .igv-roi-table-row > div:nth-child(4) {\n width: 35%;\n}\n.igv-roi-table-four-column > .igv-roi-table-row-container > .igv-roi-table-row-hover {\n background-color: rgba(0, 0, 0, 0.04);\n}\n.igv-roi-table-four-column > div:last-child {\n height: 32px;\n line-height: 32px;\n border-top-color: #7f7f7f;\n border-top-style: solid;\n border-top-width: thin;\n border-bottom-color: transparent;\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n border-bottom-width: 0;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n\n.igv-roi-table-row-selected {\n background-color: rgba(0, 0, 0, 0.125);\n}\n\n.igv-roi-table-button {\n height: 20px;\n user-select: none;\n line-height: 20px;\n text-align: center;\n vertical-align: middle;\n font-family: "Open Sans", sans-serif;\n font-size: 13px;\n font-weight: 400;\n color: black;\n padding-left: 6px;\n padding-right: 6px;\n background-color: rgb(239, 239, 239);\n border-color: black;\n border-style: solid;\n border-width: thin;\n border-radius: 3px;\n}\n\n.igv-roi-table-button:hover {\n cursor: pointer;\n font-weight: 400;\n background-color: rgba(0, 0, 0, 0.13);\n}\n\n.igv-roi-region {\n z-index: 64;\n position: absolute;\n top: 0;\n bottom: 0;\n pointer-events: none;\n overflow: visible;\n margin-top: 44px;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n}\n.igv-roi-region > div {\n position: relative;\n width: 100%;\n height: 8px;\n cursor: pointer;\n pointer-events: auto;\n}\n\n.igv-roi-menu {\n position: absolute;\n z-index: 1024;\n width: 144px;\n border-color: #7f7f7f;\n border-radius: 4px;\n border-style: solid;\n border-width: thin;\n font-family: "Open Sans", sans-serif;\n background-color: white;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n}\n.igv-roi-menu > div:not(:last-child) {\n border-bottom-color: rgba(128, 128, 128, 0.5);\n border-bottom-style: solid;\n border-bottom-width: thin;\n}\n.igv-roi-menu > div:first-child {\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-top-color: transparent;\n border-top-style: solid;\n border-top-width: 0;\n}\n.igv-roi-menu > div:last-child {\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n border-bottom-color: transparent;\n border-bottom-style: solid;\n border-bottom-width: 0;\n}\n\n.igv-roi-menu-row {\n height: 24px;\n padding-left: 8px;\n font-size: small;\n text-align: start;\n vertical-align: middle;\n line-height: 24px;\n background-color: white;\n}\n\n.igv-roi-menu-row-edit-description {\n width: -webkit-fill-available;\n font-size: small;\n text-align: start;\n vertical-align: middle;\n background-color: white;\n padding-left: 4px;\n padding-right: 4px;\n padding-bottom: 4px;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: stretch;\n align-items: stretch;\n}\n.igv-roi-menu-row-edit-description > label {\n margin-left: 2px;\n margin-bottom: 0;\n display: block;\n width: -webkit-fill-available;\n}\n.igv-roi-menu-row-edit-description > input {\n display: block;\n margin-left: 2px;\n margin-right: 2px;\n margin-bottom: 1px;\n width: -webkit-fill-available;\n}\n\n.igv-container {\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n padding-top: 4px;\n user-select: none;\n -webkit-user-select: none;\n -ms-user-select: none;\n}\n\n.igv-viewport {\n position: relative;\n margin-top: 5px;\n line-height: 1;\n overflow-x: hidden;\n overflow-y: hidden;\n}\n\n.igv-viewport-content {\n position: relative;\n width: 100%;\n}\n.igv-viewport-content > canvas {\n position: relative;\n display: block;\n}\n\n.igv-column-container {\n position: relative;\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n width: 100%;\n}\n\n.igv-column-shim {\n width: 1px;\n margin-left: 2px;\n margin-right: 2px;\n background-color: #545453;\n}\n\n.igv-column {\n position: relative;\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n box-sizing: border-box;\n height: 100%;\n}\n\n.igv-axis-column {\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n box-sizing: border-box;\n height: 100%;\n width: 50px;\n}\n.igv-axis-column > div {\n margin-top: 5px;\n width: 100%;\n}\n\n.igv-sample-name-column {\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n box-sizing: border-box;\n height: 100%;\n}\n\n.igv-scrollbar-column {\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n box-sizing: border-box;\n height: 100%;\n width: 14px;\n}\n.igv-scrollbar-column > div {\n position: relative;\n margin-top: 5px;\n width: 14px;\n}\n.igv-scrollbar-column > div > div {\n cursor: pointer;\n position: absolute;\n top: 0;\n left: 2px;\n width: 8px;\n border-width: 1px;\n border-style: solid;\n border-color: #c4c4c4;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n}\n.igv-scrollbar-column > div > div:hover {\n background-color: #c4c4c4;\n}\n\n.igv-track-drag-column {\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n box-sizing: border-box;\n height: 100%;\n width: 12px;\n background-color: white;\n}\n.igv-track-drag-column > .igv-track-drag-handle {\n z-index: 512;\n position: relative;\n cursor: pointer;\n margin-top: 5px;\n width: 100%;\n border-style: solid;\n border-width: 0;\n border-top-right-radius: 6px;\n border-bottom-right-radius: 6px;\n background-color: #c4c4c4;\n}\n.igv-track-drag-column .igv-track-drag-handle-hover {\n background-color: #787878;\n}\n.igv-track-drag-column > .igv-track-drag-shim {\n position: relative;\n margin-top: 5px;\n width: 100%;\n border-style: solid;\n border-width: 0;\n}\n\n.igv-gear-menu-column {\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n box-sizing: border-box;\n height: 100%;\n width: 28px;\n}\n.igv-gear-menu-column > div {\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n margin-top: 5px;\n width: 100%;\n background: white;\n}\n.igv-gear-menu-column > div > div {\n position: relative;\n margin-top: 4px;\n width: 16px;\n height: 16px;\n color: #7F7F7F;\n}\n.igv-gear-menu-column > div > div:hover {\n cursor: pointer;\n color: #444;\n}\n\n/*# sourceMappingURL=dom.css.map */\n',document.head.insertBefore(t,document.head.childNodes[document.head.childNodes.length-1])}();var wv={IGVGraphics:ns,MenuUtils:$o,DataRangeDialog:Xo,createTrack:async function(t,e){return await fv.prototype.createTrack.call(e,t)},createBrowser:async function(t,e){void 0===e&&(e={}),Ra.KNOWN_GENOMES||await Ra.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.showROITableButton&&(t.showROITableButton=!1);void 0===t.showROITable&&(t.showROITable=!1);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,l,c;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?(l=s[0],c=decodeURIComponent(s[1]),"file"===l?h=c.split(","):"index"===l?u=c.split(","):"name"===l?f=c.split(","):"genome"!==l||!c.startsWith("https://")&&!c.startsWith("http://")||c.endsWith(".json")?t[l]=c:t.reference={fastaURL:c,indexURL:c+".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&&To.setApiKey(e.apiKey),e.oauthToken&&ko.setToken(e.oauthToken),e.clientId&&!Fe()&&await Pe({clientId:e.clientId,apiKey:e.apiKey,scope:"https://www.googleapis.com/auth/userinfo.profile"});const n=new fv(e,t);return vv.push(n),e.sessionURL?await n.loadSession({url:e.sessionURL}):await n.loadSessionObject(e),n.navbarManager.navbarDidResize(n.$navigation.width()),n},removeBrowser:function(t){t.dispose(),t.root.remove(),vv=vv.filter((e=>e!==t))},removeAllBrowsers:function(){for(let t of vv)t.dispose(),t.root.remove();vv=[]},visibilityChange:async function(){for(let t of vv)await t.visibilityChange()},setGoogleOauthToken:function(t){return ko.setToken(t)},setOauthToken:function(t,e){return ko.setToken(t,e)},oauth:ko,version:La,setApiKey:bv};return wv}));
|
|
71
71
|
//# sourceMappingURL=igv.min.js.map
|