@junobuild/core 0.0.7 → 0.0.8

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 DELETED
@@ -1,3 +0,0 @@
1
- import{a as Rr,b as Pn,c as Br,d as Rn,e as Ne,f as Bn,g as Pe,h as Re,i as Kn,j as rr,k as Vt,l as nr,m as Cn,p as Kr,q as Cr}from"./chunk-QVUY65GN.js";var Mr={};Rn(Mr,{default:()=>Mn});var Mn,Yr=Pn(()=>{Mn={}});var jr=Br((xi,Be)=>{var Ft=(Yr(),Bn(Mr));if(Ft&&Ft.default){Be.exports=Ft.default;for(let e in Ft)Be.exports[e]=Ft[e]}else Ft&&(Be.exports=Ft)});var ir=Br((ui,Ke)=>{(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 b=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]),N=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 Mt(r,o,i,t){return st(r,o,i,t,32)}function ge(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,E=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,Y=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,j=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,U=y,P=_,A=R,d=E,x=D,m=T,p=Y,g=j,w=z,M=H,W=V,$=k,J=F,s,q=0;q<20;q+=2)s=O+M|0,P^=s<<7|s>>>32-7,s=P+O|0,m^=s<<9|s>>>32-9,s=m+P|0,M^=s<<13|s>>>32-13,s=M+m|0,O^=s<<18|s>>>32-18,s=A+K|0,p^=s<<7|s>>>32-7,s=p+A|0,W^=s<<9|s>>>32-9,s=W+p|0,K^=s<<13|s>>>32-13,s=K+W|0,A^=s<<18|s>>>32-18,s=g+d|0,$^=s<<7|s>>>32-7,s=$+g|0,S^=s<<9|s>>>32-9,s=S+$|0,d^=s<<13|s>>>32-13,s=d+S|0,g^=s<<18|s>>>32-18,s=J+w|0,U^=s<<7|s>>>32-7,s=U+J|0,x^=s<<9|s>>>32-9,s=x+U|0,w^=s<<13|s>>>32-13,s=w+x|0,J^=s<<18|s>>>32-18,s=O+U|0,K^=s<<7|s>>>32-7,s=K+O|0,S^=s<<9|s>>>32-9,s=S+K|0,U^=s<<13|s>>>32-13,s=U+S|0,O^=s<<18|s>>>32-18,s=A+P|0,d^=s<<7|s>>>32-7,s=d+A|0,x^=s<<9|s>>>32-9,s=x+d|0,P^=s<<13|s>>>32-13,s=P+x|0,A^=s<<18|s>>>32-18,s=g+p|0,w^=s<<7|s>>>32-7,s=w+g|0,m^=s<<9|s>>>32-9,s=m+w|0,p^=s<<13|s>>>32-13,s=p+m|0,g^=s<<18|s>>>32-18,s=J+$|0,M^=s<<7|s>>>32-7,s=M+J|0,W^=s<<9|s>>>32-9,s=W+M|0,$^=s<<13|s>>>32-13,s=$+W|0,J^=s<<18|s>>>32-18;O=O+f|0,K=K+c|0,S=S+l|0,U=U+y|0,P=P+_|0,A=A+R|0,d=d+E|0,x=x+D|0,m=m+T|0,p=p+Y|0,g=g+j|0,w=w+z|0,M=M+H|0,W=W+V|0,$=$+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]=U>>>0&255,r[13]=U>>>8&255,r[14]=U>>>16&255,r[15]=U>>>24&255,r[16]=P>>>0&255,r[17]=P>>>8&255,r[18]=P>>>16&255,r[19]=P>>>24&255,r[20]=A>>>0&255,r[21]=A>>>8&255,r[22]=A>>>16&255,r[23]=A>>>24&255,r[24]=d>>>0&255,r[25]=d>>>8&255,r[26]=d>>>16&255,r[27]=d>>>24&255,r[28]=x>>>0&255,r[29]=x>>>8&255,r[30]=x>>>16&255,r[31]=x>>>24&255,r[32]=m>>>0&255,r[33]=m>>>8&255,r[34]=m>>>16&255,r[35]=m>>>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]=$>>>0&255,r[57]=$>>>8&255,r[58]=$>>>16&255,r[59]=$>>>24&255,r[60]=J>>>0&255,r[61]=J>>>8&255,r[62]=J>>>16&255,r[63]=J>>>24&255}function We(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,E=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,Y=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,j=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,U=y,P=_,A=R,d=E,x=D,m=T,p=Y,g=j,w=z,M=H,W=V,$=k,J=F,s,q=0;q<20;q+=2)s=O+M|0,P^=s<<7|s>>>32-7,s=P+O|0,m^=s<<9|s>>>32-9,s=m+P|0,M^=s<<13|s>>>32-13,s=M+m|0,O^=s<<18|s>>>32-18,s=A+K|0,p^=s<<7|s>>>32-7,s=p+A|0,W^=s<<9|s>>>32-9,s=W+p|0,K^=s<<13|s>>>32-13,s=K+W|0,A^=s<<18|s>>>32-18,s=g+d|0,$^=s<<7|s>>>32-7,s=$+g|0,S^=s<<9|s>>>32-9,s=S+$|0,d^=s<<13|s>>>32-13,s=d+S|0,g^=s<<18|s>>>32-18,s=J+w|0,U^=s<<7|s>>>32-7,s=U+J|0,x^=s<<9|s>>>32-9,s=x+U|0,w^=s<<13|s>>>32-13,s=w+x|0,J^=s<<18|s>>>32-18,s=O+U|0,K^=s<<7|s>>>32-7,s=K+O|0,S^=s<<9|s>>>32-9,s=S+K|0,U^=s<<13|s>>>32-13,s=U+S|0,O^=s<<18|s>>>32-18,s=A+P|0,d^=s<<7|s>>>32-7,s=d+A|0,x^=s<<9|s>>>32-9,s=x+d|0,P^=s<<13|s>>>32-13,s=P+x|0,A^=s<<18|s>>>32-18,s=g+p|0,w^=s<<7|s>>>32-7,s=w+g|0,m^=s<<9|s>>>32-9,s=m+w|0,p^=s<<13|s>>>32-13,s=p+m|0,g^=s<<18|s>>>32-18,s=J+$|0,M^=s<<7|s>>>32-7,s=M+J|0,W^=s<<9|s>>>32-9,s=W+M|0,$^=s<<13|s>>>32-13,s=$+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]=A>>>0&255,r[5]=A>>>8&255,r[6]=A>>>16&255,r[7]=A>>>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]=d>>>0&255,r[17]=d>>>8&255,r[18]=d>>>16&255,r[19]=d>>>24&255,r[20]=x>>>0&255,r[21]=x>>>8&255,r[22]=x>>>16&255,r[23]=x>>>24&255,r[24]=m>>>0&255,r[25]=m>>>8&255,r[26]=m>>>16&255,r[27]=m>>>24&255,r[28]=p>>>0&255,r[29]=p>>>8&255,r[30]=p>>>16&255,r[31]=p>>>24&255}function Jt(r,o,i,t){ge(r,o,i,t)}function $t(r,o,i,t){We(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 be(r,o,i,t,f,c,l){var y=new Uint8Array(16),_=new Uint8Array(64),R,E;for(E=0;E<16;E++)y[E]=0;for(E=0;E<8;E++)y[E]=c[E];for(;f>=64;){for(Jt(_,y,l,Ot),E=0;E<64;E++)r[o+E]=i[t+E]^_[E];for(R=1,E=8;E<16;E++)R=R+(y[E]&255)|0,y[E]=R&255,R>>>=8;f-=64,o+=64,t+=64}if(f>0)for(Jt(_,y,l,Ot),E=0;E<f;E++)r[o+E]=i[t+E]^_[E];return 0}function me(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(Jt(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(Jt(l,c,f,Ot),_=0;_<i;_++)r[o+_]=l[_];return 0}function ne(r,o,i,t,f){var c=new Uint8Array(32);$t(c,t,f,Ot);for(var l=new Uint8Array(8),y=0;y<8;y++)l[y]=t[y+16];return me(r,o,i,l,c)}function Kt(r,o,i,t,f,c,l){var y=new Uint8Array(32);$t(y,c,l,Ot);for(var _=new Uint8Array(8),R=0;R<8;R++)_[R]=c[R+16];return be(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,E,D,T,Y,j,z,H,V,k,F,O,K,S,U=this.h[0],P=this.h[1],A=this.h[2],d=this.h[3],x=this.h[4],m=this.h[5],p=this.h[6],g=this.h[7],w=this.h[8],M=this.h[9],W=this.r[0],$=this.r[1],J=this.r[2],s=this.r[3],q=this.r[4],I=this.r[5],L=this.r[6],G=this.r[7],X=this.r[8],Q=this.r[9];i>=16;)f=r[o+0]&255|(r[o+1]&255)<<8,U+=f&8191,c=r[o+2]&255|(r[o+3]&255)<<8,P+=(f>>>13|c<<3)&8191,l=r[o+4]&255|(r[o+5]&255)<<8,A+=(c>>>10|l<<6)&8191,y=r[o+6]&255|(r[o+7]&255)<<8,d+=(l>>>7|y<<9)&8191,_=r[o+8]&255|(r[o+9]&255)<<8,x+=(y>>>4|_<<12)&8191,m+=_>>>1&8191,R=r[o+10]&255|(r[o+11]&255)<<8,p+=(_>>>14|R<<2)&8191,E=r[o+12]&255|(r[o+13]&255)<<8,g+=(R>>>11|E<<5)&8191,D=r[o+14]&255|(r[o+15]&255)<<8,w+=(E>>>8|D<<8)&8191,M+=D>>>5|t,T=0,Y=T,Y+=U*W,Y+=P*(5*Q),Y+=A*(5*X),Y+=d*(5*G),Y+=x*(5*L),T=Y>>>13,Y&=8191,Y+=m*(5*I),Y+=p*(5*q),Y+=g*(5*s),Y+=w*(5*J),Y+=M*(5*$),T+=Y>>>13,Y&=8191,j=T,j+=U*$,j+=P*W,j+=A*(5*Q),j+=d*(5*X),j+=x*(5*G),T=j>>>13,j&=8191,j+=m*(5*L),j+=p*(5*I),j+=g*(5*q),j+=w*(5*s),j+=M*(5*J),T+=j>>>13,j&=8191,z=T,z+=U*J,z+=P*$,z+=A*W,z+=d*(5*Q),z+=x*(5*X),T=z>>>13,z&=8191,z+=m*(5*G),z+=p*(5*L),z+=g*(5*I),z+=w*(5*q),z+=M*(5*s),T+=z>>>13,z&=8191,H=T,H+=U*s,H+=P*J,H+=A*$,H+=d*W,H+=x*(5*Q),T=H>>>13,H&=8191,H+=m*(5*X),H+=p*(5*G),H+=g*(5*L),H+=w*(5*I),H+=M*(5*q),T+=H>>>13,H&=8191,V=T,V+=U*q,V+=P*s,V+=A*J,V+=d*$,V+=x*W,T=V>>>13,V&=8191,V+=m*(5*Q),V+=p*(5*X),V+=g*(5*G),V+=w*(5*L),V+=M*(5*I),T+=V>>>13,V&=8191,k=T,k+=U*I,k+=P*q,k+=A*s,k+=d*J,k+=x*$,T=k>>>13,k&=8191,k+=m*W,k+=p*(5*Q),k+=g*(5*X),k+=w*(5*G),k+=M*(5*L),T+=k>>>13,k&=8191,F=T,F+=U*L,F+=P*I,F+=A*q,F+=d*s,F+=x*J,T=F>>>13,F&=8191,F+=m*$,F+=p*W,F+=g*(5*Q),F+=w*(5*X),F+=M*(5*G),T+=F>>>13,F&=8191,O=T,O+=U*G,O+=P*L,O+=A*I,O+=d*q,O+=x*s,T=O>>>13,O&=8191,O+=m*J,O+=p*$,O+=g*W,O+=w*(5*Q),O+=M*(5*X),T+=O>>>13,O&=8191,K=T,K+=U*X,K+=P*G,K+=A*L,K+=d*I,K+=x*q,T=K>>>13,K&=8191,K+=m*s,K+=p*J,K+=g*$,K+=w*W,K+=M*(5*Q),T+=K>>>13,K&=8191,S=T,S+=U*Q,S+=P*X,S+=A*G,S+=d*L,S+=x*I,T=S>>>13,S&=8191,S+=m*q,S+=p*s,S+=g*J,S+=w*$,S+=M*W,T+=S>>>13,S&=8191,T=(T<<2)+T|0,T=T+Y|0,Y=T&8191,T=T>>>13,j+=T,U=Y,P=j,A=z,d=H,x=V,m=k,p=F,g=O,w=K,M=S,o+=16,i-=16;this.h[0]=U,this.h[1]=P,this.h[2]=A,this.h[3]=d,this.h[4]=x,this.h[5]=m,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 we(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(Kt(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 fe(r,o,i,t,f){var c,l=new Uint8Array(32);if(i<32||(ne(l,0,32,t,f),we(o,16,o,32,i-32,l)!==0))return-1;for(Kt(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 Je(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 Zt(r,o){var i,t,f,c=n(),l=n();for(i=0;i<16;i++)l[i]=o[i];for(Je(l),Je(l),Je(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 br(r,o){var i=new Uint8Array(32),t=new Uint8Array(32);return Zt(i,r),Zt(t,o),Mt(i,0,t,0)}function mr(r){var o=new Uint8Array(32);return Zt(o,r),o[0]&1}function $e(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,E=0,D=0,T=0,Y=0,j=0,z=0,H=0,V=0,k=0,F=0,O=0,K=0,S=0,U=0,P=0,A=0,d=0,x=0,m=0,p=0,g=0,w=0,M=0,W=0,$=0,J=0,s=i[0],q=i[1],I=i[2],L=i[3],G=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],dt=i[15];t=o[0],c+=t*s,l+=t*q,y+=t*I,_+=t*L,R+=t*G,E+=t*X,D+=t*Q,T+=t*ft,Y+=t*et,j+=t*nt,z+=t*it,H+=t*ot,V+=t*at,k+=t*ct,F+=t*lt,O+=t*dt,t=o[1],l+=t*s,y+=t*q,_+=t*I,R+=t*L,E+=t*G,D+=t*X,T+=t*Q,Y+=t*ft,j+=t*et,z+=t*nt,H+=t*it,V+=t*ot,k+=t*at,F+=t*ct,O+=t*lt,K+=t*dt,t=o[2],y+=t*s,_+=t*q,R+=t*I,E+=t*L,D+=t*G,T+=t*X,Y+=t*Q,j+=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*dt,t=o[3],_+=t*s,R+=t*q,E+=t*I,D+=t*L,T+=t*G,Y+=t*X,j+=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,U+=t*dt,t=o[4],R+=t*s,E+=t*q,D+=t*I,T+=t*L,Y+=t*G,j+=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,U+=t*lt,P+=t*dt,t=o[5],E+=t*s,D+=t*q,T+=t*I,Y+=t*L,j+=t*G,z+=t*X,H+=t*Q,V+=t*ft,k+=t*et,F+=t*nt,O+=t*it,K+=t*ot,S+=t*at,U+=t*ct,P+=t*lt,A+=t*dt,t=o[6],D+=t*s,T+=t*q,Y+=t*I,j+=t*L,z+=t*G,H+=t*X,V+=t*Q,k+=t*ft,F+=t*et,O+=t*nt,K+=t*it,S+=t*ot,U+=t*at,P+=t*ct,A+=t*lt,d+=t*dt,t=o[7],T+=t*s,Y+=t*q,j+=t*I,z+=t*L,H+=t*G,V+=t*X,k+=t*Q,F+=t*ft,O+=t*et,K+=t*nt,S+=t*it,U+=t*ot,P+=t*at,A+=t*ct,d+=t*lt,x+=t*dt,t=o[8],Y+=t*s,j+=t*q,z+=t*I,H+=t*L,V+=t*G,k+=t*X,F+=t*Q,O+=t*ft,K+=t*et,S+=t*nt,U+=t*it,P+=t*ot,A+=t*at,d+=t*ct,x+=t*lt,m+=t*dt,t=o[9],j+=t*s,z+=t*q,H+=t*I,V+=t*L,k+=t*G,F+=t*X,O+=t*Q,K+=t*ft,S+=t*et,U+=t*nt,P+=t*it,A+=t*ot,d+=t*at,x+=t*ct,m+=t*lt,p+=t*dt,t=o[10],z+=t*s,H+=t*q,V+=t*I,k+=t*L,F+=t*G,O+=t*X,K+=t*Q,S+=t*ft,U+=t*et,P+=t*nt,A+=t*it,d+=t*ot,x+=t*at,m+=t*ct,p+=t*lt,g+=t*dt,t=o[11],H+=t*s,V+=t*q,k+=t*I,F+=t*L,O+=t*G,K+=t*X,S+=t*Q,U+=t*ft,P+=t*et,A+=t*nt,d+=t*it,x+=t*ot,m+=t*at,p+=t*ct,g+=t*lt,w+=t*dt,t=o[12],V+=t*s,k+=t*q,F+=t*I,O+=t*L,K+=t*G,S+=t*X,U+=t*Q,P+=t*ft,A+=t*et,d+=t*nt,x+=t*it,m+=t*ot,p+=t*at,g+=t*ct,w+=t*lt,M+=t*dt,t=o[13],k+=t*s,F+=t*q,O+=t*I,K+=t*L,S+=t*G,U+=t*X,P+=t*Q,A+=t*ft,d+=t*et,x+=t*nt,m+=t*it,p+=t*ot,g+=t*at,w+=t*ct,M+=t*lt,W+=t*dt,t=o[14],F+=t*s,O+=t*q,K+=t*I,S+=t*L,U+=t*G,P+=t*X,A+=t*Q,d+=t*ft,x+=t*et,m+=t*nt,p+=t*it,g+=t*ot,w+=t*at,M+=t*ct,W+=t*lt,$+=t*dt,t=o[15],O+=t*s,K+=t*q,S+=t*I,U+=t*L,P+=t*G,A+=t*X,d+=t*Q,x+=t*ft,m+=t*et,p+=t*nt,g+=t*it,w+=t*ot,M+=t*at,W+=t*ct,$+=t*lt,J+=t*dt,c+=38*K,l+=38*S,y+=38*U,_+=38*P,R+=38*A,E+=38*d,D+=38*x,T+=38*m,Y+=38*p,j+=38*g,z+=38*w,H+=38*M,V+=38*W,k+=38*$,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=E+f+65535,f=Math.floor(t/65536),E=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=Y+f+65535,f=Math.floor(t/65536),Y=t-f*65536,t=j+f+65535,f=Math.floor(t/65536),j=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=E+f+65535,f=Math.floor(t/65536),E=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=Y+f+65535,f=Math.floor(t/65536),Y=t-f*65536,t=j+f+65535,f=Math.floor(t/65536),j=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]=E,r[6]=D,r[7]=T,r[8]=Y,r[9]=j,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 wr(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 _r(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 _e(r,o,i){var t=new Uint8Array(32),f=new Float64Array(80),c,l,y=n(),_=n(),R=n(),E=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,$e(f,i),l=0;l<16;l++)_[l]=f[l],E[l]=y[l]=R[l]=0;for(y[0]=E[0]=1,l=254;l>=0;--l)c=t[l>>>3]>>>(l&7)&1,qt(y,_,c),qt(R,E,c),bt(D,y,R),mt(y,y,R),bt(R,_,E),mt(_,_,E),yt(E,D),yt(T,y),Z(y,R,y),Z(R,_,D),bt(D,y,R),mt(y,y,R),yt(_,y),mt(R,E,T),Z(y,R,B),bt(y,y,E),Z(R,R,y),Z(y,E,T),Z(E,_,f),yt(_,D),qt(y,_,c),qt(R,E,c);for(l=0;l<16;l++)f[l+16]=y[l],f[l+32]=R[l],f[l+48]=_[l],f[l+64]=E[l];var Y=f.subarray(32),j=f.subarray(16);return wr(Y,Y),Z(j,j,Y),Zt(r,j),0}function ve(r,o){return _e(r,o,h)}function vr(r,o){return a(o,32),ve(r,o)}function Ae(r,o,i){var t=new Uint8Array(32);return _e(t,i,o),$t(r,u,t,Ot)}var Ar=oe,An=fe;function En(r,o,i,t,f,c){var l=new Uint8Array(32);return Ae(l,f,c),Ar(r,o,i,t,l)}function Sn(r,o,i,t,f,c){var l=new Uint8Array(32);return Ae(l,f,c),An(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 Sr(r,o,i,t){for(var f=new Int32Array(16),c=new Int32Array(16),l,y,_,R,E,D,T,Y,j,z,H,V,k,F,O,K,S,U,P,A,d,x,m,p,g,w,M=r[0],W=r[1],$=r[2],J=r[3],s=r[4],q=r[5],I=r[6],L=r[7],G=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(P=0;P<16;P++)A=8*P+at,f[P]=i[A+0]<<24|i[A+1]<<16|i[A+2]<<8|i[A+3],c[P]=i[A+4]<<24|i[A+5]<<16|i[A+6]<<8|i[A+7];for(P=0;P<80;P++)if(l=M,y=W,_=$,R=J,E=s,D=q,T=I,Y=L,j=G,z=X,H=Q,V=ft,k=et,F=nt,O=it,K=ot,d=L,x=ot,m=x&65535,p=x>>>16,g=d&65535,w=d>>>16,d=(s>>>14|et<<32-14)^(s>>>18|et<<32-18)^(et>>>41-32|s<<32-(41-32)),x=(et>>>14|s<<32-14)^(et>>>18|s<<32-18)^(s>>>41-32|et<<32-(41-32)),m+=x&65535,p+=x>>>16,g+=d&65535,w+=d>>>16,d=s&q^~s&I,x=et&nt^~et&it,m+=x&65535,p+=x>>>16,g+=d&65535,w+=d>>>16,d=Er[P*2],x=Er[P*2+1],m+=x&65535,p+=x>>>16,g+=d&65535,w+=d>>>16,d=f[P%16],x=c[P%16],m+=x&65535,p+=x>>>16,g+=d&65535,w+=d>>>16,p+=m>>>16,g+=p>>>16,w+=g>>>16,S=g&65535|w<<16,U=m&65535|p<<16,d=S,x=U,m=x&65535,p=x>>>16,g=d&65535,w=d>>>16,d=(M>>>28|G<<32-28)^(G>>>34-32|M<<32-(34-32))^(G>>>39-32|M<<32-(39-32)),x=(G>>>28|M<<32-28)^(M>>>34-32|G<<32-(34-32))^(M>>>39-32|G<<32-(39-32)),m+=x&65535,p+=x>>>16,g+=d&65535,w+=d>>>16,d=M&W^M&$^W&$,x=G&X^G&Q^X&Q,m+=x&65535,p+=x>>>16,g+=d&65535,w+=d>>>16,p+=m>>>16,g+=p>>>16,w+=g>>>16,Y=g&65535|w<<16,K=m&65535|p<<16,d=R,x=V,m=x&65535,p=x>>>16,g=d&65535,w=d>>>16,d=S,x=U,m+=x&65535,p+=x>>>16,g+=d&65535,w+=d>>>16,p+=m>>>16,g+=p>>>16,w+=g>>>16,R=g&65535|w<<16,V=m&65535|p<<16,W=l,$=y,J=_,s=R,q=E,I=D,L=T,M=Y,X=j,Q=z,ft=H,et=V,nt=k,it=F,ot=O,G=K,P%16===15)for(A=0;A<16;A++)d=f[A],x=c[A],m=x&65535,p=x>>>16,g=d&65535,w=d>>>16,d=f[(A+9)%16],x=c[(A+9)%16],m+=x&65535,p+=x>>>16,g+=d&65535,w+=d>>>16,S=f[(A+1)%16],U=c[(A+1)%16],d=(S>>>1|U<<32-1)^(S>>>8|U<<32-8)^S>>>7,x=(U>>>1|S<<32-1)^(U>>>8|S<<32-8)^(U>>>7|S<<32-7),m+=x&65535,p+=x>>>16,g+=d&65535,w+=d>>>16,S=f[(A+14)%16],U=c[(A+14)%16],d=(S>>>19|U<<32-19)^(U>>>61-32|S<<32-(61-32))^S>>>6,x=(U>>>19|S<<32-19)^(S>>>61-32|U<<32-(61-32))^(U>>>6|S<<32-6),m+=x&65535,p+=x>>>16,g+=d&65535,w+=d>>>16,p+=m>>>16,g+=p>>>16,w+=g>>>16,f[A]=g&65535|w<<16,c[A]=m&65535|p<<16;d=M,x=G,m=x&65535,p=x>>>16,g=d&65535,w=d>>>16,d=r[0],x=o[0],m+=x&65535,p+=x>>>16,g+=d&65535,w+=d>>>16,p+=m>>>16,g+=p>>>16,w+=g>>>16,r[0]=M=g&65535|w<<16,o[0]=G=m&65535|p<<16,d=W,x=X,m=x&65535,p=x>>>16,g=d&65535,w=d>>>16,d=r[1],x=o[1],m+=x&65535,p+=x>>>16,g+=d&65535,w+=d>>>16,p+=m>>>16,g+=p>>>16,w+=g>>>16,r[1]=W=g&65535|w<<16,o[1]=X=m&65535|p<<16,d=$,x=Q,m=x&65535,p=x>>>16,g=d&65535,w=d>>>16,d=r[2],x=o[2],m+=x&65535,p+=x>>>16,g+=d&65535,w+=d>>>16,p+=m>>>16,g+=p>>>16,w+=g>>>16,r[2]=$=g&65535|w<<16,o[2]=Q=m&65535|p<<16,d=J,x=ft,m=x&65535,p=x>>>16,g=d&65535,w=d>>>16,d=r[3],x=o[3],m+=x&65535,p+=x>>>16,g+=d&65535,w+=d>>>16,p+=m>>>16,g+=p>>>16,w+=g>>>16,r[3]=J=g&65535|w<<16,o[3]=ft=m&65535|p<<16,d=s,x=et,m=x&65535,p=x>>>16,g=d&65535,w=d>>>16,d=r[4],x=o[4],m+=x&65535,p+=x>>>16,g+=d&65535,w+=d>>>16,p+=m>>>16,g+=p>>>16,w+=g>>>16,r[4]=s=g&65535|w<<16,o[4]=et=m&65535|p<<16,d=q,x=nt,m=x&65535,p=x>>>16,g=d&65535,w=d>>>16,d=r[5],x=o[5],m+=x&65535,p+=x>>>16,g+=d&65535,w+=d>>>16,p+=m>>>16,g+=p>>>16,w+=g>>>16,r[5]=q=g&65535|w<<16,o[5]=nt=m&65535|p<<16,d=I,x=it,m=x&65535,p=x>>>16,g=d&65535,w=d>>>16,d=r[6],x=o[6],m+=x&65535,p+=x>>>16,g+=d&65535,w+=d>>>16,p+=m>>>16,g+=p>>>16,w+=g>>>16,r[6]=I=g&65535|w<<16,o[6]=it=m&65535|p<<16,d=L,x=ot,m=x&65535,p=x>>>16,g=d&65535,w=d>>>16,d=r[7],x=o[7],m+=x&65535,p+=x>>>16,g+=d&65535,w+=d>>>16,p+=m>>>16,g+=p>>>16,w+=g>>>16,r[7]=L=g&65535|w<<16,o[7]=ot=m&65535|p<<16,at+=128,t-=128}return t}function Yt(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,Sr(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),Sr(t,f,c,i),l=0;l<8;l++)St(r,8*l,t[l],f[l]);return 0}function Ee(r,o){var i=n(),t=n(),f=n(),c=n(),l=n(),y=n(),_=n(),R=n(),E=n();mt(i,r[1],r[0]),mt(E,o[1],o[0]),Z(i,i,E),bt(t,r[0],r[1]),bt(E,o[0],o[1]),Z(t,t,E),Z(f,r[3],o[3]),Z(f,f,N),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 Tr(r,o,i){var t;for(t=0;t<4;t++)qt(r[t],o[t],i)}function Ge(r,o){var i=n(),t=n(),f=n();wr(f,o[2]),Z(i,o[0],f),Z(t,o[1],f),Zt(r,t),r[31]^=mr(i)<<7}function qe(r,o,i){var t,f;for(Ut(r[0],b),Ut(r[1],v),Ut(r[2],v),Ut(r[3],b),f=255;f>=0;--f)t=i[f/8|0]>>(f&7)&1,Tr(r,o,t),Ee(o,r),Ee(r,r),Tr(r,o,t)}function Se(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),qe(r,i,o)}function Ze(r,o,i){var t=new Uint8Array(64),f=[n(),n(),n(),n()],c;for(i||a(o,32),Yt(t,o,32),t[0]&=248,t[31]&=127,t[31]|=64,Se(f,t),Ge(r,f),c=0;c<32;c++)o[c+32]=r[c];return 0}var Te=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 Xe(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]*Te[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)*Te[f],i=o[f]>>8,o[f]&=255;for(f=0;f<32;f++)o[f]-=i*Te[f];for(t=0;t<32;t++)o[t+1]+=o[t]>>8,r[t]=o[t]&255}function Qe(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;Xe(r,o)}function Or(r,o,i,t){var f=new Uint8Array(64),c=new Uint8Array(64),l=new Uint8Array(64),y,_,R=new Float64Array(64),E=[n(),n(),n(),n()];Yt(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(Yt(l,r.subarray(32),i+32),Qe(l),Se(E,l),Ge(r,E),y=32;y<64;y++)r[y]=t[y];for(Yt(c,r,i+64),Qe(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 Xe(r.subarray(32),R),D}function Tn(r,o){var i=n(),t=n(),f=n(),c=n(),l=n(),y=n(),_=n();return Ut(r[2],v),$e(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),_r(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),br(t,f)&&Z(r[0],r[0],ht),yt(t,r[0]),Z(t,t,c),br(t,f)?-1:(mr(r[0])===o[31]>>7&&mt(r[0],b,r[0]),Z(r[3],r[0],r[1]),0)}function De(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||Tn(_,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(Yt(l,r,i),Qe(l),qe(y,_,l),Se(_,o.subarray(32)),Ee(y,_),Ge(c,y),i-=64,Mt(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 Ie=32,Oe=24,ae=32,Xt=16,se=32,Ue=32,ce=32,le=32,Le=32,Ur=Oe,On=ae,Un=Xt,Nt=64,jt=32,Qt=64,tr=32,er=64;e.lowlevel={crypto_core_hsalsa20:$t,crypto_stream_xor:Kt,crypto_stream:ne,crypto_stream_salsa20_xor:be,crypto_stream_salsa20:me,crypto_onetimeauth:ie,crypto_onetimeauth_verify:we,crypto_verify_16:Tt,crypto_verify_32:Mt,crypto_secretbox:oe,crypto_secretbox_open:fe,crypto_scalarmult:_e,crypto_scalarmult_base:ve,crypto_box_beforenm:Ae,crypto_box_afternm:Ar,crypto_box:En,crypto_box_open:Sn,crypto_box_keypair:vr,crypto_hash:Yt,crypto_sign:Or,crypto_sign_keypair:Ze,crypto_sign_open:De,crypto_secretbox_KEYBYTES:Ie,crypto_secretbox_NONCEBYTES:Oe,crypto_secretbox_ZEROBYTES:ae,crypto_secretbox_BOXZEROBYTES:Xt,crypto_scalarmult_BYTES:se,crypto_scalarmult_SCALARBYTES:Ue,crypto_box_PUBLICKEYBYTES:ce,crypto_box_SECRETKEYBYTES:le,crypto_box_BEFORENMBYTES:Le,crypto_box_NONCEBYTES:Ur,crypto_box_ZEROBYTES:On,crypto_box_BOXZEROBYTES:Un,crypto_sign_BYTES:Nt,crypto_sign_PUBLICKEYBYTES:jt,crypto_sign_SECRETKEYBYTES:Qt,crypto_sign_SEEDBYTES:tr,crypto_hash_BYTES:er,gf:n,D:C,L:Te,pack25519:Zt,unpack25519:$e,M:Z,A:bt,S:yt,Z:mt,pow2523:_r,add:Ee,set25519:Ut,modL:Xe,scalarmult:qe,scalarbase:Se};function Nr(r,o){if(r.length!==Ie)throw new Error("bad key size");if(o.length!==Oe)throw new Error("bad nonce size")}function Nn(r,o){if(r.length!==ce)throw new Error("bad public key size");if(o.length!==le)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 Pr(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),Nr(i,o);for(var t=new Uint8Array(ae+r.length),f=new Uint8Array(t.length),c=0;c<r.length;c++)t[c+ae]=r[c];return oe(f,t,t.length,o,i),f.subarray(Xt)},e.secretbox.open=function(r,o,i){pt(r,o,i),Nr(i,o);for(var t=new Uint8Array(Xt+r.length),f=new Uint8Array(t.length),c=0;c<r.length;c++)t[c+Xt]=r[c];return t.length<32||fe(f,t,t.length,o,i)!==0?null:f.subarray(ae)},e.secretbox.keyLength=Ie,e.secretbox.nonceLength=Oe,e.secretbox.overheadLength=Xt,e.scalarMult=function(r,o){if(pt(r,o),r.length!==Ue)throw new Error("bad n size");if(o.length!==se)throw new Error("bad p size");var i=new Uint8Array(se);return _e(i,r,o),i},e.scalarMult.base=function(r){if(pt(r),r.length!==Ue)throw new Error("bad n size");var o=new Uint8Array(se);return ve(o,r),o},e.scalarMult.scalarLength=Ue,e.scalarMult.groupElementLength=se,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),Nn(r,o);var i=new Uint8Array(Le);return Ae(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(ce),o=new Uint8Array(le);return vr(r,o),{publicKey:r,secretKey:o}},e.box.keyPair.fromSecretKey=function(r){if(pt(r),r.length!==le)throw new Error("bad secret key size");var o=new Uint8Array(ce);return ve(o,r),{publicKey:o,secretKey:new Uint8Array(r)}},e.box.publicKeyLength=ce,e.box.secretKeyLength=le,e.box.sharedKeyLength=Le,e.box.nonceLength=Ur,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(r,o){if(pt(r,o),o.length!==Qt)throw new Error("bad secret key size");var i=new Uint8Array(Nt+r.length);return Or(i,r,r.length,o),i},e.sign.open=function(r,o){if(pt(r,o),o.length!==jt)throw new Error("bad public key size");var i=new Uint8Array(r.length),t=De(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!==jt)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 De(f,t,t.length,i)>=0},e.sign.keyPair=function(){var r=new Uint8Array(jt),o=new Uint8Array(Qt);return Ze(r,o),{publicKey:r,secretKey:o}},e.sign.keyPair.fromSecretKey=function(r){if(pt(r),r.length!==Qt)throw new Error("bad secret key size");for(var o=new Uint8Array(jt),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!==tr)throw new Error("bad seed size");for(var o=new Uint8Array(jt),i=new Uint8Array(Qt),t=0;t<32;t++)i[t]=r[t];return Ze(o,i,!0),{publicKey:o,secretKey:i}},e.sign.publicKeyLength=jt,e.sign.secretKeyLength=Qt,e.sign.seedLength=tr,e.sign.signatureLength=Nt,e.hash=function(r){pt(r);var o=new Uint8Array(er);return Yt(o,r,r.length),o},e.hash.hashLength=er,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];Pr(c)})}else typeof Rr<"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];Pr(c)}))}()})(typeof Ke<"u"&&Ke.exports?Ke.exports:self.nacl=self.nacl||{})});var de=Ne(ir());function Dt(e){var n;return new Uint8Array(((n=e.match(/.{1,2}/g))!==null&&n!==void 0?n:[]).map(a=>parseInt(a,16))).buffer}function Pt(e){return new Uint8Array(e).reduce((n,a)=>n+a.toString(16).padStart(2,"0"),"")}var Yn=(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},Vr=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)")},Fr=(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)")},or=(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)")},jn=(e,n)=>{let a=or(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)")},kr=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),Ce=Uint8Array.from([48,5,6,3,43,101,112]),yi=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function Me(e,n){let a=2+Vr(e.byteLength+1),u=n.byteLength+a+e.byteLength,h=0,b=new Uint8Array(1+Vr(u)+u);return b[h++]=48,h+=Fr(b,h,u),b.set(n,h),h+=n.byteLength,b[h++]=3,h+=Fr(b,h,e.byteLength+1),b[h++]=0,b.set(new Uint8Array(e),h),b}var fr=(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+=or(h,a),!Yn(h.slice(a,a+n.byteLength),n))throw new Error("Not the expected OID.");a+=n.byteLength,u(3,"bit string");let b=jn(h,a)-1;a+=or(h,a),u(0,"0 padding");let v=h.slice(a);if(b!==v.length)throw new Error(`DER payload mismatch: Expected length ${b} 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 Me(n,Ce).buffer}static derDecode(n){let a=fr(n,Ce);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?de.sign.keyPair():de.sign.keyPair.fromSeed(n);return new this(gt.fromRaw(a),u)}static fromParsedJson(n){let[a,u]=n;return new Rt(gt.fromDer(Dt(a)),Dt(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=de.sign.keyPair.fromSecretKey(new Uint8Array(n));return Rt.fromKeyPair(a.publicKey,a.secretKey)}toJSON(){return[Pt(this._publicKey.toDer()),Pt(this._privateKey)]}getKeyPair(){return{secretKey:this._privateKey,publicKey:this._publicKey}}getPublicKey(){return this._publicKey}async sign(n){let a=new Uint8Array(n);return de.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 Hr(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??{},b=Hr(h),v=await b.generateKey({name:"ECDSA",namedCurve:"P-256"},a,u),B=await b.exportKey("spki",v.publicKey);return new this(v,B,b)}static async fromKeyPair(n,a){let u=Hr(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 It=Ne(Cn());var Vn=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},Fn=new TextEncoder().encode("ic-request-auth-delegation"),kn=new TextEncoder().encode(`
2
- ic-request`);function ar(e){if(typeof e!="string"||e.length<64)throw new Error("Invalid public key.");return Dt(e)}var Lt=class{constructor(n,a,u){this.pubkey=n,this.expiration=a,this.targets=u}toCBOR(){return It.value.map(Object.assign({pubkey:It.value.bytes(this.pubkey),expiration:It.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:It.value.array(this.targets.map(n=>It.value.bytes(n.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:Pt(this.pubkey)},this.targets&&{targets:this.targets.map(n=>n.toHex())})}};async function Hn(e,n,a,u){let h=new Lt(n.toDer(),BigInt(+a)*BigInt(1e6),u),b=new Uint8Array([...Fn,...new Uint8Array(rr(h))]),v=await e.sign(b);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 b,v;let B=await Hn(n,a,u,h.targets);return new Ht([...((b=h.previous)===null||b===void 0?void 0:b.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(b=>{let{delegation:v,signature:B}=b,{pubkey:C,expiration:N,targets:tt}=v;if(tt!==void 0&&!Array.isArray(tt))throw new Error("Invalid targets.");return{delegation:new Lt(ar(C),BigInt(`0x${N}`),tt&&tt.map(rt=>{if(typeof rt!="string")throw new Error("Invalid target.");return Re.fromHex(rt)})),signature:ar(B)}});return new this(h,ar(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:Pt(a.pubkey)},h&&{targets:h.map(b=>b.toHex())}),signature:Pt(u)}}),publicKey:Pt(this.publicKey)}}},ue=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=Vn(n,["body"]),h=await rr(a);return Object.assign(Object.assign({},u),{body:{content:a,sender_sig:await this.sign(new Uint8Array([...kn,...new Uint8Array(h)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};function zr(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"?Re.fromText(h):h)):a.push(typeof u=="string"?Re.fromText(u):u));for(let h of a){let b=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()===b){B=!1;break}if(B)return!1}}return!0}var zn=Ne(Kn()),Wn=Ne(ir());var Wr;(function(e){e[e.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(Wr||(Wr={}));var Jr=["mousedown","mousemove","keydown","touchstart","wheel"],he=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 b=this._resetTimer.bind(this);window.addEventListener("load",b,!0),Jr.forEach(function(B){document.addEventListener(B,b,!0)});let v=(B,C)=>{let N;return(...tt)=>{let rt=this,ht=function(){N=void 0,B.apply(rt,tt)};clearTimeout(N),N=window.setTimeout(ht,C)}};if(n?.captureScroll){let B=v(b,(a=n?.scrollDebounce)!==null&&a!==void 0?a:100);window.addEventListener("scroll",B,!0)}b()}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);Jr.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 Jn=(e,n)=>n.some(a=>e instanceof a),$r,Gr;function $n(){return $r||($r=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Gn(){return Gr||(Gr=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var qr=new WeakMap,cr=new WeakMap,Zr=new WeakMap,sr=new WeakMap,dr=new WeakMap;function qn(e){let n=new Promise((a,u)=>{let h=()=>{e.removeEventListener("success",b),e.removeEventListener("error",v)},b=()=>{a(_t(e.result)),h()},v=()=>{u(e.error),h()};e.addEventListener("success",b),e.addEventListener("error",v)});return n.then(a=>{a instanceof IDBCursor&&qr.set(a,e)}).catch(()=>{}),dr.set(n,e),n}function Zn(e){if(cr.has(e))return;let n=new Promise((a,u)=>{let h=()=>{e.removeEventListener("complete",b),e.removeEventListener("error",v),e.removeEventListener("abort",v)},b=()=>{a(),h()},v=()=>{u(e.error||new DOMException("AbortError","AbortError")),h()};e.addEventListener("complete",b),e.addEventListener("error",v),e.addEventListener("abort",v)});cr.set(e,n)}var lr={get(e,n,a){if(e instanceof IDBTransaction){if(n==="done")return cr.get(e);if(n==="objectStoreNames")return e.objectStoreNames||Zr.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 Xr(e){lr=e(lr)}function Xn(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(n,...a){let u=e.call(Ye(this),n,...a);return Zr.set(u,n.sort?n.sort():[n]),_t(u)}:Gn().includes(e)?function(...n){return e.apply(Ye(this),n),_t(qr.get(this))}:function(...n){return _t(e.apply(Ye(this),n))}}function Qn(e){return typeof e=="function"?Xn(e):(e instanceof IDBTransaction&&Zn(e),Jn(e,$n())?new Proxy(e,lr):e)}function _t(e){if(e instanceof IDBRequest)return qn(e);if(sr.has(e))return sr.get(e);let n=Qn(e);return n!==e&&(sr.set(e,n),dr.set(n,e)),n}var Ye=e=>dr.get(e);function Dr(e,n,{blocked:a,upgrade:u,blocking:h,terminated:b}={}){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=>{b&&C.addEventListener("close",()=>b()),h&&C.addEventListener("versionchange",N=>h(N.oldVersion,N.newVersion,N))}).catch(()=>{}),B}var Dn=["get","getKey","getAll","getAllKeys","count"],In=["put","add","delete","clear"],xr=new Map;function Qr(e,n){if(!(e instanceof IDBDatabase&&!(n in e)&&typeof n=="string"))return;if(xr.get(n))return xr.get(n);let a=n.replace(/FromIndex$/,""),u=n!==a,h=In.includes(a);if(!(a in(u?IDBIndex:IDBObjectStore).prototype)||!(h||Dn.includes(a)))return;let b=async function(v,...B){let C=this.transaction(v,h?"readwrite":"readonly"),N=C.store;return u&&(N=N.index(B.shift())),(await Promise.all([N[a](...B),h&&C.done]))[0]};return xr.set(n,b),b}Xr(e=>({...e,get:(n,a,u)=>Qr(n,a)||e.get(n,a,u),has:(n,a)=>!!Qr(n,a)||e.has(n,a)}));var Ir="auth-client-db",Lr="ic-keyval",Ln=async(e=Ir,n=Lr,a)=>(je&&(localStorage!=null&&localStorage.getItem(wt))&&(localStorage.removeItem(wt),localStorage.removeItem(vt)),await Dr(e,a,{upgrade:u=>{u.objectStoreNames,u.objectStoreNames.contains(n)&&u.clear(n),u.createObjectStore(n)}}));async function ti(e,n,a){return await e.get(n,a)}async function ei(e,n,a,u){return await e.put(n,u,a)}async function ri(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=Ir,storeName:u=Lr,version:h=1}=n??{},b=await Ln(a,u,h);return new zt(b,u)}async set(n,a){return await ei(this._db,this._storeName,n,a)}async get(n){var a;return(a=await ti(this._db,this._storeName,n))!==null&&a!==void 0?a:null}async remove(n){return await ri(this._db,this._storeName,n)}};var vt="identity",wt="delegation",tn="iv",ni=1,je=typeof window<"u",pe=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}},ye=class{get _db(){return new Promise(n=>{if(this.initializedDb){n(this.initializedDb);return}zt.create({version:ni}).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 ii="https://identity.ic0.app",oi="#authorize",fi=500,ai="UserInterrupt",Ve=class{constructor(n,a,u,h,b,v,B,C){var N;this._identity=n,this._key=a,this._chain=u,this._storage=h,this.idleManager=b,this._createOptions=v,this._idpWindow=B,this._eventHandler=C;let tt=this.logout.bind(this),rt=v?.idleOptions;!rt?.onIdle&&!rt?.disableDefaultIdleCallback&&((N=this.idleManager)===null||N===void 0||N.registerCallback(()=>{tt(),location.reload()}))}static async create(n={}){var a,u;let h=(a=n.storage)!==null&&a!==void 0?a:new ye,b=null;if(n.identity)b=n.identity;else{let N=await h.get(vt);if(!N&&je)try{let tt=new pe,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),N=rt,await tt.remove(wt),await tt.remove(vt))}catch(tt){console.error("error while attempting to recover localstorage: "+tt)}if(N)try{typeof N=="object"?b=await kt.fromKeyPair(N):typeof N=="string"&&(b=Rt.fromJSON(N))}catch{}}let v=new nr,B=null;if(b)try{let N=await h.get(wt);if(typeof N=="object"&&N!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");n.identity?v=n.identity:N&&(B=Ht.fromJSON(N),zr(B)?v=ue.fromDelegation(b,B):(await ur(h),b=null))}catch(N){console.error(N),await ur(h),b=null}let C;return!((u=n.idleOptions)===null||u===void 0)&&u.disableIdle?C=void 0:(B||n.identity)&&(C=he.create(n.idleOptions)),b||(b=await kt.generate(),await h.set(vt,b.getKeyPair())),new this(v,b,B,h,C,n)}_handleSuccess(n,a){var u,h,b;let v=n.delegations.map(N=>({delegation:new Lt(N.delegation.pubkey,N.delegation.expiration,N.delegation.targets),signature:N.signature.buffer})),B=Ht.fromDelegations(v,n.userPublicKey.buffer),C=this._key;if(C){if(this._chain=B,this._identity=ue.fromDelegation(C,this._chain),(u=this._idpWindow)===null||u===void 0||u.close(),!this.idleManager){let N=(h=this._createOptions)===null||h===void 0?void 0:h.idleOptions;this.idleManager=he.create(N),!N?.onIdle&&!N?.disableDefaultIdleCallback&&((b=this.idleManager)===null||b===void 0||b.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,b;let v=BigInt(8)*BigInt(36e11),B=new URL(((a=n?.identityProvider)===null||a===void 0?void 0:a.toString())||ii);B.hash=oi,(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=(b=window.open(B.toString(),"idpWindow",n?.windowOpenerFeatures))!==null&&b!==void 0?b:void 0;let C=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(ai,n?.onError):setTimeout(C,fi))};C()}_getEventHandler(n,a){return async u=>{var h,b,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:(b=a?.derivationOrigin)===null||b===void 0?void 0:b.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 ur(this._storage),this._identity=new nr,this._chain=null,n.returnTo)try{window.history.pushState({},"",n.returnTo)}catch{window.location.href=n.returnTo}}};async function ur(e){await e.remove(vt),await e.remove(wt),await e.remove(tn)}var en=BigInt(144e11),rn=576,nn=576;var te=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 ee=class extends te{authUser=null;constructor(){super()}static getInstance(){return ee.instance||(ee.instance=new ee),ee.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=ee;Pe(Ct,"instance");var re=class extends te{env;constructor(){super()}static getInstance(){return re.instance||(re.instance=new re),re.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}},xt=re;Pe(xt,"instance");var Fe=()=>typeof window<"u",hr=()=>{let e=xt.getInstance().get()?.satelliteId??"unknown";return xt.getInstance().localIdentity()?`http://${e}.localhost:8000`:`https://${e}.ic0.app`};var Wt=e=>e==null;var on=({width:e,height:n})=>{if(!Fe()||Wt(window)||Wt(window.top))return;let{top:{innerWidth:a,innerHeight:u}}=window,h=u/2+screenY-n/2,b=a/2+screenX-e/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${e}, height=${n}, top=${h}, left=${b}`};var ut=e=>e?[e]:[],ke=e=>e?.[0],fn=async e=>{let n=new Blob([JSON.stringify(e)],{type:"application/json; charset=utf-8"});return new Uint8Array(await n.arrayBuffer())},pr=async e=>{let n=new Blob([e instanceof Uint8Array?e:new Uint8Array(e)],{type:"application/json; charset=utf-8"});return JSON.parse(await n.text())};var He=({matcher:e,paginate:n,order:a})=>({matcher:ut(e),paginate:ut(Wt(n)?void 0:{start_after:ut(n.startAfter),limit:ut(Wt(n.limit)?void 0:BigInt(n.limit))}),order:ut(Wt(a)?void 0:{desc:a.desc,field:a.field==="created_at"?{CreatedAt:null}:a.field==="updated_at"?{UpdatedAt:null}:{Keys:null}})});var an=({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))))}),b=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}),N=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(N),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.Variant({UpdatedAt:e.Null,Keys:e.Null,CreatedAt:e.Null}),Tt=e.Record({field:st,desc:e.Bool}),Mt=e.Record({start_after:e.Opt(e.Text),limit:e.Opt(e.Nat64)}),ge=e.Record({order:e.Opt(Tt),matcher:e.Opt(e.Text),paginate:e.Opt(Mt)}),We=e.Record({token:e.Opt(e.Text),collection:e.Text,owner:e.Principal,name:e.Text,full_path:e.Text}),Jt=e.Record({modified:e.Nat64,sha256:e.Vec(e.Nat8),total_length:e.Nat}),$t=e.Record({key:We,updated_at:e.Nat64,encodings:e.Vec(e.Tuple(e.Text,Jt)),headers:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64}),Ot=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,$t))}),be=e.Record({updated_at:e.Nat64,created_at:e.Nat64,bn_id:e.Opt(e.Text)}),me=e.Record({matches_length:e.Nat64,length:e.Nat64,items:e.Vec(e.Tuple(e.Text,v))}),ne=e.Variant({Db:e.Null,Storage:e.Null}),Kt=e.Variant({Controllers:e.Null,Private:e.Null,Public:e.Null,Managed:e.Null}),Gt=e.Record({updated_at:e.Nat64,max_size:e.Opt(e.Nat),read:Kt,created_at:e.Nat64,write:Kt}),ie=e.Record({updated_at:e.Opt(e.Nat64),data:e.Vec(e.Nat8)}),we=e.Record({updated_at:e.Opt(e.Nat64),max_size:e.Opt(e.Nat),read:Kt,write:Kt}),oe=e.Record({content:e.Vec(e.Nat8),batch_id:e.Nat}),fe=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([],[b],[]),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),ge],[Ot],["query"]),list_controllers:e.Func([],[e.Vec(e.Principal)],["query"]),list_custom_domains:e.Func([],[e.Vec(e.Tuple(e.Text,be))],["query"]),list_docs:e.Func([e.Text,ge],[me],["query"]),list_rules:e.Func([ne],[e.Vec(e.Tuple(e.Text,Gt))],["query"]),remove_controllers:e.Func([n],[e.Vec(e.Principal)],[]),set_config:e.Func([b],[],[]),set_custom_domain:e.Func([e.Text,e.Opt(e.Text)],[],[]),set_doc:e.Func([e.Text,e.Text,ie],[v],[]),set_rule:e.Func([ne,e.Text,we],[],[]),upload_asset_chunk:e.Func([oe],[fe],[]),version:e.Func([],[e.Text],["query"])})};var sn=async({satelliteId:e,idlFactory:n,identity:a,fetch:u,env:h="prod"})=>{let b=h==="dev"||xt.getInstance().localIdentity(),v=b?"http://127.0.0.1:8000/":"https://ic0.app",B=new Kr({identity:a,...v&&{host:v},...u&&{fetch:u}});return b&&await B.fetchRootKey(),Cr.createActor(n,{agent:B,canisterId:e})};var At=async({satelliteId:e,...n})=>{let{satelliteId:a}=e!==void 0?{satelliteId:e}:xt.getInstance().get()??{satelliteId:void 0};if(!a)throw new Error("No satellite principal defined.");return sn({satelliteId:a,idlFactory:an,...n})};var cn=async({collection:e,key:n,satellite:a})=>{let u=await At(a),h=ke(await u.get_doc(e,n));if(!h)return;let b=await pr(h.data);return{key:n,data:b,created_at:h.created_at,updated_at:h.updated_at}},ln=async({collection:e,doc:n,satellite:a})=>{let u=await At(a),{key:h,data:b,updated_at:v}=n,B=await u.set_doc(e,h,{data:await fn(b),updated_at:ut(v)});return{key:h,data:b,created_at:B.created_at,updated_at:B.updated_at}},dn=async({collection:e,doc:n,satellite:a})=>{let u=await At(a),{key:h,updated_at:b}=n;return u.del_doc(e,h,{updated_at:ut(b)})},xn=async({collection:e,filter:n,satellite:a})=>{let u=await At(a),{items:h,matches_length:b,length:v}=await u.list_docs(e,He(n)),B=[];for(let[C,N]of h)B.push({key:C,data:await pr(N.data),created_at:N.created_at,updated_at:N.updated_at});return{items:B,length:v,matches_length:b}};var Et=e=>{if(e!==void 0)return e;let n=ze();if(!n)throw new Error("No internet identity.");return n};var un=async({satellite:e,...n})=>{let a=Et(e?.identity);return cn({...n,satellite:{...e,identity:a}})},hn=async({satellite:e,...n})=>{let a=Et(e?.identity);return ln({...n,satellite:{...e,identity:a}})},Vo=async({satellite:e,...n})=>{let a=Et(e?.identity);return dn({...n,satellite:{...e,identity:a}})},Fo=async({satellite:e,...n})=>{let a=Et(e?.identity);return xn({...n,satellite:{...e,identity:a}})};var pn=async()=>{let e=ze();if(!e)throw new Error("No internet identity.");let n=e.getPrincipal().toText(),a=await un({collection:"#user",key:n});return a||await si({userId:n,principal:e.getPrincipal()})},si=async({userId:e,principal:n})=>{let a=new Date;return hn({collection:"#user",doc:{key:e,data:{principal:n,created_at:a,updated_at:a}}})};var Bt,yn=()=>Ve.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}}),yr=async()=>{if(Bt=Bt??await yn(),!(await Bt?.isAuthenticated()||!1))return;let n=await pn();Ct.getInstance().set(n)},ci=async e=>new Promise(async(n,a)=>{Bt=Bt??await yn(),await Bt.login({onSuccess:async()=>{await yr(),n()},onError:u=>a(u),maxTimeToLive:e?.maxTimeToLive??en,...xt.getInstance().localIdentity()&&{identityProvider:`http://${xt.getInstance().get()?.localIdentityCanisterId}.localhost:8000?#authorize`},...e?.derivationOrigin!==void 0&&{derivationOrigin:e.derivationOrigin},...e?.windowed!==!1&&{windowOpenerFeatures:on({width:rn,height:nn})}})}),li=async()=>{await Bt?.logout(),Bt=void 0,Ct.getInstance().reset()},ze=()=>Bt?.getIdentity();var gn=async({data:e,filename:n,collection:a,headers:u,token:h,fullPath:b,encoding:v,satellite:B})=>{let C=await At(B),{batch_id:N}=await C.init_asset_upload({collection:a,full_path:b,name:n,token:ut(h),encoding_type:ut(v)}),tt=7e5,rt=[],ht=Fe()?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 di({batchId:N,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:N,chunk_ids:rt.map(({chunk_id:st})=>st),headers:[...u,...St||[]]})},di=async({batchId:e,chunk:n,actor:a})=>a.upload_asset_chunk({batch_id:e,content:new Uint8Array(await n.arrayBuffer())}),bn=async({collection:e,satellite:n,filter:a})=>{let u=await At(n),{items:h,matches_length:b,length:v}=await u.list_assets(ut(e),He(a));return{items:h.map(([B,C])=>C),length:v,matches_length:b}},mn=async({collection:e,storageFile:n,satellite:a})=>{let u=await At(a),{fullPath:h}=n;return u.del_asset(e,h)},wn=async({collection:e,satellite:n})=>(await At(n)).del_assets(ut(e));var _n=e=>btoa([...e].map(n=>String.fromCharCode(n)).join(""));var gr=e=>encodeURI(e.toLowerCase().replace(/\s/g,"-"));var df=async e=>vn(e),xf=async e=>vn({filename:e.data.name,...e}),vn=async({filename:e,data:n,collection:a,headers:u=[],fullPath:h,token:b,satellite:v,encoding:B})=>{let C=Et(v?.identity),N=gr(e),tt=h||`/${a}/${N}`;return await gn({data:n,filename:gr(N),collection:a,token:b,headers:u,fullPath:tt,encoding:B,satellite:{...v,identity:C}}),{downloadUrl:`${hr()}${tt}${b!==void 0?`?token=${b}`:""}`,fullPath:tt,name:N}},uf=async({collection:e,satellite:n,filter:a})=>{let{items:u,...h}=await bn({collection:e,satellite:{...n,identity:Et(n?.identity)},filter:a??{}}),b=hr();return{assets:u.map(({key:{full_path:v,token:B,name:C},headers:N,encodings:tt})=>{let rt=ke(B);return{fullPath:v,name:C,downloadUrl:`${b}${v}${rt!==void 0?`?token=${rt}`:""}`,token:rt,headers:N,encodings:tt.reduce((ht,[St,{modified:st,sha256:Tt,total_length:Mt}])=>({...ht,[St]:{modified:st,sha256:_n(Tt),total_length:Mt}}),{})}}),...h}},hf=async({storageFile:e,collection:n,satellite:a})=>mn({collection:n,storageFile:e,satellite:{...a,identity:Et(a?.identity)}}),pf=async({collection:e,satellite:n})=>wn({collection:e,satellite:{...n,identity:Et(n?.identity)}});var wf=async e=>{xt.getInstance().set(e),await yr()},_f=e=>Ct.getInstance().subscribe(e);export{_f as authSubscribe,Vo as delDoc,hf as deleteAsset,pf as deleteAssets,un as getDoc,wf as initJuno,uf as listAssets,Fo as listDocs,hn as setDoc,ci as signIn,li as signOut,df as uploadBlob,xf as uploadFile};
3
- //# sourceMappingURL=index.js.map