UNPKG

hic-straw

Version:

Utilities for reading .files (contact matrix files)

1 lines 225 kB
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):(e="undefined"!=typeof globalThis?globalThis:e||self).HicStraw=o()}(this,(function(){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},o=function(e){return e&&e.Math==Math&&e},a=o("object"==typeof globalThis&&globalThis)||o("object"==typeof window&&window)||o("object"==typeof self&&self)||o("object"==typeof e&&e)||function(){return this}()||Function("return this")(),t=function(e){try{return!!e()}catch(e){return!0}},i=!t((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),F={exports:{}},n=function(e){return"function"==typeof e},c=!t((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),s=c,r=Function.prototype,f=r.bind,d=r.call,h=s&&f.bind(d,d),w=s?function(e){return e&&h(e)}:function(e){return e&&function(){return d.apply(e,arguments)}},l=function(e){return null==e},p=l,u=TypeError,m=function(e){if(p(e))throw u("Can't call method on "+e);return e},b=Object,N=function(e){return b(m(e))},C=w({}.hasOwnProperty),g=Object.hasOwn||function(e,o){return C(N(e),o)},I=i,z=g,E=Function.prototype,D=I&&Object.getOwnPropertyDescriptor,y=z(E,"name"),H={EXISTS:y,PROPER:y&&"something"===function(){}.name,CONFIGURABLE:y&&(!I||I&&D(E,"name").configurable)},S=a,R=Object.defineProperty,x=function(e,o){try{R(S,e,{value:o,configurable:!0,writable:!0})}catch(a){S[e]=o}return o},_="__core-js_shared__",B=a[_]||x(_,{}),A=n,v=B,T=w(Function.toString);A(v.inspectSource)||(v.inspectSource=function(e){return T(e)});var L,M,j=v.inspectSource,q=n,O=a.WeakMap,k=q(O)&&/native code/.test(String(O)),U=n,K="object"==typeof document&&document.all,V=void 0===K&&void 0!==K?function(e){return"object"==typeof e?null!==e:U(e)||e===K}:function(e){return"object"==typeof e?null!==e:U(e)},P={},Z=V,W=a.document,X=Z(W)&&Z(W.createElement),Y=function(e){return X?W.createElement(e):{}},G=!i&&!t((function(){return 7!=Object.defineProperty(Y("div"),"a",{get:function(){return 7}}).a})),Q=i&&t((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),J=V,$=String,ee=TypeError,oe=function(e){if(J(e))return e;throw ee($(e)+" is not an object")},ae=c,te=Function.prototype.call,ie=ae?te.bind(te):function(){return te.apply(te,arguments)},Fe=a,ne=n,ce=function(e){return ne(e)?e:void 0},se=function(e,o){return arguments.length<2?ce(Fe[e]):Fe[e]&&Fe[e][o]},re=w({}.isPrototypeOf),fe=a,de=se("navigator","userAgent")||"",he=fe.process,we=fe.Deno,le=he&&he.versions||we&&we.version,pe=le&&le.v8;pe&&(M=(L=pe.split("."))[0]>0&&L[0]<4?1:+(L[0]+L[1])),!M&&de&&(!(L=de.match(/Edge\/(\d+)/))||L[1]>=74)&&(L=de.match(/Chrome\/(\d+)/))&&(M=+L[1]);var ue=M,me=t,be=!!Object.getOwnPropertySymbols&&!me((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&ue&&ue<41})),Ne=be&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Ce=se,ge=n,Ie=re,ze=Object,Ee=Ne?function(e){return"symbol"==typeof e}:function(e){var o=Ce("Symbol");return ge(o)&&Ie(o.prototype,ze(e))},De=String,ye=n,He=function(e){try{return De(e)}catch(e){return"Object"}},Se=TypeError,Re=function(e){if(ye(e))return e;throw Se(He(e)+" is not a function")},xe=l,_e=ie,Be=n,Ae=V,ve=TypeError,Te={exports:{}},Le=B;(Te.exports=function(e,o){return Le[e]||(Le[e]=void 0!==o?o:{})})("versions",[]).push({version:"3.25.0",mode:"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.25.0/LICENSE",source:"https://github.com/zloirock/core-js"});var Me=w,je=0,qe=Math.random(),Oe=Me(1..toString),ke=function(e){return"Symbol("+(void 0===e?"":e)+")_"+Oe(++je+qe,36)},Ue=a,Ke=Te.exports,Ve=g,Pe=ke,Ze=be,We=Ne,Xe=Ke("wks"),Ye=Ue.Symbol,Ge=Ye&&Ye.for,Qe=We?Ye:Ye&&Ye.withoutSetter||Pe,Je=ie,$e=V,eo=Ee,oo=function(e,o){var a=e[o];return xe(a)?void 0:Re(a)},ao=function(e,o){var a,t;if("string"===o&&Be(a=e.toString)&&!Ae(t=_e(a,e)))return t;if(Be(a=e.valueOf)&&!Ae(t=_e(a,e)))return t;if("string"!==o&&Be(a=e.toString)&&!Ae(t=_e(a,e)))return t;throw ve("Can't convert object to primitive value")},to=TypeError,io=function(e){if(!Ve(Xe,e)||!Ze&&"string"!=typeof Xe[e]){var o="Symbol."+e;Ze&&Ve(Ye,e)?Xe[e]=Ye[e]:Xe[e]=We&&Ge?Ge(o):Qe(o)}return Xe[e]}("toPrimitive"),Fo=function(e,o){if(!$e(e)||eo(e))return e;var a,t=oo(e,io);if(t){if(void 0===o&&(o="default"),a=Je(t,e,o),!$e(a)||eo(a))return a;throw to("Can't convert object to primitive value")}return void 0===o&&(o="number"),ao(e,o)},no=Ee,co=i,so=G,ro=Q,fo=oe,ho=function(e){var o=Fo(e,"string");return no(o)?o:o+""},wo=TypeError,lo=Object.defineProperty,po=Object.getOwnPropertyDescriptor,uo="enumerable",mo="configurable",bo="writable";P.f=co?ro?function(e,o,a){if(fo(e),o=ho(o),fo(a),"function"==typeof e&&"prototype"===o&&"value"in a&&bo in a&&!a.writable){var t=po(e,o);t&&t.writable&&(e[o]=a.value,a={configurable:mo in a?a.configurable:t.configurable,enumerable:uo in a?a.enumerable:t.enumerable,writable:!1})}return lo(e,o,a)}:lo:function(e,o,a){if(fo(e),o=ho(o),fo(a),so)try{return lo(e,o,a)}catch(e){}if("get"in a||"set"in a)throw wo("Accessors not supported");return"value"in a&&(e[o]=a.value),e};var No,Co,go,Io=P,zo=function(e,o){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:o}},Eo=i?function(e,o,a){return Io.f(e,o,zo(1,a))}:function(e,o,a){return e[o]=a,e},Do=Te.exports,yo=ke,Ho=Do("keys"),So=k,Ro=a,xo=w,_o=V,Bo=Eo,Ao=g,vo=B,To=function(e){return Ho[e]||(Ho[e]=yo(e))},Lo="Object already initialized",Mo=Ro.TypeError,jo=Ro.WeakMap;if(So||vo.state){var qo=vo.state||(vo.state=new jo),Oo=xo(qo.get),ko=xo(qo.has),Uo=xo(qo.set);No=function(e,o){if(ko(qo,e))throw Mo(Lo);return o.facade=e,Uo(qo,e,o),o},Co=function(e){return Oo(qo,e)||{}},go=function(e){return ko(qo,e)}}else{var Ko=To("state");No=function(e,o){if(Ao(e,Ko))throw Mo(Lo);return o.facade=e,Bo(e,Ko,o),o},Co=function(e){return Ao(e,Ko)?e[Ko]:{}},go=function(e){return Ao(e,Ko)}}var Vo={set:No,get:Co,has:go,enforce:function(e){return go(e)?Co(e):No(e,{})},getterFor:function(e){return function(o){var a;if(!_o(o)||(a=Co(o)).type!==e)throw Mo("Incompatible receiver, "+e+" required");return a}}},Po=t,Zo=n,Wo=g,Xo=i,Yo=H.CONFIGURABLE,Go=j,Qo=Vo.enforce,Jo=Vo.get,$o=Object.defineProperty,ea=Xo&&!Po((function(){return 8!==$o((function(){}),"length",{value:8}).length})),oa=String(String).split("String"),aa=F.exports=function(e,o,a){"Symbol("===String(o).slice(0,7)&&(o="["+String(o).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),a&&a.getter&&(o="get "+o),a&&a.setter&&(o="set "+o),(!Wo(e,"name")||Yo&&e.name!==o)&&(Xo?$o(e,"name",{value:o,configurable:!0}):e.name=o),ea&&a&&Wo(a,"arity")&&e.length!==a.arity&&$o(e,"length",{value:a.arity});try{a&&Wo(a,"constructor")&&a.constructor?Xo&&$o(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var t=Qo(e);return Wo(t,"source")||(t.source=oa.join("string"==typeof o?o:"")),e};Function.prototype.toString=aa((function(){return Zo(this)&&Jo(this).source||Go(this)}),"toString");var ta=F.exports,ia=P,Fa=oe,na=i,ca=function(e,o,a){return a.get&&ta(a.get,o,{getter:!0}),a.set&&ta(a.set,o,{setter:!0}),ia.f(e,o,a)},sa=function(){var e=Fa(this),o="";return e.hasIndices&&(o+="d"),e.global&&(o+="g"),e.ignoreCase&&(o+="i"),e.multiline&&(o+="m"),e.dotAll&&(o+="s"),e.unicode&&(o+="u"),e.unicodeSets&&(o+="v"),e.sticky&&(o+="y"),o},ra=t,fa=a.RegExp,da=fa.prototype;na&&ra((function(){var e=!0;try{fa(".","d")}catch(o){e=!1}var o={},a="",t=e?"dgimsy":"gimsy",i=function(e,t){Object.defineProperty(o,e,{get:function(){return a+=t,!0}})},F={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var n in e&&(F.hasIndices="d"),F)i(n,F[n]);return Object.getOwnPropertyDescriptor(da,"flags").get.call(o)!==t||a!==t}))&&ca(da,"flags",{configurable:!0,get:sa});var ha={Huffman:{},Util:{},CRC32:{},CompressionMethod:{DEFLATE:8,RESERVED:15},Zip:function(e){e=e||{},this.files=[],this.comment=e.comment,this.password}};ha.Zip.CompressionMethod={STORE:0,DEFLATE:8},ha.Zip.OperatingSystem={MSDOS:0,UNIX:3,MACINTOSH:7},ha.Zip.Flags={ENCRYPT:1,DESCRIPTOR:8,UTF8:2048},ha.Zip.FileHeaderSignature=[80,75,1,2],ha.Zip.LocalFileHeaderSignature=[80,75,3,4],ha.Zip.CentralDirectorySignature=[80,75,5,6],ha.Zip.prototype.addFile=function(e,o){var a;(o=o||{}).filename;var t=e.length,i=0;if(e instanceof Array&&(e=new Uint8Array(e)),"number"!=typeof o.compressionMethod&&(o.compressionMethod=ha.Zip.CompressionMethod.DEFLATE),o.compress)switch(o.compressionMethod){case ha.Zip.CompressionMethod.STORE:break;case ha.Zip.CompressionMethod.DEFLATE:i=ha.CRC32.calc(e),e=this.deflateWithOption(e,o),a=!0;break;default:throw new Error("unknown compression method:"+o.compressionMethod)}this.files.push({buffer:e,option:o,compressed:a,encrypted:!1,size:t,crc32:i})},ha.Zip.prototype.setPassword=function(e){this.password=e},ha.Zip.prototype.compress=function(){var e,o,a,t,i,F,n,c,s,r,f,d,h,w,l,p,u,m,b,N,C,g,I,z,E,D,y=this.files,H=0,S=0;for(I=0,z=y.length;I<z;++I){if(w=(e=y[I]).option.filename?e.option.filename.length:0,l=e.option.extraField?e.option.extraField.length:0,p=e.option.comment?e.option.comment.length:0,!e.compressed)switch(e.crc32=ha.CRC32.calc(e.buffer),e.option.compressionMethod){case ha.Zip.CompressionMethod.STORE:break;case ha.Zip.CompressionMethod.DEFLATE:e.buffer=this.deflateWithOption(e.buffer,e.option),e.compressed=!0;break;default:throw new Error("unknown compression method:"+e.option.compressionMethod)}if(void 0!==e.option.password||void 0!==this.password){for(g=this.createEncryptionKey(e.option.password||this.password),N=e.buffer,(C=new Uint8Array(N.length+12)).set(N,12),N=C,E=0;E<12;++E)N[E]=this.encode(g,11===I?255&e.crc32:256*Math.random()|0);for(D=N.length;E<D;++E)N[E]=this.encode(g,N[E]);e.buffer=N}H+=30+w+e.buffer.length,S+=46+w+p}for(F=22+(this.comment?this.comment.length:0),o=new Uint8Array(H+S+F),a=0,i=(t=H)+S,I=0,z=y.length;I<z;++I)w=(e=y[I]).option.filename?e.option.filename.length:0,l=0,p=e.option.comment?e.option.comment.length:0,n=a,o[a++]=ha.Zip.LocalFileHeaderSignature[0],o[a++]=ha.Zip.LocalFileHeaderSignature[1],o[a++]=ha.Zip.LocalFileHeaderSignature[2],o[a++]=ha.Zip.LocalFileHeaderSignature[3],o[t++]=ha.Zip.FileHeaderSignature[0],o[t++]=ha.Zip.FileHeaderSignature[1],o[t++]=ha.Zip.FileHeaderSignature[2],o[t++]=ha.Zip.FileHeaderSignature[3],20,o[t++]=20,o[t++]=e.option.os||ha.Zip.OperatingSystem.MSDOS,o[a++]=o[t++]=20,o[a++]=o[t++]=0,c=0,(e.option.password||this.password)&&(c|=ha.Zip.Flags.ENCRYPT),o[a++]=o[t++]=255&c,o[a++]=o[t++]=c>>8&255,s=e.option.compressionMethod,o[a++]=o[t++]=255&s,o[a++]=o[t++]=s>>8&255,r=e.option.date||new Date,o[a++]=o[t++]=(7&r.getMinutes())<<5|r.getSeconds()/2|0,o[a++]=o[t++]=r.getHours()<<3|r.getMinutes()>>3,o[a++]=o[t++]=(r.getMonth()+1&7)<<5|r.getDate(),o[a++]=o[t++]=(r.getFullYear()-1980&127)<<1|r.getMonth()+1>>3,f=e.crc32,o[a++]=o[t++]=255&f,o[a++]=o[t++]=f>>8&255,o[a++]=o[t++]=f>>16&255,o[a++]=o[t++]=f>>24&255,d=e.buffer.length,o[a++]=o[t++]=255&d,o[a++]=o[t++]=d>>8&255,o[a++]=o[t++]=d>>16&255,o[a++]=o[t++]=d>>24&255,h=e.size,o[a++]=o[t++]=255&h,o[a++]=o[t++]=h>>8&255,o[a++]=o[t++]=h>>16&255,o[a++]=o[t++]=h>>24&255,o[a++]=o[t++]=255&w,o[a++]=o[t++]=w>>8&255,o[a++]=o[t++]=255&l,o[a++]=o[t++]=l>>8&255,o[t++]=255&p,o[t++]=p>>8&255,o[t++]=0,o[t++]=0,o[t++]=0,o[t++]=0,o[t++]=0,o[t++]=0,o[t++]=0,o[t++]=0,o[t++]=255&n,o[t++]=n>>8&255,o[t++]=n>>16&255,o[t++]=n>>24&255,(u=e.option.filename)&&(o.set(u,a),o.set(u,t),a+=w,t+=w),(m=e.option.extraField)&&(o.set(m,a),o.set(m,t),a+=l,t+=l),(b=e.option.comment)&&(o.set(b,t),t+=p),o.set(e.buffer,a),a+=e.buffer.length;return o[i++]=ha.Zip.CentralDirectorySignature[0],o[i++]=ha.Zip.CentralDirectorySignature[1],o[i++]=ha.Zip.CentralDirectorySignature[2],o[i++]=ha.Zip.CentralDirectorySignature[3],o[i++]=0,o[i++]=0,o[i++]=0,o[i++]=0,o[i++]=255&z,o[i++]=z>>8&255,o[i++]=255&z,o[i++]=z>>8&255,o[i++]=255&S,o[i++]=S>>8&255,o[i++]=S>>16&255,o[i++]=S>>24&255,o[i++]=255&H,o[i++]=H>>8&255,o[i++]=H>>16&255,o[i++]=H>>24&255,p=this.comment?this.comment.length:0,o[i++]=255&p,o[i++]=p>>8&255,this.comment&&(o.set(this.comment,i),i+=p),o},ha.Zip.prototype.deflateWithOption=function(e,o){return new ha.RawDeflate(e,o.deflateOption).compress()},ha.Zip.prototype.getByte=function(e){var o=65535&e[2]|2;return o*(1^o)>>8&255},ha.Zip.prototype.encode=function(e,o){var a=this.getByte(e);return this.updateKeys(e,o),a^o},ha.Zip.prototype.updateKeys=function(e,o){e[0]=ha.CRC32.single(e[0],o),e[1]=1+(6681*(20173*(e[1]+(255&e[0]))>>>0)>>>0)>>>0,e[2]=ha.CRC32.single(e[2],e[1]>>>24)},ha.Zip.prototype.createEncryptionKey=function(e){var o,a,t=[305419896,591751049,878082192];for(t=new Uint32Array(t),o=0,a=e.length;o<a;++o)this.updateKeys(t,255&e[o]);return t},ha.Huffman.buildHuffmanTable=function(e){var o,a,t,i,F,n,c,s,r,f,d,h=e.length,w=0,l=Number.POSITIVE_INFINITY;for(s=0,r=h;s<r;++s)e[s]>w&&(w=e[s]),e[s]<l&&(l=e[s]);for(o=1<<w,a=new Uint32Array(o),t=1,i=0,F=2;t<=w;){for(s=0;s<h;++s)if(e[s]===t){for(n=0,c=i,f=0;f<t;++f)n=n<<1|1&c,c>>=1;for(d=t<<16|s,f=n;f<o;f+=F)a[f]=d;++i}++t,i<<=1,F<<=1}return[a,w,l]};var wa=ha.Huffman.buildHuffmanTable;ha.RawInflate=function(e,o){switch(this.buffer,this.blocks=[],this.bufferSize=32768,this.totalpos=0,this.ip=0,this.bitsbuf=0,this.bitsbuflen=0,this.input=new Uint8Array(e),this.output,this.op,this.bfinal=!1,this.bufferType=ha.RawInflate.BufferType.ADAPTIVE,this.resize=!1,!o&&(o={})||(o.index&&(this.ip=o.index),o.bufferSize&&(this.bufferSize=o.bufferSize),o.bufferType&&(this.bufferType=o.bufferType),o.resize&&(this.resize=o.resize)),this.bufferType){case ha.RawInflate.BufferType.BLOCK:this.op=ha.RawInflate.MaxBackwardLength,this.output=new Uint8Array(ha.RawInflate.MaxBackwardLength+this.bufferSize+ha.RawInflate.MaxCopyLength);break;case ha.RawInflate.BufferType.ADAPTIVE:this.op=0,this.output=new Uint8Array(this.bufferSize);break;default:throw new Error("invalid inflate mode")}},ha.RawInflate.BufferType={BLOCK:0,ADAPTIVE:1},ha.RawInflate.prototype.decompress=function(){for(;!this.bfinal;)this.parseBlock();switch(this.bufferType){case ha.RawInflate.BufferType.BLOCK:return this.concatBufferBlock();case ha.RawInflate.BufferType.ADAPTIVE:return this.concatBufferDynamic();default:throw new Error("invalid inflate mode")}},ha.RawInflate.MaxBackwardLength=32768,ha.RawInflate.MaxCopyLength=258,ha.RawInflate.Order=new Uint16Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ha.RawInflate.LengthCodeTable=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258]),ha.RawInflate.LengthExtraTable=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0]),ha.RawInflate.DistCodeTable=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577]),ha.RawInflate.DistExtraTable=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),ha.RawInflate.FixedLiteralLengthTable=function(){var e,o,a=new Uint8Array(288);for(e=0,o=a.length;e<o;++e)a[e]=e<=143?8:e<=255?9:e<=279?7:8;return wa(a)}(),ha.RawInflate.FixedDistanceTable=function(){var e,o,a=new Uint8Array(30);for(e=0,o=a.length;e<o;++e)a[e]=5;return wa(a)}(),ha.RawInflate.prototype.parseBlock=function(){var e=this.readBits(3);switch(1&e&&(this.bfinal=!0),e>>>=1){case 0:this.parseUncompressedBlock();break;case 1:this.parseFixedHuffmanBlock();break;case 2:this.parseDynamicHuffmanBlock();break;default:throw new Error("unknown BTYPE: "+e)}},ha.RawInflate.prototype.readBits=function(e){var o,a=this.bitsbuf,t=this.bitsbuflen,i=this.input,F=this.ip;if(F+(e-t+7>>3)>=i.length)throw new Error("input buffer is broken");for(;t<e;)a|=i[F++]<<t,t+=8;return o=a&(1<<e)-1,a>>>=e,t-=e,this.bitsbuf=a,this.bitsbuflen=t,this.ip=F,o},ha.RawInflate.prototype.readCodeByTable=function(e){for(var o,a,t=this.bitsbuf,i=this.bitsbuflen,F=this.input,n=this.ip,c=F.length,s=e[0],r=e[1];i<r&&!(n>=c);)t|=F[n++]<<i,i+=8;if((a=(o=s[t&(1<<r)-1])>>>16)>i)throw new Error("invalid code length: "+a);return this.bitsbuf=t>>a,this.bitsbuflen=i-a,this.ip=n,65535&o},ha.RawInflate.prototype.parseUncompressedBlock=function(){var e,o,a=this.input,t=this.ip,i=this.output,F=this.op,n=a.length,c=i.length;if(this.bitsbuf=0,this.bitsbuflen=0,t+1>=n)throw new Error("invalid uncompressed block header: LEN");if(e=a[t++]|a[t++]<<8,t+1>=n)throw new Error("invalid uncompressed block header: NLEN");if(e===~(a[t++]|a[t++]<<8))throw new Error("invalid uncompressed block header: length verify");if(t+e>a.length)throw new Error("input buffer is broken");switch(this.bufferType){case ha.RawInflate.BufferType.BLOCK:for(;F+e>i.length;)e-=o=c-F,i.set(a.subarray(t,t+o),F),F+=o,t+=o,this.op=F,i=this.expandBufferBlock(),F=this.op;break;case ha.RawInflate.BufferType.ADAPTIVE:for(;F+e>i.length;)i=this.expandBufferAdaptive({fixRatio:2});break;default:throw new Error("invalid inflate mode")}i.set(a.subarray(t,t+e),F),F+=e,t+=e,this.ip=t,this.op=F,this.output=i},ha.RawInflate.prototype.parseFixedHuffmanBlock=function(){switch(this.bufferType){case ha.RawInflate.BufferType.ADAPTIVE:this.decodeHuffmanAdaptive(ha.RawInflate.FixedLiteralLengthTable,ha.RawInflate.FixedDistanceTable);break;case ha.RawInflate.BufferType.BLOCK:this.decodeHuffmanBlock(ha.RawInflate.FixedLiteralLengthTable,ha.RawInflate.FixedDistanceTable);break;default:throw new Error("invalid inflate mode")}},ha.RawInflate.prototype.parseDynamicHuffmanBlock=function(){var e,o,a,t,i,F,n,c,s,r=this.readBits(5)+257,f=this.readBits(5)+1,d=this.readBits(4)+4,h=new Uint8Array(ha.RawInflate.Order.length);for(c=0;c<d;++c)h[ha.RawInflate.Order[c]]=this.readBits(3);for(e=wa(h),t=new Uint8Array(r+f),c=0,s=r+f;c<s;)switch(i=this.readCodeByTable(e)){case 16:for(n=3+this.readBits(2);n--;)t[c++]=F;break;case 17:for(n=3+this.readBits(3);n--;)t[c++]=0;F=0;break;case 18:for(n=11+this.readBits(7);n--;)t[c++]=0;F=0;break;default:t[c++]=i,F=i}switch(o=wa(t.subarray(0,r)),a=wa(t.subarray(r)),this.bufferType){case ha.RawInflate.BufferType.ADAPTIVE:this.decodeHuffmanAdaptive(o,a);break;case ha.RawInflate.BufferType.BLOCK:this.decodeHuffmanBlock(o,a);break;default:throw new Error("invalid inflate mode")}},ha.RawInflate.prototype.decodeHuffmanBlock=function(e,o){var a=this.output,t=this.op;this.currentLitlenTable=e;for(var i,F,n,c,s=a.length-ha.RawInflate.MaxCopyLength,r=ha.RawInflate.LengthCodeTable,f=ha.RawInflate.LengthExtraTable,d=ha.RawInflate.DistCodeTable,h=ha.RawInflate.DistExtraTable;256!==(i=this.readCodeByTable(e));)if(i<256)t>=s&&(this.op=t,a=this.expandBufferBlock(),t=this.op),a[t++]=i;else for(c=r[F=i-257],f[F]>0&&(c+=this.readBits(f[F])),n=d[i=this.readCodeByTable(o)],h[i]>0&&(n+=this.readBits(h[i])),t>=s&&(this.op=t,a=this.expandBufferBlock(),t=this.op);c--;)a[t]=a[t++-n];for(;this.bitsbuflen>=8;)this.bitsbuflen-=8,this.ip--;this.op=t},ha.RawInflate.prototype.decodeHuffmanAdaptive=function(e,o){var a=this.output,t=this.op;this.currentLitlenTable=e;for(var i,F,n,c,s=a.length,r=ha.RawInflate.LengthCodeTable,f=ha.RawInflate.LengthExtraTable,d=ha.RawInflate.DistCodeTable,h=ha.RawInflate.DistExtraTable;256!==(i=this.readCodeByTable(e));)if(i<256)t>=s&&(s=(a=this.expandBufferAdaptive()).length),a[t++]=i;else for(c=r[F=i-257],f[F]>0&&(c+=this.readBits(f[F])),n=d[i=this.readCodeByTable(o)],h[i]>0&&(n+=this.readBits(h[i])),t+c>s&&(s=(a=this.expandBufferAdaptive()).length);c--;)a[t]=a[t++-n];for(;this.bitsbuflen>=8;)this.bitsbuflen-=8,this.ip--;this.op=t},ha.RawInflate.prototype.expandBufferBlock=function(e){var o=new Uint8Array(this.op-ha.RawInflate.MaxBackwardLength),a=this.op-ha.RawInflate.MaxBackwardLength,t=this.output;return o.set(t.subarray(ha.RawInflate.MaxBackwardLength,o.length)),this.blocks.push(o),this.totalpos+=o.length,t.set(t.subarray(a,a+ha.RawInflate.MaxBackwardLength)),this.op=ha.RawInflate.MaxBackwardLength,t},ha.RawInflate.prototype.expandBufferAdaptive=function(e){var o,a,t,i=this.input.length/this.ip+1|0,F=this.input,n=this.output;return e&&("number"==typeof e.fixRatio&&(i=e.fixRatio),"number"==typeof e.addRatio&&(i+=e.addRatio)),a=i<2?(t=(F.length-this.ip)/this.currentLitlenTable[2]/2*258|0)<n.length?n.length+t:n.length<<1:n.length*i,(o=new Uint8Array(a)).set(n),this.output=o,this.output},ha.RawInflate.prototype.concatBufferBlock=function(){var e,o,a,t,i,F=0,n=this.totalpos+(this.op-ha.RawInflate.MaxBackwardLength),c=this.output,s=this.blocks,r=new Uint8Array(n);if(0===s.length)return this.output.subarray(ha.RawInflate.MaxBackwardLength,this.op);for(o=0,a=s.length;o<a;++o)for(t=0,i=(e=s[o]).length;t<i;++t)r[F++]=e[t];for(o=ha.RawInflate.MaxBackwardLength,a=this.op;o<a;++o)r[F++]=c[o];return this.blocks=[],this.buffer=r,this.buffer},ha.RawInflate.prototype.concatBufferDynamic=function(){var e,o=this.op;return this.resize?(e=new Uint8Array(o)).set(this.output.subarray(0,o)):e=this.output.subarray(0,o),this.buffer=e,this.buffer};var la;wa=ha.Huffman.buildHuffmanTable;ha.RawInflateStream=function(e,o,a){this.blocks=[],this.bufferSize=a||ZLIB_STREAM_RAW_INFLATE_BUFFER_SIZE,this.totalpos=0,this.ip=void 0===o?0:o,this.bitsbuf=0,this.bitsbuflen=0,this.input=new Uint8Array(e),this.output=new Uint8Array(this.bufferSize),this.op=0,this.bfinal=!1,this.blockLength,this.resize=!1,this.litlenTable,this.distTable,this.sp=0,this.status=ha.RawInflateStream.Status.INITIALIZED,this.ip_,this.bitsbuflen_,this.bitsbuf_},ha.RawInflateStream.BlockType={UNCOMPRESSED:0,FIXED:1,DYNAMIC:2},ha.RawInflateStream.Status={INITIALIZED:0,BLOCK_HEADER_START:1,BLOCK_HEADER_END:2,BLOCK_BODY_START:3,BLOCK_BODY_END:4,DECODE_BLOCK_START:5,DECODE_BLOCK_END:6},ha.RawInflateStream.prototype.decompress=function(e,o){var a=!1;for(void 0!==e&&(this.input=e),void 0!==o&&(this.ip=o);!a;)switch(this.status){case ha.RawInflateStream.Status.INITIALIZED:case ha.RawInflateStream.Status.BLOCK_HEADER_START:this.readBlockHeader()<0&&(a=!0);break;case ha.RawInflateStream.Status.BLOCK_HEADER_END:case ha.RawInflateStream.Status.BLOCK_BODY_START:switch(this.currentBlockType){case ha.RawInflateStream.BlockType.UNCOMPRESSED:this.readUncompressedBlockHeader()<0&&(a=!0);break;case ha.RawInflateStream.BlockType.FIXED:this.parseFixedHuffmanBlock()<0&&(a=!0);break;case ha.RawInflateStream.BlockType.DYNAMIC:this.parseDynamicHuffmanBlock()<0&&(a=!0)}break;case ha.RawInflateStream.Status.BLOCK_BODY_END:case ha.RawInflateStream.Status.DECODE_BLOCK_START:switch(this.currentBlockType){case ha.RawInflateStream.BlockType.UNCOMPRESSED:this.parseUncompressedBlock()<0&&(a=!0);break;case ha.RawInflateStream.BlockType.FIXED:case ha.RawInflateStream.BlockType.DYNAMIC:this.decodeHuffman()<0&&(a=!0)}break;case ha.RawInflateStream.Status.DECODE_BLOCK_END:this.bfinal?a=!0:this.status=ha.RawInflateStream.Status.INITIALIZED}return this.concatBuffer()},ha.RawInflateStream.MaxBackwardLength=32768,ha.RawInflateStream.MaxCopyLength=258,ha.RawInflateStream.Order=new Uint16Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ha.RawInflateStream.LengthCodeTable=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258]),ha.RawInflateStream.LengthExtraTable=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0]),ha.RawInflateStream.DistCodeTable=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577]),ha.RawInflateStream.DistExtraTable=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),ha.RawInflateStream.FixedLiteralLengthTable=function(){var e,o,a=new Uint8Array(288);for(e=0,o=a.length;e<o;++e)a[e]=e<=143?8:e<=255?9:e<=279?7:8;return wa(a)}(),ha.RawInflateStream.FixedDistanceTable=function(){var e,o,a=new Uint8Array(30);for(e=0,o=a.length;e<o;++e)a[e]=5;return wa(a)}(),ha.RawInflateStream.prototype.readBlockHeader=function(){var e;if(this.status=ha.RawInflateStream.Status.BLOCK_HEADER_START,this.save_(),(e=this.readBits(3))<0)return this.restore_(),-1;switch(1&e&&(this.bfinal=!0),e>>>=1){case 0:this.currentBlockType=ha.RawInflateStream.BlockType.UNCOMPRESSED;break;case 1:this.currentBlockType=ha.RawInflateStream.BlockType.FIXED;break;case 2:this.currentBlockType=ha.RawInflateStream.BlockType.DYNAMIC;break;default:throw new Error("unknown BTYPE: "+e)}this.status=ha.RawInflateStream.Status.BLOCK_HEADER_END},ha.RawInflateStream.prototype.readBits=function(e){for(var o,a=this.bitsbuf,t=this.bitsbuflen,i=this.input,F=this.ip;t<e;){if(i.length<=F)return-1;a|=(o=i[F++])<<t,t+=8}return o=a&(1<<e)-1,a>>>=e,t-=e,this.bitsbuf=a,this.bitsbuflen=t,this.ip=F,o},ha.RawInflateStream.prototype.readCodeByTable=function(e){for(var o,a,t=this.bitsbuf,i=this.bitsbuflen,F=this.input,n=this.ip,c=e[0],s=e[1];i<s;){if(F.length<=n)return-1;t|=F[n++]<<i,i+=8}if((a=(o=c[t&(1<<s)-1])>>>16)>i)throw new Error("invalid code length: "+a);return this.bitsbuf=t>>a,this.bitsbuflen=i-a,this.ip=n,65535&o},ha.RawInflateStream.prototype.readUncompressedBlockHeader=function(){var e,o=this.input,a=this.ip;if(this.status=ha.RawInflateStream.Status.BLOCK_BODY_START,a+4>=o.length)return-1;if((e=o[a++]|o[a++]<<8)===~(o[a++]|o[a++]<<8))throw new Error("invalid uncompressed block header: length verify");this.bitsbuf=0,this.bitsbuflen=0,this.ip=a,this.blockLength=e,this.status=ha.RawInflateStream.Status.BLOCK_BODY_END},ha.RawInflateStream.prototype.parseUncompressedBlock=function(){var e=this.input,o=this.ip,a=this.output,t=this.op,i=this.blockLength;for(this.status=ha.RawInflateStream.Status.DECODE_BLOCK_START;i--;){if(t===a.length&&(a=this.expandBuffer({fixRatio:2})),o>=e.length)return this.ip=o,this.op=t,this.blockLength=i+1,-1;a[t++]=e[o++]}return i<0&&(this.status=ha.RawInflateStream.Status.DECODE_BLOCK_END),this.ip=o,this.op=t,0},ha.RawInflateStream.prototype.parseFixedHuffmanBlock=function(){return this.status=ha.RawInflateStream.Status.BLOCK_BODY_START,this.litlenTable=ha.RawInflateStream.FixedLiteralLengthTable,this.distTable=ha.RawInflateStream.FixedDistanceTable,this.status=ha.RawInflateStream.Status.BLOCK_BODY_END,0},ha.RawInflateStream.prototype.save_=function(){this.ip_=this.ip,this.bitsbuflen_=this.bitsbuflen,this.bitsbuf_=this.bitsbuf},ha.RawInflateStream.prototype.restore_=function(){this.ip=this.ip_,this.bitsbuflen=this.bitsbuflen_,this.bitsbuf=this.bitsbuf_},ha.RawInflateStream.prototype.parseDynamicHuffmanBlock=function(){var e,o,a,t,i=new Uint8Array(ha.RawInflateStream.Order.length);if(this.status=ha.RawInflateStream.Status.BLOCK_BODY_START,this.save_(),e=this.readBits(5)+257,o=this.readBits(5)+1,a=this.readBits(4)+4,e<0||o<0||a<0)return this.restore_(),-1;try{(function(){var F,n,c,s,r,f,d=0;for(r=0;r<a;++r){if((F=this.readBits(3))<0)throw new Error("not enough input");i[ha.RawInflateStream.Order[r]]=F}for(t=wa(i),s=new Uint8Array(e+o),r=0,f=e+o;r<f;){if((n=this.readCodeByTable(t))<0)throw new Error("not enough input");switch(n){case 16:if((F=this.readBits(2))<0)throw new Error("not enough input");for(c=3+F;c--;)s[r++]=d;break;case 17:if((F=this.readBits(3))<0)throw new Error("not enough input");for(c=3+F;c--;)s[r++]=0;d=0;break;case 18:if((F=this.readBits(7))<0)throw new Error("not enough input");for(c=11+F;c--;)s[r++]=0;d=0;break;default:s[r++]=n,d=n}}this.litlenTable=wa(s.subarray(0,e)),this.distTable=wa(s.subarray(e))}).call(this)}catch(e){return this.restore_(),-1}return this.status=ha.RawInflateStream.Status.BLOCK_BODY_END,0},ha.RawInflateStream.prototype.decodeHuffman=function(){var e,o,a,t,i,F=this.output,n=this.op,c=this.litlenTable,s=this.distTable,r=F.length;for(this.status=ha.RawInflateStream.Status.DECODE_BLOCK_START;;){if(this.save_(),(e=this.readCodeByTable(c))<0)return this.op=n,this.restore_(),-1;if(256===e)break;if(e<256)n===r&&(r=(F=this.expandBuffer()).length),F[n++]=e;else{if(o=e-257,t=ha.RawInflateStream.LengthCodeTable[o],ha.RawInflateStream.LengthExtraTable[o]>0){if((i=this.readBits(ha.RawInflateStream.LengthExtraTable[o]))<0)return this.op=n,this.restore_(),-1;t+=i}if((e=this.readCodeByTable(s))<0)return this.op=n,this.restore_(),-1;if(a=ha.RawInflateStream.DistCodeTable[e],ha.RawInflateStream.DistExtraTable[e]>0){if((i=this.readBits(ha.RawInflateStream.DistExtraTable[e]))<0)return this.op=n,this.restore_(),-1;a+=i}for(n+t>=r&&(r=(F=this.expandBuffer()).length);t--;)F[n]=F[n++-a];if(this.ip===this.input.length)return this.op=n,-1}}for(;this.bitsbuflen>=8;)this.bitsbuflen-=8,this.ip--;this.op=n,this.status=ha.RawInflateStream.Status.DECODE_BLOCK_END},ha.RawInflateStream.prototype.expandBuffer=function(e){var o,a,t,i=this.input.length/this.ip+1|0,F=this.input,n=this.output;return e&&("number"==typeof e.fixRatio&&(i=e.fixRatio),"number"==typeof e.addRatio&&(i+=e.addRatio)),a=i<2?(t=(F.length-this.ip)/this.litlenTable[2]/2*258|0)<n.length?n.length+t:n.length<<1:n.length*i,(o=new Uint8Array(a)).set(n),this.output=o,this.output},ha.RawInflateStream.prototype.concatBuffer=function(){var e,o,a=this.op;return e=this.resize?new Uint8Array(this.output.subarray(this.sp,a)):this.output.subarray(this.sp,a),this.sp=a,a>ha.RawInflateStream.MaxBackwardLength+this.bufferSize&&(this.op=this.sp=ha.RawInflateStream.MaxBackwardLength,o=this.output,this.output=new Uint8Array(this.bufferSize+ha.RawInflateStream.MaxBackwardLength),this.output.set(o.subarray(a-ha.RawInflateStream.MaxBackwardLength,a))),e},ha.Inflate=function(e,o){var a,t;if(this.input=e,this.ip=0,this.rawinflate,this.verify,!o&&(o={})||(o.index&&(this.ip=o.index),o.verify&&(this.verify=o.verify)),a=e[this.ip++],t=e[this.ip++],(15&a)!==ha.CompressionMethod.DEFLATE)throw new Error("unsupported compression method");if(this.method=ha.CompressionMethod.DEFLATE,((a<<8)+t)%31!=0)throw new Error("invalid fcheck flag:"+((a<<8)+t)%31);if(32&t)throw new Error("fdict flag is not supported");this.rawinflate=new ha.RawInflate(e,{index:this.ip,bufferSize:o.bufferSize,bufferType:o.bufferType,resize:o.resize})},ha.Inflate.BufferType=ha.RawInflate.BufferType,ha.Inflate.prototype.decompress=function(){var e,o=this.input;if(e=this.rawinflate.decompress(),this.ip=this.rawinflate.ip,this.verify&&(o[this.ip++]<<24|o[this.ip++]<<16|o[this.ip++]<<8|o[this.ip++])>>>0!==ha.Adler32(e))throw new Error("invalid adler-32 checksum");return e},ha.InflateStream=function(e){this.input=void 0===e?new Uint8Array:e,this.ip=0,this.rawinflate=new ha.RawInflateStream(this.input,this.ip),this.method,this.output=this.rawinflate.output},ha.InflateStream.prototype.decompress=function(e){var o;if(void 0!==e){var a=new Uint8Array(this.input.length+e.length);a.set(this.input,0),a.set(e,this.input.length),this.input=a}return void 0===this.method&&this.readHeader()<0?new Uint8Array:(o=this.rawinflate.decompress(this.input,this.ip),0!==this.rawinflate.ip&&(this.input=this.input.subarray(this.rawinflate.ip),this.ip=0),o)},ha.InflateStream.prototype.readHeader=function(){var e=this.ip,o=this.input,a=o[e++],t=o[e++];if(void 0===a||void 0===t)return-1;if((15&a)!==ha.CompressionMethod.DEFLATE)throw new Error("unsupported compression method");if(this.method=ha.CompressionMethod.DEFLATE,((a<<8)+t)%31!=0)throw new Error("invalid fcheck flag:"+((a<<8)+t)%31);if(32&t)throw new Error("fdict flag is not supported");this.ip=e},ha.Gunzip=function(e,o){this.input=e,this.ip=0,this.member=[],this.decompressed=!1},ha.Gunzip.prototype.getMembers=function(){return this.decompressed||this.decompress(),this.member.slice()},ha.Gunzip.prototype.decompress=function(){for(var e=this.input.length;this.ip<e;)this.decodeMember();return this.decompressed=!0,this.concatMember()},ha.Gunzip.prototype.decodeMember=function(){var e,o,a,t,i,F,n,c,s,r=new ha.GunzipMember,f=this.input,d=this.ip;if(r.id1=f[d++],r.id2=f[d++],31!==r.id1||139!==r.id2)throw new Error("invalid file signature:"+r.id1+","+r.id2);if(r.cm=f[d++],8!==r.cm)throw new Error("unknown compression method: "+r.cm);if(r.flg=f[d++],c=f[d++]|f[d++]<<8|f[d++]<<16|f[d++]<<24,r.mtime=new Date(1e3*c),r.xfl=f[d++],r.os=f[d++],(r.flg&ha.Gzip.FlagsMask.FEXTRA)>0&&(r.xlen=f[d++]|f[d++]<<8,d=this.decodeSubField(d,r.xlen)),(r.flg&ha.Gzip.FlagsMask.FNAME)>0){for(n=[],F=0;(i=f[d++])>0;)n[F++]=String.fromCharCode(i);r.name=n.join("")}if((r.flg&ha.Gzip.FlagsMask.FCOMMENT)>0){for(n=[],F=0;(i=f[d++])>0;)n[F++]=String.fromCharCode(i);r.comment=n.join("")}if((r.flg&ha.Gzip.FlagsMask.FHCRC)>0&&(r.crc16=65535&ha.CRC32.calc(f,0,d),r.crc16!==(f[d++]|f[d++]<<8)))throw new Error("invalid header crc16");if(e=f[f.length-4]|f[f.length-3]<<8|f[f.length-2]<<16|f[f.length-1]<<24,f.length-d-4-4<512*e&&(t=e),o=new ha.RawInflate(f,{index:d,bufferSize:t}),r.data=a=o.decompress(),d=o.ip,r.crc32=s=(f[d++]|f[d++]<<8|f[d++]<<16|f[d++]<<24)>>>0,ha.CRC32.calc(a)!==s)throw new Error("invalid CRC-32 checksum: 0x"+ha.CRC32.calc(a).toString(16)+" / 0x"+s.toString(16));if(r.isize=e=(f[d++]|f[d++]<<8|f[d++]<<16|f[d++]<<24)>>>0,(4294967295&a.length)!==e)throw new Error("invalid input size: "+(4294967295&a.length)+" / "+e);this.member.push(r),this.ip=d},ha.Gunzip.prototype.decodeSubField=function(e,o){return e+o},ha.Gunzip.prototype.concatMember=function(){var e,o,a,t=this.member,i=0,F=0;for(e=0,o=t.length;e<o;++e)F+=t[e].data.length;for(a=new Uint8Array(F),e=0;e<o;++e)a.set(t[e].data,i),i+=t[e].data.length;return a},ha.GunzipMember=function(){this.id1,this.id2,this.cm,this.flg,this.mtime,this.xfl,this.os,this.crc16,this.xlen,this.crc32,this.isize,this.name,this.comment,this.data},ha.GunzipMember.prototype.getName=function(){return this.name},ha.GunzipMember.prototype.getData=function(){return this.data},ha.GunzipMember.prototype.getMtime=function(){return this.mtime},ha.Gzip=function(e,o){this.input=e,this.ip=0,this.output,this.op=0,this.flags={},this.filename,this.comment,this.deflateOptions,o&&(o.flags&&(this.flags=o.flags),"string"==typeof o.filename&&(this.filename=o.filename),"string"==typeof o.comment&&(this.comment=o.comment),o.deflateOptions&&(this.deflateOptions=o.deflateOptions)),this.deflateOptions||(this.deflateOptions={})},ha.Gzip.DefaultBufferSize=32768,ha.Gzip.prototype.compress=function(){var e,o,a,t,i,F,n,c,s=new Uint8Array(ha.Gzip.DefaultBufferSize),r=0,f=this.input,d=this.ip,h=this.filename,w=this.comment;if(s[r++]=31,s[r++]=139,s[r++]=8,e=0,this.flags.fname&&(e|=ha.Gzip.FlagsMask.FNAME),this.flags.fcomment&&(e|=ha.Gzip.FlagsMask.FCOMMENT),this.flags.fhcrc&&(e|=ha.Gzip.FlagsMask.FHCRC),s[r++]=e,o=(Date.now?Date.now():+new Date)/1e3|0,s[r++]=255&o,s[r++]=o>>>8&255,s[r++]=o>>>16&255,s[r++]=o>>>24&255,s[r++]=0,s[r++]=ha.Gzip.OperatingSystem.UNKNOWN,void 0!==this.flags.fname){for(n=0,c=h.length;n<c;++n)(F=h.charCodeAt(n))>255&&(s[r++]=F>>>8&255),s[r++]=255&F;s[r++]=0}if(this.flags.comment){for(n=0,c=w.length;n<c;++n)(F=w.charCodeAt(n))>255&&(s[r++]=F>>>8&255),s[r++]=255&F;s[r++]=0}return this.flags.fhcrc&&(a=65535&ha.CRC32.calc(s,0,r),s[r++]=255&a,s[r++]=a>>>8&255),this.deflateOptions.outputBuffer=s,this.deflateOptions.outputIndex=r,s=(i=new ha.RawDeflate(f,this.deflateOptions)).compress(),(r=i.op)+8>s.buffer.byteLength?(this.output=new Uint8Array(r+8),this.output.set(new Uint8Array(s.buffer)),s=this.output):s=new Uint8Array(s.buffer),t=ha.CRC32.calc(f),s[r++]=255&t,s[r++]=t>>>8&255,s[r++]=t>>>16&255,s[r++]=t>>>24&255,c=f.length,s[r++]=255&c,s[r++]=c>>>8&255,s[r++]=c>>>16&255,s[r++]=c>>>24&255,this.ip=d,r<s.length&&(this.output=s=s.subarray(0,r)),s},ha.Gzip.OperatingSystem={FAT:0,AMIGA:1,VMS:2,UNIX:3,VM_CMS:4,ATARI_TOS:5,HPFS:6,MACINTOSH:7,Z_SYSTEM:8,CP_M:9,TOPS_20:10,NTFS:11,QDOS:12,ACORN_RISCOS:13,UNKNOWN:255},ha.Gzip.FlagsMask={FTEXT:1,FHCRC:2,FEXTRA:4,FNAME:8,FCOMMENT:16},ha.Heap=function(e){this.buffer=new Uint16Array(2*e),this.length=0},ha.Heap.prototype.getParent=function(e){return 2*((e-2)/4|0)},ha.Heap.prototype.getChild=function(e){return 2*e+2},ha.Heap.prototype.push=function(e,o){var a,t,i,F=this.buffer;for(a=this.length,F[this.length++]=o,F[this.length++]=e;a>0&&(t=this.getParent(a),F[a]>F[t]);)i=F[a],F[a]=F[t],F[t]=i,i=F[a+1],F[a+1]=F[t+1],F[t+1]=i,a=t;return this.length},ha.Heap.prototype.pop=function(){var e,o,a,t,i,F=this.buffer;for(o=F[0],e=F[1],this.length-=2,F[0]=F[this.length],F[1]=F[this.length+1],i=0;!((t=this.getChild(i))>=this.length)&&(t+2<this.length&&F[t+2]>F[t]&&(t+=2),F[t]>F[i]);)a=F[i],F[i]=F[t],F[t]=a,a=F[i+1],F[i+1]=F[t+1],F[t+1]=a,i=t;return{index:e,value:o,length:this.length}},ha.RawDeflate=function(e,o){this.compressionType=ha.RawDeflate.CompressionType.DYNAMIC,this.lazy=0,this.freqsLitLen,this.freqsDist,this.input=e instanceof Array?new Uint8Array(e):e,this.output,this.op=0,o&&(o.lazy&&(this.lazy=o.lazy),"number"==typeof o.compressionType&&(this.compressionType=o.compressionType),o.outputBuffer&&(this.output=o.outputBuffer instanceof Array?new Uint8Array(o.outputBuffer):o.outputBuffer),"number"==typeof o.outputIndex&&(this.op=o.outputIndex)),this.output||(this.output=new Uint8Array(32768))},ha.RawDeflate.CompressionType={NONE:0,FIXED:1,DYNAMIC:2,RESERVED:3},ha.RawDeflate.Lz77MinLength=3,ha.RawDeflate.Lz77MaxLength=258,ha.RawDeflate.WindowSize=32768,ha.RawDeflate.MaxCodeLength=16,ha.RawDeflate.HUFMAX=286,ha.RawDeflate.FixedHuffmanTable=function(){var e,o=[];for(e=0;e<288;e++)switch(!0){case e<=143:o.push([e+48,8]);break;case e<=255:o.push([e-144+400,9]);break;case e<=279:o.push([e-256+0,7]);break;case e<=287:o.push([e-280+192,8]);break;default:throw"invalid literal: "+e}return o}(),ha.RawDeflate.prototype.compress=function(){var e,o,a,t=this.input;switch(this.compressionType){case ha.RawDeflate.CompressionType.NONE:for(o=0,a=t.length;o<a;)o+=(e=t.subarray(o,o+65535)).length,this.makeNocompressBlock(e,o===a);break;case ha.RawDeflate.CompressionType.FIXED:this.output=this.makeFixedHuffmanBlock(t,!0),this.op=this.output.length;break;case ha.RawDeflate.CompressionType.DYNAMIC:this.output=this.makeDynamicHuffmanBlock(t,!0),this.op=this.output.length;break;default:throw"invalid compression type"}return this.output},ha.RawDeflate.prototype.makeNocompressBlock=function(e,o){var a,t,i,F,n=this.output,c=this.op;for(n=new Uint8Array(this.output.buffer);n.length<=c+e.length+5;)n=new Uint8Array(n.length<<1);return n.set(this.output),a=o?1:0,t=ha.RawDeflate.CompressionType.NONE,n[c++]=a|t<<1,F=65536+~(i=e.length)&65535,n[c++]=255&i,n[c++]=i>>>8&255,n[c++]=255&F,n[c++]=F>>>8&255,n.set(e,c),c+=e.length,n=n.subarray(0,c),this.op=c,this.output=n,n},ha.RawDeflate.prototype.makeFixedHuffmanBlock=function(e,o){var a,t,i,F=new ha.BitStream(new Uint8Array(this.output.buffer),this.op);return a=o?1:0,t=ha.RawDeflate.CompressionType.FIXED,F.writeBits(a,1,!0),F.writeBits(t,2,!0),i=this.lz77(e),this.fixedHuffman(i,F),F.finish()},ha.RawDeflate.prototype.makeDynamicHuffmanBlock=function(e,o){var a,t,i,F,n,c,s,r,f,d,h,w,l,p,u,m,b,N=new ha.BitStream(new Uint8Array(this.output.buffer),this.op),C=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],g=new Array(19);for(a=o?1:0,t=ha.RawDeflate.CompressionType.DYNAMIC,N.writeBits(a,1,!0),N.writeBits(t,2,!0),i=this.lz77(e),s=this.getLengths_(this.freqsLitLen,15),r=this.getCodesFromLengths_(s),f=this.getLengths_(this.freqsDist,7),d=this.getCodesFromLengths_(f),F=286;F>257&&0===s[F-1];F--);for(n=30;n>1&&0===f[n-1];n--);for(h=this.getTreeSymbols_(F,s,n,f),w=this.getLengths_(h.freqs,7),m=0;m<19;m++)g[m]=w[C[m]];for(c=19;c>4&&0===g[c-1];c--);for(l=this.getCodesFromLengths_(w),N.writeBits(F-257,5,!0),N.writeBits(n-1,5,!0),N.writeBits(c-4,4,!0),m=0;m<c;m++)N.writeBits(g[m],3,!0);for(m=0,b=h.codes.length;m<b;m++)if(p=h.codes[m],N.writeBits(l[p],w[p],!0),p>=16){switch(m++,p){case 16:u=2;break;case 17:u=3;break;case 18:u=7;break;default:throw"invalid code: "+p}N.writeBits(h.codes[m],u,!0)}return this.dynamicHuffman(i,[r,s],[d,f],N),N.finish()},ha.RawDeflate.prototype.dynamicHuffman=function(e,o,a,t){var i,F,n,c,s,r,f,d;for(s=o[0],r=o[1],f=a[0],d=a[1],i=0,F=e.length;i<F;++i)if(n=e[i],t.writeBits(s[n],r[n],!0),n>256)t.writeBits(e[++i],e[++i],!0),c=e[++i],t.writeBits(f[c],d[c],!0),t.writeBits(e[++i],e[++i],!0);else if(256===n)break;return t},ha.RawDeflate.prototype.fixedHuffman=function(e,o){var a,t,i;for(a=0,t=e.length;a<t;a++)if(i=e[a],ha.BitStream.prototype.writeBits.apply(o,ha.RawDeflate.FixedHuffmanTable[i]),i>256)o.writeBits(e[++a],e[++a],!0),o.writeBits(e[++a],5),o.writeBits(e[++a],e[++a],!0);else if(256===i)break;return o},ha.RawDeflate.Lz77Match=function(e,o){this.length=e,this.backwardDistance=o},ha.RawDeflate.Lz77Match.LengthCodeTable=(la=function(){var e,o,a=[];for(e=3;e<=258;e++)o=t(e),a[e]=o[2]<<24|o[1]<<16|o[0];function t(e){switch(!0){case 3===e:return[257,e-3,0];case 4===e:return[258,e-4,0];case 5===e:return[259,e-5,0];case 6===e:return[260,e-6,0];case 7===e:return[261,e-7,0];case 8===e:return[262,e-8,0];case 9===e:return[263,e-9,0];case 10===e:return[264,e-10,0];case e<=12:return[265,e-11,1];case e<=14:return[266,e-13,1];case e<=16:return[267,e-15,1];case e<=18:return[268,e-17,1];case e<=22:return[269,e-19,2];case e<=26:return[270,e-23,2];case e<=30:return[271,e-27,2];case e<=34:return[272,e-31,2];case e<=42:return[273,e-35,3];case e<=50:return[274,e-43,3];case e<=58:return[275,e-51,3];case e<=66:return[276,e-59,3];case e<=82:return[277,e-67,4];case e<=98:return[278,e-83,4];case e<=114:return[279,e-99,4];case e<=130:return[280,e-115,4];case e<=162:return[281,e-131,5];case e<=194:return[282,e-163,5];case e<=226:return[283,e-195,5];case e<=257:return[284,e-227,5];case 258===e:return[285,e-258,0];default:throw"invalid length: "+e}}return a}(),new Uint32Array(la)),ha.RawDeflate.Lz77Match.prototype.getDistanceCode_=function(e){var o;switch(!0){case 1===e:o=[0,e-1,0];break;case 2===e:o=[1,e-2,0];break;case 3===e:o=[2,e-3,0];break;case 4===e:o=[3,e-4,0];break;case e<=6:o=[4,e-5,1];break;case e<=8:o=[5,e-7,1];break;case e<=12:o=[6,e-9,2];break;case e<=16:o=[7,e-13,2];break;case e<=24:o=[8,e-17,3];break;case e<=32:o=[9,e-25,3];break;case e<=48:o=[10,e-33,4];break;case e<=64:o=[11,e-49,4];break;case e<=96:o=[12,e-65,5];break;case e<=128:o=[13,e-97,5];break;case e<=192:o=[14,e-129,6];break;case e<=256:o=[15,e-193,6];break;case e<=384:o=[16,e-257,7];break;case e<=512:o=[17,e-385,7];break;case e<=768:o=[18,e-513,8];break;case e<=1024:o=[19,e-769,8];break;case e<=1536:o=[20,e-1025,9];break;case e<=2048:o=[21,e-1537,9];break;case e<=3072:o=[22,e-2049,10];break;case e<=4096:o=[23,e-3073,10];break;case e<=6144:o=[24,e-4097,11];break;case e<=8192:o=[25,e-6145,11];break;case e<=12288:o=[26,e-8193,12];break;case e<=16384:o=[27,e-12289,12];break;case e<=24576:o=[28,e-16385,13];break;case e<=32768:o=[29,e-24577,13];break;default:throw"invalid distance"}return o},ha.RawDeflate.Lz77Match.prototype.toLz77Array=function(){var e,o=this.length,a=this.backwardDistance,t=[],i=0;return e=ha.RawDeflate.Lz77Match.LengthCodeTable[o],t[i++]=65535&e,t[i++]=e>>16&255,t[i++]=e>>24,e=this.getDistanceCode_(a),t[i++]=e[0],t[i++]=e[1],t[i++]=e[2],t},ha.RawDeflate.prototype.lz77=function(e){var o,a,t,i,F,n,c,s,r,f={},d=ha.RawDeflate.WindowSize,h=new Uint16Array(2*e.length),w=0,l=0,p=new Uint32Array(286),u=new Uint32Array(30),m=this.lazy;function b(e,o){var a,t,i=e.toLz77Array();for(a=0,t=i.length;a<t;++a)h[w++]=i[a];p[i[0]]++,u[i[3]]++,l=e.length+o-1,s=null}for(p[256]=1,o=0,a=e.length;o<a;++o){for(F=0,t=0,i=ha.RawDeflate.Lz77MinLength;t<i&&o+t!==a;++t)F=F<<8|e[o+t];if(void 0===f[F]&&(f[F]=[]),n=f[F],l-- >0)n.push(o);else{for(;n.length>0&&o-n[0]>d;)n.shift();if(o+ha.RawDeflate.Lz77MinLength>=a){for(s&&b(s,-1),t=0,i=a-o;t<i;++t)r=e[o+t],h[w++]=r,++p[r];break}n.length>0?(c=this.searchLongestMatch_(e,o,n),s?s.length<c.length?(r=e[o-1],h[w++]=r,++p[r],b(c,0)):b(s,-1):c.length<m?s=c:b(c,0)):s?b(s,-1):(r=e[o],h[w++]=r,++p[r]),n.push(o)}}return h[w++]=256,p[256]++,this.freqsLitLen=p,this.freqsDist=u,h.subarray(0,w)},ha.RawDeflate.prototype.searchLongestMatch_=function(e,o,a){var t,i,F,n,c,s,r=0,f=e.length;e:for(n=0,s=a.length;n<s;n++){if(t=a[s-n-1],F=ha.RawDeflate.Lz77MinLength,r>ha.RawDeflate.Lz77MinLength){for(c=r;c>ha.RawDeflate.Lz77MinLength;c--)if(e[t+c-1]!==e[o+c-1])continue e;F=r}for(;F<ha.RawDeflate.Lz77MaxLength&&o+F<f&&e[t+F]===e[o+F];)++F;if(F>r&&(i=t,r=F),F===ha.RawDeflate.Lz77MaxLength)break}return new ha.RawDeflate.Lz77Match(r,o-i)},ha.RawDeflate.prototype.getTreeSymbols_=function(e,o,a,t){var i,F,n,c,s,r,f=new Uint32Array(e+a),d=new Uint32Array(316),h=new Uint8Array(19);for(F=0,i=0;i<e;i++)f[F++]=o[i];for(i=0;i<a;i++)f[F++]=t[i];for(s=0,i=0,c=f.length;i<c;i+=F){for(F=1;i+F<c&&f[i+F]===f[i];++F);if(n=F,0===f[i])if(n<3)for(;n-- >0;)d[s++]=0,h[0]++;else for(;n>0;)(r=n<138?n:138)>n-3&&r<n&&(r=n-3),r<=10?(d[s++]=17,d[s++]=r-3,h[17]++):(d[s++]=18,d[s++]=r-11,h[18]++),n-=r;else if(d[s++]=f[i],h[f[i]]++,--n<3)for(;n-- >0;)d[s++]=f[i],h[f[i]]++;else for(;n>0;)(r=n<6?n:6)>n-3&&r<n&&(r=n-3),d[s++]=16,d[s++]=r-3,h[16]++,n-=r}return{codes:d.subarray(0,s),freqs:h}},ha.RawDeflate.prototype.getLengths_=function(e,o){var a,t,i,F,n,c=e.length,s=new ha.Heap(2*ha.RawDeflate.HUFMAX),r=new Uint8Array(c);for(F=0;F<c;++F)e[F]>0&&s.push(F,e[F]);if(a=new Array(s.length/2),t=new Uint32Array(s.length/2),1===a.length)return r[s.pop().index]=1,r;for(F=0,n=s.length/2;F<n;++F)a[F]=s.pop(),t[F]=a[F].value;for(i=this.reversePackageMerge_(t,t.length,o),F=0,n=a.length;F<n;++F)r[a[F].index]=i[F];return r},ha.RawDeflate.prototype.reversePackageMerge_=function(e,o,a){var t,i,F,n,c,s=new Uint16Array(a),r=new Uint8Array(a),f=new Uint8Array(o),d=new Array(a),h=new Array(a),w=new Array(a),l=(1<<a)-o,p=1<<a-1;function u(e){var a=h[e][w[e]];a===o?(u(e+1),u(e+1)):--f[a],++w[e]}for(s[a-1]=o,i=0;i<a;++i)l<p?r[i]=0:(r[i]=1,l-=p),l<<=1,s[a-2-i]=(s[a-1-i]/2|0)+o;for(s[0]=r[0],d[0]=new Array(s[0]),h[0]=new Array(s[0]),i=1;i<a;++i)s[i]>2*s[i-1]+r[i]&&(s[i]=2*s[i-1]+r[i]),d[i]=new Array(s[i]),h[i]=new Array(s[i]);for(t=0;t<o;++t)f[t]=a;for(F=0;F<s[a-1];++F)d[a-1][F]=e[F],h[a-1][F]=F;for(t=0;t<a;++t)w[t]=0;for(1===r[a-1]&&(--f[0],++w[a-1]),i=a-2;i>=0;--i){for(t=0,n=0,c=w[i+1],F=0;F<s[i];F++)(n=d[i+1][c]+d[i+1][c+1])>e[t]?(d[i][F]=n,h[i][F]=o,c+=2):(d[i][F]=e[t],h[i][F]=t,++t);w[i]=0,1===r[i]&&u(i)}return f},ha.RawDeflate.prototype.getCodesFromLengths_=function(e){var o,a,t,i,F=new Uint16Array(e.length),n=[],c=[],s=0;for(o=0,a=e.length;o<a;o++)n[e[o]]=1+(0|n[e[o]]);for(o=1,a=ha.RawDeflate.MaxCodeLength;o<=a;o++)c[o]=s,s+=0|n[o],s<<=1;for(o=0,a=e.length;o<a;o++)for(s=c[e[o]],c[e[o]]+=1,F[o]=0,t=0,i=e[o];t<i;t++)F[o]=F[o]<<1|1&s,s>>>=1;return F},ha.Unzip=function(e,o){o=o||{},this.input=e instanceof Array?new Uint8Array(e):e,this.ip=0,this.eocdrOffset,this.numberOfThisDisk,this.startDisk,this.totalEntriesThisDisk,this.totalEntries,this.centralDirectorySize,this.centralDirectoryOffset,this.commentLength,this.comment,this.fileHeaderList,this.filenameToIndex,this.verify=o.verify||!1,this.password=o.password},ha.Unzip.CompressionMethod=ha.Zip.CompressionMethod,ha.Unzip.FileHeaderSignature=ha.Zip.FileHeaderSignature,ha.Unzip.LocalFileHeaderSignature=ha.Zip.LocalFileHeaderSignature,ha.Unzip.CentralDirectorySignature=ha.Zip.CentralDirectorySignature,ha.Unzip.FileHeader=function(e,o){this.input=e,this.offset=o,this.length,this.version,this.os,this.needVersion,this.flags,this.compression,this.time,this.date,this.crc32,this.compressedSize,this.plainSize,this.fileNameLength,this.extraFieldLength,this.fileCommentLength,this.diskNumberStart,this.internalFileAttributes,this.externalFileAttributes,this.relativeOffset,this.filename,this.extraField,this.comment},ha.Unzip.FileHeader.prototype.parse=function(){var e=this.input,o=this.offset;if(e[o++]!==ha.Unzip.FileHeaderSignature[0]||e[o++]!==ha.Unzip.FileHeaderSignature[1]||e[o++]!==ha.Unzip.FileHeaderSignature[2]||e[o++]!==ha.Unzip.FileHeaderSignature[3])throw new Error("invalid file header signature");this.version=e[o++],this.os=e[o++],this.needVersion=e[o++]|e[o++]<<8,this.flags=e[o++]|e[o++]<<8,this.compression=e[o++]|e[o++]<<8,this.time=e[o++]|e[o++]<<8,this.date=e[o++]|e[o++]<<8,this.crc32=(e[o++]|e[o++]<<8|e[o++]<<16|e[o++]<<24)>>>0,this.compressedSize=(e[o++]|e[o++]<<8|e[o++]<<16|e[o++]<<24)>>>0,this.plainSize=(e[o++]|e[o++]<<8|e[o++]<<16|e[o++]<<24)>>>0,this.fileNameLength=e[o++]|e[o++]<<8,this.extraFieldLength=e[o++]|e[o++]<<8,this.fileCommentLength=e[o++]|e[o++]<<8,this.diskNumberStart=e[o++]|e[o++]<<8,this.internalFileAttributes=e[o++]|e[o++]<<8,this.externalFileAttributes=e[o++]|e[o++]<<8|e[o++]<<16|e[o++]<<24,this.relativeOffset=(e[o++]|e[o++]<<8|e[o++]<<16|e[o++]<<24)>>>0,this.filename=String.fromCharCode.apply(null,e.subarray(o,o+=this.fileNameLength)),this.extraField=e.subarray(o,o+=this.extraFieldLength),this.comment=e.subarray(o,o+this.fileCommentLength),this.length=o-this.offset},ha.Unzip.LocalFileHeader=function(e,o){this.input=e,this.offset=o,this.length,this.needVersion,this.flags,this.compression,this.time,this.date,this.crc32,this.compressedSize,this.plainSize,this.fileNameLength,this.extraFieldLength,this.filename,this.extraField},ha.Unzip.LocalFileHeader.Flags=ha.Zip.Flags,ha.Unzip.LocalFileHeader.prototype.parse=function(){var e=this.input,o=this.offset;if(e[o++]!==ha.Unzip.LocalFileHeaderSignature[0]||e[o++]!==ha.Unzip.LocalFileHeaderSignature[1]||e[o++]!==ha.Unzip.LocalFileHeaderSignature[2]||e[o++]!==ha.Unzip.LocalFileHeaderSignature[3])throw new Error("invalid local file header signature");this.needVersion=e[o++]|e[o++]<<8,this.flags=e[o++]|e[o++]<<8,this.compression=e[o++]|e[o++]<<8,this.time=e[o++]|e[o++]<<8,this.date=e[o++]|e[o++]<<8,this.crc32=(e[o++]|e[o++]<<8|e[o++]<<16|e[o++]<<24)>>>0,this.compressedSize=(e[o++]|e[o++]<<8|e[o++]<<16|e[o++]<<24)>>>0,this.plainSize=(e[o++]|e[o++]<<8|e[o++]<<16|e[o++]<<24)>>>0,this.fileNameLength=e[o++]|e[o++]<<8,this.extraFieldLength=e[o++]|e[o++]<<8,this.filename=String.fromCharCode.apply(null,e.subarray(o,o+=this.fileNameLength)),this.extraField=e.subarray(o,o+=this.extraFieldLength),this.length=o-this.offset},ha.Unzip.prototype.searchEndOfCentralDirectoryRecord=function(){var e,o=this.input;for(e=o.length-12;e>0;--e)if(o[e]===ha.Unzip.CentralDirectorySignature[0]&&o[e+1]===ha.Unzip.CentralDirector