Comparing version 1.12.4 to 1.12.6
@@ -1,1 +0,1 @@ | ||
(()=>{var t={317:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>n});const n={}},742:(t,e)=>{"use strict";e.byteLength=function(t){var e=c(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,s=c(t),i=s[0],o=s[1],u=new a(function(t,e,r){return 3*(e+r)/4-r}(0,i,o)),l=0,h=o>0?i-4:i;for(r=0;r<h;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],u[l++]=e>>16&255,u[l++]=e>>8&255,u[l++]=255&e;2===o&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,u[l++]=255&e);1===o&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,u[l++]=e>>8&255,u[l++]=255&e);return u},e.fromByteArray=function(t){for(var e,n=t.length,a=n%3,s=[],i=16383,o=0,c=n-a;o<c;o+=i)s.push(u(t,o,o+i>c?c:o+i));1===a?(e=t[n-1],s.push(r[e>>2]+r[e<<4&63]+"==")):2===a&&(e=(t[n-2]<<8)+t[n-1],s.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return s.join("")};for(var r=[],n=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,o=s.length;i<o;++i)r[i]=s[i],n[s.charCodeAt(i)]=i;function c(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u(t,e,n){for(var a,s,i=[],o=e;o<n;o+=3)a=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),i.push(r[(s=a)>>18&63]+r[s>>12&63]+r[s>>6&63]+r[63&s]);return i.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},431:function(t,e,r){var n;!function(a){"use strict";var s,i=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,o=Math.ceil,c=Math.floor,u="[BigNumber Error] ",l=u+"Number primitive has more than 15 significant digits: ",h=1e14,f=14,d=9007199254740991,g=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],p=1e7,w=1e9;function y(t){var e=0|t;return t>0||t===e?e:e-1}function m(t){for(var e,r,n=1,a=t.length,s=t[0]+"";n<a;){for(e=t[n++]+"",r=f-e.length;r--;e="0"+e);s+=e}for(a=s.length;48===s.charCodeAt(--a););return s.slice(0,a+1||1)}function b(t,e){var r,n,a=t.c,s=e.c,i=t.s,o=e.s,c=t.e,u=e.e;if(!i||!o)return null;if(r=a&&!a[0],n=s&&!s[0],r||n)return r?n?0:-o:i;if(i!=o)return i;if(r=i<0,n=c==u,!a||!s)return n?0:!a^r?1:-1;if(!n)return c>u^r?1:-1;for(o=(c=a.length)<(u=s.length)?c:u,i=0;i<o;i++)if(a[i]!=s[i])return a[i]>s[i]^r?1:-1;return c==u?0:c>u^r?1:-1}function v(t,e,r,n){if(t<e||t>r||t!==c(t))throw Error(u+(n||"Argument")+("number"==typeof t?t<e||t>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function T(t){var e=t.c.length-1;return y(t.e/f)==e&&t.c[e]%2!=0}function E(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function A(t,e,r){var n,a;if(e<0){for(a=r+".";++e;a+=r);t=a+t}else if(++e>(n=t.length)){for(a=r,e-=n;--e;a+=r);t+=a}else e<n&&(t=t.slice(0,e)+"."+t.slice(e));return t}s=function t(e){var r,n,a,s,_,S,O,B,k,U,N=F.prototype={constructor:F,toString:null,valueOf:null},x=new F(1),R=20,C=4,P=-7,I=21,j=-1e7,D=1e7,L=!1,M=1,$=0,K={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},q="0123456789abcdefghijklmnopqrstuvwxyz",H=!0;function F(t,e){var r,s,o,u,h,g,p,w,y=this;if(!(y instanceof F))return new F(t,e);if(null==e){if(t&&!0===t._isBigNumber)return y.s=t.s,void(!t.c||t.e>D?y.c=y.e=null:t.e<j?y.c=[y.e=0]:(y.e=t.e,y.c=t.c.slice()));if((g="number"==typeof t)&&0*t==0){if(y.s=1/t<0?(t=-t,-1):1,t===~~t){for(u=0,h=t;h>=10;h/=10,u++);return void(u>D?y.c=y.e=null:(y.e=u,y.c=[t]))}w=String(t)}else{if(!i.test(w=String(t)))return a(y,w,g);y.s=45==w.charCodeAt(0)?(w=w.slice(1),-1):1}(u=w.indexOf("."))>-1&&(w=w.replace(".","")),(h=w.search(/e/i))>0?(u<0&&(u=h),u+=+w.slice(h+1),w=w.substring(0,h)):u<0&&(u=w.length)}else{if(v(e,2,q.length,"Base"),10==e&&H)return J(y=new F(t),R+y.e+1,C);if(w=String(t),g="number"==typeof t){if(0*t!=0)return a(y,w,g,e);if(y.s=1/t<0?(w=w.slice(1),-1):1,F.DEBUG&&w.replace(/^0\.0*|\./,"").length>15)throw Error(l+t)}else y.s=45===w.charCodeAt(0)?(w=w.slice(1),-1):1;for(r=q.slice(0,e),u=h=0,p=w.length;h<p;h++)if(r.indexOf(s=w.charAt(h))<0){if("."==s){if(h>u){u=p;continue}}else if(!o&&(w==w.toUpperCase()&&(w=w.toLowerCase())||w==w.toLowerCase()&&(w=w.toUpperCase()))){o=!0,h=-1,u=0;continue}return a(y,String(t),g,e)}g=!1,(u=(w=n(w,e,10,y.s)).indexOf("."))>-1?w=w.replace(".",""):u=w.length}for(h=0;48===w.charCodeAt(h);h++);for(p=w.length;48===w.charCodeAt(--p););if(w=w.slice(h,++p)){if(p-=h,g&&F.DEBUG&&p>15&&(t>d||t!==c(t)))throw Error(l+y.s*t);if((u=u-h-1)>D)y.c=y.e=null;else if(u<j)y.c=[y.e=0];else{if(y.e=u,y.c=[],h=(u+1)%f,u<0&&(h+=f),h<p){for(h&&y.c.push(+w.slice(0,h)),p-=f;h<p;)y.c.push(+w.slice(h,h+=f));h=f-(w=w.slice(h)).length}else h-=p;for(;h--;w+="0");y.c.push(+w)}}else y.c=[y.e=0]}function z(t,e,r,n){var a,s,i,o,c;if(null==r?r=C:v(r,0,8),!t.c)return t.toString();if(a=t.c[0],i=t.e,null==e)c=m(t.c),c=1==n||2==n&&(i<=P||i>=I)?E(c,i):A(c,i,"0");else if(s=(t=J(new F(t),e,r)).e,o=(c=m(t.c)).length,1==n||2==n&&(e<=s||s<=P)){for(;o<e;c+="0",o++);c=E(c,s)}else if(e-=i,c=A(c,s,"0"),s+1>o){if(--e>0)for(c+=".";e--;c+="0");}else if((e+=s-o)>0)for(s+1==o&&(c+=".");e--;c+="0");return t.s<0&&a?"-"+c:c}function G(t,e){for(var r,n=1,a=new F(t[0]);n<t.length;n++){if(!(r=new F(t[n])).s){a=r;break}e.call(a,r)&&(a=r)}return a}function W(t,e,r){for(var n=1,a=e.length;!e[--a];e.pop());for(a=e[0];a>=10;a/=10,n++);return(r=n+r*f-1)>D?t.c=t.e=null:r<j?t.c=[t.e=0]:(t.e=r,t.c=e),t}function J(t,e,r,n){var a,s,i,u,l,d,p,w=t.c,y=g;if(w){t:{for(a=1,u=w[0];u>=10;u/=10,a++);if((s=e-a)<0)s+=f,i=e,p=(l=w[d=0])/y[a-i-1]%10|0;else if((d=o((s+1)/f))>=w.length){if(!n)break t;for(;w.length<=d;w.push(0));l=p=0,a=1,i=(s%=f)-f+1}else{for(l=u=w[d],a=1;u>=10;u/=10,a++);p=(i=(s%=f)-f+a)<0?0:l/y[a-i-1]%10|0}if(n=n||e<0||null!=w[d+1]||(i<0?l:l%y[a-i-1]),n=r<4?(p||n)&&(0==r||r==(t.s<0?3:2)):p>5||5==p&&(4==r||n||6==r&&(s>0?i>0?l/y[a-i]:0:w[d-1])%10&1||r==(t.s<0?8:7)),e<1||!w[0])return w.length=0,n?(e-=t.e+1,w[0]=y[(f-e%f)%f],t.e=-e||0):w[0]=t.e=0,t;if(0==s?(w.length=d,u=1,d--):(w.length=d+1,u=y[f-s],w[d]=i>0?c(l/y[a-i]%y[i])*u:0),n)for(;;){if(0==d){for(s=1,i=w[0];i>=10;i/=10,s++);for(i=w[0]+=u,u=1;i>=10;i/=10,u++);s!=u&&(t.e++,w[0]==h&&(w[0]=1));break}if(w[d]+=u,w[d]!=h)break;w[d--]=0,u=1}for(s=w.length;0===w[--s];w.pop());}t.e>D?t.c=t.e=null:t.e<j&&(t.c=[t.e=0])}return t}function V(t){var e,r=t.e;return null===r?t.toString():(e=m(t.c),e=r<=P||r>=I?E(e,r):A(e,r,"0"),t.s<0?"-"+e:e)}return F.clone=t,F.ROUND_UP=0,F.ROUND_DOWN=1,F.ROUND_CEIL=2,F.ROUND_FLOOR=3,F.ROUND_HALF_UP=4,F.ROUND_HALF_DOWN=5,F.ROUND_HALF_EVEN=6,F.ROUND_HALF_CEIL=7,F.ROUND_HALF_FLOOR=8,F.EUCLID=9,F.config=F.set=function(t){var e,r;if(null!=t){if("object"!=typeof t)throw Error(u+"Object expected: "+t);if(t.hasOwnProperty(e="DECIMAL_PLACES")&&(v(r=t[e],0,w,e),R=r),t.hasOwnProperty(e="ROUNDING_MODE")&&(v(r=t[e],0,8,e),C=r),t.hasOwnProperty(e="EXPONENTIAL_AT")&&((r=t[e])&&r.pop?(v(r[0],-w,0,e),v(r[1],0,w,e),P=r[0],I=r[1]):(v(r,-w,w,e),P=-(I=r<0?-r:r))),t.hasOwnProperty(e="RANGE"))if((r=t[e])&&r.pop)v(r[0],-w,-1,e),v(r[1],1,w,e),j=r[0],D=r[1];else{if(v(r,-w,w,e),!r)throw Error(u+e+" cannot be zero: "+r);j=-(D=r<0?-r:r)}if(t.hasOwnProperty(e="CRYPTO")){if((r=t[e])!==!!r)throw Error(u+e+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw L=!r,Error(u+"crypto unavailable");L=r}else L=r}if(t.hasOwnProperty(e="MODULO_MODE")&&(v(r=t[e],0,9,e),M=r),t.hasOwnProperty(e="POW_PRECISION")&&(v(r=t[e],0,w,e),$=r),t.hasOwnProperty(e="FORMAT")){if("object"!=typeof(r=t[e]))throw Error(u+e+" not an object: "+r);K=r}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(r=t[e])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(u+e+" invalid: "+r);H="0123456789"==r.slice(0,10),q=r}}return{DECIMAL_PLACES:R,ROUNDING_MODE:C,EXPONENTIAL_AT:[P,I],RANGE:[j,D],CRYPTO:L,MODULO_MODE:M,POW_PRECISION:$,FORMAT:K,ALPHABET:q}},F.isBigNumber=function(t){if(!t||!0!==t._isBigNumber)return!1;if(!F.DEBUG)return!0;var e,r,n=t.c,a=t.e,s=t.s;t:if("[object Array]"=={}.toString.call(n)){if((1===s||-1===s)&&a>=-w&&a<=w&&a===c(a)){if(0===n[0]){if(0===a&&1===n.length)return!0;break t}if((e=(a+1)%f)<1&&(e+=f),String(n[0]).length==e){for(e=0;e<n.length;e++)if((r=n[e])<0||r>=h||r!==c(r))break t;if(0!==r)return!0}}}else if(null===n&&null===a&&(null===s||1===s||-1===s))return!0;throw Error(u+"Invalid BigNumber: "+t)},F.maximum=F.max=function(){return G(arguments,N.lt)},F.minimum=F.min=function(){return G(arguments,N.gt)},F.random=(s=9007199254740992,_=Math.random()*s&2097151?function(){return c(Math.random()*s)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(t){var e,r,n,a,s,i=0,l=[],h=new F(x);if(null==t?t=R:v(t,0,w),a=o(t/f),L)if(crypto.getRandomValues){for(e=crypto.getRandomValues(new Uint32Array(a*=2));i<a;)(s=131072*e[i]+(e[i+1]>>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),e[i]=r[0],e[i+1]=r[1]):(l.push(s%1e14),i+=2);i=a/2}else{if(!crypto.randomBytes)throw L=!1,Error(u+"crypto unavailable");for(e=crypto.randomBytes(a*=7);i<a;)(s=281474976710656*(31&e[i])+1099511627776*e[i+1]+4294967296*e[i+2]+16777216*e[i+3]+(e[i+4]<<16)+(e[i+5]<<8)+e[i+6])>=9e15?crypto.randomBytes(7).copy(e,i):(l.push(s%1e14),i+=7);i=a/7}if(!L)for(;i<a;)(s=_())<9e15&&(l[i++]=s%1e14);for(a=l[--i],t%=f,a&&t&&(s=g[f-t],l[i]=c(a/s)*s);0===l[i];l.pop(),i--);if(i<0)l=[n=0];else{for(n=-1;0===l[0];l.splice(0,1),n-=f);for(i=1,s=l[0];s>=10;s/=10,i++);i<f&&(n-=f-i)}return h.e=n,h.c=l,h}),F.sum=function(){for(var t=1,e=arguments,r=new F(e[0]);t<e.length;)r=r.plus(e[t++]);return r},n=function(){var t="0123456789";function e(t,e,r,n){for(var a,s,i=[0],o=0,c=t.length;o<c;){for(s=i.length;s--;i[s]*=e);for(i[0]+=n.indexOf(t.charAt(o++)),a=0;a<i.length;a++)i[a]>r-1&&(null==i[a+1]&&(i[a+1]=0),i[a+1]+=i[a]/r|0,i[a]%=r)}return i.reverse()}return function(n,a,s,i,o){var c,u,l,h,f,d,g,p,w=n.indexOf("."),y=R,b=C;for(w>=0&&(h=$,$=0,n=n.replace(".",""),d=(p=new F(a)).pow(n.length-w),$=h,p.c=e(A(m(d.c),d.e,"0"),10,s,t),p.e=p.c.length),l=h=(g=e(n,a,s,o?(c=q,t):(c=t,q))).length;0==g[--h];g.pop());if(!g[0])return c.charAt(0);if(w<0?--l:(d.c=g,d.e=l,d.s=i,g=(d=r(d,p,y,b,s)).c,f=d.r,l=d.e),w=g[u=l+y+1],h=s/2,f=f||u<0||null!=g[u+1],f=b<4?(null!=w||f)&&(0==b||b==(d.s<0?3:2)):w>h||w==h&&(4==b||f||6==b&&1&g[u-1]||b==(d.s<0?8:7)),u<1||!g[0])n=f?A(c.charAt(1),-y,c.charAt(0)):c.charAt(0);else{if(g.length=u,f)for(--s;++g[--u]>s;)g[u]=0,u||(++l,g=[1].concat(g));for(h=g.length;!g[--h];);for(w=0,n="";w<=h;n+=c.charAt(g[w++]));n=A(n,l,c.charAt(0))}return n}}(),r=function(){function t(t,e,r){var n,a,s,i,o=0,c=t.length,u=e%p,l=e/p|0;for(t=t.slice();c--;)o=((a=u*(s=t[c]%p)+(n=l*s+(i=t[c]/p|0)*u)%p*p+o)/r|0)+(n/p|0)+l*i,t[c]=a%r;return o&&(t=[o].concat(t)),t}function e(t,e,r,n){var a,s;if(r!=n)s=r>n?1:-1;else for(a=s=0;a<r;a++)if(t[a]!=e[a]){s=t[a]>e[a]?1:-1;break}return s}function r(t,e,r,n){for(var a=0;r--;)t[r]-=a,a=t[r]<e[r]?1:0,t[r]=a*n+t[r]-e[r];for(;!t[0]&&t.length>1;t.splice(0,1));}return function(n,a,s,i,o){var u,l,d,g,p,w,m,b,v,T,E,A,_,S,O,B,k,U=n.s==a.s?1:-1,N=n.c,x=a.c;if(!(N&&N[0]&&x&&x[0]))return new F(n.s&&a.s&&(N?!x||N[0]!=x[0]:x)?N&&0==N[0]||!x?0*U:U/0:NaN);for(v=(b=new F(U)).c=[],U=s+(l=n.e-a.e)+1,o||(o=h,l=y(n.e/f)-y(a.e/f),U=U/f|0),d=0;x[d]==(N[d]||0);d++);if(x[d]>(N[d]||0)&&l--,U<0)v.push(1),g=!0;else{for(S=N.length,B=x.length,d=0,U+=2,(p=c(o/(x[0]+1)))>1&&(x=t(x,p,o),N=t(N,p,o),B=x.length,S=N.length),_=B,E=(T=N.slice(0,B)).length;E<B;T[E++]=0);k=x.slice(),k=[0].concat(k),O=x[0],x[1]>=o/2&&O++;do{if(p=0,(u=e(x,T,B,E))<0){if(A=T[0],B!=E&&(A=A*o+(T[1]||0)),(p=c(A/O))>1)for(p>=o&&(p=o-1),m=(w=t(x,p,o)).length,E=T.length;1==e(w,T,m,E);)p--,r(w,B<m?k:x,m,o),m=w.length,u=1;else 0==p&&(u=p=1),m=(w=x.slice()).length;if(m<E&&(w=[0].concat(w)),r(T,w,E,o),E=T.length,-1==u)for(;e(x,T,B,E)<1;)p++,r(T,B<E?k:x,E,o),E=T.length}else 0===u&&(p++,T=[0]);v[d++]=p,T[0]?T[E++]=N[_]||0:(T=[N[_]],E=1)}while((_++<S||null!=T[0])&&U--);g=null!=T[0],v[0]||v.splice(0,1)}if(o==h){for(d=1,U=v[0];U>=10;U/=10,d++);J(b,s+(b.e=d+l*f-1)+1,i,g)}else b.e=l,b.r=+g;return b}}(),S=/^(-?)0([xbo])(?=\w[\w.]*$)/i,O=/^([^.]+)\.$/,B=/^\.([^.]+)$/,k=/^-?(Infinity|NaN)$/,U=/^\s*\+(?=[\w.])|^\s+|\s+$/g,a=function(t,e,r,n){var a,s=r?e:e.replace(U,"");if(k.test(s))t.s=isNaN(s)?null:s<0?-1:1;else{if(!r&&(s=s.replace(S,(function(t,e,r){return a="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=a?t:e})),n&&(a=n,s=s.replace(O,"$1").replace(B,"0.$1")),e!=s))return new F(s,a);if(F.DEBUG)throw Error(u+"Not a"+(n?" base "+n:"")+" number: "+e);t.s=null}t.c=t.e=null},N.absoluteValue=N.abs=function(){var t=new F(this);return t.s<0&&(t.s=1),t},N.comparedTo=function(t,e){return b(this,new F(t,e))},N.decimalPlaces=N.dp=function(t,e){var r,n,a,s=this;if(null!=t)return v(t,0,w),null==e?e=C:v(e,0,8),J(new F(s),t+s.e+1,e);if(!(r=s.c))return null;if(n=((a=r.length-1)-y(this.e/f))*f,a=r[a])for(;a%10==0;a/=10,n--);return n<0&&(n=0),n},N.dividedBy=N.div=function(t,e){return r(this,new F(t,e),R,C)},N.dividedToIntegerBy=N.idiv=function(t,e){return r(this,new F(t,e),0,1)},N.exponentiatedBy=N.pow=function(t,e){var r,n,a,s,i,l,h,d,g=this;if((t=new F(t)).c&&!t.isInteger())throw Error(u+"Exponent not an integer: "+V(t));if(null!=e&&(e=new F(e)),i=t.e>14,!g.c||!g.c[0]||1==g.c[0]&&!g.e&&1==g.c.length||!t.c||!t.c[0])return d=new F(Math.pow(+V(g),i?t.s*(2-T(t)):+V(t))),e?d.mod(e):d;if(l=t.s<0,e){if(e.c?!e.c[0]:!e.s)return new F(NaN);(n=!l&&g.isInteger()&&e.isInteger())&&(g=g.mod(e))}else{if(t.e>9&&(g.e>0||g.e<-1||(0==g.e?g.c[0]>1||i&&g.c[1]>=24e7:g.c[0]<8e13||i&&g.c[0]<=9999975e7)))return s=g.s<0&&T(t)?-0:0,g.e>-1&&(s=1/s),new F(l?1/s:s);$&&(s=o($/f+2))}for(i?(r=new F(.5),l&&(t.s=1),h=T(t)):h=(a=Math.abs(+V(t)))%2,d=new F(x);;){if(h){if(!(d=d.times(g)).c)break;s?d.c.length>s&&(d.c.length=s):n&&(d=d.mod(e))}if(a){if(0===(a=c(a/2)))break;h=a%2}else if(J(t=t.times(r),t.e+1,1),t.e>14)h=T(t);else{if(0===(a=+V(t)))break;h=a%2}g=g.times(g),s?g.c&&g.c.length>s&&(g.c.length=s):n&&(g=g.mod(e))}return n?d:(l&&(d=x.div(d)),e?d.mod(e):s?J(d,$,C,undefined):d)},N.integerValue=function(t){var e=new F(this);return null==t?t=C:v(t,0,8),J(e,e.e+1,t)},N.isEqualTo=N.eq=function(t,e){return 0===b(this,new F(t,e))},N.isFinite=function(){return!!this.c},N.isGreaterThan=N.gt=function(t,e){return b(this,new F(t,e))>0},N.isGreaterThanOrEqualTo=N.gte=function(t,e){return 1===(e=b(this,new F(t,e)))||0===e},N.isInteger=function(){return!!this.c&&y(this.e/f)>this.c.length-2},N.isLessThan=N.lt=function(t,e){return b(this,new F(t,e))<0},N.isLessThanOrEqualTo=N.lte=function(t,e){return-1===(e=b(this,new F(t,e)))||0===e},N.isNaN=function(){return!this.s},N.isNegative=function(){return this.s<0},N.isPositive=function(){return this.s>0},N.isZero=function(){return!!this.c&&0==this.c[0]},N.minus=function(t,e){var r,n,a,s,i=this,o=i.s;if(e=(t=new F(t,e)).s,!o||!e)return new F(NaN);if(o!=e)return t.s=-e,i.plus(t);var c=i.e/f,u=t.e/f,l=i.c,d=t.c;if(!c||!u){if(!l||!d)return l?(t.s=-e,t):new F(d?i:NaN);if(!l[0]||!d[0])return d[0]?(t.s=-e,t):new F(l[0]?i:3==C?-0:0)}if(c=y(c),u=y(u),l=l.slice(),o=c-u){for((s=o<0)?(o=-o,a=l):(u=c,a=d),a.reverse(),e=o;e--;a.push(0));a.reverse()}else for(n=(s=(o=l.length)<(e=d.length))?o:e,o=e=0;e<n;e++)if(l[e]!=d[e]){s=l[e]<d[e];break}if(s&&(a=l,l=d,d=a,t.s=-t.s),(e=(n=d.length)-(r=l.length))>0)for(;e--;l[r++]=0);for(e=h-1;n>o;){if(l[--n]<d[n]){for(r=n;r&&!l[--r];l[r]=e);--l[r],l[n]+=h}l[n]-=d[n]}for(;0==l[0];l.splice(0,1),--u);return l[0]?W(t,l,u):(t.s=3==C?-1:1,t.c=[t.e=0],t)},N.modulo=N.mod=function(t,e){var n,a,s=this;return t=new F(t,e),!s.c||!t.s||t.c&&!t.c[0]?new F(NaN):!t.c||s.c&&!s.c[0]?new F(s):(9==M?(a=t.s,t.s=1,n=r(s,t,0,3),t.s=a,n.s*=a):n=r(s,t,0,M),(t=s.minus(n.times(t))).c[0]||1!=M||(t.s=s.s),t)},N.multipliedBy=N.times=function(t,e){var r,n,a,s,i,o,c,u,l,d,g,w,m,b,v,T=this,E=T.c,A=(t=new F(t,e)).c;if(!(E&&A&&E[0]&&A[0]))return!T.s||!t.s||E&&!E[0]&&!A||A&&!A[0]&&!E?t.c=t.e=t.s=null:(t.s*=T.s,E&&A?(t.c=[0],t.e=0):t.c=t.e=null),t;for(n=y(T.e/f)+y(t.e/f),t.s*=T.s,(c=E.length)<(d=A.length)&&(m=E,E=A,A=m,a=c,c=d,d=a),a=c+d,m=[];a--;m.push(0));for(b=h,v=p,a=d;--a>=0;){for(r=0,g=A[a]%v,w=A[a]/v|0,s=a+(i=c);s>a;)r=((u=g*(u=E[--i]%v)+(o=w*u+(l=E[i]/v|0)*g)%v*v+m[s]+r)/b|0)+(o/v|0)+w*l,m[s--]=u%b;m[s]=r}return r?++n:m.splice(0,1),W(t,m,n)},N.negated=function(){var t=new F(this);return t.s=-t.s||null,t},N.plus=function(t,e){var r,n=this,a=n.s;if(e=(t=new F(t,e)).s,!a||!e)return new F(NaN);if(a!=e)return t.s=-e,n.minus(t);var s=n.e/f,i=t.e/f,o=n.c,c=t.c;if(!s||!i){if(!o||!c)return new F(a/0);if(!o[0]||!c[0])return c[0]?t:new F(o[0]?n:0*a)}if(s=y(s),i=y(i),o=o.slice(),a=s-i){for(a>0?(i=s,r=c):(a=-a,r=o),r.reverse();a--;r.push(0));r.reverse()}for((a=o.length)-(e=c.length)<0&&(r=c,c=o,o=r,e=a),a=0;e;)a=(o[--e]=o[e]+c[e]+a)/h|0,o[e]=h===o[e]?0:o[e]%h;return a&&(o=[a].concat(o),++i),W(t,o,i)},N.precision=N.sd=function(t,e){var r,n,a,s=this;if(null!=t&&t!==!!t)return v(t,1,w),null==e?e=C:v(e,0,8),J(new F(s),t,e);if(!(r=s.c))return null;if(n=(a=r.length-1)*f+1,a=r[a]){for(;a%10==0;a/=10,n--);for(a=r[0];a>=10;a/=10,n++);}return t&&s.e+1>n&&(n=s.e+1),n},N.shiftedBy=function(t){return v(t,-9007199254740991,d),this.times("1e"+t)},N.squareRoot=N.sqrt=function(){var t,e,n,a,s,i=this,o=i.c,c=i.s,u=i.e,l=R+4,h=new F("0.5");if(1!==c||!o||!o[0])return new F(!c||c<0&&(!o||o[0])?NaN:o?i:1/0);if(0==(c=Math.sqrt(+V(i)))||c==1/0?(((e=m(o)).length+u)%2==0&&(e+="0"),c=Math.sqrt(+e),u=y((u+1)/2)-(u<0||u%2),n=new F(e=c==1/0?"5e"+u:(e=c.toExponential()).slice(0,e.indexOf("e")+1)+u)):n=new F(c+""),n.c[0])for((c=(u=n.e)+l)<3&&(c=0);;)if(s=n,n=h.times(s.plus(r(i,s,l,1))),m(s.c).slice(0,c)===(e=m(n.c)).slice(0,c)){if(n.e<u&&--c,"9999"!=(e=e.slice(c-3,c+1))&&(a||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(J(n,n.e+R+2,1),t=!n.times(n).eq(i));break}if(!a&&(J(s,s.e+R+2,0),s.times(s).eq(i))){n=s;break}l+=4,c+=4,a=1}return J(n,n.e+R+1,C,t)},N.toExponential=function(t,e){return null!=t&&(v(t,0,w),t++),z(this,t,e,1)},N.toFixed=function(t,e){return null!=t&&(v(t,0,w),t=t+this.e+1),z(this,t,e)},N.toFormat=function(t,e,r){var n,a=this;if(null==r)null!=t&&e&&"object"==typeof e?(r=e,e=null):t&&"object"==typeof t?(r=t,t=e=null):r=K;else if("object"!=typeof r)throw Error(u+"Argument not an object: "+r);if(n=a.toFixed(t,e),a.c){var s,i=n.split("."),o=+r.groupSize,c=+r.secondaryGroupSize,l=r.groupSeparator||"",h=i[0],f=i[1],d=a.s<0,g=d?h.slice(1):h,p=g.length;if(c&&(s=o,o=c,c=s,p-=s),o>0&&p>0){for(s=p%o||o,h=g.substr(0,s);s<p;s+=o)h+=l+g.substr(s,o);c>0&&(h+=l+g.slice(s)),d&&(h="-"+h)}n=f?h+(r.decimalSeparator||"")+((c=+r.fractionGroupSize)?f.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):f):h}return(r.prefix||"")+n+(r.suffix||"")},N.toFraction=function(t){var e,n,a,s,i,o,c,l,h,d,p,w,y=this,b=y.c;if(null!=t&&(!(c=new F(t)).isInteger()&&(c.c||1!==c.s)||c.lt(x)))throw Error(u+"Argument "+(c.isInteger()?"out of range: ":"not an integer: ")+V(c));if(!b)return new F(y);for(e=new F(x),h=n=new F(x),a=l=new F(x),w=m(b),i=e.e=w.length-y.e-1,e.c[0]=g[(o=i%f)<0?f+o:o],t=!t||c.comparedTo(e)>0?i>0?e:h:c,o=D,D=1/0,c=new F(w),l.c[0]=0;d=r(c,e,0,1),1!=(s=n.plus(d.times(a))).comparedTo(t);)n=a,a=s,h=l.plus(d.times(s=h)),l=s,e=c.minus(d.times(s=e)),c=s;return s=r(t.minus(n),a,0,1),l=l.plus(s.times(h)),n=n.plus(s.times(a)),l.s=h.s=y.s,p=r(h,a,i*=2,C).minus(y).abs().comparedTo(r(l,n,i,C).minus(y).abs())<1?[h,a]:[l,n],D=o,p},N.toNumber=function(){return+V(this)},N.toPrecision=function(t,e){return null!=t&&v(t,1,w),z(this,t,e,2)},N.toString=function(t){var e,r=this,a=r.s,s=r.e;return null===s?a?(e="Infinity",a<0&&(e="-"+e)):e="NaN":(null==t?e=s<=P||s>=I?E(m(r.c),s):A(m(r.c),s,"0"):10===t&&H?e=A(m((r=J(new F(r),R+s+1,C)).c),r.e,"0"):(v(t,2,q.length,"Base"),e=n(A(m(r.c),s,"0"),10,t,a,!0)),a<0&&r.c[0]&&(e="-"+e)),e},N.valueOf=N.toJSON=function(){return V(this)},N._isBigNumber=!0,null!=e&&F.set(e),F}(),s.default=s.BigNumber=s,void 0===(n=function(){return s}.call(e,r,e,t))||(t.exports=n)}()},522:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(431);e.default=class{constructor(){this.BigNum=(t,e)=>new(n.BigNumber.clone({DECIMAL_PLACES:e}))(t)}winstonToAr(t,{formatted:e=!1,decimals:r=12,trim:n=!0}={}){let a=this.stringToBigNum(t,r).shiftedBy(-12);return e?a.toFormat(r):a.toFixed(r)}arToWinston(t,{formatted:e=!1}={}){let r=this.stringToBigNum(t).shiftedBy(12);return e?r.toFormat():r.toFixed(0)}compare(t,e){let r=this.stringToBigNum(t),n=this.stringToBigNum(e);return r.comparedTo(n)}isEqual(t,e){return 0===this.compare(t,e)}isLessThan(t,e){let r=this.stringToBigNum(t),n=this.stringToBigNum(e);return r.isLessThan(n)}isGreaterThan(t,e){let r=this.stringToBigNum(t),n=this.stringToBigNum(e);return r.isGreaterThan(n)}add(t,e){let r=this.stringToBigNum(t);this.stringToBigNum(e);return r.plus(e).toFixed(0)}sub(t,e){let r=this.stringToBigNum(t);this.stringToBigNum(e);return r.minus(e).toFixed(0)}stringToBigNum(t,e=12){return this.BigNum(t,e)}}},60:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(941);r(317);class a{constructor(t,e){this.api=t,this.network=e}async get(t){const e=await this.api.get(`${a.ENDPOINT}${t}`);if(200===e.status)return e.data;throw 404===e.status?new n.default("BLOCK_NOT_FOUND"):new Error(`Error while loading block data: ${e}`)}async getCurrent(){const{current:t}=await this.network.getInfo();return await this.get(t)}}e.default=a,a.ENDPOINT="block/hash/"},997:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(941),a=r(303);e.default=class{constructor(t){this.api=t}async getTransactionOffset(t){const e=await this.api.get(`tx/${t}/offset`);if(200===e.status)return e.data;throw new Error(`Unable to get transaction offset: ${(0,n.getError)(e)}`)}async getChunk(t){const e=await this.api.get(`chunk/${t}`);if(200===e.status)return e.data;throw new Error(`Unable to get chunk: ${(0,n.getError)(e)}`)}async getChunkData(t){const e=await this.getChunk(t);return a.b64UrlToBuffer(e.chunk)}firstChunkOffset(t){return parseInt(t.offset)-parseInt(t.size)+1}async downloadChunkedData(t){const e=await this.getTransactionOffset(t),r=parseInt(e.size),n=parseInt(e.offset)-r+1,a=new Uint8Array(r);let s=0;for(;s<r;){let t;this.api.config.logging&&console.log(`[chunk] ${s}/${r}`);try{t=await this.getChunkData(n+s)}catch(t){console.error(`[chunk] Failed to fetch chunk at offset ${n+s}`),console.error("[chunk] This could indicate that the chunk wasn't uploaded or hasn't yet seeded properly to a particular gateway/node")}if(!t)throw new Error(`Couldn't complete data download at ${s}/${r}`);a.set(t,s),s+=t.length}return a}}},415:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(522),a=r(589),s=r(716),i=r(886),o=r(198),c=r(241),u=r(993),l=r(303),h=r(470),f=r(997),d=r(60);class g{constructor(t){this.api=new a.default(t),this.wallets=new c.default(this.api,g.crypto),this.chunks=new f.default(this.api),this.transactions=new o.default(this.api,g.crypto,this.chunks),this.silo=new h.default(this.api,this.crypto,this.transactions),this.network=new i.default(this.api),this.blocks=new d.default(this.api,this.network),this.ar=new n.default}get crypto(){return g.crypto}get utils(){return g.utils}getConfig(){return{api:this.api.getConfig(),crypto:null}}async createTransaction(t,e){const r={};if(Object.assign(r,t),!(t.data||t.target&&t.quantity))throw new Error("A new Arweave transaction must have a 'data' value, or 'target' and 'quantity' values.");if(null==t.owner&&e&&"use_wallet"!==e&&(r.owner=e.n),null==t.last_tx&&(r.last_tx=await this.transactions.getTransactionAnchor()),"string"==typeof t.data&&(t.data=l.stringToBuffer(t.data)),t.data instanceof ArrayBuffer&&(t.data=new Uint8Array(t.data)),t.data&&!(t.data instanceof Uint8Array))throw new Error("Expected data to be a string, Uint8Array or ArrayBuffer");if(null==t.reward){const e=t.data?t.data.byteLength:0;r.reward=await this.transactions.getPrice(e,r.target)}r.data_root="",r.data_size=t.data?t.data.byteLength.toString():"0",r.data=t.data||new Uint8Array(0);const n=new u.default(r);return await n.getSignatureData(),n}async createSiloTransaction(t,e,r){const n={};if(Object.assign(n,t),!t.data)throw new Error("Silo transactions must have a 'data' value");if(!r)throw new Error("No Silo URI specified.");if(t.target||t.quantity)throw new Error("Silo transactions can only be used for storing data, sending AR to other wallets isn't supported.");if(null==t.owner){if(!e||!e.n)throw new Error("A new Arweave transaction must either have an 'owner' attribute, or you must provide the jwk parameter.");n.owner=e.n}null==t.last_tx&&(n.last_tx=await this.transactions.getTransactionAnchor());const a=await this.silo.parseUri(r);if("string"==typeof t.data){const e=await this.crypto.encrypt(l.stringToBuffer(t.data),a.getEncryptionKey());n.reward=await this.transactions.getPrice(e.byteLength),n.data=l.bufferTob64Url(e)}if(t.data instanceof Uint8Array){const e=await this.crypto.encrypt(t.data,a.getEncryptionKey());n.reward=await this.transactions.getPrice(e.byteLength),n.data=l.bufferTob64Url(e)}const s=new u.default(n);return s.addTag("Silo-Name",a.getAccessKey()),s.addTag("Silo-Version","0.1.0"),s}arql(t){return this.api.post("/arql",t).then((t=>t.data||[]))}}e.default=g,g.crypto=new s.default,g.utils=l},533:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var a=Object.getOwnPropertyDescriptor(e,r);a&&!("get"in a?!e.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,a)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),a=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0});const s=r(415);s.default.init=function(t={}){const e=function(){const t={host:"arweave.net",port:443,protocol:"https"};if("object"!=typeof location||!location.protocol||!location.hostname)return t;const e=location.protocol.replace(":",""),r=location.hostname,n=location.port?parseInt(location.port):"https"==e?443:80;return["localhost","127.0.0.1"].includes(r)||"file"==e?t:{host:r,port:n,protocol:e}}(),r=t.protocol||e.protocol,n=t.host||e.host,a=t.port||e.port;return new s.default(Object.assign(Object.assign({},t),{host:n,protocol:r,port:a}))},"object"==typeof globalThis?globalThis.Arweave=s.default:"object"==typeof self&&(self.Arweave=s.default),a(r(415),e),e.default=s.default},589:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=class{constructor(t){this.METHOD_GET="GET",this.METHOD_POST="POST",this.applyConfig(t)}applyConfig(t){this.config=this.mergeDefaults(t)}getConfig(){return this.config}mergeDefaults(t){const e=t.protocol||"http",r=t.port||("https"===e?443:80);return{host:t.host||"127.0.0.1",protocol:e,port:r,timeout:t.timeout||2e4,logging:t.logging||!1,logger:t.logger||console.log,network:t.network}}async get(t,e){return await this.request(t,Object.assign(Object.assign({},e),{method:this.METHOD_GET}))}async post(t,e,r){var n;const a=new Headers((null==r?void 0:r.headers)||{});return(null===(n=a.get("content-type"))||void 0===n?void 0:n.includes("application/json"))||a.append("content-type","application/json"),a.append("accept","application/json, text/plain, */*"),await this.request(t,Object.assign(Object.assign({},r),{method:this.METHOD_POST,body:"string"!=typeof e?JSON.stringify(e):e,headers:a}))}async request(t,e){const r=new Headers((null==e?void 0:e.headers)||{}),n=`${this.config.protocol}://${this.config.host}:${this.config.port}`;t.startsWith("/")&&(t=t.slice(1)),this.config.network&&r.append("x-network",this.config.network),this.config.logging&&this.config.logger(`Requesting: ${n}/${t}`);let a=await fetch(`${n}/${t}`,Object.assign(Object.assign({},e||{}),{headers:r}));this.config.logging&&this.config.logger(`Response: ${a.url} - ${a.status}`);const s=a.headers.get("content-type"),i=a;if(null==s?void 0:s.startsWith("application/json"))i.data=await a.clone().json();else try{i.data=await a.clone().text()}catch(t){i.data=await a.clone().arrayBuffer()}return i}}},716:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(303);e.default=class{constructor(){if(this.keyLength=4096,this.publicExponent=65537,this.hashAlgorithm="sha256",!this.detectWebCrypto())throw new Error("SubtleCrypto not available!");this.driver=crypto.subtle}async generateJWK(){let t=await this.driver.generateKey({name:"RSA-PSS",modulusLength:4096,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign"]),e=await this.driver.exportKey("jwk",t.privateKey);return{kty:e.kty,e:e.e,n:e.n,d:e.d,p:e.p,q:e.q,dp:e.dp,dq:e.dq,qi:e.qi}}async sign(t,e,{saltLength:r}={}){let n=await this.driver.sign({name:"RSA-PSS",saltLength:32},await this.jwkToCryptoKey(t),e);return new Uint8Array(n)}async hash(t,e="SHA-256"){let r=await this.driver.digest(e,t);return new Uint8Array(r)}async verify(t,e,r){const n={kty:"RSA",e:"AQAB",n:t},a=await this.jwkToPublicCryptoKey(n),s=await this.driver.digest("SHA-256",e),i=await this.driver.verify({name:"RSA-PSS",saltLength:0},a,r,e),o=await this.driver.verify({name:"RSA-PSS",saltLength:32},a,r,e),c=await this.driver.verify({name:"RSA-PSS",saltLength:Math.ceil((a.algorithm.modulusLength-1)/8)-s.byteLength-2},a,r,e);return i||o||c}async jwkToCryptoKey(t){return this.driver.importKey("jwk",t,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["sign"])}async jwkToPublicCryptoKey(t){return this.driver.importKey("jwk",t,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["verify"])}detectWebCrypto(){if("undefined"==typeof crypto)return!1;const t=null===crypto||void 0===crypto?void 0:crypto.subtle;if(void 0===t)return!1;return["generateKey","importKey","exportKey","digest","sign"].every((e=>"function"==typeof t[e]))}async encrypt(t,e,r){const a=await this.driver.importKey("raw","string"==typeof e?n.stringToBuffer(e):e,{name:"PBKDF2",length:32},!1,["deriveKey"]),s=await this.driver.deriveKey({name:"PBKDF2",salt:r?n.stringToBuffer(r):n.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},a,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),i=new Uint8Array(16);crypto.getRandomValues(i);const o=await this.driver.encrypt({name:"AES-CBC",iv:i},s,t);return n.concatBuffers([i,o])}async decrypt(t,e,r){const a=await this.driver.importKey("raw","string"==typeof e?n.stringToBuffer(e):e,{name:"PBKDF2",length:32},!1,["deriveKey"]),s=await this.driver.deriveKey({name:"PBKDF2",salt:r?n.stringToBuffer(r):n.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},a,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),i=t.slice(0,16),o=await this.driver.decrypt({name:"AES-CBC",iv:i},s,t.slice(16));return n.concatBuffers([o])}}},605:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(415);async function a(t){if(Array.isArray(t)){const e=n.default.utils.concatBuffers([n.default.utils.stringToBuffer("list"),n.default.utils.stringToBuffer(t.length.toString())]);return await s(t,await n.default.crypto.hash(e,"SHA-384"))}const e=n.default.utils.concatBuffers([n.default.utils.stringToBuffer("blob"),n.default.utils.stringToBuffer(t.byteLength.toString())]),r=n.default.utils.concatBuffers([await n.default.crypto.hash(e,"SHA-384"),await n.default.crypto.hash(t,"SHA-384")]);return await n.default.crypto.hash(r,"SHA-384")}async function s(t,e){if(t.length<1)return e;const r=n.default.utils.concatBuffers([e,await a(t[0])]),i=await n.default.crypto.hash(r,"SHA-384");return await s(t.slice(1),i)}e.default=a},941:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getError=void 0;class r extends Error{constructor(t,e={}){e.message?super(e.message):super(),this.type=t,this.response=e.response}getType(){return this.type}}e.default=r,e.getError=function(t){let e=t.data;if("string"==typeof t.data)try{e=JSON.parse(t.data)}catch(t){}if(t.data instanceof ArrayBuffer||t.data instanceof Uint8Array)try{e=JSON.parse(e.toString())}catch(t){}return e?e.error||e:t.statusText||"unknown"}},414:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.debug=e.validatePath=e.arrayCompare=e.bufferToInt=e.intToBuffer=e.arrayFlatten=e.generateProofs=e.buildLayers=e.generateTransactionChunks=e.generateTree=e.computeRootHash=e.generateLeaves=e.chunkData=e.MIN_CHUNK_SIZE=e.MAX_CHUNK_SIZE=void 0;const n=r(415),a=r(303);e.MAX_CHUNK_SIZE=262144,e.MIN_CHUNK_SIZE=32768;const s=32;async function i(t){let r=[],a=t,s=0;for(;a.byteLength>=e.MAX_CHUNK_SIZE;){let t=e.MAX_CHUNK_SIZE,i=a.byteLength-e.MAX_CHUNK_SIZE;i>0&&i<e.MIN_CHUNK_SIZE&&(t=Math.ceil(a.byteLength/2));const o=a.slice(0,t),c=await n.default.crypto.hash(o);s+=o.byteLength,r.push({dataHash:c,minByteRange:s-o.byteLength,maxByteRange:s}),a=a.slice(t)}return r.push({dataHash:await n.default.crypto.hash(a),minByteRange:s,maxByteRange:s+a.byteLength}),r}async function o(t){return Promise.all(t.map((async({dataHash:t,minByteRange:e,maxByteRange:r})=>({type:"leaf",id:await g(await Promise.all([g(t),g(p(r))])),dataHash:t,minByteRange:e,maxByteRange:r}))))}async function c(t){return await u(await o(await i(t)))}async function u(t,e=0){if(t.length<2){return t[0]}const r=[];for(let e=0;e<t.length;e+=2)r.push(await d(t[e],t[e+1]));return u(r,e+1)}function l(t){const e=h(t);return Array.isArray(e)?f(e):[e]}function h(t,e=new Uint8Array,r=0){if("leaf"==t.type)return{offset:t.maxByteRange-1,proof:(0,a.concatBuffers)([e,t.dataHash,p(t.maxByteRange)])};if("branch"==t.type){const n=(0,a.concatBuffers)([e,t.leftChild.id,t.rightChild.id,p(t.byteRange)]);return[h(t.leftChild,n,r+1),h(t.rightChild,n,r+1)]}throw new Error("Unexpected node type")}function f(t){const e=[];return t.forEach((t=>{Array.isArray(t)?e.push(...f(t)):e.push(t)})),e}async function d(t,e){if(!e)return t;return{type:"branch",id:await g([await g(t.id),await g(e.id),await g(p(t.maxByteRange))]),byteRange:t.maxByteRange,maxByteRange:e.maxByteRange,leftChild:t,rightChild:e}}async function g(t){return Array.isArray(t)&&(t=n.default.utils.concatBuffers(t)),new Uint8Array(await n.default.crypto.hash(t))}function p(t){const e=new Uint8Array(32);for(var r=e.length-1;r>=0;r--){var n=t%256;e[r]=n,t=(t-n)/256}return e}function w(t){let e=0;for(var r=0;r<t.length;r++)e*=256,e+=t[r];return e}e.chunkData=i,e.generateLeaves=o,e.computeRootHash=async function(t){return(await c(t)).id},e.generateTree=c,e.generateTransactionChunks=async function(t){const e=await i(t),r=await o(e),n=await u(r),a=await l(n),s=e.slice(-1)[0];return s.maxByteRange-s.minByteRange==0&&(e.splice(e.length-1,1),a.splice(a.length-1,1)),{data_root:n.id,chunks:e,proofs:a}},e.buildLayers=u,e.generateProofs=l,e.arrayFlatten=f,e.intToBuffer=p,e.bufferToInt=w;e.arrayCompare=(t,e)=>t.every(((t,r)=>e[r]===t)),e.validatePath=async function t(r,n,a,i,o){if(i<=0)return!1;if(n>=i)return t(r,0,i-1,i,o);if(n<0)return t(r,0,0,i,o);if(64==o.length){const t=o.slice(0,s),n=o.slice(t.length,t.length+32),c=await g([await g(t),await g(n)]);return!!(0,e.arrayCompare)(r,c)&&{offset:i-1,leftBound:a,rightBound:i,chunkSize:i-a}}const c=o.slice(0,s),u=o.slice(c.length,c.length+s),l=o.slice(c.length+u.length,c.length+u.length+32),h=w(l),f=o.slice(c.length+u.length+l.length),d=await g([await g(c),await g(u),await g(l)]);return!!(0,e.arrayCompare)(r,d)&&(n<h?await t(c,n,a,Math.min(i,h),f):await t(u,n,Math.max(a,h),i,f))},e.debug=async function t(e,r=""){if(e.byteLength<1)return r;const n=e.slice(0,s),a=e.slice(n.length,n.length+s),i=e.slice(n.length+a.length,n.length+a.length+32),o=w(i),c=e.slice(n.length+a.length+i.length),u=await g([await g(n),await g(a),await g(i)]);return t(c,`${r}\n${JSON.stringify(Buffer.from(n))},${JSON.stringify(Buffer.from(a))},${o} => ${JSON.stringify(u)}`)}},481:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TransactionUploader=void 0;const n=r(993),a=r(303),s=r(941),i=r(414),o=["invalid_json","chunk_too_big","data_path_too_big","offset_too_big","data_size_too_big","chunk_proof_ratio_not_attractive","invalid_proof"];class c{get isComplete(){return this.txPosted&&this.chunkIndex===this.transaction.chunks.chunks.length}get totalChunks(){return this.transaction.chunks.chunks.length}get uploadedChunks(){return this.chunkIndex}get pctComplete(){return Math.trunc(this.uploadedChunks/this.totalChunks*100)}constructor(t,e){if(this.api=t,this.chunkIndex=0,this.txPosted=!1,this.lastRequestTimeEnd=0,this.totalErrors=0,this.lastResponseStatus=0,this.lastResponseError="",!e.id)throw new Error("Transaction is not signed");if(!e.chunks)throw new Error("Transaction chunks not prepared");this.data=e.data,this.transaction=new n.default(Object.assign({},e,{data:new Uint8Array(0)}))}async uploadChunk(t){if(this.isComplete)throw new Error("Upload is already complete");if(""!==this.lastResponseError?this.totalErrors++:this.totalErrors=0,100===this.totalErrors)throw new Error(`Unable to complete upload: ${this.lastResponseStatus}: ${this.lastResponseError}`);let e=""===this.lastResponseError?0:Math.max(this.lastRequestTimeEnd+4e4-Date.now(),4e4);if(e>0&&(e-=e*Math.random()*.3,await new Promise((t=>setTimeout(t,e)))),this.lastResponseError="",!this.txPosted)return void await this.postTransaction();t&&(this.chunkIndex=t);const r=this.transaction.getChunk(t||this.chunkIndex,this.data);if(!await(0,i.validatePath)(this.transaction.chunks.data_root,parseInt(r.offset),0,parseInt(r.data_size),a.b64UrlToBuffer(r.data_path)))throw new Error(`Unable to validate chunk ${this.chunkIndex}`);const n=await this.api.post("chunk",this.transaction.getChunk(this.chunkIndex,this.data)).catch((t=>(console.error(t.message),{status:-1,data:{error:t.message}})));if(this.lastRequestTimeEnd=Date.now(),this.lastResponseStatus=n.status,200==this.lastResponseStatus)this.chunkIndex++;else if(this.lastResponseError=(0,s.getError)(n),o.includes(this.lastResponseError))throw new Error(`Fatal error uploading chunk ${this.chunkIndex}: ${this.lastResponseError}`)}static async fromSerialized(t,e,r){if(!e||"number"!=typeof e.chunkIndex||"object"!=typeof e.transaction)throw new Error("Serialized object does not match expected format.");var a=new n.default(e.transaction);a.chunks||await a.prepareChunks(r);const s=new c(t,a);if(s.chunkIndex=e.chunkIndex,s.lastRequestTimeEnd=e.lastRequestTimeEnd,s.lastResponseError=e.lastResponseError,s.lastResponseStatus=e.lastResponseStatus,s.txPosted=e.txPosted,s.data=r,s.transaction.data_root!==e.transaction.data_root)throw new Error("Data mismatch: Uploader doesn't match provided data.");return s}static async fromTransactionId(t,e){const r=await t.get(`tx/${e}`);if(200!==r.status)throw new Error(`Tx ${e} not found: ${r.status}`);const n=r.data;n.data=new Uint8Array(0);return{txPosted:!0,chunkIndex:0,lastResponseError:"",lastRequestTimeEnd:0,lastResponseStatus:0,transaction:n}}toJSON(){return{chunkIndex:this.chunkIndex,transaction:this.transaction,lastRequestTimeEnd:this.lastRequestTimeEnd,lastResponseStatus:this.lastResponseStatus,lastResponseError:this.lastResponseError,txPosted:this.txPosted}}async postTransaction(){if(this.totalChunks<=1){this.transaction.data=this.data;const t=await this.api.post("tx",this.transaction).catch((t=>(console.error(t),{status:-1,data:{error:t.message}})));if(this.lastRequestTimeEnd=Date.now(),this.lastResponseStatus=t.status,this.transaction.data=new Uint8Array(0),t.status>=200&&t.status<300)return this.txPosted=!0,void(this.chunkIndex=1);throw this.lastResponseError=(0,s.getError)(t),new Error(`Unable to upload transaction: ${t.status}, ${this.lastResponseError}`)}const t=await this.api.post("tx",this.transaction);if(this.lastRequestTimeEnd=Date.now(),this.lastResponseStatus=t.status,!(t.status>=200&&t.status<300))throw this.lastResponseError=(0,s.getError)(t),new Error(`Unable to upload transaction: ${t.status}, ${this.lastResponseError}`);this.txPosted=!0}}e.TransactionUploader=c},993:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Tag=void 0;const n=r(303),a=r(605),s=r(414);class i{get(t,e){if(!Object.getOwnPropertyNames(this).includes(t))throw new Error(`Field "${t}" is not a property of the Arweave Transaction class.`);return this[t]instanceof Uint8Array?e&&e.decode&&e.string?n.bufferToString(this[t]):e&&e.decode&&!e.string?this[t]:n.bufferTob64Url(this[t]):e&&1==e.decode?e&&e.string?n.b64UrlToString(this[t]):n.b64UrlToBuffer(this[t]):this[t]}}class o extends i{constructor(t,e,r=!1){super(),this.name=t,this.value=e}}e.Tag=o;e.default=class extends i{constructor(t={}){super(),this.format=2,this.id="",this.last_tx="",this.owner="",this.tags=[],this.target="",this.quantity="0",this.data_size="0",this.data=new Uint8Array,this.data_root="",this.reward="0",this.signature="",Object.assign(this,t),"string"==typeof this.data&&(this.data=n.b64UrlToBuffer(this.data)),t.tags&&(this.tags=t.tags.map((t=>new o(t.name,t.value))))}addTag(t,e){this.tags.push(new o(n.stringToB64Url(t),n.stringToB64Url(e)))}toJSON(){return{format:this.format,id:this.id,last_tx:this.last_tx,owner:this.owner,tags:this.tags,target:this.target,quantity:this.quantity,data:n.bufferTob64Url(this.data),data_size:this.data_size,data_root:this.data_root,data_tree:this.data_tree,reward:this.reward,signature:this.signature}}setOwner(t){this.owner=t}setSignature({id:t,owner:e,reward:r,tags:n,signature:a}){this.id=t,this.owner=e,r&&(this.reward=r),n&&(this.tags=n),this.signature=a}async prepareChunks(t){!this.chunks&&t.byteLength>0&&(this.chunks=await(0,s.generateTransactionChunks)(t),this.data_root=n.bufferTob64Url(this.chunks.data_root)),this.chunks||0!==t.byteLength||(this.chunks={chunks:[],data_root:new Uint8Array,proofs:[]},this.data_root="")}getChunk(t,e){if(!this.chunks)throw new Error("Chunks have not been prepared");const r=this.chunks.proofs[t],a=this.chunks.chunks[t];return{data_root:this.data_root,data_size:this.data_size,data_path:n.bufferTob64Url(r.proof),offset:r.offset.toString(),chunk:n.bufferTob64Url(e.slice(a.minByteRange,a.maxByteRange))}}async getSignatureData(){switch(this.format){case 1:let t=this.tags.reduce(((t,e)=>n.concatBuffers([t,e.get("name",{decode:!0,string:!1}),e.get("value",{decode:!0,string:!1})])),new Uint8Array);return n.concatBuffers([this.get("owner",{decode:!0,string:!1}),this.get("target",{decode:!0,string:!1}),this.get("data",{decode:!0,string:!1}),n.stringToBuffer(this.quantity),n.stringToBuffer(this.reward),this.get("last_tx",{decode:!0,string:!1}),t]);case 2:this.data_root||await this.prepareChunks(this.data);const e=this.tags.map((t=>[t.get("name",{decode:!0,string:!1}),t.get("value",{decode:!0,string:!1})]));return await(0,a.default)([n.stringToBuffer(this.format.toString()),this.get("owner",{decode:!0,string:!1}),this.get("target",{decode:!0,string:!1}),n.stringToBuffer(this.quantity),n.stringToBuffer(this.reward),this.get("last_tx",{decode:!0,string:!1}),e,n.stringToBuffer(this.data_size),this.get("data_root",{decode:!0,string:!1})]);default:throw new Error(`Unexpected transaction format: ${this.format}`)}}}},303:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.b64UrlDecode=e.b64UrlEncode=e.bufferTob64Url=e.bufferTob64=e.b64UrlToBuffer=e.stringToB64Url=e.stringToBuffer=e.bufferToString=e.b64UrlToString=e.concatBuffers=void 0;const n=r(742);function a(t){return new TextDecoder("utf-8",{fatal:!0}).decode(t)}function s(t){return(new TextEncoder).encode(t)}function i(t){return new Uint8Array(n.toByteArray(l(t)))}function o(t){return n.fromByteArray(new Uint8Array(t))}function c(t){return u(o(t))}function u(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}function l(t){let e;return e=(t=t.replace(/\-/g,"+").replace(/\_/g,"/")).length%4==0?0:4-t.length%4,t.concat("=".repeat(e))}e.concatBuffers=function(t){let e=0;for(let r=0;r<t.length;r++)e+=t[r].byteLength;let r=new Uint8Array(e),n=0;r.set(new Uint8Array(t[0]),n),n+=t[0].byteLength;for(let e=1;e<t.length;e++)r.set(new Uint8Array(t[e]),n),n+=t[e].byteLength;return r},e.b64UrlToString=function(t){return a(i(t))},e.bufferToString=a,e.stringToBuffer=s,e.stringToB64Url=function(t){return c(s(t))},e.b64UrlToBuffer=i,e.bufferTob64=o,e.bufferTob64Url=c,e.b64UrlEncode=u,e.b64UrlDecode=l},886:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=class{constructor(t){this.api=t}getInfo(){return this.api.get("info").then((t=>t.data))}getPeers(){return this.api.get("peers").then((t=>t.data))}}},470:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SiloResource=void 0;const n=r(303);e.default=class{constructor(t,e,r){this.api=t,this.crypto=e,this.transactions=r}async get(t){if(!t)throw new Error("No Silo URI specified");const e=await this.parseUri(t),r=await this.transactions.search("Silo-Name",e.getAccessKey());if(0==r.length)throw new Error(`No data could be found for the Silo URI: ${t}`);const n=await this.transactions.get(r[0]);if(!n)throw new Error(`No data could be found for the Silo URI: ${t}`);const a=n.get("data",{decode:!0,string:!1});return this.crypto.decrypt(a,e.getEncryptionKey())}async readTransactionData(t,e){if(!e)throw new Error("No Silo URI specified");const r=await this.parseUri(e),n=t.get("data",{decode:!0,string:!1});return this.crypto.decrypt(n,r.getEncryptionKey())}async parseUri(t){const e=t.match(/^([a-z0-9-_]+)\.([0-9]+)/i);if(!e)throw new Error("Invalid Silo name, must be a name in the format of [a-z0-9]+.[0-9]+, e.g. 'bubble.7'");const r=e[1],s=Math.pow(2,parseInt(e[2])),i=await this.hash(n.stringToBuffer(r),s),o=n.bufferTob64(i.slice(0,15)),c=await this.hash(i.slice(16,31),1);return new a(t,o,c)}async hash(t,e){let r=await this.crypto.hash(t);for(let t=0;t<e-1;t++)r=await this.crypto.hash(r);return r}};class a{constructor(t,e,r){this.uri=t,this.accessKey=e,this.encryptionKey=r}getUri(){return this.uri}getAccessKey(){return this.accessKey}getEncryptionKey(){return this.encryptionKey}}e.SiloResource=a},198:function(t,e,r){"use strict";var n=this&&this.__await||function(t){return this instanceof n?(this.v=t,this):new n(t)},a=this&&this.__asyncGenerator||function(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var a,s=r.apply(t,e||[]),i=[];return a={},o("next"),o("throw"),o("return"),a[Symbol.asyncIterator]=function(){return this},a;function o(t){s[t]&&(a[t]=function(e){return new Promise((function(r,n){i.push([t,e,r,n])>1||c(t,e)}))})}function c(t,e){try{(r=s[t](e)).value instanceof n?Promise.resolve(r.value.v).then(u,l):h(i[0][2],r)}catch(t){h(i[0][3],t)}var r}function u(t){c("next",t)}function l(t){c("throw",t)}function h(t,e){t(e),i.shift(),i.length&&c(i[0][0],i[0][1])}};Object.defineProperty(e,"__esModule",{value:!0});const s=r(941),i=r(993),o=r(303),c=r(481);r(317);e.default=class{constructor(t,e,r){this.api=t,this.crypto=e,this.chunks=r}getTransactionAnchor(){return this.api.get("tx_anchor").then((t=>t.data))}getPrice(t,e){let r=e?`price/${t}/${e}`:`price/${t}`;return this.api.get(r).then((t=>t.data))}async get(t){const e=await this.api.get(`tx/${t}`);if(200==e.status){const r=parseInt(e.data.data_size);if(e.data.format>=2&&r>0&&r<=12582912){const r=await this.getData(t);return new i.default(Object.assign(Object.assign({},e.data),{data:r}))}return new i.default(Object.assign(Object.assign({},e.data),{format:e.data.format||1}))}if(404==e.status)throw new s.default("TX_NOT_FOUND");if(410==e.status)throw new s.default("TX_FAILED");throw new s.default("TX_INVALID")}fromRaw(t){return new i.default(t)}async search(t,e){return this.api.post("arql",{op:"equals",expr1:t,expr2:e}).then((t=>t.data?t.data:[]))}getStatus(t){return this.api.get(`tx/${t}/status`).then((t=>200==t.status?{status:200,confirmed:t.data}:{status:t.status,confirmed:null}))}async getData(t,e){let r;try{r=await this.chunks.downloadChunkedData(t)}catch(e){console.error(`Error while trying to download chunked data for ${t}`),console.error(e)}if(!r){console.warn(`Falling back to gateway cache for ${t}`);try{r=(await this.api.get(`/${t}`)).data}catch(e){console.error(`Error while trying to download contiguous data from gateway cache for ${t}`),console.error(e)}}if(!r)throw new Error(`${t} was not found!`);return e&&e.decode&&!e.string?r:e&&e.decode&&e.string?o.bufferToString(r):o.bufferTob64Url(r)}async sign(t,e,r){if(!e&&"object"!=typeof arweaveWallet)throw new Error("A new Arweave transaction must provide the jwk parameter.");if(e&&"use_wallet"!==e){t.setOwner(e.n);let n=await t.getSignatureData(),a=await this.crypto.sign(e,n,r),s=await this.crypto.hash(a);t.setSignature({id:o.bufferTob64Url(s),owner:e.n,signature:o.bufferTob64Url(a)})}else{try{(await arweaveWallet.getPermissions()).includes("SIGN_TRANSACTION")||await arweaveWallet.connect(["SIGN_TRANSACTION"])}catch(t){}const e=await arweaveWallet.sign(t,r);t.setSignature({id:e.id,owner:e.owner,reward:e.reward,tags:e.tags,signature:e.signature})}}async verify(t){const e=await t.getSignatureData(),r=t.get("signature",{decode:!0,string:!1}),n=o.bufferTob64Url(await this.crypto.hash(r));if(t.id!==n)throw new Error("Invalid transaction signature or ID! The transaction ID doesn't match the expected SHA-256 hash of the signature.");return this.crypto.verify(t.owner,e,r)}async post(t){if("string"==typeof t?t=new i.default(JSON.parse(t)):"function"==typeof t.readInt32BE?t=new i.default(JSON.parse(t.toString())):"object"!=typeof t||t instanceof i.default||(t=new i.default(t)),!(t instanceof i.default))throw new Error("Must be Transaction object");t.chunks||await t.prepareChunks(t.data);const e=await this.getUploader(t,t.data);try{for(;!e.isComplete;)await e.uploadChunk()}catch(t){if(e.lastResponseStatus>0)return{status:e.lastResponseStatus,statusText:e.lastResponseError,data:{error:e.lastResponseError}};throw t}return{status:200,statusText:"OK",data:{}}}async getUploader(t,e){let r;if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),t instanceof i.default){if(e||(e=t.data),!(e instanceof Uint8Array))throw new Error("Data format is invalid");t.chunks||await t.prepareChunks(e),r=new c.TransactionUploader(this.api,t),r.data&&0!==r.data.length||(r.data=e)}else{if("string"==typeof t&&(t=await c.TransactionUploader.fromTransactionId(this.api,t)),!(e&&e instanceof Uint8Array))throw new Error("Must provide data when resuming upload");r=await c.TransactionUploader.fromSerialized(this.api,t,e)}return r}upload(t,e){return a(this,arguments,(function*(){const r=yield n(this.getUploader(t,e));for(;!r.isComplete;)yield n(r.uploadChunk()),yield yield n(r);return yield n(r)}))}}},241:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(303);r(317);e.default=class{constructor(t,e){this.api=t,this.crypto=e}getBalance(t){return this.api.get(`wallet/${t}/balance`).then((t=>t.data))}getLastTransactionID(t){return this.api.get(`wallet/${t}/last_tx`).then((t=>t.data))}generate(){return this.crypto.generateJWK()}async jwkToAddress(t){return t&&"use_wallet"!==t?this.getAddress(t):this.getAddress()}async getAddress(t){if(t&&"use_wallet"!==t)return this.ownerToAddress(t.n);try{await arweaveWallet.connect(["ACCESS_ADDRESS"])}catch(t){}return arweaveWallet.getActiveAddress()}async ownerToAddress(t){return n.bufferTob64Url(await this.crypto.hash(n.b64UrlToBuffer(t)))}}}},e={};function r(n){var a=e[n];if(void 0!==a)return a.exports;var s=e[n]={exports:{}};return t[n].call(s.exports,s,s.exports,r),s.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};r(533)})(); | ||
(()=>{var t={317:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>n});const n={}},742:(t,e)=>{"use strict";e.byteLength=function(t){var e=c(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,s=c(t),i=s[0],o=s[1],u=new a(function(t,e,r){return 3*(e+r)/4-r}(0,i,o)),l=0,h=o>0?i-4:i;for(r=0;r<h;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],u[l++]=e>>16&255,u[l++]=e>>8&255,u[l++]=255&e;2===o&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,u[l++]=255&e);1===o&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,u[l++]=e>>8&255,u[l++]=255&e);return u},e.fromByteArray=function(t){for(var e,n=t.length,a=n%3,s=[],i=16383,o=0,c=n-a;o<c;o+=i)s.push(u(t,o,o+i>c?c:o+i));1===a?(e=t[n-1],s.push(r[e>>2]+r[e<<4&63]+"==")):2===a&&(e=(t[n-2]<<8)+t[n-1],s.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return s.join("")};for(var r=[],n=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,o=s.length;i<o;++i)r[i]=s[i],n[s.charCodeAt(i)]=i;function c(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u(t,e,n){for(var a,s,i=[],o=e;o<n;o+=3)a=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),i.push(r[(s=a)>>18&63]+r[s>>12&63]+r[s>>6&63]+r[63&s]);return i.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},431:function(t,e,r){var n;!function(a){"use strict";var s,i=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,o=Math.ceil,c=Math.floor,u="[BigNumber Error] ",l=u+"Number primitive has more than 15 significant digits: ",h=1e14,f=14,d=9007199254740991,g=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],p=1e7,w=1e9;function y(t){var e=0|t;return t>0||t===e?e:e-1}function m(t){for(var e,r,n=1,a=t.length,s=t[0]+"";n<a;){for(e=t[n++]+"",r=f-e.length;r--;e="0"+e);s+=e}for(a=s.length;48===s.charCodeAt(--a););return s.slice(0,a+1||1)}function b(t,e){var r,n,a=t.c,s=e.c,i=t.s,o=e.s,c=t.e,u=e.e;if(!i||!o)return null;if(r=a&&!a[0],n=s&&!s[0],r||n)return r?n?0:-o:i;if(i!=o)return i;if(r=i<0,n=c==u,!a||!s)return n?0:!a^r?1:-1;if(!n)return c>u^r?1:-1;for(o=(c=a.length)<(u=s.length)?c:u,i=0;i<o;i++)if(a[i]!=s[i])return a[i]>s[i]^r?1:-1;return c==u?0:c>u^r?1:-1}function v(t,e,r,n){if(t<e||t>r||t!==c(t))throw Error(u+(n||"Argument")+("number"==typeof t?t<e||t>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function T(t){var e=t.c.length-1;return y(t.e/f)==e&&t.c[e]%2!=0}function E(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function A(t,e,r){var n,a;if(e<0){for(a=r+".";++e;a+=r);t=a+t}else if(++e>(n=t.length)){for(a=r,e-=n;--e;a+=r);t+=a}else e<n&&(t=t.slice(0,e)+"."+t.slice(e));return t}s=function t(e){var r,n,a,s,_,S,B,k,U,O,N=F.prototype={constructor:F,toString:null,valueOf:null},x=new F(1),R=20,C=4,P=-7,I=21,D=-1e7,j=1e7,L=!1,M=1,$=0,K={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},q="0123456789abcdefghijklmnopqrstuvwxyz",H=!0;function F(t,e){var r,s,o,u,h,g,p,w,y=this;if(!(y instanceof F))return new F(t,e);if(null==e){if(t&&!0===t._isBigNumber)return y.s=t.s,void(!t.c||t.e>j?y.c=y.e=null:t.e<D?y.c=[y.e=0]:(y.e=t.e,y.c=t.c.slice()));if((g="number"==typeof t)&&0*t==0){if(y.s=1/t<0?(t=-t,-1):1,t===~~t){for(u=0,h=t;h>=10;h/=10,u++);return void(u>j?y.c=y.e=null:(y.e=u,y.c=[t]))}w=String(t)}else{if(!i.test(w=String(t)))return a(y,w,g);y.s=45==w.charCodeAt(0)?(w=w.slice(1),-1):1}(u=w.indexOf("."))>-1&&(w=w.replace(".","")),(h=w.search(/e/i))>0?(u<0&&(u=h),u+=+w.slice(h+1),w=w.substring(0,h)):u<0&&(u=w.length)}else{if(v(e,2,q.length,"Base"),10==e&&H)return J(y=new F(t),R+y.e+1,C);if(w=String(t),g="number"==typeof t){if(0*t!=0)return a(y,w,g,e);if(y.s=1/t<0?(w=w.slice(1),-1):1,F.DEBUG&&w.replace(/^0\.0*|\./,"").length>15)throw Error(l+t)}else y.s=45===w.charCodeAt(0)?(w=w.slice(1),-1):1;for(r=q.slice(0,e),u=h=0,p=w.length;h<p;h++)if(r.indexOf(s=w.charAt(h))<0){if("."==s){if(h>u){u=p;continue}}else if(!o&&(w==w.toUpperCase()&&(w=w.toLowerCase())||w==w.toLowerCase()&&(w=w.toUpperCase()))){o=!0,h=-1,u=0;continue}return a(y,String(t),g,e)}g=!1,(u=(w=n(w,e,10,y.s)).indexOf("."))>-1?w=w.replace(".",""):u=w.length}for(h=0;48===w.charCodeAt(h);h++);for(p=w.length;48===w.charCodeAt(--p););if(w=w.slice(h,++p)){if(p-=h,g&&F.DEBUG&&p>15&&(t>d||t!==c(t)))throw Error(l+y.s*t);if((u=u-h-1)>j)y.c=y.e=null;else if(u<D)y.c=[y.e=0];else{if(y.e=u,y.c=[],h=(u+1)%f,u<0&&(h+=f),h<p){for(h&&y.c.push(+w.slice(0,h)),p-=f;h<p;)y.c.push(+w.slice(h,h+=f));h=f-(w=w.slice(h)).length}else h-=p;for(;h--;w+="0");y.c.push(+w)}}else y.c=[y.e=0]}function z(t,e,r,n){var a,s,i,o,c;if(null==r?r=C:v(r,0,8),!t.c)return t.toString();if(a=t.c[0],i=t.e,null==e)c=m(t.c),c=1==n||2==n&&(i<=P||i>=I)?E(c,i):A(c,i,"0");else if(s=(t=J(new F(t),e,r)).e,o=(c=m(t.c)).length,1==n||2==n&&(e<=s||s<=P)){for(;o<e;c+="0",o++);c=E(c,s)}else if(e-=i,c=A(c,s,"0"),s+1>o){if(--e>0)for(c+=".";e--;c+="0");}else if((e+=s-o)>0)for(s+1==o&&(c+=".");e--;c+="0");return t.s<0&&a?"-"+c:c}function G(t,e){for(var r,n=1,a=new F(t[0]);n<t.length;n++){if(!(r=new F(t[n])).s){a=r;break}e.call(a,r)&&(a=r)}return a}function W(t,e,r){for(var n=1,a=e.length;!e[--a];e.pop());for(a=e[0];a>=10;a/=10,n++);return(r=n+r*f-1)>j?t.c=t.e=null:r<D?t.c=[t.e=0]:(t.e=r,t.c=e),t}function J(t,e,r,n){var a,s,i,u,l,d,p,w=t.c,y=g;if(w){t:{for(a=1,u=w[0];u>=10;u/=10,a++);if((s=e-a)<0)s+=f,i=e,p=(l=w[d=0])/y[a-i-1]%10|0;else if((d=o((s+1)/f))>=w.length){if(!n)break t;for(;w.length<=d;w.push(0));l=p=0,a=1,i=(s%=f)-f+1}else{for(l=u=w[d],a=1;u>=10;u/=10,a++);p=(i=(s%=f)-f+a)<0?0:l/y[a-i-1]%10|0}if(n=n||e<0||null!=w[d+1]||(i<0?l:l%y[a-i-1]),n=r<4?(p||n)&&(0==r||r==(t.s<0?3:2)):p>5||5==p&&(4==r||n||6==r&&(s>0?i>0?l/y[a-i]:0:w[d-1])%10&1||r==(t.s<0?8:7)),e<1||!w[0])return w.length=0,n?(e-=t.e+1,w[0]=y[(f-e%f)%f],t.e=-e||0):w[0]=t.e=0,t;if(0==s?(w.length=d,u=1,d--):(w.length=d+1,u=y[f-s],w[d]=i>0?c(l/y[a-i]%y[i])*u:0),n)for(;;){if(0==d){for(s=1,i=w[0];i>=10;i/=10,s++);for(i=w[0]+=u,u=1;i>=10;i/=10,u++);s!=u&&(t.e++,w[0]==h&&(w[0]=1));break}if(w[d]+=u,w[d]!=h)break;w[d--]=0,u=1}for(s=w.length;0===w[--s];w.pop());}t.e>j?t.c=t.e=null:t.e<D&&(t.c=[t.e=0])}return t}function V(t){var e,r=t.e;return null===r?t.toString():(e=m(t.c),e=r<=P||r>=I?E(e,r):A(e,r,"0"),t.s<0?"-"+e:e)}return F.clone=t,F.ROUND_UP=0,F.ROUND_DOWN=1,F.ROUND_CEIL=2,F.ROUND_FLOOR=3,F.ROUND_HALF_UP=4,F.ROUND_HALF_DOWN=5,F.ROUND_HALF_EVEN=6,F.ROUND_HALF_CEIL=7,F.ROUND_HALF_FLOOR=8,F.EUCLID=9,F.config=F.set=function(t){var e,r;if(null!=t){if("object"!=typeof t)throw Error(u+"Object expected: "+t);if(t.hasOwnProperty(e="DECIMAL_PLACES")&&(v(r=t[e],0,w,e),R=r),t.hasOwnProperty(e="ROUNDING_MODE")&&(v(r=t[e],0,8,e),C=r),t.hasOwnProperty(e="EXPONENTIAL_AT")&&((r=t[e])&&r.pop?(v(r[0],-w,0,e),v(r[1],0,w,e),P=r[0],I=r[1]):(v(r,-w,w,e),P=-(I=r<0?-r:r))),t.hasOwnProperty(e="RANGE"))if((r=t[e])&&r.pop)v(r[0],-w,-1,e),v(r[1],1,w,e),D=r[0],j=r[1];else{if(v(r,-w,w,e),!r)throw Error(u+e+" cannot be zero: "+r);D=-(j=r<0?-r:r)}if(t.hasOwnProperty(e="CRYPTO")){if((r=t[e])!==!!r)throw Error(u+e+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw L=!r,Error(u+"crypto unavailable");L=r}else L=r}if(t.hasOwnProperty(e="MODULO_MODE")&&(v(r=t[e],0,9,e),M=r),t.hasOwnProperty(e="POW_PRECISION")&&(v(r=t[e],0,w,e),$=r),t.hasOwnProperty(e="FORMAT")){if("object"!=typeof(r=t[e]))throw Error(u+e+" not an object: "+r);K=r}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(r=t[e])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(u+e+" invalid: "+r);H="0123456789"==r.slice(0,10),q=r}}return{DECIMAL_PLACES:R,ROUNDING_MODE:C,EXPONENTIAL_AT:[P,I],RANGE:[D,j],CRYPTO:L,MODULO_MODE:M,POW_PRECISION:$,FORMAT:K,ALPHABET:q}},F.isBigNumber=function(t){if(!t||!0!==t._isBigNumber)return!1;if(!F.DEBUG)return!0;var e,r,n=t.c,a=t.e,s=t.s;t:if("[object Array]"=={}.toString.call(n)){if((1===s||-1===s)&&a>=-w&&a<=w&&a===c(a)){if(0===n[0]){if(0===a&&1===n.length)return!0;break t}if((e=(a+1)%f)<1&&(e+=f),String(n[0]).length==e){for(e=0;e<n.length;e++)if((r=n[e])<0||r>=h||r!==c(r))break t;if(0!==r)return!0}}}else if(null===n&&null===a&&(null===s||1===s||-1===s))return!0;throw Error(u+"Invalid BigNumber: "+t)},F.maximum=F.max=function(){return G(arguments,N.lt)},F.minimum=F.min=function(){return G(arguments,N.gt)},F.random=(s=9007199254740992,_=Math.random()*s&2097151?function(){return c(Math.random()*s)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(t){var e,r,n,a,s,i=0,l=[],h=new F(x);if(null==t?t=R:v(t,0,w),a=o(t/f),L)if(crypto.getRandomValues){for(e=crypto.getRandomValues(new Uint32Array(a*=2));i<a;)(s=131072*e[i]+(e[i+1]>>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),e[i]=r[0],e[i+1]=r[1]):(l.push(s%1e14),i+=2);i=a/2}else{if(!crypto.randomBytes)throw L=!1,Error(u+"crypto unavailable");for(e=crypto.randomBytes(a*=7);i<a;)(s=281474976710656*(31&e[i])+1099511627776*e[i+1]+4294967296*e[i+2]+16777216*e[i+3]+(e[i+4]<<16)+(e[i+5]<<8)+e[i+6])>=9e15?crypto.randomBytes(7).copy(e,i):(l.push(s%1e14),i+=7);i=a/7}if(!L)for(;i<a;)(s=_())<9e15&&(l[i++]=s%1e14);for(a=l[--i],t%=f,a&&t&&(s=g[f-t],l[i]=c(a/s)*s);0===l[i];l.pop(),i--);if(i<0)l=[n=0];else{for(n=-1;0===l[0];l.splice(0,1),n-=f);for(i=1,s=l[0];s>=10;s/=10,i++);i<f&&(n-=f-i)}return h.e=n,h.c=l,h}),F.sum=function(){for(var t=1,e=arguments,r=new F(e[0]);t<e.length;)r=r.plus(e[t++]);return r},n=function(){var t="0123456789";function e(t,e,r,n){for(var a,s,i=[0],o=0,c=t.length;o<c;){for(s=i.length;s--;i[s]*=e);for(i[0]+=n.indexOf(t.charAt(o++)),a=0;a<i.length;a++)i[a]>r-1&&(null==i[a+1]&&(i[a+1]=0),i[a+1]+=i[a]/r|0,i[a]%=r)}return i.reverse()}return function(n,a,s,i,o){var c,u,l,h,f,d,g,p,w=n.indexOf("."),y=R,b=C;for(w>=0&&(h=$,$=0,n=n.replace(".",""),d=(p=new F(a)).pow(n.length-w),$=h,p.c=e(A(m(d.c),d.e,"0"),10,s,t),p.e=p.c.length),l=h=(g=e(n,a,s,o?(c=q,t):(c=t,q))).length;0==g[--h];g.pop());if(!g[0])return c.charAt(0);if(w<0?--l:(d.c=g,d.e=l,d.s=i,g=(d=r(d,p,y,b,s)).c,f=d.r,l=d.e),w=g[u=l+y+1],h=s/2,f=f||u<0||null!=g[u+1],f=b<4?(null!=w||f)&&(0==b||b==(d.s<0?3:2)):w>h||w==h&&(4==b||f||6==b&&1&g[u-1]||b==(d.s<0?8:7)),u<1||!g[0])n=f?A(c.charAt(1),-y,c.charAt(0)):c.charAt(0);else{if(g.length=u,f)for(--s;++g[--u]>s;)g[u]=0,u||(++l,g=[1].concat(g));for(h=g.length;!g[--h];);for(w=0,n="";w<=h;n+=c.charAt(g[w++]));n=A(n,l,c.charAt(0))}return n}}(),r=function(){function t(t,e,r){var n,a,s,i,o=0,c=t.length,u=e%p,l=e/p|0;for(t=t.slice();c--;)o=((a=u*(s=t[c]%p)+(n=l*s+(i=t[c]/p|0)*u)%p*p+o)/r|0)+(n/p|0)+l*i,t[c]=a%r;return o&&(t=[o].concat(t)),t}function e(t,e,r,n){var a,s;if(r!=n)s=r>n?1:-1;else for(a=s=0;a<r;a++)if(t[a]!=e[a]){s=t[a]>e[a]?1:-1;break}return s}function r(t,e,r,n){for(var a=0;r--;)t[r]-=a,a=t[r]<e[r]?1:0,t[r]=a*n+t[r]-e[r];for(;!t[0]&&t.length>1;t.splice(0,1));}return function(n,a,s,i,o){var u,l,d,g,p,w,m,b,v,T,E,A,_,S,B,k,U,O=n.s==a.s?1:-1,N=n.c,x=a.c;if(!(N&&N[0]&&x&&x[0]))return new F(n.s&&a.s&&(N?!x||N[0]!=x[0]:x)?N&&0==N[0]||!x?0*O:O/0:NaN);for(v=(b=new F(O)).c=[],O=s+(l=n.e-a.e)+1,o||(o=h,l=y(n.e/f)-y(a.e/f),O=O/f|0),d=0;x[d]==(N[d]||0);d++);if(x[d]>(N[d]||0)&&l--,O<0)v.push(1),g=!0;else{for(S=N.length,k=x.length,d=0,O+=2,(p=c(o/(x[0]+1)))>1&&(x=t(x,p,o),N=t(N,p,o),k=x.length,S=N.length),_=k,E=(T=N.slice(0,k)).length;E<k;T[E++]=0);U=x.slice(),U=[0].concat(U),B=x[0],x[1]>=o/2&&B++;do{if(p=0,(u=e(x,T,k,E))<0){if(A=T[0],k!=E&&(A=A*o+(T[1]||0)),(p=c(A/B))>1)for(p>=o&&(p=o-1),m=(w=t(x,p,o)).length,E=T.length;1==e(w,T,m,E);)p--,r(w,k<m?U:x,m,o),m=w.length,u=1;else 0==p&&(u=p=1),m=(w=x.slice()).length;if(m<E&&(w=[0].concat(w)),r(T,w,E,o),E=T.length,-1==u)for(;e(x,T,k,E)<1;)p++,r(T,k<E?U:x,E,o),E=T.length}else 0===u&&(p++,T=[0]);v[d++]=p,T[0]?T[E++]=N[_]||0:(T=[N[_]],E=1)}while((_++<S||null!=T[0])&&O--);g=null!=T[0],v[0]||v.splice(0,1)}if(o==h){for(d=1,O=v[0];O>=10;O/=10,d++);J(b,s+(b.e=d+l*f-1)+1,i,g)}else b.e=l,b.r=+g;return b}}(),S=/^(-?)0([xbo])(?=\w[\w.]*$)/i,B=/^([^.]+)\.$/,k=/^\.([^.]+)$/,U=/^-?(Infinity|NaN)$/,O=/^\s*\+(?=[\w.])|^\s+|\s+$/g,a=function(t,e,r,n){var a,s=r?e:e.replace(O,"");if(U.test(s))t.s=isNaN(s)?null:s<0?-1:1;else{if(!r&&(s=s.replace(S,(function(t,e,r){return a="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=a?t:e})),n&&(a=n,s=s.replace(B,"$1").replace(k,"0.$1")),e!=s))return new F(s,a);if(F.DEBUG)throw Error(u+"Not a"+(n?" base "+n:"")+" number: "+e);t.s=null}t.c=t.e=null},N.absoluteValue=N.abs=function(){var t=new F(this);return t.s<0&&(t.s=1),t},N.comparedTo=function(t,e){return b(this,new F(t,e))},N.decimalPlaces=N.dp=function(t,e){var r,n,a,s=this;if(null!=t)return v(t,0,w),null==e?e=C:v(e,0,8),J(new F(s),t+s.e+1,e);if(!(r=s.c))return null;if(n=((a=r.length-1)-y(this.e/f))*f,a=r[a])for(;a%10==0;a/=10,n--);return n<0&&(n=0),n},N.dividedBy=N.div=function(t,e){return r(this,new F(t,e),R,C)},N.dividedToIntegerBy=N.idiv=function(t,e){return r(this,new F(t,e),0,1)},N.exponentiatedBy=N.pow=function(t,e){var r,n,a,s,i,l,h,d,g=this;if((t=new F(t)).c&&!t.isInteger())throw Error(u+"Exponent not an integer: "+V(t));if(null!=e&&(e=new F(e)),i=t.e>14,!g.c||!g.c[0]||1==g.c[0]&&!g.e&&1==g.c.length||!t.c||!t.c[0])return d=new F(Math.pow(+V(g),i?t.s*(2-T(t)):+V(t))),e?d.mod(e):d;if(l=t.s<0,e){if(e.c?!e.c[0]:!e.s)return new F(NaN);(n=!l&&g.isInteger()&&e.isInteger())&&(g=g.mod(e))}else{if(t.e>9&&(g.e>0||g.e<-1||(0==g.e?g.c[0]>1||i&&g.c[1]>=24e7:g.c[0]<8e13||i&&g.c[0]<=9999975e7)))return s=g.s<0&&T(t)?-0:0,g.e>-1&&(s=1/s),new F(l?1/s:s);$&&(s=o($/f+2))}for(i?(r=new F(.5),l&&(t.s=1),h=T(t)):h=(a=Math.abs(+V(t)))%2,d=new F(x);;){if(h){if(!(d=d.times(g)).c)break;s?d.c.length>s&&(d.c.length=s):n&&(d=d.mod(e))}if(a){if(0===(a=c(a/2)))break;h=a%2}else if(J(t=t.times(r),t.e+1,1),t.e>14)h=T(t);else{if(0===(a=+V(t)))break;h=a%2}g=g.times(g),s?g.c&&g.c.length>s&&(g.c.length=s):n&&(g=g.mod(e))}return n?d:(l&&(d=x.div(d)),e?d.mod(e):s?J(d,$,C,undefined):d)},N.integerValue=function(t){var e=new F(this);return null==t?t=C:v(t,0,8),J(e,e.e+1,t)},N.isEqualTo=N.eq=function(t,e){return 0===b(this,new F(t,e))},N.isFinite=function(){return!!this.c},N.isGreaterThan=N.gt=function(t,e){return b(this,new F(t,e))>0},N.isGreaterThanOrEqualTo=N.gte=function(t,e){return 1===(e=b(this,new F(t,e)))||0===e},N.isInteger=function(){return!!this.c&&y(this.e/f)>this.c.length-2},N.isLessThan=N.lt=function(t,e){return b(this,new F(t,e))<0},N.isLessThanOrEqualTo=N.lte=function(t,e){return-1===(e=b(this,new F(t,e)))||0===e},N.isNaN=function(){return!this.s},N.isNegative=function(){return this.s<0},N.isPositive=function(){return this.s>0},N.isZero=function(){return!!this.c&&0==this.c[0]},N.minus=function(t,e){var r,n,a,s,i=this,o=i.s;if(e=(t=new F(t,e)).s,!o||!e)return new F(NaN);if(o!=e)return t.s=-e,i.plus(t);var c=i.e/f,u=t.e/f,l=i.c,d=t.c;if(!c||!u){if(!l||!d)return l?(t.s=-e,t):new F(d?i:NaN);if(!l[0]||!d[0])return d[0]?(t.s=-e,t):new F(l[0]?i:3==C?-0:0)}if(c=y(c),u=y(u),l=l.slice(),o=c-u){for((s=o<0)?(o=-o,a=l):(u=c,a=d),a.reverse(),e=o;e--;a.push(0));a.reverse()}else for(n=(s=(o=l.length)<(e=d.length))?o:e,o=e=0;e<n;e++)if(l[e]!=d[e]){s=l[e]<d[e];break}if(s&&(a=l,l=d,d=a,t.s=-t.s),(e=(n=d.length)-(r=l.length))>0)for(;e--;l[r++]=0);for(e=h-1;n>o;){if(l[--n]<d[n]){for(r=n;r&&!l[--r];l[r]=e);--l[r],l[n]+=h}l[n]-=d[n]}for(;0==l[0];l.splice(0,1),--u);return l[0]?W(t,l,u):(t.s=3==C?-1:1,t.c=[t.e=0],t)},N.modulo=N.mod=function(t,e){var n,a,s=this;return t=new F(t,e),!s.c||!t.s||t.c&&!t.c[0]?new F(NaN):!t.c||s.c&&!s.c[0]?new F(s):(9==M?(a=t.s,t.s=1,n=r(s,t,0,3),t.s=a,n.s*=a):n=r(s,t,0,M),(t=s.minus(n.times(t))).c[0]||1!=M||(t.s=s.s),t)},N.multipliedBy=N.times=function(t,e){var r,n,a,s,i,o,c,u,l,d,g,w,m,b,v,T=this,E=T.c,A=(t=new F(t,e)).c;if(!(E&&A&&E[0]&&A[0]))return!T.s||!t.s||E&&!E[0]&&!A||A&&!A[0]&&!E?t.c=t.e=t.s=null:(t.s*=T.s,E&&A?(t.c=[0],t.e=0):t.c=t.e=null),t;for(n=y(T.e/f)+y(t.e/f),t.s*=T.s,(c=E.length)<(d=A.length)&&(m=E,E=A,A=m,a=c,c=d,d=a),a=c+d,m=[];a--;m.push(0));for(b=h,v=p,a=d;--a>=0;){for(r=0,g=A[a]%v,w=A[a]/v|0,s=a+(i=c);s>a;)r=((u=g*(u=E[--i]%v)+(o=w*u+(l=E[i]/v|0)*g)%v*v+m[s]+r)/b|0)+(o/v|0)+w*l,m[s--]=u%b;m[s]=r}return r?++n:m.splice(0,1),W(t,m,n)},N.negated=function(){var t=new F(this);return t.s=-t.s||null,t},N.plus=function(t,e){var r,n=this,a=n.s;if(e=(t=new F(t,e)).s,!a||!e)return new F(NaN);if(a!=e)return t.s=-e,n.minus(t);var s=n.e/f,i=t.e/f,o=n.c,c=t.c;if(!s||!i){if(!o||!c)return new F(a/0);if(!o[0]||!c[0])return c[0]?t:new F(o[0]?n:0*a)}if(s=y(s),i=y(i),o=o.slice(),a=s-i){for(a>0?(i=s,r=c):(a=-a,r=o),r.reverse();a--;r.push(0));r.reverse()}for((a=o.length)-(e=c.length)<0&&(r=c,c=o,o=r,e=a),a=0;e;)a=(o[--e]=o[e]+c[e]+a)/h|0,o[e]=h===o[e]?0:o[e]%h;return a&&(o=[a].concat(o),++i),W(t,o,i)},N.precision=N.sd=function(t,e){var r,n,a,s=this;if(null!=t&&t!==!!t)return v(t,1,w),null==e?e=C:v(e,0,8),J(new F(s),t,e);if(!(r=s.c))return null;if(n=(a=r.length-1)*f+1,a=r[a]){for(;a%10==0;a/=10,n--);for(a=r[0];a>=10;a/=10,n++);}return t&&s.e+1>n&&(n=s.e+1),n},N.shiftedBy=function(t){return v(t,-9007199254740991,d),this.times("1e"+t)},N.squareRoot=N.sqrt=function(){var t,e,n,a,s,i=this,o=i.c,c=i.s,u=i.e,l=R+4,h=new F("0.5");if(1!==c||!o||!o[0])return new F(!c||c<0&&(!o||o[0])?NaN:o?i:1/0);if(0==(c=Math.sqrt(+V(i)))||c==1/0?(((e=m(o)).length+u)%2==0&&(e+="0"),c=Math.sqrt(+e),u=y((u+1)/2)-(u<0||u%2),n=new F(e=c==1/0?"5e"+u:(e=c.toExponential()).slice(0,e.indexOf("e")+1)+u)):n=new F(c+""),n.c[0])for((c=(u=n.e)+l)<3&&(c=0);;)if(s=n,n=h.times(s.plus(r(i,s,l,1))),m(s.c).slice(0,c)===(e=m(n.c)).slice(0,c)){if(n.e<u&&--c,"9999"!=(e=e.slice(c-3,c+1))&&(a||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(J(n,n.e+R+2,1),t=!n.times(n).eq(i));break}if(!a&&(J(s,s.e+R+2,0),s.times(s).eq(i))){n=s;break}l+=4,c+=4,a=1}return J(n,n.e+R+1,C,t)},N.toExponential=function(t,e){return null!=t&&(v(t,0,w),t++),z(this,t,e,1)},N.toFixed=function(t,e){return null!=t&&(v(t,0,w),t=t+this.e+1),z(this,t,e)},N.toFormat=function(t,e,r){var n,a=this;if(null==r)null!=t&&e&&"object"==typeof e?(r=e,e=null):t&&"object"==typeof t?(r=t,t=e=null):r=K;else if("object"!=typeof r)throw Error(u+"Argument not an object: "+r);if(n=a.toFixed(t,e),a.c){var s,i=n.split("."),o=+r.groupSize,c=+r.secondaryGroupSize,l=r.groupSeparator||"",h=i[0],f=i[1],d=a.s<0,g=d?h.slice(1):h,p=g.length;if(c&&(s=o,o=c,c=s,p-=s),o>0&&p>0){for(s=p%o||o,h=g.substr(0,s);s<p;s+=o)h+=l+g.substr(s,o);c>0&&(h+=l+g.slice(s)),d&&(h="-"+h)}n=f?h+(r.decimalSeparator||"")+((c=+r.fractionGroupSize)?f.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):f):h}return(r.prefix||"")+n+(r.suffix||"")},N.toFraction=function(t){var e,n,a,s,i,o,c,l,h,d,p,w,y=this,b=y.c;if(null!=t&&(!(c=new F(t)).isInteger()&&(c.c||1!==c.s)||c.lt(x)))throw Error(u+"Argument "+(c.isInteger()?"out of range: ":"not an integer: ")+V(c));if(!b)return new F(y);for(e=new F(x),h=n=new F(x),a=l=new F(x),w=m(b),i=e.e=w.length-y.e-1,e.c[0]=g[(o=i%f)<0?f+o:o],t=!t||c.comparedTo(e)>0?i>0?e:h:c,o=j,j=1/0,c=new F(w),l.c[0]=0;d=r(c,e,0,1),1!=(s=n.plus(d.times(a))).comparedTo(t);)n=a,a=s,h=l.plus(d.times(s=h)),l=s,e=c.minus(d.times(s=e)),c=s;return s=r(t.minus(n),a,0,1),l=l.plus(s.times(h)),n=n.plus(s.times(a)),l.s=h.s=y.s,p=r(h,a,i*=2,C).minus(y).abs().comparedTo(r(l,n,i,C).minus(y).abs())<1?[h,a]:[l,n],j=o,p},N.toNumber=function(){return+V(this)},N.toPrecision=function(t,e){return null!=t&&v(t,1,w),z(this,t,e,2)},N.toString=function(t){var e,r=this,a=r.s,s=r.e;return null===s?a?(e="Infinity",a<0&&(e="-"+e)):e="NaN":(null==t?e=s<=P||s>=I?E(m(r.c),s):A(m(r.c),s,"0"):10===t&&H?e=A(m((r=J(new F(r),R+s+1,C)).c),r.e,"0"):(v(t,2,q.length,"Base"),e=n(A(m(r.c),s,"0"),10,t,a,!0)),a<0&&r.c[0]&&(e="-"+e)),e},N.valueOf=N.toJSON=function(){return V(this)},N._isBigNumber=!0,null!=e&&F.set(e),F}(),s.default=s.BigNumber=s,void 0===(n=function(){return s}.call(e,r,e,t))||(t.exports=n)}()},522:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(431);e.default=class{BigNum;constructor(){this.BigNum=(t,e)=>new(n.BigNumber.clone({DECIMAL_PLACES:e}))(t)}winstonToAr(t,{formatted:e=!1,decimals:r=12,trim:n=!0}={}){let a=this.stringToBigNum(t,r).shiftedBy(-12);return e?a.toFormat(r):a.toFixed(r)}arToWinston(t,{formatted:e=!1}={}){let r=this.stringToBigNum(t).shiftedBy(12);return e?r.toFormat():r.toFixed(0)}compare(t,e){let r=this.stringToBigNum(t),n=this.stringToBigNum(e);return r.comparedTo(n)}isEqual(t,e){return 0===this.compare(t,e)}isLessThan(t,e){let r=this.stringToBigNum(t),n=this.stringToBigNum(e);return r.isLessThan(n)}isGreaterThan(t,e){let r=this.stringToBigNum(t),n=this.stringToBigNum(e);return r.isGreaterThan(n)}add(t,e){let r=this.stringToBigNum(t);this.stringToBigNum(e);return r.plus(e).toFixed(0)}sub(t,e){let r=this.stringToBigNum(t);this.stringToBigNum(e);return r.minus(e).toFixed(0)}stringToBigNum(t,e=12){return this.BigNum(t,e)}}},60:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(941);r(317);class a{api;network;static ENDPOINT="block/hash/";constructor(t,e){this.api=t,this.network=e}async get(t){const e=await this.api.get(`${a.ENDPOINT}${t}`);if(200===e.status)return e.data;throw 404===e.status?new n.default("BLOCK_NOT_FOUND"):new Error(`Error while loading block data: ${e}`)}async getCurrent(){const{current:t}=await this.network.getInfo();return await this.get(t)}}e.default=a},997:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(941),a=r(303);e.default=class{api;constructor(t){this.api=t}async getTransactionOffset(t){const e=await this.api.get(`tx/${t}/offset`);if(200===e.status)return e.data;throw new Error(`Unable to get transaction offset: ${(0,n.getError)(e)}`)}async getChunk(t){const e=await this.api.get(`chunk/${t}`);if(200===e.status)return e.data;throw new Error(`Unable to get chunk: ${(0,n.getError)(e)}`)}async getChunkData(t){const e=await this.getChunk(t);return a.b64UrlToBuffer(e.chunk)}firstChunkOffset(t){return parseInt(t.offset)-parseInt(t.size)+1}async downloadChunkedData(t){const e=await this.getTransactionOffset(t),r=parseInt(e.size),n=parseInt(e.offset)-r+1,a=new Uint8Array(r);let s=0;for(;s<r;){let t;this.api.config.logging&&console.log(`[chunk] ${s}/${r}`);try{t=await this.getChunkData(n+s)}catch(t){console.error(`[chunk] Failed to fetch chunk at offset ${n+s}`),console.error("[chunk] This could indicate that the chunk wasn't uploaded or hasn't yet seeded properly to a particular gateway/node")}if(!t)throw new Error(`Couldn't complete data download at ${s}/${r}`);a.set(t,s),s+=t.length}return a}}},415:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(522),a=r(589),s=r(716),i=r(886),o=r(198),c=r(241),u=r(993),l=r(303),h=r(470),f=r(997),d=r(60);class g{api;wallets;transactions;network;blocks;ar;silo;chunks;static init;static crypto=new s.default;static utils=l;constructor(t){this.api=new a.default(t),this.wallets=new c.default(this.api,g.crypto),this.chunks=new f.default(this.api),this.transactions=new o.default(this.api,g.crypto,this.chunks),this.silo=new h.default(this.api,this.crypto,this.transactions),this.network=new i.default(this.api),this.blocks=new d.default(this.api,this.network),this.ar=new n.default}get crypto(){return g.crypto}get utils(){return g.utils}getConfig(){return{api:this.api.getConfig(),crypto:null}}async createTransaction(t,e){const r={};if(Object.assign(r,t),!(t.data||t.target&&t.quantity))throw new Error("A new Arweave transaction must have a 'data' value, or 'target' and 'quantity' values.");if(null==t.owner&&e&&"use_wallet"!==e&&(r.owner=e.n),null==t.last_tx&&(r.last_tx=await this.transactions.getTransactionAnchor()),"string"==typeof t.data&&(t.data=l.stringToBuffer(t.data)),t.data instanceof ArrayBuffer&&(t.data=new Uint8Array(t.data)),t.data&&!(t.data instanceof Uint8Array))throw new Error("Expected data to be a string, Uint8Array or ArrayBuffer");if(null==t.reward){const e=t.data?t.data.byteLength:0;r.reward=await this.transactions.getPrice(e,r.target)}r.data_root="",r.data_size=t.data?t.data.byteLength.toString():"0",r.data=t.data||new Uint8Array(0);const n=new u.default(r);return await n.getSignatureData(),n}async createSiloTransaction(t,e,r){const n={};if(Object.assign(n,t),!t.data)throw new Error("Silo transactions must have a 'data' value");if(!r)throw new Error("No Silo URI specified.");if(t.target||t.quantity)throw new Error("Silo transactions can only be used for storing data, sending AR to other wallets isn't supported.");if(null==t.owner){if(!e||!e.n)throw new Error("A new Arweave transaction must either have an 'owner' attribute, or you must provide the jwk parameter.");n.owner=e.n}null==t.last_tx&&(n.last_tx=await this.transactions.getTransactionAnchor());const a=await this.silo.parseUri(r);if("string"==typeof t.data){const e=await this.crypto.encrypt(l.stringToBuffer(t.data),a.getEncryptionKey());n.reward=await this.transactions.getPrice(e.byteLength),n.data=l.bufferTob64Url(e)}if(t.data instanceof Uint8Array){const e=await this.crypto.encrypt(t.data,a.getEncryptionKey());n.reward=await this.transactions.getPrice(e.byteLength),n.data=l.bufferTob64Url(e)}const s=new u.default(n);return s.addTag("Silo-Name",a.getAccessKey()),s.addTag("Silo-Version","0.1.0"),s}arql(t){return this.api.post("/arql",t).then((t=>t.data||[]))}}e.default=g},533:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var a=Object.getOwnPropertyDescriptor(e,r);a&&!("get"in a?!e.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,a)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),a=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0});const s=r(415);s.default.init=function(t={}){const e=function(){const t={host:"arweave.net",port:443,protocol:"https"};if("object"!=typeof location||!location.protocol||!location.hostname)return t;const e=location.protocol.replace(":",""),r=location.hostname,n=location.port?parseInt(location.port):"https"==e?443:80;return["localhost","127.0.0.1"].includes(r)||"file"==e?t:{host:r,port:n,protocol:e}}(),r=t.protocol||e.protocol,n=t.host||e.host,a=t.port||e.port;return new s.default({...t,host:n,protocol:r,port:a})},"object"==typeof globalThis?globalThis.Arweave=s.default:"object"==typeof self&&(self.Arweave=s.default),a(r(415),e),e.default=s.default},589:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=class{METHOD_GET="GET";METHOD_POST="POST";config;constructor(t){this.applyConfig(t)}applyConfig(t){this.config=this.mergeDefaults(t)}getConfig(){return this.config}mergeDefaults(t){const e=t.protocol||"http",r=t.port||("https"===e?443:80);return{host:t.host||"127.0.0.1",protocol:e,port:r,timeout:t.timeout||2e4,logging:t.logging||!1,logger:t.logger||console.log,network:t.network}}async get(t,e){return await this.request(t,{...e,method:this.METHOD_GET})}async post(t,e,r){const n=new Headers(r?.headers||{});return n.get("content-type")?.includes("application/json")||n.append("content-type","application/json"),n.append("accept","application/json, text/plain, */*"),await this.request(t,{...r,method:this.METHOD_POST,body:"string"!=typeof e?JSON.stringify(e):e,headers:n})}async request(t,e){const r=new Headers(e?.headers||{}),n=`${this.config.protocol}://${this.config.host}:${this.config.port}`,a=e?.responseType;delete e?.responseType,t.startsWith("/")&&(t=t.slice(1)),this.config.network&&r.append("x-network",this.config.network),this.config.logging&&this.config.logger(`Requesting: ${n}/${t}`);let s=await fetch(`${n}/${t}`,{...e||{},headers:r});this.config.logging&&this.config.logger(`Response: ${s.url} - ${s.status}`);const i=s.headers.get("content-type"),o=s;if("arraybuffer"===a)o.data=await s.arrayBuffer();else if("text"===a)o.data=await s.text();else if(i?.startsWith("application/json"))try{await s.clone().json(),o.data=await s.json()}catch{o.data=await s.text()}else o.data=await s.text();return o}}},716:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(303);e.default=class{keyLength=4096;publicExponent=65537;hashAlgorithm="sha256";driver;constructor(){if(!this.detectWebCrypto())throw new Error("SubtleCrypto not available!");this.driver=crypto.subtle}async generateJWK(){let t=await this.driver.generateKey({name:"RSA-PSS",modulusLength:4096,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign"]),e=await this.driver.exportKey("jwk",t.privateKey);return{kty:e.kty,e:e.e,n:e.n,d:e.d,p:e.p,q:e.q,dp:e.dp,dq:e.dq,qi:e.qi}}async sign(t,e,{saltLength:r}={}){let n=await this.driver.sign({name:"RSA-PSS",saltLength:32},await this.jwkToCryptoKey(t),e);return new Uint8Array(n)}async hash(t,e="SHA-256"){let r=await this.driver.digest(e,t);return new Uint8Array(r)}async verify(t,e,r){const n={kty:"RSA",e:"AQAB",n:t},a=await this.jwkToPublicCryptoKey(n),s=await this.driver.digest("SHA-256",e),i=await this.driver.verify({name:"RSA-PSS",saltLength:0},a,r,e),o=await this.driver.verify({name:"RSA-PSS",saltLength:32},a,r,e),c=await this.driver.verify({name:"RSA-PSS",saltLength:Math.ceil((a.algorithm.modulusLength-1)/8)-s.byteLength-2},a,r,e);return i||o||c}async jwkToCryptoKey(t){return this.driver.importKey("jwk",t,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["sign"])}async jwkToPublicCryptoKey(t){return this.driver.importKey("jwk",t,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["verify"])}detectWebCrypto(){if("undefined"==typeof crypto)return!1;const t=crypto?.subtle;if(void 0===t)return!1;return["generateKey","importKey","exportKey","digest","sign"].every((e=>"function"==typeof t[e]))}async encrypt(t,e,r){const a=await this.driver.importKey("raw","string"==typeof e?n.stringToBuffer(e):e,{name:"PBKDF2",length:32},!1,["deriveKey"]),s=await this.driver.deriveKey({name:"PBKDF2",salt:r?n.stringToBuffer(r):n.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},a,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),i=new Uint8Array(16);crypto.getRandomValues(i);const o=await this.driver.encrypt({name:"AES-CBC",iv:i},s,t);return n.concatBuffers([i,o])}async decrypt(t,e,r){const a=await this.driver.importKey("raw","string"==typeof e?n.stringToBuffer(e):e,{name:"PBKDF2",length:32},!1,["deriveKey"]),s=await this.driver.deriveKey({name:"PBKDF2",salt:r?n.stringToBuffer(r):n.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},a,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),i=t.slice(0,16),o=await this.driver.decrypt({name:"AES-CBC",iv:i},s,t.slice(16));return n.concatBuffers([o])}}},605:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(415);async function a(t){if(Array.isArray(t)){const e=n.default.utils.concatBuffers([n.default.utils.stringToBuffer("list"),n.default.utils.stringToBuffer(t.length.toString())]);return await s(t,await n.default.crypto.hash(e,"SHA-384"))}const e=n.default.utils.concatBuffers([n.default.utils.stringToBuffer("blob"),n.default.utils.stringToBuffer(t.byteLength.toString())]),r=n.default.utils.concatBuffers([await n.default.crypto.hash(e,"SHA-384"),await n.default.crypto.hash(t,"SHA-384")]);return await n.default.crypto.hash(r,"SHA-384")}async function s(t,e){if(t.length<1)return e;const r=n.default.utils.concatBuffers([e,await a(t[0])]),i=await n.default.crypto.hash(r,"SHA-384");return await s(t.slice(1),i)}e.default=a},941:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getError=void 0;class r extends Error{type;response;constructor(t,e={}){e.message?super(e.message):super(),this.type=t,this.response=e.response}getType(){return this.type}}e.default=r,e.getError=function(t){let e=t.data;if("string"==typeof t.data)try{e=JSON.parse(t.data)}catch(t){}if(t.data instanceof ArrayBuffer||t.data instanceof Uint8Array)try{e=JSON.parse(e.toString())}catch(t){}return e?e.error||e:t.statusText||"unknown"}},414:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.debug=e.validatePath=e.arrayCompare=e.bufferToInt=e.intToBuffer=e.arrayFlatten=e.generateProofs=e.buildLayers=e.generateTransactionChunks=e.generateTree=e.computeRootHash=e.generateLeaves=e.chunkData=e.MIN_CHUNK_SIZE=e.MAX_CHUNK_SIZE=void 0;const n=r(415),a=r(303);e.MAX_CHUNK_SIZE=262144,e.MIN_CHUNK_SIZE=32768;const s=32;async function i(t){let r=[],a=t,s=0;for(;a.byteLength>=e.MAX_CHUNK_SIZE;){let t=e.MAX_CHUNK_SIZE,i=a.byteLength-e.MAX_CHUNK_SIZE;i>0&&i<e.MIN_CHUNK_SIZE&&(t=Math.ceil(a.byteLength/2));const o=a.slice(0,t),c=await n.default.crypto.hash(o);s+=o.byteLength,r.push({dataHash:c,minByteRange:s-o.byteLength,maxByteRange:s}),a=a.slice(t)}return r.push({dataHash:await n.default.crypto.hash(a),minByteRange:s,maxByteRange:s+a.byteLength}),r}async function o(t){return Promise.all(t.map((async({dataHash:t,minByteRange:e,maxByteRange:r})=>({type:"leaf",id:await g(await Promise.all([g(t),g(p(r))])),dataHash:t,minByteRange:e,maxByteRange:r}))))}async function c(t){return await u(await o(await i(t)))}async function u(t,e=0){if(t.length<2){return t[0]}const r=[];for(let e=0;e<t.length;e+=2)r.push(await d(t[e],t[e+1]));return u(r,e+1)}function l(t){const e=h(t);return Array.isArray(e)?f(e):[e]}function h(t,e=new Uint8Array,r=0){if("leaf"==t.type)return{offset:t.maxByteRange-1,proof:(0,a.concatBuffers)([e,t.dataHash,p(t.maxByteRange)])};if("branch"==t.type){const n=(0,a.concatBuffers)([e,t.leftChild.id,t.rightChild.id,p(t.byteRange)]);return[h(t.leftChild,n,r+1),h(t.rightChild,n,r+1)]}throw new Error("Unexpected node type")}function f(t){const e=[];return t.forEach((t=>{Array.isArray(t)?e.push(...f(t)):e.push(t)})),e}async function d(t,e){if(!e)return t;return{type:"branch",id:await g([await g(t.id),await g(e.id),await g(p(t.maxByteRange))]),byteRange:t.maxByteRange,maxByteRange:e.maxByteRange,leftChild:t,rightChild:e}}async function g(t){return Array.isArray(t)&&(t=n.default.utils.concatBuffers(t)),new Uint8Array(await n.default.crypto.hash(t))}function p(t){const e=new Uint8Array(32);for(var r=e.length-1;r>=0;r--){var n=t%256;e[r]=n,t=(t-n)/256}return e}function w(t){let e=0;for(var r=0;r<t.length;r++)e*=256,e+=t[r];return e}e.chunkData=i,e.generateLeaves=o,e.computeRootHash=async function(t){return(await c(t)).id},e.generateTree=c,e.generateTransactionChunks=async function(t){const e=await i(t),r=await o(e),n=await u(r),a=await l(n),s=e.slice(-1)[0];return s.maxByteRange-s.minByteRange==0&&(e.splice(e.length-1,1),a.splice(a.length-1,1)),{data_root:n.id,chunks:e,proofs:a}},e.buildLayers=u,e.generateProofs=l,e.arrayFlatten=f,e.intToBuffer=p,e.bufferToInt=w;e.arrayCompare=(t,e)=>t.every(((t,r)=>e[r]===t)),e.validatePath=async function t(r,n,a,i,o){if(i<=0)return!1;if(n>=i)return t(r,0,i-1,i,o);if(n<0)return t(r,0,0,i,o);if(64==o.length){const t=o.slice(0,s),n=o.slice(t.length,t.length+32),c=await g([await g(t),await g(n)]);return!!(0,e.arrayCompare)(r,c)&&{offset:i-1,leftBound:a,rightBound:i,chunkSize:i-a}}const c=o.slice(0,s),u=o.slice(c.length,c.length+s),l=o.slice(c.length+u.length,c.length+u.length+32),h=w(l),f=o.slice(c.length+u.length+l.length),d=await g([await g(c),await g(u),await g(l)]);return!!(0,e.arrayCompare)(r,d)&&(n<h?await t(c,n,a,Math.min(i,h),f):await t(u,n,Math.max(a,h),i,f))},e.debug=async function t(e,r=""){if(e.byteLength<1)return r;const n=e.slice(0,s),a=e.slice(n.length,n.length+s),i=e.slice(n.length+a.length,n.length+a.length+32),o=w(i),c=e.slice(n.length+a.length+i.length),u=await g([await g(n),await g(a),await g(i)]);return t(c,`${r}\n${JSON.stringify(Buffer.from(n))},${JSON.stringify(Buffer.from(a))},${o} => ${JSON.stringify(u)}`)}},481:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TransactionUploader=void 0;const n=r(993),a=r(303),s=r(941),i=r(414),o=["invalid_json","chunk_too_big","data_path_too_big","offset_too_big","data_size_too_big","chunk_proof_ratio_not_attractive","invalid_proof"];class c{api;chunkIndex=0;txPosted=!1;transaction;lastRequestTimeEnd=0;totalErrors=0;data;lastResponseStatus=0;lastResponseError="";get isComplete(){return this.txPosted&&this.chunkIndex===this.transaction.chunks.chunks.length}get totalChunks(){return this.transaction.chunks.chunks.length}get uploadedChunks(){return this.chunkIndex}get pctComplete(){return Math.trunc(this.uploadedChunks/this.totalChunks*100)}constructor(t,e){if(this.api=t,!e.id)throw new Error("Transaction is not signed");if(!e.chunks)throw new Error("Transaction chunks not prepared");this.data=e.data,this.transaction=new n.default(Object.assign({},e,{data:new Uint8Array(0)}))}async uploadChunk(t){if(this.isComplete)throw new Error("Upload is already complete");if(""!==this.lastResponseError?this.totalErrors++:this.totalErrors=0,100===this.totalErrors)throw new Error(`Unable to complete upload: ${this.lastResponseStatus}: ${this.lastResponseError}`);let e=""===this.lastResponseError?0:Math.max(this.lastRequestTimeEnd+4e4-Date.now(),4e4);if(e>0&&(e-=e*Math.random()*.3,await new Promise((t=>setTimeout(t,e)))),this.lastResponseError="",!this.txPosted)return void await this.postTransaction();t&&(this.chunkIndex=t);const r=this.transaction.getChunk(t||this.chunkIndex,this.data);if(!await(0,i.validatePath)(this.transaction.chunks.data_root,parseInt(r.offset),0,parseInt(r.data_size),a.b64UrlToBuffer(r.data_path)))throw new Error(`Unable to validate chunk ${this.chunkIndex}`);const n=await this.api.post("chunk",this.transaction.getChunk(this.chunkIndex,this.data)).catch((t=>(console.error(t.message),{status:-1,data:{error:t.message}})));if(this.lastRequestTimeEnd=Date.now(),this.lastResponseStatus=n.status,200==this.lastResponseStatus)this.chunkIndex++;else if(this.lastResponseError=(0,s.getError)(n),o.includes(this.lastResponseError))throw new Error(`Fatal error uploading chunk ${this.chunkIndex}: ${this.lastResponseError}`)}static async fromSerialized(t,e,r){if(!e||"number"!=typeof e.chunkIndex||"object"!=typeof e.transaction)throw new Error("Serialized object does not match expected format.");var a=new n.default(e.transaction);a.chunks||await a.prepareChunks(r);const s=new c(t,a);if(s.chunkIndex=e.chunkIndex,s.lastRequestTimeEnd=e.lastRequestTimeEnd,s.lastResponseError=e.lastResponseError,s.lastResponseStatus=e.lastResponseStatus,s.txPosted=e.txPosted,s.data=r,s.transaction.data_root!==e.transaction.data_root)throw new Error("Data mismatch: Uploader doesn't match provided data.");return s}static async fromTransactionId(t,e){const r=await t.get(`tx/${e}`);if(200!==r.status)throw new Error(`Tx ${e} not found: ${r.status}`);const n=r.data;n.data=new Uint8Array(0);return{txPosted:!0,chunkIndex:0,lastResponseError:"",lastRequestTimeEnd:0,lastResponseStatus:0,transaction:n}}toJSON(){return{chunkIndex:this.chunkIndex,transaction:this.transaction,lastRequestTimeEnd:this.lastRequestTimeEnd,lastResponseStatus:this.lastResponseStatus,lastResponseError:this.lastResponseError,txPosted:this.txPosted}}async postTransaction(){if(this.totalChunks<=1){this.transaction.data=this.data;const t=await this.api.post("tx",this.transaction).catch((t=>(console.error(t),{status:-1,data:{error:t.message}})));if(this.lastRequestTimeEnd=Date.now(),this.lastResponseStatus=t.status,this.transaction.data=new Uint8Array(0),t.status>=200&&t.status<300)return this.txPosted=!0,void(this.chunkIndex=1);throw this.lastResponseError=(0,s.getError)(t),new Error(`Unable to upload transaction: ${t.status}, ${this.lastResponseError}`)}const t=await this.api.post("tx",this.transaction);if(this.lastRequestTimeEnd=Date.now(),this.lastResponseStatus=t.status,!(t.status>=200&&t.status<300))throw this.lastResponseError=(0,s.getError)(t),new Error(`Unable to upload transaction: ${t.status}, ${this.lastResponseError}`);this.txPosted=!0}}e.TransactionUploader=c},993:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Tag=void 0;const n=r(303),a=r(605),s=r(414);class i{get(t,e){if(!Object.getOwnPropertyNames(this).includes(t))throw new Error(`Field "${t}" is not a property of the Arweave Transaction class.`);return this[t]instanceof Uint8Array?e&&e.decode&&e.string?n.bufferToString(this[t]):e&&e.decode&&!e.string?this[t]:n.bufferTob64Url(this[t]):e&&1==e.decode?e&&e.string?n.b64UrlToString(this[t]):n.b64UrlToBuffer(this[t]):this[t]}}class o extends i{name;value;constructor(t,e,r=!1){super(),this.name=t,this.value=e}}e.Tag=o;e.default=class extends i{format=2;id="";last_tx="";owner="";tags=[];target="";quantity="0";data_size="0";data=new Uint8Array;data_root="";reward="0";signature="";chunks;constructor(t={}){super(),Object.assign(this,t),"string"==typeof this.data&&(this.data=n.b64UrlToBuffer(this.data)),t.tags&&(this.tags=t.tags.map((t=>new o(t.name,t.value))))}addTag(t,e){this.tags.push(new o(n.stringToB64Url(t),n.stringToB64Url(e)))}toJSON(){return{format:this.format,id:this.id,last_tx:this.last_tx,owner:this.owner,tags:this.tags,target:this.target,quantity:this.quantity,data:n.bufferTob64Url(this.data),data_size:this.data_size,data_root:this.data_root,data_tree:this.data_tree,reward:this.reward,signature:this.signature}}setOwner(t){this.owner=t}setSignature({id:t,owner:e,reward:r,tags:n,signature:a}){this.id=t,this.owner=e,r&&(this.reward=r),n&&(this.tags=n),this.signature=a}async prepareChunks(t){!this.chunks&&t.byteLength>0&&(this.chunks=await(0,s.generateTransactionChunks)(t),this.data_root=n.bufferTob64Url(this.chunks.data_root)),this.chunks||0!==t.byteLength||(this.chunks={chunks:[],data_root:new Uint8Array,proofs:[]},this.data_root="")}getChunk(t,e){if(!this.chunks)throw new Error("Chunks have not been prepared");const r=this.chunks.proofs[t],a=this.chunks.chunks[t];return{data_root:this.data_root,data_size:this.data_size,data_path:n.bufferTob64Url(r.proof),offset:r.offset.toString(),chunk:n.bufferTob64Url(e.slice(a.minByteRange,a.maxByteRange))}}async getSignatureData(){switch(this.format){case 1:let t=this.tags.reduce(((t,e)=>n.concatBuffers([t,e.get("name",{decode:!0,string:!1}),e.get("value",{decode:!0,string:!1})])),new Uint8Array);return n.concatBuffers([this.get("owner",{decode:!0,string:!1}),this.get("target",{decode:!0,string:!1}),this.get("data",{decode:!0,string:!1}),n.stringToBuffer(this.quantity),n.stringToBuffer(this.reward),this.get("last_tx",{decode:!0,string:!1}),t]);case 2:this.data_root||await this.prepareChunks(this.data);const e=this.tags.map((t=>[t.get("name",{decode:!0,string:!1}),t.get("value",{decode:!0,string:!1})]));return await(0,a.default)([n.stringToBuffer(this.format.toString()),this.get("owner",{decode:!0,string:!1}),this.get("target",{decode:!0,string:!1}),n.stringToBuffer(this.quantity),n.stringToBuffer(this.reward),this.get("last_tx",{decode:!0,string:!1}),e,n.stringToBuffer(this.data_size),this.get("data_root",{decode:!0,string:!1})]);default:throw new Error(`Unexpected transaction format: ${this.format}`)}}}},303:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.b64UrlDecode=e.b64UrlEncode=e.bufferTob64Url=e.bufferTob64=e.b64UrlToBuffer=e.stringToB64Url=e.stringToBuffer=e.bufferToString=e.b64UrlToString=e.concatBuffers=void 0;const n=r(742);function a(t){return new TextDecoder("utf-8",{fatal:!0}).decode(t)}function s(t){return(new TextEncoder).encode(t)}function i(t){return new Uint8Array(n.toByteArray(l(t)))}function o(t){return n.fromByteArray(new Uint8Array(t))}function c(t){return u(o(t))}function u(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}function l(t){let e;return e=(t=t.replace(/\-/g,"+").replace(/\_/g,"/")).length%4==0?0:4-t.length%4,t.concat("=".repeat(e))}e.concatBuffers=function(t){let e=0;for(let r=0;r<t.length;r++)e+=t[r].byteLength;let r=new Uint8Array(e),n=0;r.set(new Uint8Array(t[0]),n),n+=t[0].byteLength;for(let e=1;e<t.length;e++)r.set(new Uint8Array(t[e]),n),n+=t[e].byteLength;return r},e.b64UrlToString=function(t){return a(i(t))},e.bufferToString=a,e.stringToBuffer=s,e.stringToB64Url=function(t){return c(s(t))},e.b64UrlToBuffer=i,e.bufferTob64=o,e.bufferTob64Url=c,e.b64UrlEncode=u,e.b64UrlDecode=l},886:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=class{api;constructor(t){this.api=t}getInfo(){return this.api.get("info").then((t=>t.data))}getPeers(){return this.api.get("peers").then((t=>t.data))}}},470:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SiloResource=void 0;const n=r(303);e.default=class{api;crypto;transactions;constructor(t,e,r){this.api=t,this.crypto=e,this.transactions=r}async get(t){if(!t)throw new Error("No Silo URI specified");const e=await this.parseUri(t),r=await this.transactions.search("Silo-Name",e.getAccessKey());if(0==r.length)throw new Error(`No data could be found for the Silo URI: ${t}`);const n=await this.transactions.get(r[0]);if(!n)throw new Error(`No data could be found for the Silo URI: ${t}`);const a=n.get("data",{decode:!0,string:!1});return this.crypto.decrypt(a,e.getEncryptionKey())}async readTransactionData(t,e){if(!e)throw new Error("No Silo URI specified");const r=await this.parseUri(e),n=t.get("data",{decode:!0,string:!1});return this.crypto.decrypt(n,r.getEncryptionKey())}async parseUri(t){const e=t.match(/^([a-z0-9-_]+)\.([0-9]+)/i);if(!e)throw new Error("Invalid Silo name, must be a name in the format of [a-z0-9]+.[0-9]+, e.g. 'bubble.7'");const r=e[1],s=Math.pow(2,parseInt(e[2])),i=await this.hash(n.stringToBuffer(r),s),o=n.bufferTob64(i.slice(0,15)),c=await this.hash(i.slice(16,31),1);return new a(t,o,c)}async hash(t,e){let r=await this.crypto.hash(t);for(let t=0;t<e-1;t++)r=await this.crypto.hash(r);return r}};class a{uri;accessKey;encryptionKey;constructor(t,e,r){this.uri=t,this.accessKey=e,this.encryptionKey=r}getUri(){return this.uri}getAccessKey(){return this.accessKey}getEncryptionKey(){return this.encryptionKey}}e.SiloResource=a},198:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(941),a=r(993),s=r(303),i=r(481);r(317);e.default=class{api;crypto;chunks;constructor(t,e,r){this.api=t,this.crypto=e,this.chunks=r}getTransactionAnchor(){return this.api.get("tx_anchor").then((t=>t.data))}getPrice(t,e){let r=e?`price/${t}/${e}`:`price/${t}`;return this.api.get(r).then((t=>t.data))}async get(t){const e=await this.api.get(`tx/${t}`);if(200==e.status){const r=parseInt(e.data.data_size);if(e.data.format>=2&&r>0&&r<=12582912){const r=await this.getData(t);return new a.default({...e.data,data:r})}return new a.default({...e.data,format:e.data.format||1})}if(404==e.status)throw new n.default("TX_NOT_FOUND");if(410==e.status)throw new n.default("TX_FAILED");throw new n.default("TX_INVALID")}fromRaw(t){return new a.default(t)}async search(t,e){return this.api.post("arql",{op:"equals",expr1:t,expr2:e}).then((t=>t.data?t.data:[]))}getStatus(t){return this.api.get(`tx/${t}/status`).then((t=>200==t.status?{status:200,confirmed:t.data}:{status:t.status,confirmed:null}))}async getData(t,e){let r;try{r=await this.chunks.downloadChunkedData(t)}catch(e){console.error(`Error while trying to download chunked data for ${t}`),console.error(e)}if(!r){console.warn(`Falling back to gateway cache for ${t}`);try{r=(await this.api.get(`/${t}`)).data}catch(e){console.error(`Error while trying to download contiguous data from gateway cache for ${t}`),console.error(e)}}if(!r)throw new Error(`${t} was not found!`);return e&&e.decode&&!e.string?r:e&&e.decode&&e.string?s.bufferToString(r):s.bufferTob64Url(r)}async sign(t,e,r){if(!e&&"object"!=typeof arweaveWallet)throw new Error("A new Arweave transaction must provide the jwk parameter.");if(e&&"use_wallet"!==e){t.setOwner(e.n);let n=await t.getSignatureData(),a=await this.crypto.sign(e,n,r),i=await this.crypto.hash(a);t.setSignature({id:s.bufferTob64Url(i),owner:e.n,signature:s.bufferTob64Url(a)})}else{try{(await arweaveWallet.getPermissions()).includes("SIGN_TRANSACTION")||await arweaveWallet.connect(["SIGN_TRANSACTION"])}catch{}const e=await arweaveWallet.sign(t,r);t.setSignature({id:e.id,owner:e.owner,reward:e.reward,tags:e.tags,signature:e.signature})}}async verify(t){const e=await t.getSignatureData(),r=t.get("signature",{decode:!0,string:!1}),n=s.bufferTob64Url(await this.crypto.hash(r));if(t.id!==n)throw new Error("Invalid transaction signature or ID! The transaction ID doesn't match the expected SHA-256 hash of the signature.");return this.crypto.verify(t.owner,e,r)}async post(t){if("string"==typeof t?t=new a.default(JSON.parse(t)):"function"==typeof t.readInt32BE?t=new a.default(JSON.parse(t.toString())):"object"!=typeof t||t instanceof a.default||(t=new a.default(t)),!(t instanceof a.default))throw new Error("Must be Transaction object");t.chunks||await t.prepareChunks(t.data);const e=await this.getUploader(t,t.data);try{for(;!e.isComplete;)await e.uploadChunk()}catch(t){if(e.lastResponseStatus>0)return{status:e.lastResponseStatus,statusText:e.lastResponseError,data:{error:e.lastResponseError}};throw t}return{status:200,statusText:"OK",data:{}}}async getUploader(t,e){let r;if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),t instanceof a.default){if(e||(e=t.data),!(e instanceof Uint8Array))throw new Error("Data format is invalid");t.chunks||await t.prepareChunks(e),r=new i.TransactionUploader(this.api,t),r.data&&0!==r.data.length||(r.data=e)}else{if("string"==typeof t&&(t=await i.TransactionUploader.fromTransactionId(this.api,t)),!(e&&e instanceof Uint8Array))throw new Error("Must provide data when resuming upload");r=await i.TransactionUploader.fromSerialized(this.api,t,e)}return r}async*upload(t,e){const r=await this.getUploader(t,e);for(;!r.isComplete;)await r.uploadChunk(),yield r;return r}}},241:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(303);r(317);e.default=class{api;crypto;constructor(t,e){this.api=t,this.crypto=e}getBalance(t){return this.api.get(`wallet/${t}/balance`).then((t=>t.data))}getLastTransactionID(t){return this.api.get(`wallet/${t}/last_tx`).then((t=>t.data))}generate(){return this.crypto.generateJWK()}async jwkToAddress(t){return t&&"use_wallet"!==t?this.getAddress(t):this.getAddress()}async getAddress(t){if(t&&"use_wallet"!==t)return this.ownerToAddress(t.n);try{await arweaveWallet.connect(["ACCESS_ADDRESS"])}catch{}return arweaveWallet.getActiveAddress()}async ownerToAddress(t){return n.bufferTob64Url(await this.crypto.hash(n.b64UrlToBuffer(t)))}}}},e={};function r(n){var a=e[n];if(void 0!==a)return a.exports;var s=e[n]={exports:{}};return t[n].call(s.exports,s,s.exports,r),s.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};r(533)})(); |
@@ -5,2 +5,10 @@ "use strict"; | ||
class Ar { | ||
/** | ||
* Method to take a string value and return a bignumber object. | ||
* | ||
* @protected | ||
* @type {Function} | ||
* @memberof Arweave | ||
*/ | ||
BigNum; | ||
constructor() { | ||
@@ -7,0 +15,0 @@ // Configure and assign the constructor function for the bignumber library. |
@@ -9,2 +9,5 @@ "use strict"; | ||
class Blocks { | ||
api; | ||
network; | ||
static ENDPOINT = "block/hash/"; | ||
constructor(api, network) { | ||
@@ -40,3 +43,2 @@ this.api = api; | ||
exports.default = Blocks; | ||
Blocks.ENDPOINT = "block/hash/"; | ||
//# sourceMappingURL=blocks.js.map |
@@ -29,2 +29,3 @@ "use strict"; | ||
class Chunks { | ||
api; | ||
constructor(api) { | ||
@@ -31,0 +32,0 @@ this.api = api; |
@@ -41,2 +41,13 @@ "use strict"; | ||
class Arweave { | ||
api; | ||
wallets; | ||
transactions; | ||
network; | ||
blocks; | ||
ar; | ||
silo; | ||
chunks; | ||
static init; | ||
static crypto = new node_driver_1.default(); | ||
static utils = ArweaveUtils; | ||
constructor(apiConfig) { | ||
@@ -147,4 +158,2 @@ this.api = new api_1.default(apiConfig); | ||
exports.default = Arweave; | ||
Arweave.crypto = new node_driver_1.default(); | ||
Arweave.utils = ArweaveUtils; | ||
//# sourceMappingURL=common.js.map |
@@ -13,2 +13,5 @@ export interface ApiConfig { | ||
} | ||
export interface RequestInitWithAxios extends RequestInit { | ||
responseType?: "arraybuffer" | "json" | "text"; | ||
} | ||
export default class Api { | ||
@@ -22,5 +25,5 @@ readonly METHOD_GET = "GET"; | ||
private mergeDefaults; | ||
get<T = any>(endpoint: string, config?: RequestInit): Promise<ResponseWithData<T>>; | ||
post<T = any>(endpoint: string, body: any, config?: RequestInit): Promise<ResponseWithData<T>>; | ||
request<T = unknown>(endpoint: string, init?: RequestInit): Promise<ResponseWithData<T>>; | ||
get<T = any>(endpoint: string, config?: RequestInitWithAxios): Promise<ResponseWithData<T>>; | ||
post<T = any>(endpoint: string, body: any, config?: RequestInitWithAxios): Promise<ResponseWithData<T>>; | ||
request<T = unknown>(endpoint: string, init?: RequestInitWithAxios): Promise<ResponseWithData<T>>; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class Api { | ||
METHOD_GET = "GET"; | ||
METHOD_POST = "POST"; | ||
config; | ||
constructor(config) { | ||
this.METHOD_GET = "GET"; | ||
this.METHOD_POST = "POST"; | ||
this.applyConfig(config); | ||
@@ -47,2 +48,5 @@ } | ||
const baseURL = `${this.config.protocol}://${this.config.host}:${this.config.port}`; | ||
/* responseType is purely for backwards compatibility with external apps */ | ||
const responseType = init?.responseType; | ||
delete init?.responseType; | ||
if (endpoint.startsWith("/")) { | ||
@@ -66,13 +70,20 @@ endpoint = endpoint.slice(1); | ||
const response = res; | ||
if (contentType?.startsWith("application/json")) { | ||
response.data = (await res.clone().json()); | ||
if (responseType === "arraybuffer") { | ||
response.data = (await res.arrayBuffer()); | ||
} | ||
else { | ||
else if (responseType === "text") { | ||
response.data = (await res.text()); | ||
} | ||
else if (contentType?.startsWith("application/json")) { | ||
try { | ||
response.data = (await res.clone().text()); | ||
await res.clone().json(); //the test | ||
response.data = (await res.json()); | ||
} | ||
catch { | ||
response.data = (await res.clone().arrayBuffer()); | ||
response.data = (await res.text()); | ||
} | ||
} | ||
else { | ||
response.data = (await res.text()); | ||
} | ||
return response; | ||
@@ -79,0 +90,0 @@ } |
@@ -29,8 +29,6 @@ "use strict"; | ||
class NodeCryptoDriver { | ||
constructor() { | ||
this.keyLength = 4096; | ||
this.publicExponent = 0x10001; | ||
this.hashAlgorithm = "sha256"; | ||
this.encryptionAlgorithm = "aes-256-cbc"; | ||
} | ||
keyLength = 4096; | ||
publicExponent = 0x10001; | ||
hashAlgorithm = "sha256"; | ||
encryptionAlgorithm = "aes-256-cbc"; | ||
generateJWK() { | ||
@@ -37,0 +35,0 @@ if (typeof crypto.generateKeyPair != "function") { |
@@ -28,6 +28,7 @@ "use strict"; | ||
class WebCryptoDriver { | ||
keyLength = 4096; | ||
publicExponent = 0x10001; | ||
hashAlgorithm = "sha256"; | ||
driver; | ||
constructor() { | ||
this.keyLength = 4096; | ||
this.publicExponent = 0x10001; | ||
this.hashAlgorithm = "sha256"; | ||
if (!this.detectWebCrypto()) { | ||
@@ -34,0 +35,0 @@ throw new Error("SubtleCrypto not available!"); |
@@ -5,2 +5,4 @@ "use strict"; | ||
class ArweaveError extends Error { | ||
type; | ||
response; | ||
constructor(type, optional = {}) { | ||
@@ -7,0 +9,0 @@ if (optional.message) { |
@@ -55,2 +55,11 @@ "use strict"; | ||
class TransactionUploader { | ||
api; | ||
chunkIndex = 0; | ||
txPosted = false; | ||
transaction; | ||
lastRequestTimeEnd = 0; | ||
totalErrors = 0; // Not serialized. | ||
data; | ||
lastResponseStatus = 0; | ||
lastResponseError = ""; | ||
get isComplete() { | ||
@@ -71,8 +80,2 @@ return (this.txPosted && | ||
this.api = api; | ||
this.chunkIndex = 0; | ||
this.txPosted = false; | ||
this.lastRequestTimeEnd = 0; | ||
this.totalErrors = 0; // Not serialized. | ||
this.lastResponseStatus = 0; | ||
this.lastResponseError = ""; | ||
if (!transaction.id) { | ||
@@ -79,0 +82,0 @@ throw new Error(`Transaction is not signed`); |
@@ -60,2 +60,4 @@ "use strict"; | ||
class Tag extends BaseObject { | ||
name; | ||
value; | ||
constructor(name, value, decode = false) { | ||
@@ -69,16 +71,18 @@ super(); | ||
class Transaction extends BaseObject { | ||
format = 2; | ||
id = ""; | ||
last_tx = ""; | ||
owner = ""; | ||
tags = []; | ||
target = ""; | ||
quantity = "0"; | ||
data_size = "0"; | ||
data = new Uint8Array(); | ||
data_root = ""; | ||
reward = "0"; | ||
signature = ""; | ||
// Computed when needed. | ||
chunks; | ||
constructor(attributes = {}) { | ||
super(); | ||
this.format = 2; | ||
this.id = ""; | ||
this.last_tx = ""; | ||
this.owner = ""; | ||
this.tags = []; | ||
this.target = ""; | ||
this.quantity = "0"; | ||
this.data_size = "0"; | ||
this.data = new Uint8Array(); | ||
this.data_root = ""; | ||
this.reward = "0"; | ||
this.signature = ""; | ||
Object.assign(this, attributes); | ||
@@ -85,0 +89,0 @@ // If something passes in a Tx that has been toJSON'ed and back, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class Network { | ||
api; | ||
constructor(api) { | ||
@@ -5,0 +6,0 @@ this.api = api; |
@@ -29,2 +29,5 @@ "use strict"; | ||
class Silo { | ||
api; | ||
crypto; | ||
transactions; | ||
constructor(api, crypto, transactions) { | ||
@@ -81,2 +84,5 @@ this.api = api; | ||
class SiloResource { | ||
uri; | ||
accessKey; | ||
encryptionKey; | ||
constructor(uri, accessKey, encryptionKey) { | ||
@@ -83,0 +89,0 @@ this.uri = uri; |
@@ -36,2 +36,5 @@ "use strict"; | ||
class Transactions { | ||
api; | ||
crypto; | ||
chunks; | ||
constructor(api, crypto, chunks) { | ||
@@ -38,0 +41,0 @@ this.api = api; |
@@ -29,2 +29,4 @@ "use strict"; | ||
class Wallets { | ||
api; | ||
crypto; | ||
constructor(api, crypto) { | ||
@@ -31,0 +33,0 @@ this.api = api; |
{ | ||
"name": "arweave", | ||
"version": "1.12.4", | ||
"version": "1.12.6", | ||
"description": "Arweave JS client library", | ||
@@ -26,10 +26,20 @@ "main": "./node/index.js", | ||
"prepublishOnly": "npm run clean && npm run build", | ||
"test": "mocha -r ts-node/register -r tsconfig-paths/register test/*.ts && echo \"NOW RUN => 'npm run test:web' <= \" ", | ||
"test": "mocha test/*.ts && echo \"NOW RUN => 'npm run test:web' <= \" ", | ||
"test:web": "npm run bundle:web && webpack --config-name web-tests && opener test/web/web.html", | ||
"prettier:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\"", | ||
"prettier:write": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", | ||
"preversion": "npm run test", | ||
"version": "npm run prettier:write && git add -A src && git add -A test", | ||
"postversion": "git push && git push --tags" | ||
}, | ||
"mocha": { | ||
"extension": [ | ||
"ts" | ||
], | ||
"node-option": [ | ||
"require=ts-node/register", | ||
"require=tsconfig-paths/register", | ||
"experimental-fetch", | ||
"no-warnings" | ||
] | ||
}, | ||
"repository": { | ||
@@ -36,0 +46,0 @@ "type": "git", |
@@ -5,2 +5,10 @@ "use strict"; | ||
class Ar { | ||
/** | ||
* Method to take a string value and return a bignumber object. | ||
* | ||
* @protected | ||
* @type {Function} | ||
* @memberof Arweave | ||
*/ | ||
BigNum; | ||
constructor() { | ||
@@ -54,2 +62,1 @@ // Configure and assign the constructor function for the bignumber library. | ||
exports.default = Ar; | ||
//# sourceMappingURL=ar.js.map |
@@ -6,2 +6,5 @@ "use strict"; | ||
class Blocks { | ||
api; | ||
network; | ||
static ENDPOINT = "block/hash/"; | ||
constructor(api, network) { | ||
@@ -37,3 +40,1 @@ this.api = api; | ||
exports.default = Blocks; | ||
Blocks.ENDPOINT = "block/hash/"; | ||
//# sourceMappingURL=blocks.js.map |
@@ -6,2 +6,3 @@ "use strict"; | ||
class Chunks { | ||
api; | ||
constructor(api) { | ||
@@ -63,2 +64,1 @@ this.api = api; | ||
exports.default = Chunks; | ||
//# sourceMappingURL=chunks.js.map |
@@ -15,2 +15,13 @@ "use strict"; | ||
class Arweave { | ||
api; | ||
wallets; | ||
transactions; | ||
network; | ||
blocks; | ||
ar; | ||
silo; | ||
chunks; | ||
static init; | ||
static crypto = new node_driver_1.default(); | ||
static utils = ArweaveUtils; | ||
constructor(apiConfig) { | ||
@@ -121,4 +132,1 @@ this.api = new api_1.default(apiConfig); | ||
exports.default = Arweave; | ||
Arweave.crypto = new node_driver_1.default(); | ||
Arweave.utils = ArweaveUtils; | ||
//# sourceMappingURL=common.js.map |
@@ -55,5 +55,8 @@ "use strict"; | ||
const port = apiConfig.port || defaultConfig.port; | ||
return new common_1.default(Object.assign(Object.assign({}, apiConfig), { host, | ||
return new common_1.default({ | ||
...apiConfig, | ||
host, | ||
protocol, | ||
port })); | ||
port, | ||
}); | ||
}; | ||
@@ -68,2 +71,1 @@ if (typeof globalThis === "object") { | ||
exports.default = common_1.default; | ||
//# sourceMappingURL=index.js.map |
@@ -13,2 +13,5 @@ export interface ApiConfig { | ||
} | ||
export interface RequestInitWithAxios extends RequestInit { | ||
responseType?: "arraybuffer" | "json" | "text"; | ||
} | ||
export default class Api { | ||
@@ -22,5 +25,5 @@ readonly METHOD_GET = "GET"; | ||
private mergeDefaults; | ||
get<T = any>(endpoint: string, config?: RequestInit): Promise<ResponseWithData<T>>; | ||
post<T = any>(endpoint: string, body: any, config?: RequestInit): Promise<ResponseWithData<T>>; | ||
request<T = unknown>(endpoint: string, init?: RequestInit): Promise<ResponseWithData<T>>; | ||
get<T = any>(endpoint: string, config?: RequestInitWithAxios): Promise<ResponseWithData<T>>; | ||
post<T = any>(endpoint: string, body: any, config?: RequestInitWithAxios): Promise<ResponseWithData<T>>; | ||
request<T = unknown>(endpoint: string, init?: RequestInitWithAxios): Promise<ResponseWithData<T>>; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class Api { | ||
METHOD_GET = "GET"; | ||
METHOD_POST = "POST"; | ||
config; | ||
constructor(config) { | ||
this.METHOD_GET = "GET"; | ||
this.METHOD_POST = "POST"; | ||
this.applyConfig(config); | ||
@@ -29,16 +30,23 @@ } | ||
async get(endpoint, config) { | ||
return await this.request(endpoint, Object.assign(Object.assign({}, config), { method: this.METHOD_GET })); | ||
return await this.request(endpoint, { ...config, method: this.METHOD_GET }); | ||
} | ||
async post(endpoint, body, config) { | ||
var _a; | ||
const headers = new Headers((config === null || config === void 0 ? void 0 : config.headers) || {}); | ||
if (!((_a = headers.get("content-type")) === null || _a === void 0 ? void 0 : _a.includes("application/json"))) { | ||
const headers = new Headers(config?.headers || {}); | ||
if (!headers.get("content-type")?.includes("application/json")) { | ||
headers.append("content-type", "application/json"); | ||
} | ||
headers.append("accept", "application/json, text/plain, */*"); | ||
return await this.request(endpoint, Object.assign(Object.assign({}, config), { method: this.METHOD_POST, body: typeof body !== "string" ? JSON.stringify(body) : body, headers })); | ||
return await this.request(endpoint, { | ||
...config, | ||
method: this.METHOD_POST, | ||
body: typeof body !== "string" ? JSON.stringify(body) : body, | ||
headers, | ||
}); | ||
} | ||
async request(endpoint, init) { | ||
const headers = new Headers((init === null || init === void 0 ? void 0 : init.headers) || {}); | ||
const headers = new Headers(init?.headers || {}); | ||
const baseURL = `${this.config.protocol}://${this.config.host}:${this.config.port}`; | ||
/* responseType is purely for backwards compatibility with external apps */ | ||
const responseType = init?.responseType; | ||
delete init?.responseType; | ||
if (endpoint.startsWith("/")) { | ||
@@ -53,3 +61,6 @@ endpoint = endpoint.slice(1); | ||
} | ||
let res = await fetch(`${baseURL}/${endpoint}`, Object.assign(Object.assign({}, (init || {})), { headers })); | ||
let res = await fetch(`${baseURL}/${endpoint}`, { | ||
...(init || {}), | ||
headers, | ||
}); | ||
if (this.config.logging) { | ||
@@ -60,13 +71,20 @@ this.config.logger(`Response: ${res.url} - ${res.status}`); | ||
const response = res; | ||
if (contentType === null || contentType === void 0 ? void 0 : contentType.startsWith("application/json")) { | ||
response.data = (await res.clone().json()); | ||
if (responseType === "arraybuffer") { | ||
response.data = (await res.arrayBuffer()); | ||
} | ||
else { | ||
else if (responseType === "text") { | ||
response.data = (await res.text()); | ||
} | ||
else if (contentType?.startsWith("application/json")) { | ||
try { | ||
response.data = (await res.clone().text()); | ||
await res.clone().json(); //the test | ||
response.data = (await res.json()); | ||
} | ||
catch (_a) { | ||
response.data = (await res.clone().arrayBuffer()); | ||
catch { | ||
response.data = (await res.text()); | ||
} | ||
} | ||
else { | ||
response.data = (await res.text()); | ||
} | ||
return response; | ||
@@ -76,2 +94,1 @@ } | ||
exports.default = Api; | ||
//# sourceMappingURL=api.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=crypto-interface.js.map |
@@ -6,8 +6,6 @@ "use strict"; | ||
class NodeCryptoDriver { | ||
constructor() { | ||
this.keyLength = 4096; | ||
this.publicExponent = 0x10001; | ||
this.hashAlgorithm = "sha256"; | ||
this.encryptionAlgorithm = "aes-256-cbc"; | ||
} | ||
keyLength = 4096; | ||
publicExponent = 0x10001; | ||
hashAlgorithm = "sha256"; | ||
encryptionAlgorithm = "aes-256-cbc"; | ||
generateJWK() { | ||
@@ -135,2 +133,1 @@ if (typeof crypto.generateKeyPair != "function") { | ||
exports.default = NodeCryptoDriver; | ||
//# sourceMappingURL=node-driver.js.map |
@@ -150,2 +150,1 @@ "use strict"; | ||
exports.jwkTopem = jwkTopem; | ||
//# sourceMappingURL=pem.js.map |
@@ -5,6 +5,7 @@ "use strict"; | ||
class WebCryptoDriver { | ||
keyLength = 4096; | ||
publicExponent = 0x10001; | ||
hashAlgorithm = "sha256"; | ||
driver; | ||
constructor() { | ||
this.keyLength = 4096; | ||
this.publicExponent = 0x10001; | ||
this.hashAlgorithm = "sha256"; | ||
if (!this.detectWebCrypto()) { | ||
@@ -94,3 +95,3 @@ throw new Error("SubtleCrypto not available!"); | ||
} | ||
const subtle = crypto === null || crypto === void 0 ? void 0 : crypto.subtle; | ||
const subtle = crypto?.subtle; | ||
if (subtle === undefined) { | ||
@@ -162,2 +163,1 @@ return false; | ||
exports.default = WebCryptoDriver; | ||
//# sourceMappingURL=webcrypto-driver.js.map |
@@ -34,2 +34,1 @@ "use strict"; | ||
} | ||
//# sourceMappingURL=deepHash.js.map |
@@ -5,2 +5,4 @@ "use strict"; | ||
class ArweaveError extends Error { | ||
type; | ||
response; | ||
constructor(type, optional = {}) { | ||
@@ -44,2 +46,1 @@ if (optional.message) { | ||
exports.getError = getError; | ||
//# sourceMappingURL=error.js.map |
@@ -289,2 +289,1 @@ "use strict"; | ||
exports.debug = debug; | ||
//# sourceMappingURL=merkle.js.map |
@@ -29,2 +29,11 @@ "use strict"; | ||
class TransactionUploader { | ||
api; | ||
chunkIndex = 0; | ||
txPosted = false; | ||
transaction; | ||
lastRequestTimeEnd = 0; | ||
totalErrors = 0; // Not serialized. | ||
data; | ||
lastResponseStatus = 0; | ||
lastResponseError = ""; | ||
get isComplete() { | ||
@@ -45,8 +54,2 @@ return (this.txPosted && | ||
this.api = api; | ||
this.chunkIndex = 0; | ||
this.txPosted = false; | ||
this.lastRequestTimeEnd = 0; | ||
this.totalErrors = 0; // Not serialized. | ||
this.lastResponseStatus = 0; | ||
this.lastResponseError = ""; | ||
if (!transaction.id) { | ||
@@ -223,2 +226,1 @@ throw new Error(`Transaction is not signed`); | ||
exports.TransactionUploader = TransactionUploader; | ||
//# sourceMappingURL=transaction-uploader.js.map |
@@ -34,2 +34,4 @@ "use strict"; | ||
class Tag extends BaseObject { | ||
name; | ||
value; | ||
constructor(name, value, decode = false) { | ||
@@ -43,16 +45,18 @@ super(); | ||
class Transaction extends BaseObject { | ||
format = 2; | ||
id = ""; | ||
last_tx = ""; | ||
owner = ""; | ||
tags = []; | ||
target = ""; | ||
quantity = "0"; | ||
data_size = "0"; | ||
data = new Uint8Array(); | ||
data_root = ""; | ||
reward = "0"; | ||
signature = ""; | ||
// Computed when needed. | ||
chunks; | ||
constructor(attributes = {}) { | ||
super(); | ||
this.format = 2; | ||
this.id = ""; | ||
this.last_tx = ""; | ||
this.owner = ""; | ||
this.tags = []; | ||
this.target = ""; | ||
this.quantity = "0"; | ||
this.data_size = "0"; | ||
this.data = new Uint8Array(); | ||
this.data_root = ""; | ||
this.reward = "0"; | ||
this.signature = ""; | ||
Object.assign(this, attributes); | ||
@@ -183,2 +187,1 @@ // If something passes in a Tx that has been toJSON'ed and back, | ||
exports.default = Transaction; | ||
//# sourceMappingURL=transaction.js.map |
@@ -66,2 +66,1 @@ "use strict"; | ||
exports.b64UrlDecode = b64UrlDecode; | ||
//# sourceMappingURL=utils.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=wallet.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class Network { | ||
api; | ||
constructor(api) { | ||
@@ -19,2 +20,1 @@ this.api = api; | ||
exports.default = Network; | ||
//# sourceMappingURL=network.js.map |
@@ -6,2 +6,5 @@ "use strict"; | ||
class Silo { | ||
api; | ||
crypto; | ||
transactions; | ||
constructor(api, crypto, transactions) { | ||
@@ -58,2 +61,5 @@ this.api = api; | ||
class SiloResource { | ||
uri; | ||
accessKey; | ||
encryptionKey; | ||
constructor(uri, accessKey, encryptionKey) { | ||
@@ -75,2 +81,1 @@ this.uri = uri; | ||
exports.SiloResource = SiloResource; | ||
//# sourceMappingURL=silo.js.map |
"use strict"; | ||
/// <reference path="../modules.d.ts" /> | ||
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } | ||
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { | ||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); | ||
var g = generator.apply(thisArg, _arguments || []), i, q = []; | ||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; | ||
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } | ||
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } | ||
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } | ||
function fulfill(value) { resume("next", value); } | ||
function reject(value) { resume("throw", value); } | ||
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -22,2 +10,5 @@ const error_1 = require("./lib/error"); | ||
class Transactions { | ||
api; | ||
crypto; | ||
chunks; | ||
constructor(api, crypto, chunks) { | ||
@@ -56,5 +47,11 @@ this.api = api; | ||
const data = await this.getData(id); | ||
return new transaction_1.default(Object.assign(Object.assign({}, response.data), { data })); | ||
return new transaction_1.default({ | ||
...response.data, | ||
data, | ||
}); | ||
} | ||
return new transaction_1.default(Object.assign(Object.assign({}, response.data), { format: response.data.format || 1 })); | ||
return new transaction_1.default({ | ||
...response.data, | ||
format: response.data.format || 1, | ||
}); | ||
} | ||
@@ -141,3 +138,3 @@ if (response.status == 404) { | ||
} | ||
catch (_a) { | ||
catch { | ||
// Permission is already granted | ||
@@ -290,14 +287,11 @@ } | ||
*/ | ||
upload(upload, data) { | ||
return __asyncGenerator(this, arguments, function* upload_1() { | ||
const uploader = yield __await(this.getUploader(upload, data)); | ||
while (!uploader.isComplete) { | ||
yield __await(uploader.uploadChunk()); | ||
yield yield __await(uploader); | ||
} | ||
return yield __await(uploader); | ||
}); | ||
async *upload(upload, data) { | ||
const uploader = await this.getUploader(upload, data); | ||
while (!uploader.isComplete) { | ||
await uploader.uploadChunk(); | ||
yield uploader; | ||
} | ||
return uploader; | ||
} | ||
} | ||
exports.default = Transactions; | ||
//# sourceMappingURL=transactions.js.map |
@@ -6,2 +6,4 @@ "use strict"; | ||
class Wallets { | ||
api; | ||
crypto; | ||
constructor(api, crypto) { | ||
@@ -52,3 +54,3 @@ this.api = api; | ||
} | ||
catch (_a) { | ||
catch { | ||
// Permission is already granted | ||
@@ -68,2 +70,1 @@ } | ||
exports.default = Wallets; | ||
//# sourceMappingURL=wallets.js.map |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10469
807524
110