openSNP/snpr

View on GitHub
app/assets/javascripts/dalliance-compiled.js

Summary

Maintainability
A
0 mins
Test Coverage
(function e$$0(u,s,n){function h(g,p){if(!s[g]){if(!u[g]){var x="function"==typeof require&&require;if(!p&&x)return x(g,!0);if(q)return q(g,!0);throw Error("Cannot find module '"+g+"'");}x=s[g]={exports:{}};u[g][0].call(x.exports,function(d){var a=u[g][1][d];return h(a?a:d)},x,x.exports,e$$0,u,s,n)}return s[g].exports}for(var q="function"==typeof require&&require,g=0;g<n.length;g++)h(n[g]);return h})({1:[function(k,u,s){function n(){}function h(b,m,r){var y=new n;y.data=b;y.bai=m;y.bai.fetch(function(b){if(!b)return r(null,
"Couldn't access BAI");var m=new Uint8Array(b),p=g(m,0);if(p!=w)return r(null,"Not a BAI file, magic=0x"+p.toString(16));p=g(m,4);y.indices=[];for(var h=8,E=1E9,e=0;e<p;++e){for(var t=h,l=g(m,h),h=h+4,f=0;f<l;++f){g(m,h);var v=g(m,h+4),h=h+(8+16*v)}for(var f=g(m,h),G=h+=4,D=0;D<f;++D)if(v=d(m,G),G+=8,v){G=v.block;0<v.offset&&(G+=65536);G<E&&(E=G);break}h+=8*f;0<l&&(y.indices[e]=new Uint8Array(b,t,h-t))}y.data.slice(0,E).fetch(function(f){if(!f)return r(null,"Couldn't access BAM");f=a(f,f.byteLength);
f=new Uint8Array(f);var l=g(f,0);if(l!=c)return r(null,"Not a BAM file, magic=0x"+l.toString(16));for(var v=g(f,4),e="",l=0;l<v;++l)e+=String.fromCharCode(f[l+8]);e=g(f,v+8);v+=12;y.chrToIndex={};y.indexToChr=[];for(l=0;l<e;++l){for(var t=g(f,v),b="",D=0;D<t-1;++D)b+=String.fromCharCode(f[v+4+D]);g(f,v+t+4);y.chrToIndex[b]=l;0==b.indexOf("chr")?y.chrToIndex[b.substring(3)]=l:y.chrToIndex["chr"+b]=l;y.indexToChr.push(b);v=v+8+t}if(y.indices)return r(y)})})}function q(){}if("undefined"!==typeof k){k("./spans");
s=k("./bin");var g=s.readInt,z=s.readShort,p=s.readByte,x=s.readFloat;k=k("./lh3utils");var d=k.readVob,a=k.unbgzf,b=k.reg2bins,m=k.Chunk}var c=21840194,w=21578050;k={MULTIPLE_SEGMENTS:1,ALL_SEGMENTS_ALIGN:2,SEGMENT_UNMAPPED:4,NEXT_SEGMENT_UNMAPPED:8,REVERSE_COMPLEMENT:16,NEXT_REVERSE_COMPLEMENT:32,FIRST_SEGMENT:64,LAST_SEGMENT:128,SECONDARY_ALIGNMENT:256,QC_FAIL:512,DUPLICATE:1024,SUPPLEMENTARY:2048};n.prototype.blocksForRange=function(a,c,r){var w=this.indices[a];if(!w)return[];a=b(c,r);for(var y=
[],p=0;p<a.length;++p)y[a[p]]=!0;a=[];for(var h=[],p=g(w,0),k=4,E=0;E<p;++E){var e=g(w,k),t=g(w,k+4),k=k+8;if(y[e])for(var l=0;l<t;++l){var f=d(w,k),v=d(w,k+8);(4681>e?h:a).push(new m(f,v));k+=16}else k+=16*t}p=g(w,k);y=null;c=Math.min(c>>14,p-1);r=Math.min(r>>14,p-1);for(p=c;p<=r;++p)(c=d(w,k+4+8*p))&&(!y||c.block<y.block||c.offset<y.offset)&&(y=c);w=[];if(null!=y)for(p=0;p<h.length;++p)r=h[p],r.maxv.block>=y.block&&r.maxv.offset>=y.offset&&w.push(r);h=w;w=[];for(p=0;p<h.length;++p)w.push(h[p]);
for(p=0;p<a.length;++p)w.push(a[p]);w.sort(function(f,l){var v=f.minv.block-l.minv.block;return 0!=v?v:f.minv.offset-l.minv.offset});a=[];if(0<w.length){h=w[0];for(p=1;p<w.length;++p)r=w[p],r.minv.block==h.maxv.block?h=new m(h.minv,r.maxv):(a.push(h),h=r);a.push(h)}return a};n.prototype.fetch=function(b,c,m,r,d){function w(){if(t>=h.length)return r(e);if(l){var f=new Uint8Array(l);p.readBamRecords(f,h[t].minv.offset,e,c,m,y,d);l=null;++t;return w()}var v=h[t],f=v.minv.block;p.data.slice(f,v.maxv.block+
65536-f).fetch(function(f){l=a(f,v.maxv.block-v.minv.block+1);return w()})}var p=this;d=d||{};var y=this.chrToIndex[b],h;void 0===y?h=[]:(h=this.blocksForRange(y,c,m))||r(null,"Error in index fetch");var e=[],t=0,l;w()};var r="=ACxGxxxTxxxxxxN".split(""),y="MIDNSHP=X???????".split("");n.prototype.readBamRecords=function(b,a,c,m,d,w,h){for(;;){var k=g(b,a),k=a+k+4;if(k>=b.length)return c;var E=new q,e=g(b,a+4),t=g(b,a+8),l=g(b,a+12),f=(l&65280)>>8,v=l&255,l=g(b,a+16),G=(l&4294901760)>>16,D=l&65535,
l=g(b,a+20),M=g(b,a+24),n=g(b,a+28);g(b,a+32);E.segment=this.indexToChr[e];E.flag=G;E.pos=t;E.mq=f;h.light&&(E.seqLength=l);if(!h.light){0<=M&&(E.nextSegment=this.indexToChr[M],E.nextPos=n);f="";for(t=0;t<v-1;++t)f+=String.fromCharCode(b[a+36+t]);E.readName=f;a=a+36+v;v="";for(t=0;t<D;++t)f=g(b,a),v=v+(f>>4)+y[f&15],a+=4;E.cigar=v;D="";v=l+1>>1;for(t=0;t<v;++t)f=b[a+t],D+=r[(f&240)>>4],D+=r[f&15];a+=v;E.seq=D;D="";for(t=0;t<l;++t)D+=String.fromCharCode(b[a+t]+33);a+=l;for(E.quals=D;a<k;){D=String.fromCharCode(b[a],
b[a+1]);v=String.fromCharCode(b[a+2]);if("A"==v)v=String.fromCharCode(b[a+3]),a+=4;else if("i"==v||"I"==v)v=g(b,a+3),a+=7;else if("c"==v||"C"==v)v=b[a+3],a+=4;else if("s"==v||"S"==v)v=z(b,a+3),a+=5;else if("f"==v)v=x(b,a+3),a+=7;else if("Z"==v||"H"==v)for(a+=3,v="";t=b[a++],0!=t;)v+=String.fromCharCode(t);else if("B"==v){v=String.fromCharCode(b[a+3]);t=g(b,a+4);if("i"==v||"I"==v||"f"==v)f=4,G="f"==v?x:g;else if("s"==v||"S"==v)f=2,G=z;else if("c"==v||"C"==v)f=1,G=p;else throw"Unknown array type "+
v;a+=8;v=[];for(M=0;M<t;++M)v.push(G(b,a)),a+=f}else throw"Unknown type "+v;E[D]=v}}if(!m||E.pos<=d&&E.pos+l>=m)void 0!==w&&e!=w||c.push(E);a=k}};"undefined"!==typeof u&&(u.exports={makeBam:h,BAM_MAGIC:c,BAI_MAGIC:w,BamFlags:k})},{"./bin":4,"./lh3utils":22,"./spans":33}],2:[function(k,u,s){function n(a){this.type=a}function h(a,m){this.parser=a;this.sink=m}function q(a,m){this.parser=a;this.sink=m;this.wigState=null}if("undefined"!==typeof k){var g=k("./sourceadapters").registerParserFactory;k=k("./das");
var z=k.DASStylesheet,p=k.DASStyle,x=k.DASGroup}n.prototype.createSession=function(a){return"wig"==this.type?new q(this,a):new h(this,a)};var d=/([^=]+)=(.+)/,a=/\s/;h.prototype.parse=function(b){var m=b.split(a);if(!(3>m.length)){var c=parseInt(m[1])+1;b=parseInt(m[2]);b={segment:m[0],min:c,max:b};3<m.length&&"."!==m[3]&&(b.label=m[3]);4<m.length&&(b.score=parseFloat(m[4]));5<m.length&&(b.orientation=m[5]);if(8<m.length){var d=m[8];BED_COLOR_REGEXP.test(d)&&(b.itemRgb="rgb("+d+")")}if(12<=m.length){var d=
parseInt(m[6]),r=parseInt(m[7]),p=parseInt(m[9]),h=m[10].split(",").map(function(a){return parseInt(a)}),g=m[11].split(",").map(function(a){return parseInt(a)});b.type="transcript";var k=new x;k.id=m[3];k.type="transcript";k.notes=[];b.groups=[k];if(12<m.length){var n=k=m[12];13<m.length&&(n=m[13]);m=new x;m.id=k;m.label=n;m.type="gene";b.groups.push(m)}m=null;for(k=0;k<p;++k)n=g[k]+c,n=new Range(n,n+h[k]),m=m?union(m,n):n;g=m.ranges();for(c=0;c<g.length;++c)p=g[c],h=shallowCopy(b),h.min=p.min(),
h.max=p.max(),this.sink(h);if(r>d&&(d=intersection(m,new Range(d,r))))for(b.type="translation",d=d.ranges(),c=0;c<d.length;++c)p=d[c],h=shallowCopy(b),h.min=p.min(),h.max=p.max(),this.sink(h)}else this.sink(b)}};h.prototype.flush=function(){};q.prototype.parse=function(b){b=b.split(a);if("fixedStep"==b[0]){this.wigState="fixedStep";this.chr=this.pos=this.step=null;for(var m=this.span=1;m<b.length;++m){var c=d.exec(b[m]);c&&("chrom"==c[1]?this.chr=c[2]:"start"==c[1]?this.pos=parseInt(c[2]):"step"==
c[1]?this.step=parseInt(c[2]):"span"==c[1]&&(this.span=parseInt(c[2])))}}else if("variableStep"==b[0])for(this.wigState="variableStep",this.chr=null,m=this.span=1;m<b.length;++m)c=d.exec(b[m]),"chrom"==c[1]?this.chr=c[2]:"span"==c[1]&&(this.span=parseInt(c[2]));else this.wigState?"fixedStep"==this.wigState?1==b.length&&(b=parseFloat(b[0]),b={segment:this.chr,min:this.pos,max:this.pos+this.span-1,score:b},this.pos+=this.step,this.sink(b)):"variableStep"==this.wigState&&2==b.length&&(m=parseInt(b[0]),
b=parseFloat(b[1]),b={segment:this.chr,min:m,max:m+this.span-1,score:b},this.sink(b)):4>b.length||(b={segment:b[0],min:parseInt(b[1])+1,max:parseInt(b[2]),score:parseFloat(b[3])},this.sink(b))};q.prototype.flush=function(){};n.prototype.getStyleSheet=function(a){var m=new z;if("wig"==this.type){var c=new p;c.glyph="HISTOGRAM";c.BGCOLOR="blue";c.HEIGHT=30;m.pushStyle({type:"default"},null,c)}else c=new p,c.glyph="BOX",c.FGCOLOR="black",c.BGCOLOR="blue",c.HEIGHT=8,c.BUMP=!0,c.LABEL=!0,c.ZINDEX=20,m.pushStyle({type:"default"},
null,c),c=new p,c.glyph="BOX",c.FGCOLOR="black",c.BGCOLOR="red",c.HEIGHT=10,c.BUMP=!0,c.ZINDEX=20,m.pushStyle({type:"translation"},null,c),c=new p,c.glyph="BOX",c.FGCOLOR="black",c.BGCOLOR="white",c.HEIGHT=10,c.ZINDEX=10,c.BUMP=!0,c.LABEL=!0,m.pushStyle({type:"transcript"},null,c),c=new p,c.glyph="HISTOGRAM",c.COLOR1="white",c.COLOR2="black",c.HEIGHT=30,m.pushStyle({type:"density"},null,c);return a(m)};g("bed",function(a){return new n(a)});g("wig",function(a){return new n(a)})},{"./das":10,"./sourceadapters":32}],
3:[function(k,u,s){function n(a,e){return a[e]+a[e+1]*R+a[e+2]*B+a[e+3]*Q+a[e+4]*K}function h(){}function q(a,e,t,l){this.bwg=a;this.cirTreeOffset=e;this.cirTreeLength=t;this.isSummary=l}function g(a,e,t){var l=new h;l.data=a;l.name=t;l.data.slice(0,512).salted().fetch(function(f){if(!f)return e(null,"Couldn't fetch file");var v=new Uint8Array(f),a=new Int16Array(f);f=new Int32Array(f);var t=v[0]+R*v[1]+B*v[2]+Q*v[3];t==y?l.type="bigwig":t==F?l.type="bigbed":t==C||t==A?e(null,"Currently don't support big-endian BBI files"):
e(null,"Not a supported format, magic=0x"+t.toString(16));l.version=a[2];l.numZoomLevels=a[3];l.chromTreeOffset=n(v,8);l.unzoomedDataOffset=n(v,16);l.unzoomedIndexOffset=n(v,24);l.fieldCount=a[16];l.definedFieldCount=a[17];l.asOffset=n(v,36);l.totalSummaryOffset=n(v,44);l.uncompressBufSize=f[13];l.extHeaderOffset=n(v,56);l.zoomLevels=[];for(a=0;a<l.numZoomLevels;++a){var t=f[6*a+16],b=n(v,24*a+72),c=n(v,24*a+80);l.zoomLevels.push({reduction:t,dataOffset:b,indexOffset:c})}l.readChromTree(function(){l.getAutoSQL(function(f){l.schema=
f;return e(l)})})})}function z(a,e,t,l,f){this.bbi=a;this.type=e;this.fieldCount=t;this.offset=l;this.field=f}if("undefined"!==typeof k){s=k("./spans");var p=s.Range,x=s.union,d=s.intersection;s=k("./das");var a=s.DASFeature,b=s.DASGroup,m=k("./utils").shallowCopy,c=k("./bin").readInt;k=k("jszlib");var w=k.inflateBuffer,r=k.arrayCopy}var y=2291137574,C=654086024,F=2273964779,A=3958540679,R=256,B=65536,Q=16777216,K=4294967296,L=/^[0-9]+,[0-9]+,[0-9]+/;h.prototype.readChromTree=function(a){var e=this;
this.chromsToIDs={};this.idsToChroms={};this.maxID=0;var t=this.unzoomedDataOffset,t=t+4-(t-this.chromTreeOffset&3);this.data.slice(this.chromTreeOffset,t-this.chromTreeOffset).fetch(function(l){var f=new Uint8Array(l),v=new Int16Array(l),t=(new Int32Array(l))[2];n(f,16);var b=function(l){var a=f[l],c=v[l/2+1];l+=4;for(var m=0;m<c;++m)if(0==a){l+=t;var d=n(f,l);l+=8;d-=e.chromTreeOffset;b(d)}else{for(var d="",r=0;r<t;++r){var w=f[l++];0!=w&&(d+=String.fromCharCode(w))}r=f[l+3]<<24|f[l+2]<<16|f[l+
1]<<8|f[l+0];l+=8;e.chromsToIDs[d]=r;0==d.indexOf("chr")&&(e.chromsToIDs[d.substr(3)]=r);e.idsToChroms[r]=d;e.maxID=Math.max(e.maxID,r)}};b(32);a(e)})};q.prototype.readWigData=function(a,e,t,l){a=this.bwg.chromsToIDs[a];if(void 0===a)return l([]);this.readWigDataById(a,e,t,l)};q.prototype.readWigDataById=function(a,e,t,l){var f=this;if(this.cirHeader){var v=[],b=0;Date.now();var c=function(f,l,v,b){return(0>a||f==a)&&l<=t&&v>=e},m=function(e,a){f.bwg.instrument&&console.log("level="+a+"; offset="+
e+"; time="+(Date.now()|0));b+=e.length;if(1==e.length&&48==e[0]-f.cirTreeOffset&&f.cachedCirRoot)r(f.cachedCirRoot,0,a),--b,0==b&&f.fetchFeatures(c,v,l);else{for(var t=4+32*f.cirBlockSize,m,w=0;w<e.length;++w){var M=new p(e[w],e[w]+t);m=m?x(m,M):M}t=m.ranges();for(m=0;m<t.length;++m)d(e,t[m],a)}},d=function(e,a,t,m){a.max();a.min();f.bwg.data.slice(a.min(),a.max()-a.min()).fetch(function(m){for(var d=0;d<e.length;++d)a.contains(e[d])&&(r(m,e[d]-a.min(),t),48==e[d]-f.cirTreeOffset&&0==e[d]-a.min()&&
(f.cachedCirRoot=m),--b,0==b&&f.fetchFeatures(c,v,l))})},r=function(f,l,b){var c=new Uint8Array(f),d=new Int16Array(f);f=new Int32Array(f);var D=c[l],d=d[l/2+1];l+=4;if(0!=D)for(D=0;D<d;++D){var r=l/4,G=f[r],H=f[r+1],w=f[r+2],r=f[r+3],p=n(c,l+16);b=n(c,l+24);(0>a||G<a||G==a&&H<=t)&&(0>a||w>a||w==a&&r>=e)&&v.push({offset:p,size:b});l+=32}else{for(var y=[],D=0;D<d;++D)r=l/4,G=f[r],H=f[r+1],w=f[r+2],r=f[r+3],p=n(c,l+16),(0>a||G<a||G==a&&H<=t)&&(0>a||w>a||w==a&&r>=e)&&y.push(p),l+=24;0<y.length&&m(y,
b+1)}};m([f.cirTreeOffset+48],1)}else this.bwg.data.slice(this.cirTreeOffset,48).fetch(function(v){f.cirHeader=v;v=new Int32Array(f.cirHeader);f.cirBlockSize=v[1];f.readWigDataById(a,e,t,l)})};q.prototype.fetchFeatures=function(b,e,t){var l=this;e.sort(function(f,l){return(f.offset|0)-(l.offset|0)});if(0==e.length)t([]);else{var f=[],v=function(e,v,t,b){b||(b={});var c=new a;c._chromId=e;c.segment=l.bwg.idsToChroms[e];c.min=v;c.max=t;c.type="bigwig";for(var m in b)c[m]=b[m];f.push(c)},c=function(){if(0==
e.length)Date.now(),t(f);else{var a=e[0];if(a.data)l.parseFeatures(a.data,v,b),e.splice(0,1),c();else{for(var m=a.offset,d=a.size,a=1;a<e.length&&e[a].offset==m+d;)d+=e[a].size,++a;l.bwg.data.slice(m,d).fetch(function(f){for(var v=0,a=0;v<d;){var t=e[a],b;0<l.bwg.uncompressBufSize?b=w(f,v+2,t.size-2):(b=new Uint8Array(t.size),r(new Uint8Array(f,v,t.size),0,b,0,t.size),b=b.buffer);t.data=b;v+=t.size;++a}c()})}}};c()}};q.prototype.parseFeatures=function(a,e,t){var l=new Uint8Array(a);if(this.isSummary)for(var f=
new Int16Array(a),v=new Int32Array(a),c=new Float32Array(a),l=a.byteLength/32,f=0;f<l;++f){a=v[8*f];var r=v[8*f+1],w=v[8*f+2],y=v[8*f+3],H=c[8*f+5],h=c[8*f+6];t(a,r+1,w)&&(y={type:"bigwig",score:h/y,maxScore:H},"bigbed"==this.bwg.type&&(y.type="density"),e(a,r+1,w,y))}else if("bigwig"==this.bwg.type)if(f=new Int16Array(a),v=new Int32Array(a),c=new Float32Array(a),a=v[0],r=v[1],H=v[3],y=v[4],w=l[20],l=f[11],3==w)for(f=0;f<l;++f)h=c[f+6],v=r+f*H+1,w=r+f*H+y,t(a,v,w)&&e(a,v,w,{score:h});else if(2==w)for(f=
0;f<l;++f)r=v[2*f+6]+1,w=r+y-1,h=c[2*f+7],t(a,r,w)&&e(a,r,w,{score:h});else if(1==w)for(f=0;f<l;++f)r=v[3*f+6]+1,w=v[3*f+7],h=c[3*f+8],r>w&&(r=w),t(a,r,w)&&e(a,r,w,{score:h});else console.log("Currently not handling bwgType="+w);else if("bigbed"==this.bwg.type)for(v=0,f=this.bwg.definedFieldCount,y=this.bwg.schema;v<l.length;){a=l[v+3]<<24|l[v+2]<<16|l[v+1]<<8|l[v+0];r=l[v+7]<<24|l[v+6]<<16|l[v+5]<<8|l[v+4];w=l[v+11]<<24|l[v+10]<<16|l[v+9]<<8|l[v+8];v+=12;for(h="";;)if(H=l[v++],0!=H)h+=String.fromCharCode(H);
else break;var H={},g;g=0<h.length?h.split("\t"):[];0<g.length&&3<f&&(H.label=g[0]);1<g.length&&4<f&&(h=parseInt(g[1]),isNaN(h)||(H.score=h));2<g.length&&5<f&&(H.orientation=g[2]);5<g.length&&8<f&&(h=g[5],L.test(h)&&(H.itemRgb="rgb("+h+")"));if(g.length>f-3&&y)for(h=f-3;h<g.length;++h)H[y.fields[h+3].name]=g[h];if(t(a,r+1,w,g))if(12>f)e(a,r+1,w,H);else{var h=g[3]|0,k=g[4]|0,A=g[6]|0,n=g[7].split(","),K=g[8].split(",");H.type="transcript";var C=new b;for(c in H)C[c]=H[c];C.id=g[0];C.segment=this.bwg.idsToChroms[a];
C.min=r+1;C.max=w;C.notes=[];H.groups=[C];if(9<g.length){var B=w=g[9];10<g.length&&(B=g[10]);g=m(C);g.id=w;g.label=B;g.type="gene";H.groups.push(g)}w=[];for(g=0;g<A;++g)C=(K[g]|0)+r,C=new p(C,C+(n[g]|0)),w.push(C);A=x(w);n=A.ranges();for(r=0;r<n.length;++r)w=n[r],e(a,w.min()+1,w.max(),H);if(k>h&&(r=d(A,new p(h,k))))for(H.type="translation",h=r.ranges(),r=0;r<h.length;++r)w=h[r],e(a,w.min()+1,w.max(),H)}}else throw Error("Don't know what to do with "+this.bwg.type);};q.prototype.getFirstAdjacent=function(a,
e,t,l){a=this.bwg.chromsToIDs[a];if(void 0===a)return l([]);this.getFirstAdjacentById(a,e,t,l)};q.prototype.getFirstAdjacentById=function(a,e,t,l){var f=this;if(this.cirHeader){var v=null,b=-1,c=-1,r=0;Date.now();var m=function(l,v){r+=l.length;for(var e=4+32*f.cirBlockSize,a,t=0;t<l.length;++t){var b=new p(l[t],l[t]+e);a=a?x(a,b):b}e=a.ranges();for(a=0;a<e.length;++a)d(l,e[a],v)},d=function(b,c,m,d){c.max();c.min();f.bwg.data.slice(c.min(),c.max()-c.min()).fetch(function(d){for(var D=0;D<b.length;++D)if(c.contains(b[D])&&
(w(d,b[D]-c.min(),m),--r,0==r)){if(!v)return 0<t&&(0!=a||0<e)?f.getFirstAdjacentById(0,0,t,l):0>t&&(a!=f.bwg.maxID||1E9>e)?f.getFirstAdjacentById(f.bwg.maxID,1E9,t,l):l([]);f.fetchFeatures(function(f,l,v,b){return 0>t&&(f<a||v<e)||0<t&&(f>a||l>e)},[v],function(f){for(var v=null,e=-1,a=-1,b=0;b<f.length;++b){var c=f[b],r=c._chromId,m=c.min,d=c.max;if(null==v||0>t&&(r>e||d>a)||0<t&&(r<e||m<a))v=c,a=0>t?d:m,e=r}return null!=v?l([v]):l([])})}})},w=function(l,r,d){var w=new Uint8Array(l),H=new Int16Array(l);
l=new Int32Array(l);var h=w[r],H=H[r/2+1];r+=4;if(0!=h)for(h=0;h<H;++h){var p=r/4,U=l[p],y=l[p+1],g=l[p+2],M=l[p+3],p=n(w,r+16);d=n(w,r+24);(0>t&&(U<a||U==a&&y<=e)||0<t&&(g>a||g==a&&M>=e))&&!/_random/.exec(f.bwg.idsToChroms[U])&&(null==v||0>t&&(g>b||g==b&&M>c)||0<t&&(U<b||U==b&&y<c))&&(v={offset:p,size:d},c=0>t?M:y,b=0>t?g:U);r+=32}else{for(var k=w=-1,h=0;h<H;++h){p=r/4;U=l[p];y=l[p+1];g=l[p+2];M=l[p+3];p=l[p+4]<<32|l[p+5];if(0>t&&(U<a||U==a&&y<=e)&&g>=a||0<t&&(g>a||g==a&&M>=e)&&U<=a)if(0>w||M>k)w=
p,k=0>t?M:y;r+=24}0<=w&&m([w],d+1)}};m([f.cirTreeOffset+48],1)}else this.bwg.data.slice(this.cirTreeOffset,48).fetch(function(v){f.cirHeader=v;v=new Int32Array(f.cirHeader);f.cirBlockSize=v[1];f.getFirstAdjacentById(a,e,t,l)})};h.prototype.readWigData=function(a,e,t,l){this.getUnzoomedView().readWigData(a,e,t,l)};h.prototype.getUnzoomedView=function(){if(!this.unzoomedView){var a=4E3;this.zoomLevels[0]&&(a=this.zoomLevels[0].dataOffset-this.unzoomedIndexOffset);this.unzoomedView=new q(this,this.unzoomedIndexOffset,
a,!1)}return this.unzoomedView};h.prototype.getZoomedView=function(a){a=this.zoomLevels[a];a.view||(a.view=new q(this,a.indexOffset,4E3,!0));return a.view};h.prototype._tsFetch=function(a,e,t,l,f){var v=this;if(a>=this.zoomLevels.length-1){if(this.topLevelReductionCache){for(var b=[],c=this.topLevelReductionCache,r=0;r<c.length;++r)c[r]._chromId==e&&b.push(c[r]);return f(b)}this.getZoomedView(this.zoomLevels.length-1).readWigDataById(-1,0,3E8,function(b){v.topLevelReductionCache=b;return v._tsFetch(a,
e,t,l,f)})}else return(0>a?this.getUnzoomedView():this.getZoomedView(a)).readWigDataById(e,t,l,f)};h.prototype.thresholdSearch=function(a,e,t,l,f){function v(){if(0==c.length)return f(null);c.sort(function(f,l){var a=f.zoom-l.zoom;if(0!=a)return a;a=f.chrOrd-l.chrOrd;return 0!=a?a:f.min-l.min*t});var a=c.splice(0,1)[0];b._tsFetch(a.zoom,a.chr,a.min,a.max,function(b){var r=0<t?0:3E8;a.fromRef&&(r=e);for(var m=0;m<b.length;++m){var d=b[m],w;w=void 0!=d.maxScore?d.maxScore:d.score;if(0<t){if(w>l)if(0>
a.zoom){if(d.min>r)return f(d)}else d.max>r&&c.push({chr:a.chr,chrOrd:a.chrOrd,zoom:a.zoom-2,min:d.min,max:d.max,fromRef:a.fromRef})}else if(w>l)if(0>a.zoom){if(d.max<r)return f(d)}else d.min<r&&c.push({chr:a.chr,chrOrd:a.chrOrd,zoom:a.zoom-2,min:d.min,max:d.max,fromRef:a.fromRef})}v()})}t=0>t?-1:1;var b=this;a=this.chromsToIDs[a];for(var c=[{chrOrd:0,chr:a,zoom:b.zoomLevels.length-4,min:0,max:3E8,fromRef:!0}],r=1;r<=this.maxID+1;++r){var m=(a+t*r)%(this.maxID+1);0>m&&(m+=this.maxID+1);c.push({chrOrd:r,
chr:m,zoom:b.zoomLevels.length-1,min:0,max:3E8})}v()};h.prototype.getAutoSQL=function(a){if(!this.asOffset)return a(null);this.data.slice(this.asOffset,2048).fetch(function(e){var t=new Uint8Array(e);e="";for(var l=0;l<t.length&&0!=t[l];++l)e+=String.fromCharCode(t[l]);var t=/([\w\[\]]+)\s+(\w+)\s*;\s*("([^"]+)")?\s*/g,f=/(\w+)\s+(\w+)\s+("([^"]+)")?\s+\(\s*/.exec(e);if(f){l={declType:f[1],name:f[2],comment:f[4],fields:[]};e=e.substring(f[0]);for(f=t.exec(e);null!=f;f=t.exec(e))l.fields.push({type:f[1],
name:f[2],comment:f[4]});return a(l)}})};h.prototype.getExtraIndices=function(a){var e=this;if(4>this.version||0==this.extHeaderOffset||"bigbed"!=this.type)return a(null);this.data.slice(this.extHeaderOffset,64).fetch(function(t){if(!t)return a(null,"Couldn't fetch extension header");var l=new Uint8Array(t),f=new Int16Array(t);new Int32Array(t);var v=f[1];t=n(l,4);if(0==v)return a(null);e.data.slice(t,20*v).fetch(function(f){if(!f)return a(null,"Couldn't fetch index info");var l=new Uint8Array(f),
t=new Int16Array(f);new Int32Array(f);f=[];for(var b=0;b<v;++b){var c=t[10*b],r=t[10*b+1],m=n(l,20*b+4),c=new z(e,c,r,m,t[10*b+8]);f.push(c)}a(f)})})};z.prototype.lookup=function(a,e){var t=this;this.bbi.data.slice(this.offset,32).fetch(function(l){function f(l){t.bbi.data.slice(l,4+b*(r+m)).fetch(function(l){var v=new Uint8Array(l),b=new Uint16Array(l);new Uint32Array(l);b=b[1];l=4;if(0==v[0]){for(var d=null,w=0;w<b;++w){for(var p="",h=0;h<r;++h){var G=v[l++];0!=G&&(p+=String.fromCharCode(G))}h=
n(v,l);l+=8;if(0>a.localeCompare(p)&&d){f(d);return}d=h}f(d)}else{for(w=0;w<b;++w){p="";for(h=0;h<r;++h)G=v[l++],0!=G&&(p+=String.fromCharCode(G));if(p==a)return b=n(v,l),v=c(v,l+8),t.bbi.getUnzoomedView().fetchFeatures(function(f,l,v,e){if(e&&e.length>t.field-3)return e[t.field-3]==a},[{offset:b,size:v}],e);l+=m}return e([])}})}var v=new Uint8Array(l);new Int16Array(l);l=new Int32Array(l);var b=l[1],r=l[2],m=l[3];n(v,16);f(t.offset+32)})};"undefined"!==typeof u&&(u.exports={makeBwg:g,BIG_BED_MAGIC:F,
BIG_WIG_MAGIC:y})},{"./bin":4,"./das":10,"./spans":33,"./utils":45,jszlib:60}],4:[function(k,u,s){function n(a){this.blob=a}function h(a,b,c,m){m||("object"===typeof b?(m=b,b=void 0):m={});this.url=a;this.start=b||0;c&&(this.end=c);this.opts=m}function q(a){if(!a)return null;for(var b=new Uint8Array(a.length),c=0;c<b.length;++c)b[c]=a.charCodeAt(c);return b.buffer}function g(a,b){return a[b+7]<<24|a[b+6]<<16|a[b+5]<<8|a[b+4]}function z(a,b){return a[b+3]<<24|a[b+2]<<16|a[b+1]<<8|a[b]}function p(a,
b){return a[b+1]<<8|a[b]}function x(a,b){return a[b]}function d(a,b){return a[b]<<24|a[b+1]<<16|a[b+2]<<8|a[b+3]}if("undefined"!==typeof k)var a=k("./utils").shallowCopy,b=k("./sha1").b64_sha1;n.prototype.slice=function(a,b){var c;c=this.blob.slice?b?this.blob.slice(a,a+b):this.blob.slice(a):b?this.blob.webkitSlice(a,a+b):this.blob.webkitSlice(a);return new n(c)};n.prototype.salted=function(){return this};n.prototype.fetch="undefined"!==typeof FileReader?function(a){var b=new FileReader;b.onloadend=
function(c){a(q(b.result))};b.readAsBinaryString(this.blob)}:function(a){var b=new FileReaderSync;try{var c=b.readAsArrayBuffer(this.blob);a(c)}catch(m){a(null,m)}};h.prototype.slice=function(a,b){if(0>a)throw"Bad slice "+a;var c=this.start,m=this.end,c=c&&a?c+a:a||c;return new h(this.url,c,b&&c?c+b-1:m||b-1,this.opts)};var m=0,c=0<=navigator.userAgent.indexOf("Safari")&&0>navigator.userAgent.indexOf("Chrome");h.prototype.fetchAsText=function(a){var d=new XMLHttpRequest,p=this.url;if(c||this.opts.salt)p=
saltURL(p),p=p+"?salt="+b(""+Date.now()+","+ ++m);d.open("GET",p,!0);if(this.end){if(1E8<this.end-this.start)throw"Monster fetch!";d.setRequestHeader("Range","bytes="+this.start+"-"+this.end)}d.onreadystatechange=function(){if(4==d.readyState)return 200==d.status||206==d.status?a(d.responseText):a(null)};this.opts.credentials&&(d.withCredentials=!0);d.send("")};h.prototype.salted=function(){var b=a(this.opts);b.salt=!0;return new h(this.url,this.start,this.end,b)};h.prototype.fetch=function(a,d,p){var h=
this;d=d||1;if(3<d)return a(null);var g=new XMLHttpRequest,k,n=this.url;if(c||this.opts.salt)n=n+"?salt="+b(""+Date.now()+","+ ++m);g.open("GET",n,!0);g.overrideMimeType("text/plain; charset=x-user-defined");if(this.end){if(1E8<this.end-this.start)throw"Monster fetch!";g.setRequestHeader("Range","bytes="+this.start+"-"+this.end);k=this.end-this.start+1}g.responseType="arraybuffer";g.onreadystatechange=function(){if(4==g.readyState){if(200==g.status||206==g.status){if(g.response){var b=g.response.byteLength;
return!k||k==b||p&&b==p?a(g.response):h.fetch(a,d+1,b)}if(g.mozResponseArrayBuffer)return a(g.mozResponseArrayBuffer);b=g.responseText;return!k||k==b.length||p&&b.length==p?a(q(g.responseText)):h.fetch(a,d+1,b.length)}return h.fetch(a,d+1)}};this.opts.credentials&&(g.withCredentials=!0);g.send("")};(function(a){var b=new ArrayBuffer(8),c=new Uint8Array(b),m=new Float32Array(b);a.readFloat=function(a,b){c[0]=a[b];c[1]=a[b+1];c[2]=a[b+2];c[3]=a[b+3];return m[0]}})(this);"undefined"!==typeof u&&(u.exports=
{BlobFetchable:n,URLFetchable:h,readInt:z,readIntBE:d,readInt64:g,readShort:p,readByte:x,readFloat:this.readFloat})},{"./sha1":31,"./utils":45}],5:[function(k,u,s){if("undefined"!==typeof k){var n=k("./cbrowser").Browser,h=k("./utils").makeElement,q=k("./numformats").formatLongInt;k("./tier-edit");k("./export-config");k("./export-ui");k("./svg-export");k("./session")}n.prototype.initUI=function(g,k){document.head.appendChild(h("link","",{rel:"stylesheet",href:this.resolveURL("$$css/bootstrap-scoped.css")}));
document.head.appendChild(h("link","",{rel:"stylesheet",href:this.resolveURL("$$css/dalliance-scoped.css")}));document.head.appendChild(h("link","",{rel:"stylesheet",href:this.resolveURL("$$css/font-awesome.min.css")}));var p=this;p.disableDefaultFeaturePopup||this.addFeatureListener(function(a,l,f,v){p.featurePopup(a,l,f,v)});g.classList.add("dalliance");var n=p.toolbar=h("div",null,{className:"btn-toolbar toolbar"}),d=p.coordSystem.speciesName+" "+p.nameForCoordSystem(p.coordSystem);this.setDocumentTitle&&
(document.title=d+" :: dalliance");var a=h("input","",{className:"loc-field"});p.makeTooltip(a,"Enter a genomic location or gene name");var b=h("p","",{className:"loc-status"}),m=h("a",[h("i",null,{className:"fa fa-search-plus"})],{className:"btn"}),c=h("input","",{type:"range",min:100,max:250},{className:"zoom-slider"},{width:"150px"}),w=h("a",[h("i",null,{className:"fa fa-search-minus"})],{className:"btn"}),r=h("a",[h("i",null,{className:"fa fa-eraser"})],{className:"btn"}),y=h("a",[h("i",null,
{className:"fa fa-plus"})],{className:"btn"}),C=h("a",[h("i",null,{className:"fa fa-bookmark"})],{className:"btn"}),F=h("a",[h("i",null,{className:"fa fa-print"})],{className:"btn"});h("a",[h("i",null,{className:"fa fa-refresh"})],{className:"btn"});var A=h("a",[h("i",null,{className:"fa fa-cogs"})],{className:"btn"}),s=h("a",[h("i",null,{className:"fa fa-question"})],{className:"btn"}),B=h("a",[h("i",null,{className:"fa fa-road"})],{className:"btn"});p.makeTooltip(B,"Configure currently selected track(s) (E)");
var Q=h("a",[h("i",null,{className:"fa fa-angle-left"})],{className:"btn"},{width:"5px"}),K=h("a",[h("i",null,{className:"fa fa-angle-right"})],{className:"btn pull-right"},{width:"5px"}),L=h("div",null,{className:"btn-group pull-right"});this.noTrackAdder||L.appendChild(y);this.noTrackEditor||L.appendChild(B);this.noExport||L.appendChild(F);this.noOptions||L.appendChild(A);this.noHelp||L.appendChild(s);this.setUiMode=function(a){this.uiMode=a;var l={help:s,add:y,opts:A,"export":F,tier:B},f;for(f in l)f==
a?l[f].classList.add("active"):l[f].classList.remove("active")};this.noLeapButtons||n.appendChild(K);L.firstChild&&n.appendChild(L);this.noLeapButtons||n.appendChild(Q);this.noTitle||n.appendChild(h("div",h("h4",d,{},{margin:"0px"}),{className:"btn-group title"}));this.noLocationField||n.appendChild(h("div",[a,b],{className:"btn-group loc-group"}));this.noClearHighlightsButton||n.appendChild(r);this.noZoomSlider||n.appendChild(h("div",[m,h("span",c,{className:"btn"}),w],{className:"btn-group"}));
g.appendChild(n);g.appendChild(k);this.addViewListener(function(e,l,f,v,b){a.value=e+":"+q(l)+".."+q(f);c.min=b.min|0;c.max=b.max|0;c.value=b.current|0;p.storeStatus&&p.storeViewStatus();r.style.display=0<p.highlights.length?"inline-block":"none"});this.addTierListener(function(){p.storeStatus&&p.storeTierStatus()});a.addEventListener("keydown",function(e){40==e.keyCode&&(e.preventDefault(),e.stopPropagation(),p.setSelectedTier(0));if(10==e.keyCode||13==e.keyCode)e.preventDefault(),p.search(a.value,
function(l){b.textContent=l?""+l:""})},!1);var E;y.addEventListener("click",function(a){E&&E.displayed?p.removeAllPopups():E=p.showTrackAdder(a)},!1);p.makeTooltip(y,"Add a new track from the registry or an indexed file. (A)");m.addEventListener("click",function(a){a.stopPropagation();a.preventDefault();p.zoomStep(-10)},!1);p.makeTooltip(m,"Zoom in (+)");w.addEventListener("click",function(a){a.stopPropagation();a.preventDefault();p.zoomStep(10)},!1);p.makeTooltip(w,"Zoom out (-)");c.addEventListener("change",
function(a){p.zoomSliderValue=1*c.value;p.zoom(Math.exp(1*c.value/p.zoomExpt))},!1);C.addEventListener("click",function(a){a.stopPropagation();a.preventDefault()},!1);p.makeTooltip(C,"Favourite regions");F.addEventListener("click",function(a){a.stopPropagation();a.preventDefault();p.openExportPanel()},!1);p.makeTooltip(F,"Export publication-quality SVG. (X)");A.addEventListener("click",function(a){a.stopPropagation();a.preventDefault();p.toggleOptsPopup(a)},!1);p.makeTooltip(A,"Configure options.");
s.addEventListener("click",function(a){a.stopPropagation();a.preventDefault();p.toggleHelpPopup(a)});p.makeTooltip(s,"Help; Keyboard shortcuts. (H)");B.addEventListener("click",function(a){a.stopPropagation();a.preventDefault();1==p.selectedTiers.length&&p.openTierPanel(p.tiers[p.selectedTiers[0]])},!1);Q.addEventListener("click",function(a){p.leap(p.reverseKeyScrolling?-1:1,!1)},!1);p.makeTooltip(Q,function(a){a=p.getSelectedTier();var l;0<=a&&(l=p.tiers[a]);return l&&l.featureSource&&p.sourceAdapterIsCapable(l.featureSource,
"quantLeap")&&"number"==typeof l.quantLeapThreshold?'Jump to the next region with a score above the threshold in the selected track "'+(l.config.name||l.dasSource.name)+'"" (ctrl+LEFT)':l&&l.featureSource&&p.sourceAdapterIsCapable(l.featureSource,"leap")?'Jump to the next feature in the selected track "'+(l.config.name||l.dasSource.name)+'" (ctrl+LEFT)':"Jump left (shift+LEFT)"});K.addEventListener("click",function(a){p.leap(p.reverseKeyScrolling?1:-1,!1)},!1);p.makeTooltip(K,function(a){a=p.getSelectedTier();
var l;0<=a&&(l=p.tiers[a]);return l&&l.featureSource&&p.sourceAdapterIsCapable(l.featureSource,"quantLeap")&&"number"==typeof l.quantLeapThreshold?'Jump to the next region with a score above the threshold in the selected track "'+(l.config.name||l.dasSource.name)+'"" (ctrl+RIGHT)':l&&l.featureSource&&p.sourceAdapterIsCapable(l.featureSource,"leap")?'Jump to the next feature in the selected track "'+(l.config.name||l.dasSource.name)+'" (ctrl+RIGHT)':"Jump right (shift+RIGHT)"});p.addTierSelectionListener(function(){var a=
p.getSelectedTier(),l;0<=a&&(l=p.tiers[a]);a=!1;l&&l.featureSource&&(p.sourceAdapterIsCapable(l.featureSource,"quantLeap")&&"number"==typeof l.quantLeapThreshold?a=!0:p.sourceAdapterIsCapable(l.featureSource,"leap")&&(a=!0));Q.firstChild.className=a?"fa fa-angle-double-left":"fa fa-angle-left";K.firstChild.className=a?"fa fa-angle-double-right":"fa fa-angle-right"});r.addEventListener("click",function(a){p.clearHighlights()},!1);p.makeTooltip(r,"Clear highlights (C)");p.addTierSelectionWrapListener(function(e){0>
e&&(p.setSelectedTier(null),a.focus())});p.addTierSelectionListener(function(a){"tier"===p.uiMode&&(0==a.length?(p.hideToolPanel(),p.manipulatingTier=null,p.uiMode="none"):(a=p.tiers[a[0]],a!=p.manipulatingTier&&p.openTierPanel(a)))});var e=function(a){if(65==a.keyCode||97==a.keyCode)a.preventDefault(),a.stopPropagation(),p.showTrackAdder();else if(72==a.keyCode||104==a.keyCode)a.stopPropagation(),a.preventDefault(),p.toggleHelpPopup(a);else if(69==a.keyCode||101==a.keyCode)a.stopPropagation(),a.preventDefault(),
1==p.selectedTiers.length&&p.openTierPanel(p.tiers[p.selectedTiers[0]]);else if(88==a.keyCode||120==a.keyCode)a.stopPropagation(),a.preventDefault(),p.openExportPanel();else if(67==a.keyCode||99==a.keyCode)a.stopPropagation(),a.preventDefault(),p.clearHighlights()};g.addEventListener("focus",function(a){g.addEventListener("keydown",e,!1)},!1);g.addEventListener("blur",function(a){g.removeEventListener("keydown",e,!1)},!1);g.addEventListener("keydown",function(a){27===a.keyCode&&(a.preventDefault(),
a.stopPropagation(),p.uiMode="none",p.hideToolPanel(),p.selectedTiers&&0<p.selectedTiers.length&&p.browserHolder.focus())},!1)};n.prototype.showToolPanel=function(g,k){var p=this;this.activeToolPanel&&this.activeToolPanel.parentElement.removeChild(this.activeToolPanel);var n;n=k?g:h("div",g,{},{overflowY:"auto",width:"100%"});var d=h("div",h("i",null,{className:"fa fa-caret-right"}),{className:"tool-divider"});d.addEventListener("click",function(a){p.hideToolPanel();p.setUiMode("none")},!1);this.makeTooltip(d,
"Close tool panel (ESC)");this.activeToolPanel=h("div",[d,n],{className:"tool-holder"});this.svgHolder.appendChild(this.activeToolPanel);this.resizeViewer();p=this};n.prototype.hideToolPanel=function(){this.activeToolPanel&&this.activeToolPanel.parentElement.removeChild(this.activeToolPanel);this.svgHolder.style.width="100%";this.activeToolPanel=null;this.resizeViewer()};n.prototype.toggleHelpPopup=function(g){"help"===this.uiMode?(this.hideToolPanel(),this.setUiMode("none")):(g=h("iframe",null,{scrolling:"yes",
seamless:"seamless",src:this.resolveURL("$$help/index.html"),className:"help-panel"}),this.showToolPanel(g,!1),this.setUiMode("help"))};n.prototype.toggleOptsPopup=function(g){var k=this;if("opts"===this.uiMode)this.hideToolPanel(),this.setUiMode("none");else{g=h("div",null,{className:"form-horizontal"},{boxSizing:"border-box",MozBoxSizing:"border-box",display:"inline-block",verticalAlign:"top"});var p=h("table");p.cellPadding=5;var n=h("input","",{type:"checkbox",checked:k.reverseScrolling});n.addEventListener("change",
function(a){k.reverseScrolling=n.checked;k.storeStatus()},!1);p.appendChild(h("tr",[h("td","Reverse trackpad scrolling",{align:"right"}),h("td",n)]));var d=h("input","",{type:"checkbox",checked:k.reverseKeyScrolling});d.addEventListener("change",function(a){k.reverseKeyScrolling=d.checked;k.storeStatus()},!1);p.appendChild(h("tr",[h("td","Reverse scrolling buttons and keys",{align:"right"}),h("td",d)]));var a=h("select");a.appendChild(h("option","Left",{value:"left"}));a.appendChild(h("option","Center",
{value:"center"}));a.appendChild(h("option","Right",{value:"right"}));a.appendChild(h("option","None",{value:"none"}));a.value=k.rulerLocation;a.addEventListener("change",function(b){k.rulerLocation=a.value;k.positionRuler();for(b=0;b<k.tiers.length;++b)k.tiers[b].paintQuant();k.storeStatus()},!1);p.appendChild(h("tr",[h("td","Vertical guideline",{align:"right"}),h("td",a)]));g.appendChild(p);p=h("button","Reset browser",{className:"btn"},{marginLeft:"auto",marginRight:"auto",display:"block"});p.addEventListener("click",
function(a){k.reset()},!1);g.appendChild(p);this.showToolPanel(g);this.setUiMode("opts")}}},{"./cbrowser":6,"./export-config":13,"./export-ui":14,"./numformats":24,"./session":30,"./svg-export":34,"./tier-edit":40,"./utils":45}],6:[function(k,u,s){function n(l,f,a){this.min=f;this.max=a;this.chr=l}function h(l){l||(l={});this.prefix="//www.biodalliance.org/release-0.12/";this.sources=[];this.tiers=[];this.featureListeners=[];this.featureHoverListeners=[];this.viewListeners=[];this.regionSelectListeners=
[];this.tierListeners=[];this.tierSelectionListeners=[];this.tierSelectionWrapListeners=[];this.cookieKey="browser";this.registry="https://www.dasregistry.org/das/sources";this.chains={};this.pageName="svgHolder";this.maxExtra=2.5;this.minExtra=0.5;this.zoomFactor=1;this.zoomMin=10;this.origin=0;this.targetQuantRes=1;this.featurePanelWidth=750;this.zoomBase=100;this.zoomExpt=30;this.zoomSliderValue=100;this.entryPoints=null;this.currentSeqMax=-1;this.highlights=[];this.selectedTiers=[1];this.maxViewWidth=
5E5;this.reverseScrolling=!1;this.rulerLocation="center";this.defaultHighlightFill="red";this.defaultHighlightAlpha=0.3;this.exportRuler=this.exportHighlights=!0;this.tierBackgroundColors=["rgb(245,245,245)","white"];this.minTierHeight=20;this.noDefaultLabels=!1;this.baseColors={A:"green",C:"blue",G:"black",T:"red"};this.availableSources=new m;this.defaultSources=[];this.mappableSources={};this.hubs=[];this.hubObjects=[];this.sourceCache=new b;this.useFetchWorkers=this.retina=!0;this.maxWorkers=2;
this.workerPath="$$worker-all.js";this.assemblyNameUcsc=this.assemblyNamePrimary=!0;this.initListeners=[];if(void 0!==l.viewStart&&"number"!==typeof l.viewStart)throw Error("viewStart must be an integer");if(void 0!==l.viewEnd&&"number"!==typeof l.viewEnd)throw Error("viewEnd must be an integer");for(var f in l)this[f]=l[f];"string"===typeof l.uiPrefix&&"string"!==typeof l.prefix&&(this.prefix=l.uiPrefix);0===this.prefix.indexOf("//")&&"http:"!==window.location.prototol&&"https:"!==window.location.protocol&&
(this.prefix="http:"+this.prefix);if(!this.coordSystem)throw Error("Coordinate system must be configured");if(void 0===this.chr||void 0===this.viewStart||void 0===this.viewEnd)throw Error("Viewed region (chr:start..end) must be defined");var a=this;"complete"===document.readyState?a.realInit():window.addEventListener("load",function(f){a.realInit()},!1)}function q(l,f,a){if(a)for(var e=0;e<f.length;++e)f[e].mapping=a;l.set(f)}function g(l){return l.uri?l.uri:l.blob?"file:"+l.blob.name:l.bwgBlob?"file:"+
l.bwgBlob.name:l.bamBlob?"file:"+l.bamBlob.name:l.twoBitBlob?"file:"+l.twoBitBlob.name:l.bwgURI||l.bamURI||l.jbURI||l.twoBitURI||"https://www.biodalliance.org/magic/no_uri"}function z(l){return l.stylesheet_uri?l.stylesheet_uri:"sequence"==l.tier_type||l.twoBitURI||l.twoBitBlob?"https://www.biodalliance.org/magic/sequence":g(l)}function p(l,f){if(g(l)!=g(f)||z(l)!=z(f)||l.mapping!=f.mapping||l.tier_type!=f.tier_type)return!1;if(l.overlay){if(!f.overlay||f.overlay.length!=l.overlay.length)return!1;for(var a=
0;a<l.overlay.length;++a)if(!p(l.overlay[a],f.overlay[a]))return!1}else if(f.overlay)return!1;return!0}function x(l,f,a,e){e=e||[];for(var b=l.length-1;0<=b;--b){var c=l[b];if(!c.notSelectable&&c.min()<=f&&c.max()>=f&&(!c.minY||!(a<c.minY()||a>c.maxY()))){c.feature?e.push(c.feature):c.group&&e.push(c.group);if(c.glyphs)return x(c.glyphs,f,a,e);if(c.glyph)return x([c.glyph],f,a,e);break}}return e}function d(l,f){var a=this;this.tagSeed=0;this.callbacks={};this.browser=l;this.worker=f;this.worker.onmessage=
function(f){var l=a.callbacks[f.data.tag];l&&(l(f.data.result,f.data.error),delete a.callbacks[f.data.tag])}}function a(l){var f=l.resolveURL(l.workerPath);0==f.indexOf("//")&&(f="https:"===window.location.prototype?"https:"+f:"http:"+f);var a=new Blob(['importScripts("'+f+'");'],{type:"application/javascript"});return new K(function(f,e){var b=new Worker(URL.createObjectURL(a));b.onmessage=function(a){"init"===a.data.tag&&(console.log("Worker initialized"),f(new d(l,b)))};b.onerror=function(f){e(f.message)}})}
function b(){this.sourcesByURI={}}if("undefined"!==typeof k){s=k("./utils");var m=s.Observed,c=s.makeElement,w=s.removeChildren,r=s.miniJSONify,y=s.shallowCopy,C=k("./tier").DasTier,F=k("./sha1").hex_sha1,A=k("./thub").connectTrackHub,R=k("./version"),B=k("./numformats").formatQuantLabel,Q=k("./chainset").Chainset,K=k("es6-promise").Promise}h.prototype.resolveURL=function(l){return l.replace("$$",this.prefix)};h.prototype.realInit=function(){if(this.wasInitialized)console.log("Attemping to call realInit on an already-initialized Dalliance instance");
else{this.wasInitialized=!0;this.defaultChr=this.chr;this.defaultStart=this.viewStart;this.defaultEnd=this.viewEnd;this.defaultSources=[];for(var l=0;l<this.sources.length;++l)this.defaultSources.push(this.sources[l]);this.restoreStatus&&(this.statusRestored=this.restoreStatus());var f=this;this.browserHolderHolder=document.getElementById(this.pageName);this.browserHolderHolder.classList.add("dalliance-injection-point");this.browserHolder=c("div",null,{className:"dalliance dalliance-root",tabIndex:-1});
this.maxHeight?this.browserHolder.style.maxHeight=this.maxHeight+"px":void 0!=this.maxHeight&&(this.browserHolder.style.maxHeight=null);w(this.browserHolderHolder);this.browserHolderHolder.appendChild(this.browserHolder);this.svgHolder=c("div",null,{className:"main-holder"});this.initUI(this.browserHolder,this.svgHolder);this.pinnedTierHolder=c("div",null,{className:"tier-holder tier-holder-pinned"});this.tierHolder=c("div",this.makeLoader(24),{className:"tier-holder tier-holder-rest"});this.tierHolderHolder=
c("div",[this.pinnedTierHolder,this.tierHolder],{className:"tier-holder-holder"});this.svgHolder.appendChild(this.tierHolderHolder);this.bhtmlRoot=c("div");this.disablePoweredBy||this.bhtmlRoot.appendChild(c("span",["Powered by ",c("a","Biodalliance",{href:"https://www.biodalliance.org/"})," "+R],{className:"powered-by"}));this.browserHolder.appendChild(this.bhtmlRoot);window.addEventListener("resize",function(l){f.resizeViewer()},!1);this.ruler=c("div",null,{className:"guideline"});this.ruler2=c("div",
null,{className:"guideline"},{backgroundColor:"gray",opacity:"0.5",zIndex:899});this.tierHolderHolder.appendChild(this.ruler);this.tierHolderHolder.appendChild(this.ruler2);this.chainConfigs=this.chains||{};this.chains={};for(var e in this.chainConfigs)l=this.chainConfigs[e],l instanceof Q&&console.log('WARNING: Should no longer use "new Chainset" in Biodalliance configurations.'),this.chains[e]=new Q(l);if(0<this.maxWorkers){e=[];for(l=0;l<this.maxWorkers;++l)e.push(a(this));e=K.all(e)}else e=K.resolve([]);
this.fetchWorkers=null;this.nextWorker=0;e.then(function(l){console.log("Booted "+l.length+" workers");f.fetchWorkers=l},function(f){console.log("Failed to boot workers",f)}).then(function(){if("none"!=window.getComputedStyle(f.browserHolderHolder).display)setTimeout(function(){f.realInit2()},1);else var l=setInterval(function(){"none"!=window.getComputedStyle(f.browserHolderHolder).display&&(clearInterval(l),f.realInit2())},300)})}};h.prototype.realInit2=function(){var l=this;w(this.tierHolder);
w(this.pinnedTierHolder);this.featurePanelWidth=this.tierHolder.getBoundingClientRect().width|0;this.scale=this.featurePanelWidth/(this.viewEnd-this.viewStart);this.zoomMax||(this.zoomMax=this.zoomExpt*Math.log(this.maxViewWidth/this.zoomBase),this.zoomMin=this.zoomExpt*Math.log(this.featurePanelWidth/10/this.zoomBase));this.zoomSliderValue=this.zoomExpt*Math.log((this.viewEnd-this.viewStart+1)/this.zoomBase);this.tierHolderHolder.addEventListener("mousewheel",function(f){f.stopPropagation();f.preventDefault();
if(f.wheelDeltaX){var a=f.wheelDeltaX/5;l.reverseScrolling||(a=-a);l.move(a)}f.wheelDeltaY&&(a=f.wheelDeltaY,l.reverseScrolling&&(a=-a),l.tierHolder.scrollTop+=a)},!1);this.tierHolderHolder.addEventListener("MozMousePixelScroll",function(f){f.stopPropagation();f.preventDefault();1==f.axis?0!=f.detail&&(f=f.detail/4,l.reverseScrolling&&(f=-f),l.move(f)):(f=f.detail,l.reverseScrolling||(f=-f),l.tierHolder.scrollTop+=f)},!1);this.tierHolderHolder.addEventListener("touchstart",function(f){return l.touchStartHandler(f)},
!1);this.tierHolderHolder.addEventListener("touchmove",function(f){return l.touchMoveHandler(f)},!1);this.tierHolderHolder.addEventListener("touchend",function(f){return l.touchEndHandler(f)},!1);this.tierHolderHolder.addEventListener("touchcancel",function(f){return l.touchCancelHandler(f)},!1);var f=function(f){if(13==f.keyCode){var a=!1;for(f=0;f<l.tiers.length;++f){var e=l.tiers[f];e.wantedLayoutHeight&&e.wantedLayoutHeight!=e.layoutHeight&&(e.layoutHeight=e.wantedLayoutHeight,e.clipTier(),a=
!0)}a&&l.arrangeTiers()}else if(32==f.keyCode||32==f.charCode)l.isSnapZooming?(l.isSnapZooming=!1,a=(l.savedZoom||20)+l.zoomMin):(l.isSnapZooming=!0,a=(l.savedZoom||0)+l.zoomMin),l.savedZoom=l.zoomSliderValue-l.zoomMin,l.zoomSliderValue=a,l.zoom(Math.exp(1*a/l.zoomExpt)),l.snapZoomLockout=!0,f.stopPropagation(),f.preventDefault();else if(39==f.keyCode)f.stopPropagation(),f.preventDefault(),l.scrollArrowKey(f,-1);else if(37==f.keyCode)f.stopPropagation(),f.preventDefault(),l.scrollArrowKey(f,1);else if(38==
f.keyCode||87==f.keyCode)if(f.stopPropagation(),f.preventDefault(),f.shiftKey)f=l.getSelectedTier(),0>f||(a=l.tiers[f],f=a.forceHeight||a.subtiers[0].height,40<=f&&a.mergeConfig({height:f-10}));else if(f.ctrlKey||f.metaKey){if(f=l.getSelectedTier(),!(0>f)&&(a=l.tiers[f],a.quantLeapThreshold)){var e=a.subtiers[0].height,v=a.subtiers[0].quant;v&&(f=1*v.min,v=1*v.max,e=(v-f)/e,a.mergeConfig({quantLeapThreshold:f+((Math.round((a.quantLeapThreshold-f)/e)|0)+1)*e}),a.notify("Threshold: "+B(a.quantLeapThreshold)))}}else if(f.altKey){if(v=
l.selectedTiers.length,0!=v){f=l.selectedTiers[0];for(var b=!0,a=[],e=0;e<l.selectedTiers.length;++e)a.push(l.tiers[l.selectedTiers[e]]),0<e&&1!=l.selectedTiers[e]-l.selectedTiers[e-1]&&(b=!1);if(!(b&&0>=f)){for(e=l.selectedTiers.length-1;0<=e;--e)l.tiers.splice(l.selectedTiers[e],1);l.selectedTiers.splice(0,v);f=b?f-1:f;for(e=0;e<a.length;++e)l.tiers.splice(f+e,0,a[e]),l.selectedTiers.push(f+e);l.markSelectedTiers();l.notifyTierSelection();l.reorderTiers();l.notifyTier()}}}else if(f=l.getSelectedTier(),
0<f){if(l.setSelectedTier(f-1),f=l.tiers[l.getSelectedTier()],a=f.row.offsetTop,f=a+f.row.offsetHeight,a<l.tierHolder.scrollTop||f>l.tierHolder.scrollTop+l.tierHolder.offsetHeight)l.tierHolder.scrollTop=a}else l.notifyTierSelectionWrap(-1);else if(40==f.keyCode||83==f.keyCode)if(f.stopPropagation(),f.preventDefault(),f.shiftKey)f=l.getSelectedTier(),0>f||(a=l.tiers[f],f=a.forceHeight||a.subtiers[0].height,a.mergeConfig({height:f+10}));else if(f.ctrlKey||f.metaKey){if(f=l.getSelectedTier(),!(0>f)&&
(a=l.tiers[f],a.quantLeapThreshold&&(e=a.subtiers[0].height,v=a.subtiers[0].quant)))f=1*v.min,v=1*v.max,e=(v-f)/e,v=Math.round((a.quantLeapThreshold-f)/e)|0,1<v&&(a.mergeConfig({quantLeapThreshold:f+(v-1)*e}),a.notify("Threshold: "+B(a.quantLeapThreshold)))}else if(f.altKey){if(v=l.selectedTiers.length,0!=v){f=l.selectedTiers[0];for(var c=0,a=[],e=0;e<l.selectedTiers.length;++e)a.push(l.tiers[l.selectedTiers[e]]),0<e&&(c+=l.selectedTiers[e]-l.selectedTiers[e-1]-1);b=0==c;if(!(b&&f+v>=l.tiers.length)){for(e=
l.selectedTiers.length-1;0<=e;--e)l.tiers.splice(l.selectedTiers[e],1);l.selectedTiers.splice(0,v);f=b?f+1:f+c;for(e=0;e<a.length;++e)l.tiers.splice(f+e,0,a[e]),l.selectedTiers.push(f+e);l.markSelectedTiers();l.notifyTierSelection();l.reorderTiers();l.notifyTier()}}}else{if(f=l.getSelectedTier(),f<l.tiers.length-1&&(l.setSelectedTier(f+1),f=l.tiers[l.getSelectedTier()],a=f.row.offsetTop,f=a+f.row.offsetHeight,a<l.tierHolder.scrollTop||f>l.tierHolder.scrollTop+l.tierHolder.offsetHeight))l.tierHolder.scrollTop=
Math.min(a,f-l.tierHolder.offsetHeight)}else if(187==f.keyCode||61==f.keyCode)f.stopPropagation(),f.preventDefault(),l.zoomStep(-10);else if(189==f.keyCode||173==f.keyCode)f.stopPropagation(),f.preventDefault(),l.zoomStep(10);else if(73==f.keyCode||105==f.keyCode)f.stopPropagation(),f.preventDefault(),f=l.getSelectedTier(),0>f||(e=l.tiers[f],e.infoVisible?(e.infoElement.style.display="none",e.updateHeight(),e.infoVisible=!1):(e.infoElement.style.display="block",e.updateHeight(),e.infoVisible=!0));
else if(84==f.keyCode||116==f.keyCode)if(f.shiftKey)for(f.stopPropagation(),f.preventDefault(),f=0;f<l.tiers.length;++f)e=l.tiers[f],e.dasSource.collapseSuperGroups&&(void 0===a&&(a=!e.bumped),e.bumped=a,e.layoutWasDone=!1,e.draw(),e.updateLabel());else f.ctrlKey||f.metaKey||(f.stopPropagation(),f.preventDefault(),f=l.getSelectedTier(),0>f||(e=l.tiers[f],e.dasSource.collapseSuperGroups&&(void 0===a&&(a=!e.bumped),e.bumped=a,e.layoutWasDone=!1,e.draw(),e.updateLabel())));else if(77==f.keyCode||109==
f.keyCode)f.stopPropagation(),f.preventDefault(),(f.ctrlKey||f.metaKey)&&1<l.selectedTiers.length&&l.mergeSelectedTiers();else if(68==f.keyCode||100==f.keyCode){if(f.stopPropagation(),f.preventDefault(),f.ctrlKey||f.metaKey)f=l.getSelectedTier(),0>f||l.addTier(l.tiers[f].dasSource)}else if(80==f.keyCode||112==f.keyCode)if(f.ctrlKey||f.metaKey){a=[];for(f=0;f<l.selectedTiers.length;++f)a.push(l.tiers[l.selectedTiers[f]]);for(f=0;f<a.length;++f)a[f].mergeConfig({pinned:!a[f].pinned})}};this.browserHolder.addEventListener("focus",
function(a){l.browserHolder.addEventListener("keydown",f,!1)},!1);this.browserHolder.addEventListener("blur",function(a){l.browserHolder.removeEventListener("keydown",f,!1)},!1);this.hPopupHolder=c("div");this.hPopupHolder.style["font-family"]="helvetica";this.hPopupHolder.style["font-size"]="12pt";this.hPopupHolder.classList.add("dalliance");document.body.appendChild(this.hPopupHolder);for(var a=0;a<this.sources.length;++a){var e=this.sources[a],b={};this.restoredConfigs&&(b=this.restoredConfigs[a]);
e.disabled||this.makeTier(e,b)}l.arrangeTiers();l.refresh();l.setSelectedTier(1);l.positionRuler();(a=this.getSequenceSource())&&a.getSeqInfo(this.chr,function(f){l.currentSeqMax=f.length});this.queryRegistry();for(var m in this.chains)this.queryRegistry(m,!0);if(this.hubs)for(m=0;m<this.hubs.length;++m)a=this.hubs[m],"string"==typeof a&&(a={url:a}),function(f){A(f.url,function(a,e){if(e)console.log(e);else{var v;if(v=f.genome?a.genomes[f.genome]:a.genomes[l.coordSystem.ucscName])f.mapping&&(v.mapping=
f.mapping),l.hubObjects.push(v)}},f)}(a);this.fullScreen&&this.setFullScreenHeight();!this.statusRestored&&this.storeStatus&&this.storeStatus();for(m=0;m<this.initListeners.length;++m)try{this.initListeners[m].call(this)}catch(t){console.log(t)}};h.prototype.touchStartHandler=function(a){a.stopPropagation();a.preventDefault();this.touchOriginX=a.touches[0].pageX;this.touchOriginY=a.touches[0].pageY;2==a.touches.length&&(a=Math.abs(a.touches[0].pageX-a.touches[1].pageX),this.zooming=!0,this.zoomLastSep=
this.zoomInitialSep=a,this.zoomInitialScale=this.scale)};h.prototype.touchMoveHandler=function(a){a.stopPropagation();a.preventDefault();if(1==a.touches.length){var f=a.touches[0].pageX;a=a.touches[0].pageY;this.touchOriginX&&f!=this.touchOriginX&&this.move(f-this.touchOriginX);this.touchOriginY&&a!=this.touchOriginY&&(this.tierHolder.scrollTop-=a-this.touchOriginY);this.touchOriginX=f;this.touchOriginY=a}else if(this.zooming&&2==a.touches.length){f=Math.abs(a.touches[0].pageX-a.touches[1].pageX);
if(f!=this.zoomLastSep){a=(a.touches[0].pageX+a.touches[1].pageX)/2;var e=this.viewStart+a/this.scale|0;this.scale=f/this.zoomInitialSep*this.zoomInitialScale;this.viewStart=e-a/this.scale|0;for(a=0;a<this.tiers.length;++a)this.tiers[a].draw()}this.zoomLastSep=f}};h.prototype.touchEndHandler=function(a){a.stopPropagation();a.preventDefault()};h.prototype.touchCancelHandler=function(a){};h.prototype.makeTier=function(a,f){try{return this.realMakeTier(a,f)}catch(e){console.log(e.stack||e)}};h.prototype.realMakeTier=
function(a,f){var e=this,b=null;this.tierBackgroundColors&&(b=this.tierBackgroundColors[this.tiers.length%this.tierBackgroundColors.length]);var c=new C(this,a,f,b);c.oorigin=this.viewStart;var m=!1,t,d,r,p=function(f,a){var l=c.subtiers;if(l){var b=0;for(a-=c.padding;b<l.length&&a>l[b].height&&b<l.length-1;)a=a-l[b].height-c.padding,++b;if(!(b>=l.length))return l=l[b].glyphs,f-=(c.glyphCacheOrigin-e.viewStart)*e.scale,x(l,f,a)}},w=function(f){f.preventDefault();f.stopPropagation();f=f.clientX;f!=
d&&(e.move(f-d),d=f);e.isDragging=!0},h=function(f){window.removeEventListener("mousemove",w,!0);window.removeEventListener("mouseup",h,!0)};c.viewport.addEventListener("mousedown",function(f){e.browserHolder.focus();f.preventDefault();c.row.getBoundingClientRect();f=f.clientX;window.addEventListener("mousemove",w,!0);window.addEventListener("mouseup",h,!0);t=d=f;e.isDragging=!1},!1);c.viewport.addEventListener("mousemove",function(f){var a=c.row.getBoundingClientRect(),l=f.clientX-a.left,b=f.clientY-
a.top;r&&clearTimeout(r);m||(r=setTimeout(function(){var a=p(l,b);a&&0<a.length&&e.notifyFeatureHover(f,a[a.length-1],a,c)},1E3))});var g=null;c.viewport.addEventListener("mouseup",function(f){var a=c.row.getBoundingClientRect(),l=f.clientX-a.left,a=f.clientY-a.top,b=p(l,a);b&&0<b.length&&!e.isDragging&&(g?(clearTimeout(g),g=null,e.featureDoubleClick(b,l,a)):g=setTimeout(function(){g=null;e.notifyFeature(f,b[b.length-1],b,c)},500));if(e.isDragging&&l!=t&&c.sequenceSource){var a=e.viewStart+l/e.scale,
m=e.viewStart+t/e.scale;a<m?(l=a|0,a=m|0):(l=m|0,a|=0);e.notifyRegionSelect(e.chr,l,a)}e.isDragging=!1},!1);c.viewport.addEventListener("mouseout",function(f){m=!1});c.removeButton.addEventListener("click",function(f){f.stopPropagation();f.preventDefault();for(f=0;f<e.tiers.length;++f)if(e.tiers[f]===c){e.removeTier({index:f});break}},!1);c.nameButton.addEventListener("click",function(f){f.stopPropagation();f.preventDefault();if(f.shiftKey){f=-1;for(var a=0;a<e.tiers.length;++a)if(e.tiers[a]===c){f=
a;break}0<=f&&(a=e.selectedTiers.indexOf(f),0<=a?e.selectedTiers.splice(a,1):(e.selectedTiers.push(f),e.selectedTiers.sort()),e.markSelectedTiers(),e.notifyTierSelection(),0<e.selectedTiers.length?e.browserHolder.focus():e.notifyTierSelectionWrap(-1))}else{for(a=0;a<e.tiers.length;++a)if(e.tiers[a]===c&&(e.browserHolder.focus(),1!=e.selectedTiers.length||e.selectedTiers[0]!=a)){e.setSelectedTier(a);return}c.infoVisible?(c.infoElement.style.display="none",c.updateHeight(),c.infoVisible=!1):(c.infoElement.style.display=
"block",c.updateHeight(),c.infoVisible=!0)}},!1);c.bumpButton.addEventListener("click",function(f){f.stopPropagation();f.preventDefault();var a;c.dasSource.collapseSuperGroups&&(void 0===a&&(a=!c.bumped),c.bumped=a,c.layoutWasDone=!1,c.draw(),c.updateLabel())},!1);var k,y,n,U,A,ea=!1,K=function(f){var a=c.label;f.stopPropagation();f.preventDefault();if(!k){y=c.pinned?e.pinnedTierHolder:e.tierHolder;n=y.scrollHeight-y.offsetHeight;k=a.cloneNode(!0);k.style.cursor="pointer";y.appendChild(k);a.style.visibility=
"hidden";for(var l=0;l<e.tiers.length;++l)if(e.tiers[l]===c){U=l;break}A=f.clientY}var b=y.getBoundingClientRect();k.style.left=a.getBoundingClientRect().left-b.left+"px";k.style.top=f.clientY-b.top+y.scrollTop-10+"px";a=f.clientY-b.top+y.scrollTop;for(l=0;l<e.tiers.length;++l)if(b=e.tiers[l],!(b.pinned^c.pinned)&&(b=b.row.getBoundingClientRect(),a-=b.bottom-b.top,0>a)){if(l<U&&f.clientY<A||l>U&&f.clientY>A)e.withPreservedSelection(function(){e.tiers.splice(U,1);e.tiers.splice(l,0,c)}),U=l,A=f.clientY,
e.reorderTiers(),y.appendChild(k),ea=!0;break}k.offsetTop<y.scrollTop?y.scrollTop-=y.scrollTop-k.offsetTop:k.offsetTop+k.offsetHeight>y.scrollTop+y.offsetHeight&&(y.scrollTop=Math.min(y.scrollTop+(k.offsetTop+k.offsetHeight)-(y.scrollTop+y.offsetHeight),n))},B=function(f){var a=c.label;f.stopPropagation();f.preventDefault();k&&(k.style.cursor="auto",y.removeChild(k),k=null,a.style.visibility=null);document.removeEventListener("mousemove",K,!1);document.removeEventListener("mouseup",B,!1);if(ea){for(f=
0;f<e.tiers.length;++f)if(e.tiers[f]==c){e.setSelectedTier(f);break}e.notifyTier()}};c.label.addEventListener("mousedown",function(f){f.stopPropagation();f.preventDefault();ea=!1;document.addEventListener("mousemove",K,!1);document.addEventListener("mouseup",B,!1)},!1);this.tiers.push(c);c.init();c.currentlyHeight=50;this.updateHeight();c.updateLabel();c.featureSource&&c.featureSource.addActivityListener&&c.featureSource.addActivityListener(function(f){c.loaderButton.style.display=0<f?"inline-block":
"none";e.pingActivity()});c._updateFromConfig();this.reorderTiers();return c};h.prototype.reorderTiers=function(){w(this.tierHolder);w(this.pinnedTierHolder);for(var a=!1,f=[],e=[],b=0;b<this.tiers.length;++b){var c=this.tiers[b];c.pinned?(f.push(c),this.pinnedTierHolder.appendChild(this.tiers[b].row),a=!0):(e.push(c),this.tierHolder.appendChild(this.tiers[b].row))}this.withPreservedSelection(function(){this.tiers.splice(0,this.tiers.length);for(var a=0;a<f.length;++a)this.tiers.push(f[a]);for(a=
0;a<e.length;++a)this.tiers.push(e[a])});a?this.pinnedTierHolder.classList.add("tier-holder-pinned-full"):this.pinnedTierHolder.classList.remove("tier-holder-pinned-full");this.arrangeTiers()};h.prototype.withPreservedSelection=function(a){for(var f=[],e=0;e<this.selectedTiers.length;++e)f.push(this.tiers[this.selectedTiers[e]]);a.call(this);this.selectedTiers=[];for(a=0;a<this.tiers.length;++a)0<=f.indexOf(this.tiers[a])&&this.selectedTiers.push(a)};h.prototype.refreshTier=function(a){this.knownSpace&&
this.knownSpace.invalidate(a)};h.prototype.arrangeTiers=function(){for(var a=[],f=0;f<this.tiers.length;++f){var e=this.tiers[f];e.pinned&&a.push(e)}for(f=0;f<this.tiers.length;++f)e=this.tiers[f],e.pinned||a.push(e);if(this.tierBackgroundColors)for(f=0;f<a.length;++f)e=a[f],e.background=this.tierBackgroundColors[f%this.tierBackgroundColors.length]};h.prototype.refresh=function(){this.notifyLocation();var a=100/this.scale|0,f=1E3/this.scale|0,b=(this.viewStart+this.viewEnd)/2,c=b-this.origin;this.origin=
b;this.scaleAtLastRedraw=this.scale;for(b=0;b<this.tiers.length;++b){var m=c;this.tiers[b].originHaxx&&(m+=this.tiers[b].originHaxx);this.tiers[b].originHaxx=m}c=this.targetQuantRes/this.scale;b=Math.max(1,(this.viewStart|0)-a);a=Math.min((this.viewEnd|0)+a,0<(this.currentSeqMax|0)?this.currentSeqMax|0:1E9);m=Math.max(1,(this.viewStart|0)-f);f=Math.min((this.viewEnd|0)+f,0<(this.currentSeqMax|0)?this.currentSeqMax|0:1E9);if(!this.knownSpace||this.knownSpace.chr!==this.chr){var t=this.getSequenceSource();
this.knownSpace=new e(this.tiers,this.chr,m,f,c,t)}(t=this.knownSpace.bestCacheOverlapping(this.chr,b,a))&&t.min<=b&&t.max>=a?(this.drawnStart=Math.max(t.min,m),this.drawnEnd=Math.min(t.max,f)):(this.drawnStart=m,this.drawnEnd=f);this.knownSpace.viewFeatures(this.chr,this.drawnStart,this.drawnEnd,c);this.drawOverlays()};h.prototype.queryRegistry=function(a,f){var e,b;a?(e=this.chains[a].coords,this.mappableSources[a]||(this.mappableSources[a]=new m),b=this.mappableSources[a]):(e=this.coordSystem,
b=this.availableSources);var c=F(r(e));if(f){var d=localStorage["dalliance.registry."+c+".last_queried"];if(d)try{if(q(b,JSON.parse(localStorage["dalliance.registry."+c+".sources"]),a),432E5>(Date.now()|0)-(d|0))return}catch(p){console.log("Bad registry cache: "+p)}}(new t(this.registry)).sources(function(f){for(var m=[],t=0;t<f.length;++t){var d=f[t];if(d.coords&&0!=d.coords.length){var r=d.coords[0];r.taxon==e.taxon&&r.auth==e.auth&&r.version==e.version&&m.push(d)}}localStorage["dalliance.registry."+
c+".sources"]=JSON.stringify(m);localStorage["dalliance.registry."+c+".last_queried"]=""+Date.now();q(b,m,a)},function(f){},e)};h.prototype.move=function(a){var f=this.viewEnd-this.viewStart;this.viewStart-=a/this.scale;this.viewEnd=this.viewStart+f;0<this.currentSeqMax&&this.viewEnd>this.currentSeqMax&&(this.viewEnd=this.currentSeqMax,this.viewStart=this.viewEnd-f);1>this.viewStart&&(this.viewStart=1,this.viewEnd=this.viewStart+f);this.notifyLocation();for(a=0;a<this.tiers.length;++a)this.tiers[a].viewport.style.left=
""+((-((this.viewStart-this.tiers[a].norigin)*this.scale)|0)-1E3)+"px",this.tiers[a].overlay.style.left=""+((-((this.viewStart-this.tiers[a].oorigin)*this.scale)|0)-1E3)+"px";this.spaceCheck()};h.prototype.zoomStep=function(a){var f=1*this.zoomSliderValue;a=f+a;a<this.zoomMin&&(a=this.zoomMin);a>this.zoomMax&&(a=this.zoomMax);a!=f&&(this.zoomSliderValue=a,this.zoom(Math.exp(1*a/this.zoomExpt)))};h.prototype.zoom=function(a){this.zoomFactor=a;a=Math.round((this.viewStart+this.viewEnd)/2)|0;this.viewStart=
a-this.zoomBase*this.zoomFactor/2;this.viewEnd=a+this.zoomBase*this.zoomFactor/2;0<this.currentSeqMax&&this.viewEnd>this.currentSeqMax+5&&(a=this.viewEnd-this.viewStart+1,this.viewEnd=this.currentSeqMax,this.viewStart=this.viewEnd-a+1);1>this.viewStart&&(a=this.viewEnd-this.viewStart+1,this.viewStart=1,this.viewEnd=this.viewStart+a-1);this.scale=this.featurePanelWidth/(this.viewEnd-this.viewStart);this.refresh()};h.prototype.spaceCheck=function(a){this.knownSpace&&this.knownSpace.chr===this.chr?(a=
100/this.scale|0,((this.drawnStart|0)>Math.max(1,(this.viewStart|0)-a|0)||(this.drawnEnd|0)<Math.min((this.viewEnd|0)+a,0<(this.currentSeqMax|0)?this.currentSeqMax|0:1E9))&&this.refresh()):this.refresh()};h.prototype.resizeViewer=function(a){var f=this.tierHolder.getBoundingClientRect().width|0;if(0!=f){var e=Math.max(this.featurePanelWidth,300);this.featurePanelWidth=f|0;e!=this.featurePanelWidth&&(this.zoomMax=this.zoomExpt*Math.log(this.maxViewWidth/this.zoomBase),this.zoomMin=this.zoomExpt*Math.log(this.featurePanelWidth/
10/this.zoomBase),this.zoomSliderValue=this.zoomExpt*Math.log((this.viewEnd-this.viewStart+1)/this.zoomBase),this.viewEnd=this.viewStart+(this.viewEnd-this.viewStart)*this.featurePanelWidth/e,f=this.viewEnd-this.viewStart+1,0<this.currentSeqMax&&this.viewEnd>this.currentSeqMax&&(this.viewEnd=this.currentSeqMax,this.viewStart=this.viewEnd-f+1),1>this.viewStart&&(this.viewStart=1,this.viewEnd=this.viewStart+f-1),this.positionRuler(),a||this.spaceCheck(),this.notifyLocation());this.fullScreen&&this.setFullScreenHeight()}};
h.prototype.setFullScreenHeight=function(){this.browserHolder.style.maxHeight=Math.max(300,window.innerHeight-(document.body.offsetHeight-this.browserHolder.offsetHeight)-20)+"px"};h.prototype.addTier=function(a){a=y(a);a.disabled=!1;a=this.makeTier(a);this.markSelectedTiers();this.positionRuler();this.notifyTier();return a};h.prototype.removeTier=function(a,f){var e=-1;if("undefined"!==typeof a.index&&0<=a.index&&a.index<this.tiers.length)e=a.index;else for(var b=0;b<this.tiers.length;++b)if(p(a,
this.tiers[b].dasSource)){e=b;break}if(0>e)throw"Couldn't find requested tier";this.tiers.splice(e,1);for(var b=[],c=0;c<this.selectedTiers.length;++c){var m=this.selectedTiers[c];m<e?b.push(m):m>e&&b.push(m-1)}this.selectedTiers=b;this.markSelectedTiers();this.reorderTiers();this.notifyTier()};h.prototype.getSequenceSource=function(){void 0===this._sequenceSource&&(this._sequenceSource=this._getSequenceSource());return this._sequenceSource};h.prototype._getSequenceSource=function(){for(var a=0;a<
this.tiers.length;++a)if(this.tiers[a].sequenceSource)return this.tiers[a].sequenceSource;for(a=0;a<this.defaultSources.length;++a){var f=this.defaultSources[a];if(f.provides_entrypoints||"sequence"==f.tier_type||f.twoBitURI||f.twoBitBlob)return f.twoBitURI||f.twoBitBlob?new L(f):new E(f)}};h.prototype.setLocation=function(a,f,e,b){if("number"!==typeof f)throw Error("minimum must be a number (got "+JSON.stringify(f)+")");if("number"!==typeof e)throw Error("maximum must be a number (got "+JSON.stringify(e)+
")");b||(b=function(f){if(f)throw f;});var c=this;if(a&&a!=this.chr){var m=this.getSequenceSource();if(!m)return b("Need a sequence source");m.getSeqInfo(a,function(t){if(t)return c._setLocation(a,f,e,t,b);var d;d=0==a.indexOf("chr")?a.substr(3):"chr"+a;m.getSeqInfo(d,function(m){return m?c._setLocation(d,f,e,m,b):b("Couldn't find sequence '"+a+"'")})})}else return this._setLocation(null,f,e,null,b)};h.prototype._setLocation=function(a,f,e,b,c){var m=!1;a&&(0==a.indexOf("chr")&&(a=a.substring(3)),
this.chr!=a&&(m=!0),this.chr=a,this.currentSeqMax=b.length);f|=0;e|=0;a=Math.max(10,e-f+1);1>f&&(f=1,e=f+a-1);e>this.currentSeqMax&&(e=this.currentSeqMax,f=Math.max(1,e-a+1));this.viewStart=f;this.viewEnd=e;f=Math.max(this.featurePanelWidth,50)/(this.viewEnd-this.viewStart);a=1E-4<Math.abs(f-this.scale);this.scale=f;e=this.zoomSliderValue;this.zoomSliderValue=f=this.zoomExpt*Math.log((this.viewEnd-this.viewStart+1)/this.zoomBase);if(a||m){for(m=0;m<this.tiers.length;++m)this.tiers[m].viewport.style.left=
"5000px",this.tiers[m].overlay.style.left="5000px";this.refresh();this.savedZoom?(f-=this.zoomMin,e-=this.zoomMin,m=f-this.savedZoom,Math.abs(f-e)>Math.abs(m)&&(this.isSnapZooming=!this.isSnapZooming,this.savedZoom=e)):(this.isSnapZooming=!1,this.savedZoom=null)}else for(m=0;m<this.tiers.length;++m)this.tiers[m].viewport.style.left=""+((-((this.viewStart-this.tiers[m].norigin)*this.scale)|0)-1E3)+"px",this.tiers[m].overlay.style.left=""+((-((this.viewStart-this.tiers[m].oorigin)*this.scale)|0)-1E3)+
"px";this.notifyLocation();this.spaceCheck();this.instrumentActivity&&(this.activityStartTime=Date.now()|0);return c()};h.prototype.pingActivity=function(){if(this.instrumentActivity&&this.activityStartTime){for(var a=0,f=0;f<this.tiers.length;++f)"none"!==this.tiers[f].loaderButton.style.display&&++a;0==a&&(a=Date.now()|0,console.log("Loading took "+(a-this.activityStartTime)+"ms"),this.activityStartTime=null)}};h.prototype.addInitListener=function(a){this.initListeners.push(a)};h.prototype.addFeatureListener=
function(a,f){this.featureListeners.push(a)};h.prototype.notifyFeature=function(a,f,e,b){for(var c=0;c<this.featureListeners.length;++c)try{if(this.featureListeners[c](a,f,e,b))break}catch(m){console.log(m.stack)}};h.prototype.addFeatureHoverListener=function(a,f){this.featureHoverListeners.push(a)};h.prototype.notifyFeatureHover=function(a,f,e,b){for(var c=0;c<this.featureHoverListeners.length;++c)try{this.featureHoverListeners[c](a,f,e,b)}catch(m){console.log(m.stack)}};h.prototype.addViewListener=
function(a,f){this.viewListeners.push(a)};h.prototype.notifyLocation=function(){for(var a=0;a<this.viewListeners.length;++a)try{this.viewListeners[a](this.chr,this.viewStart|0,this.viewEnd|0,this.zoomSliderValue,{current:this.zoomSliderValue,min:this.zoomMin,max:this.zoomMax})}catch(f){console.log(f.stack)}};h.prototype.addTierListener=function(a){this.tierListeners.push(a)};h.prototype.notifyTier=function(){for(var a=0;a<this.tierListeners.length;++a)try{this.tierListeners[a]()}catch(f){console.log(f.stack)}};
h.prototype.addRegionSelectListener=function(a){this.regionSelectListeners.push(a)};h.prototype.notifyRegionSelect=function(a,f,e){for(var b=0;b<this.regionSelectListeners.length;++b)try{this.regionSelectListeners[b](a,f,e)}catch(c){console.log(c.stack)}};h.prototype.highlightRegion=function(a,f,e){var b=this;if(a==this.chr)return this._highlightRegion(a,f,e);var c=this.getSequenceSource();if(!c)throw"Need a sequence source";c.getSeqInfo(a,function(m){if(m)return b._highlightRegion(a,f,e);var t;t=
0==a.indexOf("chr")?a.substr(3):"chr"+a;c.getSeqInfo(t,function(a){if(a)return b._highlightRegion(t,f,e)})})};h.prototype._highlightRegion=function(a,f,e){for(var b=0;b<this.highlights.length;++b){var c=this.highlights[b];if(c.chr==a&&c.min==f&&c.max==e)return}this.highlights.push(new n(a,f,e));b=this.viewStart-1E3/this.scale;c=this.viewEnd+1E3/this.scale;(a==this.chr||a=="chr"+this.chr)&&f<c&&e>b&&this.drawOverlays();this.notifyLocation()};h.prototype.clearHighlights=function(){this.highlights=[];
this.drawOverlays();this.notifyLocation()};h.prototype.drawOverlays=function(){for(var a=0;a<this.tiers.length;++a)this.tiers[a].drawOverlay()};h.prototype.featuresInRegion=function(a,f,e){var b=[];if(a!==this.chr)return[];for(a=0;a<this.tiers.length;++a)for(var c=this.tiers[a].currentFeatures||[],m=0;m<c.length;++m){var t=c[m];t.min<=e&&t.max>=f&&b.push(t)}return b};h.prototype.getSelectedTier=function(){return 0<this.selectedTiers.length?this.selectedTiers[0]:-1};h.prototype.setSelectedTier=function(a){this.selectedTiers=
null==a?[]:[a];this.markSelectedTiers();this.notifyTierSelection()};h.prototype.markSelectedTiers=function(){for(var a=0;a<this.tiers.length;++a){var f=this.tiers[a].nameButton;0<=this.selectedTiers.indexOf(a)?f.classList.add("active"):f.classList.remove("active")}0<this.selectedTiers.length&&this.browserHolder.focus()};h.prototype.addTierSelectionListener=function(a){this.tierSelectionListeners.push(a)};h.prototype.notifyTierSelection=function(){for(var a=0;a<this.tierSelectionListeners.length;++a)try{this.tierSelectionListeners[a](this.selectedTiers)}catch(f){console.log(f.stack)}};
h.prototype.addTierSelectionWrapListener=function(a){this.tierSelectionWrapListeners.push(a)};h.prototype.notifyTierSelectionWrap=function(a){for(var f=0;f<this.tierSelectionWrapListeners.length;++f)try{this.tierSelectionWrapListeners[f](a)}catch(e){console.log(e.stack)}};h.prototype.positionRuler=function(){var a="none",f="",e="";"center"==this.rulerLocation?(a="block",f=""+(this.featurePanelWidth/2|0)+"px"):"left"==this.rulerLocation?(a="block",f="0px"):"right"==this.rulerLocation?(a="block",e=
"0px"):a="none";this.ruler.style.display=a;this.ruler.style.left=f;this.ruler.style.right=e;this.ruler2.style.display="center"==this.rulerLocation?"none":"block";this.ruler2.style.left=""+(this.featurePanelWidth/2|0)+"px";for(var b=0;b<this.tiers.length;++b){var c=this.tiers[b],m=c.quantOverlay,t;c.subtiers&&0<c.subtiers.length&&(t=c.subtiers[0].quant);m&&(m.style.display=t?a:"none",m.style.left=f,m.style.right=e)}};h.prototype.featureDoubleClick=function(a,f,e){if(a&&0!=a.length&&(e=a[a.length-1],
e.min&&e.max)){var b=((e.min|0)-(this.viewStart|0))*this.scale,c=(e.max-e.min+1)*this.scale;a=((e.min|0)+(e.max|0))/2;10<c&&(f=1*(f-b)/c,0.3>f?a=e.min|0:0.7<f&&(a=(e.max|0)+1));f=this.viewEnd-this.viewStart;this.setLocation(null,a-f/2,a+f/2)}};h.prototype.zoomForScale=function(a){return 0.2<a?"high":0.01<a?"medium":"low"};h.prototype.zoomForCurrentScale=function(){return this.zoomForScale(this.scale)};h.prototype.updateHeight=function(){for(var a=0,f=0;f<this.tiers.length;++f)a+=this.tiers[f].currentHeight||
30;this.ruler.style.height=""+a+"px";this.ruler2.style.height=""+a+"px"};h.prototype.scrollArrowKey=function(a,f){this.reverseKeyScrolling&&(f=-f);if(a.ctrlKey||a.metaKey){var e=!1;a.shiftKey&&(e=!0);this.leap(f,e)}else this.move(a.shiftKey?100*f:25*f)};h.prototype.leap=function(a,f){var e=this,b=(e.viewStart+e.viewEnd+1)/2|0;0<a&&1>=e.viewStart?b-=1E8:0>a&&e.viewEnd>=e.currentSeqMax&&(b+=1E8);var c=e.getSelectedTier();0>c||((c=e.tiers[c])&&(c.featureSource&&this.sourceAdapterIsCapable(c.featureSource,
"quantLeap")&&"number"==typeof c.quantLeapThreshold||c.featureSource&&this.sourceAdapterIsCapable(c.featureSource,"leap"))?c.findNextFeature(e.chr,b,-a,f,function(c){if(c){var m=c.min,t=c.max;f&&(0<a?m>b+1?t=m:(t++,m=t):t<b-1?(t++,m=t):t=m);var d=e.viewEnd-e.viewStart+1;parseFloat(d/2)==parseInt(d/2)&&d--;m=(m+t-d)/2+1;e.setLocation(c.segment,m,m+d-1)}else alert("no next feature")}):this.move(100*a))};h.prototype.nameForCoordSystem=function(a){var f=null,e=null;this.assemblyNamePrimary&&(f=""+a.auth,
"undefined"!==typeof a.version&&(f+=a.version));this.assemblyNameUcsc&&(e=a.ucscName);return null!=f&&null!=e?f+"/"+e:f||e||"unknown"};h.prototype.makeLoader=function(a){var f=1<window.devicePixelRatio;return 20>(a||16)?c("img",null,{src:this.resolveURL("$$img/spinner_"+(f?16:32)+".gif"),width:"16",height:"16"}):c("img",null,{src:this.resolveURL("$$img/spinner_"+(f?24:48)+".gif"),width:"24",height:"24"})};h.prototype.getWorker=function(){if(!this.useFetchWorkers||!this.fetchWorkers||0==this.fetchWorkers.length)return null;
this.nextWorker>=this.fetchWorkers.length&&(this.nextWorker=0);return this.fetchWorkers[this.nextWorker++]};d.prototype.postCommand=function(a,f,e){var b="x"+ ++this.tagSeed;a.tag=b;this.callbacks[b]=f;this.worker.postMessage(a,e)};if("undefined"!==typeof u){u.exports={Browser:h,sourcesAreEqual:p,sourceDataURI:g};k("./browser-ui");k("./track-adder");k("./feature-popup");k("./tier-actions");k("./domui");k("./search");u=k("./sourceadapters");var L=u.TwoBitSequenceSource,E=u.DASSequenceSource,e=k("./kspace").KnownSpace,
t=k("./das").DASRegistry}b.prototype.get=function(a){var f=this.sourcesByURI[g(a)];if(f)for(var e=0;e<f.configs.length;++e)if(p(f.configs[e],a))return f.sources[e]};b.prototype.put=function(a,f){var e=g(a),b=this.sourcesByURI[e];b||(b={configs:[],sources:[]},this.sourcesByURI[e]=b);b.configs.push(a);b.sources.push(f)}},{"./browser-ui":5,"./chainset":7,"./das":10,"./domui":11,"./feature-popup":17,"./kspace":21,"./numformats":24,"./search":28,"./sha1":31,"./sourceadapters":32,"./thub":38,"./tier":41,
"./tier-actions":39,"./track-adder":42,"./utils":45,"./version":47,"es6-promise":48}],7:[function(k,u,s){function n(b,c,m,d){"string"==typeof b?(this.uri=b,this.srcTag=c,this.destTag=m,this.coords=d):(this.uri=b.uri,this.srcTag=b.srcTag,this.destTag=b.destTag,this.coords=a(b.coords),this.type=b.type,this.credentials=b.credentials);this.chainsBySrc={};this.chainsByDest={};this.postFetchQueues={};this.chainFetcher="bigbed"==this.type?new q(this.uri,this.credentials):new h(this.uri,this.srcTag,this.destTag)}
function h(a,b,c){this.source=new p(a);this.srcTag=b;this.destTag=c}function q(a,b){var d=this;this.uri=a;this.credentials=b;this.bwg=new w(function(a,b){c(new m(d.uri,{credentials:d.credentials}),function(c,m){c?a(c):b(m)})});this.bwg.then(function(a,b){b&&console.log(b)})}function g(a){return parseInt(a)}function z(a){var b={srcChr:a.srcChrom,srcMin:parseInt(a.srcStart),srcMax:parseInt(a.srcEnd),srcOri:a.srcOri,destChr:a.segment,destMin:a.min-1,destMax:a.max,destOri:a.ori,blocks:[]},c=a.srcStarts.split(",").map(g),
m=a.destStarts.split(",").map(g);a=a.blockLens.split(",").map(g);for(var d=0;d<c.length;++d)b.blocks.push([c[d],m[d],a[d]]);return b}if("undefined"!==typeof k){s=k("./das");var p=s.DASSource,x=s.DASSegment;s=k("./utils");var d=s.pusho,a=s.shallowCopy,b=k("./cigar").parseCigar,m=k("./bin").URLFetchable,c=k("./bigwig").makeBwg,w=k("es6-promise").Promise}n.prototype.exportConfig=function(){return{uri:this.uri,srcTag:this.srcTag,destTag:this.destTag,coords:this.coords,type:this.type,credentials:this.credentials}};
n.prototype.mapPoint=function(a,b){for(var c=this.chainsBySrc[a]||[],m=0;m<c.length;++m){var d=c[m];if(b>=d.srcMin&&b<=d.srcMax){var p;p="-"==d.srcOri?d.srcMax-b:b-d.srcMin;for(var w=d.blocks,h=0;h<w.length;++h){var g=w[h],k=g[0],n=g[1],g=g[2];if(p>=k&&p<=k+g)return c=p-k,{seq:d.destChr,pos:"-"==d.destOri?d.destMax-n-c:c+n+d.destMin,flipped:d.srcOri!=d.destOri}}}}return null};n.prototype.unmapPoint=function(a,b){for(var c=this.chainsByDest[a]||[],m=0;m<c.length;++m){var d=c[m];if(b>=d.destMin&&b<=
d.destMax){var p;p="-"==d.srcOri?d.destMax-b:b-d.destMin;for(var w=d.blocks,h=0;h<w.length;++h){var g=w[h],k=g[0],n=g[1],g=g[2];if(p>=n&&p<=n+g)return c=p-n,m=c+k+d.srcMin,m="-"==d.destOri?d.srcMax-k-c:c+k+d.srcMin,{seq:d.srcChr,pos:m,flipped:d.srcOri!=d.destOri}}}}return null};n.prototype.sourceBlocksForRange=function(a,b,c,m){if(this.chainsByDest[a]){for(var p=[],w=this.chainsByDest[a]||[],h=0;h<w.length;++h){var g=w[h];if(b<=g.destMax&&c>=g.destMin){var k,n;"-"==g.srcOri?(k=g.destMax-c,n=g.destMax-
b):(k=b-g.destMin,n=c-g.destMin);for(var q=g.blocks,e=0;e<q.length;++e){var t=q[e],l=t[0],f=t[1],v=t[2];n>=f&&k<=f+v&&(t=Math.max(k,f)-f,f=Math.min(n,f+v)-f,"-"==g.destOri?p.push(new x(g.srcChr,g.srcMax-l-f,g.srcMax-l-t)):p.push(new x(g.srcChr,g.srcMin+t+l,g.srcMin+f+l)))}}}m(p)}else{var p=!this.postFetchQueues[a],G=this;d(this.postFetchQueues,a,function(){G.sourceBlocksForRange(a,b,c,m)});p&&this.chainFetcher.fetchChains(a).then(function(f,e){G.chainsByDest||(G.chainsByDest[a]=[]);for(var b=0;b<
f.length;++b){var c=f[b];d(G.chainsBySrc,c.srcChr,c);d(G.chainsByDest,c.destChr,c)}if(G.postFetchQueues[a]){b=G.postFetchQueues[a];for(c=0;c<b.length;++c)b[c]();G.postFetchQueues[a]=null}})}};h.prototype.fetchChains=function(a,c,m){var d=this;return new w(function(c,m){d.source.alignments(a,{},function(a){for(var m=[],r=0;r<a.length;++r)for(var p=a[r],g=0;g<p.blocks.length;++g){for(var e=p.blocks[g],t,l,f=0;f<e.segments.length;++f){var v=e.segments[f],w=p.objects[v.object];w.dbSource===d.srcTag?t=
v:w.dbSource===d.destTag&&(l=v)}if(t&&l){for(var e={srcChr:p.objects[t.object].accession,srcMin:t.min|0,srcMax:t.max|0,srcOri:t.strand,destChr:p.objects[l.object].accession,destMin:l.min|0,destMax:l.max|0,destOri:l.strand,blocks:[]},f=b(t.cigar),v=b(l.cigar),h=w=0,k=0,y=0;k<f.length&&y<v.length;)if("M"==f[k].op&&"M"==v[y].op){var n=Math.min(f[k].cnt,v[y].cnt);e.blocks.push([w,h,n]);f[k].cnt==n?++k:f[k].cnt-=n;v[y].cnt==n?++y:v[y]-=n;w+=n;h+=n}else"I"==f[k].op?h+=f[k++].cnt:"I"==v[y].op&&(w+=v[y++].cnt);
m.push(e)}}c(m)})})};q.prototype.fetchChains=function(a,b,c){return this.bwg.then(function(b,c){if(!b)throw Error("No BWG");return new w(function(c,m){b.getUnzoomedView().readWigData(a,1,3E10,function(a){c(a.map(z))})})})};"undefined"!==typeof u&&(u.exports={Chainset:n})},{"./bigwig":3,"./bin":4,"./cigar":8,"./das":10,"./utils":45,"es6-promise":48}],8:[function(k,u,s){function n(k){for(var g=[],n;null!=(n=h.exec(k));){var p=n[1];0==p.length&&(p=1);g.push({cnt:p|0,op:n[2]})}return g}var h=RegExp("([0-9]*)([MIDS])",
"g");"undefined"!==typeof u&&(u.exports={parseCigar:n})},{}],9:[function(k,u,s){function n(a,b,m,c){this.red=a|0;this.green=b|0;this.blue=m|0;c&&(this.name=c)}function h(a){a="00"+a.toString(16);return a.substring(a.length-2)}function q(a){var b=p[a];b||((b=x.exec(a))?b=new n("0x"+b[1]|0,"0x"+b[2]|0,"0x"+b[3]|0,a):(b=d.exec(a))?b=new n(b[1]|0,b[2]|0,b[3]|0,a):(console.log("couldn't handle color: "+a),b=p.black),p[a]=b);return b}function g(a,b,m){for(var c=[],d=0;d<m.length;++d)c.push(q(m[d]));m=[];
d=0;a:for(;d<a;++d){for(var r=b[0]+1*d/(a-1)*(b[b.length-1]-b[0]),p=0;p<b.length-1;++p)if(r>=b[p]&&r<=b[p+1]){var r=(r-b[p])/(b[p+1]-b[p]),g=c[p],p=c[p+1],p=(new n(g.red*(1-r)+p.red*r|0,g.green*(1-r)+p.green*r|0,g.blue*(1-r)+p.blue*r|0)).toSvgString();m.push(p);continue a}throw"Bad step";}return m}function z(a,b,m,c){return c?g(a,[0,0.5,1],[b,m,c]):g(a,[0,1],[b,m])}n.prototype.toSvgString=function(){this.name||(this.name="rgb("+this.red+","+this.green+","+this.blue+")");return this.name};n.prototype.toHexString=
function(){return"#"+h(this.red)+h(this.green)+h(this.blue)};var p={red:new n(255,0,0,"red"),green:new n(0,255,0,"green"),blue:new n(0,0,255,"blue"),yellow:new n(255,255,0,"yellow"),white:new n(255,255,255,"white"),black:new n(0,0,0,"black"),gray:new n(180,180,180,"gray"),grey:new n(180,180,180,"grey")},x=/^#([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/,d=/rgb\(([0-9]+),([0-9]+),([0-9]+)\)/;"undefined"!==typeof u&&(u.exports={makeColourSteps:g,makeGradient:z,dasColourForName:q})},{}],10:[function(k,
u,s){function n(a,b,c,e){this.name=a;this.start=b;this.end=c;this.description=e}function h(a,b){var c;"string"==typeof a?(this.uri=a,c=b||{}):c=a||{};for(var e in c)"function"!=typeof c[e]&&(this[e]=c[e]);this.coords||(this.coords=[]);this.props||(this.props={});(this.dasBaseURI=this.uri)&&"/"!=this.dasBaseURI.substr(this.uri.length-1)&&(this.dasBaseURI+="/")}function q(){}function g(a,b,c,e,m){this.name=a;this.start=b;this.end=c;this.alphabet=e;this.seq=m}function z(){}function p(a){a&&(this.id=
a)}function x(a,b){this.desc=a;this.uri=b}function d(a){this.type=a;this.objects={};this.blocks=[]}function a(){this.styles=[]}function b(){}function m(a,b){b=b||{};this.uri=a;this.opts=b}function c(a,b){var c=a.getElementsByTagName(b);if(0<c.length&&c[0].firstChild){c=c[0];if(1==c.childNodes.length)return c.firstChild.nodeValue;for(var e="",m=0;m<c.childNodes.length;++m)e+=c.childNodes[m].nodeValue;return e}return null}function w(a){for(var b=[],c=a.getElementsByTagName("LINK"),e=0;e<c.length;++e){var m=
c[e];m.parentNode==a&&b.push(new x(m.firstChild?m.firstChild.nodeValue:"Unknown",m.getAttribute("href")))}return b}function r(a){var b=[];a=a.getElementsByTagName("NOTE");for(var c=0;c<a.length;++c)a[c].firstChild&&b.push(a[c].firstChild.nodeValue);return b}function y(a,b,c,e){if(window.XDomainRequest){var m=new XDomainRequest;m.onload=function(){var a=new ActiveXObject("Microsoft.XMLDOM");a.async=!1;a.loadXML(m.responseText);b(a)};m.open("get",a)}else Date.now(),m=new XMLHttpRequest,m.onreadystatechange=
function(){4==m.readyState&&(200<=m.status||0==m.status)&&b(m.responseXML,m)},m.open("get",a,!0),c&&(m.withCredentials=!0),e&&m.setRequestHeader("X-DAS-Authorisation",e),m.setRequestHeader("Accept","application/xml,*/*");m.send("")}function C(a){a=(""+a).toLowerCase();return"yes"===a||"true"===a}function F(a){if(!a)return!1;a=(""+a).toLowerCase();return"no"!==a||"false"!==a}function A(a){var b=R(a);b.styles=[];for(var c=0;c<a.styles.length;++c){var e=b.styles[c]=R(a.styles[c]);e._methodRE=e._labelRE=
e._typeRE=void 0;e.style=R(e.style);e.style.id=void 0}return b}if("undefined"!==typeof k){s=k("./utils");var R=s.shallowCopy,B=s.pusho,Q=k("./color").makeColourSteps}n.prototype.toString=function(){return this.name+":"+this.start+".."+this.end};n.prototype.isBounded=function(){return this.start&&this.end};n.prototype.toDASQuery=function(){var a="segment="+this.name;this.start&&this.end&&(a+=":"+this.start+","+this.end);return a};h.prototype.entryPoints=function(a){this.doCrossDomainRequest(this.dasBaseURI+
"entry_points",function(b){if(!b)return a([]);var c=[];b=b.getElementsByTagName("SEGMENT");for(var e=0;e<b.length;++e){var m=b[e],l=m.getAttribute("id"),f=m.getAttribute("size"),d;f?(d=1,f|=0):((d=m.getAttribute("start"))&&(d|=0),(f=m.getAttribute("stop"))&&(f|=0));var r=null;m.firstChild&&(r=m.firstChild.nodeValue);c.push(new n(l,d,f,r))}a(c)})};h.prototype.sequence=function(a,b){var c=this.dasBaseURI+"sequence?"+a.toDASQuery();this.doCrossDomainRequest(c,function(a){if(a){var c=[];a=a.getElementsByTagName("SEQUENCE");
for(var l=0;l<a.length;++l){var f=a[l],m=f.getAttribute("id"),d=f.getAttribute("start"),r=f.getAttribute("stop"),p=null;if(f.firstChild)for(var f=f.firstChild.nodeValue,p="",h=0;;){var w=f.indexOf("\n",h);if(0<=w)p+=f.substring(h,w),h=w+1;else{p+=f.substring(h);break}}c.push(new g(m,d,r,"DNA",p))}b(c)}else b([])})};h.prototype.features=function(a,b,m){b=b||{};var e;if(this.features_uri)e=this.features_uri;else{var d=[];if(a)d.push(a.toDASQuery());else if(b.group)if(a=b.group,"string"==typeof a)d.push("group_id="+
a);else for(var l=0;l<a.length;++l)d.push("group_id="+a[l]);if(b.adjacent)for(a=b.adjacent,"string"==typeof a&&(a=[a]),l=0;l<a.length;++l)d.push("adjacent="+a[l]);if(b.type)if("string"==typeof b.type)d.push("type="+b.type);else for(a=0;a<b.type.length;++a)d.push("type="+b.type[a]);b.maxbins&&d.push("maxbins="+b.maxbins);0<d.length?e=this.dasBaseURI+"features?"+d.join(";"):m([],"No filters specified")}this.doCrossDomainRequest(e,function(a,e){if(a){for(var b=[],l={},d=a.getElementsByTagName("SEGMENT"),
t=0;t<d.length;++t){var g=d[t],h=g.getAttribute("id");l[h]={min:g.getAttribute("start"),max:g.getAttribute("stop")};for(var g=g.getElementsByTagName("FEATURE"),k=0;k<g.length;++k){var y=g[k],n=new z;n.segment=h;n.id=y.getAttribute("id");n.label=y.getAttribute("label");var x=c(y,"START"),A=c(y,"END");(x|0)>(A|0)?(n.min=A|0,n.max=x|0):(n.min=x|0,n.max=A|0);x=y.getElementsByTagName("TYPE");0<x.length&&(x=x[0],x.firstChild&&(n.type=x.firstChild.nodeValue),n.typeId=x.getAttribute("id"),n.typeCv=x.getAttribute("cvId"));
n.type=c(y,"TYPE");!n.type&&n.typeId&&(n.type=n.typeId);n.method=c(y,"METHOD");(x=c(y,"ORIENTATION"))||(x="0");n.orientation=x;n.score=c(y,"SCORE");n.links=w(y);n.notes=r(y);x=y.getElementsByTagName("GROUP");for(A=0;A<x.length;++A){var C=x[A],B=new p;B.type=C.getAttribute("type");B.id=C.getAttribute("id");B.links=w(C);B.notes=r(C);n.groups?n.groups.push(B):n.groups=Array(B)}if(n.notes)for(x=0;x<n.notes.length;++x)A=n.notes[x],0==A.indexOf("Genename=")&&(C=new p,C.type="gene",C.id=A.substring(9),n.groups?
n.groups.push(C):n.groups=Array(C));x=y.getElementsByTagName("PART");if(0<x.length){C=[];for(A=0;A<x.length;++A)C.push(x[A].getAttribute("id"));n.parts=C}x=y.getElementsByTagName("PARENT");if(0<x.length){y=[];for(A=0;A<x.length;++A)y.push(x[A].getAttribute("id"));n.parents=y}b.push(n)}}m(b,void 0,l)}else m([],"Failed request: "+(0==e.status?"server may not support CORS":"status="+e.status))},function(a){m([],a)})};h.prototype.alignments=function(a,b,m){var e=this.dasBaseURI+"alignment?query="+a;this.doCrossDomainRequest(e,
function(a){if(a){var b=[];a=a.getElementsByTagName("alignment");for(var f=0;f<a.length;++f){for(var v=a[f],r=new d(v.getAttribute("alignType")),p=v.getElementsByTagName("alignObject"),g=0;g<p.length;++g){var h=p[g],h={id:h.getAttribute("intObjectId"),accession:h.getAttribute("dbAccessionId"),version:h.getAttribute("objectVersion"),dbSource:h.getAttribute("dbSource"),dbVersion:h.getAttribute("dbVersion")};r.objects[h.id]=h}v=v.getElementsByTagName("block");for(p=0;p<v.length;++p){for(var h=v[p],g=
{order:h.getAttribute("blockOrder"),segments:[]},h=h.getElementsByTagName("segment"),w=0;w<h.length;++w){var k=h[w],k={object:k.getAttribute("intObjectId"),min:k.getAttribute("start"),max:k.getAttribute("end"),strand:k.getAttribute("strand"),cigar:c(k,"cigar")};g.segments.push(k)}r.blocks.push(g)}b.push(r)}m(b)}else m([],"Failed request "+e)})};a.prototype.pushStyle=function(a,b,c){a||(a={type:"default"});a=R(a);b&&(a.zoom=b);a.style=c;this.styles.push(a)};h.prototype.stylesheet=function(c,m){var d,
e=this.credentials;this.stylesheet_uri?(d=this.stylesheet_uri,e=!1):d=this.dasBaseURI+"stylesheet";y(d,function(e){if(e){var l=new a;e=e.getElementsByTagName("TYPE");for(var f=0;f<e.length;++f){var d=e[f],r={};r.type=d.getAttribute("id");r.label=d.getAttribute("label");r.method=d.getAttribute("method");for(var d=d.getElementsByTagName("GLYPH"),p=0;p<d.length;++p){var g=d[p],h=g.getAttribute("zoom"),w;a:{if(g.hasChildNodes()){g=g.firstChild;do{if(g.nodeType==Node.ELEMENT_NODE){w=g;break a}g=g.nextSibling}while(null!=
g)}w=null}g=new b;g.glyph=w.localName;for(w=w.firstChild;w;){if(w.nodeType==Node.ELEMENT_NODE)if("BGGRAD"==w.localName){var k=g,n=w.localName,y,x=w;y=(y=x.getAttribute("steps"))?y|0:50;for(var A=[],C=[],x=x.getElementsByTagName("STOP"),B=0;B<x.length;++B){var q=x[B];A.push(1*q.getAttribute("score"));C.push(q.firstChild.nodeValue)}y=Q(y,A,C);k[n]=y}else g[w.localName]=w.firstChild.nodeValue;w=w.nextSibling}l.pushStyle(r,h,g)}}c(l)}else m&&m()},e)};m.prototype.sources=function(a,b,c){c||(c={});var e=
[];c.taxon&&e.push("organism="+c.taxon);c.auth&&e.push("authority="+c.auth);c.version&&e.push("version="+c.version);c=this.uri;0<e.length&&(c=c+"?"+e.join("&"));y(c,function(e){if(!e&&b)b();else{var c=[];e=e.getElementsByTagName("SOURCE");for(var f=0;f<e.length;++f){var m=e[f],d=m.getElementsByTagName("VERSION");if(!(1>d.length)){for(var r=d[0],p=r.getElementsByTagName("COORDINATES"),d=[],g=0;g<p.length;++g){var w=p[g],k=new q;k.auth=w.getAttribute("authority");k.taxon=w.getAttribute("taxid");k.version=
w.getAttribute("version");d.push(k)}for(var p=[],w=r.getElementsByTagName("CAPABILITY"),y,g=0;g<w.length;++g)k=w[g],p.push(k.getAttribute("type")),"das1:features"==k.getAttribute("type")&&(y=k.getAttribute("query_uri"),y=y.substring(0,y.length-8));g={};r=r.getElementsByTagName("PROP");for(w=0;w<r.length;++w)B(g,r[w].getAttribute("name"),r[w].getAttribute("value"));y&&(m=new h(y,{source_uri:m.getAttribute("uri"),name:m.getAttribute("title"),desc:m.getAttribute("description"),coords:d,props:g,capabilities:p}),
c.push(m))}}a(c)}})};h.prototype.doCrossDomainRequest=function(a,b,c){var e;this.xUser&&(e="Basic "+btoa(this.xUser+":"+this.xPass));try{return y(a,b,this.credentials,e)}catch(m){if(c)c(m);else throw m;}};"undefined"!==typeof u&&(u.exports={DASGroup:p,DASFeature:z,DASStylesheet:a,DASStyle:b,DASSource:h,DASSegment:n,DASRegistry:m,DASSequence:g,isDasBooleanTrue:C,isDasBooleanNotFalse:F,copyStylesheet:A})},{"./color":9,"./utils":45}],11:[function(k,u,s){function n(g,p,h){function d(){h?(a.className=
"fa fa-caret-down",p.style.display="table"):(a.className="fa fa-caret-right",p.style.display="none")}var a=q("i");d();a.addEventListener("click",function(a){a.preventDefault();a.stopPropagation();h=!h;d()},!1);g=q("h6",[a," ",g],{},{display:"block",background:"gray",color:"white",width:"100%",padding:"5px 2px",margin:"0px"});return q("div",[g,p],{})}if("undefined"!==typeof k){var h=k("./cbrowser").Browser;k=k("./utils");var q=k.makeElement,g=k.removeChildren}h.prototype.removeAllPopups=function(){g(this.hPopupHolder);
g(this.popupHolder)};h.prototype.makeTooltip=function(g,p){var h=!1,d=this,a=null,b;b=function(c){h=!1;a&&(clearTimeout(a),a=null);g.removeEventListener("mouseout",b,!1)};var m=function(b){var w=b.clientX+window.scrollX,r=b.clientY+window.scrollY;a||(a=setTimeout(function(){var b;b="function"===typeof p?p():p;var c=q("div",[q("div",null,{className:"tooltip-arrow"}),q("div",b,{className:"tooltip-inner"})],{className:"tooltip bottom in"},{display:"block",top:""+(r+20)+"px",left:""+Math.max(w-30,20)+
"px"});d.hPopupHolder.appendChild(c);var k;k=function(a){try{d.hPopupHolder.removeChild(c)}catch(b){}window.removeEventListener("mousemove",k,!1);h&&null!=g.offsetParent&&m(a)};window.addEventListener("mousemove",k,!1);a=null},1E3))};g.addEventListener("mouseover",function(a){h=!0;g.addEventListener("mouseout",b,!1);m(a)},!1);g.addEventListener("DOMNodeRemovedFromDocument",function(b){h=!1;a&&(clearTimeout(a),a=null)},!1)};h.prototype.popit=function(g,p,h,d){var a=this;d||(d={});g||(g={});var b=d.width||
200,m;g.clientX?(d=g.clientX,m=g.clientY):(d=500,m=50);d+=document.documentElement.scrollLeft||document.body.scrollLeft;m+=document.documentElement.scrollTop||document.body.scrollTop;var c=window.innerWidth,w=m,r=Math.min(d-b/2-4,c-b-30),k=q("div");k.className="popover fade "+(g.clientX?"bottom ":"")+"in";k.style.display="block";k.style.position="absolute";k.style.top=""+w+"px";k.style.left=""+r+"px";k.style.width=b+"px";276<b&&(k.style.maxWidth=b+"px");k.appendChild(q("div",null,{className:"arrow"}));
if(p){var n=q("button","",{className:"close"});n.innerHTML="&times;";n.addEventListener("mouseover",function(a){n.style.color="red"},!1);n.addEventListener("mouseout",function(a){n.style.color="black"},!1);n.addEventListener("click",function(b){b.preventDefault();b.stopPropagation();a.removeAllPopups()},!1);g=q("h4",[q("span",p,null,{maxWidth:"200px"}),n],{},{paddingLeft:"10px",paddingRight:"10px"});var F,A,s,B;s=function(a){a.stopPropagation();a.preventDefault();r+=a.clientX-F;8>r&&(r=8);r>c-b-32&&
(r=c-b-26);w+=a.clientY-A;w=Math.max(10,w);k.style.top=""+w+"px";k.style.left=""+Math.min(r,c-b-10)+"px";F=a.clientX;A=a.clientY};B=function(a){a.stopPropagation();a.preventDefault();window.removeEventListener("mousemove",s,!1);window.removeEventListener("mouseup",B,!1)};g.addEventListener("mousedown",function(a){a.preventDefault();a.stopPropagation();F=a.clientX;A=a.clientY;window.addEventListener("mousemove",s,!1);window.addEventListener("mouseup",B,!1)},!1);k.appendChild(g)}k.appendChild(q("div",
h,{className:"popover-content"},{padding:"0px"}));this.hPopupHolder.appendChild(k);var Q={node:k,displayed:!0};k.addEventListener("DOMNodeRemoved",function(a){a.target==k&&(Q.displayed=!1)},!1);return Q};"undefined"!==typeof u&&(u.exports={makeTreeTableSection:n})},{"./cbrowser":6,"./utils":45}],12:[function(k,u,s){function n(g){this.source=g;this.base=g.uri||"http://beta.rest.ensembl.org";this.species=g.species||"human";this.activityListeners=[];this.busy=0;this.type="string"===typeof g.type?[g.type]:
g.type||["regulatory"]}if("undefined"!==typeof k){var h=k("./sourceadapters").registerSourceAdapterFactory;k=k("./das");var q=k.DASStylesheet,g=k.DASStyle,z=k.DASFeature,p=k.DASGroup}n.prototype.addActivityListener=function(g){this.activityListeners.push(g)};n.prototype.notifyActivity=function(){for(var g=0;g<this.activityListeners.length;++g)try{this.activityListeners[g](this.busy)}catch(d){console.log(d)}};n.prototype.getStyleSheet=function(p){var d=new q,a=new g;a.glyph="__NONE";0<=this.type.indexOf("exon")&&
d.pushStyle({type:"transcript"},null,a);(0<=this.type.indexOf("exon")||0<=this.type.indexOf("transcript"))&&d.pushStyle({type:"gene"},null,a);a=new g;a.glyph="BOX";a.FGCOLOR="black";a.BGCOLOR="red";a.HEIGHT=8;a.BUMP=!0;a.LABEL=!0;a.ZINDEX=10;d.pushStyle({type:"cds"},null,a);a=new g;a.glyph="SQUARE";a.BUMP="yes";a.LABEL="no";a.FGCOLOR="blue";d.pushStyle({type:"variation",method:".+_UTR_variant"},null,a);a=new g;a.glyph="TRIANGLE";a.DIRECTION="S";a.BUMP="yes";a.LABEL="no";a.FGCOLOR="blue";d.pushStyle({type:"variation",
method:"missense_variant"},null,a);a=new g;a.glyph="TRIANGLE";a.DIRECTION="N";a.BUMP="yes";a.LABEL="no";a.FGCOLOR="blue";d.pushStyle({type:"variation",method:"splice_.+_variant"},null,a);a=new g;a.glyph="STAR";a.POINTS=6;a.BUMP="yes";a.LABEL="no";a.FGCOLOR="blue";d.pushStyle({type:"variation",method:"regulatory_region_variant"},null,a);a=new g;a.glyph="PLIMSOLL";a.BUMP="yes";a.LABEL="no";a.FGCOLOR="rgb(50,80,255)";a.STROKECOLOR="black";d.pushStyle({type:"variation"},null,a);a=new g;a.glyph="SQUARE";
a.BUMP="yes";a.LABEL="no";a.BGCOLOR="#888888";a.FGCOLOR="red";d.pushStyle({type:"indel",method:".+_UTR_variant"},null,a);a=new g;a.glyph="TRIANGLE";a.DIRECTION="S";a.BUMP="yes";a.LABEL="no";a.BGCOLOR="#888888";a.FGCOLOR="red";d.pushStyle({type:"indel",method:"missense_variant"},null,a);a=new g;a.glyph="TRIANGLE";a.DIRECTION="N";a.BUMP="yes";a.LABEL="no";a.BGCOLOR="#888888";a.FGCOLOR="red";d.pushStyle({type:"indel",method:"splice_.+_variant"},null,a);a=new g;a.glyph="STAR";a.POINTS=6;a.BUMP="yes";
a.LABEL="no";a.BGCOLOR="#888888";a.FGCOLOR="red";d.pushStyle({type:"indel",method:"regulatory_region_variant"},null,a);a=new g;a.glyph="PLIMSOLL";a.BUMP="yes";a.LABEL="no";a.BGCOLOR="#888888";a.FGCOLOR="red";a.STROKECOLOR="black";d.pushStyle({type:"indel"},null,a);a=new g;a.glyph="BOX";a.FGCOLOR="black";a.BGCOLOR="orange";a.HEIGHT=8;a.BUMP=!0;a.LABEL=!0;a.ZINDEX=20;d.pushStyle({type:"default"},null,a);return p(d)};n.prototype.getScales=function(){return[]};n.prototype.fetch=function(g,d,a,b,m,c,h){var r=
this;d=this.base+"/feature/region/"+this.species+"/"+g+":"+d+"-"+a;a=[];for(b=0;b<this.type.length;++b)a.push("feature="+this.type[b]);a.push("content-type=application/json");d=d+"?"+a.join(";");var k=new XMLHttpRequest;k.onreadystatechange=function(){if(4==k.readyState)if(r.busy--,r.notifyActivity(),300<=k.status){var a="Error code "+k.status;try{var b=JSON.parse(k.response);b.error&&(a=b.error)}catch(c){}h(a,null)}else{for(var a=JSON.parse(k.response),b=[],m=0;m<a.length;++m){var d=a[m],n=[],q=
new z;q.segment=g;q.min=d.start|0;q.max=d.end|0;q.type=d.feature_type||"unknown";q.id=d.ID;if(d.Parent){var s=new p;s.id=d.Parent;q.groups=[s]}d.strand&&(0>d.strand?q.orientation="-":0<d.strand&&(q.orientation="+"));d.consequence_type&&(q.method=d.consequence_type);d.alt_alleles&&(n.push("Alleles="+d.alt_alleles.join("/")),1<d.alt_alleles.length&&(d.alt_alleles[1].length!=d.alt_alleles[0].length||"-"==d.alt_alleles[1])&&(q.type="indel"));0<n.length&&(q.notes=n);b.push(q)}h(null,b)}};r.busy++;r.notifyActivity();
k.open("GET",d,!0);k.responseType="text";k.send("")};h("ensembl",function(g){return{features:new n(g)}})},{"./das":10,"./sourceadapters":32}],13:[function(k,u,s){if("undefined"!==typeof k)var n=k("./cbrowser").Browser,h=k("./utils").shallowCopy,q=k("./sha1").hex_sha1,g=k("./das").copyStylesheet;n.prototype.exportFullConfig=function(g){g={chr:this.chr,viewStart:this.viewStart|0,viewEnd:this.viewEnd|0,cookieKey:"dalliance_"+q(Date.now()),coordSystem:this.coordSystem,sources:this.exportSourceConfig(),
chains:this.exportChains()};this.prefix&&(g.prefix=this.prefix);return g};n.prototype.exportChains=function(){var g={},p=this.chains||{},h;for(h in p)g[h]=p[h].exportConfig();return g};n.prototype.exportSourceConfig=function(k){k=[];for(var p=0;p<this.tiers.length;++p){var n=this.tiers[p],d=h(n.dasSource);d.coords=void 0;d.props=void 0;d.disabled||(d.disabled=void 0);n.config.stylesheet?(d.style=n.config.stylesheet.styles,d.stylesheet_uri=void 0):d.style&&(d.style=g({styles:d.style}).styles);"string"===
typeof n.config.name&&(d.name=n.config.name);void 0!==n.config.height&&(d.forceHeight=n.config.height);void 0!==n.config.forceMin&&(d.forceMin=n.config.forceMin);n.config.forceMinDynamic&&(d.forceMinDynamic=n.config.forceMinDynamic);void 0!==n.config.forceMax&&(d.forceMax=n.config.forceMax);n.config.forceMaxDynamic&&(d.forceMaxDynamic=n.config.forceMaxDynamic);k.push(d)}return k};n.prototype.exportPageTemplate=function(g){g=g||{};return'<html>\n  <head>\n    <script language="javascript" src="'+this.resolveURL("$$dalliance-compiled.js")+
'">\x3c/script>\n    <script language="javascript">\n      var dalliance_browser = new Browser('+JSON.stringify(this.exportFullConfig(g),null,2)+');\n    \x3c/script>\n  </head>\n  <body>\n    <div id="svgHolder">Dalliance goes here</div>\n  </body>\n<html>\n'}},{"./cbrowser":6,"./das":10,"./sha1":31,"./utils":45}],14:[function(k,u,s){if("undefined"!==typeof k){var n=k("./cbrowser").Browser;k=k("./utils");var h=k.makeElement,q=k.removeChildren}n.prototype.openExportPanel=function(){var g=this;if("export"===
this.uiMode)this.hideToolPanel(),this.setUiMode("none");else{var k=h("div",null,{className:"export-form"}),p=h("select");p.appendChild(h("option","SVG",{value:"svg"}));p.appendChild(h("option","Dalliance config",{value:"config"}));p.appendChild(h("option","Dalliance sources",{value:"sources"}));p.appendChild(h("option","Dalliance page",{value:"page"}));p.value="svg";p.addEventListener("change",function(a){q(b)},!1);k.appendChild(h("p",["Export as: ",p]));var n=h("input",null,{type:"checkbox",checked:this.exportHighlights});
n.addEventListener("change",function(a){g.exportHighlights=n.checked;g.storeStatus()},!1);var d=h("input",null,{type:"checkbox",checked:this.exportRuler});d.addEventListener("change",function(a){g.exportRuler=d.checked;g.storeStatus()},!1);var a=h("button","Export",{className:"btn btn-primary"});a.addEventListener("click",function(a){q(b);var m,r,k;"svg"===p.value?(m=URL.createObjectURL(g.makeSVG({highlights:n.checked,ruler:d.checked?g.rulerLocation:"none"})),r="SVG",k="image/svg"):"config"===p.value?
(k=JSON.stringify(g.exportFullConfig(),null,2),r=new Blob([k],{type:"text/plain"}),m=URL.createObjectURL(r),r="Configuration",k="text/plain"):"sources"===p.value?(k=JSON.stringify(g.exportSourceConfig(),null,2),r=new Blob([k],{type:"text/plain"}),m=URL.createObjectURL(r),r="Source array",k="text/plain"):"page"===p.value&&(r=g.exportPageTemplate(),k="text/html",r=new Blob([r],{type:k}),m=URL.createObjectURL(r),r="Page template");m&&(a=h("a","[Download]",{href:m,download:"dalliance-view.svg",type:k}),
k=h("a","[Preview in browser]",{href:m,type:k,target:"_new"}),b.appendChild(h("p",[""+r+" created: ",a,k])))},!1);g.addViewListener(function(){q(b)});g.addTierListener(function(){q(b)});var b=h("p",""),m=h("table",[h("tr",[h("th","Include highlights",{},{width:"200px",textAlign:"right"}),h("td",n)]),h("tr",[h("th","Include vertical guideline"),h("td",d)])]);k.appendChild(m);k.appendChild(a);k.appendChild(b);"none"!==this.uiMode&&this.hideToolPanel();this.browserHolder.insertBefore(k,this.svgHolder);
this.activeToolPanel=k;this.setUiMode("export")}}},{"./cbrowser":6,"./utils":45}],15:[function(k,u,s){u=k("./cbrowser");s=k("./chainset");var n=k("./sourceadapters"),h=k("./utils");k=k("./das");window.Browser=u.Browser;window.Chainset=s.Chainset;window.makeElement=h.makeElement;window.dalliance_registerSourceAdapterFactory=n.registerSourceAdapterFactory;window.dalliance_registerParserFactory=n.registerParserFactory;window.dalliance_makeParser=n.makeParser;window.DASFeature=k.DASFeature;window.DASGroup=
k.DASGroup;window.DASStylesheet=k.DASStylesheet;window.DASStyle=k.DASStyle;window.DASSource=k.DASSource},{"./cbrowser":6,"./chainset":7,"./das":10,"./sourceadapters":32,"./utils":45}],16:[function(k,u,s){function n(){this.glyphs=[];this.height=0;this.quant=null}function h(f){Date.now();X=f.viewport.getContext("2d");a(f);f.padding="number"===typeof f.dasSource.padding?f.dasSource.padding:W;var e=[],b={},c={},l;for(l in f.ungroupedFeatures)for(var m=f.ungroupedFeatures[l],t=0;t<m.length;++t){var r=
m[t];if(!r.parts){var p=f.styleForFeature(r);if(p)if("LINEPLOT"==p.glyph)d(b,p.id,r),c[p.id]=p;else{var h=g(r,0,p,f);h&&e.push(h)}}}for(var k in b)l=b[k],p=c[k],"LINEPLOT"==p.glyph&&e.push(z(l,p,f));if(f.dasSource.collapseSuperGroups&&!f.bumped)for(var w in f.superGroups){b=f.superGroups[w];f.groups[w]=x(f.groups[w]);f.groups[w].isSuperGroup=!0;c={};k=1E10;m=-1E10;t=null;for(h=0;h<b.length;++h)if(l=f.groupedFeatures[b[h]]){for(p=0;p<l.length;++p)r=l[p],d(c,r.type,r),k=Math.min(r.min,k),m=Math.max(r.max,
m),r.segment&&!t&&(t=r.segment);if(f.groups[w]&&!f.groups[w].links||0==f.groups[w].links.length)f.groups[w].links=f.groups[b[0]].links;delete f.groupedFeatures[b[h]]}f.groups[w].max=m;f.groups[w].min=k;f.groups[w].segment=t;for(var y in c){l=c[y];k=l[0];m=null;for(p=0;p<l.length;++p)r=l[p],r=new P(r.min,r.max),m=m?H(m,r):r;m=m.ranges();for(t=0;t<m.length;++t){for(var D=m[t],G=((D.max()|0)-(D.min()|0)+1)*b.length,C=0,p=0;p<l.length;++p)if(r=l[p],(r.min|0)<=D.max()&&(r.max|0)>=D.min())var M=Math.max(r.min|
0,D.min()),r=Math.min(r.max|0,D.max()),C=C+(r-M+1);var r=new N,B;for(B in k)r[B]=k[B];r.min=D.min();r.max=D.max();r.label&&1<b.length&&(r.label+=" ("+b.length+" vars)");r.visualWeight=1*C/G;d(f.groupedFeatures,w,r)}}delete f.superGroups[w]}B=[];for(var F in f.groupedFeatures)B.push(F);B.sort(function(a,e){var b=f.groupedFeatures[a][0].score-f.groupedFeatures[e][0].score;return 0<b?-1:0==b?0:1});y={};for(r=0;r<B.length;++r)if(F=B[r],h=q(f.groupedFeatures[F],0,f.groups[F],f,f.dasSource.collapseSuperGroups&&
!f.bumped?"collapsed_gene":"tent"))h.group=f.groups[F],y[F]=h;for(w in f.superGroups){b=f.superGroups[w];F=[];k=1E10;m=-1E10;for(B=0;B<b.length;++B)r=y[b[B]],y[b[B]]=null,r&&(F.push(r),k=Math.min(k,r.min()),m=Math.max(m,r.max()));for(B=0;B<F.length;++B)r=F[B],e.push(new A(r,k,m))}for(h in y)(r=y[h])&&e.push(r);w=new n;F=[];y=f.dasSource.subtierMax||V;B=0;a:for(;B<e.length;++B)if(h=e[B],h.bump&&(f.bumped||f.dasSource.collapseSuperGroups)){for(r=0;r<F.length;++r)if(b=F[r],b.hasSpaceFor(h)){b.add(h);
continue a}F.length>=y||(b=new n,b.add(h),F.push(b))}else w.add(h);0<w.glyphs.length&&(F=[w].concat(F));for(r=0;r<F.length;++r)b=F[r],b.quant&&b.glyphs.unshift(new v(b.height));for(r=0;r<F.length;++r)b=F[r],b.glyphs.sort(function(a,f){return(a.zindex||0)-(f.zindex||0)});f.subtiers=F;f.glyphCacheOrigin=f.browser.viewStart;Date.now()}function q(a,f,e,b,c){c=b.styleForFeature(e);var l,d=!1,v=[];f=null;for(var r=0;r<a.length;++r){var t=a[r];t.orientation&&null==f&&(f=t.orientation);!l&&t.label&&(l=t.label);
var p=b.styleForFeature(t);p&&!t.parts&&(S(p.LABEL)&&(d=!0),(t=g(t,0,p,b,null,!0))&&v.push(t))}if(0==v.length)return null;a="flat";c&&"LINE"===c.glyph||(b.dasSource.collapseSuperGroups&&!b.bumped?"+"===f?a="collapsed+":"-"===f&&(a="collapsed-"):"+"===f?a="hat+":"-"===f&&(a="hat-"));b=null;if(l&&d||c&&(S(c.LABEL)||S(c.LABELS)))b=e.label||l;e=new m(v,a);b&&("+"===f?b=">"+b:"-"===f&&(b="<"+b),e=new w(X,e,b,!1));e.bump=!0;return e}function g(a,c,d,v,g,p){var h=v.browser.scale,k=v.browser.viewStart,n=
d.glyph||"BOX",q=a.min,x=a.max,s=a.orientation,P=a.score,z=a.label||a.id,H=(q-k)*h,u=Math.max((x-k+1)*h,H+1),N=v.forceHeight||d.HEIGHT||g||12,I=N*=1,k=d.BUMP&&S(d.BUMP),W;if("CROSS"===n||"EX"===n||"TRIANGLE"===n||"DOT"===n||"SQUARE"===n||"STAR"===n||"PLIMSOLL"===n){var O=d.FGCOLOR||"black",q=d.BGCOLOR||"none",h=d.STROKECOLOR;d.BGITEM&&a.itemRgb?O=a.itemRgb:S(d.COLOR_BY_SCORE2)&&(x=d.BGGRAD||d._gradient,x||(x=M(50,d.COLOR1,d.COLOR2,d.COLOR3),d._gradient=x),N=a.score2,void 0==N&&O||(I=d.MIN2?1*d.MIN2:
0,I=(1*(N||0)-I)/((d.MAX2?1*d.MAX2:1)-I)*x.length|0,0>I&&(I=0),I>=x.length&&(I=x.length-1),O=x[I]));N=v.forceHeight||d.HEIGHT||g||12;I=N*=1;g=d.SIZE||N;d.RSIZE&&(g=1*d.RSIZE*N);d.STROKETHRESHOLD&&g<1*d.STROKETHRESHOLD&&(h=null);g*=1;N=(H+u)/2;x=g/2;"EX"===n?h=new y(N,g,O):"TRIANGLE"===n?h=new C(N,g,d.DIRECTION||"N",d.LINEWIDTH||g,O,h):"DOT"===n?h=new F(N,g,O,h):"PLIMSOLL"===n?h=new D(N,g,0.2*g,O,h):"SQUARE"===n?h=new b(N-x,0,g,g,O,h):"STAR"===n?(n=5,d.POINTS&&(n=d.POINTS|0),h=new G(N,x,n,O,h)):h=
new r(N,g,O);q&&"none"!=q&&5<u-H&&(H=new b(H,0,u-H,g,q),h=new m([H,h]));if(S(d.SCATTER)){q=v.quantMin(d);(O=v.quantMax(d))||(O=0>q?0:10);q||(q=0);v=(1*P-q)/(O-q);P=-1*q/(O-q);if(0>v||1<v)return null;v>=P?(N=Math.max(1,(v-P)*I),c=c+(1-P)*I-N):(Math.max(1,(v-P)*I),c+=(1-P)*I);W={min:q,max:O};H=0;u="undefined"!==typeof a.forceLabel?a.forceLabel:d.LABEL;ha(u)&&z&&!p&&(h=new w(X,h,z,!0,null,"above"==u?"above":"below"),"above"==u&&(H=h.textHeight+2),p=!0);h=new l(h,0,c-x-H,I)}}else if("HISTOGRAM"===n||
"GRADIENT"===n&&"undefined"!==P)q=v.quantMin(d),(O=v.quantMax(d))||(O=0>q?0:10),q||(q=0),1*P<1*q&&(P=q),1*P>1*O&&(P=O),v=(1*P-q)/(O-q),P=-1*q/(O-q),"HISTOGRAM"===n&&(v>=P?(N=Math.max(1,(v-P)*I),c=c+(1-P)*I-N):(N=Math.max(1,(P-v)*I),c+=(1-P)*I),W={min:q,max:O}),O=d.FGCOLOR||null,q=d.BGCOLOR||d.COLOR1||"green",d.BGITEM&&a.itemRgb&&(q=a.itemRgb),P=d.ALPHA?1*d.ALPHA:null,d.BGGRAD&&(x=d.BGGRAD,I=v*x.length|0,0>I&&(I=0),I>=x.length&&(I=x.length-1),q=x[I]),d.COLOR2&&(x=d._gradient,x||(x=M(50,d.COLOR1,d.COLOR2,
d.COLOR3),d._gradient=x),I=v*x.length|0,0>I&&(I=0),I>=x.length&&(I=x.length-1),q=x[I]),h=new b(H,c,u-H,N,q,O,P);else if("HIDDEN"===n)h=new A(null,H,u),p=!0;else if("ARROW"===n)v=d.FGCOLOR||"purple",c=S(d.PARALLEL),q=S(d.SOUTHWEST),x=S(d.NORTHEAST),h=new L(H,u,N,v,c,q,x);else if("ANCHORED_ARROW"===n)O=d.FGCOLOR||"none",q=d.BGCOLOR||"green",h=new R(H,u,N,q,O,s),h.bump=!0;else if("SPAN"===n)O=d.FGCOLOR||"black",h=new B(H,u,N,O);else if("LINE"===n)O=d.FGCOLOR||"black",h=new Q(H,u,N,d.STYLE||"solid",s,
O);else if("PRIMERS"===n)O=d.FGCOLOR||"black",q=d.BGCOLOR||"red",h=new K(H,u,N,q,O);else if("TEXT"===n)v=d.STRING||"text",q=d.FGCOLOR||"black",h=new e(X,H,u,N,q,v);else if("TOOMANY"===n)O=d.FGCOLOR||"gray",q=d.BGCOLOR||"orange",h=new E(H,u,N,q,O);else if("POINT"===n)N=v.forceHeight||d.HEIGHT||30,q=v.quantMin(d),O=v.quantMax(d),v=(1*P-q)/(O-q),c=1*N/(O-q)*(P-1*q)|0,W={min:q,max:O},q=d.FGCOLOR||d.COLOR1||"black",d.COLOR2&&(x=d._gradient,x||(x=M(50,d.COLOR1,d.COLOR2,d.COLOR3),d._gradient=x),I=v*x.length|
0,0>I&&(I=0),I>=x.length&&(I=x.length-1),q=x[I]),h=new f((H+u)/2,N-c,N,q);else if("__SEQUENCE"===n){n=O=a.seq;I=g=a.quals;c=S(d.__INSERTIONS);P=[];if(a.cigar)for(var s=da(a.cigar),I=n="",V=0,ba=0;ba<s.length;++ba){var $=s[ba];if("M"==$.op)n+=O.substr(V,$.cnt),I+=g.substr(V,$.cnt),V+=$.cnt;else if("D"==$.op)for(var ga=0;ga<$.cnt;++ga)n+="-",I+="Z";else if("I"==$.op){var aa=O.substr(V,$.cnt),ga=new C(H+n.length*h,5,"S",5,"red");c&&(ga=new w(X,ga,aa,!1,"center","above","7px sans-serif"));ga.feature=
{label:"Insertion: "+aa,type:"insertion",method:"insertion"};P.push(ga);V+=$.cnt}else"S"==$.op?V+=$.cnt:console.log("unknown cigop"+$.op)}h=null;if(v.currentSequence&&(O=v.currentSequence.start|0,s=v.currentSequence.end|0,O<=x&&s>=q)){g=Math.max(q,O);s=Math.min(x,s);for(h=v.currentSequence.seq.substr(g-O,s-g+1);q<g;)h="N"+h,g--;for(;x>s;)h+="N",s++}h=new t(v.browser.baseColors,H,u,N,n,h,d.__SEQCOLOR,I);c&&(h=new l(h,0,7));0<P.length&&(P.splice(0,0,h),h=new m(P))}else if("__INSERTION"===n)ga=new C(H,
5,"S",5,"red"),h=new w(X,ga,a.insertion||a.altAlleles[0],!1,"center","above","7px sans-serif"),1<u-H&&(q=d.BGCOLOR||d.COLOR1||"green",H=new b(H,5,u-H,N,q,O),h=new m([H,h]));else{if("__NONE"===n)return null;O=d.FGCOLOR||null;q=d.BGCOLOR||d.COLOR1||"green";d.BGITEM&&a.itemRgb&&(q=a.itemRgb);h=new b(H,0,u-H,N,q,O)}(S(d.LABEL)||a.forceLabel)&&z&&!p&&(h=new w(X,h,z,!1));k&&(h.bump=!0);h.feature=a;W&&(h.quant=W);d.ZINDEX&&(h.zindex=d.ZINDEX|0);return h}function z(a,f,e){var b=e.browser.viewStart,l=e.browser.scale,
d=e.forceHeight||f.HEIGHT||30,m=e.quantMin(f);e=e.quantMax(f);for(var v=1*d/(e-m),r=f.FGCOLOR||f.COLOR1||"black",t=[],g=0;g<a.length;++g){var h=a[g],p=d-((h.score-1*m)*v|0);t.push((((h.min|0)+(h.max|0))/2-b)*l);t.push(p)}a=new c(t,r,d);a.quant={min:m,max:e};f.ZINDEX&&(a.zindex=f.ZINDEX|0);return a}if("undefined"!==typeof k){var p=k("./utils"),x=p.shallowCopy,d=p.pusho,p=k("./tier").DasTier,a=k("./features").sortFeatures;s=k("./glyphs");var b=s.BoxGlyph,m=s.GroupGlyph,c=s.LineGraphGlyph,w=s.LabelledGlyph,
r=s.CrossGlyph,y=s.ExGlyph,C=s.TriangleGlyph,F=s.DotGlyph,A=s.PaddedGlyph,R=s.AArrowGlyph,B=s.SpanGlyph,Q=s.LineGlyph,K=s.PrimersGlyph,L=s.ArrowGlyph,E=s.TooManyGlyph,e=s.TextGlyph,t=s.SequenceGlyph,l=s.TranslatedGlyph,f=s.PointGlyph,v=s.GridGlyph,G=s.StarGlyph,D=s.PlimsollGlyph,M=k("./color").makeGradient;s=k("./spans");var P=s.Range,H=s.union;s=k("./das");var N=s.DASFeature,S=s.isDasBooleanTrue,ha=s.isDasBooleanNotFalse,da=k("./cigar").parseCigar,I=k("./numformats").formatQuantLabel}var W=3,V=100;
n.prototype.indexFor=function(a){a=a.min();for(var f=0,e=this.glyphs.length;e>f;){var b=(f+e)/2|0;if(b>=this.glyphs.length)return this.glyphs.length;a<this.glyphs[b].min()?e=b:f=b+1}return e};n.prototype.add=function(a){var f=this.indexFor(a);this.glyphs.splice(f,0,a);this.height=Math.max(this.height,a.height());a.quant&&null==this.quant&&(this.quant=a.quant)};n.prototype.hasSpaceFor=function(a){var f=this.indexFor(a);return 0<f&&this.glyphs[f-1].max()>=a.min()||f<this.glyphs.length&&this.glyphs[f].min()<=
a.max()?!1:!0};var X;p.prototype.paint=function(){Date.now();var a=this.browser.retina&&1<window.devicePixelRatio,f=this.subtiers;if(f){var e=this.browser.featurePanelWidth+2E3;a&&(e*=2);var b=this.viewport.width|0;b<e-50&&(this.viewport.width=b=e);for(var c=this.padding,l=0;l<f.length;++l)c=c+f[l].height+this.padding;l=c=Math.max(c+6,this.browser.minTierHeight);a&&(l*=2);l!=this.viewport.height&&(this.viewport.height=l);Math.max(c,this.browser.minTierHeight);this.viewport.style.left="-1000px";this.viewport.style.width=
a?""+b/2+"px":""+b+"px";this.viewport.style.height=""+c+"px";this.layoutHeight=Math.max(c,this.browser.minTierHeight);this.updateHeight();this.drawOverlay();this.norigin=this.browser.viewStart;e=this.viewport.getContext("2d");e.clearRect(0,0,b,l);e.save();a&&e.scale(2,2);if(this.background&&(e.fillStyle=this.background,this.knownCoverage))for(var l=this.knownCoverage.ranges(),d=0;d<l.length;++d){var m=l[d],v=(m.min()-this.browser.viewStart)*this.browser.scale+1E3,m=(m.max()-this.browser.viewStart)*
this.browser.scale+1E3;e.fillRect(v,0,m-v,c)}c=(this.glyphCacheOrigin-this.browser.viewStart)*this.browser.scale+1E3;e.translate(c,this.padding);for(l=0;l<f.length;++l){for(var r=null,d=f[l].glyphs,v=0;v<d.length;++v)m=d[v],m.min()<b-c&&m.max()>-c&&(m=d[v],m.draw(e),m.quant&&(r=m.quant));e.translate(0,f[l].height+this.padding)}e.restore();r&&this.quantLeapThreshold&&this.featureSource&&this.browser.sourceAdapterIsCapable(this.featureSource,"quantLeap")&&(f=3+f[0].height*(1-(this.quantLeapThreshold-
r.min)/(r.max-r.min)),e.save(),a&&e.scale(2,2),e.strokeStyle="red",e.lineWidth=0.3,e.beginPath(),e.moveTo(0,f),e.lineTo(5E3,f),e.stroke(),e.restore());this.paintQuant();Date.now()}};p.prototype.paintQuant=function(){if(this.quantOverlay){var a=this.browser.retina&&1<window.devicePixelRatio,f;this.subtiers&&0<this.subtiers.length&&(f=this.subtiers[0].quant);if(f){var e=this.subtiers[0].height;this.quantOverlay.height=this.viewport.height;this.quantOverlay.width=a?100:50;this.quantOverlay.style.height=
""+(a?this.quantOverlay.height/2:this.quantOverlay.height)+"px";this.quantOverlay.style.width="50px";this.quantOverlay.style.display="block";var b=this.quantOverlay.getContext("2d");a&&b.scale(2,2);a=2;40<e&&(a=1+(e/20|0));var c=(e+2*this.padding)/(a-1),l=(f.max-f.min)/(a-1);b.fillStyle="white";b.globalAlpha=0.6;"right"==this.browser.rulerLocation?b.fillRect(20,0,30,e+2*this.padding):b.fillRect(0,0,30,e+2*this.padding);b.globalAlpha=1;b.strokeStyle="black";b.lineWidth=1;b.beginPath();if("right"==
this.browser.rulerLocation){b.moveTo(42,this.padding);b.lineTo(50,this.padding);b.lineTo(50,e+this.padding);b.lineTo(42,e+this.padding);for(var d=1;d<a-1;++d){var m=d*c;b.moveTo(50,m);b.lineTo(45,m)}}else for(b.moveTo(8,this.padding),b.lineTo(0,this.padding),b.lineTo(0,e+this.padding),b.lineTo(8,e+this.padding),d=1;d<a-1;++d)m=d*c,b.moveTo(0,m),b.lineTo(5,m);b.stroke();b.fillStyle="black";if("right"==this.browser.rulerLocation)for(b.textAlign="right",b.fillText(I(f.max),41,8),b.fillText(I(f.min),
41,e+this.padding),d=1;d<a-1;++d)m=d*c,b.fillText(I(1*f.max-d*l),41,m+3);else for(b.textAlign="left",b.fillText(I(f.max),9,8),b.fillText(I(f.min),9,e+this.padding),d=1;d<a-1;++d)m=d*c,b.fillText(I(1*f.max-d*l),9,m+3)}else this.quantOverlay.style.display="none"}};p.prototype.styleForFeature=function(a){var f=this.browser.zoomForCurrentScale();if(!this.stylesheet)return null;for(var e=null,b=this.stylesheet.styles,c=0;c<b.length;++c){var l=b[c];if(!(l.zoom&&l.zoom!=f||l.orientation&&l.orientation!=
a.orientation)){var d=l._labelRE;d&&d.test||(d=new RegExp("^"+l.label+"$"),l._labelRE=d);if(!l.label||d.test(a.label))if(d=l._methodRE,d&&d.test||(d=new RegExp("^"+l.method+"$"),l._methodRE=d),!l.method||d.test(a.method)){if(l.type)if("default"==l.type){e||(e=l.style);continue}else if(d=l._typeRE,d&&d.test||(d=new RegExp("^"+l.type+"$"),l._typeRE=d),!d.test(a.type))continue;return l.style}}}return e};p.prototype.quantMin=function(a){return this.forceMinDynamic?this.currentFeaturesMinScore||0:"number"===
typeof this.forceMin?this.forceMin:a.MIN||this.currentFeaturesMinScore||0};p.prototype.quantMax=function(a){return this.forceMaxDynamic?this.currentFeaturesMaxScore||0:"number"===typeof this.forceMax?this.forceMax:a.MAX||this.currentFeaturesMaxScore||0};"undefined"!==typeof u&&(u.exports={drawFeatureTier:h})},{"./cigar":8,"./color":9,"./das":10,"./features":18,"./glyphs":19,"./numformats":24,"./spans":33,"./tier":41,"./utils":45}],17:[function(k,u,s){function n(d,a,b){var m=g(b.type,a.type),c=g(b.label,
a.label,b.id,a.id);c&&0!=c.indexOf("__dazzle")&&(m=m+": "+c);this.hit=d;this.feature=a;this.group=b;this.title=m;this.sections=[]}function h(d,a){var b=[];if(d)for(var m=0;m<d.length;++m)z(b,d[m]);if(a)for(m=0;m<a.length;++m)z(b,a[m]);return b}if("undefined"!==typeof k){var q=k("./cbrowser").Browser;k=k("./utils");var g=k.pick,z=k.pushnew,p=k.makeElement}var x=/^([A-Za-z]+)=(.+)/;q.prototype.addFeatureInfoPlugin=function(d){this.featureInfoPlugins||(this.featureInfoPlugins=[]);this.featureInfoPlugins.push(d)};
n.prototype.setTitle=function(d){this.title=d};n.prototype.add=function(d,a){"string"===typeof a&&(a=p("span",a));this.sections.push({label:d,info:a})};q.prototype.featurePopup=function(d,a,b,m){var c=b.length;a=0<=--c?b[c]:{};var g=0<=--c?b[c]:{};b=new n(b,a,g);b.tier=m;for(var c=this.featureInfoPlugins||[],r=0;r<c.length;++r)try{c[r](a,b)}catch(k){console.log(k.stack||k)}c=m.featureInfoPlugins||[];for(r=0;r<c.length;++r)try{c[r](a,b)}catch(q){console.log(q.stack||q)}this.removeAllPopups();m=p("table",
null,{className:"table table-striped table-condensed"});m.style.width="100%";m.style.margin="0px";c=0;a.method&&(r=p("tr",[p("th","Method"),p("td",a.method)]),m.appendChild(r),++c);r=g.segment?g:a;r=p("tr",[p("th","Location"),p("td",r.segment+":"+r.min+"-"+r.max,{},{minWidth:"200px"})]);m.appendChild(r);++c;void 0!==a.score&&null!==a.score&&"-"!=a.score&&(r=p("tr",[p("th","Score"),p("td",""+a.score)]),m.appendChild(r),++c);(r=h(g.links,a.links))&&0<r.length&&(r=p("tr",[p("th","Links"),p("td",r.map(function(a){return p("div",
p("a",a.desc,{href:a.uri,target:"_new"}))}))]),m.appendChild(r),++c);a=h(g.notes,a.notes);for(g=0;g<a.length;++g){var r="Note",F=a[g],A=F.match(x);A&&(r=A[1],F=A[2]);r=p("tr",[p("th",r),p("td",F)]);m.appendChild(r);++c}for(a=0;a<b.sections.length;++a)c=b.sections[a],m.appendChild(p("tr",[p("th",c.label),p("td",c.info)]));this.popit(d,b.title||"Feature",m,{width:450})}},{"./cbrowser":6,"./utils":45}],18:[function(k,u,s){function n(g){for(var k=g.browser.drawnStart,p=g.browser.drawnEnd,n={},d={},a=
{},b={},m={},c={},w={},r={},y=[],C,F,A,s=function(){A={};for(var a=0;a<g.currentFeatures.length;++a){var f=g.currentFeatures[a];f.id&&(A[f.id]=f)}},B=function(a){var f=[];if(a.parents)for(var e=0;e<a.parents.length;++e){var b=a.parents[e],c=A[b];c&&"SO:0000704"==c.typeCv&&pushnew(f,b)}return f},Q=0;Q<g.currentFeatures.length;++Q){var u=g.currentFeatures[Q];if(!u.parts){var L=u.min<=p&&u.max>=k;if(u.min&&u.max){if(u.score&&"."!=u.score&&"-"!=u.score){var E=1*u.score;if(!C||E<C)C=E;if(!F||E>F)F=E}var E=
[],e=null;if(u.groups)for(var t=0;t<u.groups.length;++t){var l=u.groups[t],f=l.id;if("gene"==l.type)e=f,c[f]=l;else if("translation"!=l.type){h(d,f,u);c[f]=l;E.push(f);l=b[f];if(!l||u.min<l)b[f]=u.min;l=m[f];if(!l||u.max>l)m[f]=u.max}}if(u.parents)for(A||s(),t=0;t<u.parents.length;++t){var v=u.parents[t],G=A[v];if(G){G.parts||(G.parts=[u]);q(d,v,G);h(d,v,u);c[v]||(c[v]={type:G.type,id:G.id,label:G.label||G.id});E.push(v);l=b[v];if(!l||u.min<l)b[v]=u.min;l=m[v];if(!l||u.max>l)m[v]=u.max;l=B(G);0<l.length&&
(e=l[0],v=A[l[0]],c[l[0]]={type:v.type,id:v.id,label:v.label||v.id},g.dasSource.collapseSuperGroups||(g.dasSource.collapseSuperGroups=!0))}}if(0==E.length)L&&h(n,u.type,u);else if(e)for(l=0;l<E.length;++l)f=E[l],q(w,e,f),r[f]=e}else y.push(u)}}for(f in d)y=c[f],"number"!==typeof y.min&&(y.min=b[f]),"number"!==typeof y.max&&(y.max=m[f]),m[f]>=k&&b[f]<=p&&(a[f]=d[f]);g.ungroupedFeatures=n;g.groupedFeatures=a;g.groups=c;g.superGroups=w;g.groupsToSupers=r;C&&(0<C?C=0:0>F&&(F=0),g.currentFeaturesMinScore=
C,g.currentFeaturesMaxScore=F)}if("undefined"!==typeof k){k=k("./utils");var h=k.pusho,q=k.pushnewo}"undefined"!==typeof u&&(u.exports={sortFeatures:n})},{"./utils":45}],19:[function(k,u,s){function n(a,e){this._stroke=a;this._fill=e}function h(a,e,b,c,l,d,m,g){this.x=a;this.y=e;this._width=b;this._height=c;this.fill=l;this.stroke=d;this._alpha=m;this._radius=g||0}function q(a,e){this.glyphs=a;this.connector=e;this.h=a[0].height();for(var b=[],c=0;c<a.length;++c){var l=a[c];b.push(new E(l.min(),l.max()));
this.h=Math.max(this.h,l.height())}this.coverage=L(b)}function g(a,e,b){this.points=a;this.color=e;this._height=b||50}function z(a,e,b,c,l,d,m){this.glyph=e;this.text=b;this.anchor=l||"left";this.align=d||"below";m&&(this.font=m);this.font&&(a.save(),a.font=this.font);b=a.measureText(b);this.font&&a.restore();this.textLen=b.width;this.textHeight=5;this.bump=e.bump;this.measured=!c}function p(a,e,b){this._x=a;this._height=e;this._stroke=b}function x(a,e,b){this._x=a;this._height=e;this._stroke=b}function d(a,
e,b,c,l,d){n.call(this,d,l);this._x=a;this._height=e;this._dir=b;this._width=c}function a(a,e,b,c){this._x=a;this._height=e;this._fill=b;this._stroke=c}function b(a,e,b){this.glyph=a;this._min=e;this._max=b;a&&(this.bump=a.bump)}function m(a,e,b,c,l,d){n.call(this,l,c);this._min=a;this._max=e;this._height=b;this._ori=d}function c(a,e,b,c){n.call(this,c,null);this._min=a;this._max=e;this._height=b}function w(a,e,b,c,l,d){this._min=a;this._max=e;this._height=b;this._style=c;this._strand=l;this._stroke=
d}function r(a,e,b,c,l){this._min=a;this._max=e;this._height=b;this._fill=c;this._stroke=l}function y(a,e,b,c,l,d,m){n.call(this,null,c);this._min=a;this._max=e;this._height=b;this._color=c;this._parallel=l;this._sw=d;this._ne=m}function C(a,e,b,c,l){this._min=a;this._max=e;this._height=b;this._fill=c;this._stroke=l}function F(a,e,b,c,l,d){this._min=e;this._max=b;this._height=c;this._fill=l;this._string=d;this._textLen=a.measureText(d).width}function A(a,e,b,c){this.glyph=a;this._height=c;this._x=
e;this._y=b}function R(a,e,b,c){this._x=a;this._y=e;this._height=b;this._fill=c}function B(a){this._height=a||50}function Q(a,e,b,c,l){n.call(this,l,c);this._x=a;this._r=e;this._points=b}function K(a,e,b,c,l){this._x=a;this._height=e;this._overhang=b;this._fill=c;this._stroke=l;this._hh=e/2}if("undefined"!==typeof k){s=k("./spans");var L=s.union,E=s.Range,e=k("./utils").makeElementNS;k=k("./svg-utils");var t=k.NS_SVG,l=k.SVGPath}n.prototype.draw=function(a){a.beginPath();this.drawPath(a);this._fill&&
(a.fillStyle=this._fill,a.fill());this._stroke&&(a.strokeStyle=this._stroke,a.stroke())};n.prototype.toSVG=function(){var a=new l;this.drawPath(a);return e(t,"path",null,{d:a.toPathData(),fill:this._fill||"none",stroke:this._stroke||"none"})};n.prototype.drawPath=function(a){throw"drawPath method on PathGlyphBase must be overridden";};h.prototype.draw=function(a){var e=this._radius;0<e?(a.beginPath(),a.moveTo(this.x+e,this.y),a.lineTo(this.x+this._width-e,this.y),a.arcTo(this.x+this._width,this.y,
this.x+this._width,this.y+e,e),a.lineTo(this.x+this._width,this.y+this._height-e),a.arcTo(this.x+this._width,this.y+this._height,this.x+this._width-e,this.y+this._height,e),a.lineTo(this.x+e,this.y+this._height),a.arcTo(this.x,this.y+this._height,this.x,this.y+this._height-e,e),a.lineTo(this.x,this.y+e),a.arcTo(this.x,this.y,this.x+e,this.y,e),a.closePath(),null!=this._alpha&&(a.save(),a.globalAlpha=this._alpha),this.fill&&(a.fillStyle=this.fill,a.fill()),this.stroke&&(a.strokeStyle=this.stroke,a.lineWidth=
0.5,a.stroke())):(null!=this._alpha&&(a.save(),a.globalAlpha=this._alpha),this.fill&&(a.fillStyle=this.fill,a.fillRect(this.x,this.y,this._width,this._height)),this.stroke&&(a.strokeStyle=this.stroke,a.lineWidth=0.5,a.strokeRect(this.x,this.y,this._width,this._height)));null!=this._alpha&&a.restore()};h.prototype.toSVG=function(){var a=e(t,"rect",null,{x:this.x,y:this.y,width:this._width,height:this._height,stroke:this.stroke||"none",strokeWidth:0.5,fill:this.fill||"none"});null!=this._alpha&&a.setAttribute("opacity",
this._alpha);return a};h.prototype.min=function(){return this.x};h.prototype.max=function(){return this.x+this._width};h.prototype.height=function(){return this.y+this._height};q.prototype.drawConnectors=function(a){for(var e=this.coverage.ranges(),b=1;b<e.length;++b){var c=e[b],l=e[b-1];if(l&&c.min()>l.max()){var l=l.max(),c=c.min(),d=(l+c)/2;"hat+"===this.connector?(a.moveTo(l,this.h/2),a.lineTo(d,0),a.lineTo(c,this.h/2)):"hat-"===this.connector?(a.moveTo(l,this.h/2),a.lineTo(d,this.h),a.lineTo(c,
this.h/2)):"collapsed+"===this.connector?(a.moveTo(l,this.h/2),a.lineTo(c,this.h/2),4<c-l&&(a.moveTo(d-2,this.h/2-3),a.lineTo(d+2,this.h/2),a.lineTo(d-2,this.h/2+3))):"collapsed-"===this.connector?(a.moveTo(l,this.h/2),a.lineTo(c,this.h/2),4<c-l&&(a.moveTo(d+2,this.h/2-3),a.lineTo(d-2,this.h/2),a.lineTo(d+2,this.h/2+3))):(a.moveTo(l,this.h/2),a.lineTo(c,this.h/2))}}};q.prototype.draw=function(a){for(var e=0;e<this.glyphs.length;++e)this.glyphs[e].draw(a);a.strokeStyle="black";a.beginPath();this.drawConnectors(a);
a.stroke()};q.prototype.toSVG=function(){for(var a=e(t,"g"),b=0;b<this.glyphs.length;++b)a.appendChild(this.glyphs[b].toSVG());b=new l;this.drawConnectors(b);0<b.toPathData().length&&(b=e(t,"path",null,{d:b.toPathData(),fill:"none",stroke:"black",strokeWidth:0.5}),a.appendChild(b));return a};q.prototype.min=function(){return this.coverage.min()};q.prototype.max=function(){return this.coverage.max()};q.prototype.height=function(){return this.h};g.prototype.min=function(){return this.points[0]};g.prototype.max=
function(){return this.points[this.points.length-2]};g.prototype.height=function(){return this._height};g.prototype.draw=function(a){a.save();a.strokeStyle=this.color;a.lineWidth=2;a.beginPath();for(var e=0;e<this.points.length;e+=2){var b=this.points[e],c=this.points[e+1];0==e?a.moveTo(b,c):a.lineTo(b,c)}a.stroke();a.restore()};g.prototype.toSVG=function(){for(var a=new l,b=0;b<this.points.length;b+=2){var c=this.points[b],d=this.points[b+1];0==b?a.moveTo(c,d):a.lineTo(c,d)}return e(t,"path",null,
{d:a.toPathData(),fill:"none",stroke:this.color,strokeWidth:"2px"})};z.prototype.toSVG=function(){var a=this.glyph.toSVG(),b={};"above"==this.align?(a=e(t,"g",a,{transform:"translate(0, "+(this.textHeight|2)+")"}),b.y=this.textHeight):b.y=this.glyph.height()+15;this.font&&(b.fontSize=7);b.x="center"==this.anchor?(this.glyph.min()+this.glyph.max()-this.textLen)/2:this.glyph.min();return e(t,"g",[a,e(t,"text",this.text,b)])};z.prototype.min=function(){return this.glyph.min()};z.prototype.max=function(){return this.measured?
Math.max(this.glyph.max(),1*this.glyph.min()+this.textLen+10):this.glyph.max()};z.prototype.height=function(){var a=this.glyph.height();this.measured&&(a="above"==this.align?a+(this.textHeight+2):a+20);return a};z.prototype.draw=function(a){"above"==this.align&&(a.save(),a.translate(0,this.textHeight+2));this.glyph.draw(a);"above"==this.align&&a.restore();a.fillStyle="black";this.font&&(a.save(),a.font=this.font);var e;e="center"==this.anchor?(this.glyph.min()+this.glyph.max()-this.textLen)/2:this.glyph.min();
a.fillText(this.text,e,"above"==this.align?this.textHeight:this.glyph.height()+15);this.font&&a.restore()};p.prototype.draw=function(a){var e=this._height/2;a.beginPath();a.moveTo(this._x,0);a.lineTo(this._x,this._height);a.moveTo(this._x-e,e);a.lineTo(this._x+e,e);a.strokeStyle=this._stroke;a.lineWidth=1;a.stroke()};p.prototype.toSVG=function(){var a=this._height/2,b=new l;b.moveTo(this._x,0);b.lineTo(this._x,this._height);b.moveTo(this._x-a,a);b.lineTo(this._x+a,a);return e(t,"path",null,{d:b.toPathData(),
fill:"none",stroke:this._stroke,strokeWidth:"1px"})};p.prototype.min=function(){return this._x-this._height/2};p.prototype.max=function(){return this._x+this._height/2};p.prototype.height=function(){return this._height};x.prototype.draw=function(a){var e=this._height/2;a.beginPath();a.moveTo(this._x-e,0);a.lineTo(this._x+e,this._height);a.moveTo(this._x-e,this._height);a.lineTo(this._x+e,0);a.strokeStyle=this._stroke;a.lineWidth=1;a.stroke()};x.prototype.toSVG=function(){var a=this._height/2,b=new l;
b.moveTo(this._x-a,0);b.lineTo(this._x+a,this._height);b.moveTo(this._x-a,this._height);b.lineTo(this._x+a,0);return e(t,"path",null,{d:b.toPathData(),fill:"none",stroke:this._stroke,strokeWidth:"1px"})};x.prototype.min=function(){return this._x-this._height/2};x.prototype.max=function(){return this._x+this._height/2};x.prototype.height=function(){return this._height};d.prototype=Object.create(n.prototype);d.prototype.drawPath=function(a){var e=this._height/2,b=this._width/2;"S"===this._dir?(a.moveTo(this._x,
this._height),a.lineTo(this._x-b,0),a.lineTo(this._x+b,0)):"W"===this._dir?(a.moveTo(this._x+b,e),a.lineTo(this._x-b,0),a.lineTo(this._x-b,this._height)):"E"===this._dir?(a.moveTo(this._x-b,e),a.lineTo(this._x+b,0),a.lineTo(this._x+b,this._height)):(a.moveTo(this._x,0),a.lineTo(this._x+b,this._height),a.lineTo(this._x-b,this._height));a.closePath()};d.prototype.min=function(){return this._x-this._height/2};d.prototype.max=function(){return this._x+this._height/2};d.prototype.height=function(){return this._height};
a.prototype.draw=function(a){var e=this._height/2;a.fillStyle=this._stroke;a.beginPath();a.arc(this._x,e,e,0,6.29);this._fill&&(a.fillStyle=this._fill,a.fill());this._stroke&&(a.strokeStyle=this._stroke,a.stroke())};a.prototype.toSVG=function(){var a=this._height/2;return e(t,"circle",null,{cx:this._x,cy:a,r:a,fill:this._fill||"none",stroke:this._stroke||"none",strokeWidth:"1px"})};a.prototype.min=function(){return this._x-this._height/2};a.prototype.max=function(){return this._x+this._height/2};
a.prototype.height=function(){return this._height};b.prototype.draw=function(a){this.glyph&&this.glyph.draw(a)};b.prototype.toSVG=function(){return this.glyph?this.glyph.toSVG():e(t,"g")};b.prototype.min=function(){return this._min};b.prototype.max=function(){return this._max};b.prototype.height=function(){return this.glyph?this.glyph.height():1};m.prototype=Object.create(n.prototype);m.prototype.min=function(){return this._min};m.prototype.max=function(){return this._max};m.prototype.height=function(){return this._height};
m.prototype.drawPath=function(a){var e=this._max,b=this._min,c=this._height,l=0,d=0,m=this._height+2,g=0.333333*this._height;this._ori&&("+"===this._ori?d=0.5*this._height:"-"===this._ori&&(l=0.5*this._height));e-b<m&&(b=(e+b-m)/2,e=b+m);a.moveTo(b+l,0+g);a.lineTo(e-d,0+g);a.lineTo(e-d,0);a.lineTo(e,0+this._height/2);a.lineTo(e-d,0+c);a.lineTo(e-d,0+g+g);a.lineTo(b+l,0+g+g);a.lineTo(b+l,0+c);a.lineTo(b,0+c/2);a.lineTo(b+l,0);a.lineTo(b+l,0+g)};c.prototype=Object.create(n.prototype);c.prototype.min=
function(){return this._min};c.prototype.max=function(){return this._max};c.prototype.height=function(){return this._height};c.prototype.drawPath=function(a){var e=this._min,b=this._max,c=this._height,l=c/2;a.moveTo(e,l);a.lineTo(b,l);a.moveTo(e,0);a.lineTo(e,c);a.moveTo(b,0);a.lineTo(b,c)};w.prototype.min=function(){return this._min};w.prototype.max=function(){return this._max};w.prototype.height=function(){return this._height};w.prototype.drawPath=function(a){var e=this._min,b=this._max,c=this._height,
l=c/2;"hat"===this._style?(a.moveTo(e,l),a.lineTo((e+b)/2,"-"===this._strand?c:0)):a.moveTo(e,l);a.lineTo(b,l)};w.prototype.draw=function(a){a.beginPath();this.drawPath(a);a.strokeStyle=this._stroke;"dashed"===this._style&&a.setLineDash?(a.save(),a.setLineDash([3]),a.stroke(),a.restore()):a.stroke()};w.prototype.toSVG=function(){var a=new l;this.drawPath(a);a={d:a.toPathData(),stroke:this._stroke||"none"};"dashed"===this._style&&(a.strokeDasharray="3");return e(t,"path",null,a)};r.prototype.min=function(){return this._min};
r.prototype.max=function(){return this._max};r.prototype.height=function(){return this._height};r.prototype.drawStemPath=function(a){var e=this._max,b=this._height/2;a.moveTo(this._min,b);a.lineTo(e,b)};r.prototype.drawTrigsPath=function(a){var e=this._min,b=this._max,c=this._height,l=c/2;a.moveTo(e,0);a.lineTo(e+c,l);a.lineTo(e,c);a.lineTo(e,0);a.moveTo(b,0);a.lineTo(b-c,l);a.lineTo(b,c);a.lineTo(b,0)};r.prototype.draw=function(a){a.beginPath();this.drawStemPath(a);a.strokeStyle=this._stroke;a.stroke();
a.beginPath();this.drawTrigsPath(a);a.fillStyle=this._fill;a.fill()};r.prototype.toSVG=function(){var a=new l;this.drawStemPath(a);var b=new l;this.drawTrigsPath(b);return e(t,"g",[e(t,"path",null,{d:a.toPathData(),stroke:this._stroke||"none"}),e(t,"path",null,{d:b.toPathData(),fill:this._fill||"none"})])};y.prototype=Object.create(n.prototype);y.prototype.min=function(){return this._min};y.prototype.max=function(){return this._max};y.prototype.height=function(){return this._height};y.prototype.drawPath=
function(a){var e=this._min,b=this._max,c=this._height;if(this._parallel){var l=c/2,d=0.4*c;this._sw?(a.moveTo(e+l,c-d),a.lineTo(e+l,c),a.lineTo(e,l),a.lineTo(e+l,0),a.lineTo(e+l,d)):(a.moveTo(e,c-d),a.lineTo(e,d));this._ne?(a.lineTo(b-l,d),a.lineTo(b-l,0),a.lineTo(b,l),a.lineTo(b-l,c),a.lineTo(b-l,c-d)):(a.lineTo(b,d),a.lineTo(b,c-d))}else{var l=(e+b)/2,d=0.4*(b-e),m=c/3;this._ne?(a.moveTo(e+d,m),a.lineTo(e,m),a.lineTo(l,0),a.lineTo(b,m),a.lineTo(b-d,m)):(a.moveTo(e+d,0),a.lineTo(b-d,0));this._sw?
(a.lineTo(b-d,c-m),a.lineTo(b,c-m),a.lineTo(l,c),a.lineTo(e,c-m),a.lineTo(e+d,c-m)):(a.lineTo(b-d,c),a.lineTo(e+d,c))}a.closePath()};C.prototype.min=function(){return this._min};C.prototype.max=function(){return this._max};C.prototype.height=function(){return this._height};C.prototype.toSVG=function(){return e(t,"rect",null,{x:this._min,y:0,width:this._max-this._min,height:this._height,stroke:this._stroke||"none",fill:this._fill||"none"})};C.prototype.draw=function(a){this._fill&&(a.fillStyle=this._fill,
a.fillRect(this._min,0,this._max-this._min,this._height));if(this._stroke){a.strokeStyle=this._stroke;a.strokeRect(this._min,0,this._max-this._min,this._height);a.beginPath();for(var e=2;e<this._height;e+=3)a.moveTo(this._min,e),a.lineTo(this._max,e);a.stroke()}};F.prototype.min=function(){return this._min};F.prototype.max=function(){return Math.max(this._max,this._min+this._textLen)};F.prototype.height=function(){return this._height};F.prototype.draw=function(a){a.fillStyle=this._fill;a.fillText(this._string,
this._min,this._height-4)};F.prototype.toSVG=function(){return e(t,"text",this._string,{x:this._min,y:this._height-4})};(function(a){function b(a,e,f,c,l,d,m,g){this.baseColors=a;this._min=e;this._max=f;this._height=c;this._seq=l;this._ref=d;this._scheme=m;this._quals=g}var c=1<window.devicePixelRatio,l={};b.prototype.min=function(){return this._min};b.prototype.max=function(){return this._max};b.prototype.height=function(){return this._height};b.prototype.alphaForQual=function(a){return 0.1+0.9*
Math.max(0,Math.min(1*a/30,1))};b.prototype.draw=function(a){var e=this._seq;e||(e="NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN");for(var b=(this._max-this._min+1)/e.length,f=0;f<e.length;++f){var d=e.substr(f,1).toUpperCase(),m=this.baseColors[d];m||(m="gray");"mismatch"===this._scheme&&this._ref&&(m=this._ref.substr(f,1).toUpperCase(),m="N"===m?"gray":m===d?"black":"red");if(this._quals){var g=this._quals.charCodeAt(f)-33,r=a.globalAlpha;a.globalAlpha=this.alphaForQual(g)}if(8<=
b){var g=m+"_"+d,t=l[g];if(!t){t=document.createElement("canvas");c?(t.width=16,t.height=20):(t.width=8,t.height=10);var h=t.getContext("2d");c&&h.scale(2,2);h.fillStyle=m;h.fillText(d,0,8);l[g]=t}c?a.drawImage(t,this._min+f*b,0,8,10):a.drawImage(t,this._min+f*b,0)}else a.fillStyle=m,a.fillRect(this._min+f*b,0,b,this._height);this._quals&&(a.globalAlpha=r)}};b.prototype.toSVG=function(){for(var a=this._seq,b=(this._max-this._min+1)/this._seq.length,f=e(t,"g"),c=0;c<a.length;++c){var l=a.substr(c,
1).toUpperCase(),d=baseColors[l];d||(d="gray");"mismatch"===this._scheme&&this._ref&&(d=this._ref.substr(c,1).toUpperCase(),d="N"===d?"gray":d===l?"black":"red");var m=1;this._quals&&(m=this._quals.charCodeAt(c)-33,m=this.alphaForQual(m));8<=b?f.appendChild(e(t,"text",l,{x:this._min+c*b,y:8,fill:d,fillOpacity:m})):f.appendChild(e(t,"rect",null,{x:this._min+c*b,y:0,width:b,height:this._height,fill:d,fillOpacity:m}))}return f};a.SequenceGlyph=b})(this);A.prototype.height=function(){return this._height?
this._height:this.glyph.height()+this._y};A.prototype.min=function(){return this.glyph.min()+this._x};A.prototype.max=function(){return this.glyph.max()+this._x};A.prototype.minY=function(){return this._y};A.prototype.maxY=function(){return this._y+this.glyph.height()};A.prototype.draw=function(a){a.save();a.translate(this._x,this._y);this.glyph.draw(a);a.restore()};A.prototype.toSVG=function(){var a=this.glyph.toSVG();a.setAttribute("transform","translate("+this._x+","+this._y+")");return a};R.prototype.min=
function(){return this._x-2};R.prototype.max=function(){return this._x+2};R.prototype.height=function(){return this._height};R.prototype.draw=function(a){a.save();a.globalAlpha=0.3;a.fillStyle=this._fill;a.beginPath();a.arc(this._x,this._y,1.5,0,6.29);a.fill();a.restore()};R.prototype.toSVG=function(){return e(t,"circle",null,{cx:this._x,cy:this._y,r:2,fill:this._fill,stroke:"none"})};B.prototype.notSelectable=!0;B.prototype.min=function(){return-1E5};B.prototype.max=function(){return 1E5};B.prototype.height=
function(){return this._height};B.prototype.draw=function(a){a.save();a.strokeStyle="black";a.lineWidth=0.1;a.beginPath();for(var e=0;e<=this._height;e+=10)a.moveTo(-5E3,e),a.lineTo(5E3,e);a.stroke();a.restore()};B.prototype.toSVG=function(){for(var a=new l,b=0;b<=this._height;b+=10)a.moveTo(-5E3,b),a.lineTo(5E3,b);return e(t,"path",null,{d:a.toPathData(),fill:"none",stroke:"black",strokeWidth:"0.1px"})};Q.prototype=Object.create(n.prototype);Q.prototype.min=function(){return this._x-this._r};Q.prototype.max=
function(){return this._x+this._r};Q.prototype.height=function(){return 2*this._r};Q.prototype.drawPath=function(a){for(var e=this._x,b=this._r,c=this._r,l=0;l<this._points;++l){var d=6.28*l/this._points,m=e+c*Math.sin(d),d=b-c*Math.cos(d);0==l?a.moveTo(m,d):a.lineTo(m,d);d=6.28*(l+0.5)/this._points;m=e+0.4*c*Math.sin(d);d=b-0.4*c*Math.cos(d);a.lineTo(m,d)}a.closePath()};K.prototype.draw=function(a){var e=this._height/2;a.fillStyle=this._stroke;a.beginPath();a.arc(this._x,e,e-this._overhang,0,6.29);
a.moveTo(this._x,0);a.lineTo(this._x,this._height);this._fill&&(a.fillStyle=this._fill,a.fill());this._stroke&&(a.strokeStyle=this._stroke,a.stroke())};K.prototype.toSVG=function(){var a=this._hh;return e(t,"g",[e(t,"circle",null,{cx:this._x,cy:a,r:a-this._overhang}),e(t,"line",null,{x1:this._x,y1:0,x2:this._x,y2:this._height})],{fill:this._fill||"none",stroke:this._stroke||"none",strokeWidth:"1px"})};K.prototype.min=function(){return this._x-this._hh};K.prototype.max=function(){return this._x+this._hh};
K.prototype.height=function(){return this._height};"undefined"!==typeof u&&(u.exports={BoxGlyph:h,GroupGlyph:q,LineGraphGlyph:g,LabelledGlyph:z,CrossGlyph:p,ExGlyph:x,TriangleGlyph:d,DotGlyph:a,PaddedGlyph:b,AArrowGlyph:m,SpanGlyph:c,LineGlyph:w,PrimersGlyph:r,ArrowGlyph:y,TooManyGlyph:C,TextGlyph:F,SequenceGlyph:this.SequenceGlyph,TranslatedGlyph:A,GridGlyph:B,StarGlyph:Q,PointGlyph:R,PlimsollGlyph:K})},{"./spans":33,"./svg-utils":35,"./utils":45}],20:[function(k,u,s){function n(h,g){this.base=h;
this.query=g}if("undefined"!==typeof k)var h=k("./das").DASFeature;n.prototype.features=function(k,g,n){url=this.base+"/features/"+k.name;g=[];this.query&&g.push(this.query);k.isBounded&&(g.push("start="+k.start),g.push("end="+k.end));0<g.length&&(url=url+"?"+g.join("&"));var p=new XMLHttpRequest;p.onreadystatechange=function(){if(4==p.readyState)if(300<=p.status)n(null,"Error code "+p.status);else{var g=JSON.parse(p.response).features,d=[];for(fi=0;fi<g.length;++fi){var a=g[fi],b=new h;b.segment=
k;b.min=(a.start|0)+1;b.max=a.end|0;a.name&&(b.label=a.name);b.type=a.type||"unknown";d.push(b)}n(d)}};p.open("GET",url,!0);p.responseType="text";p.send("")};"undefined"!==typeof u&&(u.exports={JBrowseStore:n})},{"./das":10}],21:[function(k,u,s){function n(){this.reqs=[];this.awaitedFeatures={}}function h(a,b,c,d,m,e,g){this.chr=a;this.min=b;this.max=c;this.coverage=g;this.scale=d;this.features=m||[];this.status=e}function q(a,b,c,d,m,e){this.tierMap=a;this.chr=b;this.min=c;this.max=d;this.scale=
m;this.seqSource=e||new w;this.viewCount=0;this.featureCache={};this.latestViews={}}function g(a,b,c){for(var d=[],m={},e=0;e<a.length;++e){var g=a[e];g.min&&g.max?g.groups&&0<g.groups.length?p(m,g.groups[0].id,g):g.min<=c&&g.max>=b&&d.push(g):d.push(g)}for(var l in m){a=m[l];for(var f=1E11,r=-1E11,e=0;e<a.length;++e)g=a[e],f=Math.min(f,g.min),r=Math.max(r,g.max);if(f<=c||r>=b)for(e=0;e<a.length;++e)d.push(a[e])}return d}if("undefined"!==typeof k){s=k("./utils");var z=s.Awaited,p=s.pusho;s=k("./sourceadapters");
var x=s.MappedFeatureSource,d=s.CachingFeatureSource,a=s.BWGFeatureSource,b=s.RemoteBWGFeatureSource,m=s.BAMFeatureSource,c=s.RemoteBAMFeatureSource,w=s.DummySequenceSource,r=s.DummyFeatureSource,y=k("./overlay").OverlayFeatureSource;s=k("./spans");var C=s.Range,F=s.intersection,A=k("./sample").downsample,R=k("./das").DASSequence}n.prototype.addRequest=function(a){this.reqs.push(a)};n.prototype.abortAll=function(){for(var a=0;a<this.reqs.length;++a)this.reqs[a].abort()};h.prototype.toString=function(){return this.chr+
":"+this.min+".."+this.max+";scale="+this.scale};q.prototype.bestCacheOverlapping=function(a,b,c){return(a=this.featureCache[this.tierMap[0]])?a:null};q.prototype.viewFeatures=function(a,b,c,d){if(d!=d)throw"viewFeatures called with silly scale";if(a!=this.chr)throw"Can't extend Known Space to a new chromosome";1>b&&(b=1);this.min=b;this.max=c;this.scale=d;this.pool&&this.pool.abortAll();this.pool=new n;this.awaitedSeq=new z;this.seqWasFetched=!1;this.viewCount++;this.startFetchesForTiers(this.tierMap)};
q.prototype.invalidate=function(a){this.pool&&(this.featureCache[a]=null,this.startFetchesForTiers([a]))};q.prototype.startFetchesForTiers=function(a){for(var b=this,c=this.awaitedSeq,d=!1,m,e=0;e<a.length;++e)try{this.startFetchesFor(a[e],c)&&(d=!0)}catch(g){a[e].updateStatus(g),console.log("Error fetching tier source"),console.log(g),m=g}if(d&&!this.seqWasFetched){this.seqWasFetched=!0;var l=this.min,f=this.max;if(this.cs&&this.cs.start<=l&&this.cs.end>=f)return a=this.cs.start==l&&this.cs.end==
f?this.cs:new R(this.cs.name,l,f,this.cs.alphabet,this.cs.seq.substring(l-this.cs.start,f+1-this.cs.start)),c.provide(a);this.seqSource.fetch(this.chr,l,f,this.pool,function(a,e){if(e){if(!b.cs||l<=b.cs.start&&f>=b.cs.end||l>=b.cs.end||f<=b.cs.start||f-l>b.cs.end-b.cs.start)b.cs=e;c.provide(e)}else console.log("Sequence loading failed",a),c.provide(null)})}if(m)throw m;};q.prototype.startFetchesFor=function(a,b){var c=this,d=this.viewCount,m=a.getSource()||new r,e=a.needsSequence(this.scale),t=c.featureCache[a],
l=a.getDesiredTypes(this.scale),f=this.chr,p=this.min,k=this.max;if(void 0===l)return!1;if(t&&t.chr===this.chr&&t.min<=p&&t.max>=k){var w=t.features;if(t.min<p||t.max>k)w=g(w,p,k);c.provision(a,t.chr,F(t.coverage,new C(p,k)),t.scale,l,w,t.status,e?b:null);w=m.getScales();if(t.scale<=this.scale||!w)return e}m.instrument&&console.log("Starting  fetch "+d+" ("+p+", "+k+")");m.fetch(f,p,k,this.scale,l,this.pool,function(g,r,w,n){m.instrument&&console.log("Finishing fetch "+d);if(!((c.latestViews[a]||
-1)>d)){n||(n=new C(p,k));if(!t||p<t.min||k>t.max)c.featureCache[a]=new h(f,p,k,w,r,g,n);c.latestViews[a]=d;c.provision(a,f,n,w,l,r,g,e?b:null)}});return e};q.prototype.provision=function(g,r,h,p,k,e,t,l){g.updateStatus(t);if(!t){t=!1;for(var f=g.getSource();x.prototype.isPrototypeOf(f)||d.prototype.isPrototypeOf(f)||y.prototype.isPrototypeOf(f);)f=y.prototype.isPrototypeOf(f)?f.sources[0]:f.source;if(a.prototype.isPrototypeOf(f)||b.prototype.isPrototypeOf(f)||m.prototype.isPrototypeOf(f)||c.prototype.isPrototypeOf(f))t=
!0;if(!f.opts||!f.opts.forceReduction&&!f.opts.noDownsample)if(p<this.scale/2&&200<e.length||t&&k&&1==k.length&&0<=k.indexOf("density"))e=A(e,this.scale);l?l.await(function(a){g.viewFeatures(r,h,p,e,a)}):g.viewFeatures(r,h,p,e)}};"undefined"!==typeof u&&(u.exports={KnownSpace:q})},{"./das":10,"./overlay":25,"./sample":27,"./sourceadapters":32,"./spans":33,"./utils":45}],22:[function(k,u,s){function n(a,b){this.block=a;this.offset=b}function h(a,b){var d=4294967296*(a[b+6]&255)+16777216*(a[b+5]&255)+
65536*(a[b+4]&255)+256*(a[b+3]&255)+(a[b+2]&255),c=a[b+1]<<8|a[b];return 0==d&&0==c?null:new n(d,c)}function q(a,b){b=Math.min(b||1,a.byteLength-50);for(var m=[],c=[0],g=0;c[0]<b;){var r=new Uint8Array(a,c[0],12),r=r[11]<<8|r[10],r=x(a,12+r+c[0],Math.min(65536,a.byteLength-12-r-c[0]),c);c[0]+=8;g+=r.byteLength;m.push(r)}if(1==m.length)return m[0];c=new Uint8Array(g);for(r=g=0;r<m.length;++r){var h=new Uint8Array(m[r]);d(h,0,c,g,h.length);g+=h.length}return c.buffer}function g(a,b){this.minv=a;this.maxv=
b}function z(a,b){--b;return a>>14==b>>14?4681+(a>>14):a>>17==b>>17?585+(a>>17):a>>20==b>>20?73+(a>>20):a>>23==b>>23?9+(a>>23):a>>26==b>>26?1+(a>>26):0}function p(a,b){var d,c=[];--b;c.push(0);for(d=1+(a>>26);d<=1+(b>>26);++d)c.push(d);for(d=9+(a>>23);d<=9+(b>>23);++d)c.push(d);for(d=73+(a>>20);d<=73+(b>>20);++d)c.push(d);for(d=585+(a>>17);d<=585+(b>>17);++d)c.push(d);for(d=4681+(a>>14);d<=4681+(b>>14);++d)c.push(d);return c}if("undefined"!==typeof k){k=k("jszlib");var x=k.inflateBuffer,d=k.arrayCopy}n.prototype.toString=
function(){return""+this.block+":"+this.offset};"undefined"!==typeof u&&(u.exports={unbgzf:q,readVob:h,reg2bin:z,reg2bins:p,Chunk:g})},{jszlib:60}],23:[function(k,u,s){function n(){this.featuresByChr={};this.maxLength=1;this.chrRing=null}function h(d){this.source=d;z.call(this);this.storeHolder=new p;this.parser=g(d.payload);if(!this.parser)throw"Unsupported memstore payload: "+d.payload;var a=this;this._load(function(b,d){if(b){for(var c=new n,g=[],r=b.split("\n"),h=a.parser.createSession(function(a){g.push(a)}),
p=0;p<r.length;++p){var k=r[p];0<k.length&&h.parse(k)}h.flush();c.addFeatures(g);a.storeHolder.provide(c)}else a.error=d||"No data",a.storeHolder.provide(null)})}if("undefined"!==typeof k){u=k("./sourceadapters");var q=u.registerSourceAdapterFactory,g=u.makeParser,z=u.FeatureSourceBase;k("./das");k=k("./utils");var p=k.Awaited,x=k.textXHR}n.prototype.addFeatures=function(d){for(var a={},b=0;b<d.length;++b){var m=d[b],c=m.segment||m.chr,g=this.featuresByChr[c];g||(g=[],this.featuresByChr[c]=g);g.push(m);
a[c]=!0;m=m.max-m.min+1;m>this.maxLength&&(this.maxLength=m)}for(c in a)g=this.featuresByChr[c],g.sort(function(a,b){var c=a.min-b.min;return 0!=c?c:a.max-b.max});this.chrRing=null};n.prototype._indexFor=function(d,a){for(var b=0,m=d.length;m>b;){var c=(b+m)/2|0;if(c>=d.length)return d.length;a<d[c].min?m=c:b=c+1}return m};n.prototype.fetch=function(d,a,b){var m=this.featuresByChr[d];m||(m=0==d.indexOf("chr")?this.featuresByChr[d.substring(3)]:this.featuresByChr["chr"+d]);if(!m)return[];var c=Math.max(0,
this._indexFor(m,a-this.maxLength-1));d=Math.min(m.length-1,this._indexFor(m,b));for(var g=[];c<=d;++c){var r=m[c];r.min<=b&&r.max>=a&&g.push(r)}return g};n.prototype.findNextFeature=function(d,a,b){if(null==this.chrRing){this.chrRing=[];for(d in this.featuresByChr)this.chrRing.push(d);this.chrRing.sort()}var m=this.featuresByChr[d];m||(d=0==d.indexOf("chr")?d.substring(3):"chr"+d,m=this.featuresByChr[d]);if(!m)return null;var c=Math.max(0,Math.min(this._indexFor(m,a),m.length-1));if(0<b){for(;c<
m.length;){var g=m[c++];if(g.min>a)return g}d=this.chrRing.indexOf(d)+1;d>=this.chrRing.length&&(d=0);return this.findNextFeature(this.chrRing[d],0,b)}for(;0<=c;)if(g=m[c--],g.max<a)return g;d=this.chrRing.indexOf(d)-1;0>d&&(d=this.chrRing.length-1);return this.findNextFeature(this.chrRing[d],1E10,b)};h.prototype=Object.create(z.prototype);h.prototype._load=function(d){if(this.source.blob){var a=new FileReader;a.onloadend=function(){return d(a.result,a.error)};a.readAsText(this.source.blob)}else x(this.source.uri,
d,{})};h.prototype.fetch=function(d,a,b,m,c,g,r){var h=this;this.storeHolder.await(function(c){return c?(c=c.fetch(d,a,b),r(null,c,1E8)):r(h.error)})};h.prototype.getStyleSheet=function(d){this.parser&&this.parser.getStyleSheet&&this.parser.getStyleSheet(d)};h.prototype.getDefaultFIPs=function(d){this.parser&&this.parser.getDefaultFIPs&&this.parser.getDefaultFIPs(d)};h.prototype.getScales=function(){return 1E8};h.prototype.findNextFeature=function(d,a,b,m){var c=this;this.storeHolder.await(function(g){return g?
m(g.findNextFeature(d,a,b)):m(null,c.error)})};h.prototype.capabilities=function(){return{leap:!0}};q("memstore",function(d){return{features:new h(d)}})},{"./das":10,"./sourceadapters":32,"./utils":45}],24:[function(k,u,s){function n(h){return(h|0).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}function h(h){h=""+h;var g=h.indexOf(".");if(0>g)return h;var k=2;"-"==h.substring(0,1)&&++k;return g>=k?h.substring(0,g):h.substring(0,g+2)}"undefined"!==typeof u&&(u.exports={formatLongInt:n,formatQuantLabel:h})},
{}],25:[function(k,u,s){function n(h,k){this.sources=h;this.opts=k||{};this.activityListeners=[];this.readinessListeners=[];this.changeListeners=[];this.business=[];this.readiness=[];for(var d=0;d<this.sources.length;++d)this.initN(d);this.merge="concat"==k.merge?g:q}function h(g,h,d){this.source=g;this.callback=h;this.count=d;this.statusCount=this.returnCount=0;this.returns=[];this.features=[];this.statuses=[];this.scale=null}function q(g){for(var h=[],d=1;d<g.length;++d){for(var a={},b=g[d],m=0;m<
b.length;++m)a[this.keyForFeature(b[m])]=b[m];h.push(a)}d=[];g=g[0];for(m=0;m<g.length;++m){for(var c=g[m],k=0;k<h.length;++k)if(a=h[k],b=a[this.keyForFeature(c)])for(var r in b)"score"===r?c.score2=b.score:"min"!==r&&"max"!==r&&"segment"!==r&&"_cachedStyle"!==r&&(c[r]=b[r]);d.push(c)}return d}function g(g){for(var h=[],d=0;d<g.length;++d)for(var a=g[d],b=this.sources[d].name,m=0;m<a.length;++m){var c=a[m];c.method=b;h.push(c)}return h}if("undefined"!==typeof k)var z=k("./utils").shallowCopy;n.prototype.initN=
function(g){var h=this.sources[g],d=this;this.business[g]=0;h.addActivityListener&&h.addActivityListener(function(a){d.business[g]=a;d.notifyActivity()});h.addChangeListener&&h.addChangeListener(function(){d.notifyChange()});h.addReadinessListener&&h.addReadinessListener(function(a){d.readiness[g]=a;d.notifyReadiness()})};n.prototype.addReadinessListener=function(g){this.readinessListeners.push(g);this.notifyReadinessListener(g)};n.prototype.notifyReadiness=function(){for(var g=0;g<this.readinessListeners.length;++g)this.notifyReadinessListener(this.readinessListeners[g])};
n.prototype.notifyReadinessListener=function(g){for(var h=null,d=0;d<this.readiness.length;++d)if(null!=this.readiness[d]){h=this.readiness[d];break}try{g(h)}catch(a){console.log(a)}};n.prototype.addActivityListener=function(g){this.activityListeners.push(g)};n.prototype.notifyActivity=function(){for(var g=0,h=0;h<this.business.length;++h)g+=this.business[h];for(h=0;h<this.activityListeners.length;++h)try{this.activityListeners[h](g)}catch(d){console.log(d)}};n.prototype.addChangeListener=function(g){this.changeListeners.push(g)};
n.prototype.notifyChange=function(){for(var g=0;g<this.changeListeners.length;++g)try{this.changeListeners[g](this.busy)}catch(h){console.log(h)}};n.prototype.getScales=function(){return this.sources[0].getScales()};n.prototype.getStyleSheet=function(g){return this.sources[0].getStyleSheet(g)};n.prototype.capabilities=function(){var g={},h=this.sources[0];h.capabilities&&(g=z(h.capabilities()));for(h=1;h<this.sources.length;++h){var d=this.sources[h];d.capabilities&&(d=d.capabilities(),d.search&&
(g.search=d.search))}return g};n.prototype.search=function(g,h){for(var d=0;d<this.sources.length;++d)if(sourceAdapterIsCapable(this.sources[d],"search"))return this.sources[d].search(g,h)};n.prototype.fetch=function(g,k,d,a,b,m,c){c=new h(this,c,this.sources.length);for(var n=0;n<this.sources.length;++n)this.fetchN(c,n,g,k,d,a,b,m)};n.prototype.fetchN=function(g,h,d,a,b,m,c,k){this.sources[h].fetch(d,a,b,m,c,k,function(a,b,c){return g.completed(h,a,b,c)})};n.prototype.quantFindNextFeature=function(g,
h,d,a,b){return this.sources[0].quantFindNextFeature(g,h,d,a,b)};n.prototype.findNextFeature=function(g,h,d,a){return this.sources[0].findNextFeature(g,h,d,a)};h.prototype.completed=function(g,h,d,a){if(null==this.scale||0==g)this.scale=a;if(this.returns[g])throw"Multiple returns for source "+g;this.returns[g]=!0;this.returnCount++;this.features[g]=d;h&&(this.statuses[g]=h,this.statusCount++);if(this.returnCount==this.count){if(0<this.statusCount){g="";for(h=0;h<this.count;++h)if(d=this.statuses[h])0<
g.length&&(g+=", "),g+=d;return this.callback(g,null,this.scale)}this.callback(null,this.source.merge(this.features),this.scale)}};n.prototype.getDefaultFIPs=function(g){for(var h=0;h<this.sources.length;++h){var d=this.sources[h];d.getDefaultFIPs&&d.getDefaultFIPs(g)}};n.prototype.keyForFeature=function(g){return""+g.min+".."+g.max};"undefined"!==typeof u&&(u.exports={OverlayFeatureSource:n})},{"./utils":45}],26:[function(k,u,s){function n(c,k,r){var y=/^.+\t[0-9]+\t[0-9]+.*$/,C=/([^=]+)=\"?([^\"]+)\"?/,
F=/^##\s*fileformat=VCFv4\..+/;(c.blob?new g(c.blob):new q(c.uri)).slice(0,65536).salted().fetch(function(g,q){if(!g)return r||(c.credentials=!0,n(c,k,!0)),k(c,"Couldn't fetch data");var B=new Uint8Array(g),s=(new Uint32Array(g,0,1))[0];if(s==p||s==x){c.tier_type="bwg";B=/\/?([^/]+?)(.bw|.bb|.bigWig|.bigBed)?$/;if(B=B.exec(c.uri||c.blob.name))c.name=B[1];return k(c,null)}if(s==b)return c.tier_type="bai",k(c,null);if(31==B[0]||139==B[1]){B=d(g);B=new Uint8Array(B);s=z(B,0);if(s==a){c.tier_type="bam";
B=/\/?([^/]+?)(.bam)?$/;if(B=B.exec(c.uri||c.blob.name))c.name=B[1];return k(c,null)}if(s==m)return c.tier_type="tabix-index",k(c,null);if(1768301347==s){c.tier_type="tabix";c.payload="vcf";B=/\/?([^/]+?)(.vcf)?(.gz)?$/;if(B=B.exec(c.uri||c.blob.name))c.name=B[1];return k(c,null)}console.log("magic = "+s.toString(16));return k(c,"Unsupported format")}B=String.fromCharCode.apply(null,B).split("\n");if(0<B.length&&F.test(B[0]))return c.tier_type="memstore",c.payload="vcf",B=/\/?([^/]+?)(.vcf)?$/,(B=
B.exec(c.uri||c.blob.name))&&!c.name&&(c.name=B[1]),k(c,null);for(var u=0;u<B.length;++u)if(s=B[u].replace("\r",""),0!=s.length&&0!=s.indexOf("browser")){if(0==s.indexOf("track")){B="bed";s=s.split(/\s/);for(u=1;u<s.length;++u){var L=C.exec(s[u]);L&&("type"==L[1]&&"wiggle_0"==L[2]?B="wig":"name"==L[0]&&(c.name=L[2]))}h(c,B);return k(c,null)}if(0==s.indexOf("fixedStep")||0==s.indexOf("variableStep"))return h(c,"wig"),k(c,null);if(y.test(s))return h(c,null),k(c,null);break}return k(c,"Unsupported format")})}
function h(a,b){a.tier_type="memstore";var d=/\/?([^/]+?)(.(bed|wig))?$/.exec(a.uri||a.blob.name);d&&(a.name||(a.name=d[1]),!b&&d[3]&&(b=d[3]));a.payload=b||"bed"}if("undefined"!==typeof k){s=k("./bin");var q=s.URLFetchable,g=s.BlobFetchable,z=s.readInt;s=k("./bigwig");var p=s.BIG_WIG_MAGIC,x=s.BIG_BED_MAGIC,d=k("./lh3utils").unbgzf;s=k("./bam");var a=s.BAM_MAGIC,b=s.BAI_MAGIC,m=k("./tabix").TABIX_MAGIC}"undefined"!==typeof u&&(u.exports={probeResource:n})},{"./bam":1,"./bigwig":3,"./bin":4,"./lh3utils":22,
"./tabix":37}],27:[function(k,u,s){function n(g){return p[g%p.length]*Math.pow(10,g/p.length|0)}function h(g,d,a){this.scale=g;this.cnt=this.tot=0;this.hasScore=!1;this.min=d;this.max=a;this.features=[]}function q(g,d){return g.min<d.min?-1:g.min>d.min?1:g.max<d.max?-1:d.max>g.max?1:0}function g(g,d){for(var a=0;n(a+1)<d;)++a;for(var a=n(a),b=[],m=-1E10,c=1E10,k=0;k<g.length;++k){var r=g[k];if(r.groups&&0<r.groups.length)return g;for(var p=r.min/a|0,q=r.max/a|0,m=Math.max(m,q),c=Math.min(c,p);p<=
q;++p){var s=b[p];s||(s=new h(a,p*a,(p+1)*a-1),b[p]=s);s.feature(r)}}k=[];for(p=c;p<=m;++p)if(s=b[p])r=new z,r.segment=g[0].segment,r.min=p*a+1,r.max=(p+1)*a,r.score=s.score(),r.type="density",k.push(r);Date.now();return k}if("undefined"!==typeof k)var z=k("./das").DASFeature;var p=[1,2,5];h.prototype.score=function(){if(0==this.cnt)return 0;if(this.hasScore)return this.tot/this.cnt;var g=this.features;g.sort(q);for(var d=-1E10,a=0,b=0,m=1;m<g.length;++m){var c=g[m],h=Math.max(c.min,this.min),c=Math.min(c.max,
this.max),b=b+(c-h+1);h>d?(a+=c-h+1,d=c):c>d&&(a+=c-d,d=c)}return 0<a?1*b/a:0};h.prototype.feature=function(g){void 0!==g.score&&(this.tot+=g.score,this.hasScore=!0);++this.cnt;this.features.push(g)};"undefined"!==typeof u&&(u.exports={downsample:g})},{"./das":10}],28:[function(k,u,s){function n(g,h){var d=parseFloat(g.replace(/,/g,""));return"k"===h||"K"===h?1E3*d|0:"m"==h||"M"===h?1E6*d|0:d|0}if("undefined"!==typeof k)var h=k("./cbrowser").Browser,q=k("./bin").URLFetchable,g=k("./trix").connectTrix;
var z=/^([\d+,\w,\.,\_,\-]+):([0-9,\.]+?)([KkMmGg])?((-|\.\.)+([0-9,\.]+)([KkMmGg])?)?$/;h.prototype.search=function(h,k){var d=this,a=z.exec(h);if(a){var b=a[1],m;if(a[6])m=n(a[2],a[3]),a=n(a[6],a[7]);else{var c=this.viewEnd-this.viewStart+1;m=n(a[2],a[3])-c/2|0;a=m+c-1}this.setLocation(b,m,a,k)}else{if(!h||0==h.length)return!1;var w=0,r=!1,y=function(a,b){--w;if(b)return k(b);a||(a=[]);for(var c=5E8,m=-1E8,g=null,n=0;n<a.length;++n){var y=a[n];null==g&&(g=y.segment);c=Math.min(c,y.min);m=Math.max(m,
y.max)}if(g)r=!0,d.highlightRegion(g,c,m),n=Math.max(2500,0.3*(m-c+1)|0),d.setLocation(g,c-n,m+n,k);else if(0==w&&!r)return k("no match for '"+h+"'")},C=function(a,b){b.lookup(h,function(b,c){if(null==b||2>b.length)return a.featureSource.search(h,y);var d=b[1].split(",")[0];return a.featureSource.search(d,y)})};if(this.searchEndpoint)return w=1,this.doDasSearch(d.searchEndpoint,h,y);for(b=0;b<this.tiers.length;++b)(function(a){d.sourceAdapterIsCapable(a.featureSource,"search")?a.dasSource.trixURI?
(++w,a.trix?C(a,a.trix):g(new q(a.dasSource.trixURI),new q(a.dasSource.trixURI+"x"),function(b){a.trix=b;C(a,b)})):(++w,a.featureSource.search(h,y)):a.dasSource.provides_search&&(++w,d.doDasSearch(a.dasSource,h,y))})(this.tiers[b])}};h.prototype.doDasSearch=function(g,h,d){g.features(null,{group:h,type:"transcript"},function(a){a||(a=[]);for(var b=[],m=0;m<a.length;++m){var c=a[m];c.label.toLowerCase()==h.toLowerCase()&&b.push(c)}return d(b)},!1)}},{"./bin":4,"./cbrowser":6,"./trix":43}],29:[function(k,
u,s){function n(a,b){b||(b=x);for(var m=d.length;a*d[m%d.length]*Math.pow(10,m/d.length|0)<b;)++m;return d[m%d.length]*Math.pow(10,m/d.length|0)}function h(a,b){var d=a.browser.retina&&1<window.devicePixelRatio,c=a.browser.scale,h=a.browser.viewStart-1E3/c|0,r=a.browser.viewEnd+2E3/c,k=a.browser.currentSeqMax,p=a.browser.featurePanelWidth+2E3;d&&(p*=2);var q=a.viewport.width|0;q<p-50&&(a.viewport.width=q=p);p=50;b&&b.seq&&(p+=25);var A=p;d&&(A*=2);a.viewport.height=A;a.viewport.style.height=""+p+
"px";a.viewport.style.width=d?""+q/2+"px":""+q+"px";a.layoutHeight=p;a.updateHeight();p=a.viewport.getContext("2d");a.background&&(p.fillStyle=a.background,p.fillRect(0,0,q,a.viewport.height));d&&p.scale(2,2);p.translate(1E3,0);d=r;0<k&&k<r&&(d=k);q=n(c);A=Math.max(0,(h/q|0)*q);for(k=a.browser.viewStart;A<=d;)p.fillStyle=0==A/q%2?"white":"black",p.strokeStyle="black",p.fillRect((A-k)*c,8,q*c,3),p.strokeRect((A-k)*c,8,q*c,3),p.fillStyle="black",p.fillText(g(A),(A-k)*c,22),A+=q;if(b&&b.seq)for(;h<=
r;++h)h>=b.start&&h<=b.end&&(d=b.seq.substr(h-b.start,1).toUpperCase(),(q=a.browser.baseColors[d])||(q="gray"),p.fillStyle=q,8<=c?p.fillText(d,(h-k)*c,52):p.fillRect((h-k)*c,42,c,12));a.norigin=a.browser.viewStart;a.viewport.style.left="-1000px"}function q(a,b){var d=a.browser.scale,c=a.browser.viewStart-1E3/d|0,h=a.browser.viewEnd+2E3/d,r=a.browser.currentSeqMax,k=h;0<r&&r<h&&(k=r);for(var q=n(d),s=Math.max(0,(c/q|0)*q),r=a.browser.viewStart,A=z(p,"g",[],{fontSize:"8pt"});s<=k;)A.appendChild(z(p,
"rect",null,{x:(s-r)*d,y:8,width:q*d,height:3,fill:0==s/q%2?"white":"black",stroke:"black"})),A.appendChild(z(p,"text",g(s),{x:(s-r)*d,y:28,fill:"black",stroke:"none"})),s+=q;if(b&&b.seq)for(;c<=h;++c)c>=b.start&&c<=b.end&&(k=b.seq.substr(c-b.start,1).toUpperCase(),(q=a.browser.baseColors[k])||(q="gray"),8<=d?A.appendChild(z(p,"text",k,{x:(c-r)*d,y:52,fill:q})):A.appendChild(z(p,"rect",null,{x:(c-r)*d,y:42,width:d,height:12,fill:q})));return A}if("undefined"!==typeof k){s=k("./utils");var g=s.formatLongInt,
z=s.makeElementNS,p=k("./svg-utils").NS_SVG,g=k("./numformats").formatLongInt}var x=100,d=[1,2,5],p="http://www.w3.org/2000/svg";"undefined"!==typeof u&&(u.exports={drawSeqTier:h,svgSeqTier:q})},{"./numformats":24,"./svg-utils":35,"./utils":45}],30:[function(k,u,s){if("undefined"!=typeof k){u=k("./cbrowser");var n=u.Browser,h=u.sourceDataURI,q=u.sourcesAreEqual,g=k("./version"),z=k("./utils").miniJSONify,p=k("./sha1").hex_sha1}n.prototype.nukeStatus=function(){delete localStorage["dalliance."+this.cookieKey+
".view-chr"];delete localStorage["dalliance."+this.cookieKey+".view-start"];delete localStorage["dalliance."+this.cookieKey+".view-end"];delete localStorage["dalliance."+this.cookieKey+".current-seq-length"];delete localStorage["dalliance."+this.cookieKey+".showing-alt-zoom"];delete localStorage["dalliance."+this.cookieKey+".saved-zoom"];delete localStorage["dalliance."+this.cookieKey+".sources"];delete localStorage["dalliance."+this.cookieKey+".hubs"];delete localStorage["dalliance."+this.cookieKey+
".version"];delete localStorage["dalliance."+this.cookieKey+".reverse-scrolling"];delete localStorage["dalliance."+this.cookieKey+".reverse-key-scrolling"];delete localStorage["dalliance."+this.cookieKey+".ruler-location"]};n.prototype.storeStatus=function(){this.storeViewStatus();this.storeTierStatus()};n.prototype.storeViewStatus=function(){!this.cookieKey||this.noPersist||this.noPersistView||(localStorage["dalliance."+this.cookieKey+".view-chr"]=this.chr,localStorage["dalliance."+this.cookieKey+
".view-start"]=this.viewStart|0,localStorage["dalliance."+this.cookieKey+".view-end"]=this.viewEnd|0,localStorage["dalliance."+this.cookieKey+".showing-alt-zoom"]=""+this.isSnapZooming,localStorage["dalliance."+this.cookieKey+".saved-zoom"]=this.savedZoom,this.currentSeqMax&&(localStorage["dalliance."+this.cookieKey+".current-seq-length"]=this.currentSeqMax))};n.prototype.storeTierStatus=function(){if(this.cookieKey&&!this.noPersist){for(var h=[],d=0;d<this.tiers.length;++d){var a=this.tiers[d];a.dasSource.noPersist||
h.push({source:a.dasSource,config:a.config||{}})}localStorage["dalliance."+this.cookieKey+".sources"]=JSON.stringify(h);h={};d=[];for(a=0;a<this.hubObjects.length;++a){var b=this.hubObjects[a],m={url:b.hub.url,genome:b.genome};b.credentials&&(m.credentials=b.credentials);b.mapping&&(m.mapping=b.mapping);h[m.url]=!0;d.push(m)}for(a=0;a<this.hubs.length;++a)m=this.hubs[a],"string"===typeof m&&(m={url:m}),h[m.url]||d.push(m);localStorage["dalliance."+this.cookieKey+".hubs"]=JSON.stringify(d);localStorage["dalliance."+
this.cookieKey+".reverse-scrolling"]=this.reverseScrolling;localStorage["dalliance."+this.cookieKey+".reverse-key-scrolling"]=this.reverseKeyScrolling;localStorage["dalliance."+this.cookieKey+".ruler-location"]=this.rulerLocation;localStorage["dalliance."+this.cookieKey+".export-ruler"]=this.exportRuler;localStorage["dalliance."+this.cookieKey+".export-highlights"]=this.exportHighlights;localStorage["dalliance."+this.cookieKey+".version"]=g.CONFIG}};n.prototype.restoreStatus=function(){if(!this.noPersist){var k=
localStorage["dalliance."+this.cookieKey+".version"];if(g.CONFIG==(k?k|0:-100)){var k=localStorage["dalliance."+this.cookieKey+".configHash"]||"",d=p(z({sources:this.sources,hubs:this.hubs}));if(d!=k)localStorage["dalliance."+this.cookieKey+".configHash"]=d;else{k={};for(d=0;d<this.sources.length;++d){var a=this.sources[d],b=h(a),m=k[b];m||(k[b]=m=[]);m.push(a)}if(!this.noPersistView&&(d=localStorage["dalliance."+this.cookieKey+".view-chr"],a=localStorage["dalliance."+this.cookieKey+".view-start"]|
0,m=localStorage["dalliance."+this.cookieKey+".view-end"]|0,d&&a&&m)){this.chr=d;this.viewStart=a;this.viewEnd=m;if(d=localStorage["dalliance."+this.cookieKey+".current-seq-length"])this.currentSeqMax=d|0;this.isSnapZooming="true"==localStorage["dalliance."+this.cookieKey+".showing-alt-zoom"];d=parseFloat(localStorage["dalliance."+this.cookieKey+".saved-zoom"]);"number"!==typeof d||isNaN(d)||(this.savedZoom=d)}this.reverseScrolling=(d=localStorage["dalliance."+this.cookieKey+".reverse-scrolling"])&&
"true"==d;this.reverseKeyScrolling=(d=localStorage["dalliance."+this.cookieKey+".reverse-key-scrolling"])&&"true"==d;if(d=localStorage["dalliance."+this.cookieKey+".ruler-location"])this.rulerLocation=d;if(d=localStorage["dalliance."+this.cookieKey+".export-ruler"])this.exportRuler="true"===d;if(d=localStorage["dalliance."+this.cookieKey+".export-highlights"])this.exportHighlights="true"===d;if(d=localStorage["dalliance."+this.cookieKey+".sources"]){var c=JSON.parse(d);this.sources=[];this.restoredConfigs=
[];for(d=0;d<c.length;++d)for(a=this.sources[d]=c[d].source,this.restoredConfigs[d]=c[d].config,b=h(a),m=k[b]||[],b=0;b<m.length;++b){var n=m[b];q(a,n)&&n.featureInfoPlugin&&(a.featureInfoPlugin=n.featureInfoPlugin)}}if(k=localStorage["dalliance."+this.cookieKey+".hubs"])this.hubs=JSON.parse(k);return!0}}}};n.prototype.reset=function(){for(var g=this.tiers.length-1;0<=g;--g)this.removeTier({index:g},!0);for(g=0;g<this.defaultSources.length;++g)this.defaultSources[g].disabled||this.addTier(this.defaultSources[g]);
this.highlights.splice(0,this.highlights.length);this.setLocation(this.defaultChr,this.defaultStart,this.defaultEnd)}},{"./cbrowser":6,"./sha1":31,"./utils":45,"./version":47}],31:[function(k,u,s){function n(d){d=q(g(d));for(var a=p?"0123456789ABCDEF":"0123456789abcdef",b="",m,c=0;c<d.length;c++)m=d.charCodeAt(c),b+=a.charAt(m>>>4&15)+a.charAt(m&15);return b}function h(d){d=q(g(d));for(var a="",b=d.length,m=0;m<b;m+=3)for(var c=d.charCodeAt(m)<<16|(m+1<b?d.charCodeAt(m+1)<<8:0)|(m+2<b?d.charCodeAt(m+
2):0),h=0;4>h;h++)a=8*m+6*h>8*d.length?a+x:a+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(c>>>6*(3-h)&63);return a}function q(d){for(var a=Array(d.length>>2),b=0;b<a.length;b++)a[b]=0;for(b=0;b<8*d.length;b+=8)a[b>>5]|=(d.charCodeAt(b/8)&255)<<24-b%32;d=8*d.length;a[d>>5]|=128<<24-d%32;a[(d+64>>9<<4)+15]=d;d=Array(80);for(var b=1732584193,m=-271733879,c=-1732584194,g=271733878,h=-1009589776,k=0;k<a.length;k+=16){for(var p=b,n=m,q=c,s=g,B=h,u=0;80>u;u++){if(16>u)d[u]=a[k+
u];else{var x=d[u-3]^d[u-8]^d[u-14]^d[u-16];d[u]=x<<1|x>>>31}var x=b<<5|b>>>27,L;L=20>u?m&c|~m&g:40>u?m^c^g:60>u?m&c|m&g|c&g:m^c^g;x=z(z(x,L),z(z(h,d[u]),20>u?1518500249:40>u?1859775393:60>u?-1894007588:-899497514));h=g;g=c;c=m<<30|m>>>2;m=b;b=x}b=z(b,p);m=z(m,n);c=z(c,q);g=z(g,s);h=z(h,B)}a=[b,m,c,g,h];d="";for(b=0;b<32*a.length;b+=8)d+=String.fromCharCode(a[b>>5]>>>24-b%32&255);return d}function g(d){for(var a="",b=-1,m,c;++b<d.length;)m=d.charCodeAt(b),c=b+1<d.length?d.charCodeAt(b+1):0,55296<=
m&&56319>=m&&56320<=c&&57343>=c&&(m=65536+((m&1023)<<10)+(c&1023),b++),127>=m?a+=String.fromCharCode(m):2047>=m?a+=String.fromCharCode(192|m>>>6&31,128|m&63):65535>=m?a+=String.fromCharCode(224|m>>>12&15,128|m>>>6&63,128|m&63):2097151>=m&&(a+=String.fromCharCode(240|m>>>18&7,128|m>>>12&63,128|m>>>6&63,128|m&63));return a}function z(d,a){var b=(d&65535)+(a&65535);return(d>>16)+(a>>16)+(b>>16)<<16|b&65535}var p=0,x="";"undefined"!==typeof u&&(u.exports={b64_sha1:h,hex_sha1:n})},{}],32:[function(k,u,
s){function n(a,e){I[a]=e}function h(a,e){W[a]=e}function q(a){if(W[a])return W[a](a)}function g(a){var e=this;this.source=a;this.cfsid="cfs"+ ++V;a.name&&(this.name=a.name);a.addChangeListener&&a.addChangeListener(function(){e.cfsid="cfs"+ ++V})}function z(){this.busy=0;this.activityListeners=[];this.readinessListeners=[];this.readiness=null}function p(a){this.dasSource=new E(a);this.busy=0;this.activityListeners=[]}function x(a){this.dasSource=new E(a);this.awaitedEntryPoints=new B;var e=this;this.dasSource.entryPoints(function(a){e.awaitedEntryPoints.provide(a)})}
function d(a){var e=this;this.source=a;this.twoBit=new B;if(a.twoBitURI)a=new f(a.twoBitURI);else if(a.twoBitBlob)a=new v(a.twoBitBlob);else throw Error("No twoBitURI or twoBitBlob parameter");G(a,function(a,b){b?console.log(b):e.twoBit.provide(a)})}function a(a){z.call(this);var e=this;this.readiness="Connecting";this.bwgSource=this.opts=a;e.bwgHolder=new B;if(this.opts.preflight){var b=X[this.opts.preflight];if(!b){b=new B;X[this.opts.preflight]=b;var c=new XMLHttpRequest;c.onreadystatechange=function(){4==
c.readyState&&(200==c.status?b.provide("success"):b.provide("failure"))};c.open("get",this.opts.preflight+"?"+hex_sha1("salt"+Date.now()),!0);this.opts.credentials&&(c.withCredentials=!0);c.send("")}b.await(function(a){"success"===a&&e.init()})}else e.init()}function b(a,e){z.call(this);this.worker=e;this.readiness="Connecting";this.bwgSource=this.opts=a;this.keyHolder=new B;this.init()}function m(a,e){if(!(a.flag&P.SEGMENT_UNMAPPED)){var b;b=a.seq?a.seq.length:a.seqLength;if(a.cigar){b=0;for(var c=
S(a.cigar),f=0;f<c.length;++f){var d=c[f];if("M"==d.op||"D"==d.op)b+=d.cnt}}c=new t;c.min=a.pos+1;c.max=a.pos+b;c.segment=a.segment;c.type="bam";c.id=a.readName;c.notes=["MQ="+a.mq];c.cigar=a.cigar;c.seq=a.seq;c.quals=a.quals;c.orientation=a.flag&P.REVERSE_COMPLEMENT?"-":"+";c.bamRecord=a;e&&a.flag&P.MULTIPLE_SEGMENTS&&(c.groups=[{id:a.readName,type:"readpair"}]);return c}}function c(a){z.call(this);var e=this;this.bamSource=a;this.opts={credentials:a.credentials,preflight:a.preflight,bamGroup:a.bamGroup};
this.bamHolder=new B;if(this.opts.preflight){var b=X[this.opts.preflight];if(!b){b=new B;X[this.opts.preflight]=b;var c=new XMLHttpRequest;c.onreadystatechange=function(){4==c.readyState&&(200==c.status?b.provide("success"):b.provide("failure"))};c.open("get",this.opts.preflight+"?"+hex_sha1("salt"+Date.now()),!0);this.opts.credentials&&(c.withCredentials="true");c.send("")}b.await(function(a){"success"===a&&e.init()})}else e.init()}function w(a,e){z.call(this);this.bamSource=a;this.worker=e;this.opts=
{credentials:a.credentials,preflight:a.preflight,bamGroup:a.bamGroup};this.keyHolder=new B;this.init()}function r(a,e){this.source=a;this.mapping=e;this.activityListeners=[];this.busy=0}function y(){}function C(){}function F(a){this.store=new da(a.jbURI,a.jbQuery)}if("undefined"!==typeof k){var A=k("./cbrowser").Browser,R=k("./tier").DasTier;s=k("./utils");var B=s.Awaited,Q=s.arrayIndexOf;s=k("./das");var K=s.DASStylesheet,L=s.DASStyle,E=s.DASSource,e=s.DASSegment,t=s.DASFeature,l=s.DASSequence;s=
k("./bin");var f=s.URLFetchable,v=s.BlobFetchable,G=k("./twoBit").makeTwoBit,D=k("./bigwig").makeBwg;s=k("./bam");var M=s.makeBam,P=s.BamFlags;s=k("./spans");var H=s.Range,N=s.union,S=k("./cigar").parseCigar,ha=k("./overlay").OverlayFeatureSource,da=k("./jbjson").JBrowseStore}var I={},W={};R.prototype.initSources=function(){var a=this,e=new y,b;"sequence"==this.dasSource.tier_type||this.dasSource.twoBitURI||this.dasSource.twoBitBlob?b=this.dasSource.twoBitURI||this.dasSource.twoBitBlob?new d(this.dasSource):
new x(this.dasSource):e=this.browser.createFeatureSource(this.dasSource);this.featureSource=e;this.sequenceSource=b;this.featureSource&&this.featureSource.addChangeListener&&this.featureSource.addChangeListener(function(){a.browser.refreshTier(a)})};A.prototype.createFeatureSource=function(e){var f=this.sourceCache.get(e);if(f)return f;if(e.tier_type&&I[e.tier_type])f=(0,I[e.tier_type])(e).features;else if(e.bwgURI||e.bwgBlob)var d=this.getWorker(),f=d?new b(e,d):new a(e);else if(e.bamURI||e.bamBlob)f=
(d=this.getWorker())?new w(e,d):new c(e);else if(e.jbURI)f=new F(e);else if(e.uri||e.features_uri)f=new p(e);if(e.overlay){d=[];f&&d.push(new g(f));for(f=0;f<e.overlay.length;++f)d.push(this.createFeatureSource(e.overlay[f]));f=new ha(d,e)}e.mapping&&(f=new r(f,this.chains[e.mapping]));e.name&&!f.name&&(f.name=e.name);null!=f&&(f=new g(f),this.sourceCache.put(e,f));return f};R.prototype.fetchStylesheet=function(a){(this.dasSource.stylesheet_uri?new p(this.dasSource):this.getSource()).getStyleSheet(a)};
var V=0;g.prototype.addReadinessListener=function(a){if(this.source.addReadinessListener)return this.source.addReadinessListener(a);a(null)};g.prototype.search=function(a,e){if(this.source.search)return this.source.search(a,e)};g.prototype.getDefaultFIPs=function(a){if(this.source.getDefaultFIPs)return this.source.getDefaultFIPs(a)};g.prototype.getStyleSheet=function(a){this.source.getStyleSheet(a)};g.prototype.getScales=function(){return this.source.getScales()};g.prototype.addActivityListener=function(a){this.source.addActivityListener&&
this.source.addActivityListener(a)};g.prototype.addChangeListener=function(a){this.source.addChangeListener&&this.source.addChangeListener(a)};g.prototype.findNextFeature=function(a,e,b,c){this.source.findNextFeature(a,e,b,c)};g.prototype.quantFindNextFeature=function(a,e,b,c,f){this.source.quantFindNextFeature(a,e,b,c,f)};g.prototype.capabilities=function(){return this.source.capabilities?this.source.capabilities():{}};g.prototype.fetch=function(a,e,b,c,f,d,l){if(null==d)throw"pool is null...";var m=
d.awaitedFeatures[this.cfsid];m||(m=new B,d.awaitedFeatures[this.cfsid]=m,this.source.fetch(a,e,b,c,f,d,function(a,e,b,c){m.res||m.provide({status:a,features:e,scale:b,coverage:c})}));m.await(function(a){l(a.status,a.features,a.scale,a.coverage)})};z.prototype.addReadinessListener=function(a){this.readinessListeners.push(a);a(this.readiness)};z.prototype.notifyReadiness=function(){for(var a=0;a<this.readinessListeners.length;++a)try{this.readinessListeners[a](this.readiness)}catch(e){console.log(e)}};
z.prototype.addActivityListener=function(a){this.activityListeners.push(a)};z.prototype.notifyActivity=function(){for(var a=0;a<this.activityListeners.length;++a)try{this.activityListeners[a](this.busy)}catch(e){console.log(e)}};z.prototype.getScales=function(){return null};z.prototype.fetch=function(a,e,b,c,f,d,l){return l(null,[],1E9)};z.prototype.getStyleSheet=function(a){var e=new K,b=new L;b.glyph="BOX";b.BGCOLOR="blue";b.FGCOLOR="black";e.pushStyle({type:"default"},null,b);return a(e)};p.prototype.addActivityListener=
function(a){this.activityListeners.push(a)};p.prototype.notifyActivity=function(){for(var a=0;a<this.activityListeners.length;++a)try{this.activityListeners[a](this.busy)}catch(e){console.log(e)}};p.prototype.getStyleSheet=function(a){this.dasSource.stylesheet(function(e){a(e)},function(){a(null,"Couldn't fetch DAS stylesheet")})};p.prototype.fetch=function(a,b,c,f,d,l,m){if(d&&0==d.length)m(null,[],f);else if(this.dasSource.uri||this.dasSource.features_uri){if(this.dasSource.dasStaticFeatures&&this.cachedStaticFeatures)return m(null,
this.cachedStaticFeatures,this.cachedStaticScale);var g=!1!==this.dasSource.maxbins;d={type:d};g&&(d.maxbins=1+((c-b)/f|0));var h=this;h.busy++;h.notifyActivity();this.dasSource.features(new e(a,b,c),d,function(a,e){h.busy--;h.notifyActivity();var b=f;g||(b=0.1);!e&&h.dasSource.dasStaticFeatures&&(h.cachedStaticFeatures=a,h.cachedStaticScale=b);m(e,a,b)})}};p.prototype.findNextFeature=this.sourceFindNextFeature=function(a,e,b,c){if(this.dasSource.capabilities&&0<=Q(this.dasSource.capabilities,"das1:adjacent-feature")){var f=
this;if(this.dasAdjLock)return console.log("Already looking for a next feature, be patient!");this.dasAdjLock=!0;a={adjacent:a+":"+(e|0)+":"+(0<b?"F":"B")};if(e=thisTier.getDesiredTypes(thisTier.browser.scale))a.types=e;thisTier.dasSource.features(null,a,function(a){f.dasAdjLock=!1;0<a.length&&null!=a[0]&&c(a[0])})}};x.prototype.fetch=function(a,b,c,f,d){this.dasSource.sequence(new e(a,b,c),function(a){return 1==a.length?d(null,a[0]):d("Didn't get sequence")})};x.prototype.getSeqInfo=function(a,e){this.awaitedEntryPoints.await(function(b){for(var c=
0;c<b.length;++c)if(b[c].name==a)return e({length:b[c].end});return e()})};d.prototype.fetch=function(a,e,b,c,f){this.twoBit.await(function(c){c.fetch(a,e,b,function(c,d){if(d)return f(d,null);var m=new l(a,e,b,"DNA",c);return f(null,m)})})};d.prototype.getSeqInfo=function(a,e){this.twoBit.await(function(b){b.getSeq(a)?b.getSeq(a).length(function(a){e({length:a})}):e()})};p.prototype.getScales=function(){return[]};var X={};a.prototype=Object.create(z.prototype);a.prototype.init=function(){var a=this,
e;e=this.bwgSource.bwgURI?new f(this.bwgSource.bwgURI,{credentials:this.opts.credentials}):new v(this.bwgSource.bwgBlob);D(e,function(e,b){b?(a.error=b,a.readiness=null,a.notifyReadiness(),a.bwgHolder.provide(null)):(a.bwgHolder.provide(e),a.readiness=null,a.notifyReadiness(),"bigbed"==e.type&&e.getExtraIndices(function(e){a.extraIndices=e}))})};a.prototype.capabilities=function(){var a={leap:!0};this.bwgHolder.res&&"bigwig"==this.bwgHolder.res.type&&(a.quantLeap=!0);if(this.extraIndices&&0<this.extraIndices.length){a.search=
[];for(var e=0;e<this.extraIndices.length;++e)a.search.push(this.extraIndices[e].field)}return a};a.prototype.fetch=function(a,e,b,c,f,d,l){var m=this;this.bwgHolder.await(function(d){if(null==d)return l(m.error||"Can't access binary file",null,null);var g;g=!f||0==f.length||0<=Q(f,"density");m.opts.clientBin&&(g=!1);if("bigwig"==d.type||g||"undefined"!==typeof m.opts.forceReduction){g=-1;for(var h=0;h<d.zoomLevels.length;++h)if(d.zoomLevels[h].reduction<=c)g=h;else break;"undefined"!==typeof m.opts.forceReduction&&
(g=m.opts.forceReduction);g=0>g?d.getUnzoomedView():d.getZoomedView(g)}else g=d.getUnzoomedView();m.busy++;m.notifyActivity();g.readWigData(a,e,b,function(a){m.busy--;m.notifyActivity();var c=1E9;if("bigwig"===d.type){var f=(b-e)/a.length/2;f<c&&(c=f)}if(m.opts.link)for(f=0;f<a.length;++f){var g=a[f];g.label&&(g.links=[new DASLink("Link",m.opts.link.replace(/\$\$/,g.label))])}l(null,a,c)})})};a.prototype.quantFindNextFeature=function(a,e,b,c,f){var d=this;d.busy++;d.notifyActivity();this.bwgHolder.res.thresholdSearch(a,
e,b,c,function(a,e){d.busy--;d.notifyActivity();return f(a,e)})};a.prototype.findNextFeature=function(a,e,b,c){var f=this;f.busy++;f.notifyActivity();this.bwgHolder.res.getUnzoomedView().getFirstAdjacent(a,e,b,function(a){f.busy--;f.notifyActivity();0<a.length&&null!=a[0]&&c(a[0])})};a.prototype.getScales=function(){var a=this.bwgHolder.res;if(a){for(var e=[1],b=0;b<a.zoomLevels.length;++b)e.push(a.zoomLevels[b].reduction);return e}return null};a.prototype.search=function(a,e){return this.extraIndices&&
0!=this.extraIndices.length?this.extraIndices[0].lookup(a,e):e(null,"No indices available")};a.prototype.getDefaultFIPs=function(a){if(this.opts.noExtraFeatureInfo)return!0;this.bwgHolder.await(function(e){e&&e.schema&&e.definedFieldCount<e.schema.fields.length&&a(function(a,b){for(var c=0;c<b.hit.length;++c)if(b.hit[c].isSuperGroup)return;for(c=e.definedFieldCount;c<e.schema.fields.length;++c){var f=e.schema.fields[c];b.add(f.comment,a[f.name])}})})};a.prototype.getStyleSheet=function(a){this.bwgHolder.await(function(e){if(!e)return a(null,
"bbi error");var b=new K;if("bigbed"==e.type){var c=new L;c.glyph="BOX";c.FGCOLOR="black";c.BGCOLOR="blue";c.HEIGHT=8;c.BUMP=!0;c.LABEL=!0;c.ZINDEX=20;b.pushStyle({type:"bigwig"},null,c);c.glyph="BOX";c.FGCOLOR="black";c.BGCOLOR="red";c.HEIGHT=10;c.BUMP=!0;c.ZINDEX=20;b.pushStyle({type:"translation"},null,c);c=new L;c.glyph="BOX";c.FGCOLOR="black";c.BGCOLOR="white";c.HEIGHT=10;c.ZINDEX=10;c.BUMP=!0;c.LABEL=!0;b.pushStyle({type:"transcript"},null,c);c=new L;c.glyph="HISTOGRAM";c.COLOR1="white";c.COLOR2=
"black";c.HEIGHT=30;b.pushStyle({type:"density"},null,c)}else c=new L,c.glyph="HISTOGRAM",c.COLOR1="white",c.COLOR2="black",c.HEIGHT=30,b.pushStyle({type:"default"},null,c);12==e.definedFieldCount&&14<=e.fieldCount&&(b.geneHint=!0);return a(b)})};b.prototype=Object.create(z.prototype);b.prototype.init=function(){var a=this,e=this.bwgSource.uri||this.bwgSource.bwgURI,b=this.bwgSource.blob||this.bwgSource.bwgBlob,c=function(e,b){a.readiness=null;a.notifyReadiness();e?a.worker.postCommand({command:"meta",
connection:e},function(b,c){c?(a.error=c,a.keyHolder.provide(null)):(a.meta=b,a.keyHolder.provide(e))}):(a.error=b,a.keyHolder.provide(null))};b?this.worker.postCommand({command:"connectBBI",blob:b},c):this.worker.postCommand({command:"connectBBI",uri:e},c)};b.prototype.capabilities=function(){var a={leap:!0};this.meta&&"bigwig"==this.meta.type&&(a.quantLeap=!0);if(this.meta&&this.meta.extraIndices&&0<this.meta.extraIndices.length){a.search=[];for(var e=0;e<this.meta.extraIndices.length;++e)a.search.push(this.meta.extraIndices[e].field)}return a};
b.prototype.fetch=function(a,e,b,c,f,d,l){var m=this;m.busy++;m.notifyActivity();this.keyHolder.await(function(d){if(!d)return m.busy--,m.notifyActivity(),l(m.error||"Can't access binary file",null,null);var g=-1,h=!f||0==f.length||0<=Q(f,"density");m.opts.clientBin&&(h=!1);if("bigwig"==m.meta.type||h||"undefined"!==typeof m.opts.forceReduction){for(h=1;h<m.meta.zoomLevels.length;++h)if(m.meta.zoomLevels[h]<=c)g=h-1;else break;"undefined"!==typeof m.opts.forceReduction&&(g=m.opts.forceReduction)}m.worker.postCommand({command:"fetch",
connection:d,chr:a,min:e,max:b,zoom:g},function(a,c){m.busy--;m.notifyActivity();var f=1E9;if("bigwig"===m.meta.type){var d=(b-e)/a.length/2;d<f&&(f=d)}if(m.opts.link)for(d=0;d<a.length;++d){var g=a[d];g.label&&(g.links=[new DASLink("Link",m.opts.link.replace(/\$\$/,g.label))])}l(c,a,f)})})};b.prototype.quantFindNextFeature=function(a,e,b,c,f){var d=this;this.busy++;this.notifyActivity();this.worker.postCommand({command:"quantLeap",connection:this.keyHolder.res,chr:a,pos:e,dir:b,threshold:c,under:!1},
function(a,e){console.log(a,e);d.busy--;d.notifyActivity();return f(a,e)})};b.prototype.findNextFeature=function(a,e,b,c){var f=this;this.busy++;this.notifyActivity();this.worker.postCommand({command:"leap",connection:this.keyHolder.res,chr:a,pos:e,dir:b},function(a,e){f.busy--;f.notifyActivity();0<a.length&&null!=a[0]&&c(a[0])})};b.prototype.getScales=function(){var a=this.meta;return a?a.zoomLevels:null};b.prototype.search=function(a,e){if(!this.meta.extraIndices||0==this.meta.extraIndices.length)return e(null,
"No indices available");var b=this;this.busy++;this.notifyActivity();this.worker.postCommand({command:"search",connection:this.keyHolder.res,query:a,index:this.meta.extraIndices[0]},function(a,c){b.busy--;b.notifyActivity();e(a,c)})};b.prototype.getDefaultFIPs=function(a){if(this.opts.noExtraFeatureInfo)return!0;var e=this;this.keyHolder.await(function(b){var c=e.meta;c&&c.schema&&c.definedFieldCount<c.schema.fields.length&&a(function(a,e){for(var b=0;b<e.hit.length;++b)if(e.hit[b].isSuperGroup)return;
for(b=c.definedFieldCount;b<c.schema.fields.length;++b){var f=c.schema.fields[b];e.add(f.comment,a[f.name])}})})};b.prototype.getStyleSheet=function(a){var e=this;this.keyHolder.await(function(b){b=e.meta;if(!b)return a(null,"bbi error");var c=new K;if("bigbed"==b.type){var f=new L;f.glyph="BOX";f.FGCOLOR="black";f.BGCOLOR="blue";f.HEIGHT=8;f.BUMP=!0;f.LABEL=!0;f.ZINDEX=20;c.pushStyle({type:"bigwig"},null,f);f.glyph="BOX";f.FGCOLOR="black";f.BGCOLOR="red";f.HEIGHT=10;f.BUMP=!0;f.ZINDEX=20;c.pushStyle({type:"translation"},
null,f);f=new L;f.glyph="BOX";f.FGCOLOR="black";f.BGCOLOR="white";f.HEIGHT=10;f.ZINDEX=10;f.BUMP=!0;f.LABEL=!0;c.pushStyle({type:"transcript"},null,f);f=new L;f.glyph="HISTOGRAM";f.COLOR1="white";f.COLOR2="black";f.HEIGHT=30;c.pushStyle({type:"density"},null,f)}else f=new L,f.glyph="HISTOGRAM",f.COLOR1="white",f.COLOR2="black",f.HEIGHT=30,c.pushStyle({type:"default"},null,f);12==b.definedFieldCount&&14<=b.fieldCount&&(c.geneHint=!0);return a(c)})};c.prototype=Object.create(z.prototype);c.prototype.init=
function(){var a=this,e,b;this.bamSource.bamBlob?(e=new v(this.bamSource.bamBlob),b=new v(this.bamSource.baiBlob)):(e=new f(this.bamSource.bamURI,{credentials:this.opts.credentials}),b=new f(this.bamSource.baiURI||this.bamSource.bamURI+".bai",{credentials:this.opts.credentials}));M(e,b,function(e,b){a.readiness=null;a.notifyReadiness();e?a.bamHolder.provide(e):(a.error=b,a.bamHolder.provide(null))})};c.prototype.fetch=function(a,e,b,c,f,d,l){var g=f&&1==f.length&&"density"==f[0],h=this;h.busy++;h.notifyActivity();
this.bamHolder.await(function(c){if(!c)return h.busy--,h.notifyActivity(),l(h.error||"Couldn't fetch BAM");c.fetch(a,e,b,function(a,e){h.busy--;h.notifyActivity();if(e)l(e,null,null);else{for(var b=[],c=0;c<a.length;++c){var f=m(a[c],h.opts.bamGroup);f&&b.push(f)}l(null,b,1E9)}},{light:g})})};c.prototype.getScales=function(){return 1E9};c.prototype.getStyleSheet=function(a){this.bamHolder.await(function(e){e=new K;var b=new L;b.glyph="HISTOGRAM";b.COLOR1="black";b.COLOR2="red";b.HEIGHT=30;e.pushStyle({type:"density"},
"low",b);e.pushStyle({type:"density"},"medium",b);b=new L;b.glyph="__SEQUENCE";b.FGCOLOR="black";b.BGCOLOR="blue";b.HEIGHT=8;b.BUMP=!0;b.LABEL=!1;b.ZINDEX=20;e.pushStyle({type:"bam"},"high",b);return a(e)})};w.prototype=Object.create(z.prototype);w.prototype.init=function(){var a=this,e=this.bamSource.uri||this.bamSource.bamURI,b=this.bamSource.indexUri||this.bamSource.baiURI||e+".bai",c=this.bamSource.bamBlob||this.bamSource.blob,f=this.bamSource.baiBlob||this.bamSource.indexBlob,d=function(e,b){a.readiness=
null;a.notifyReadiness();e?a.keyHolder.provide(e):(a.error=b,a.keyHolder.provide(null))};c?this.worker.postCommand({command:"connectBAM",blob:c,indexBlob:f},d):this.worker.postCommand({command:"connectBAM",uri:e,indexUri:b},d)};w.prototype.fetch=function(a,e,b,c,f,d,l){var g=f&&1==f.length&&"density"==f[0],h=this;h.busy++;h.notifyActivity();this.keyHolder.await(function(c){if(!c)return h.busy--,h.notifyActivity(),l(h.error||"Couldn't fetch BAM");h.worker.postCommand({command:"fetch",connection:c,
chr:a,min:e,max:b,opts:{light:g}},function(a,e){h.busy--;h.notifyActivity();if(e)l(e,null,null);else{for(var b=[],c=0;c<a.length;++c){var f=m(a[c],h.opts.bamGroup);f&&b.push(f)}l(null,b,1E9)}})})};w.prototype.getScales=function(){return 1E9};w.prototype.getStyleSheet=function(a){this.keyHolder.await(function(e){e=new K;var b=new L;b.glyph="HISTOGRAM";b.COLOR1="black";b.COLOR2="red";b.HEIGHT=30;e.pushStyle({type:"density"},"low",b);e.pushStyle({type:"density"},"medium",b);b=new L;b.glyph="__SEQUENCE";
b.FGCOLOR="black";b.BGCOLOR="blue";b.HEIGHT=8;b.BUMP=!0;b.LABEL=!1;b.ZINDEX=20;e.pushStyle({type:"bam"},"high",b);return a(e)})};r.prototype.addActivityListener=function(a){this.activityListeners.push(a)};r.prototype.notifyActivity=function(){for(var a=0;a<this.activityListeners.length;++a)try{this.activityListeners[a](this.busy)}catch(e){console.log(e)}};r.prototype.getStyleSheet=function(a){return this.source.getStyleSheet(a)};r.prototype.getScales=function(){return this.source.getScales()};r.prototype.simplifySegments=
function(a,b){if(0==a.length)return a;a.sort(function(a,e){var b=a.name-e.name;return b?b:(b=a.start-e.start)?b:a.end-e.end});for(var c=[],f=a[0],d=0;d<a.length;++d){var l=a[d];l.name!=f.name||l.start>f.end+b?(c.push(f),f=l):f=new e(f.name,Math.min(f.start,l.start),Math.max(f.end,l.end))}c.push(f);return c};r.prototype.fetch=function(a,e,b,c,f,d,l){var m=this,g=b-e+1;m.busy++;m.notifyActivity();this.mapping.sourceBlocksForRange(a,e,b,function(e){if(0==e.length)m.busy--,m.notifyActivity(),l("No mapping available for this regions",
[],c);else{e=m.simplifySegments(e,Math.max(100,0.05*g));var b=[],h=null,k=e.length,r;e.map(function(e){m.source.fetch(e.name,e.start,e.end,c,f,d,function(c,f,d){c&&!r&&(r=c);if(f)for(c=0;c<f.length;++c){var g=f[c],t=g.segment;0==t.indexOf("chr")&&(t=t.substr(3));var p=m.mapping.mapPoint(t,g.min),t=m.mapping.mapPoint(t,g.max);p&&t&&p.seq==t.seq&&p.seq==a?(g.segment=p.seq,g.min=p.pos,g.max=t.pos,g.min>g.max&&(t=g.max,g.max=g.min,g.min=t),p.flipped&&("-"==g.orientation?g.orientation="+":"+"==g.orientation&&
(g.orientation="-")),b.push(g)):g.parts&&0<g.parts.length&&b.push(g)}f=m.mapping.mapPoint(e.name,e.start);c=m.mapping.mapPoint(e.name,e.end);f&&c&&(f=new H(f.pos,c.pos),h=h?N(h,f):f);--k;0==k&&(m.busy--,m.notifyActivity(),l(r,b,d,h))})})}})};y.prototype.getScales=function(){return null};y.prototype.fetch=function(a,e,b,c,f,d,l){return l(null,[],1E9)};y.prototype.getStyleSheet=function(a){var e=new K,b=new L;b.glyph="BOX";b.BGCOLOR="blue";b.FGCOLOR="black";e.pushStyle({type:"default"},null,b);return a(e)};
C.prototype.fetch=function(a,e,b,c,f){return f(null,null)};F.prototype.getScales=function(){return null};F.prototype.getStyleSheet=function(a){var e=new K,b=new L;b.glyph="BOX";b.FGCOLOR="black";b.BGCOLOR="green";b.HEIGHT=8;b.BUMP=!0;b.LABEL=!0;b.ZINDEX=20;e.pushStyle({type:"default"},null,b);return a(e)};F.prototype.fetch=function(a,b,c,f,d,l,m){d&&0==d.length?m(null,[],f):this.store.features(new e(a,b,c),{},function(a,e){m(e,a,1E5)})};A.prototype.sourceAdapterIsCapable=function(a,e){return a.capabilities?
a.capabilities()[e]:!1};"undefined"!==typeof u&&(u.exports={FeatureSourceBase:z,TwoBitSequenceSource:d,DASSequenceSource:x,MappedFeatureSource:r,CachingFeatureSource:g,BWGFeatureSource:a,RemoteBWGFeatureSource:b,BAMFeatureSource:c,RemoteBAMFeatureSource:w,DummyFeatureSource:y,DummySequenceSource:C,registerSourceAdapterFactory:n,registerParserFactory:h,makeParser:q},k("./ensembljson"),k("./tabix-source"),k("./memstore"),k("./bedwig"),k("./vcf"))},{"./bam":1,"./bedwig":2,"./bigwig":3,"./bin":4,"./cbrowser":6,
"./cigar":8,"./das":10,"./ensembljson":12,"./jbjson":20,"./memstore":23,"./overlay":25,"./spans":33,"./tabix-source":36,"./tier":41,"./twoBit":44,"./utils":45,"./vcf":46}],33:[function(k,u,s){function n(d,a){if("number"!=typeof d||"number"!=typeof a)throw"Bad range "+d+","+a;this._min=d;this._max=a}function h(d){this._ranges=d}function q(d,a){d instanceof Array||(d=[d],a&&d.push(a));if(0==d.length)return null;if(1==d.length)return d[0];for(var b=[],m=0;m<d.length;++m)d[m]._pushRanges(b);for(var b=
b.sort(x),m=[],c=b[0],c=new n(c._min,c._max),g=1;g<b.length;++g){var k=b[g];k._min>c._max+1?(m.push(c),c=new n(k._min,k._max)):k._max>c._max&&(c._max=k._max)}m.push(c);return 1==m.length?m[0]:new h(m)}function g(d,a){for(var b=d.ranges(),m=a.ranges(),c=b.length,g=m.length,k=0,p=0,q=[];k<c&&p<g;){d=b[k];a=m[p];var s=Math.max(d.min(),a.min()),A=Math.min(d.max(),a.max());A>=s&&q.push(new n(s,A));d.max()>a.max()?++p:++k}return 0==q.length?null:1==q.length?q[0]:new h(q)}function z(d){var a=0;d=d.ranges();
for(var b=0;b<d.length;++b)var m=d[b],a=a+(m.max()-m.min()+1);return a}function p(d,a){return d.min()<a.min()?-1:d.min()>a.min()?1:d.max()<a.max()?-1:a.max()>d.max()?1:0}function x(d,a){return d._min<a._min?-1:d._min>a._min?1:d._max<a._max?-1:a._max>d._max?1:0}n.prototype.min=function(){return this._min};n.prototype.max=function(){return this._max};n.prototype.contains=function(d){return d>=this._min&&d<=this._max};n.prototype.isContiguous=function(){return!0};n.prototype.ranges=function(){return[this]};
n.prototype._pushRanges=function(d){d.push(this)};n.prototype.toString=function(){return"["+this._min+"-"+this._max+"]"};h.prototype.min=function(){return this._ranges[0].min()};h.prototype.max=function(){return this._ranges[this._ranges.length-1].max()};h.prototype.contains=function(d){for(var a=0;a<this._ranges.length;++a)if(this._ranges[a].contains(d))return!0;return!1};h.prototype.isContiguous=function(){return 1<this._ranges.length};h.prototype.ranges=function(){return this._ranges};h.prototype._pushRanges=
function(d){for(var a=0;a<this._ranges.length;++a)d.push(this._ranges[a])};h.prototype.toString=function(){for(var d="",a=0;a<this._ranges.length;++a)0<a&&(d+=","),d+=this._ranges[a].toString();return d};"undefined"!==typeof u&&(u.exports={Range:n,union:q,intersection:g,coverage:z,rangeOver:p,_rangeOrder:x})},{}],34:[function(k,u,s){if("undefined"!==typeof k){var n=k("./cbrowser").Browser,h=k("./utils").makeElementNS,q=k("./version"),g=k("./sequence-draw").svgSeqTier;u=k("./svg-utils");var z=u.NS_SVG,
p=u.NS_XLINK,x=u.SVGPath,d=k("./numformats").formatQuantLabel}n.prototype.makeSVG=function(a){a=a||{};var b=a.minTierHeight||20,m=document.implementation.createDocument(z,"svg",null),c=h(z,"g",null,{fontFamily:"helvetica",fontSize:"8pt"});m.documentElement.appendChild(c);var k=h(z,"a",h(z,"text","Graphics from Dalliance "+q,{x:(this.featurePanelWidth+200+20)/2,y:30,strokeWidth:0,fontSize:"12pt",textAnchor:"middle",fill:"blue"}));k.setAttribute("xmlns:xlink",p);k.setAttribute("xlink:href","https://www.biodalliance.org/");
c.appendChild(k);k=h(z,"rect",null,{x:200,y:50,width:this.featurePanelWidth,height:1E5});k=h(z,"clipPath",k,{id:"featureClip"});c.appendChild(k);for(var k=70,r=h(z,"g",null,{}),n=0;n<this.tiers.length;++n){var s=this.tiers[n],u=h(z,"g",null,{clipPath:"url(#featureClip)",clipRule:"nonzero"}),A=h(z,"g"),R=k,B=h(z,"rect",null,{x:0,y:R,width:"10000",height:50,fill:s.background});u.appendChild(B);if(s.sequenceSource){var Q=g(s,s.currentSequence);u.appendChild(h(z,"g",Q,{transform:"translate(200, "+k+")"}));
k+=80}else{if(!s.subtiers)continue;for(var Q=(s.glyphCacheOrigin-this.viewStart)*this.scale,K=!1,L=0;L<s.subtiers.length;++L){for(var k=k+3,E=s.subtiers[L],e=[],t=0;t<E.glyphs.length;++t)e.push(E.glyphs[t].toSVG());u.appendChild(h(z,"g",e,{transform:"translate("+(200+Q)+", "+k+")"}));if(E.quant){var K=!0,e=E.quant,l=E.height,t=2;40<l&&(t=1+(l/20|0));var l=l/(t-1),f=(e.max-e.min)/(t-1),v=new x;v.moveTo(205,k);v.lineTo(200,k);v.lineTo(200,k+E.height);v.lineTo(205,k+E.height);for(var G=1;G<t-1;++G){var D=
G*l;v.moveTo(200,k+D);v.lineTo(203,k+D)}A.appendChild(h(z,"path",null,{d:v.toPathData(),fill:"none",stroke:"black",strokeWidth:"2px"}));A.appendChild(h(z,"text",d(e.max),{x:197,y:k+7,textAnchor:"end"}));A.appendChild(h(z,"text",d(e.min),{x:197,y:k+E.height,textAnchor:"end"}));for(G=1;G<t-1;++G)D=G*l,A.appendChild(h(z,"text",d(1*e.max-G*f),{x:197,y:k+D+3,textAnchor:"end"}))}k+=E.height+3}k-R<b&&(k=R+b)}A.appendChild(h(z,"text","string"===typeof s.config.name?s.config.name:s.dasSource.name,{x:200-(K?
20:12),y:(k+R+8)/2,fontSize:"10pt",textAnchor:"end"}));B.setAttribute("height",k-R);r.appendChild(h(z,"g",[u,A]))}if(a.highlights)for(b=this.highlights||[],K=0;K<b.length;++K)l=b[K],(l.chr==this.chr||l.chr=="chr"+this.chr)&&l.min<this.viewEnd&&l.max>this.viewStart&&(n=(Math.max(l.min,this.viewStart)-this.viewStart)*this.scale,s=(Math.min(l.max,this.viewEnd)-this.viewStart)*this.scale,r.appendChild(h(z,"rect",null,{x:200+n,y:70,width:s-n,height:k-70,stroke:"none",fill:this.defaultHighlightFill,fillOpacity:this.defaultHighlightAlpha})));
b=-1;"center"==a.ruler?b=200+(this.viewEnd-this.viewStart+1)*this.scale/2:"left"==a.ruler?b=200:"right"==a.ruler&&(b=200+(this.viewEnd-this.viewStart+1)*this.scale);0<=b&&r.appendChild(h(z,"line",null,{x1:b,y1:70,x2:b,y2:k,stroke:"blue"}));c.appendChild(r);m.documentElement.setAttribute("width",this.featurePanelWidth+20+200);m.documentElement.setAttribute("height",k+50);return new Blob([(new XMLSerializer).serializeToString(m)],{type:"image/svg+xml"})}},{"./cbrowser":6,"./numformats":24,"./sequence-draw":29,
"./svg-utils":35,"./utils":45,"./version":47}],35:[function(k,u,s){function n(){this.ops=[]}n.prototype.moveTo=function(h,k){this.ops.push("M "+h+" "+k)};n.prototype.lineTo=function(h,k){this.ops.push("L "+h+" "+k)};n.prototype.closePath=function(){this.ops.push("Z")};n.prototype.toPathData=function(){return this.ops.join(" ")};"undefined"!==typeof u&&(u.exports={NS_SVG:"http://www.w3.org/2000/svg",NS_XLINK:"http://www.w3.org/1999/xlink",SVGPath:n})},{}],36:[function(k,u,s){function n(a){g.call(this);
this.readiness="Connecting";this.source=a;this.tabixHolder=new x;var b=this,m=q(a.payload);if(m)this.parser=m;else throw"Unsuported tabix payload "+a.payload;var c;this.source.blob?(a=new p(this.source.blob),c=new p(this.source.indexBlob)):(a=new z(this.source.uri,{credentials:this.source.credentials}),c=new z(this.source.indexURI||this.source.uri+".tbi",{credentials:this.source.credentials}));d(a,c,function(a,c){b.tabixHolder.provide(a);a.fetchHeader(function(a,b){if(a){for(var c=m.createSession(function(){}),
d=0;d<a.length;++d)c.parse(a[d]);c.flush()}});b.readiness=null;b.notifyReadiness()})}if("undefined"!==typeof k){u=k("./sourceadapters");var h=u.registerSourceAdapterFactory,q=u.makeParser,g=u.FeatureSourceBase;u=k("./bin");var z=u.URLFetchable,p=u.BlobFetchable,x=k("./utils").Awaited,d=k("./tabix").connectTabix}n.prototype=Object.create(g.prototype);n.prototype.fetch=function(a,b,d,c,g,h,k){var p=this;p.busy++;p.notifyActivity();this.tabixHolder.await(function(c){c.fetch(a,b,d,function(a,b){p.busy--;
p.notifyActivity();for(var c=[],d=p.parser.createSession(function(a){c.push(a)}),m=0;m<a.length;++m)d.parse(a[m]);d.flush();k(null,c,1E9)})})};n.prototype.getStyleSheet=function(a){this.parser&&this.parser.getStyleSheet&&this.parser.getStyleSheet(a)};n.prototype.getDefaultFIPs=function(a){this.parser&&this.parser.getDefaultFIPs&&this.parser.getDefaultFIPs(a)};h("tabix",function(a){return{features:new n(a)}})},{"./bin":4,"./sourceadapters":32,"./tabix":37,"./utils":45}],37:[function(k,u,s){function n(){}
function h(a,b,d){var c=new n;c.data=a;c.tbi=b;c.tbi.fetch(function(a){if(!a)return d(null,"Couldn't access Tabix");a=p(a,a.byteLength);var b=new Uint8Array(a);if(g(b,0)!=q)return d(null,"Not a tabix index");var h=g(b,4);c.format=g(b,8);c.colSeq=g(b,12);c.colStart=g(b,16);c.colEnd=g(b,20);c.meta=g(b,24);c.skip=g(b,28);g(b,32);c.indices=[];var k=36;c.chrToIndex={};c.indexToChr=[];for(var n=0;n<h;++n){for(var A="";;){var s=b[k++];if(0==s)break;A+=String.fromCharCode(s)}c.chrToIndex[A]=n;0==A.indexOf("chr")?
c.chrToIndex[A.substring(3)]=n:c.chrToIndex["chr"+A]=n;c.indexToChr.push(A)}A=1E9;for(s=0;s<h;++s){for(var u=k,x=g(b,k),k=k+4,n=0;n<x;++n){g(b,k);var K=g(b,k+4),k=k+(8+16*K)}for(var K=g(b,k),L=k+=4,n=0;n<K;++n){var E=z(b,L),L=L+8;if(E){n=E.block;0<E.offset&&(n+=65536);n<A&&(A=n);break}}k+=8*K;0<x&&(c.indices[s]=new Uint8Array(a,u,k-u))}c.headerMax=A;d(c)})}var q=21578324;if("undefined"!==typeof k){k("./spans");var g=k("./bin").readInt;k=k("./lh3utils");var z=k.readVob,p=k.unbgzf,x=k.reg2bins,d=k.Chunk}n.prototype.blocksForRange=
function(a,b,m){var c=this.indices[a];if(!c)return[];a=x(b,m);for(var h=[],k=0;k<a.length;++k)h[a[k]]=!0;a=[];for(var p=[],k=g(c,0),n=4,q=0;q<k;++q){var A=g(c,n),s=g(c,n+4),n=n+8;if(h[A])for(var u=0;u<s;++u){var Q=z(c,n),K=z(c,n+8);(4681>A?p:a).push(new d(Q,K));n+=16}else n+=16*s}k=g(c,n);h=null;b=Math.min(b>>14,k-1);m=Math.min(m>>14,k-1);for(k=b;k<=m;++k)(b=z(c,n+4+8*k))&&(!h||b.block<h.block||b.offset<h.offset)&&(h=b);c=[];if(null!=h)for(k=0;k<p.length;++k)m=p[k],m.maxv.block>=h.block&&m.maxv.offset>=
h.offset&&c.push(m);p=c;c=[];for(k=0;k<p.length;++k)c.push(p[k]);for(k=0;k<a.length;++k)c.push(a[k]);c.sort(function(a,b){var e=a.minv.block-b.minv.block;return 0!=e?e:a.minv.offset-b.minv.offset});a=[];if(0<c.length){p=c[0];for(k=1;k<c.length;++k)m=c[k],m.minv.block==p.maxv.block?p=new d(p.minv,m.maxv):(a.push(p),p=m);a.push(p)}return a};n.prototype.fetch=function(a,b,d,c){function g(){if(s>=n.length)return c(q);if(u){var a=new Uint8Array(u);h.readRecords(a,n[s].minv.offset,q,b,d,k);u=null;++s;return g()}var x=
n[s],a=x.minv.block;h.data.slice(a,x.maxv.block+65536-a).fetch(function(a){u=p(a,x.maxv.block-x.minv.block+1);return g()})}var h=this;a=this.chrToIndex[a];if(void 0==a)return c([]);var k=this.indexToChr[a],n;void 0===a?n=[]:(n=this.blocksForRange(a,b,d))||c(null,"Error in index fetch");var q=[],s=0,u;g()};n.prototype.readRecords=function(a,b,d,c,g,h){a:for(;;){for(var k="";b<a.length;){var p=a[b++];if(10==p){p=k.split("\t");if(p[this.colSeq-1]==h){var n=parseInt(p[this.colStart-1]),q=n;0<this.colEnd&&
(q=parseInt(p[this.colEnd-1]));this.format&65536&&++n;n<=g&&q>=c&&d.push(k)}continue a}else k+=String.fromCharCode(p)}break}};n.prototype.fetchHeader=function(a){var b=this;b.data.slice(0,b.headerMax).fetch(function(d){if(!d)return a(null,"Fetch failed");d=new Uint8Array(p(d,d.byteLength));for(var c=0,g="",h=[];c<d.length;){var k=d[c++];if(10==k)if(g.charCodeAt(0)==b.meta)h.push(g),g="";else return a(h);else g+=String.fromCharCode(k)}a(h)})};"undefined"!==typeof u&&(u.exports={connectTabix:h,TABIX_MAGIC:q})},
{"./bin":4,"./lh3utils":22,"./spans":33}],38:[function(k,u,s){function n(a){this.genomes={};this.url=a}function h(){}function q(a){this.hub=a}function g(a,b,d){d=d||{};d.salt=!0;p(a,function(g,h){if(h)return b(null,h);var k=g.split(c),w=new n(a);d.credentials&&(w.credentials=d.credentials);for(var s=0;s<k.length-2;s+=3)w[k[s+1]]=k[s+2];if(w.genomesFile){var u=x(a,w.genomesFile);p(u,function(a,g){if(g)return b(null,g);for(var e=a.split(m),h=0;h<e.length;++h){var l=e[h].split(c),f=new q(w);d.credentials&&
(f.credentials=d.credentials);for(var k=0;k<l.length-2;k+=3)f[l[k+1]]=l[k+2];f.twoBitPath&&(f.twoBitPath=x(u,f.twoBitPath));f.genome&&f.trackDb&&(f.absURL=x(u,f.trackDb),w.genomes[f.genome]=f)}b(w)},d)}else b(null,"No genomesFile")},d)}function z(a,b){return a.priority&&b.priority?1*a.priority-1*b.priority:a.priority?1:b.priority?-1:a.shortLabel.localeCompare(b.shortLabel)}if("undefined"!==typeof k){s=k("./utils");var p=s.textXHR,x=s.relativeURL,d=s.shallowCopy;k=k("./das");var a=k.DASStylesheet,
b=k.DASStyle}var m=/\n\s*\n/,c=/(\w+) +(.+)\n?/,w=/subGroup[1-9]/;h.prototype.get=function(a){if(this[a])return this[a];if(this._parent)return this._parent.get(a)};q.prototype.getTracks=function(a){var b=this;if(this._tracks)return a(this._tracks);p(this.absURL,function(d,g){if(g)return a(null,g);d=d.replace("\\\n"," ");for(var k=[],p={},n=d.split(m),q=0;q<n.length;++q){var s=n[q].replace(/\#.*/g,"").split(c),u=new h;u._db=b;for(var x=0;x<s.length-2;x+=3){var e=s[x+1],t=s[x+2];if(e.match(w)){u.subgroups||
(u.subgroups={});for(var e=t.split(/\s/),t=e[0],l={name:e[1],tags:[],titles:[]},f=2;f<e.length;++f){var v=e[f].split(/=/);l.tags.push(v[0]);l.titles.push(v[1])}u.subgroups[t]=l}else if("subGroups"===e)for(e=t.split(/(\w+)=(\w+)/),u.sgm={},f=0;f<e.length-2;f+=3)u.sgm[e[f+1]]=e[f+2];else u[s[x+1]]=s[x+2]}u.track&&(u.type||u.container||u.view)&&(k.push(u),p[u.track]=u)}n=[];q=[];for(e=0;e<k.length;++e)u=k[e],s=!0,u.parent&&(x=u.parent.split(/\s+/),x=p[x[0]])&&(u._parent=x,x.children||(x.children=[]),
x.children.push(u),x&&(s=!1)),u.compositeTrack?q.push(u):s&&n.push(u);for(k=0;k<q.length;++k)if(p=q[k],p.children){u=!1;for(s=0;s<p.children.length;++s)e=p.children[s],e.view&&(e.shortLabel=p.shortLabel+": "+e.shortLabel,n.push(e),u=!0);u||n.push(p)}b._tracks=n;return a(b._tracks,null)},{credentials:this.credentials,salt:!0})};h.prototype.toDallianceSource=function(){var a={name:this.shortLabel,desc:this.longLabel};this._db.mapping&&(a.mapping=this._db.mapping);var b=this.get("pennantIcon");b&&(b=
b.split(/\s+/),a.pennant="http://genome.ucsc.edu/images/"+b[0]);if(b=this.get("searchTrix"))a.trixURI=x(this._db.absURL,b);if("multiWig"==this.container){a.merge="concat";a.overlay=[];b=this.children||[];a.style=[];a.noDownsample=!0;for(var c=0;c<b.length;++c){var d=b[c],g=d.toDallianceSource();a.overlay.push(g);if(g.style)for(var m=0;m<g.style.length;++m){var h=g.style[m];h.method=d.shortLabel;"transparentOverlay"==this.aggregate&&(h.style.ALPHA=0.5);a.style.push(h)}}return a}c=this.type.split(/\s+/);
if("bigBed"==c[0])return b=c[1]|0,c="+"==c[2],a.bwgURI=x(this._db.absURL,this.bigDataUrl),a.style=this.bigbedStyles(),this._db.credentials&&(a.credentials=!0),12<=b&&c&&(a.collapseSuperGroups=!0),a;if("bigWig"==c[0])return a.bwgURI=x(this._db.absURL,this.bigDataUrl),a.style=this.bigwigStyles(),a.noDownsample=!0,this.yLineOnOff&&"on"==this.yLineOnOff&&(a.quantLeapThreshold=void 0!==this.yLineMark?1*this.yLineMark:0),this._db.credentials&&(a.credentials=!0),a;if("bam"==c[0])return a.bamURI=x(this._db.absURL,
this.bigDataUrl),this._db.credentials&&(a.credentials=!0),a;if("vcfTabix"==c[0])return a.uri=x(this._db.absURL,this.bigDataUrl),a.tier_type="tabix",a.payload="vcf",this._db.credentials&&(a.credentials=!0),a;console.log("Unsupported "+this.type)};h.prototype.bigwigStyles=function(){var c=this.type.split(/\s+/),d,g;3<=c.length&&(d=1*c[1],g=1*c[2]);var m;this.maxHeightPixels&&(c=this.maxHeightPixels.split(/:/),3==c.length?m=c[1]|0:console.log("maxHeightPixels should be of the form max:default:min"));
c="bars";this.graphTypeDefault&&(c=this.graphTypeDefault);var h="black",k=null;this.color&&(h="rgb("+this.color+")");this.altColor&&(k="rgb("+this.altColor+")");var p=new a,n=new b;n.glyph="points"==c?"POINT":"HISTOGRAM";k?(n.COLOR1=h,n.COLOR2=k):n.BGCOLOR=h;n.HEIGHT=m||30;if(d||g)n.MIN=d,n.MAX=g;p.pushStyle({type:"default"},null,n);return p.styles};h.prototype.bigbedStyles=function(){var c="on"==(""+this.get("itemRgb")).toLowerCase(),g=this.get("visibility")||"full",m=this.get("color"),m=m?"rgb("+
m+")":"blue",h=new a,k=new b;k.glyph="BOX";k.FGCOLOR="black";k.BGCOLOR=m;k.HEIGHT="full"==g||"pack"==g?12:8;k.BUMP="full"==g||"pack"==g;k.LABEL="full"==g||"pack"==g;k.ZINDEX=20;c&&(k.BGITEM=!0);(g=this.get("colorByStrand"))?(g=g.split(/\s+/),m=d(k),m.BGCOLOR="rgb("+g[0]+")",h.pushStyle({type:"bigwig",orientation:"+"},null,m),k=d(k),k.BGCOLOR="rgb("+g[1]+")",h.pushStyle({type:"bigwig",orientation:"-"},null,k)):h.pushStyle({type:"bigwig"},null,k);k=new b;k.glyph="BOX";k.FGCOLOR="black";c&&(k.BGITEM=
!0);k.BGCOLOR="red";k.HEIGHT=10;k.BUMP=!0;k.ZINDEX=20;h.pushStyle({type:"translation"},null,k);c=new b;c.glyph="BOX";c.FGCOLOR="black";c.BGCOLOR="white";c.HEIGHT=10;c.ZINDEX=10;c.BUMP=!0;c.LABEL=!0;h.pushStyle({type:"transcript"},null,c);return h.styles};"undefined"!==typeof u&&(u.exports={connectTrackHub:g,THUB_COMPARE:z})},{"./das":10,"./utils":45}],39:[function(k,u,s){if("undefined"!==typeof k)var n=k("./cbrowser").Browser,h=k("./utils").shallowCopy;n.prototype.mergeSelectedTiers=function(){for(var k=
[],g=[],n=0;n<this.selectedTiers.length;++n){var p=this.tiers[this.selectedTiers[n]];k.push(h(p.dasSource));for(var s=p.stylesheet.styles,d=0;d<s.length;++d){var a=s[d],b=h(a);b.method=p.dasSource.name.replace(/[()+*?]/g,"\\$&");b._methodRE=null;b.style=h(a.style);void 0===b.style.ZINDEX&&(b.style.ZINDEX=n);p.forceMin&&(b.style.MIN=p.forceMin);p.forceMax&&(b.style.MAX=p.forceMax);g.push(b)}}this.addTier({name:"Merged",merge:"concat",overlay:k,noDownsample:!0,style:g});this.setSelectedTier(this.tiers.length-
1)}},{"./cbrowser":6,"./utils":45}],40:[function(k,u,s){function n(d){for(var a=0;a<d.styles.length;++a){var b=d.styles[a].style;if("__SEQUENCE"===b.glyph)return b}}if("undefined"!==typeof k){var h=k("./cbrowser").Browser,q=k("./utils").makeElement;u=k("./das");var g=u.isDasBooleanTrue,z=u.copyStylesheet,p=k("./color").dasColourForName}var x={DOT:!0,EX:!0,STAR:!0,SQUARE:!0,CROSS:!0,TRIANGLE:!0,PLIMSOLL:!0};h.prototype.openTierPanel=function(d){if("tier"===this.uiMode&&this.manipulatingTier===d)this.hideToolPanel(),
this.setUiMode("none");else{var a=function(a){a.BGGRAD||(1==E?("LINEPLOT"==a.glyph||x[a.glyph]?a.FGCOLOR=A.value:a.BGCOLOR=A.value,a.COLOR1=a.COLOR2=a.COLOR3=null):(a.COLOR1=A.value,a.COLOR2=R.value,a.COLOR3=2<E?B.value:null),a._gradient=null)},b=function(a){for(var e=z(d.stylesheet),b=d.browser.zoomForCurrentScale(),c=0;c<e.styles.length;++c){var f=e.styles[c];f.zoom&&f.zoom!=b||a(f.style)}return e},m=function(e){d.mergeConfig({stylesheet:b(a)})};this.manipulatingTier=d;var c=q("div",null,{className:"tier-edit"});
if(d.dasSource.mapping){var h=this.chains[d.dasSource.mapping].coords;c.appendChild(q("div","Mapped from "+h.auth+h.version,null,{background:"gray",paddingBottom:"5px",marginBottom:"5px",textAlign:"center"}))}var k=q("div","Editing styles for current zoom level",null,{background:"gray",paddingBottom:"5px",marginBottom:"5px",textAlign:"center",display:"none"});c.appendChild(k);var s=q("input",null,{type:"text"}),u=q("input",null,{type:"checkbox"}),F=q("select");F.appendChild(q("option","Histogram",
{value:"HISTOGRAM"}));F.appendChild(q("option","Line Plot",{value:"LINEPLOT"}));F.appendChild(q("option","Ribbon",{value:"GRADIENT"}));F.appendChild(q("option","Scatter",{value:"SCATTER"}));var A=q("input",null,{type:"text",value:"#dd00dd"}),R=q("input",null,{type:"text",value:"#dd00dd"}),B=q("input",null,{type:"text",value:"#dd00dd"});try{A.type=R.type=B.type="color"}catch(Q){}var K=[A,R,B],h=q("i",null,{className:"fa fa-plus-circle"}),L=q("i",null,{className:"fa fa-minus-circle"}),E=1,e=q("td",
K),t=function(a){E=a;for(var e=0;e<a;++e)K[e].style.display="block";for(e=a;e<K.length;++e)K[e].style.display="none"};h.addEventListener("click",function(a){3>E&&(t(E+1),m(null))},!1);L.addEventListener("click",function(a){1<E&&(t(E-1),m(null))},!1);var l=q("input",null,{type:"text",value:"0.0"}),f=q("input",null,{type:"text",value:"10.0"}),v=q("input",null,{type:"checkbox"}),G=q("input",null,{type:"checkbox"}),D=q("input",null,{type:"checkbox",checked:void 0!==d.quantLeapThreshold}),M=q("input",
null,{type:"text",value:d.quantLeapThreshold,disabled:!D.checked}),P=q("input",null,{type:"text",value:"50"}),H=q("input",null,{type:"checkbox"}),N=q("input",null,{type:"checkbox"}),S=null;0<d.stylesheet.styles.length&&(S=d.stylesheet.styles[0].style);var ha=function(){s.value="string"===typeof d.config.name?d.config.name:d.dasSource.name;u.checked=d.pinned;d.forceHeight?P.value=""+d.forceHeight:S&&S.HEIGHT&&(P.value=""+S.HEIGHT);"number"==typeof d.quantLeapThreshold?(D.checked=!0,M.disabled=!1,parseFloat(M.value)!=
d.quantLeapThreshold&&(M.value=d.quantLeapThreshold)):(D.checked=!1,M.disabled=!0);if(0<d.stylesheet.styles.length){for(var a=null,e=!1,b=!1,b=d.browser.zoomForCurrentScale(),c=0,m=0;m<d.stylesheet.styles.length;++m){var h=d.stylesheet.styles[m];if(!h.zoom||h.zoom==b)if(++c,h=d.stylesheet.styles[m].style,a||(a=S=h),"LINEPLOT"==h.glyph||"HISTOGRAM"==h.glyph||"GRADIENT"==h.glyph||g(h.SCATTER))e||(a=S=h),e=!0}if(!a)return;k.style.display=c==d.stylesheet.styles.length?"none":"block";b=e&&1==c;e?(na.style.display=
"table-row",ea.style.display="table-row",Y.style.display="none",ka.style.display="none"):(na.style.display="none",ea.style.display="none",Y.style.display="table-row",H.checked=g(S.BUMP),ka.style.display="table-row",N.checked=g(S.LABEL));b?(X.style.display="table-row",U.style.display="table-row"):(X.style.display="none",U.style.display="none");b=1;a.COLOR1?(A.value=p(a.COLOR1).toHexString(),a.COLOR2&&(R.value=p(a.COLOR2).toHexString(),a.COLOR3?(B.value=p(a.COLOR3).toHexString(),b=3):b=2)):"LINEPLOT"==
a.glyph||"DOT"==a.glyph&&a.FGCOLOR?A.value=p(a.FGCOLOR).toHexString():a.BGCOLOR&&(A.value=p(a.BGCOLOR).toHexString());t(b);g(a.SCATTER)?F.value="SCATTER":F.value=a.glyph;var q,w;void 0!==a.MIN&&(b=parseFloat(a.MIN),isNaN(b)||(q=b));d.forceMinDynamic||void 0===a.MIN&&void 0===d.forceMin?(v.checked=!1,l.disabled=!0):(v.checked=!0,l.disabled=!1);void 0!==a.MAX&&(b=parseFloat(a.MAX),isNaN(b)||(w=b));d.forceMaxDynamic||void 0===a.MAX&&void 0===d.forceMax?(G.checked=!1,f.disabled=!0):(G.checked=!0,f.disabled=
!1);void 0!=d.forceMin&&(q=d.forceMin);void 0!=d.forceMax&&(w=d.forceMax);"number"==typeof q&&q!=parseFloat(l.value)&&(l.value=q);"number"==typeof w&&w!=parseFloat(f.value)&&(f.value=w);(a=n(d.stylesheet))?(I.style.display="table-row",da.checked="mismatch"===a.__SEQCOLOR,V.style.display="table-row",W.checked=g(a.__INSERTIONS)):(I.style.display="none",V.style.display="none")}e&&d.browser.sourceAdapterIsCapable(d.featureSource,"quantLeap")?oa.style.display="table-row":oa.style.display="none"},da=q("input",
null,{type:"checkbox"}),I=q("tr",[q("th","Color mismatches"),q("td",da)]);da.addEventListener("change",function(a){a=z(d.stylesheet);n(a).__SEQCOLOR=da.checked?"mismatch":"base";d.mergeConfig({stylesheet:a})});var W=q("input",null,{type:"checkbox"}),V=q("tr",[q("th","Show insertions"),q("td",W)]);W.addEventListener("change",function(a){a=z(d.stylesheet);n(a).__INSERTIONS=W.checked?"yes":"no";d.mergeConfig({stylesheet:a})});var X=q("tr",[q("th","Style"),q("td",F)]),U=q("tr",[q("th",["Colour(s)",h,
L]),e]),na=q("tr",[q("th","Min value"),q("td",[v," ",l])]),ea=q("tr",[q("th","Max value"),q("td",[G," ",f])]),oa=q("tr",[q("th","Threshold leap:"),q("td",[D," ",M])]),Y=q("tr",[q("th","Bump overlaps"),q("td",H)]),ka=q("tr",[q("th","Label features"),q("td",N)]),h=q("table",[q("tr",[q("th","Name",{},{width:"150px",textAlign:"right"}),s]),q("tr",[q("th","Pin to top"),u]),q("tr",[q("th","Height"),q("td",P)]),X,U,na,ea,oa,Y,ka,I,V]);ha();c.appendChild(h);h=q("button","Reset track",{className:"btn"},{marginLeft:"auto",
marginRight:"auto",display:"block"});h.addEventListener("click",function(a){d.setConfig({})},!1);c.appendChild(h);s.addEventListener("input",function(a){d.mergeConfig({name:s.value})},!1);u.addEventListener("change",function(a){d.mergeConfig({pinned:u.checked})},!1);for(h=0;h<K.length;++h)K[h].addEventListener("change",m,!1);F.addEventListener("change",function(e){e=b(function(e){"SCATTER"===F.value?(e.SCATTER=!0,e.glyph="DOT",e.SIZE="3"):(e.glyph=F.value,e.SCATTER=void 0);a(e)});d.mergeConfig({stylesheet:e})},
!1);v.addEventListener("change",function(a){a={forceMinDynamic:!v.checked};l.disabled=!v.checked;var e=parseFloat(l.value);v.checked&&"number"==typeof e&&!isNaN(e)&&(a.forceMin=parseFloat(e));d.mergeConfig(a)});l.addEventListener("input",function(a){a=parseFloat(l.value);"number"!=typeof a||isNaN(a)||d.mergeConfig({forceMin:a})},!1);G.addEventListener("change",function(a){a={forceMaxDynamic:!G.checked};f.disabled=!G.checked;var e=parseFloat(f.value);G.checked&&"number"==typeof e&&!isNaN(e)&&(a.forceMax=
parseFloat(e));d.mergeConfig(a)});f.addEventListener("input",function(a){a=parseFloat(f.value);"number"!=typeof a||isNaN(a)||d.mergeConfig({forceMax:a})},!1);P.addEventListener("input",function(a){a=parseFloat(P.value);"number"!=typeof a||isNaN(a)||d.mergeConfig({height:Math.min(500,a|0)})},!1);var ia=function(){M.disabled=!D.checked;if(D.checked){var a=parseFloat(M.value);"number"!=typeof a||isNaN(a)||d.mergeConfig({quantLeapThreshold:parseFloat(M.value)})}else d.mergeConfig({quantLeapThreshold:null})};
D.addEventListener("change",function(a){ia()},!1);M.addEventListener("input",function(a){ia()},!1);N.addEventListener("change",function(a){a=b(function(a){a.LABEL=N.checked?"yes":"no"});d.mergeConfig({stylesheet:a})},!1);H.addEventListener("change",function(a){a=b(function(a){a.BUMP=H.checked?"yes":"no"});d.mergeConfig({stylesheet:a})},!1);this.showToolPanel(c);this.setUiMode("tier");d.addTierListener(ha);var la=d.browser.scale;d.browser.addViewListener(function(){d.browser.scale!=la&&(la=d.browser.scale,
ha())})}}},{"./cbrowser":6,"./color":9,"./das":10,"./utils":45}],41:[function(k,u,s){function n(a,d,c,g){this.config=c||{};this.id="tier"+ ++x;this.browser=a;this.dasSource=q(d);this.background=g;this.viewport=h("canvas",null,{width:""+((this.browser.featurePanelWidth|0)+2E3),height:"30",className:"viewport"});this.overlay=h("canvas",null,{width:+((this.browser.featurePanelWidth|0)+2E3),height:"30",className:"viewport-overlay"});this.notifier=h("div","",{className:"notifier"});this.notifierHolder=
h("div",this.notifier,{className:"notifier-holder"});this.quantOverlay=h("canvas",null,{width:"50",height:"56",className:"quant-overlay"});this.removeButton=h("i",null,{className:"fa fa-times"});this.bumpButton=h("i",null,{className:"fa fa-plus-circle"});this.loaderButton=a.makeLoader(16);this.loaderButton.style.display="none";this.infoElement=h("div",this.dasSource.desc,{className:"track-label-info"});this.nameButton=h("div",[],{className:"tier-tab"});this.nameButton.appendChild(this.removeButton);
d.pennant&&this.nameButton.appendChild(h("img",null,{src:d.pennant,width:"16",height:"16"}));this.nameElement=h("span",d.name);this.nameButton.appendChild(h("span",[this.nameElement,this.infoElement],{className:"track-name-holder"}));this.nameButton.appendChild(this.bumpButton);this.nameButton.appendChild(this.loaderButton);this.label=h("span",[this.nameButton],{className:"btn-group track-label"});this.row=h("div",[this.viewport,this.overlay,this.quantOverlay],{className:"tier"});g||(this.row.style.background=
"none");a.noDefaultLabels||this.row.appendChild(this.label);this.row.appendChild(this.notifierHolder);this.layoutHeight=25;this.bumped=!0;this.styleIdSeed=0;d.quantLeapThreshold&&(this.quantLeapThreshold=d.quantLeapThreshold);this.dasSource.collapseSuperGroups&&(this.bumped=!1);this.layoutWasDone=!1;d.featureInfoPlugin&&this.addFeatureInfoPlugin(d.featureInfoPlugin);this.initSources();var k=this;this.featureSource&&this.featureSource.getDefaultFIPs&&!d.noSourceFeatureInfo&&this.featureSource.getDefaultFIPs(function(a){a&&
k.addFeatureInfoPlugin(a)});this.featureSource&&this.featureSource.addReadinessListener&&this.featureSource.addReadinessListener(function(a){k.notify(a,-1)});this.listeners=[];this.featuresLoadedListeners=[]}if("undefined"!==typeof k){s=k("./utils");var h=s.makeElement,q=s.shallowCopy,g=s.pushnew;s=k("./das");var z=s.DASStylesheet,p=s.DASStyle}var x=0;n.prototype.toString=function(){return this.id};n.prototype.addFeatureInfoPlugin=function(a){this.featureInfoPlugins||(this.featureInfoPlugins=[]);
this.featureInfoPlugins.push(a)};n.prototype.init=function(){var a=this;a.dasSource.style?(this.setStylesheet({styles:a.dasSource.style}),this.browser.refreshTier(this)):(a.status="Fetching stylesheet",a.fetchStylesheet(function(d,c){if(c||!d){a.error="No stylesheet";d=new z;var g=new p;g.glyph="BOX";g.BGCOLOR="blue";g.FGCOLOR="black";d.pushStyle({type:"default"},null,g);a.setStylesheet(d)}else a.setStylesheet(d),d.geneHint&&(a.dasSource.collapseSuperGroups=!0,a.bumped=!1,a.updateLabel());a.browser.refreshTier(a)}))};
n.prototype.setStylesheet=function(a){this.baseStylesheet=q(a);for(a=0;a<this.baseStylesheet.styles.length;++a){var d=this.baseStylesheet.styles[a]=q(this.baseStylesheet.styles[a]);d._methodRE=d._labelRE=d._typeRE=null;d.style=q(d.style);d.style.id="style"+ ++this.styleIdSeed}this._updateFromConfig()};n.prototype.getSource=function(){return this.featureSource};n.prototype.getDesiredTypes=function(a){a=[];var d=!1,c=this.browser.zoomForCurrentScale();if(this.stylesheet){for(var h=this.stylesheet.styles,
k=0;k<h.length;++k){var p=h[k];if(!p.zoom||p.zoom==c)if(p.type&&"default"!=p.type)g(a,p.type);else{d=!0;break}}return d?null:a}};n.prototype.needsSequence=function(a){return this.sequenceSource&&5>a||(this.dasSource.bamURI||this.dasSource.bamBlob)&&20>a?!0:!1};n.prototype.viewFeatures=function(a,d,c,g,h){this.currentFeatures=g;this.currentSequence=h;this.notifyFeaturesLoaded();this.knownChr=a;this.knownCoverage=d;this.status&&(this.status=null,this._notifierToStatus());this.draw()};n.prototype.draw=
function(){var b=this.currentSequence;this.sequenceSource?a(this,b):d(this);this.paint();this.originHaxx=0;this.browser.arrangeTiers()};n.prototype.findNextFeature=function(a,d,c,g,h){if(this.quantLeapThreshold)d=d+(this.browser.viewEnd-this.browser.viewStart+1)*c/2|0,this.featureSource.quantFindNextFeature(a,d,c,this.quantLeapThreshold,h);else{if(this.knownCoverage&&d>=this.knownCoverage.min()&&d<=this.knownCoverage.max()&&this.currentFeatures){for(var k=null,p=0;p<this.currentFeatures.length;++p){var n=
this.currentFeatures[p];if(n.min&&n.max&&!(n.parents&&0<n.parents.length))if(0>c)if(1==g&&n.max>=d&&n.min<d){if(!k||n.min>k.min||n.min==k.min&&n.max<k.max)k=n}else n.max<d&&(!k||n.max>k.max||n.max==k.max&&n.min<k.min||n.min==k.mmin&&k.max>=d)&&(k=n);else if(1==g&&n.min<=d&&n.max>d){if(!k||n.max<k.max||n.max==k.max&&n.min>k.min)k=n}else n.min>d&&(!k||n.min<k.min||n.min==k.min&&n.max>k.max||n.max==k.max&&k.min<=d)&&(k=n)}if(k)return h(k);d=0>c?this.browser.knownSpace.min:this.browser.knownSpace.max}this.trySourceFNF(a,
d,c,h)}};n.prototype.trySourceFNF=function(a,d,c,g){var h=this;this.featureSource.findNextFeature(a,d,c,function(a){a||g(a);var b=h.browser.getSequenceSource();b||g(a);b.getSeqInfo(a.segment,function(b){b?g(a):h.trySourceFNF(a.segment,0<c?1E10:0,c,g)})})};n.prototype.updateLabel=function(){this.bumpButton.className=this.bumped?"fa fa-minus-circle":"fa fa-plus-circle";this.bumpButton.style.display=this.dasSource.collapseSuperGroups?"inline-block":"none"};n.prototype.updateHeight=function(){this.currentHeight=
Math.max(Math.max(this.layoutHeight,this.label.clientHeight+2),this.browser.minTierHeight);this.row.style.height=""+this.currentHeight+"px";this.browser.updateHeight()};n.prototype.drawOverlay=function(){var a=this.browser,d=a.retina&&1<window.devicePixelRatio,c=this.overlay.getContext("2d");this.overlay.height=this.viewport.height;this.overlay.width=this.viewport.width;d&&c.scale(2,2);for(var d=a.viewStart-1E3/a.scale,g=a.viewStart-1E3/a.scale,h=a.viewEnd+1E3/a.scale,k=0;k<a.highlights.length;++k){var n=
a.highlights[k];(n.chr===a.chr||n.chr==="chr"+a.chr)&&n.min<h&&n.max>g&&(c.globalAlpha=a.defaultHighlightAlpha,c.fillStyle=a.defaultHighlightFill,c.fillRect((n.min-d)*a.scale,0,(n.max-n.min)*a.scale,this.overlay.height))}this.oorigin=a.viewStart;this.overlay.style.width=this.viewport.style.width;this.overlay.style.height=this.viewport.style.height;this.overlay.style.left="-1000px"};n.prototype.updateStatus=function(a){a?(this.status=a,this.currentFeatures=[],this.currentSequence=null,this.draw(),
this.updateHeight(),this._notifierToStatus()):this.status&&(this.status=null,this._notifierToStatus())};n.prototype.notify=function(a,d){"number"!==typeof d&&(d=2E3);this.notifierFadeTimeout&&(clearTimeout(this.notifierFadeTimeout),this.notifierFadeTimeout=null);if(a){if(this._notifierOn(a),0<d){var c=this;this.notifierFadeTimeout=setTimeout(function(){c._notifierToStatus()},d)}}else this._notifierToStatus()};n.prototype._notifierOn=function(a){this.notifier.textContent=a;this.notifier.style.opacity=
0.8};n.prototype._notifierOff=function(){this.notifier.style.opacity=0};n.prototype._notifierToStatus=function(){this.status?this._notifierOn(this.status):this._notifierOff()};n.prototype.setConfig=function(a){this.config=a||{};this._updateFromConfig();this.notifyTierListeners()};n.prototype.mergeConfig=function(a){for(var d in a)this.config[d]=a[d];this._updateFromConfig();this.notifyTierListeners()};n.prototype._updateFromConfig=function(){var a=!1,d=!1;this.nameElement.textContent="string"===typeof this.config.name?
this.config.name:this.dasSource.name;var c=this.config.height||this.dasSource.forceHeight;c!=this.forceHeight&&(this.forceHeight=c,a=!0);this.forceMinDynamic!=this.config.forceMinDynamic&&(this.forceMinDynamic=this.config.forceMinDynamic,a=!0);c=void 0!=this.config.forceMin?this.config.forceMin:this.dasSource.forceMin;this.forceMin!=c&&(this.forceMin=c,a=!0);this.forceMaxDynamic!=this.config.forceMaxDynamic&&(this.forceMaxDynamic=this.config.forceMaxDynamic,a=!0);c=void 0!=this.config.forceMax?this.config.forceMax:
this.dasSource.forceMax;this.forceMax!=c&&(this.forceMax=c,a=!0);c=null;void 0!==this.config.quantLeapThreshold?c=this.config.quantLeapThreshold:void 0!==this.dasSource.quantLeapThreshold&&(c=this.dasSource.quantLeapThreshold);c!=this.quantLeapThreshold&&(this.quantLeapThreshold=c,a=!0);c=this.config.stylesheet||this.baseStylesheet;this.stylesheet!==c&&(this.stylesheet=c,a=!0);c=void 0!==this.config.pinned?this.config.pinned:this.dasSource.pinned;c!==this.pinned&&(this.pinned=c,d=!0);a&&this.scheduleRedraw();
d&&this.browser.reorderTiers()};n.prototype.scheduleRedraw=function(){if(this.currentFeatures){var a=this;this.redrawTimeout||(this.redrawTimeout=setTimeout(function(){a.draw();a.redrawTimeout=null},10))}};n.prototype.addTierListener=function(a){this.listeners.push(a)};n.prototype.notifyTierListeners=function(a){for(var d=0;d<this.listeners.length;++d)try{this.listeners[d](a)}catch(c){console.log(c)}this.browser.notifyTier()};n.prototype.addFeaturesLoadedListener=function(a){this.featuresLoadedListeners.push(a)};
n.prototype.notifyFeaturesLoaded=function(){for(var a=0;a<this.featuresLoadedListeners.length;++a)try{this.featuresLoadedListeners[a].call(this)}catch(d){console.log(d)}};if("undefined"!==typeof u){u.exports={DasTier:n};var d=k("./feature-draw").drawFeatureTier,a=k("./sequence-draw").drawSeqTier}},{"./das":10,"./feature-draw":16,"./sequence-draw":29,"./utils":45}],42:[function(k,u,s){function n(a,b){for(var c=0;c<a.length;++c){var d=a[c];d===b?d.classList.add("active"):d.classList.remove("active")}}
if("undefined"!==typeof k){u=k("./cbrowser");var h=u.Browser,q=u.sourcesAreEqual;u=k("./utils");var g=u.makeElement,z=u.removeChildren,p=u.Observed;u=k("./thub");var x=u.THUB_COMPARE,d=u.connectTrackHub,a=k("./domui").makeTreeTableSection,b=k("./probe").probeResource;u=k("./bin");var m=u.URLFetchable,c=u.BlobFetchable,w=u.readInt,r=k("./lh3utils").unbgzf,y=k("./bam").BAI_MAGIC,C=k("./tabix").TABIX_MAGIC;k=k("./das");var F=k.DASSource,A=k.DASSegment,R=k.DASRegistry}h.prototype.currentlyActive=function(a){for(var b=
0;b<this.tiers.length;++b)if(q(this.tiers[b].dasSource,a))return this.tiers[b];return!1};h.prototype.makeButton=function(a,b){var c=g("a",a,{href:"#"});b&&this.makeTooltip(c,b);return g("li",c)};h.prototype.showTrackAdder=function(h){function k(e){ca.style.display="none";fa.style.display="none";aa.style.display="none";T=!1;z(J);for(var b=g("div",null,{},{width:"100%"}),c=[],f=0;f<e.length;++f)c.push(e[f]);c.sort(function(a,e){return a.shortLabel.toLowerCase().trim().localeCompare(e.shortLabel.toLowerCase().trim())});
e=[];for(var d=[],f=0;f<c.length;++f){var l=c[f];l.children&&0<l.children.length&&"multiWig"!=l.container?e.push(l):d.push(l)}0<d.length&&e.push({shortLabel:"Others",priority:-1E8,children:d});e.sort(x);for(var h=[],c=0;c<e.length;++c){l=d=e[c];!l.dimensions&&l._parent&&l._parent.dimensions&&(l=l._parent);f={};if(l.dimensions)for(var m=l.dimensions.split(/(\w+)=(\w+)/),n=0;n<m.length-2;n+=3)f[m[n+1]]=m[n+2];if(f.dimX&&f.dimY){for(var t=f.dimX,p=f.dimY,f=l.subgroups[t],m=l.subgroups[p],n={},r=0;r<
d.children.length;++r){var v=d.children[r],l=v.sgm[t],q=v.sgm[p];n[l]||(n[l]={});n[l][q]=v}p=g("table",null,{className:"table table-striped table-condensed"},{tableLayout:"fixed"});l=g("tr");l.appendChild(g("th",null,{},{width:"150px",height:"100px"}));for(q=0;q<f.titles.length;++q)t=g("th",g("div",f.titles[q],{},{transform:"rotate(-60deg)",transformOrigin:"0% 100%",webkitTransform:"rotate(-60deg) translate(20px,10px)",webkitTransformOrigin:"0% 100%",textAlign:"left"}),{},{width:"35px",height:"100px",
verticalAlign:"bottom"}),l.appendChild(t);p.appendChild(l);for(var w=g("tbody",null,{className:"table table-striped table-condensed"}),s=0;s<m.titles.length;++s){var q=m.tags[s],u=g("tr");u.appendChild(g("th",m.titles[s]),{});for(var A=0;A<f.titles.length;++A){var l=f.tags[A],y=g("td");if(n[l]&&n[l][q]){l=n[l][q];r=l.toDallianceSource();if(!r)continue;t=g("tr");v=g("td");v.style.textAlign="center";var G=g("input");G.type="checkbox";G.dalliance_source=r;ma&&(G.dalliance_mapping=ma);h.push(G);y.appendChild(G);
G.addEventListener("change",function(a){a.target.checked?D.addTier(a.target.dalliance_source):D.removeTier(a.target.dalliance_source)})}u.appendChild(y)}w.appendChild(u)}p.appendChild(w);b.appendChild(a(d.shortLabel,p,0==c))}else{m=g("tbody",null,{className:"table table-striped table-condensed"});n=g("table",m,{className:"table table-striped table-condensed"},{width:"100%",tableLayout:"fixed"});q=0;d.children.sort(x);for(f=0;f<d.children.length;++f)if(l=d.children[f],r=l.toDallianceSource())t=g("tr"),
v=g("td",null,{},{width:"30px"}),v.style.textAlign="center",G=g("input"),G.type="checkbox",G.dalliance_source=r,ma&&(G.dalliance_mapping=ma),h.push(G),v.appendChild(G),G.addEventListener("change",function(a){a.target.checked?D.addTier(a.target.dalliance_source):D.removeTier(a.target.dalliance_source)}),t.appendChild(v),p=g("td"),p.appendChild(document.createTextNode(l.shortLabel)),l.longLabel&&0<l.longLabel.length&&D.makeTooltip(p,l.longLabel),t.appendChild(p),m.appendChild(t),++q;1<e.length||"Others"!==
d.shortLabel?b.appendChild(a(d.shortLabel,n,0==c)):b.appendChild(n)}}var B=function(){for(var a=0;a<h.length;++a){var e=h[a],b=D.currentlyActive(e.dalliance_source);b?(e.checked=!0,e.disabled=null!=b.sequenceSource):e.checked=!1}};B();D.addTierListener(function(a){B()});J.appendChild(b)}function q(){n(M,na);T="bin";ca.style.display="none";fa.style.display="inline";aa.style.display="none";z(J);var a=g("div",null,{},{paddingLeft:"10px",paddingRight:"10px"});a.appendChild(g("h3","Add custom URL-based data"));
a.appendChild(g("p",["You can add indexed binary data hosted on an web server that supports CORS (",g("a","full details",{href:"https://www.biodalliance.org/bin.html"}),").  Currently supported formats are bigwig, bigbed, and indexed BAM."]));a.appendChild(g("br"));a.appendChild(document.createTextNode("URL: "));Y=g("input","",{size:80,value:"https://www.biodalliance.org/datasets/ensGene.bb"},{width:"100%"});a.appendChild(Y);a.appendChild(g("br"));a.appendChild(g("b","- or -"));a.appendChild(g("br"));
a.appendChild(document.createTextNode("File: "));ja=g("input",null,{type:"file",multiple:"multiple"});a.appendChild(ja);a.appendChild(g("p",'Clicking the "Add" button below will initiate a series of test queries.'));J.appendChild(a);Y.focus()}function s(){n(M,ea);ca.style.display="none";fa.style.display="inline";aa.style.display="none";T="hub-connect";ca.style.visibility="hidden";z(J);var a=g("div",null,{},{paddingLeft:"10px",paddingRight:"10px"});a.appendChild(g("h3","Connect to a track hub."));
a.appendChild(g("p",['Enter the top-level URL (usually points to a file called "hub.txt") of a UCSC-style track hub']));Y=g("input","",{size:120,value:"https://www.biodalliance.org/datasets/testhub/hub.txt"},{width:"100%"});a.appendChild(Y);J.appendChild(a);Y.focus()}function u(){n(M,U);ca.style.display="none";fa.style.display="inline";aa.style.display="none";T="das";z(J);var a=g("div",null,{},{paddingLeft:"10px",paddingRight:"10px"});a.appendChild(g("h3","Add custom DAS data"));a.appendChild(g("p",
"This interface is intended for adding custom or lab-specific data.  Public data can be added more easily via the registry interface."));a.appendChild(document.createTextNode("URL: "));a.appendChild(g("br"));Y=g("input","",{size:80,value:"http://www.derkholm.net:8080/das/medipseq_reads/"},{width:"100%"});a.appendChild(Y);a.appendChild(g("p",'Clicking the "Add" button below will initiate a series of test queries.  If the source is password-protected, you may be prompted to enter credentials.'));J.appendChild(a);
Y.focus()}function e(){if(T)if("das"===T){var a=Y.value.trim();/^.+:\/\//.exec(a)||(a="http://"+a);var e=new F({name:"temporary",uri:a});ta(e)}else if("bin"===T)if((a=ja.files)&&0<a.length){e=ba=[];T="multiple";for(var b=0;b<a.length;++b){var c=a[b];c&&e.push({blob:c})}for(b=0;b<e.length;++b)$(e[b]);ga()}else a=Y.value.trim(),/^.+:\/\//.exec(a)||(a="http://"+a),O({uri:a});else if("reset"===T)u();else if("reset-bin"===T)q();else if("reset-hub"===T)s();else if("prompt-bai"===T)(a=ja.files)&&0<a.length&&
a[0]?(Z.baiBlob=a[0],f(Z)):(a=Z,ca.style.display="none",fa.style.display="inline",aa.style.display="inline",z(J),T="prompt-bai",J.appendChild(g("h2","Select an index file")),J.appendChild(g("p","Dalliance requires a BAM index (.bai) file when displaying BAM data.  These normally accompany BAM files.  For security reasons, web applications like Dalliance can only access local files which you have explicity selected.  Please use the file chooser below to select the appropriate BAI file")),J.appendChild(document.createTextNode("Index file: ")),
ja=g("input",null,{type:"file"}),J.appendChild(ja),Z=a);else if("prompt-tbi"===T)(a=ja.files)&&0<a.length&&a[0]?(Z.indexBlob=a[0],v(Z)):(a=Z,ca.style.display="none",fa.style.display="inline",aa.style.display="inline",z(J),T="prompt-tbi",J.appendChild(g("h2","Select an index file")),J.appendChild(g("p","Dalliance requires a Tabix index (.tbi) file when displaying VCF data.  For security reasons, web applications like Dalliance can only access local files which you have explicity selected.  Please use the file chooser below to select the appropriate BAI file")),
J.appendChild(document.createTextNode("Index file: ")),ja=g("input",null,{type:"file"}),J.appendChild(ja),Z=a);else if("finalize"===T||"finalize-bin"===T)Z.name=ka.value,a=ia.value,Z.mapping="__default__"!=a?a:void 0,la&&(Z.maxbins=la.checked),1<ra.value.length&&1<sa.value.length&&(Z.xUser=ra.value,Z.xPass=sa.value),D.addTier(Z),"finalize-bin"==T?q():u();else if("hub-connect"===T)a=Y.value.trim(),/^.+:\/\//.exec(a)||(a="http://"+a),t(a);else{if("multiple"===T){for(a=0;a<ba.length;++a)if(e=ba[a],!e.hidden&&
("bam"!=e.tier_type||e.indexBlob||e.indexUri)&&("tabix"!=e.tier_type||e.indexBlob||e.indexUri)&&(e=ua(e)))e.noPersist=!0,D.addTier(e);q()}}else D.removeAllPopups()}function t(a,e,b){e=e||{};d(a,function(c,f){if(f){if(!b)return t(a,{credentials:!0},!0);z(J);J.appendChild(g("h2","Error connecting to track hub"));J.appendChild(g("p",f));T="reset-hub"}else{var d=null,l=null,h;for(h in c.genomes){var m=null,p=!1;if(h==D.coordSystem.ucscName)p=!0;else for(var r in D.chains)h==D.chains[r].coords.ucscName&&
(m=r,p=!0);p&&(p={url:a,genome:h},e.credentials&&(p.credentials=!0),m&&(p.mapping=m,c.genomes[h].mapping=m),D.hubs.push(p),D.hubObjects.push(c.genomes[h]),p=W(c.genomes[h]),oa.appendChild(p),m&&d||(d=c.genomes[h],l=p))}d?(D.notifyTier(),n(M,l),d.getTracks(function(a,e){k(a)})):(z(J),J.appendChild(g("h2","No data for this genome")),J.appendChild(g("p","This URL appears to be a valid track-hub, but it doesn't contain any data for the coordinate system of this browser")),J.appendChild(g("p","coordSystem.ucscName = "+
D.coordSystem.ucscName)),T="reset-hub")}},e)}function l(a,e){var b=a.uri;if(e){var c=/(.+)\/[^\/]+\/?/.exec(b);c&&(b=c[1]+"/sources")}(new R(b,{credentials:a.credentials})).sources(function(b){if(!b||0==b.length)return e?pa(a):l(a,!0);var c=null;if(1==b.length)c=b[0];else for(var f=0;f<b.length;++f)if(b[f].uri===a.uri){c=b[f];break}f=b=!1;if(c&&(a.name=c.name,a.desc=c.desc,a.maxbins=c.maxbins?!0:!1,c.capabilities&&(a.capabilities=c.capabilities),f=!0,c.coords&&1==c.coords.length))if(c=c.coords[0],
coordsMatch(c,D.coordSystem))b=!0;else if(D.chains)for(var d in D.chains)coordsMatch(c,D.chains[d].coords)&&(a.mapping=d,b=!0);return pa(a,b,f)},function(){return e?pa(a):l(a,!0)})}function f(a){(a.baiBlob?new c(a.baiBlob):new m(a.bamURI+".bai")).slice(0,256).fetch(function(e){var b=!1;e&&(e=new Uint8Array(e),b=w(e,0)==y);return b?pa(a,!1,!1,!0):G("You have selected a valid BAM file, but a corresponding index (.bai) file was not found.  Please index your BAM (samtools index) and place the BAI file in the same directory")})}
function v(a){(a.indexBlob?new c(a.indexBlob):new m(a.uri+".tbi")).slice(0,65536).fetch(function(e){var b=!1;if(e){var c=new Uint8Array(e);if(31==c[0]||139==c[1])e=r(e),c=new Uint8Array(e),b=w(c,0)==C}return b?pa(a,!1,!1,!0):G('You have selected a valid VCF file, but a corresponding index (.tbi) file was not found.  Please index your VCF ("tabix -p vcf -f myfile.vcf.gz") and place the .tbi file in the same directory')})}function G(a){ca.style.display="none";fa.style.display="inline";aa.style.display=
"inline";z(J);a=a||"Custom data format not recognized";J.appendChild(g("h2","Error adding custom data"));J.appendChild(g("p",a));J.appendChild(g("p","Currently supported formats are bigBed, bigWig, and BAM."));T="reset-bin"}if("add"===this.uiMode)this.hideToolPanel(),this.setUiMode("none");else{var D=this;h=g("div",null,{className:"dalliance"},{width:"100%",display:"inline-block",boxSizing:"border-box",MozBoxSizing:"border-box",verticalAlign:"top",paddingRight:"15px"});var M=[],P,H;if(!this.noRegistryTabs){var N=
this.makeButton("Registry","Browse compatible datasources from the DAS registry");M.push(N);for(var S in this.mappableSources)(function(a){var e=D.makeButton(D.chains[a].srcTag,"Browse datasources mapped from "+D.chains[a].srcTag);M.push(e);e.addEventListener("click",function(b){b.preventDefault();b.stopPropagation();n(M,e);P(D.mappableSources[a],a)},!1)})(S)}S={};for(var ha=0;ha<this.defaultSources.length;++ha){var da=this.defaultSources[ha],I=da.group||"Defaults";S[I]?S[I].push(da):S[I]=[da]}var W=
function(a){var e=a.hub,b=g("i",null,{className:"fa fa-list-alt"}),c=e.shortLabel||"Unknown";a.mapping&&(c=c+" ("+a.genome+")");var c=g("span",[c," ",b]),f=D.makeButton(c,e.longLabel);M.push(f);f.addEventListener("click",function(e){e.preventDefault();e.stopPropagation();n(M,f);z(J);e=D.makeLoader(24);e.style.marginLeft="auto";e.style.marginRight="auto";e.style.marginTop="100px";J.appendChild(g("div",e,null,{textAlign:"center"}));ca.style.display="none";fa.style.display="none";aa.style.display="none";
a.getTracks(function(a,e){e&&console.log(e);k(a)})},!1);b.addEventListener("click",function(e){e.preventDefault();e.stopPropagation();var b=g("li",g("a","Remove hub")),c=g("li",g("a","Enable all")),d=g("li",g("a","Disable all")),l=g("ul",[b,c,d],{className:"dropdown-menu"},{display:"block"}),h=e.clientX;e=e.clientY;h+=document.documentElement.scrollLeft||document.body.scrollLeft;e+=document.documentElement.scrollTop||document.body.scrollTop;l.style.position="absolute";l.style.top=""+(e+10)+"px";l.style.left=
""+(h-30)+"px";D.hPopupHolder.appendChild(l);var m=function(a){console.log("cc");document.body.removeEventListener("click",m,!0);D.hPopupHolder.removeChild(l)};document.body.addEventListener("click",m,!0);b.addEventListener("click",function(e){for(e=0;e<D.hubObjects.length;++e)if(D.hubObjects[e].absURL==a.absURL){D.hubObjects.splice(e,1);break}for(e=0;e<D.hubs.length;++e){var b=D.hubs[e];"string"===typeof b&&(b={url:b});if(b.url==a.hub.url&&!b.genome||b.genome==a.genome){D.hubs.splice(e,1);break}}D.notifyTier();
oa.removeChild(f);n(M,ea);s()},!1);c.addEventListener("click",function(e){a.getTracks(function(a,e){e&&console.log(e);for(var b=0;b<a.length;++b){var c=a[b].toDallianceSource();D.currentlyActive(c)||D.addTier(c)}})},!1);d.addEventListener("click",function(e){a.getTracks(function(a,e){e&&console.log(e);for(var b=0;b<a.length;++b){var c=a[b].toDallianceSource();D.currentlyActive(c)&&D.removeTier(c)}})},!1)},!1);return f},V=null,X=null;for(I in S)(function(a,e){var b=D.makeButton(a,"Browse the default set of data for this browser");
b.addEventListener("click",function(a){a.preventDefault();a.stopPropagation();n(M,b);P(new p(e))},!1);M.push(b);V||(V=b,X=e)})(I,S[I]);var U=this.makeButton("DAS","Add arbitrary DAS data");M.push(U);var na=this.makeButton("Binary","Add data in bigwig or bigbed format");M.push(na);for(I=0;I<this.hubObjects.length;++I)W(this.hubObjects[I]);var ea=this.makeButton("+","Connect to a new track-hub");M.push(ea);var oa=g("ul",M,{className:"nav nav-tabs"},{marginBottom:"0px"});h.appendChild(oa);var Y,ka,ia,
la,ja,ra,sa,T=!1,Z=null,I=g("form",null,{},{display:"inline-block",width:"100%"});I.addEventListener("submit",function(a){a.stopPropagation();a.preventDefault();e();return!1},!0);var J=g("div");J.style.position="relative";J.style.overflow="scroll";I.appendChild(J);var ma,qa;P=function(a,e){ca.style.display="none";fa.style.display="none";aa.style.display="none";qa&&qa.removeListener(H);ma=e;qa=a;qa.addListenerAndFire(H)};H=function(a){T=!1;var e=[];z(J);if(a){for(var b=g("tbody",null,{className:"table table-striped table-condensed"},
{width:"100%"}),c=g("table",b,{className:"table table-striped table-condensed"},{width:"100%",tableLayout:"fixed"}),f=0,d=[],l=0;l<a.length;++l)d.push(a[l]);d.sort(function(a,e){return a.name.toLowerCase().trim().localeCompare(e.name.toLowerCase().trim())});for(l=0;l<d.length;++l){a=d[l];var h=g("tr"),m=g("td",null,{},{width:"30px"});m.style.textAlign="center";if(!a.props||a.props.cors){var k=g("input");k.type="checkbox";k.dalliance_source=a;ma&&(k.dalliance_mapping=ma);m.appendChild(k);e.push(k);
k.addEventListener("change",function(a){a.target.checked?D.addTier(a.target.dalliance_source):D.removeTier(a.target.dalliance_source)})}else m.appendChild(document.createTextNode("!")),D.makeTooltip(m,g("span",["This data source isn't accessible because it doesn't support ",g("a","CORS",{href:"http://www.w3.org/TR/cors/"}),"."]));h.appendChild(m);m=g("td");m.appendChild(document.createTextNode(a.name));a.desc&&0<a.desc.length&&D.makeTooltip(m,a.desc);h.appendChild(m);b.appendChild(h);++f}var n=function(){for(var a=
0;a<e.length;++a){var b=e[a];D.currentlyActive(b.dalliance_source)?b.checked=!0:b.checked=!1}};n();D.addTierListener(function(a){n()});J.appendChild(c)}else J.appendChild(g("p","Dalliance was unable to retrieve data source information from the DAS registry, please try again later"))};N&&N.addEventListener("click",function(a){a.preventDefault();a.stopPropagation();n(M,N);P(D.availableSources)},!1);na.addEventListener("click",function(a){a.preventDefault();a.stopPropagation();q()},!1);ea.addEventListener("click",
function(a){a.preventDefault();a.stopPropagation();s()},!1);U.addEventListener("click",function(a){a.preventDefault();a.stopPropagation();u()},!1);var fa=g("button","Add",{className:"btn btn-primary"});fa.addEventListener("click",function(a){a.stopPropagation();a.preventDefault();e()},!1);var ta=function(a,e){var b=D.knownSpace;if(b){var c=Math.max(b.min,(b.min+b.max-100)/2)|0,b=new A(b.chr,c,Math.min(c+99,b.max));a.features(b,{},function(b,c){if(c)e?(z(J),J.appendChild(g("h2","Custom data not found")),
J.appendChild(g("p","DAS uri: "+a.uri+" is not answering features requests")),T="reset"):(a.credentials=!0,ta(a,!0));else{var f=/\/([^/]+)\/?$/.exec(a.uri);f&&(a.name=f[1]);l(a)}})}else alert("Can't confirm track-addition to an uninit browser.")},ua=function(a){var e={name:a.name};a.mapping&&"__default__"!=a.mapping&&(e.mapping=a.mapping);if("bwg"==a.tier_type)return a.blob?e.bwgBlob=a.blob:a.uri&&(e.bwgURI=a.uri),e;if("bam"==a.tier_type)return a.blob?(e.bamBlob=a.blob,e.baiBlob=a.indexBlob):(e.bamURI=
a.uri,e.baiURI=a.indexUri),e;if("tabix"==a.tier_type)return e.tier_type="tabix",e.payload=a.payload,a.blob?(e.blob=a.blob,e.indexBlob=a.indexBlob):(e.uri=a.uri,e.indexUri=a.indexUri),e;if("memstore"==a.tier_type)return e.tier_type="memstore",e.payload=a.payload,a.blob?e.blob=a.blob:e.uri=a.uri,e},O=function(a){b(a,function(a,e){if(e)z(J),J.appendChild(g("h2","Couldn't access custom data")),J.appendChild(g("p",""+e)),T="reset-bin";else{var b=ua(a);return"bam"==a.tier_type?f(b):"tabix"==a.tier_type?
v(b):pa(b,!1,!1,!0)}})},pa=function(a,e,b,c){ca.style.display="none";fa.style.display="inline";aa.style.display="inline";z(J);J.appendChild(g("h2","Add custom data: step 2"));J.appendChild(document.createTextNode("Label: "));ka=g("input","",{value:a.name});J.appendChild(ka);ra=g("input","");sa=g("input","");J.appendChild(g("br"));J.appendChild(g("br"));J.appendChild(g("h4","Coordinate system: "));ia=g("select",null);ia.appendChild(g("option",D.nameForCoordSystem(D.coordSystem),{value:"__default__"}));
if(D.chains)for(var f in D.chains)ia.appendChild(g("option",D.nameForCoordSystem(D.chains[f].coords),{value:f}));ia.value=a.mapping||"__default__";J.appendChild(ia);e?J.appendChild(g("p","(Based on server response, probably doesn't need changing.)")):(J.appendChild(g("p",[g("b","Warning: "),"unable to determine the correct value from server responses.  Please check carefully."])),J.appendChild(g("p","If you don't see the mapping you're looking for, please contact thomas@biodalliance.org")));c||(J.appendChild(document.createTextNode("Quantitative: ")),
la=g("input",null,{type:"checkbox",checked:!0}),"undefined"!==typeof a.maxbins&&(la.checked=a.maxbins),J.appendChild(la),b?J.appendChild(g("p","(Based on server response, probably doesn't need changing.)")):J.appendChild(g("p",[g("b","Warning: "),"unable to determine correct value.  If in doubt, leave checked."])));a.bwgBlob&&J.appendChild(g("p",[g("b","Warning: "),"data added from local file.  Due to the browser security model, the track will disappear if you reload Dalliance."]));ka.focus();T="bin"===
T||"prompt-bai"===T||"prompt-tbi"===T?"finalize-bin":"finalize";Z=a},ba=null,$=function(a){b(a,function(a,e){e&&(a.error=e);for(var b=[],c={},f={},d=0;d<ba.length;++d){var l=ba[d];"bam"!=l.tier_type||l.indexBlob||(c[l.blob.name]=l);"tabix"!=l.tier_type||l.indexBlob||(f[l.blob.name]=l)}for(d=0;d<ba.length;++d)if(l=ba[d],"bai"===l.tier_type){var g=/(.+)\.bai$/.exec(l.blob.name);g&&c[g[1]]&&(c[g[1]].indexBlob=l.blob,b.push(d))}else"tabix-index"===l.tier_type&&(g=/(.+)\.tbi$/.exec(l.blob.name))&&f[g[1]]&&
(f[g[1]].indexBlob=l.blob,b.push(d));for(c=b.length-1;0<=c;--c)ba.splice(b[c],1);ga()})},ga=function(){z(J);var a=!1,e=g("table",ba.filter(function(a){return!a.hidden}).map(function(e){g("tr").appendChild(g("td",e.name||e.blob.name));var b;b=e.error?g("span","Error",null,{color:"red"}):e.tier_type?e.payload||e.tier_type:D.makeLoader(16);var c,f="unknown";"bwg"==e.tier_type||"memstore"==e.tier_type?f="okay":"bam"==e.tier_type?f=e.indexBlob?"okay":"needs-index":"tabix"==e.tier_type&&(f=e.indexBlob?
"okay":"needs-index");if("okay"==f){c=g("select",null,null,{width:"150px"});c.appendChild(g("option",D.nameForCoordSystem(D.coordSystem),{value:"__default__"}));if(D.chains)for(var d in D.chains)c.appendChild(g("option",D.nameForCoordSystem(D.chains[d].coords),{value:d}));c.value=e.mapping||"__default__";c.addEventListener("change",function(a){e.mapping=c.value;console.log(e)},!1)}else"needs-index"==f&&(c=g("span","Needs index",{},{color:"red"}),a=!0);return g("tr",[g("td",e.name||e.blob.name),g("td",
b),g("td",c)])}),{className:"table table-striped table-condensed"});J.appendChild(e);if(a){J.appendChild(g("p","Some of these files are missing required index (.bai or .tbi) files.  For security reasons, web applications like Dalliance can only access local files which you have explicity selected.  Please use the file chooser below to select the appropriate index file"));J.appendChild(document.createTextNode("Index file(s): "));var b=g("input",null,{type:"file",multiple:"multiple"});J.appendChild(b);
b.addEventListener("change",function(a){console.log("fileset changed");a=b.files||[];for(var e=0;e<a.length;++e){var c=a[e];c&&(c={blob:c,hidden:!0},ba.push(c),$(c))}},!1)}},aa=g("button","Cancel",{className:"btn"});aa.addEventListener("click",function(a){a.stopPropagation();a.preventDefault();"finalize-bin"===T?q():u()},!1);var ca=g("button","Refresh",{className:"btn"});ca.addEventListener("click",function(a){a.stopPropagation();a.preventDefault();D.queryRegistry(ma)},!1);this.makeTooltip(ca,"Click to re-fetch data from the DAS registry");
S=g("div",[fa," ",aa," ",ca]);S.style.margin="10px";I.appendChild(S);h.appendChild(I);P(D.availableSources);this.showToolPanel(h);this.setUiMode("add");V&&(n(M,V),P(new p(X)))}}},{"./bam":1,"./bin":4,"./cbrowser":6,"./das":10,"./domui":11,"./lh3utils":22,"./probe":26,"./tabix":37,"./thub":38,"./utils":45}],43:[function(k,u,s){function n(k,g,n){g.fetchAsText(function(g){if(!g)return n(null,"Couldn't fetch index-index");g=g.split(/(.+)([0-9A-F]{10})\n/);for(var s=[],d=[],a=1;a<g.length;a+=3)s.push(g[a]),
d.push(parseInt(g[a+1],16));return n(new h(s,d,k))})}function h(h,g,k){this.keys=h;this.offsets=g;this.ix=k}h.prototype.lookup=function(h,g){for(var k,n=(h+"     ").substring(0,5).toLowerCase(),s=0;s<this.keys.length;++s)if(0>n.localeCompare(this.keys[s])){k=this.ix.slice(this.offsets[s-1],this.offsets[s]-this.offsets[s-1]);break}k||(k=this.ix.slice(this.offsets[this.offsets.length-1]));k.fetchAsText(function(d){d=d.split("\n");for(var a=0;a<d.length;++a)if(0==d[a].indexOf(h.toLowerCase()+" "))return g(d[a].split(" "));
return g(null)})};"undefined"!==typeof u&&(u.exports={connectTrix:n})},{}],44:[function(k,u,s){function n(){}function h(c,d){var h=new n;h.data=c;h.data.slice(0,12500).fetch(function(c){if(!c)return d(null,"Couldn't access data");var m=new Uint8Array(c);c=g(m,0);if(c==a)h.readInt=g;else if(c==b)h.readInt=z;else return d(null,"Not a .2bit file, magic=0x"+c.toString(16));c=h.readInt(m,4);if(0!=c)return d(null,"Unsupported version "+c);h.seqCount=h.readInt(m,8);h.seqDict={};var k=16,n=0,p=0,s=function(){for(;n<
h.seqCount;){var a=m[k];if(k+a+6>=m.length)return h.data.slice(p+k,12500).fetch(function(a){p+=k;k=0;m=new Uint8Array(a);s()});++k;for(var b="",c=1;c<=a;++c)b+=String.fromCharCode(m[k++]);a=h.readInt(m,k);k+=4;h.seqDict[b]=new q(h,a);++n}return d(h)};s()})}function q(a,b){this.tbf=a;this.offset=b}if("undefined"!==typeof k){s=k("./bin");var g=s.readInt,z=s.readIntBE;k=k("./spans");var p=k.Range,x=k.union,d=k.intersection}var a=440477507,b=1126646042;n.prototype.getSeq=function(a){var b=this.seqDict[a];
b||(b=this.seqDict["chr"+a]);return b};n.prototype.fetch=function(a,b,d,g){var h=this.getSeq(a);if(h){if(d<=b)return g("");h.fetch(b,d,g)}else return g(null,"Couldn't find "+a)};q.prototype.init=function(a){if(this.seqOffset)return a();var b=this;b.tbf.data.slice(b.offset,8).fetch(function(d){if(!d)return a("Fetch failed");d=new Uint8Array(d);b._length=b.tbf.readInt(d,0);b.nBlockCnt=b.tbf.readInt(d,4);b.tbf.data.slice(b.offset+8,8*b.nBlockCnt+4).fetch(function(d){if(!d)return a("Fetch failed");d=
new Uint8Array(d);for(var g=null,h=0;h<b.nBlockCnt;++h)var m=b.tbf.readInt(d,4*h),k=b.tbf.readInt(d,4*(h+b.nBlockCnt)),m=new p(m,m+k-1),g=g?x(g,m):m;b.nBlocks=g;b.mBlockCnt=b.tbf.readInt(d,8*b.nBlockCnt);b.seqLength=(b._length+3)/4|0;b.seqOffset=b.offset+16+8*(b.nBlockCnt+b.mBlockCnt);return a()})})};var m=["T","C","A","G"];q.prototype.fetch=function(a,b,g){--a;--b;var h=this;this.init(function(k){if(k)return g(null,k);var n=a>>2;k=b+3>>2;if(0>n||k>h.seqLength)return g("Coordinates out of bounds: "+
a+":"+b);h.tbf.data.slice(h.seqOffset+n,k-n).fetch(function(k){function q(a){for(;z<=a;){var b=z&3,c=s[(z>>2)-n];x+=m[0==b?c>>6&3:1==b?c>>4&3:2==b?c>>2&3:c&3];++z}}if(null==k)return g("SeqFetch failed");var s=new Uint8Array(k);k=[];if(h.nBlocks){var u=d(new p(a,b),h.nBlocks);u&&(k=u.ranges())}for(var x="",z=a,u=0;u<k.length;++u){var E=k[u];if(z>E.min())throw"N mismatch...";for(z<E.min()&&q(E.min()-1);z<=E.max();)x+="N",++z}z<=b&&q(b);return g(x)})})};q.prototype.length=function(a){var b=this;this.init(function(d){return d?
a(null,d):a(b._length)})};"undefined"!==typeof u&&(u.exports={makeTwoBit:h})},{"./bin":4,"./spans":33}],45:[function(k,u,s){function n(a,b){for(var c=0;c<a.length;++c)if(a[c]==b)return;a.push(b)}function h(a,b,c){a[b]?a[b].push(c):a[b]=[c]}function q(a,b,c){var d=a[b];if(d){for(a=0;a<d.length;++a)if(d[a]==c)return;d.push(c)}else a[b]=[c]}function g(a,b,c,d){if(a)return a;if(b)return b;if(c)return c;if(d)return d}function n(a,b){for(var c=0;c<a.length;++c)if(a[c]==b)return;a.push(b)}function z(a,b){if(!a)return-1;
for(var c=0;c<a.length;++c)if(a[c]===b)return c;return-1}function p(a,b,c,d){a=document.createElement(a);if(b){b instanceof Array||(b=[b]);for(var g=0;g<b.length;++g){var h=b[g];"string"==typeof h&&(h=document.createTextNode(h));a.appendChild(h)}}if(c)for(var m in c)try{a[m]=c[m]}catch(e){throw console.log("error setting "+m),e;}if(d)for(m in d)a.style[m]=d[m];return a}function x(a,b,c,d){a=document.createElementNS(a,b);if(c)for(c instanceof Array||(c=[c]),b=0;b<c.length;++b){var g=c[b];"string"==
typeof g&&(g=document.createTextNode(g));a.appendChild(g)}if(d)for(var h in d){c=a;b=h;var g=d[h],m=C[b];if(!m){for(var m="",e=0;e<b.length;++e)var k=b.substring(e,e+1),l=k.toLowerCase(),m=l!=k?m+"-"+l:m+k;C[b]=m}c.setAttribute(m,g)}return a}function d(a){if(a&&a.childNodes)for(;0<a.childNodes.length;)a.removeChild(a.firstChild)}function a(b,c){if("undefined"===typeof b)return"undefined";if(null==b)return"null";if("string"==typeof b)return"'"+b+"'";if("number"==typeof b||"boolean"==typeof b)return""+
b;if("object"==typeof b){if(b instanceof Array){for(var d=null,g=0;g<b.length;++g)d=(null==d?"":d+", ")+a(b[g],c);return"["+(d?d:"")+"]"}c=c||{};d=null;for(g in b)c[g]||void 0!=g&&"function"!=typeof b[g]&&(d=(null==d?"":d+", ")+g+": "+a(b[g],c));return"{"+(d?d:"")+"}"}return typeof b}function b(a){var b={},c;for(c in a)b[c]=a[c];return b}function m(a){this.value=a;this.listeners=[]}function c(){this.queue=[]}function w(a,b,c){c.salt&&(a=a+"?salt="+y(""+Date.now()+","+ ++F));var d=new XMLHttpRequest;
d.onreadystatechange=function(){4==d.readyState&&(300<=d.status?b(null,"Error code "+d.status):b(d.responseText))};d.open("GET",a,!0);d.responseType="text";c&&c.credentials&&(d.withCredentials=!0);d.send("")}function r(a,b){if(0==b.indexOf("http:")||0==b.indexOf("https:"))return b;var c=a.lastIndexOf("/");return 0<=c?a.substr(0,c+1)+b:b}if("undefined"!==typeof k)var y=k("./sha1").b64_sha1;var C={};m.prototype.addListener=function(a){this.listeners.push(a)};m.prototype.addListenerAndFire=function(a){this.listeners.push(a);
a(this.value)};m.prototype.removeListener=function(a){var b=this.listeners;a=z(b,a);0<=a&&b.splice(a,1)};m.prototype.get=function(){return this.value};m.prototype.set=function(a){this.value=a;for(var b=0;b<this.listeners.length;++b)this.listeners[b](a)};c.prototype.provide=function(a){if(void 0!==this.res)throw"Resource has already been provided.";this.res=a;for(var b=0;b<this.queue.length;++b)this.queue[b](a);this.queue=null};c.prototype.await=function(a){if(void 0!==this.res)return a(this.res),
this.res;this.queue.push(a)};var F=0;"trim"in String.prototype||(String.prototype.trim=function(){return this.replace(/^\s+/,"").replace(/\s+$/,"")});"undefined"!==typeof u&&(u.exports={textXHR:w,relativeURL:r,shallowCopy:b,pusho:h,pushnew:n,pushnewo:q,arrayIndexOf:z,pick:g,makeElement:p,makeElementNS:x,removeChildren:d,miniJSONify:a,Observed:m,Awaited:c})},{"./sha1":31}],46:[function(k,u,s){function n(){this.info=[]}function h(a,d){this.parser=a;this.sink=d}if("undefined"!==typeof k){var q=k("./sourceadapters").registerParserFactory;
k=k("./das");var g=k.DASStylesheet,z=k.DASStyle,p=k.DASFeature}var x=/([^;=]+)(=([^;]+))?;?/,d=/##INFO=<([^>]+)>/,a=/([^,=]+)=([^,]+|"[^"]+"),?/;n.prototype.createSession=function(a){return new h(this,a)};h.prototype.parse=function(b){if(0!=b.length)if("#"==b[0]){if(1<b.length&&"#"==b[1]&&(b=d.exec(b))){var g=b[1].split(a),c=null,h=null;for(b=0;b<g.length-1;b+=3){var k=g[b+1],n=g[b+2].replace(/"/g,"");"ID"==k?c=n:"Description"==k&&(h=n)}c&&h&&this.parser.info.push({id:c,desc:h})}}else{g=b.split("\t");
c=new p;c.segment=g[0];c.id=g[2];c.refAllele=g[3];c.altAlleles=g[4].split(",");c.min=parseInt(g[1]);c.max=c.min+c.refAllele.length-1;g=g[7].split(x);c.info={};for(b=0;b<g.length;b+=4)c.info[g[b+1]]=g[b+3];b=c.altAlleles[0];g=c.refAllele;b.length>g.length?(c.type="insertion",0==b.indexOf(g)?(c.insertion=b.substr(g.length),c.min+=g.length,c.max=c.min-1):c.insertion=b):c.type=b.length<g.length?"deletion":"substitution";this.sink(c)}};h.prototype.flush=function(){};n.prototype.getStyleSheet=function(a){var d=
new g,c=new z;c.glyph="__INSERTION";c.BUMP="yes";c.LABEL="no";c.FGCOLOR="rgb(50,80,255)";c.BGCOLOR="#888888";c.STROKECOLOR="black";d.pushStyle({type:"insertion"},null,c);c=new z;c.glyph="PLIMSOLL";c.BUMP="yes";c.LABEL="no";c.FGCOLOR="rgb(255, 60, 60)";c.BGCOLOR="#888888";c.STROKECOLOR="black";d.pushStyle({type:"deletion"},null,c);c=new z;c.glyph="PLIMSOLL";c.BUMP="yes";c.LABEL="no";c.FGCOLOR="rgb(50,80,255)";c.BGCOLOR="#888888";c.STROKECOLOR="black";d.pushStyle({type:"default"},null,c);return a(d)};
n.prototype.getDefaultFIPs=function(a){var d=this;a(function(a,b){b.add("Ref. allele",a.refAllele);b.add("Alt. alleles",a.altAlleles.join(","));if(a.info)for(var g=0;g<d.info.length;++g){var h=d.info[g],k=a.info[h.id];void 0!==k&&b.add(h.desc,k)}})};q("vcf",function(){return new n})},{"./das":10,"./sourceadapters":32}],47:[function(k,u,s){k={CONFIG:5,MAJOR:0,MINOR:12,MICRO:4,PATCH:"",BRANCH:"",toString:function(){var k=""+this.MAJOR+"."+this.MINOR+"."+this.MICRO;this.PATCH&&(k+=this.PATCH);this.BRANCH&&
""!=this.BRANCH&&(k=k+"-"+this.BRANCH);return k}};"undefined"!==typeof u&&(u.exports=k)},{}],48:[function(k,u,s){u=k("./promise/promise").Promise;k=k("./promise/polyfill").polyfill;s.Promise=u;s.polyfill=k},{"./promise/polyfill":53,"./promise/promise":54}],49:[function(k,u,s){var n=k("./utils").isArray,h=k("./utils").isFunction;s.all=function(k){if(!n(k))throw new TypeError("You must pass an array to all.");return new this(function(g,n){function p(a){return function(b){s[a]=b;0===--d&&g(s)}}var s=
[],d=k.length,a;0===d&&g([]);for(var b=0;b<k.length;b++)(a=k[b])&&h(a.then)?a.then(p(b),n):(s[b]=a,0===--d&&g(s))})}},{"./utils":58}],50:[function(k,u,s){(function(k,h){function q(){return function(){k.nextTick(p)}}function g(){var a=0,b=new d(p),g=document.createTextNode("");b.observe(g,{characterData:!0});return function(){g.data=a=++a%2}}function u(){return function(){a.setTimeout(p,1)}}function p(){for(var a=0;a<b.length;a++){var d=b[a];(0,d[0])(d[1])}b=[]}var x="undefined"!==typeof window?window:
{},d=x.MutationObserver||x.WebKitMutationObserver,a="undefined"!==typeof h?h:void 0===this?window:this,b=[],m;m="undefined"!==typeof k&&"[object process]"==={}.toString.call(k)?q():d?g():u();s.asap=function(a,d){1===b.push([a,d])&&m()}}).call(this,k("/Users/thomas/Projects/dalliance/node_modules/gulp-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!==typeof self?self:"undefined"!==typeof window?window:{})},{"/Users/thomas/Projects/dalliance/node_modules/gulp-browserify/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":59}],
51:[function(k,u,s){s.cast=function(k){return k&&"object"===typeof k&&k.constructor===this?k:new this(function(h){h(k)})}},{}],52:[function(k,u,s){var n={instrument:!1};s.config=n;s.configure=function(h,k){if(2===arguments.length)n[h]=k;else return n[h]}},{}],53:[function(k,u,s){(function(n){var h=k("./promise").Promise,q=k("./utils").isFunction;s.polyfill=function(){var g;g="undefined"!==typeof n?n:"undefined"!==typeof window&&window.document?window:self;"Promise"in g&&"cast"in g.Promise&&"resolve"in
g.Promise&&"reject"in g.Promise&&"all"in g.Promise&&"race"in g.Promise&&function(){var h;new g.Promise(function(g){h=g});return q(h)}()||(g.Promise=h)}}).call(this,"undefined"!==typeof self?self:"undefined"!==typeof window?window:{})},{"./promise":54,"./utils":58}],54:[function(k,u,s){function n(a){if(!r(a))throw new TypeError("You must pass a resolver function as the first argument to the promise constructor");if(!(this instanceof n))throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
this._subscribers=[];h(a,this)}function h(b,c){function e(a){x(c,a)}function d(e){a(c,e)}try{b(e,d)}catch(l){d(l)}}function q(b,c,e,d){var l=r(e),f,g,h,k;if(l)try{f=e(d),h=!0}catch(m){k=!0,g=m}else f=d,h=!0;p(c,f)||(l&&h?x(c,f):k?a(c,g):b===Q?x(c,f):b===K&&a(c,f))}function g(a,b,e,c){a=a._subscribers;var d=a.length;a[d]=b;a[d+Q]=e;a[d+K]=c}function z(a,b){for(var e,c,d=a._subscribers,f=a._detail,g=0;g<d.length;g+=3)e=d[g],c=d[g+b],q(b,e,c,f);a._subscribers=null}function p(b,c){var e=null,g;try{if(b===
c)throw new TypeError("A promises callback cannot return that same promise.");if(w(c)&&(e=c.then,r(e)))return e.call(c,function(a){if(g)return!0;g=!0;c!==a?x(b,a):d(b,a)},function(e){if(g)return!0;g=!0;a(b,e)}),!0}catch(l){if(g)return!0;a(b,l);return!0}return!1}function x(a,b){a===b?d(a,b):p(a,b)||d(a,b)}function d(a,d){a._state===R&&(a._state=B,a._detail=d,c.async(b,a))}function a(a,b){a._state===R&&(a._state=B,a._detail=b,c.async(m,a))}function b(a){z(a,a._state=Q)}function m(a){z(a,a._state=K)}
var c=k("./config").config;k("./config");var w=k("./utils").objectOrFunction,r=k("./utils").isFunction;k("./utils");u=k("./cast").cast;var y=k("./all").all,C=k("./race").race,F=k("./resolve").resolve,A=k("./reject").reject;k=k("./asap").asap;c.async=k;var R=void 0,B=0,Q=1,K=2;n.prototype={constructor:n,_state:void 0,_detail:void 0,_subscribers:void 0,then:function(a,b){var e=this,d=new this.constructor(function(){});if(this._state){var l=arguments;c.async(function(){q(e._state,d,l[e._state-1],e._detail)})}else g(this,
d,a,b);return d},"catch":function(a){return this.then(null,a)}};n.all=y;n.cast=u;n.race=C;n.resolve=F;n.reject=A;s.Promise=n},{"./all":49,"./asap":50,"./cast":51,"./config":52,"./race":55,"./reject":56,"./resolve":57,"./utils":58}],55:[function(k,u,s){var n=k("./utils").isArray;s.race=function(h){if(!n(h))throw new TypeError("You must pass an array to race.");return new this(function(k,g){for(var n,p=0;p<h.length;p++)(n=h[p])&&"function"===typeof n.then?n.then(k,g):k(n)})}},{"./utils":58}],56:[function(k,
u,s){s.reject=function(k){return new this(function(h,q){q(k)})}},{}],57:[function(k,u,s){s.resolve=function(k){return new this(function(h,q){h(k)})}},{}],58:[function(k,u,s){function n(h){return"function"===typeof h}k=Date.now||function(){return(new Date).getTime()};s.objectOrFunction=function(h){return n(h)||"object"===typeof h&&null!==h};s.isFunction=n;s.isArray=function(h){return"[object Array]"===Object.prototype.toString.call(h)};s.now=k},{}],59:[function(k,u,s){function n(){}k=u.exports={};
k.nextTick=function(){if("undefined"!==typeof window&&window.setImmediate)return function(h){return window.setImmediate(h)};if("undefined"!==typeof window&&window.postMessage&&window.addEventListener){var h=[];window.addEventListener("message",function(k){var g=k.source;g!==window&&null!==g||"process-tick"!==k.data||(k.stopPropagation(),0<h.length&&h.shift()())},!0);return function(k){h.push(k);window.postMessage("process-tick","*")}}return function(h){setTimeout(h,0)}}();k.title="browser";k.browser=
!0;k.env={};k.argv=[];k.on=n;k.once=n;k.off=n;k.emit=n;k.binding=function(h){throw Error("process.binding is not supported");};k.cwd=function(){return"/"};k.chdir=function(h){throw Error("process.chdir is not supported");}},{}],60:[function(k,u,s){function n(){}function h(){this.was=[0]}function q(e,b,c){this.hufts=new Int32Array(3*a);this.window=new Uint8Array(c);this.end=c;this.checkfn=b;this.mode=y;this.reset(e,null);this.index=this.table=this.left=0;this.blens=null;this.bb=new Int32Array(1);this.tb=
new Int32Array(1);this.codes=new g;this.check=this.write=this.read=this.bitb=this.bitk=this.last=0;this.inftree=new z}function g(){}function z(){}function p(a,b,c,d,g){if(0!=g){if(!a)throw"Undef src";if(!c)throw"Undef dest";if(0==b&&g==a.length)c.set(a,d);else if(E)a=a.subarray(b,b+g),c.set(a,d);else if(1==a.BYTES_PER_ELEMENT&&100<g)a=new Uint8Array(a.buffer,a.byteOffset+b,g),c.set(a,d);else for(var h=0;h<g;++h)c[d+h]=a[b+h]}}function x(a,g,l,f){a=g?new Uint8Array(a,g,l):new Uint8Array(a);l=new n;
l.inflateInit(d,!0);l.next_in=a;l.next_in_index=0;l.avail_in=a.length;a=[];for(var h=0;;){var k=new Uint8Array(32E3);l.next_out=k;l.next_out_index=0;l.avail_out=k.length;var r=l.inflate(b);if(r!=m&&r!=c&&r!=w)throw l.msg;if(0!=l.avail_out){var q=new Uint8Array(k.length-l.avail_out);p(k,0,q,0,k.length-l.avail_out);k=q}a.push(k);h+=k.length;if(r==c||r==w)break}f&&(f[0]=(g||0)+l.next_in_index);if(1==a.length)return a[0].buffer;g=new Uint8Array(h);for(l=f=0;l<a.length;++l)h=a[l],p(h,0,g,f,h.length),f+=
h.length;return g.buffer}var d=15,a=1440,b=0,m=0,c=1,w=-5,r=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],y=0,C=[96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,192,80,7,10,0,8,96,0,8,32,0,9,160,0,8,0,0,8,128,0,8,64,0,9,224,80,7,6,0,8,88,0,8,24,0,9,144,83,7,59,0,8,120,0,8,56,0,9,208,81,7,17,0,8,104,0,8,40,0,9,176,0,8,8,0,8,136,0,8,72,0,9,240,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,200,81,7,13,0,8,100,0,8,36,0,9,168,0,8,4,0,8,132,0,8,68,0,9,232,80,
7,8,0,8,92,0,8,28,0,9,152,84,7,83,0,8,124,0,8,60,0,9,216,82,7,23,0,8,108,0,8,44,0,9,184,0,8,12,0,8,140,0,8,76,0,9,248,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,196,81,7,11,0,8,98,0,8,34,0,9,164,0,8,2,0,8,130,0,8,66,0,9,228,80,7,7,0,8,90,0,8,26,0,9,148,84,7,67,0,8,122,0,8,58,0,9,212,82,7,19,0,8,106,0,8,42,0,9,180,0,8,10,0,8,138,0,8,74,0,9,244,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,204,81,7,15,0,8,102,0,8,38,0,9,172,0,8,6,0,8,134,0,8,70,0,9,236,80,7,9,0,8,94,0,8,30,0,
9,156,84,7,99,0,8,126,0,8,62,0,9,220,82,7,27,0,8,110,0,8,46,0,9,188,0,8,14,0,8,142,0,8,78,0,9,252,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,194,80,7,10,0,8,97,0,8,33,0,9,162,0,8,1,0,8,129,0,8,65,0,9,226,80,7,6,0,8,89,0,8,25,0,9,146,83,7,59,0,8,121,0,8,57,0,9,210,81,7,17,0,8,105,0,8,41,0,9,178,0,8,9,0,8,137,0,8,73,0,9,242,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,202,81,7,13,0,8,101,0,8,37,0,9,170,0,8,5,0,8,133,0,8,69,0,9,234,80,7,8,0,8,93,0,8,29,0,9,154,84,7,83,0,8,
125,0,8,61,0,9,218,82,7,23,0,8,109,0,8,45,0,9,186,0,8,13,0,8,141,0,8,77,0,9,250,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,198,81,7,11,0,8,99,0,8,35,0,9,166,0,8,3,0,8,131,0,8,67,0,9,230,80,7,7,0,8,91,0,8,27,0,9,150,84,7,67,0,8,123,0,8,59,0,9,214,82,7,19,0,8,107,0,8,43,0,9,182,0,8,11,0,8,139,0,8,75,0,9,246,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,206,81,7,15,0,8,103,0,8,39,0,9,174,0,8,7,0,8,135,0,8,71,0,9,238,80,7,9,0,8,95,0,8,31,0,9,158,84,7,99,0,8,127,0,8,63,0,9,222,
82,7,27,0,8,111,0,8,47,0,9,190,0,8,15,0,8,143,0,8,79,0,9,254,96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,193,80,7,10,0,8,96,0,8,32,0,9,161,0,8,0,0,8,128,0,8,64,0,9,225,80,7,6,0,8,88,0,8,24,0,9,145,83,7,59,0,8,120,0,8,56,0,9,209,81,7,17,0,8,104,0,8,40,0,9,177,0,8,8,0,8,136,0,8,72,0,9,241,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,201,81,7,13,0,8,100,0,8,36,0,9,169,0,8,4,0,8,132,0,8,68,0,9,233,80,7,8,0,8,92,0,8,28,0,9,153,84,7,83,0,8,124,0,8,60,0,9,217,82,7,23,0,8,108,0,
8,44,0,9,185,0,8,12,0,8,140,0,8,76,0,9,249,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,197,81,7,11,0,8,98,0,8,34,0,9,165,0,8,2,0,8,130,0,8,66,0,9,229,80,7,7,0,8,90,0,8,26,0,9,149,84,7,67,0,8,122,0,8,58,0,9,213,82,7,19,0,8,106,0,8,42,0,9,181,0,8,10,0,8,138,0,8,74,0,9,245,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,205,81,7,15,0,8,102,0,8,38,0,9,173,0,8,6,0,8,134,0,8,70,0,9,237,80,7,9,0,8,94,0,8,30,0,9,157,84,7,99,0,8,126,0,8,62,0,9,221,82,7,27,0,8,110,0,8,46,0,9,189,0,8,14,
0,8,142,0,8,78,0,9,253,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,195,80,7,10,0,8,97,0,8,33,0,9,163,0,8,1,0,8,129,0,8,65,0,9,227,80,7,6,0,8,89,0,8,25,0,9,147,83,7,59,0,8,121,0,8,57,0,9,211,81,7,17,0,8,105,0,8,41,0,9,179,0,8,9,0,8,137,0,8,73,0,9,243,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,203,81,7,13,0,8,101,0,8,37,0,9,171,0,8,5,0,8,133,0,8,69,0,9,235,80,7,8,0,8,93,0,8,29,0,9,155,84,7,83,0,8,125,0,8,61,0,9,219,82,7,23,0,8,109,0,8,45,0,9,187,0,8,13,0,8,141,0,8,77,0,
9,251,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,199,81,7,11,0,8,99,0,8,35,0,9,167,0,8,3,0,8,131,0,8,67,0,9,231,80,7,7,0,8,91,0,8,27,0,9,151,84,7,67,0,8,123,0,8,59,0,9,215,82,7,19,0,8,107,0,8,43,0,9,183,0,8,11,0,8,139,0,8,75,0,9,247,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,207,81,7,15,0,8,103,0,8,39,0,9,175,0,8,7,0,8,135,0,8,71,0,9,239,80,7,9,0,8,95,0,8,31,0,9,159,84,7,99,0,8,127,0,8,63,0,9,223,82,7,27,0,8,111,0,8,47,0,9,191,0,8,15,0,8,143,0,8,79,0,9,255],F=[80,5,1,87,
5,257,83,5,17,91,5,4097,81,5,5,89,5,1025,85,5,65,93,5,16385,80,5,3,88,5,513,84,5,33,92,5,8193,82,5,9,90,5,2049,86,5,129,192,5,24577,80,5,2,87,5,385,83,5,25,91,5,6145,81,5,7,89,5,1537,85,5,97,93,5,24577,80,5,4,88,5,769,84,5,49,92,5,12289,82,5,13,90,5,3073,86,5,193,192,5,24577],A=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],R=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,112,112],B=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,
1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],Q=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13];n.prototype.inflateInit=function(a,b){a||(a=d);b&&(b=!1);this.istate=new h;return this.istate.inflateInit(this,b?-a:a)};n.prototype.inflate=function(a){return null==this.istate?-2:this.istate.inflate(this,a)};n.prototype.inflateEnd=function(){if(null==this.istate)return-2;var a=istate.inflateEnd(this);this.istate=null;return a};n.prototype.inflateSync=function(){return istate.inflateSync(this)};
n.prototype.inflateSetDictionary=function(a,b){return istate.inflateSetDictionary(this,a,b)};h.prototype.inflateReset=function(a){if(null==a||null==a.istate)return-2;a.total_in=a.total_out=0;a.msg=null;a.istate.mode=0!=a.istate.nowrap?7:0;a.istate.blocks.reset(a,null);return m};h.prototype.inflateEnd=function(a){null!=this.blocks&&this.blocks.free(a);this.blocks=null;return m};h.prototype.inflateInit=function(a,b){this.blocks=a.msg=null;nowrap=0;0>b&&(b=-b,nowrap=1);if(8>b||15<b)return this.inflateEnd(a),
-2;this.wbits=b;a.istate.blocks=new q(a,0!=a.istate.nowrap?null:this,1<<b);this.inflateReset(a);return m};h.prototype.inflate=function(a,b){var d,f;if(null==a||null==a.istate||null==a.next_in)return-2;b=4==b?w:m;for(d=w;;)switch(a.istate.mode){case 0:if(0==a.avail_in)return d;d=b;a.avail_in--;a.total_in++;if(8!=((a.istate.method=a.next_in[a.next_in_index++])&15)){a.istate.mode=13;a.msg="unknown compression method";a.istate.marker=5;break}if((a.istate.method>>4)+8>a.istate.wbits){a.istate.mode=13;
a.msg="invalid window size";a.istate.marker=5;break}a.istate.mode=1;case 1:if(0==a.avail_in)return d;d=b;a.avail_in--;a.total_in++;f=a.next_in[a.next_in_index++]&255;if(0!=((a.istate.method<<8)+f)%31){a.istate.mode=13;a.msg="incorrect header check";a.istate.marker=5;break}if(0==(f&32)){a.istate.mode=7;break}a.istate.mode=2;case 2:if(0==a.avail_in)return d;d=b;a.avail_in--;a.total_in++;a.istate.need=(a.next_in[a.next_in_index++]&255)<<24&4278190080;a.istate.mode=3;case 3:if(0==a.avail_in)return d;
d=b;a.avail_in--;a.total_in++;a.istate.need+=(a.next_in[a.next_in_index++]&255)<<16&16711680;a.istate.mode=4;case 4:if(0==a.avail_in)return d;d=b;a.avail_in--;a.total_in++;a.istate.need+=(a.next_in[a.next_in_index++]&255)<<8&65280;a.istate.mode=5;case 5:if(0==a.avail_in)return d;a.avail_in--;a.total_in++;a.istate.need+=a.next_in[a.next_in_index++]&255;a.adler=a.istate.need;a.istate.mode=6;return 2;case 6:return a.istate.mode=13,a.msg="need dictionary",a.istate.marker=0,-2;case 7:d=a.istate.blocks.proc(a,
d);if(-3==d){a.istate.mode=13;a.istate.marker=0;break}d==m&&(d=b);if(d!=c)return d;d=b;a.istate.blocks.reset(a,a.istate.was);if(0!=a.istate.nowrap){a.istate.mode=12;break}a.istate.mode=8;case 8:if(0==a.avail_in)return d;d=b;a.avail_in--;a.total_in++;a.istate.need=(a.next_in[a.next_in_index++]&255)<<24&4278190080;a.istate.mode=9;case 9:if(0==a.avail_in)return d;d=b;a.avail_in--;a.total_in++;a.istate.need+=(a.next_in[a.next_in_index++]&255)<<16&16711680;a.istate.mode=10;case 10:if(0==a.avail_in)return d;
d=b;a.avail_in--;a.total_in++;a.istate.need+=(a.next_in[a.next_in_index++]&255)<<8&65280;a.istate.mode=11;case 11:if(0==a.avail_in)return d;d=b;a.avail_in--;a.total_in++;a.istate.need+=a.next_in[a.next_in_index++]&255;if(a.istate.was[0]!=a.istate.need){a.istate.mode=13;a.msg="incorrect data check";a.istate.marker=5;break}a.istate.mode=12;case 12:return c;case 13:return-3;default:return-2}};h.prototype.inflateSetDictionary=function(a,b,c){var d=0,g=c;if(null==a||null==a.istate||6!=a.istate.mode)return-2;
if(a._adler.adler32(1,b,0,c)!=a.adler)return-3;a.adler=a._adler.adler32(0,null,0,0);g>=1<<a.istate.wbits&&(g=(1<<a.istate.wbits)-1,d=c-g);a.istate.blocks.set_dictionary(b,d,g);a.istate.mode=7;return m};var K=[0,0,255,255];h.prototype.inflateSync=function(a){var b,c,d;if(null==a||null==a.istate)return-2;13!=a.istate.mode&&(a.istate.mode=13,a.istate.marker=0);if(0==(b=a.avail_in))return w;c=a.next_in_index;for(d=a.istate.marker;0!=b&&4>d;)a.next_in[c]==K[d]?d++:d=0!=a.next_in[c]?0:4-d,c++,b--;a.total_in+=
c-a.next_in_index;a.next_in_index=c;a.avail_in=b;a.istate.marker=d;if(4!=d)return-3;b=a.total_in;c=a.total_out;this.inflateReset(a);a.total_in=b;a.total_out=c;a.istate.mode=7;return m};h.prototype.inflateSyncPoint=function(a){return null==a||null==a.istate||null==a.istate.blocks?-2:a.istate.blocks.sync_point()};var L=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];q.prototype.reset=function(a,b){b&&(b[0]=this.check);6==this.mode&&this.codes.free(a);this.mode=y;this.read=this.write=this.bitb=this.bitk=
0;this.checkfn&&(a.adler=this.check=a._adler.adler32(0,null,0,0))};q.prototype.proc=function(a,b){var d,f,g,h,k,n,q;h=a.next_in_index;k=a.avail_in;f=this.bitb;g=this.bitk;n=this.write;for(q=n<this.read?this.read-n-1:this.end-n;;)switch(this.mode){case y:for(;3>g;){if(0!=k)b=m;else return this.bitb=f,this.bitk=g,a.avail_in=k,a.total_in+=h-a.next_in_index,a.next_in_index=h,this.write=n,this.inflate_flush(a,b);k--;f|=(a.next_in[h++]&255)<<g;g+=8}d=f&7;this.last=d&1;switch(d>>>1){case 0:f>>>=3;g-=3;d=
g&7;f>>>=d;g-=d;this.mode=1;break;case 1:var s=new Int32Array(1),u=new Int32Array(1),w=[],x=[];d=u;var z=w,A=x;s[0]=9;d[0]=5;z[0]=C;A[0]=F;this.codes.init(s[0],u[0],w[0],0,x[0],0,a);f>>>=3;g-=3;this.mode=6;break;case 2:f>>>=3;g-=3;this.mode=3;break;case 3:return f>>>=3,g-=3,this.mode=13,a.msg="invalid block type",b=-3,this.bitb=f,this.bitk=g,a.avail_in=k,a.total_in+=h-a.next_in_index,a.next_in_index=h,this.write=n,this.inflate_flush(a,b)}break;case 1:for(;32>g;){if(0!=k)b=m;else return this.bitb=
f,this.bitk=g,a.avail_in=k,a.total_in+=h-a.next_in_index,a.next_in_index=h,this.write=n,this.inflate_flush(a,b);k--;f|=(a.next_in[h++]&255)<<g;g+=8}if((~f>>>16&65535)!=(f&65535))return this.mode=13,a.msg="invalid stored block lengths",b=-3,this.bitb=f,this.bitk=g,a.avail_in=k,a.total_in+=h-a.next_in_index,a.next_in_index=h,this.write=n,this.inflate_flush(a,b);this.left=f&65535;f=g=0;this.mode=0!=this.left?2:0!=this.last?7:y;break;case 2:if(0==k)return this.bitb=f,this.bitk=g,a.avail_in=k,a.total_in+=
h-a.next_in_index,a.next_in_index=h,write=n,this.inflate_flush(a,b);if(0==q&&(n==end&&0!=read&&(n=0,q=n<this.read?this.read-n-1:this.end-n),0==q&&(this.write=n,b=this.inflate_flush(a,b),n=this.write,q=n<this.read?this.read-n-1:this.end-n,n==this.end&&0!=this.read&&(n=0,q=n<this.read?this.read-n-1:this.end-n),0==q)))return this.bitb=f,this.bitk=g,a.avail_in=k,a.total_in+=h-a.next_in_index,a.next_in_index=h,this.write=n,this.inflate_flush(a,b);b=m;d=this.left;d>k&&(d=k);d>q&&(d=q);p(a.next_in,h,window,
n,d);h+=d;k-=d;n+=d;q-=d;if(0!=(this.left-=d))break;this.mode=0!=this.last?7:y;break;case 3:for(;14>g;){if(0!=k)b=m;else return this.bitb=f,this.bitk=g,a.avail_in=k,a.total_in+=h-a.next_in_index,a.next_in_index=h,this.write=n,this.inflate_flush(a,b);k--;f|=(a.next_in[h++]&255)<<g;g+=8}this.table=d=f&16383;if(29<(d&31)||29<(d>>5&31))return this.mode=9,a.msg="too many length or distance symbols",b=-3,this.bitb=f,this.bitk=g,a.avail_in=k,a.total_in+=h-a.next_in_index,a.next_in_index=h,this.write=n,this.inflate_flush(a,
b);d=258+(d&31)+(d>>5&31);if(null==this.blens||this.blens.length<d)this.blens=new Int32Array(d);else for(q=0;q<d;q++)this.blens[q]=0;f>>>=14;g-=14;this.index=0;mode=4;case 4:for(;this.index<4+(this.table>>>10);){for(;3>g;){if(0!=k)b=m;else return this.bitb=f,this.bitk=g,a.avail_in=k,a.total_in+=h-a.next_in_index,a.next_in_index=h,this.write=n,this.inflate_flush(a,b);k--;f|=(a.next_in[h++]&255)<<g;g+=8}this.blens[L[this.index++]]=f&7;f>>>=3;g-=3}for(;19>this.index;)this.blens[L[this.index++]]=0;this.bb[0]=
7;d=this.inftree.inflate_trees_bits(this.blens,this.bb,this.tb,this.hufts,a);if(d!=m)return b=d,-3==b&&(this.blens=null,this.mode=9),this.bitb=f,this.bitk=g,a.avail_in=k,a.total_in+=h-a.next_in_index,a.next_in_index=h,write=n,this.inflate_flush(a,b);this.index=0;this.mode=5;case 5:for(;;){d=this.table;if(!(this.index<258+(d&31)+(d>>5&31)))break;for(d=this.bb[0];g<d;){if(0!=k)b=m;else return this.bitb=f,this.bitk=g,a.avail_in=k,a.total_in+=h-a.next_in_index,a.next_in_index=h,this.write=n,this.inflate_flush(a,
b);k--;f|=(a.next_in[h++]&255)<<g;g+=8}d=this.hufts[3*(this.tb[0]+(f&r[d]))+1];u=this.hufts[3*(this.tb[0]+(f&r[d]))+2];if(16>u)f>>>=d,g-=d,this.blens[this.index++]=u;else{q=18==u?7:u-14;for(s=18==u?11:3;g<d+q;){if(0!=k)b=m;else return this.bitb=f,this.bitk=g,a.avail_in=k,a.total_in+=h-a.next_in_index,a.next_in_index=h,this.write=n,this.inflate_flush(a,b);k--;f|=(a.next_in[h++]&255)<<g;g+=8}f>>>=d;g-=d;s+=f&r[q];f>>>=q;g-=q;q=this.index;d=this.table;if(q+s>258+(d&31)+(d>>5&31)||16==u&&1>q)return this.blens=
null,this.mode=9,a.msg="invalid bit length repeat",b=-3,this.bitb=f,this.bitk=g,a.avail_in=k,a.total_in+=h-a.next_in_index,a.next_in_index=h,this.write=n,this.inflate_flush(a,b);u=16==u?this.blens[q-1]:0;do this.blens[q++]=u;while(0!=--s);this.index=q}}this.tb[0]=-1;s=new Int32Array(1);u=new Int32Array(1);w=new Int32Array(1);x=new Int32Array(1);s[0]=9;u[0]=6;d=this.table;d=this.inftree.inflate_trees_dynamic(257+(d&31),1+(d>>5&31),this.blens,s,u,w,x,this.hufts,a);if(d!=m)return-3==d&&(this.blens=null,
this.mode=13),b=d,this.bitb=f,this.bitk=g,a.avail_in=k,a.total_in+=h-a.next_in_index,a.next_in_index=h,this.write=n,this.inflate_flush(a,b);this.codes.init(s[0],u[0],this.hufts,w[0],this.hufts,x[0],a);this.mode=6;case 6:this.bitb=f;this.bitk=g;a.avail_in=k;a.total_in+=h-a.next_in_index;a.next_in_index=h;this.write=n;if((b=this.codes.proc(this,a,b))!=c)return this.inflate_flush(a,b);b=m;this.codes.free(a);h=a.next_in_index;k=a.avail_in;f=this.bitb;g=this.bitk;n=this.write;q=n<this.read?this.read-n-
1:this.end-n;if(0==this.last){this.mode=y;break}this.mode=7;case 7:this.write=n;b=this.inflate_flush(a,b);n=this.write;if(this.read!=this.write)return this.bitb=f,this.bitk=g,a.avail_in=k,a.total_in+=h-a.next_in_index,a.next_in_index=h,this.write=n,this.inflate_flush(a,b);mode=12;case 8:return b=c,this.bitb=f,this.bitk=g,a.avail_in=k,a.total_in+=h-a.next_in_index,a.next_in_index=h,this.write=n,this.inflate_flush(a,b);case 9:return b=-3,this.bitb=f,this.bitk=g,a.avail_in=k,a.total_in+=h-a.next_in_index,
a.next_in_index=h,this.write=n,this.inflate_flush(a,b);default:return b=-2,this.bitb=f,this.bitk=g,a.avail_in=k,a.total_in+=h-a.next_in_index,a.next_in_index=h,this.write=n,this.inflate_flush(a,b)}};q.prototype.free=function(a){this.reset(a,null);this.hufts=this.window=null};q.prototype.set_dictionary=function(a,b,c){p(a,b,window,0,c);this.read=this.write=c};q.prototype.sync_point=function(){return 1==this.mode};q.prototype.inflate_flush=function(a,b){var c,d,g;d=a.next_out_index;g=this.read;c=(g<=
this.write?this.write:this.end)-g;c>a.avail_out&&(c=a.avail_out);0!=c&&b==w&&(b=m);a.avail_out-=c;a.total_out+=c;null!=this.checkfn&&(a.adler=this.check=a._adler.adler32(this.check,this.window,g,c));p(this.window,g,a.next_out,d,c);d+=c;g+=c;g==this.end&&(g=0,this.write==this.end&&(this.write=0),c=this.write-g,c>a.avail_out&&(c=a.avail_out),0!=c&&b==w&&(b=m),a.avail_out-=c,a.total_out+=c,null!=this.checkfn&&(a.adler=this.check=a._adler.adler32(this.check,this.window,g,c)),p(this.window,g,a.next_out,
d,c),d+=c,g+=c);a.next_out_index=d;this.read=g;return b};g.prototype.init=function(a,b,c,d,g,h,k){this.mode=0;this.lbits=a;this.dbits=b;this.ltree=c;this.ltree_index=d;this.dtree=g;this.dtree_index=h;this.tree=null};g.prototype.proc=function(a,b,d){var f,g,h=0,k=0,n=0,p,q,s,n=b.next_in_index;p=b.avail_in;h=a.bitb;k=a.bitk;q=a.write;for(s=q<a.read?a.read-q-1:a.end-q;;)switch(this.mode){case 0:if(258<=s&&10<=p&&(a.bitb=h,a.bitk=k,b.avail_in=p,b.total_in+=n-b.next_in_index,b.next_in_index=n,a.write=
q,d=this.inflate_fast(this.lbits,this.dbits,this.ltree,this.ltree_index,this.dtree,this.dtree_index,a,b),n=b.next_in_index,p=b.avail_in,h=a.bitb,k=a.bitk,q=a.write,s=q<a.read?a.read-q-1:a.end-q,d!=m)){this.mode=d==c?7:9;break}this.need=this.lbits;this.tree=this.ltree;this.tree_index=this.ltree_index;this.mode=1;case 1:for(f=this.need;k<f;){if(0!=p)d=m;else return a.bitb=h,a.bitk=k,b.avail_in=p,b.total_in+=n-b.next_in_index,b.next_in_index=n,a.write=q,a.inflate_flush(b,d);p--;h|=(b.next_in[n++]&255)<<
k;k+=8}f=3*(this.tree_index+(h&r[f]));h>>>=this.tree[f+1];k-=this.tree[f+1];g=this.tree[f];if(0==g){this.lit=this.tree[f+2];this.mode=6;break}if(0!=(g&16)){this.get=g&15;this.len=this.tree[f+2];this.mode=2;break}if(0==(g&64)){this.need=g;this.tree_index=f/3+this.tree[f+2];break}if(0!=(g&32)){this.mode=7;break}this.mode=9;b.msg="invalid literal/length code";d=-3;a.bitb=h;a.bitk=k;b.avail_in=p;b.total_in+=n-b.next_in_index;b.next_in_index=n;a.write=q;return a.inflate_flush(b,d);case 2:for(f=this.get;k<
f;){if(0!=p)d=m;else return a.bitb=h,a.bitk=k,b.avail_in=p,b.total_in+=n-b.next_in_index,b.next_in_index=n,a.write=q,a.inflate_flush(b,d);p--;h|=(b.next_in[n++]&255)<<k;k+=8}this.len+=h&r[f];h>>=f;k-=f;this.need=this.dbits;this.tree=this.dtree;this.tree_index=this.dtree_index;this.mode=3;case 3:for(f=this.need;k<f;){if(0!=p)d=m;else return a.bitb=h,a.bitk=k,b.avail_in=p,b.total_in+=n-b.next_in_index,b.next_in_index=n,a.write=q,a.inflate_flush(b,d);p--;h|=(b.next_in[n++]&255)<<k;k+=8}f=3*(this.tree_index+
(h&r[f]));h>>=this.tree[f+1];k-=this.tree[f+1];g=this.tree[f];if(0!=(g&16)){this.get=g&15;this.dist=this.tree[f+2];this.mode=4;break}if(0==(g&64)){this.need=g;this.tree_index=f/3+this.tree[f+2];break}this.mode=9;b.msg="invalid distance code";d=-3;a.bitb=h;a.bitk=k;b.avail_in=p;b.total_in+=n-b.next_in_index;b.next_in_index=n;a.write=q;return a.inflate_flush(b,d);case 4:for(f=this.get;k<f;){if(0!=p)d=m;else return a.bitb=h,a.bitk=k,b.avail_in=p,b.total_in+=n-b.next_in_index,b.next_in_index=n,a.write=
q,a.inflate_flush(b,d);p--;h|=(b.next_in[n++]&255)<<k;k+=8}this.dist+=h&r[f];h>>=f;k-=f;this.mode=5;case 5:for(f=q-this.dist;0>f;)f+=a.end;for(;0!=this.len;){if(0==s&&(q==a.end&&0!=a.read&&(q=0,s=q<a.read?a.read-q-1:a.end-q),0==s&&(a.write=q,d=a.inflate_flush(b,d),q=a.write,s=q<a.read?a.read-q-1:a.end-q,q==a.end&&0!=a.read&&(q=0,s=q<a.read?a.read-q-1:a.end-q),0==s)))return a.bitb=h,a.bitk=k,b.avail_in=p,b.total_in+=n-b.next_in_index,b.next_in_index=n,a.write=q,a.inflate_flush(b,d);a.window[q++]=a.window[f++];
s--;f==a.end&&(f=0);this.len--}this.mode=0;break;case 6:if(0==s&&(q==a.end&&0!=a.read&&(q=0,s=q<a.read?a.read-q-1:a.end-q),0==s&&(a.write=q,d=a.inflate_flush(b,d),q=a.write,s=q<a.read?a.read-q-1:a.end-q,q==a.end&&0!=a.read&&(q=0,s=q<a.read?a.read-q-1:a.end-q),0==s)))return a.bitb=h,a.bitk=k,b.avail_in=p,b.total_in+=n-b.next_in_index,b.next_in_index=n,a.write=q,a.inflate_flush(b,d);d=m;a.window[q++]=this.lit;s--;this.mode=0;break;case 7:7<k&&(k-=8,p++,n--);a.write=q;d=a.inflate_flush(b,d);q=a.write;
if(a.read!=a.write)return a.bitb=h,a.bitk=k,b.avail_in=p,b.total_in+=n-b.next_in_index,b.next_in_index=n,a.write=q,a.inflate_flush(b,d);this.mode=8;case 8:return d=c,a.bitb=h,a.bitk=k,b.avail_in=p,b.total_in+=n-b.next_in_index,b.next_in_index=n,a.write=q,a.inflate_flush(b,d);case 9:return d=-3,a.bitb=h,a.bitk=k,b.avail_in=p,b.total_in+=n-b.next_in_index,b.next_in_index=n,a.write=q,a.inflate_flush(b,d);default:return d=-2,a.bitb=h,a.bitk=k,b.avail_in=p,b.total_in+=n-b.next_in_index,b.next_in_index=
n,a.write=q,a.inflate_flush(b,d)}};g.prototype.free=function(a){};g.prototype.inflate_fast=function(a,b,d,f,g,h,k,n){var q,s,u,w,x,y,z,A,B,F,C,E;y=n.next_in_index;z=n.avail_in;w=k.bitb;x=k.bitk;A=k.write;B=A<k.read?k.read-A-1:k.end-A;a=r[a];F=r[b];do{for(;20>x;)z--,w|=(n.next_in[y++]&255)<<x,x+=8;q=w&a;s=d;u=f;E=3*(u+q);if(0==(b=s[E]))w>>=s[E+1],x-=s[E+1],k.window[A++]=s[E+2],B--;else{do{w>>=s[E+1];x-=s[E+1];if(0!=(b&16)){b&=15;C=s[E+2]+(w&r[b]);w>>=b;for(x-=b;15>x;)z--,w|=(n.next_in[y++]&255)<<x,
x+=8;q=w&F;s=g;u=h;E=3*(u+q);b=s[E];do if(w>>=s[E+1],x-=s[E+1],0!=(b&16)){for(b&=15;x<b;)z--,w|=(n.next_in[y++]&255)<<x,x+=8;q=s[E+2]+(w&r[b]);w>>=b;x-=b;B-=C;if(A>=q)q=A-q,k.window[A++]=k.window[q++],k.window[A++]=k.window[q++],C-=2;else{q=A-q;do q+=k.end;while(0>q);b=k.end-q;if(C>b){C-=b;if(0<A-q&&b>A-q){do k.window[A++]=k.window[q++];while(0!=--b)}else p(k.window,q,k.window,A,b),A+=b;q=0}}do k.window[A++]=k.window[q++];while(0!=--C);break}else if(0==(b&64))q+=s[E+2],q+=w&r[b],E=3*(u+q),b=s[E];
else return n.msg="invalid distance code",C=n.avail_in-z,C=x>>3<C?x>>3:C,z+=C,y-=C,x-=C<<3,k.bitb=w,k.bitk=x,n.avail_in=z,n.total_in+=y-n.next_in_index,n.next_in_index=y,k.write=A,-3;while(1);break}if(0==(b&64)){if(q+=s[E+2],q+=w&r[b],E=3*(u+q),0==(b=s[E])){w>>=s[E+1];x-=s[E+1];k.window[A++]=s[E+2];B--;break}}else{if(0!=(b&32))return C=n.avail_in-z,C=x>>3<C?x>>3:C,z+=C,y-=C,x-=C<<3,k.bitb=w,k.bitk=x,n.avail_in=z,n.total_in+=y-n.next_in_index,n.next_in_index=y,k.write=A,c;n.msg="invalid literal/length code";
C=n.avail_in-z;C=x>>3<C?x>>3:C;z+=C;y-=C;x-=C<<3;k.bitb=w;k.bitk=x;n.avail_in=z;n.total_in+=y-n.next_in_index;n.next_in_index=y;k.write=A;return-3}}while(1)}}while(258<=B&&10<=z);C=n.avail_in-z;C=x>>3<C?x>>3:C;y-=C;k.bitb=w;k.bitk=x-(C<<3);n.avail_in=z+C;n.total_in+=y-n.next_in_index;n.next_in_index=y;k.write=A;return m};z.prototype.huft_build=function(b,c,d,f,g,h,k,n,q,r,s){var u,x,y,z,A,B,C,E,F;B=0;x=d;do this.c[b[c+B]]++,B++,x--;while(0!=x);if(this.c[0]==d)return k[0]=-1,n[0]=0,m;A=n[0];for(y=
1;15>=y&&0==this.c[y];y++);z=y;A<y&&(A=y);for(x=15;0!=x&&0==this.c[x];x--);r=x;A>x&&(A=x);n[0]=A;for(n=1<<y;y<x;y++,n<<=1)if(0>(n-=this.c[y]))return-3;if(0>(n-=this.c[x]))return-3;this.c[x]+=n;this.x[1]=y=0;B=1;for(C=2;0!=--x;)this.x[C]=y+=this.c[B],C++,B++;B=x=0;do 0!=(y=b[c+B])&&(this.v[this.x[y]++]=x),B++;while(++x<d);d=this.x[r];B=this.x[0]=x=0;c=-1;E=-A;for(F=C=this.u[0]=0;z<=r;z++)for(b=this.c[z];0!=b--;){for(;z>E+A;){c++;E+=A;F=r-E;F=F>A?A:F;if((u=1<<(y=z-E))>b+1&&(u-=b+1,C=z,y<F))for(;++y<
F&&!((u<<=1)<=this.c[++C]);)u-=this.c[C];F=1<<y;if(this.hn[0]+F>a)return-3;this.u[c]=C=this.hn[0];this.hn[0]+=F;0!=c?(this.x[c]=x,this.r[0]=y,this.r[1]=A,y=x>>>E-A,this.r[2]=C-this.u[c-1]-y,p(this.r,0,q,3*(this.u[c-1]+y),3)):k[0]=C}this.r[1]=z-E;B>=d?this.r[0]=192:s[B]<f?(this.r[0]=256>this.v[B]?0:96,this.r[2]=this.v[B++]):(this.r[0]=h[this.v[B]-f]+16+64,this.r[2]=g[this.v[B++]-f]);u=1<<z-E;for(y=x>>>E;y<F;y+=u)p(this.r,0,q,3*(C+y),3);for(y=1<<z-1;0!=(x&y);y>>>=1)x^=y;x^=y;for(y=(1<<E)-1;(x&y)!=this.x[c];)c--,
E-=A,y=(1<<E)-1}return 0!=n&&1!=r?w:m};z.prototype.inflate_trees_bits=function(a,b,c,d,g){this.initWorkArea(19);this.hn[0]=0;a=this.huft_build(a,0,19,19,null,null,c,b,d,this.hn,this.v);if(-3==a)g.msg="oversubscribed dynamic bit lengths tree";else if(a==w||0==b[0])g.msg="incomplete dynamic bit lengths tree",a=-3;return a};z.prototype.inflate_trees_dynamic=function(a,b,c,d,g,h,k,n,p){this.initWorkArea(288);this.hn[0]=0;h=this.huft_build(c,0,a,257,A,R,h,d,n,this.hn,this.v);if(h!=m||0==d[0])return-3==
h?p.msg="oversubscribed literal/length tree":-4!=h&&(p.msg="incomplete literal/length tree",h=-3),h;this.initWorkArea(288);h=this.huft_build(c,a,b,0,B,Q,k,g,n,this.hn,this.v);return h!=m||0==g[0]&&257<a?(-3==h?p.msg="oversubscribed distance tree":h==w?(p.msg="incomplete distance tree",h=-3):-4!=h&&(p.msg="empty distance tree with lengths",h=-3),h):m};z.prototype.initWorkArea=function(a){null==this.hn&&(this.hn=new Int32Array(1),this.v=new Int32Array(a),this.c=new Int32Array(16),this.r=new Int32Array(3),
this.u=new Int32Array(15),this.x=new Int32Array(16));this.v.length<a&&(this.v=new Int32Array(a));for(var b=0;b<a;b++)this.v[b]=0;for(b=0;16>b;b++)this.c[b]=0;for(b=0;3>b;b++)this.r[b]=0;p(this.c,0,this.u,0,15);p(this.c,0,this.x,0,16)};var E="function"===typeof(new Uint8Array(1)).subarray;"undefined"!==typeof u&&(u.exports={inflateBuffer:x,arrayCopy:p})},{}]},{},[15]);