@junobuild/core 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import{a as Nr,b as On,c as Rr,d as Pn,e as Te,f as Un,g as Oe,h as Pe,i as Nn,j as tr,k as Vt,l as er,m as Rn,p as Br,q as Kr}from"./chunk-VT367M3F.js";var Cr={};Pn(Cr,{default:()=>Bn});var Bn,Mr=On(()=>{Bn={}});var jr=Rr((ci,Ue)=>{var Ft=(Mr(),Un(Cr));if(Ft&&Ft.default){Ue.exports=Ft.default;for(let e in Ft)Ue.exports[e]=Ft[e]}else Ft&&(Ue.exports=Ft)});var rr=Rr((li,Ne)=>{(function(e){"use strict";var n=function(r){var o,i=new Float64Array(16);if(r)for(o=0;o<r.length;o++)i[o]=r[o];return i},a=function(){throw new Error("no PRNG")},u=new Uint8Array(16),h=new Uint8Array(32);h[0]=9;var m=n(),v=n([1]),B=n([56129,1]),C=n([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),U=n([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),tt=n([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),rt=n([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),ht=n([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function Ot(r,o,i,t){r[o]=i>>24&255,r[o+1]=i>>16&255,r[o+2]=i>>8&255,r[o+3]=i&255,r[o+4]=t>>24&255,r[o+5]=t>>16&255,r[o+6]=t>>8&255,r[o+7]=t&255}function vt(r,o,i,t,f){var c,l=0;for(c=0;c<f;c++)l|=r[o+c]^i[t+c];return(1&l-1>>>8)-1}function xt(r,o,i,t){return vt(r,o,i,t,16)}function bt(r,o,i,t){return vt(r,o,i,t,32)}function Fe(r,o,i,t){for(var f=t[0]&255|(t[1]&255)<<8|(t[2]&255)<<16|(t[3]&255)<<24,c=i[0]&255|(i[1]&255)<<8|(i[2]&255)<<16|(i[3]&255)<<24,l=i[4]&255|(i[5]&255)<<8|(i[6]&255)<<16|(i[7]&255)<<24,y=i[8]&255|(i[9]&255)<<8|(i[10]&255)<<16|(i[11]&255)<<24,_=i[12]&255|(i[13]&255)<<8|(i[14]&255)<<16|(i[15]&255)<<24,R=t[4]&255|(t[5]&255)<<8|(t[6]&255)<<16|(t[7]&255)<<24,A=o[0]&255|(o[1]&255)<<8|(o[2]&255)<<16|(o[3]&255)<<24,D=o[4]&255|(o[5]&255)<<8|(o[6]&255)<<16|(o[7]&255)<<24,T=o[8]&255|(o[9]&255)<<8|(o[10]&255)<<16|(o[11]&255)<<24,j=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,Y=t[8]&255|(t[9]&255)<<8|(t[10]&255)<<16|(t[11]&255)<<24,z=i[16]&255|(i[17]&255)<<8|(i[18]&255)<<16|(i[19]&255)<<24,H=i[20]&255|(i[21]&255)<<8|(i[22]&255)<<16|(i[23]&255)<<24,V=i[24]&255|(i[25]&255)<<8|(i[26]&255)<<16|(i[27]&255)<<24,k=i[28]&255|(i[29]&255)<<8|(i[30]&255)<<16|(i[31]&255)<<24,F=t[12]&255|(t[13]&255)<<8|(t[14]&255)<<16|(t[15]&255)<<24,O=f,K=c,S=l,P=y,N=_,E=R,x=A,d=D,b=T,p=j,g=Y,w=z,M=H,W=V,G=k,J=F,s,q=0;q<20;q+=2)s=O+M|0,N^=s<<7|s>>>32-7,s=N+O|0,b^=s<<9|s>>>32-9,s=b+N|0,M^=s<<13|s>>>32-13,s=M+b|0,O^=s<<18|s>>>32-18,s=E+K|0,p^=s<<7|s>>>32-7,s=p+E|0,W^=s<<9|s>>>32-9,s=W+p|0,K^=s<<13|s>>>32-13,s=K+W|0,E^=s<<18|s>>>32-18,s=g+x|0,G^=s<<7|s>>>32-7,s=G+g|0,S^=s<<9|s>>>32-9,s=S+G|0,x^=s<<13|s>>>32-13,s=x+S|0,g^=s<<18|s>>>32-18,s=J+w|0,P^=s<<7|s>>>32-7,s=P+J|0,d^=s<<9|s>>>32-9,s=d+P|0,w^=s<<13|s>>>32-13,s=w+d|0,J^=s<<18|s>>>32-18,s=O+P|0,K^=s<<7|s>>>32-7,s=K+O|0,S^=s<<9|s>>>32-9,s=S+K|0,P^=s<<13|s>>>32-13,s=P+S|0,O^=s<<18|s>>>32-18,s=E+N|0,x^=s<<7|s>>>32-7,s=x+E|0,d^=s<<9|s>>>32-9,s=d+x|0,N^=s<<13|s>>>32-13,s=N+d|0,E^=s<<18|s>>>32-18,s=g+p|0,w^=s<<7|s>>>32-7,s=w+g|0,b^=s<<9|s>>>32-9,s=b+w|0,p^=s<<13|s>>>32-13,s=p+b|0,g^=s<<18|s>>>32-18,s=J+G|0,M^=s<<7|s>>>32-7,s=M+J|0,W^=s<<9|s>>>32-9,s=W+M|0,G^=s<<13|s>>>32-13,s=G+W|0,J^=s<<18|s>>>32-18;O=O+f|0,K=K+c|0,S=S+l|0,P=P+y|0,N=N+_|0,E=E+R|0,x=x+A|0,d=d+D|0,b=b+T|0,p=p+j|0,g=g+Y|0,w=w+z|0,M=M+H|0,W=W+V|0,G=G+k|0,J=J+F|0,r[0]=O>>>0&255,r[1]=O>>>8&255,r[2]=O>>>16&255,r[3]=O>>>24&255,r[4]=K>>>0&255,r[5]=K>>>8&255,r[6]=K>>>16&255,r[7]=K>>>24&255,r[8]=S>>>0&255,r[9]=S>>>8&255,r[10]=S>>>16&255,r[11]=S>>>24&255,r[12]=P>>>0&255,r[13]=P>>>8&255,r[14]=P>>>16&255,r[15]=P>>>24&255,r[16]=N>>>0&255,r[17]=N>>>8&255,r[18]=N>>>16&255,r[19]=N>>>24&255,r[20]=E>>>0&255,r[21]=E>>>8&255,r[22]=E>>>16&255,r[23]=E>>>24&255,r[24]=x>>>0&255,r[25]=x>>>8&255,r[26]=x>>>16&255,r[27]=x>>>24&255,r[28]=d>>>0&255,r[29]=d>>>8&255,r[30]=d>>>16&255,r[31]=d>>>24&255,r[32]=b>>>0&255,r[33]=b>>>8&255,r[34]=b>>>16&255,r[35]=b>>>24&255,r[36]=p>>>0&255,r[37]=p>>>8&255,r[38]=p>>>16&255,r[39]=p>>>24&255,r[40]=g>>>0&255,r[41]=g>>>8&255,r[42]=g>>>16&255,r[43]=g>>>24&255,r[44]=w>>>0&255,r[45]=w>>>8&255,r[46]=w>>>16&255,r[47]=w>>>24&255,r[48]=M>>>0&255,r[49]=M>>>8&255,r[50]=M>>>16&255,r[51]=M>>>24&255,r[52]=W>>>0&255,r[53]=W>>>8&255,r[54]=W>>>16&255,r[55]=W>>>24&255,r[56]=G>>>0&255,r[57]=G>>>8&255,r[58]=G>>>16&255,r[59]=G>>>24&255,r[60]=J>>>0&255,r[61]=J>>>8&255,r[62]=J>>>16&255,r[63]=J>>>24&255}function ke(r,o,i,t){for(var f=t[0]&255|(t[1]&255)<<8|(t[2]&255)<<16|(t[3]&255)<<24,c=i[0]&255|(i[1]&255)<<8|(i[2]&255)<<16|(i[3]&255)<<24,l=i[4]&255|(i[5]&255)<<8|(i[6]&255)<<16|(i[7]&255)<<24,y=i[8]&255|(i[9]&255)<<8|(i[10]&255)<<16|(i[11]&255)<<24,_=i[12]&255|(i[13]&255)<<8|(i[14]&255)<<16|(i[15]&255)<<24,R=t[4]&255|(t[5]&255)<<8|(t[6]&255)<<16|(t[7]&255)<<24,A=o[0]&255|(o[1]&255)<<8|(o[2]&255)<<16|(o[3]&255)<<24,D=o[4]&255|(o[5]&255)<<8|(o[6]&255)<<16|(o[7]&255)<<24,T=o[8]&255|(o[9]&255)<<8|(o[10]&255)<<16|(o[11]&255)<<24,j=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,Y=t[8]&255|(t[9]&255)<<8|(t[10]&255)<<16|(t[11]&255)<<24,z=i[16]&255|(i[17]&255)<<8|(i[18]&255)<<16|(i[19]&255)<<24,H=i[20]&255|(i[21]&255)<<8|(i[22]&255)<<16|(i[23]&255)<<24,V=i[24]&255|(i[25]&255)<<8|(i[26]&255)<<16|(i[27]&255)<<24,k=i[28]&255|(i[29]&255)<<8|(i[30]&255)<<16|(i[31]&255)<<24,F=t[12]&255|(t[13]&255)<<8|(t[14]&255)<<16|(t[15]&255)<<24,O=f,K=c,S=l,P=y,N=_,E=R,x=A,d=D,b=T,p=j,g=Y,w=z,M=H,W=V,G=k,J=F,s,q=0;q<20;q+=2)s=O+M|0,N^=s<<7|s>>>32-7,s=N+O|0,b^=s<<9|s>>>32-9,s=b+N|0,M^=s<<13|s>>>32-13,s=M+b|0,O^=s<<18|s>>>32-18,s=E+K|0,p^=s<<7|s>>>32-7,s=p+E|0,W^=s<<9|s>>>32-9,s=W+p|0,K^=s<<13|s>>>32-13,s=K+W|0,E^=s<<18|s>>>32-18,s=g+x|0,G^=s<<7|s>>>32-7,s=G+g|0,S^=s<<9|s>>>32-9,s=S+G|0,x^=s<<13|s>>>32-13,s=x+S|0,g^=s<<18|s>>>32-18,s=J+w|0,P^=s<<7|s>>>32-7,s=P+J|0,d^=s<<9|s>>>32-9,s=d+P|0,w^=s<<13|s>>>32-13,s=w+d|0,J^=s<<18|s>>>32-18,s=O+P|0,K^=s<<7|s>>>32-7,s=K+O|0,S^=s<<9|s>>>32-9,s=S+K|0,P^=s<<13|s>>>32-13,s=P+S|0,O^=s<<18|s>>>32-18,s=E+N|0,x^=s<<7|s>>>32-7,s=x+E|0,d^=s<<9|s>>>32-9,s=d+x|0,N^=s<<13|s>>>32-13,s=N+d|0,E^=s<<18|s>>>32-18,s=g+p|0,w^=s<<7|s>>>32-7,s=w+g|0,b^=s<<9|s>>>32-9,s=b+w|0,p^=s<<13|s>>>32-13,s=p+b|0,g^=s<<18|s>>>32-18,s=J+G|0,M^=s<<7|s>>>32-7,s=M+J|0,W^=s<<9|s>>>32-9,s=W+M|0,G^=s<<13|s>>>32-13,s=G+W|0,J^=s<<18|s>>>32-18;r[0]=O>>>0&255,r[1]=O>>>8&255,r[2]=O>>>16&255,r[3]=O>>>24&255,r[4]=E>>>0&255,r[5]=E>>>8&255,r[6]=E>>>16&255,r[7]=E>>>24&255,r[8]=g>>>0&255,r[9]=g>>>8&255,r[10]=g>>>16&255,r[11]=g>>>24&255,r[12]=J>>>0&255,r[13]=J>>>8&255,r[14]=J>>>16&255,r[15]=J>>>24&255,r[16]=x>>>0&255,r[17]=x>>>8&255,r[18]=x>>>16&255,r[19]=x>>>24&255,r[20]=d>>>0&255,r[21]=d>>>8&255,r[22]=d>>>16&255,r[23]=d>>>24&255,r[24]=b>>>0&255,r[25]=b>>>8&255,r[26]=b>>>16&255,r[27]=b>>>24&255,r[28]=p>>>0&255,r[29]=p>>>8&255,r[30]=p>>>16&255,r[31]=p>>>24&255}function Wt(r,o,i,t){Fe(r,o,i,t)}function Jt(r,o,i,t){ke(r,o,i,t)}var Pt=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function ye(r,o,i,t,f,c,l){var y=new Uint8Array(16),_=new Uint8Array(64),R,A;for(A=0;A<16;A++)y[A]=0;for(A=0;A<8;A++)y[A]=c[A];for(;f>=64;){for(Wt(_,y,l,Pt),A=0;A<64;A++)r[o+A]=i[t+A]^_[A];for(R=1,A=8;A<16;A++)R=R+(y[A]&255)|0,y[A]=R&255,R>>>=8;f-=64,o+=64,t+=64}if(f>0)for(Wt(_,y,l,Pt),A=0;A<f;A++)r[o+A]=i[t+A]^_[A];return 0}function re(r,o,i,t,f){var c=new Uint8Array(16),l=new Uint8Array(64),y,_;for(_=0;_<16;_++)c[_]=0;for(_=0;_<8;_++)c[_]=t[_];for(;i>=64;){for(Wt(l,c,f,Pt),_=0;_<64;_++)r[o+_]=l[_];for(y=1,_=8;_<16;_++)y=y+(c[_]&255)|0,c[_]=y&255,y>>>=8;i-=64,o+=64}if(i>0)for(Wt(l,c,f,Pt),_=0;_<i;_++)r[o+_]=l[_];return 0}function Mt(r,o,i,t,f){var c=new Uint8Array(32);Jt(c,t,f,Pt);for(var l=new Uint8Array(8),y=0;y<8;y++)l[y]=t[y+16];return re(r,o,i,l,c)}function ne(r,o,i,t,f,c,l){var y=new Uint8Array(32);Jt(y,c,l,Pt);for(var _=new Uint8Array(8),R=0;R<8;R++)_[R]=c[R+16];return ye(r,o,i,t,f,_,y)}var Gt=function(r){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 o,i,t,f,c,l,y,_;o=r[0]&255|(r[1]&255)<<8,this.r[0]=o&8191,i=r[2]&255|(r[3]&255)<<8,this.r[1]=(o>>>13|i<<3)&8191,t=r[4]&255|(r[5]&255)<<8,this.r[2]=(i>>>10|t<<6)&7939,f=r[6]&255|(r[7]&255)<<8,this.r[3]=(t>>>7|f<<9)&8191,c=r[8]&255|(r[9]&255)<<8,this.r[4]=(f>>>4|c<<12)&255,this.r[5]=c>>>1&8190,l=r[10]&255|(r[11]&255)<<8,this.r[6]=(c>>>14|l<<2)&8191,y=r[12]&255|(r[13]&255)<<8,this.r[7]=(l>>>11|y<<5)&8065,_=r[14]&255|(r[15]&255)<<8,this.r[8]=(y>>>8|_<<8)&8191,this.r[9]=_>>>5&127,this.pad[0]=r[16]&255|(r[17]&255)<<8,this.pad[1]=r[18]&255|(r[19]&255)<<8,this.pad[2]=r[20]&255|(r[21]&255)<<8,this.pad[3]=r[22]&255|(r[23]&255)<<8,this.pad[4]=r[24]&255|(r[25]&255)<<8,this.pad[5]=r[26]&255|(r[27]&255)<<8,this.pad[6]=r[28]&255|(r[29]&255)<<8,this.pad[7]=r[30]&255|(r[31]&255)<<8};Gt.prototype.blocks=function(r,o,i){for(var t=this.fin?0:2048,f,c,l,y,_,R,A,D,T,j,Y,z,H,V,k,F,O,K,S,P=this.h[0],N=this.h[1],E=this.h[2],x=this.h[3],d=this.h[4],b=this.h[5],p=this.h[6],g=this.h[7],w=this.h[8],M=this.h[9],W=this.r[0],G=this.r[1],J=this.r[2],s=this.r[3],q=this.r[4],I=this.r[5],L=this.r[6],$=this.r[7],X=this.r[8],Q=this.r[9];i>=16;)f=r[o+0]&255|(r[o+1]&255)<<8,P+=f&8191,c=r[o+2]&255|(r[o+3]&255)<<8,N+=(f>>>13|c<<3)&8191,l=r[o+4]&255|(r[o+5]&255)<<8,E+=(c>>>10|l<<6)&8191,y=r[o+6]&255|(r[o+7]&255)<<8,x+=(l>>>7|y<<9)&8191,_=r[o+8]&255|(r[o+9]&255)<<8,d+=(y>>>4|_<<12)&8191,b+=_>>>1&8191,R=r[o+10]&255|(r[o+11]&255)<<8,p+=(_>>>14|R<<2)&8191,A=r[o+12]&255|(r[o+13]&255)<<8,g+=(R>>>11|A<<5)&8191,D=r[o+14]&255|(r[o+15]&255)<<8,w+=(A>>>8|D<<8)&8191,M+=D>>>5|t,T=0,j=T,j+=P*W,j+=N*(5*Q),j+=E*(5*X),j+=x*(5*$),j+=d*(5*L),T=j>>>13,j&=8191,j+=b*(5*I),j+=p*(5*q),j+=g*(5*s),j+=w*(5*J),j+=M*(5*G),T+=j>>>13,j&=8191,Y=T,Y+=P*G,Y+=N*W,Y+=E*(5*Q),Y+=x*(5*X),Y+=d*(5*$),T=Y>>>13,Y&=8191,Y+=b*(5*L),Y+=p*(5*I),Y+=g*(5*q),Y+=w*(5*s),Y+=M*(5*J),T+=Y>>>13,Y&=8191,z=T,z+=P*J,z+=N*G,z+=E*W,z+=x*(5*Q),z+=d*(5*X),T=z>>>13,z&=8191,z+=b*(5*$),z+=p*(5*L),z+=g*(5*I),z+=w*(5*q),z+=M*(5*s),T+=z>>>13,z&=8191,H=T,H+=P*s,H+=N*J,H+=E*G,H+=x*W,H+=d*(5*Q),T=H>>>13,H&=8191,H+=b*(5*X),H+=p*(5*$),H+=g*(5*L),H+=w*(5*I),H+=M*(5*q),T+=H>>>13,H&=8191,V=T,V+=P*q,V+=N*s,V+=E*J,V+=x*G,V+=d*W,T=V>>>13,V&=8191,V+=b*(5*Q),V+=p*(5*X),V+=g*(5*$),V+=w*(5*L),V+=M*(5*I),T+=V>>>13,V&=8191,k=T,k+=P*I,k+=N*q,k+=E*s,k+=x*J,k+=d*G,T=k>>>13,k&=8191,k+=b*W,k+=p*(5*Q),k+=g*(5*X),k+=w*(5*$),k+=M*(5*L),T+=k>>>13,k&=8191,F=T,F+=P*L,F+=N*I,F+=E*q,F+=x*s,F+=d*J,T=F>>>13,F&=8191,F+=b*G,F+=p*W,F+=g*(5*Q),F+=w*(5*X),F+=M*(5*$),T+=F>>>13,F&=8191,O=T,O+=P*$,O+=N*L,O+=E*I,O+=x*q,O+=d*s,T=O>>>13,O&=8191,O+=b*J,O+=p*G,O+=g*W,O+=w*(5*Q),O+=M*(5*X),T+=O>>>13,O&=8191,K=T,K+=P*X,K+=N*$,K+=E*L,K+=x*I,K+=d*q,T=K>>>13,K&=8191,K+=b*s,K+=p*J,K+=g*G,K+=w*W,K+=M*(5*Q),T+=K>>>13,K&=8191,S=T,S+=P*Q,S+=N*X,S+=E*$,S+=x*L,S+=d*I,T=S>>>13,S&=8191,S+=b*q,S+=p*s,S+=g*J,S+=w*G,S+=M*W,T+=S>>>13,S&=8191,T=(T<<2)+T|0,T=T+j|0,j=T&8191,T=T>>>13,Y+=T,P=j,N=Y,E=z,x=H,d=V,b=k,p=F,g=O,w=K,M=S,o+=16,i-=16;this.h[0]=P,this.h[1]=N,this.h[2]=E,this.h[3]=x,this.h[4]=d,this.h[5]=b,this.h[6]=p,this.h[7]=g,this.h[8]=w,this.h[9]=M},Gt.prototype.finish=function(r,o){var i=new Uint16Array(10),t,f,c,l;if(this.leftover){for(l=this.leftover,this.buffer[l++]=1;l<16;l++)this.buffer[l]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(t=this.h[1]>>>13,this.h[1]&=8191,l=2;l<10;l++)this.h[l]+=t,t=this.h[l]>>>13,this.h[l]&=8191;for(this.h[0]+=t*5,t=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=t,t=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=t,i[0]=this.h[0]+5,t=i[0]>>>13,i[0]&=8191,l=1;l<10;l++)i[l]=this.h[l]+t,t=i[l]>>>13,i[l]&=8191;for(i[9]-=1<<13,f=(t^1)-1,l=0;l<10;l++)i[l]&=f;for(f=~f,l=0;l<10;l++)this.h[l]=this.h[l]&f|i[l];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,c=this.h[0]+this.pad[0],this.h[0]=c&65535,l=1;l<8;l++)c=(this.h[l]+this.pad[l]|0)+(c>>>16)|0,this.h[l]=c&65535;r[o+0]=this.h[0]>>>0&255,r[o+1]=this.h[0]>>>8&255,r[o+2]=this.h[1]>>>0&255,r[o+3]=this.h[1]>>>8&255,r[o+4]=this.h[2]>>>0&255,r[o+5]=this.h[2]>>>8&255,r[o+6]=this.h[3]>>>0&255,r[o+7]=this.h[3]>>>8&255,r[o+8]=this.h[4]>>>0&255,r[o+9]=this.h[4]>>>8&255,r[o+10]=this.h[5]>>>0&255,r[o+11]=this.h[5]>>>8&255,r[o+12]=this.h[6]>>>0&255,r[o+13]=this.h[6]>>>8&255,r[o+14]=this.h[7]>>>0&255,r[o+15]=this.h[7]>>>8&255},Gt.prototype.update=function(r,o,i){var t,f;if(this.leftover){for(f=16-this.leftover,f>i&&(f=i),t=0;t<f;t++)this.buffer[this.leftover+t]=r[o+t];if(i-=f,o+=f,this.leftover+=f,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(i>=16&&(f=i-i%16,this.blocks(r,o,f),o+=f,i-=f),i){for(t=0;t<i;t++)this.buffer[this.leftover+t]=r[o+t];this.leftover+=i}};function ie(r,o,i,t,f,c){var l=new Gt(c);return l.update(i,t,f),l.finish(r,o),0}function ge(r,o,i,t,f,c){var l=new Uint8Array(16);return ie(l,0,i,t,f,c),xt(r,o,l,0)}function oe(r,o,i,t,f){var c;if(i<32)return-1;for(ne(r,0,o,0,i,t,f),ie(r,16,r,32,i-32,r),c=0;c<16;c++)r[c]=0;return 0}function He(r,o,i,t,f){var c,l=new Uint8Array(32);if(i<32||(Mt(l,0,32,t,f),ge(o,16,o,32,i-32,l)!==0))return-1;for(ne(r,0,o,0,i,t,f),c=0;c<32;c++)r[c]=0;return 0}function Ut(r,o){var i;for(i=0;i<16;i++)r[i]=o[i]|0}function ze(r){var o,i,t=1;for(o=0;o<16;o++)i=r[o]+t+65535,t=Math.floor(i/65536),r[o]=i-t*65536;r[0]+=t-1+37*(t-1)}function $t(r,o,i){for(var t,f=~(i-1),c=0;c<16;c++)t=f&(r[c]^o[c]),r[c]^=t,o[c]^=t}function qt(r,o){var i,t,f,c=n(),l=n();for(i=0;i<16;i++)l[i]=o[i];for(ze(l),ze(l),ze(l),t=0;t<2;t++){for(c[0]=l[0]-65517,i=1;i<15;i++)c[i]=l[i]-65535-(c[i-1]>>16&1),c[i-1]&=65535;c[15]=l[15]-32767-(c[14]>>16&1),f=c[15]>>16&1,c[14]&=65535,$t(l,c,1-f)}for(i=0;i<16;i++)r[2*i]=l[i]&255,r[2*i+1]=l[i]>>8}function gr(r,o){var i=new Uint8Array(32),t=new Uint8Array(32);return qt(i,r),qt(t,o),bt(i,0,t,0)}function br(r){var o=new Uint8Array(32);return qt(o,r),o[0]&1}function We(r,o){var i;for(i=0;i<16;i++)r[i]=o[2*i]+(o[2*i+1]<<8);r[15]&=32767}function mt(r,o,i){for(var t=0;t<16;t++)r[t]=o[t]+i[t]}function wt(r,o,i){for(var t=0;t<16;t++)r[t]=o[t]-i[t]}function Z(r,o,i){var t,f,c=0,l=0,y=0,_=0,R=0,A=0,D=0,T=0,j=0,Y=0,z=0,H=0,V=0,k=0,F=0,O=0,K=0,S=0,P=0,N=0,E=0,x=0,d=0,b=0,p=0,g=0,w=0,M=0,W=0,G=0,J=0,s=i[0],q=i[1],I=i[2],L=i[3],$=i[4],X=i[5],Q=i[6],ft=i[7],et=i[8],nt=i[9],it=i[10],ot=i[11],at=i[12],st=i[13],ct=i[14],lt=i[15];t=o[0],c+=t*s,l+=t*q,y+=t*I,_+=t*L,R+=t*$,A+=t*X,D+=t*Q,T+=t*ft,j+=t*et,Y+=t*nt,z+=t*it,H+=t*ot,V+=t*at,k+=t*st,F+=t*ct,O+=t*lt,t=o[1],l+=t*s,y+=t*q,_+=t*I,R+=t*L,A+=t*$,D+=t*X,T+=t*Q,j+=t*ft,Y+=t*et,z+=t*nt,H+=t*it,V+=t*ot,k+=t*at,F+=t*st,O+=t*ct,K+=t*lt,t=o[2],y+=t*s,_+=t*q,R+=t*I,A+=t*L,D+=t*$,T+=t*X,j+=t*Q,Y+=t*ft,z+=t*et,H+=t*nt,V+=t*it,k+=t*ot,F+=t*at,O+=t*st,K+=t*ct,S+=t*lt,t=o[3],_+=t*s,R+=t*q,A+=t*I,D+=t*L,T+=t*$,j+=t*X,Y+=t*Q,z+=t*ft,H+=t*et,V+=t*nt,k+=t*it,F+=t*ot,O+=t*at,K+=t*st,S+=t*ct,P+=t*lt,t=o[4],R+=t*s,A+=t*q,D+=t*I,T+=t*L,j+=t*$,Y+=t*X,z+=t*Q,H+=t*ft,V+=t*et,k+=t*nt,F+=t*it,O+=t*ot,K+=t*at,S+=t*st,P+=t*ct,N+=t*lt,t=o[5],A+=t*s,D+=t*q,T+=t*I,j+=t*L,Y+=t*$,z+=t*X,H+=t*Q,V+=t*ft,k+=t*et,F+=t*nt,O+=t*it,K+=t*ot,S+=t*at,P+=t*st,N+=t*ct,E+=t*lt,t=o[6],D+=t*s,T+=t*q,j+=t*I,Y+=t*L,z+=t*$,H+=t*X,V+=t*Q,k+=t*ft,F+=t*et,O+=t*nt,K+=t*it,S+=t*ot,P+=t*at,N+=t*st,E+=t*ct,x+=t*lt,t=o[7],T+=t*s,j+=t*q,Y+=t*I,z+=t*L,H+=t*$,V+=t*X,k+=t*Q,F+=t*ft,O+=t*et,K+=t*nt,S+=t*it,P+=t*ot,N+=t*at,E+=t*st,x+=t*ct,d+=t*lt,t=o[8],j+=t*s,Y+=t*q,z+=t*I,H+=t*L,V+=t*$,k+=t*X,F+=t*Q,O+=t*ft,K+=t*et,S+=t*nt,P+=t*it,N+=t*ot,E+=t*at,x+=t*st,d+=t*ct,b+=t*lt,t=o[9],Y+=t*s,z+=t*q,H+=t*I,V+=t*L,k+=t*$,F+=t*X,O+=t*Q,K+=t*ft,S+=t*et,P+=t*nt,N+=t*it,E+=t*ot,x+=t*at,d+=t*st,b+=t*ct,p+=t*lt,t=o[10],z+=t*s,H+=t*q,V+=t*I,k+=t*L,F+=t*$,O+=t*X,K+=t*Q,S+=t*ft,P+=t*et,N+=t*nt,E+=t*it,x+=t*ot,d+=t*at,b+=t*st,p+=t*ct,g+=t*lt,t=o[11],H+=t*s,V+=t*q,k+=t*I,F+=t*L,O+=t*$,K+=t*X,S+=t*Q,P+=t*ft,N+=t*et,E+=t*nt,x+=t*it,d+=t*ot,b+=t*at,p+=t*st,g+=t*ct,w+=t*lt,t=o[12],V+=t*s,k+=t*q,F+=t*I,O+=t*L,K+=t*$,S+=t*X,P+=t*Q,N+=t*ft,E+=t*et,x+=t*nt,d+=t*it,b+=t*ot,p+=t*at,g+=t*st,w+=t*ct,M+=t*lt,t=o[13],k+=t*s,F+=t*q,O+=t*I,K+=t*L,S+=t*$,P+=t*X,N+=t*Q,E+=t*ft,x+=t*et,d+=t*nt,b+=t*it,p+=t*ot,g+=t*at,w+=t*st,M+=t*ct,W+=t*lt,t=o[14],F+=t*s,O+=t*q,K+=t*I,S+=t*L,P+=t*$,N+=t*X,E+=t*Q,x+=t*ft,d+=t*et,b+=t*nt,p+=t*it,g+=t*ot,w+=t*at,M+=t*st,W+=t*ct,G+=t*lt,t=o[15],O+=t*s,K+=t*q,S+=t*I,P+=t*L,N+=t*$,E+=t*X,x+=t*Q,d+=t*ft,b+=t*et,p+=t*nt,g+=t*it,w+=t*ot,M+=t*at,W+=t*st,G+=t*ct,J+=t*lt,c+=38*K,l+=38*S,y+=38*P,_+=38*N,R+=38*E,A+=38*x,D+=38*d,T+=38*b,j+=38*p,Y+=38*g,z+=38*w,H+=38*M,V+=38*W,k+=38*G,F+=38*J,f=1,t=c+f+65535,f=Math.floor(t/65536),c=t-f*65536,t=l+f+65535,f=Math.floor(t/65536),l=t-f*65536,t=y+f+65535,f=Math.floor(t/65536),y=t-f*65536,t=_+f+65535,f=Math.floor(t/65536),_=t-f*65536,t=R+f+65535,f=Math.floor(t/65536),R=t-f*65536,t=A+f+65535,f=Math.floor(t/65536),A=t-f*65536,t=D+f+65535,f=Math.floor(t/65536),D=t-f*65536,t=T+f+65535,f=Math.floor(t/65536),T=t-f*65536,t=j+f+65535,f=Math.floor(t/65536),j=t-f*65536,t=Y+f+65535,f=Math.floor(t/65536),Y=t-f*65536,t=z+f+65535,f=Math.floor(t/65536),z=t-f*65536,t=H+f+65535,f=Math.floor(t/65536),H=t-f*65536,t=V+f+65535,f=Math.floor(t/65536),V=t-f*65536,t=k+f+65535,f=Math.floor(t/65536),k=t-f*65536,t=F+f+65535,f=Math.floor(t/65536),F=t-f*65536,t=O+f+65535,f=Math.floor(t/65536),O=t-f*65536,c+=f-1+37*(f-1),f=1,t=c+f+65535,f=Math.floor(t/65536),c=t-f*65536,t=l+f+65535,f=Math.floor(t/65536),l=t-f*65536,t=y+f+65535,f=Math.floor(t/65536),y=t-f*65536,t=_+f+65535,f=Math.floor(t/65536),_=t-f*65536,t=R+f+65535,f=Math.floor(t/65536),R=t-f*65536,t=A+f+65535,f=Math.floor(t/65536),A=t-f*65536,t=D+f+65535,f=Math.floor(t/65536),D=t-f*65536,t=T+f+65535,f=Math.floor(t/65536),T=t-f*65536,t=j+f+65535,f=Math.floor(t/65536),j=t-f*65536,t=Y+f+65535,f=Math.floor(t/65536),Y=t-f*65536,t=z+f+65535,f=Math.floor(t/65536),z=t-f*65536,t=H+f+65535,f=Math.floor(t/65536),H=t-f*65536,t=V+f+65535,f=Math.floor(t/65536),V=t-f*65536,t=k+f+65535,f=Math.floor(t/65536),k=t-f*65536,t=F+f+65535,f=Math.floor(t/65536),F=t-f*65536,t=O+f+65535,f=Math.floor(t/65536),O=t-f*65536,c+=f-1+37*(f-1),r[0]=c,r[1]=l,r[2]=y,r[3]=_,r[4]=R,r[5]=A,r[6]=D,r[7]=T,r[8]=j,r[9]=Y,r[10]=z,r[11]=H,r[12]=V,r[13]=k,r[14]=F,r[15]=O}function yt(r,o){Z(r,o,o)}function mr(r,o){var i=n(),t;for(t=0;t<16;t++)i[t]=o[t];for(t=253;t>=0;t--)yt(i,i),t!==2&&t!==4&&Z(i,i,o);for(t=0;t<16;t++)r[t]=i[t]}function wr(r,o){var i=n(),t;for(t=0;t<16;t++)i[t]=o[t];for(t=250;t>=0;t--)yt(i,i),t!==1&&Z(i,i,o);for(t=0;t<16;t++)r[t]=i[t]}function be(r,o,i){var t=new Uint8Array(32),f=new Float64Array(80),c,l,y=n(),_=n(),R=n(),A=n(),D=n(),T=n();for(l=0;l<31;l++)t[l]=o[l];for(t[31]=o[31]&127|64,t[0]&=248,We(f,i),l=0;l<16;l++)_[l]=f[l],A[l]=y[l]=R[l]=0;for(y[0]=A[0]=1,l=254;l>=0;--l)c=t[l>>>3]>>>(l&7)&1,$t(y,_,c),$t(R,A,c),mt(D,y,R),wt(y,y,R),mt(R,_,A),wt(_,_,A),yt(A,D),yt(T,y),Z(y,R,y),Z(R,_,D),mt(D,y,R),wt(y,y,R),yt(_,y),wt(R,A,T),Z(y,R,B),mt(y,y,A),Z(R,R,y),Z(y,A,T),Z(A,_,f),yt(_,D),$t(y,_,c),$t(R,A,c);for(l=0;l<16;l++)f[l+16]=y[l],f[l+32]=R[l],f[l+48]=_[l],f[l+64]=A[l];var j=f.subarray(32),Y=f.subarray(16);return mr(j,j),Z(Y,Y,j),qt(r,Y),0}function me(r,o){return be(r,o,h)}function _r(r,o){return a(o,32),me(r,o)}function we(r,o,i){var t=new Uint8Array(32);return be(t,i,o),Jt(r,u,t,Pt)}var vr=oe,wn=He;function _n(r,o,i,t,f,c){var l=new Uint8Array(32);return we(l,f,c),vr(r,o,i,t,l)}function vn(r,o,i,t,f,c){var l=new Uint8Array(32);return we(l,f,c),wn(r,o,i,t,l)}var Er=[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];function Ar(r,o,i,t){for(var f=new Int32Array(16),c=new Int32Array(16),l,y,_,R,A,D,T,j,Y,z,H,V,k,F,O,K,S,P,N,E,x,d,b,p,g,w,M=r[0],W=r[1],G=r[2],J=r[3],s=r[4],q=r[5],I=r[6],L=r[7],$=o[0],X=o[1],Q=o[2],ft=o[3],et=o[4],nt=o[5],it=o[6],ot=o[7],at=0;t>=128;){for(N=0;N<16;N++)E=8*N+at,f[N]=i[E+0]<<24|i[E+1]<<16|i[E+2]<<8|i[E+3],c[N]=i[E+4]<<24|i[E+5]<<16|i[E+6]<<8|i[E+7];for(N=0;N<80;N++)if(l=M,y=W,_=G,R=J,A=s,D=q,T=I,j=L,Y=$,z=X,H=Q,V=ft,k=et,F=nt,O=it,K=ot,x=L,d=ot,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=(s>>>14|et<<32-14)^(s>>>18|et<<32-18)^(et>>>41-32|s<<32-(41-32)),d=(et>>>14|s<<32-14)^(et>>>18|s<<32-18)^(s>>>41-32|et<<32-(41-32)),b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,x=s&q^~s&I,d=et&nt^~et&it,b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,x=Er[N*2],d=Er[N*2+1],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,x=f[N%16],d=c[N%16],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,S=g&65535|w<<16,P=b&65535|p<<16,x=S,d=P,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=(M>>>28|$<<32-28)^($>>>34-32|M<<32-(34-32))^($>>>39-32|M<<32-(39-32)),d=($>>>28|M<<32-28)^(M>>>34-32|$<<32-(34-32))^(M>>>39-32|$<<32-(39-32)),b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,x=M&W^M&G^W&G,d=$&X^$&Q^X&Q,b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,j=g&65535|w<<16,K=b&65535|p<<16,x=R,d=V,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=S,d=P,b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,R=g&65535|w<<16,V=b&65535|p<<16,W=l,G=y,J=_,s=R,q=A,I=D,L=T,M=j,X=Y,Q=z,ft=H,et=V,nt=k,it=F,ot=O,$=K,N%16===15)for(E=0;E<16;E++)x=f[E],d=c[E],b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=f[(E+9)%16],d=c[(E+9)%16],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,S=f[(E+1)%16],P=c[(E+1)%16],x=(S>>>1|P<<32-1)^(S>>>8|P<<32-8)^S>>>7,d=(P>>>1|S<<32-1)^(P>>>8|S<<32-8)^(P>>>7|S<<32-7),b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,S=f[(E+14)%16],P=c[(E+14)%16],x=(S>>>19|P<<32-19)^(P>>>61-32|S<<32-(61-32))^S>>>6,d=(P>>>19|S<<32-19)^(S>>>61-32|P<<32-(61-32))^(P>>>6|S<<32-6),b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,f[E]=g&65535|w<<16,c[E]=b&65535|p<<16;x=M,d=$,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[0],d=o[0],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[0]=M=g&65535|w<<16,o[0]=$=b&65535|p<<16,x=W,d=X,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[1],d=o[1],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[1]=W=g&65535|w<<16,o[1]=X=b&65535|p<<16,x=G,d=Q,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[2],d=o[2],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[2]=G=g&65535|w<<16,o[2]=Q=b&65535|p<<16,x=J,d=ft,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[3],d=o[3],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[3]=J=g&65535|w<<16,o[3]=ft=b&65535|p<<16,x=s,d=et,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[4],d=o[4],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[4]=s=g&65535|w<<16,o[4]=et=b&65535|p<<16,x=q,d=nt,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[5],d=o[5],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[5]=q=g&65535|w<<16,o[5]=nt=b&65535|p<<16,x=I,d=it,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[6],d=o[6],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[6]=I=g&65535|w<<16,o[6]=it=b&65535|p<<16,x=L,d=ot,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[7],d=o[7],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[7]=L=g&65535|w<<16,o[7]=ot=b&65535|p<<16,at+=128,t-=128}return t}function jt(r,o,i){var t=new Int32Array(8),f=new Int32Array(8),c=new Uint8Array(256),l,y=i;for(t[0]=1779033703,t[1]=3144134277,t[2]=1013904242,t[3]=2773480762,t[4]=1359893119,t[5]=2600822924,t[6]=528734635,t[7]=1541459225,f[0]=4089235720,f[1]=2227873595,f[2]=4271175723,f[3]=1595750129,f[4]=2917565137,f[5]=725511199,f[6]=4215389547,f[7]=327033209,Ar(t,f,o,i),i%=128,l=0;l<i;l++)c[l]=o[y-i+l];for(c[i]=128,i=256-128*(i<112?1:0),c[i-9]=0,Ot(c,i-8,y/536870912|0,y<<3),Ar(t,f,c,i),l=0;l<8;l++)Ot(r,8*l,t[l],f[l]);return 0}function _e(r,o){var i=n(),t=n(),f=n(),c=n(),l=n(),y=n(),_=n(),R=n(),A=n();wt(i,r[1],r[0]),wt(A,o[1],o[0]),Z(i,i,A),mt(t,r[0],r[1]),mt(A,o[0],o[1]),Z(t,t,A),Z(f,r[3],o[3]),Z(f,f,U),Z(c,r[2],o[2]),mt(c,c,c),wt(l,t,i),wt(y,c,f),mt(_,c,f),mt(R,t,i),Z(r[0],l,y),Z(r[1],R,_),Z(r[2],_,y),Z(r[3],l,R)}function Sr(r,o,i){var t;for(t=0;t<4;t++)$t(r[t],o[t],i)}function Je(r,o){var i=n(),t=n(),f=n();mr(f,o[2]),Z(i,o[0],f),Z(t,o[1],f),qt(r,t),r[31]^=br(i)<<7}function Ge(r,o,i){var t,f;for(Ut(r[0],m),Ut(r[1],v),Ut(r[2],v),Ut(r[3],m),f=255;f>=0;--f)t=i[f/8|0]>>(f&7)&1,Sr(r,o,t),_e(o,r),_e(r,r),Sr(r,o,t)}function ve(r,o){var i=[n(),n(),n(),n()];Ut(i[0],tt),Ut(i[1],rt),Ut(i[2],v),Z(i[3],tt,rt),Ge(r,i,o)}function $e(r,o,i){var t=new Uint8Array(64),f=[n(),n(),n(),n()],c;for(i||a(o,32),jt(t,o,32),t[0]&=248,t[31]&=127,t[31]|=64,ve(f,t),Je(r,f),c=0;c<32;c++)o[c+32]=r[c];return 0}var Ee=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]);function qe(r,o){var i,t,f,c;for(t=63;t>=32;--t){for(i=0,f=t-32,c=t-12;f<c;++f)o[f]+=i-16*o[t]*Ee[f-(t-32)],i=Math.floor((o[f]+128)/256),o[f]-=i*256;o[f]+=i,o[t]=0}for(i=0,f=0;f<32;f++)o[f]+=i-(o[31]>>4)*Ee[f],i=o[f]>>8,o[f]&=255;for(f=0;f<32;f++)o[f]-=i*Ee[f];for(t=0;t<32;t++)o[t+1]+=o[t]>>8,r[t]=o[t]&255}function Ze(r){var o=new Float64Array(64),i;for(i=0;i<64;i++)o[i]=r[i];for(i=0;i<64;i++)r[i]=0;qe(r,o)}function Tr(r,o,i,t){var f=new Uint8Array(64),c=new Uint8Array(64),l=new Uint8Array(64),y,_,R=new Float64Array(64),A=[n(),n(),n(),n()];jt(f,t,32),f[0]&=248,f[31]&=127,f[31]|=64;var D=i+64;for(y=0;y<i;y++)r[64+y]=o[y];for(y=0;y<32;y++)r[32+y]=f[32+y];for(jt(l,r.subarray(32),i+32),Ze(l),ve(A,l),Je(r,A),y=32;y<64;y++)r[y]=t[y];for(jt(c,r,i+64),Ze(c),y=0;y<64;y++)R[y]=0;for(y=0;y<32;y++)R[y]=l[y];for(y=0;y<32;y++)for(_=0;_<32;_++)R[y+_]+=c[y]*f[_];return qe(r.subarray(32),R),D}function En(r,o){var i=n(),t=n(),f=n(),c=n(),l=n(),y=n(),_=n();return Ut(r[2],v),We(r[1],o),yt(f,r[1]),Z(c,f,C),wt(f,f,r[2]),mt(c,r[2],c),yt(l,c),yt(y,l),Z(_,y,l),Z(i,_,f),Z(i,i,c),wr(i,i),Z(i,i,f),Z(i,i,c),Z(i,i,c),Z(r[0],i,c),yt(t,r[0]),Z(t,t,c),gr(t,f)&&Z(r[0],r[0],ht),yt(t,r[0]),Z(t,t,c),gr(t,f)?-1:(br(r[0])===o[31]>>7&&wt(r[0],m,r[0]),Z(r[3],r[0],r[1]),0)}function Xe(r,o,i,t){var f,c=new Uint8Array(32),l=new Uint8Array(64),y=[n(),n(),n(),n()],_=[n(),n(),n(),n()];if(i<64||En(_,t))return-1;for(f=0;f<i;f++)r[f]=o[f];for(f=0;f<32;f++)r[f+32]=t[f];if(jt(l,r,i),Ze(l),Ge(y,_,l),ve(_,o.subarray(32)),_e(y,_),Je(c,y),i-=64,bt(o,0,c,0)){for(f=0;f<i;f++)r[f]=0;return-1}for(f=0;f<i;f++)r[f]=o[f+64];return i}var Qe=32,Ae=24,fe=32,Zt=16,ae=32,Se=32,se=32,ce=32,De=32,Or=Ae,An=fe,Sn=Zt,Nt=64,Yt=32,Xt=64,Ie=32,Le=64;e.lowlevel={crypto_core_hsalsa20:Jt,crypto_stream_xor:ne,crypto_stream:Mt,crypto_stream_salsa20_xor:ye,crypto_stream_salsa20:re,crypto_onetimeauth:ie,crypto_onetimeauth_verify:ge,crypto_verify_16:xt,crypto_verify_32:bt,crypto_secretbox:oe,crypto_secretbox_open:He,crypto_scalarmult:be,crypto_scalarmult_base:me,crypto_box_beforenm:we,crypto_box_afternm:vr,crypto_box:_n,crypto_box_open:vn,crypto_box_keypair:_r,crypto_hash:jt,crypto_sign:Tr,crypto_sign_keypair:$e,crypto_sign_open:Xe,crypto_secretbox_KEYBYTES:Qe,crypto_secretbox_NONCEBYTES:Ae,crypto_secretbox_ZEROBYTES:fe,crypto_secretbox_BOXZEROBYTES:Zt,crypto_scalarmult_BYTES:ae,crypto_scalarmult_SCALARBYTES:Se,crypto_box_PUBLICKEYBYTES:se,crypto_box_SECRETKEYBYTES:ce,crypto_box_BEFORENMBYTES:De,crypto_box_NONCEBYTES:Or,crypto_box_ZEROBYTES:An,crypto_box_BOXZEROBYTES:Sn,crypto_sign_BYTES:Nt,crypto_sign_PUBLICKEYBYTES:Yt,crypto_sign_SECRETKEYBYTES:Xt,crypto_sign_SEEDBYTES:Ie,crypto_hash_BYTES:Le,gf:n,D:C,L:Ee,pack25519:qt,unpack25519:We,M:Z,A:mt,S:yt,Z:wt,pow2523:wr,add:_e,set25519:Ut,modL:qe,scalarmult:Ge,scalarbase:ve};function Pr(r,o){if(r.length!==Qe)throw new Error("bad key size");if(o.length!==Ae)throw new Error("bad nonce size")}function Tn(r,o){if(r.length!==se)throw new Error("bad public key size");if(o.length!==ce)throw new Error("bad secret key size")}function pt(){for(var r=0;r<arguments.length;r++)if(!(arguments[r]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function Ur(r){for(var o=0;o<r.length;o++)r[o]=0}e.randomBytes=function(r){var o=new Uint8Array(r);return a(o,r),o},e.secretbox=function(r,o,i){pt(r,o,i),Pr(i,o);for(var t=new Uint8Array(fe+r.length),f=new Uint8Array(t.length),c=0;c<r.length;c++)t[c+fe]=r[c];return oe(f,t,t.length,o,i),f.subarray(Zt)},e.secretbox.open=function(r,o,i){pt(r,o,i),Pr(i,o);for(var t=new Uint8Array(Zt+r.length),f=new Uint8Array(t.length),c=0;c<r.length;c++)t[c+Zt]=r[c];return t.length<32||He(f,t,t.length,o,i)!==0?null:f.subarray(fe)},e.secretbox.keyLength=Qe,e.secretbox.nonceLength=Ae,e.secretbox.overheadLength=Zt,e.scalarMult=function(r,o){if(pt(r,o),r.length!==Se)throw new Error("bad n size");if(o.length!==ae)throw new Error("bad p size");var i=new Uint8Array(ae);return be(i,r,o),i},e.scalarMult.base=function(r){if(pt(r),r.length!==Se)throw new Error("bad n size");var o=new Uint8Array(ae);return me(o,r),o},e.scalarMult.scalarLength=Se,e.scalarMult.groupElementLength=ae,e.box=function(r,o,i,t){var f=e.box.before(i,t);return e.secretbox(r,o,f)},e.box.before=function(r,o){pt(r,o),Tn(r,o);var i=new Uint8Array(De);return we(i,r,o),i},e.box.after=e.secretbox,e.box.open=function(r,o,i,t){var f=e.box.before(i,t);return e.secretbox.open(r,o,f)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var r=new Uint8Array(se),o=new Uint8Array(ce);return _r(r,o),{publicKey:r,secretKey:o}},e.box.keyPair.fromSecretKey=function(r){if(pt(r),r.length!==ce)throw new Error("bad secret key size");var o=new Uint8Array(se);return me(o,r),{publicKey:o,secretKey:new Uint8Array(r)}},e.box.publicKeyLength=se,e.box.secretKeyLength=ce,e.box.sharedKeyLength=De,e.box.nonceLength=Or,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(r,o){if(pt(r,o),o.length!==Xt)throw new Error("bad secret key size");var i=new Uint8Array(Nt+r.length);return Tr(i,r,r.length,o),i},e.sign.open=function(r,o){if(pt(r,o),o.length!==Yt)throw new Error("bad public key size");var i=new Uint8Array(r.length),t=Xe(i,r,r.length,o);if(t<0)return null;for(var f=new Uint8Array(t),c=0;c<f.length;c++)f[c]=i[c];return f},e.sign.detached=function(r,o){for(var i=e.sign(r,o),t=new Uint8Array(Nt),f=0;f<t.length;f++)t[f]=i[f];return t},e.sign.detached.verify=function(r,o,i){if(pt(r,o,i),o.length!==Nt)throw new Error("bad signature size");if(i.length!==Yt)throw new Error("bad public key size");var t=new Uint8Array(Nt+r.length),f=new Uint8Array(Nt+r.length),c;for(c=0;c<Nt;c++)t[c]=o[c];for(c=0;c<r.length;c++)t[c+Nt]=r[c];return Xe(f,t,t.length,i)>=0},e.sign.keyPair=function(){var r=new Uint8Array(Yt),o=new Uint8Array(Xt);return $e(r,o),{publicKey:r,secretKey:o}},e.sign.keyPair.fromSecretKey=function(r){if(pt(r),r.length!==Xt)throw new Error("bad secret key size");for(var o=new Uint8Array(Yt),i=0;i<o.length;i++)o[i]=r[32+i];return{publicKey:o,secretKey:new Uint8Array(r)}},e.sign.keyPair.fromSeed=function(r){if(pt(r),r.length!==Ie)throw new Error("bad seed size");for(var o=new Uint8Array(Yt),i=new Uint8Array(Xt),t=0;t<32;t++)i[t]=r[t];return $e(o,i,!0),{publicKey:o,secretKey:i}},e.sign.publicKeyLength=Yt,e.sign.secretKeyLength=Xt,e.sign.seedLength=Ie,e.sign.signatureLength=Nt,e.hash=function(r){pt(r);var o=new Uint8Array(Le);return jt(o,r,r.length),o},e.hash.hashLength=Le,e.verify=function(r,o){return pt(r,o),r.length===0||o.length===0||r.length!==o.length?!1:vt(r,0,o,0,r.length)===0},e.setPRNG=function(r){a=r},function(){var r=typeof self<"u"?self.crypto||self.msCrypto:null;if(r&&r.getRandomValues){var o=65536;e.setPRNG(function(i,t){var f,c=new Uint8Array(t);for(f=0;f<t;f+=o)r.getRandomValues(c.subarray(f,f+Math.min(t-f,o)));for(f=0;f<t;f++)i[f]=c[f];Ur(c)})}else typeof Nr<"u"&&(r=jr(),r&&r.randomBytes&&e.setPRNG(function(i,t){var f,c=r.randomBytes(t);for(f=0;f<t;f++)i[f]=c[f];Ur(c)}))}()})(typeof Ne<"u"&&Ne.exports?Ne.exports:self.nacl=self.nacl||{})});var le=Te(rr());function Qt(e){var n;return new Uint8Array(((n=e.match(/.{1,2}/g))!==null&&n!==void 0?n:[]).map(a=>parseInt(a,16))).buffer}function Rt(e){return new Uint8Array(e).reduce((n,a)=>n+a.toString(16).padStart(2,"0"),"")}var Kn=(e,n)=>{if(e.byteLength!==n.byteLength)return!1;let a=new Uint8Array(e),u=new Uint8Array(n);for(let h=0;h<a.length;h++)if(a[h]!==u[h])return!1;return!0},Yr=e=>{if(e<=127)return 1;if(e<=255)return 2;if(e<=65535)return 3;if(e<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")},Vr=(e,n,a)=>{if(a<=127)return e[n]=a,1;if(a<=255)return e[n]=129,e[n+1]=a,2;if(a<=65535)return e[n]=130,e[n+1]=a>>8,e[n+2]=a,3;if(a<=16777215)return e[n]=131,e[n+1]=a>>16,e[n+2]=a>>8,e[n+3]=a,4;throw new Error("Length too long (> 4 bytes)")},nr=(e,n)=>{if(e[n]<128)return 1;if(e[n]===128)throw new Error("Invalid length 0");if(e[n]===129)return 2;if(e[n]===130)return 3;if(e[n]===131)return 4;throw new Error("Length too long (> 4 bytes)")},Cn=(e,n)=>{let a=nr(e,n);if(a===1)return e[n];if(a===2)return e[n+1];if(a===3)return(e[n+1]<<8)+e[n+2];if(a===4)return(e[n+1]<<16)+(e[n+2]<<8)+e[n+3];throw new Error("Length too long (> 4 bytes)")},Fr=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),Re=Uint8Array.from([48,5,6,3,43,101,112]),ui=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function Be(e,n){let a=2+Yr(e.byteLength+1),u=n.byteLength+a+e.byteLength,h=0,m=new Uint8Array(1+Yr(u)+u);return m[h++]=48,h+=Vr(m,h,u),m.set(n,h),h+=n.byteLength,m[h++]=3,h+=Vr(m,h,e.byteLength+1),m[h++]=0,m.set(new Uint8Array(e),h),m}var ir=(e,n)=>{let a=0,u=(B,C)=>{if(h[a++]!==B)throw new Error("Expected: "+C)},h=new Uint8Array(e);if(u(48,"sequence"),a+=nr(h,a),!Kn(h.slice(a,a+n.byteLength),n))throw new Error("Not the expected OID.");a+=n.byteLength,u(3,"bit string");let m=Cn(h,a)-1;a+=nr(h,a),u(0,"0 padding");let v=h.slice(a);if(m!==v.length)throw new Error(`DER payload mismatch: Expected length ${m} actual length ${v.length}`);return v};var gt=class{constructor(n){this.rawKey=n,this.derKey=gt.derEncode(n)}static from(n){return this.fromDer(n.toDer())}static fromRaw(n){return new gt(n)}static fromDer(n){return new gt(this.derDecode(n))}static derEncode(n){return Be(n,Re).buffer}static derDecode(n){let a=ir(n,Re);if(a.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return a}toDer(){return this.derKey}toRaw(){return this.rawKey}};gt.RAW_KEY_LENGTH=32;var Bt=class extends Vt{constructor(n,a){super(),this._privateKey=a,this._publicKey=gt.from(n)}static generate(n){if(n&&n.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");let{publicKey:a,secretKey:u}=n===void 0?le.sign.keyPair():le.sign.keyPair.fromSeed(n);return new this(gt.fromRaw(a),u)}static fromParsedJson(n){let[a,u]=n;return new Bt(gt.fromDer(Qt(a)),Qt(u))}static fromJSON(n){let a=JSON.parse(n);if(Array.isArray(a)){if(typeof a[0]=="string"&&typeof a[1]=="string")return this.fromParsedJson([a[0],a[1]]);throw new Error("Deserialization error: JSON must have at least 2 items.")}throw new Error(`Deserialization error: Invalid JSON type for string: ${JSON.stringify(n)}`)}static fromKeyPair(n,a){return new Bt(gt.fromRaw(n),a)}static fromSecretKey(n){let a=le.sign.keyPair.fromSecretKey(new Uint8Array(n));return Bt.fromKeyPair(a.publicKey,a.secretKey)}toJSON(){return[Rt(this._publicKey.toDer()),Rt(this._privateKey)]}getKeyPair(){return{secretKey:this._privateKey,publicKey:this._publicKey}}getPublicKey(){return this._publicKey}async sign(n){let a=new Uint8Array(n);return le.sign.detached(a,new Uint8Array(this._privateKey)).buffer}};var xe=class extends Error{constructor(n){super(n),this.message=n,Object.setPrototypeOf(this,xe.prototype)}};function kr(e){if(e)return e;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new xe("Global crypto was not available and none was provided. Please inlcude a SubtleCrypto implementation. See https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto")}var kt=class extends Vt{constructor(n,a,u){super(),this._keyPair=n,this._derKey=a,this._subtleCrypto=u}static async generate(n){let{extractable:a=!1,keyUsages:u=["sign","verify"],subtleCrypto:h}=n??{},m=kr(h),v=await m.generateKey({name:"ECDSA",namedCurve:"P-256"},a,u),B=await m.exportKey("spki",v.publicKey);return new this(v,B,m)}static async fromKeyPair(n,a){let u=kr(a),h=await u.exportKey("spki",n.publicKey);return new kt(n,h,u)}getKeyPair(){return this._keyPair}getPublicKey(){let n=this._derKey,a=Object.create(this._keyPair.publicKey);return a.toDer=function(){return n},a}async sign(n){let a={name:"ECDSA",hash:{name:"SHA-256"}};return this._keyPair.privateKey,await this._subtleCrypto.sign(a,this._keyPair.privateKey,n)}};var Dt=Te(Rn());var Mn=function(e,n){var a={};for(var u in e)Object.prototype.hasOwnProperty.call(e,u)&&n.indexOf(u)<0&&(a[u]=e[u]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var h=0,u=Object.getOwnPropertySymbols(e);h<u.length;h++)n.indexOf(u[h])<0&&Object.prototype.propertyIsEnumerable.call(e,u[h])&&(a[u[h]]=e[u[h]]);return a},jn=new TextEncoder().encode("ic-request-auth-delegation"),Yn=new TextEncoder().encode(`
2
- ic-request`);function or(e){if(typeof e!="string"||e.length<64)throw new Error("Invalid public key.");return Qt(e)}var It=class{constructor(n,a,u){this.pubkey=n,this.expiration=a,this.targets=u}toCBOR(){return Dt.value.map(Object.assign({pubkey:Dt.value.bytes(this.pubkey),expiration:Dt.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:Dt.value.array(this.targets.map(n=>Dt.value.bytes(n.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:Rt(this.pubkey)},this.targets&&{targets:this.targets.map(n=>n.toHex())})}};async function Vn(e,n,a,u){let h=new It(n.toDer(),BigInt(+a)*BigInt(1e6),u),m=new Uint8Array([...jn,...new Uint8Array(tr(h))]),v=await e.sign(m);return{delegation:h,signature:v}}var Ht=class{constructor(n,a){this.delegations=n,this.publicKey=a}static async create(n,a,u=new Date(Date.now()+15*60*1e3),h={}){var m,v;let B=await Vn(n,a,u,h.targets);return new Ht([...((m=h.previous)===null||m===void 0?void 0:m.delegations)||[],B],((v=h.previous)===null||v===void 0?void 0:v.publicKey)||n.getPublicKey().toDer())}static fromJSON(n){let{publicKey:a,delegations:u}=typeof n=="string"?JSON.parse(n):n;if(!Array.isArray(u))throw new Error("Invalid delegations.");let h=u.map(m=>{let{delegation:v,signature:B}=m,{pubkey:C,expiration:U,targets:tt}=v;if(tt!==void 0&&!Array.isArray(tt))throw new Error("Invalid targets.");return{delegation:new It(or(C),BigInt(`0x${U}`),tt&&tt.map(rt=>{if(typeof rt!="string")throw new Error("Invalid target.");return Pe.fromHex(rt)})),signature:or(B)}});return new this(h,or(a))}static fromDelegations(n,a){return new this(n,a)}toJSON(){return{delegations:this.delegations.map(n=>{let{delegation:a,signature:u}=n,{targets:h}=a;return{delegation:Object.assign({expiration:a.expiration.toString(16),pubkey:Rt(a.pubkey)},h&&{targets:h.map(m=>m.toHex())}),signature:Rt(u)}}),publicKey:Rt(this.publicKey)}}},de=class extends Vt{constructor(n,a){super(),this._inner=n,this._delegation=a}static fromDelegation(n,a){return new this(n,a)}getDelegation(){return this._delegation}getPublicKey(){return{toDer:()=>this._delegation.publicKey}}sign(n){return this._inner.sign(n)}async transformRequest(n){let{body:a}=n,u=Mn(n,["body"]),h=await tr(a);return Object.assign(Object.assign({},u),{body:{content:a,sender_sig:await this.sign(new Uint8Array([...Yn,...new Uint8Array(h)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};function Hr(e,n){for(let{delegation:h}of e.delegations)if(+new Date(Number(h.expiration/BigInt(1e6)))<=+Date.now())return!1;let a=[],u=n?.scope;u&&(Array.isArray(u)?a.push(...u.map(h=>typeof h=="string"?Pe.fromText(h):h)):a.push(typeof u=="string"?Pe.fromText(u):u));for(let h of a){let m=h.toText();for(let{delegation:v}of e.delegations){if(v.targets===void 0)continue;let B=!0;for(let C of v.targets)if(C.toText()===m){B=!1;break}if(B)return!1}}return!0}var Fn=Te(Nn()),kn=Te(rr());var zr;(function(e){e[e.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(zr||(zr={}));var Wr=["mousedown","mousemove","keydown","touchstart","wheel"],ue=class{constructor(n={}){var a;this.callbacks=[],this.idleTimeout=10*60*1e3,this.timeoutID=void 0;let{onIdle:u,idleTimeout:h=10*60*1e3}=n||{};this.callbacks=u?[u]:[],this.idleTimeout=h;let m=this._resetTimer.bind(this);window.addEventListener("load",m,!0),Wr.forEach(function(B){document.addEventListener(B,m,!0)});let v=(B,C)=>{let U;return(...tt)=>{let rt=this,ht=function(){U=void 0,B.apply(rt,tt)};clearTimeout(U),U=window.setTimeout(ht,C)}};if(n?.captureScroll){let B=v(m,(a=n?.scrollDebounce)!==null&&a!==void 0?a:100);window.addEventListener("scroll",B,!0)}m()}static create(n={}){return new this(n)}registerCallback(n){this.callbacks.push(n)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let n=this._resetTimer.bind(this);Wr.forEach(function(a){document.removeEventListener(a,n,!0)}),this.callbacks.forEach(a=>a())}_resetTimer(){let n=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(n,this.idleTimeout)}};var Hn=(e,n)=>n.some(a=>e instanceof a),Jr,Gr;function zn(){return Jr||(Jr=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Wn(){return Gr||(Gr=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var $r=new WeakMap,ar=new WeakMap,qr=new WeakMap,fr=new WeakMap,cr=new WeakMap;function Jn(e){let n=new Promise((a,u)=>{let h=()=>{e.removeEventListener("success",m),e.removeEventListener("error",v)},m=()=>{a(Et(e.result)),h()},v=()=>{u(e.error),h()};e.addEventListener("success",m),e.addEventListener("error",v)});return n.then(a=>{a instanceof IDBCursor&&$r.set(a,e)}).catch(()=>{}),cr.set(n,e),n}function Gn(e){if(ar.has(e))return;let n=new Promise((a,u)=>{let h=()=>{e.removeEventListener("complete",m),e.removeEventListener("error",v),e.removeEventListener("abort",v)},m=()=>{a(),h()},v=()=>{u(e.error||new DOMException("AbortError","AbortError")),h()};e.addEventListener("complete",m),e.addEventListener("error",v),e.addEventListener("abort",v)});ar.set(e,n)}var sr={get(e,n,a){if(e instanceof IDBTransaction){if(n==="done")return ar.get(e);if(n==="objectStoreNames")return e.objectStoreNames||qr.get(e);if(n==="store")return a.objectStoreNames[1]?void 0:a.objectStore(a.objectStoreNames[0])}return Et(e[n])},set(e,n,a){return e[n]=a,!0},has(e,n){return e instanceof IDBTransaction&&(n==="done"||n==="store")?!0:n in e}};function Zr(e){sr=e(sr)}function $n(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(n,...a){let u=e.call(Ke(this),n,...a);return qr.set(u,n.sort?n.sort():[n]),Et(u)}:Wn().includes(e)?function(...n){return e.apply(Ke(this),n),Et($r.get(this))}:function(...n){return Et(e.apply(Ke(this),n))}}function qn(e){return typeof e=="function"?$n(e):(e instanceof IDBTransaction&&Gn(e),Hn(e,zn())?new Proxy(e,sr):e)}function Et(e){if(e instanceof IDBRequest)return Jn(e);if(fr.has(e))return fr.get(e);let n=qn(e);return n!==e&&(fr.set(e,n),cr.set(n,e)),n}var Ke=e=>cr.get(e);function Qr(e,n,{blocked:a,upgrade:u,blocking:h,terminated:m}={}){let v=indexedDB.open(e,n),B=Et(v);return u&&v.addEventListener("upgradeneeded",C=>{u(Et(v.result),C.oldVersion,C.newVersion,Et(v.transaction),C)}),a&&v.addEventListener("blocked",C=>a(C.oldVersion,C.newVersion,C)),B.then(C=>{m&&C.addEventListener("close",()=>m()),h&&C.addEventListener("versionchange",U=>h(U.oldVersion,U.newVersion,U))}).catch(()=>{}),B}var Zn=["get","getKey","getAll","getAllKeys","count"],Xn=["put","add","delete","clear"],lr=new Map;function Xr(e,n){if(!(e instanceof IDBDatabase&&!(n in e)&&typeof n=="string"))return;if(lr.get(n))return lr.get(n);let a=n.replace(/FromIndex$/,""),u=n!==a,h=Xn.includes(a);if(!(a in(u?IDBIndex:IDBObjectStore).prototype)||!(h||Zn.includes(a)))return;let m=async function(v,...B){let C=this.transaction(v,h?"readwrite":"readonly"),U=C.store;return u&&(U=U.index(B.shift())),(await Promise.all([U[a](...B),h&&C.done]))[0]};return lr.set(n,m),m}Zr(e=>({...e,get:(n,a,u)=>Xr(n,a)||e.get(n,a,u),has:(n,a)=>!!Xr(n,a)||e.has(n,a)}));var Dr="auth-client-db",Ir="ic-keyval",Qn=async(e=Dr,n=Ir,a)=>(Ce&&(localStorage!=null&&localStorage.getItem(_t))&&(localStorage.removeItem(_t),localStorage.removeItem(At)),await Qr(e,a,{upgrade:u=>{u.objectStoreNames,u.objectStoreNames.contains(n)&&u.clear(n),u.createObjectStore(n)}}));async function Dn(e,n,a){return await e.get(n,a)}async function In(e,n,a,u){return await e.put(n,u,a)}async function Ln(e,n,a){return await e.delete(n,a)}var zt=class{constructor(n,a){this._db=n,this._storeName=a}static async create(n){let{dbName:a=Dr,storeName:u=Ir,version:h=1}=n??{},m=await Qn(a,u,h);return new zt(m,u)}async set(n,a){return await In(this._db,this._storeName,n,a)}async get(n){var a;return(a=await Dn(this._db,this._storeName,n))!==null&&a!==void 0?a:null}async remove(n){return await Ln(this._db,this._storeName,n)}};var At="identity",_t="delegation",Lr="iv",ti=1,Ce=typeof window<"u",he=class{constructor(n="ic-",a){this.prefix=n,this._localStorage=a}get(n){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+n))}set(n,a){return this._getLocalStorage().setItem(this.prefix+n,a),Promise.resolve()}remove(n){return this._getLocalStorage().removeItem(this.prefix+n),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let n=typeof window>"u"&&typeof window>"u"?typeof self>"u"?void 0:self.localStorage:window.localStorage;if(!n)throw new Error("Could not find local storage.");return n}},pe=class{get _db(){return new Promise(n=>{if(this.initializedDb){n(this.initializedDb);return}zt.create({version:ti}).then(a=>{this.initializedDb=a,n(a)})})}async get(n){return await(await this._db).get(n)}async set(n,a){await(await this._db).set(n,a)}async remove(n){await(await this._db).remove(n)}};var ei="https://identity.ic0.app",ri="#authorize",ni=500,ii="UserInterrupt",Me=class{constructor(n,a,u,h,m,v,B,C){var U;this._identity=n,this._key=a,this._chain=u,this._storage=h,this.idleManager=m,this._createOptions=v,this._idpWindow=B,this._eventHandler=C;let tt=this.logout.bind(this),rt=v?.idleOptions;!rt?.onIdle&&!rt?.disableDefaultIdleCallback&&((U=this.idleManager)===null||U===void 0||U.registerCallback(()=>{tt(),location.reload()}))}static async create(n={}){var a,u;let h=(a=n.storage)!==null&&a!==void 0?a:new pe,m=null;if(n.identity)m=n.identity;else{let U=await h.get(At);if(!U&&Ce)try{let tt=new he,rt=await tt.get(_t),ht=await tt.get(At);rt&&ht&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await h.set(_t,rt),await h.set(At,ht),U=rt,await tt.remove(_t),await tt.remove(At))}catch(tt){console.error("error while attempting to recover localstorage: "+tt)}if(U)try{typeof U=="object"?m=await kt.fromKeyPair(U):typeof U=="string"&&(m=Bt.fromJSON(U))}catch{}}let v=new er,B=null;if(m)try{let U=await h.get(_t);if(typeof U=="object"&&U!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");n.identity?v=n.identity:U&&(B=Ht.fromJSON(U),Hr(B)?v=de.fromDelegation(m,B):(await xr(h),m=null))}catch(U){console.error(U),await xr(h),m=null}let C;return!((u=n.idleOptions)===null||u===void 0)&&u.disableIdle?C=void 0:(B||n.identity)&&(C=ue.create(n.idleOptions)),m||(m=await kt.generate(),await h.set(At,m.getKeyPair())),new this(v,m,B,h,C,n)}_handleSuccess(n,a){var u,h,m;let v=n.delegations.map(U=>({delegation:new It(U.delegation.pubkey,U.delegation.expiration,U.delegation.targets),signature:U.signature.buffer})),B=Ht.fromDelegations(v,n.userPublicKey.buffer),C=this._key;if(C){if(this._chain=B,this._identity=de.fromDelegation(C,this._chain),(u=this._idpWindow)===null||u===void 0||u.close(),!this.idleManager){let U=(h=this._createOptions)===null||h===void 0?void 0:h.idleOptions;this.idleManager=ue.create(U),!U?.onIdle&&!U?.disableDefaultIdleCallback&&((m=this.idleManager)===null||m===void 0||m.registerCallback(()=>{this.logout(),location.reload()}))}a?.(),this._removeEventListener(),delete this._idpWindow}}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(n){var a,u,h,m;let v=BigInt(8)*BigInt(36e11),B=new URL(((a=n?.identityProvider)===null||a===void 0?void 0:a.toString())||ei);B.hash=ri,(u=this._idpWindow)===null||u===void 0||u.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(B,Object.assign({maxTimeToLive:(h=n?.maxTimeToLive)!==null&&h!==void 0?h:v},n)),window.addEventListener("message",this._eventHandler),this._idpWindow=(m=window.open(B.toString(),"idpWindow",n?.windowOpenerFeatures))!==null&&m!==void 0?m:void 0;let C=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(ii,n?.onError):setTimeout(C,ni))};C()}_getEventHandler(n,a){return async u=>{var h,m,v;if(u.origin!==n.origin){console.warn(`WARNING: expected origin '${n.origin}', got '${u.origin}' (ignoring)`);return}let B=u.data;switch(B.kind){case"authorize-ready":{let C={kind:"authorize-client",sessionPublicKey:new Uint8Array((h=this._key)===null||h===void 0?void 0:h.getPublicKey().toDer()),maxTimeToLive:a?.maxTimeToLive,derivationOrigin:(m=a?.derivationOrigin)===null||m===void 0?void 0:m.toString()};(v=this._idpWindow)===null||v===void 0||v.postMessage(C,n.origin);break}case"authorize-client-success":try{this._handleSuccess(B,a?.onSuccess),this._chain&&await this._storage.set(_t,JSON.stringify(this._chain.toJSON()))}catch(C){this._handleFailure(C.message,a?.onError)}break;case"authorize-client-failure":this._handleFailure(B.text,a?.onError);break;default:break}}}_handleFailure(n,a){var u;(u=this._idpWindow)===null||u===void 0||u.close(),a?.(n),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(n={}){if(await xr(this._storage),this._identity=new er,this._chain=null,n.returnTo)try{window.history.pushState({},"",n.returnTo)}catch{window.location.href=n.returnTo}}};async function xr(e){await e.remove(At),await e.remove(_t),await e.remove(Lr)}var tn=BigInt(144e11);var Lt=class{callbacks=[];populate(n){this.callbacks.forEach(({callback:a})=>a(n))}subscribe(n){let a=Symbol();return this.callbacks.push({id:a,callback:n}),()=>this.callbacks=this.callbacks.filter(({id:u})=>u!==a)}};var te=class extends Lt{authUser=null;constructor(){super()}static getInstance(){return te.instance||(te.instance=new te),te.instance}set(n){this.authUser=n,this.populate(n)}get(){return this.authUser}subscribe(n){let a=super.subscribe(n);return n(this.authUser),a}isLoggedIn(){return!this.authUser?.data?.principal.isAnonymous()}reset(){this.authUser=null,this.populate(this.authUser)}},Ct=te;Oe(Ct,"instance");var ee=class extends Lt{env;constructor(){super()}static getInstance(){return ee.instance||(ee.instance=new ee),ee.instance}set(n){this.env=n,this.populate(n)}get(){return this.env}localIdentity(){return this.get()?.localIdentityCanisterId!==void 0}subscribe(n){let a=super.subscribe(n);return n(this.env),a}},dt=ee;Oe(dt,"instance");var ut=e=>e?[e]:[],je=e=>e?.[0],en=async e=>{let n=new Blob([JSON.stringify(e)],{type:"application/json; charset=utf-8"});return new Uint8Array(await n.arrayBuffer())},dr=async e=>{let n=new Blob([e],{type:"application/json; charset=utf-8"});return JSON.parse(await n.text())};var ur=e=>e==null;var Ye=({matcher:e,paginate:n,order:a})=>({matcher:ut(e),paginate:ut(ur(n)?void 0:{start_after:ut(n.startAfter),limit:ut(ur(n.limit)?void 0:BigInt(n.limit))}),order:ut(a)});var rn=({IDL:e})=>{let n=e.Record({controllers:e.Vec(e.Principal)}),a=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),u=e.Record({updated_at:e.Opt(e.Nat64)}),h=e.Record({headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text))))}),m=e.Record({storage:h}),v=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),created_at:e.Nat64}),B=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text))}),C=e.Record({token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),U=e.Variant({Callback:e.Record({token:C,callback:e.Func([],[],[])})}),tt=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(U),status_code:e.Nat16}),rt=e.Record({token:e.Opt(C),body:e.Vec(e.Nat8)}),ht=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,encoding_type:e.Opt(e.Text),full_path:e.Text}),Ot=e.Record({batch_id:e.Nat}),vt=e.Record({desc:e.Bool}),xt=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),bt=e.Record({order:e.Opt(vt),matcher:e.Opt(e.Text),paginate:e.Opt(xt)}),Fe=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),ke=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),Wt=e.Record({key:Fe,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,ke)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),Jt=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,Wt))}),Pt=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),ye=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,v))}),re=e.Variant({Db:e.Null,Storage:e.Null}),Mt=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),ne=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:Mt,created_at:e.Nat64,write:Mt}),Gt=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),ie=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:Mt,write:Mt}),ge=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),oe=e.Record({chunk_id:e.Nat});return e.Service({add_controllers:e.Func([n],[e.Vec(e.Principal)],[]),commit_asset_upload:e.Func([a],[],[]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Opt(e.Text)],[],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,u],[],[]),get_config:e.Func([],[m],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(v)],["query"]),http_request:e.Func([B],[tt],["query"]),http_request_streaming_callback:e.Func([C],[rt],["query"]),init_asset_upload:e.Func([ht],[Ot],[]),list_assets:e.Func([e.Opt(e.Text),bt],[Jt],["query"]),list_controllers:e.Func([],[e.Vec(e.Principal)],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,Pt))],["query"]),list_docs:e.Func([e.Text,bt],[ye],["query"]),list_rules:e.Func([re],[e.Vec(e.Tuple(e.Text,ne))],["query"]),remove_controllers:e.Func([n],[e.Vec(e.Principal)],[]),set_config:e.Func([m],[],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_doc:e.Func([e.Text,e.Text,Gt],[v],[]),set_rule:e.Func([re,e.Text,ie],[],[]),upload_asset_chunk:e.Func([ge],[oe],[]),version:e.Func([],[e.Text],["query"])})};var nn=async({satelliteId:e,idlFactory:n,identity:a,fetch:u,env:h="prod"})=>{let m=h==="dev"||dt.getInstance().localIdentity(),v=m?"http://127.0.0.1:8000/":"https://ic0.app",B=new Br({identity:a,...v&&{host:v},...u&&{fetch:u}});return m&&await B.fetchRootKey(),Kr.createActor(n,{agent:B,canisterId:e})};var St=async({satelliteId:e,...n})=>{let{satelliteId:a}=e!==void 0?{satelliteId:e}:dt.getInstance().get()??{satelliteId:void 0};if(!a)throw new Error("No satellite principal defined.");return nn({satelliteId:a,idlFactory:rn,...n})};var on=async({collection:e,key:n,satellite:a})=>{let u=await St(a),h=je(await u.get_doc(e,n));if(!h)return;let m=await dr(h.data);return{key:n,data:m,created_at:h.created_at,updated_at:h.updated_at}},fn=async({collection:e,doc:n,satellite:a})=>{let u=await St(a),{key:h,data:m,updated_at:v}=n,B=await u.set_doc(e,h,{data:await en(m),updated_at:ut(v)});return{key:h,data:m,created_at:B.created_at,updated_at:B.updated_at}},an=async({collection:e,doc:n,satellite:a})=>{let u=await St(a),{key:h,updated_at:m}=n;return u.del_doc(e,h,{updated_at:ut(m)})},sn=async({collection:e,filter:n,satellite:a})=>{let u=await St(a),{items:h,matches_length:m,length:v}=await u.list_docs(e,Ye(n)),B=[];for(let[C,U]of h)B.push({key:C,data:await dr(U.data),created_at:U.created_at,updated_at:U.updated_at});return{items:B,length:v,matches_length:m}};var Tt=e=>{if(e!==void 0)return e;let n=Ve();if(!n)throw new Error("No internet identity.");return n};var cn=async({satellite:e,...n})=>{let a=Tt(e?.identity);return on({...n,satellite:{...e,identity:a}})},ln=async({satellite:e,...n})=>{let a=Tt(e?.identity);return fn({...n,satellite:{...e,identity:a}})},No=async({satellite:e,...n})=>{let a=Tt(e?.identity);return an({...n,satellite:{...e,identity:a}})},Ro=async({satellite:e,...n})=>{let a=Tt(e?.identity);return sn({...n,satellite:{...e,identity:a}})};var xn=async()=>{let e=Ve();if(!e)throw new Error("No internet identity.");let n=e.getPrincipal().toText(),a=await cn({collection:"#user",key:n});return a||await oi({userId:n,principal:e.getPrincipal()})},oi=async({userId:e,principal:n})=>{let a=new Date;return ln({collection:"#user",doc:{key:e,data:{principal:n,created_at:a,updated_at:a}}})};var Kt,dn=()=>Me.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}}),hr=async()=>{if(Kt=Kt??await dn(),!(await Kt?.isAuthenticated()||!1))return;let n=await xn();Ct.getInstance().set(n)},fi=async e=>new Promise(async(n,a)=>{Kt=Kt??await dn(),await Kt.login({onSuccess:async()=>{await hr(),n()},onError:u=>a(u),maxTimeToLive:e?.maxTimeToLive??tn,...dt.getInstance().localIdentity()&&{identityProvider:`http://${dt.getInstance().get()?.localIdentityCanisterId}.localhost:8000?#authorize`},...e?.derivationOrigin!==void 0&&{derivationOrigin:e.derivationOrigin},...e?.windowOpenerFeatures!==void 0&&{windowOpenerFeatures:e.windowOpenerFeatures}})}),ai=async()=>{await Kt?.logout(),Kt=void 0,Ct.getInstance().reset()},Ve=()=>Kt?.getIdentity();var un=()=>typeof window<"u",pr=()=>{let e=dt.getInstance().get()?.satelliteId??"unknown";return dt.getInstance().localIdentity()?`http://${e}.localhost:8000`:`https://${e}.ic0.app`};var hn=async({data:e,filename:n,collection:a,headers:u,token:h,fullPath:m,encoding:v,satellite:B})=>{let C=`${n}${v?` (${v})`:""}`,U=await St(B),{batch_id:tt}=await U.init_asset_upload({collection:a,full_path:m,name:n,token:ut(h),encoding_type:ut(v)}),rt=7e5,ht=[],Ot=un()?new Blob([await e.arrayBuffer()]):e;for(let xt=0;xt<Ot.size;xt+=rt){let bt=Ot.slice(xt,xt+rt);ht.push(await si({batchId:tt,chunk:bt,actor:U}))}let vt=u.find(([xt,bt])=>xt.toLowerCase()==="content-type")===void 0&&e.type!==void 0&&e.type!==""?[["Content-Type",e.type]]:void 0;await U.commit_asset_upload({batch_id:tt,chunk_ids:ht.map(({chunk_id:xt})=>xt),headers:[...u,...vt||[]]})},si=async({batchId:e,chunk:n,actor:a})=>a.upload_asset_chunk({batch_id:e,content:new Uint8Array(await n.arrayBuffer())}),pn=async({collection:e,satellite:n,filter:a})=>{let u=await St(n),{items:h,matches_length:m,length:v}=await u.list_assets(ut(e),Ye(a));return{items:h.map(([B,C])=>C),length:v,matches_length:m}},yn=async({collection:e,storageFile:n,satellite:a})=>{let u=await St(a),{fullPath:h}=n;return u.del_asset(e,h)},gn=async({collection:e,satellite:n})=>(await St(n)).del_assets(ut(e));var bn=e=>btoa([...e].map(n=>String.fromCharCode(n)).join(""));var yr=e=>encodeURI(e.toLowerCase().replace(/\s/g,"-"));var nf=async e=>mn(e),of=async e=>mn({filename:e.data.name,...e}),mn=async({filename:e,data:n,collection:a,headers:u=[],fullPath:h,token:m,satellite:v,encoding:B})=>{let C=Tt(v?.identity),U=yr(e),tt=h||`/${U}`;return await hn({data:n,filename:yr(U),collection:a,token:m,headers:u,fullPath:tt,encoding:B,satellite:{...v,identity:C}}),{downloadUrl:`${pr()}${tt}${m!==void 0?`?token=${m}`:""}`,fullPath:tt,name:U}},ff=async({collection:e,satellite:n,filter:a})=>{let{items:u,...h}=await pn({collection:e,satellite:{...n,identity:Tt(n?.identity)},filter:a??{}}),m=pr();return{assets:u.map(({key:{full_path:v,token:B,name:C},headers:U,encodings:tt})=>{let rt=je(B);return{fullPath:v,name:C,downloadUrl:`${m}${v}${rt!==void 0?`?token=${rt}`:""}`,token:rt,headers:U,encodings:tt.reduce((ht,[Ot,{modified:vt,sha256:xt,total_length:bt}])=>({...ht,[Ot]:{modified:vt,sha256:bn(xt),total_length:bt}}),{})}}),...h}},af=async({storageFile:e,collection:n,satellite:a})=>yn({collection:n,storageFile:e,satellite:{...a,identity:Tt(a?.identity)}}),sf=async({collection:e,satellite:n})=>gn({collection:e,satellite:{...n,identity:Tt(n?.identity)}});var uf=async e=>{dt.getInstance().set(e),await hr()},hf=e=>Ct.getInstance().subscribe(e);export{hf as authSubscribe,No as delDoc,af as deleteAsset,sf as deleteAssets,cn as getDoc,uf as initJuno,ff as listAssets,Ro as listDocs,ln as setDoc,fi as signIn,ai as signOut,nf as uploadBlob,of as uploadFile};
1
+ import{a as Nr,b as On,c as Rr,d as Pn,e as Te,f as Un,g as Oe,h as Pe,i as Nn,j as tr,k as Vt,l as er,m as Rn,p as Br,q as Kr}from"./chunk-QVUY65GN.js";var Cr={};Pn(Cr,{default:()=>Bn});var Bn,Mr=On(()=>{Bn={}});var jr=Rr((ci,Ue)=>{var Ft=(Mr(),Un(Cr));if(Ft&&Ft.default){Ue.exports=Ft.default;for(let e in Ft)Ue.exports[e]=Ft[e]}else Ft&&(Ue.exports=Ft)});var rr=Rr((li,Ne)=>{(function(e){"use strict";var n=function(r){var o,i=new Float64Array(16);if(r)for(o=0;o<r.length;o++)i[o]=r[o];return i},a=function(){throw new Error("no PRNG")},u=new Uint8Array(16),h=new Uint8Array(32);h[0]=9;var m=n(),v=n([1]),B=n([56129,1]),C=n([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),U=n([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),tt=n([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),rt=n([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),ht=n([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function St(r,o,i,t){r[o]=i>>24&255,r[o+1]=i>>16&255,r[o+2]=i>>8&255,r[o+3]=i&255,r[o+4]=t>>24&255,r[o+5]=t>>16&255,r[o+6]=t>>8&255,r[o+7]=t&255}function st(r,o,i,t,f){var c,l=0;for(c=0;c<f;c++)l|=r[o+c]^i[t+c];return(1&l-1>>>8)-1}function Tt(r,o,i,t){return st(r,o,i,t,16)}function Kt(r,o,i,t){return st(r,o,i,t,32)}function Fe(r,o,i,t){for(var f=t[0]&255|(t[1]&255)<<8|(t[2]&255)<<16|(t[3]&255)<<24,c=i[0]&255|(i[1]&255)<<8|(i[2]&255)<<16|(i[3]&255)<<24,l=i[4]&255|(i[5]&255)<<8|(i[6]&255)<<16|(i[7]&255)<<24,y=i[8]&255|(i[9]&255)<<8|(i[10]&255)<<16|(i[11]&255)<<24,_=i[12]&255|(i[13]&255)<<8|(i[14]&255)<<16|(i[15]&255)<<24,R=t[4]&255|(t[5]&255)<<8|(t[6]&255)<<16|(t[7]&255)<<24,A=o[0]&255|(o[1]&255)<<8|(o[2]&255)<<16|(o[3]&255)<<24,D=o[4]&255|(o[5]&255)<<8|(o[6]&255)<<16|(o[7]&255)<<24,T=o[8]&255|(o[9]&255)<<8|(o[10]&255)<<16|(o[11]&255)<<24,j=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,Y=t[8]&255|(t[9]&255)<<8|(t[10]&255)<<16|(t[11]&255)<<24,z=i[16]&255|(i[17]&255)<<8|(i[18]&255)<<16|(i[19]&255)<<24,H=i[20]&255|(i[21]&255)<<8|(i[22]&255)<<16|(i[23]&255)<<24,V=i[24]&255|(i[25]&255)<<8|(i[26]&255)<<16|(i[27]&255)<<24,k=i[28]&255|(i[29]&255)<<8|(i[30]&255)<<16|(i[31]&255)<<24,F=t[12]&255|(t[13]&255)<<8|(t[14]&255)<<16|(t[15]&255)<<24,O=f,K=c,S=l,P=y,N=_,E=R,x=A,d=D,b=T,p=j,g=Y,w=z,M=H,W=V,G=k,J=F,s,$=0;$<20;$+=2)s=O+M|0,N^=s<<7|s>>>32-7,s=N+O|0,b^=s<<9|s>>>32-9,s=b+N|0,M^=s<<13|s>>>32-13,s=M+b|0,O^=s<<18|s>>>32-18,s=E+K|0,p^=s<<7|s>>>32-7,s=p+E|0,W^=s<<9|s>>>32-9,s=W+p|0,K^=s<<13|s>>>32-13,s=K+W|0,E^=s<<18|s>>>32-18,s=g+x|0,G^=s<<7|s>>>32-7,s=G+g|0,S^=s<<9|s>>>32-9,s=S+G|0,x^=s<<13|s>>>32-13,s=x+S|0,g^=s<<18|s>>>32-18,s=J+w|0,P^=s<<7|s>>>32-7,s=P+J|0,d^=s<<9|s>>>32-9,s=d+P|0,w^=s<<13|s>>>32-13,s=w+d|0,J^=s<<18|s>>>32-18,s=O+P|0,K^=s<<7|s>>>32-7,s=K+O|0,S^=s<<9|s>>>32-9,s=S+K|0,P^=s<<13|s>>>32-13,s=P+S|0,O^=s<<18|s>>>32-18,s=E+N|0,x^=s<<7|s>>>32-7,s=x+E|0,d^=s<<9|s>>>32-9,s=d+x|0,N^=s<<13|s>>>32-13,s=N+d|0,E^=s<<18|s>>>32-18,s=g+p|0,w^=s<<7|s>>>32-7,s=w+g|0,b^=s<<9|s>>>32-9,s=b+w|0,p^=s<<13|s>>>32-13,s=p+b|0,g^=s<<18|s>>>32-18,s=J+G|0,M^=s<<7|s>>>32-7,s=M+J|0,W^=s<<9|s>>>32-9,s=W+M|0,G^=s<<13|s>>>32-13,s=G+W|0,J^=s<<18|s>>>32-18;O=O+f|0,K=K+c|0,S=S+l|0,P=P+y|0,N=N+_|0,E=E+R|0,x=x+A|0,d=d+D|0,b=b+T|0,p=p+j|0,g=g+Y|0,w=w+z|0,M=M+H|0,W=W+V|0,G=G+k|0,J=J+F|0,r[0]=O>>>0&255,r[1]=O>>>8&255,r[2]=O>>>16&255,r[3]=O>>>24&255,r[4]=K>>>0&255,r[5]=K>>>8&255,r[6]=K>>>16&255,r[7]=K>>>24&255,r[8]=S>>>0&255,r[9]=S>>>8&255,r[10]=S>>>16&255,r[11]=S>>>24&255,r[12]=P>>>0&255,r[13]=P>>>8&255,r[14]=P>>>16&255,r[15]=P>>>24&255,r[16]=N>>>0&255,r[17]=N>>>8&255,r[18]=N>>>16&255,r[19]=N>>>24&255,r[20]=E>>>0&255,r[21]=E>>>8&255,r[22]=E>>>16&255,r[23]=E>>>24&255,r[24]=x>>>0&255,r[25]=x>>>8&255,r[26]=x>>>16&255,r[27]=x>>>24&255,r[28]=d>>>0&255,r[29]=d>>>8&255,r[30]=d>>>16&255,r[31]=d>>>24&255,r[32]=b>>>0&255,r[33]=b>>>8&255,r[34]=b>>>16&255,r[35]=b>>>24&255,r[36]=p>>>0&255,r[37]=p>>>8&255,r[38]=p>>>16&255,r[39]=p>>>24&255,r[40]=g>>>0&255,r[41]=g>>>8&255,r[42]=g>>>16&255,r[43]=g>>>24&255,r[44]=w>>>0&255,r[45]=w>>>8&255,r[46]=w>>>16&255,r[47]=w>>>24&255,r[48]=M>>>0&255,r[49]=M>>>8&255,r[50]=M>>>16&255,r[51]=M>>>24&255,r[52]=W>>>0&255,r[53]=W>>>8&255,r[54]=W>>>16&255,r[55]=W>>>24&255,r[56]=G>>>0&255,r[57]=G>>>8&255,r[58]=G>>>16&255,r[59]=G>>>24&255,r[60]=J>>>0&255,r[61]=J>>>8&255,r[62]=J>>>16&255,r[63]=J>>>24&255}function ke(r,o,i,t){for(var f=t[0]&255|(t[1]&255)<<8|(t[2]&255)<<16|(t[3]&255)<<24,c=i[0]&255|(i[1]&255)<<8|(i[2]&255)<<16|(i[3]&255)<<24,l=i[4]&255|(i[5]&255)<<8|(i[6]&255)<<16|(i[7]&255)<<24,y=i[8]&255|(i[9]&255)<<8|(i[10]&255)<<16|(i[11]&255)<<24,_=i[12]&255|(i[13]&255)<<8|(i[14]&255)<<16|(i[15]&255)<<24,R=t[4]&255|(t[5]&255)<<8|(t[6]&255)<<16|(t[7]&255)<<24,A=o[0]&255|(o[1]&255)<<8|(o[2]&255)<<16|(o[3]&255)<<24,D=o[4]&255|(o[5]&255)<<8|(o[6]&255)<<16|(o[7]&255)<<24,T=o[8]&255|(o[9]&255)<<8|(o[10]&255)<<16|(o[11]&255)<<24,j=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,Y=t[8]&255|(t[9]&255)<<8|(t[10]&255)<<16|(t[11]&255)<<24,z=i[16]&255|(i[17]&255)<<8|(i[18]&255)<<16|(i[19]&255)<<24,H=i[20]&255|(i[21]&255)<<8|(i[22]&255)<<16|(i[23]&255)<<24,V=i[24]&255|(i[25]&255)<<8|(i[26]&255)<<16|(i[27]&255)<<24,k=i[28]&255|(i[29]&255)<<8|(i[30]&255)<<16|(i[31]&255)<<24,F=t[12]&255|(t[13]&255)<<8|(t[14]&255)<<16|(t[15]&255)<<24,O=f,K=c,S=l,P=y,N=_,E=R,x=A,d=D,b=T,p=j,g=Y,w=z,M=H,W=V,G=k,J=F,s,$=0;$<20;$+=2)s=O+M|0,N^=s<<7|s>>>32-7,s=N+O|0,b^=s<<9|s>>>32-9,s=b+N|0,M^=s<<13|s>>>32-13,s=M+b|0,O^=s<<18|s>>>32-18,s=E+K|0,p^=s<<7|s>>>32-7,s=p+E|0,W^=s<<9|s>>>32-9,s=W+p|0,K^=s<<13|s>>>32-13,s=K+W|0,E^=s<<18|s>>>32-18,s=g+x|0,G^=s<<7|s>>>32-7,s=G+g|0,S^=s<<9|s>>>32-9,s=S+G|0,x^=s<<13|s>>>32-13,s=x+S|0,g^=s<<18|s>>>32-18,s=J+w|0,P^=s<<7|s>>>32-7,s=P+J|0,d^=s<<9|s>>>32-9,s=d+P|0,w^=s<<13|s>>>32-13,s=w+d|0,J^=s<<18|s>>>32-18,s=O+P|0,K^=s<<7|s>>>32-7,s=K+O|0,S^=s<<9|s>>>32-9,s=S+K|0,P^=s<<13|s>>>32-13,s=P+S|0,O^=s<<18|s>>>32-18,s=E+N|0,x^=s<<7|s>>>32-7,s=x+E|0,d^=s<<9|s>>>32-9,s=d+x|0,N^=s<<13|s>>>32-13,s=N+d|0,E^=s<<18|s>>>32-18,s=g+p|0,w^=s<<7|s>>>32-7,s=w+g|0,b^=s<<9|s>>>32-9,s=b+w|0,p^=s<<13|s>>>32-13,s=p+b|0,g^=s<<18|s>>>32-18,s=J+G|0,M^=s<<7|s>>>32-7,s=M+J|0,W^=s<<9|s>>>32-9,s=W+M|0,G^=s<<13|s>>>32-13,s=G+W|0,J^=s<<18|s>>>32-18;r[0]=O>>>0&255,r[1]=O>>>8&255,r[2]=O>>>16&255,r[3]=O>>>24&255,r[4]=E>>>0&255,r[5]=E>>>8&255,r[6]=E>>>16&255,r[7]=E>>>24&255,r[8]=g>>>0&255,r[9]=g>>>8&255,r[10]=g>>>16&255,r[11]=g>>>24&255,r[12]=J>>>0&255,r[13]=J>>>8&255,r[14]=J>>>16&255,r[15]=J>>>24&255,r[16]=x>>>0&255,r[17]=x>>>8&255,r[18]=x>>>16&255,r[19]=x>>>24&255,r[20]=d>>>0&255,r[21]=d>>>8&255,r[22]=d>>>16&255,r[23]=d>>>24&255,r[24]=b>>>0&255,r[25]=b>>>8&255,r[26]=b>>>16&255,r[27]=b>>>24&255,r[28]=p>>>0&255,r[29]=p>>>8&255,r[30]=p>>>16&255,r[31]=p>>>24&255}function Wt(r,o,i,t){Fe(r,o,i,t)}function Jt(r,o,i,t){ke(r,o,i,t)}var Ot=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function ye(r,o,i,t,f,c,l){var y=new Uint8Array(16),_=new Uint8Array(64),R,A;for(A=0;A<16;A++)y[A]=0;for(A=0;A<8;A++)y[A]=c[A];for(;f>=64;){for(Wt(_,y,l,Ot),A=0;A<64;A++)r[o+A]=i[t+A]^_[A];for(R=1,A=8;A<16;A++)R=R+(y[A]&255)|0,y[A]=R&255,R>>>=8;f-=64,o+=64,t+=64}if(f>0)for(Wt(_,y,l,Ot),A=0;A<f;A++)r[o+A]=i[t+A]^_[A];return 0}function re(r,o,i,t,f){var c=new Uint8Array(16),l=new Uint8Array(64),y,_;for(_=0;_<16;_++)c[_]=0;for(_=0;_<8;_++)c[_]=t[_];for(;i>=64;){for(Wt(l,c,f,Ot),_=0;_<64;_++)r[o+_]=l[_];for(y=1,_=8;_<16;_++)y=y+(c[_]&255)|0,c[_]=y&255,y>>>=8;i-=64,o+=64}if(i>0)for(Wt(l,c,f,Ot),_=0;_<i;_++)r[o+_]=l[_];return 0}function Mt(r,o,i,t,f){var c=new Uint8Array(32);Jt(c,t,f,Ot);for(var l=new Uint8Array(8),y=0;y<8;y++)l[y]=t[y+16];return re(r,o,i,l,c)}function ne(r,o,i,t,f,c,l){var y=new Uint8Array(32);Jt(y,c,l,Ot);for(var _=new Uint8Array(8),R=0;R<8;R++)_[R]=c[R+16];return ye(r,o,i,t,f,_,y)}var Gt=function(r){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 o,i,t,f,c,l,y,_;o=r[0]&255|(r[1]&255)<<8,this.r[0]=o&8191,i=r[2]&255|(r[3]&255)<<8,this.r[1]=(o>>>13|i<<3)&8191,t=r[4]&255|(r[5]&255)<<8,this.r[2]=(i>>>10|t<<6)&7939,f=r[6]&255|(r[7]&255)<<8,this.r[3]=(t>>>7|f<<9)&8191,c=r[8]&255|(r[9]&255)<<8,this.r[4]=(f>>>4|c<<12)&255,this.r[5]=c>>>1&8190,l=r[10]&255|(r[11]&255)<<8,this.r[6]=(c>>>14|l<<2)&8191,y=r[12]&255|(r[13]&255)<<8,this.r[7]=(l>>>11|y<<5)&8065,_=r[14]&255|(r[15]&255)<<8,this.r[8]=(y>>>8|_<<8)&8191,this.r[9]=_>>>5&127,this.pad[0]=r[16]&255|(r[17]&255)<<8,this.pad[1]=r[18]&255|(r[19]&255)<<8,this.pad[2]=r[20]&255|(r[21]&255)<<8,this.pad[3]=r[22]&255|(r[23]&255)<<8,this.pad[4]=r[24]&255|(r[25]&255)<<8,this.pad[5]=r[26]&255|(r[27]&255)<<8,this.pad[6]=r[28]&255|(r[29]&255)<<8,this.pad[7]=r[30]&255|(r[31]&255)<<8};Gt.prototype.blocks=function(r,o,i){for(var t=this.fin?0:2048,f,c,l,y,_,R,A,D,T,j,Y,z,H,V,k,F,O,K,S,P=this.h[0],N=this.h[1],E=this.h[2],x=this.h[3],d=this.h[4],b=this.h[5],p=this.h[6],g=this.h[7],w=this.h[8],M=this.h[9],W=this.r[0],G=this.r[1],J=this.r[2],s=this.r[3],$=this.r[4],I=this.r[5],L=this.r[6],q=this.r[7],X=this.r[8],Q=this.r[9];i>=16;)f=r[o+0]&255|(r[o+1]&255)<<8,P+=f&8191,c=r[o+2]&255|(r[o+3]&255)<<8,N+=(f>>>13|c<<3)&8191,l=r[o+4]&255|(r[o+5]&255)<<8,E+=(c>>>10|l<<6)&8191,y=r[o+6]&255|(r[o+7]&255)<<8,x+=(l>>>7|y<<9)&8191,_=r[o+8]&255|(r[o+9]&255)<<8,d+=(y>>>4|_<<12)&8191,b+=_>>>1&8191,R=r[o+10]&255|(r[o+11]&255)<<8,p+=(_>>>14|R<<2)&8191,A=r[o+12]&255|(r[o+13]&255)<<8,g+=(R>>>11|A<<5)&8191,D=r[o+14]&255|(r[o+15]&255)<<8,w+=(A>>>8|D<<8)&8191,M+=D>>>5|t,T=0,j=T,j+=P*W,j+=N*(5*Q),j+=E*(5*X),j+=x*(5*q),j+=d*(5*L),T=j>>>13,j&=8191,j+=b*(5*I),j+=p*(5*$),j+=g*(5*s),j+=w*(5*J),j+=M*(5*G),T+=j>>>13,j&=8191,Y=T,Y+=P*G,Y+=N*W,Y+=E*(5*Q),Y+=x*(5*X),Y+=d*(5*q),T=Y>>>13,Y&=8191,Y+=b*(5*L),Y+=p*(5*I),Y+=g*(5*$),Y+=w*(5*s),Y+=M*(5*J),T+=Y>>>13,Y&=8191,z=T,z+=P*J,z+=N*G,z+=E*W,z+=x*(5*Q),z+=d*(5*X),T=z>>>13,z&=8191,z+=b*(5*q),z+=p*(5*L),z+=g*(5*I),z+=w*(5*$),z+=M*(5*s),T+=z>>>13,z&=8191,H=T,H+=P*s,H+=N*J,H+=E*G,H+=x*W,H+=d*(5*Q),T=H>>>13,H&=8191,H+=b*(5*X),H+=p*(5*q),H+=g*(5*L),H+=w*(5*I),H+=M*(5*$),T+=H>>>13,H&=8191,V=T,V+=P*$,V+=N*s,V+=E*J,V+=x*G,V+=d*W,T=V>>>13,V&=8191,V+=b*(5*Q),V+=p*(5*X),V+=g*(5*q),V+=w*(5*L),V+=M*(5*I),T+=V>>>13,V&=8191,k=T,k+=P*I,k+=N*$,k+=E*s,k+=x*J,k+=d*G,T=k>>>13,k&=8191,k+=b*W,k+=p*(5*Q),k+=g*(5*X),k+=w*(5*q),k+=M*(5*L),T+=k>>>13,k&=8191,F=T,F+=P*L,F+=N*I,F+=E*$,F+=x*s,F+=d*J,T=F>>>13,F&=8191,F+=b*G,F+=p*W,F+=g*(5*Q),F+=w*(5*X),F+=M*(5*q),T+=F>>>13,F&=8191,O=T,O+=P*q,O+=N*L,O+=E*I,O+=x*$,O+=d*s,T=O>>>13,O&=8191,O+=b*J,O+=p*G,O+=g*W,O+=w*(5*Q),O+=M*(5*X),T+=O>>>13,O&=8191,K=T,K+=P*X,K+=N*q,K+=E*L,K+=x*I,K+=d*$,T=K>>>13,K&=8191,K+=b*s,K+=p*J,K+=g*G,K+=w*W,K+=M*(5*Q),T+=K>>>13,K&=8191,S=T,S+=P*Q,S+=N*X,S+=E*q,S+=x*L,S+=d*I,T=S>>>13,S&=8191,S+=b*$,S+=p*s,S+=g*J,S+=w*G,S+=M*W,T+=S>>>13,S&=8191,T=(T<<2)+T|0,T=T+j|0,j=T&8191,T=T>>>13,Y+=T,P=j,N=Y,E=z,x=H,d=V,b=k,p=F,g=O,w=K,M=S,o+=16,i-=16;this.h[0]=P,this.h[1]=N,this.h[2]=E,this.h[3]=x,this.h[4]=d,this.h[5]=b,this.h[6]=p,this.h[7]=g,this.h[8]=w,this.h[9]=M},Gt.prototype.finish=function(r,o){var i=new Uint16Array(10),t,f,c,l;if(this.leftover){for(l=this.leftover,this.buffer[l++]=1;l<16;l++)this.buffer[l]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(t=this.h[1]>>>13,this.h[1]&=8191,l=2;l<10;l++)this.h[l]+=t,t=this.h[l]>>>13,this.h[l]&=8191;for(this.h[0]+=t*5,t=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=t,t=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=t,i[0]=this.h[0]+5,t=i[0]>>>13,i[0]&=8191,l=1;l<10;l++)i[l]=this.h[l]+t,t=i[l]>>>13,i[l]&=8191;for(i[9]-=1<<13,f=(t^1)-1,l=0;l<10;l++)i[l]&=f;for(f=~f,l=0;l<10;l++)this.h[l]=this.h[l]&f|i[l];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,c=this.h[0]+this.pad[0],this.h[0]=c&65535,l=1;l<8;l++)c=(this.h[l]+this.pad[l]|0)+(c>>>16)|0,this.h[l]=c&65535;r[o+0]=this.h[0]>>>0&255,r[o+1]=this.h[0]>>>8&255,r[o+2]=this.h[1]>>>0&255,r[o+3]=this.h[1]>>>8&255,r[o+4]=this.h[2]>>>0&255,r[o+5]=this.h[2]>>>8&255,r[o+6]=this.h[3]>>>0&255,r[o+7]=this.h[3]>>>8&255,r[o+8]=this.h[4]>>>0&255,r[o+9]=this.h[4]>>>8&255,r[o+10]=this.h[5]>>>0&255,r[o+11]=this.h[5]>>>8&255,r[o+12]=this.h[6]>>>0&255,r[o+13]=this.h[6]>>>8&255,r[o+14]=this.h[7]>>>0&255,r[o+15]=this.h[7]>>>8&255},Gt.prototype.update=function(r,o,i){var t,f;if(this.leftover){for(f=16-this.leftover,f>i&&(f=i),t=0;t<f;t++)this.buffer[this.leftover+t]=r[o+t];if(i-=f,o+=f,this.leftover+=f,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(i>=16&&(f=i-i%16,this.blocks(r,o,f),o+=f,i-=f),i){for(t=0;t<i;t++)this.buffer[this.leftover+t]=r[o+t];this.leftover+=i}};function ie(r,o,i,t,f,c){var l=new Gt(c);return l.update(i,t,f),l.finish(r,o),0}function ge(r,o,i,t,f,c){var l=new Uint8Array(16);return ie(l,0,i,t,f,c),Tt(r,o,l,0)}function oe(r,o,i,t,f){var c;if(i<32)return-1;for(ne(r,0,o,0,i,t,f),ie(r,16,r,32,i-32,r),c=0;c<16;c++)r[c]=0;return 0}function He(r,o,i,t,f){var c,l=new Uint8Array(32);if(i<32||(Mt(l,0,32,t,f),ge(o,16,o,32,i-32,l)!==0))return-1;for(ne(r,0,o,0,i,t,f),c=0;c<32;c++)r[c]=0;return 0}function Pt(r,o){var i;for(i=0;i<16;i++)r[i]=o[i]|0}function ze(r){var o,i,t=1;for(o=0;o<16;o++)i=r[o]+t+65535,t=Math.floor(i/65536),r[o]=i-t*65536;r[0]+=t-1+37*(t-1)}function qt(r,o,i){for(var t,f=~(i-1),c=0;c<16;c++)t=f&(r[c]^o[c]),r[c]^=t,o[c]^=t}function $t(r,o){var i,t,f,c=n(),l=n();for(i=0;i<16;i++)l[i]=o[i];for(ze(l),ze(l),ze(l),t=0;t<2;t++){for(c[0]=l[0]-65517,i=1;i<15;i++)c[i]=l[i]-65535-(c[i-1]>>16&1),c[i-1]&=65535;c[15]=l[15]-32767-(c[14]>>16&1),f=c[15]>>16&1,c[14]&=65535,qt(l,c,1-f)}for(i=0;i<16;i++)r[2*i]=l[i]&255,r[2*i+1]=l[i]>>8}function gr(r,o){var i=new Uint8Array(32),t=new Uint8Array(32);return $t(i,r),$t(t,o),Kt(i,0,t,0)}function br(r){var o=new Uint8Array(32);return $t(o,r),o[0]&1}function We(r,o){var i;for(i=0;i<16;i++)r[i]=o[2*i]+(o[2*i+1]<<8);r[15]&=32767}function bt(r,o,i){for(var t=0;t<16;t++)r[t]=o[t]+i[t]}function mt(r,o,i){for(var t=0;t<16;t++)r[t]=o[t]-i[t]}function Z(r,o,i){var t,f,c=0,l=0,y=0,_=0,R=0,A=0,D=0,T=0,j=0,Y=0,z=0,H=0,V=0,k=0,F=0,O=0,K=0,S=0,P=0,N=0,E=0,x=0,d=0,b=0,p=0,g=0,w=0,M=0,W=0,G=0,J=0,s=i[0],$=i[1],I=i[2],L=i[3],q=i[4],X=i[5],Q=i[6],ft=i[7],et=i[8],nt=i[9],it=i[10],ot=i[11],at=i[12],ct=i[13],lt=i[14],xt=i[15];t=o[0],c+=t*s,l+=t*$,y+=t*I,_+=t*L,R+=t*q,A+=t*X,D+=t*Q,T+=t*ft,j+=t*et,Y+=t*nt,z+=t*it,H+=t*ot,V+=t*at,k+=t*ct,F+=t*lt,O+=t*xt,t=o[1],l+=t*s,y+=t*$,_+=t*I,R+=t*L,A+=t*q,D+=t*X,T+=t*Q,j+=t*ft,Y+=t*et,z+=t*nt,H+=t*it,V+=t*ot,k+=t*at,F+=t*ct,O+=t*lt,K+=t*xt,t=o[2],y+=t*s,_+=t*$,R+=t*I,A+=t*L,D+=t*q,T+=t*X,j+=t*Q,Y+=t*ft,z+=t*et,H+=t*nt,V+=t*it,k+=t*ot,F+=t*at,O+=t*ct,K+=t*lt,S+=t*xt,t=o[3],_+=t*s,R+=t*$,A+=t*I,D+=t*L,T+=t*q,j+=t*X,Y+=t*Q,z+=t*ft,H+=t*et,V+=t*nt,k+=t*it,F+=t*ot,O+=t*at,K+=t*ct,S+=t*lt,P+=t*xt,t=o[4],R+=t*s,A+=t*$,D+=t*I,T+=t*L,j+=t*q,Y+=t*X,z+=t*Q,H+=t*ft,V+=t*et,k+=t*nt,F+=t*it,O+=t*ot,K+=t*at,S+=t*ct,P+=t*lt,N+=t*xt,t=o[5],A+=t*s,D+=t*$,T+=t*I,j+=t*L,Y+=t*q,z+=t*X,H+=t*Q,V+=t*ft,k+=t*et,F+=t*nt,O+=t*it,K+=t*ot,S+=t*at,P+=t*ct,N+=t*lt,E+=t*xt,t=o[6],D+=t*s,T+=t*$,j+=t*I,Y+=t*L,z+=t*q,H+=t*X,V+=t*Q,k+=t*ft,F+=t*et,O+=t*nt,K+=t*it,S+=t*ot,P+=t*at,N+=t*ct,E+=t*lt,x+=t*xt,t=o[7],T+=t*s,j+=t*$,Y+=t*I,z+=t*L,H+=t*q,V+=t*X,k+=t*Q,F+=t*ft,O+=t*et,K+=t*nt,S+=t*it,P+=t*ot,N+=t*at,E+=t*ct,x+=t*lt,d+=t*xt,t=o[8],j+=t*s,Y+=t*$,z+=t*I,H+=t*L,V+=t*q,k+=t*X,F+=t*Q,O+=t*ft,K+=t*et,S+=t*nt,P+=t*it,N+=t*ot,E+=t*at,x+=t*ct,d+=t*lt,b+=t*xt,t=o[9],Y+=t*s,z+=t*$,H+=t*I,V+=t*L,k+=t*q,F+=t*X,O+=t*Q,K+=t*ft,S+=t*et,P+=t*nt,N+=t*it,E+=t*ot,x+=t*at,d+=t*ct,b+=t*lt,p+=t*xt,t=o[10],z+=t*s,H+=t*$,V+=t*I,k+=t*L,F+=t*q,O+=t*X,K+=t*Q,S+=t*ft,P+=t*et,N+=t*nt,E+=t*it,x+=t*ot,d+=t*at,b+=t*ct,p+=t*lt,g+=t*xt,t=o[11],H+=t*s,V+=t*$,k+=t*I,F+=t*L,O+=t*q,K+=t*X,S+=t*Q,P+=t*ft,N+=t*et,E+=t*nt,x+=t*it,d+=t*ot,b+=t*at,p+=t*ct,g+=t*lt,w+=t*xt,t=o[12],V+=t*s,k+=t*$,F+=t*I,O+=t*L,K+=t*q,S+=t*X,P+=t*Q,N+=t*ft,E+=t*et,x+=t*nt,d+=t*it,b+=t*ot,p+=t*at,g+=t*ct,w+=t*lt,M+=t*xt,t=o[13],k+=t*s,F+=t*$,O+=t*I,K+=t*L,S+=t*q,P+=t*X,N+=t*Q,E+=t*ft,x+=t*et,d+=t*nt,b+=t*it,p+=t*ot,g+=t*at,w+=t*ct,M+=t*lt,W+=t*xt,t=o[14],F+=t*s,O+=t*$,K+=t*I,S+=t*L,P+=t*q,N+=t*X,E+=t*Q,x+=t*ft,d+=t*et,b+=t*nt,p+=t*it,g+=t*ot,w+=t*at,M+=t*ct,W+=t*lt,G+=t*xt,t=o[15],O+=t*s,K+=t*$,S+=t*I,P+=t*L,N+=t*q,E+=t*X,x+=t*Q,d+=t*ft,b+=t*et,p+=t*nt,g+=t*it,w+=t*ot,M+=t*at,W+=t*ct,G+=t*lt,J+=t*xt,c+=38*K,l+=38*S,y+=38*P,_+=38*N,R+=38*E,A+=38*x,D+=38*d,T+=38*b,j+=38*p,Y+=38*g,z+=38*w,H+=38*M,V+=38*W,k+=38*G,F+=38*J,f=1,t=c+f+65535,f=Math.floor(t/65536),c=t-f*65536,t=l+f+65535,f=Math.floor(t/65536),l=t-f*65536,t=y+f+65535,f=Math.floor(t/65536),y=t-f*65536,t=_+f+65535,f=Math.floor(t/65536),_=t-f*65536,t=R+f+65535,f=Math.floor(t/65536),R=t-f*65536,t=A+f+65535,f=Math.floor(t/65536),A=t-f*65536,t=D+f+65535,f=Math.floor(t/65536),D=t-f*65536,t=T+f+65535,f=Math.floor(t/65536),T=t-f*65536,t=j+f+65535,f=Math.floor(t/65536),j=t-f*65536,t=Y+f+65535,f=Math.floor(t/65536),Y=t-f*65536,t=z+f+65535,f=Math.floor(t/65536),z=t-f*65536,t=H+f+65535,f=Math.floor(t/65536),H=t-f*65536,t=V+f+65535,f=Math.floor(t/65536),V=t-f*65536,t=k+f+65535,f=Math.floor(t/65536),k=t-f*65536,t=F+f+65535,f=Math.floor(t/65536),F=t-f*65536,t=O+f+65535,f=Math.floor(t/65536),O=t-f*65536,c+=f-1+37*(f-1),f=1,t=c+f+65535,f=Math.floor(t/65536),c=t-f*65536,t=l+f+65535,f=Math.floor(t/65536),l=t-f*65536,t=y+f+65535,f=Math.floor(t/65536),y=t-f*65536,t=_+f+65535,f=Math.floor(t/65536),_=t-f*65536,t=R+f+65535,f=Math.floor(t/65536),R=t-f*65536,t=A+f+65535,f=Math.floor(t/65536),A=t-f*65536,t=D+f+65535,f=Math.floor(t/65536),D=t-f*65536,t=T+f+65535,f=Math.floor(t/65536),T=t-f*65536,t=j+f+65535,f=Math.floor(t/65536),j=t-f*65536,t=Y+f+65535,f=Math.floor(t/65536),Y=t-f*65536,t=z+f+65535,f=Math.floor(t/65536),z=t-f*65536,t=H+f+65535,f=Math.floor(t/65536),H=t-f*65536,t=V+f+65535,f=Math.floor(t/65536),V=t-f*65536,t=k+f+65535,f=Math.floor(t/65536),k=t-f*65536,t=F+f+65535,f=Math.floor(t/65536),F=t-f*65536,t=O+f+65535,f=Math.floor(t/65536),O=t-f*65536,c+=f-1+37*(f-1),r[0]=c,r[1]=l,r[2]=y,r[3]=_,r[4]=R,r[5]=A,r[6]=D,r[7]=T,r[8]=j,r[9]=Y,r[10]=z,r[11]=H,r[12]=V,r[13]=k,r[14]=F,r[15]=O}function yt(r,o){Z(r,o,o)}function mr(r,o){var i=n(),t;for(t=0;t<16;t++)i[t]=o[t];for(t=253;t>=0;t--)yt(i,i),t!==2&&t!==4&&Z(i,i,o);for(t=0;t<16;t++)r[t]=i[t]}function wr(r,o){var i=n(),t;for(t=0;t<16;t++)i[t]=o[t];for(t=250;t>=0;t--)yt(i,i),t!==1&&Z(i,i,o);for(t=0;t<16;t++)r[t]=i[t]}function be(r,o,i){var t=new Uint8Array(32),f=new Float64Array(80),c,l,y=n(),_=n(),R=n(),A=n(),D=n(),T=n();for(l=0;l<31;l++)t[l]=o[l];for(t[31]=o[31]&127|64,t[0]&=248,We(f,i),l=0;l<16;l++)_[l]=f[l],A[l]=y[l]=R[l]=0;for(y[0]=A[0]=1,l=254;l>=0;--l)c=t[l>>>3]>>>(l&7)&1,qt(y,_,c),qt(R,A,c),bt(D,y,R),mt(y,y,R),bt(R,_,A),mt(_,_,A),yt(A,D),yt(T,y),Z(y,R,y),Z(R,_,D),bt(D,y,R),mt(y,y,R),yt(_,y),mt(R,A,T),Z(y,R,B),bt(y,y,A),Z(R,R,y),Z(y,A,T),Z(A,_,f),yt(_,D),qt(y,_,c),qt(R,A,c);for(l=0;l<16;l++)f[l+16]=y[l],f[l+32]=R[l],f[l+48]=_[l],f[l+64]=A[l];var j=f.subarray(32),Y=f.subarray(16);return mr(j,j),Z(Y,Y,j),$t(r,Y),0}function me(r,o){return be(r,o,h)}function _r(r,o){return a(o,32),me(r,o)}function we(r,o,i){var t=new Uint8Array(32);return be(t,i,o),Jt(r,u,t,Ot)}var vr=oe,wn=He;function _n(r,o,i,t,f,c){var l=new Uint8Array(32);return we(l,f,c),vr(r,o,i,t,l)}function vn(r,o,i,t,f,c){var l=new Uint8Array(32);return we(l,f,c),wn(r,o,i,t,l)}var Er=[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];function Ar(r,o,i,t){for(var f=new Int32Array(16),c=new Int32Array(16),l,y,_,R,A,D,T,j,Y,z,H,V,k,F,O,K,S,P,N,E,x,d,b,p,g,w,M=r[0],W=r[1],G=r[2],J=r[3],s=r[4],$=r[5],I=r[6],L=r[7],q=o[0],X=o[1],Q=o[2],ft=o[3],et=o[4],nt=o[5],it=o[6],ot=o[7],at=0;t>=128;){for(N=0;N<16;N++)E=8*N+at,f[N]=i[E+0]<<24|i[E+1]<<16|i[E+2]<<8|i[E+3],c[N]=i[E+4]<<24|i[E+5]<<16|i[E+6]<<8|i[E+7];for(N=0;N<80;N++)if(l=M,y=W,_=G,R=J,A=s,D=$,T=I,j=L,Y=q,z=X,H=Q,V=ft,k=et,F=nt,O=it,K=ot,x=L,d=ot,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=(s>>>14|et<<32-14)^(s>>>18|et<<32-18)^(et>>>41-32|s<<32-(41-32)),d=(et>>>14|s<<32-14)^(et>>>18|s<<32-18)^(s>>>41-32|et<<32-(41-32)),b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,x=s&$^~s&I,d=et&nt^~et&it,b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,x=Er[N*2],d=Er[N*2+1],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,x=f[N%16],d=c[N%16],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,S=g&65535|w<<16,P=b&65535|p<<16,x=S,d=P,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=(M>>>28|q<<32-28)^(q>>>34-32|M<<32-(34-32))^(q>>>39-32|M<<32-(39-32)),d=(q>>>28|M<<32-28)^(M>>>34-32|q<<32-(34-32))^(M>>>39-32|q<<32-(39-32)),b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,x=M&W^M&G^W&G,d=q&X^q&Q^X&Q,b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,j=g&65535|w<<16,K=b&65535|p<<16,x=R,d=V,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=S,d=P,b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,R=g&65535|w<<16,V=b&65535|p<<16,W=l,G=y,J=_,s=R,$=A,I=D,L=T,M=j,X=Y,Q=z,ft=H,et=V,nt=k,it=F,ot=O,q=K,N%16===15)for(E=0;E<16;E++)x=f[E],d=c[E],b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=f[(E+9)%16],d=c[(E+9)%16],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,S=f[(E+1)%16],P=c[(E+1)%16],x=(S>>>1|P<<32-1)^(S>>>8|P<<32-8)^S>>>7,d=(P>>>1|S<<32-1)^(P>>>8|S<<32-8)^(P>>>7|S<<32-7),b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,S=f[(E+14)%16],P=c[(E+14)%16],x=(S>>>19|P<<32-19)^(P>>>61-32|S<<32-(61-32))^S>>>6,d=(P>>>19|S<<32-19)^(S>>>61-32|P<<32-(61-32))^(P>>>6|S<<32-6),b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,f[E]=g&65535|w<<16,c[E]=b&65535|p<<16;x=M,d=q,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[0],d=o[0],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[0]=M=g&65535|w<<16,o[0]=q=b&65535|p<<16,x=W,d=X,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[1],d=o[1],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[1]=W=g&65535|w<<16,o[1]=X=b&65535|p<<16,x=G,d=Q,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[2],d=o[2],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[2]=G=g&65535|w<<16,o[2]=Q=b&65535|p<<16,x=J,d=ft,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[3],d=o[3],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[3]=J=g&65535|w<<16,o[3]=ft=b&65535|p<<16,x=s,d=et,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[4],d=o[4],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[4]=s=g&65535|w<<16,o[4]=et=b&65535|p<<16,x=$,d=nt,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[5],d=o[5],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[5]=$=g&65535|w<<16,o[5]=nt=b&65535|p<<16,x=I,d=it,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[6],d=o[6],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[6]=I=g&65535|w<<16,o[6]=it=b&65535|p<<16,x=L,d=ot,b=d&65535,p=d>>>16,g=x&65535,w=x>>>16,x=r[7],d=o[7],b+=d&65535,p+=d>>>16,g+=x&65535,w+=x>>>16,p+=b>>>16,g+=p>>>16,w+=g>>>16,r[7]=L=g&65535|w<<16,o[7]=ot=b&65535|p<<16,at+=128,t-=128}return t}function jt(r,o,i){var t=new Int32Array(8),f=new Int32Array(8),c=new Uint8Array(256),l,y=i;for(t[0]=1779033703,t[1]=3144134277,t[2]=1013904242,t[3]=2773480762,t[4]=1359893119,t[5]=2600822924,t[6]=528734635,t[7]=1541459225,f[0]=4089235720,f[1]=2227873595,f[2]=4271175723,f[3]=1595750129,f[4]=2917565137,f[5]=725511199,f[6]=4215389547,f[7]=327033209,Ar(t,f,o,i),i%=128,l=0;l<i;l++)c[l]=o[y-i+l];for(c[i]=128,i=256-128*(i<112?1:0),c[i-9]=0,St(c,i-8,y/536870912|0,y<<3),Ar(t,f,c,i),l=0;l<8;l++)St(r,8*l,t[l],f[l]);return 0}function _e(r,o){var i=n(),t=n(),f=n(),c=n(),l=n(),y=n(),_=n(),R=n(),A=n();mt(i,r[1],r[0]),mt(A,o[1],o[0]),Z(i,i,A),bt(t,r[0],r[1]),bt(A,o[0],o[1]),Z(t,t,A),Z(f,r[3],o[3]),Z(f,f,U),Z(c,r[2],o[2]),bt(c,c,c),mt(l,t,i),mt(y,c,f),bt(_,c,f),bt(R,t,i),Z(r[0],l,y),Z(r[1],R,_),Z(r[2],_,y),Z(r[3],l,R)}function Sr(r,o,i){var t;for(t=0;t<4;t++)qt(r[t],o[t],i)}function Je(r,o){var i=n(),t=n(),f=n();mr(f,o[2]),Z(i,o[0],f),Z(t,o[1],f),$t(r,t),r[31]^=br(i)<<7}function Ge(r,o,i){var t,f;for(Pt(r[0],m),Pt(r[1],v),Pt(r[2],v),Pt(r[3],m),f=255;f>=0;--f)t=i[f/8|0]>>(f&7)&1,Sr(r,o,t),_e(o,r),_e(r,r),Sr(r,o,t)}function ve(r,o){var i=[n(),n(),n(),n()];Pt(i[0],tt),Pt(i[1],rt),Pt(i[2],v),Z(i[3],tt,rt),Ge(r,i,o)}function qe(r,o,i){var t=new Uint8Array(64),f=[n(),n(),n(),n()],c;for(i||a(o,32),jt(t,o,32),t[0]&=248,t[31]&=127,t[31]|=64,ve(f,t),Je(r,f),c=0;c<32;c++)o[c+32]=r[c];return 0}var Ee=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]);function $e(r,o){var i,t,f,c;for(t=63;t>=32;--t){for(i=0,f=t-32,c=t-12;f<c;++f)o[f]+=i-16*o[t]*Ee[f-(t-32)],i=Math.floor((o[f]+128)/256),o[f]-=i*256;o[f]+=i,o[t]=0}for(i=0,f=0;f<32;f++)o[f]+=i-(o[31]>>4)*Ee[f],i=o[f]>>8,o[f]&=255;for(f=0;f<32;f++)o[f]-=i*Ee[f];for(t=0;t<32;t++)o[t+1]+=o[t]>>8,r[t]=o[t]&255}function Ze(r){var o=new Float64Array(64),i;for(i=0;i<64;i++)o[i]=r[i];for(i=0;i<64;i++)r[i]=0;$e(r,o)}function Tr(r,o,i,t){var f=new Uint8Array(64),c=new Uint8Array(64),l=new Uint8Array(64),y,_,R=new Float64Array(64),A=[n(),n(),n(),n()];jt(f,t,32),f[0]&=248,f[31]&=127,f[31]|=64;var D=i+64;for(y=0;y<i;y++)r[64+y]=o[y];for(y=0;y<32;y++)r[32+y]=f[32+y];for(jt(l,r.subarray(32),i+32),Ze(l),ve(A,l),Je(r,A),y=32;y<64;y++)r[y]=t[y];for(jt(c,r,i+64),Ze(c),y=0;y<64;y++)R[y]=0;for(y=0;y<32;y++)R[y]=l[y];for(y=0;y<32;y++)for(_=0;_<32;_++)R[y+_]+=c[y]*f[_];return $e(r.subarray(32),R),D}function En(r,o){var i=n(),t=n(),f=n(),c=n(),l=n(),y=n(),_=n();return Pt(r[2],v),We(r[1],o),yt(f,r[1]),Z(c,f,C),mt(f,f,r[2]),bt(c,r[2],c),yt(l,c),yt(y,l),Z(_,y,l),Z(i,_,f),Z(i,i,c),wr(i,i),Z(i,i,f),Z(i,i,c),Z(i,i,c),Z(r[0],i,c),yt(t,r[0]),Z(t,t,c),gr(t,f)&&Z(r[0],r[0],ht),yt(t,r[0]),Z(t,t,c),gr(t,f)?-1:(br(r[0])===o[31]>>7&&mt(r[0],m,r[0]),Z(r[3],r[0],r[1]),0)}function Xe(r,o,i,t){var f,c=new Uint8Array(32),l=new Uint8Array(64),y=[n(),n(),n(),n()],_=[n(),n(),n(),n()];if(i<64||En(_,t))return-1;for(f=0;f<i;f++)r[f]=o[f];for(f=0;f<32;f++)r[f+32]=t[f];if(jt(l,r,i),Ze(l),Ge(y,_,l),ve(_,o.subarray(32)),_e(y,_),Je(c,y),i-=64,Kt(o,0,c,0)){for(f=0;f<i;f++)r[f]=0;return-1}for(f=0;f<i;f++)r[f]=o[f+64];return i}var Qe=32,Ae=24,fe=32,Zt=16,ae=32,Se=32,se=32,ce=32,De=32,Or=Ae,An=fe,Sn=Zt,Ut=64,Yt=32,Xt=64,Ie=32,Le=64;e.lowlevel={crypto_core_hsalsa20:Jt,crypto_stream_xor:ne,crypto_stream:Mt,crypto_stream_salsa20_xor:ye,crypto_stream_salsa20:re,crypto_onetimeauth:ie,crypto_onetimeauth_verify:ge,crypto_verify_16:Tt,crypto_verify_32:Kt,crypto_secretbox:oe,crypto_secretbox_open:He,crypto_scalarmult:be,crypto_scalarmult_base:me,crypto_box_beforenm:we,crypto_box_afternm:vr,crypto_box:_n,crypto_box_open:vn,crypto_box_keypair:_r,crypto_hash:jt,crypto_sign:Tr,crypto_sign_keypair:qe,crypto_sign_open:Xe,crypto_secretbox_KEYBYTES:Qe,crypto_secretbox_NONCEBYTES:Ae,crypto_secretbox_ZEROBYTES:fe,crypto_secretbox_BOXZEROBYTES:Zt,crypto_scalarmult_BYTES:ae,crypto_scalarmult_SCALARBYTES:Se,crypto_box_PUBLICKEYBYTES:se,crypto_box_SECRETKEYBYTES:ce,crypto_box_BEFORENMBYTES:De,crypto_box_NONCEBYTES:Or,crypto_box_ZEROBYTES:An,crypto_box_BOXZEROBYTES:Sn,crypto_sign_BYTES:Ut,crypto_sign_PUBLICKEYBYTES:Yt,crypto_sign_SECRETKEYBYTES:Xt,crypto_sign_SEEDBYTES:Ie,crypto_hash_BYTES:Le,gf:n,D:C,L:Ee,pack25519:$t,unpack25519:We,M:Z,A:bt,S:yt,Z:mt,pow2523:wr,add:_e,set25519:Pt,modL:$e,scalarmult:Ge,scalarbase:ve};function Pr(r,o){if(r.length!==Qe)throw new Error("bad key size");if(o.length!==Ae)throw new Error("bad nonce size")}function Tn(r,o){if(r.length!==se)throw new Error("bad public key size");if(o.length!==ce)throw new Error("bad secret key size")}function pt(){for(var r=0;r<arguments.length;r++)if(!(arguments[r]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function Ur(r){for(var o=0;o<r.length;o++)r[o]=0}e.randomBytes=function(r){var o=new Uint8Array(r);return a(o,r),o},e.secretbox=function(r,o,i){pt(r,o,i),Pr(i,o);for(var t=new Uint8Array(fe+r.length),f=new Uint8Array(t.length),c=0;c<r.length;c++)t[c+fe]=r[c];return oe(f,t,t.length,o,i),f.subarray(Zt)},e.secretbox.open=function(r,o,i){pt(r,o,i),Pr(i,o);for(var t=new Uint8Array(Zt+r.length),f=new Uint8Array(t.length),c=0;c<r.length;c++)t[c+Zt]=r[c];return t.length<32||He(f,t,t.length,o,i)!==0?null:f.subarray(fe)},e.secretbox.keyLength=Qe,e.secretbox.nonceLength=Ae,e.secretbox.overheadLength=Zt,e.scalarMult=function(r,o){if(pt(r,o),r.length!==Se)throw new Error("bad n size");if(o.length!==ae)throw new Error("bad p size");var i=new Uint8Array(ae);return be(i,r,o),i},e.scalarMult.base=function(r){if(pt(r),r.length!==Se)throw new Error("bad n size");var o=new Uint8Array(ae);return me(o,r),o},e.scalarMult.scalarLength=Se,e.scalarMult.groupElementLength=ae,e.box=function(r,o,i,t){var f=e.box.before(i,t);return e.secretbox(r,o,f)},e.box.before=function(r,o){pt(r,o),Tn(r,o);var i=new Uint8Array(De);return we(i,r,o),i},e.box.after=e.secretbox,e.box.open=function(r,o,i,t){var f=e.box.before(i,t);return e.secretbox.open(r,o,f)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var r=new Uint8Array(se),o=new Uint8Array(ce);return _r(r,o),{publicKey:r,secretKey:o}},e.box.keyPair.fromSecretKey=function(r){if(pt(r),r.length!==ce)throw new Error("bad secret key size");var o=new Uint8Array(se);return me(o,r),{publicKey:o,secretKey:new Uint8Array(r)}},e.box.publicKeyLength=se,e.box.secretKeyLength=ce,e.box.sharedKeyLength=De,e.box.nonceLength=Or,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(r,o){if(pt(r,o),o.length!==Xt)throw new Error("bad secret key size");var i=new Uint8Array(Ut+r.length);return Tr(i,r,r.length,o),i},e.sign.open=function(r,o){if(pt(r,o),o.length!==Yt)throw new Error("bad public key size");var i=new Uint8Array(r.length),t=Xe(i,r,r.length,o);if(t<0)return null;for(var f=new Uint8Array(t),c=0;c<f.length;c++)f[c]=i[c];return f},e.sign.detached=function(r,o){for(var i=e.sign(r,o),t=new Uint8Array(Ut),f=0;f<t.length;f++)t[f]=i[f];return t},e.sign.detached.verify=function(r,o,i){if(pt(r,o,i),o.length!==Ut)throw new Error("bad signature size");if(i.length!==Yt)throw new Error("bad public key size");var t=new Uint8Array(Ut+r.length),f=new Uint8Array(Ut+r.length),c;for(c=0;c<Ut;c++)t[c]=o[c];for(c=0;c<r.length;c++)t[c+Ut]=r[c];return Xe(f,t,t.length,i)>=0},e.sign.keyPair=function(){var r=new Uint8Array(Yt),o=new Uint8Array(Xt);return qe(r,o),{publicKey:r,secretKey:o}},e.sign.keyPair.fromSecretKey=function(r){if(pt(r),r.length!==Xt)throw new Error("bad secret key size");for(var o=new Uint8Array(Yt),i=0;i<o.length;i++)o[i]=r[32+i];return{publicKey:o,secretKey:new Uint8Array(r)}},e.sign.keyPair.fromSeed=function(r){if(pt(r),r.length!==Ie)throw new Error("bad seed size");for(var o=new Uint8Array(Yt),i=new Uint8Array(Xt),t=0;t<32;t++)i[t]=r[t];return qe(o,i,!0),{publicKey:o,secretKey:i}},e.sign.publicKeyLength=Yt,e.sign.secretKeyLength=Xt,e.sign.seedLength=Ie,e.sign.signatureLength=Ut,e.hash=function(r){pt(r);var o=new Uint8Array(Le);return jt(o,r,r.length),o},e.hash.hashLength=Le,e.verify=function(r,o){return pt(r,o),r.length===0||o.length===0||r.length!==o.length?!1:st(r,0,o,0,r.length)===0},e.setPRNG=function(r){a=r},function(){var r=typeof self<"u"?self.crypto||self.msCrypto:null;if(r&&r.getRandomValues){var o=65536;e.setPRNG(function(i,t){var f,c=new Uint8Array(t);for(f=0;f<t;f+=o)r.getRandomValues(c.subarray(f,f+Math.min(t-f,o)));for(f=0;f<t;f++)i[f]=c[f];Ur(c)})}else typeof Nr<"u"&&(r=jr(),r&&r.randomBytes&&e.setPRNG(function(i,t){var f,c=r.randomBytes(t);for(f=0;f<t;f++)i[f]=c[f];Ur(c)}))}()})(typeof Ne<"u"&&Ne.exports?Ne.exports:self.nacl=self.nacl||{})});var le=Te(rr());function Qt(e){var n;return new Uint8Array(((n=e.match(/.{1,2}/g))!==null&&n!==void 0?n:[]).map(a=>parseInt(a,16))).buffer}function Nt(e){return new Uint8Array(e).reduce((n,a)=>n+a.toString(16).padStart(2,"0"),"")}var Kn=(e,n)=>{if(e.byteLength!==n.byteLength)return!1;let a=new Uint8Array(e),u=new Uint8Array(n);for(let h=0;h<a.length;h++)if(a[h]!==u[h])return!1;return!0},Yr=e=>{if(e<=127)return 1;if(e<=255)return 2;if(e<=65535)return 3;if(e<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")},Vr=(e,n,a)=>{if(a<=127)return e[n]=a,1;if(a<=255)return e[n]=129,e[n+1]=a,2;if(a<=65535)return e[n]=130,e[n+1]=a>>8,e[n+2]=a,3;if(a<=16777215)return e[n]=131,e[n+1]=a>>16,e[n+2]=a>>8,e[n+3]=a,4;throw new Error("Length too long (> 4 bytes)")},nr=(e,n)=>{if(e[n]<128)return 1;if(e[n]===128)throw new Error("Invalid length 0");if(e[n]===129)return 2;if(e[n]===130)return 3;if(e[n]===131)return 4;throw new Error("Length too long (> 4 bytes)")},Cn=(e,n)=>{let a=nr(e,n);if(a===1)return e[n];if(a===2)return e[n+1];if(a===3)return(e[n+1]<<8)+e[n+2];if(a===4)return(e[n+1]<<16)+(e[n+2]<<8)+e[n+3];throw new Error("Length too long (> 4 bytes)")},Fr=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),Re=Uint8Array.from([48,5,6,3,43,101,112]),ui=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function Be(e,n){let a=2+Yr(e.byteLength+1),u=n.byteLength+a+e.byteLength,h=0,m=new Uint8Array(1+Yr(u)+u);return m[h++]=48,h+=Vr(m,h,u),m.set(n,h),h+=n.byteLength,m[h++]=3,h+=Vr(m,h,e.byteLength+1),m[h++]=0,m.set(new Uint8Array(e),h),m}var ir=(e,n)=>{let a=0,u=(B,C)=>{if(h[a++]!==B)throw new Error("Expected: "+C)},h=new Uint8Array(e);if(u(48,"sequence"),a+=nr(h,a),!Kn(h.slice(a,a+n.byteLength),n))throw new Error("Not the expected OID.");a+=n.byteLength,u(3,"bit string");let m=Cn(h,a)-1;a+=nr(h,a),u(0,"0 padding");let v=h.slice(a);if(m!==v.length)throw new Error(`DER payload mismatch: Expected length ${m} actual length ${v.length}`);return v};var gt=class{constructor(n){this.rawKey=n,this.derKey=gt.derEncode(n)}static from(n){return this.fromDer(n.toDer())}static fromRaw(n){return new gt(n)}static fromDer(n){return new gt(this.derDecode(n))}static derEncode(n){return Be(n,Re).buffer}static derDecode(n){let a=ir(n,Re);if(a.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return a}toDer(){return this.derKey}toRaw(){return this.rawKey}};gt.RAW_KEY_LENGTH=32;var Rt=class extends Vt{constructor(n,a){super(),this._privateKey=a,this._publicKey=gt.from(n)}static generate(n){if(n&&n.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");let{publicKey:a,secretKey:u}=n===void 0?le.sign.keyPair():le.sign.keyPair.fromSeed(n);return new this(gt.fromRaw(a),u)}static fromParsedJson(n){let[a,u]=n;return new Rt(gt.fromDer(Qt(a)),Qt(u))}static fromJSON(n){let a=JSON.parse(n);if(Array.isArray(a)){if(typeof a[0]=="string"&&typeof a[1]=="string")return this.fromParsedJson([a[0],a[1]]);throw new Error("Deserialization error: JSON must have at least 2 items.")}throw new Error(`Deserialization error: Invalid JSON type for string: ${JSON.stringify(n)}`)}static fromKeyPair(n,a){return new Rt(gt.fromRaw(n),a)}static fromSecretKey(n){let a=le.sign.keyPair.fromSecretKey(new Uint8Array(n));return Rt.fromKeyPair(a.publicKey,a.secretKey)}toJSON(){return[Nt(this._publicKey.toDer()),Nt(this._privateKey)]}getKeyPair(){return{secretKey:this._privateKey,publicKey:this._publicKey}}getPublicKey(){return this._publicKey}async sign(n){let a=new Uint8Array(n);return le.sign.detached(a,new Uint8Array(this._privateKey)).buffer}};var xe=class extends Error{constructor(n){super(n),this.message=n,Object.setPrototypeOf(this,xe.prototype)}};function kr(e){if(e)return e;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new xe("Global crypto was not available and none was provided. Please inlcude a SubtleCrypto implementation. See https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto")}var kt=class extends Vt{constructor(n,a,u){super(),this._keyPair=n,this._derKey=a,this._subtleCrypto=u}static async generate(n){let{extractable:a=!1,keyUsages:u=["sign","verify"],subtleCrypto:h}=n??{},m=kr(h),v=await m.generateKey({name:"ECDSA",namedCurve:"P-256"},a,u),B=await m.exportKey("spki",v.publicKey);return new this(v,B,m)}static async fromKeyPair(n,a){let u=kr(a),h=await u.exportKey("spki",n.publicKey);return new kt(n,h,u)}getKeyPair(){return this._keyPair}getPublicKey(){let n=this._derKey,a=Object.create(this._keyPair.publicKey);return a.toDer=function(){return n},a}async sign(n){let a={name:"ECDSA",hash:{name:"SHA-256"}};return this._keyPair.privateKey,await this._subtleCrypto.sign(a,this._keyPair.privateKey,n)}};var Dt=Te(Rn());var Mn=function(e,n){var a={};for(var u in e)Object.prototype.hasOwnProperty.call(e,u)&&n.indexOf(u)<0&&(a[u]=e[u]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var h=0,u=Object.getOwnPropertySymbols(e);h<u.length;h++)n.indexOf(u[h])<0&&Object.prototype.propertyIsEnumerable.call(e,u[h])&&(a[u[h]]=e[u[h]]);return a},jn=new TextEncoder().encode("ic-request-auth-delegation"),Yn=new TextEncoder().encode(`
2
+ ic-request`);function or(e){if(typeof e!="string"||e.length<64)throw new Error("Invalid public key.");return Qt(e)}var It=class{constructor(n,a,u){this.pubkey=n,this.expiration=a,this.targets=u}toCBOR(){return Dt.value.map(Object.assign({pubkey:Dt.value.bytes(this.pubkey),expiration:Dt.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:Dt.value.array(this.targets.map(n=>Dt.value.bytes(n.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:Nt(this.pubkey)},this.targets&&{targets:this.targets.map(n=>n.toHex())})}};async function Vn(e,n,a,u){let h=new It(n.toDer(),BigInt(+a)*BigInt(1e6),u),m=new Uint8Array([...jn,...new Uint8Array(tr(h))]),v=await e.sign(m);return{delegation:h,signature:v}}var Ht=class{constructor(n,a){this.delegations=n,this.publicKey=a}static async create(n,a,u=new Date(Date.now()+15*60*1e3),h={}){var m,v;let B=await Vn(n,a,u,h.targets);return new Ht([...((m=h.previous)===null||m===void 0?void 0:m.delegations)||[],B],((v=h.previous)===null||v===void 0?void 0:v.publicKey)||n.getPublicKey().toDer())}static fromJSON(n){let{publicKey:a,delegations:u}=typeof n=="string"?JSON.parse(n):n;if(!Array.isArray(u))throw new Error("Invalid delegations.");let h=u.map(m=>{let{delegation:v,signature:B}=m,{pubkey:C,expiration:U,targets:tt}=v;if(tt!==void 0&&!Array.isArray(tt))throw new Error("Invalid targets.");return{delegation:new It(or(C),BigInt(`0x${U}`),tt&&tt.map(rt=>{if(typeof rt!="string")throw new Error("Invalid target.");return Pe.fromHex(rt)})),signature:or(B)}});return new this(h,or(a))}static fromDelegations(n,a){return new this(n,a)}toJSON(){return{delegations:this.delegations.map(n=>{let{delegation:a,signature:u}=n,{targets:h}=a;return{delegation:Object.assign({expiration:a.expiration.toString(16),pubkey:Nt(a.pubkey)},h&&{targets:h.map(m=>m.toHex())}),signature:Nt(u)}}),publicKey:Nt(this.publicKey)}}},de=class extends Vt{constructor(n,a){super(),this._inner=n,this._delegation=a}static fromDelegation(n,a){return new this(n,a)}getDelegation(){return this._delegation}getPublicKey(){return{toDer:()=>this._delegation.publicKey}}sign(n){return this._inner.sign(n)}async transformRequest(n){let{body:a}=n,u=Mn(n,["body"]),h=await tr(a);return Object.assign(Object.assign({},u),{body:{content:a,sender_sig:await this.sign(new Uint8Array([...Yn,...new Uint8Array(h)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};function Hr(e,n){for(let{delegation:h}of e.delegations)if(+new Date(Number(h.expiration/BigInt(1e6)))<=+Date.now())return!1;let a=[],u=n?.scope;u&&(Array.isArray(u)?a.push(...u.map(h=>typeof h=="string"?Pe.fromText(h):h)):a.push(typeof u=="string"?Pe.fromText(u):u));for(let h of a){let m=h.toText();for(let{delegation:v}of e.delegations){if(v.targets===void 0)continue;let B=!0;for(let C of v.targets)if(C.toText()===m){B=!1;break}if(B)return!1}}return!0}var Fn=Te(Nn()),kn=Te(rr());var zr;(function(e){e[e.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(zr||(zr={}));var Wr=["mousedown","mousemove","keydown","touchstart","wheel"],ue=class{constructor(n={}){var a;this.callbacks=[],this.idleTimeout=10*60*1e3,this.timeoutID=void 0;let{onIdle:u,idleTimeout:h=10*60*1e3}=n||{};this.callbacks=u?[u]:[],this.idleTimeout=h;let m=this._resetTimer.bind(this);window.addEventListener("load",m,!0),Wr.forEach(function(B){document.addEventListener(B,m,!0)});let v=(B,C)=>{let U;return(...tt)=>{let rt=this,ht=function(){U=void 0,B.apply(rt,tt)};clearTimeout(U),U=window.setTimeout(ht,C)}};if(n?.captureScroll){let B=v(m,(a=n?.scrollDebounce)!==null&&a!==void 0?a:100);window.addEventListener("scroll",B,!0)}m()}static create(n={}){return new this(n)}registerCallback(n){this.callbacks.push(n)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let n=this._resetTimer.bind(this);Wr.forEach(function(a){document.removeEventListener(a,n,!0)}),this.callbacks.forEach(a=>a())}_resetTimer(){let n=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(n,this.idleTimeout)}};var Hn=(e,n)=>n.some(a=>e instanceof a),Jr,Gr;function zn(){return Jr||(Jr=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Wn(){return Gr||(Gr=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var qr=new WeakMap,ar=new WeakMap,$r=new WeakMap,fr=new WeakMap,cr=new WeakMap;function Jn(e){let n=new Promise((a,u)=>{let h=()=>{e.removeEventListener("success",m),e.removeEventListener("error",v)},m=()=>{a(_t(e.result)),h()},v=()=>{u(e.error),h()};e.addEventListener("success",m),e.addEventListener("error",v)});return n.then(a=>{a instanceof IDBCursor&&qr.set(a,e)}).catch(()=>{}),cr.set(n,e),n}function Gn(e){if(ar.has(e))return;let n=new Promise((a,u)=>{let h=()=>{e.removeEventListener("complete",m),e.removeEventListener("error",v),e.removeEventListener("abort",v)},m=()=>{a(),h()},v=()=>{u(e.error||new DOMException("AbortError","AbortError")),h()};e.addEventListener("complete",m),e.addEventListener("error",v),e.addEventListener("abort",v)});ar.set(e,n)}var sr={get(e,n,a){if(e instanceof IDBTransaction){if(n==="done")return ar.get(e);if(n==="objectStoreNames")return e.objectStoreNames||$r.get(e);if(n==="store")return a.objectStoreNames[1]?void 0:a.objectStore(a.objectStoreNames[0])}return _t(e[n])},set(e,n,a){return e[n]=a,!0},has(e,n){return e instanceof IDBTransaction&&(n==="done"||n==="store")?!0:n in e}};function Zr(e){sr=e(sr)}function qn(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(n,...a){let u=e.call(Ke(this),n,...a);return $r.set(u,n.sort?n.sort():[n]),_t(u)}:Wn().includes(e)?function(...n){return e.apply(Ke(this),n),_t(qr.get(this))}:function(...n){return _t(e.apply(Ke(this),n))}}function $n(e){return typeof e=="function"?qn(e):(e instanceof IDBTransaction&&Gn(e),Hn(e,zn())?new Proxy(e,sr):e)}function _t(e){if(e instanceof IDBRequest)return Jn(e);if(fr.has(e))return fr.get(e);let n=$n(e);return n!==e&&(fr.set(e,n),cr.set(n,e)),n}var Ke=e=>cr.get(e);function Qr(e,n,{blocked:a,upgrade:u,blocking:h,terminated:m}={}){let v=indexedDB.open(e,n),B=_t(v);return u&&v.addEventListener("upgradeneeded",C=>{u(_t(v.result),C.oldVersion,C.newVersion,_t(v.transaction),C)}),a&&v.addEventListener("blocked",C=>a(C.oldVersion,C.newVersion,C)),B.then(C=>{m&&C.addEventListener("close",()=>m()),h&&C.addEventListener("versionchange",U=>h(U.oldVersion,U.newVersion,U))}).catch(()=>{}),B}var Zn=["get","getKey","getAll","getAllKeys","count"],Xn=["put","add","delete","clear"],lr=new Map;function Xr(e,n){if(!(e instanceof IDBDatabase&&!(n in e)&&typeof n=="string"))return;if(lr.get(n))return lr.get(n);let a=n.replace(/FromIndex$/,""),u=n!==a,h=Xn.includes(a);if(!(a in(u?IDBIndex:IDBObjectStore).prototype)||!(h||Zn.includes(a)))return;let m=async function(v,...B){let C=this.transaction(v,h?"readwrite":"readonly"),U=C.store;return u&&(U=U.index(B.shift())),(await Promise.all([U[a](...B),h&&C.done]))[0]};return lr.set(n,m),m}Zr(e=>({...e,get:(n,a,u)=>Xr(n,a)||e.get(n,a,u),has:(n,a)=>!!Xr(n,a)||e.has(n,a)}));var Dr="auth-client-db",Ir="ic-keyval",Qn=async(e=Dr,n=Ir,a)=>(Ce&&(localStorage!=null&&localStorage.getItem(wt))&&(localStorage.removeItem(wt),localStorage.removeItem(vt)),await Qr(e,a,{upgrade:u=>{u.objectStoreNames,u.objectStoreNames.contains(n)&&u.clear(n),u.createObjectStore(n)}}));async function Dn(e,n,a){return await e.get(n,a)}async function In(e,n,a,u){return await e.put(n,u,a)}async function Ln(e,n,a){return await e.delete(n,a)}var zt=class{constructor(n,a){this._db=n,this._storeName=a}static async create(n){let{dbName:a=Dr,storeName:u=Ir,version:h=1}=n??{},m=await Qn(a,u,h);return new zt(m,u)}async set(n,a){return await In(this._db,this._storeName,n,a)}async get(n){var a;return(a=await Dn(this._db,this._storeName,n))!==null&&a!==void 0?a:null}async remove(n){return await Ln(this._db,this._storeName,n)}};var vt="identity",wt="delegation",Lr="iv",ti=1,Ce=typeof window<"u",he=class{constructor(n="ic-",a){this.prefix=n,this._localStorage=a}get(n){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+n))}set(n,a){return this._getLocalStorage().setItem(this.prefix+n,a),Promise.resolve()}remove(n){return this._getLocalStorage().removeItem(this.prefix+n),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let n=typeof window>"u"&&typeof window>"u"?typeof self>"u"?void 0:self.localStorage:window.localStorage;if(!n)throw new Error("Could not find local storage.");return n}},pe=class{get _db(){return new Promise(n=>{if(this.initializedDb){n(this.initializedDb);return}zt.create({version:ti}).then(a=>{this.initializedDb=a,n(a)})})}async get(n){return await(await this._db).get(n)}async set(n,a){await(await this._db).set(n,a)}async remove(n){await(await this._db).remove(n)}};var ei="https://identity.ic0.app",ri="#authorize",ni=500,ii="UserInterrupt",Me=class{constructor(n,a,u,h,m,v,B,C){var U;this._identity=n,this._key=a,this._chain=u,this._storage=h,this.idleManager=m,this._createOptions=v,this._idpWindow=B,this._eventHandler=C;let tt=this.logout.bind(this),rt=v?.idleOptions;!rt?.onIdle&&!rt?.disableDefaultIdleCallback&&((U=this.idleManager)===null||U===void 0||U.registerCallback(()=>{tt(),location.reload()}))}static async create(n={}){var a,u;let h=(a=n.storage)!==null&&a!==void 0?a:new pe,m=null;if(n.identity)m=n.identity;else{let U=await h.get(vt);if(!U&&Ce)try{let tt=new he,rt=await tt.get(wt),ht=await tt.get(vt);rt&&ht&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await h.set(wt,rt),await h.set(vt,ht),U=rt,await tt.remove(wt),await tt.remove(vt))}catch(tt){console.error("error while attempting to recover localstorage: "+tt)}if(U)try{typeof U=="object"?m=await kt.fromKeyPair(U):typeof U=="string"&&(m=Rt.fromJSON(U))}catch{}}let v=new er,B=null;if(m)try{let U=await h.get(wt);if(typeof U=="object"&&U!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");n.identity?v=n.identity:U&&(B=Ht.fromJSON(U),Hr(B)?v=de.fromDelegation(m,B):(await xr(h),m=null))}catch(U){console.error(U),await xr(h),m=null}let C;return!((u=n.idleOptions)===null||u===void 0)&&u.disableIdle?C=void 0:(B||n.identity)&&(C=ue.create(n.idleOptions)),m||(m=await kt.generate(),await h.set(vt,m.getKeyPair())),new this(v,m,B,h,C,n)}_handleSuccess(n,a){var u,h,m;let v=n.delegations.map(U=>({delegation:new It(U.delegation.pubkey,U.delegation.expiration,U.delegation.targets),signature:U.signature.buffer})),B=Ht.fromDelegations(v,n.userPublicKey.buffer),C=this._key;if(C){if(this._chain=B,this._identity=de.fromDelegation(C,this._chain),(u=this._idpWindow)===null||u===void 0||u.close(),!this.idleManager){let U=(h=this._createOptions)===null||h===void 0?void 0:h.idleOptions;this.idleManager=ue.create(U),!U?.onIdle&&!U?.disableDefaultIdleCallback&&((m=this.idleManager)===null||m===void 0||m.registerCallback(()=>{this.logout(),location.reload()}))}a?.(),this._removeEventListener(),delete this._idpWindow}}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(n){var a,u,h,m;let v=BigInt(8)*BigInt(36e11),B=new URL(((a=n?.identityProvider)===null||a===void 0?void 0:a.toString())||ei);B.hash=ri,(u=this._idpWindow)===null||u===void 0||u.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(B,Object.assign({maxTimeToLive:(h=n?.maxTimeToLive)!==null&&h!==void 0?h:v},n)),window.addEventListener("message",this._eventHandler),this._idpWindow=(m=window.open(B.toString(),"idpWindow",n?.windowOpenerFeatures))!==null&&m!==void 0?m:void 0;let C=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(ii,n?.onError):setTimeout(C,ni))};C()}_getEventHandler(n,a){return async u=>{var h,m,v;if(u.origin!==n.origin){console.warn(`WARNING: expected origin '${n.origin}', got '${u.origin}' (ignoring)`);return}let B=u.data;switch(B.kind){case"authorize-ready":{let C={kind:"authorize-client",sessionPublicKey:new Uint8Array((h=this._key)===null||h===void 0?void 0:h.getPublicKey().toDer()),maxTimeToLive:a?.maxTimeToLive,derivationOrigin:(m=a?.derivationOrigin)===null||m===void 0?void 0:m.toString()};(v=this._idpWindow)===null||v===void 0||v.postMessage(C,n.origin);break}case"authorize-client-success":try{this._handleSuccess(B,a?.onSuccess),this._chain&&await this._storage.set(wt,JSON.stringify(this._chain.toJSON()))}catch(C){this._handleFailure(C.message,a?.onError)}break;case"authorize-client-failure":this._handleFailure(B.text,a?.onError);break;default:break}}}_handleFailure(n,a){var u;(u=this._idpWindow)===null||u===void 0||u.close(),a?.(n),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(n={}){if(await xr(this._storage),this._identity=new er,this._chain=null,n.returnTo)try{window.history.pushState({},"",n.returnTo)}catch{window.location.href=n.returnTo}}};async function xr(e){await e.remove(vt),await e.remove(wt),await e.remove(Lr)}var tn=BigInt(144e11);var Lt=class{callbacks=[];populate(n){this.callbacks.forEach(({callback:a})=>a(n))}subscribe(n){let a=Symbol();return this.callbacks.push({id:a,callback:n}),()=>this.callbacks=this.callbacks.filter(({id:u})=>u!==a)}};var te=class extends Lt{authUser=null;constructor(){super()}static getInstance(){return te.instance||(te.instance=new te),te.instance}set(n){this.authUser=n,this.populate(n)}get(){return this.authUser}subscribe(n){let a=super.subscribe(n);return n(this.authUser),a}isLoggedIn(){return!this.authUser?.data?.principal.isAnonymous()}reset(){this.authUser=null,this.populate(this.authUser)}},Ct=te;Oe(Ct,"instance");var ee=class extends Lt{env;constructor(){super()}static getInstance(){return ee.instance||(ee.instance=new ee),ee.instance}set(n){this.env=n,this.populate(n)}get(){return this.env}localIdentity(){return this.get()?.localIdentityCanisterId!==void 0}subscribe(n){let a=super.subscribe(n);return n(this.env),a}},dt=ee;Oe(dt,"instance");var ut=e=>e?[e]:[],je=e=>e?.[0],en=async e=>{let n=new Blob([JSON.stringify(e)],{type:"application/json; charset=utf-8"});return new Uint8Array(await n.arrayBuffer())},dr=async e=>{let n=new Blob([e],{type:"application/json; charset=utf-8"});return JSON.parse(await n.text())};var ur=e=>e==null;var Ye=({matcher:e,paginate:n,order:a})=>({matcher:ut(e),paginate:ut(ur(n)?void 0:{start_after:ut(n.startAfter),limit:ut(ur(n.limit)?void 0:BigInt(n.limit))}),order:ut(a)});var rn=({IDL:e})=>{let n=e.Record({controllers:e.Vec(e.Principal)}),a=e.Record({batch_id:e.Nat,headers:e.Vec(e.Tuple(e.Text,e.Text)),chunk_ids:e.Vec(e.Nat)}),u=e.Record({updated_at:e.Opt(e.Nat64)}),h=e.Record({headers:e.Vec(e.Tuple(e.Text,e.Vec(e.Tuple(e.Text,e.Text))))}),m=e.Record({storage:h}),v=e.Record({updated_at:e.Nat64,owner:e.Principal,data:e.Vec(e.Nat8),created_at:e.Nat64}),B=e.Record({url:e.Text,method:e.Text,body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text))}),C=e.Record({token:e.Opt(e.Text),sha256:e.Opt(e.Vec(e.Nat8)),headers:e.Vec(e.Tuple(e.Text,e.Text)),index:e.Nat64,encoding_type:e.Text,full_path:e.Text}),U=e.Variant({Callback:e.Record({token:C,callback:e.Func([],[],[])})}),tt=e.Record({body:e.Vec(e.Nat8),headers:e.Vec(e.Tuple(e.Text,e.Text)),streaming_strategy:e.Opt(U),status_code:e.Nat16}),rt=e.Record({token:e.Opt(C),body:e.Vec(e.Nat8)}),ht=e.Record({token:e.Opt(e.Text),collection:e.Text,name:e.Text,encoding_type:e.Opt(e.Text),full_path:e.Text}),St=e.Record({batch_id:e.Nat}),st=e.Record({desc:e.Bool}),Tt=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),Kt=e.Record({order:e.Opt(st),matcher:e.Opt(e.Text),paginate:e.Opt(Tt)}),Fe=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),ke=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),Wt=e.Record({key:Fe,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,ke)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),Jt=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,Wt))}),Ot=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),ye=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,v))}),re=e.Variant({Db:e.Null,Storage:e.Null}),Mt=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),ne=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:Mt,created_at:e.Nat64,write:Mt}),Gt=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),ie=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:Mt,write:Mt}),ge=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),oe=e.Record({chunk_id:e.Nat});return e.Service({add_controllers:e.Func([n],[e.Vec(e.Principal)],[]),commit_asset_upload:e.Func([a],[],[]),del_asset:e.Func([e.Text,e.Text],[],[]),del_assets:e.Func([e.Opt(e.Text)],[],[]),del_custom_domain:e.Func([e.Text],[],[]),del_doc:e.Func([e.Text,e.Text,u],[],[]),get_config:e.Func([],[m],[]),get_doc:e.Func([e.Text,e.Text],[e.Opt(v)],["query"]),http_request:e.Func([B],[tt],["query"]),http_request_streaming_callback:e.Func([C],[rt],["query"]),init_asset_upload:e.Func([ht],[St],[]),list_assets:e.Func([e.Opt(e.Text),Kt],[Jt],["query"]),list_controllers:e.Func([],[e.Vec(e.Principal)],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,Ot))],["query"]),list_docs:e.Func([e.Text,Kt],[ye],["query"]),list_rules:e.Func([re],[e.Vec(e.Tuple(e.Text,ne))],["query"]),remove_controllers:e.Func([n],[e.Vec(e.Principal)],[]),set_config:e.Func([m],[],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_doc:e.Func([e.Text,e.Text,Gt],[v],[]),set_rule:e.Func([re,e.Text,ie],[],[]),upload_asset_chunk:e.Func([ge],[oe],[]),version:e.Func([],[e.Text],["query"])})};var nn=async({satelliteId:e,idlFactory:n,identity:a,fetch:u,env:h="prod"})=>{let m=h==="dev"||dt.getInstance().localIdentity(),v=m?"http://127.0.0.1:8000/":"https://ic0.app",B=new Br({identity:a,...v&&{host:v},...u&&{fetch:u}});return m&&await B.fetchRootKey(),Kr.createActor(n,{agent:B,canisterId:e})};var Et=async({satelliteId:e,...n})=>{let{satelliteId:a}=e!==void 0?{satelliteId:e}:dt.getInstance().get()??{satelliteId:void 0};if(!a)throw new Error("No satellite principal defined.");return nn({satelliteId:a,idlFactory:rn,...n})};var on=async({collection:e,key:n,satellite:a})=>{let u=await Et(a),h=je(await u.get_doc(e,n));if(!h)return;let m=await dr(h.data);return{key:n,data:m,created_at:h.created_at,updated_at:h.updated_at}},fn=async({collection:e,doc:n,satellite:a})=>{let u=await Et(a),{key:h,data:m,updated_at:v}=n,B=await u.set_doc(e,h,{data:await en(m),updated_at:ut(v)});return{key:h,data:m,created_at:B.created_at,updated_at:B.updated_at}},an=async({collection:e,doc:n,satellite:a})=>{let u=await Et(a),{key:h,updated_at:m}=n;return u.del_doc(e,h,{updated_at:ut(m)})},sn=async({collection:e,filter:n,satellite:a})=>{let u=await Et(a),{items:h,matches_length:m,length:v}=await u.list_docs(e,Ye(n)),B=[];for(let[C,U]of h)B.push({key:C,data:await dr(U.data),created_at:U.created_at,updated_at:U.updated_at});return{items:B,length:v,matches_length:m}};var At=e=>{if(e!==void 0)return e;let n=Ve();if(!n)throw new Error("No internet identity.");return n};var cn=async({satellite:e,...n})=>{let a=At(e?.identity);return on({...n,satellite:{...e,identity:a}})},ln=async({satellite:e,...n})=>{let a=At(e?.identity);return fn({...n,satellite:{...e,identity:a}})},No=async({satellite:e,...n})=>{let a=At(e?.identity);return an({...n,satellite:{...e,identity:a}})},Ro=async({satellite:e,...n})=>{let a=At(e?.identity);return sn({...n,satellite:{...e,identity:a}})};var xn=async()=>{let e=Ve();if(!e)throw new Error("No internet identity.");let n=e.getPrincipal().toText(),a=await cn({collection:"#user",key:n});return a||await oi({userId:n,principal:e.getPrincipal()})},oi=async({userId:e,principal:n})=>{let a=new Date;return ln({collection:"#user",doc:{key:e,data:{principal:n,created_at:a,updated_at:a}}})};var Bt,dn=()=>Me.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}}),hr=async()=>{if(Bt=Bt??await dn(),!(await Bt?.isAuthenticated()||!1))return;let n=await xn();Ct.getInstance().set(n)},fi=async e=>new Promise(async(n,a)=>{Bt=Bt??await dn(),await Bt.login({onSuccess:async()=>{await hr(),n()},onError:u=>a(u),maxTimeToLive:e?.maxTimeToLive??tn,...dt.getInstance().localIdentity()&&{identityProvider:`http://${dt.getInstance().get()?.localIdentityCanisterId}.localhost:8000?#authorize`},...e?.derivationOrigin!==void 0&&{derivationOrigin:e.derivationOrigin},...e?.windowOpenerFeatures!==void 0&&{windowOpenerFeatures:e.windowOpenerFeatures}})}),ai=async()=>{await Bt?.logout(),Bt=void 0,Ct.getInstance().reset()},Ve=()=>Bt?.getIdentity();var un=()=>typeof window<"u",pr=()=>{let e=dt.getInstance().get()?.satelliteId??"unknown";return dt.getInstance().localIdentity()?`http://${e}.localhost:8000`:`https://${e}.ic0.app`};var hn=async({data:e,filename:n,collection:a,headers:u,token:h,fullPath:m,encoding:v,satellite:B})=>{let C=await Et(B),{batch_id:U}=await C.init_asset_upload({collection:a,full_path:m,name:n,token:ut(h),encoding_type:ut(v)}),tt=7e5,rt=[],ht=un()?new Blob([await e.arrayBuffer()]):e;for(let st=0;st<ht.size;st+=tt){let Tt=ht.slice(st,st+tt);rt.push(await si({batchId:U,chunk:Tt,actor:C}))}let St=u.find(([st,Tt])=>st.toLowerCase()==="content-type")===void 0&&e.type!==void 0&&e.type!==""?[["Content-Type",e.type]]:void 0;await C.commit_asset_upload({batch_id:U,chunk_ids:rt.map(({chunk_id:st})=>st),headers:[...u,...St||[]]})},si=async({batchId:e,chunk:n,actor:a})=>a.upload_asset_chunk({batch_id:e,content:new Uint8Array(await n.arrayBuffer())}),pn=async({collection:e,satellite:n,filter:a})=>{let u=await Et(n),{items:h,matches_length:m,length:v}=await u.list_assets(ut(e),Ye(a));return{items:h.map(([B,C])=>C),length:v,matches_length:m}},yn=async({collection:e,storageFile:n,satellite:a})=>{let u=await Et(a),{fullPath:h}=n;return u.del_asset(e,h)},gn=async({collection:e,satellite:n})=>(await Et(n)).del_assets(ut(e));var bn=e=>btoa([...e].map(n=>String.fromCharCode(n)).join(""));var yr=e=>encodeURI(e.toLowerCase().replace(/\s/g,"-"));var nf=async e=>mn(e),of=async e=>mn({filename:e.data.name,...e}),mn=async({filename:e,data:n,collection:a,headers:u=[],fullPath:h,token:m,satellite:v,encoding:B})=>{let C=At(v?.identity),U=yr(e),tt=h||`/${a}/${U}`;return await hn({data:n,filename:yr(U),collection:a,token:m,headers:u,fullPath:tt,encoding:B,satellite:{...v,identity:C}}),{downloadUrl:`${pr()}${tt}${m!==void 0?`?token=${m}`:""}`,fullPath:tt,name:U}},ff=async({collection:e,satellite:n,filter:a})=>{let{items:u,...h}=await pn({collection:e,satellite:{...n,identity:At(n?.identity)},filter:a??{}}),m=pr();return{assets:u.map(({key:{full_path:v,token:B,name:C},headers:U,encodings:tt})=>{let rt=je(B);return{fullPath:v,name:C,downloadUrl:`${m}${v}${rt!==void 0?`?token=${rt}`:""}`,token:rt,headers:U,encodings:tt.reduce((ht,[St,{modified:st,sha256:Tt,total_length:Kt}])=>({...ht,[St]:{modified:st,sha256:bn(Tt),total_length:Kt}}),{})}}),...h}},af=async({storageFile:e,collection:n,satellite:a})=>yn({collection:n,storageFile:e,satellite:{...a,identity:At(a?.identity)}}),sf=async({collection:e,satellite:n})=>gn({collection:e,satellite:{...n,identity:At(n?.identity)}});var uf=async e=>{dt.getInstance().set(e),await hr()},hf=e=>Ct.getInstance().subscribe(e);export{hf as authSubscribe,No as delDoc,af as deleteAsset,sf as deleteAssets,cn as getDoc,uf as initJuno,ff as listAssets,Ro as listDocs,ln as setDoc,fi as signIn,ai as signOut,nf as uploadBlob,of as uploadFile};
3
3
  //# sourceMappingURL=index.js.map