nekotsume-ime/lib/zip.min.js

21 lines
30 KiB
JavaScript
Raw Normal View History

(function(J){function A(){this.list=this.next=null}function C(){this.n=this.b=this.e=0;this.t=null}function n(a,d,i,c,b,q){this.BMAX=16;this.N_MAX=288;this.status=0;this.root=null;this.m=0;var t=new Uint32Array(this.BMAX+1),o,e,l,k,f,h,g,m=new Uint32Array(this.BMAX+1),r,n,y,v=new C,s=Array(this.BMAX);k=new Uint32Array(this.N_MAX);var w,p=new Uint32Array(this.BMAX+1),u,z,x;x=this.root=null;for(f=0;f<t.length;f++)t[f]=0;for(f=0;f<m.length;f++)m[f]=0;for(f=0;f<s.length;f++)s[f]=null;for(f=0;f<k.length;f++)k[f]=
0;for(f=0;f<p.length;f++)p[f]=0;o=256<d?a[256]:this.BMAX;r=a;n=0;f=d;do t[r[n]]++,n++;while(0<--f);if(t[0]==d)this.root=null,this.status=this.m=0;else{for(h=1;h<=this.BMAX&&0==t[h];h++);g=h;q<h&&(q=h);for(f=this.BMAX;0!=f&&0==t[f];f--);l=f;q>f&&(q=f);for(u=1<<h;h<f;h++,u<<=1)if(0>(u-=t[h])){this.status=2;this.m=q;return}if(0>(u-=t[f]))this.status=2,this.m=q;else{t[f]+=u;p[1]=h=0;r=t;n=1;for(y=2;0<--f;)p[y++]=h+=r[n++];r=a;f=n=0;do if(0!=(h=r[n++]))k[p[h]++]=f;while(++f<d);d=p[l];p[0]=f=0;r=k;n=0;
k=-1;w=m[0]=0;y=null;for(z=0;g<=l;g++)for(a=t[g];0<a--;){for(;g>w+m[1+k];){w+=m[1+k];k++;z=(z=l-w)>q?q:z;if((e=1<<(h=g-w))>a+1){e-=a+1;for(y=g;++h<z&&!((e<<=1)<=t[++y]);)e-=t[y]}w+h>o&&w<o&&(h=o-w);z=1<<h;m[1+k]=h;y=Array(z);for(e=0;e<z;e++)y[e]=new C;x=null==x?this.root=new A:x.next=new A;x.next=null;x.list=y;s[k]=y;0<k&&(p[k]=f,v.b=m[k],v.e=16+h,v.t=y,h=(f&(1<<w)-1)>>w-m[k],s[k-1][h].e=v.e,s[k-1][h].b=v.b,s[k-1][h].n=v.n,s[k-1][h].t=v.t)}v.b=g-w;n>=d?v.e=99:r[n]<i?(v.e=256>r[n]?16:15,v.n=r[n++]):
(v.e=b[r[n]-i],v.n=c[r[n++]-i]);e=1<<g-w;for(h=f>>w;h<z;h+=e)y[h].e=v.e,y[h].b=v.b,y[h].n=v.n,y[h].t=v.t;for(h=1<<g-1;0!=(f&h);h>>=1)f^=h;for(f^=h;(f&(1<<w)-1)!=p[k];)w-=m[k],k--}this.m=m[1];this.status=0!=u&&1!=l?1:0}}}function d(a){for(;D<a;){var d=F,i;i=K.length==N?-1:K[N++];F=d|i<<D;D+=8}}function g(a){return F&Z[a]}function l(a){F>>=a;D-=a}function L(a,n,i){var c,b,q;if(0==i)return 0;for(q=0;;){d(u);b=x.list[g(u)];for(c=b.e;16<c;){if(99==c)return-1;l(b.b);c-=16;d(c);b=b.t[g(c)];c=b.e}l(b.b);
if(16==c)m&=G-1,a[n+q++]=E[m++]=b.n;else{if(15==c)break;d(c);r=b.n+g(c);l(c);d(H);b=R.list[g(H)];for(c=b.e;16<c;){if(99==c)return-1;l(b.b);c-=16;d(c);b=b.t[g(c)];c=b.e}l(b.b);d(c);I=m-b.n-g(c);l(c);c=r;b=I;for(var t=G-1,o=m,e=a,p=E;0<c&&q<i;)--c,b&=t,o&=t,e[n+q]=p[o]=p[b],++q,++o,++b;r=c;I=b;m=o}if(q==i)return i}B=-1;return q}function a(a,r,i){var c,b,q,t,o,e,m,k=new Uint32Array(316);for(c=0;c<k.length;c++)k[c]=0;d(5);e=257+g(5);l(5);d(5);m=1+g(5);l(5);d(4);c=4+g(4);l(4);if(286<e||30<m)return-1;for(b=
0;b<c;b++)d(3),k[S[b]]=g(3),l(3);for(;19>b;b++)k[S[b]]=0;u=7;b=new n(k,19,19,null,null,u);if(0!=b.status)return-1;x=b.root;u=b.m;t=e+m;for(c=q=0;c<t;)if(d(u),o=x.list[g(u)],b=o.b,l(b),b=o.n,16>b)k[c++]=q=b;else if(16==b){d(2);b=3+g(2);l(2);if(c+b>t)return-1;for(;0<b--;)k[c++]=q}else{17==b?(d(3),b=3+g(3),l(3)):(d(7),b=11+g(7),l(7));if(c+b>t)return-1;for(;0<b--;)k[c++]=0;q=0}u=$;b=new n(k,e,257,T,U,u);0==u&&(b.status=1);if(0!=b.status)return-1;x=b.root;u=b.m;for(c=0;c<m;c++)k[c]=k[c+e];H=aa;b=new n(k,
m,0,V,W,H);R=b.root;H=b.m;return 0==H&&257<e||0!=b.status?-1:L(a,r,i)}function z(){null==E&&(E=new Uint8Array(2*G));D=F=m=0;B=-1;M=!1;r=I=0;x=null}function p(p,s,i){var c,b;for(c=0;c<i&&!(M&&-1==B);){if(0<r){if(B!=ba)for(;0<r&&c<i;)r--,I&=G-1,m&=G-1,p[s+c++]=E[m++]=E[I++];else{for(;0<r&&c<i;)r--,m&=G-1,d(8),p[s+c++]=E[m++]=g(8),l(8);0==r&&(B=-1)}if(c==i)break}if(-1==B){if(M)break;d(1);0!=g(1)&&(M=!0);l(1);d(2);B=g(2);l(2);x=null;r=0}switch(B){case 0:b=p;var q=s+c,t=i-c,o=void 0,o=D&7;l(o);d(16);o=
g(16);l(16);d(16);if(o!=(~F&65535))b=-1;else{l(16);r=o;for(o=0;0<r&&o<t;)r--,m&=G-1,d(8),b[q+o++]=E[m++]=g(8),l(8);0==r&&(B=-1);b=o}break;case 1:if(null!=x)b=L(p,s+c,i-c);else a:{b=p;q=s+c;t=i-c;if(null==O){for(var e=void 0,o=new Uint32Array(288),e=void 0,e=0;144>e;e++)o[e]=8;for(;256>e;e++)o[e]=9;for(;280>e;e++)o[e]=7;for(;288>e;e++)o[e]=8;P=7;e=new n(o,288,257,T,U,P);if(0!=e.status){alert("HufBuild error: "+e.status);b=-1;break a}O=e.root;P=e.m;for(e=0;30>e;e++)o[e]=5;zip_fixed_bd=5;e=new n(o,30,
0,V,W,zip_fixed_bd);if(1<e.status){O=null;alert("HufBuild error: "+e.status);b=-1;break a}X=e.root;zip_fixed_bd=e.m}x=O;R=X;u=P;H=zip_fixed_bd;b=L(b,q,t)}break;case 2:b=null!=x?L(p,s+c,i-c):a(p,s+c,i-c);break;default:b=-1}if(-1==b)return M?0:-1;c+=b}return c}function s(a,d){var i=p(d,0,d.length);if(0<i){var c="";for(j=0;j<i;j++)c+=String.fromCharCode(d[j]);a.write(c)}return i}var Y=0,G=32768,ba=0,$=9,aa=6,E,m,O=null,X,P,F,D,B,M,r,I,x,R,u,H,K,N,Z=new Uint16Array([0,1,3,7,15,31,63,127,255,511,1023,
2047,4095,8191,16383,32767,65535]),T=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),U=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,99,99]),V=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]),W=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]),S=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,
3,13,2,14,1,15]),Q={};if("object"==typeof module){module.exports=Q;var ca=require("fs")}else J.JSInflate=Q;Q.inflate=function(a,d){Y=0;var i,c,b,q=0;z();K=a;N=0;c=new Uint8Array(1024);for(i=new Uint8Array(d||1024);0<(b=p(c,0,c.length));){if(q+b>i.length){var g=new Uint8Array(2*i.length);g.set(i,0);i=g}i.set(c.subarray(0,b),q);q+=b}K=null;return i.subarray(0,q)};Q.inflateStream=function(a,d,i){var c,b;z();K=a;b=N=0;var g=ca.createWriteStream(d);c=new Uint8Array(1024);var p=0;g.on("drain",
function(){p=s(g,c);0<p?b+=p:(K=null,i(b))});b+=s(g,c)}})(this);
(function(){var J="\u3000\u3001\u3002\uff0c\uff0e\u30fb\uff1a\uff1b\uff1f\uff01\u309b\u309c\u00b4\uff40\u00a8\uff3e\uffe3\uff3f\u30fd\u30fe\u309d\u309e\u3003\u4edd\u3005\u3006\u3007\u30fc\u2015\u2010\uff0f\u301c\u2016\uff5c\u2026\u2025\u2018\u2019\u201c\u201d\uff08\uff09\u3014\u3015\uff3b\uff3d\uff5b\uff5d\u3008\u3009\u300a\u300b\u300c\u300d\u300e\u300f\u3010\u3011\uff0b\u2212\u00b1\u00d7 \u00f7\uff1d\u2260\uff1c\uff1e\u2266\u2267\u221e\u2234\u2642\u2640\u00b0\u2032\u2033\u2103\uffe5\uff04\u00a2\u00a3\uff05\uff03\uff06\uff0a\uff20\u00a7\u2606\u2605\u25cb\u25cf\u25ce\u25c7\u25c6\u25a1\u25a0\u25b3\u25b2\u25bd\u25bc\u203b\u3012\u2192\u2190\u2191\u2193\u3013~0b\u2208\u220b\u2286\u2287\u2282\u2283\u222a\u2229~08\u2227\u2228\u00ac\u21d2\u21d4\u2200\u2203~0b\u2220\u22a5\u2312\u2202\u2207\u2261\u2252\u226a\u226b\u221a\u223d\u221d\u2235\u222b\u222c~07\u212b\u2030\u266f\u266d\u266a\u2020\u2021\u00b6~04\u25ef~2a\uff10\uff11\uff12\uff13\uff14\uff15\uff16\uff17\uff18\uff19~07\uff21\uff22\uff23\uff24\uff25\uff26\uff27\uff28\uff29\uff2a\uff2b\uff2c\uff2d\uff2e\uff2f\uff30\uff31\uff32\uff33\uff34\uff35\uff36\uff37\uff38\uff39\uff3a~07\uff41\uff42\uff43\uff44\uff45\uff46\uff47\uff48\uff49\uff4a\uff4b\uff4c\uff4d\uff4e\uff4f\uff50\uff51\uff52\uff53\uff54\uff55\uff56\uff57\uff58\uff59\uff5a~04\u3041\u3042\u3043\u3044\u3045\u3046\u3047\u3048\u3049\u304a\u304b\u304c\u304d\u304e\u304f\u3050\u3051\u3052\u3053\u3054\u3055\u3056\u3057\u3058\u3059\u305a\u305b\u305c\u305d\u305e\u305f\u3060\u3061\u3062\u3063\u3064\u3065\u3066\u3067\u3068\u3069\u306a\u306b\u306c\u306d\u306e\u306f\u3070\u3071\u3072\u3073\u3074\u3075\u3076\u3077\u3078\u3079\u307a\u307b\u307c\u307d\u307e\u307f\u3080\u3081\u3082\u3083\u3084\u3085\u3086\u3087\u3088\u3089\u308a\u308b\u308c\u308d\u308e\u308f\u3090\u3091\u3092\u3093~26\u30a1\u30a2\u30a3\u30a4\u30a5\u30a6\u30a7\u30a8\u30a9\u30aa\u30ab\u30ac\u30ad\u30ae\u30af\u30b0\u30b1\u30b2\u30b3\u30b4\u30b5\u30b6\u30b7\u30b8\u30b9\u30ba\u30bb\u30bc\u30bd\u30be\u30bf\u30c0\u30c1\u30c2\u30c3\u30c4\u30c5\u30c6\u30c7\u30c8\u30c9\u30ca\u30cb\u30cc\u30cd\u30ce\u30cf\u30d0\u30d1\u30d2\u30d3\u30d4\u30d5\u30d6\u30d7\u30d8\u30d9\u30da\u30db\u30dc\u30dd\u30de\u30df \u30e0\u30e1\u30e2\u30e3\u30e4\u30e5\u30e6\u30e7\u30e8\u30e9\u30ea\u30eb\u30ec\u30ed\u30ee\u30ef\u30f0\u30f1\u30f2\u30f3\u30f4\u30f5\u30f6~08\u0391\u0392\u0393\u0394\u0395\u0396\u0397\u0398\u0399\u039a\u039b\u039c\u039d\u039e\u039f\u03a0\u03a1\u03a3\u03a4\u03a5\u03a6\u03a7\u03a8\u03a9~08\u03b1\u03b2\u03b3\u03b4\u03b5\u03b6\u03b7\u03b8\u03b9\u03ba\u03bb\u03bc\u03bd\u03be\u03bf\u03c0\u03c1\u03c3\u03c4\u03c5\u03c6\u03c7\u03c8\u03c9~2x\u0410\u0411\u0412\u0413\u0414\u0415\u0401\u0416\u0417\u0418\u0419\u041a\u041b\u041c\u041d\u041e\u041f\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042a\u042b\u042c\u042d\u042e\u042f~0f\u0430\u0431\u0432\u0433\u0434\u0435\u0451\u0436\u0437\u0438\u0439\u043a\u043b\u043c\u043d \u043e\u043f\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044a\u044b\u044c\u044d\u044e\u044f~0d\u2500\u2502\u250c\u2510\u2518\u2514\u251c\u252c\u2524\u2534\u253c\u2501\u2503\u250f\u2513\u251b\u2517\u2523\u2533\u252b\u253b\u254b\u2520\u252f\u2528\u2537\u253f\u251d\u2530\u2525\u2538\u2542~rk\u4e9c\u5516\u5a03\u963f\u54c0\u611b\u6328\u59f6\u9022\u8475\u831c\u7a50\u60aa\u63e1\u6e25\u65ed\u8466\u82a6\u9bf5\u6893\u5727\u65a1\u6271\u5b9b\u59d0\u867b\u98f4\u7d62\u7dbe\u9b8e\u6216\u7c9f\u88b7\u5b89\u5eb5\u6309\u6697\u6848\u95c7\u978d\u674f\u4ee5\u4f0a\u4f4d\u4f9d\u5049\u56f2\u5937\u59d4\u5a01\u5c09\u60df\u610f\u6170\u6613\u6905\u70ba\u754f\u7570\u79fb\u7dad\u7def\u80c3\u840e\u8863\u8b02\u9055\u907a\u533b\u4e95\u4ea5\u57df\u80b2\u90c1\u78ef\u4e00\u58f1\u6ea2\u9038\u7a32\u8328\u828b\u9c2f\u5141\u5370\u54bd\u54e1\u56e0\u59fb\u5f15\u98f2\u6deb\u80e4\u852d~1v\u9662\u9670\u96a0\u97fb\u540b\u53f3\u5b87\u70cf\u7fbd\u8fc2\u96e8\u536f\u9d5c\u7aba\u4e11\u7893\u81fc\u6e26\u5618\u5504\u6b1d\u851a\u9c3b\u59e5\u53a9\u6d66\u74dc\u958f\u5642\u4e91\u904b\u96f2\u834f\u990c\u53e1\u55b6\u5b30\u5f71\u6620\u66f3\u6804\u6c38\u6cf3\u6d29\u745b\u76c8\u7a4e\u9834\u82f1\u885b\u8a60\u92ed\u6db2\u
C){return Array(parseInt(C,36)+1).join(" ")});String.prototype.sjis2utf16=function(){return this.replace(/[\u0081-\u0098]./g,function(A){A=A.charCodeAt(0)<<8|A.charCodeAt(1);return J.charAt(A-33089)})}})(this);
(function(J){function A(){this.files={};this.directories={};this.record=null}function C(){}function n(a){this.version=a.read_int16();this.bitFlag=a.read_int16();this.method=a.read_int16();this.fileTime=a.read_int16();this.fileDate=a.read_int16();this.crc32=a.read_int();this.size=a.read_int();this.fileSize=a.read_int();this.nameLength=a.read_int16();this.extraLength=a.read_int16();this.name=a.read_text(this.nameLength);this.extra=a.read_ascii(this.extraLength);this.data=a.read(this.size)}function d(a){this.version=
a.read_int16();this.extVersion=a.read_int16();this.bitFlag=a.read_int16();this.method=a.read_int16();this.fileTime=a.read_int16();this.fileDate=a.read_int16();this.crc32=a.read_int();this.size=a.read_int();this.fileSize=a.read_int();this.nameLength=a.read_int16();this.extraLength=a.read_int16();this.commentLength=a.read_int16();this.diskNumberStart=a.read_int16();this.attributes=a.read_int16();this.extAttributes=a.read_int();this.headerOffset=a.read_int();this.name=a.read_text(this.nameLength);this.extra=
a.read_text(this.extraLength);this.comment=a.read_text(this.commentLength)}function g(a){this.bytes=a;this.length=a.length}function l(a){for(var a=new g(a),l=new A,p;!a.eos();){var s=a.read_int(4);if(67324752==s)p=new n(a),l.files[p.name]=p;else if(134695760==s)p.header=new n.Header(a);else if(33639248==s)s=new d(a),l.directories[s.name]=s;else if(101010256==s)s=new d.Record(a),l.record=s;else throw"Invalid ZIP header.";}delete a;delete byes;return l}function L(a,d){var g=new XMLHttpRequest;g.open("GET",
a);g.onload=function(){var a=new Uint8Array(g.response);d(l(a))};g.responseType="arraybuffer";g.send(null)}J.Zip||(J.Zip={inflate:l,inflate_file:L});C.prototype={version:0,bitFlag:0,method:0,fileTime:0,fileDate:0,crc32:0,size:0,fileSize:0,nameLength:0,extraLength:0,name:null,extra:null,modified:function(){return new Date(1980+(this.fileDate>>9),(this.fileDate>>5&15)-1,this.fileDate&31,this.fileTime>>11,this.fileTime>>5&60)}};n.prototype=new C;n.prototype.data=null;n.prototype.header=null;n.prototype.inflate=
function(){var a=this.data;return 0==this.method?a:JSInflate.inflate(a,this.fileSize)};n.Header=function(a){this.crc32=a.read_int();this.size=a.read_int();this.fileSize=this.read_int()};n.Header.prototype={crc32:0,size:0,fileSize:0};d.prototype=new C;d.prototype.extVersion=0;d.prototype.commentLength=null;d.prototype.comment=null;d.prototype.diskNumberStart=0;d.prototype.attributes=0;d.prototype.extAttributes=0;d.prototype.headerOffset=0;d.prototype.record=null;d.Record=function(a){this.diskNumber=
a.read_int16();this.startNumber=a.read_int16();this.diskLength=a.read_int16();this.length=a.read_int16();this.directorySize=a.read_int();this.offset=a.read_int();this.commentLength=a.read_int16();this.comment=a.read_text(this.commentLength)};d.Record.prototype={diskNumber:0,startNumber:0,diskLength:0,length:0,directorySize:0,offset:0,commentLength:0,comment:null};g.prototype={position:0,eos:function(){return this.position>=this.length},read:function(a){var d=this.bytes.subarray(this.position,this.position+
a);this.position+=a;return d},read_ascii:function(a){return String.fromCharCode.apply(null,this.read(a))},read_text:function(a){a=this.read_ascii(a);return a.sjis2utf16?a.sjis2utf16():a},read_int:function(){var a=this.read(4);return a[0]|a[1]<<8|a[2]<<16|a[3]<<24},read_int16:function(){var a=this.read(2);return a[0]|a[1]<<8}}})(this);