@fastnear/api 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/cryptoUtils.js +89 -0
- package/dist/cjs/cryptoUtils.js.map +7 -0
- package/dist/cjs/index.esm.js +1191 -0
- package/dist/cjs/index.esm.js.map +7 -0
- package/dist/cjs/index.js +1246 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/near.js +1191 -0
- package/dist/cjs/near.js.map +7 -0
- package/dist/cjs/transaction.js +360 -0
- package/dist/cjs/transaction.js.map +7 -0
- package/dist/cjs/utils.js +105 -0
- package/dist/cjs/utils.js.map +7 -0
- package/dist/esm/chunk-2SCAGR3F.js +68 -0
- package/dist/esm/chunk-2SCAGR3F.js.map +7 -0
- package/dist/esm/chunk-B2HMQPYI.js +814 -0
- package/dist/esm/chunk-B2HMQPYI.js.map +7 -0
- package/dist/esm/chunk-S5Q2EM2B.js +48 -0
- package/dist/esm/chunk-S5Q2EM2B.js.map +7 -0
- package/{src/transaction.js → dist/esm/chunk-YKPILPMX.js} +113 -99
- package/dist/esm/chunk-YKPILPMX.js.map +7 -0
- package/dist/esm/cryptoUtils.js +21 -0
- package/dist/esm/cryptoUtils.js.map +7 -0
- package/dist/esm/index.esm.js +13 -0
- package/dist/esm/index.esm.js.map +7 -0
- package/dist/esm/index.js +63 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/near.js +15 -0
- package/dist/esm/near.js.map +7 -0
- package/dist/esm/transaction.js +16 -0
- package/dist/esm/transaction.js.map +7 -0
- package/dist/esm/utils.js +24 -0
- package/dist/esm/utils.js.map +7 -0
- package/dist/umd/index.js +4199 -0
- package/dist/umd/index.js.map +7 -0
- package/package.json +33 -25
- package/README.md +0 -76
- package/dist/fastnear.cjs +0 -35
- package/dist/fastnear.ejs +0 -24
- package/dist/fastnear.js +0 -35
- package/src/crypto.js +0 -37
- package/src/index.esm.js +0 -3
- package/src/index.js +0 -8
- package/src/near.js +0 -566
- package/src/utils.js +0 -48
package/dist/fastnear.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
(()=>{var Xn=Object.create;var br=Object.defineProperty;var Jn=Object.getOwnPropertyDescriptor;var Qn=Object.getOwnPropertyNames;var ti=Object.getPrototypeOf,ei=Object.prototype.hasOwnProperty;var Be=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ri=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Qn(t))!ei.call(e,i)&&i!==r&&br(e,i,{get:()=>t[i],enumerable:!(n=Jn(t,i))||n.enumerable});return e};var ni=(e,t,r)=>(r=e!=null?Xn(ti(e)):{},ri(t||!e||!e.__esModule?br(r,"default",{value:e,enumerable:!0}):r,e));var Er=Be(Qt=>{"use strict";Qt.byteLength=oi;Qt.toByteArray=ci;Qt.fromByteArray=ai;var et=[],G=[],ii=typeof Uint8Array<"u"?Uint8Array:Array,Ee="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(bt=0,mr=Ee.length;bt<mr;++bt)et[bt]=Ee[bt],G[Ee.charCodeAt(bt)]=bt;var bt,mr;G[45]=62;G[95]=63;function Br(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function oi(e){var t=Br(e),r=t[0],n=t[1];return(r+n)*3/4-n}function si(e,t,r){return(t+r)*3/4-r}function ci(e){var t,r=Br(e),n=r[0],i=r[1],o=new ii(si(e,n,i)),s=0,c=i>0?n-4:n,f;for(f=0;f<c;f+=4)t=G[e.charCodeAt(f)]<<18|G[e.charCodeAt(f+1)]<<12|G[e.charCodeAt(f+2)]<<6|G[e.charCodeAt(f+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=G[e.charCodeAt(f)]<<2|G[e.charCodeAt(f+1)]>>4,o[s++]=t&255),i===1&&(t=G[e.charCodeAt(f)]<<10|G[e.charCodeAt(f+1)]<<4|G[e.charCodeAt(f+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function fi(e){return et[e>>18&63]+et[e>>12&63]+et[e>>6&63]+et[e&63]}function ui(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(fi(n));return i.join("")}function ai(e){for(var t,r=e.length,n=r%3,i=[],o=16383,s=0,c=r-n;s<c;s+=o)i.push(ui(e,s,s+o>c?c:s+o));return n===1?(t=e[r-1],i.push(et[t>>2]+et[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(et[t>>10]+et[t>>4&63]+et[t<<2&63]+"=")),i.join("")}});var _r=Be(_e=>{_e.read=function(e,t,r,n,i){var o,s,c=i*8-n-1,f=(1<<c)-1,u=f>>1,a=-7,l=r?i-1:0,d=r?-1:1,x=e[t+l];for(l+=d,o=x&(1<<-a)-1,x>>=-a,a+=c;a>0;o=o*256+e[t+l],l+=d,a-=8);for(s=o&(1<<-a)-1,o>>=-a,a+=n;a>0;s=s*256+e[t+l],l+=d,a-=8);if(o===0)o=1-u;else{if(o===f)return s?NaN:(x?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-u}return(x?-1:1)*s*Math.pow(2,o-n)};_e.write=function(e,t,r,n,i,o){var s,c,f,u=o*8-i-1,a=(1<<u)-1,l=a>>1,d=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=n?0:o-1,b=n?1:-1,g=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,s=a):(s=Math.floor(Math.log(t)/Math.LN2),t*(f=Math.pow(2,-s))<1&&(s--,f*=2),s+l>=1?t+=d/f:t+=d*Math.pow(2,1-l),t*f>=2&&(s++,f/=2),s+l>=a?(c=0,s=a):s+l>=1?(c=(t*f-1)*Math.pow(2,i),s=s+l):(c=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+x]=c&255,x+=b,c/=256,i-=8);for(s=s<<i|c,u+=i;u>0;e[r+x]=s&255,x+=b,s/=256,u-=8);e[r+x-b]|=g*128}});var Kr=Be(Mt=>{"use strict";var Ie=Er(),Ot=_r(),Ir=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Mt.Buffer=h;Mt.SlowBuffer=yi;Mt.INSPECT_MAX_BYTES=50;var te=2147483647;Mt.kMaxLength=te;h.TYPED_ARRAY_SUPPORT=li();!h.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function li(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(h.prototype,"parent",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.buffer}});Object.defineProperty(h.prototype,"offset",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.byteOffset}});function it(e){if(e>te)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,h.prototype),t}function h(e,t,r){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return ve(e)}return vr(e,t,r)}h.poolSize=8192;function vr(e,t,r){if(typeof e=="string")return pi(e,t);if(ArrayBuffer.isView(e))return di(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(rt(e,ArrayBuffer)||e&&rt(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(rt(e,SharedArrayBuffer)||e&&rt(e.buffer,SharedArrayBuffer)))return Se(e,t,r);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return h.from(n,t,r);let i=xi(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return h.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}h.from=function(e,t,r){return vr(e,t,r)};Object.setPrototypeOf(h.prototype,Uint8Array.prototype);Object.setPrototypeOf(h,Uint8Array);function Fr(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function hi(e,t,r){return Fr(e),e<=0?it(e):t!==void 0?typeof r=="string"?it(e).fill(t,r):it(e).fill(t):it(e)}h.alloc=function(e,t,r){return hi(e,t,r)};function ve(e){return Fr(e),it(e<0?0:Fe(e)|0)}h.allocUnsafe=function(e){return ve(e)};h.allocUnsafeSlow=function(e){return ve(e)};function pi(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!h.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=Tr(e,t)|0,n=it(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function Ae(e){let t=e.length<0?0:Fe(e.length)|0,r=it(t);for(let n=0;n<t;n+=1)r[n]=e[n]&255;return r}function di(e){if(rt(e,Uint8Array)){let t=new Uint8Array(e);return Se(t.buffer,t.byteOffset,t.byteLength)}return Ae(e)}function Se(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&r===void 0?n=new Uint8Array(e):r===void 0?n=new Uint8Array(e,t):n=new Uint8Array(e,t,r),Object.setPrototypeOf(n,h.prototype),n}function xi(e){if(h.isBuffer(e)){let t=Fe(e.length)|0,r=it(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||Le(e.length)?it(0):Ae(e);if(e.type==="Buffer"&&Array.isArray(e.data))return Ae(e.data)}function Fe(e){if(e>=te)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+te.toString(16)+" bytes");return e|0}function yi(e){return+e!=e&&(e=0),h.alloc(+e)}h.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==h.prototype};h.compare=function(t,r){if(rt(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),rt(r,Uint8Array)&&(r=h.from(r,r.offset,r.byteLength)),!h.isBuffer(t)||!h.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;let n=t.length,i=r.length;for(let o=0,s=Math.min(n,i);o<s;++o)if(t[o]!==r[o]){n=t[o],i=r[o];break}return n<i?-1:i<n?1:0};h.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};h.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return h.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;let i=h.allocUnsafe(r),o=0;for(n=0;n<t.length;++n){let s=t[n];if(rt(s,Uint8Array))o+s.length>i.length?(h.isBuffer(s)||(s=h.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(h.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function Tr(e,t){if(h.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||rt(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let r=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return Ue(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Pr(e).length;default:if(i)return n?-1:Ue(e).length;t=(""+t).toLowerCase(),i=!0}}h.byteLength=Tr;function gi(e,t,r){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return Ui(this,t,r);case"utf8":case"utf-8":return Cr(this,t,r);case"ascii":return Ai(this,t,r);case"latin1":case"binary":return Si(this,t,r);case"base64":return _i(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return vi(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}h.prototype._isBuffer=!0;function mt(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}h.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<t;r+=2)mt(this,r,r+1);return this};h.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<t;r+=4)mt(this,r,r+3),mt(this,r+1,r+2);return this};h.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<t;r+=8)mt(this,r,r+7),mt(this,r+1,r+6),mt(this,r+2,r+5),mt(this,r+3,r+4);return this};h.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?Cr(this,0,t):gi.apply(this,arguments)};h.prototype.toLocaleString=h.prototype.toString;h.prototype.equals=function(t){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:h.compare(this,t)===0};h.prototype.inspect=function(){let t="",r=Mt.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"};Ir&&(h.prototype[Ir]=h.prototype.inspect);h.prototype.compare=function(t,r,n,i,o){if(rt(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),r<0||n>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===t)return 0;let s=o-i,c=n-r,f=Math.min(s,c),u=this.slice(i,o),a=t.slice(r,n);for(let l=0;l<f;++l)if(u[l]!==a[l]){s=u[l],c=a[l];break}return s<c?-1:c<s?1:0};function Lr(e,t,r,n,i){if(e.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Le(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof t=="string"&&(t=h.from(t,n)),h.isBuffer(t))return t.length===0?-1:Ar(e,t,r,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Ar(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Ar(e,t,r,n,i){let o=1,s=e.length,c=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;o=2,s/=2,c/=2,r/=2}function f(a,l){return o===1?a[l]:a.readUInt16BE(l*o)}let u;if(i){let a=-1;for(u=r;u<s;u++)if(f(e,u)===f(t,a===-1?0:u-a)){if(a===-1&&(a=u),u-a+1===c)return a*o}else a!==-1&&(u-=u-a),a=-1}else for(r+c>s&&(r=s-c),u=r;u>=0;u--){let a=!0;for(let l=0;l<c;l++)if(f(e,u+l)!==f(t,l)){a=!1;break}if(a)return u}return-1}h.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1};h.prototype.indexOf=function(t,r,n){return Lr(this,t,r,n,!0)};h.prototype.lastIndexOf=function(t,r,n){return Lr(this,t,r,n,!1)};function wi(e,t,r,n){r=Number(r)||0;let i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let o=t.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let c=parseInt(t.substr(s*2,2),16);if(Le(c))return s;e[r+s]=c}return s}function bi(e,t,r,n){return ee(Ue(t,e.length-r),e,r,n)}function mi(e,t,r,n){return ee(Ci(t),e,r,n)}function Bi(e,t,r,n){return ee(Pr(t),e,r,n)}function Ei(e,t,r,n){return ee(Ri(t,e.length-r),e,r,n)}h.prototype.write=function(t,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-r;if((n===void 0||n>o)&&(n=o),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return wi(this,t,r,n);case"utf8":case"utf-8":return bi(this,t,r,n);case"ascii":case"latin1":case"binary":return mi(this,t,r,n);case"base64":return Bi(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ei(this,t,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function _i(e,t,r){return t===0&&r===e.length?Ie.fromByteArray(e):Ie.fromByteArray(e.slice(t,r))}function Cr(e,t,r){r=Math.min(e.length,r);let n=[],i=t;for(;i<r;){let o=e[i],s=null,c=o>239?4:o>223?3:o>191?2:1;if(i+c<=r){let f,u,a,l;switch(c){case 1:o<128&&(s=o);break;case 2:f=e[i+1],(f&192)===128&&(l=(o&31)<<6|f&63,l>127&&(s=l));break;case 3:f=e[i+1],u=e[i+2],(f&192)===128&&(u&192)===128&&(l=(o&15)<<12|(f&63)<<6|u&63,l>2047&&(l<55296||l>57343)&&(s=l));break;case 4:f=e[i+1],u=e[i+2],a=e[i+3],(f&192)===128&&(u&192)===128&&(a&192)===128&&(l=(o&15)<<18|(f&63)<<12|(u&63)<<6|a&63,l>65535&&l<1114112&&(s=l))}}s===null?(s=65533,c=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=c}return Ii(n)}var Sr=4096;function Ii(e){let t=e.length;if(t<=Sr)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Sr));return r}function Ai(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]&127);return n}function Si(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function Ui(e,t,r){let n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);let i="";for(let o=t;o<r;++o)i+=Ni[e[o]];return i}function vi(e,t,r){let n=e.slice(t,r),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}h.prototype.slice=function(t,r){let n=this.length;t=~~t,r=r===void 0?n:~~r,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<t&&(r=t);let i=this.subarray(t,r);return Object.setPrototypeOf(i,h.prototype),i};function M(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}h.prototype.readUintLE=h.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||M(t,r,this.length);let i=this[t],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[t+s]*o;return i};h.prototype.readUintBE=h.prototype.readUIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||M(t,r,this.length);let i=this[t+--r],o=1;for(;r>0&&(o*=256);)i+=this[t+--r]*o;return i};h.prototype.readUint8=h.prototype.readUInt8=function(t,r){return t=t>>>0,r||M(t,1,this.length),this[t]};h.prototype.readUint16LE=h.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||M(t,2,this.length),this[t]|this[t+1]<<8};h.prototype.readUint16BE=h.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||M(t,2,this.length),this[t]<<8|this[t+1]};h.prototype.readUint32LE=h.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||M(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};h.prototype.readUint32BE=h.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||M(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};h.prototype.readBigUInt64LE=lt(function(t){t=t>>>0,kt(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Wt(t,this.length-8);let i=r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,o=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});h.prototype.readBigUInt64BE=lt(function(t){t=t>>>0,kt(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Wt(t,this.length-8);let i=r*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],o=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});h.prototype.readIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||M(t,r,this.length);let i=this[t],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[t+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i};h.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||M(t,r,this.length);let i=r,o=1,s=this[t+--i];for(;i>0&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};h.prototype.readInt8=function(t,r){return t=t>>>0,r||M(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};h.prototype.readInt16LE=function(t,r){t=t>>>0,r||M(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};h.prototype.readInt16BE=function(t,r){t=t>>>0,r||M(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};h.prototype.readInt32LE=function(t,r){return t=t>>>0,r||M(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};h.prototype.readInt32BE=function(t,r){return t=t>>>0,r||M(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};h.prototype.readBigInt64LE=lt(function(t){t=t>>>0,kt(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Wt(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});h.prototype.readBigInt64BE=lt(function(t){t=t>>>0,kt(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Wt(t,this.length-8);let i=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)});h.prototype.readFloatLE=function(t,r){return t=t>>>0,r||M(t,4,this.length),Ot.read(this,t,!0,23,4)};h.prototype.readFloatBE=function(t,r){return t=t>>>0,r||M(t,4,this.length),Ot.read(this,t,!1,23,4)};h.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||M(t,8,this.length),Ot.read(this,t,!0,52,8)};h.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||M(t,8,this.length),Ot.read(this,t,!1,52,8)};function q(e,t,r,n,i,o){if(!h.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}h.prototype.writeUintLE=h.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;q(this,t,r,n,c,0)}let o=1,s=0;for(this[r]=t&255;++s<n&&(o*=256);)this[r+s]=t/o&255;return r+n};h.prototype.writeUintBE=h.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;q(this,t,r,n,c,0)}let o=n-1,s=1;for(this[r+o]=t&255;--o>=0&&(s*=256);)this[r+o]=t/s&255;return r+n};h.prototype.writeUint8=h.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||q(this,t,r,1,255,0),this[r]=t&255,r+1};h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||q(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||q(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||q(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4};h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||q(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};function Rr(e,t,r,n,i){Mr(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,r}function Nr(e,t,r,n,i){Mr(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r+7]=o,o=o>>8,e[r+6]=o,o=o>>8,e[r+5]=o,o=o>>8,e[r+4]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s=s>>8,e[r+2]=s,s=s>>8,e[r+1]=s,s=s>>8,e[r]=s,r+8}h.prototype.writeBigUInt64LE=lt(function(t,r=0){return Rr(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});h.prototype.writeBigUInt64BE=lt(function(t,r=0){return Nr(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});h.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let f=Math.pow(2,8*n-1);q(this,t,r,n,f-1,-f)}let o=0,s=1,c=0;for(this[r]=t&255;++o<n&&(s*=256);)t<0&&c===0&&this[r+o-1]!==0&&(c=1),this[r+o]=(t/s>>0)-c&255;return r+n};h.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let f=Math.pow(2,8*n-1);q(this,t,r,n,f-1,-f)}let o=n-1,s=1,c=0;for(this[r+o]=t&255;--o>=0&&(s*=256);)t<0&&c===0&&this[r+o+1]!==0&&(c=1),this[r+o]=(t/s>>0)-c&255;return r+n};h.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||q(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};h.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||q(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};h.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||q(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};h.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||q(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4};h.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||q(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};h.prototype.writeBigInt64LE=lt(function(t,r=0){return Rr(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});h.prototype.writeBigInt64BE=lt(function(t,r=0){return Nr(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Dr(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Or(e,t,r,n,i){return t=+t,r=r>>>0,i||Dr(e,t,r,4,34028234663852886e22,-34028234663852886e22),Ot.write(e,t,r,n,23,4),r+4}h.prototype.writeFloatLE=function(t,r,n){return Or(this,t,r,!0,n)};h.prototype.writeFloatBE=function(t,r,n){return Or(this,t,r,!1,n)};function kr(e,t,r,n,i){return t=+t,r=r>>>0,i||Dr(e,t,r,8,17976931348623157e292,-17976931348623157e292),Ot.write(e,t,r,n,52,8),r+8}h.prototype.writeDoubleLE=function(t,r,n){return kr(this,t,r,!0,n)};h.prototype.writeDoubleBE=function(t,r,n){return kr(this,t,r,!1,n)};h.prototype.copy=function(t,r,n,i){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r<i-n&&(i=t.length-r+n);let o=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),r),o};h.prototype.fill=function(t,r,n,i){if(typeof t=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!h.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let s=t.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(t=s)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let o;if(typeof t=="number")for(o=r;o<n;++o)this[o]=t;else{let s=h.isBuffer(t)?t:h.from(t,i),c=s.length;if(c===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-r;++o)this[o+r]=s[o%c]}return this};var Dt={};function Te(e,t,r){Dt[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}Te("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Te("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError);Te("ERR_OUT_OF_RANGE",function(e,t,r){let n=`The value of "${e}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=Ur(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=Ur(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function Ur(e){let t="",r=e.length,n=e[0]==="-"?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function Fi(e,t,r){kt(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&Wt(t,e.length-(r+1))}function Mr(e,t,r,n,i,o){if(e>r||e<t){let s=typeof t=="bigint"?"n":"",c;throw o>3?t===0||t===BigInt(0)?c=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:c=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:c=`>= ${t}${s} and <= ${r}${s}`,new Dt.ERR_OUT_OF_RANGE("value",c,e)}Fi(n,i,o)}function kt(e,t){if(typeof e!="number")throw new Dt.ERR_INVALID_ARG_TYPE(t,"number",e)}function Wt(e,t,r){throw Math.floor(e)!==e?(kt(e,r),new Dt.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new Dt.ERR_BUFFER_OUT_OF_BOUNDS:new Dt.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var Ti=/[^+/0-9A-Za-z-_]/g;function Li(e){if(e=e.split("=")[0],e=e.trim().replace(Ti,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function Ue(e,t){t=t||1/0;let r,n=e.length,i=null,o=[];for(let s=0;s<n;++s){if(r=e.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function Ci(e){let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function Ri(e,t){let r,n,i,o=[];for(let s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function Pr(e){return Ie.toByteArray(Li(e))}function ee(e,t,r,n){let i;for(i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function rt(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Le(e){return e!==e}var Ni=function(){let e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t}();function lt(e){return typeof BigInt>"u"?Di:e}function Di(){throw new Error("BigInt not supported")}});var qn=ni(Kr(),1);var Oi=20,ki=1,Bt=1e6,Hr=1e6,Mi=-7,Pi=21,Ki=!1,Zt="[big.js] ",Et=Zt+"Invalid ",re=Et+"decimal places",Hi=Et+"rounding mode",qr=Zt+"Division by zero",S={},nt=void 0,qi=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function jr(){function e(t){var r=this;if(!(r instanceof e))return t===nt?jr():new e(t);if(t instanceof e)r.s=t.s,r.e=t.e,r.c=t.c.slice();else{if(typeof t!="string"){if(e.strict===!0&&typeof t!="bigint")throw TypeError(Et+"value");t=t===0&&1/t<0?"-0":String(t)}ji(r,t)}r.constructor=e}return e.prototype=S,e.DP=Oi,e.RM=ki,e.NE=Mi,e.PE=Pi,e.strict=Ki,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}function ji(e,t){var r,n,i;if(!qi.test(t))throw Error(Et+"number");for(e.s=t.charAt(0)=="-"?(t=t.slice(1),-1):1,(r=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),i=t.length,n=0;n<i&&t.charAt(n)=="0";)++n;if(n==i)e.c=[e.e=0];else{for(;i>0&&t.charAt(--i)=="0";);for(e.e=r-n-1,e.c=[],r=0;n<=i;)e.c[r++]=+t.charAt(n++)}return e}function _t(e,t,r,n){var i=e.c;if(r===nt&&(r=e.constructor.RM),r!==0&&r!==1&&r!==2&&r!==3)throw Error(Hi);if(t<1)n=r===3&&(n||!!i[0])||t===0&&(r===1&&i[0]>=5||r===2&&(i[0]>5||i[0]===5&&(n||i[1]!==nt))),i.length=1,n?(e.e=e.e-t+1,i[0]=1):i[0]=e.e=0;else if(t<i.length){if(n=r===1&&i[t]>=5||r===2&&(i[t]>5||i[t]===5&&(n||i[t+1]!==nt||i[t-1]&1))||r===3&&(n||!!i[0]),i.length=t,n){for(;++i[--t]>9;)if(i[t]=0,t===0){++e.e,i.unshift(1);break}}for(t=i.length;!i[--t];)i.pop()}return e}function It(e,t,r){var n=e.e,i=e.c.join(""),o=i.length;if(t)i=i.charAt(0)+(o>1?"."+i.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)i="0"+i;i="0."+i}else if(n>0)if(++n>o)for(n-=o;n--;)i+="0";else n<o&&(i=i.slice(0,n)+"."+i.slice(n));else o>1&&(i=i.charAt(0)+"."+i.slice(1));return e.s<0&&r?"-"+i:i}S.abs=function(){var e=new this.constructor(this);return e.s=1,e};S.cmp=function(e){var t,r=this,n=r.c,i=(e=new r.constructor(e)).c,o=r.s,s=e.s,c=r.e,f=e.e;if(!n[0]||!i[0])return n[0]?o:i[0]?-s:0;if(o!=s)return o;if(t=o<0,c!=f)return c>f^t?1:-1;for(s=(c=n.length)<(f=i.length)?c:f,o=-1;++o<s;)if(n[o]!=i[o])return n[o]>i[o]^t?1:-1;return c==f?0:c>f^t?1:-1};S.div=function(e){var t=this,r=t.constructor,n=t.c,i=(e=new r(e)).c,o=t.s==e.s?1:-1,s=r.DP;if(s!==~~s||s<0||s>Bt)throw Error(re);if(!i[0])throw Error(qr);if(!n[0])return e.s=o,e.c=[e.e=0],e;var c,f,u,a,l,d=i.slice(),x=c=i.length,b=n.length,g=n.slice(0,c),_=g.length,D=e,v=D.c=[],y=0,O=s+(D.e=t.e-e.e)+1;for(D.s=o,o=O<0?0:O,d.unshift(0);_++<c;)g.push(0);do{for(u=0;u<10;u++){if(c!=(_=g.length))a=c>_?1:-1;else for(l=-1,a=0;++l<c;)if(i[l]!=g[l]){a=i[l]>g[l]?1:-1;break}if(a<0){for(f=_==c?i:d;_;){if(g[--_]<f[_]){for(l=_;l&&!g[--l];)g[l]=9;--g[l],g[_]+=10}g[_]-=f[_]}for(;!g[0];)g.shift()}else break}v[y++]=a?u:++u,g[0]&&a?g[_]=n[x]||0:g=[n[x]]}while((x++<b||g[0]!==nt)&&o--);return!v[0]&&y!=1&&(v.shift(),D.e--,O--),y>O&&_t(D,O,r.RM,g[0]!==nt),D};S.eq=function(e){return this.cmp(e)===0};S.gt=function(e){return this.cmp(e)>0};S.gte=function(e){return this.cmp(e)>-1};S.lt=function(e){return this.cmp(e)<0};S.lte=function(e){return this.cmp(e)<1};S.minus=S.sub=function(e){var t,r,n,i,o=this,s=o.constructor,c=o.s,f=(e=new s(e)).s;if(c!=f)return e.s=-f,o.plus(e);var u=o.c.slice(),a=o.e,l=e.c,d=e.e;if(!u[0]||!l[0])return l[0]?e.s=-f:u[0]?e=new s(o):e.s=1,e;if(c=a-d){for((i=c<0)?(c=-c,n=u):(d=a,n=l),n.reverse(),f=c;f--;)n.push(0);n.reverse()}else for(r=((i=u.length<l.length)?u:l).length,c=f=0;f<r;f++)if(u[f]!=l[f]){i=u[f]<l[f];break}if(i&&(n=u,u=l,l=n,e.s=-e.s),(f=(r=l.length)-(t=u.length))>0)for(;f--;)u[t++]=0;for(f=t;r>c;){if(u[--r]<l[r]){for(t=r;t&&!u[--t];)u[t]=9;--u[t],u[r]+=10}u[r]-=l[r]}for(;u[--f]===0;)u.pop();for(;u[0]===0;)u.shift(),--d;return u[0]||(e.s=1,u=[d=0]),e.c=u,e.e=d,e};S.mod=function(e){var t,r=this,n=r.constructor,i=r.s,o=(e=new n(e)).s;if(!e.c[0])throw Error(qr);return r.s=e.s=1,t=e.cmp(r)==1,r.s=i,e.s=o,t?new n(r):(i=n.DP,o=n.RM,n.DP=n.RM=0,r=r.div(e),n.DP=i,n.RM=o,this.minus(r.times(e)))};S.neg=function(){var e=new this.constructor(this);return e.s=-e.s,e};S.plus=S.add=function(e){var t,r,n,i=this,o=i.constructor;if(e=new o(e),i.s!=e.s)return e.s=-e.s,i.minus(e);var s=i.e,c=i.c,f=e.e,u=e.c;if(!c[0]||!u[0])return u[0]||(c[0]?e=new o(i):e.s=i.s),e;if(c=c.slice(),t=s-f){for(t>0?(f=s,n=u):(t=-t,n=c),n.reverse();t--;)n.push(0);n.reverse()}for(c.length-u.length<0&&(n=u,u=c,c=n),t=u.length,r=0;t;c[t]%=10)r=(c[--t]=c[t]+u[t]+r)/10|0;for(r&&(c.unshift(r),++f),t=c.length;c[--t]===0;)c.pop();return e.c=c,e.e=f,e};S.pow=function(e){var t=this,r=new t.constructor("1"),n=r,i=e<0;if(e!==~~e||e<-Hr||e>Hr)throw Error(Et+"exponent");for(i&&(e=-e);e&1&&(n=n.times(t)),e>>=1,!!e;)t=t.times(t);return i?r.div(n):n};S.prec=function(e,t){if(e!==~~e||e<1||e>Bt)throw Error(Et+"precision");return _t(new this.constructor(this),e,t)};S.round=function(e,t){if(e===nt)e=0;else if(e!==~~e||e<-Bt||e>Bt)throw Error(re);return _t(new this.constructor(this),e+this.e+1,t)};S.sqrt=function(){var e,t,r,n=this,i=n.constructor,o=n.s,s=n.e,c=new i("0.5");if(!n.c[0])return new i(n);if(o<0)throw Error(Zt+"No square root");o=Math.sqrt(+It(n,!0,!0)),o===0||o===1/0?(t=n.c.join(""),t.length+s&1||(t+="0"),o=Math.sqrt(t),s=((s+1)/2|0)-(s<0||s&1),e=new i((o==1/0?"5e":(o=o.toExponential()).slice(0,o.indexOf("e")+1))+s)):e=new i(o+""),s=e.e+(i.DP+=4);do r=e,e=c.times(r.plus(n.div(r)));while(r.c.slice(0,s).join("")!==e.c.slice(0,s).join(""));return _t(e,(i.DP-=4)+e.e+1,i.RM)};S.times=S.mul=function(e){var t,r=this,n=r.constructor,i=r.c,o=(e=new n(e)).c,s=i.length,c=o.length,f=r.e,u=e.e;if(e.s=r.s==e.s?1:-1,!i[0]||!o[0])return e.c=[e.e=0],e;for(e.e=f+u,s<c&&(t=i,i=o,o=t,u=s,s=c,c=u),t=new Array(u=s+c);u--;)t[u]=0;for(f=c;f--;){for(c=0,u=s+f;u>f;)c=t[u]+o[f]*i[u-f-1]+c,t[u--]=c%10,c=c/10|0;t[u]=c}for(c?++e.e:t.shift(),f=t.length;!t[--f];)t.pop();return e.c=t,e};S.toExponential=function(e,t){var r=this,n=r.c[0];if(e!==nt){if(e!==~~e||e<0||e>Bt)throw Error(re);for(r=_t(new r.constructor(r),++e,t);r.c.length<e;)r.c.push(0)}return It(r,!0,!!n)};S.toFixed=function(e,t){var r=this,n=r.c[0];if(e!==nt){if(e!==~~e||e<0||e>Bt)throw Error(re);for(r=_t(new r.constructor(r),e+r.e+1,t),e=e+r.e+1;r.c.length<e;)r.c.push(0)}return It(r,!1,!!n)};S[Symbol.for("nodejs.util.inspect.custom")]=S.toJSON=S.toString=function(){var e=this,t=e.constructor;return It(e,e.e<=t.NE||e.e>=t.PE,!!e.c[0])};S.toNumber=function(){var e=+It(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(e.toString()))throw Error(Zt+"Imprecise conversion");return e};S.toPrecision=function(e,t){var r=this,n=r.constructor,i=r.c[0];if(e!==nt){if(e!==~~e||e<1||e>Bt)throw Error(Et+"precision");for(r=_t(new n(r),e,t);r.c.length<e;)r.c.push(0)}return It(r,e<=r.e||r.e<=n.NE||r.e>=n.PE,!!i)};S.valueOf=function(){var e=this,t=e.constructor;if(t.strict===!0)throw Error(Zt+"valueOf disallowed");return It(e,e.e<=t.NE||e.e>=t.PE,!0)};var zi=jr(),W=zi;var zr=class Vr{#t=null;#r;#i;#n=new Map;#e={};#o;#s;static defaultWidgetUrl="https://wallet-adapter.fastnear.com";constructor({widgetUrl:t=Vr.defaultWidgetUrl,targetOrigin:r="*",onStateUpdate:n,callbackUrl:i=window.location.href}={}){this.#r=r,this.#i=t,this.#o=n,this.#s=i,window.addEventListener("message",this.#c.bind(this))}#u(t){this.#t&&this.#t.remove();let r=new URL(t,this.#i),n=document.createElement("iframe");return n.src=r.toString(),n.allow="usb",n.style.border="none",n.style.zIndex="10000",n.style.position="fixed",n.style.display="block",n.style.top="0",n.style.left="0",n.style.width="100%",n.style.height="100%",document.body.appendChild(n),this.#t=n,n}#c(t){if(this.#r!=="*"&&t.origin!==this.#r)return;let{id:r,type:n,action:i,payload:o}=t.data;if(n!=="wallet-adapter")return;if(i==="close"){this.#t?.remove(),this.#t=null;return}o?.state&&(this.#e={...this.#e,...o.state},this.#o?.(this.#e));let s=this.#n.get(r);s&&(this.#n.delete(r),this.#t?.remove(),this.#t=null,s(o))}async#f(t,r,n){return new Promise(i=>{let o=Math.random().toString(36).slice(2);this.#n.set(o,i);let s=this.#u(t);s.onload=()=>{s.contentWindow?.postMessage({type:"wallet-adapter",method:r,params:{id:o,...n,state:this.#e,callbackUrl:n.callbackUrl||this.#s}},this.#r)}})}getState(){return{...this.#e}}async signIn(t){return this.#f("/login.html","signIn",t)}async sendTransaction(t){return this.#f("/sign.html","sendTransaction",t)}destroy(){window.removeEventListener("message",this.#c),this.#t?.remove(),this.#t=null}};function Vi(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ce(e,...t){if(!Vi(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Re(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Gr(e,t){Ce(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}var At=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var ie=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);function Wr(e){if(typeof e!="string")throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}function Ne(e){return typeof e=="string"&&(e=Wr(e)),Ce(e),e}var ne=class{clone(){return this._cloneInto()}};function Zr(e){let t=n=>e().update(Ne(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function $r(e=32){if(At&&typeof At.getRandomValues=="function")return At.getRandomValues(new Uint8Array(e));if(At&&typeof At.randomBytes=="function")return At.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}function Gi(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),c=Number(r&o),f=n?4:0,u=n?0:4;e.setUint32(t+f,s,n),e.setUint32(t+u,c,n)}var oe=class extends ne{constructor(t,r,n,i){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=ie(this.buffer)}update(t){Re(this);let{view:r,buffer:n,blockLen:i}=this;t=Ne(t);let o=t.length;for(let s=0;s<o;){let c=Math.min(i-this.pos,o-s);if(c===i){let f=ie(t);for(;i<=o-s;s+=i)this.process(f,s);continue}n.set(t.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Re(this),Gr(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let l=s;l<i;l++)r[l]=0;Gi(n,i-8,BigInt(this.length*8),o),this.process(n,0);let c=ie(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=f/4,a=this.get();if(u>a.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)c.setUint32(4*l,a[l],o)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:c}=this;return t.length=i,t.pos=c,t.finished=o,t.destroyed=s,i%r&&t.buffer.set(n),t}};var se=BigInt(4294967295),De=BigInt(32);function Yr(e,t=!1){return t?{h:Number(e&se),l:Number(e>>De&se)}:{h:Number(e>>De&se)|0,l:Number(e&se)|0}}function Wi(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let i=0;i<e.length;i++){let{h:o,l:s}=Yr(e[i],t);[r[i],n[i]]=[o,s]}return[r,n]}var Zi=(e,t)=>BigInt(e>>>0)<<De|BigInt(t>>>0),$i=(e,t,r)=>e>>>r,Yi=(e,t,r)=>e<<32-r|t>>>r,Xi=(e,t,r)=>e>>>r|t<<32-r,Ji=(e,t,r)=>e<<32-r|t>>>r,Qi=(e,t,r)=>e<<64-r|t>>>r-32,to=(e,t,r)=>e>>>r-32|t<<64-r,eo=(e,t)=>t,ro=(e,t)=>e,no=(e,t,r)=>e<<r|t>>>32-r,io=(e,t,r)=>t<<r|e>>>32-r,oo=(e,t,r)=>t<<r-32|e>>>64-r,so=(e,t,r)=>e<<r-32|t>>>64-r;function co(e,t,r,n){let i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:i|0}}var fo=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),uo=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,ao=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),lo=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0,ho=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0),po=(e,t,r,n,i,o)=>t+r+n+i+o+(e/2**32|0)|0;var xo={fromBig:Yr,split:Wi,toBig:Zi,shrSH:$i,shrSL:Yi,rotrSH:Xi,rotrSL:Ji,rotrBH:Qi,rotrBL:to,rotr32H:eo,rotr32L:ro,rotlSH:no,rotlSL:io,rotlBH:oo,rotlBL:so,add:co,add3L:fo,add3H:uo,add4L:ao,add4H:lo,add5H:po,add5L:ho},E=xo;var[yo,go]=E.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),ht=new Uint32Array(80),pt=new Uint32Array(80),Oe=class extends oe{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:r,Bh:n,Bl:i,Ch:o,Cl:s,Dh:c,Dl:f,Eh:u,El:a,Fh:l,Fl:d,Gh:x,Gl:b,Hh:g,Hl:_}=this;return[t,r,n,i,o,s,c,f,u,a,l,d,x,b,g,_]}set(t,r,n,i,o,s,c,f,u,a,l,d,x,b,g,_){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=o|0,this.Cl=s|0,this.Dh=c|0,this.Dl=f|0,this.Eh=u|0,this.El=a|0,this.Fh=l|0,this.Fl=d|0,this.Gh=x|0,this.Gl=b|0,this.Hh=g|0,this.Hl=_|0}process(t,r){for(let y=0;y<16;y++,r+=4)ht[y]=t.getUint32(r),pt[y]=t.getUint32(r+=4);for(let y=16;y<80;y++){let O=ht[y-15]|0,J=pt[y-15]|0,ut=E.rotrSH(O,J,1)^E.rotrSH(O,J,8)^E.shrSH(O,J,7),Ct=E.rotrSL(O,J,1)^E.rotrSL(O,J,8)^E.shrSL(O,J,7),z=ht[y-2]|0,K=pt[y-2]|0,Rt=E.rotrSH(z,K,19)^E.rotrBH(z,K,61)^E.shrSH(z,K,6),gt=E.rotrSL(z,K,19)^E.rotrBL(z,K,61)^E.shrSL(z,K,6),Nt=E.add4L(Ct,gt,pt[y-7],pt[y-16]),Gt=E.add4H(Nt,ut,Rt,ht[y-7],ht[y-16]);ht[y]=Gt|0,pt[y]=Nt|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:c,Cl:f,Dh:u,Dl:a,Eh:l,El:d,Fh:x,Fl:b,Gh:g,Gl:_,Hh:D,Hl:v}=this;for(let y=0;y<80;y++){let O=E.rotrSH(l,d,14)^E.rotrSH(l,d,18)^E.rotrBH(l,d,41),J=E.rotrSL(l,d,14)^E.rotrSL(l,d,18)^E.rotrBL(l,d,41),ut=l&x^~l&g,Ct=d&b^~d&_,z=E.add5L(v,J,Ct,go[y],pt[y]),K=E.add5H(z,D,O,ut,yo[y],ht[y]),Rt=z|0,gt=E.rotrSH(n,i,28)^E.rotrBH(n,i,34)^E.rotrBH(n,i,39),Nt=E.rotrSL(n,i,28)^E.rotrBL(n,i,34)^E.rotrBL(n,i,39),Gt=n&o^n&c^o&c,we=i&s^i&f^s&f;D=g|0,v=_|0,g=x|0,_=b|0,x=l|0,b=d|0,{h:l,l:d}=E.add(u|0,a|0,K|0,Rt|0),u=c|0,a=f|0,c=o|0,f=s|0,o=n|0,s=i|0;let be=E.add3L(Rt,Nt,we);n=E.add3H(be,K,gt,Gt),i=be|0}({h:n,l:i}=E.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=E.add(this.Bh|0,this.Bl|0,o|0,s|0),{h:c,l:f}=E.add(this.Ch|0,this.Cl|0,c|0,f|0),{h:u,l:a}=E.add(this.Dh|0,this.Dl|0,u|0,a|0),{h:l,l:d}=E.add(this.Eh|0,this.El|0,l|0,d|0),{h:x,l:b}=E.add(this.Fh|0,this.Fl|0,x|0,b|0),{h:g,l:_}=E.add(this.Gh|0,this.Gl|0,g|0,_|0),{h:D,l:v}=E.add(this.Hh|0,this.Hl|0,D|0,v|0),this.set(n,i,o,s,c,f,u,a,l,d,x,b,g,_,D,v)}roundClean(){ht.fill(0),pt.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var Xr=Zr(()=>new Oe);var Me=BigInt(0),Qr=BigInt(1),wo=BigInt(2);function Pe(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ke(e){if(!Pe(e))throw new Error("Uint8Array expected")}function ce(e,t){if(typeof t!="boolean")throw new Error(e+" boolean expected, got "+t)}var bo=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function fe(e){Ke(e);let t="";for(let r=0;r<e.length;r++)t+=bo[e[r]];return t}function tn(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?Me:BigInt("0x"+e)}var ot={_0:48,_9:57,A:65,F:70,a:97,f:102};function Jr(e){if(e>=ot._0&&e<=ot._9)return e-ot._0;if(e>=ot.A&&e<=ot.F)return e-(ot.A-10);if(e>=ot.a&&e<=ot.f)return e-(ot.a-10)}function en(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);let t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let i=0,o=0;i<r;i++,o+=2){let s=Jr(e.charCodeAt(o)),c=Jr(e.charCodeAt(o+1));if(s===void 0||c===void 0){let f=e[o]+e[o+1];throw new Error('hex string expected, got non-hex character "'+f+'" at index '+o)}n[i]=s*16+c}return n}function rn(e){return tn(fe(e))}function Pt(e){return Ke(e),tn(fe(Uint8Array.from(e).reverse()))}function He(e,t){return en(e.toString(16).padStart(t*2,"0"))}function $t(e,t){return He(e,t).reverse()}function Z(e,t,r){let n;if(typeof t=="string")try{n=en(t)}catch(o){throw new Error(e+" must be hex string or Uint8Array, cause: "+o)}else if(Pe(t))n=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(e+" of length "+r+" expected, got "+i);return n}function qe(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];Ke(i),t+=i.length}let r=new Uint8Array(t);for(let n=0,i=0;n<e.length;n++){let o=e[n];r.set(o,i),i+=o.length}return r}var ke=e=>typeof e=="bigint"&&Me<=e;function mo(e,t,r){return ke(e)&&ke(t)&&ke(r)&&t<=e&&e<r}function Kt(e,t,r,n){if(!mo(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function nn(e){let t;for(t=0;e>Me;e>>=Qr,t+=1);return t}var on=e=>(wo<<BigInt(e-1))-Qr;var Bo={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",stringOrUint8Array:e=>typeof e=="string"||Pe(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function Ht(e,t,r={}){let n=(i,o,s)=>{let c=Bo[o];if(typeof c!="function")throw new Error("invalid validator function");let f=e[i];if(!(s&&f===void 0)&&!c(f,e))throw new Error("param "+String(i)+" is invalid. Expected "+o+", got "+f)};for(let[i,o]of Object.entries(t))n(i,o,!1);for(let[i,o]of Object.entries(r))n(i,o,!0);return e}function je(e){let t=new WeakMap;return(r,...n)=>{let i=t.get(r);if(i!==void 0)return i;let o=e(r,...n);return t.set(r,o),o}}var k=BigInt(0),C=BigInt(1),St=BigInt(2),_o=BigInt(3),ze=BigInt(4),sn=BigInt(5),cn=BigInt(8),Io=BigInt(9),Ao=BigInt(16);function R(e,t){let r=e%t;return r>=k?r:t+r}function So(e,t,r){if(t<k)throw new Error("invalid exponent, negatives unsupported");if(r<=k)throw new Error("invalid modulus");if(r===C)return k;let n=C;for(;t>k;)t&C&&(n=n*e%r),e=e*e%r,t>>=C;return n}function $(e,t,r){let n=e;for(;t-- >k;)n*=n,n%=r;return n}function fn(e,t){if(e===k)throw new Error("invert: expected non-zero number");if(t<=k)throw new Error("invert: expected positive modulus, got "+t);let r=R(e,t),n=t,i=k,o=C,s=C,c=k;for(;r!==k;){let u=n/r,a=n%r,l=i-s*u,d=o-c*u;n=r,r=a,i=s,o=c,s=l,c=d}if(n!==C)throw new Error("invert: does not exist");return R(i,t)}function Uo(e){let t=(e-C)/St,r,n,i;for(r=e-C,n=0;r%St===k;r/=St,n++);for(i=St;i<e&&So(i,t,e)!==e-C;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let s=(e+C)/ze;return function(f,u){let a=f.pow(u,s);if(!f.eql(f.sqr(a),u))throw new Error("Cannot find square root");return a}}let o=(r+C)/St;return function(c,f){if(c.pow(f,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let u=n,a=c.pow(c.mul(c.ONE,i),r),l=c.pow(f,o),d=c.pow(f,r);for(;!c.eql(d,c.ONE);){if(c.eql(d,c.ZERO))return c.ZERO;let x=1;for(let g=c.sqr(d);x<u&&!c.eql(g,c.ONE);x++)g=c.sqr(g);let b=c.pow(a,C<<BigInt(u-x-1));a=c.sqr(b),l=c.mul(l,b),d=c.mul(d,a),u=x}return l}}function vo(e){if(e%ze===_o){let t=(e+C)/ze;return function(n,i){let o=n.pow(i,t);if(!n.eql(n.sqr(o),i))throw new Error("Cannot find square root");return o}}if(e%cn===sn){let t=(e-sn)/cn;return function(n,i){let o=n.mul(i,St),s=n.pow(o,t),c=n.mul(i,s),f=n.mul(n.mul(c,St),s),u=n.mul(c,n.sub(f,n.ONE));if(!n.eql(n.sqr(u),i))throw new Error("Cannot find square root");return u}}return e%Ao,Uo(e)}var un=(e,t)=>(R(e,t)&C)===C,Fo=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function an(e){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Fo.reduce((n,i)=>(n[i]="function",n),t);return Ht(e,r)}function To(e,t,r){if(r<k)throw new Error("invalid exponent, negatives unsupported");if(r===k)return e.ONE;if(r===C)return t;let n=e.ONE,i=t;for(;r>k;)r&C&&(n=e.mul(n,i)),i=e.sqr(i),r>>=C;return n}function Lo(e,t){let r=new Array(t.length),n=t.reduce((o,s,c)=>e.is0(s)?o:(r[c]=o,e.mul(o,s)),e.ONE),i=e.inv(n);return t.reduceRight((o,s,c)=>e.is0(s)?o:(r[c]=e.mul(o,r[c]),e.mul(o,s)),i),r}function Ve(e,t){let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function ue(e,t,r=!1,n={}){if(e<=k)throw new Error("invalid field: expected ORDER > 0, got "+e);let{nBitLength:i,nByteLength:o}=Ve(e,t);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s,c=Object.freeze({ORDER:e,BITS:i,BYTES:o,MASK:on(i),ZERO:k,ONE:C,create:f=>R(f,e),isValid:f=>{if(typeof f!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof f);return k<=f&&f<e},is0:f=>f===k,isOdd:f=>(f&C)===C,neg:f=>R(-f,e),eql:(f,u)=>f===u,sqr:f=>R(f*f,e),add:(f,u)=>R(f+u,e),sub:(f,u)=>R(f-u,e),mul:(f,u)=>R(f*u,e),pow:(f,u)=>To(c,f,u),div:(f,u)=>R(f*fn(u,e),e),sqrN:f=>f*f,addN:(f,u)=>f+u,subN:(f,u)=>f-u,mulN:(f,u)=>f*u,inv:f=>fn(f,e),sqrt:n.sqrt||(f=>(s||(s=vo(e)),s(c,f))),invertBatch:f=>Lo(c,f),cmov:(f,u,a)=>a?u:f,toBytes:f=>r?$t(f,o):He(f,o),fromBytes:f=>{if(f.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+f.length);return r?Pt(f):rn(f)}});return Object.freeze(c)}var ln=BigInt(0),ae=BigInt(1);function Ge(e,t){let r=t.negate();return e?r:t}function hn(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function We(e,t){hn(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1);return{windows:r,windowSize:n}}function Co(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((r,n)=>{if(!(r instanceof t))throw new Error("invalid point at index "+n)})}function Ro(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((r,n)=>{if(!t.isValid(r))throw new Error("invalid scalar at index "+n)})}var Ze=new WeakMap,pn=new WeakMap;function $e(e){return pn.get(e)||1}function dn(e,t){return{constTimeNegate:Ge,hasPrecomputes(r){return $e(r)!==1},unsafeLadder(r,n,i=e.ZERO){let o=r;for(;n>ln;)n&ae&&(i=i.add(o)),o=o.double(),n>>=ae;return i},precomputeWindow(r,n){let{windows:i,windowSize:o}=We(n,t),s=[],c=r,f=c;for(let u=0;u<i;u++){f=c,s.push(f);for(let a=1;a<o;a++)f=f.add(c),s.push(f);c=f.double()}return s},wNAF(r,n,i){let{windows:o,windowSize:s}=We(r,t),c=e.ZERO,f=e.BASE,u=BigInt(2**r-1),a=2**r,l=BigInt(r);for(let d=0;d<o;d++){let x=d*s,b=Number(i&u);i>>=l,b>s&&(b-=a,i+=ae);let g=x,_=x+Math.abs(b)-1,D=d%2!==0,v=b<0;b===0?f=f.add(Ge(D,n[g])):c=c.add(Ge(v,n[_]))}return{p:c,f}},wNAFUnsafe(r,n,i,o=e.ZERO){let{windows:s,windowSize:c}=We(r,t),f=BigInt(2**r-1),u=2**r,a=BigInt(r);for(let l=0;l<s;l++){let d=l*c;if(i===ln)break;let x=Number(i&f);if(i>>=a,x>c&&(x-=u,i+=ae),x===0)continue;let b=n[d+Math.abs(x)-1];x<0&&(b=b.negate()),o=o.add(b)}return o},getPrecomputes(r,n,i){let o=Ze.get(n);return o||(o=this.precomputeWindow(n,r),r!==1&&Ze.set(n,i(o))),o},wNAFCached(r,n,i){let o=$e(r);return this.wNAF(o,this.getPrecomputes(o,r,i),n)},wNAFCachedUnsafe(r,n,i,o){let s=$e(r);return s===1?this.unsafeLadder(r,n,o):this.wNAFUnsafe(s,this.getPrecomputes(s,r,i),n,o)},setWindowSize(r,n){hn(n,t),pn.set(r,n),Ze.delete(r)}}}function xn(e,t,r,n){if(Co(r,e),Ro(n,t),r.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let i=e.ZERO,o=nn(BigInt(r.length)),s=o>12?o-3:o>4?o-2:o?2:1,c=(1<<s)-1,f=new Array(c+1).fill(i),u=Math.floor((t.BITS-1)/s)*s,a=i;for(let l=u;l>=0;l-=s){f.fill(i);for(let x=0;x<n.length;x++){let b=n[x],g=Number(b>>BigInt(l)&BigInt(c));f[g]=f[g].add(r[x])}let d=i;for(let x=f.length-1,b=i;x>0;x--)b=b.add(f[x]),d=d.add(b);if(a=a.add(d),l!==0)for(let x=0;x<s;x++)a=a.double()}return a}function yn(e){return an(e.Fp),Ht(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ve(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}var Y=BigInt(0),j=BigInt(1),le=BigInt(2),No=BigInt(8),Do={zip215:!0};function Oo(e){let t=yn(e);return Ht(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function gn(e){let t=Oo(e),{Fp:r,n,prehash:i,hash:o,randomBytes:s,nByteLength:c,h:f}=t,u=le<<BigInt(c*8)-j,a=r.create,l=ue(t.n,t.nBitLength),d=t.uvRatio||((B,p)=>{try{return{isValid:!0,value:r.sqrt(B*r.inv(p))}}catch{return{isValid:!1,value:Y}}}),x=t.adjustScalarBytes||(B=>B),b=t.domain||((B,p,w)=>{if(ce("phflag",w),p.length||w)throw new Error("Contexts/pre-hash are not supported");return B});function g(B,p){Kt("coordinate "+B,p,Y,u)}function _(B){if(!(B instanceof y))throw new Error("ExtendedPoint expected")}let D=je((B,p)=>{let{ex:w,ey:m,ez:I}=B,A=B.is0();p==null&&(p=A?No:r.inv(I));let U=a(w*p),T=a(m*p),F=a(I*p);if(A)return{x:Y,y:j};if(F!==j)throw new Error("invZ was invalid");return{x:U,y:T}}),v=je(B=>{let{a:p,d:w}=t;if(B.is0())throw new Error("bad point: ZERO");let{ex:m,ey:I,ez:A,et:U}=B,T=a(m*m),F=a(I*I),L=a(A*A),P=a(L*L),H=a(T*p),Q=a(L*a(H+F)),tt=a(P+a(w*a(T*F)));if(Q!==tt)throw new Error("bad point: equation left != right (1)");let V=a(m*I),at=a(A*U);if(V!==at)throw new Error("bad point: equation left != right (2)");return!0});class y{constructor(p,w,m,I){this.ex=p,this.ey=w,this.ez=m,this.et=I,g("x",p),g("y",w),g("z",m),g("t",I),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof y)throw new Error("extended point not allowed");let{x:w,y:m}=p||{};return g("x",w),g("y",m),new y(w,m,j,a(w*m))}static normalizeZ(p){let w=r.invertBatch(p.map(m=>m.ez));return p.map((m,I)=>m.toAffine(w[I])).map(y.fromAffine)}static msm(p,w){return xn(y,l,p,w)}_setWindowSize(p){ut.setWindowSize(this,p)}assertValidity(){v(this)}equals(p){_(p);let{ex:w,ey:m,ez:I}=this,{ex:A,ey:U,ez:T}=p,F=a(w*T),L=a(A*I),P=a(m*T),H=a(U*I);return F===L&&P===H}is0(){return this.equals(y.ZERO)}negate(){return new y(a(-this.ex),this.ey,this.ez,a(-this.et))}double(){let{a:p}=t,{ex:w,ey:m,ez:I}=this,A=a(w*w),U=a(m*m),T=a(le*a(I*I)),F=a(p*A),L=w+m,P=a(a(L*L)-A-U),H=F+U,Q=H-T,tt=F-U,V=a(P*Q),at=a(H*tt),wt=a(P*tt),Jt=a(Q*H);return new y(V,at,Jt,wt)}add(p){_(p);let{a:w,d:m}=t,{ex:I,ey:A,ez:U,et:T}=this,{ex:F,ey:L,ez:P,et:H}=p;if(w===BigInt(-1)){let hr=a((A-I)*(L+F)),pr=a((A+I)*(L-F)),me=a(pr-hr);if(me===Y)return this.double();let dr=a(U*le*H),xr=a(T*le*P),yr=xr+dr,gr=pr+hr,wr=xr-dr,Wn=a(yr*me),Zn=a(gr*wr),$n=a(yr*wr),Yn=a(me*gr);return new y(Wn,Zn,Yn,$n)}let Q=a(I*F),tt=a(A*L),V=a(T*m*H),at=a(U*P),wt=a((I+A)*(F+L)-Q-tt),Jt=at-V,ar=at+V,lr=a(tt-w*Q),jn=a(wt*Jt),zn=a(ar*lr),Vn=a(wt*lr),Gn=a(Jt*ar);return new y(jn,zn,Gn,Vn)}subtract(p){return this.add(p.negate())}wNAF(p){return ut.wNAFCached(this,p,y.normalizeZ)}multiply(p){let w=p;Kt("scalar",w,j,n);let{p:m,f:I}=this.wNAF(w);return y.normalizeZ([m,I])[0]}multiplyUnsafe(p,w=y.ZERO){let m=p;return Kt("scalar",m,Y,n),m===Y?J:this.is0()||m===j?this:ut.wNAFCachedUnsafe(this,m,y.normalizeZ,w)}isSmallOrder(){return this.multiplyUnsafe(f).is0()}isTorsionFree(){return ut.unsafeLadder(this,n).is0()}toAffine(p){return D(this,p)}clearCofactor(){let{h:p}=t;return p===j?this:this.multiplyUnsafe(p)}static fromHex(p,w=!1){let{d:m,a:I}=t,A=r.BYTES;p=Z("pointHex",p,A),ce("zip215",w);let U=p.slice(),T=p[A-1];U[A-1]=T&-129;let F=Pt(U),L=w?u:r.ORDER;Kt("pointHex.y",F,Y,L);let P=a(F*F),H=a(P-j),Q=a(m*P-I),{isValid:tt,value:V}=d(H,Q);if(!tt)throw new Error("Point.fromHex: invalid y coordinate");let at=(V&j)===j,wt=(T&128)!==0;if(!w&&V===Y&&wt)throw new Error("Point.fromHex: x=0 and x_0=1");return wt!==at&&(V=a(-V)),y.fromAffine({x:V,y:F})}static fromPrivateKey(p){return K(p).point}toRawBytes(){let{x:p,y:w}=this.toAffine(),m=$t(w,r.BYTES);return m[m.length-1]|=p&j?128:0,m}toHex(){return fe(this.toRawBytes())}}y.BASE=new y(t.Gx,t.Gy,j,a(t.Gx*t.Gy)),y.ZERO=new y(Y,j,j,Y);let{BASE:O,ZERO:J}=y,ut=dn(y,c*8);function Ct(B){return R(B,n)}function z(B){return Ct(Pt(B))}function K(B){let p=r.BYTES;B=Z("private key",B,p);let w=Z("hashed private key",o(B),2*p),m=x(w.slice(0,p)),I=w.slice(p,2*p),A=z(m),U=O.multiply(A),T=U.toRawBytes();return{head:m,prefix:I,scalar:A,point:U,pointBytes:T}}function Rt(B){return K(B).pointBytes}function gt(B=new Uint8Array,...p){let w=qe(...p);return z(o(b(w,Z("context",B),!!i)))}function Nt(B,p,w={}){B=Z("message",B),i&&(B=i(B));let{prefix:m,scalar:I,pointBytes:A}=K(p),U=gt(w.context,m,B),T=O.multiply(U).toRawBytes(),F=gt(w.context,T,A,B),L=Ct(U+F*I);Kt("signature.s",L,Y,n);let P=qe(T,$t(L,r.BYTES));return Z("result",P,r.BYTES*2)}let Gt=Do;function we(B,p,w,m=Gt){let{context:I,zip215:A}=m,U=r.BYTES;B=Z("signature",B,2*U),p=Z("message",p),w=Z("publicKey",w,U),A!==void 0&&ce("zip215",A),i&&(p=i(p));let T=Pt(B.slice(U,2*U)),F,L,P;try{F=y.fromHex(w,A),L=y.fromHex(B.slice(0,U),A),P=O.multiplyUnsafe(T)}catch{return!1}if(!A&&F.isSmallOrder())return!1;let H=gt(I,L.toRawBytes(),F.toRawBytes(),p);return L.add(F.multiplyUnsafe(H)).subtract(P).clearCofactor().equals(y.ZERO)}return O._setWindowSize(8),{CURVE:t,getPublicKey:Rt,sign:Nt,verify:we,ExtendedPoint:y,utils:{getExtendedPublicKey:K,randomPrivateKey:()=>s(r.BYTES),precompute(B=8,p=y.BASE){return p._setWindowSize(B),p.multiply(BigInt(3)),p}}}}var Ye=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),wn=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Js=BigInt(0),ko=BigInt(1),bn=BigInt(2),Qs=BigInt(3),Mo=BigInt(5),Po=BigInt(8);function Ko(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),o=Ye,c=e*e%o*e%o,f=$(c,bn,o)*c%o,u=$(f,ko,o)*e%o,a=$(u,Mo,o)*u%o,l=$(a,t,o)*a%o,d=$(l,r,o)*l%o,x=$(d,n,o)*d%o,b=$(x,i,o)*x%o,g=$(b,i,o)*x%o,_=$(g,t,o)*a%o;return{pow_p_5_8:$(_,bn,o)*e%o,b2:c}}function Ho(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function qo(e,t){let r=Ye,n=R(t*t*t,r),i=R(n*n*t,r),o=Ko(e*i).pow_p_5_8,s=R(e*n*o,r),c=R(t*s*s,r),f=s,u=R(s*wn,r),a=c===e,l=c===R(-e,r),d=c===R(-e*wn,r);return a&&(s=f),(l||d)&&(s=u),un(s,r)&&(s=R(-s,r)),{isValid:a||l,value:s}}var jo=ue(Ye,void 0,!0),zo={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:jo,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Po,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Xr,randomBytes:$r,adjustScalarBytes:Ho,uvRatio:qo},Xe=gn(zo);function Vo(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Je(e,...t){if(!Vo(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Qe(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function mn(e,t){Je(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}var pe=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),X=(e,t)=>e<<32-t|e>>>t;function Go(e){if(typeof e!="string")throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}function tr(e){return typeof e=="string"&&(e=Go(e)),Je(e),e}var he=class{clone(){return this._cloneInto()}};function Bn(e){let t=n=>e().update(tr(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Wo(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),c=Number(r&o),f=n?4:0,u=n?0:4;e.setUint32(t+f,s,n),e.setUint32(t+u,c,n)}var En=(e,t,r)=>e&t^~e&r,_n=(e,t,r)=>e&t^e&r^t&r,de=class extends he{constructor(t,r,n,i){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=pe(this.buffer)}update(t){Qe(this);let{view:r,buffer:n,blockLen:i}=this;t=tr(t);let o=t.length;for(let s=0;s<o;){let c=Math.min(i-this.pos,o-s);if(c===i){let f=pe(t);for(;i<=o-s;s+=i)this.process(f,s);continue}n.set(t.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Qe(this),mn(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let l=s;l<i;l++)r[l]=0;Wo(n,i-8,BigInt(this.length*8),o),this.process(n,0);let c=pe(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=f/4,a=this.get();if(u>a.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)c.setUint32(4*l,a[l],o)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:c}=this;return t.length=i,t.pos=c,t.finished=o,t.destroyed=s,i%r&&t.buffer.set(n),t}};var Zo=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),dt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),xt=new Uint32Array(64),er=class extends de{constructor(){super(64,32,8,!1),this.A=dt[0]|0,this.B=dt[1]|0,this.C=dt[2]|0,this.D=dt[3]|0,this.E=dt[4]|0,this.F=dt[5]|0,this.G=dt[6]|0,this.H=dt[7]|0}get(){let{A:t,B:r,C:n,D:i,E:o,F:s,G:c,H:f}=this;return[t,r,n,i,o,s,c,f]}set(t,r,n,i,o,s,c,f){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=c|0,this.H=f|0}process(t,r){for(let l=0;l<16;l++,r+=4)xt[l]=t.getUint32(r,!1);for(let l=16;l<64;l++){let d=xt[l-15],x=xt[l-2],b=X(d,7)^X(d,18)^d>>>3,g=X(x,17)^X(x,19)^x>>>10;xt[l]=g+xt[l-7]+b+xt[l-16]|0}let{A:n,B:i,C:o,D:s,E:c,F:f,G:u,H:a}=this;for(let l=0;l<64;l++){let d=X(c,6)^X(c,11)^X(c,25),x=a+d+En(c,f,u)+Zo[l]+xt[l]|0,g=(X(n,2)^X(n,13)^X(n,22))+_n(n,i,o)|0;a=u,u=f,f=c,c=s+x|0,s=o,o=i,i=n,n=x+g|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,c=c+this.E|0,f=f+this.F|0,u=u+this.G|0,a=a+this.H|0,this.set(n,i,o,s,c,f,u,a)}roundClean(){xt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var xe=Bn(()=>new er);var $o="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",yt=$o;function Yo(e){if(!e||typeof e!="string")throw new Error(`Expected base58 string but got \u201C${e}\u201D`);if(e.match(/[IOl0]/gmu))throw new Error(`Invalid base58 character \u201C${e.match(/[IOl0]/gmu)}\u201D`);let t=e.match(/^1+/gmu),r=t?t[0].length:0,n=(e.length-r)*(Math.log(58)/Math.log(256))+1>>>0;return new Uint8Array([...new Uint8Array(r),...e.match(/.{1}/gmu).map(i=>yt.indexOf(i)).reduce((i,o)=>(i=i.map(s=>{let c=s*58+o;return o=c>>8,c}),i),new Uint8Array(n)).reverse().filter((i=>o=>i=i||o)(!1))])}var st=Yo;var Xo=()=>{let e=Array(256).fill(-1);for(let t=0;t<yt.length;++t)e[yt.charCodeAt(t)]=t;return e},In=Xo;var Jo=In();function Qo(e){let t=[];for(let r of e){let n=r;for(let i=0;i<t.length;++i){let o=(Jo[t[i]]<<8)+n;t[i]=yt.charCodeAt(o%58),n=o/58|0}for(;n;)t.push(yt.charCodeAt(n%58)),n=n/58|0}for(let r of e){if(r)break;t.push(49)}return t.reverse(),String.fromCharCode(...t)}var Ut=Qo;var rr="__fastnear_";function nr(e){return Buffer.from(e).toString("base64")}function ir(e){return Buffer.from(e,"base64")}function ct(e,t){t==null?localStorage.removeItem(rr+e):localStorage.setItem(rr+e,JSON.stringify(t))}function vt(e){let t=localStorage.getItem(rr+e);try{return JSON.parse(t)}catch{return null}}function or(e){return JSON.parse(JSON.stringify(e))}function sr(...e){try{return JSON.parse(e[0])}catch{return e.length>1?e[1]:value}}var Ft=e=>st(e.includes(":")?(()=>{let[t,r]=e.split(":");if(t!=="ed25519")throw new Error(`Unsupported curve: ${t}`);return r})():e),ts=e=>`ed25519:${Ut(e)}`;function cr(e){e=Ft(e).slice(0,32);let t=Xe.getPublicKey(e);return ts(t)}function An(e,t){t=Ft(t).slice(0,32);let r=Xe.sign(st(e),t);return Ut(r)}var qt=["u8","u16","u32","u64","u128","i8","i16","i32","i64","i128","f32","f64"];var Sn=function(){function e(){this.offset=0,this.buffer_size=256,this.buffer=new ArrayBuffer(this.buffer_size),this.view=new DataView(this.buffer)}return e.prototype.resize_if_necessary=function(t){if(this.buffer_size-this.offset<t){this.buffer_size=Math.max(this.buffer_size*2,this.buffer_size+t);var r=new ArrayBuffer(this.buffer_size);new Uint8Array(r).set(new Uint8Array(this.buffer)),this.buffer=r,this.view=new DataView(r)}},e.prototype.get_used_buffer=function(){return new Uint8Array(this.buffer).slice(0,this.offset)},e.prototype.store_value=function(t,r){var n=r.substring(1),i=parseInt(n)/8;this.resize_if_necessary(i);var o=r[0]==="f"?"setFloat".concat(n):r[0]==="i"?"setInt".concat(n):"setUint".concat(n);this.view[o](this.offset,t,!0),this.offset+=i},e.prototype.store_bytes=function(t){this.resize_if_necessary(t.length),new Uint8Array(this.buffer).set(new Uint8Array(t),this.offset),this.offset+=t.length},e}();var Un=function(){function e(t){this.offset=0,this.buffer_size=t.length,this.buffer=new ArrayBuffer(t.length),new Uint8Array(this.buffer).set(t),this.view=new DataView(this.buffer)}return e.prototype.assert_enough_buffer=function(t){if(this.offset+t>this.buffer.byteLength)throw new Error("Error in schema, the buffer is smaller than expected")},e.prototype.consume_value=function(t){var r=t.substring(1),n=parseInt(r)/8;this.assert_enough_buffer(n);var i=t[0]==="f"?"getFloat".concat(r):t[0]==="i"?"getInt".concat(r):"getUint".concat(r),o=this.view[i](this.offset,!0);return this.offset+=n,o},e.prototype.consume_bytes=function(t){this.assert_enough_buffer(t);var r=this.buffer.slice(this.offset,this.offset+t);return this.offset+=t,r},e}();var rs=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},e(t,r)};return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}();function Tn(e){return Array.isArray(e)||!!e&&typeof e=="object"&&"length"in e&&typeof e.length=="number"&&(e.length===0||e.length>0&&e.length-1 in e)}function Tt(e,t,r){if(typeof e!==t)throw new Error("Expected ".concat(t," not ").concat(typeof e,"(").concat(e,") at ").concat(r.join(".")))}function Ln(e,t){var r=["number","string","bigint","boolean"].includes(typeof e),n=typeof e=="object"&&e!==null&&"toString"in e;if(!r&&!n)throw new Error("Expected bigint, number, boolean or string not ".concat(typeof e,"(").concat(e,") at ").concat(t.join(".")))}function fr(e,t,r){if(e!==t)throw new Error("Array length ".concat(e," does not match schema length ").concat(t," at ").concat(r.join(".")))}function Cn(e,t){if(typeof e!="object"||e===null)throw new Error("Expected object not ".concat(typeof e,"(").concat(e,") at ").concat(t.join(".")))}var vn=qt.concat(["bool","string"]),Fn=["option","enum","array","set","map","struct"],jt=function(e){rs(t,e);function t(r,n){var i="Invalid schema: ".concat(JSON.stringify(r)," expected ").concat(n);return e.call(this,i)||this}return t}(Error);function ft(e){if(!(typeof e=="string"&&vn.includes(e))){if(e&&typeof e=="object"){var t=Object.keys(e);if(t.length===1&&Fn.includes(t[0])){var r=t[0];if(r==="option")return ft(e[r]);if(r==="enum")return ns(e[r]);if(r==="array")return is(e[r]);if(r==="set")return ft(e[r]);if(r==="map")return os(e[r]);if(r==="struct")return ss(e[r])}}throw new jt(e,Fn.join(", ")+" or "+vn.join(", "))}}function ns(e){if(!Array.isArray(e))throw new jt(e,"Array");for(var t=0,r=e;t<r.length;t++){var n=r[t];if(typeof n!="object"||!("struct"in n))throw new Error('Missing "struct" key in enum schema');if(typeof n.struct!="object"||Object.keys(n.struct).length!==1)throw new Error('The "struct" in each enum must have a single key');ft({struct:n.struct})}}function is(e){if(typeof e!="object")throw new jt(e,"{ type, len? }");if(e.len&&typeof e.len!="number")throw new Error("Invalid schema: ".concat(e));if("type"in e)return ft(e.type);throw new jt(e,"{ type, len? }")}function os(e){if(typeof e=="object"&&"key"in e&&"value"in e)ft(e.key),ft(e.value);else throw new jt(e,"{ key, value }")}function ss(e){if(typeof e!="object")throw new jt(e,"object");for(var t in e)ft(e[t])}var Nn=function(){function e(t){this.encoded=new Sn,this.fieldPath=["value"],this.checkTypes=t}return e.prototype.encode=function(t,r){return this.encode_value(t,r),this.encoded.get_used_buffer()},e.prototype.encode_value=function(t,r){if(typeof r=="string"){if(qt.includes(r))return this.encode_integer(t,r);if(r==="string")return this.encode_string(t);if(r==="bool")return this.encode_boolean(t)}if(typeof r=="object"){if("option"in r)return this.encode_option(t,r);if("enum"in r)return this.encode_enum(t,r);if("array"in r)return this.encode_array(t,r);if("set"in r)return this.encode_set(t,r);if("map"in r)return this.encode_map(t,r);if("struct"in r)return this.encode_struct(t,r)}},e.prototype.encode_integer=function(t,r){var n=parseInt(r.substring(1));n<=32||r=="f64"?(this.checkTypes&&Tt(t,"number",this.fieldPath),this.encoded.store_value(t,r)):(this.checkTypes&&Ln(t,this.fieldPath),this.encode_bigint(BigInt(t),n))},e.prototype.encode_bigint=function(t,r){for(var n=r/8,i=new Uint8Array(n),o=0;o<n;o++)i[o]=Number(t&BigInt(255)),t=t>>BigInt(8);this.encoded.store_bytes(new Uint8Array(i))},e.prototype.encode_string=function(t){this.checkTypes&&Tt(t,"string",this.fieldPath);for(var r=t,n=[],i=0;i<r.length;i++){var o=r.charCodeAt(i);o<128?n.push(o):o<2048?n.push(192|o>>6,128|o&63):o<55296||o>=57344?n.push(224|o>>12,128|o>>6&63,128|o&63):(i++,o=65536+((o&1023)<<10|r.charCodeAt(i)&1023),n.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|o&63))}this.encoded.store_value(n.length,"u32"),this.encoded.store_bytes(new Uint8Array(n))},e.prototype.encode_boolean=function(t){this.checkTypes&&Tt(t,"boolean",this.fieldPath),this.encoded.store_value(t?1:0,"u8")},e.prototype.encode_option=function(t,r){t==null?this.encoded.store_value(0,"u8"):(this.encoded.store_value(1,"u8"),this.encode_value(t,r.option))},e.prototype.encode_enum=function(t,r){this.checkTypes&&Cn(t,this.fieldPath);for(var n=Object.keys(t)[0],i=0;i<r.enum.length;i++){var o=r.enum[i];if(n===Object.keys(o.struct)[0])return this.encoded.store_value(i,"u8"),this.encode_struct(t,o)}throw new Error("Enum key (".concat(n,") not found in enum schema: ").concat(JSON.stringify(r)," at ").concat(this.fieldPath.join(".")))},e.prototype.encode_array=function(t,r){if(Tn(t))return this.encode_arraylike(t,r);if(t instanceof ArrayBuffer)return this.encode_buffer(t,r);throw new Error("Expected Array-like not ".concat(typeof t,"(").concat(t,") at ").concat(this.fieldPath.join(".")))},e.prototype.encode_arraylike=function(t,r){r.array.len?fr(t.length,r.array.len,this.fieldPath):this.encoded.store_value(t.length,"u32");for(var n=0;n<t.length;n++)this.encode_value(t[n],r.array.type)},e.prototype.encode_buffer=function(t,r){r.array.len?fr(t.byteLength,r.array.len,this.fieldPath):this.encoded.store_value(t.byteLength,"u32"),this.encoded.store_bytes(new Uint8Array(t))},e.prototype.encode_set=function(t,r){this.checkTypes&&Tt(t,"object",this.fieldPath);var n=t instanceof Set,i=n?Array.from(t.values()):Object.values(t);this.encoded.store_value(i.length,"u32");for(var o=0,s=i;o<s.length;o++){var c=s[o];this.encode_value(c,r.set)}},e.prototype.encode_map=function(t,r){this.checkTypes&&Tt(t,"object",this.fieldPath);var n=t instanceof Map,i=n?Array.from(t.keys()):Object.keys(t);this.encoded.store_value(i.length,"u32");for(var o=0,s=i;o<s.length;o++){var c=s[o];this.encode_value(c,r.map.key),this.encode_value(n?t.get(c):t[c],r.map.value)}},e.prototype.encode_struct=function(t,r){this.checkTypes&&Tt(t,"object",this.fieldPath);for(var n=0,i=Object.keys(r.struct);n<i.length;n++){var o=i[n];this.fieldPath.push(o),this.encode_value(t[o],r.struct[o]),this.fieldPath.pop()}},e}();var cs=function(){function e(t){this.buffer=new Un(t)}return e.prototype.decode=function(t){return this.decode_value(t)},e.prototype.decode_value=function(t){if(typeof t=="string"){if(qt.includes(t))return this.decode_integer(t);if(t==="string")return this.decode_string();if(t==="bool")return this.decode_boolean()}if(typeof t=="object"){if("option"in t)return this.decode_option(t);if("enum"in t)return this.decode_enum(t);if("array"in t)return this.decode_array(t);if("set"in t)return this.decode_set(t);if("map"in t)return this.decode_map(t);if("struct"in t)return this.decode_struct(t)}throw new Error("Unsupported type: ".concat(t))},e.prototype.decode_integer=function(t){var r=parseInt(t.substring(1));return r<=32||t=="f64"?this.buffer.consume_value(t):this.decode_bigint(r,t.startsWith("i"))},e.prototype.decode_bigint=function(t,r){r===void 0&&(r=!1);var n=t/8,i=new Uint8Array(this.buffer.consume_bytes(n)),o=i.reduceRight(function(s,c){return s+c.toString(16).padStart(2,"0")},"");return r&&i[n-1]?BigInt.asIntN(t,BigInt("0x".concat(o))):BigInt("0x".concat(o))},e.prototype.decode_string=function(){for(var t=this.decode_integer("u32"),r=new Uint8Array(this.buffer.consume_bytes(t)),n=[],i=0;i<t;++i){var o=r[i];if(o<128)n.push(o);else if(o<224)n.push((o&31)<<6|r[++i]&63);else if(o<240)n.push((o&15)<<12|(r[++i]&63)<<6|r[++i]&63);else{var s=(o&7)<<18|(r[++i]&63)<<12|(r[++i]&63)<<6|r[++i]&63;n.push(s)}}return String.fromCodePoint.apply(String,n)},e.prototype.decode_boolean=function(){return this.buffer.consume_value("u8")>0},e.prototype.decode_option=function(t){var r=this.buffer.consume_value("u8");if(r===1)return this.decode_value(t.option);if(r!==0)throw new Error("Invalid option ".concat(r));return null},e.prototype.decode_enum=function(t){var r,n=this.buffer.consume_value("u8");if(n>t.enum.length)throw new Error("Enum option ".concat(n," is not available"));var i=t.enum[n].struct,o=Object.keys(i)[0];return r={},r[o]=this.decode_value(i[o]),r},e.prototype.decode_array=function(t){for(var r=[],n=t.array.len?t.array.len:this.decode_integer("u32"),i=0;i<n;++i)r.push(this.decode_value(t.array.type));return r},e.prototype.decode_set=function(t){for(var r=this.decode_integer("u32"),n=new Set,i=0;i<r;++i)n.add(this.decode_value(t.set));return n},e.prototype.decode_map=function(t){for(var r=this.decode_integer("u32"),n=new Map,i=0;i<r;++i){var o=this.decode_value(t.map.key),s=this.decode_value(t.map.value);n.set(o,s)}return n},e.prototype.decode_struct=function(t){var r={};for(var n in t.struct)r[n]=this.decode_value(t.struct[n]);return r},e}();function ur(e,t,r){r===void 0&&(r=!0),r&&ft(e);var n=new Nn(r);return n.encode(t,e)}function Dn(e){return{signerId:e.signerId,publicKey:{ed25519Key:{data:Ft(e.publicKey)}},nonce:BigInt(e.nonce),receiverId:e.receiverId,blockHash:st(e.blockHash),actions:e.actions.map(Mn)}}function On(e){let t=Dn(e);return ur(Pn.Transaction,t)}function kn(e,t){let r={transaction:Dn(e),signature:{ed25519Signature:{data:st(t)}}};return ur(Pn.SignedTransaction,r)}function Mn(e){switch(e.type){case"CreateAccount":return{createAccount:{}};case"DeployContract":return{deployContract:{code:ir(e.codeBase64)}};case"FunctionCall":return{functionCall:{methodName:e.methodName,args:e.argsBase64?ir(e.argsBase64):Buffer.from(JSON.stringify(e.args)),gas:BigInt(e.gas),deposit:BigInt(e.deposit)}};case"Transfer":return{transfer:{deposit:BigInt(e.deposit)}};case"Stake":return{stake:{stake:BigInt(e.stake),publicKey:{ed25519Key:Ft(e.publicKey)}}};case"AddKey":return{addKey:{publicKey:Ft(e.publicKey),accessKey:{nonce:BigInt(e.accessKey.nonce),permission:e.accessKey.permission==="FullAccess"?{fullAccess:{}}:{functionCall:{allowance:e.accessKey.allowance?BigInt(e.accessKey.allowance):null,receiverId:e.accessKey.receiverId,methodNames:e.accessKey.methodNames}}}}};case"DeleteKey":return{deleteKey:{publicKey:Ft(e.publicKey)}};case"DeleteAccount":return{deleteAccount:{beneficiaryId:e.beneficiaryId}};case"SignedDelegate":return{signedDelegate:{delegateAction:Mn(e.delegateAction),signature:{ed25519Signature:st(e.signature)}}};default:throw new Error("Not implemented action: "+e.type)}}var Pn=new class{Ed25519Signature={struct:{data:{array:{type:"u8",len:64}}}};Secp256k1Signature={struct:{data:{array:{type:"u8",len:65}}}};Signature={enum:[{struct:{ed25519Signature:this.Ed25519Signature}},{struct:{secp256k1Signature:this.Secp256k1Signature}}]};Ed25519Data={struct:{data:{array:{type:"u8",len:32}}}};Secp256k1Data={struct:{data:{array:{type:"u8",len:64}}}};PublicKey={enum:[{struct:{ed25519Key:this.Ed25519Data}},{struct:{secp256k1Key:this.Secp256k1Data}}]};FunctionCallPermission={struct:{allowance:{option:"u128"},receiverId:"string",methodNames:{array:{type:"string"}}}};FullAccessPermission={struct:{}};AccessKeyPermission={enum:[{struct:{functionCall:this.FunctionCallPermission}},{struct:{fullAccess:this.FullAccessPermission}}]};AccessKey={struct:{nonce:"u64",permission:this.AccessKeyPermission}};CreateAccount={struct:{}};DeployContract={struct:{code:{array:{type:"u8"}}}};FunctionCall={struct:{methodName:"string",args:{array:{type:"u8"}},gas:"u64",deposit:"u128"}};Transfer={struct:{deposit:"u128"}};Stake={struct:{stake:"u128",publicKey:this.PublicKey}};AddKey={struct:{publicKey:this.PublicKey,accessKey:this.AccessKey}};DeleteKey={struct:{publicKey:this.PublicKey}};DeleteAccount={struct:{beneficiaryId:"string"}};ClassicAction={enum:[{struct:{createAccount:this.CreateAccount}},{struct:{deployContract:this.DeployContract}},{struct:{functionCall:this.FunctionCall}},{struct:{transfer:this.Transfer}},{struct:{stake:this.Stake}},{struct:{addKey:this.AddKey}},{struct:{deleteKey:this.DeleteKey}},{struct:{deleteAccount:this.DeleteAccount}}]};DelegateAction={struct:{senderId:"string",receiverId:"string",actions:{array:{type:this.ClassicAction}},nonce:"u64",maxBlockHeight:"u64",publicKey:this.PublicKey}};SignedDelegate={struct:{delegateAction:this.DelegateAction,signature:this.Signature}};Action={enum:[{struct:{createAccount:this.CreateAccount}},{struct:{deployContract:this.DeployContract}},{struct:{functionCall:this.FunctionCall}},{struct:{transfer:this.Transfer}},{struct:{stake:this.Stake}},{struct:{addKey:this.AddKey}},{struct:{deleteKey:this.DeleteKey}},{struct:{deleteAccount:this.DeleteAccount}},{struct:{signedDelegate:this.SignedDelegate}}]};Transaction={struct:{signerId:"string",publicKey:this.PublicKey,nonce:"u64",receiverId:"string",blockHash:{array:{type:"u8",len:32}},actions:{array:{type:this.Action}}}};SignedTransaction={struct:{transaction:this.Transaction,signature:this.Signature}}};W.DP=27;var fs=1e3*60*60*6,us="mainnet",as={testnet:{networkId:"testnet",nodeUrl:"https://rpc.testnet.fastnear.com/"},mainnet:{networkId:"mainnet",nodeUrl:"https://rpc.mainnet.fastnear.com/"}},zt={...as[us]},N;{let e=vt("privateKey");N={accountId:vt("accountId"),accessKeyContractId:vt("accessKeyContractId"),lastWalletId:vt("lastWalletId"),privateKey:e,publicKey:e?cr(e):null}}var Vt={},ge={account:new Set,tx:new Set};function Xt(e){let t=N;N={...N,...e},ct("accountId",N.accountId),ct("privateKey",N.privateKey),ct("lastWalletId",N.lastWalletId),ct("accessKeyContractId",N.accessKeyContractId),e.hasOwnProperty("privateKey")&&e.privateKey!==t.privateKey&&(N.publicKey=e.privateKey?cr(e.privateKey):null,ct("nonce",null)),e.accountId!==t.accountId&&xs(e.accountId)}function Yt(e){let t=e.txId;Vt[t]={...Vt[t]??{},...e},ys(Vt[t])}function ls(e){console.log("Adapter state update:",e),Xt({privateKey:e.privateKey,accountId:e.accountId,lastWalletId:e.lastWalletId})}var hs=new zr({onStateUpdate:ls});function ps(e){try{return JSON.parse(Buffer.from(e).toString())}catch{try{return Buffer.from(e)}catch{return e}}}function ye(e,t){return t==="final"||t==="optimistic"?{...e,finality:t}:t?{...e,block_id:t}:{...e,finality:"optimistic"}}async function Lt(e,t){let n=await(await fetch(zt.nodeUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:`fastnear-${Date.now()}`,method:e,params:t})})).json();if(n.error)throw new Error(JSON.stringify(n.error));return n.result}function ds(e,t,r){Lt("send_tx",{signed_tx_base64:e,wait_until:t??"INCLUDED"}).then(n=>{Yt({txId:r,status:"Included"}),Lt("tx",{tx_hash:Vt[r].txHash,sender_account_id:Vt[r].tx.signerId,wait_until:"EXECUTED_OPTIMISTIC"}).then(i=>{Yt({txId:r,status:"Executed",result:i})}).catch(i=>{Yt({txId:r,status:"ErrorAfterIncluded",error:sr(i.message)})})}).catch(n=>{Yt({txId:r,status:"Error",error:sr(n.message)})})}function xs(e){ge.account.forEach(t=>{try{t(e)}catch(r){console.error(r)}})}function ys(e){ge.tx.forEach(t=>{try{t(or(e))}catch(r){console.error(r)}})}function Kn(e,...t){if(Array.isArray(e)&&(e=e.reduce((r,n,i)=>r+(t[i-1]||"")+n)),typeof e=="string"){let r=e.match(/([0-9.,_]+)\s*([a-zA-Z]+)?/);if(r){let n=r[1].replace(/[_,]/g,""),i=r[2];if(i)switch(i.toLowerCase()){case"near":return W(n).mul(W(10).pow(24)).toFixed(0);case"tgas":return W(n).mul(W(10).pow(12)).toFixed(0);case"ggas":return W(n).mul(W(10).pow(9)).toFixed(0);case"gas":return W(n).toFixed(0);default:throw new Error(`Unknown unit: ${unit}`)}else return W(n).toFixed(0)}}return W(e).toFixed(0)}var Hn={get accountId(){return N.accountId},get publicKey(){return N.publicKey},config(e){if(e){if(e.networkId&&zt.networkId!==e.networkId)throw new Error("TODO: Network ID change should handle scope");zt={...zt,...e}}return zt},get authStatus(){if(!N.accountId)return"SignedOut";let e=N.publicKey,t=N.accessKeyContractId;return e?{type:"SignedInWithLimitedAccessKey",accessKey:e,contractId:t}:"SignedIn"},async view({contractId:e,methodName:t,args:r,argsBase64:n,blockId:i}){let o=n||(r?nr(JSON.stringify(r)):""),s=await Lt("query",ye({request_type:"call_function",account_id:e,method_name:t,args_base64:o},i));return ps(s.result)},async account({accountId:e,blockId:t}){return Lt("query",ye({request_type:"view_account",account_id:e},t))},async block({blockId:e}){return Lt("block",ye({},e))},async accessKey({accountId:e,publicKey:t,blockId:r}){return Lt("query",ye({request_type:"view_access_key",account_id:e,public_key:t},r))},async tx({txHash:e,accountId:t}){return Lt("tx",[e,t])},localTxHistory(){return[...Vt]},async sendTx({receiverId:e,actions:t,waitUntil:r}){if(!N.accountId)throw new Error("Not signed in");if(e!==N.accessKeyContractId)throw new Error("Need to use walletAdapter. Not implemented yet");let n=N.accountId,i=N.publicKey,o=N.privateKey,s={},c=vt("nonce");c||(s.nonce=this.accessKey({accountId:n,publicKey:i}).then(v=>(ct("nonce",v.nonce),v.nonce)));let f=vt("block");if((!f||parseFloat(f.header.timestamp_nanosec)/1e6+fs<Date.now())&&(s.block=this.block({blockId:"final"}).then(v=>(v={header:{prev_hash:v.header.prev_hash,timestamp_nanosec:v.header.timestamp_nanosec}},ct("block",v),v))),Object.keys(s).length>0){let v=await Promise.all(Object.values(s));for(let y=0;y<v.length;y++)Object.keys(s)[y]==="nonce"?c=v[y]:Object.keys(s)[y]==="block"&&(f=v[y])}let u=c+1;ct("nonce",u);let a=f.header.prev_hash,l=`tx-${Date.now()}-${Math.random()}`,d={signerId:n,publicKey:i,nonce:u,receiverId:e,blockHash:a,actions:t};console.log("Transaction:",d);let x=On(d),b=Ut(xe(x)),g=An(b,o),_=kn(d,g),D=nr(_);return Yt({status:"Pending",txId:l,tx:or(d),signature:g,signedTxBase64:D,txHash:b}),ds(D,r,l),l},async requestSignIn({contractId:e}){Xt({accessKeyContractId:e,accountId:null,privateKey:null});let t=await hs.signIn({networkId:zt.networkId,contractId:e});if(console.log("Sign in result:",t),t.error)throw new Error(`Wallet error: ${t.error}`);t.url?(console.log("Redirecting to wallet:",t.url),window.location.href=t.url):t.accountId&&Xt({accountId:t.accountId})},signOut(){Xt({accountId:null,privateKey:null,contractId:null})},onAccount(e){ge.account.add(e)},onTx(e){ge.tx.add(e)},actions:{functionCall:({methodName:e,gas:t,deposit:r,args:n,argsBase64:i})=>({type:"FunctionCall",methodName:e,args:n,argsBase64:i,gas:t,deposit:r}),transfer:e=>({type:"Transfer",deposit:e}),stakeNEAR:({amount:e,publicKey:t})=>({type:"Stake",stake:e,publicKey:t}),addFullAccessKey:({publicKey:e})=>({type:"AddKey",publicKey:e,accessKey:{permission:"FullAccess"}}),addLimitedAccessKey:({publicKey:e,allowance:t,accountId:r,methodNames:n})=>({type:"AddKey",publicKey:e,accessKey:{permission:"FunctionCall",allowance:t,receiverId:r,methodNames:n}}),deleteKey:({publicKey:e})=>({type:"DeleteKey",publicKey:e}),deleteAccount:({beneficiaryId:e})=>({type:"DeleteAccount",beneficiaryId:e}),createAccount:()=>({type:"CreateAccount"}),deployContract:({codeBase64:e})=>({type:"DeployContract",codeBase64:e})}};try{let e=new URL(window.location.href),t=e.searchParams.get("account_id"),r=e.searchParams.get("public_key"),n=e.searchParams.get("error_code");n&&console.error(new Error(`Wallet error: ${n}`)),t&&r&&(r===N.publicKey?Xt({accountId:t}):console.error(new Error("Public key mismatch from wallet redirect"),r,N.publicKey)),e.searchParams.delete("account_id"),e.searchParams.delete("public_key"),e.searchParams.delete("error_code"),e.searchParams.delete("all_keys"),window.history.replaceState({},"",e.toString())}catch(e){console.error("Error handling wallet redirect:",e)}window.Buffer=qn.Buffer;window.near=Hn;window.$$=Kn;})();
|
|
2
|
-
/*! Bundled license information:
|
|
3
|
-
|
|
4
|
-
ieee754/index.js:
|
|
5
|
-
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
6
|
-
|
|
7
|
-
buffer/index.js:
|
|
8
|
-
(*!
|
|
9
|
-
* The buffer module from node.js, for the browser.
|
|
10
|
-
*
|
|
11
|
-
* @author Feross Aboukhadijeh <https://feross.org>
|
|
12
|
-
* @license MIT
|
|
13
|
-
*)
|
|
14
|
-
|
|
15
|
-
@noble/hashes/esm/utils.js:
|
|
16
|
-
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
17
|
-
|
|
18
|
-
@noble/curves/esm/abstract/utils.js:
|
|
19
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
20
|
-
|
|
21
|
-
@noble/curves/esm/abstract/modular.js:
|
|
22
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
23
|
-
|
|
24
|
-
@noble/curves/esm/abstract/curve.js:
|
|
25
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
26
|
-
|
|
27
|
-
@noble/curves/esm/abstract/edwards.js:
|
|
28
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
29
|
-
|
|
30
|
-
@noble/curves/esm/ed25519.js:
|
|
31
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
32
|
-
|
|
33
|
-
@noble/hashes/esm/utils.js:
|
|
34
|
-
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
35
|
-
*/
|
package/src/crypto.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { ed25519 } from "@noble/curves/ed25519";
|
|
2
|
-
import { sha256 } from "@noble/hashes/sha2";
|
|
3
|
-
import { fromBase58, toBase58 } from "./utils";
|
|
4
|
-
|
|
5
|
-
export { sha256 };
|
|
6
|
-
|
|
7
|
-
export const keyFromString = (key) =>
|
|
8
|
-
fromBase58(
|
|
9
|
-
key.includes(":")
|
|
10
|
-
? (() => {
|
|
11
|
-
const [curve, keyPart] = key.split(":");
|
|
12
|
-
if (curve !== "ed25519") {
|
|
13
|
-
throw new Error(`Unsupported curve: ${curve}`);
|
|
14
|
-
}
|
|
15
|
-
return keyPart;
|
|
16
|
-
})()
|
|
17
|
-
: key,
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
export const keyToString = (key) => `ed25519:${toBase58(key)}`;
|
|
21
|
-
|
|
22
|
-
export function publicKeyFromPrivate(privateKey) {
|
|
23
|
-
privateKey = keyFromString(privateKey).slice(0, 32);
|
|
24
|
-
const publicKey = ed25519.getPublicKey(privateKey);
|
|
25
|
-
return keyToString(publicKey);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function signHash(hash, privateKey) {
|
|
29
|
-
privateKey = keyFromString(privateKey).slice(0, 32);
|
|
30
|
-
const signature = ed25519.sign(fromBase58(hash), privateKey);
|
|
31
|
-
return toBase58(signature);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function signBytes(bytes, privateKey) {
|
|
35
|
-
const hash = sha256(bytes);
|
|
36
|
-
return signHash(toBase58(hash), privateKey);
|
|
37
|
-
}
|
package/src/index.esm.js
DELETED