index.js 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. !function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){(function(e){r(13);var n=r(15);"object"==typeof e&&e+""=="[object process]"?t.exports=n:window.SafeApp=n}).call(e,r(4))},function(t,e,r){function n(t){try{var e=JSON.parse(t);if(e&&"object"==typeof e&&null!==e)return e}catch(r){}return t}function o(t){var e,r=unescape(encodeURIComponent(t)),n=new Uint8Array(r.length);for(e=0;e<r.length;e++)n[e]=r.charCodeAt(e);return n}function i(t){var e,r=[];for(e=0;e<t.length;e++)r.push(String.fromCharCode(t[e]));return decodeURIComponent(escape(r.join("")))}var s=r(2),a=r(3);t.exports.unserialize=function(t){var e=JSON.parse(t);return{token:e.token,symKey:s.toByteArray(e.symKey),symNonce:s.toByteArray(e.symNonce)}},t.exports.serialize=function(t){var e={token:t.token,symKey:s.fromByteArray(t.symKey),symNonce:s.fromByteArray(t.symNonce)};return JSON.stringify(e)},t.exports.parseJson=n,t.exports.encodeUTF8=o,t.exports.decodeUTF8=i,t.exports.decrypt=function(t,e,r){var o=s.toByteArray(t),i=s.fromByteArray(a.secretbox.open(o,e,r));return n(atob(i))},t.exports.encrypt=function(t,e,r){var n=a.secretbox(o(t),e,r);return s.fromByteArray(n)}},function(t,e){"use strict";function r(){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,r=t.length;r>e;++e)a[e]=t[e],h[t.charCodeAt(e)]=e;h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63}function n(t){var e,r,n,o,i,s,a=t.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i="="===t[a-2]?2:"="===t[a-1]?1:0,s=new u(3*a/4-i),n=i>0?a-4:a;var f=0;for(e=0,r=0;n>e;e+=4,r+=3)o=h[t.charCodeAt(e)]<<18|h[t.charCodeAt(e+1)]<<12|h[t.charCodeAt(e+2)]<<6|h[t.charCodeAt(e+3)],s[f++]=o>>16&255,s[f++]=o>>8&255,s[f++]=255&o;return 2===i?(o=h[t.charCodeAt(e)]<<2|h[t.charCodeAt(e+1)]>>4,s[f++]=255&o):1===i&&(o=h[t.charCodeAt(e)]<<10|h[t.charCodeAt(e+1)]<<4|h[t.charCodeAt(e+2)]>>2,s[f++]=o>>8&255,s[f++]=255&o),s}function o(t){return a[t>>18&63]+a[t>>12&63]+a[t>>6&63]+a[63&t]}function i(t,e,r){for(var n,i=[],s=e;r>s;s+=3)n=(t[s]<<16)+(t[s+1]<<8)+t[s+2],i.push(o(n));return i.join("")}function s(t){for(var e,r=t.length,n=r%3,o="",s=[],h=16383,u=0,f=r-n;f>u;u+=h)s.push(i(t,u,u+h>f?f:u+h));return 1===n?(e=t[r-1],o+=a[e>>2],o+=a[e<<4&63],o+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],o+=a[e>>10],o+=a[e>>4&63],o+=a[e<<2&63],o+="="),s.push(o),s.join("")}e.toByteArray=n,e.fromByteArray=s;var a=[],h=[],u="undefined"!=typeof Uint8Array?Uint8Array:Array;r()},function(t,e,r){!function(t){"use strict";function e(t,e,r,n){t[e]=r>>24&255,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r,t[e+4]=n>>24&255,t[e+5]=n>>16&255,t[e+6]=n>>8&255,t[e+7]=255&n}function n(t,e,r,n,o){var i,s=0;for(i=0;o>i;i++)s|=t[e+i]^r[n+i];return(1&s-1>>>8)-1}function o(t,e,r,o){return n(t,e,r,o,16)}function i(t,e,r,o){return n(t,e,r,o,32)}function s(t,e,r,n){for(var o,i=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,a=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,h=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,u=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,f=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,l=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,y=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,d=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,v=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,b=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,g=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,w=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,m=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,_=i,A=s,x=a,U=h,E=u,S=f,T=c,R=l,B=y,C=p,P=d,O=v,M=b,k=g,I=w,K=m,L=0;20>L;L+=2)o=_+M|0,E^=o<<7|o>>>25,o=E+_|0,B^=o<<9|o>>>23,o=B+E|0,M^=o<<13|o>>>19,o=M+B|0,_^=o<<18|o>>>14,o=S+A|0,C^=o<<7|o>>>25,o=C+S|0,k^=o<<9|o>>>23,o=k+C|0,A^=o<<13|o>>>19,o=A+k|0,S^=o<<18|o>>>14,o=P+T|0,I^=o<<7|o>>>25,o=I+P|0,x^=o<<9|o>>>23,o=x+I|0,T^=o<<13|o>>>19,o=T+x|0,P^=o<<18|o>>>14,o=K+O|0,U^=o<<7|o>>>25,o=U+K|0,R^=o<<9|o>>>23,o=R+U|0,O^=o<<13|o>>>19,o=O+R|0,K^=o<<18|o>>>14,o=_+U|0,A^=o<<7|o>>>25,o=A+_|0,x^=o<<9|o>>>23,o=x+A|0,U^=o<<13|o>>>19,o=U+x|0,_^=o<<18|o>>>14,o=S+E|0,T^=o<<7|o>>>25,o=T+S|0,R^=o<<9|o>>>23,o=R+T|0,E^=o<<13|o>>>19,o=E+R|0,S^=o<<18|o>>>14,o=P+C|0,O^=o<<7|o>>>25,o=O+P|0,B^=o<<9|o>>>23,o=B+O|0,C^=o<<13|o>>>19,o=C+B|0,P^=o<<18|o>>>14,o=K+I|0,M^=o<<7|o>>>25,o=M+K|0,k^=o<<9|o>>>23,o=k+M|0,I^=o<<13|o>>>19,o=I+k|0,K^=o<<18|o>>>14;_=_+i|0,A=A+s|0,x=x+a|0,U=U+h|0,E=E+u|0,S=S+f|0,T=T+c|0,R=R+l|0,B=B+y|0,C=C+p|0,P=P+d|0,O=O+v|0,M=M+b|0,k=k+g|0,I=I+w|0,K=K+m|0,t[0]=_>>>0&255,t[1]=_>>>8&255,t[2]=_>>>16&255,t[3]=_>>>24&255,t[4]=A>>>0&255,t[5]=A>>>8&255,t[6]=A>>>16&255,t[7]=A>>>24&255,t[8]=x>>>0&255,t[9]=x>>>8&255,t[10]=x>>>16&255,t[11]=x>>>24&255,t[12]=U>>>0&255,t[13]=U>>>8&255,t[14]=U>>>16&255,t[15]=U>>>24&255,t[16]=E>>>0&255,t[17]=E>>>8&255,t[18]=E>>>16&255,t[19]=E>>>24&255,t[20]=S>>>0&255,t[21]=S>>>8&255,t[22]=S>>>16&255,t[23]=S>>>24&255,t[24]=T>>>0&255,t[25]=T>>>8&255,t[26]=T>>>16&255,t[27]=T>>>24&255,t[28]=R>>>0&255,t[29]=R>>>8&255,t[30]=R>>>16&255,t[31]=R>>>24&255,t[32]=B>>>0&255,t[33]=B>>>8&255,t[34]=B>>>16&255,t[35]=B>>>24&255,t[36]=C>>>0&255,t[37]=C>>>8&255,t[38]=C>>>16&255,t[39]=C>>>24&255,t[40]=P>>>0&255,t[41]=P>>>8&255,t[42]=P>>>16&255,t[43]=P>>>24&255,t[44]=O>>>0&255,t[45]=O>>>8&255,t[46]=O>>>16&255,t[47]=O>>>24&255,t[48]=M>>>0&255,t[49]=M>>>8&255,t[50]=M>>>16&255,t[51]=M>>>24&255,t[52]=k>>>0&255,t[53]=k>>>8&255,t[54]=k>>>16&255,t[55]=k>>>24&255,t[56]=I>>>0&255,t[57]=I>>>8&255,t[58]=I>>>16&255,t[59]=I>>>24&255,t[60]=K>>>0&255,t[61]=K>>>8&255,t[62]=K>>>16&255,t[63]=K>>>24&255}function a(t,e,r,n){for(var o,i=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,a=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,h=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,u=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,f=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,l=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,y=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,d=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,v=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,b=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,g=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,w=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,m=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,_=i,A=s,x=a,U=h,E=u,S=f,T=c,R=l,B=y,C=p,P=d,O=v,M=b,k=g,I=w,K=m,L=0;20>L;L+=2)o=_+M|0,E^=o<<7|o>>>25,o=E+_|0,B^=o<<9|o>>>23,o=B+E|0,M^=o<<13|o>>>19,o=M+B|0,_^=o<<18|o>>>14,o=S+A|0,C^=o<<7|o>>>25,o=C+S|0,k^=o<<9|o>>>23,o=k+C|0,A^=o<<13|o>>>19,o=A+k|0,S^=o<<18|o>>>14,o=P+T|0,I^=o<<7|o>>>25,o=I+P|0,x^=o<<9|o>>>23,o=x+I|0,T^=o<<13|o>>>19,o=T+x|0,P^=o<<18|o>>>14,o=K+O|0,U^=o<<7|o>>>25,o=U+K|0,R^=o<<9|o>>>23,o=R+U|0,O^=o<<13|o>>>19,o=O+R|0,K^=o<<18|o>>>14,o=_+U|0,A^=o<<7|o>>>25,o=A+_|0,x^=o<<9|o>>>23,o=x+A|0,U^=o<<13|o>>>19,o=U+x|0,_^=o<<18|o>>>14,o=S+E|0,T^=o<<7|o>>>25,o=T+S|0,R^=o<<9|o>>>23,o=R+T|0,E^=o<<13|o>>>19,o=E+R|0,S^=o<<18|o>>>14,o=P+C|0,O^=o<<7|o>>>25,o=O+P|0,B^=o<<9|o>>>23,o=B+O|0,C^=o<<13|o>>>19,o=C+B|0,P^=o<<18|o>>>14,o=K+I|0,M^=o<<7|o>>>25,o=M+K|0,k^=o<<9|o>>>23,o=k+M|0,I^=o<<13|o>>>19,o=I+k|0,K^=o<<18|o>>>14;t[0]=_>>>0&255,t[1]=_>>>8&255,t[2]=_>>>16&255,t[3]=_>>>24&255,t[4]=S>>>0&255,t[5]=S>>>8&255,t[6]=S>>>16&255,t[7]=S>>>24&255,t[8]=P>>>0&255,t[9]=P>>>8&255,t[10]=P>>>16&255,t[11]=P>>>24&255,t[12]=K>>>0&255,t[13]=K>>>8&255,t[14]=K>>>16&255,t[15]=K>>>24&255,t[16]=T>>>0&255,t[17]=T>>>8&255,t[18]=T>>>16&255,t[19]=T>>>24&255,t[20]=R>>>0&255,t[21]=R>>>8&255,t[22]=R>>>16&255,t[23]=R>>>24&255,t[24]=B>>>0&255,t[25]=B>>>8&255,t[26]=B>>>16&255,t[27]=B>>>24&255,t[28]=C>>>0&255,t[29]=C>>>8&255,t[30]=C>>>16&255,t[31]=C>>>24&255}function h(t,e,r,n){s(t,e,r,n)}function u(t,e,r,n){a(t,e,r,n)}function f(t,e,r,n,o,i,s){var a,u,f=new Uint8Array(16),c=new Uint8Array(64);for(u=0;16>u;u++)f[u]=0;for(u=0;8>u;u++)f[u]=i[u];for(;o>=64;){for(h(c,f,s,lt),u=0;64>u;u++)t[e+u]=r[n+u]^c[u];for(a=1,u=8;16>u;u++)a=a+(255&f[u])|0,f[u]=255&a,a>>>=8;o-=64,e+=64,n+=64}if(o>0)for(h(c,f,s,lt),u=0;o>u;u++)t[e+u]=r[n+u]^c[u];return 0}function c(t,e,r,n,o){var i,s,a=new Uint8Array(16),u=new Uint8Array(64);for(s=0;16>s;s++)a[s]=0;for(s=0;8>s;s++)a[s]=n[s];for(;r>=64;){for(h(u,a,o,lt),s=0;64>s;s++)t[e+s]=u[s];for(i=1,s=8;16>s;s++)i=i+(255&a[s])|0,a[s]=255&i,i>>>=8;r-=64,e+=64}if(r>0)for(h(u,a,o,lt),s=0;r>s;s++)t[e+s]=u[s];return 0}function l(t,e,r,n,o){var i=new Uint8Array(32);u(i,n,o,lt);for(var s=new Uint8Array(8),a=0;8>a;a++)s[a]=n[a+16];return c(t,e,r,s,i)}function y(t,e,r,n,o,i,s){var a=new Uint8Array(32);u(a,i,s,lt);for(var h=new Uint8Array(8),c=0;8>c;c++)h[c]=i[c+16];return f(t,e,r,n,o,h,a)}function p(t,e,r,n,o,i){var s=new yt(i);return s.update(r,n,o),s.finish(t,e),0}function d(t,e,r,n,i,s){var a=new Uint8Array(16);return p(a,0,r,n,i,s),o(t,e,a,0)}function v(t,e,r,n,o){var i;if(32>r)return-1;for(y(t,0,e,0,r,n,o),p(t,16,t,32,r-32,t),i=0;16>i;i++)t[i]=0;return 0}function b(t,e,r,n,o){var i,s=new Uint8Array(32);if(32>r)return-1;if(l(s,0,32,n,o),0!==d(e,16,e,32,r-32,s))return-1;for(y(t,0,e,0,r,n,o),i=0;32>i;i++)t[i]=0;return 0}function g(t,e){var r;for(r=0;16>r;r++)t[r]=0|e[r]}function w(t){var e,r,n=1;for(e=0;16>e;e++)r=t[e]+n+65535,n=Math.floor(r/65536),t[e]=r-65536*n;t[0]+=n-1+37*(n-1)}function m(t,e,r){for(var n,o=~(r-1),i=0;16>i;i++)n=o&(t[i]^e[i]),t[i]^=n,e[i]^=n}function _(t,e){var r,n,o,i=tt(),s=tt();for(r=0;16>r;r++)s[r]=e[r];for(w(s),w(s),w(s),n=0;2>n;n++){for(i[0]=s[0]-65517,r=1;15>r;r++)i[r]=s[r]-65535-(i[r-1]>>16&1),i[r-1]&=65535;i[15]=s[15]-32767-(i[14]>>16&1),o=i[15]>>16&1,i[14]&=65535,m(s,i,1-o)}for(r=0;16>r;r++)t[2*r]=255&s[r],t[2*r+1]=s[r]>>8}function A(t,e){var r=new Uint8Array(32),n=new Uint8Array(32);return _(r,t),_(n,e),i(r,0,n,0)}function x(t){var e=new Uint8Array(32);return _(e,t),1&e[0]}function U(t,e){var r;for(r=0;16>r;r++)t[r]=e[2*r]+(e[2*r+1]<<8);t[15]&=32767}function E(t,e,r){for(var n=0;16>n;n++)t[n]=e[n]+r[n]}function S(t,e,r){for(var n=0;16>n;n++)t[n]=e[n]-r[n]}function T(t,e,r){var n,o,i=0,s=0,a=0,h=0,u=0,f=0,c=0,l=0,y=0,p=0,d=0,v=0,b=0,g=0,w=0,m=0,_=0,A=0,x=0,U=0,E=0,S=0,T=0,R=0,B=0,C=0,P=0,O=0,M=0,k=0,I=0,K=r[0],L=r[1],N=r[2],q=r[3],j=r[4],z=r[5],F=r[6],D=r[7],Y=r[8],G=r[9],H=r[10],J=r[11],X=r[12],Z=r[13],V=r[14],W=r[15];n=e[0],i+=n*K,s+=n*L,a+=n*N,h+=n*q,u+=n*j,f+=n*z,c+=n*F,l+=n*D,y+=n*Y,p+=n*G,d+=n*H,v+=n*J,b+=n*X,g+=n*Z,w+=n*V,m+=n*W,n=e[1],s+=n*K,a+=n*L,h+=n*N,u+=n*q,f+=n*j,c+=n*z,l+=n*F,y+=n*D,p+=n*Y,d+=n*G,v+=n*H,b+=n*J,g+=n*X,w+=n*Z,m+=n*V,_+=n*W,n=e[2],a+=n*K,h+=n*L,u+=n*N,f+=n*q,c+=n*j,l+=n*z,y+=n*F,p+=n*D,d+=n*Y,v+=n*G,b+=n*H,g+=n*J,w+=n*X,m+=n*Z,_+=n*V,A+=n*W,n=e[3],h+=n*K,u+=n*L,f+=n*N,c+=n*q,l+=n*j,y+=n*z,p+=n*F,d+=n*D,v+=n*Y,b+=n*G,g+=n*H,w+=n*J,m+=n*X,_+=n*Z,A+=n*V,x+=n*W,n=e[4],u+=n*K,f+=n*L,c+=n*N,l+=n*q,y+=n*j,p+=n*z,d+=n*F,v+=n*D,b+=n*Y,g+=n*G,w+=n*H,m+=n*J,_+=n*X,A+=n*Z,x+=n*V,U+=n*W,n=e[5],f+=n*K,c+=n*L,l+=n*N,y+=n*q,p+=n*j,d+=n*z,v+=n*F,b+=n*D,g+=n*Y,w+=n*G,m+=n*H,_+=n*J,A+=n*X,x+=n*Z,U+=n*V,E+=n*W,n=e[6],c+=n*K,l+=n*L,y+=n*N,p+=n*q,d+=n*j,v+=n*z,b+=n*F,g+=n*D,w+=n*Y,m+=n*G,_+=n*H,A+=n*J,x+=n*X,U+=n*Z,E+=n*V,S+=n*W,n=e[7],l+=n*K,y+=n*L,p+=n*N,d+=n*q,v+=n*j,b+=n*z,g+=n*F,w+=n*D,m+=n*Y,_+=n*G,A+=n*H,x+=n*J,U+=n*X,E+=n*Z,S+=n*V,T+=n*W,n=e[8],y+=n*K,p+=n*L,d+=n*N,v+=n*q,b+=n*j,g+=n*z,w+=n*F,m+=n*D,_+=n*Y,A+=n*G,x+=n*H,U+=n*J,E+=n*X,S+=n*Z,T+=n*V,R+=n*W,n=e[9],p+=n*K,d+=n*L,v+=n*N,b+=n*q,g+=n*j,w+=n*z,m+=n*F,_+=n*D,A+=n*Y,x+=n*G,U+=n*H,E+=n*J,S+=n*X,T+=n*Z,R+=n*V,B+=n*W,n=e[10],d+=n*K,v+=n*L,b+=n*N,g+=n*q,w+=n*j,m+=n*z,_+=n*F,A+=n*D,x+=n*Y,U+=n*G,E+=n*H,S+=n*J,T+=n*X,R+=n*Z,B+=n*V,C+=n*W,n=e[11],v+=n*K,b+=n*L,g+=n*N,w+=n*q,m+=n*j,_+=n*z,A+=n*F,x+=n*D,U+=n*Y,E+=n*G,S+=n*H,T+=n*J,R+=n*X,B+=n*Z,C+=n*V,P+=n*W,n=e[12],b+=n*K,g+=n*L,w+=n*N,m+=n*q,_+=n*j,A+=n*z,x+=n*F,U+=n*D,E+=n*Y,S+=n*G,T+=n*H,R+=n*J,B+=n*X,C+=n*Z,P+=n*V,O+=n*W,n=e[13],g+=n*K,w+=n*L,m+=n*N,_+=n*q,A+=n*j,x+=n*z,U+=n*F,E+=n*D,S+=n*Y,T+=n*G,R+=n*H,B+=n*J,C+=n*X,P+=n*Z,O+=n*V,M+=n*W,n=e[14],w+=n*K,m+=n*L,_+=n*N,A+=n*q,x+=n*j,U+=n*z,E+=n*F,S+=n*D,T+=n*Y,R+=n*G,B+=n*H,C+=n*J,P+=n*X,O+=n*Z,M+=n*V,k+=n*W,n=e[15],m+=n*K,_+=n*L,A+=n*N,x+=n*q,U+=n*j,E+=n*z,S+=n*F,T+=n*D,R+=n*Y,B+=n*G,C+=n*H,P+=n*J,O+=n*X,M+=n*Z,k+=n*V,I+=n*W,i+=38*_,s+=38*A,a+=38*x,h+=38*U,u+=38*E,f+=38*S,c+=38*T,l+=38*R,y+=38*B,p+=38*C,d+=38*P,v+=38*O,b+=38*M,g+=38*k,w+=38*I,o=1,n=i+o+65535,o=Math.floor(n/65536),i=n-65536*o,n=s+o+65535,o=Math.floor(n/65536),s=n-65536*o,n=a+o+65535,o=Math.floor(n/65536),a=n-65536*o,n=h+o+65535,o=Math.floor(n/65536),h=n-65536*o,n=u+o+65535,o=Math.floor(n/65536),u=n-65536*o,n=f+o+65535,o=Math.floor(n/65536),f=n-65536*o,n=c+o+65535,o=Math.floor(n/65536),c=n-65536*o,n=l+o+65535,o=Math.floor(n/65536),l=n-65536*o,n=y+o+65535,o=Math.floor(n/65536),y=n-65536*o,n=p+o+65535,o=Math.floor(n/65536),p=n-65536*o,n=d+o+65535,o=Math.floor(n/65536),d=n-65536*o,n=v+o+65535,o=Math.floor(n/65536),v=n-65536*o,n=b+o+65535,o=Math.floor(n/65536),b=n-65536*o,n=g+o+65535,o=Math.floor(n/65536),g=n-65536*o,n=w+o+65535,o=Math.floor(n/65536),w=n-65536*o,n=m+o+65535,o=Math.floor(n/65536),m=n-65536*o,i+=o-1+37*(o-1),o=1,n=i+o+65535,o=Math.floor(n/65536),i=n-65536*o,n=s+o+65535,o=Math.floor(n/65536),s=n-65536*o,n=a+o+65535,o=Math.floor(n/65536),a=n-65536*o,n=h+o+65535,o=Math.floor(n/65536),h=n-65536*o,n=u+o+65535,o=Math.floor(n/65536),u=n-65536*o,n=f+o+65535,o=Math.floor(n/65536),f=n-65536*o,n=c+o+65535,o=Math.floor(n/65536),c=n-65536*o,n=l+o+65535,o=Math.floor(n/65536),l=n-65536*o,n=y+o+65535,o=Math.floor(n/65536),y=n-65536*o,n=p+o+65535,o=Math.floor(n/65536),p=n-65536*o,n=d+o+65535,o=Math.floor(n/65536),d=n-65536*o,n=v+o+65535,o=Math.floor(n/65536),v=n-65536*o,n=b+o+65535,o=Math.floor(n/65536),b=n-65536*o,n=g+o+65535,o=Math.floor(n/65536),g=n-65536*o,n=w+o+65535,o=Math.floor(n/65536),w=n-65536*o,n=m+o+65535,o=Math.floor(n/65536),m=n-65536*o,i+=o-1+37*(o-1),t[0]=i,t[1]=s,t[2]=a,t[3]=h,t[4]=u,t[5]=f,t[6]=c,t[7]=l,t[8]=y,t[9]=p,t[10]=d,t[11]=v,t[12]=b,t[13]=g,t[14]=w,t[15]=m}function R(t,e){T(t,e,e)}function B(t,e){var r,n=tt();for(r=0;16>r;r++)n[r]=e[r];for(r=253;r>=0;r--)R(n,n),2!==r&&4!==r&&T(n,n,e);for(r=0;16>r;r++)t[r]=n[r]}function C(t,e){var r,n=tt();for(r=0;16>r;r++)n[r]=e[r];for(r=250;r>=0;r--)R(n,n),1!==r&&T(n,n,e);for(r=0;16>r;r++)t[r]=n[r]}function P(t,e,r){var n,o,i=new Uint8Array(32),s=new Float64Array(80),a=tt(),h=tt(),u=tt(),f=tt(),c=tt(),l=tt();for(o=0;31>o;o++)i[o]=e[o];for(i[31]=127&e[31]|64,i[0]&=248,U(s,r),o=0;16>o;o++)h[o]=s[o],f[o]=a[o]=u[o]=0;for(a[0]=f[0]=1,o=254;o>=0;--o)n=i[o>>>3]>>>(7&o)&1,m(a,h,n),m(u,f,n),E(c,a,u),S(a,a,u),E(u,h,f),S(h,h,f),R(f,c),R(l,a),T(a,u,a),T(u,h,c),E(c,a,u),S(a,a,u),R(h,a),S(u,f,l),T(a,u,st),E(a,a,f),T(u,u,a),T(a,f,l),T(f,h,s),R(h,c),m(a,h,n),m(u,f,n);for(o=0;16>o;o++)s[o+16]=a[o],s[o+32]=u[o],s[o+48]=h[o],s[o+64]=f[o];var y=s.subarray(32),p=s.subarray(16);return B(y,y),T(p,p,y),_(t,p),0}function O(t,e){return P(t,e,nt)}function M(t,e){return et(e,32),O(t,e)}function k(t,e,r){var n=new Uint8Array(32);return P(n,r,e),u(t,rt,n,lt)}function I(t,e,r,n,o,i){var s=new Uint8Array(32);return k(s,o,i),pt(t,e,r,n,s)}function K(t,e,r,n,o,i){var s=new Uint8Array(32);return k(s,o,i),dt(t,e,r,n,s)}function L(t,e,r,n){for(var o,i,s,a,h,u,f,c,l,y,p,d,v,b,g,w,m,_,A,x,U,E,S,T,R,B,C=new Int32Array(16),P=new Int32Array(16),O=t[0],M=t[1],k=t[2],I=t[3],K=t[4],L=t[5],N=t[6],q=t[7],j=e[0],z=e[1],F=e[2],D=e[3],Y=e[4],G=e[5],H=e[6],J=e[7],X=0;n>=128;){for(A=0;16>A;A++)x=8*A+X,C[A]=r[x+0]<<24|r[x+1]<<16|r[x+2]<<8|r[x+3],P[A]=r[x+4]<<24|r[x+5]<<16|r[x+6]<<8|r[x+7];for(A=0;80>A;A++)if(o=O,i=M,s=k,a=I,h=K,u=L,f=N,c=q,l=j,y=z,p=F,d=D,v=Y,b=G,g=H,w=J,U=q,E=J,S=65535&E,T=E>>>16,R=65535&U,B=U>>>16,U=(K>>>14|Y<<18)^(K>>>18|Y<<14)^(Y>>>9|K<<23),E=(Y>>>14|K<<18)^(Y>>>18|K<<14)^(K>>>9|Y<<23),S+=65535&E,T+=E>>>16,R+=65535&U,B+=U>>>16,U=K&L^~K&N,E=Y&G^~Y&H,S+=65535&E,T+=E>>>16,R+=65535&U,B+=U>>>16,U=vt[2*A],E=vt[2*A+1],S+=65535&E,T+=E>>>16,R+=65535&U,B+=U>>>16,U=C[A%16],E=P[A%16],S+=65535&E,T+=E>>>16,R+=65535&U,B+=U>>>16,T+=S>>>16,R+=T>>>16,B+=R>>>16,m=65535&R|B<<16,_=65535&S|T<<16,U=m,E=_,S=65535&E,T=E>>>16,R=65535&U,B=U>>>16,U=(O>>>28|j<<4)^(j>>>2|O<<30)^(j>>>7|O<<25),E=(j>>>28|O<<4)^(O>>>2|j<<30)^(O>>>7|j<<25),S+=65535&E,T+=E>>>16,R+=65535&U,B+=U>>>16,U=O&M^O&k^M&k,E=j&z^j&F^z&F,S+=65535&E,T+=E>>>16,R+=65535&U,B+=U>>>16,T+=S>>>16,R+=T>>>16,B+=R>>>16,c=65535&R|B<<16,w=65535&S|T<<16,U=a,E=d,S=65535&E,T=E>>>16,R=65535&U,B=U>>>16,U=m,E=_,S+=65535&E,T+=E>>>16,R+=65535&U,B+=U>>>16,T+=S>>>16,R+=T>>>16,B+=R>>>16,a=65535&R|B<<16,d=65535&S|T<<16,M=o,k=i,I=s,K=a,L=h,N=u,q=f,O=c,z=l,F=y,D=p,Y=d,G=v,H=b,J=g,j=w,A%16===15)for(x=0;16>x;x++)U=C[x],E=P[x],S=65535&E,T=E>>>16,R=65535&U,B=U>>>16,U=C[(x+9)%16],E=P[(x+9)%16],S+=65535&E,T+=E>>>16,R+=65535&U,B+=U>>>16,m=C[(x+1)%16],_=P[(x+1)%16],U=(m>>>1|_<<31)^(m>>>8|_<<24)^m>>>7,E=(_>>>1|m<<31)^(_>>>8|m<<24)^(_>>>7|m<<25),S+=65535&E,T+=E>>>16,R+=65535&U,B+=U>>>16,m=C[(x+14)%16],_=P[(x+14)%16],U=(m>>>19|_<<13)^(_>>>29|m<<3)^m>>>6,E=(_>>>19|m<<13)^(m>>>29|_<<3)^(_>>>6|m<<26),S+=65535&E,T+=E>>>16,R+=65535&U,B+=U>>>16,T+=S>>>16,R+=T>>>16,B+=R>>>16,C[x]=65535&R|B<<16,P[x]=65535&S|T<<16;U=O,E=j,S=65535&E,T=E>>>16,R=65535&U,B=U>>>16,U=t[0],E=e[0],S+=65535&E,T+=E>>>16,R+=65535&U,B+=U>>>16,T+=S>>>16,R+=T>>>16,B+=R>>>16,t[0]=O=65535&R|B<<16,e[0]=j=65535&S|T<<16,U=M,E=z,S=65535&E,T=E>>>16,R=65535&U,B=U>>>16,U=t[1],E=e[1],S+=65535&E,T+=E>>>16,R+=65535&U,B+=U>>>16,T+=S>>>16,R+=T>>>16,B+=R>>>16,t[1]=M=65535&R|B<<16,e[1]=z=65535&S|T<<16,U=k,E=F,S=65535&E,T=E>>>16,R=65535&U,B=U>>>16,U=t[2],E=e[2],S+=65535&E,T+=E>>>16,R+=65535&U,B+=U>>>16,T+=S>>>16,R+=T>>>16,B+=R>>>16,t[2]=k=65535&R|B<<16,e[2]=F=65535&S|T<<16,U=I,E=D,S=65535&E,T=E>>>16,R=65535&U,B=U>>>16,U=t[3],E=e[3],S+=65535&E,T+=E>>>16,R+=65535&U,B+=U>>>16,T+=S>>>16,R+=T>>>16,B+=R>>>16,t[3]=I=65535&R|B<<16,e[3]=D=65535&S|T<<16,U=K,E=Y,S=65535&E,T=E>>>16,R=65535&U,B=U>>>16,U=t[4],E=e[4],S+=65535&E,T+=E>>>16,R+=65535&U,B+=U>>>16,T+=S>>>16,R+=T>>>16,B+=R>>>16,t[4]=K=65535&R|B<<16,e[4]=Y=65535&S|T<<16,U=L,E=G,S=65535&E,T=E>>>16,R=65535&U,B=U>>>16,U=t[5],E=e[5],S+=65535&E,T+=E>>>16,R+=65535&U,B+=U>>>16,T+=S>>>16,R+=T>>>16,B+=R>>>16,t[5]=L=65535&R|B<<16,e[5]=G=65535&S|T<<16,U=N,E=H,S=65535&E,T=E>>>16,R=65535&U,B=U>>>16,U=t[6],E=e[6],S+=65535&E,T+=E>>>16,R+=65535&U,B+=U>>>16,T+=S>>>16,R+=T>>>16,B+=R>>>16,t[6]=N=65535&R|B<<16,e[6]=H=65535&S|T<<16,U=q,E=J,S=65535&E,T=E>>>16,R=65535&U,B=U>>>16,U=t[7],E=e[7],S+=65535&E,T+=E>>>16,R+=65535&U,B+=U>>>16,T+=S>>>16,R+=T>>>16,B+=R>>>16,t[7]=q=65535&R|B<<16,e[7]=J=65535&S|T<<16,X+=128,n-=128}return n}function N(t,r,n){var o,i=new Int32Array(8),s=new Int32Array(8),a=new Uint8Array(256),h=n;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,s[0]=4089235720,s[1]=2227873595,s[2]=4271175723,s[3]=1595750129,s[4]=2917565137,s[5]=725511199,s[6]=4215389547,s[7]=327033209,L(i,s,r,n),n%=128,o=0;n>o;o++)a[o]=r[h-n+o];for(a[n]=128,n=256-128*(112>n?1:0),a[n-9]=0,e(a,n-8,h/536870912|0,h<<3),L(i,s,a,n),o=0;8>o;o++)e(t,8*o,i[o],s[o]);return 0}function q(t,e){var r=tt(),n=tt(),o=tt(),i=tt(),s=tt(),a=tt(),h=tt(),u=tt(),f=tt();S(r,t[1],t[0]),S(f,e[1],e[0]),T(r,r,f),E(n,t[0],t[1]),E(f,e[0],e[1]),T(n,n,f),T(o,t[3],e[3]),T(o,o,ht),T(i,t[2],e[2]),E(i,i,i),S(s,n,r),S(a,i,o),E(h,i,o),E(u,n,r),T(t[0],s,a),T(t[1],u,h),T(t[2],h,a),T(t[3],s,u)}function j(t,e,r){var n;for(n=0;4>n;n++)m(t[n],e[n],r)}function z(t,e){var r=tt(),n=tt(),o=tt();B(o,e[2]),T(r,e[0],o),T(n,e[1],o),_(t,n),t[31]^=x(r)<<7}function F(t,e,r){var n,o;for(g(t[0],ot),g(t[1],it),g(t[2],it),g(t[3],ot),o=255;o>=0;--o)n=r[o/8|0]>>(7&o)&1,j(t,e,n),q(e,t),q(t,t),j(t,e,n)}function D(t,e){var r=[tt(),tt(),tt(),tt()];g(r[0],ut),g(r[1],ft),g(r[2],it),T(r[3],ut,ft),F(t,r,e)}function Y(t,e,r){var n,o=new Uint8Array(64),i=[tt(),tt(),tt(),tt()];for(r||et(e,32),N(o,e,32),o[0]&=248,o[31]&=127,o[31]|=64,D(i,o),z(t,i),n=0;32>n;n++)e[n+32]=t[n];return 0}function G(t,e){var r,n,o,i;for(n=63;n>=32;--n){for(r=0,o=n-32,i=n-12;i>o;++o)e[o]+=r-16*e[n]*bt[o-(n-32)],r=e[o]+128>>8,e[o]-=256*r;e[o]+=r,e[n]=0}for(r=0,o=0;32>o;o++)e[o]+=r-(e[31]>>4)*bt[o],r=e[o]>>8,e[o]&=255;for(o=0;32>o;o++)e[o]-=r*bt[o];for(n=0;32>n;n++)e[n+1]+=e[n]>>8,t[n]=255&e[n]}function H(t){var e,r=new Float64Array(64);for(e=0;64>e;e++)r[e]=t[e];for(e=0;64>e;e++)t[e]=0;G(t,r)}function J(t,e,r,n){var o,i,s=new Uint8Array(64),a=new Uint8Array(64),h=new Uint8Array(64),u=new Float64Array(64),f=[tt(),tt(),tt(),tt()];N(s,n,32),s[0]&=248,s[31]&=127,s[31]|=64;var c=r+64;for(o=0;r>o;o++)t[64+o]=e[o];for(o=0;32>o;o++)t[32+o]=s[32+o];for(N(h,t.subarray(32),r+32),H(h),D(f,h),z(t,f),o=32;64>o;o++)t[o]=n[o];for(N(a,t,r+64),H(a),o=0;64>o;o++)u[o]=0;for(o=0;32>o;o++)u[o]=h[o];for(o=0;32>o;o++)for(i=0;32>i;i++)u[o+i]+=a[o]*s[i];return G(t.subarray(32),u),c}function X(t,e){var r=tt(),n=tt(),o=tt(),i=tt(),s=tt(),a=tt(),h=tt();return g(t[2],it),U(t[1],e),R(o,t[1]),T(i,o,at),S(o,o,t[2]),E(i,t[2],i),R(s,i),R(a,s),T(h,a,s),T(r,h,o),T(r,r,i),C(r,r),T(r,r,o),T(r,r,i),T(r,r,i),T(t[0],r,i),R(n,t[0]),T(n,n,i),A(n,o)&&T(t[0],t[0],ct),R(n,t[0]),T(n,n,i),A(n,o)?-1:(x(t[0])===e[31]>>7&&S(t[0],ot,t[0]),T(t[3],t[0],t[1]),0)}function Z(t,e,r,n){var o,s,a=new Uint8Array(32),h=new Uint8Array(64),u=[tt(),tt(),tt(),tt()],f=[tt(),tt(),tt(),tt()];if(s=-1,64>r)return-1;if(X(f,n))return-1;for(o=0;r>o;o++)t[o]=e[o];for(o=0;32>o;o++)t[o+32]=n[o];if(N(h,t,r),H(h),F(u,f,h),D(f,e.subarray(32)),q(u,f),z(a,u),r-=64,i(e,0,a,0)){for(o=0;r>o;o++)t[o]=0;return-1}for(o=0;r>o;o++)t[o]=e[o+64];return s=r}function V(t,e){if(t.length!==gt)throw new Error("bad key size");if(e.length!==wt)throw new Error("bad nonce size")}function W(t,e){if(t.length!==Ut)throw new Error("bad public key size");if(e.length!==Et)throw new Error("bad secret key size")}function Q(){var t,e;for(e=0;e<arguments.length;e++)if("[object Uint8Array]"!==(t=Object.prototype.toString.call(arguments[e])))throw new TypeError("unexpected type "+t+", use Uint8Array")}function $(t){for(var e=0;e<t.length;e++)t[e]=0}var tt=function(t){var e,r=new Float64Array(16);if(t)for(e=0;e<t.length;e++)r[e]=t[e];return r},et=function(){throw new Error("no PRNG")},rt=new Uint8Array(16),nt=new Uint8Array(32);nt[0]=9;var ot=tt(),it=tt([1]),st=tt([56129,1]),at=tt([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),ht=tt([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),ut=tt([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),ft=tt([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),ct=tt([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]),lt=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]),yt=function(t){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var e,r,n,o,i,s,a,h;e=255&t[0]|(255&t[1])<<8,this.r[0]=8191&e,r=255&t[2]|(255&t[3])<<8,this.r[1]=8191&(e>>>13|r<<3),n=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(r>>>10|n<<6),o=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(n>>>7|o<<9),i=255&t[8]|(255&t[9])<<8,this.r[4]=255&(o>>>4|i<<12),this.r[5]=i>>>1&8190,s=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(i>>>14|s<<2),a=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(s>>>11|a<<5),h=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(a>>>8|h<<8),this.r[9]=h>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};yt.prototype.blocks=function(t,e,r){for(var n,o,i,s,a,h,u,f,c,l,y,p,d,v,b,g,w,m,_,A=this.fin?0:2048,x=this.h[0],U=this.h[1],E=this.h[2],S=this.h[3],T=this.h[4],R=this.h[5],B=this.h[6],C=this.h[7],P=this.h[8],O=this.h[9],M=this.r[0],k=this.r[1],I=this.r[2],K=this.r[3],L=this.r[4],N=this.r[5],q=this.r[6],j=this.r[7],z=this.r[8],F=this.r[9];r>=16;)n=255&t[e+0]|(255&t[e+1])<<8,x+=8191&n,o=255&t[e+2]|(255&t[e+3])<<8,U+=8191&(n>>>13|o<<3),i=255&t[e+4]|(255&t[e+5])<<8,E+=8191&(o>>>10|i<<6),s=255&t[e+6]|(255&t[e+7])<<8,S+=8191&(i>>>7|s<<9),a=255&t[e+8]|(255&t[e+9])<<8,T+=8191&(s>>>4|a<<12),R+=a>>>1&8191,h=255&t[e+10]|(255&t[e+11])<<8,B+=8191&(a>>>14|h<<2),u=255&t[e+12]|(255&t[e+13])<<8,C+=8191&(h>>>11|u<<5),f=255&t[e+14]|(255&t[e+15])<<8,P+=8191&(u>>>8|f<<8),O+=f>>>5|A,c=0,l=c,l+=x*M,l+=U*(5*F),l+=E*(5*z),l+=S*(5*j),l+=T*(5*q),c=l>>>13,l&=8191,l+=R*(5*N),l+=B*(5*L),l+=C*(5*K),l+=P*(5*I),l+=O*(5*k),c+=l>>>13,l&=8191,y=c,y+=x*k,y+=U*M,y+=E*(5*F),y+=S*(5*z),y+=T*(5*j),c=y>>>13,y&=8191,y+=R*(5*q),y+=B*(5*N),y+=C*(5*L),y+=P*(5*K),y+=O*(5*I),c+=y>>>13,y&=8191,p=c,p+=x*I,p+=U*k,p+=E*M,p+=S*(5*F),p+=T*(5*z),c=p>>>13,p&=8191,p+=R*(5*j),p+=B*(5*q),p+=C*(5*N),p+=P*(5*L),p+=O*(5*K),c+=p>>>13,p&=8191,d=c,d+=x*K,d+=U*I,d+=E*k,d+=S*M,d+=T*(5*F),c=d>>>13,d&=8191,d+=R*(5*z),d+=B*(5*j),d+=C*(5*q),d+=P*(5*N),d+=O*(5*L),c+=d>>>13,d&=8191,v=c,v+=x*L,v+=U*K,v+=E*I,v+=S*k,v+=T*M,c=v>>>13,v&=8191,v+=R*(5*F),v+=B*(5*z),v+=C*(5*j),v+=P*(5*q),v+=O*(5*N),c+=v>>>13,v&=8191,b=c,b+=x*N,b+=U*L,b+=E*K,b+=S*I,b+=T*k,c=b>>>13,b&=8191,b+=R*M,b+=B*(5*F),b+=C*(5*z),b+=P*(5*j),b+=O*(5*q),c+=b>>>13,b&=8191,g=c,g+=x*q,g+=U*N,g+=E*L,g+=S*K,g+=T*I,c=g>>>13,g&=8191,g+=R*k,g+=B*M,g+=C*(5*F),g+=P*(5*z),g+=O*(5*j),c+=g>>>13,g&=8191,w=c,w+=x*j,w+=U*q,w+=E*N,w+=S*L,w+=T*K,c=w>>>13,w&=8191,w+=R*I,w+=B*k,w+=C*M,w+=P*(5*F),w+=O*(5*z),c+=w>>>13,w&=8191,m=c,m+=x*z,m+=U*j,m+=E*q,m+=S*N,m+=T*L,c=m>>>13,m&=8191,m+=R*K,m+=B*I,m+=C*k,m+=P*M,m+=O*(5*F),c+=m>>>13,m&=8191,_=c,_+=x*F,_+=U*z,_+=E*j,_+=S*q,_+=T*N,c=_>>>13,_&=8191,_+=R*L,_+=B*K,_+=C*I,_+=P*k,_+=O*M,c+=_>>>13,_&=8191,c=(c<<2)+c|0,c=c+l|0,l=8191&c,c>>>=13,y+=c,x=l,U=y,E=p,S=d,T=v,R=b,B=g,C=w,P=m,O=_,e+=16,r-=16;this.h[0]=x,this.h[1]=U,this.h[2]=E,this.h[3]=S,this.h[4]=T,this.h[5]=R,this.h[6]=B,this.h[7]=C,this.h[8]=P,this.h[9]=O},yt.prototype.finish=function(t,e){var r,n,o,i,s=new Uint16Array(10);if(this.leftover){for(i=this.leftover,this.buffer[i++]=1;16>i;i++)this.buffer[i]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(r=this.h[1]>>>13,this.h[1]&=8191,i=2;10>i;i++)this.h[i]+=r,r=this.h[i]>>>13,this.h[i]&=8191;for(this.h[0]+=5*r,r=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=r,r=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=r,s[0]=this.h[0]+5,r=s[0]>>>13,s[0]&=8191,i=1;10>i;i++)s[i]=this.h[i]+r,r=s[i]>>>13,s[i]&=8191;for(s[9]-=8192,n=(1^r)-1,i=0;10>i;i++)s[i]&=n;for(n=~n,i=0;10>i;i++)this.h[i]=this.h[i]&n|s[i];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),o=this.h[0]+this.pad[0],this.h[0]=65535&o,i=1;8>i;i++)o=(this.h[i]+this.pad[i]|0)+(o>>>16)|0,this.h[i]=65535&o;t[e+0]=this.h[0]>>>0&255,t[e+1]=this.h[0]>>>8&255,t[e+2]=this.h[1]>>>0&255,t[e+3]=this.h[1]>>>8&255,t[e+4]=this.h[2]>>>0&255,t[e+5]=this.h[2]>>>8&255,t[e+6]=this.h[3]>>>0&255,t[e+7]=this.h[3]>>>8&255,t[e+8]=this.h[4]>>>0&255,t[e+9]=this.h[4]>>>8&255,t[e+10]=this.h[5]>>>0&255,t[e+11]=this.h[5]>>>8&255,t[e+12]=this.h[6]>>>0&255,t[e+13]=this.h[6]>>>8&255,t[e+14]=this.h[7]>>>0&255,t[e+15]=this.h[7]>>>8&255},yt.prototype.update=function(t,e,r){var n,o;if(this.leftover){for(o=16-this.leftover,o>r&&(o=r),n=0;o>n;n++)this.buffer[this.leftover+n]=t[e+n];if(r-=o,e+=o,this.leftover+=o,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(r>=16&&(o=r-r%16,this.blocks(t,e,o),e+=o,r-=o),r){for(n=0;r>n;n++)this.buffer[this.leftover+n]=t[e+n];this.leftover+=r}};var pt=v,dt=b,vt=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],bt=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]),gt=32,wt=24,mt=32,_t=16,At=32,xt=32,Ut=32,Et=32,St=32,Tt=wt,Rt=mt,Bt=_t,Ct=64,Pt=32,Ot=64,Mt=32,kt=64;t.lowlevel={crypto_core_hsalsa20:u,crypto_stream_xor:y,crypto_stream:l,crypto_stream_salsa20_xor:f,crypto_stream_salsa20:c,crypto_onetimeauth:p,crypto_onetimeauth_verify:d,crypto_verify_16:o,crypto_verify_32:i,crypto_secretbox:v,crypto_secretbox_open:b,crypto_scalarmult:P,crypto_scalarmult_base:O,crypto_box_beforenm:k,crypto_box_afternm:pt,crypto_box:I,crypto_box_open:K,crypto_box_keypair:M,crypto_hash:N,crypto_sign:J,crypto_sign_keypair:Y,crypto_sign_open:Z,crypto_secretbox_KEYBYTES:gt,crypto_secretbox_NONCEBYTES:wt,crypto_secretbox_ZEROBYTES:mt,crypto_secretbox_BOXZEROBYTES:_t,crypto_scalarmult_BYTES:At,crypto_scalarmult_SCALARBYTES:xt,crypto_box_PUBLICKEYBYTES:Ut,crypto_box_SECRETKEYBYTES:Et,crypto_box_BEFORENMBYTES:St,crypto_box_NONCEBYTES:Tt,crypto_box_ZEROBYTES:Rt,crypto_box_BOXZEROBYTES:Bt,crypto_sign_BYTES:Ct,crypto_sign_PUBLICKEYBYTES:Pt,crypto_sign_SECRETKEYBYTES:Ot,crypto_sign_SEEDBYTES:Mt,crypto_hash_BYTES:kt},t.util||(t.util={},t.util.decodeUTF8=t.util.encodeUTF8=t.util.encodeBase64=t.util.decodeBase64=function(){throw new Error("nacl.util moved into separate package: https://github.com/dchest/tweetnacl-util-js")}),t.randomBytes=function(t){var e=new Uint8Array(t);return et(e,t),e},t.secretbox=function(t,e,r){Q(t,e,r),V(r,e);for(var n=new Uint8Array(mt+t.length),o=new Uint8Array(n.length),i=0;i<t.length;i++)n[i+mt]=t[i];return v(o,n,n.length,e,r),o.subarray(_t)},t.secretbox.open=function(t,e,r){Q(t,e,r),V(r,e);for(var n=new Uint8Array(_t+t.length),o=new Uint8Array(n.length),i=0;i<t.length;i++)n[i+_t]=t[i];return n.length<32?!1:0!==b(o,n,n.length,e,r)?!1:o.subarray(mt)},t.secretbox.keyLength=gt,t.secretbox.nonceLength=wt,t.secretbox.overheadLength=_t,t.scalarMult=function(t,e){if(Q(t,e),t.length!==xt)throw new Error("bad n size");if(e.length!==At)throw new Error("bad p size");
  2. var r=new Uint8Array(At);return P(r,t,e),r},t.scalarMult.base=function(t){if(Q(t),t.length!==xt)throw new Error("bad n size");var e=new Uint8Array(At);return O(e,t),e},t.scalarMult.scalarLength=xt,t.scalarMult.groupElementLength=At,t.box=function(e,r,n,o){var i=t.box.before(n,o);return t.secretbox(e,r,i)},t.box.before=function(t,e){Q(t,e),W(t,e);var r=new Uint8Array(St);return k(r,t,e),r},t.box.after=t.secretbox,t.box.open=function(e,r,n,o){var i=t.box.before(n,o);return t.secretbox.open(e,r,i)},t.box.open.after=t.secretbox.open,t.box.keyPair=function(){var t=new Uint8Array(Ut),e=new Uint8Array(Et);return M(t,e),{publicKey:t,secretKey:e}},t.box.keyPair.fromSecretKey=function(t){if(Q(t),t.length!==Et)throw new Error("bad secret key size");var e=new Uint8Array(Ut);return O(e,t),{publicKey:e,secretKey:new Uint8Array(t)}},t.box.publicKeyLength=Ut,t.box.secretKeyLength=Et,t.box.sharedKeyLength=St,t.box.nonceLength=Tt,t.box.overheadLength=t.secretbox.overheadLength,t.sign=function(t,e){if(Q(t,e),e.length!==Ot)throw new Error("bad secret key size");var r=new Uint8Array(Ct+t.length);return J(r,t,t.length,e),r},t.sign.open=function(t,e){if(2!==arguments.length)throw new Error("nacl.sign.open accepts 2 arguments; did you mean to use nacl.sign.detached.verify?");if(Q(t,e),e.length!==Pt)throw new Error("bad public key size");var r=new Uint8Array(t.length),n=Z(r,t,t.length,e);if(0>n)return null;for(var o=new Uint8Array(n),i=0;i<o.length;i++)o[i]=r[i];return o},t.sign.detached=function(e,r){for(var n=t.sign(e,r),o=new Uint8Array(Ct),i=0;i<o.length;i++)o[i]=n[i];return o},t.sign.detached.verify=function(t,e,r){if(Q(t,e,r),e.length!==Ct)throw new Error("bad signature size");if(r.length!==Pt)throw new Error("bad public key size");var n,o=new Uint8Array(Ct+t.length),i=new Uint8Array(Ct+t.length);for(n=0;Ct>n;n++)o[n]=e[n];for(n=0;n<t.length;n++)o[n+Ct]=t[n];return Z(i,o,o.length,r)>=0},t.sign.keyPair=function(){var t=new Uint8Array(Pt),e=new Uint8Array(Ot);return Y(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(Q(t),t.length!==Ot)throw new Error("bad secret key size");for(var e=new Uint8Array(Pt),r=0;r<e.length;r++)e[r]=t[32+r];return{publicKey:e,secretKey:new Uint8Array(t)}},t.sign.keyPair.fromSeed=function(t){if(Q(t),t.length!==Mt)throw new Error("bad seed size");for(var e=new Uint8Array(Pt),r=new Uint8Array(Ot),n=0;32>n;n++)r[n]=t[n];return Y(e,r,!0),{publicKey:e,secretKey:r}},t.sign.publicKeyLength=Pt,t.sign.secretKeyLength=Ot,t.sign.seedLength=Mt,t.sign.signatureLength=Ct,t.hash=function(t){Q(t);var e=new Uint8Array(kt);return N(e,t,t.length),e},t.hash.hashLength=kt,t.verify=function(t,e){return Q(t,e),0===t.length||0===e.length?!1:t.length!==e.length?!1:0===n(t,0,e,0,t.length)},t.setPRNG=function(t){et=t},function(){var e="undefined"!=typeof self?self.crypto||self.msCrypto:null;if(e&&e.getRandomValues){var n=65536;t.setPRNG(function(t,r){var o,i=new Uint8Array(r);for(o=0;r>o;o+=n)e.getRandomValues(i.subarray(o,o+Math.min(r-o,n)));for(o=0;r>o;o++)t[o]=i[o];$(i)})}else e=r(18),e&&e.randomBytes&&t.setPRNG(function(t,r){var n,o=e.randomBytes(r);for(n=0;r>n;n++)t[n]=o[n];$(o)})}()}("undefined"!=typeof t&&t.exports?t.exports:self.nacl=self.nacl||{})},function(t,e){function r(){u=!1,s.length?h=s.concat(h):f=-1,h.length&&n()}function n(){if(!u){var t=setTimeout(r);u=!0;for(var e=h.length;e;){for(s=h,h=[];++f<e;)s&&s[f].run();f=-1,e=h.length}s=null,u=!1,clearTimeout(t)}}function o(t,e){this.fun=t,this.array=e}function i(){}var s,a=t.exports={},h=[],u=!1,f=-1;a.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];h.push(new o(t,e)),1!==h.length||u||setTimeout(n,0)},o.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=i,a.addListener=i,a.once=i,a.off=i,a.removeListener=i,a.removeAllListeners=i,a.emit=i,a.binding=function(t){throw new Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(t){throw new Error("process.chdir is not supported")},a.umask=function(){return 0}},function(t,e,r){var n;(function(t,o,i){/*!
  3. * @overview es6-promise - a tiny implementation of Promises/A+.
  4. * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
  5. * @license Licensed under MIT license
  6. * See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE
  7. * @version 3.1.2
  8. */
  9. (function(){"use strict";
  10. function s(t){return"function"==typeof t||"object"==typeof t&&null!==t}
  11. function a(t){return"function"==typeof t}
  12. function h(t){J=t}
  13. function u(t){W=t}
  14. function f(){return function(){t.nextTick(d)}}
  15. function c(){return function(){H(d)}}
  16. function l(){var t=0,e=new tt(d),r=document.createTextNode("");
  17. return e.observe(r,{characterData:!0}),function(){r.data=t=++t%2}}
  18. function y(){var t=new MessageChannel;
  19. return t.port1.onmessage=d,function(){t.port2.postMessage(0)}}
  20. function p(){return function(){setTimeout(d,1)}}
  21. function d(){for(var t=0;V>t;t+=2){var e=nt[t],r=nt[t+1];e(r),nt[t]=void 0,nt[t+1]=void 0}V=0}
  22. function v(){try{var t=r(17);return H=t.runOnLoop||t.runOnContext,c()}catch(e){return p()}}
  23. function b(t,e){var r=this,n=r._state;if(n===at&&!t||n===ht&&!e)return this;var o=new this.constructor(w),i=r._result;if(n){var s=arguments[n-1];W(function(){I(n,o,s,i)})}else P(r,o,t,e);return o}
  24. function g(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var r=new e(w);return T(r,t),r}
  25. function w(){}
  26. function m(){return new TypeError("You cannot resolve a promise with itself")}
  27. function _(){return new TypeError("A promises callback cannot return that same promise.")}
  28. function A(t){try{return t.then}catch(e){return ut.error=e,ut}}
  29. function x(t,e,r,n){try{t.call(e,r,n)}catch(o){return o}}
  30. function U(t,e,r){W(function(t){var n=!1,o=x(r,e,function(r){n||(n=!0,e!==r?T(t,r):B(t,r))},function(e){n||(n=!0,C(t,e))},"Settle: "+(t._label||" unknown promise"));!n&&o&&(n=!0,C(t,o))},t)}
  31. function E(t,e){e._state===at?B(t,e._result):e._state===ht?C(t,e._result):P(e,void 0,function(e){T(t,e)},function(e){C(t,e)})}
  32. function S(t,e,r){e.constructor===t.constructor&&r===ot&&constructor.resolve===it?E(t,e):r===ut?C(t,ut.error):void 0===r?B(t,e):a(r)?U(t,e,r):B(t,e)}
  33. function T(t,e){t===e?C(t,m()):s(e)?S(t,e,A(e)):B(t,e)}
  34. function R(t){t._onerror&&t._onerror(t._result),O(t)}
  35. function B(t,e){t._state===st&&(t._result=e,t._state=at,0!==t._subscribers.length&&W(O,t))}
  36. function C(t,e){t._state===st&&(t._state=ht,t._result=e,W(R,t))}
  37. function P(t,e,r,n){var o=t._subscribers,i=o.length;t._onerror=null,o[i]=e,o[i+at]=r,o[i+ht]=n,0===i&&t._state&&W(O,t)}
  38. function O(t){var e=t._subscribers,r=t._state;if(0!==e.length){for(var n,o,i=t._result,s=0;s<e.length;s+=3)n=e[s],o=e[s+r],n?I(r,n,o,i):o(i);t._subscribers.length=0}}
  39. function M(){this.error=null}
  40. function k(t,e){try{return t(e)}catch(r){return ft.error=r,ft}}
  41. function I(t,e,r,n){var o,i,s,h,u=a(r);if(u){if(o=k(r,n),o===ft?(h=!0,i=o.error,o=null):s=!0,e===o)return void C(e,_())}else o=n,s=!0;e._state!==st||(u&&s?T(e,o):h?C(e,i):t===at?B(e,o):t===ht&&C(e,o))}
  42. function K(t,e){try{e(function(e){T(t,e)},function(e){C(t,e)})}catch(r){C(t,r)}}
  43. function L(t){return new vt(this,t).promise}
  44. function N(t){function e(t){T(o,t)}function r(t){C(o,t)}var n=this,o=new n(w);if(!Z(t))return C(o,new TypeError("You must pass an array to race.")),o;for(var i=t.length,s=0;o._state===st&&i>s;s++)P(n.resolve(t[s]),void 0,e,r);return o}
  45. function q(t){var e=this,r=new e(w);return C(r,t),r}
  46. function j(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}
  47. function z(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}
  48. function F(t){this._id=pt++,this._state=void 0,this._result=void 0,this._subscribers=[],w!==t&&("function"!=typeof t&&j(),this instanceof F?K(this,t):z())}
  49. function D(t,e){this._instanceConstructor=t,this.promise=new t(w),Array.isArray(e)?(this._input=e,this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?B(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&B(this.promise,this._result))):C(this.promise,this._validationError())}
  50. function Y(){var t;if("undefined"!=typeof o)t=o;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var r=t.Promise;r&&"[object Promise]"===Object.prototype.toString.call(r.resolve())&&!r.cast||(t.Promise=dt)}var G;G=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var H,J,X,Z=G,V=0,W=function(t,e){nt[V]=t,nt[V+1]=e,V+=2,2===V&&(J?J(d):X())},Q="undefined"!=typeof window?window:void 0,$=Q||{},tt=$.MutationObserver||$.WebKitMutationObserver,et="undefined"!=typeof t&&"[object process]"==={}.toString.call(t),rt="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,nt=new Array(1e3);X=et?f():tt?l():rt?y():void 0===Q?v():p();var ot=b,it=g,st=void 0,at=1,ht=2,ut=new M,ft=new M,ct=L,lt=N,yt=q,pt=0,dt=F;F.all=ct,F.race=lt,F.resolve=it,F.reject=yt,F._setScheduler=h,F._setAsap=u,F._asap=W,F.prototype={constructor:F,then:ot,"catch":function(t){return this.then(null,t)}};var vt=D;D.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},D.prototype._enumerate=function(){for(var t=this.length,e=this._input,r=0;this._state===st&&t>r;r++)this._eachEntry(e[r],r)},D.prototype._eachEntry=function(t,e){var r=this._instanceConstructor,n=r.resolve;if(n===it){var o=A(t);if(o===ot&&t._state!==st)this._settledAt(t._state,e,t._result);else if("function"!=typeof o)this._remaining--,this._result[e]=t;else if(r===dt){var i=new r(w);S(i,t,o),this._willSettleAt(i,e)}else this._willSettleAt(new r(function(e){e(t)}),e)}else this._willSettleAt(n(t),e)},D.prototype._settledAt=function(t,e,r){var n=this.promise;n._state===st&&(this._remaining--,t===ht?C(n,r):this._result[e]=r),0===this._remaining&&B(n,this._result)},D.prototype._willSettleAt=function(t,e){var r=this;P(t,void 0,function(t){r._settledAt(at,e,t)},function(t){r._settledAt(ht,e,t)})};var bt=Y,gt={Promise:dt,polyfill:bt};r(8).amd?(n=function(){return gt}.call(e,r,e,i),!(void 0!==n&&(i.exports=n))):"undefined"!=typeof i&&i.exports?i.exports=gt:"undefined"!=typeof this&&(this.ES6Promise=gt),bt()}).call(this)}).call(e,r(4),function(){return this}(),r(9)(t))},function(t,e,r){r(7),t.exports=self.fetch.bind(self)},function(t,e){!function(t){"use strict";function e(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function r(t){return"string"!=typeof t&&(t=String(t)),t}
  51. function n(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return d.iterable&&(e[Symbol.iterator]=function(){return e}),e}
  52. function o(t){this.map={},t instanceof o?t.forEach(function(t,e){this.append(e,t)},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function i(t){return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function s(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function a(t){var e=new FileReader;return e.readAsArrayBuffer(t),s(e)}function h(t){var e=new FileReader;return e.readAsText(t),s(e)}function u(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,"string"==typeof t)this._bodyText=t;else if(d.blob&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(d.formData&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(d.searchParams&&URLSearchParams.prototype.isPrototypeOf(t))this._bodyText=t.toString();else if(t){if(!d.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(t))throw new Error("unsupported BodyInit type")}else this._bodyText="";this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):d.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},d.blob?(this.blob=function(){var t=i(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this.blob().then(a)},this.text=function(){var t=i(this);if(t)return t;if(this._bodyBlob)return h(this._bodyBlob);if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)}):this.text=function(){var t=i(this);return t?t:Promise.resolve(this._bodyText)},d.formData&&(this.formData=function(){return this.text().then(l)}),this.json=function(){return this.text().then(JSON.parse)},this}
  53. function f(t){var e=t.toUpperCase();return v.indexOf(e)>-1?e:t}
  54. function c(t,e){e=e||{};var r=e.body;if(c.prototype.isPrototypeOf(t)){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new o(t.headers)),this.method=t.method,this.mode=t.mode,r||(r=t._bodyInit,t.bodyUsed=!0)}else this.url=t;if(this.credentials=e.credentials||this.credentials||"omit",!e.headers&&this.headers||(this.headers=new o(e.headers)),this.method=f(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function l(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(o))}}),e}
  55. function y(t){var e=new o,r=(t.getAllResponseHeaders()||"").trim().split("\n");return r.forEach(function(t){var r=t.trim().split(":"),n=r.shift().trim(),o=r.join(":").trim();e.append(n,o)}),e}
  56. function p(t,e){e||(e={}),this.type="default",this.status=e.status,this.ok=this.status>=200&&this.status<300,this.statusText=e.statusText,this.headers=e.headers instanceof o?e.headers:new o(e.headers),this.url=e.url||"",this._initBody(t)}if(!t.fetch){var d={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};o.prototype.append=function(t,n){t=e(t),n=r(n);var o=this.map[t];o||(o=[],this.map[t]=o),o.push(n)},o.prototype["delete"]=function(t){delete this.map[e(t)]},o.prototype.get=function(t){var r=this.map[e(t)];return r?r[0]:null},o.prototype.getAll=function(t){return this.map[e(t)]||[]},o.prototype.has=function(t){return this.map.hasOwnProperty(e(t))},o.prototype.set=function(t,n){this.map[e(t)]=[r(n)]},o.prototype.forEach=function(t,e){Object.getOwnPropertyNames(this.map).forEach(function(r){this.map[r].forEach(function(n){t.call(e,n,r,this)},this)},this)},o.prototype.keys=function(){var t=[];return this.forEach(function(e,r){t.push(r)}),n(t)},o.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),n(t)},o.prototype.entries=function(){var t=[];return this.forEach(function(e,r){t.push([r,e])}),n(t)},d.iterable&&(o.prototype[Symbol.iterator]=o.prototype.entries);var v=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];c.prototype.clone=function(){return new c(this)},u.call(c.prototype),u.call(p.prototype),p.prototype.clone=function(){return new p(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new o(this.headers),url:this.url})},p.error=function(){var t=new p(null,{status:0,statusText:""});return t.type="error",t};var b=[301,302,303,307,308];p.redirect=function(t,e){if(-1===b.indexOf(e))throw new RangeError("Invalid status code");return new p(null,{status:e,headers:{location:t}})},t.Headers=o,t.Request=c,t.Response=p,t.fetch=function(t,e){return new Promise(function(r,n){function o(){return"responseURL"in s?s.responseURL:/^X-Request-URL:/m.test(s.getAllResponseHeaders())?s.getResponseHeader("X-Request-URL"):void 0}var i;i=c.prototype.isPrototypeOf(t)&&!e?t:new c(t,e);var s=new XMLHttpRequest;s.onload=function(){var t={status:s.status,statusText:s.statusText,headers:y(s),url:o()},e="response"in s?s.response:s.responseText;r(new p(e,t))},s.onerror=function(){n(new TypeError("Network request failed"))},s.ontimeout=function(){n(new TypeError("Network request failed"))},s.open(i.method,i.url,!0),"include"===i.credentials&&(s.withCredentials=!0),"responseType"in s&&d.blob&&(s.responseType="blob"),i.headers.forEach(function(t,e){s.setRequestHeader(e,t)}),s.send("undefined"==typeof i._bodyInit?null:i._bodyInit)})},t.fetch.polyfill=!0}}("undefined"!=typeof self?self:this)},function(t,e){t.exports=function(){throw new Error("define cannot be used indirect")}},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children=[],t.webpackPolyfill=1),t}},function(t,e,r){function n(){this._auth={token:null,symKey:null,symNonce:null}}var o=r(3),i=r(2),s=r(1);t.exports={authenticate:function(){var t=this.storage.get();return t?(this.log("Auth data stored, checking validity..."),this._auth=s.unserialize(t),this.auth.isAuth().then(function(t){return t===!1?this.auth.authorize():void 0}.bind(this))):(this.log("No auth data stored, starting authorization from scratch..."),this.auth.authorize())},authorize:function(){this.log("Authorizing...");var t=o.box.keyPair(),e=o.randomBytes(o.box.nonceLength),r={app:this.app,publicKey:i.fromByteArray(t.publicKey),nonce:i.fromByteArray(e),permissions:this.permissions};return this.Request.post("/auth").body(r).execute().then(function(r){var n=i.toByteArray(r.publicKey),a=i.toByteArray(r.encryptedKey),h=o.box.open(a,e,n,t.secretKey);this._auth={token:r.token,symKey:h.slice(0,o.secretbox.keyLength),symNonce:h.slice(o.secretbox.keyLength)},this.storage.set(s.serialize(this._auth)),this.log("Authorized")}.bind(this),function(t){this.log("Could not authorize."),this.storage.clear()}.bind(this))},isAuth:function(){return this.log("Checking if authorized..."),this.Request.get("/auth").auth().execute().then(function(){return this.log("Authorized"),!0}.bind(this),function(t){if(this.log("Not authorized, or received error.",t),401===t.status)return this.log("Not authorized, removing any stored auth data."),n.call(this),!1;throw t}.bind(this))},deauthorize:function(){return this.log("Deauthorizing..."),this.Request["delete"]("/auth").auth().execute().then(function(t){return this.storage.clear(),n.call(this),this.log("Deauthorized and cleared from storage."),t}.bind(this))}}},function(t,e){t.exports={listNames:function(){return this.Request.get("/dns").auth().execute()},createName:function(t){return this.Request.post("/dns/"+encodeURIComponent(t)).auth().execute()},deleteName:function(t){return this.Request["delete"]("/dns/"+encodeURIComponent(t)).auth().execute()},listServices:function(t){return this.Request.get("/dns/"+encodeURIComponent(t)).auth().execute()},createServiceAndName:function(t){return this.Request.post("/dns").auth().body(t).execute()},createServiceForName:function(t){return this.Request.put("/dns").auth().body(t).execute()},getServiceDir:function(t,e){return this.Request.get("/dns/"+encodeURIComponent(t)+"/"+encodeURIComponent(e)).execute()},getFile:function(t,e,r,n){var o={};return n.offset&&(o.offset=n.offset),n.length&&(o.length=n.length),this.Request.get("/dns/"+encodeURIComponent(t)+"/"+encodeURIComponent(e)+"/"+encodeURIComponent(r)).query(o).returnMeta().execute()},deleteService:function(t,e){return this.Request["delete"]("/dns/"+encodeURIComponent(t)+"/"+encodeURIComponent(e)).auth().execute()}}},function(t,e,r){function n(t){return"string"==typeof t?"true"===t?"true":"false":t?"true":"false"}var o=r(1).decodeUTF8;t.exports={createDirectory:function(t,e){e&&e.metadata&&(e.metadata=btoa(e.metadata));var r=Object.assign({},{dirPath:t},e);return this.Request.post("/nfs/directory").auth().body(r).execute()},getDirectory:function(t,e){return this.Request.get("/nfs/directory/"+encodeURIComponent(t)+"/"+n(e.isPathShared)).auth().execute().then(function(t){return t.info.metadata&&(t.info.metadata=atob(t.info.metadata)),t})},deleteDirectory:function(t,e){return this.Request["delete"]("/nfs/directory/"+encodeURIComponent(t)+"/"+n(e.isPathShared)).auth().execute()},createFile:function(t,e){e&&e.metadata&&(e.metadata=btoa(e.metadata));var r=Object.assign({},{filePath:t},e);return this.Request.post("/nfs/file").auth().body(r).execute()},updateFile:function(t,e,r){ArrayBuffer.isView(e)&&(e=o(e));var i={};return r.offset&&(i.offset=r.offset),this.Request.put("/nfs/file/"+encodeURIComponent(t)+"/"+n(r.isPathShared)).auth().body(e).query(i).execute()},getFile:function(t,e){var r={};return e.offset&&(r.offset=e.offset),e.length&&(r.length=e.length),this.Request.get("/nfs/file/"+encodeURIComponent(t)+"/"+n(e.isPathShared)).query(r).auth().returnMeta().execute()},deleteFile:function(t,e){return this.Request["delete"]("/nfs/file/"+encodeURIComponent(t)+"/"+n(e.isPathShared)).auth().execute()}}},function(t,e,r){r(5).polyfill(),r(6),"function"!=typeof Object.assign&&(Object.assign=function(t){"use strict";if(void 0===t||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),r=1;r<arguments.length;r++){var n=arguments[r];if(void 0!==n&&null!==n)for(var o in n)n.hasOwnProperty(o)&&(e[o]=n[o])}return e})},function(t,e,r){function n(t){return this?void(this.Safe=t):new n(t)}function o(t,e,r){return this?(this.Safe=t,this.uri=e,this.method=r,this._needAuth=!1,void(this._returnMeta=!1)):new o(t,e,r)}function i(t){return Safe.log("Received response: ",t),t.text().then(function(e){if(Safe.log("Launcher returned status "+t.status),t.ok){if(!this._needAuth||y.indexOf(e)>-1)var r=l.parseJson(e);else var r=l.decrypt(e,this.Safe.getAuth("symNonce"),this.Safe.getAuth("symKey"));
  57. return this._returnMeta?{body:r,meta:t.headers.entries}:"string"==typeof r&&"OK"===r.toUpperCase()?void 0:r}if(this._needAuth&&-1===y.indexOf(e)){var n=l.decrypt(e,this.Safe.getAuth("symNonce"),this.Safe.getAuth("symKey")),o=f(n,t.status);throw new h("launcher",o.message,o.status,t)}var o=f(l.parseJson(e),t.status);throw new h("http",o.message,o.status,t)}.bind(this))}function s(t){throw new h("network","Could not connect to SAFE launcher. Is it running?")}function a(t){if(t.isSafeError)throw t;throw new h("error",t.message,0)}function h(t,e,r,n){this.isSafeError=!0,this.type=t,this.message=e,this.status=r||0,this.response=n,this.toString=function(){return this.type+": "+this.message+" ("+this.status+")"}}function u(){var t=o.baseUrl+this.uri;if(this._query&&Object.keys(this._query).length>0){var e=c(this._query);return this._needAuth&&(e=l.encrypt(e,this.Safe.getAuth("symNonce"),this.Safe.getAuth("symKey"))),t+"?"+e}return t}
  58. function f(t,e){return"object"==typeof t?{status:t.errorCode,message:t.description}:{status:e,message:t}}
  59. function c(t){var e=[];for(var r in t)t.hasOwnProperty(r)&&e.push(encodeURIComponent(r)+"="+encodeURIComponent(t[r]));return e.join("&")}
  60. var l=r(1),y=["OK","Unauthorized","Server Error"];t.exports.Factory=n,n.prototype.get=function(t){return new o(this.Safe,t,"GET")},n.prototype.post=function(t){return new o(this.Safe,t,"POST")},n.prototype.put=function(t){return new o(this.Safe,t,"PUT")},n.prototype["delete"]=function(t){return new o(this.Safe,t,"DELETE")},o.baseUrl="http://localhost:8100",o.prototype.body=function(t){return this._body=t,this},o.prototype.auth=function(){return this._needAuth=!0,this},o.prototype.query=function(t){return this._query=t,this},o.prototype.returnMeta=function(){return this._returnMeta=!0,this},o.prototype.execute=function(){var t={};t.method=this.method.toUpperCase(),t.mode="cors",t.headers={},this._body&&(t.body="string"!=typeof this._body?JSON.stringify(this._body):this._body,this._needAuth&&(t.body=l.encrypt(t.body,this.Safe.getAuth("symNonce"),this.Safe.getAuth("symKey")))),this._needAuth&&(t.headers.Authorization="Bearer "+this.Safe.getAuth("token")),["POST","PUT"].indexOf(t.method)>-1&&(t.headers["Content-Type"]=this._needAuth?"text/plain":"application/json");var e=u.call(this);return Safe.log("Executing "+t.method+' request with uri "'+e+'" and payload: ',t),fetch(e,t).then(i.bind(this),s.bind(this))["catch"](a.bind(this))},t.exports.Request=o},function(t,e,r){function n(t,e,r){if(e=e||[],r=r||{},!(t.name&&t.version&&t.vendor&&t.id))throw new Error("`app` must be an object containing name, version, vendor, and id.");if(r.storage)this.storage=r.storage;else{if("undefined"==typeof localStorage)throw new Error("Default storage is localStorage, which is not present in this environment. You must provide a storage class that has the `set`, `get`, and `clear` methods. See readme for details.");this.storage=s.localStorage}this.app=t,this.permissions=e,this.Request=new i(this),this._auth={token:null,symKey:null,symNonce:null},o.call(this),n.log("Instantiated new Safe instance.")}function o(){for(var t in a){for(var e in a[t])a[t][e]=a[t][e].bind(this);this[t]=a[t]}}var i=r(14).Factory,s=r(16),a={auth:r(10),dns:r(11),nfs:r(12)};n.log=function(){},n.prototype.log=function(){this.constructor.log.apply(this,arguments)},n.prototype.getAuth=function(t){return t?this._auth[t]:this._auth},t.exports=n},function(t,e){t.exports={localStorage:{set:function(t){localStorage.setItem("auth",t)},get:function(){return localStorage.getItem("auth")},clear:function(){localStorage.removeItem("auth")}}}},function(t,e){},function(t,e){}]);