1 line
4.7 KiB
JavaScript
1 line
4.7 KiB
JavaScript
var O={exports:{}};(function(x){var S=function(){var y=String.fromCharCode,M="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",_={};function g(o,r){if(!_[o]){_[o]={};for(var s=0;s<o.length;s++)_[o][o.charAt(s)]=s}return _[o][r]}var d={compressToBase64:function(o){if(o==null)return"";var r=d._compress(o,6,function(s){return M.charAt(s)});switch(r.length%4){default:case 0:return r;case 1:return r+"===";case 2:return r+"==";case 3:return r+"="}},decompressFromBase64:function(o){return o==null?"":o==""?null:d._decompress(o.length,32,function(r){return g(M,o.charAt(r))})},compressToUTF16:function(o){return o==null?"":d._compress(o,15,function(r){return y(r+32)})+" "},decompressFromUTF16:function(o){return o==null?"":o==""?null:d._decompress(o.length,16384,function(r){return o.charCodeAt(r)-32})},compressToUint8Array:function(o){for(var r=d.compress(o),s=new Uint8Array(r.length*2),e=0,t=r.length;e<t;e++){var p=r.charCodeAt(e);s[e*2]=p>>>8,s[e*2+1]=p%256}return s},decompressFromUint8Array:function(o){if(o==null)return d.decompress(o);for(var r=new Array(o.length/2),s=0,e=r.length;s<e;s++)r[s]=o[s*2]*256+o[s*2+1];var t=[];return r.forEach(function(p){t.push(y(p))}),d.decompress(t.join(""))},compressToEncodedURIComponent:function(o){return o==null?"":d._compress(o,6,function(r){return m.charAt(r)})},decompressFromEncodedURIComponent:function(o){return o==null?"":o==""?null:(o=o.replace(/ /g,"+"),d._decompress(o.length,32,function(r){return g(m,o.charAt(r))}))},compress:function(o){return d._compress(o,16,function(r){return y(r)})},_compress:function(o,r,s){if(o==null)return"";var e,t,p={},w={},v="",A="",u="",h=2,a=3,c=2,l=[],n=0,f=0,i;for(i=0;i<o.length;i+=1)if(v=o.charAt(i),Object.prototype.hasOwnProperty.call(p,v)||(p[v]=a++,w[v]=!0),A=u+v,Object.prototype.hasOwnProperty.call(p,A))u=A;else{if(Object.prototype.hasOwnProperty.call(w,u)){if(u.charCodeAt(0)<256){for(e=0;e<c;e++)n=n<<1,f==r-1?(f=0,l.push(s(n)),n=0):f++;for(t=u.charCodeAt(0),e=0;e<8;e++)n=n<<1|t&1,f==r-1?(f=0,l.push(s(n)),n=0):f++,t=t>>1}else{for(t=1,e=0;e<c;e++)n=n<<1|t,f==r-1?(f=0,l.push(s(n)),n=0):f++,t=0;for(t=u.charCodeAt(0),e=0;e<16;e++)n=n<<1|t&1,f==r-1?(f=0,l.push(s(n)),n=0):f++,t=t>>1}h--,h==0&&(h=Math.pow(2,c),c++),delete w[u]}else for(t=p[u],e=0;e<c;e++)n=n<<1|t&1,f==r-1?(f=0,l.push(s(n)),n=0):f++,t=t>>1;h--,h==0&&(h=Math.pow(2,c),c++),p[A]=a++,u=String(v)}if(u!==""){if(Object.prototype.hasOwnProperty.call(w,u)){if(u.charCodeAt(0)<256){for(e=0;e<c;e++)n=n<<1,f==r-1?(f=0,l.push(s(n)),n=0):f++;for(t=u.charCodeAt(0),e=0;e<8;e++)n=n<<1|t&1,f==r-1?(f=0,l.push(s(n)),n=0):f++,t=t>>1}else{for(t=1,e=0;e<c;e++)n=n<<1|t,f==r-1?(f=0,l.push(s(n)),n=0):f++,t=0;for(t=u.charCodeAt(0),e=0;e<16;e++)n=n<<1|t&1,f==r-1?(f=0,l.push(s(n)),n=0):f++,t=t>>1}h--,h==0&&(h=Math.pow(2,c),c++),delete w[u]}else for(t=p[u],e=0;e<c;e++)n=n<<1|t&1,f==r-1?(f=0,l.push(s(n)),n=0):f++,t=t>>1;h--,h==0&&(h=Math.pow(2,c),c++)}for(t=2,e=0;e<c;e++)n=n<<1|t&1,f==r-1?(f=0,l.push(s(n)),n=0):f++,t=t>>1;for(;;)if(n=n<<1,f==r-1){l.push(s(n));break}else f++;return l.join("")},decompress:function(o){return o==null?"":o==""?null:d._decompress(o.length,32768,function(r){return o.charCodeAt(r)})},_decompress:function(o,r,s){var e=[],t=4,p=4,w=3,v="",A=[],u,h,a,c,l,n,f,i={val:s(0),position:r,index:1};for(u=0;u<3;u+=1)e[u]=u;for(a=0,l=Math.pow(2,2),n=1;n!=l;)c=i.val&i.position,i.position>>=1,i.position==0&&(i.position=r,i.val=s(i.index++)),a|=(c>0?1:0)*n,n<<=1;switch(a){case 0:for(a=0,l=Math.pow(2,8),n=1;n!=l;)c=i.val&i.position,i.position>>=1,i.position==0&&(i.position=r,i.val=s(i.index++)),a|=(c>0?1:0)*n,n<<=1;f=y(a);break;case 1:for(a=0,l=Math.pow(2,16),n=1;n!=l;)c=i.val&i.position,i.position>>=1,i.position==0&&(i.position=r,i.val=s(i.index++)),a|=(c>0?1:0)*n,n<<=1;f=y(a);break;case 2:return""}for(e[3]=f,h=f,A.push(f);;){if(i.index>o)return"";for(a=0,l=Math.pow(2,w),n=1;n!=l;)c=i.val&i.position,i.position>>=1,i.position==0&&(i.position=r,i.val=s(i.index++)),a|=(c>0?1:0)*n,n<<=1;switch(f=a){case 0:for(a=0,l=Math.pow(2,8),n=1;n!=l;)c=i.val&i.position,i.position>>=1,i.position==0&&(i.position=r,i.val=s(i.index++)),a|=(c>0?1:0)*n,n<<=1;e[p++]=y(a),f=p-1,t--;break;case 1:for(a=0,l=Math.pow(2,16),n=1;n!=l;)c=i.val&i.position,i.position>>=1,i.position==0&&(i.position=r,i.val=s(i.index++)),a|=(c>0?1:0)*n,n<<=1;e[p++]=y(a),f=p-1,t--;break;case 2:return A.join("")}if(t==0&&(t=Math.pow(2,w),w++),e[f])v=e[f];else if(f===p)v=h+h.charAt(0);else return null;A.push(v),e[p++]=h+v.charAt(0),t--,h=v,t==0&&(t=Math.pow(2,w),w++)}}};return d}();x!=null?x.exports=S:typeof angular!="undefined"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return S})})(O);var U=O.exports;export{U as L};
|