droplinked-web3-kit 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  */(function(c){const t=base64Js,n=ieee754,ie=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;c.Buffer=xe,c.SlowBuffer=He,c.INSPECT_MAX_BYTES=50;const fe=2147483647;c.kMaxLength=fe;const{Uint8Array:ae,ArrayBuffer:le,SharedArrayBuffer:he}=globalThis;xe.TYPED_ARRAY_SUPPORT=ye(),!xe.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 ye(){try{const We=new ae(1),Le={foo:function(){return 42}};return Object.setPrototypeOf(Le,ae.prototype),Object.setPrototypeOf(We,Le),We.foo()===42}catch{return!1}}Object.defineProperty(xe.prototype,"parent",{enumerable:!0,get:function(){if(xe.isBuffer(this))return this.buffer}}),Object.defineProperty(xe.prototype,"offset",{enumerable:!0,get:function(){if(xe.isBuffer(this))return this.byteOffset}});function me(We){if(We>fe)throw new RangeError('The value "'+We+'" is invalid for option "size"');const Le=new ae(We);return Object.setPrototypeOf(Le,xe.prototype),Le}function xe(We,Le,Ge){if(typeof We=="number"){if(typeof Le=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Be(We)}return Ee(We,Le,Ge)}xe.poolSize=8192;function Ee(We,Le,Ge){if(typeof We=="string")return $e(We,Le);if(le.isView(We))return ke(We);if(We==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof We);if($t(We,le)||We&&$t(We.buffer,le)||typeof he<"u"&&($t(We,he)||We&&$t(We.buffer,he)))return Pe(We,Le,Ge);if(typeof We=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const Mt=We.valueOf&&We.valueOf();if(Mt!=null&&Mt!==We)return xe.from(Mt,Le,Ge);const Ft=Ue(We);if(Ft)return Ft;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof We[Symbol.toPrimitive]=="function")return xe.from(We[Symbol.toPrimitive]("string"),Le,Ge);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof We)}xe.from=function(We,Le,Ge){return Ee(We,Le,Ge)},Object.setPrototypeOf(xe.prototype,ae.prototype),Object.setPrototypeOf(xe,ae);function Se(We){if(typeof We!="number")throw new TypeError('"size" argument must be of type number');if(We<0)throw new RangeError('The value "'+We+'" is invalid for option "size"')}function Me(We,Le,Ge){return Se(We),We<=0?me(We):Le!==void 0?typeof Ge=="string"?me(We).fill(Le,Ge):me(We).fill(Le):me(We)}xe.alloc=function(We,Le,Ge){return Me(We,Le,Ge)};function Be(We){return Se(We),me(We<0?0:qe(We)|0)}xe.allocUnsafe=function(We){return Be(We)},xe.allocUnsafeSlow=function(We){return Be(We)};function $e(We,Le){if((typeof Le!="string"||Le==="")&&(Le="utf8"),!xe.isEncoding(Le))throw new TypeError("Unknown encoding: "+Le);const Ge=Ve(We,Le)|0;let Mt=me(Ge);const Ft=Mt.write(We,Le);return Ft!==Ge&&(Mt=Mt.slice(0,Ft)),Mt}function Ce(We){const Le=We.length<0?0:qe(We.length)|0,Ge=me(Le);for(let Mt=0;Mt<Le;Mt+=1)Ge[Mt]=We[Mt]&255;return Ge}function ke(We){if($t(We,ae)){const Le=new ae(We);return Pe(Le.buffer,Le.byteOffset,Le.byteLength)}return Ce(We)}function Pe(We,Le,Ge){if(Le<0||We.byteLength<Le)throw new RangeError('"offset" is outside of buffer bounds');if(We.byteLength<Le+(Ge||0))throw new RangeError('"length" is outside of buffer bounds');let Mt;return Le===void 0&&Ge===void 0?Mt=new ae(We):Ge===void 0?Mt=new ae(We,Le):Mt=new ae(We,Le,Ge),Object.setPrototypeOf(Mt,xe.prototype),Mt}function Ue(We){if(xe.isBuffer(We)){const Le=qe(We.length)|0,Ge=me(Le);return Ge.length===0||We.copy(Ge,0,0,Le),Ge}if(We.length!==void 0)return typeof We.length!="number"||Xt(We.length)?me(0):Ce(We);if(We.type==="Buffer"&&Array.isArray(We.data))return Ce(We.data)}function qe(We){if(We>=fe)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+fe.toString(16)+" bytes");return We|0}function He(We){return+We!=We&&(We=0),xe.alloc(+We)}xe.isBuffer=function(Le){return Le!=null&&Le._isBuffer===!0&&Le!==xe.prototype},xe.compare=function(Le,Ge){if($t(Le,ae)&&(Le=xe.from(Le,Le.offset,Le.byteLength)),$t(Ge,ae)&&(Ge=xe.from(Ge,Ge.offset,Ge.byteLength)),!xe.isBuffer(Le)||!xe.isBuffer(Ge))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(Le===Ge)return 0;let Mt=Le.length,Ft=Ge.length;for(let Qt=0,Wt=Math.min(Mt,Ft);Qt<Wt;++Qt)if(Le[Qt]!==Ge[Qt]){Mt=Le[Qt],Ft=Ge[Qt];break}return Mt<Ft?-1:Ft<Mt?1:0},xe.isEncoding=function(Le){switch(String(Le).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}},xe.concat=function(Le,Ge){if(!Array.isArray(Le))throw new TypeError('"list" argument must be an Array of Buffers');if(Le.length===0)return xe.alloc(0);let Mt;if(Ge===void 0)for(Ge=0,Mt=0;Mt<Le.length;++Mt)Ge+=Le[Mt].length;const Ft=xe.allocUnsafe(Ge);let Qt=0;for(Mt=0;Mt<Le.length;++Mt){let Wt=Le[Mt];if($t(Wt,ae))Qt+Wt.length>Ft.length?(xe.isBuffer(Wt)||(Wt=xe.from(Wt)),Wt.copy(Ft,Qt)):ae.prototype.set.call(Ft,Wt,Qt);else if(xe.isBuffer(Wt))Wt.copy(Ft,Qt);else throw new TypeError('"list" argument must be an Array of Buffers');Qt+=Wt.length}return Ft};function Ve(We,Le){if(xe.isBuffer(We))return We.length;if(le.isView(We)||$t(We,le))return We.byteLength;if(typeof We!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof We);const Ge=We.length,Mt=arguments.length>2&&arguments[2]===!0;if(!Mt&&Ge===0)return 0;let Ft=!1;for(;;)switch(Le){case"ascii":case"latin1":case"binary":return Ge;case"utf8":case"utf-8":return An(We).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ge*2;case"hex":return Ge>>>1;case"base64":return _n(We).length;default:if(Ft)return Mt?-1:An(We).length;Le=(""+Le).toLowerCase(),Ft=!0}}xe.byteLength=Ve;function Ye(We,Le,Ge){let Mt=!1;if((Le===void 0||Le<0)&&(Le=0),Le>this.length||((Ge===void 0||Ge>this.length)&&(Ge=this.length),Ge<=0)||(Ge>>>=0,Le>>>=0,Ge<=Le))return"";for(We||(We="utf8");;)switch(We){case"hex":return Re(this,Le,Ge);case"utf8":case"utf-8":return we(this,Le,Ge);case"ascii":return ue(this,Le,Ge);case"latin1":case"binary":return be(this,Le,Ge);case"base64":return ve(this,Le,Ge);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ne(this,Le,Ge);default:if(Mt)throw new TypeError("Unknown encoding: "+We);We=(We+"").toLowerCase(),Mt=!0}}xe.prototype._isBuffer=!0;function Qe(We,Le,Ge){const Mt=We[Le];We[Le]=We[Ge],We[Ge]=Mt}xe.prototype.swap16=function(){const Le=this.length;if(Le%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let Ge=0;Ge<Le;Ge+=2)Qe(this,Ge,Ge+1);return this},xe.prototype.swap32=function(){const Le=this.length;if(Le%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let Ge=0;Ge<Le;Ge+=4)Qe(this,Ge,Ge+3),Qe(this,Ge+1,Ge+2);return this},xe.prototype.swap64=function(){const Le=this.length;if(Le%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let Ge=0;Ge<Le;Ge+=8)Qe(this,Ge,Ge+7),Qe(this,Ge+1,Ge+6),Qe(this,Ge+2,Ge+5),Qe(this,Ge+3,Ge+4);return this},xe.prototype.toString=function(){const Le=this.length;return Le===0?"":arguments.length===0?we(this,0,Le):Ye.apply(this,arguments)},xe.prototype.toLocaleString=xe.prototype.toString,xe.prototype.equals=function(Le){if(!xe.isBuffer(Le))throw new TypeError("Argument must be a Buffer");return this===Le?!0:xe.compare(this,Le)===0},xe.prototype.inspect=function(){let Le="";const Ge=c.INSPECT_MAX_BYTES;return Le=this.toString("hex",0,Ge).replace(/(.{2})/g,"$1 ").trim(),this.length>Ge&&(Le+=" ... "),"<Buffer "+Le+">"},ie&&(xe.prototype[ie]=xe.prototype.inspect),xe.prototype.compare=function(Le,Ge,Mt,Ft,Qt){if($t(Le,ae)&&(Le=xe.from(Le,Le.offset,Le.byteLength)),!xe.isBuffer(Le))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof Le);if(Ge===void 0&&(Ge=0),Mt===void 0&&(Mt=Le?Le.length:0),Ft===void 0&&(Ft=0),Qt===void 0&&(Qt=this.length),Ge<0||Mt>Le.length||Ft<0||Qt>this.length)throw new RangeError("out of range index");if(Ft>=Qt&&Ge>=Mt)return 0;if(Ft>=Qt)return-1;if(Ge>=Mt)return 1;if(Ge>>>=0,Mt>>>=0,Ft>>>=0,Qt>>>=0,this===Le)return 0;let Wt=Qt-Ft,en=Mt-Ge;const En=Math.min(Wt,en),tn=this.slice(Ft,Qt),nn=Le.slice(Ge,Mt);for(let Sn=0;Sn<En;++Sn)if(tn[Sn]!==nn[Sn]){Wt=tn[Sn],en=nn[Sn];break}return Wt<en?-1:en<Wt?1:0};function Ke(We,Le,Ge,Mt,Ft){if(We.length===0)return-1;if(typeof Ge=="string"?(Mt=Ge,Ge=0):Ge>2147483647?Ge=2147483647:Ge<-2147483648&&(Ge=-2147483648),Ge=+Ge,Xt(Ge)&&(Ge=Ft?0:We.length-1),Ge<0&&(Ge=We.length+Ge),Ge>=We.length){if(Ft)return-1;Ge=We.length-1}else if(Ge<0)if(Ft)Ge=0;else return-1;if(typeof Le=="string"&&(Le=xe.from(Le,Mt)),xe.isBuffer(Le))return Le.length===0?-1:Pt(We,Le,Ge,Mt,Ft);if(typeof Le=="number")return Le=Le&255,typeof ae.prototype.indexOf=="function"?Ft?ae.prototype.indexOf.call(We,Le,Ge):ae.prototype.lastIndexOf.call(We,Le,Ge):Pt(We,[Le],Ge,Mt,Ft);throw new TypeError("val must be string, number or Buffer")}function Pt(We,Le,Ge,Mt,Ft){let Qt=1,Wt=We.length,en=Le.length;if(Mt!==void 0&&(Mt=String(Mt).toLowerCase(),Mt==="ucs2"||Mt==="ucs-2"||Mt==="utf16le"||Mt==="utf-16le")){if(We.length<2||Le.length<2)return-1;Qt=2,Wt/=2,en/=2,Ge/=2}function En(nn,Sn){return Qt===1?nn[Sn]:nn.readUInt16BE(Sn*Qt)}let tn;if(Ft){let nn=-1;for(tn=Ge;tn<Wt;tn++)if(En(We,tn)===En(Le,nn===-1?0:tn-nn)){if(nn===-1&&(nn=tn),tn-nn+1===en)return nn*Qt}else nn!==-1&&(tn-=tn-nn),nn=-1}else for(Ge+en>Wt&&(Ge=Wt-en),tn=Ge;tn>=0;tn--){let nn=!0;for(let Sn=0;Sn<en;Sn++)if(En(We,tn+Sn)!==En(Le,Sn)){nn=!1;break}if(nn)return tn}return-1}xe.prototype.includes=function(Le,Ge,Mt){return this.indexOf(Le,Ge,Mt)!==-1},xe.prototype.indexOf=function(Le,Ge,Mt){return Ke(this,Le,Ge,Mt,!0)},xe.prototype.lastIndexOf=function(Le,Ge,Mt){return Ke(this,Le,Ge,Mt,!1)};function _e(We,Le,Ge,Mt){Ge=Number(Ge)||0;const Ft=We.length-Ge;Mt?(Mt=Number(Mt),Mt>Ft&&(Mt=Ft)):Mt=Ft;const Qt=Le.length;Mt>Qt/2&&(Mt=Qt/2);let Wt;for(Wt=0;Wt<Mt;++Wt){const en=parseInt(Le.substr(Wt*2,2),16);if(Xt(en))return Wt;We[Ge+Wt]=en}return Wt}function se(We,Le,Ge,Mt){return Je(An(Le,We.length-Ge),We,Ge,Mt)}function ce(We,Le,Ge,Mt){return Je(Yt(Le),We,Ge,Mt)}function de(We,Le,Ge,Mt){return Je(_n(Le),We,Ge,Mt)}function pe(We,Le,Ge,Mt){return Je(Jt(Le,We.length-Ge),We,Ge,Mt)}xe.prototype.write=function(Le,Ge,Mt,Ft){if(Ge===void 0)Ft="utf8",Mt=this.length,Ge=0;else if(Mt===void 0&&typeof Ge=="string")Ft=Ge,Mt=this.length,Ge=0;else if(isFinite(Ge))Ge=Ge>>>0,isFinite(Mt)?(Mt=Mt>>>0,Ft===void 0&&(Ft="utf8")):(Ft=Mt,Mt=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const Qt=this.length-Ge;if((Mt===void 0||Mt>Qt)&&(Mt=Qt),Le.length>0&&(Mt<0||Ge<0)||Ge>this.length)throw new RangeError("Attempt to write outside buffer bounds");Ft||(Ft="utf8");let Wt=!1;for(;;)switch(Ft){case"hex":return _e(this,Le,Ge,Mt);case"utf8":case"utf-8":return se(this,Le,Ge,Mt);case"ascii":case"latin1":case"binary":return ce(this,Le,Ge,Mt);case"base64":return de(this,Le,Ge,Mt);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,Le,Ge,Mt);default:if(Wt)throw new TypeError("Unknown encoding: "+Ft);Ft=(""+Ft).toLowerCase(),Wt=!0}},xe.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ve(We,Le,Ge){return Le===0&&Ge===We.length?t.fromByteArray(We):t.fromByteArray(We.slice(Le,Ge))}function we(We,Le,Ge){Ge=Math.min(We.length,Ge);const Mt=[];let Ft=Le;for(;Ft<Ge;){const Qt=We[Ft];let Wt=null,en=Qt>239?4:Qt>223?3:Qt>191?2:1;if(Ft+en<=Ge){let En,tn,nn,Sn;switch(en){case 1:Qt<128&&(Wt=Qt);break;case 2:En=We[Ft+1],(En&192)===128&&(Sn=(Qt&31)<<6|En&63,Sn>127&&(Wt=Sn));break;case 3:En=We[Ft+1],tn=We[Ft+2],(En&192)===128&&(tn&192)===128&&(Sn=(Qt&15)<<12|(En&63)<<6|tn&63,Sn>2047&&(Sn<55296||Sn>57343)&&(Wt=Sn));break;case 4:En=We[Ft+1],tn=We[Ft+2],nn=We[Ft+3],(En&192)===128&&(tn&192)===128&&(nn&192)===128&&(Sn=(Qt&15)<<18|(En&63)<<12|(tn&63)<<6|nn&63,Sn>65535&&Sn<1114112&&(Wt=Sn))}}Wt===null?(Wt=65533,en=1):Wt>65535&&(Wt-=65536,Mt.push(Wt>>>10&1023|55296),Wt=56320|Wt&1023),Mt.push(Wt),Ft+=en}return ge(Mt)}const Ae=4096;function ge(We){const Le=We.length;if(Le<=Ae)return String.fromCharCode.apply(String,We);let Ge="",Mt=0;for(;Mt<Le;)Ge+=String.fromCharCode.apply(String,We.slice(Mt,Mt+=Ae));return Ge}function ue(We,Le,Ge){let Mt="";Ge=Math.min(We.length,Ge);for(let Ft=Le;Ft<Ge;++Ft)Mt+=String.fromCharCode(We[Ft]&127);return Mt}function be(We,Le,Ge){let Mt="";Ge=Math.min(We.length,Ge);for(let Ft=Le;Ft<Ge;++Ft)Mt+=String.fromCharCode(We[Ft]);return Mt}function Re(We,Le,Ge){const Mt=We.length;(!Le||Le<0)&&(Le=0),(!Ge||Ge<0||Ge>Mt)&&(Ge=Mt);let Ft="";for(let Qt=Le;Qt<Ge;++Qt)Ft+=Ht[We[Qt]];return Ft}function Ne(We,Le,Ge){const Mt=We.slice(Le,Ge);let Ft="";for(let Qt=0;Qt<Mt.length-1;Qt+=2)Ft+=String.fromCharCode(Mt[Qt]+Mt[Qt+1]*256);return Ft}xe.prototype.slice=function(Le,Ge){const Mt=this.length;Le=~~Le,Ge=Ge===void 0?Mt:~~Ge,Le<0?(Le+=Mt,Le<0&&(Le=0)):Le>Mt&&(Le=Mt),Ge<0?(Ge+=Mt,Ge<0&&(Ge=0)):Ge>Mt&&(Ge=Mt),Ge<Le&&(Ge=Le);const Ft=this.subarray(Le,Ge);return Object.setPrototypeOf(Ft,xe.prototype),Ft};function Fe(We,Le,Ge){if(We%1!==0||We<0)throw new RangeError("offset is not uint");if(We+Le>Ge)throw new RangeError("Trying to access beyond buffer length")}xe.prototype.readUintLE=xe.prototype.readUIntLE=function(Le,Ge,Mt){Le=Le>>>0,Ge=Ge>>>0,Mt||Fe(Le,Ge,this.length);let Ft=this[Le],Qt=1,Wt=0;for(;++Wt<Ge&&(Qt*=256);)Ft+=this[Le+Wt]*Qt;return Ft},xe.prototype.readUintBE=xe.prototype.readUIntBE=function(Le,Ge,Mt){Le=Le>>>0,Ge=Ge>>>0,Mt||Fe(Le,Ge,this.length);let Ft=this[Le+--Ge],Qt=1;for(;Ge>0&&(Qt*=256);)Ft+=this[Le+--Ge]*Qt;return Ft},xe.prototype.readUint8=xe.prototype.readUInt8=function(Le,Ge){return Le=Le>>>0,Ge||Fe(Le,1,this.length),this[Le]},xe.prototype.readUint16LE=xe.prototype.readUInt16LE=function(Le,Ge){return Le=Le>>>0,Ge||Fe(Le,2,this.length),this[Le]|this[Le+1]<<8},xe.prototype.readUint16BE=xe.prototype.readUInt16BE=function(Le,Ge){return Le=Le>>>0,Ge||Fe(Le,2,this.length),this[Le]<<8|this[Le+1]},xe.prototype.readUint32LE=xe.prototype.readUInt32LE=function(Le,Ge){return Le=Le>>>0,Ge||Fe(Le,4,this.length),(this[Le]|this[Le+1]<<8|this[Le+2]<<16)+this[Le+3]*16777216},xe.prototype.readUint32BE=xe.prototype.readUInt32BE=function(Le,Ge){return Le=Le>>>0,Ge||Fe(Le,4,this.length),this[Le]*16777216+(this[Le+1]<<16|this[Le+2]<<8|this[Le+3])},xe.prototype.readBigUInt64LE=Vt(function(Le){Le=Le>>>0,jt(Le,"offset");const Ge=this[Le],Mt=this[Le+7];(Ge===void 0||Mt===void 0)&&hn(Le,this.length-8);const Ft=Ge+this[++Le]*2**8+this[++Le]*2**16+this[++Le]*2**24,Qt=this[++Le]+this[++Le]*2**8+this[++Le]*2**16+Mt*2**24;return BigInt(Ft)+(BigInt(Qt)<<BigInt(32))}),xe.prototype.readBigUInt64BE=Vt(function(Le){Le=Le>>>0,jt(Le,"offset");const Ge=this[Le],Mt=this[Le+7];(Ge===void 0||Mt===void 0)&&hn(Le,this.length-8);const Ft=Ge*2**24+this[++Le]*2**16+this[++Le]*2**8+this[++Le],Qt=this[++Le]*2**24+this[++Le]*2**16+this[++Le]*2**8+Mt;return(BigInt(Ft)<<BigInt(32))+BigInt(Qt)}),xe.prototype.readIntLE=function(Le,Ge,Mt){Le=Le>>>0,Ge=Ge>>>0,Mt||Fe(Le,Ge,this.length);let Ft=this[Le],Qt=1,Wt=0;for(;++Wt<Ge&&(Qt*=256);)Ft+=this[Le+Wt]*Qt;return Qt*=128,Ft>=Qt&&(Ft-=Math.pow(2,8*Ge)),Ft},xe.prototype.readIntBE=function(Le,Ge,Mt){Le=Le>>>0,Ge=Ge>>>0,Mt||Fe(Le,Ge,this.length);let Ft=Ge,Qt=1,Wt=this[Le+--Ft];for(;Ft>0&&(Qt*=256);)Wt+=this[Le+--Ft]*Qt;return Qt*=128,Wt>=Qt&&(Wt-=Math.pow(2,8*Ge)),Wt},xe.prototype.readInt8=function(Le,Ge){return Le=Le>>>0,Ge||Fe(Le,1,this.length),this[Le]&128?(255-this[Le]+1)*-1:this[Le]},xe.prototype.readInt16LE=function(Le,Ge){Le=Le>>>0,Ge||Fe(Le,2,this.length);const Mt=this[Le]|this[Le+1]<<8;return Mt&32768?Mt|4294901760:Mt},xe.prototype.readInt16BE=function(Le,Ge){Le=Le>>>0,Ge||Fe(Le,2,this.length);const Mt=this[Le+1]|this[Le]<<8;return Mt&32768?Mt|4294901760:Mt},xe.prototype.readInt32LE=function(Le,Ge){return Le=Le>>>0,Ge||Fe(Le,4,this.length),this[Le]|this[Le+1]<<8|this[Le+2]<<16|this[Le+3]<<24},xe.prototype.readInt32BE=function(Le,Ge){return Le=Le>>>0,Ge||Fe(Le,4,this.length),this[Le]<<24|this[Le+1]<<16|this[Le+2]<<8|this[Le+3]},xe.prototype.readBigInt64LE=Vt(function(Le){Le=Le>>>0,jt(Le,"offset");const Ge=this[Le],Mt=this[Le+7];(Ge===void 0||Mt===void 0)&&hn(Le,this.length-8);const Ft=this[Le+4]+this[Le+5]*2**8+this[Le+6]*2**16+(Mt<<24);return(BigInt(Ft)<<BigInt(32))+BigInt(Ge+this[++Le]*2**8+this[++Le]*2**16+this[++Le]*2**24)}),xe.prototype.readBigInt64BE=Vt(function(Le){Le=Le>>>0,jt(Le,"offset");const Ge=this[Le],Mt=this[Le+7];(Ge===void 0||Mt===void 0)&&hn(Le,this.length-8);const Ft=(Ge<<24)+this[++Le]*2**16+this[++Le]*2**8+this[++Le];return(BigInt(Ft)<<BigInt(32))+BigInt(this[++Le]*2**24+this[++Le]*2**16+this[++Le]*2**8+Mt)}),xe.prototype.readFloatLE=function(Le,Ge){return Le=Le>>>0,Ge||Fe(Le,4,this.length),n.read(this,Le,!0,23,4)},xe.prototype.readFloatBE=function(Le,Ge){return Le=Le>>>0,Ge||Fe(Le,4,this.length),n.read(this,Le,!1,23,4)},xe.prototype.readDoubleLE=function(Le,Ge){return Le=Le>>>0,Ge||Fe(Le,8,this.length),n.read(this,Le,!0,52,8)},xe.prototype.readDoubleBE=function(Le,Ge){return Le=Le>>>0,Ge||Fe(Le,8,this.length),n.read(this,Le,!1,52,8)};function Ie(We,Le,Ge,Mt,Ft,Qt){if(!xe.isBuffer(We))throw new TypeError('"buffer" argument must be a Buffer instance');if(Le>Ft||Le<Qt)throw new RangeError('"value" argument is out of bounds');if(Ge+Mt>We.length)throw new RangeError("Index out of range")}xe.prototype.writeUintLE=xe.prototype.writeUIntLE=function(Le,Ge,Mt,Ft){if(Le=+Le,Ge=Ge>>>0,Mt=Mt>>>0,!Ft){const en=Math.pow(2,8*Mt)-1;Ie(this,Le,Ge,Mt,en,0)}let Qt=1,Wt=0;for(this[Ge]=Le&255;++Wt<Mt&&(Qt*=256);)this[Ge+Wt]=Le/Qt&255;return Ge+Mt},xe.prototype.writeUintBE=xe.prototype.writeUIntBE=function(Le,Ge,Mt,Ft){if(Le=+Le,Ge=Ge>>>0,Mt=Mt>>>0,!Ft){const en=Math.pow(2,8*Mt)-1;Ie(this,Le,Ge,Mt,en,0)}let Qt=Mt-1,Wt=1;for(this[Ge+Qt]=Le&255;--Qt>=0&&(Wt*=256);)this[Ge+Qt]=Le/Wt&255;return Ge+Mt},xe.prototype.writeUint8=xe.prototype.writeUInt8=function(Le,Ge,Mt){return Le=+Le,Ge=Ge>>>0,Mt||Ie(this,Le,Ge,1,255,0),this[Ge]=Le&255,Ge+1},xe.prototype.writeUint16LE=xe.prototype.writeUInt16LE=function(Le,Ge,Mt){return Le=+Le,Ge=Ge>>>0,Mt||Ie(this,Le,Ge,2,65535,0),this[Ge]=Le&255,this[Ge+1]=Le>>>8,Ge+2},xe.prototype.writeUint16BE=xe.prototype.writeUInt16BE=function(Le,Ge,Mt){return Le=+Le,Ge=Ge>>>0,Mt||Ie(this,Le,Ge,2,65535,0),this[Ge]=Le>>>8,this[Ge+1]=Le&255,Ge+2},xe.prototype.writeUint32LE=xe.prototype.writeUInt32LE=function(Le,Ge,Mt){return Le=+Le,Ge=Ge>>>0,Mt||Ie(this,Le,Ge,4,4294967295,0),this[Ge+3]=Le>>>24,this[Ge+2]=Le>>>16,this[Ge+1]=Le>>>8,this[Ge]=Le&255,Ge+4},xe.prototype.writeUint32BE=xe.prototype.writeUInt32BE=function(Le,Ge,Mt){return Le=+Le,Ge=Ge>>>0,Mt||Ie(this,Le,Ge,4,4294967295,0),this[Ge]=Le>>>24,this[Ge+1]=Le>>>16,this[Ge+2]=Le>>>8,this[Ge+3]=Le&255,Ge+4};function je(We,Le,Ge,Mt,Ft){Dt(Le,Mt,Ft,We,Ge,7);let Qt=Number(Le&BigInt(4294967295));We[Ge++]=Qt,Qt=Qt>>8,We[Ge++]=Qt,Qt=Qt>>8,We[Ge++]=Qt,Qt=Qt>>8,We[Ge++]=Qt;let Wt=Number(Le>>BigInt(32)&BigInt(4294967295));return We[Ge++]=Wt,Wt=Wt>>8,We[Ge++]=Wt,Wt=Wt>>8,We[Ge++]=Wt,Wt=Wt>>8,We[Ge++]=Wt,Ge}function Te(We,Le,Ge,Mt,Ft){Dt(Le,Mt,Ft,We,Ge,7);let Qt=Number(Le&BigInt(4294967295));We[Ge+7]=Qt,Qt=Qt>>8,We[Ge+6]=Qt,Qt=Qt>>8,We[Ge+5]=Qt,Qt=Qt>>8,We[Ge+4]=Qt;let Wt=Number(Le>>BigInt(32)&BigInt(4294967295));return We[Ge+3]=Wt,Wt=Wt>>8,We[Ge+2]=Wt,Wt=Wt>>8,We[Ge+1]=Wt,Wt=Wt>>8,We[Ge]=Wt,Ge+8}xe.prototype.writeBigUInt64LE=Vt(function(Le,Ge=0){return je(this,Le,Ge,BigInt(0),BigInt("0xffffffffffffffff"))}),xe.prototype.writeBigUInt64BE=Vt(function(Le,Ge=0){return Te(this,Le,Ge,BigInt(0),BigInt("0xffffffffffffffff"))}),xe.prototype.writeIntLE=function(Le,Ge,Mt,Ft){if(Le=+Le,Ge=Ge>>>0,!Ft){const En=Math.pow(2,8*Mt-1);Ie(this,Le,Ge,Mt,En-1,-En)}let Qt=0,Wt=1,en=0;for(this[Ge]=Le&255;++Qt<Mt&&(Wt*=256);)Le<0&&en===0&&this[Ge+Qt-1]!==0&&(en=1),this[Ge+Qt]=(Le/Wt>>0)-en&255;return Ge+Mt},xe.prototype.writeIntBE=function(Le,Ge,Mt,Ft){if(Le=+Le,Ge=Ge>>>0,!Ft){const En=Math.pow(2,8*Mt-1);Ie(this,Le,Ge,Mt,En-1,-En)}let Qt=Mt-1,Wt=1,en=0;for(this[Ge+Qt]=Le&255;--Qt>=0&&(Wt*=256);)Le<0&&en===0&&this[Ge+Qt+1]!==0&&(en=1),this[Ge+Qt]=(Le/Wt>>0)-en&255;return Ge+Mt},xe.prototype.writeInt8=function(Le,Ge,Mt){return Le=+Le,Ge=Ge>>>0,Mt||Ie(this,Le,Ge,1,127,-128),Le<0&&(Le=255+Le+1),this[Ge]=Le&255,Ge+1},xe.prototype.writeInt16LE=function(Le,Ge,Mt){return Le=+Le,Ge=Ge>>>0,Mt||Ie(this,Le,Ge,2,32767,-32768),this[Ge]=Le&255,this[Ge+1]=Le>>>8,Ge+2},xe.prototype.writeInt16BE=function(Le,Ge,Mt){return Le=+Le,Ge=Ge>>>0,Mt||Ie(this,Le,Ge,2,32767,-32768),this[Ge]=Le>>>8,this[Ge+1]=Le&255,Ge+2},xe.prototype.writeInt32LE=function(Le,Ge,Mt){return Le=+Le,Ge=Ge>>>0,Mt||Ie(this,Le,Ge,4,2147483647,-2147483648),this[Ge]=Le&255,this[Ge+1]=Le>>>8,this[Ge+2]=Le>>>16,this[Ge+3]=Le>>>24,Ge+4},xe.prototype.writeInt32BE=function(Le,Ge,Mt){return Le=+Le,Ge=Ge>>>0,Mt||Ie(this,Le,Ge,4,2147483647,-2147483648),Le<0&&(Le=4294967295+Le+1),this[Ge]=Le>>>24,this[Ge+1]=Le>>>16,this[Ge+2]=Le>>>8,this[Ge+3]=Le&255,Ge+4},xe.prototype.writeBigInt64LE=Vt(function(Le,Ge=0){return je(this,Le,Ge,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),xe.prototype.writeBigInt64BE=Vt(function(Le,Ge=0){return Te(this,Le,Ge,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function De(We,Le,Ge,Mt,Ft,Qt){if(Ge+Mt>We.length)throw new RangeError("Index out of range");if(Ge<0)throw new RangeError("Index out of range")}function ze(We,Le,Ge,Mt,Ft){return Le=+Le,Ge=Ge>>>0,Ft||De(We,Le,Ge,4),n.write(We,Le,Ge,Mt,23,4),Ge+4}xe.prototype.writeFloatLE=function(Le,Ge,Mt){return ze(this,Le,Ge,!0,Mt)},xe.prototype.writeFloatBE=function(Le,Ge,Mt){return ze(this,Le,Ge,!1,Mt)};function Xe(We,Le,Ge,Mt,Ft){return Le=+Le,Ge=Ge>>>0,Ft||De(We,Le,Ge,8),n.write(We,Le,Ge,Mt,52,8),Ge+8}xe.prototype.writeDoubleLE=function(Le,Ge,Mt){return Xe(this,Le,Ge,!0,Mt)},xe.prototype.writeDoubleBE=function(Le,Ge,Mt){return Xe(this,Le,Ge,!1,Mt)},xe.prototype.copy=function(Le,Ge,Mt,Ft){if(!xe.isBuffer(Le))throw new TypeError("argument should be a Buffer");if(Mt||(Mt=0),!Ft&&Ft!==0&&(Ft=this.length),Ge>=Le.length&&(Ge=Le.length),Ge||(Ge=0),Ft>0&&Ft<Mt&&(Ft=Mt),Ft===Mt||Le.length===0||this.length===0)return 0;if(Ge<0)throw new RangeError("targetStart out of bounds");if(Mt<0||Mt>=this.length)throw new RangeError("Index out of range");if(Ft<0)throw new RangeError("sourceEnd out of bounds");Ft>this.length&&(Ft=this.length),Le.length-Ge<Ft-Mt&&(Ft=Le.length-Ge+Mt);const Qt=Ft-Mt;return this===Le&&typeof ae.prototype.copyWithin=="function"?this.copyWithin(Ge,Mt,Ft):ae.prototype.set.call(Le,this.subarray(Mt,Ft),Ge),Qt},xe.prototype.fill=function(Le,Ge,Mt,Ft){if(typeof Le=="string"){if(typeof Ge=="string"?(Ft=Ge,Ge=0,Mt=this.length):typeof Mt=="string"&&(Ft=Mt,Mt=this.length),Ft!==void 0&&typeof Ft!="string")throw new TypeError("encoding must be a string");if(typeof Ft=="string"&&!xe.isEncoding(Ft))throw new TypeError("Unknown encoding: "+Ft);if(Le.length===1){const Wt=Le.charCodeAt(0);(Ft==="utf8"&&Wt<128||Ft==="latin1")&&(Le=Wt)}}else typeof Le=="number"?Le=Le&255:typeof Le=="boolean"&&(Le=Number(Le));if(Ge<0||this.length<Ge||this.length<Mt)throw new RangeError("Out of range index");if(Mt<=Ge)return this;Ge=Ge>>>0,Mt=Mt===void 0?this.length:Mt>>>0,Le||(Le=0);let Qt;if(typeof Le=="number")for(Qt=Ge;Qt<Mt;++Qt)this[Qt]=Le;else{const Wt=xe.isBuffer(Le)?Le:xe.from(Le,Ft),en=Wt.length;if(en===0)throw new TypeError('The value "'+Le+'" is invalid for argument "value"');for(Qt=0;Qt<Mt-Ge;++Qt)this[Qt+Ge]=Wt[Qt%en]}return this};const Rt={};function Oe(We,Le,Ge){Rt[We]=class extends Ge{constructor(){super(),Object.defineProperty(this,"message",{value:Le.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${We}]`,this.stack,delete this.name}get code(){return We}set code(Ft){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:Ft,writable:!0})}toString(){return`${this.name} [${We}]: ${this.message}`}}}Oe("ERR_BUFFER_OUT_OF_BOUNDS",function(We){return We?`${We} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Oe("ERR_INVALID_ARG_TYPE",function(We,Le){return`The "${We}" argument must be of type number. Received type ${typeof Le}`},TypeError),Oe("ERR_OUT_OF_RANGE",function(We,Le,Ge){let Mt=`The value of "${We}" is out of range.`,Ft=Ge;return Number.isInteger(Ge)&&Math.abs(Ge)>2**32?Ft=Ze(String(Ge)):typeof Ge=="bigint"&&(Ft=String(Ge),(Ge>BigInt(2)**BigInt(32)||Ge<-(BigInt(2)**BigInt(32)))&&(Ft=Ze(Ft)),Ft+="n"),Mt+=` It must be ${Le}. Received ${Ft}`,Mt},RangeError);function Ze(We){let Le="",Ge=We.length;const Mt=We[0]==="-"?1:0;for(;Ge>=Mt+4;Ge-=3)Le=`_${We.slice(Ge-3,Ge)}${Le}`;return`${We.slice(0,Ge)}${Le}`}function Gt(We,Le,Ge){jt(Le,"offset"),(We[Le]===void 0||We[Le+Ge]===void 0)&&hn(Le,We.length-(Ge+1))}function Dt(We,Le,Ge,Mt,Ft,Qt){if(We>Ge||We<Le){const Wt=typeof Le=="bigint"?"n":"";let en;throw Le===0||Le===BigInt(0)?en=`>= 0${Wt} and < 2${Wt} ** ${(Qt+1)*8}${Wt}`:en=`>= -(2${Wt} ** ${(Qt+1)*8-1}${Wt}) and < 2 ** ${(Qt+1)*8-1}${Wt}`,new Rt.ERR_OUT_OF_RANGE("value",en,We)}Gt(Mt,Ft,Qt)}function jt(We,Le){if(typeof We!="number")throw new Rt.ERR_INVALID_ARG_TYPE(Le,"number",We)}function hn(We,Le,Ge){throw Math.floor(We)!==We?(jt(We,Ge),new Rt.ERR_OUT_OF_RANGE("offset","an integer",We)):Le<0?new Rt.ERR_BUFFER_OUT_OF_BOUNDS:new Rt.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${Le}`,We)}const Zt=/[^+/0-9A-Za-z-_]/g;function Kt(We){if(We=We.split("=")[0],We=We.trim().replace(Zt,""),We.length<2)return"";for(;We.length%4!==0;)We=We+"=";return We}function An(We,Le){Le=Le||1/0;let Ge;const Mt=We.length;let Ft=null;const Qt=[];for(let Wt=0;Wt<Mt;++Wt){if(Ge=We.charCodeAt(Wt),Ge>55295&&Ge<57344){if(!Ft){if(Ge>56319){(Le-=3)>-1&&Qt.push(239,191,189);continue}else if(Wt+1===Mt){(Le-=3)>-1&&Qt.push(239,191,189);continue}Ft=Ge;continue}if(Ge<56320){(Le-=3)>-1&&Qt.push(239,191,189),Ft=Ge;continue}Ge=(Ft-55296<<10|Ge-56320)+65536}else Ft&&(Le-=3)>-1&&Qt.push(239,191,189);if(Ft=null,Ge<128){if((Le-=1)<0)break;Qt.push(Ge)}else if(Ge<2048){if((Le-=2)<0)break;Qt.push(Ge>>6|192,Ge&63|128)}else if(Ge<65536){if((Le-=3)<0)break;Qt.push(Ge>>12|224,Ge>>6&63|128,Ge&63|128)}else if(Ge<1114112){if((Le-=4)<0)break;Qt.push(Ge>>18|240,Ge>>12&63|128,Ge>>6&63|128,Ge&63|128)}else throw new Error("Invalid code point")}return Qt}function Yt(We){const Le=[];for(let Ge=0;Ge<We.length;++Ge)Le.push(We.charCodeAt(Ge)&255);return Le}function Jt(We,Le){let Ge,Mt,Ft;const Qt=[];for(let Wt=0;Wt<We.length&&!((Le-=2)<0);++Wt)Ge=We.charCodeAt(Wt),Mt=Ge>>8,Ft=Ge%256,Qt.push(Ft),Qt.push(Mt);return Qt}function _n(We){return t.toByteArray(Kt(We))}function Je(We,Le,Ge,Mt){let Ft;for(Ft=0;Ft<Mt&&!(Ft+Ge>=Le.length||Ft>=We.length);++Ft)Le[Ft+Ge]=We[Ft];return Ft}function $t(We,Le){return We instanceof Le||We!=null&&We.constructor!=null&&We.constructor.name!=null&&We.constructor.name===Le.name}function Xt(We){return We!==We}const Ht=function(){const We="0123456789abcdef",Le=new Array(256);for(let Ge=0;Ge<16;++Ge){const Mt=Ge*16;for(let Ft=0;Ft<16;++Ft)Le[Mt+Ft]=We[Ge]+We[Ft]}return Le}();function Vt(We){return typeof BigInt>"u"?rn:We}function rn(){throw new Error("BigInt not supported")}})(buffer$1);const Buffer$7=buffer$1.Buffer,Blob$2=buffer$1.Blob,BlobOptions=buffer$1.BlobOptions,Buffer$1$1=buffer$1.Buffer,File=buffer$1.File,FileOptions=buffer$1.FileOptions,INSPECT_MAX_BYTES=buffer$1.INSPECT_MAX_BYTES,SlowBuffer=buffer$1.SlowBuffer,TranscodeEncoding=buffer$1.TranscodeEncoding,atob$1=buffer$1.atob,btoa$1=buffer$1.btoa,constants$4=buffer$1.constants,isAscii=buffer$1.isAscii,isUtf8=buffer$1.isUtf8,kMaxLength=buffer$1.kMaxLength,kStringMaxLength=buffer$1.kStringMaxLength,resolveObjectURL=buffer$1.resolveObjectURL,transcode=buffer$1.transcode,dist$1=Object.freeze(Object.defineProperty({__proto__:null,Blob:Blob$2,BlobOptions,Buffer:Buffer$1$1,File,FileOptions,INSPECT_MAX_BYTES,SlowBuffer,TranscodeEncoding,atob:atob$1,btoa:btoa$1,constants:constants$4,default:Buffer$7,isAscii,isUtf8,kMaxLength,kStringMaxLength,resolveObjectURL,transcode},Symbol.toStringTag,{value:"Module"})),require$$0$4=getAugmentedNamespace(dist$1);bn$8.exports;(function(c){(function(t,n){function ie(ce,de){if(!ce)throw new Error(de||"Assertion failed")}function fe(ce,de){ce.super_=de;var pe=function(){};pe.prototype=de.prototype,ce.prototype=new pe,ce.prototype.constructor=ce}function ae(ce,de,pe){if(ae.isBN(ce))return ce;this.negative=0,this.words=null,this.length=0,this.red=null,ce!==null&&((de==="le"||de==="be")&&(pe=de,de=10),this._init(ce||0,de||10,pe||"be"))}typeof t=="object"?t.exports=ae:n.BN=ae,ae.BN=ae,ae.wordSize=26;var le;try{typeof window<"u"&&typeof window.Buffer<"u"?le=window.Buffer:le=require$$0$4.Buffer}catch{}ae.isBN=function(de){return de instanceof ae?!0:de!==null&&typeof de=="object"&&de.constructor.wordSize===ae.wordSize&&Array.isArray(de.words)},ae.max=function(de,pe){return de.cmp(pe)>0?de:pe},ae.min=function(de,pe){return de.cmp(pe)<0?de:pe},ae.prototype._init=function(de,pe,ve){if(typeof de=="number")return this._initNumber(de,pe,ve);if(typeof de=="object")return this._initArray(de,pe,ve);pe==="hex"&&(pe=16),ie(pe===(pe|0)&&pe>=2&&pe<=36),de=de.toString().replace(/\s+/g,"");var we=0;de[0]==="-"&&(we++,this.negative=1),we<de.length&&(pe===16?this._parseHex(de,we,ve):(this._parseBase(de,pe,we),ve==="le"&&this._initArray(this.toArray(),pe,ve)))},ae.prototype._initNumber=function(de,pe,ve){de<0&&(this.negative=1,de=-de),de<67108864?(this.words=[de&67108863],this.length=1):de<4503599627370496?(this.words=[de&67108863,de/67108864&67108863],this.length=2):(ie(de<9007199254740992),this.words=[de&67108863,de/67108864&67108863,1],this.length=3),ve==="le"&&this._initArray(this.toArray(),pe,ve)},ae.prototype._initArray=function(de,pe,ve){if(ie(typeof de.length=="number"),de.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(de.length/3),this.words=new Array(this.length);for(var we=0;we<this.length;we++)this.words[we]=0;var Ae,ge,ue=0;if(ve==="be")for(we=de.length-1,Ae=0;we>=0;we-=3)ge=de[we]|de[we-1]<<8|de[we-2]<<16,this.words[Ae]|=ge<<ue&67108863,this.words[Ae+1]=ge>>>26-ue&67108863,ue+=24,ue>=26&&(ue-=26,Ae++);else if(ve==="le")for(we=0,Ae=0;we<de.length;we+=3)ge=de[we]|de[we+1]<<8|de[we+2]<<16,this.words[Ae]|=ge<<ue&67108863,this.words[Ae+1]=ge>>>26-ue&67108863,ue+=24,ue>=26&&(ue-=26,Ae++);return this._strip()};function he(ce,de){var pe=ce.charCodeAt(de);if(pe>=48&&pe<=57)return pe-48;if(pe>=65&&pe<=70)return pe-55;if(pe>=97&&pe<=102)return pe-87;ie(!1,"Invalid character in "+ce)}function ye(ce,de,pe){var ve=he(ce,pe);return pe-1>=de&&(ve|=he(ce,pe-1)<<4),ve}ae.prototype._parseHex=function(de,pe,ve){this.length=Math.ceil((de.length-pe)/6),this.words=new Array(this.length);for(var we=0;we<this.length;we++)this.words[we]=0;var Ae=0,ge=0,ue;if(ve==="be")for(we=de.length-1;we>=pe;we-=2)ue=ye(de,pe,we)<<Ae,this.words[ge]|=ue&67108863,Ae>=18?(Ae-=18,ge+=1,this.words[ge]|=ue>>>26):Ae+=8;else{var be=de.length-pe;for(we=be%2===0?pe+1:pe;we<de.length;we+=2)ue=ye(de,pe,we)<<Ae,this.words[ge]|=ue&67108863,Ae>=18?(Ae-=18,ge+=1,this.words[ge]|=ue>>>26):Ae+=8}this._strip()};function me(ce,de,pe,ve){for(var we=0,Ae=0,ge=Math.min(ce.length,pe),ue=de;ue<ge;ue++){var be=ce.charCodeAt(ue)-48;we*=ve,be>=49?Ae=be-49+10:be>=17?Ae=be-17+10:Ae=be,ie(be>=0&&Ae<ve,"Invalid character"),we+=Ae}return we}ae.prototype._parseBase=function(de,pe,ve){this.words=[0],this.length=1;for(var we=0,Ae=1;Ae<=67108863;Ae*=pe)we++;we--,Ae=Ae/pe|0;for(var ge=de.length-ve,ue=ge%we,be=Math.min(ge,ge-ue)+ve,Re=0,Ne=ve;Ne<be;Ne+=we)Re=me(de,Ne,Ne+we,pe),this.imuln(Ae),this.words[0]+Re<67108864?this.words[0]+=Re:this._iaddn(Re);if(ue!==0){var Fe=1;for(Re=me(de,Ne,de.length,pe),Ne=0;Ne<ue;Ne++)Fe*=pe;this.imuln(Fe),this.words[0]+Re<67108864?this.words[0]+=Re:this._iaddn(Re)}this._strip()},ae.prototype.copy=function(de){de.words=new Array(this.length);for(var pe=0;pe<this.length;pe++)de.words[pe]=this.words[pe];de.length=this.length,de.negative=this.negative,de.red=this.red};function xe(ce,de){ce.words=de.words,ce.length=de.length,ce.negative=de.negative,ce.red=de.red}if(ae.prototype._move=function(de){xe(de,this)},ae.prototype.clone=function(){var de=new ae(null);return this.copy(de),de},ae.prototype._expand=function(de){for(;this.length<de;)this.words[this.length++]=0;return this},ae.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},ae.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{ae.prototype[Symbol.for("nodejs.util.inspect.custom")]=Ee}catch{ae.prototype.inspect=Ee}else ae.prototype.inspect=Ee;function Ee(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var Se=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],Me=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],Be=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];ae.prototype.toString=function(de,pe){de=de||10,pe=pe|0||1;var ve;if(de===16||de==="hex"){ve="";for(var we=0,Ae=0,ge=0;ge<this.length;ge++){var ue=this.words[ge],be=((ue<<we|Ae)&16777215).toString(16);Ae=ue>>>24-we&16777215,we+=2,we>=26&&(we-=26,ge--),Ae!==0||ge!==this.length-1?ve=Se[6-be.length]+be+ve:ve=be+ve}for(Ae!==0&&(ve=Ae.toString(16)+ve);ve.length%pe!==0;)ve="0"+ve;return this.negative!==0&&(ve="-"+ve),ve}if(de===(de|0)&&de>=2&&de<=36){var Re=Me[de],Ne=Be[de];ve="";var Fe=this.clone();for(Fe.negative=0;!Fe.isZero();){var Ie=Fe.modrn(Ne).toString(de);Fe=Fe.idivn(Ne),Fe.isZero()?ve=Ie+ve:ve=Se[Re-Ie.length]+Ie+ve}for(this.isZero()&&(ve="0"+ve);ve.length%pe!==0;)ve="0"+ve;return this.negative!==0&&(ve="-"+ve),ve}ie(!1,"Base should be between 2 and 36")},ae.prototype.toNumber=function(){var de=this.words[0];return this.length===2?de+=this.words[1]*67108864:this.length===3&&this.words[2]===1?de+=4503599627370496+this.words[1]*67108864:this.length>2&&ie(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-de:de},ae.prototype.toJSON=function(){return this.toString(16,2)},le&&(ae.prototype.toBuffer=function(de,pe){return this.toArrayLike(le,de,pe)}),ae.prototype.toArray=function(de,pe){return this.toArrayLike(Array,de,pe)};var $e=function(de,pe){return de.allocUnsafe?de.allocUnsafe(pe):new de(pe)};ae.prototype.toArrayLike=function(de,pe,ve){this._strip();var we=this.byteLength(),Ae=ve||Math.max(1,we);ie(we<=Ae,"byte array longer than desired length"),ie(Ae>0,"Requested array length <= 0");var ge=$e(de,Ae),ue=pe==="le"?"LE":"BE";return this["_toArrayLike"+ue](ge,we),ge},ae.prototype._toArrayLikeLE=function(de,pe){for(var ve=0,we=0,Ae=0,ge=0;Ae<this.length;Ae++){var ue=this.words[Ae]<<ge|we;de[ve++]=ue&255,ve<de.length&&(de[ve++]=ue>>8&255),ve<de.length&&(de[ve++]=ue>>16&255),ge===6?(ve<de.length&&(de[ve++]=ue>>24&255),we=0,ge=0):(we=ue>>>24,ge+=2)}if(ve<de.length)for(de[ve++]=we;ve<de.length;)de[ve++]=0},ae.prototype._toArrayLikeBE=function(de,pe){for(var ve=de.length-1,we=0,Ae=0,ge=0;Ae<this.length;Ae++){var ue=this.words[Ae]<<ge|we;de[ve--]=ue&255,ve>=0&&(de[ve--]=ue>>8&255),ve>=0&&(de[ve--]=ue>>16&255),ge===6?(ve>=0&&(de[ve--]=ue>>24&255),we=0,ge=0):(we=ue>>>24,ge+=2)}if(ve>=0)for(de[ve--]=we;ve>=0;)de[ve--]=0},Math.clz32?ae.prototype._countBits=function(de){return 32-Math.clz32(de)}:ae.prototype._countBits=function(de){var pe=de,ve=0;return pe>=4096&&(ve+=13,pe>>>=13),pe>=64&&(ve+=7,pe>>>=7),pe>=8&&(ve+=4,pe>>>=4),pe>=2&&(ve+=2,pe>>>=2),ve+pe},ae.prototype._zeroBits=function(de){if(de===0)return 26;var pe=de,ve=0;return pe&8191||(ve+=13,pe>>>=13),pe&127||(ve+=7,pe>>>=7),pe&15||(ve+=4,pe>>>=4),pe&3||(ve+=2,pe>>>=2),pe&1||ve++,ve},ae.prototype.bitLength=function(){var de=this.words[this.length-1],pe=this._countBits(de);return(this.length-1)*26+pe};function Ce(ce){for(var de=new Array(ce.bitLength()),pe=0;pe<de.length;pe++){var ve=pe/26|0,we=pe%26;de[pe]=ce.words[ve]>>>we&1}return de}ae.prototype.zeroBits=function(){if(this.isZero())return 0;for(var de=0,pe=0;pe<this.length;pe++){var ve=this._zeroBits(this.words[pe]);if(de+=ve,ve!==26)break}return de},ae.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},ae.prototype.toTwos=function(de){return this.negative!==0?this.abs().inotn(de).iaddn(1):this.clone()},ae.prototype.fromTwos=function(de){return this.testn(de-1)?this.notn(de).iaddn(1).ineg():this.clone()},ae.prototype.isNeg=function(){return this.negative!==0},ae.prototype.neg=function(){return this.clone().ineg()},ae.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},ae.prototype.iuor=function(de){for(;this.length<de.length;)this.words[this.length++]=0;for(var pe=0;pe<de.length;pe++)this.words[pe]=this.words[pe]|de.words[pe];return this._strip()},ae.prototype.ior=function(de){return ie((this.negative|de.negative)===0),this.iuor(de)},ae.prototype.or=function(de){return this.length>de.length?this.clone().ior(de):de.clone().ior(this)},ae.prototype.uor=function(de){return this.length>de.length?this.clone().iuor(de):de.clone().iuor(this)},ae.prototype.iuand=function(de){var pe;this.length>de.length?pe=de:pe=this;for(var ve=0;ve<pe.length;ve++)this.words[ve]=this.words[ve]&de.words[ve];return this.length=pe.length,this._strip()},ae.prototype.iand=function(de){return ie((this.negative|de.negative)===0),this.iuand(de)},ae.prototype.and=function(de){return this.length>de.length?this.clone().iand(de):de.clone().iand(this)},ae.prototype.uand=function(de){return this.length>de.length?this.clone().iuand(de):de.clone().iuand(this)},ae.prototype.iuxor=function(de){var pe,ve;this.length>de.length?(pe=this,ve=de):(pe=de,ve=this);for(var we=0;we<ve.length;we++)this.words[we]=pe.words[we]^ve.words[we];if(this!==pe)for(;we<pe.length;we++)this.words[we]=pe.words[we];return this.length=pe.length,this._strip()},ae.prototype.ixor=function(de){return ie((this.negative|de.negative)===0),this.iuxor(de)},ae.prototype.xor=function(de){return this.length>de.length?this.clone().ixor(de):de.clone().ixor(this)},ae.prototype.uxor=function(de){return this.length>de.length?this.clone().iuxor(de):de.clone().iuxor(this)},ae.prototype.inotn=function(de){ie(typeof de=="number"&&de>=0);var pe=Math.ceil(de/26)|0,ve=de%26;this._expand(pe),ve>0&&pe--;for(var we=0;we<pe;we++)this.words[we]=~this.words[we]&67108863;return ve>0&&(this.words[we]=~this.words[we]&67108863>>26-ve),this._strip()},ae.prototype.notn=function(de){return this.clone().inotn(de)},ae.prototype.setn=function(de,pe){ie(typeof de=="number"&&de>=0);var ve=de/26|0,we=de%26;return this._expand(ve+1),pe?this.words[ve]=this.words[ve]|1<<we:this.words[ve]=this.words[ve]&~(1<<we),this._strip()},ae.prototype.iadd=function(de){var pe;if(this.negative!==0&&de.negative===0)return this.negative=0,pe=this.isub(de),this.negative^=1,this._normSign();if(this.negative===0&&de.negative!==0)return de.negative=0,pe=this.isub(de),de.negative=1,pe._normSign();var ve,we;this.length>de.length?(ve=this,we=de):(ve=de,we=this);for(var Ae=0,ge=0;ge<we.length;ge++)pe=(ve.words[ge]|0)+(we.words[ge]|0)+Ae,this.words[ge]=pe&67108863,Ae=pe>>>26;for(;Ae!==0&&ge<ve.length;ge++)pe=(ve.words[ge]|0)+Ae,this.words[ge]=pe&67108863,Ae=pe>>>26;if(this.length=ve.length,Ae!==0)this.words[this.length]=Ae,this.length++;else if(ve!==this)for(;ge<ve.length;ge++)this.words[ge]=ve.words[ge];return this},ae.prototype.add=function(de){var pe;return de.negative!==0&&this.negative===0?(de.negative=0,pe=this.sub(de),de.negative^=1,pe):de.negative===0&&this.negative!==0?(this.negative=0,pe=de.sub(this),this.negative=1,pe):this.length>de.length?this.clone().iadd(de):de.clone().iadd(this)},ae.prototype.isub=function(de){if(de.negative!==0){de.negative=0;var pe=this.iadd(de);return de.negative=1,pe._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(de),this.negative=1,this._normSign();var ve=this.cmp(de);if(ve===0)return this.negative=0,this.length=1,this.words[0]=0,this;var we,Ae;ve>0?(we=this,Ae=de):(we=de,Ae=this);for(var ge=0,ue=0;ue<Ae.length;ue++)pe=(we.words[ue]|0)-(Ae.words[ue]|0)+ge,ge=pe>>26,this.words[ue]=pe&67108863;for(;ge!==0&&ue<we.length;ue++)pe=(we.words[ue]|0)+ge,ge=pe>>26,this.words[ue]=pe&67108863;if(ge===0&&ue<we.length&&we!==this)for(;ue<we.length;ue++)this.words[ue]=we.words[ue];return this.length=Math.max(this.length,ue),we!==this&&(this.negative=1),this._strip()},ae.prototype.sub=function(de){return this.clone().isub(de)};function ke(ce,de,pe){pe.negative=de.negative^ce.negative;var ve=ce.length+de.length|0;pe.length=ve,ve=ve-1|0;var we=ce.words[0]|0,Ae=de.words[0]|0,ge=we*Ae,ue=ge&67108863,be=ge/67108864|0;pe.words[0]=ue;for(var Re=1;Re<ve;Re++){for(var Ne=be>>>26,Fe=be&67108863,Ie=Math.min(Re,de.length-1),je=Math.max(0,Re-ce.length+1);je<=Ie;je++){var Te=Re-je|0;we=ce.words[Te]|0,Ae=de.words[je]|0,ge=we*Ae+Fe,Ne+=ge/67108864|0,Fe=ge&67108863}pe.words[Re]=Fe|0,be=Ne|0}return be!==0?pe.words[Re]=be|0:pe.length--,pe._strip()}var Pe=function(de,pe,ve){var we=de.words,Ae=pe.words,ge=ve.words,ue=0,be,Re,Ne,Fe=we[0]|0,Ie=Fe&8191,je=Fe>>>13,Te=we[1]|0,De=Te&8191,ze=Te>>>13,Xe=we[2]|0,Rt=Xe&8191,Oe=Xe>>>13,Ze=we[3]|0,Gt=Ze&8191,Dt=Ze>>>13,jt=we[4]|0,hn=jt&8191,Zt=jt>>>13,Kt=we[5]|0,An=Kt&8191,Yt=Kt>>>13,Jt=we[6]|0,_n=Jt&8191,Je=Jt>>>13,$t=we[7]|0,Xt=$t&8191,Ht=$t>>>13,Vt=we[8]|0,rn=Vt&8191,We=Vt>>>13,Le=we[9]|0,Ge=Le&8191,Mt=Le>>>13,Ft=Ae[0]|0,Qt=Ft&8191,Wt=Ft>>>13,en=Ae[1]|0,En=en&8191,tn=en>>>13,nn=Ae[2]|0,Sn=nn&8191,an=nn>>>13,pn=Ae[3]|0,Bn=pn&8191,sn=pn>>>13,yn=Ae[4]|0,$n=yn&8191,fn=yn>>>13,mn=Ae[5]|0,kn=mn&8191,un=mn>>>13,gn=Ae[6]|0,Cn=gn&8191,cn=gn>>>13,vn=Ae[7]|0,Tn=vn&8191,ln=vn>>>13,xn=Ae[8]|0,Nn=xn&8191,dn=xn>>>13,wn=Ae[9]|0,Mn=wn&8191,Rn=wn>>>13;ve.negative=de.negative^pe.negative,ve.length=19,be=Math.imul(Ie,Qt),Re=Math.imul(Ie,Wt),Re=Re+Math.imul(je,Qt)|0,Ne=Math.imul(je,Wt);var Pn=(ue+be|0)+((Re&8191)<<13)|0;ue=(Ne+(Re>>>13)|0)+(Pn>>>26)|0,Pn&=67108863,be=Math.imul(De,Qt),Re=Math.imul(De,Wt),Re=Re+Math.imul(ze,Qt)|0,Ne=Math.imul(ze,Wt),be=be+Math.imul(Ie,En)|0,Re=Re+Math.imul(Ie,tn)|0,Re=Re+Math.imul(je,En)|0,Ne=Ne+Math.imul(je,tn)|0;var In=(ue+be|0)+((Re&8191)<<13)|0;ue=(Ne+(Re>>>13)|0)+(In>>>26)|0,In&=67108863,be=Math.imul(Rt,Qt),Re=Math.imul(Rt,Wt),Re=Re+Math.imul(Oe,Qt)|0,Ne=Math.imul(Oe,Wt),be=be+Math.imul(De,En)|0,Re=Re+Math.imul(De,tn)|0,Re=Re+Math.imul(ze,En)|0,Ne=Ne+Math.imul(ze,tn)|0,be=be+Math.imul(Ie,Sn)|0,Re=Re+Math.imul(Ie,an)|0,Re=Re+Math.imul(je,Sn)|0,Ne=Ne+Math.imul(je,an)|0;var On=(ue+be|0)+((Re&8191)<<13)|0;ue=(Ne+(Re>>>13)|0)+(On>>>26)|0,On&=67108863,be=Math.imul(Gt,Qt),Re=Math.imul(Gt,Wt),Re=Re+Math.imul(Dt,Qt)|0,Ne=Math.imul(Dt,Wt),be=be+Math.imul(Rt,En)|0,Re=Re+Math.imul(Rt,tn)|0,Re=Re+Math.imul(Oe,En)|0,Ne=Ne+Math.imul(Oe,tn)|0,be=be+Math.imul(De,Sn)|0,Re=Re+Math.imul(De,an)|0,Re=Re+Math.imul(ze,Sn)|0,Ne=Ne+Math.imul(ze,an)|0,be=be+Math.imul(Ie,Bn)|0,Re=Re+Math.imul(Ie,sn)|0,Re=Re+Math.imul(je,Bn)|0,Ne=Ne+Math.imul(je,sn)|0;var Dn=(ue+be|0)+((Re&8191)<<13)|0;ue=(Ne+(Re>>>13)|0)+(Dn>>>26)|0,Dn&=67108863,be=Math.imul(hn,Qt),Re=Math.imul(hn,Wt),Re=Re+Math.imul(Zt,Qt)|0,Ne=Math.imul(Zt,Wt),be=be+Math.imul(Gt,En)|0,Re=Re+Math.imul(Gt,tn)|0,Re=Re+Math.imul(Dt,En)|0,Ne=Ne+Math.imul(Dt,tn)|0,be=be+Math.imul(Rt,Sn)|0,Re=Re+Math.imul(Rt,an)|0,Re=Re+Math.imul(Oe,Sn)|0,Ne=Ne+Math.imul(Oe,an)|0,be=be+Math.imul(De,Bn)|0,Re=Re+Math.imul(De,sn)|0,Re=Re+Math.imul(ze,Bn)|0,Ne=Ne+Math.imul(ze,sn)|0,be=be+Math.imul(Ie,$n)|0,Re=Re+Math.imul(Ie,fn)|0,Re=Re+Math.imul(je,$n)|0,Ne=Ne+Math.imul(je,fn)|0;var Ln=(ue+be|0)+((Re&8191)<<13)|0;ue=(Ne+(Re>>>13)|0)+(Ln>>>26)|0,Ln&=67108863,be=Math.imul(An,Qt),Re=Math.imul(An,Wt),Re=Re+Math.imul(Yt,Qt)|0,Ne=Math.imul(Yt,Wt),be=be+Math.imul(hn,En)|0,Re=Re+Math.imul(hn,tn)|0,Re=Re+Math.imul(Zt,En)|0,Ne=Ne+Math.imul(Zt,tn)|0,be=be+Math.imul(Gt,Sn)|0,Re=Re+Math.imul(Gt,an)|0,Re=Re+Math.imul(Dt,Sn)|0,Ne=Ne+Math.imul(Dt,an)|0,be=be+Math.imul(Rt,Bn)|0,Re=Re+Math.imul(Rt,sn)|0,Re=Re+Math.imul(Oe,Bn)|0,Ne=Ne+Math.imul(Oe,sn)|0,be=be+Math.imul(De,$n)|0,Re=Re+Math.imul(De,fn)|0,Re=Re+Math.imul(ze,$n)|0,Ne=Ne+Math.imul(ze,fn)|0,be=be+Math.imul(Ie,kn)|0,Re=Re+Math.imul(Ie,un)|0,Re=Re+Math.imul(je,kn)|0,Ne=Ne+Math.imul(je,un)|0;var Fn=(ue+be|0)+((Re&8191)<<13)|0;ue=(Ne+(Re>>>13)|0)+(Fn>>>26)|0,Fn&=67108863,be=Math.imul(_n,Qt),Re=Math.imul(_n,Wt),Re=Re+Math.imul(Je,Qt)|0,Ne=Math.imul(Je,Wt),be=be+Math.imul(An,En)|0,Re=Re+Math.imul(An,tn)|0,Re=Re+Math.imul(Yt,En)|0,Ne=Ne+Math.imul(Yt,tn)|0,be=be+Math.imul(hn,Sn)|0,Re=Re+Math.imul(hn,an)|0,Re=Re+Math.imul(Zt,Sn)|0,Ne=Ne+Math.imul(Zt,an)|0,be=be+Math.imul(Gt,Bn)|0,Re=Re+Math.imul(Gt,sn)|0,Re=Re+Math.imul(Dt,Bn)|0,Ne=Ne+Math.imul(Dt,sn)|0,be=be+Math.imul(Rt,$n)|0,Re=Re+Math.imul(Rt,fn)|0,Re=Re+Math.imul(Oe,$n)|0,Ne=Ne+Math.imul(Oe,fn)|0,be=be+Math.imul(De,kn)|0,Re=Re+Math.imul(De,un)|0,Re=Re+Math.imul(ze,kn)|0,Ne=Ne+Math.imul(ze,un)|0,be=be+Math.imul(Ie,Cn)|0,Re=Re+Math.imul(Ie,cn)|0,Re=Re+Math.imul(je,Cn)|0,Ne=Ne+Math.imul(je,cn)|0;var qn=(ue+be|0)+((Re&8191)<<13)|0;ue=(Ne+(Re>>>13)|0)+(qn>>>26)|0,qn&=67108863,be=Math.imul(Xt,Qt),Re=Math.imul(Xt,Wt),Re=Re+Math.imul(Ht,Qt)|0,Ne=Math.imul(Ht,Wt),be=be+Math.imul(_n,En)|0,Re=Re+Math.imul(_n,tn)|0,Re=Re+Math.imul(Je,En)|0,Ne=Ne+Math.imul(Je,tn)|0,be=be+Math.imul(An,Sn)|0,Re=Re+Math.imul(An,an)|0,Re=Re+Math.imul(Yt,Sn)|0,Ne=Ne+Math.imul(Yt,an)|0,be=be+Math.imul(hn,Bn)|0,Re=Re+Math.imul(hn,sn)|0,Re=Re+Math.imul(Zt,Bn)|0,Ne=Ne+Math.imul(Zt,sn)|0,be=be+Math.imul(Gt,$n)|0,Re=Re+Math.imul(Gt,fn)|0,Re=Re+Math.imul(Dt,$n)|0,Ne=Ne+Math.imul(Dt,fn)|0,be=be+Math.imul(Rt,kn)|0,Re=Re+Math.imul(Rt,un)|0,Re=Re+Math.imul(Oe,kn)|0,Ne=Ne+Math.imul(Oe,un)|0,be=be+Math.imul(De,Cn)|0,Re=Re+Math.imul(De,cn)|0,Re=Re+Math.imul(ze,Cn)|0,Ne=Ne+Math.imul(ze,cn)|0,be=be+Math.imul(Ie,Tn)|0,Re=Re+Math.imul(Ie,ln)|0,Re=Re+Math.imul(je,Tn)|0,Ne=Ne+Math.imul(je,ln)|0;var Un=(ue+be|0)+((Re&8191)<<13)|0;ue=(Ne+(Re>>>13)|0)+(Un>>>26)|0,Un&=67108863,be=Math.imul(rn,Qt),Re=Math.imul(rn,Wt),Re=Re+Math.imul(We,Qt)|0,Ne=Math.imul(We,Wt),be=be+Math.imul(Xt,En)|0,Re=Re+Math.imul(Xt,tn)|0,Re=Re+Math.imul(Ht,En)|0,Ne=Ne+Math.imul(Ht,tn)|0,be=be+Math.imul(_n,Sn)|0,Re=Re+Math.imul(_n,an)|0,Re=Re+Math.imul(Je,Sn)|0,Ne=Ne+Math.imul(Je,an)|0,be=be+Math.imul(An,Bn)|0,Re=Re+Math.imul(An,sn)|0,Re=Re+Math.imul(Yt,Bn)|0,Ne=Ne+Math.imul(Yt,sn)|0,be=be+Math.imul(hn,$n)|0,Re=Re+Math.imul(hn,fn)|0,Re=Re+Math.imul(Zt,$n)|0,Ne=Ne+Math.imul(Zt,fn)|0,be=be+Math.imul(Gt,kn)|0,Re=Re+Math.imul(Gt,un)|0,Re=Re+Math.imul(Dt,kn)|0,Ne=Ne+Math.imul(Dt,un)|0,be=be+Math.imul(Rt,Cn)|0,Re=Re+Math.imul(Rt,cn)|0,Re=Re+Math.imul(Oe,Cn)|0,Ne=Ne+Math.imul(Oe,cn)|0,be=be+Math.imul(De,Tn)|0,Re=Re+Math.imul(De,ln)|0,Re=Re+Math.imul(ze,Tn)|0,Ne=Ne+Math.imul(ze,ln)|0,be=be+Math.imul(Ie,Nn)|0,Re=Re+Math.imul(Ie,dn)|0,Re=Re+Math.imul(je,Nn)|0,Ne=Ne+Math.imul(je,dn)|0;var Kn=(ue+be|0)+((Re&8191)<<13)|0;ue=(Ne+(Re>>>13)|0)+(Kn>>>26)|0,Kn&=67108863,be=Math.imul(Ge,Qt),Re=Math.imul(Ge,Wt),Re=Re+Math.imul(Mt,Qt)|0,Ne=Math.imul(Mt,Wt),be=be+Math.imul(rn,En)|0,Re=Re+Math.imul(rn,tn)|0,Re=Re+Math.imul(We,En)|0,Ne=Ne+Math.imul(We,tn)|0,be=be+Math.imul(Xt,Sn)|0,Re=Re+Math.imul(Xt,an)|0,Re=Re+Math.imul(Ht,Sn)|0,Ne=Ne+Math.imul(Ht,an)|0,be=be+Math.imul(_n,Bn)|0,Re=Re+Math.imul(_n,sn)|0,Re=Re+Math.imul(Je,Bn)|0,Ne=Ne+Math.imul(Je,sn)|0,be=be+Math.imul(An,$n)|0,Re=Re+Math.imul(An,fn)|0,Re=Re+Math.imul(Yt,$n)|0,Ne=Ne+Math.imul(Yt,fn)|0,be=be+Math.imul(hn,kn)|0,Re=Re+Math.imul(hn,un)|0,Re=Re+Math.imul(Zt,kn)|0,Ne=Ne+Math.imul(Zt,un)|0,be=be+Math.imul(Gt,Cn)|0,Re=Re+Math.imul(Gt,cn)|0,Re=Re+Math.imul(Dt,Cn)|0,Ne=Ne+Math.imul(Dt,cn)|0,be=be+Math.imul(Rt,Tn)|0,Re=Re+Math.imul(Rt,ln)|0,Re=Re+Math.imul(Oe,Tn)|0,Ne=Ne+Math.imul(Oe,ln)|0,be=be+Math.imul(De,Nn)|0,Re=Re+Math.imul(De,dn)|0,Re=Re+Math.imul(ze,Nn)|0,Ne=Ne+Math.imul(ze,dn)|0,be=be+Math.imul(Ie,Mn)|0,Re=Re+Math.imul(Ie,Rn)|0,Re=Re+Math.imul(je,Mn)|0,Ne=Ne+Math.imul(je,Rn)|0;var Hn=(ue+be|0)+((Re&8191)<<13)|0;ue=(Ne+(Re>>>13)|0)+(Hn>>>26)|0,Hn&=67108863,be=Math.imul(Ge,En),Re=Math.imul(Ge,tn),Re=Re+Math.imul(Mt,En)|0,Ne=Math.imul(Mt,tn),be=be+Math.imul(rn,Sn)|0,Re=Re+Math.imul(rn,an)|0,Re=Re+Math.imul(We,Sn)|0,Ne=Ne+Math.imul(We,an)|0,be=be+Math.imul(Xt,Bn)|0,Re=Re+Math.imul(Xt,sn)|0,Re=Re+Math.imul(Ht,Bn)|0,Ne=Ne+Math.imul(Ht,sn)|0,be=be+Math.imul(_n,$n)|0,Re=Re+Math.imul(_n,fn)|0,Re=Re+Math.imul(Je,$n)|0,Ne=Ne+Math.imul(Je,fn)|0,be=be+Math.imul(An,kn)|0,Re=Re+Math.imul(An,un)|0,Re=Re+Math.imul(Yt,kn)|0,Ne=Ne+Math.imul(Yt,un)|0,be=be+Math.imul(hn,Cn)|0,Re=Re+Math.imul(hn,cn)|0,Re=Re+Math.imul(Zt,Cn)|0,Ne=Ne+Math.imul(Zt,cn)|0,be=be+Math.imul(Gt,Tn)|0,Re=Re+Math.imul(Gt,ln)|0,Re=Re+Math.imul(Dt,Tn)|0,Ne=Ne+Math.imul(Dt,ln)|0,be=be+Math.imul(Rt,Nn)|0,Re=Re+Math.imul(Rt,dn)|0,Re=Re+Math.imul(Oe,Nn)|0,Ne=Ne+Math.imul(Oe,dn)|0,be=be+Math.imul(De,Mn)|0,Re=Re+Math.imul(De,Rn)|0,Re=Re+Math.imul(ze,Mn)|0,Ne=Ne+Math.imul(ze,Rn)|0;var zn=(ue+be|0)+((Re&8191)<<13)|0;ue=(Ne+(Re>>>13)|0)+(zn>>>26)|0,zn&=67108863,be=Math.imul(Ge,Sn),Re=Math.imul(Ge,an),Re=Re+Math.imul(Mt,Sn)|0,Ne=Math.imul(Mt,an),be=be+Math.imul(rn,Bn)|0,Re=Re+Math.imul(rn,sn)|0,Re=Re+Math.imul(We,Bn)|0,Ne=Ne+Math.imul(We,sn)|0,be=be+Math.imul(Xt,$n)|0,Re=Re+Math.imul(Xt,fn)|0,Re=Re+Math.imul(Ht,$n)|0,Ne=Ne+Math.imul(Ht,fn)|0,be=be+Math.imul(_n,kn)|0,Re=Re+Math.imul(_n,un)|0,Re=Re+Math.imul(Je,kn)|0,Ne=Ne+Math.imul(Je,un)|0,be=be+Math.imul(An,Cn)|0,Re=Re+Math.imul(An,cn)|0,Re=Re+Math.imul(Yt,Cn)|0,Ne=Ne+Math.imul(Yt,cn)|0,be=be+Math.imul(hn,Tn)|0,Re=Re+Math.imul(hn,ln)|0,Re=Re+Math.imul(Zt,Tn)|0,Ne=Ne+Math.imul(Zt,ln)|0,be=be+Math.imul(Gt,Nn)|0,Re=Re+Math.imul(Gt,dn)|0,Re=Re+Math.imul(Dt,Nn)|0,Ne=Ne+Math.imul(Dt,dn)|0,be=be+Math.imul(Rt,Mn)|0,Re=Re+Math.imul(Rt,Rn)|0,Re=Re+Math.imul(Oe,Mn)|0,Ne=Ne+Math.imul(Oe,Rn)|0;var jn=(ue+be|0)+((Re&8191)<<13)|0;ue=(Ne+(Re>>>13)|0)+(jn>>>26)|0,jn&=67108863,be=Math.imul(Ge,Bn),Re=Math.imul(Ge,sn),Re=Re+Math.imul(Mt,Bn)|0,Ne=Math.imul(Mt,sn),be=be+Math.imul(rn,$n)|0,Re=Re+Math.imul(rn,fn)|0,Re=Re+Math.imul(We,$n)|0,Ne=Ne+Math.imul(We,fn)|0,be=be+Math.imul(Xt,kn)|0,Re=Re+Math.imul(Xt,un)|0,Re=Re+Math.imul(Ht,kn)|0,Ne=Ne+Math.imul(Ht,un)|0,be=be+Math.imul(_n,Cn)|0,Re=Re+Math.imul(_n,cn)|0,Re=Re+Math.imul(Je,Cn)|0,Ne=Ne+Math.imul(Je,cn)|0,be=be+Math.imul(An,Tn)|0,Re=Re+Math.imul(An,ln)|0,Re=Re+Math.imul(Yt,Tn)|0,Ne=Ne+Math.imul(Yt,ln)|0,be=be+Math.imul(hn,Nn)|0,Re=Re+Math.imul(hn,dn)|0,Re=Re+Math.imul(Zt,Nn)|0,Ne=Ne+Math.imul(Zt,dn)|0,be=be+Math.imul(Gt,Mn)|0,Re=Re+Math.imul(Gt,Rn)|0,Re=Re+Math.imul(Dt,Mn)|0,Ne=Ne+Math.imul(Dt,Rn)|0;var Gn=(ue+be|0)+((Re&8191)<<13)|0;ue=(Ne+(Re>>>13)|0)+(Gn>>>26)|0,Gn&=67108863,be=Math.imul(Ge,$n),Re=Math.imul(Ge,fn),Re=Re+Math.imul(Mt,$n)|0,Ne=Math.imul(Mt,fn),be=be+Math.imul(rn,kn)|0,Re=Re+Math.imul(rn,un)|0,Re=Re+Math.imul(We,kn)|0,Ne=Ne+Math.imul(We,un)|0,be=be+Math.imul(Xt,Cn)|0,Re=Re+Math.imul(Xt,cn)|0,Re=Re+Math.imul(Ht,Cn)|0,Ne=Ne+Math.imul(Ht,cn)|0,be=be+Math.imul(_n,Tn)|0,Re=Re+Math.imul(_n,ln)|0,Re=Re+Math.imul(Je,Tn)|0,Ne=Ne+Math.imul(Je,ln)|0,be=be+Math.imul(An,Nn)|0,Re=Re+Math.imul(An,dn)|0,Re=Re+Math.imul(Yt,Nn)|0,Ne=Ne+Math.imul(Yt,dn)|0,be=be+Math.imul(hn,Mn)|0,Re=Re+Math.imul(hn,Rn)|0,Re=Re+Math.imul(Zt,Mn)|0,Ne=Ne+Math.imul(Zt,Rn)|0;var Wn=(ue+be|0)+((Re&8191)<<13)|0;ue=(Ne+(Re>>>13)|0)+(Wn>>>26)|0,Wn&=67108863,be=Math.imul(Ge,kn),Re=Math.imul(Ge,un),Re=Re+Math.imul(Mt,kn)|0,Ne=Math.imul(Mt,un),be=be+Math.imul(rn,Cn)|0,Re=Re+Math.imul(rn,cn)|0,Re=Re+Math.imul(We,Cn)|0,Ne=Ne+Math.imul(We,cn)|0,be=be+Math.imul(Xt,Tn)|0,Re=Re+Math.imul(Xt,ln)|0,Re=Re+Math.imul(Ht,Tn)|0,Ne=Ne+Math.imul(Ht,ln)|0,be=be+Math.imul(_n,Nn)|0,Re=Re+Math.imul(_n,dn)|0,Re=Re+Math.imul(Je,Nn)|0,Ne=Ne+Math.imul(Je,dn)|0,be=be+Math.imul(An,Mn)|0,Re=Re+Math.imul(An,Rn)|0,Re=Re+Math.imul(Yt,Mn)|0,Ne=Ne+Math.imul(Yt,Rn)|0;var Vn=(ue+be|0)+((Re&8191)<<13)|0;ue=(Ne+(Re>>>13)|0)+(Vn>>>26)|0,Vn&=67108863,be=Math.imul(Ge,Cn),Re=Math.imul(Ge,cn),Re=Re+Math.imul(Mt,Cn)|0,Ne=Math.imul(Mt,cn),be=be+Math.imul(rn,Tn)|0,Re=Re+Math.imul(rn,ln)|0,Re=Re+Math.imul(We,Tn)|0,Ne=Ne+Math.imul(We,ln)|0,be=be+Math.imul(Xt,Nn)|0,Re=Re+Math.imul(Xt,dn)|0,Re=Re+Math.imul(Ht,Nn)|0,Ne=Ne+Math.imul(Ht,dn)|0,be=be+Math.imul(_n,Mn)|0,Re=Re+Math.imul(_n,Rn)|0,Re=Re+Math.imul(Je,Mn)|0,Ne=Ne+Math.imul(Je,Rn)|0;var Zn=(ue+be|0)+((Re&8191)<<13)|0;ue=(Ne+(Re>>>13)|0)+(Zn>>>26)|0,Zn&=67108863,be=Math.imul(Ge,Tn),Re=Math.imul(Ge,ln),Re=Re+Math.imul(Mt,Tn)|0,Ne=Math.imul(Mt,ln),be=be+Math.imul(rn,Nn)|0,Re=Re+Math.imul(rn,dn)|0,Re=Re+Math.imul(We,Nn)|0,Ne=Ne+Math.imul(We,dn)|0,be=be+Math.imul(Xt,Mn)|0,Re=Re+Math.imul(Xt,Rn)|0,Re=Re+Math.imul(Ht,Mn)|0,Ne=Ne+Math.imul(Ht,Rn)|0;var Jn=(ue+be|0)+((Re&8191)<<13)|0;ue=(Ne+(Re>>>13)|0)+(Jn>>>26)|0,Jn&=67108863,be=Math.imul(Ge,Nn),Re=Math.imul(Ge,dn),Re=Re+Math.imul(Mt,Nn)|0,Ne=Math.imul(Mt,dn),be=be+Math.imul(rn,Mn)|0,Re=Re+Math.imul(rn,Rn)|0,Re=Re+Math.imul(We,Mn)|0,Ne=Ne+Math.imul(We,Rn)|0;var ti=(ue+be|0)+((Re&8191)<<13)|0;ue=(Ne+(Re>>>13)|0)+(ti>>>26)|0,ti&=67108863,be=Math.imul(Ge,Mn),Re=Math.imul(Ge,Rn),Re=Re+Math.imul(Mt,Mn)|0,Ne=Math.imul(Mt,Rn);var ri=(ue+be|0)+((Re&8191)<<13)|0;return ue=(Ne+(Re>>>13)|0)+(ri>>>26)|0,ri&=67108863,ge[0]=Pn,ge[1]=In,ge[2]=On,ge[3]=Dn,ge[4]=Ln,ge[5]=Fn,ge[6]=qn,ge[7]=Un,ge[8]=Kn,ge[9]=Hn,ge[10]=zn,ge[11]=jn,ge[12]=Gn,ge[13]=Wn,ge[14]=Vn,ge[15]=Zn,ge[16]=Jn,ge[17]=ti,ge[18]=ri,ue!==0&&(ge[19]=ue,ve.length++),ve};Math.imul||(Pe=ke);function Ue(ce,de,pe){pe.negative=de.negative^ce.negative,pe.length=ce.length+de.length;for(var ve=0,we=0,Ae=0;Ae<pe.length-1;Ae++){var ge=we;we=0;for(var ue=ve&67108863,be=Math.min(Ae,de.length-1),Re=Math.max(0,Ae-ce.length+1);Re<=be;Re++){var Ne=Ae-Re,Fe=ce.words[Ne]|0,Ie=de.words[Re]|0,je=Fe*Ie,Te=je&67108863;ge=ge+(je/67108864|0)|0,Te=Te+ue|0,ue=Te&67108863,ge=ge+(Te>>>26)|0,we+=ge>>>26,ge&=67108863}pe.words[Ae]=ue,ve=ge,ge=we}return ve!==0?pe.words[Ae]=ve:pe.length--,pe._strip()}function qe(ce,de,pe){return Ue(ce,de,pe)}ae.prototype.mulTo=function(de,pe){var ve,we=this.length+de.length;return this.length===10&&de.length===10?ve=Pe(this,de,pe):we<63?ve=ke(this,de,pe):we<1024?ve=Ue(this,de,pe):ve=qe(this,de,pe),ve},ae.prototype.mul=function(de){var pe=new ae(null);return pe.words=new Array(this.length+de.length),this.mulTo(de,pe)},ae.prototype.mulf=function(de){var pe=new ae(null);return pe.words=new Array(this.length+de.length),qe(this,de,pe)},ae.prototype.imul=function(de){return this.clone().mulTo(de,this)},ae.prototype.imuln=function(de){var pe=de<0;pe&&(de=-de),ie(typeof de=="number"),ie(de<67108864);for(var ve=0,we=0;we<this.length;we++){var Ae=(this.words[we]|0)*de,ge=(Ae&67108863)+(ve&67108863);ve>>=26,ve+=Ae/67108864|0,ve+=ge>>>26,this.words[we]=ge&67108863}return ve!==0&&(this.words[we]=ve,this.length++),this.length=de===0?1:this.length,pe?this.ineg():this},ae.prototype.muln=function(de){return this.clone().imuln(de)},ae.prototype.sqr=function(){return this.mul(this)},ae.prototype.isqr=function(){return this.imul(this.clone())},ae.prototype.pow=function(de){var pe=Ce(de);if(pe.length===0)return new ae(1);for(var ve=this,we=0;we<pe.length&&pe[we]===0;we++,ve=ve.sqr());if(++we<pe.length)for(var Ae=ve.sqr();we<pe.length;we++,Ae=Ae.sqr())pe[we]!==0&&(ve=ve.mul(Ae));return ve},ae.prototype.iushln=function(de){ie(typeof de=="number"&&de>=0);var pe=de%26,ve=(de-pe)/26,we=67108863>>>26-pe<<26-pe,Ae;if(pe!==0){var ge=0;for(Ae=0;Ae<this.length;Ae++){var ue=this.words[Ae]&we,be=(this.words[Ae]|0)-ue<<pe;this.words[Ae]=be|ge,ge=ue>>>26-pe}ge&&(this.words[Ae]=ge,this.length++)}if(ve!==0){for(Ae=this.length-1;Ae>=0;Ae--)this.words[Ae+ve]=this.words[Ae];for(Ae=0;Ae<ve;Ae++)this.words[Ae]=0;this.length+=ve}return this._strip()},ae.prototype.ishln=function(de){return ie(this.negative===0),this.iushln(de)},ae.prototype.iushrn=function(de,pe,ve){ie(typeof de=="number"&&de>=0);var we;pe?we=(pe-pe%26)/26:we=0;var Ae=de%26,ge=Math.min((de-Ae)/26,this.length),ue=67108863^67108863>>>Ae<<Ae,be=ve;if(we-=ge,we=Math.max(0,we),be){for(var Re=0;Re<ge;Re++)be.words[Re]=this.words[Re];be.length=ge}if(ge!==0)if(this.length>ge)for(this.length-=ge,Re=0;Re<this.length;Re++)this.words[Re]=this.words[Re+ge];else this.words[0]=0,this.length=1;var Ne=0;for(Re=this.length-1;Re>=0&&(Ne!==0||Re>=we);Re--){var Fe=this.words[Re]|0;this.words[Re]=Ne<<26-Ae|Fe>>>Ae,Ne=Fe&ue}return be&&Ne!==0&&(be.words[be.length++]=Ne),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},ae.prototype.ishrn=function(de,pe,ve){return ie(this.negative===0),this.iushrn(de,pe,ve)},ae.prototype.shln=function(de){return this.clone().ishln(de)},ae.prototype.ushln=function(de){return this.clone().iushln(de)},ae.prototype.shrn=function(de){return this.clone().ishrn(de)},ae.prototype.ushrn=function(de){return this.clone().iushrn(de)},ae.prototype.testn=function(de){ie(typeof de=="number"&&de>=0);var pe=de%26,ve=(de-pe)/26,we=1<<pe;if(this.length<=ve)return!1;var Ae=this.words[ve];return!!(Ae&we)},ae.prototype.imaskn=function(de){ie(typeof de=="number"&&de>=0);var pe=de%26,ve=(de-pe)/26;if(ie(this.negative===0,"imaskn works only with positive numbers"),this.length<=ve)return this;if(pe!==0&&ve++,this.length=Math.min(ve,this.length),pe!==0){var we=67108863^67108863>>>pe<<pe;this.words[this.length-1]&=we}return this._strip()},ae.prototype.maskn=function(de){return this.clone().imaskn(de)},ae.prototype.iaddn=function(de){return ie(typeof de=="number"),ie(de<67108864),de<0?this.isubn(-de):this.negative!==0?this.length===1&&(this.words[0]|0)<=de?(this.words[0]=de-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(de),this.negative=1,this):this._iaddn(de)},ae.prototype._iaddn=function(de){this.words[0]+=de;for(var pe=0;pe<this.length&&this.words[pe]>=67108864;pe++)this.words[pe]-=67108864,pe===this.length-1?this.words[pe+1]=1:this.words[pe+1]++;return this.length=Math.max(this.length,pe+1),this},ae.prototype.isubn=function(de){if(ie(typeof de=="number"),ie(de<67108864),de<0)return this.iaddn(-de);if(this.negative!==0)return this.negative=0,this.iaddn(de),this.negative=1,this;if(this.words[0]-=de,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var pe=0;pe<this.length&&this.words[pe]<0;pe++)this.words[pe]+=67108864,this.words[pe+1]-=1;return this._strip()},ae.prototype.addn=function(de){return this.clone().iaddn(de)},ae.prototype.subn=function(de){return this.clone().isubn(de)},ae.prototype.iabs=function(){return this.negative=0,this},ae.prototype.abs=function(){return this.clone().iabs()},ae.prototype._ishlnsubmul=function(de,pe,ve){var we=de.length+ve,Ae;this._expand(we);var ge,ue=0;for(Ae=0;Ae<de.length;Ae++){ge=(this.words[Ae+ve]|0)+ue;var be=(de.words[Ae]|0)*pe;ge-=be&67108863,ue=(ge>>26)-(be/67108864|0),this.words[Ae+ve]=ge&67108863}for(;Ae<this.length-ve;Ae++)ge=(this.words[Ae+ve]|0)+ue,ue=ge>>26,this.words[Ae+ve]=ge&67108863;if(ue===0)return this._strip();for(ie(ue===-1),ue=0,Ae=0;Ae<this.length;Ae++)ge=-(this.words[Ae]|0)+ue,ue=ge>>26,this.words[Ae]=ge&67108863;return this.negative=1,this._strip()},ae.prototype._wordDiv=function(de,pe){var ve=this.length-de.length,we=this.clone(),Ae=de,ge=Ae.words[Ae.length-1]|0,ue=this._countBits(ge);ve=26-ue,ve!==0&&(Ae=Ae.ushln(ve),we.iushln(ve),ge=Ae.words[Ae.length-1]|0);var be=we.length-Ae.length,Re;if(pe!=="mod"){Re=new ae(null),Re.length=be+1,Re.words=new Array(Re.length);for(var Ne=0;Ne<Re.length;Ne++)Re.words[Ne]=0}var Fe=we.clone()._ishlnsubmul(Ae,1,be);Fe.negative===0&&(we=Fe,Re&&(Re.words[be]=1));for(var Ie=be-1;Ie>=0;Ie--){var je=(we.words[Ae.length+Ie]|0)*67108864+(we.words[Ae.length+Ie-1]|0);for(je=Math.min(je/ge|0,67108863),we._ishlnsubmul(Ae,je,Ie);we.negative!==0;)je--,we.negative=0,we._ishlnsubmul(Ae,1,Ie),we.isZero()||(we.negative^=1);Re&&(Re.words[Ie]=je)}return Re&&Re._strip(),we._strip(),pe!=="div"&&ve!==0&&we.iushrn(ve),{div:Re||null,mod:we}},ae.prototype.divmod=function(de,pe,ve){if(ie(!de.isZero()),this.isZero())return{div:new ae(0),mod:new ae(0)};var we,Ae,ge;return this.negative!==0&&de.negative===0?(ge=this.neg().divmod(de,pe),pe!=="mod"&&(we=ge.div.neg()),pe!=="div"&&(Ae=ge.mod.neg(),ve&&Ae.negative!==0&&Ae.iadd(de)),{div:we,mod:Ae}):this.negative===0&&de.negative!==0?(ge=this.divmod(de.neg(),pe),pe!=="mod"&&(we=ge.div.neg()),{div:we,mod:ge.mod}):this.negative&de.negative?(ge=this.neg().divmod(de.neg(),pe),pe!=="div"&&(Ae=ge.mod.neg(),ve&&Ae.negative!==0&&Ae.isub(de)),{div:ge.div,mod:Ae}):de.length>this.length||this.cmp(de)<0?{div:new ae(0),mod:this}:de.length===1?pe==="div"?{div:this.divn(de.words[0]),mod:null}:pe==="mod"?{div:null,mod:new ae(this.modrn(de.words[0]))}:{div:this.divn(de.words[0]),mod:new ae(this.modrn(de.words[0]))}:this._wordDiv(de,pe)},ae.prototype.div=function(de){return this.divmod(de,"div",!1).div},ae.prototype.mod=function(de){return this.divmod(de,"mod",!1).mod},ae.prototype.umod=function(de){return this.divmod(de,"mod",!0).mod},ae.prototype.divRound=function(de){var pe=this.divmod(de);if(pe.mod.isZero())return pe.div;var ve=pe.div.negative!==0?pe.mod.isub(de):pe.mod,we=de.ushrn(1),Ae=de.andln(1),ge=ve.cmp(we);return ge<0||Ae===1&&ge===0?pe.div:pe.div.negative!==0?pe.div.isubn(1):pe.div.iaddn(1)},ae.prototype.modrn=function(de){var pe=de<0;pe&&(de=-de),ie(de<=67108863);for(var ve=(1<<26)%de,we=0,Ae=this.length-1;Ae>=0;Ae--)we=(ve*we+(this.words[Ae]|0))%de;return pe?-we:we},ae.prototype.modn=function(de){return this.modrn(de)},ae.prototype.idivn=function(de){var pe=de<0;pe&&(de=-de),ie(de<=67108863);for(var ve=0,we=this.length-1;we>=0;we--){var Ae=(this.words[we]|0)+ve*67108864;this.words[we]=Ae/de|0,ve=Ae%de}return this._strip(),pe?this.ineg():this},ae.prototype.divn=function(de){return this.clone().idivn(de)},ae.prototype.egcd=function(de){ie(de.negative===0),ie(!de.isZero());var pe=this,ve=de.clone();pe.negative!==0?pe=pe.umod(de):pe=pe.clone();for(var we=new ae(1),Ae=new ae(0),ge=new ae(0),ue=new ae(1),be=0;pe.isEven()&&ve.isEven();)pe.iushrn(1),ve.iushrn(1),++be;for(var Re=ve.clone(),Ne=pe.clone();!pe.isZero();){for(var Fe=0,Ie=1;!(pe.words[0]&Ie)&&Fe<26;++Fe,Ie<<=1);if(Fe>0)for(pe.iushrn(Fe);Fe-- >0;)(we.isOdd()||Ae.isOdd())&&(we.iadd(Re),Ae.isub(Ne)),we.iushrn(1),Ae.iushrn(1);for(var je=0,Te=1;!(ve.words[0]&Te)&&je<26;++je,Te<<=1);if(je>0)for(ve.iushrn(je);je-- >0;)(ge.isOdd()||ue.isOdd())&&(ge.iadd(Re),ue.isub(Ne)),ge.iushrn(1),ue.iushrn(1);pe.cmp(ve)>=0?(pe.isub(ve),we.isub(ge),Ae.isub(ue)):(ve.isub(pe),ge.isub(we),ue.isub(Ae))}return{a:ge,b:ue,gcd:ve.iushln(be)}},ae.prototype._invmp=function(de){ie(de.negative===0),ie(!de.isZero());var pe=this,ve=de.clone();pe.negative!==0?pe=pe.umod(de):pe=pe.clone();for(var we=new ae(1),Ae=new ae(0),ge=ve.clone();pe.cmpn(1)>0&&ve.cmpn(1)>0;){for(var ue=0,be=1;!(pe.words[0]&be)&&ue<26;++ue,be<<=1);if(ue>0)for(pe.iushrn(ue);ue-- >0;)we.isOdd()&&we.iadd(ge),we.iushrn(1);for(var Re=0,Ne=1;!(ve.words[0]&Ne)&&Re<26;++Re,Ne<<=1);if(Re>0)for(ve.iushrn(Re);Re-- >0;)Ae.isOdd()&&Ae.iadd(ge),Ae.iushrn(1);pe.cmp(ve)>=0?(pe.isub(ve),we.isub(Ae)):(ve.isub(pe),Ae.isub(we))}var Fe;return pe.cmpn(1)===0?Fe=we:Fe=Ae,Fe.cmpn(0)<0&&Fe.iadd(de),Fe},ae.prototype.gcd=function(de){if(this.isZero())return de.abs();if(de.isZero())return this.abs();var pe=this.clone(),ve=de.clone();pe.negative=0,ve.negative=0;for(var we=0;pe.isEven()&&ve.isEven();we++)pe.iushrn(1),ve.iushrn(1);do{for(;pe.isEven();)pe.iushrn(1);for(;ve.isEven();)ve.iushrn(1);var Ae=pe.cmp(ve);if(Ae<0){var ge=pe;pe=ve,ve=ge}else if(Ae===0||ve.cmpn(1)===0)break;pe.isub(ve)}while(!0);return ve.iushln(we)},ae.prototype.invm=function(de){return this.egcd(de).a.umod(de)},ae.prototype.isEven=function(){return(this.words[0]&1)===0},ae.prototype.isOdd=function(){return(this.words[0]&1)===1},ae.prototype.andln=function(de){return this.words[0]&de},ae.prototype.bincn=function(de){ie(typeof de=="number");var pe=de%26,ve=(de-pe)/26,we=1<<pe;if(this.length<=ve)return this._expand(ve+1),this.words[ve]|=we,this;for(var Ae=we,ge=ve;Ae!==0&&ge<this.length;ge++){var ue=this.words[ge]|0;ue+=Ae,Ae=ue>>>26,ue&=67108863,this.words[ge]=ue}return Ae!==0&&(this.words[ge]=Ae,this.length++),this},ae.prototype.isZero=function(){return this.length===1&&this.words[0]===0},ae.prototype.cmpn=function(de){var pe=de<0;if(this.negative!==0&&!pe)return-1;if(this.negative===0&&pe)return 1;this._strip();var ve;if(this.length>1)ve=1;else{pe&&(de=-de),ie(de<=67108863,"Number is too big");var we=this.words[0]|0;ve=we===de?0:we<de?-1:1}return this.negative!==0?-ve|0:ve},ae.prototype.cmp=function(de){if(this.negative!==0&&de.negative===0)return-1;if(this.negative===0&&de.negative!==0)return 1;var pe=this.ucmp(de);return this.negative!==0?-pe|0:pe},ae.prototype.ucmp=function(de){if(this.length>de.length)return 1;if(this.length<de.length)return-1;for(var pe=0,ve=this.length-1;ve>=0;ve--){var we=this.words[ve]|0,Ae=de.words[ve]|0;if(we!==Ae){we<Ae?pe=-1:we>Ae&&(pe=1);break}}return pe},ae.prototype.gtn=function(de){return this.cmpn(de)===1},ae.prototype.gt=function(de){return this.cmp(de)===1},ae.prototype.gten=function(de){return this.cmpn(de)>=0},ae.prototype.gte=function(de){return this.cmp(de)>=0},ae.prototype.ltn=function(de){return this.cmpn(de)===-1},ae.prototype.lt=function(de){return this.cmp(de)===-1},ae.prototype.lten=function(de){return this.cmpn(de)<=0},ae.prototype.lte=function(de){return this.cmp(de)<=0},ae.prototype.eqn=function(de){return this.cmpn(de)===0},ae.prototype.eq=function(de){return this.cmp(de)===0},ae.red=function(de){return new _e(de)},ae.prototype.toRed=function(de){return ie(!this.red,"Already a number in reduction context"),ie(this.negative===0,"red works only with positives"),de.convertTo(this)._forceRed(de)},ae.prototype.fromRed=function(){return ie(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},ae.prototype._forceRed=function(de){return this.red=de,this},ae.prototype.forceRed=function(de){return ie(!this.red,"Already a number in reduction context"),this._forceRed(de)},ae.prototype.redAdd=function(de){return ie(this.red,"redAdd works only with red numbers"),this.red.add(this,de)},ae.prototype.redIAdd=function(de){return ie(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,de)},ae.prototype.redSub=function(de){return ie(this.red,"redSub works only with red numbers"),this.red.sub(this,de)},ae.prototype.redISub=function(de){return ie(this.red,"redISub works only with red numbers"),this.red.isub(this,de)},ae.prototype.redShl=function(de){return ie(this.red,"redShl works only with red numbers"),this.red.shl(this,de)},ae.prototype.redMul=function(de){return ie(this.red,"redMul works only with red numbers"),this.red._verify2(this,de),this.red.mul(this,de)},ae.prototype.redIMul=function(de){return ie(this.red,"redMul works only with red numbers"),this.red._verify2(this,de),this.red.imul(this,de)},ae.prototype.redSqr=function(){return ie(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},ae.prototype.redISqr=function(){return ie(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},ae.prototype.redSqrt=function(){return ie(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},ae.prototype.redInvm=function(){return ie(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},ae.prototype.redNeg=function(){return ie(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},ae.prototype.redPow=function(de){return ie(this.red&&!de.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,de)};var He={k256:null,p224:null,p192:null,p25519:null};function Ve(ce,de){this.name=ce,this.p=new ae(de,16),this.n=this.p.bitLength(),this.k=new ae(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}Ve.prototype._tmp=function(){var de=new ae(null);return de.words=new Array(Math.ceil(this.n/13)),de},Ve.prototype.ireduce=function(de){var pe=de,ve;do this.split(pe,this.tmp),pe=this.imulK(pe),pe=pe.iadd(this.tmp),ve=pe.bitLength();while(ve>this.n);var we=ve<this.n?-1:pe.ucmp(this.p);return we===0?(pe.words[0]=0,pe.length=1):we>0?pe.isub(this.p):pe.strip!==void 0?pe.strip():pe._strip(),pe},Ve.prototype.split=function(de,pe){de.iushrn(this.n,0,pe)},Ve.prototype.imulK=function(de){return de.imul(this.k)};function Ye(){Ve.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}fe(Ye,Ve),Ye.prototype.split=function(de,pe){for(var ve=4194303,we=Math.min(de.length,9),Ae=0;Ae<we;Ae++)pe.words[Ae]=de.words[Ae];if(pe.length=we,de.length<=9){de.words[0]=0,de.length=1;return}var ge=de.words[9];for(pe.words[pe.length++]=ge&ve,Ae=10;Ae<de.length;Ae++){var ue=de.words[Ae]|0;de.words[Ae-10]=(ue&ve)<<4|ge>>>22,ge=ue}ge>>>=22,de.words[Ae-10]=ge,ge===0&&de.length>10?de.length-=10:de.length-=9},Ye.prototype.imulK=function(de){de.words[de.length]=0,de.words[de.length+1]=0,de.length+=2;for(var pe=0,ve=0;ve<de.length;ve++){var we=de.words[ve]|0;pe+=we*977,de.words[ve]=pe&67108863,pe=we*64+(pe/67108864|0)}return de.words[de.length-1]===0&&(de.length--,de.words[de.length-1]===0&&de.length--),de};function Qe(){Ve.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}fe(Qe,Ve);function Ke(){Ve.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}fe(Ke,Ve);function Pt(){Ve.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}fe(Pt,Ve),Pt.prototype.imulK=function(de){for(var pe=0,ve=0;ve<de.length;ve++){var we=(de.words[ve]|0)*19+pe,Ae=we&67108863;we>>>=26,de.words[ve]=Ae,pe=we}return pe!==0&&(de.words[de.length++]=pe),de},ae._prime=function(de){if(He[de])return He[de];var pe;if(de==="k256")pe=new Ye;else if(de==="p224")pe=new Qe;else if(de==="p192")pe=new Ke;else if(de==="p25519")pe=new Pt;else throw new Error("Unknown prime "+de);return He[de]=pe,pe};function _e(ce){if(typeof ce=="string"){var de=ae._prime(ce);this.m=de.p,this.prime=de}else ie(ce.gtn(1),"modulus must be greater than 1"),this.m=ce,this.prime=null}_e.prototype._verify1=function(de){ie(de.negative===0,"red works only with positives"),ie(de.red,"red works only with red numbers")},_e.prototype._verify2=function(de,pe){ie((de.negative|pe.negative)===0,"red works only with positives"),ie(de.red&&de.red===pe.red,"red works only with red numbers")},_e.prototype.imod=function(de){return this.prime?this.prime.ireduce(de)._forceRed(this):(xe(de,de.umod(this.m)._forceRed(this)),de)},_e.prototype.neg=function(de){return de.isZero()?de.clone():this.m.sub(de)._forceRed(this)},_e.prototype.add=function(de,pe){this._verify2(de,pe);var ve=de.add(pe);return ve.cmp(this.m)>=0&&ve.isub(this.m),ve._forceRed(this)},_e.prototype.iadd=function(de,pe){this._verify2(de,pe);var ve=de.iadd(pe);return ve.cmp(this.m)>=0&&ve.isub(this.m),ve},_e.prototype.sub=function(de,pe){this._verify2(de,pe);var ve=de.sub(pe);return ve.cmpn(0)<0&&ve.iadd(this.m),ve._forceRed(this)},_e.prototype.isub=function(de,pe){this._verify2(de,pe);var ve=de.isub(pe);return ve.cmpn(0)<0&&ve.iadd(this.m),ve},_e.prototype.shl=function(de,pe){return this._verify1(de),this.imod(de.ushln(pe))},_e.prototype.imul=function(de,pe){return this._verify2(de,pe),this.imod(de.imul(pe))},_e.prototype.mul=function(de,pe){return this._verify2(de,pe),this.imod(de.mul(pe))},_e.prototype.isqr=function(de){return this.imul(de,de.clone())},_e.prototype.sqr=function(de){return this.mul(de,de)},_e.prototype.sqrt=function(de){if(de.isZero())return de.clone();var pe=this.m.andln(3);if(ie(pe%2===1),pe===3){var ve=this.m.add(new ae(1)).iushrn(2);return this.pow(de,ve)}for(var we=this.m.subn(1),Ae=0;!we.isZero()&&we.andln(1)===0;)Ae++,we.iushrn(1);ie(!we.isZero());var ge=new ae(1).toRed(this),ue=ge.redNeg(),be=this.m.subn(1).iushrn(1),Re=this.m.bitLength();for(Re=new ae(2*Re*Re).toRed(this);this.pow(Re,be).cmp(ue)!==0;)Re.redIAdd(ue);for(var Ne=this.pow(Re,we),Fe=this.pow(de,we.addn(1).iushrn(1)),Ie=this.pow(de,we),je=Ae;Ie.cmp(ge)!==0;){for(var Te=Ie,De=0;Te.cmp(ge)!==0;De++)Te=Te.redSqr();ie(De<je);var ze=this.pow(Ne,new ae(1).iushln(je-De-1));Fe=Fe.redMul(ze),Ne=ze.redSqr(),Ie=Ie.redMul(Ne),je=De}return Fe},_e.prototype.invm=function(de){var pe=de._invmp(this.m);return pe.negative!==0?(pe.negative=0,this.imod(pe).redNeg()):this.imod(pe)},_e.prototype.pow=function(de,pe){if(pe.isZero())return new ae(1).toRed(this);if(pe.cmpn(1)===0)return de.clone();var ve=4,we=new Array(1<<ve);we[0]=new ae(1).toRed(this),we[1]=de;for(var Ae=2;Ae<we.length;Ae++)we[Ae]=this.mul(we[Ae-1],de);var ge=we[0],ue=0,be=0,Re=pe.bitLength()%26;for(Re===0&&(Re=26),Ae=pe.length-1;Ae>=0;Ae--){for(var Ne=pe.words[Ae],Fe=Re-1;Fe>=0;Fe--){var Ie=Ne>>Fe&1;if(ge!==we[0]&&(ge=this.sqr(ge)),Ie===0&&ue===0){be=0;continue}ue<<=1,ue|=Ie,be++,!(be!==ve&&(Ae!==0||Fe!==0))&&(ge=this.mul(ge,we[ue]),be=0,ue=0)}Re=26}return ge},_e.prototype.convertTo=function(de){var pe=de.umod(this.m);return pe===de?pe.clone():pe},_e.prototype.convertFrom=function(de){var pe=de.clone();return pe.red=null,pe},ae.mont=function(de){return new se(de)};function se(ce){_e.call(this,ce),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new ae(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}fe(se,_e),se.prototype.convertTo=function(de){return this.imod(de.ushln(this.shift))},se.prototype.convertFrom=function(de){var pe=this.imod(de.mul(this.rinv));return pe.red=null,pe},se.prototype.imul=function(de,pe){if(de.isZero()||pe.isZero())return de.words[0]=0,de.length=1,de;var ve=de.imul(pe),we=ve.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),Ae=ve.isub(we).iushrn(this.shift),ge=Ae;return Ae.cmp(this.m)>=0?ge=Ae.isub(this.m):Ae.cmpn(0)<0&&(ge=Ae.iadd(this.m)),ge._forceRed(this)},se.prototype.mul=function(de,pe){if(de.isZero()||pe.isZero())return new ae(0)._forceRed(this);var ve=de.mul(pe),we=ve.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),Ae=ve.isub(we).iushrn(this.shift),ge=Ae;return Ae.cmp(this.m)>=0?ge=Ae.isub(this.m):Ae.cmpn(0)<0&&(ge=Ae.iadd(this.m)),ge._forceRed(this)},se.prototype.invm=function(de){var pe=this.imod(de._invmp(this.m).mul(this.r2));return pe._forceRed(this)}})(c,commonjsGlobal)})(bn$8);var bnExports$3=bn$8.exports;const BN$8=getDefaultExportFromCjs$2(bnExports$3),version$u="logger/5.8.0";let _permanentCensorErrors=!1,_censorErrors=!1;const LogLevels={debug:1,default:2,info:2,warning:3,error:4,off:5};let _logLevel=LogLevels.default,_globalLogger=null;function _checkNormalize(){try{const c=[];if(["NFD","NFC","NFKD","NFKC"].forEach(t=>{try{if("test".normalize(t)!=="test")throw new Error("bad normalize")}catch{c.push(t)}}),c.length)throw new Error("missing "+c.join(", "));if("é".normalize("NFD")!=="é")throw new Error("broken implementation")}catch(c){return c.message}return null}const _normalizeError=_checkNormalize();var LogLevel;(function(c){c.DEBUG="DEBUG",c.INFO="INFO",c.WARNING="WARNING",c.ERROR="ERROR",c.OFF="OFF"})(LogLevel||(LogLevel={}));var ErrorCode;(function(c){c.UNKNOWN_ERROR="UNKNOWN_ERROR",c.NOT_IMPLEMENTED="NOT_IMPLEMENTED",c.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",c.NETWORK_ERROR="NETWORK_ERROR",c.SERVER_ERROR="SERVER_ERROR",c.TIMEOUT="TIMEOUT",c.BUFFER_OVERRUN="BUFFER_OVERRUN",c.NUMERIC_FAULT="NUMERIC_FAULT",c.MISSING_NEW="MISSING_NEW",c.INVALID_ARGUMENT="INVALID_ARGUMENT",c.MISSING_ARGUMENT="MISSING_ARGUMENT",c.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",c.CALL_EXCEPTION="CALL_EXCEPTION",c.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",c.NONCE_EXPIRED="NONCE_EXPIRED",c.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",c.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",c.TRANSACTION_REPLACED="TRANSACTION_REPLACED",c.ACTION_REJECTED="ACTION_REJECTED"})(ErrorCode||(ErrorCode={}));const HEX="0123456789abcdef";class Logger{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,n){const ie=t.toLowerCase();LogLevels[ie]==null&&this.throwArgumentError("invalid log level name","logLevel",t),!(_logLevel>LogLevels[ie])&&console.log.apply(console,n)}debug(...t){this._log(Logger.levels.DEBUG,t)}info(...t){this._log(Logger.levels.INFO,t)}warn(...t){this._log(Logger.levels.WARNING,t)}makeError(t,n,ie){if(_censorErrors)return this.makeError("censored error",n,{});n||(n=Logger.errors.UNKNOWN_ERROR),ie||(ie={});const fe=[];Object.keys(ie).forEach(ye=>{const me=ie[ye];try{if(me instanceof Uint8Array){let xe="";for(let Ee=0;Ee<me.length;Ee++)xe+=HEX[me[Ee]>>4],xe+=HEX[me[Ee]&15];fe.push(ye+"=Uint8Array(0x"+xe+")")}else fe.push(ye+"="+JSON.stringify(me))}catch{fe.push(ye+"="+JSON.stringify(ie[ye].toString()))}}),fe.push(`code=${n}`),fe.push(`version=${this.version}`);const ae=t;let le="";switch(n){case ErrorCode.NUMERIC_FAULT:{le="NUMERIC_FAULT";const ye=t;switch(ye){case"overflow":case"underflow":case"division-by-zero":le+="-"+ye;break;case"negative-power":case"negative-width":le+="-unsupported";break;case"unbound-bitwise-result":le+="-unbound-result";break}break}case ErrorCode.CALL_EXCEPTION:case ErrorCode.INSUFFICIENT_FUNDS:case ErrorCode.MISSING_NEW:case ErrorCode.NONCE_EXPIRED:case ErrorCode.REPLACEMENT_UNDERPRICED:case ErrorCode.TRANSACTION_REPLACED:case ErrorCode.UNPREDICTABLE_GAS_LIMIT:le=n;break}le&&(t+=" [ See: https://links.ethers.org/v5-errors-"+le+" ]"),fe.length&&(t+=" ("+fe.join(", ")+")");const he=new Error(t);return he.reason=ae,he.code=n,Object.keys(ie).forEach(function(ye){he[ye]=ie[ye]}),he}throwError(t,n,ie){throw this.makeError(t,n,ie)}throwArgumentError(t,n,ie){return this.throwError(t,Logger.errors.INVALID_ARGUMENT,{argument:n,value:ie})}assert(t,n,ie,fe){t||this.throwError(n,ie,fe)}assertArgument(t,n,ie,fe){t||this.throwArgumentError(n,ie,fe)}checkNormalize(t){_normalizeError&&this.throwError("platform missing String.prototype.normalize",Logger.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:_normalizeError})}checkSafeUint53(t,n){typeof t=="number"&&(n==null&&(n="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(n,Logger.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(n,Logger.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,n,ie){ie?ie=": "+ie:ie="",t<n&&this.throwError("missing argument"+ie,Logger.errors.MISSING_ARGUMENT,{count:t,expectedCount:n}),t>n&&this.throwError("too many arguments"+ie,Logger.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:n})}checkNew(t,n){(t===Object||t==null)&&this.throwError("missing new",Logger.errors.MISSING_NEW,{name:n.name})}checkAbstract(t,n){t===n?this.throwError("cannot instantiate abstract class "+JSON.stringify(n.name)+" directly; use a sub-class",Logger.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):(t===Object||t==null)&&this.throwError("missing new",Logger.errors.MISSING_NEW,{name:n.name})}static globalLogger(){return _globalLogger||(_globalLogger=new Logger(version$u)),_globalLogger}static setCensorship(t,n){if(!t&&n&&this.globalLogger().throwError("cannot permanently disable censorship",Logger.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),_permanentCensorErrors){if(!t)return;this.globalLogger().throwError("error censorship permanent",Logger.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}_censorErrors=!!t,_permanentCensorErrors=!!n}static setLogLevel(t){const n=LogLevels[t.toLowerCase()];if(n==null){Logger.globalLogger().warn("invalid log level - "+t);return}_logLevel=n}static from(t){return new Logger(t)}}Logger.errors=ErrorCode;Logger.levels=LogLevel;const lib_esm$k=Object.freeze(Object.defineProperty({__proto__:null,get ErrorCode(){return ErrorCode},get LogLevel(){return LogLevel},Logger},Symbol.toStringTag,{value:"Module"})),version$t="bytes/5.8.0",logger$x=new Logger(version$t);function isHexable(c){return!!c.toHexString}function addSlice(c){return c.slice||(c.slice=function(){const t=Array.prototype.slice.call(arguments);return addSlice(new Uint8Array(Array.prototype.slice.apply(c,t)))}),c}function isBytesLike(c){return isHexString(c)&&!(c.length%2)||isBytes$1(c)}function isInteger(c){return typeof c=="number"&&c==c&&c%1===0}function isBytes$1(c){if(c==null)return!1;if(c.constructor===Uint8Array)return!0;if(typeof c=="string"||!isInteger(c.length)||c.length<0)return!1;for(let t=0;t<c.length;t++){const n=c[t];if(!isInteger(n)||n<0||n>=256)return!1}return!0}function arrayify(c,t){if(t||(t={}),typeof c=="number"){logger$x.checkSafeUint53(c,"invalid arrayify value");const n=[];for(;c;)n.unshift(c&255),c=parseInt(String(c/256));return n.length===0&&n.push(0),addSlice(new Uint8Array(n))}if(t.allowMissingPrefix&&typeof c=="string"&&c.substring(0,2)!=="0x"&&(c="0x"+c),isHexable(c)&&(c=c.toHexString()),isHexString(c)){let n=c.substring(2);n.length%2&&(t.hexPad==="left"?n="0"+n:t.hexPad==="right"?n+="0":logger$x.throwArgumentError("hex data is odd-length","value",c));const ie=[];for(let fe=0;fe<n.length;fe+=2)ie.push(parseInt(n.substring(fe,fe+2),16));return addSlice(new Uint8Array(ie))}return isBytes$1(c)?addSlice(new Uint8Array(c)):logger$x.throwArgumentError("invalid arrayify value","value",c)}function concat$1(c){const t=c.map(fe=>arrayify(fe)),n=t.reduce((fe,ae)=>fe+ae.length,0),ie=new Uint8Array(n);return t.reduce((fe,ae)=>(ie.set(ae,fe),fe+ae.length),0),addSlice(ie)}function stripZeros(c){let t=arrayify(c);if(t.length===0)return t;let n=0;for(;n<t.length&&t[n]===0;)n++;return n&&(t=t.slice(n)),t}function zeroPad(c,t){c=arrayify(c),c.length>t&&logger$x.throwArgumentError("value out of range","value",arguments[0]);const n=new Uint8Array(t);return n.set(c,t-c.length),addSlice(n)}function isHexString(c,t){return!(typeof c!="string"||!c.match(/^0x[0-9A-Fa-f]*$/)||t&&c.length!==2+2*t)}const HexCharacters="0123456789abcdef";function hexlify(c,t){if(t||(t={}),typeof c=="number"){logger$x.checkSafeUint53(c,"invalid hexlify value");let n="";for(;c;)n=HexCharacters[c&15]+n,c=Math.floor(c/16);return n.length?(n.length%2&&(n="0"+n),"0x"+n):"0x00"}if(typeof c=="bigint")return c=c.toString(16),c.length%2?"0x0"+c:"0x"+c;if(t.allowMissingPrefix&&typeof c=="string"&&c.substring(0,2)!=="0x"&&(c="0x"+c),isHexable(c))return c.toHexString();if(isHexString(c))return c.length%2&&(t.hexPad==="left"?c="0x0"+c.substring(2):t.hexPad==="right"?c+="0":logger$x.throwArgumentError("hex data is odd-length","value",c)),c.toLowerCase();if(isBytes$1(c)){let n="0x";for(let ie=0;ie<c.length;ie++){let fe=c[ie];n+=HexCharacters[(fe&240)>>4]+HexCharacters[fe&15]}return n}return logger$x.throwArgumentError("invalid hexlify value","value",c)}function hexDataLength(c){if(typeof c!="string")c=hexlify(c);else if(!isHexString(c)||c.length%2)return null;return(c.length-2)/2}function hexDataSlice(c,t,n){return typeof c!="string"?c=hexlify(c):(!isHexString(c)||c.length%2)&&logger$x.throwArgumentError("invalid hexData","value",c),t=2+2*t,n!=null?"0x"+c.substring(t,2+2*n):"0x"+c.substring(t)}function hexConcat(c){let t="0x";return c.forEach(n=>{t+=hexlify(n).substring(2)}),t}function hexValue(c){const t=hexStripZeros(hexlify(c,{hexPad:"left"}));return t==="0x"?"0x0":t}function hexStripZeros(c){typeof c!="string"&&(c=hexlify(c)),isHexString(c)||logger$x.throwArgumentError("invalid hex string","value",c),c=c.substring(2);let t=0;for(;t<c.length&&c[t]==="0";)t++;return"0x"+c.substring(t)}function hexZeroPad(c,t){for(typeof c!="string"?c=hexlify(c):isHexString(c)||logger$x.throwArgumentError("invalid hex string","value",c),c.length>2*t+2&&logger$x.throwArgumentError("value out of range","value",arguments[1]);c.length<2*t+2;)c="0x0"+c.substring(2);return c}function splitSignature(c){const t={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(isBytesLike(c)){let n=arrayify(c);n.length===64?(t.v=27+(n[32]>>7),n[32]&=127,t.r=hexlify(n.slice(0,32)),t.s=hexlify(n.slice(32,64))):n.length===65?(t.r=hexlify(n.slice(0,32)),t.s=hexlify(n.slice(32,64)),t.v=n[64]):logger$x.throwArgumentError("invalid signature string","signature",c),t.v<27&&(t.v===0||t.v===1?t.v+=27:logger$x.throwArgumentError("signature invalid v byte","signature",c)),t.recoveryParam=1-t.v%2,t.recoveryParam&&(n[32]|=128),t._vs=hexlify(n.slice(32,64))}else{if(t.r=c.r,t.s=c.s,t.v=c.v,t.recoveryParam=c.recoveryParam,t._vs=c._vs,t._vs!=null){const fe=zeroPad(arrayify(t._vs),32);t._vs=hexlify(fe);const ae=fe[0]>=128?1:0;t.recoveryParam==null?t.recoveryParam=ae:t.recoveryParam!==ae&&logger$x.throwArgumentError("signature recoveryParam mismatch _vs","signature",c),fe[0]&=127;const le=hexlify(fe);t.s==null?t.s=le:t.s!==le&&logger$x.throwArgumentError("signature v mismatch _vs","signature",c)}if(t.recoveryParam==null)t.v==null?logger$x.throwArgumentError("signature missing v and recoveryParam","signature",c):t.v===0||t.v===1?t.recoveryParam=t.v:t.recoveryParam=1-t.v%2;else if(t.v==null)t.v=27+t.recoveryParam;else{const fe=t.v===0||t.v===1?t.v:1-t.v%2;t.recoveryParam!==fe&&logger$x.throwArgumentError("signature recoveryParam mismatch v","signature",c)}t.r==null||!isHexString(t.r)?logger$x.throwArgumentError("signature missing or invalid r","signature",c):t.r=hexZeroPad(t.r,32),t.s==null||!isHexString(t.s)?logger$x.throwArgumentError("signature missing or invalid s","signature",c):t.s=hexZeroPad(t.s,32);const n=arrayify(t.s);n[0]>=128&&logger$x.throwArgumentError("signature s out of range","signature",c),t.recoveryParam&&(n[0]|=128);const ie=hexlify(n);t._vs&&(isHexString(t._vs)||logger$x.throwArgumentError("signature invalid _vs","signature",c),t._vs=hexZeroPad(t._vs,32)),t._vs==null?t._vs=ie:t._vs!==ie&&logger$x.throwArgumentError("signature _vs mismatch v and s","signature",c)}return t.yParityAndS=t._vs,t.compact=t.r+t.yParityAndS.substring(2),t}function joinSignature(c){return c=splitSignature(c),hexlify(concat$1([c.r,c.s,c.recoveryParam?"0x1c":"0x1b"]))}const lib_esm$j=Object.freeze(Object.defineProperty({__proto__:null,arrayify,concat:concat$1,hexConcat,hexDataLength,hexDataSlice,hexStripZeros,hexValue,hexZeroPad,hexlify,isBytes:isBytes$1,isBytesLike,isHexString,joinSignature,splitSignature,stripZeros,zeroPad},Symbol.toStringTag,{value:"Module"})),version$s="bignumber/5.8.0";var BN$7=BN$8.BN;const logger$w=new Logger(version$s),_constructorGuard$4={},MAX_SAFE=9007199254740991;function isBigNumberish(c){return c!=null&&(BigNumber.isBigNumber(c)||typeof c=="number"&&c%1===0||typeof c=="string"&&!!c.match(/^-?[0-9]+$/)||isHexString(c)||typeof c=="bigint"||isBytes$1(c))}let _warnedToStringRadix=!1;class BigNumber{constructor(t,n){t!==_constructorGuard$4&&logger$w.throwError("cannot call constructor directly; use BigNumber.from",Logger.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=n,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return toBigNumber(toBN(this).fromTwos(t))}toTwos(t){return toBigNumber(toBN(this).toTwos(t))}abs(){return this._hex[0]==="-"?BigNumber.from(this._hex.substring(1)):this}add(t){return toBigNumber(toBN(this).add(toBN(t)))}sub(t){return toBigNumber(toBN(this).sub(toBN(t)))}div(t){return BigNumber.from(t).isZero()&&throwFault$1("division-by-zero","div"),toBigNumber(toBN(this).div(toBN(t)))}mul(t){return toBigNumber(toBN(this).mul(toBN(t)))}mod(t){const n=toBN(t);return n.isNeg()&&throwFault$1("division-by-zero","mod"),toBigNumber(toBN(this).umod(n))}pow(t){const n=toBN(t);return n.isNeg()&&throwFault$1("negative-power","pow"),toBigNumber(toBN(this).pow(n))}and(t){const n=toBN(t);return(this.isNegative()||n.isNeg())&&throwFault$1("unbound-bitwise-result","and"),toBigNumber(toBN(this).and(n))}or(t){const n=toBN(t);return(this.isNegative()||n.isNeg())&&throwFault$1("unbound-bitwise-result","or"),toBigNumber(toBN(this).or(n))}xor(t){const n=toBN(t);return(this.isNegative()||n.isNeg())&&throwFault$1("unbound-bitwise-result","xor"),toBigNumber(toBN(this).xor(n))}mask(t){return(this.isNegative()||t<0)&&throwFault$1("negative-width","mask"),toBigNumber(toBN(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&throwFault$1("negative-width","shl"),toBigNumber(toBN(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&throwFault$1("negative-width","shr"),toBigNumber(toBN(this).shrn(t))}eq(t){return toBN(this).eq(toBN(t))}lt(t){return toBN(this).lt(toBN(t))}lte(t){return toBN(this).lte(toBN(t))}gt(t){return toBN(this).gt(toBN(t))}gte(t){return toBN(this).gte(toBN(t))}isNegative(){return this._hex[0]==="-"}isZero(){return toBN(this).isZero()}toNumber(){try{return toBN(this).toNumber()}catch{throwFault$1("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return logger$w.throwError("this platform does not support BigInt",Logger.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?_warnedToStringRadix||(_warnedToStringRadix=!0,logger$w.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?logger$w.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Logger.errors.UNEXPECTED_ARGUMENT,{}):logger$w.throwError("BigNumber.toString does not accept parameters",Logger.errors.UNEXPECTED_ARGUMENT,{})),toBN(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof BigNumber)return t;if(typeof t=="string")return t.match(/^-?0x[0-9a-f]+$/i)?new BigNumber(_constructorGuard$4,toHex$2(t)):t.match(/^-?[0-9]+$/)?new BigNumber(_constructorGuard$4,toHex$2(new BN$7(t))):logger$w.throwArgumentError("invalid BigNumber string","value",t);if(typeof t=="number")return t%1&&throwFault$1("underflow","BigNumber.from",t),(t>=MAX_SAFE||t<=-MAX_SAFE)&&throwFault$1("overflow","BigNumber.from",t),BigNumber.from(String(t));const n=t;if(typeof n=="bigint")return BigNumber.from(n.toString());if(isBytes$1(n))return BigNumber.from(hexlify(n));if(n)if(n.toHexString){const ie=n.toHexString();if(typeof ie=="string")return BigNumber.from(ie)}else{let ie=n._hex;if(ie==null&&n.type==="BigNumber"&&(ie=n.hex),typeof ie=="string"&&(isHexString(ie)||ie[0]==="-"&&isHexString(ie.substring(1))))return BigNumber.from(ie)}return logger$w.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!!(t&&t._isBigNumber)}}function toHex$2(c){if(typeof c!="string")return toHex$2(c.toString(16));if(c[0]==="-")return c=c.substring(1),c[0]==="-"&&logger$w.throwArgumentError("invalid hex","value",c),c=toHex$2(c),c==="0x00"?c:"-"+c;if(c.substring(0,2)!=="0x"&&(c="0x"+c),c==="0x")return"0x00";for(c.length%2&&(c="0x0"+c.substring(2));c.length>4&&c.substring(0,4)==="0x00";)c="0x"+c.substring(4);return c}function toBigNumber(c){return BigNumber.from(toHex$2(c))}function toBN(c){const t=BigNumber.from(c).toHexString();return t[0]==="-"?new BN$7("-"+t.substring(3),16):new BN$7(t.substring(2),16)}function throwFault$1(c,t,n){const ie={fault:c,operation:t};return n!=null&&(ie.value=n),logger$w.throwError(c,Logger.errors.NUMERIC_FAULT,ie)}function _base36To16(c){return new BN$7(c,36).toString(16)}function _base16To36(c){return new BN$7(c,16).toString(36)}const logger$v=new Logger(version$s),_constructorGuard$3={},Zero$2=BigNumber.from(0),NegativeOne$2=BigNumber.from(-1);function throwFault(c,t,n,ie){const fe={fault:t,operation:n};return ie!==void 0&&(fe.value=ie),logger$v.throwError(c,Logger.errors.NUMERIC_FAULT,fe)}let zeros="0";for(;zeros.length<256;)zeros+=zeros;function getMultiplier(c){if(typeof c!="number")try{c=BigNumber.from(c).toNumber()}catch{}return typeof c=="number"&&c>=0&&c<=256&&!(c%1)?"1"+zeros.substring(0,c):logger$v.throwArgumentError("invalid decimal size","decimals",c)}function formatFixed(c,t){t==null&&(t=0);const n=getMultiplier(t);c=BigNumber.from(c);const ie=c.lt(Zero$2);ie&&(c=c.mul(NegativeOne$2));let fe=c.mod(n).toString();for(;fe.length<n.length-1;)fe="0"+fe;fe=fe.match(/^([0-9]*[1-9]|0)(0*)/)[1];const ae=c.div(n).toString();return n.length===1?c=ae:c=ae+"."+fe,ie&&(c="-"+c),c}function parseFixed(c,t){t==null&&(t=0);const n=getMultiplier(t);(typeof c!="string"||!c.match(/^-?[0-9.]+$/))&&logger$v.throwArgumentError("invalid decimal value","value",c);const ie=c.substring(0,1)==="-";ie&&(c=c.substring(1)),c==="."&&logger$v.throwArgumentError("missing value","value",c);const fe=c.split(".");fe.length>2&&logger$v.throwArgumentError("too many decimal points","value",c);let ae=fe[0],le=fe[1];for(ae||(ae="0"),le||(le="0");le[le.length-1]==="0";)le=le.substring(0,le.length-1);for(le.length>n.length-1&&throwFault("fractional component exceeds decimals","underflow","parseFixed"),le===""&&(le="0");le.length<n.length-1;)le+="0";const he=BigNumber.from(ae),ye=BigNumber.from(le);let me=he.mul(n).add(ye);return ie&&(me=me.mul(NegativeOne$2)),me}class FixedFormat{constructor(t,n,ie,fe){t!==_constructorGuard$3&&logger$v.throwError("cannot use FixedFormat constructor; use FixedFormat.from",Logger.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=n,this.width=ie,this.decimals=fe,this.name=(n?"":"u")+"fixed"+String(ie)+"x"+String(fe),this._multiplier=getMultiplier(fe),Object.freeze(this)}static from(t){if(t instanceof FixedFormat)return t;typeof t=="number"&&(t=`fixed128x${t}`);let n=!0,ie=128,fe=18;if(typeof t=="string"){if(t!=="fixed")if(t==="ufixed")n=!1;else{const ae=t.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);ae||logger$v.throwArgumentError("invalid fixed format","format",t),n=ae[1]!=="u",ie=parseInt(ae[2]),fe=parseInt(ae[3])}}else if(t){const ae=(le,he,ye)=>t[le]==null?ye:(typeof t[le]!==he&&logger$v.throwArgumentError("invalid fixed format ("+le+" not "+he+")","format."+le,t[le]),t[le]);n=ae("signed","boolean",n),ie=ae("width","number",ie),fe=ae("decimals","number",fe)}return ie%8&&logger$v.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",ie),fe>80&&logger$v.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",fe),new FixedFormat(_constructorGuard$3,n,ie,fe)}}class FixedNumber{constructor(t,n,ie,fe){t!==_constructorGuard$3&&logger$v.throwError("cannot use FixedNumber constructor; use FixedNumber.from",Logger.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=fe,this._hex=n,this._value=ie,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(t){this.format.name!==t.format.name&&logger$v.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",t)}addUnsafe(t){this._checkFormat(t);const n=parseFixed(this._value,this.format.decimals),ie=parseFixed(t._value,t.format.decimals);return FixedNumber.fromValue(n.add(ie),this.format.decimals,this.format)}subUnsafe(t){this._checkFormat(t);const n=parseFixed(this._value,this.format.decimals),ie=parseFixed(t._value,t.format.decimals);return FixedNumber.fromValue(n.sub(ie),this.format.decimals,this.format)}mulUnsafe(t){this._checkFormat(t);const n=parseFixed(this._value,this.format.decimals),ie=parseFixed(t._value,t.format.decimals);return FixedNumber.fromValue(n.mul(ie).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(t){this._checkFormat(t);const n=parseFixed(this._value,this.format.decimals),ie=parseFixed(t._value,t.format.decimals);return FixedNumber.fromValue(n.mul(this.format._multiplier).div(ie),this.format.decimals,this.format)}floor(){const t=this.toString().split(".");t.length===1&&t.push("0");let n=FixedNumber.from(t[0],this.format);const ie=!t[1].match(/^(0*)$/);return this.isNegative()&&ie&&(n=n.subUnsafe(ONE.toFormat(n.format))),n}ceiling(){const t=this.toString().split(".");t.length===1&&t.push("0");let n=FixedNumber.from(t[0],this.format);const ie=!t[1].match(/^(0*)$/);return!this.isNegative()&&ie&&(n=n.addUnsafe(ONE.toFormat(n.format))),n}round(t){t==null&&(t=0);const n=this.toString().split(".");if(n.length===1&&n.push("0"),(t<0||t>80||t%1)&&logger$v.throwArgumentError("invalid decimal count","decimals",t),n[1].length<=t)return this;const ie=FixedNumber.from("1"+zeros.substring(0,t),this.format),fe=BUMP.toFormat(this.format);return this.mulUnsafe(ie).addUnsafe(fe).floor().divUnsafe(ie)}isZero(){return this._value==="0.0"||this._value==="0"}isNegative(){return this._value[0]==="-"}toString(){return this._value}toHexString(t){if(t==null)return this._hex;t%8&&logger$v.throwArgumentError("invalid byte width","width",t);const n=BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(t).toHexString();return hexZeroPad(n,t/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(t){return FixedNumber.fromString(this._value,t)}static fromValue(t,n,ie){return ie==null&&n!=null&&!isBigNumberish(n)&&(ie=n,n=null),n==null&&(n=0),ie==null&&(ie="fixed"),FixedNumber.fromString(formatFixed(t,n),FixedFormat.from(ie))}static fromString(t,n){n==null&&(n="fixed");const ie=FixedFormat.from(n),fe=parseFixed(t,ie.decimals);!ie.signed&&fe.lt(Zero$2)&&throwFault("unsigned value cannot be negative","overflow","value",t);let ae=null;ie.signed?ae=fe.toTwos(ie.width).toHexString():(ae=fe.toHexString(),ae=hexZeroPad(ae,ie.width/8));const le=formatFixed(fe,ie.decimals);return new FixedNumber(_constructorGuard$3,ae,le,ie)}static fromBytes(t,n){n==null&&(n="fixed");const ie=FixedFormat.from(n);if(arrayify(t).length>ie.width/8)throw new Error("overflow");let fe=BigNumber.from(t);ie.signed&&(fe=fe.fromTwos(ie.width));const ae=fe.toTwos((ie.signed?0:1)+ie.width).toHexString(),le=formatFixed(fe,ie.decimals);return new FixedNumber(_constructorGuard$3,ae,le,ie)}static from(t,n){if(typeof t=="string")return FixedNumber.fromString(t,n);if(isBytes$1(t))return FixedNumber.fromBytes(t,n);try{return FixedNumber.fromValue(t,0,n)}catch(ie){if(ie.code!==Logger.errors.INVALID_ARGUMENT)throw ie}return logger$v.throwArgumentError("invalid FixedNumber value","value",t)}static isFixedNumber(t){return!!(t&&t._isFixedNumber)}}const ONE=FixedNumber.from(1),BUMP=FixedNumber.from("0.5"),version$r="properties/5.8.0";var __awaiter$l=function(c,t,n,ie){function fe(ae){return ae instanceof n?ae:new n(function(le){le(ae)})}return new(n||(n=Promise))(function(ae,le){function he(xe){try{me(ie.next(xe))}catch(Ee){le(Ee)}}function ye(xe){try{me(ie.throw(xe))}catch(Ee){le(Ee)}}function me(xe){xe.done?ae(xe.value):fe(xe.value).then(he,ye)}me((ie=ie.apply(c,t||[])).next())})};const logger$u=new Logger(version$r);function defineReadOnly(c,t,n){Object.defineProperty(c,t,{enumerable:!0,value:n,writable:!1})}function getStatic(c,t){for(let n=0;n<32;n++){if(c[t])return c[t];if(!c.prototype||typeof c.prototype!="object")break;c=Object.getPrototypeOf(c.prototype).constructor}return null}function resolveProperties(c){return __awaiter$l(this,void 0,void 0,function*(){const t=Object.keys(c).map(ie=>{const fe=c[ie];return Promise.resolve(fe).then(ae=>({key:ie,value:ae}))});return(yield Promise.all(t)).reduce((ie,fe)=>(ie[fe.key]=fe.value,ie),{})})}function checkProperties(c,t){(!c||typeof c!="object")&&logger$u.throwArgumentError("invalid object","object",c),Object.keys(c).forEach(n=>{t[n]||logger$u.throwArgumentError("invalid object key - "+n,"transaction:"+n,c)})}function shallowCopy(c){const t={};for(const n in c)t[n]=c[n];return t}const opaque={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function _isFrozen(c){if(c==null||opaque[typeof c])return!0;if(Array.isArray(c)||typeof c=="object"){if(!Object.isFrozen(c))return!1;const t=Object.keys(c);for(let n=0;n<t.length;n++){let ie=null;try{ie=c[t[n]]}catch{continue}if(!_isFrozen(ie))return!1}return!0}return logger$u.throwArgumentError(`Cannot deepCopy ${typeof c}`,"object",c)}function _deepCopy(c){if(_isFrozen(c))return c;if(Array.isArray(c))return Object.freeze(c.map(t=>deepCopy(t)));if(typeof c=="object"){const t={};for(const n in c){const ie=c[n];ie!==void 0&&defineReadOnly(t,n,deepCopy(ie))}return t}return logger$u.throwArgumentError(`Cannot deepCopy ${typeof c}`,"object",c)}function deepCopy(c){return _deepCopy(c)}class Description{constructor(t){for(const n in t)this[n]=deepCopy(t[n])}}const lib_esm$i=Object.freeze(Object.defineProperty({__proto__:null,Description,checkProperties,deepCopy,defineReadOnly,getStatic,resolveProperties,shallowCopy},Symbol.toStringTag,{value:"Module"})),version$q="abi/5.8.0",logger$t=new Logger(version$q),_constructorGuard$2={};let ModifiersBytes={calldata:!0,memory:!0,storage:!0},ModifiersNest={calldata:!0,memory:!0};function checkModifier(c,t){if(c==="bytes"||c==="string"){if(ModifiersBytes[t])return!0}else if(c==="address"){if(t==="payable")return!0}else if((c.indexOf("[")>=0||c==="tuple")&&ModifiersNest[t])return!0;return(ModifiersBytes[t]||t==="payable")&&logger$t.throwArgumentError("invalid modifier","name",t),!1}function parseParamType(c,t){let n=c;function ie(he){logger$t.throwArgumentError(`unexpected character at position ${he}`,"param",c)}c=c.replace(/\s/g," ");function fe(he){let ye={type:"",name:"",parent:he,state:{allowType:!0}};return t&&(ye.indexed=!1),ye}let ae={type:"",name:"",state:{allowType:!0}},le=ae;for(let he=0;he<c.length;he++){let ye=c[he];switch(ye){case"(":le.state.allowType&&le.type===""?le.type="tuple":le.state.allowParams||ie(he),le.state.allowType=!1,le.type=verifyType(le.type),le.components=[fe(le)],le=le.components[0];break;case")":delete le.state,le.name==="indexed"&&(t||ie(he),le.indexed=!0,le.name=""),checkModifier(le.type,le.name)&&(le.name=""),le.type=verifyType(le.type);let me=le;le=le.parent,le||ie(he),delete me.parent,le.state.allowParams=!1,le.state.allowName=!0,le.state.allowArray=!0;break;case",":delete le.state,le.name==="indexed"&&(t||ie(he),le.indexed=!0,le.name=""),checkModifier(le.type,le.name)&&(le.name=""),le.type=verifyType(le.type);let xe=fe(le.parent);le.parent.components.push(xe),delete le.parent,le=xe;break;case" ":le.state.allowType&&le.type!==""&&(le.type=verifyType(le.type),delete le.state.allowType,le.state.allowName=!0,le.state.allowParams=!0),le.state.allowName&&le.name!==""&&(le.name==="indexed"?(t||ie(he),le.indexed&&ie(he),le.indexed=!0,le.name=""):checkModifier(le.type,le.name)?le.name="":le.state.allowName=!1);break;case"[":le.state.allowArray||ie(he),le.type+=ye,le.state.allowArray=!1,le.state.allowName=!1,le.state.readArray=!0;break;case"]":le.state.readArray||ie(he),le.type+=ye,le.state.readArray=!1,le.state.allowArray=!0,le.state.allowName=!0;break;default:le.state.allowType?(le.type+=ye,le.state.allowParams=!0,le.state.allowArray=!0):le.state.allowName?(le.name+=ye,delete le.state.allowArray):le.state.readArray?le.type+=ye:ie(he)}}return le.parent&&logger$t.throwArgumentError("unexpected eof","param",c),delete ae.state,le.name==="indexed"?(t||ie(n.length-7),le.indexed&&ie(n.length-7),le.indexed=!0,le.name=""):checkModifier(le.type,le.name)&&(le.name=""),ae.type=verifyType(ae.type),ae}function populate(c,t){for(let n in t)defineReadOnly(c,n,t[n])}const FormatTypes=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),paramTypeArray=new RegExp(/^(.*)\[([0-9]*)\]$/);class ParamType{constructor(t,n){t!==_constructorGuard$2&&logger$t.throwError("use fromString",Logger.errors.UNSUPPORTED_OPERATION,{operation:"new ParamType()"}),populate(this,n);let ie=this.type.match(paramTypeArray);ie?populate(this,{arrayLength:parseInt(ie[2]||"-1"),arrayChildren:ParamType.fromObject({type:ie[1],components:this.components}),baseType:"array"}):populate(this,{arrayLength:null,arrayChildren:null,baseType:this.components!=null?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(t){if(t||(t=FormatTypes.sighash),FormatTypes[t]||logger$t.throwArgumentError("invalid format type","format",t),t===FormatTypes.json){let ie={type:this.baseType==="tuple"?"tuple":this.type,name:this.name||void 0};return typeof this.indexed=="boolean"&&(ie.indexed=this.indexed),this.components&&(ie.components=this.components.map(fe=>JSON.parse(fe.format(t)))),JSON.stringify(ie)}let n="";return this.baseType==="array"?(n+=this.arrayChildren.format(t),n+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):this.baseType==="tuple"?(t!==FormatTypes.sighash&&(n+=this.type),n+="("+this.components.map(ie=>ie.format(t)).join(t===FormatTypes.full?", ":",")+")"):n+=this.type,t!==FormatTypes.sighash&&(this.indexed===!0&&(n+=" indexed"),t===FormatTypes.full&&this.name&&(n+=" "+this.name)),n}static from(t,n){return typeof t=="string"?ParamType.fromString(t,n):ParamType.fromObject(t)}static fromObject(t){return ParamType.isParamType(t)?t:new ParamType(_constructorGuard$2,{name:t.name||null,type:verifyType(t.type),indexed:t.indexed==null?null:!!t.indexed,components:t.components?t.components.map(ParamType.fromObject):null})}static fromString(t,n){function ie(fe){return ParamType.fromObject({name:fe.name,type:fe.type,indexed:fe.indexed,components:fe.components})}return ie(parseParamType(t,!!n))}static isParamType(t){return!!(t!=null&&t._isParamType)}}function parseParams(c,t){return splitNesting(c).map(n=>ParamType.fromString(n,t))}class Fragment{constructor(t,n){t!==_constructorGuard$2&&logger$t.throwError("use a static from method",Logger.errors.UNSUPPORTED_OPERATION,{operation:"new Fragment()"}),populate(this,n),this._isFragment=!0,Object.freeze(this)}static from(t){return Fragment.isFragment(t)?t:typeof t=="string"?Fragment.fromString(t):Fragment.fromObject(t)}static fromObject(t){if(Fragment.isFragment(t))return t;switch(t.type){case"function":return FunctionFragment.fromObject(t);case"event":return EventFragment.fromObject(t);case"constructor":return ConstructorFragment.fromObject(t);case"error":return ErrorFragment.fromObject(t);case"fallback":case"receive":return null}return logger$t.throwArgumentError("invalid fragment object","value",t)}static fromString(t){return t=t.replace(/\s/g," "),t=t.replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," "),t=t.trim(),t.split(" ")[0]==="event"?EventFragment.fromString(t.substring(5).trim()):t.split(" ")[0]==="function"?FunctionFragment.fromString(t.substring(8).trim()):t.split("(")[0].trim()==="constructor"?ConstructorFragment.fromString(t.trim()):t.split(" ")[0]==="error"?ErrorFragment.fromString(t.substring(5).trim()):logger$t.throwArgumentError("unsupported fragment","value",t)}static isFragment(t){return!!(t&&t._isFragment)}}class EventFragment extends Fragment{format(t){if(t||(t=FormatTypes.sighash),FormatTypes[t]||logger$t.throwArgumentError("invalid format type","format",t),t===FormatTypes.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(ie=>JSON.parse(ie.format(t)))});let n="";return t!==FormatTypes.sighash&&(n+="event "),n+=this.name+"("+this.inputs.map(ie=>ie.format(t)).join(t===FormatTypes.full?", ":",")+") ",t!==FormatTypes.sighash&&this.anonymous&&(n+="anonymous "),n.trim()}static from(t){return typeof t=="string"?EventFragment.fromString(t):EventFragment.fromObject(t)}static fromObject(t){if(EventFragment.isEventFragment(t))return t;t.type!=="event"&&logger$t.throwArgumentError("invalid event object","value",t);const n={name:verifyIdentifier(t.name),anonymous:t.anonymous,inputs:t.inputs?t.inputs.map(ParamType.fromObject):[],type:"event"};return new EventFragment(_constructorGuard$2,n)}static fromString(t){let n=t.match(regexParen);n||logger$t.throwArgumentError("invalid event string","value",t);let ie=!1;return n[3].split(" ").forEach(fe=>{switch(fe.trim()){case"anonymous":ie=!0;break;case"":break;default:logger$t.warn("unknown modifier: "+fe)}}),EventFragment.fromObject({name:n[1].trim(),anonymous:ie,inputs:parseParams(n[2],!0),type:"event"})}static isEventFragment(t){return t&&t._isFragment&&t.type==="event"}}function parseGas(c,t){t.gas=null;let n=c.split("@");return n.length!==1?(n.length>2&&logger$t.throwArgumentError("invalid human-readable ABI signature","value",c),n[1].match(/^[0-9]+$/)||logger$t.throwArgumentError("invalid human-readable ABI signature gas","value",c),t.gas=BigNumber.from(n[1]),n[0]):c}function parseModifiers(c,t){t.constant=!1,t.payable=!1,t.stateMutability="nonpayable",c.split(" ").forEach(n=>{switch(n.trim()){case"constant":t.constant=!0;break;case"payable":t.payable=!0,t.stateMutability="payable";break;case"nonpayable":t.payable=!1,t.stateMutability="nonpayable";break;case"pure":t.constant=!0,t.stateMutability="pure";break;case"view":t.constant=!0,t.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+n)}})}function verifyState(c){let t={constant:!1,payable:!0,stateMutability:"payable"};return c.stateMutability!=null?(t.stateMutability=c.stateMutability,t.constant=t.stateMutability==="view"||t.stateMutability==="pure",c.constant!=null&&!!c.constant!==t.constant&&logger$t.throwArgumentError("cannot have constant function with mutability "+t.stateMutability,"value",c),t.payable=t.stateMutability==="payable",c.payable!=null&&!!c.payable!==t.payable&&logger$t.throwArgumentError("cannot have payable function with mutability "+t.stateMutability,"value",c)):c.payable!=null?(t.payable=!!c.payable,c.constant==null&&!t.payable&&c.type!=="constructor"&&logger$t.throwArgumentError("unable to determine stateMutability","value",c),t.constant=!!c.constant,t.constant?t.stateMutability="view":t.stateMutability=t.payable?"payable":"nonpayable",t.payable&&t.constant&&logger$t.throwArgumentError("cannot have constant payable function","value",c)):c.constant!=null?(t.constant=!!c.constant,t.payable=!t.constant,t.stateMutability=t.constant?"view":"payable"):c.type!=="constructor"&&logger$t.throwArgumentError("unable to determine stateMutability","value",c),t}class ConstructorFragment extends Fragment{format(t){if(t||(t=FormatTypes.sighash),FormatTypes[t]||logger$t.throwArgumentError("invalid format type","format",t),t===FormatTypes.json)return JSON.stringify({type:"constructor",stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(ie=>JSON.parse(ie.format(t)))});t===FormatTypes.sighash&&logger$t.throwError("cannot format a constructor for sighash",Logger.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let n="constructor("+this.inputs.map(ie=>ie.format(t)).join(t===FormatTypes.full?", ":",")+") ";return this.stateMutability&&this.stateMutability!=="nonpayable"&&(n+=this.stateMutability+" "),n.trim()}static from(t){return typeof t=="string"?ConstructorFragment.fromString(t):ConstructorFragment.fromObject(t)}static fromObject(t){if(ConstructorFragment.isConstructorFragment(t))return t;t.type!=="constructor"&&logger$t.throwArgumentError("invalid constructor object","value",t);let n=verifyState(t);n.constant&&logger$t.throwArgumentError("constructor cannot be constant","value",t);const ie={name:null,type:t.type,inputs:t.inputs?t.inputs.map(ParamType.fromObject):[],payable:n.payable,stateMutability:n.stateMutability,gas:t.gas?BigNumber.from(t.gas):null};return new ConstructorFragment(_constructorGuard$2,ie)}static fromString(t){let n={type:"constructor"};t=parseGas(t,n);let ie=t.match(regexParen);return(!ie||ie[1].trim()!=="constructor")&&logger$t.throwArgumentError("invalid constructor string","value",t),n.inputs=parseParams(ie[2].trim(),!1),parseModifiers(ie[3].trim(),n),ConstructorFragment.fromObject(n)}static isConstructorFragment(t){return t&&t._isFragment&&t.type==="constructor"}}class FunctionFragment extends ConstructorFragment{format(t){if(t||(t=FormatTypes.sighash),FormatTypes[t]||logger$t.throwArgumentError("invalid format type","format",t),t===FormatTypes.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(ie=>JSON.parse(ie.format(t))),outputs:this.outputs.map(ie=>JSON.parse(ie.format(t)))});let n="";return t!==FormatTypes.sighash&&(n+="function "),n+=this.name+"("+this.inputs.map(ie=>ie.format(t)).join(t===FormatTypes.full?", ":",")+") ",t!==FormatTypes.sighash&&(this.stateMutability?this.stateMutability!=="nonpayable"&&(n+=this.stateMutability+" "):this.constant&&(n+="view "),this.outputs&&this.outputs.length&&(n+="returns ("+this.outputs.map(ie=>ie.format(t)).join(", ")+") "),this.gas!=null&&(n+="@"+this.gas.toString()+" ")),n.trim()}static from(t){return typeof t=="string"?FunctionFragment.fromString(t):FunctionFragment.fromObject(t)}static fromObject(t){if(FunctionFragment.isFunctionFragment(t))return t;t.type!=="function"&&logger$t.throwArgumentError("invalid function object","value",t);let n=verifyState(t);const ie={type:t.type,name:verifyIdentifier(t.name),constant:n.constant,inputs:t.inputs?t.inputs.map(ParamType.fromObject):[],outputs:t.outputs?t.outputs.map(ParamType.fromObject):[],payable:n.payable,stateMutability:n.stateMutability,gas:t.gas?BigNumber.from(t.gas):null};return new FunctionFragment(_constructorGuard$2,ie)}static fromString(t){let n={type:"function"};t=parseGas(t,n);let ie=t.split(" returns ");ie.length>2&&logger$t.throwArgumentError("invalid function string","value",t);let fe=ie[0].match(regexParen);if(fe||logger$t.throwArgumentError("invalid function signature","value",t),n.name=fe[1].trim(),n.name&&verifyIdentifier(n.name),n.inputs=parseParams(fe[2],!1),parseModifiers(fe[3].trim(),n),ie.length>1){let ae=ie[1].match(regexParen);(ae[1].trim()!=""||ae[3].trim()!="")&&logger$t.throwArgumentError("unexpected tokens","value",t),n.outputs=parseParams(ae[2],!1)}else n.outputs=[];return FunctionFragment.fromObject(n)}static isFunctionFragment(t){return t&&t._isFragment&&t.type==="function"}}function checkForbidden(c){const t=c.format();return(t==="Error(string)"||t==="Panic(uint256)")&&logger$t.throwArgumentError(`cannot specify user defined ${t} error`,"fragment",c),c}class ErrorFragment extends Fragment{format(t){if(t||(t=FormatTypes.sighash),FormatTypes[t]||logger$t.throwArgumentError("invalid format type","format",t),t===FormatTypes.json)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(ie=>JSON.parse(ie.format(t)))});let n="";return t!==FormatTypes.sighash&&(n+="error "),n+=this.name+"("+this.inputs.map(ie=>ie.format(t)).join(t===FormatTypes.full?", ":",")+") ",n.trim()}static from(t){return typeof t=="string"?ErrorFragment.fromString(t):ErrorFragment.fromObject(t)}static fromObject(t){if(ErrorFragment.isErrorFragment(t))return t;t.type!=="error"&&logger$t.throwArgumentError("invalid error object","value",t);const n={type:t.type,name:verifyIdentifier(t.name),inputs:t.inputs?t.inputs.map(ParamType.fromObject):[]};return checkForbidden(new ErrorFragment(_constructorGuard$2,n))}static fromString(t){let n={type:"error"},ie=t.match(regexParen);return ie||logger$t.throwArgumentError("invalid error signature","value",t),n.name=ie[1].trim(),n.name&&verifyIdentifier(n.name),n.inputs=parseParams(ie[2],!1),checkForbidden(ErrorFragment.fromObject(n))}static isErrorFragment(t){return t&&t._isFragment&&t.type==="error"}}function verifyType(c){return c.match(/^uint($|[^1-9])/)?c="uint256"+c.substring(4):c.match(/^int($|[^1-9])/)&&(c="int256"+c.substring(3)),c}const regexIdentifier=new RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$");function verifyIdentifier(c){return(!c||!c.match(regexIdentifier))&&logger$t.throwArgumentError(`invalid identifier "${c}"`,"value",c),c}const regexParen=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");function splitNesting(c){c=c.trim();let t=[],n="",ie=0;for(let fe=0;fe<c.length;fe++){let ae=c[fe];ae===","&&ie===0?(t.push(n),n=""):(n+=ae,ae==="("?ie++:ae===")"&&(ie--,ie===-1&&logger$t.throwArgumentError("unbalanced parenthesis","value",c)))}return n&&t.push(n),t}const logger$s=new Logger(version$q);function checkResultErrors(c){const t=[],n=function(ie,fe){if(Array.isArray(fe))for(let ae in fe){const le=ie.slice();le.push(ae);try{n(le,fe[ae])}catch(he){t.push({path:le,error:he})}}};return n([],c),t}class Coder{constructor(t,n,ie,fe){this.name=t,this.type=n,this.localName=ie,this.dynamic=fe}_throwError(t,n){logger$s.throwArgumentError(t,this.localName,n)}}class Writer{constructor(t){defineReadOnly(this,"wordSize",t||32),this._data=[],this._dataLength=0,this._padding=new Uint8Array(t)}get data(){return hexConcat(this._data)}get length(){return this._dataLength}_writeData(t){return this._data.push(t),this._dataLength+=t.length,t.length}appendWriter(t){return this._writeData(concat$1(t._data))}writeBytes(t){let n=arrayify(t);const ie=n.length%this.wordSize;return ie&&(n=concat$1([n,this._padding.slice(ie)])),this._writeData(n)}_getValue(t){let n=arrayify(BigNumber.from(t));return n.length>this.wordSize&&logger$s.throwError("value out-of-bounds",Logger.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:n.length}),n.length%this.wordSize&&(n=concat$1([this._padding.slice(n.length%this.wordSize),n])),n}writeValue(t){return this._writeData(this._getValue(t))}writeUpdatableValue(){const t=this._data.length;return this._data.push(this._padding),this._dataLength+=this.wordSize,n=>{this._data[t]=this._getValue(n)}}}class Reader{constructor(t,n,ie,fe){defineReadOnly(this,"_data",arrayify(t)),defineReadOnly(this,"wordSize",n||32),defineReadOnly(this,"_coerceFunc",ie),defineReadOnly(this,"allowLoose",fe),this._offset=0}get data(){return hexlify(this._data)}get consumed(){return this._offset}static coerce(t,n){let ie=t.match("^u?int([0-9]+)$");return ie&&parseInt(ie[1])<=48&&(n=n.toNumber()),n}coerce(t,n){return this._coerceFunc?this._coerceFunc(t,n):Reader.coerce(t,n)}_peekBytes(t,n,ie){let fe=Math.ceil(n/this.wordSize)*this.wordSize;return this._offset+fe>this._data.length&&(this.allowLoose&&ie&&this._offset+n<=this._data.length?fe=n:logger$s.throwError("data out-of-bounds",Logger.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+fe})),this._data.slice(this._offset,this._offset+fe)}subReader(t){return new Reader(this._data.slice(this._offset+t),this.wordSize,this._coerceFunc,this.allowLoose)}readBytes(t,n){let ie=this._peekBytes(0,t,!!n);return this._offset+=ie.length,ie.slice(0,t)}readValue(){return BigNumber.from(this.readBytes(this.wordSize))}}function getDefaultExportFromCjs$1(c){return c&&c.__esModule&&Object.prototype.hasOwnProperty.call(c,"default")?c.default:c}var browser$e={exports:{}},process=browser$e.exports={},cachedSetTimeout,cachedClearTimeout;function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?cachedSetTimeout=setTimeout:cachedSetTimeout=defaultSetTimout}catch{cachedSetTimeout=defaultSetTimout}try{typeof clearTimeout=="function"?cachedClearTimeout=clearTimeout:cachedClearTimeout=defaultClearTimeout}catch{cachedClearTimeout=defaultClearTimeout}})();function runTimeout(c){if(cachedSetTimeout===setTimeout)return setTimeout(c,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(c,0);try{return cachedSetTimeout(c,0)}catch{try{return cachedSetTimeout.call(null,c,0)}catch{return cachedSetTimeout.call(this,c,0)}}}function runClearTimeout(c){if(cachedClearTimeout===clearTimeout)return clearTimeout(c);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(c);try{return cachedClearTimeout(c)}catch{try{return cachedClearTimeout.call(null,c)}catch{return cachedClearTimeout.call(this,c)}}}var queue=[],draining=!1,currentQueue,queueIndex=-1;function cleanUpNextTick(){!draining||!currentQueue||(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var c=runTimeout(cleanUpNextTick);draining=!0;for(var t=queue.length;t;){for(currentQueue=queue,queue=[];++queueIndex<t;)currentQueue&&currentQueue[queueIndex].run();queueIndex=-1,t=queue.length}currentQueue=null,draining=!1,runClearTimeout(c)}}process.nextTick=function(c){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];queue.push(new Item(c,t)),queue.length===1&&!draining&&runTimeout(drainQueue)};function Item(c,t){this.fun=c,this.array=t}Item.prototype.run=function(){this.fun.apply(null,this.array)};process.title="browser";process.browser=!0;process.env={};process.argv=[];process.version="";process.versions={};function noop(){}process.on=noop;process.addListener=noop;process.once=noop;process.off=noop;process.removeListener=noop;process.removeAllListeners=noop;process.emit=noop;process.prependListener=noop;process.prependOnceListener=noop;process.listeners=function(c){return[]};process.binding=function(c){throw new Error("process.binding is not supported")};process.cwd=function(){return"/"};process.chdir=function(c){throw new Error("process.chdir is not supported")};process.umask=function(){return 0};var browserExports=browser$e.exports;const process$1=getDefaultExportFromCjs$1(browserExports);var sha3$3={exports:{}};(function(c){(function(){var t="input is invalid type",n="finalize already called",ie=typeof window=="object",fe=ie?window:{};fe.JS_SHA3_NO_WINDOW&&(ie=!1);var ae=!ie&&typeof self=="object",le=!fe.JS_SHA3_NO_NODE_JS&&typeof process$1=="object"&&process$1.versions&&process$1.versions.node;le?fe=globalThis:ae&&(fe=self);var he=!fe.JS_SHA3_NO_COMMON_JS&&!0&&c.exports,ye=!fe.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",me="0123456789abcdef".split(""),xe=[31,7936,2031616,520093696],Ee=[4,1024,262144,67108864],Se=[1,256,65536,16777216],Me=[6,1536,393216,100663296],Be=[0,8,16,24],$e=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],Ce=[224,256,384,512],ke=[128,256],Pe=["hex","buffer","arrayBuffer","array","digest"],Ue={128:168,256:136};(fe.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(Ie){return Object.prototype.toString.call(Ie)==="[object Array]"}),ye&&(fe.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(Ie){return typeof Ie=="object"&&Ie.buffer&&Ie.buffer.constructor===ArrayBuffer});for(var qe=function(Ie,je,Te){return function(De){return new Re(Ie,je,Ie).update(De)[Te]()}},He=function(Ie,je,Te){return function(De,ze){return new Re(Ie,je,ze).update(De)[Te]()}},Ve=function(Ie,je,Te){return function(De,ze,Xe,Rt){return de["cshake"+Ie].update(De,ze,Xe,Rt)[Te]()}},Ye=function(Ie,je,Te){return function(De,ze,Xe,Rt){return de["kmac"+Ie].update(De,ze,Xe,Rt)[Te]()}},Qe=function(Ie,je,Te,De){for(var ze=0;ze<Pe.length;++ze){var Xe=Pe[ze];Ie[Xe]=je(Te,De,Xe)}return Ie},Ke=function(Ie,je){var Te=qe(Ie,je,"hex");return Te.create=function(){return new Re(Ie,je,Ie)},Te.update=function(De){return Te.create().update(De)},Qe(Te,qe,Ie,je)},Pt=function(Ie,je){var Te=He(Ie,je,"hex");return Te.create=function(De){return new Re(Ie,je,De)},Te.update=function(De,ze){return Te.create(ze).update(De)},Qe(Te,He,Ie,je)},_e=function(Ie,je){var Te=Ue[Ie],De=Ve(Ie,je,"hex");return De.create=function(ze,Xe,Rt){return!Xe&&!Rt?de["shake"+Ie].create(ze):new Re(Ie,je,ze).bytepad([Xe,Rt],Te)},De.update=function(ze,Xe,Rt,Oe){return De.create(Xe,Rt,Oe).update(ze)},Qe(De,Ve,Ie,je)},se=function(Ie,je){var Te=Ue[Ie],De=Ye(Ie,je,"hex");return De.create=function(ze,Xe,Rt){return new Ne(Ie,je,Xe).bytepad(["KMAC",Rt],Te).bytepad([ze],Te)},De.update=function(ze,Xe,Rt,Oe){return De.create(ze,Rt,Oe).update(Xe)},Qe(De,Ye,Ie,je)},ce=[{name:"keccak",padding:Se,bits:Ce,createMethod:Ke},{name:"sha3",padding:Me,bits:Ce,createMethod:Ke},{name:"shake",padding:xe,bits:ke,createMethod:Pt},{name:"cshake",padding:Ee,bits:ke,createMethod:_e},{name:"kmac",padding:Ee,bits:ke,createMethod:se}],de={},pe=[],ve=0;ve<ce.length;++ve)for(var we=ce[ve],Ae=we.bits,ge=0;ge<Ae.length;++ge){var ue=we.name+"_"+Ae[ge];if(pe.push(ue),de[ue]=we.createMethod(Ae[ge],we.padding),we.name!=="sha3"){var be=we.name+Ae[ge];pe.push(be),de[be]=de[ue]}}function Re(Ie,je,Te){this.blocks=[],this.s=[],this.padding=je,this.outputBits=Te,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(Ie<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=Te>>5,this.extraBytes=(Te&31)>>3;for(var De=0;De<50;++De)this.s[De]=0}Re.prototype.update=function(Ie){if(this.finalized)throw new Error(n);var je,Te=typeof Ie;if(Te!=="string"){if(Te==="object"){if(Ie===null)throw new Error(t);if(ye&&Ie.constructor===ArrayBuffer)Ie=new Uint8Array(Ie);else if(!Array.isArray(Ie)&&(!ye||!ArrayBuffer.isView(Ie)))throw new Error(t)}else throw new Error(t);je=!0}for(var De=this.blocks,ze=this.byteCount,Xe=Ie.length,Rt=this.blockCount,Oe=0,Ze=this.s,Gt,Dt;Oe<Xe;){if(this.reset)for(this.reset=!1,De[0]=this.block,Gt=1;Gt<Rt+1;++Gt)De[Gt]=0;if(je)for(Gt=this.start;Oe<Xe&&Gt<ze;++Oe)De[Gt>>2]|=Ie[Oe]<<Be[Gt++&3];else for(Gt=this.start;Oe<Xe&&Gt<ze;++Oe)Dt=Ie.charCodeAt(Oe),Dt<128?De[Gt>>2]|=Dt<<Be[Gt++&3]:Dt<2048?(De[Gt>>2]|=(192|Dt>>6)<<Be[Gt++&3],De[Gt>>2]|=(128|Dt&63)<<Be[Gt++&3]):Dt<55296||Dt>=57344?(De[Gt>>2]|=(224|Dt>>12)<<Be[Gt++&3],De[Gt>>2]|=(128|Dt>>6&63)<<Be[Gt++&3],De[Gt>>2]|=(128|Dt&63)<<Be[Gt++&3]):(Dt=65536+((Dt&1023)<<10|Ie.charCodeAt(++Oe)&1023),De[Gt>>2]|=(240|Dt>>18)<<Be[Gt++&3],De[Gt>>2]|=(128|Dt>>12&63)<<Be[Gt++&3],De[Gt>>2]|=(128|Dt>>6&63)<<Be[Gt++&3],De[Gt>>2]|=(128|Dt&63)<<Be[Gt++&3]);if(this.lastByteIndex=Gt,Gt>=ze){for(this.start=Gt-ze,this.block=De[Rt],Gt=0;Gt<Rt;++Gt)Ze[Gt]^=De[Gt];Fe(Ze),this.reset=!0}else this.start=Gt}return this},Re.prototype.encode=function(Ie,je){var Te=Ie&255,De=1,ze=[Te];for(Ie=Ie>>8,Te=Ie&255;Te>0;)ze.unshift(Te),Ie=Ie>>8,Te=Ie&255,++De;return je?ze.push(De):ze.unshift(De),this.update(ze),ze.length},Re.prototype.encodeString=function(Ie){var je,Te=typeof Ie;if(Te!=="string"){if(Te==="object"){if(Ie===null)throw new Error(t);if(ye&&Ie.constructor===ArrayBuffer)Ie=new Uint8Array(Ie);else if(!Array.isArray(Ie)&&(!ye||!ArrayBuffer.isView(Ie)))throw new Error(t)}else throw new Error(t);je=!0}var De=0,ze=Ie.length;if(je)De=ze;else for(var Xe=0;Xe<Ie.length;++Xe){var Rt=Ie.charCodeAt(Xe);Rt<128?De+=1:Rt<2048?De+=2:Rt<55296||Rt>=57344?De+=3:(Rt=65536+((Rt&1023)<<10|Ie.charCodeAt(++Xe)&1023),De+=4)}return De+=this.encode(De*8),this.update(Ie),De},Re.prototype.bytepad=function(Ie,je){for(var Te=this.encode(je),De=0;De<Ie.length;++De)Te+=this.encodeString(Ie[De]);var ze=je-Te%je,Xe=[];return Xe.length=ze,this.update(Xe),this},Re.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var Ie=this.blocks,je=this.lastByteIndex,Te=this.blockCount,De=this.s;if(Ie[je>>2]|=this.padding[je&3],this.lastByteIndex===this.byteCount)for(Ie[0]=Ie[Te],je=1;je<Te+1;++je)Ie[je]=0;for(Ie[Te-1]|=2147483648,je=0;je<Te;++je)De[je]^=Ie[je];Fe(De)}},Re.prototype.toString=Re.prototype.hex=function(){this.finalize();for(var Ie=this.blockCount,je=this.s,Te=this.outputBlocks,De=this.extraBytes,ze=0,Xe=0,Rt="",Oe;Xe<Te;){for(ze=0;ze<Ie&&Xe<Te;++ze,++Xe)Oe=je[ze],Rt+=me[Oe>>4&15]+me[Oe&15]+me[Oe>>12&15]+me[Oe>>8&15]+me[Oe>>20&15]+me[Oe>>16&15]+me[Oe>>28&15]+me[Oe>>24&15];Xe%Ie===0&&(Fe(je),ze=0)}return De&&(Oe=je[ze],Rt+=me[Oe>>4&15]+me[Oe&15],De>1&&(Rt+=me[Oe>>12&15]+me[Oe>>8&15]),De>2&&(Rt+=me[Oe>>20&15]+me[Oe>>16&15])),Rt},Re.prototype.arrayBuffer=function(){this.finalize();var Ie=this.blockCount,je=this.s,Te=this.outputBlocks,De=this.extraBytes,ze=0,Xe=0,Rt=this.outputBits>>3,Oe;De?Oe=new ArrayBuffer(Te+1<<2):Oe=new ArrayBuffer(Rt);for(var Ze=new Uint32Array(Oe);Xe<Te;){for(ze=0;ze<Ie&&Xe<Te;++ze,++Xe)Ze[Xe]=je[ze];Xe%Ie===0&&Fe(je)}return De&&(Ze[ze]=je[ze],Oe=Oe.slice(0,Rt)),Oe},Re.prototype.buffer=Re.prototype.arrayBuffer,Re.prototype.digest=Re.prototype.array=function(){this.finalize();for(var Ie=this.blockCount,je=this.s,Te=this.outputBlocks,De=this.extraBytes,ze=0,Xe=0,Rt=[],Oe,Ze;Xe<Te;){for(ze=0;ze<Ie&&Xe<Te;++ze,++Xe)Oe=Xe<<2,Ze=je[ze],Rt[Oe]=Ze&255,Rt[Oe+1]=Ze>>8&255,Rt[Oe+2]=Ze>>16&255,Rt[Oe+3]=Ze>>24&255;Xe%Ie===0&&Fe(je)}return De&&(Oe=Xe<<2,Ze=je[ze],Rt[Oe]=Ze&255,De>1&&(Rt[Oe+1]=Ze>>8&255),De>2&&(Rt[Oe+2]=Ze>>16&255)),Rt};function Ne(Ie,je,Te){Re.call(this,Ie,je,Te)}Ne.prototype=new Re,Ne.prototype.finalize=function(){return this.encode(this.outputBits,!0),Re.prototype.finalize.call(this)};var Fe=function(Ie){var je,Te,De,ze,Xe,Rt,Oe,Ze,Gt,Dt,jt,hn,Zt,Kt,An,Yt,Jt,_n,Je,$t,Xt,Ht,Vt,rn,We,Le,Ge,Mt,Ft,Qt,Wt,en,En,tn,nn,Sn,an,pn,Bn,sn,yn,$n,fn,mn,kn,un,gn,Cn,cn,vn,Tn,ln,xn,Nn,dn,wn,Mn,Rn,Pn,In,On,Dn,Ln;for(De=0;De<48;De+=2)ze=Ie[0]^Ie[10]^Ie[20]^Ie[30]^Ie[40],Xe=Ie[1]^Ie[11]^Ie[21]^Ie[31]^Ie[41],Rt=Ie[2]^Ie[12]^Ie[22]^Ie[32]^Ie[42],Oe=Ie[3]^Ie[13]^Ie[23]^Ie[33]^Ie[43],Ze=Ie[4]^Ie[14]^Ie[24]^Ie[34]^Ie[44],Gt=Ie[5]^Ie[15]^Ie[25]^Ie[35]^Ie[45],Dt=Ie[6]^Ie[16]^Ie[26]^Ie[36]^Ie[46],jt=Ie[7]^Ie[17]^Ie[27]^Ie[37]^Ie[47],hn=Ie[8]^Ie[18]^Ie[28]^Ie[38]^Ie[48],Zt=Ie[9]^Ie[19]^Ie[29]^Ie[39]^Ie[49],je=hn^(Rt<<1|Oe>>>31),Te=Zt^(Oe<<1|Rt>>>31),Ie[0]^=je,Ie[1]^=Te,Ie[10]^=je,Ie[11]^=Te,Ie[20]^=je,Ie[21]^=Te,Ie[30]^=je,Ie[31]^=Te,Ie[40]^=je,Ie[41]^=Te,je=ze^(Ze<<1|Gt>>>31),Te=Xe^(Gt<<1|Ze>>>31),Ie[2]^=je,Ie[3]^=Te,Ie[12]^=je,Ie[13]^=Te,Ie[22]^=je,Ie[23]^=Te,Ie[32]^=je,Ie[33]^=Te,Ie[42]^=je,Ie[43]^=Te,je=Rt^(Dt<<1|jt>>>31),Te=Oe^(jt<<1|Dt>>>31),Ie[4]^=je,Ie[5]^=Te,Ie[14]^=je,Ie[15]^=Te,Ie[24]^=je,Ie[25]^=Te,Ie[34]^=je,Ie[35]^=Te,Ie[44]^=je,Ie[45]^=Te,je=Ze^(hn<<1|Zt>>>31),Te=Gt^(Zt<<1|hn>>>31),Ie[6]^=je,Ie[7]^=Te,Ie[16]^=je,Ie[17]^=Te,Ie[26]^=je,Ie[27]^=Te,Ie[36]^=je,Ie[37]^=Te,Ie[46]^=je,Ie[47]^=Te,je=Dt^(ze<<1|Xe>>>31),Te=jt^(Xe<<1|ze>>>31),Ie[8]^=je,Ie[9]^=Te,Ie[18]^=je,Ie[19]^=Te,Ie[28]^=je,Ie[29]^=Te,Ie[38]^=je,Ie[39]^=Te,Ie[48]^=je,Ie[49]^=Te,Kt=Ie[0],An=Ie[1],un=Ie[11]<<4|Ie[10]>>>28,gn=Ie[10]<<4|Ie[11]>>>28,Mt=Ie[20]<<3|Ie[21]>>>29,Ft=Ie[21]<<3|Ie[20]>>>29,In=Ie[31]<<9|Ie[30]>>>23,On=Ie[30]<<9|Ie[31]>>>23,$n=Ie[40]<<18|Ie[41]>>>14,fn=Ie[41]<<18|Ie[40]>>>14,tn=Ie[2]<<1|Ie[3]>>>31,nn=Ie[3]<<1|Ie[2]>>>31,Yt=Ie[13]<<12|Ie[12]>>>20,Jt=Ie[12]<<12|Ie[13]>>>20,Cn=Ie[22]<<10|Ie[23]>>>22,cn=Ie[23]<<10|Ie[22]>>>22,Qt=Ie[33]<<13|Ie[32]>>>19,Wt=Ie[32]<<13|Ie[33]>>>19,Dn=Ie[42]<<2|Ie[43]>>>30,Ln=Ie[43]<<2|Ie[42]>>>30,Nn=Ie[5]<<30|Ie[4]>>>2,dn=Ie[4]<<30|Ie[5]>>>2,Sn=Ie[14]<<6|Ie[15]>>>26,an=Ie[15]<<6|Ie[14]>>>26,_n=Ie[25]<<11|Ie[24]>>>21,Je=Ie[24]<<11|Ie[25]>>>21,vn=Ie[34]<<15|Ie[35]>>>17,Tn=Ie[35]<<15|Ie[34]>>>17,en=Ie[45]<<29|Ie[44]>>>3,En=Ie[44]<<29|Ie[45]>>>3,rn=Ie[6]<<28|Ie[7]>>>4,We=Ie[7]<<28|Ie[6]>>>4,wn=Ie[17]<<23|Ie[16]>>>9,Mn=Ie[16]<<23|Ie[17]>>>9,pn=Ie[26]<<25|Ie[27]>>>7,Bn=Ie[27]<<25|Ie[26]>>>7,$t=Ie[36]<<21|Ie[37]>>>11,Xt=Ie[37]<<21|Ie[36]>>>11,ln=Ie[47]<<24|Ie[46]>>>8,xn=Ie[46]<<24|Ie[47]>>>8,mn=Ie[8]<<27|Ie[9]>>>5,kn=Ie[9]<<27|Ie[8]>>>5,Le=Ie[18]<<20|Ie[19]>>>12,Ge=Ie[19]<<20|Ie[18]>>>12,Rn=Ie[29]<<7|Ie[28]>>>25,Pn=Ie[28]<<7|Ie[29]>>>25,sn=Ie[38]<<8|Ie[39]>>>24,yn=Ie[39]<<8|Ie[38]>>>24,Ht=Ie[48]<<14|Ie[49]>>>18,Vt=Ie[49]<<14|Ie[48]>>>18,Ie[0]=Kt^~Yt&_n,Ie[1]=An^~Jt&Je,Ie[10]=rn^~Le&Mt,Ie[11]=We^~Ge&Ft,Ie[20]=tn^~Sn&pn,Ie[21]=nn^~an&Bn,Ie[30]=mn^~un&Cn,Ie[31]=kn^~gn&cn,Ie[40]=Nn^~wn&Rn,Ie[41]=dn^~Mn&Pn,Ie[2]=Yt^~_n&$t,Ie[3]=Jt^~Je&Xt,Ie[12]=Le^~Mt&Qt,Ie[13]=Ge^~Ft&Wt,Ie[22]=Sn^~pn&sn,Ie[23]=an^~Bn&yn,Ie[32]=un^~Cn&vn,Ie[33]=gn^~cn&Tn,Ie[42]=wn^~Rn&In,Ie[43]=Mn^~Pn&On,Ie[4]=_n^~$t&Ht,Ie[5]=Je^~Xt&Vt,Ie[14]=Mt^~Qt&en,Ie[15]=Ft^~Wt&En,Ie[24]=pn^~sn&$n,Ie[25]=Bn^~yn&fn,Ie[34]=Cn^~vn&ln,Ie[35]=cn^~Tn&xn,Ie[44]=Rn^~In&Dn,Ie[45]=Pn^~On&Ln,Ie[6]=$t^~Ht&Kt,Ie[7]=Xt^~Vt&An,Ie[16]=Qt^~en&rn,Ie[17]=Wt^~En&We,Ie[26]=sn^~$n&tn,Ie[27]=yn^~fn&nn,Ie[36]=vn^~ln&mn,Ie[37]=Tn^~xn&kn,Ie[46]=In^~Dn&Nn,Ie[47]=On^~Ln&dn,Ie[8]=Ht^~Kt&Yt,Ie[9]=Vt^~An&Jt,Ie[18]=en^~rn&Le,Ie[19]=En^~We&Ge,Ie[28]=$n^~tn&Sn,Ie[29]=fn^~nn&an,Ie[38]=ln^~mn&un,Ie[39]=xn^~kn&gn,Ie[48]=Dn^~Nn&wn,Ie[49]=Ln^~dn&Mn,Ie[0]^=$e[De],Ie[1]^=$e[De+1]};if(he)c.exports=de;else for(ve=0;ve<pe.length;++ve)fe[pe[ve]]=de[pe[ve]]})()})(sha3$3);var sha3Exports$1=sha3$3.exports;const sha3$2=getDefaultExportFromCjs$2(sha3Exports$1);function keccak256$1(c){return"0x"+sha3$2.keccak_256(arrayify(c))}const lib_esm$h=Object.freeze(Object.defineProperty({__proto__:null,keccak256:keccak256$1},Symbol.toStringTag,{value:"Module"})),version$p="rlp/5.8.0",logger$r=new Logger(version$p);function arrayifyInteger(c){const t=[];for(;c;)t.unshift(c&255),c>>=8;return t}function unarrayifyInteger(c,t,n){let ie=0;for(let fe=0;fe<n;fe++)ie=ie*256+c[t+fe];return ie}function _encode(c){if(Array.isArray(c)){let ie=[];if(c.forEach(function(ae){ie=ie.concat(_encode(ae))}),ie.length<=55)return ie.unshift(192+ie.length),ie;const fe=arrayifyInteger(ie.length);return fe.unshift(247+fe.length),fe.concat(ie)}isBytesLike(c)||logger$r.throwArgumentError("RLP object must be BytesLike","object",c);const t=Array.prototype.slice.call(arrayify(c));if(t.length===1&&t[0]<=127)return t;if(t.length<=55)return t.unshift(128+t.length),t;const n=arrayifyInteger(t.length);return n.unshift(183+n.length),n.concat(t)}function encode$6(c){return hexlify(_encode(c))}function _decodeChildren(c,t,n,ie){const fe=[];for(;n<t+1+ie;){const ae=_decode(c,n);fe.push(ae.result),n+=ae.consumed,n>t+1+ie&&logger$r.throwError("child data too short",Logger.errors.BUFFER_OVERRUN,{})}return{consumed:1+ie,result:fe}}function _decode(c,t){if(c.length===0&&logger$r.throwError("data too short",Logger.errors.BUFFER_OVERRUN,{}),c[t]>=248){const n=c[t]-247;t+1+n>c.length&&logger$r.throwError("data short segment too short",Logger.errors.BUFFER_OVERRUN,{});const ie=unarrayifyInteger(c,t+1,n);return t+1+n+ie>c.length&&logger$r.throwError("data long segment too short",Logger.errors.BUFFER_OVERRUN,{}),_decodeChildren(c,t,t+1+n,n+ie)}else if(c[t]>=192){const n=c[t]-192;return t+1+n>c.length&&logger$r.throwError("data array too short",Logger.errors.BUFFER_OVERRUN,{}),_decodeChildren(c,t,t+1,n)}else if(c[t]>=184){const n=c[t]-183;t+1+n>c.length&&logger$r.throwError("data array too short",Logger.errors.BUFFER_OVERRUN,{});const ie=unarrayifyInteger(c,t+1,n);t+1+n+ie>c.length&&logger$r.throwError("data array too short",Logger.errors.BUFFER_OVERRUN,{});const fe=hexlify(c.slice(t+1+n,t+1+n+ie));return{consumed:1+n+ie,result:fe}}else if(c[t]>=128){const n=c[t]-128;t+1+n>c.length&&logger$r.throwError("data too short",Logger.errors.BUFFER_OVERRUN,{});const ie=hexlify(c.slice(t+1,t+1+n));return{consumed:1+n,result:ie}}return{consumed:1,result:hexlify(c[t])}}function decode$7(c){const t=arrayify(c),n=_decode(t,0);return n.consumed!==t.length&&logger$r.throwArgumentError("invalid rlp data","data",c),n.result}const lib_esm$g=Object.freeze(Object.defineProperty({__proto__:null,decode:decode$7,encode:encode$6},Symbol.toStringTag,{value:"Module"})),version$o="address/5.8.0",logger$q=new Logger(version$o);function getChecksumAddress(c){isHexString(c,20)||logger$q.throwArgumentError("invalid address","address",c),c=c.toLowerCase();const t=c.substring(2).split(""),n=new Uint8Array(40);for(let fe=0;fe<40;fe++)n[fe]=t[fe].charCodeAt(0);const ie=arrayify(keccak256$1(n));for(let fe=0;fe<40;fe+=2)ie[fe>>1]>>4>=8&&(t[fe]=t[fe].toUpperCase()),(ie[fe>>1]&15)>=8&&(t[fe+1]=t[fe+1].toUpperCase());return"0x"+t.join("")}const MAX_SAFE_INTEGER=9007199254740991;function log10(c){return Math.log10?Math.log10(c):Math.log(c)/Math.LN10}const ibanLookup={};for(let c=0;c<10;c++)ibanLookup[String(c)]=String(c);for(let c=0;c<26;c++)ibanLookup[String.fromCharCode(65+c)]=String(10+c);const safeDigits=Math.floor(log10(MAX_SAFE_INTEGER));function ibanChecksum(c){c=c.toUpperCase(),c=c.substring(4)+c.substring(0,2)+"00";let t=c.split("").map(ie=>ibanLookup[ie]).join("");for(;t.length>=safeDigits;){let ie=t.substring(0,safeDigits);t=parseInt(ie,10)%97+t.substring(ie.length)}let n=String(98-parseInt(t,10)%97);for(;n.length<2;)n="0"+n;return n}function getAddress$1(c){let t=null;if(typeof c!="string"&&logger$q.throwArgumentError("invalid address","address",c),c.match(/^(0x)?[0-9a-fA-F]{40}$/))c.substring(0,2)!=="0x"&&(c="0x"+c),t=getChecksumAddress(c),c.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==c&&logger$q.throwArgumentError("bad address checksum","address",c);else if(c.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(c.substring(2,4)!==ibanChecksum(c)&&logger$q.throwArgumentError("bad icap checksum","address",c),t=_base36To16(c.substring(4));t.length<40;)t="0"+t;t=getChecksumAddress("0x"+t)}else logger$q.throwArgumentError("invalid address","address",c);return t}function isAddress(c){try{return getAddress$1(c),!0}catch{}return!1}function getIcapAddress(c){let t=_base16To36(getAddress$1(c).substring(2)).toUpperCase();for(;t.length<30;)t="0"+t;return"XE"+ibanChecksum("XE00"+t)+t}function getContractAddress(c){let t=null;try{t=getAddress$1(c.from)}catch{logger$q.throwArgumentError("missing from address","transaction",c)}const n=stripZeros(arrayify(BigNumber.from(c.nonce).toHexString()));return getAddress$1(hexDataSlice(keccak256$1(encode$6([t,n])),12))}function getCreate2Address(c,t,n){return hexDataLength(t)!==32&&logger$q.throwArgumentError("salt must be 32 bytes","salt",t),hexDataLength(n)!==32&&logger$q.throwArgumentError("initCodeHash must be 32 bytes","initCodeHash",n),getAddress$1(hexDataSlice(keccak256$1(concat$1(["0xff",getAddress$1(c),t,n])),12))}const lib_esm$f=Object.freeze(Object.defineProperty({__proto__:null,getAddress:getAddress$1,getContractAddress,getCreate2Address,getIcapAddress,isAddress},Symbol.toStringTag,{value:"Module"}));class AddressCoder extends Coder{constructor(t){super("address","address",t,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(t,n){try{n=getAddress$1(n)}catch(ie){this._throwError(ie.message,n)}return t.writeValue(n)}decode(t){return getAddress$1(hexZeroPad(t.readValue().toHexString(),20))}}class AnonymousCoder extends Coder{constructor(t){super(t.name,t.type,void 0,t.dynamic),this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,n){return this.coder.encode(t,n)}decode(t){return this.coder.decode(t)}}const logger$p=new Logger(version$q);function pack$1(c,t,n){let ie=null;if(Array.isArray(n))ie=n;else if(n&&typeof n=="object"){let ye={};ie=t.map(me=>{const xe=me.localName;return xe||logger$p.throwError("cannot encode object for signature with missing names",Logger.errors.INVALID_ARGUMENT,{argument:"values",coder:me,value:n}),ye[xe]&&logger$p.throwError("cannot encode object for signature with duplicate names",Logger.errors.INVALID_ARGUMENT,{argument:"values",coder:me,value:n}),ye[xe]=!0,n[xe]})}else logger$p.throwArgumentError("invalid tuple value","tuple",n);t.length!==ie.length&&logger$p.throwArgumentError("types/value length mismatch","tuple",n);let fe=new Writer(c.wordSize),ae=new Writer(c.wordSize),le=[];t.forEach((ye,me)=>{let xe=ie[me];if(ye.dynamic){let Ee=ae.length;ye.encode(ae,xe);let Se=fe.writeUpdatableValue();le.push(Me=>{Se(Me+Ee)})}else ye.encode(fe,xe)}),le.forEach(ye=>{ye(fe.length)});let he=c.appendWriter(fe);return he+=c.appendWriter(ae),he}function unpack(c,t){let n=[],ie=c.subReader(0);t.forEach(ae=>{let le=null;if(ae.dynamic){let he=c.readValue(),ye=ie.subReader(he.toNumber());try{le=ae.decode(ye)}catch(me){if(me.code===Logger.errors.BUFFER_OVERRUN)throw me;le=me,le.baseType=ae.name,le.name=ae.localName,le.type=ae.type}}else try{le=ae.decode(c)}catch(he){if(he.code===Logger.errors.BUFFER_OVERRUN)throw he;le=he,le.baseType=ae.name,le.name=ae.localName,le.type=ae.type}le!=null&&n.push(le)});const fe=t.reduce((ae,le)=>{const he=le.localName;return he&&(ae[he]||(ae[he]=0),ae[he]++),ae},{});t.forEach((ae,le)=>{let he=ae.localName;if(!he||fe[he]!==1||(he==="length"&&(he="_length"),n[he]!=null))return;const ye=n[le];ye instanceof Error?Object.defineProperty(n,he,{enumerable:!0,get:()=>{throw ye}}):n[he]=ye});for(let ae=0;ae<n.length;ae++){const le=n[ae];le instanceof Error&&Object.defineProperty(n,ae,{enumerable:!0,get:()=>{throw le}})}return Object.freeze(n)}class ArrayCoder extends Coder{constructor(t,n,ie){const fe=t.type+"["+(n>=0?n:"")+"]",ae=n===-1||t.dynamic;super("array",fe,ie,ae),this.coder=t,this.length=n}defaultValue(){const t=this.coder.defaultValue(),n=[];for(let ie=0;ie<this.length;ie++)n.push(t);return n}encode(t,n){Array.isArray(n)||this._throwError("expected array value",n);let ie=this.length;ie===-1&&(ie=n.length,t.writeValue(n.length)),logger$p.checkArgumentCount(n.length,ie,"coder array"+(this.localName?" "+this.localName:""));let fe=[];for(let ae=0;ae<n.length;ae++)fe.push(this.coder);return pack$1(t,fe,n)}decode(t){let n=this.length;n===-1&&(n=t.readValue().toNumber(),n*32>t._data.length&&logger$p.throwError("insufficient data length",Logger.errors.BUFFER_OVERRUN,{length:t._data.length,count:n}));let ie=[];for(let fe=0;fe<n;fe++)ie.push(new AnonymousCoder(this.coder));return t.coerce(this.name,unpack(t,ie))}}class BooleanCoder extends Coder{constructor(t){super("bool","bool",t,!1)}defaultValue(){return!1}encode(t,n){return t.writeValue(n?1:0)}decode(t){return t.coerce(this.type,!t.readValue().isZero())}}class DynamicBytesCoder extends Coder{constructor(t,n){super(t,t,n,!0)}defaultValue(){return"0x"}encode(t,n){n=arrayify(n);let ie=t.writeValue(n.length);return ie+=t.writeBytes(n),ie}decode(t){return t.readBytes(t.readValue().toNumber(),!0)}}class BytesCoder extends DynamicBytesCoder{constructor(t){super("bytes",t)}decode(t){return t.coerce(this.name,hexlify(super.decode(t)))}}class FixedBytesCoder extends Coder{constructor(t,n){let ie="bytes"+String(t);super(ie,ie,n,!1),this.size=t}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(t,n){let ie=arrayify(n);return ie.length!==this.size&&this._throwError("incorrect data length",n),t.writeBytes(ie)}decode(t){return t.coerce(this.name,hexlify(t.readBytes(this.size)))}}class NullCoder extends Coder{constructor(t){super("null","",t,!1)}defaultValue(){return null}encode(t,n){return n!=null&&this._throwError("not null",n),t.writeBytes([])}decode(t){return t.readBytes(0),t.coerce(this.name,null)}}const AddressZero="0x0000000000000000000000000000000000000000",NegativeOne$1=BigNumber.from(-1),Zero$1=BigNumber.from(0),One$1=BigNumber.from(1),MaxUint256$1=BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),HashZero="0x0000000000000000000000000000000000000000000000000000000000000000";class NumberCoder extends Coder{constructor(t,n,ie){const fe=(n?"int":"uint")+t*8;super(fe,fe,ie,!1),this.size=t,this.signed=n}defaultValue(){return 0}encode(t,n){let ie=BigNumber.from(n),fe=MaxUint256$1.mask(t.wordSize*8);if(this.signed){let ae=fe.mask(this.size*8-1);(ie.gt(ae)||ie.lt(ae.add(One$1).mul(NegativeOne$1)))&&this._throwError("value out-of-bounds",n)}else(ie.lt(Zero$1)||ie.gt(fe.mask(this.size*8)))&&this._throwError("value out-of-bounds",n);return ie=ie.toTwos(this.size*8).mask(this.size*8),this.signed&&(ie=ie.fromTwos(this.size*8).toTwos(8*t.wordSize)),t.writeValue(ie)}decode(t){let n=t.readValue().mask(this.size*8);return this.signed&&(n=n.fromTwos(this.size*8)),t.coerce(this.name,n)}}const version$n="strings/5.8.0",logger$o=new Logger(version$n);var UnicodeNormalizationForm;(function(c){c.current="",c.NFC="NFC",c.NFD="NFD",c.NFKC="NFKC",c.NFKD="NFKD"})(UnicodeNormalizationForm||(UnicodeNormalizationForm={}));var Utf8ErrorReason;(function(c){c.UNEXPECTED_CONTINUE="unexpected continuation byte",c.BAD_PREFIX="bad codepoint prefix",c.OVERRUN="string overrun",c.MISSING_CONTINUE="missing continuation byte",c.OUT_OF_RANGE="out of UTF-8 range",c.UTF16_SURROGATE="UTF-16 surrogate",c.OVERLONG="overlong representation"})(Utf8ErrorReason||(Utf8ErrorReason={}));function errorFunc(c,t,n,ie,fe){return logger$o.throwArgumentError(`invalid codepoint at offset ${t}; ${c}`,"bytes",n)}function ignoreFunc(c,t,n,ie,fe){if(c===Utf8ErrorReason.BAD_PREFIX||c===Utf8ErrorReason.UNEXPECTED_CONTINUE){let ae=0;for(let le=t+1;le<n.length&&n[le]>>6===2;le++)ae++;return ae}return c===Utf8ErrorReason.OVERRUN?n.length-t-1:0}function replaceFunc(c,t,n,ie,fe){return c===Utf8ErrorReason.OVERLONG?(ie.push(fe),0):(ie.push(65533),ignoreFunc(c,t,n))}const Utf8ErrorFuncs=Object.freeze({error:errorFunc,ignore:ignoreFunc,replace:replaceFunc});function getUtf8CodePoints(c,t){t==null&&(t=Utf8ErrorFuncs.error),c=arrayify(c);const n=[];let ie=0;for(;ie<c.length;){const fe=c[ie++];if(!(fe>>7)){n.push(fe);continue}let ae=null,le=null;if((fe&224)===192)ae=1,le=127;else if((fe&240)===224)ae=2,le=2047;else if((fe&248)===240)ae=3,le=65535;else{(fe&192)===128?ie+=t(Utf8ErrorReason.UNEXPECTED_CONTINUE,ie-1,c,n):ie+=t(Utf8ErrorReason.BAD_PREFIX,ie-1,c,n);continue}if(ie-1+ae>=c.length){ie+=t(Utf8ErrorReason.OVERRUN,ie-1,c,n);continue}let he=fe&(1<<8-ae-1)-1;for(let ye=0;ye<ae;ye++){let me=c[ie];if((me&192)!=128){ie+=t(Utf8ErrorReason.MISSING_CONTINUE,ie,c,n),he=null;break}he=he<<6|me&63,ie++}if(he!==null){if(he>1114111){ie+=t(Utf8ErrorReason.OUT_OF_RANGE,ie-1-ae,c,n,he);continue}if(he>=55296&&he<=57343){ie+=t(Utf8ErrorReason.UTF16_SURROGATE,ie-1-ae,c,n,he);continue}if(he<=le){ie+=t(Utf8ErrorReason.OVERLONG,ie-1-ae,c,n,he);continue}n.push(he)}}return n}function toUtf8Bytes(c,t=UnicodeNormalizationForm.current){t!=UnicodeNormalizationForm.current&&(logger$o.checkNormalize(),c=c.normalize(t));let n=[];for(let ie=0;ie<c.length;ie++){const fe=c.charCodeAt(ie);if(fe<128)n.push(fe);else if(fe<2048)n.push(fe>>6|192),n.push(fe&63|128);else if((fe&64512)==55296){ie++;const ae=c.charCodeAt(ie);if(ie>=c.length||(ae&64512)!==56320)throw new Error("invalid utf-8 string");const le=65536+((fe&1023)<<10)+(ae&1023);n.push(le>>18|240),n.push(le>>12&63|128),n.push(le>>6&63|128),n.push(le&63|128)}else n.push(fe>>12|224),n.push(fe>>6&63|128),n.push(fe&63|128)}return arrayify(n)}function escapeChar(c){const t="0000"+c.toString(16);return"\\u"+t.substring(t.length-4)}function _toEscapedUtf8String(c,t){return'"'+getUtf8CodePoints(c,t).map(n=>{if(n<256){switch(n){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(n>=32&&n<127)return String.fromCharCode(n)}return n<=65535?escapeChar(n):(n-=65536,escapeChar((n>>10&1023)+55296)+escapeChar((n&1023)+56320))}).join("")+'"'}function _toUtf8String(c){return c.map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10&1023)+55296,(t&1023)+56320))).join("")}function toUtf8String(c,t){return _toUtf8String(getUtf8CodePoints(c,t))}function toUtf8CodePoints(c,t=UnicodeNormalizationForm.current){return getUtf8CodePoints(toUtf8Bytes(c,t))}function formatBytes32String(c){const t=toUtf8Bytes(c);if(t.length>31)throw new Error("bytes32 string must be less than 32 bytes");return hexlify(concat$1([t,HashZero]).slice(0,32))}function parseBytes32String(c){const t=arrayify(c);if(t.length!==32)throw new Error("invalid bytes32 - not 32 bytes long");if(t[31]!==0)throw new Error("invalid bytes32 string - no null terminator");let n=31;for(;t[n-1]===0;)n--;return toUtf8String(t.slice(0,n))}function bytes2(c){if(c.length%4!==0)throw new Error("bad data");let t=[];for(let n=0;n<c.length;n+=4)t.push(parseInt(c.substring(n,n+4),16));return t}function createTable(c,t){t||(t=function(fe){return[parseInt(fe,16)]});let n=0,ie={};return c.split(",").forEach(fe=>{let ae=fe.split(":");n+=parseInt(ae[0],16),ie[n]=t(ae[1])}),ie}function createRangeTable(c){let t=0;return c.split(",").map(n=>{let ie=n.split("-");ie.length===1?ie[1]="0":ie[1]===""&&(ie[1]="1");let fe=t+parseInt(ie[0],16);return t=parseInt(ie[1],16),{l:fe,h:t}})}function matchMap(c,t){let n=0;for(let ie=0;ie<t.length;ie++){let fe=t[ie];if(n+=fe.l,c>=n&&c<=n+fe.h&&(c-n)%(fe.d||1)===0){if(fe.e&&fe.e.indexOf(c-n)!==-1)continue;return fe}}return null}const Table_A_1_ranges=createRangeTable("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),Table_B_1_flags="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(c=>parseInt(c,16)),Table_B_2_ranges=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],Table_B_2_lut_abs=createTable("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),Table_B_2_lut_rel=createTable("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),Table_B_2_complex=createTable("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",bytes2),Table_C_ranges=createRangeTable("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001");function flatten(c){return c.reduce((t,n)=>(n.forEach(ie=>{t.push(ie)}),t),[])}function _nameprepTableA1(c){return!!matchMap(c,Table_A_1_ranges)}function _nameprepTableB2(c){let t=matchMap(c,Table_B_2_ranges);if(t)return[c+t.s];let n=Table_B_2_lut_abs[c];if(n)return n;let ie=Table_B_2_lut_rel[c];if(ie)return[c+ie[0]];let fe=Table_B_2_complex[c];return fe||null}function _nameprepTableC(c){return!!matchMap(c,Table_C_ranges)}function nameprep(c){if(c.match(/^[a-z0-9-]*$/i)&&c.length<=59)return c.toLowerCase();let t=toUtf8CodePoints(c);t=flatten(t.map(ie=>{if(Table_B_1_flags.indexOf(ie)>=0)return[];if(ie>=65024&&ie<=65039)return[];let fe=_nameprepTableB2(ie);return fe||[ie]})),t=toUtf8CodePoints(_toUtf8String(t),UnicodeNormalizationForm.NFKC),t.forEach(ie=>{if(_nameprepTableC(ie))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")}),t.forEach(ie=>{if(_nameprepTableA1(ie))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")});let n=_toUtf8String(t);if(n.substring(0,1)==="-"||n.substring(2,4)==="--"||n.substring(n.length-1)==="-")throw new Error("invalid hyphen");return n}const lib_esm$e=Object.freeze(Object.defineProperty({__proto__:null,get UnicodeNormalizationForm(){return UnicodeNormalizationForm},Utf8ErrorFuncs,get Utf8ErrorReason(){return Utf8ErrorReason},_toEscapedUtf8String,formatBytes32String,nameprep,parseBytes32String,toUtf8Bytes,toUtf8CodePoints,toUtf8String},Symbol.toStringTag,{value:"Module"}));class StringCoder extends DynamicBytesCoder{constructor(t){super("string",t)}defaultValue(){return""}encode(t,n){return super.encode(t,toUtf8Bytes(n))}decode(t){return toUtf8String(super.decode(t))}}class TupleCoder extends Coder{constructor(t,n){let ie=!1;const fe=[];t.forEach(le=>{le.dynamic&&(ie=!0),fe.push(le.type)});const ae="tuple("+fe.join(",")+")";super("tuple",ae,n,ie),this.coders=t}defaultValue(){const t=[];this.coders.forEach(ie=>{t.push(ie.defaultValue())});const n=this.coders.reduce((ie,fe)=>{const ae=fe.localName;return ae&&(ie[ae]||(ie[ae]=0),ie[ae]++),ie},{});return this.coders.forEach((ie,fe)=>{let ae=ie.localName;!ae||n[ae]!==1||(ae==="length"&&(ae="_length"),t[ae]==null&&(t[ae]=t[fe]))}),Object.freeze(t)}encode(t,n){return pack$1(t,this.coders,n)}decode(t){return t.coerce(this.name,unpack(t,this.coders))}}const logger$n=new Logger(version$q),paramTypeBytes=new RegExp(/^bytes([0-9]*)$/),paramTypeNumber=new RegExp(/^(u?int)([0-9]*)$/);class AbiCoder{constructor(t){defineReadOnly(this,"coerceFunc",t||null)}_getCoder(t){switch(t.baseType){case"address":return new AddressCoder(t.name);case"bool":return new BooleanCoder(t.name);case"string":return new StringCoder(t.name);case"bytes":return new BytesCoder(t.name);case"array":return new ArrayCoder(this._getCoder(t.arrayChildren),t.arrayLength,t.name);case"tuple":return new TupleCoder((t.components||[]).map(ie=>this._getCoder(ie)),t.name);case"":return new NullCoder(t.name)}let n=t.type.match(paramTypeNumber);if(n){let ie=parseInt(n[2]||"256");return(ie===0||ie>256||ie%8!==0)&&logger$n.throwArgumentError("invalid "+n[1]+" bit length","param",t),new NumberCoder(ie/8,n[1]==="int",t.name)}if(n=t.type.match(paramTypeBytes),n){let ie=parseInt(n[1]);return(ie===0||ie>32)&&logger$n.throwArgumentError("invalid bytes length","param",t),new FixedBytesCoder(ie,t.name)}return logger$n.throwArgumentError("invalid type","type",t.type)}_getWordSize(){return 32}_getReader(t,n){return new Reader(t,this._getWordSize(),this.coerceFunc,n)}_getWriter(){return new Writer(this._getWordSize())}getDefaultValue(t){const n=t.map(fe=>this._getCoder(ParamType.from(fe)));return new TupleCoder(n,"_").defaultValue()}encode(t,n){t.length!==n.length&&logger$n.throwError("types/values length mismatch",Logger.errors.INVALID_ARGUMENT,{count:{types:t.length,values:n.length},value:{types:t,values:n}});const ie=t.map(le=>this._getCoder(ParamType.from(le))),fe=new TupleCoder(ie,"_"),ae=this._getWriter();return fe.encode(ae,n),ae.data}decode(t,n,ie){const fe=t.map(le=>this._getCoder(ParamType.from(le)));return new TupleCoder(fe,"_").decode(this._getReader(arrayify(n),ie))}}const defaultAbiCoder=new AbiCoder;function id(c){return keccak256$1(toUtf8Bytes(c))}const version$m="hash/5.8.0";function decode$6(c){c=atob(c);const t=[];for(let n=0;n<c.length;n++)t.push(c.charCodeAt(n));return arrayify(t)}function encode$5(c){c=arrayify(c);let t="";for(let n=0;n<c.length;n++)t+=String.fromCharCode(c[n]);return btoa(t)}const lib_esm$d=Object.freeze(Object.defineProperty({__proto__:null,decode:decode$6,encode:encode$5},Symbol.toStringTag,{value:"Module"}));function flat(c,t){t==null&&(t=1);const n=[],ie=n.forEach,fe=function(ae,le){ie.call(ae,function(he){le>0&&Array.isArray(he)?fe(he,le-1):n.push(he)})};return fe(c,t),n}function fromEntries(c){const t={};for(let n=0;n<c.length;n++){const ie=c[n];t[ie[0]]=ie[1]}return t}function decode_arithmetic(c){let t=0;function n(){return c[t++]<<8|c[t++]}let ie=n(),fe=1,ae=[0,1];for(let He=1;He<ie;He++)ae.push(fe+=n());let le=n(),he=t;t+=le;let ye=0,me=0;function xe(){return ye==0&&(me=me<<8|c[t++],ye=8),me>>--ye&1}const Ee=31,Se=Math.pow(2,Ee),Me=Se>>>1,Be=Me>>1,$e=Se-1;let Ce=0;for(let He=0;He<Ee;He++)Ce=Ce<<1|xe();let ke=[],Pe=0,Ue=Se;for(;;){let He=Math.floor(((Ce-Pe+1)*fe-1)/Ue),Ve=0,Ye=ie;for(;Ye-Ve>1;){let Pt=Ve+Ye>>>1;He<ae[Pt]?Ye=Pt:Ve=Pt}if(Ve==0)break;ke.push(Ve);let Qe=Pe+Math.floor(Ue*ae[Ve]/fe),Ke=Pe+Math.floor(Ue*ae[Ve+1]/fe)-1;for(;!((Qe^Ke)&Me);)Ce=Ce<<1&$e|xe(),Qe=Qe<<1&$e,Ke=Ke<<1&$e|1;for(;Qe&~Ke&Be;)Ce=Ce&Me|Ce<<1&$e>>>1|xe(),Qe=Qe<<1^Me,Ke=(Ke^Me)<<1|Me|1;Pe=Qe,Ue=1+Ke-Qe}let qe=ie-4;return ke.map(He=>{switch(He-qe){case 3:return qe+65792+(c[he++]<<16|c[he++]<<8|c[he++]);case 2:return qe+256+(c[he++]<<8|c[he++]);case 1:return qe+c[he++];default:return He-1}})}function read_payload(c){let t=0;return()=>c[t++]}function read_compressed_payload(c){return read_payload(decode_arithmetic(c))}function signed(c){return c&1?~c>>1:c>>1}function read_counts(c,t){let n=Array(c);for(let ie=0;ie<c;ie++)n[ie]=1+t();return n}function read_ascending(c,t){let n=Array(c);for(let ie=0,fe=-1;ie<c;ie++)n[ie]=fe+=1+t();return n}function read_deltas(c,t){let n=Array(c);for(let ie=0,fe=0;ie<c;ie++)n[ie]=fe+=signed(t());return n}function read_member_array(c,t){let n=read_ascending(c(),c),ie=c(),fe=read_ascending(ie,c),ae=read_counts(ie,c);for(let le=0;le<ie;le++)for(let he=0;he<ae[le];he++)n.push(fe[le]+he);return t?n.map(le=>t[le]):n}function read_mapped_map(c){let t=[];for(;;){let n=c();if(n==0)break;t.push(read_linear_table(n,c))}for(;;){let n=c()-1;if(n<0)break;t.push(read_replacement_table(n,c))}return fromEntries(flat(t))}function read_zero_terminated_array(c){let t=[];for(;;){let n=c();if(n==0)break;t.push(n)}return t}function read_transposed(c,t,n){let ie=Array(c).fill(void 0).map(()=>[]);for(let fe=0;fe<t;fe++)read_deltas(c,n).forEach((ae,le)=>ie[le].push(ae));return ie}function read_linear_table(c,t){let n=1+t(),ie=t(),fe=read_zero_terminated_array(t),ae=read_transposed(fe.length,1+c,t);return flat(ae.map((le,he)=>{const ye=le[0],me=le.slice(1);return Array(fe[he]).fill(void 0).map((xe,Ee)=>{let Se=Ee*ie;return[ye+Ee*n,me.map(Me=>Me+Se)]})}))}function read_replacement_table(c,t){let n=1+t();return read_transposed(n,1+c,t).map(fe=>[fe[0],fe.slice(1)])}function read_emoji_trie(c){let t=read_member_array(c).sort((ie,fe)=>ie-fe);return n();function n(){let ie=[];for(;;){let me=read_member_array(c,t);if(me.length==0)break;ie.push({set:new Set(me),node:n()})}ie.sort((me,xe)=>xe.set.size-me.set.size);let fe=c(),ae=fe%3;fe=fe/3|0;let le=!!(fe&1);fe>>=1;let he=fe==1,ye=fe==2;return{branches:ie,valid:ae,fe0f:le,save:he,check:ye}}}function getData(){return read_compressed_payload(decode$6("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA=="))}const r$2=getData(),VALID=new Set(read_member_array(r$2)),IGNORED=new Set(read_member_array(r$2)),MAPPED=read_mapped_map(r$2),EMOJI_ROOT=read_emoji_trie(r$2),HYPHEN=45,UNDERSCORE=95;function explode_cp(c){return toUtf8CodePoints(c)}function filter_fe0f(c){return c.filter(t=>t!=65039)}function ens_normalize_post_check(c){for(let t of c.split(".")){let n=explode_cp(t);try{for(let ie=n.lastIndexOf(UNDERSCORE)-1;ie>=0;ie--)if(n[ie]!==UNDERSCORE)throw new Error("underscore only allowed at start");if(n.length>=4&&n.every(ie=>ie<128)&&n[2]===HYPHEN&&n[3]===HYPHEN)throw new Error("invalid label extension")}catch(ie){throw new Error(`Invalid label "${t}": ${ie.message}`)}}return c}function ens_normalize(c){return ens_normalize_post_check(normalize(c,filter_fe0f))}function normalize(c,t){let n=explode_cp(c).reverse(),ie=[];for(;n.length;){let fe=consume_emoji_reversed(n);if(fe){ie.push(...t(fe));continue}let ae=n.pop();if(VALID.has(ae)){ie.push(ae);continue}if(IGNORED.has(ae))continue;let le=MAPPED[ae];if(le){ie.push(...le);continue}throw new Error(`Disallowed codepoint: 0x${ae.toString(16).toUpperCase()}`)}return ens_normalize_post_check(nfc(String.fromCodePoint(...ie)))}function nfc(c){return c.normalize("NFC")}function consume_emoji_reversed(c,t){var n;let ie=EMOJI_ROOT,fe,ae,le=[],he=c.length;for(;he;){let ye=c[--he];if(ie=(n=ie.branches.find(me=>me.set.has(ye)))===null||n===void 0?void 0:n.node,!ie)break;if(ie.save)ae=ye;else if(ie.check&&ye===ae)break;le.push(ye),ie.fe0f&&(le.push(65039),he>0&&c[he-1]==65039&&he--),ie.valid&&(fe=le.slice(),ie.valid==2&&fe.splice(1,1),c.length=he)}return fe}const logger$m=new Logger(version$m),Zeros$1=new Uint8Array(32);Zeros$1.fill(0);function checkComponent(c){if(c.length===0)throw new Error("invalid ENS name; empty component");return c}function ensNameSplit(c){const t=toUtf8Bytes(ens_normalize(c)),n=[];if(c.length===0)return n;let ie=0;for(let fe=0;fe<t.length;fe++)t[fe]===46&&(n.push(checkComponent(t.slice(ie,fe))),ie=fe+1);if(ie>=t.length)throw new Error("invalid ENS name; empty component");return n.push(checkComponent(t.slice(ie))),n}function ensNormalize(c){return ensNameSplit(c).map(t=>toUtf8String(t)).join(".")}function isValidName(c){try{return ensNameSplit(c).length!==0}catch{}return!1}function namehash$1(c){typeof c!="string"&&logger$m.throwArgumentError("invalid ENS name; not a string","name",c);let t=Zeros$1;const n=ensNameSplit(c);for(;n.length;)t=keccak256$1(concat$1([t,keccak256$1(n.pop())]));return hexlify(t)}function dnsEncode(c){return hexlify(concat$1(ensNameSplit(c).map(t=>{if(t.length>63)throw new Error("invalid DNS encoded entry; length exceeds 63 bytes");const n=new Uint8Array(t.length+1);return n.set(t,1),n[0]=n.length-1,n})))+"00"}const messagePrefix=`Ethereum Signed Message:
7
7
  `;function hashMessage(c){return typeof c=="string"&&(c=toUtf8Bytes(c)),keccak256$1(concat$1([toUtf8Bytes(messagePrefix),toUtf8Bytes(String(c.length)),c]))}var __awaiter$k=function(c,t,n,ie){function fe(ae){return ae instanceof n?ae:new n(function(le){le(ae)})}return new(n||(n=Promise))(function(ae,le){function he(xe){try{me(ie.next(xe))}catch(Ee){le(Ee)}}function ye(xe){try{me(ie.throw(xe))}catch(Ee){le(Ee)}}function me(xe){xe.done?ae(xe.value):fe(xe.value).then(he,ye)}me((ie=ie.apply(c,t||[])).next())})};const logger$l=new Logger(version$m),padding=new Uint8Array(32);padding.fill(0);const NegativeOne=BigNumber.from(-1),Zero=BigNumber.from(0),One=BigNumber.from(1),MaxUint256=BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function hexPadRight(c){const t=arrayify(c),n=t.length%32;return n?hexConcat([t,padding.slice(n)]):hexlify(t)}const hexTrue=hexZeroPad(One.toHexString(),32),hexFalse=hexZeroPad(Zero.toHexString(),32),domainFieldTypes={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},domainFieldNames=["name","version","chainId","verifyingContract","salt"];function checkString(c){return function(t){return typeof t!="string"&&logger$l.throwArgumentError(`invalid domain value for ${JSON.stringify(c)}`,`domain.${c}`,t),t}}const domainChecks={name:checkString("name"),version:checkString("version"),chainId:function(c){try{return BigNumber.from(c).toString()}catch{}return logger$l.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",c)},verifyingContract:function(c){try{return getAddress$1(c).toLowerCase()}catch{}return logger$l.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",c)},salt:function(c){try{const t=arrayify(c);if(t.length!==32)throw new Error("bad length");return hexlify(t)}catch{}return logger$l.throwArgumentError('invalid domain value "salt"',"domain.salt",c)}};function getBaseEncoder(c){{const t=c.match(/^(u?)int(\d*)$/);if(t){const n=t[1]==="",ie=parseInt(t[2]||"256");(ie%8!==0||ie>256||t[2]&&t[2]!==String(ie))&&logger$l.throwArgumentError("invalid numeric width","type",c);const fe=MaxUint256.mask(n?ie-1:ie),ae=n?fe.add(One).mul(NegativeOne):Zero;return function(le){const he=BigNumber.from(le);return(he.lt(ae)||he.gt(fe))&&logger$l.throwArgumentError(`value out-of-bounds for ${c}`,"value",le),hexZeroPad(he.toTwos(256).toHexString(),32)}}}{const t=c.match(/^bytes(\d+)$/);if(t){const n=parseInt(t[1]);return(n===0||n>32||t[1]!==String(n))&&logger$l.throwArgumentError("invalid bytes width","type",c),function(ie){return arrayify(ie).length!==n&&logger$l.throwArgumentError(`invalid length for ${c}`,"value",ie),hexPadRight(ie)}}}switch(c){case"address":return function(t){return hexZeroPad(getAddress$1(t),32)};case"bool":return function(t){return t?hexTrue:hexFalse};case"bytes":return function(t){return keccak256$1(t)};case"string":return function(t){return id(t)}}return null}function encodeType(c,t){return`${c}(${t.map(({name:n,type:ie})=>ie+" "+n).join(",")})`}class TypedDataEncoder{constructor(t){defineReadOnly(this,"types",Object.freeze(deepCopy(t))),defineReadOnly(this,"_encoderCache",{}),defineReadOnly(this,"_types",{});const n={},ie={},fe={};Object.keys(t).forEach(he=>{n[he]={},ie[he]=[],fe[he]={}});for(const he in t){const ye={};t[he].forEach(me=>{ye[me.name]&&logger$l.throwArgumentError(`duplicate variable name ${JSON.stringify(me.name)} in ${JSON.stringify(he)}`,"types",t),ye[me.name]=!0;const xe=me.type.match(/^([^\x5b]*)(\x5b|$)/)[1];xe===he&&logger$l.throwArgumentError(`circular type reference to ${JSON.stringify(xe)}`,"types",t),!getBaseEncoder(xe)&&(ie[xe]||logger$l.throwArgumentError(`unknown type ${JSON.stringify(xe)}`,"types",t),ie[xe].push(he),n[he][xe]=!0)})}const ae=Object.keys(ie).filter(he=>ie[he].length===0);ae.length===0?logger$l.throwArgumentError("missing primary type","types",t):ae.length>1&&logger$l.throwArgumentError(`ambiguous primary types or unused types: ${ae.map(he=>JSON.stringify(he)).join(", ")}`,"types",t),defineReadOnly(this,"primaryType",ae[0]);function le(he,ye){ye[he]&&logger$l.throwArgumentError(`circular type reference to ${JSON.stringify(he)}`,"types",t),ye[he]=!0,Object.keys(n[he]).forEach(me=>{ie[me]&&(le(me,ye),Object.keys(ye).forEach(xe=>{fe[xe][me]=!0}))}),delete ye[he]}le(this.primaryType,{});for(const he in fe){const ye=Object.keys(fe[he]);ye.sort(),this._types[he]=encodeType(he,t[he])+ye.map(me=>encodeType(me,t[me])).join("")}}getEncoder(t){let n=this._encoderCache[t];return n||(n=this._encoderCache[t]=this._getEncoder(t)),n}_getEncoder(t){{const fe=getBaseEncoder(t);if(fe)return fe}const n=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(n){const fe=n[1],ae=this.getEncoder(fe),le=parseInt(n[3]);return he=>{le>=0&&he.length!==le&&logger$l.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",he);let ye=he.map(ae);return this._types[fe]&&(ye=ye.map(keccak256$1)),keccak256$1(hexConcat(ye))}}const ie=this.types[t];if(ie){const fe=id(this._types[t]);return ae=>{const le=ie.map(({name:he,type:ye})=>{const me=this.getEncoder(ye)(ae[he]);return this._types[ye]?keccak256$1(me):me});return le.unshift(fe),hexConcat(le)}}return logger$l.throwArgumentError(`unknown type: ${t}`,"type",t)}encodeType(t){const n=this._types[t];return n||logger$l.throwArgumentError(`unknown type: ${JSON.stringify(t)}`,"name",t),n}encodeData(t,n){return this.getEncoder(t)(n)}hashStruct(t,n){return keccak256$1(this.encodeData(t,n))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,n,ie){if(getBaseEncoder(t))return ie(t,n);const fe=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(fe){const le=fe[1],he=parseInt(fe[3]);return he>=0&&n.length!==he&&logger$l.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",n),n.map(ye=>this._visit(le,ye,ie))}const ae=this.types[t];return ae?ae.reduce((le,{name:he,type:ye})=>(le[he]=this._visit(ye,n[he],ie),le),{}):logger$l.throwArgumentError(`unknown type: ${t}`,"type",t)}visit(t,n){return this._visit(this.primaryType,t,n)}static from(t){return new TypedDataEncoder(t)}static getPrimaryType(t){return TypedDataEncoder.from(t).primaryType}static hashStruct(t,n,ie){return TypedDataEncoder.from(n).hashStruct(t,ie)}static hashDomain(t){const n=[];for(const ie in t){const fe=domainFieldTypes[ie];fe||logger$l.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(ie)}`,"domain",t),n.push({name:ie,type:fe})}return n.sort((ie,fe)=>domainFieldNames.indexOf(ie.name)-domainFieldNames.indexOf(fe.name)),TypedDataEncoder.hashStruct("EIP712Domain",{EIP712Domain:n},t)}static encode(t,n,ie){return hexConcat(["0x1901",TypedDataEncoder.hashDomain(t),TypedDataEncoder.from(n).hash(ie)])}static hash(t,n,ie){return keccak256$1(TypedDataEncoder.encode(t,n,ie))}static resolveNames(t,n,ie,fe){return __awaiter$k(this,void 0,void 0,function*(){t=shallowCopy(t);const ae={};t.verifyingContract&&!isHexString(t.verifyingContract,20)&&(ae[t.verifyingContract]="0x");const le=TypedDataEncoder.from(n);le.visit(ie,(he,ye)=>(he==="address"&&!isHexString(ye,20)&&(ae[ye]="0x"),ye));for(const he in ae)ae[he]=yield fe(he);return t.verifyingContract&&ae[t.verifyingContract]&&(t.verifyingContract=ae[t.verifyingContract]),ie=le.visit(ie,(he,ye)=>he==="address"&&ae[ye]?ae[ye]:ye),{domain:t,value:ie}})}static getPayload(t,n,ie){TypedDataEncoder.hashDomain(t);const fe={},ae=[];domainFieldNames.forEach(ye=>{const me=t[ye];me!=null&&(fe[ye]=domainChecks[ye](me),ae.push({name:ye,type:domainFieldTypes[ye]}))});const le=TypedDataEncoder.from(n),he=shallowCopy(n);return he.EIP712Domain?logger$l.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",n):he.EIP712Domain=ae,le.encode(ie),{types:he,domain:fe,primaryType:le.primaryType,message:le.visit(ie,(ye,me)=>{if(ye.match(/^bytes(\d*)/))return hexlify(arrayify(me));if(ye.match(/^u?int/))return BigNumber.from(me).toString();switch(ye){case"address":return me.toLowerCase();case"bool":return!!me;case"string":return typeof me!="string"&&logger$l.throwArgumentError("invalid string","value",me),me}return logger$l.throwArgumentError("unsupported type","type",ye)})}}}const lib_esm$c=Object.freeze(Object.defineProperty({__proto__:null,_TypedDataEncoder:TypedDataEncoder,dnsEncode,ensNormalize,hashMessage,id,isValidName,messagePrefix,namehash:namehash$1},Symbol.toStringTag,{value:"Module"})),logger$k=new Logger(version$q);class LogDescription extends Description{}class TransactionDescription extends Description{}class ErrorDescription extends Description{}class Indexed extends Description{static isIndexed(t){return!!(t&&t._isIndexed)}}const BuiltinErrors={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:!0},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"]}};function wrapAccessError(c,t){const n=new Error(`deferred error during ABI decoding triggered accessing ${c}`);return n.error=t,n}class Interface{constructor(t){let n=[];typeof t=="string"?n=JSON.parse(t):n=t,defineReadOnly(this,"fragments",n.map(ie=>Fragment.from(ie)).filter(ie=>ie!=null)),defineReadOnly(this,"_abiCoder",getStatic(new.target,"getAbiCoder")()),defineReadOnly(this,"functions",{}),defineReadOnly(this,"errors",{}),defineReadOnly(this,"events",{}),defineReadOnly(this,"structs",{}),this.fragments.forEach(ie=>{let fe=null;switch(ie.type){case"constructor":if(this.deploy){logger$k.warn("duplicate definition - constructor");return}defineReadOnly(this,"deploy",ie);return;case"function":fe=this.functions;break;case"event":fe=this.events;break;case"error":fe=this.errors;break;default:return}let ae=ie.format();if(fe[ae]){logger$k.warn("duplicate definition - "+ae);return}fe[ae]=ie}),this.deploy||defineReadOnly(this,"deploy",ConstructorFragment.from({payable:!1,type:"constructor"})),defineReadOnly(this,"_isInterface",!0)}format(t){t||(t=FormatTypes.full),t===FormatTypes.sighash&&logger$k.throwArgumentError("interface does not support formatting sighash","format",t);const n=this.fragments.map(ie=>ie.format(t));return t===FormatTypes.json?JSON.stringify(n.map(ie=>JSON.parse(ie))):n}static getAbiCoder(){return defaultAbiCoder}static getAddress(t){return getAddress$1(t)}static getSighash(t){return hexDataSlice(id(t.format()),0,4)}static getEventTopic(t){return id(t.format())}getFunction(t){if(isHexString(t)){for(const ie in this.functions)if(t===this.getSighash(ie))return this.functions[ie];logger$k.throwArgumentError("no matching function","sighash",t)}if(t.indexOf("(")===-1){const ie=t.trim(),fe=Object.keys(this.functions).filter(ae=>ae.split("(")[0]===ie);return fe.length===0?logger$k.throwArgumentError("no matching function","name",ie):fe.length>1&&logger$k.throwArgumentError("multiple matching functions","name",ie),this.functions[fe[0]]}const n=this.functions[FunctionFragment.fromString(t).format()];return n||logger$k.throwArgumentError("no matching function","signature",t),n}getEvent(t){if(isHexString(t)){const ie=t.toLowerCase();for(const fe in this.events)if(ie===this.getEventTopic(fe))return this.events[fe];logger$k.throwArgumentError("no matching event","topichash",ie)}if(t.indexOf("(")===-1){const ie=t.trim(),fe=Object.keys(this.events).filter(ae=>ae.split("(")[0]===ie);return fe.length===0?logger$k.throwArgumentError("no matching event","name",ie):fe.length>1&&logger$k.throwArgumentError("multiple matching events","name",ie),this.events[fe[0]]}const n=this.events[EventFragment.fromString(t).format()];return n||logger$k.throwArgumentError("no matching event","signature",t),n}getError(t){if(isHexString(t)){const ie=getStatic(this.constructor,"getSighash");for(const fe in this.errors){const ae=this.errors[fe];if(t===ie(ae))return this.errors[fe]}logger$k.throwArgumentError("no matching error","sighash",t)}if(t.indexOf("(")===-1){const ie=t.trim(),fe=Object.keys(this.errors).filter(ae=>ae.split("(")[0]===ie);return fe.length===0?logger$k.throwArgumentError("no matching error","name",ie):fe.length>1&&logger$k.throwArgumentError("multiple matching errors","name",ie),this.errors[fe[0]]}const n=this.errors[FunctionFragment.fromString(t).format()];return n||logger$k.throwArgumentError("no matching error","signature",t),n}getSighash(t){if(typeof t=="string")try{t=this.getFunction(t)}catch(n){try{t=this.getError(t)}catch{throw n}}return getStatic(this.constructor,"getSighash")(t)}getEventTopic(t){return typeof t=="string"&&(t=this.getEvent(t)),getStatic(this.constructor,"getEventTopic")(t)}_decodeParams(t,n){return this._abiCoder.decode(t,n)}_encodeParams(t,n){return this._abiCoder.encode(t,n)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}decodeErrorResult(t,n){typeof t=="string"&&(t=this.getError(t));const ie=arrayify(n);return hexlify(ie.slice(0,4))!==this.getSighash(t)&&logger$k.throwArgumentError(`data signature does not match error ${t.name}.`,"data",hexlify(ie)),this._decodeParams(t.inputs,ie.slice(4))}encodeErrorResult(t,n){return typeof t=="string"&&(t=this.getError(t)),hexlify(concat$1([this.getSighash(t),this._encodeParams(t.inputs,n||[])]))}decodeFunctionData(t,n){typeof t=="string"&&(t=this.getFunction(t));const ie=arrayify(n);return hexlify(ie.slice(0,4))!==this.getSighash(t)&&logger$k.throwArgumentError(`data signature does not match function ${t.name}.`,"data",hexlify(ie)),this._decodeParams(t.inputs,ie.slice(4))}encodeFunctionData(t,n){return typeof t=="string"&&(t=this.getFunction(t)),hexlify(concat$1([this.getSighash(t),this._encodeParams(t.inputs,n||[])]))}decodeFunctionResult(t,n){typeof t=="string"&&(t=this.getFunction(t));let ie=arrayify(n),fe=null,ae="",le=null,he=null,ye=null;switch(ie.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(t.outputs,ie)}catch{}break;case 4:{const me=hexlify(ie.slice(0,4)),xe=BuiltinErrors[me];if(xe)le=this._abiCoder.decode(xe.inputs,ie.slice(4)),he=xe.name,ye=xe.signature,xe.reason&&(fe=le[0]),he==="Error"?ae=`; VM Exception while processing transaction: reverted with reason string ${JSON.stringify(le[0])}`:he==="Panic"&&(ae=`; VM Exception while processing transaction: reverted with panic code ${le[0]}`);else try{const Ee=this.getError(me);le=this._abiCoder.decode(Ee.inputs,ie.slice(4)),he=Ee.name,ye=Ee.format()}catch{}break}}return logger$k.throwError("call revert exception"+ae,Logger.errors.CALL_EXCEPTION,{method:t.format(),data:hexlify(n),errorArgs:le,errorName:he,errorSignature:ye,reason:fe})}encodeFunctionResult(t,n){return typeof t=="string"&&(t=this.getFunction(t)),hexlify(this._abiCoder.encode(t.outputs,n||[]))}encodeFilterTopics(t,n){typeof t=="string"&&(t=this.getEvent(t)),n.length>t.inputs.length&&logger$k.throwError("too many arguments for "+t.format(),Logger.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:n});let ie=[];t.anonymous||ie.push(this.getEventTopic(t));const fe=(ae,le)=>ae.type==="string"?id(le):ae.type==="bytes"?keccak256$1(hexlify(le)):(ae.type==="bool"&&typeof le=="boolean"&&(le=le?"0x01":"0x00"),ae.type.match(/^u?int/)&&(le=BigNumber.from(le).toHexString()),ae.type==="address"&&this._abiCoder.encode(["address"],[le]),hexZeroPad(hexlify(le),32));for(n.forEach((ae,le)=>{let he=t.inputs[le];if(!he.indexed){ae!=null&&logger$k.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+he.name,ae);return}ae==null?ie.push(null):he.baseType==="array"||he.baseType==="tuple"?logger$k.throwArgumentError("filtering with tuples or arrays not supported","contract."+he.name,ae):Array.isArray(ae)?ie.push(ae.map(ye=>fe(he,ye))):ie.push(fe(he,ae))});ie.length&&ie[ie.length-1]===null;)ie.pop();return ie}encodeEventLog(t,n){typeof t=="string"&&(t=this.getEvent(t));const ie=[],fe=[],ae=[];return t.anonymous||ie.push(this.getEventTopic(t)),n.length!==t.inputs.length&&logger$k.throwArgumentError("event arguments/values mismatch","values",n),t.inputs.forEach((le,he)=>{const ye=n[he];if(le.indexed)if(le.type==="string")ie.push(id(ye));else if(le.type==="bytes")ie.push(keccak256$1(ye));else{if(le.baseType==="tuple"||le.baseType==="array")throw new Error("not implemented");ie.push(this._abiCoder.encode([le.type],[ye]))}else fe.push(le),ae.push(ye)}),{data:this._abiCoder.encode(fe,ae),topics:ie}}decodeEventLog(t,n,ie){if(typeof t=="string"&&(t=this.getEvent(t)),ie!=null&&!t.anonymous){let Se=this.getEventTopic(t);(!isHexString(ie[0],32)||ie[0].toLowerCase()!==Se)&&logger$k.throwError("fragment/topic mismatch",Logger.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:Se,value:ie[0]}),ie=ie.slice(1)}let fe=[],ae=[],le=[];t.inputs.forEach((Se,Me)=>{Se.indexed?Se.type==="string"||Se.type==="bytes"||Se.baseType==="tuple"||Se.baseType==="array"?(fe.push(ParamType.fromObject({type:"bytes32",name:Se.name})),le.push(!0)):(fe.push(Se),le.push(!1)):(ae.push(Se),le.push(!1))});let he=ie!=null?this._abiCoder.decode(fe,concat$1(ie)):null,ye=this._abiCoder.decode(ae,n,!0),me=[],xe=0,Ee=0;t.inputs.forEach((Se,Me)=>{if(Se.indexed)if(he==null)me[Me]=new Indexed({_isIndexed:!0,hash:null});else if(le[Me])me[Me]=new Indexed({_isIndexed:!0,hash:he[Ee++]});else try{me[Me]=he[Ee++]}catch(Be){me[Me]=Be}else try{me[Me]=ye[xe++]}catch(Be){me[Me]=Be}if(Se.name&&me[Se.name]==null){const Be=me[Me];Be instanceof Error?Object.defineProperty(me,Se.name,{enumerable:!0,get:()=>{throw wrapAccessError(`property ${JSON.stringify(Se.name)}`,Be)}}):me[Se.name]=Be}});for(let Se=0;Se<me.length;Se++){const Me=me[Se];Me instanceof Error&&Object.defineProperty(me,Se,{enumerable:!0,get:()=>{throw wrapAccessError(`index ${Se}`,Me)}})}return Object.freeze(me)}parseTransaction(t){let n=this.getFunction(t.data.substring(0,10).toLowerCase());return n?new TransactionDescription({args:this._abiCoder.decode(n.inputs,"0x"+t.data.substring(10)),functionFragment:n,name:n.name,signature:n.format(),sighash:this.getSighash(n),value:BigNumber.from(t.value||"0")}):null}parseLog(t){let n=this.getEvent(t.topics[0]);return!n||n.anonymous?null:new LogDescription({eventFragment:n,name:n.name,signature:n.format(),topic:this.getEventTopic(n),args:this.decodeEventLog(n,t.data,t.topics)})}parseError(t){const n=hexlify(t);let ie=this.getError(n.substring(0,10).toLowerCase());return ie?new ErrorDescription({args:this._abiCoder.decode(ie.inputs,"0x"+n.substring(10)),errorFragment:ie,name:ie.name,signature:ie.format(),sighash:this.getSighash(ie)}):null}static isInterface(t){return!!(t&&t._isInterface)}}const lib_esm$b=Object.freeze(Object.defineProperty({__proto__:null,AbiCoder,ConstructorFragment,ErrorFragment,EventFragment,FormatTypes,Fragment,FunctionFragment,Indexed,Interface,LogDescription,ParamType,TransactionDescription,checkResultErrors,defaultAbiCoder},Symbol.toStringTag,{value:"Module"})),version$l="abstract-provider/5.8.0";var __awaiter$j=function(c,t,n,ie){function fe(ae){return ae instanceof n?ae:new n(function(le){le(ae)})}return new(n||(n=Promise))(function(ae,le){function he(xe){try{me(ie.next(xe))}catch(Ee){le(Ee)}}function ye(xe){try{me(ie.throw(xe))}catch(Ee){le(Ee)}}function me(xe){xe.done?ae(xe.value):fe(xe.value).then(he,ye)}me((ie=ie.apply(c,t||[])).next())})};const logger$j=new Logger(version$l);class ForkEvent extends Description{static isForkEvent(t){return!!(t&&t._isForkEvent)}}class Provider{constructor(){logger$j.checkAbstract(new.target,Provider),defineReadOnly(this,"_isProvider",!0)}getFeeData(){return __awaiter$j(this,void 0,void 0,function*(){const{block:t,gasPrice:n}=yield resolveProperties({block:this.getBlock("latest"),gasPrice:this.getGasPrice().catch(le=>null)});let ie=null,fe=null,ae=null;return t&&t.baseFeePerGas&&(ie=t.baseFeePerGas,ae=BigNumber.from("1500000000"),fe=t.baseFeePerGas.mul(2).add(ae)),{lastBaseFeePerGas:ie,maxFeePerGas:fe,maxPriorityFeePerGas:ae,gasPrice:n}})}addListener(t,n){return this.on(t,n)}removeListener(t,n){return this.off(t,n)}static isProvider(t){return!!(t&&t._isProvider)}}const version$k="abstract-signer/5.8.0";var __awaiter$i=function(c,t,n,ie){function fe(ae){return ae instanceof n?ae:new n(function(le){le(ae)})}return new(n||(n=Promise))(function(ae,le){function he(xe){try{me(ie.next(xe))}catch(Ee){le(Ee)}}function ye(xe){try{me(ie.throw(xe))}catch(Ee){le(Ee)}}function me(xe){xe.done?ae(xe.value):fe(xe.value).then(he,ye)}me((ie=ie.apply(c,t||[])).next())})};const logger$i=new Logger(version$k),allowedTransactionKeys$2=["accessList","ccipReadEnabled","chainId","customData","data","from","gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","nonce","to","type","value"],forwardErrors=[Logger.errors.INSUFFICIENT_FUNDS,Logger.errors.NONCE_EXPIRED,Logger.errors.REPLACEMENT_UNDERPRICED];class Signer{constructor(){logger$i.checkAbstract(new.target,Signer),defineReadOnly(this,"_isSigner",!0)}getBalance(t){return __awaiter$i(this,void 0,void 0,function*(){return this._checkProvider("getBalance"),yield this.provider.getBalance(this.getAddress(),t)})}getTransactionCount(t){return __awaiter$i(this,void 0,void 0,function*(){return this._checkProvider("getTransactionCount"),yield this.provider.getTransactionCount(this.getAddress(),t)})}estimateGas(t){return __awaiter$i(this,void 0,void 0,function*(){this._checkProvider("estimateGas");const n=yield resolveProperties(this.checkTransaction(t));return yield this.provider.estimateGas(n)})}call(t,n){return __awaiter$i(this,void 0,void 0,function*(){this._checkProvider("call");const ie=yield resolveProperties(this.checkTransaction(t));return yield this.provider.call(ie,n)})}sendTransaction(t){return __awaiter$i(this,void 0,void 0,function*(){this._checkProvider("sendTransaction");const n=yield this.populateTransaction(t),ie=yield this.signTransaction(n);return yield this.provider.sendTransaction(ie)})}getChainId(){return __awaiter$i(this,void 0,void 0,function*(){return this._checkProvider("getChainId"),(yield this.provider.getNetwork()).chainId})}getGasPrice(){return __awaiter$i(this,void 0,void 0,function*(){return this._checkProvider("getGasPrice"),yield this.provider.getGasPrice()})}getFeeData(){return __awaiter$i(this,void 0,void 0,function*(){return this._checkProvider("getFeeData"),yield this.provider.getFeeData()})}resolveName(t){return __awaiter$i(this,void 0,void 0,function*(){return this._checkProvider("resolveName"),yield this.provider.resolveName(t)})}checkTransaction(t){for(const ie in t)allowedTransactionKeys$2.indexOf(ie)===-1&&logger$i.throwArgumentError("invalid transaction key: "+ie,"transaction",t);const n=shallowCopy(t);return n.from==null?n.from=this.getAddress():n.from=Promise.all([Promise.resolve(n.from),this.getAddress()]).then(ie=>(ie[0].toLowerCase()!==ie[1].toLowerCase()&&logger$i.throwArgumentError("from address mismatch","transaction",t),ie[0])),n}populateTransaction(t){return __awaiter$i(this,void 0,void 0,function*(){const n=yield resolveProperties(this.checkTransaction(t));n.to!=null&&(n.to=Promise.resolve(n.to).then(fe=>__awaiter$i(this,void 0,void 0,function*(){if(fe==null)return null;const ae=yield this.resolveName(fe);return ae==null&&logger$i.throwArgumentError("provided ENS name resolves to null","tx.to",fe),ae})),n.to.catch(fe=>{}));const ie=n.maxFeePerGas!=null||n.maxPriorityFeePerGas!=null;if(n.gasPrice!=null&&(n.type===2||ie)?logger$i.throwArgumentError("eip-1559 transaction do not support gasPrice","transaction",t):(n.type===0||n.type===1)&&ie&&logger$i.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","transaction",t),(n.type===2||n.type==null)&&n.maxFeePerGas!=null&&n.maxPriorityFeePerGas!=null)n.type=2;else if(n.type===0||n.type===1)n.gasPrice==null&&(n.gasPrice=this.getGasPrice());else{const fe=yield this.getFeeData();if(n.type==null)if(fe.maxFeePerGas!=null&&fe.maxPriorityFeePerGas!=null)if(n.type=2,n.gasPrice!=null){const ae=n.gasPrice;delete n.gasPrice,n.maxFeePerGas=ae,n.maxPriorityFeePerGas=ae}else n.maxFeePerGas==null&&(n.maxFeePerGas=fe.maxFeePerGas),n.maxPriorityFeePerGas==null&&(n.maxPriorityFeePerGas=fe.maxPriorityFeePerGas);else fe.gasPrice!=null?(ie&&logger$i.throwError("network does not support EIP-1559",Logger.errors.UNSUPPORTED_OPERATION,{operation:"populateTransaction"}),n.gasPrice==null&&(n.gasPrice=fe.gasPrice),n.type=0):logger$i.throwError("failed to get consistent fee data",Logger.errors.UNSUPPORTED_OPERATION,{operation:"signer.getFeeData"});else n.type===2&&(n.maxFeePerGas==null&&(n.maxFeePerGas=fe.maxFeePerGas),n.maxPriorityFeePerGas==null&&(n.maxPriorityFeePerGas=fe.maxPriorityFeePerGas))}return n.nonce==null&&(n.nonce=this.getTransactionCount("pending")),n.gasLimit==null&&(n.gasLimit=this.estimateGas(n).catch(fe=>{if(forwardErrors.indexOf(fe.code)>=0)throw fe;return logger$i.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",Logger.errors.UNPREDICTABLE_GAS_LIMIT,{error:fe,tx:n})})),n.chainId==null?n.chainId=this.getChainId():n.chainId=Promise.all([Promise.resolve(n.chainId),this.getChainId()]).then(fe=>(fe[1]!==0&&fe[0]!==fe[1]&&logger$i.throwArgumentError("chainId address mismatch","transaction",t),fe[0])),yield resolveProperties(n)})}_checkProvider(t){this.provider||logger$i.throwError("missing provider",Logger.errors.UNSUPPORTED_OPERATION,{operation:t||"_checkProvider"})}static isSigner(t){return!!(t&&t._isSigner)}}class VoidSigner extends Signer{constructor(t,n){super(),defineReadOnly(this,"address",t),defineReadOnly(this,"provider",n||null)}getAddress(){return Promise.resolve(this.address)}_fail(t,n){return Promise.resolve().then(()=>{logger$i.throwError(t,Logger.errors.UNSUPPORTED_OPERATION,{operation:n})})}signMessage(t){return this._fail("VoidSigner cannot sign messages","signMessage")}signTransaction(t){return this._fail("VoidSigner cannot sign transactions","signTransaction")}_signTypedData(t,n,ie){return this._fail("VoidSigner cannot sign typed data","signTypedData")}connect(t){return new VoidSigner(this.address,t)}}var hash$4={},utils$o={},minimalisticAssert$1=assert$h;function assert$h(c,t){if(!c)throw new Error(t||"Assertion failed")}assert$h.equal=function(t,n,ie){if(t!=n)throw new Error(ie||"Assertion failed: "+t+" != "+n)};var inherits_browser$1={exports:{}};typeof Object.create=="function"?inherits_browser$1.exports=function(t,n){n&&(t.super_=n,t.prototype=Object.create(n.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:inherits_browser$1.exports=function(t,n){if(n){t.super_=n;var ie=function(){};ie.prototype=n.prototype,t.prototype=new ie,t.prototype.constructor=t}};var inherits_browserExports=inherits_browser$1.exports,assert$g=minimalisticAssert$1,inherits$3=inherits_browserExports;utils$o.inherits=inherits$3;function isSurrogatePair(c,t){return(c.charCodeAt(t)&64512)!==55296||t<0||t+1>=c.length?!1:(c.charCodeAt(t+1)&64512)===56320}function toArray(c,t){if(Array.isArray(c))return c.slice();if(!c)return[];var n=[];if(typeof c=="string")if(t){if(t==="hex")for(c=c.replace(/[^a-z0-9]+/ig,""),c.length%2!==0&&(c="0"+c),fe=0;fe<c.length;fe+=2)n.push(parseInt(c[fe]+c[fe+1],16))}else for(var ie=0,fe=0;fe<c.length;fe++){var ae=c.charCodeAt(fe);ae<128?n[ie++]=ae:ae<2048?(n[ie++]=ae>>6|192,n[ie++]=ae&63|128):isSurrogatePair(c,fe)?(ae=65536+((ae&1023)<<10)+(c.charCodeAt(++fe)&1023),n[ie++]=ae>>18|240,n[ie++]=ae>>12&63|128,n[ie++]=ae>>6&63|128,n[ie++]=ae&63|128):(n[ie++]=ae>>12|224,n[ie++]=ae>>6&63|128,n[ie++]=ae&63|128)}else for(fe=0;fe<c.length;fe++)n[fe]=c[fe]|0;return n}utils$o.toArray=toArray;function toHex$1(c){for(var t="",n=0;n<c.length;n++)t+=zero2(c[n].toString(16));return t}utils$o.toHex=toHex$1;function htonl(c){var t=c>>>24|c>>>8&65280|c<<8&16711680|(c&255)<<24;return t>>>0}utils$o.htonl=htonl;function toHex32(c,t){for(var n="",ie=0;ie<c.length;ie++){var fe=c[ie];t==="little"&&(fe=htonl(fe)),n+=zero8(fe.toString(16))}return n}utils$o.toHex32=toHex32;function zero2(c){return c.length===1?"0"+c:c}utils$o.zero2=zero2;function zero8(c){return c.length===7?"0"+c:c.length===6?"00"+c:c.length===5?"000"+c:c.length===4?"0000"+c:c.length===3?"00000"+c:c.length===2?"000000"+c:c.length===1?"0000000"+c:c}utils$o.zero8=zero8;function join32(c,t,n,ie){var fe=n-t;assert$g(fe%4===0);for(var ae=new Array(fe/4),le=0,he=t;le<ae.length;le++,he+=4){var ye;ie==="big"?ye=c[he]<<24|c[he+1]<<16|c[he+2]<<8|c[he+3]:ye=c[he+3]<<24|c[he+2]<<16|c[he+1]<<8|c[he],ae[le]=ye>>>0}return ae}utils$o.join32=join32;function split32(c,t){for(var n=new Array(c.length*4),ie=0,fe=0;ie<c.length;ie++,fe+=4){var ae=c[ie];t==="big"?(n[fe]=ae>>>24,n[fe+1]=ae>>>16&255,n[fe+2]=ae>>>8&255,n[fe+3]=ae&255):(n[fe+3]=ae>>>24,n[fe+2]=ae>>>16&255,n[fe+1]=ae>>>8&255,n[fe]=ae&255)}return n}utils$o.split32=split32;function rotr32$1(c,t){return c>>>t|c<<32-t}utils$o.rotr32=rotr32$1;function rotl32$2(c,t){return c<<t|c>>>32-t}utils$o.rotl32=rotl32$2;function sum32$3(c,t){return c+t>>>0}utils$o.sum32=sum32$3;function sum32_3$1(c,t,n){return c+t+n>>>0}utils$o.sum32_3=sum32_3$1;function sum32_4$2(c,t,n,ie){return c+t+n+ie>>>0}utils$o.sum32_4=sum32_4$2;function sum32_5$2(c,t,n,ie,fe){return c+t+n+ie+fe>>>0}utils$o.sum32_5=sum32_5$2;function sum64$1(c,t,n,ie){var fe=c[t],ae=c[t+1],le=ie+ae>>>0,he=(le<ie?1:0)+n+fe;c[t]=he>>>0,c[t+1]=le}utils$o.sum64=sum64$1;function sum64_hi$1(c,t,n,ie){var fe=t+ie>>>0,ae=(fe<t?1:0)+c+n;return ae>>>0}utils$o.sum64_hi=sum64_hi$1;function sum64_lo$1(c,t,n,ie){var fe=t+ie;return fe>>>0}utils$o.sum64_lo=sum64_lo$1;function sum64_4_hi$1(c,t,n,ie,fe,ae,le,he){var ye=0,me=t;me=me+ie>>>0,ye+=me<t?1:0,me=me+ae>>>0,ye+=me<ae?1:0,me=me+he>>>0,ye+=me<he?1:0;var xe=c+n+fe+le+ye;return xe>>>0}utils$o.sum64_4_hi=sum64_4_hi$1;function sum64_4_lo$1(c,t,n,ie,fe,ae,le,he){var ye=t+ie+ae+he;return ye>>>0}utils$o.sum64_4_lo=sum64_4_lo$1;function sum64_5_hi$1(c,t,n,ie,fe,ae,le,he,ye,me){var xe=0,Ee=t;Ee=Ee+ie>>>0,xe+=Ee<t?1:0,Ee=Ee+ae>>>0,xe+=Ee<ae?1:0,Ee=Ee+he>>>0,xe+=Ee<he?1:0,Ee=Ee+me>>>0,xe+=Ee<me?1:0;var Se=c+n+fe+le+ye+xe;return Se>>>0}utils$o.sum64_5_hi=sum64_5_hi$1;function sum64_5_lo$1(c,t,n,ie,fe,ae,le,he,ye,me){var xe=t+ie+ae+he+me;return xe>>>0}utils$o.sum64_5_lo=sum64_5_lo$1;function rotr64_hi$1(c,t,n){var ie=t<<32-n|c>>>n;return ie>>>0}utils$o.rotr64_hi=rotr64_hi$1;function rotr64_lo$1(c,t,n){var ie=c<<32-n|t>>>n;return ie>>>0}utils$o.rotr64_lo=rotr64_lo$1;function shr64_hi$1(c,t,n){return c>>>n}utils$o.shr64_hi=shr64_hi$1;function shr64_lo$1(c,t,n){var ie=c<<32-n|t>>>n;return ie>>>0}utils$o.shr64_lo=shr64_lo$1;var common$5={},utils$n=utils$o,assert$f=minimalisticAssert$1;function BlockHash$4(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}common$5.BlockHash=BlockHash$4;BlockHash$4.prototype.update=function(t,n){if(t=utils$n.toArray(t,n),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){t=this.pending;var ie=t.length%this._delta8;this.pending=t.slice(t.length-ie,t.length),this.pending.length===0&&(this.pending=null),t=utils$n.join32(t,0,t.length-ie,this.endian);for(var fe=0;fe<t.length;fe+=this._delta32)this._update(t,fe,fe+this._delta32)}return this};BlockHash$4.prototype.digest=function(t){return this.update(this._pad()),assert$f(this.pending===null),this._digest(t)};BlockHash$4.prototype._pad=function(){var t=this.pendingTotal,n=this._delta8,ie=n-(t+this.padLength)%n,fe=new Array(ie+this.padLength);fe[0]=128;for(var ae=1;ae<ie;ae++)fe[ae]=0;if(t<<=3,this.endian==="big"){for(var le=8;le<this.padLength;le++)fe[ae++]=0;fe[ae++]=0,fe[ae++]=0,fe[ae++]=0,fe[ae++]=0,fe[ae++]=t>>>24&255,fe[ae++]=t>>>16&255,fe[ae++]=t>>>8&255,fe[ae++]=t&255}else for(fe[ae++]=t&255,fe[ae++]=t>>>8&255,fe[ae++]=t>>>16&255,fe[ae++]=t>>>24&255,fe[ae++]=0,fe[ae++]=0,fe[ae++]=0,fe[ae++]=0,le=8;le<this.padLength;le++)fe[ae++]=0;return fe};var sha$1={},common$4={},utils$m=utils$o,rotr32=utils$m.rotr32;function ft_1$1(c,t,n,ie){if(c===0)return ch32$1(t,n,ie);if(c===1||c===3)return p32(t,n,ie);if(c===2)return maj32$1(t,n,ie)}common$4.ft_1=ft_1$1;function ch32$1(c,t,n){return c&t^~c&n}common$4.ch32=ch32$1;function maj32$1(c,t,n){return c&t^c&n^t&n}common$4.maj32=maj32$1;function p32(c,t,n){return c^t^n}common$4.p32=p32;function s0_256$1(c){return rotr32(c,2)^rotr32(c,13)^rotr32(c,22)}common$4.s0_256=s0_256$1;function s1_256$1(c){return rotr32(c,6)^rotr32(c,11)^rotr32(c,25)}common$4.s1_256=s1_256$1;function g0_256$1(c){return rotr32(c,7)^rotr32(c,18)^c>>>3}common$4.g0_256=g0_256$1;function g1_256$1(c){return rotr32(c,17)^rotr32(c,19)^c>>>10}common$4.g1_256=g1_256$1;var utils$l=utils$o,common$3=common$5,shaCommon$1=common$4,rotl32$1=utils$l.rotl32,sum32$2=utils$l.sum32,sum32_5$1=utils$l.sum32_5,ft_1=shaCommon$1.ft_1,BlockHash$3=common$3.BlockHash,sha1_K=[1518500249,1859775393,2400959708,3395469782];function SHA1(){if(!(this instanceof SHA1))return new SHA1;BlockHash$3.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}utils$l.inherits(SHA1,BlockHash$3);var _1=SHA1;SHA1.blockSize=512;SHA1.outSize=160;SHA1.hmacStrength=80;SHA1.padLength=64;SHA1.prototype._update=function(t,n){for(var ie=this.W,fe=0;fe<16;fe++)ie[fe]=t[n+fe];for(;fe<ie.length;fe++)ie[fe]=rotl32$1(ie[fe-3]^ie[fe-8]^ie[fe-14]^ie[fe-16],1);var ae=this.h[0],le=this.h[1],he=this.h[2],ye=this.h[3],me=this.h[4];for(fe=0;fe<ie.length;fe++){var xe=~~(fe/20),Ee=sum32_5$1(rotl32$1(ae,5),ft_1(xe,le,he,ye),me,ie[fe],sha1_K[xe]);me=ye,ye=he,he=rotl32$1(le,30),le=ae,ae=Ee}this.h[0]=sum32$2(this.h[0],ae),this.h[1]=sum32$2(this.h[1],le),this.h[2]=sum32$2(this.h[2],he),this.h[3]=sum32$2(this.h[3],ye),this.h[4]=sum32$2(this.h[4],me)};SHA1.prototype._digest=function(t){return t==="hex"?utils$l.toHex32(this.h,"big"):utils$l.split32(this.h,"big")};var utils$k=utils$o,common$2=common$5,shaCommon=common$4,assert$e=minimalisticAssert$1,sum32$1=utils$k.sum32,sum32_4$1=utils$k.sum32_4,sum32_5=utils$k.sum32_5,ch32=shaCommon.ch32,maj32=shaCommon.maj32,s0_256=shaCommon.s0_256,s1_256=shaCommon.s1_256,g0_256=shaCommon.g0_256,g1_256=shaCommon.g1_256,BlockHash$2=common$2.BlockHash,sha256_K=[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];function SHA256$2(){if(!(this instanceof SHA256$2))return new SHA256$2;BlockHash$2.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=sha256_K,this.W=new Array(64)}utils$k.inherits(SHA256$2,BlockHash$2);var _256=SHA256$2;SHA256$2.blockSize=512;SHA256$2.outSize=256;SHA256$2.hmacStrength=192;SHA256$2.padLength=64;SHA256$2.prototype._update=function(t,n){for(var ie=this.W,fe=0;fe<16;fe++)ie[fe]=t[n+fe];for(;fe<ie.length;fe++)ie[fe]=sum32_4$1(g1_256(ie[fe-2]),ie[fe-7],g0_256(ie[fe-15]),ie[fe-16]);var ae=this.h[0],le=this.h[1],he=this.h[2],ye=this.h[3],me=this.h[4],xe=this.h[5],Ee=this.h[6],Se=this.h[7];for(assert$e(this.k.length===ie.length),fe=0;fe<ie.length;fe++){var Me=sum32_5(Se,s1_256(me),ch32(me,xe,Ee),this.k[fe],ie[fe]),Be=sum32$1(s0_256(ae),maj32(ae,le,he));Se=Ee,Ee=xe,xe=me,me=sum32$1(ye,Me),ye=he,he=le,le=ae,ae=sum32$1(Me,Be)}this.h[0]=sum32$1(this.h[0],ae),this.h[1]=sum32$1(this.h[1],le),this.h[2]=sum32$1(this.h[2],he),this.h[3]=sum32$1(this.h[3],ye),this.h[4]=sum32$1(this.h[4],me),this.h[5]=sum32$1(this.h[5],xe),this.h[6]=sum32$1(this.h[6],Ee),this.h[7]=sum32$1(this.h[7],Se)};SHA256$2.prototype._digest=function(t){return t==="hex"?utils$k.toHex32(this.h,"big"):utils$k.split32(this.h,"big")};var utils$j=utils$o,SHA256$1=_256;function SHA224(){if(!(this instanceof SHA224))return new SHA224;SHA256$1.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}utils$j.inherits(SHA224,SHA256$1);var _224=SHA224;SHA224.blockSize=512;SHA224.outSize=224;SHA224.hmacStrength=192;SHA224.padLength=64;SHA224.prototype._digest=function(t){return t==="hex"?utils$j.toHex32(this.h.slice(0,7),"big"):utils$j.split32(this.h.slice(0,7),"big")};var utils$i=utils$o,common$1=common$5,assert$d=minimalisticAssert$1,rotr64_hi=utils$i.rotr64_hi,rotr64_lo=utils$i.rotr64_lo,shr64_hi=utils$i.shr64_hi,shr64_lo=utils$i.shr64_lo,sum64=utils$i.sum64,sum64_hi=utils$i.sum64_hi,sum64_lo=utils$i.sum64_lo,sum64_4_hi=utils$i.sum64_4_hi,sum64_4_lo=utils$i.sum64_4_lo,sum64_5_hi=utils$i.sum64_5_hi,sum64_5_lo=utils$i.sum64_5_lo,BlockHash$1=common$1.BlockHash,sha512_K=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function SHA512$2(){if(!(this instanceof SHA512$2))return new SHA512$2;BlockHash$1.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=sha512_K,this.W=new Array(160)}utils$i.inherits(SHA512$2,BlockHash$1);var _512=SHA512$2;SHA512$2.blockSize=1024;SHA512$2.outSize=512;SHA512$2.hmacStrength=192;SHA512$2.padLength=128;SHA512$2.prototype._prepareBlock=function(t,n){for(var ie=this.W,fe=0;fe<32;fe++)ie[fe]=t[n+fe];for(;fe<ie.length;fe+=2){var ae=g1_512_hi(ie[fe-4],ie[fe-3]),le=g1_512_lo(ie[fe-4],ie[fe-3]),he=ie[fe-14],ye=ie[fe-13],me=g0_512_hi(ie[fe-30],ie[fe-29]),xe=g0_512_lo(ie[fe-30],ie[fe-29]),Ee=ie[fe-32],Se=ie[fe-31];ie[fe]=sum64_4_hi(ae,le,he,ye,me,xe,Ee,Se),ie[fe+1]=sum64_4_lo(ae,le,he,ye,me,xe,Ee,Se)}};SHA512$2.prototype._update=function(t,n){this._prepareBlock(t,n);var ie=this.W,fe=this.h[0],ae=this.h[1],le=this.h[2],he=this.h[3],ye=this.h[4],me=this.h[5],xe=this.h[6],Ee=this.h[7],Se=this.h[8],Me=this.h[9],Be=this.h[10],$e=this.h[11],Ce=this.h[12],ke=this.h[13],Pe=this.h[14],Ue=this.h[15];assert$d(this.k.length===ie.length);for(var qe=0;qe<ie.length;qe+=2){var He=Pe,Ve=Ue,Ye=s1_512_hi(Se,Me),Qe=s1_512_lo(Se,Me),Ke=ch64_hi(Se,Me,Be,$e,Ce),Pt=ch64_lo(Se,Me,Be,$e,Ce,ke),_e=this.k[qe],se=this.k[qe+1],ce=ie[qe],de=ie[qe+1],pe=sum64_5_hi(He,Ve,Ye,Qe,Ke,Pt,_e,se,ce,de),ve=sum64_5_lo(He,Ve,Ye,Qe,Ke,Pt,_e,se,ce,de);He=s0_512_hi(fe,ae),Ve=s0_512_lo(fe,ae),Ye=maj64_hi(fe,ae,le,he,ye),Qe=maj64_lo(fe,ae,le,he,ye,me);var we=sum64_hi(He,Ve,Ye,Qe),Ae=sum64_lo(He,Ve,Ye,Qe);Pe=Ce,Ue=ke,Ce=Be,ke=$e,Be=Se,$e=Me,Se=sum64_hi(xe,Ee,pe,ve),Me=sum64_lo(Ee,Ee,pe,ve),xe=ye,Ee=me,ye=le,me=he,le=fe,he=ae,fe=sum64_hi(pe,ve,we,Ae),ae=sum64_lo(pe,ve,we,Ae)}sum64(this.h,0,fe,ae),sum64(this.h,2,le,he),sum64(this.h,4,ye,me),sum64(this.h,6,xe,Ee),sum64(this.h,8,Se,Me),sum64(this.h,10,Be,$e),sum64(this.h,12,Ce,ke),sum64(this.h,14,Pe,Ue)};SHA512$2.prototype._digest=function(t){return t==="hex"?utils$i.toHex32(this.h,"big"):utils$i.split32(this.h,"big")};function ch64_hi(c,t,n,ie,fe){var ae=c&n^~c&fe;return ae<0&&(ae+=4294967296),ae}function ch64_lo(c,t,n,ie,fe,ae){var le=t&ie^~t&ae;return le<0&&(le+=4294967296),le}function maj64_hi(c,t,n,ie,fe){var ae=c&n^c&fe^n&fe;return ae<0&&(ae+=4294967296),ae}function maj64_lo(c,t,n,ie,fe,ae){var le=t&ie^t&ae^ie&ae;return le<0&&(le+=4294967296),le}function s0_512_hi(c,t){var n=rotr64_hi(c,t,28),ie=rotr64_hi(t,c,2),fe=rotr64_hi(t,c,7),ae=n^ie^fe;return ae<0&&(ae+=4294967296),ae}function s0_512_lo(c,t){var n=rotr64_lo(c,t,28),ie=rotr64_lo(t,c,2),fe=rotr64_lo(t,c,7),ae=n^ie^fe;return ae<0&&(ae+=4294967296),ae}function s1_512_hi(c,t){var n=rotr64_hi(c,t,14),ie=rotr64_hi(c,t,18),fe=rotr64_hi(t,c,9),ae=n^ie^fe;return ae<0&&(ae+=4294967296),ae}function s1_512_lo(c,t){var n=rotr64_lo(c,t,14),ie=rotr64_lo(c,t,18),fe=rotr64_lo(t,c,9),ae=n^ie^fe;return ae<0&&(ae+=4294967296),ae}function g0_512_hi(c,t){var n=rotr64_hi(c,t,1),ie=rotr64_hi(c,t,8),fe=shr64_hi(c,t,7),ae=n^ie^fe;return ae<0&&(ae+=4294967296),ae}function g0_512_lo(c,t){var n=rotr64_lo(c,t,1),ie=rotr64_lo(c,t,8),fe=shr64_lo(c,t,7),ae=n^ie^fe;return ae<0&&(ae+=4294967296),ae}function g1_512_hi(c,t){var n=rotr64_hi(c,t,19),ie=rotr64_hi(t,c,29),fe=shr64_hi(c,t,6),ae=n^ie^fe;return ae<0&&(ae+=4294967296),ae}function g1_512_lo(c,t){var n=rotr64_lo(c,t,19),ie=rotr64_lo(t,c,29),fe=shr64_lo(c,t,6),ae=n^ie^fe;return ae<0&&(ae+=4294967296),ae}var utils$h=utils$o,SHA512$1=_512;function SHA384(){if(!(this instanceof SHA384))return new SHA384;SHA512$1.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}utils$h.inherits(SHA384,SHA512$1);var _384=SHA384;SHA384.blockSize=1024;SHA384.outSize=384;SHA384.hmacStrength=192;SHA384.padLength=128;SHA384.prototype._digest=function(t){return t==="hex"?utils$h.toHex32(this.h.slice(0,12),"big"):utils$h.split32(this.h.slice(0,12),"big")};sha$1.sha1=_1;sha$1.sha224=_224;sha$1.sha256=_256;sha$1.sha384=_384;sha$1.sha512=_512;var ripemd={},utils$g=utils$o,common=common$5,rotl32=utils$g.rotl32,sum32=utils$g.sum32,sum32_3=utils$g.sum32_3,sum32_4=utils$g.sum32_4,BlockHash=common.BlockHash;function RIPEMD160$1(){if(!(this instanceof RIPEMD160$1))return new RIPEMD160$1;BlockHash.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}utils$g.inherits(RIPEMD160$1,BlockHash);ripemd.ripemd160=RIPEMD160$1;RIPEMD160$1.blockSize=512;RIPEMD160$1.outSize=160;RIPEMD160$1.hmacStrength=192;RIPEMD160$1.padLength=64;RIPEMD160$1.prototype._update=function(t,n){for(var ie=this.h[0],fe=this.h[1],ae=this.h[2],le=this.h[3],he=this.h[4],ye=ie,me=fe,xe=ae,Ee=le,Se=he,Me=0;Me<80;Me++){var Be=sum32(rotl32(sum32_4(ie,f$2(Me,fe,ae,le),t[r$1[Me]+n],K$3(Me)),s$2[Me]),he);ie=he,he=le,le=rotl32(ae,10),ae=fe,fe=Be,Be=sum32(rotl32(sum32_4(ye,f$2(79-Me,me,xe,Ee),t[rh[Me]+n],Kh(Me)),sh[Me]),Se),ye=Se,Se=Ee,Ee=rotl32(xe,10),xe=me,me=Be}Be=sum32_3(this.h[1],ae,Ee),this.h[1]=sum32_3(this.h[2],le,Se),this.h[2]=sum32_3(this.h[3],he,ye),this.h[3]=sum32_3(this.h[4],ie,me),this.h[4]=sum32_3(this.h[0],fe,xe),this.h[0]=Be};RIPEMD160$1.prototype._digest=function(t){return t==="hex"?utils$g.toHex32(this.h,"little"):utils$g.split32(this.h,"little")};function f$2(c,t,n,ie){return c<=15?t^n^ie:c<=31?t&n|~t&ie:c<=47?(t|~n)^ie:c<=63?t&ie|n&~ie:t^(n|~ie)}function K$3(c){return c<=15?0:c<=31?1518500249:c<=47?1859775393:c<=63?2400959708:2840853838}function Kh(c){return c<=15?1352829926:c<=31?1548603684:c<=47?1836072691:c<=63?2053994217:0}var r$1=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],rh=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],s$2=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],sh=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],utils$f=utils$o,assert$c=minimalisticAssert$1;function Hmac(c,t,n){if(!(this instanceof Hmac))return new Hmac(c,t,n);this.Hash=c,this.blockSize=c.blockSize/8,this.outSize=c.outSize/8,this.inner=null,this.outer=null,this._init(utils$f.toArray(t,n))}var hmac$1=Hmac;Hmac.prototype._init=function(t){t.length>this.blockSize&&(t=new this.Hash().update(t).digest()),assert$c(t.length<=this.blockSize);for(var n=t.length;n<this.blockSize;n++)t.push(0);for(n=0;n<t.length;n++)t[n]^=54;for(this.inner=new this.Hash().update(t),n=0;n<t.length;n++)t[n]^=106;this.outer=new this.Hash().update(t)};Hmac.prototype.update=function(t,n){return this.inner.update(t,n),this};Hmac.prototype.digest=function(t){return this.outer.update(this.inner.digest()),this.outer.digest(t)};(function(c){var t=c;t.utils=utils$o,t.common=common$5,t.sha=sha$1,t.ripemd=ripemd,t.hmac=hmac$1,t.sha1=t.sha.sha1,t.sha256=t.sha.sha256,t.sha224=t.sha.sha224,t.sha384=t.sha.sha384,t.sha512=t.sha.sha512,t.ripemd160=t.ripemd.ripemd160})(hash$4);const hash$3=getDefaultExportFromCjs$2(hash$4);function createCommonjsModule(c,t,n){return n={path:t,exports:{},require:function(ie,fe){return commonjsRequire$1(ie,fe??n.path)}},c(n,n.exports),n.exports}function commonjsRequire$1(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var minimalisticAssert=assert$b;function assert$b(c,t){if(!c)throw new Error(t||"Assertion failed")}assert$b.equal=function(t,n,ie){if(t!=n)throw new Error(ie||"Assertion failed: "+t+" != "+n)};var utils_1$7=createCommonjsModule(function(c,t){var n=t;function ie(le,he){if(Array.isArray(le))return le.slice();if(!le)return[];var ye=[];if(typeof le!="string"){for(var me=0;me<le.length;me++)ye[me]=le[me]|0;return ye}if(he==="hex"){le=le.replace(/[^a-z0-9]+/ig,""),le.length%2!==0&&(le="0"+le);for(var me=0;me<le.length;me+=2)ye.push(parseInt(le[me]+le[me+1],16))}else for(var me=0;me<le.length;me++){var xe=le.charCodeAt(me),Ee=xe>>8,Se=xe&255;Ee?ye.push(Ee,Se):ye.push(Se)}return ye}n.toArray=ie;function fe(le){return le.length===1?"0"+le:le}n.zero2=fe;function ae(le){for(var he="",ye=0;ye<le.length;ye++)he+=fe(le[ye].toString(16));return he}n.toHex=ae,n.encode=function(he,ye){return ye==="hex"?ae(he):he}}),utils_1$1$1=createCommonjsModule(function(c,t){var n=t;n.assert=minimalisticAssert,n.toArray=utils_1$7.toArray,n.zero2=utils_1$7.zero2,n.toHex=utils_1$7.toHex,n.encode=utils_1$7.encode;function ie(ye,me,xe){var Ee=new Array(Math.max(ye.bitLength(),xe)+1),Se;for(Se=0;Se<Ee.length;Se+=1)Ee[Se]=0;var Me=1<<me+1,Be=ye.clone();for(Se=0;Se<Ee.length;Se++){var $e,Ce=Be.andln(Me-1);Be.isOdd()?(Ce>(Me>>1)-1?$e=(Me>>1)-Ce:$e=Ce,Be.isubn($e)):$e=0,Ee[Se]=$e,Be.iushrn(1)}return Ee}n.getNAF=ie;function fe(ye,me){var xe=[[],[]];ye=ye.clone(),me=me.clone();for(var Ee=0,Se=0,Me;ye.cmpn(-Ee)>0||me.cmpn(-Se)>0;){var Be=ye.andln(3)+Ee&3,$e=me.andln(3)+Se&3;Be===3&&(Be=-1),$e===3&&($e=-1);var Ce;Be&1?(Me=ye.andln(7)+Ee&7,(Me===3||Me===5)&&$e===2?Ce=-Be:Ce=Be):Ce=0,xe[0].push(Ce);var ke;$e&1?(Me=me.andln(7)+Se&7,(Me===3||Me===5)&&Be===2?ke=-$e:ke=$e):ke=0,xe[1].push(ke),2*Ee===Ce+1&&(Ee=1-Ee),2*Se===ke+1&&(Se=1-Se),ye.iushrn(1),me.iushrn(1)}return xe}n.getJSF=fe;function ae(ye,me,xe){var Ee="_"+me;ye.prototype[me]=function(){return this[Ee]!==void 0?this[Ee]:this[Ee]=xe.call(this)}}n.cachedProperty=ae;function le(ye){return typeof ye=="string"?n.toArray(ye,"hex"):ye}n.parseBytes=le;function he(ye){return new BN$8(ye,"hex","le")}n.intFromLE=he}),getNAF$1=utils_1$1$1.getNAF,getJSF$1=utils_1$1$1.getJSF,assert$1$1=utils_1$1$1.assert;function BaseCurve$1(c,t){this.type=c,this.p=new BN$8(t.p,16),this.red=t.prime?BN$8.red(t.prime):BN$8.mont(this.p),this.zero=new BN$8(0).toRed(this.red),this.one=new BN$8(1).toRed(this.red),this.two=new BN$8(2).toRed(this.red),this.n=t.n&&new BN$8(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var n=this.n&&this.p.div(this.n);!n||n.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var base$5=BaseCurve$1;BaseCurve$1.prototype.point=function(){throw new Error("Not implemented")};BaseCurve$1.prototype.validate=function(){throw new Error("Not implemented")};BaseCurve$1.prototype._fixedNafMul=function(t,n){assert$1$1(t.precomputed);var ie=t._getDoubles(),fe=getNAF$1(n,1,this._bitLength),ae=(1<<ie.step+1)-(ie.step%2===0?2:1);ae/=3;var le=[],he,ye;for(he=0;he<fe.length;he+=ie.step){ye=0;for(var me=he+ie.step-1;me>=he;me--)ye=(ye<<1)+fe[me];le.push(ye)}for(var xe=this.jpoint(null,null,null),Ee=this.jpoint(null,null,null),Se=ae;Se>0;Se--){for(he=0;he<le.length;he++)ye=le[he],ye===Se?Ee=Ee.mixedAdd(ie.points[he]):ye===-Se&&(Ee=Ee.mixedAdd(ie.points[he].neg()));xe=xe.add(Ee)}return xe.toP()};BaseCurve$1.prototype._wnafMul=function(t,n){var ie=4,fe=t._getNAFPoints(ie);ie=fe.wnd;for(var ae=fe.points,le=getNAF$1(n,ie,this._bitLength),he=this.jpoint(null,null,null),ye=le.length-1;ye>=0;ye--){for(var me=0;ye>=0&&le[ye]===0;ye--)me++;if(ye>=0&&me++,he=he.dblp(me),ye<0)break;var xe=le[ye];assert$1$1(xe!==0),t.type==="affine"?xe>0?he=he.mixedAdd(ae[xe-1>>1]):he=he.mixedAdd(ae[-xe-1>>1].neg()):xe>0?he=he.add(ae[xe-1>>1]):he=he.add(ae[-xe-1>>1].neg())}return t.type==="affine"?he.toP():he};BaseCurve$1.prototype._wnafMulAdd=function(t,n,ie,fe,ae){var le=this._wnafT1,he=this._wnafT2,ye=this._wnafT3,me=0,xe,Ee,Se;for(xe=0;xe<fe;xe++){Se=n[xe];var Me=Se._getNAFPoints(t);le[xe]=Me.wnd,he[xe]=Me.points}for(xe=fe-1;xe>=1;xe-=2){var Be=xe-1,$e=xe;if(le[Be]!==1||le[$e]!==1){ye[Be]=getNAF$1(ie[Be],le[Be],this._bitLength),ye[$e]=getNAF$1(ie[$e],le[$e],this._bitLength),me=Math.max(ye[Be].length,me),me=Math.max(ye[$e].length,me);continue}var Ce=[n[Be],null,null,n[$e]];n[Be].y.cmp(n[$e].y)===0?(Ce[1]=n[Be].add(n[$e]),Ce[2]=n[Be].toJ().mixedAdd(n[$e].neg())):n[Be].y.cmp(n[$e].y.redNeg())===0?(Ce[1]=n[Be].toJ().mixedAdd(n[$e]),Ce[2]=n[Be].add(n[$e].neg())):(Ce[1]=n[Be].toJ().mixedAdd(n[$e]),Ce[2]=n[Be].toJ().mixedAdd(n[$e].neg()));var ke=[-3,-1,-5,-7,0,7,5,1,3],Pe=getJSF$1(ie[Be],ie[$e]);for(me=Math.max(Pe[0].length,me),ye[Be]=new Array(me),ye[$e]=new Array(me),Ee=0;Ee<me;Ee++){var Ue=Pe[0][Ee]|0,qe=Pe[1][Ee]|0;ye[Be][Ee]=ke[(Ue+1)*3+(qe+1)],ye[$e][Ee]=0,he[Be]=Ce}}var He=this.jpoint(null,null,null),Ve=this._wnafT4;for(xe=me;xe>=0;xe--){for(var Ye=0;xe>=0;){var Qe=!0;for(Ee=0;Ee<fe;Ee++)Ve[Ee]=ye[Ee][xe]|0,Ve[Ee]!==0&&(Qe=!1);if(!Qe)break;Ye++,xe--}if(xe>=0&&Ye++,He=He.dblp(Ye),xe<0)break;for(Ee=0;Ee<fe;Ee++){var Ke=Ve[Ee];Ke!==0&&(Ke>0?Se=he[Ee][Ke-1>>1]:Ke<0&&(Se=he[Ee][-Ke-1>>1].neg()),Se.type==="affine"?He=He.mixedAdd(Se):He=He.add(Se))}}for(xe=0;xe<fe;xe++)he[xe]=null;return ae?He:He.toP()};function BasePoint$1(c,t){this.curve=c,this.type=t,this.precomputed=null}BaseCurve$1.BasePoint=BasePoint$1;BasePoint$1.prototype.eq=function(){throw new Error("Not implemented")};BasePoint$1.prototype.validate=function(){return this.curve.validate(this)};BaseCurve$1.prototype.decodePoint=function(t,n){t=utils_1$1$1.toArray(t,n);var ie=this.p.byteLength();if((t[0]===4||t[0]===6||t[0]===7)&&t.length-1===2*ie){t[0]===6?assert$1$1(t[t.length-1]%2===0):t[0]===7&&assert$1$1(t[t.length-1]%2===1);var fe=this.point(t.slice(1,1+ie),t.slice(1+ie,1+2*ie));return fe}else if((t[0]===2||t[0]===3)&&t.length-1===ie)return this.pointFromX(t.slice(1,1+ie),t[0]===3);throw new Error("Unknown point format")};BasePoint$1.prototype.encodeCompressed=function(t){return this.encode(t,!0)};BasePoint$1.prototype._encode=function(t){var n=this.curve.p.byteLength(),ie=this.getX().toArray("be",n);return t?[this.getY().isEven()?2:3].concat(ie):[4].concat(ie,this.getY().toArray("be",n))};BasePoint$1.prototype.encode=function(t,n){return utils_1$1$1.encode(this._encode(n),t)};BasePoint$1.prototype.precompute=function(t){if(this.precomputed)return this;var n={doubles:null,naf:null,beta:null};return n.naf=this._getNAFPoints(8),n.doubles=this._getDoubles(4,t),n.beta=this._getBeta(),this.precomputed=n,this};BasePoint$1.prototype._hasDoubles=function(t){if(!this.precomputed)return!1;var n=this.precomputed.doubles;return n?n.points.length>=Math.ceil((t.bitLength()+1)/n.step):!1};BasePoint$1.prototype._getDoubles=function(t,n){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var ie=[this],fe=this,ae=0;ae<n;ae+=t){for(var le=0;le<t;le++)fe=fe.dbl();ie.push(fe)}return{step:t,points:ie}};BasePoint$1.prototype._getNAFPoints=function(t){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var n=[this],ie=(1<<t)-1,fe=ie===1?null:this.dbl(),ae=1;ae<ie;ae++)n[ae]=n[ae-1].add(fe);return{wnd:t,points:n}};BasePoint$1.prototype._getBeta=function(){return null};BasePoint$1.prototype.dblp=function(t){for(var n=this,ie=0;ie<t;ie++)n=n.dbl();return n};var inherits_browser=createCommonjsModule(function(c){typeof Object.create=="function"?c.exports=function(n,ie){ie&&(n.super_=ie,n.prototype=Object.create(ie.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}))}:c.exports=function(n,ie){if(ie){n.super_=ie;var fe=function(){};fe.prototype=ie.prototype,n.prototype=new fe,n.prototype.constructor=n}}}),assert$2$1=utils_1$1$1.assert;function ShortCurve$1(c){base$5.call(this,"short",c),this.a=new BN$8(c.a,16).toRed(this.red),this.b=new BN$8(c.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(c),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}inherits_browser(ShortCurve$1,base$5);var short_1=ShortCurve$1;ShortCurve$1.prototype._getEndomorphism=function(t){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var n,ie;if(t.beta)n=new BN$8(t.beta,16).toRed(this.red);else{var fe=this._getEndoRoots(this.p);n=fe[0].cmp(fe[1])<0?fe[0]:fe[1],n=n.toRed(this.red)}if(t.lambda)ie=new BN$8(t.lambda,16);else{var ae=this._getEndoRoots(this.n);this.g.mul(ae[0]).x.cmp(this.g.x.redMul(n))===0?ie=ae[0]:(ie=ae[1],assert$2$1(this.g.mul(ie).x.cmp(this.g.x.redMul(n))===0))}var le;return t.basis?le=t.basis.map(function(he){return{a:new BN$8(he.a,16),b:new BN$8(he.b,16)}}):le=this._getEndoBasis(ie),{beta:n,lambda:ie,basis:le}}};ShortCurve$1.prototype._getEndoRoots=function(t){var n=t===this.p?this.red:BN$8.mont(t),ie=new BN$8(2).toRed(n).redInvm(),fe=ie.redNeg(),ae=new BN$8(3).toRed(n).redNeg().redSqrt().redMul(ie),le=fe.redAdd(ae).fromRed(),he=fe.redSub(ae).fromRed();return[le,he]};ShortCurve$1.prototype._getEndoBasis=function(t){for(var n=this.n.ushrn(Math.floor(this.n.bitLength()/2)),ie=t,fe=this.n.clone(),ae=new BN$8(1),le=new BN$8(0),he=new BN$8(0),ye=new BN$8(1),me,xe,Ee,Se,Me,Be,$e,Ce=0,ke,Pe;ie.cmpn(0)!==0;){var Ue=fe.div(ie);ke=fe.sub(Ue.mul(ie)),Pe=he.sub(Ue.mul(ae));var qe=ye.sub(Ue.mul(le));if(!Ee&&ke.cmp(n)<0)me=$e.neg(),xe=ae,Ee=ke.neg(),Se=Pe;else if(Ee&&++Ce===2)break;$e=ke,fe=ie,ie=ke,he=ae,ae=Pe,ye=le,le=qe}Me=ke.neg(),Be=Pe;var He=Ee.sqr().add(Se.sqr()),Ve=Me.sqr().add(Be.sqr());return Ve.cmp(He)>=0&&(Me=me,Be=xe),Ee.negative&&(Ee=Ee.neg(),Se=Se.neg()),Me.negative&&(Me=Me.neg(),Be=Be.neg()),[{a:Ee,b:Se},{a:Me,b:Be}]};ShortCurve$1.prototype._endoSplit=function(t){var n=this.endo.basis,ie=n[0],fe=n[1],ae=fe.b.mul(t).divRound(this.n),le=ie.b.neg().mul(t).divRound(this.n),he=ae.mul(ie.a),ye=le.mul(fe.a),me=ae.mul(ie.b),xe=le.mul(fe.b),Ee=t.sub(he).sub(ye),Se=me.add(xe).neg();return{k1:Ee,k2:Se}};ShortCurve$1.prototype.pointFromX=function(t,n){t=new BN$8(t,16),t.red||(t=t.toRed(this.red));var ie=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),fe=ie.redSqrt();if(fe.redSqr().redSub(ie).cmp(this.zero)!==0)throw new Error("invalid point");var ae=fe.fromRed().isOdd();return(n&&!ae||!n&&ae)&&(fe=fe.redNeg()),this.point(t,fe)};ShortCurve$1.prototype.validate=function(t){if(t.inf)return!0;var n=t.x,ie=t.y,fe=this.a.redMul(n),ae=n.redSqr().redMul(n).redIAdd(fe).redIAdd(this.b);return ie.redSqr().redISub(ae).cmpn(0)===0};ShortCurve$1.prototype._endoWnafMulAdd=function(t,n,ie){for(var fe=this._endoWnafT1,ae=this._endoWnafT2,le=0;le<t.length;le++){var he=this._endoSplit(n[le]),ye=t[le],me=ye._getBeta();he.k1.negative&&(he.k1.ineg(),ye=ye.neg(!0)),he.k2.negative&&(he.k2.ineg(),me=me.neg(!0)),fe[le*2]=ye,fe[le*2+1]=me,ae[le*2]=he.k1,ae[le*2+1]=he.k2}for(var xe=this._wnafMulAdd(1,fe,ae,le*2,ie),Ee=0;Ee<le*2;Ee++)fe[Ee]=null,ae[Ee]=null;return xe};function Point$3(c,t,n,ie){base$5.BasePoint.call(this,c,"affine"),t===null&&n===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new BN$8(t,16),this.y=new BN$8(n,16),ie&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}inherits_browser(Point$3,base$5.BasePoint);ShortCurve$1.prototype.point=function(t,n,ie){return new Point$3(this,t,n,ie)};ShortCurve$1.prototype.pointFromJSON=function(t,n){return Point$3.fromJSON(this,t,n)};Point$3.prototype._getBeta=function(){if(this.curve.endo){var t=this.precomputed;if(t&&t.beta)return t.beta;var n=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(t){var ie=this.curve,fe=function(ae){return ie.point(ae.x.redMul(ie.endo.beta),ae.y)};t.beta=n,n.precomputed={beta:null,naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(fe)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(fe)}}}return n}};Point$3.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]};Point$3.fromJSON=function(t,n,ie){typeof n=="string"&&(n=JSON.parse(n));var fe=t.point(n[0],n[1],ie);if(!n[2])return fe;function ae(he){return t.point(he[0],he[1],ie)}var le=n[2];return fe.precomputed={beta:null,doubles:le.doubles&&{step:le.doubles.step,points:[fe].concat(le.doubles.points.map(ae))},naf:le.naf&&{wnd:le.naf.wnd,points:[fe].concat(le.naf.points.map(ae))}},fe};Point$3.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"};Point$3.prototype.isInfinity=function(){return this.inf};Point$3.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(this.x.cmp(t.x)===0)return this.curve.point(null,null);var n=this.y.redSub(t.y);n.cmpn(0)!==0&&(n=n.redMul(this.x.redSub(t.x).redInvm()));var ie=n.redSqr().redISub(this.x).redISub(t.x),fe=n.redMul(this.x.redSub(ie)).redISub(this.y);return this.curve.point(ie,fe)};Point$3.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(t.cmpn(0)===0)return this.curve.point(null,null);var n=this.curve.a,ie=this.x.redSqr(),fe=t.redInvm(),ae=ie.redAdd(ie).redIAdd(ie).redIAdd(n).redMul(fe),le=ae.redSqr().redISub(this.x.redAdd(this.x)),he=ae.redMul(this.x.redSub(le)).redISub(this.y);return this.curve.point(le,he)};Point$3.prototype.getX=function(){return this.x.fromRed()};Point$3.prototype.getY=function(){return this.y.fromRed()};Point$3.prototype.mul=function(t){return t=new BN$8(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)};Point$3.prototype.mulAdd=function(t,n,ie){var fe=[this,n],ae=[t,ie];return this.curve.endo?this.curve._endoWnafMulAdd(fe,ae):this.curve._wnafMulAdd(1,fe,ae,2)};Point$3.prototype.jmulAdd=function(t,n,ie){var fe=[this,n],ae=[t,ie];return this.curve.endo?this.curve._endoWnafMulAdd(fe,ae,!0):this.curve._wnafMulAdd(1,fe,ae,2,!0)};Point$3.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||this.x.cmp(t.x)===0&&this.y.cmp(t.y)===0)};Point$3.prototype.neg=function(t){if(this.inf)return this;var n=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var ie=this.precomputed,fe=function(ae){return ae.neg()};n.precomputed={naf:ie.naf&&{wnd:ie.naf.wnd,points:ie.naf.points.map(fe)},doubles:ie.doubles&&{step:ie.doubles.step,points:ie.doubles.points.map(fe)}}}return n};Point$3.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var t=this.curve.jpoint(this.x,this.y,this.curve.one);return t};function JPoint$1(c,t,n,ie){base$5.BasePoint.call(this,c,"jacobian"),t===null&&n===null&&ie===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new BN$8(0)):(this.x=new BN$8(t,16),this.y=new BN$8(n,16),this.z=new BN$8(ie,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}inherits_browser(JPoint$1,base$5.BasePoint);ShortCurve$1.prototype.jpoint=function(t,n,ie){return new JPoint$1(this,t,n,ie)};JPoint$1.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),n=t.redSqr(),ie=this.x.redMul(n),fe=this.y.redMul(n).redMul(t);return this.curve.point(ie,fe)};JPoint$1.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};JPoint$1.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var n=t.z.redSqr(),ie=this.z.redSqr(),fe=this.x.redMul(n),ae=t.x.redMul(ie),le=this.y.redMul(n.redMul(t.z)),he=t.y.redMul(ie.redMul(this.z)),ye=fe.redSub(ae),me=le.redSub(he);if(ye.cmpn(0)===0)return me.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var xe=ye.redSqr(),Ee=xe.redMul(ye),Se=fe.redMul(xe),Me=me.redSqr().redIAdd(Ee).redISub(Se).redISub(Se),Be=me.redMul(Se.redISub(Me)).redISub(le.redMul(Ee)),$e=this.z.redMul(t.z).redMul(ye);return this.curve.jpoint(Me,Be,$e)};JPoint$1.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var n=this.z.redSqr(),ie=this.x,fe=t.x.redMul(n),ae=this.y,le=t.y.redMul(n).redMul(this.z),he=ie.redSub(fe),ye=ae.redSub(le);if(he.cmpn(0)===0)return ye.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var me=he.redSqr(),xe=me.redMul(he),Ee=ie.redMul(me),Se=ye.redSqr().redIAdd(xe).redISub(Ee).redISub(Ee),Me=ye.redMul(Ee.redISub(Se)).redISub(ae.redMul(xe)),Be=this.z.redMul(he);return this.curve.jpoint(Se,Me,Be)};JPoint$1.prototype.dblp=function(t){if(t===0)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var n;if(this.curve.zeroA||this.curve.threeA){var ie=this;for(n=0;n<t;n++)ie=ie.dbl();return ie}var fe=this.curve.a,ae=this.curve.tinv,le=this.x,he=this.y,ye=this.z,me=ye.redSqr().redSqr(),xe=he.redAdd(he);for(n=0;n<t;n++){var Ee=le.redSqr(),Se=xe.redSqr(),Me=Se.redSqr(),Be=Ee.redAdd(Ee).redIAdd(Ee).redIAdd(fe.redMul(me)),$e=le.redMul(Se),Ce=Be.redSqr().redISub($e.redAdd($e)),ke=$e.redISub(Ce),Pe=Be.redMul(ke);Pe=Pe.redIAdd(Pe).redISub(Me);var Ue=xe.redMul(ye);n+1<t&&(me=me.redMul(Me)),le=Ce,ye=Ue,xe=Pe}return this.curve.jpoint(le,xe.redMul(ae),ye)};JPoint$1.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()};JPoint$1.prototype._zeroDbl=function(){var t,n,ie;if(this.zOne){var fe=this.x.redSqr(),ae=this.y.redSqr(),le=ae.redSqr(),he=this.x.redAdd(ae).redSqr().redISub(fe).redISub(le);he=he.redIAdd(he);var ye=fe.redAdd(fe).redIAdd(fe),me=ye.redSqr().redISub(he).redISub(he),xe=le.redIAdd(le);xe=xe.redIAdd(xe),xe=xe.redIAdd(xe),t=me,n=ye.redMul(he.redISub(me)).redISub(xe),ie=this.y.redAdd(this.y)}else{var Ee=this.x.redSqr(),Se=this.y.redSqr(),Me=Se.redSqr(),Be=this.x.redAdd(Se).redSqr().redISub(Ee).redISub(Me);Be=Be.redIAdd(Be);var $e=Ee.redAdd(Ee).redIAdd(Ee),Ce=$e.redSqr(),ke=Me.redIAdd(Me);ke=ke.redIAdd(ke),ke=ke.redIAdd(ke),t=Ce.redISub(Be).redISub(Be),n=$e.redMul(Be.redISub(t)).redISub(ke),ie=this.y.redMul(this.z),ie=ie.redIAdd(ie)}return this.curve.jpoint(t,n,ie)};JPoint$1.prototype._threeDbl=function(){var t,n,ie;if(this.zOne){var fe=this.x.redSqr(),ae=this.y.redSqr(),le=ae.redSqr(),he=this.x.redAdd(ae).redSqr().redISub(fe).redISub(le);he=he.redIAdd(he);var ye=fe.redAdd(fe).redIAdd(fe).redIAdd(this.curve.a),me=ye.redSqr().redISub(he).redISub(he);t=me;var xe=le.redIAdd(le);xe=xe.redIAdd(xe),xe=xe.redIAdd(xe),n=ye.redMul(he.redISub(me)).redISub(xe),ie=this.y.redAdd(this.y)}else{var Ee=this.z.redSqr(),Se=this.y.redSqr(),Me=this.x.redMul(Se),Be=this.x.redSub(Ee).redMul(this.x.redAdd(Ee));Be=Be.redAdd(Be).redIAdd(Be);var $e=Me.redIAdd(Me);$e=$e.redIAdd($e);var Ce=$e.redAdd($e);t=Be.redSqr().redISub(Ce),ie=this.y.redAdd(this.z).redSqr().redISub(Se).redISub(Ee);var ke=Se.redSqr();ke=ke.redIAdd(ke),ke=ke.redIAdd(ke),ke=ke.redIAdd(ke),n=Be.redMul($e.redISub(t)).redISub(ke)}return this.curve.jpoint(t,n,ie)};JPoint$1.prototype._dbl=function(){var t=this.curve.a,n=this.x,ie=this.y,fe=this.z,ae=fe.redSqr().redSqr(),le=n.redSqr(),he=ie.redSqr(),ye=le.redAdd(le).redIAdd(le).redIAdd(t.redMul(ae)),me=n.redAdd(n);me=me.redIAdd(me);var xe=me.redMul(he),Ee=ye.redSqr().redISub(xe.redAdd(xe)),Se=xe.redISub(Ee),Me=he.redSqr();Me=Me.redIAdd(Me),Me=Me.redIAdd(Me),Me=Me.redIAdd(Me);var Be=ye.redMul(Se).redISub(Me),$e=ie.redAdd(ie).redMul(fe);return this.curve.jpoint(Ee,Be,$e)};JPoint$1.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var t=this.x.redSqr(),n=this.y.redSqr(),ie=this.z.redSqr(),fe=n.redSqr(),ae=t.redAdd(t).redIAdd(t),le=ae.redSqr(),he=this.x.redAdd(n).redSqr().redISub(t).redISub(fe);he=he.redIAdd(he),he=he.redAdd(he).redIAdd(he),he=he.redISub(le);var ye=he.redSqr(),me=fe.redIAdd(fe);me=me.redIAdd(me),me=me.redIAdd(me),me=me.redIAdd(me);var xe=ae.redIAdd(he).redSqr().redISub(le).redISub(ye).redISub(me),Ee=n.redMul(xe);Ee=Ee.redIAdd(Ee),Ee=Ee.redIAdd(Ee);var Se=this.x.redMul(ye).redISub(Ee);Se=Se.redIAdd(Se),Se=Se.redIAdd(Se);var Me=this.y.redMul(xe.redMul(me.redISub(xe)).redISub(he.redMul(ye)));Me=Me.redIAdd(Me),Me=Me.redIAdd(Me),Me=Me.redIAdd(Me);var Be=this.z.redAdd(he).redSqr().redISub(ie).redISub(ye);return this.curve.jpoint(Se,Me,Be)};JPoint$1.prototype.mul=function(t,n){return t=new BN$8(t,n),this.curve._wnafMul(this,t)};JPoint$1.prototype.eq=function(t){if(t.type==="affine")return this.eq(t.toJ());if(this===t)return!0;var n=this.z.redSqr(),ie=t.z.redSqr();if(this.x.redMul(ie).redISub(t.x.redMul(n)).cmpn(0)!==0)return!1;var fe=n.redMul(this.z),ae=ie.redMul(t.z);return this.y.redMul(ae).redISub(t.y.redMul(fe)).cmpn(0)===0};JPoint$1.prototype.eqXToP=function(t){var n=this.z.redSqr(),ie=t.toRed(this.curve.red).redMul(n);if(this.x.cmp(ie)===0)return!0;for(var fe=t.clone(),ae=this.curve.redN.redMul(n);;){if(fe.iadd(this.curve.n),fe.cmp(this.curve.p)>=0)return!1;if(ie.redIAdd(ae),this.x.cmp(ie)===0)return!0}};JPoint$1.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"};JPoint$1.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var curve_1=createCommonjsModule(function(c,t){var n=t;n.base=base$5,n.short=short_1,n.mont=null,n.edwards=null}),curves_1=createCommonjsModule(function(c,t){var n=t,ie=utils_1$1$1.assert;function fe(he){he.type==="short"?this.curve=new curve_1.short(he):he.type==="edwards"?this.curve=new curve_1.edwards(he):this.curve=new curve_1.mont(he),this.g=this.curve.g,this.n=this.curve.n,this.hash=he.hash,ie(this.g.validate(),"Invalid curve"),ie(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}n.PresetCurve=fe;function ae(he,ye){Object.defineProperty(n,he,{configurable:!0,enumerable:!0,get:function(){var me=new fe(ye);return Object.defineProperty(n,he,{configurable:!0,enumerable:!0,value:me}),me}})}ae("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:hash$3.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),ae("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:hash$3.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),ae("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:hash$3.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),ae("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:hash$3.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),ae("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:hash$3.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),ae("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:hash$3.sha256,gRed:!1,g:["9"]}),ae("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:hash$3.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var le;try{le=null.crash()}catch{le=void 0}ae("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:hash$3.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",le]})});function HmacDRBG$1(c){if(!(this instanceof HmacDRBG$1))return new HmacDRBG$1(c);this.hash=c.hash,this.predResist=!!c.predResist,this.outLen=this.hash.outSize,this.minEntropy=c.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=utils_1$7.toArray(c.entropy,c.entropyEnc||"hex"),n=utils_1$7.toArray(c.nonce,c.nonceEnc||"hex"),ie=utils_1$7.toArray(c.pers,c.persEnc||"hex");minimalisticAssert(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,n,ie)}var hmacDrbg$1=HmacDRBG$1;HmacDRBG$1.prototype._init=function(t,n,ie){var fe=t.concat(n).concat(ie);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var ae=0;ae<this.V.length;ae++)this.K[ae]=0,this.V[ae]=1;this._update(fe),this._reseed=1,this.reseedInterval=281474976710656};HmacDRBG$1.prototype._hmac=function(){return new hash$3.hmac(this.hash,this.K)};HmacDRBG$1.prototype._update=function(t){var n=this._hmac().update(this.V).update([0]);t&&(n=n.update(t)),this.K=n.digest(),this.V=this._hmac().update(this.V).digest(),t&&(this.K=this._hmac().update(this.V).update([1]).update(t).digest(),this.V=this._hmac().update(this.V).digest())};HmacDRBG$1.prototype.reseed=function(t,n,ie,fe){typeof n!="string"&&(fe=ie,ie=n,n=null),t=utils_1$7.toArray(t,n),ie=utils_1$7.toArray(ie,fe),minimalisticAssert(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(ie||[])),this._reseed=1};HmacDRBG$1.prototype.generate=function(t,n,ie,fe){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof n!="string"&&(fe=ie,ie=n,n=null),ie&&(ie=utils_1$7.toArray(ie,fe||"hex"),this._update(ie));for(var ae=[];ae.length<t;)this.V=this._hmac().update(this.V).digest(),ae=ae.concat(this.V);var le=ae.slice(0,t);return this._update(ie),this._reseed++,utils_1$7.encode(le,n)};var assert$3$1=utils_1$1$1.assert;function KeyPair$3(c,t){this.ec=c,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}var key$2=KeyPair$3;KeyPair$3.fromPublic=function(t,n,ie){return n instanceof KeyPair$3?n:new KeyPair$3(t,{pub:n,pubEnc:ie})};KeyPair$3.fromPrivate=function(t,n,ie){return n instanceof KeyPair$3?n:new KeyPair$3(t,{priv:n,privEnc:ie})};KeyPair$3.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}};KeyPair$3.prototype.getPublic=function(t,n){return typeof t=="string"&&(n=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),n?this.pub.encode(n,t):this.pub};KeyPair$3.prototype.getPrivate=function(t){return t==="hex"?this.priv.toString(16,2):this.priv};KeyPair$3.prototype._importPrivate=function(t,n){this.priv=new BN$8(t,n||16),this.priv=this.priv.umod(this.ec.curve.n)};KeyPair$3.prototype._importPublic=function(t,n){if(t.x||t.y){this.ec.curve.type==="mont"?assert$3$1(t.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&assert$3$1(t.x&&t.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(t.x,t.y);return}this.pub=this.ec.curve.decodePoint(t,n)};KeyPair$3.prototype.derive=function(t){return t.validate()||assert$3$1(t.validate(),"public point not validated"),t.mul(this.priv).getX()};KeyPair$3.prototype.sign=function(t,n,ie){return this.ec.sign(t,this,n,ie)};KeyPair$3.prototype.verify=function(t,n,ie){return this.ec.verify(t,n,this,void 0,ie)};KeyPair$3.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var assert$4$1=utils_1$1$1.assert;function Signature$3(c,t){if(c instanceof Signature$3)return c;this._importDER(c,t)||(assert$4$1(c.r&&c.s,"Signature without r or s"),this.r=new BN$8(c.r,16),this.s=new BN$8(c.s,16),c.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=c.recoveryParam)}var signature$3=Signature$3;function Position$1(){this.place=0}function getLength$1(c,t){var n=c[t.place++];if(!(n&128))return n;var ie=n&15;if(ie===0||ie>4||c[t.place]===0)return!1;for(var fe=0,ae=0,le=t.place;ae<ie;ae++,le++)fe<<=8,fe|=c[le],fe>>>=0;return fe<=127?!1:(t.place=le,fe)}function rmPadding$1(c){for(var t=0,n=c.length-1;!c[t]&&!(c[t+1]&128)&&t<n;)t++;return t===0?c:c.slice(t)}Signature$3.prototype._importDER=function(t,n){t=utils_1$1$1.toArray(t,n);var ie=new Position$1;if(t[ie.place++]!==48)return!1;var fe=getLength$1(t,ie);if(fe===!1||fe+ie.place!==t.length||t[ie.place++]!==2)return!1;var ae=getLength$1(t,ie);if(ae===!1||t[ie.place]&128)return!1;var le=t.slice(ie.place,ae+ie.place);if(ie.place+=ae,t[ie.place++]!==2)return!1;var he=getLength$1(t,ie);if(he===!1||t.length!==he+ie.place||t[ie.place]&128)return!1;var ye=t.slice(ie.place,he+ie.place);if(le[0]===0)if(le[1]&128)le=le.slice(1);else return!1;if(ye[0]===0)if(ye[1]&128)ye=ye.slice(1);else return!1;return this.r=new BN$8(le),this.s=new BN$8(ye),this.recoveryParam=null,!0};function constructLength$1(c,t){if(t<128){c.push(t);return}var n=1+(Math.log(t)/Math.LN2>>>3);for(c.push(n|128);--n;)c.push(t>>>(n<<3)&255);c.push(t)}Signature$3.prototype.toDER=function(t){var n=this.r.toArray(),ie=this.s.toArray();for(n[0]&128&&(n=[0].concat(n)),ie[0]&128&&(ie=[0].concat(ie)),n=rmPadding$1(n),ie=rmPadding$1(ie);!ie[0]&&!(ie[1]&128);)ie=ie.slice(1);var fe=[2];constructLength$1(fe,n.length),fe=fe.concat(n),fe.push(2),constructLength$1(fe,ie.length);var ae=fe.concat(ie),le=[48];return constructLength$1(le,ae.length),le=le.concat(ae),utils_1$1$1.encode(le,t)};var rand=function(){throw new Error("unsupported")},assert$5$1=utils_1$1$1.assert;function EC(c){if(!(this instanceof EC))return new EC(c);typeof c=="string"&&(assert$5$1(Object.prototype.hasOwnProperty.call(curves_1,c),"Unknown curve "+c),c=curves_1[c]),c instanceof curves_1.PresetCurve&&(c={curve:c}),this.curve=c.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=c.curve.g,this.g.precompute(c.curve.n.bitLength()+1),this.hash=c.hash||c.curve.hash}var ec$1=EC;EC.prototype.keyPair=function(t){return new key$2(this,t)};EC.prototype.keyFromPrivate=function(t,n){return key$2.fromPrivate(this,t,n)};EC.prototype.keyFromPublic=function(t,n){return key$2.fromPublic(this,t,n)};EC.prototype.genKeyPair=function(t){t||(t={});for(var n=new hmacDrbg$1({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||rand(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),ie=this.n.byteLength(),fe=this.n.sub(new BN$8(2));;){var ae=new BN$8(n.generate(ie));if(!(ae.cmp(fe)>0))return ae.iaddn(1),this.keyFromPrivate(ae)}};EC.prototype._truncateToN=function(t,n,ie){var fe;if(BN$8.isBN(t)||typeof t=="number")t=new BN$8(t,16),fe=t.byteLength();else if(typeof t=="object")fe=t.length,t=new BN$8(t,16);else{var ae=t.toString();fe=ae.length+1>>>1,t=new BN$8(ae,16)}typeof ie!="number"&&(ie=fe*8);var le=ie-this.n.bitLength();return le>0&&(t=t.ushrn(le)),!n&&t.cmp(this.n)>=0?t.sub(this.n):t};EC.prototype.sign=function(t,n,ie,fe){if(typeof ie=="object"&&(fe=ie,ie=null),fe||(fe={}),typeof t!="string"&&typeof t!="number"&&!BN$8.isBN(t)){assert$5$1(typeof t=="object"&&t&&typeof t.length=="number","Expected message to be an array-like, a hex string, or a BN instance"),assert$5$1(t.length>>>0===t.length);for(var ae=0;ae<t.length;ae++)assert$5$1((t[ae]&255)===t[ae])}n=this.keyFromPrivate(n,ie),t=this._truncateToN(t,!1,fe.msgBitLength),assert$5$1(!t.isNeg(),"Can not sign a negative message");var le=this.n.byteLength(),he=n.getPrivate().toArray("be",le),ye=t.toArray("be",le);assert$5$1(new BN$8(ye).eq(t),"Can not sign message");for(var me=new hmacDrbg$1({hash:this.hash,entropy:he,nonce:ye,pers:fe.pers,persEnc:fe.persEnc||"utf8"}),xe=this.n.sub(new BN$8(1)),Ee=0;;Ee++){var Se=fe.k?fe.k(Ee):new BN$8(me.generate(this.n.byteLength()));if(Se=this._truncateToN(Se,!0),!(Se.cmpn(1)<=0||Se.cmp(xe)>=0)){var Me=this.g.mul(Se);if(!Me.isInfinity()){var Be=Me.getX(),$e=Be.umod(this.n);if($e.cmpn(0)!==0){var Ce=Se.invm(this.n).mul($e.mul(n.getPrivate()).iadd(t));if(Ce=Ce.umod(this.n),Ce.cmpn(0)!==0){var ke=(Me.getY().isOdd()?1:0)|(Be.cmp($e)!==0?2:0);return fe.canonical&&Ce.cmp(this.nh)>0&&(Ce=this.n.sub(Ce),ke^=1),new signature$3({r:$e,s:Ce,recoveryParam:ke})}}}}}};EC.prototype.verify=function(t,n,ie,fe,ae){ae||(ae={}),t=this._truncateToN(t,!1,ae.msgBitLength),ie=this.keyFromPublic(ie,fe),n=new signature$3(n,"hex");var le=n.r,he=n.s;if(le.cmpn(1)<0||le.cmp(this.n)>=0||he.cmpn(1)<0||he.cmp(this.n)>=0)return!1;var ye=he.invm(this.n),me=ye.mul(t).umod(this.n),xe=ye.mul(le).umod(this.n),Ee;return this.curve._maxwellTrick?(Ee=this.g.jmulAdd(me,ie.getPublic(),xe),Ee.isInfinity()?!1:Ee.eqXToP(le)):(Ee=this.g.mulAdd(me,ie.getPublic(),xe),Ee.isInfinity()?!1:Ee.getX().umod(this.n).cmp(le)===0)};EC.prototype.recoverPubKey=function(c,t,n,ie){assert$5$1((3&n)===n,"The recovery param is more than two bits"),t=new signature$3(t,ie);var fe=this.n,ae=new BN$8(c),le=t.r,he=t.s,ye=n&1,me=n>>1;if(le.cmp(this.curve.p.umod(this.curve.n))>=0&&me)throw new Error("Unable to find sencond key candinate");me?le=this.curve.pointFromX(le.add(this.curve.n),ye):le=this.curve.pointFromX(le,ye);var xe=t.r.invm(fe),Ee=fe.sub(ae).mul(xe).umod(fe),Se=he.mul(xe).umod(fe);return this.g.mulAdd(Ee,le,Se)};EC.prototype.getKeyRecoveryParam=function(c,t,n,ie){if(t=new signature$3(t,ie),t.recoveryParam!==null)return t.recoveryParam;for(var fe=0;fe<4;fe++){var ae;try{ae=this.recoverPubKey(c,t,fe)}catch{continue}if(ae.eq(n))return fe}throw new Error("Unable to find valid recovery factor")};var elliptic_1=createCommonjsModule(function(c,t){var n=t;n.version="6.6.1",n.utils=utils_1$1$1,n.rand=function(){throw new Error("unsupported")},n.curve=curve_1,n.curves=curves_1,n.ec=ec$1,n.eddsa=null}),EC$1=elliptic_1.ec;const version$j="signing-key/5.8.0",logger$h=new Logger(version$j);let _curve=null;function getCurve(){return _curve||(_curve=new EC$1("secp256k1")),_curve}class SigningKey{constructor(t){defineReadOnly(this,"curve","secp256k1"),defineReadOnly(this,"privateKey",hexlify(t)),hexDataLength(this.privateKey)!==32&&logger$h.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const n=getCurve().keyFromPrivate(arrayify(this.privateKey));defineReadOnly(this,"publicKey","0x"+n.getPublic(!1,"hex")),defineReadOnly(this,"compressedPublicKey","0x"+n.getPublic(!0,"hex")),defineReadOnly(this,"_isSigningKey",!0)}_addPoint(t){const n=getCurve().keyFromPublic(arrayify(this.publicKey)),ie=getCurve().keyFromPublic(arrayify(t));return"0x"+n.pub.add(ie.pub).encodeCompressed("hex")}signDigest(t){const n=getCurve().keyFromPrivate(arrayify(this.privateKey)),ie=arrayify(t);ie.length!==32&&logger$h.throwArgumentError("bad digest length","digest",t);const fe=n.sign(ie,{canonical:!0});return splitSignature({recoveryParam:fe.recoveryParam,r:hexZeroPad("0x"+fe.r.toString(16),32),s:hexZeroPad("0x"+fe.s.toString(16),32)})}computeSharedSecret(t){const n=getCurve().keyFromPrivate(arrayify(this.privateKey)),ie=getCurve().keyFromPublic(arrayify(computePublicKey(t)));return hexZeroPad("0x"+n.derive(ie.getPublic()).toString(16),32)}static isSigningKey(t){return!!(t&&t._isSigningKey)}}function recoverPublicKey(c,t){const n=splitSignature(t),ie={r:arrayify(n.r),s:arrayify(n.s)};return"0x"+getCurve().recoverPubKey(arrayify(c),ie,n.recoveryParam).encode("hex",!1)}function computePublicKey(c,t){const n=arrayify(c);if(n.length===32){const ie=new SigningKey(n);return t?"0x"+getCurve().keyFromPrivate(n).getPublic(!0,"hex"):ie.publicKey}else{if(n.length===33)return t?hexlify(n):"0x"+getCurve().keyFromPublic(n).getPublic(!1,"hex");if(n.length===65)return t?"0x"+getCurve().keyFromPublic(n).getPublic(!0,"hex"):hexlify(n)}return logger$h.throwArgumentError("invalid public or private key","key","[REDACTED]")}const lib_esm$a=Object.freeze(Object.defineProperty({__proto__:null,SigningKey,computePublicKey,recoverPublicKey},Symbol.toStringTag,{value:"Module"})),version$i="transactions/5.8.0",logger$g=new Logger(version$i);var TransactionTypes;(function(c){c[c.legacy=0]="legacy",c[c.eip2930=1]="eip2930",c[c.eip1559=2]="eip1559"})(TransactionTypes||(TransactionTypes={}));function handleAddress(c){return c==="0x"?null:getAddress$1(c)}function handleNumber(c){return c==="0x"?Zero$1:BigNumber.from(c)}const transactionFields=[{name:"nonce",maxLength:32,numeric:!0},{name:"gasPrice",maxLength:32,numeric:!0},{name:"gasLimit",maxLength:32,numeric:!0},{name:"to",length:20},{name:"value",maxLength:32,numeric:!0},{name:"data"}],allowedTransactionKeys$1={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,type:!0,value:!0};function computeAddress(c){const t=computePublicKey(c);return getAddress$1(hexDataSlice(keccak256$1(hexDataSlice(t,1)),12))}function recoverAddress(c,t){return computeAddress(recoverPublicKey(arrayify(c),t))}function formatNumber(c,t){const n=stripZeros(BigNumber.from(c).toHexString());return n.length>32&&logger$g.throwArgumentError("invalid length for "+t,"transaction:"+t,c),n}function accessSetify(c,t){return{address:getAddress$1(c),storageKeys:(t||[]).map((n,ie)=>(hexDataLength(n)!==32&&logger$g.throwArgumentError("invalid access list storageKey",`accessList[${c}:${ie}]`,n),n.toLowerCase()))}}function accessListify(c){if(Array.isArray(c))return c.map((n,ie)=>Array.isArray(n)?(n.length>2&&logger$g.throwArgumentError("access list expected to be [ address, storageKeys[] ]",`value[${ie}]`,n),accessSetify(n[0],n[1])):accessSetify(n.address,n.storageKeys));const t=Object.keys(c).map(n=>{const ie=c[n].reduce((fe,ae)=>(fe[ae]=!0,fe),{});return accessSetify(n,Object.keys(ie).sort())});return t.sort((n,ie)=>n.address.localeCompare(ie.address)),t}function formatAccessList(c){return accessListify(c).map(t=>[t.address,t.storageKeys])}function _serializeEip1559(c,t){if(c.gasPrice!=null){const ie=BigNumber.from(c.gasPrice),fe=BigNumber.from(c.maxFeePerGas||0);ie.eq(fe)||logger$g.throwArgumentError("mismatch EIP-1559 gasPrice != maxFeePerGas","tx",{gasPrice:ie,maxFeePerGas:fe})}const n=[formatNumber(c.chainId||0,"chainId"),formatNumber(c.nonce||0,"nonce"),formatNumber(c.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),formatNumber(c.maxFeePerGas||0,"maxFeePerGas"),formatNumber(c.gasLimit||0,"gasLimit"),c.to!=null?getAddress$1(c.to):"0x",formatNumber(c.value||0,"value"),c.data||"0x",formatAccessList(c.accessList||[])];if(t){const ie=splitSignature(t);n.push(formatNumber(ie.recoveryParam,"recoveryParam")),n.push(stripZeros(ie.r)),n.push(stripZeros(ie.s))}return hexConcat(["0x02",encode$6(n)])}function _serializeEip2930(c,t){const n=[formatNumber(c.chainId||0,"chainId"),formatNumber(c.nonce||0,"nonce"),formatNumber(c.gasPrice||0,"gasPrice"),formatNumber(c.gasLimit||0,"gasLimit"),c.to!=null?getAddress$1(c.to):"0x",formatNumber(c.value||0,"value"),c.data||"0x",formatAccessList(c.accessList||[])];if(t){const ie=splitSignature(t);n.push(formatNumber(ie.recoveryParam,"recoveryParam")),n.push(stripZeros(ie.r)),n.push(stripZeros(ie.s))}return hexConcat(["0x01",encode$6(n)])}function _serialize(c,t){checkProperties(c,allowedTransactionKeys$1);const n=[];transactionFields.forEach(function(le){let he=c[le.name]||[];const ye={};le.numeric&&(ye.hexPad="left"),he=arrayify(hexlify(he,ye)),le.length&&he.length!==le.length&&he.length>0&&logger$g.throwArgumentError("invalid length for "+le.name,"transaction:"+le.name,he),le.maxLength&&(he=stripZeros(he),he.length>le.maxLength&&logger$g.throwArgumentError("invalid length for "+le.name,"transaction:"+le.name,he)),n.push(hexlify(he))});let ie=0;if(c.chainId!=null?(ie=c.chainId,typeof ie!="number"&&logger$g.throwArgumentError("invalid transaction.chainId","transaction",c)):t&&!isBytesLike(t)&&t.v>28&&(ie=Math.floor((t.v-35)/2)),ie!==0&&(n.push(hexlify(ie)),n.push("0x"),n.push("0x")),!t)return encode$6(n);const fe=splitSignature(t);let ae=27+fe.recoveryParam;return ie!==0?(n.pop(),n.pop(),n.pop(),ae+=ie*2+8,fe.v>28&&fe.v!==ae&&logger$g.throwArgumentError("transaction.chainId/signature.v mismatch","signature",t)):fe.v!==ae&&logger$g.throwArgumentError("transaction.chainId/signature.v mismatch","signature",t),n.push(hexlify(ae)),n.push(stripZeros(arrayify(fe.r))),n.push(stripZeros(arrayify(fe.s))),encode$6(n)}function serialize$1(c,t){if(c.type==null||c.type===0)return c.accessList!=null&&logger$g.throwArgumentError("untyped transactions do not support accessList; include type: 1","transaction",c),_serialize(c,t);switch(c.type){case 1:return _serializeEip2930(c,t);case 2:return _serializeEip1559(c,t)}return logger$g.throwError(`unsupported transaction type: ${c.type}`,Logger.errors.UNSUPPORTED_OPERATION,{operation:"serializeTransaction",transactionType:c.type})}function _parseEipSignature(c,t,n){try{const ie=handleNumber(t[0]).toNumber();if(ie!==0&&ie!==1)throw new Error("bad recid");c.v=ie}catch{logger$g.throwArgumentError("invalid v for transaction type: 1","v",t[0])}c.r=hexZeroPad(t[1],32),c.s=hexZeroPad(t[2],32);try{const ie=keccak256$1(n(c));c.from=recoverAddress(ie,{r:c.r,s:c.s,recoveryParam:c.v})}catch{}}function _parseEip1559(c){const t=decode$7(c.slice(1));t.length!==9&&t.length!==12&&logger$g.throwArgumentError("invalid component count for transaction type: 2","payload",hexlify(c));const n=handleNumber(t[2]),ie=handleNumber(t[3]),fe={type:2,chainId:handleNumber(t[0]).toNumber(),nonce:handleNumber(t[1]).toNumber(),maxPriorityFeePerGas:n,maxFeePerGas:ie,gasPrice:null,gasLimit:handleNumber(t[4]),to:handleAddress(t[5]),value:handleNumber(t[6]),data:t[7],accessList:accessListify(t[8])};return t.length===9||(fe.hash=keccak256$1(c),_parseEipSignature(fe,t.slice(9),_serializeEip1559)),fe}function _parseEip2930(c){const t=decode$7(c.slice(1));t.length!==8&&t.length!==11&&logger$g.throwArgumentError("invalid component count for transaction type: 1","payload",hexlify(c));const n={type:1,chainId:handleNumber(t[0]).toNumber(),nonce:handleNumber(t[1]).toNumber(),gasPrice:handleNumber(t[2]),gasLimit:handleNumber(t[3]),to:handleAddress(t[4]),value:handleNumber(t[5]),data:t[6],accessList:accessListify(t[7])};return t.length===8||(n.hash=keccak256$1(c),_parseEipSignature(n,t.slice(8),_serializeEip2930)),n}function _parse(c){const t=decode$7(c);t.length!==9&&t.length!==6&&logger$g.throwArgumentError("invalid raw transaction","rawTransaction",c);const n={nonce:handleNumber(t[0]).toNumber(),gasPrice:handleNumber(t[1]),gasLimit:handleNumber(t[2]),to:handleAddress(t[3]),value:handleNumber(t[4]),data:t[5],chainId:0};if(t.length===6)return n;try{n.v=BigNumber.from(t[6]).toNumber()}catch{return n}if(n.r=hexZeroPad(t[7],32),n.s=hexZeroPad(t[8],32),BigNumber.from(n.r).isZero()&&BigNumber.from(n.s).isZero())n.chainId=n.v,n.v=0;else{n.chainId=Math.floor((n.v-35)/2),n.chainId<0&&(n.chainId=0);let ie=n.v-27;const fe=t.slice(0,6);n.chainId!==0&&(fe.push(hexlify(n.chainId)),fe.push("0x"),fe.push("0x"),ie-=n.chainId*2+8);const ae=keccak256$1(encode$6(fe));try{n.from=recoverAddress(ae,{r:hexlify(n.r),s:hexlify(n.s),recoveryParam:ie})}catch{}n.hash=keccak256$1(c)}return n.type=null,n}function parse$2(c){const t=arrayify(c);if(t[0]>127)return _parse(t);switch(t[0]){case 1:return _parseEip2930(t);case 2:return _parseEip1559(t)}return logger$g.throwError(`unsupported transaction type: ${t[0]}`,Logger.errors.UNSUPPORTED_OPERATION,{operation:"parseTransaction",transactionType:t[0]})}const lib_esm$9=Object.freeze(Object.defineProperty({__proto__:null,get TransactionTypes(){return TransactionTypes},accessListify,computeAddress,parse:parse$2,recoverAddress,serialize:serialize$1},Symbol.toStringTag,{value:"Module"})),version$h="contracts/5.8.0";var __awaiter$h=function(c,t,n,ie){function fe(ae){return ae instanceof n?ae:new n(function(le){le(ae)})}return new(n||(n=Promise))(function(ae,le){function he(xe){try{me(ie.next(xe))}catch(Ee){le(Ee)}}function ye(xe){try{me(ie.throw(xe))}catch(Ee){le(Ee)}}function me(xe){xe.done?ae(xe.value):fe(xe.value).then(he,ye)}me((ie=ie.apply(c,t||[])).next())})};const logger$f=new Logger(version$h);function resolveName(c,t){return __awaiter$h(this,void 0,void 0,function*(){const n=yield t;typeof n!="string"&&logger$f.throwArgumentError("invalid address or ENS name","name",n);try{return getAddress$1(n)}catch{}c||logger$f.throwError("a provider or signer is needed to resolve ENS names",Logger.errors.UNSUPPORTED_OPERATION,{operation:"resolveName"});const ie=yield c.resolveName(n);return ie==null&&logger$f.throwArgumentError("resolver or addr is not configured for ENS name","name",n),ie})}function resolveAddresses(c,t,n){return __awaiter$h(this,void 0,void 0,function*(){return Array.isArray(n)?yield Promise.all(n.map((ie,fe)=>resolveAddresses(c,Array.isArray(t)?t[fe]:t[ie.name],ie))):n.type==="address"?yield resolveName(c,t):n.type==="tuple"?yield resolveAddresses(c,t,n.components):n.baseType==="array"?Array.isArray(t)?yield Promise.all(t.map(ie=>resolveAddresses(c,ie,n.arrayChildren))):Promise.reject(logger$f.makeError("invalid value for array",Logger.errors.INVALID_ARGUMENT,{argument:"value",value:t})):t})}function populateTransaction(c,t,n){return __awaiter$h(this,void 0,void 0,function*(){let ie={};n.length===t.inputs.length+1&&typeof n[n.length-1]=="object"&&(ie=shallowCopy(n.pop())),logger$f.checkArgumentCount(n.length,t.inputs.length,"passed to contract"),c.signer?ie.from?ie.from=resolveProperties({override:resolveName(c.signer,ie.from),signer:c.signer.getAddress()}).then(me=>__awaiter$h(this,void 0,void 0,function*(){return getAddress$1(me.signer)!==me.override&&logger$f.throwError("Contract with a Signer cannot override from",Logger.errors.UNSUPPORTED_OPERATION,{operation:"overrides.from"}),me.override})):ie.from=c.signer.getAddress():ie.from&&(ie.from=resolveName(c.provider,ie.from));const fe=yield resolveProperties({args:resolveAddresses(c.signer||c.provider,n,t.inputs),address:c.resolvedAddress,overrides:resolveProperties(ie)||{}}),ae=c.interface.encodeFunctionData(t,fe.args),le={data:ae,to:fe.address},he=fe.overrides;if(he.nonce!=null&&(le.nonce=BigNumber.from(he.nonce).toNumber()),he.gasLimit!=null&&(le.gasLimit=BigNumber.from(he.gasLimit)),he.gasPrice!=null&&(le.gasPrice=BigNumber.from(he.gasPrice)),he.maxFeePerGas!=null&&(le.maxFeePerGas=BigNumber.from(he.maxFeePerGas)),he.maxPriorityFeePerGas!=null&&(le.maxPriorityFeePerGas=BigNumber.from(he.maxPriorityFeePerGas)),he.from!=null&&(le.from=he.from),he.type!=null&&(le.type=he.type),he.accessList!=null&&(le.accessList=accessListify(he.accessList)),le.gasLimit==null&&t.gas!=null){let me=21e3;const xe=arrayify(ae);for(let Ee=0;Ee<xe.length;Ee++)me+=4,xe[Ee]&&(me+=64);le.gasLimit=BigNumber.from(t.gas).add(me)}if(he.value){const me=BigNumber.from(he.value);!me.isZero()&&!t.payable&&logger$f.throwError("non-payable method cannot override value",Logger.errors.UNSUPPORTED_OPERATION,{operation:"overrides.value",value:ie.value}),le.value=me}he.customData&&(le.customData=shallowCopy(he.customData)),he.ccipReadEnabled&&(le.ccipReadEnabled=!!he.ccipReadEnabled),delete ie.nonce,delete ie.gasLimit,delete ie.gasPrice,delete ie.from,delete ie.value,delete ie.type,delete ie.accessList,delete ie.maxFeePerGas,delete ie.maxPriorityFeePerGas,delete ie.customData,delete ie.ccipReadEnabled;const ye=Object.keys(ie).filter(me=>ie[me]!=null);return ye.length&&logger$f.throwError(`cannot override ${ye.map(me=>JSON.stringify(me)).join(",")}`,Logger.errors.UNSUPPORTED_OPERATION,{operation:"overrides",overrides:ye}),le})}function buildPopulate(c,t){return function(...n){return populateTransaction(c,t,n)}}function buildEstimate(c,t){const n=c.signer||c.provider;return function(...ie){return __awaiter$h(this,void 0,void 0,function*(){n||logger$f.throwError("estimate require a provider or signer",Logger.errors.UNSUPPORTED_OPERATION,{operation:"estimateGas"});const fe=yield populateTransaction(c,t,ie);return yield n.estimateGas(fe)})}}function addContractWait(c,t){const n=t.wait.bind(t);t.wait=ie=>n(ie).then(fe=>(fe.events=fe.logs.map(ae=>{let le=deepCopy(ae),he=null;try{he=c.interface.parseLog(ae)}catch{}return he&&(le.args=he.args,le.decode=(ye,me)=>c.interface.decodeEventLog(he.eventFragment,ye,me),le.event=he.name,le.eventSignature=he.signature),le.removeListener=()=>c.provider,le.getBlock=()=>c.provider.getBlock(fe.blockHash),le.getTransaction=()=>c.provider.getTransaction(fe.transactionHash),le.getTransactionReceipt=()=>Promise.resolve(fe),le}),fe))}function buildCall(c,t,n){const ie=c.signer||c.provider;return function(...fe){return __awaiter$h(this,void 0,void 0,function*(){let ae;if(fe.length===t.inputs.length+1&&typeof fe[fe.length-1]=="object"){const ye=shallowCopy(fe.pop());ye.blockTag!=null&&(ae=yield ye.blockTag),delete ye.blockTag,fe.push(ye)}c.deployTransaction!=null&&(yield c._deployed(ae));const le=yield populateTransaction(c,t,fe),he=yield ie.call(le,ae);try{let ye=c.interface.decodeFunctionResult(t,he);return n&&t.outputs.length===1&&(ye=ye[0]),ye}catch(ye){throw ye.code===Logger.errors.CALL_EXCEPTION&&(ye.address=c.address,ye.args=fe,ye.transaction=le),ye}})}}function buildSend(c,t){return function(...n){return __awaiter$h(this,void 0,void 0,function*(){c.signer||logger$f.throwError("sending a transaction requires a signer",Logger.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction"}),c.deployTransaction!=null&&(yield c._deployed());const ie=yield populateTransaction(c,t,n),fe=yield c.signer.sendTransaction(ie);return addContractWait(c,fe),fe})}}function buildDefault(c,t,n){return t.constant?buildCall(c,t,n):buildSend(c,t)}function getEventTag$1(c){return c.address&&(c.topics==null||c.topics.length===0)?"*":(c.address||"*")+"@"+(c.topics?c.topics.map(t=>Array.isArray(t)?t.join("|"):t).join(":"):"")}class RunningEvent{constructor(t,n){defineReadOnly(this,"tag",t),defineReadOnly(this,"filter",n),this._listeners=[]}addListener(t,n){this._listeners.push({listener:t,once:n})}removeListener(t){let n=!1;this._listeners=this._listeners.filter(ie=>n||ie.listener!==t?!0:(n=!0,!1))}removeAllListeners(){this._listeners=[]}listeners(){return this._listeners.map(t=>t.listener)}listenerCount(){return this._listeners.length}run(t){const n=this.listenerCount();return this._listeners=this._listeners.filter(ie=>{const fe=t.slice();return setTimeout(()=>{ie.listener.apply(this,fe)},0),!ie.once}),n}prepareEvent(t){}getEmit(t){return[t]}}class ErrorRunningEvent extends RunningEvent{constructor(){super("error",null)}}class FragmentRunningEvent extends RunningEvent{constructor(t,n,ie,fe){const ae={address:t};let le=n.getEventTopic(ie);fe?(le!==fe[0]&&logger$f.throwArgumentError("topic mismatch","topics",fe),ae.topics=fe.slice()):ae.topics=[le],super(getEventTag$1(ae),ae),defineReadOnly(this,"address",t),defineReadOnly(this,"interface",n),defineReadOnly(this,"fragment",ie)}prepareEvent(t){super.prepareEvent(t),t.event=this.fragment.name,t.eventSignature=this.fragment.format(),t.decode=(n,ie)=>this.interface.decodeEventLog(this.fragment,n,ie);try{t.args=this.interface.decodeEventLog(this.fragment,t.data,t.topics)}catch(n){t.args=null,t.decodeError=n}}getEmit(t){const n=checkResultErrors(t.args);if(n.length)throw n[0].error;const ie=(t.args||[]).slice();return ie.push(t),ie}}class WildcardRunningEvent extends RunningEvent{constructor(t,n){super("*",{address:t}),defineReadOnly(this,"address",t),defineReadOnly(this,"interface",n)}prepareEvent(t){super.prepareEvent(t);try{const n=this.interface.parseLog(t);t.event=n.name,t.eventSignature=n.signature,t.decode=(ie,fe)=>this.interface.decodeEventLog(n.eventFragment,ie,fe),t.args=n.args}catch{}}}class BaseContract{constructor(t,n,ie){defineReadOnly(this,"interface",getStatic(new.target,"getInterface")(n)),ie==null?(defineReadOnly(this,"provider",null),defineReadOnly(this,"signer",null)):Signer.isSigner(ie)?(defineReadOnly(this,"provider",ie.provider||null),defineReadOnly(this,"signer",ie)):Provider.isProvider(ie)?(defineReadOnly(this,"provider",ie),defineReadOnly(this,"signer",null)):logger$f.throwArgumentError("invalid signer or provider","signerOrProvider",ie),defineReadOnly(this,"callStatic",{}),defineReadOnly(this,"estimateGas",{}),defineReadOnly(this,"functions",{}),defineReadOnly(this,"populateTransaction",{}),defineReadOnly(this,"filters",{});{const le={};Object.keys(this.interface.events).forEach(he=>{const ye=this.interface.events[he];defineReadOnly(this.filters,he,(...me)=>({address:this.address,topics:this.interface.encodeFilterTopics(ye,me)})),le[ye.name]||(le[ye.name]=[]),le[ye.name].push(he)}),Object.keys(le).forEach(he=>{const ye=le[he];ye.length===1?defineReadOnly(this.filters,he,this.filters[ye[0]]):logger$f.warn(`Duplicate definition of ${he} (${ye.join(", ")})`)})}if(defineReadOnly(this,"_runningEvents",{}),defineReadOnly(this,"_wrappedEmits",{}),t==null&&logger$f.throwArgumentError("invalid contract address or ENS name","addressOrName",t),defineReadOnly(this,"address",t),this.provider)defineReadOnly(this,"resolvedAddress",resolveName(this.provider,t));else try{defineReadOnly(this,"resolvedAddress",Promise.resolve(getAddress$1(t)))}catch{logger$f.throwError("provider is required to use ENS name as contract address",Logger.errors.UNSUPPORTED_OPERATION,{operation:"new Contract"})}this.resolvedAddress.catch(le=>{});const fe={},ae={};Object.keys(this.interface.functions).forEach(le=>{const he=this.interface.functions[le];if(ae[le]){logger$f.warn(`Duplicate ABI entry for ${JSON.stringify(le)}`);return}ae[le]=!0;{const ye=he.name;fe[`%${ye}`]||(fe[`%${ye}`]=[]),fe[`%${ye}`].push(le)}this[le]==null&&defineReadOnly(this,le,buildDefault(this,he,!0)),this.functions[le]==null&&defineReadOnly(this.functions,le,buildDefault(this,he,!1)),this.callStatic[le]==null&&defineReadOnly(this.callStatic,le,buildCall(this,he,!0)),this.populateTransaction[le]==null&&defineReadOnly(this.populateTransaction,le,buildPopulate(this,he)),this.estimateGas[le]==null&&defineReadOnly(this.estimateGas,le,buildEstimate(this,he))}),Object.keys(fe).forEach(le=>{const he=fe[le];if(he.length>1)return;le=le.substring(1);const ye=he[0];try{this[le]==null&&defineReadOnly(this,le,this[ye])}catch{}this.functions[le]==null&&defineReadOnly(this.functions,le,this.functions[ye]),this.callStatic[le]==null&&defineReadOnly(this.callStatic,le,this.callStatic[ye]),this.populateTransaction[le]==null&&defineReadOnly(this.populateTransaction,le,this.populateTransaction[ye]),this.estimateGas[le]==null&&defineReadOnly(this.estimateGas,le,this.estimateGas[ye])})}static getContractAddress(t){return getContractAddress(t)}static getInterface(t){return Interface.isInterface(t)?t:new Interface(t)}deployed(){return this._deployed()}_deployed(t){return this._deployedPromise||(this.deployTransaction?this._deployedPromise=this.deployTransaction.wait().then(()=>this):this._deployedPromise=this.provider.getCode(this.address,t).then(n=>(n==="0x"&&logger$f.throwError("contract not deployed",Logger.errors.UNSUPPORTED_OPERATION,{contractAddress:this.address,operation:"getDeployed"}),this))),this._deployedPromise}fallback(t){this.signer||logger$f.throwError("sending a transactions require a signer",Logger.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction(fallback)"});const n=shallowCopy(t||{});return["from","to"].forEach(function(ie){n[ie]!=null&&logger$f.throwError("cannot override "+ie,Logger.errors.UNSUPPORTED_OPERATION,{operation:ie})}),n.to=this.resolvedAddress,this.deployed().then(()=>this.signer.sendTransaction(n))}connect(t){typeof t=="string"&&(t=new VoidSigner(t,this.provider));const n=new this.constructor(this.address,this.interface,t);return this.deployTransaction&&defineReadOnly(n,"deployTransaction",this.deployTransaction),n}attach(t){return new this.constructor(t,this.interface,this.signer||this.provider)}static isIndexed(t){return Indexed.isIndexed(t)}_normalizeRunningEvent(t){return this._runningEvents[t.tag]?this._runningEvents[t.tag]:t}_getRunningEvent(t){if(typeof t=="string"){if(t==="error")return this._normalizeRunningEvent(new ErrorRunningEvent);if(t==="event")return this._normalizeRunningEvent(new RunningEvent("event",null));if(t==="*")return this._normalizeRunningEvent(new WildcardRunningEvent(this.address,this.interface));const n=this.interface.getEvent(t);return this._normalizeRunningEvent(new FragmentRunningEvent(this.address,this.interface,n))}if(t.topics&&t.topics.length>0){try{const ie=t.topics[0];if(typeof ie!="string")throw new Error("invalid topic");const fe=this.interface.getEvent(ie);return this._normalizeRunningEvent(new FragmentRunningEvent(this.address,this.interface,fe,t.topics))}catch{}const n={address:this.address,topics:t.topics};return this._normalizeRunningEvent(new RunningEvent(getEventTag$1(n),n))}return this._normalizeRunningEvent(new WildcardRunningEvent(this.address,this.interface))}_checkRunningEvents(t){if(t.listenerCount()===0){delete this._runningEvents[t.tag];const n=this._wrappedEmits[t.tag];n&&t.filter&&(this.provider.off(t.filter,n),delete this._wrappedEmits[t.tag])}}_wrapEvent(t,n,ie){const fe=deepCopy(n);return fe.removeListener=()=>{ie&&(t.removeListener(ie),this._checkRunningEvents(t))},fe.getBlock=()=>this.provider.getBlock(n.blockHash),fe.getTransaction=()=>this.provider.getTransaction(n.transactionHash),fe.getTransactionReceipt=()=>this.provider.getTransactionReceipt(n.transactionHash),t.prepareEvent(fe),fe}_addEventListener(t,n,ie){if(this.provider||logger$f.throwError("events require a provider or a signer with a provider",Logger.errors.UNSUPPORTED_OPERATION,{operation:"once"}),t.addListener(n,ie),this._runningEvents[t.tag]=t,!this._wrappedEmits[t.tag]){const fe=ae=>{let le=this._wrapEvent(t,ae,n);if(le.decodeError==null)try{const he=t.getEmit(le);this.emit(t.filter,...he)}catch(he){le.decodeError=he.error}t.filter!=null&&this.emit("event",le),le.decodeError!=null&&this.emit("error",le.decodeError,le)};this._wrappedEmits[t.tag]=fe,t.filter!=null&&this.provider.on(t.filter,fe)}}queryFilter(t,n,ie){const fe=this._getRunningEvent(t),ae=shallowCopy(fe.filter);return typeof n=="string"&&isHexString(n,32)?(ie!=null&&logger$f.throwArgumentError("cannot specify toBlock with blockhash","toBlock",ie),ae.blockHash=n):(ae.fromBlock=n??0,ae.toBlock=ie??"latest"),this.provider.getLogs(ae).then(le=>le.map(he=>this._wrapEvent(fe,he,null)))}on(t,n){return this._addEventListener(this._getRunningEvent(t),n,!1),this}once(t,n){return this._addEventListener(this._getRunningEvent(t),n,!0),this}emit(t,...n){if(!this.provider)return!1;const ie=this._getRunningEvent(t),fe=ie.run(n)>0;return this._checkRunningEvents(ie),fe}listenerCount(t){return this.provider?t==null?Object.keys(this._runningEvents).reduce((n,ie)=>n+this._runningEvents[ie].listenerCount(),0):this._getRunningEvent(t).listenerCount():0}listeners(t){if(!this.provider)return[];if(t==null){const n=[];for(let ie in this._runningEvents)this._runningEvents[ie].listeners().forEach(fe=>{n.push(fe)});return n}return this._getRunningEvent(t).listeners()}removeAllListeners(t){if(!this.provider)return this;if(t==null){for(const ie in this._runningEvents){const fe=this._runningEvents[ie];fe.removeAllListeners(),this._checkRunningEvents(fe)}return this}const n=this._getRunningEvent(t);return n.removeAllListeners(),this._checkRunningEvents(n),this}off(t,n){if(!this.provider)return this;const ie=this._getRunningEvent(t);return ie.removeListener(n),this._checkRunningEvents(ie),this}removeListener(t,n){return this.off(t,n)}}class Contract extends BaseContract{}class BaseX{constructor(t){defineReadOnly(this,"alphabet",t),defineReadOnly(this,"base",t.length),defineReadOnly(this,"_alphabetMap",{}),defineReadOnly(this,"_leader",t.charAt(0));for(let n=0;n<t.length;n++)this._alphabetMap[t.charAt(n)]=n}encode(t){let n=arrayify(t);if(n.length===0)return"";let ie=[0];for(let ae=0;ae<n.length;++ae){let le=n[ae];for(let he=0;he<ie.length;++he)le+=ie[he]<<8,ie[he]=le%this.base,le=le/this.base|0;for(;le>0;)ie.push(le%this.base),le=le/this.base|0}let fe="";for(let ae=0;n[ae]===0&&ae<n.length-1;++ae)fe+=this._leader;for(let ae=ie.length-1;ae>=0;--ae)fe+=this.alphabet[ie[ae]];return fe}decode(t){if(typeof t!="string")throw new TypeError("Expected String");let n=[];if(t.length===0)return new Uint8Array(n);n.push(0);for(let ie=0;ie<t.length;ie++){let fe=this._alphabetMap[t[ie]];if(fe===void 0)throw new Error("Non-base"+this.base+" character");let ae=fe;for(let le=0;le<n.length;++le)ae+=n[le]*this.base,n[le]=ae&255,ae>>=8;for(;ae>0;)n.push(ae&255),ae>>=8}for(let ie=0;t[ie]===this._leader&&ie<t.length-1;++ie)n.push(0);return arrayify(new Uint8Array(n.reverse()))}}const Base32=new BaseX("abcdefghijklmnopqrstuvwxyz234567"),Base58=new BaseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),lib_esm$8=Object.freeze(Object.defineProperty({__proto__:null,Base32,Base58,BaseX},Symbol.toStringTag,{value:"Module"}));var SupportedAlgorithm;(function(c){c.sha256="sha256",c.sha512="sha512"})(SupportedAlgorithm||(SupportedAlgorithm={}));const version$g="sha2/5.8.0",logger$e=new Logger(version$g);function ripemd160$1(c){return"0x"+hash$3.ripemd160().update(arrayify(c)).digest("hex")}function sha256$7(c){return"0x"+hash$3.sha256().update(arrayify(c)).digest("hex")}function sha512$4(c){return"0x"+hash$3.sha512().update(arrayify(c)).digest("hex")}function computeHmac(c,t,n){return SupportedAlgorithm[c]||logger$e.throwError("unsupported algorithm "+c,Logger.errors.UNSUPPORTED_OPERATION,{operation:"hmac",algorithm:c}),"0x"+hash$3.hmac(hash$3[c],arrayify(t)).update(arrayify(n)).digest("hex")}const lib_esm$7=Object.freeze(Object.defineProperty({__proto__:null,get SupportedAlgorithm(){return SupportedAlgorithm},computeHmac,ripemd160:ripemd160$1,sha256:sha256$7,sha512:sha512$4},Symbol.toStringTag,{value:"Module"}));function pbkdf2$1(c,t,n,ie,fe){c=arrayify(c),t=arrayify(t);let ae,le=1;const he=new Uint8Array(ie),ye=new Uint8Array(t.length+4);ye.set(t);let me,xe;for(let Ee=1;Ee<=le;Ee++){ye[t.length]=Ee>>24&255,ye[t.length+1]=Ee>>16&255,ye[t.length+2]=Ee>>8&255,ye[t.length+3]=Ee&255;let Se=arrayify(computeHmac(fe,c,ye));ae||(ae=Se.length,xe=new Uint8Array(ae),le=Math.ceil(ie/ae),me=ie-(le-1)*ae),xe.set(Se);for(let $e=1;$e<n;$e++){Se=arrayify(computeHmac(fe,c,Se));for(let Ce=0;Ce<ae;Ce++)xe[Ce]^=Se[Ce]}const Me=(Ee-1)*ae,Be=Ee===le?me:ae;he.set(arrayify(xe).slice(0,Be),Me)}return hexlify(he)}const version$f="wordlists/5.8.0",logger$d=new Logger(version$f);class Wordlist{constructor(t){logger$d.checkAbstract(new.target,Wordlist),defineReadOnly(this,"locale",t)}split(t){return t.toLowerCase().split(/ +/g)}join(t){return t.join(" ")}static check(t){const n=[];for(let ie=0;ie<2048;ie++){const fe=t.getWord(ie);if(ie!==t.getWordIndex(fe))return"0x";n.push(fe)}return id(n.join(`
8
8
  `)+`
9
- `)}static register(t,n){n||(n=t.locale)}}const words="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo";let wordlist=null;function loadWords(c){if(wordlist==null&&(wordlist=words.replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),Wordlist.check(c)!=="0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"))throw wordlist=null,new Error("BIP39 Wordlist for en (English) FAILED")}class LangEn extends Wordlist{constructor(){super("en")}getWord(t){return loadWords(this),wordlist[t]}getWordIndex(t){return loadWords(this),wordlist.indexOf(t)}}const langEn=new LangEn;Wordlist.register(langEn);const wordlists={en:langEn},version$e="hdnode/5.8.0",logger$c=new Logger(version$e),N$3=BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),MasterSecret=toUtf8Bytes("Bitcoin seed"),HardenedBit=2147483648;function getUpperMask(c){return(1<<c)-1<<8-c}function getLowerMask(c){return(1<<c)-1}function bytes32(c){return hexZeroPad(hexlify(c),32)}function base58check(c){return Base58.encode(concat$1([c,hexDataSlice(sha256$7(sha256$7(c)),0,4)]))}function getWordlist(c){if(c==null)return wordlists.en;if(typeof c=="string"){const t=wordlists[c];return t==null&&logger$c.throwArgumentError("unknown locale","wordlist",c),t}return c}const _constructorGuard$1={},defaultPath="m/44'/60'/0'/0/0";class HDNode{constructor(t,n,ie,fe,ae,le,he,ye){if(t!==_constructorGuard$1)throw new Error("HDNode constructor cannot be called directly");if(n){const me=new SigningKey(n);defineReadOnly(this,"privateKey",me.privateKey),defineReadOnly(this,"publicKey",me.compressedPublicKey)}else defineReadOnly(this,"privateKey",null),defineReadOnly(this,"publicKey",hexlify(ie));defineReadOnly(this,"parentFingerprint",fe),defineReadOnly(this,"fingerprint",hexDataSlice(ripemd160$1(sha256$7(this.publicKey)),0,4)),defineReadOnly(this,"address",computeAddress(this.publicKey)),defineReadOnly(this,"chainCode",ae),defineReadOnly(this,"index",le),defineReadOnly(this,"depth",he),ye==null?(defineReadOnly(this,"mnemonic",null),defineReadOnly(this,"path",null)):typeof ye=="string"?(defineReadOnly(this,"mnemonic",null),defineReadOnly(this,"path",ye)):(defineReadOnly(this,"mnemonic",ye),defineReadOnly(this,"path",ye.path))}get extendedKey(){if(this.depth>=256)throw new Error("Depth too large!");return base58check(concat$1([this.privateKey!=null?"0x0488ADE4":"0x0488B21E",hexlify(this.depth),this.parentFingerprint,hexZeroPad(hexlify(this.index),4),this.chainCode,this.privateKey!=null?concat$1(["0x00",this.privateKey]):this.publicKey]))}neuter(){return new HDNode(_constructorGuard$1,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,this.path)}_derive(t){if(t>4294967295)throw new Error("invalid index - "+String(t));let n=this.path;n&&(n+="/"+(t&~HardenedBit));const ie=new Uint8Array(37);if(t&HardenedBit){if(!this.privateKey)throw new Error("cannot derive child of neutered node");ie.set(arrayify(this.privateKey),1),n&&(n+="'")}else ie.set(arrayify(this.publicKey));for(let Ee=24;Ee>=0;Ee-=8)ie[33+(Ee>>3)]=t>>24-Ee&255;const fe=arrayify(computeHmac(SupportedAlgorithm.sha512,this.chainCode,ie)),ae=fe.slice(0,32),le=fe.slice(32);let he=null,ye=null;this.privateKey?he=bytes32(BigNumber.from(ae).add(this.privateKey).mod(N$3)):ye=new SigningKey(hexlify(ae))._addPoint(this.publicKey);let me=n;const xe=this.mnemonic;return xe&&(me=Object.freeze({phrase:xe.phrase,path:n,locale:xe.locale||"en"})),new HDNode(_constructorGuard$1,he,ye,this.fingerprint,bytes32(le),t,this.depth+1,me)}derivePath(t){const n=t.split("/");if(n.length===0||n[0]==="m"&&this.depth!==0)throw new Error("invalid path - "+t);n[0]==="m"&&n.shift();let ie=this;for(let fe=0;fe<n.length;fe++){const ae=n[fe];if(ae.match(/^[0-9]+'$/)){const le=parseInt(ae.substring(0,ae.length-1));if(le>=HardenedBit)throw new Error("invalid path index - "+ae);ie=ie._derive(HardenedBit+le)}else if(ae.match(/^[0-9]+$/)){const le=parseInt(ae);if(le>=HardenedBit)throw new Error("invalid path index - "+ae);ie=ie._derive(le)}else throw new Error("invalid path component - "+ae)}return ie}static _fromSeed(t,n){const ie=arrayify(t);if(ie.length<16||ie.length>64)throw new Error("invalid seed");const fe=arrayify(computeHmac(SupportedAlgorithm.sha512,MasterSecret,ie));return new HDNode(_constructorGuard$1,bytes32(fe.slice(0,32)),null,"0x00000000",bytes32(fe.slice(32)),0,0,n)}static fromMnemonic(t,n,ie){return ie=getWordlist(ie),t=entropyToMnemonic(mnemonicToEntropy(t,ie),ie),HDNode._fromSeed(mnemonicToSeed(t,n),{phrase:t,path:"m",locale:ie.locale})}static fromSeed(t){return HDNode._fromSeed(t,null)}static fromExtendedKey(t){const n=Base58.decode(t);(n.length!==82||base58check(n.slice(0,78))!==t)&&logger$c.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");const ie=n[4],fe=hexlify(n.slice(5,9)),ae=parseInt(hexlify(n.slice(9,13)).substring(2),16),le=hexlify(n.slice(13,45)),he=n.slice(45,78);switch(hexlify(n.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new HDNode(_constructorGuard$1,null,hexlify(he),fe,le,ae,ie,null);case"0x0488ade4":case"0x04358394 ":if(he[0]!==0)break;return new HDNode(_constructorGuard$1,hexlify(he.slice(1)),null,fe,le,ae,ie,null)}return logger$c.throwArgumentError("invalid extended key","extendedKey","[REDACTED]")}}function mnemonicToSeed(c,t){t||(t="");const n=toUtf8Bytes("mnemonic"+t,UnicodeNormalizationForm.NFKD);return pbkdf2$1(toUtf8Bytes(c,UnicodeNormalizationForm.NFKD),n,2048,64,"sha512")}function mnemonicToEntropy(c,t){t=getWordlist(t),logger$c.checkNormalize();const n=t.split(c);if(n.length%3!==0)throw new Error("invalid mnemonic");const ie=arrayify(new Uint8Array(Math.ceil(11*n.length/8)));let fe=0;for(let me=0;me<n.length;me++){let xe=t.getWordIndex(n[me].normalize("NFKD"));if(xe===-1)throw new Error("invalid mnemonic");for(let Ee=0;Ee<11;Ee++)xe&1<<10-Ee&&(ie[fe>>3]|=1<<7-fe%8),fe++}const ae=32*n.length/3,le=n.length/3,he=getUpperMask(le);if((arrayify(sha256$7(ie.slice(0,ae/8)))[0]&he)!==(ie[ie.length-1]&he))throw new Error("invalid checksum");return hexlify(ie.slice(0,ae/8))}function entropyToMnemonic(c,t){if(t=getWordlist(t),c=arrayify(c),c.length%4!==0||c.length<16||c.length>32)throw new Error("invalid entropy");const n=[0];let ie=11;for(let le=0;le<c.length;le++)ie>8?(n[n.length-1]<<=8,n[n.length-1]|=c[le],ie-=8):(n[n.length-1]<<=ie,n[n.length-1]|=c[le]>>8-ie,n.push(c[le]&getLowerMask(8-ie)),ie+=3);const fe=c.length/4,ae=arrayify(sha256$7(c))[0]&getUpperMask(fe);return n[n.length-1]<<=fe,n[n.length-1]|=ae>>8-fe,t.join(n.map(le=>t.getWord(le)))}function isValidMnemonic(c,t){try{return mnemonicToEntropy(c,t),!0}catch{}return!1}function getAccountPath(c){return(typeof c!="number"||c<0||c>=HardenedBit||c%1)&&logger$c.throwArgumentError("invalid account index","index",c),`m/44'/60'/${c}'/0/0`}const lib_esm$6=Object.freeze(Object.defineProperty({__proto__:null,HDNode,defaultPath,entropyToMnemonic,getAccountPath,isValidMnemonic,mnemonicToEntropy,mnemonicToSeed},Symbol.toStringTag,{value:"Module"})),version$d="random/5.8.0",logger$b=new Logger(version$d);function getGlobal(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof globalThis<"u")return globalThis;throw new Error("unable to locate global object")}const anyGlobal=getGlobal();let crypto$3=anyGlobal.crypto||anyGlobal.msCrypto;(!crypto$3||!crypto$3.getRandomValues)&&(logger$b.warn("WARNING: Missing strong random number source"),crypto$3={getRandomValues:function(c){return logger$b.throwError("no secure random source avaialble",Logger.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}});function randomBytes$1(c){(c<=0||c>1024||c%1||c!=c)&&logger$b.throwArgumentError("invalid length","length",c);const t=new Uint8Array(c);return crypto$3.getRandomValues(t),arrayify(t)}function shuffled(c){c=c.slice();for(let t=c.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1)),ie=c[t];c[t]=c[n],c[n]=ie}return c}const lib_esm$5=Object.freeze(Object.defineProperty({__proto__:null,randomBytes:randomBytes$1,shuffled},Symbol.toStringTag,{value:"Module"}));var aesJs={exports:{}};(function(c,t){(function(n){function ie(be){return parseInt(be)===be}function fe(be){if(!ie(be.length))return!1;for(var Re=0;Re<be.length;Re++)if(!ie(be[Re])||be[Re]<0||be[Re]>255)return!1;return!0}function ae(be,Re){if(be.buffer&&ArrayBuffer.isView(be)&&be.name==="Uint8Array")return Re&&(be.slice?be=be.slice():be=Array.prototype.slice.call(be)),be;if(Array.isArray(be)){if(!fe(be))throw new Error("Array contains invalid value: "+be);return new Uint8Array(be)}if(ie(be.length)&&fe(be))return new Uint8Array(be);throw new Error("unsupported array-like object")}function le(be){return new Uint8Array(be)}function he(be,Re,Ne,Fe,Ie){(Fe!=null||Ie!=null)&&(be.slice?be=be.slice(Fe,Ie):be=Array.prototype.slice.call(be,Fe,Ie)),Re.set(be,Ne)}var ye=function(){function be(Ne){var Fe=[],Ie=0;for(Ne=encodeURI(Ne);Ie<Ne.length;){var je=Ne.charCodeAt(Ie++);je===37?(Fe.push(parseInt(Ne.substr(Ie,2),16)),Ie+=2):Fe.push(je)}return ae(Fe)}function Re(Ne){for(var Fe=[],Ie=0;Ie<Ne.length;){var je=Ne[Ie];je<128?(Fe.push(String.fromCharCode(je)),Ie++):je>191&&je<224?(Fe.push(String.fromCharCode((je&31)<<6|Ne[Ie+1]&63)),Ie+=2):(Fe.push(String.fromCharCode((je&15)<<12|(Ne[Ie+1]&63)<<6|Ne[Ie+2]&63)),Ie+=3)}return Fe.join("")}return{toBytes:be,fromBytes:Re}}(),me=function(){function be(Fe){for(var Ie=[],je=0;je<Fe.length;je+=2)Ie.push(parseInt(Fe.substr(je,2),16));return Ie}var Re="0123456789abcdef";function Ne(Fe){for(var Ie=[],je=0;je<Fe.length;je++){var Te=Fe[je];Ie.push(Re[(Te&240)>>4]+Re[Te&15])}return Ie.join("")}return{toBytes:be,fromBytes:Ne}}(),xe={16:10,24:12,32:14},Ee=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],Se=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],Me=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],Be=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],$e=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],Ce=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],ke=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],Pe=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],Ue=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],qe=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],He=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],Ve=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],Ye=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],Qe=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],Ke=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function Pt(be){for(var Re=[],Ne=0;Ne<be.length;Ne+=4)Re.push(be[Ne]<<24|be[Ne+1]<<16|be[Ne+2]<<8|be[Ne+3]);return Re}var _e=function(be){if(!(this instanceof _e))throw Error("AES must be instanitated with `new`");Object.defineProperty(this,"key",{value:ae(be,!0)}),this._prepare()};_e.prototype._prepare=function(){var be=xe[this.key.length];if(be==null)throw new Error("invalid key size (must be 16, 24 or 32 bytes)");this._Ke=[],this._Kd=[];for(var Re=0;Re<=be;Re++)this._Ke.push([0,0,0,0]),this._Kd.push([0,0,0,0]);for(var Ne=(be+1)*4,Fe=this.key.length/4,Ie=Pt(this.key),je,Re=0;Re<Fe;Re++)je=Re>>2,this._Ke[je][Re%4]=Ie[Re],this._Kd[be-je][Re%4]=Ie[Re];for(var Te=0,De=Fe,ze;De<Ne;){if(ze=Ie[Fe-1],Ie[0]^=Se[ze>>16&255]<<24^Se[ze>>8&255]<<16^Se[ze&255]<<8^Se[ze>>24&255]^Ee[Te]<<24,Te+=1,Fe!=8)for(var Re=1;Re<Fe;Re++)Ie[Re]^=Ie[Re-1];else{for(var Re=1;Re<Fe/2;Re++)Ie[Re]^=Ie[Re-1];ze=Ie[Fe/2-1],Ie[Fe/2]^=Se[ze&255]^Se[ze>>8&255]<<8^Se[ze>>16&255]<<16^Se[ze>>24&255]<<24;for(var Re=Fe/2+1;Re<Fe;Re++)Ie[Re]^=Ie[Re-1]}for(var Re=0,Xe,Rt;Re<Fe&&De<Ne;)Xe=De>>2,Rt=De%4,this._Ke[Xe][Rt]=Ie[Re],this._Kd[be-Xe][Rt]=Ie[Re++],De++}for(var Xe=1;Xe<be;Xe++)for(var Rt=0;Rt<4;Rt++)ze=this._Kd[Xe][Rt],this._Kd[Xe][Rt]=Ve[ze>>24&255]^Ye[ze>>16&255]^Qe[ze>>8&255]^Ke[ze&255]},_e.prototype.encrypt=function(be){if(be.length!=16)throw new Error("invalid plaintext size (must be 16 bytes)");for(var Re=this._Ke.length-1,Ne=[0,0,0,0],Fe=Pt(be),Ie=0;Ie<4;Ie++)Fe[Ie]^=this._Ke[0][Ie];for(var je=1;je<Re;je++){for(var Ie=0;Ie<4;Ie++)Ne[Ie]=Be[Fe[Ie]>>24&255]^$e[Fe[(Ie+1)%4]>>16&255]^Ce[Fe[(Ie+2)%4]>>8&255]^ke[Fe[(Ie+3)%4]&255]^this._Ke[je][Ie];Fe=Ne.slice()}for(var Te=le(16),De,Ie=0;Ie<4;Ie++)De=this._Ke[Re][Ie],Te[4*Ie]=(Se[Fe[Ie]>>24&255]^De>>24)&255,Te[4*Ie+1]=(Se[Fe[(Ie+1)%4]>>16&255]^De>>16)&255,Te[4*Ie+2]=(Se[Fe[(Ie+2)%4]>>8&255]^De>>8)&255,Te[4*Ie+3]=(Se[Fe[(Ie+3)%4]&255]^De)&255;return Te},_e.prototype.decrypt=function(be){if(be.length!=16)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var Re=this._Kd.length-1,Ne=[0,0,0,0],Fe=Pt(be),Ie=0;Ie<4;Ie++)Fe[Ie]^=this._Kd[0][Ie];for(var je=1;je<Re;je++){for(var Ie=0;Ie<4;Ie++)Ne[Ie]=Pe[Fe[Ie]>>24&255]^Ue[Fe[(Ie+3)%4]>>16&255]^qe[Fe[(Ie+2)%4]>>8&255]^He[Fe[(Ie+1)%4]&255]^this._Kd[je][Ie];Fe=Ne.slice()}for(var Te=le(16),De,Ie=0;Ie<4;Ie++)De=this._Kd[Re][Ie],Te[4*Ie]=(Me[Fe[Ie]>>24&255]^De>>24)&255,Te[4*Ie+1]=(Me[Fe[(Ie+3)%4]>>16&255]^De>>16)&255,Te[4*Ie+2]=(Me[Fe[(Ie+2)%4]>>8&255]^De>>8)&255,Te[4*Ie+3]=(Me[Fe[(Ie+1)%4]&255]^De)&255;return Te};var se=function(be){if(!(this instanceof se))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new _e(be)};se.prototype.encrypt=function(be){if(be=ae(be),be.length%16!==0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var Re=le(be.length),Ne=le(16),Fe=0;Fe<be.length;Fe+=16)he(be,Ne,0,Fe,Fe+16),Ne=this._aes.encrypt(Ne),he(Ne,Re,Fe);return Re},se.prototype.decrypt=function(be){if(be=ae(be),be.length%16!==0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var Re=le(be.length),Ne=le(16),Fe=0;Fe<be.length;Fe+=16)he(be,Ne,0,Fe,Fe+16),Ne=this._aes.decrypt(Ne),he(Ne,Re,Fe);return Re};var ce=function(be,Re){if(!(this instanceof ce))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Block Chaining",this.name="cbc",!Re)Re=le(16);else if(Re.length!=16)throw new Error("invalid initialation vector size (must be 16 bytes)");this._lastCipherblock=ae(Re,!0),this._aes=new _e(be)};ce.prototype.encrypt=function(be){if(be=ae(be),be.length%16!==0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var Re=le(be.length),Ne=le(16),Fe=0;Fe<be.length;Fe+=16){he(be,Ne,0,Fe,Fe+16);for(var Ie=0;Ie<16;Ie++)Ne[Ie]^=this._lastCipherblock[Ie];this._lastCipherblock=this._aes.encrypt(Ne),he(this._lastCipherblock,Re,Fe)}return Re},ce.prototype.decrypt=function(be){if(be=ae(be),be.length%16!==0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var Re=le(be.length),Ne=le(16),Fe=0;Fe<be.length;Fe+=16){he(be,Ne,0,Fe,Fe+16),Ne=this._aes.decrypt(Ne);for(var Ie=0;Ie<16;Ie++)Re[Fe+Ie]=Ne[Ie]^this._lastCipherblock[Ie];he(be,this._lastCipherblock,0,Fe,Fe+16)}return Re};var de=function(be,Re,Ne){if(!(this instanceof de))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Feedback",this.name="cfb",!Re)Re=le(16);else if(Re.length!=16)throw new Error("invalid initialation vector size (must be 16 size)");Ne||(Ne=1),this.segmentSize=Ne,this._shiftRegister=ae(Re,!0),this._aes=new _e(be)};de.prototype.encrypt=function(be){if(be.length%this.segmentSize!=0)throw new Error("invalid plaintext size (must be segmentSize bytes)");for(var Re=ae(be,!0),Ne,Fe=0;Fe<Re.length;Fe+=this.segmentSize){Ne=this._aes.encrypt(this._shiftRegister);for(var Ie=0;Ie<this.segmentSize;Ie++)Re[Fe+Ie]^=Ne[Ie];he(this._shiftRegister,this._shiftRegister,0,this.segmentSize),he(Re,this._shiftRegister,16-this.segmentSize,Fe,Fe+this.segmentSize)}return Re},de.prototype.decrypt=function(be){if(be.length%this.segmentSize!=0)throw new Error("invalid ciphertext size (must be segmentSize bytes)");for(var Re=ae(be,!0),Ne,Fe=0;Fe<Re.length;Fe+=this.segmentSize){Ne=this._aes.encrypt(this._shiftRegister);for(var Ie=0;Ie<this.segmentSize;Ie++)Re[Fe+Ie]^=Ne[Ie];he(this._shiftRegister,this._shiftRegister,0,this.segmentSize),he(be,this._shiftRegister,16-this.segmentSize,Fe,Fe+this.segmentSize)}return Re};var pe=function(be,Re){if(!(this instanceof pe))throw Error("AES must be instanitated with `new`");if(this.description="Output Feedback",this.name="ofb",!Re)Re=le(16);else if(Re.length!=16)throw new Error("invalid initialation vector size (must be 16 bytes)");this._lastPrecipher=ae(Re,!0),this._lastPrecipherIndex=16,this._aes=new _e(be)};pe.prototype.encrypt=function(be){for(var Re=ae(be,!0),Ne=0;Ne<Re.length;Ne++)this._lastPrecipherIndex===16&&(this._lastPrecipher=this._aes.encrypt(this._lastPrecipher),this._lastPrecipherIndex=0),Re[Ne]^=this._lastPrecipher[this._lastPrecipherIndex++];return Re},pe.prototype.decrypt=pe.prototype.encrypt;var ve=function(be){if(!(this instanceof ve))throw Error("Counter must be instanitated with `new`");be!==0&&!be&&(be=1),typeof be=="number"?(this._counter=le(16),this.setValue(be)):this.setBytes(be)};ve.prototype.setValue=function(be){if(typeof be!="number"||parseInt(be)!=be)throw new Error("invalid counter value (must be an integer)");for(var Re=15;Re>=0;--Re)this._counter[Re]=be%256,be=be>>8},ve.prototype.setBytes=function(be){if(be=ae(be,!0),be.length!=16)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=be},ve.prototype.increment=function(){for(var be=15;be>=0;be--)if(this._counter[be]===255)this._counter[be]=0;else{this._counter[be]++;break}};var we=function(be,Re){if(!(this instanceof we))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",Re instanceof ve||(Re=new ve(Re)),this._counter=Re,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new _e(be)};we.prototype.encrypt=function(be){for(var Re=ae(be,!0),Ne=0;Ne<Re.length;Ne++)this._remainingCounterIndex===16&&(this._remainingCounter=this._aes.encrypt(this._counter._counter),this._remainingCounterIndex=0,this._counter.increment()),Re[Ne]^=this._remainingCounter[this._remainingCounterIndex++];return Re},we.prototype.decrypt=we.prototype.encrypt;function Ae(be){be=ae(be,!0);var Re=16-be.length%16,Ne=le(be.length+Re);he(be,Ne);for(var Fe=be.length;Fe<Ne.length;Fe++)Ne[Fe]=Re;return Ne}function ge(be){if(be=ae(be,!0),be.length<16)throw new Error("PKCS#7 invalid length");var Re=be[be.length-1];if(Re>16)throw new Error("PKCS#7 padding byte out of range");for(var Ne=be.length-Re,Fe=0;Fe<Re;Fe++)if(be[Ne+Fe]!==Re)throw new Error("PKCS#7 invalid padding byte");var Ie=le(Ne);return he(be,Ie,0,0,Ne),Ie}var ue={AES:_e,Counter:ve,ModeOfOperation:{ecb:se,cbc:ce,cfb:de,ofb:pe,ctr:we},utils:{hex:me,utf8:ye},padding:{pkcs7:{pad:Ae,strip:ge}},_arrayTest:{coerceArray:ae,createArray:le,copyArray:he}};c.exports=ue})()})(aesJs);var aesJsExports=aesJs.exports;const aes$1=getDefaultExportFromCjs$2(aesJsExports),version$c="json-wallets/5.8.0";function looseArrayify(c){return typeof c=="string"&&c.substring(0,2)!=="0x"&&(c="0x"+c),arrayify(c)}function zpad(c,t){for(c=String(c);c.length<t;)c="0"+c;return c}function getPassword(c){return typeof c=="string"?toUtf8Bytes(c,UnicodeNormalizationForm.NFKC):arrayify(c)}function searchPath(c,t){let n=c;const ie=t.toLowerCase().split("/");for(let fe=0;fe<ie.length;fe++){let ae=null;for(const le in n)if(le.toLowerCase()===ie[fe]){ae=n[le];break}if(ae===null)return null;n=ae}return n}function uuidV4(c){const t=arrayify(c);t[6]=t[6]&15|64,t[8]=t[8]&63|128;const n=hexlify(t);return[n.substring(2,10),n.substring(10,14),n.substring(14,18),n.substring(18,22),n.substring(22,34)].join("-")}const logger$a=new Logger(version$c);class CrowdsaleAccount extends Description{isCrowdsaleAccount(t){return!!(t&&t._isCrowdsaleAccount)}}function decrypt$1(c,t){const n=JSON.parse(c);t=getPassword(t);const ie=getAddress$1(searchPath(n,"ethaddr")),fe=looseArrayify(searchPath(n,"encseed"));(!fe||fe.length%16!==0)&&logger$a.throwArgumentError("invalid encseed","json",c);const ae=arrayify(pbkdf2$1(t,t,2e3,32,"sha256")).slice(0,16),le=fe.slice(0,16),he=fe.slice(16),ye=new aes$1.ModeOfOperation.cbc(ae,le),me=aes$1.padding.pkcs7.strip(arrayify(ye.decrypt(he)));let xe="";for(let Me=0;Me<me.length;Me++)xe+=String.fromCharCode(me[Me]);const Ee=toUtf8Bytes(xe),Se=keccak256$1(Ee);return new CrowdsaleAccount({_isCrowdsaleAccount:!0,address:ie,privateKey:Se})}function isCrowdsaleWallet(c){let t=null;try{t=JSON.parse(c)}catch{return!1}return t.encseed&&t.ethaddr}function isKeystoreWallet(c){let t=null;try{t=JSON.parse(c)}catch{return!1}return!(!t.version||parseInt(t.version)!==t.version||parseInt(t.version)!==3)}function getJsonWalletAddress(c){if(isCrowdsaleWallet(c))try{return getAddress$1(JSON.parse(c).ethaddr)}catch{return null}if(isKeystoreWallet(c))try{return getAddress$1(JSON.parse(c).address)}catch{return null}return null}var scrypt$1={exports:{}};(function(c,t){(function(n){function fe($e){const Ce=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]);let ke=1779033703,Pe=3144134277,Ue=1013904242,qe=2773480762,He=1359893119,Ve=2600822924,Ye=528734635,Qe=1541459225;const Ke=new Uint32Array(64);function Pt(we){let Ae=0,ge=we.length;for(;ge>=64;){let ue=ke,be=Pe,Re=Ue,Ne=qe,Fe=He,Ie=Ve,je=Ye,Te=Qe,De,ze,Xe,Rt,Oe;for(ze=0;ze<16;ze++)Xe=Ae+ze*4,Ke[ze]=(we[Xe]&255)<<24|(we[Xe+1]&255)<<16|(we[Xe+2]&255)<<8|we[Xe+3]&255;for(ze=16;ze<64;ze++)De=Ke[ze-2],Rt=(De>>>17|De<<15)^(De>>>19|De<<13)^De>>>10,De=Ke[ze-15],Oe=(De>>>7|De<<25)^(De>>>18|De<<14)^De>>>3,Ke[ze]=(Rt+Ke[ze-7]|0)+(Oe+Ke[ze-16]|0)|0;for(ze=0;ze<64;ze++)Rt=(((Fe>>>6|Fe<<26)^(Fe>>>11|Fe<<21)^(Fe>>>25|Fe<<7))+(Fe&Ie^~Fe&je)|0)+(Te+(Ce[ze]+Ke[ze]|0)|0)|0,Oe=((ue>>>2|ue<<30)^(ue>>>13|ue<<19)^(ue>>>22|ue<<10))+(ue&be^ue&Re^be&Re)|0,Te=je,je=Ie,Ie=Fe,Fe=Ne+Rt|0,Ne=Re,Re=be,be=ue,ue=Rt+Oe|0;ke=ke+ue|0,Pe=Pe+be|0,Ue=Ue+Re|0,qe=qe+Ne|0,He=He+Fe|0,Ve=Ve+Ie|0,Ye=Ye+je|0,Qe=Qe+Te|0,Ae+=64,ge-=64}}Pt($e);let _e,se=$e.length%64,ce=$e.length/536870912|0,de=$e.length<<3,pe=se<56?56:120,ve=$e.slice($e.length-se,$e.length);for(ve.push(128),_e=se+1;_e<pe;_e++)ve.push(0);return ve.push(ce>>>24&255),ve.push(ce>>>16&255),ve.push(ce>>>8&255),ve.push(ce>>>0&255),ve.push(de>>>24&255),ve.push(de>>>16&255),ve.push(de>>>8&255),ve.push(de>>>0&255),Pt(ve),[ke>>>24&255,ke>>>16&255,ke>>>8&255,ke>>>0&255,Pe>>>24&255,Pe>>>16&255,Pe>>>8&255,Pe>>>0&255,Ue>>>24&255,Ue>>>16&255,Ue>>>8&255,Ue>>>0&255,qe>>>24&255,qe>>>16&255,qe>>>8&255,qe>>>0&255,He>>>24&255,He>>>16&255,He>>>8&255,He>>>0&255,Ve>>>24&255,Ve>>>16&255,Ve>>>8&255,Ve>>>0&255,Ye>>>24&255,Ye>>>16&255,Ye>>>8&255,Ye>>>0&255,Qe>>>24&255,Qe>>>16&255,Qe>>>8&255,Qe>>>0&255]}function ae($e,Ce,ke){$e=$e.length<=64?$e:fe($e);const Pe=64+Ce.length+4,Ue=new Array(Pe),qe=new Array(64);let He,Ve=[];for(He=0;He<64;He++)Ue[He]=54;for(He=0;He<$e.length;He++)Ue[He]^=$e[He];for(He=0;He<Ce.length;He++)Ue[64+He]=Ce[He];for(He=Pe-4;He<Pe;He++)Ue[He]=0;for(He=0;He<64;He++)qe[He]=92;for(He=0;He<$e.length;He++)qe[He]^=$e[He];function Ye(){for(let Qe=Pe-1;Qe>=Pe-4;Qe--){if(Ue[Qe]++,Ue[Qe]<=255)return;Ue[Qe]=0}}for(;ke>=32;)Ye(),Ve=Ve.concat(fe(qe.concat(fe(Ue)))),ke-=32;return ke>0&&(Ye(),Ve=Ve.concat(fe(qe.concat(fe(Ue))).slice(0,ke))),Ve}function le($e,Ce,ke,Pe,Ue){let qe;for(xe($e,(2*ke-1)*16,Ue,0,16),qe=0;qe<2*ke;qe++)me($e,qe*16,Ue,16),ye(Ue,Pe),xe(Ue,0,$e,Ce+qe*16,16);for(qe=0;qe<ke;qe++)xe($e,Ce+qe*2*16,$e,qe*16,16);for(qe=0;qe<ke;qe++)xe($e,Ce+(qe*2+1)*16,$e,(qe+ke)*16,16)}function he($e,Ce){return $e<<Ce|$e>>>32-Ce}function ye($e,Ce){xe($e,0,Ce,0,16);for(let ke=8;ke>0;ke-=2)Ce[4]^=he(Ce[0]+Ce[12],7),Ce[8]^=he(Ce[4]+Ce[0],9),Ce[12]^=he(Ce[8]+Ce[4],13),Ce[0]^=he(Ce[12]+Ce[8],18),Ce[9]^=he(Ce[5]+Ce[1],7),Ce[13]^=he(Ce[9]+Ce[5],9),Ce[1]^=he(Ce[13]+Ce[9],13),Ce[5]^=he(Ce[1]+Ce[13],18),Ce[14]^=he(Ce[10]+Ce[6],7),Ce[2]^=he(Ce[14]+Ce[10],9),Ce[6]^=he(Ce[2]+Ce[14],13),Ce[10]^=he(Ce[6]+Ce[2],18),Ce[3]^=he(Ce[15]+Ce[11],7),Ce[7]^=he(Ce[3]+Ce[15],9),Ce[11]^=he(Ce[7]+Ce[3],13),Ce[15]^=he(Ce[11]+Ce[7],18),Ce[1]^=he(Ce[0]+Ce[3],7),Ce[2]^=he(Ce[1]+Ce[0],9),Ce[3]^=he(Ce[2]+Ce[1],13),Ce[0]^=he(Ce[3]+Ce[2],18),Ce[6]^=he(Ce[5]+Ce[4],7),Ce[7]^=he(Ce[6]+Ce[5],9),Ce[4]^=he(Ce[7]+Ce[6],13),Ce[5]^=he(Ce[4]+Ce[7],18),Ce[11]^=he(Ce[10]+Ce[9],7),Ce[8]^=he(Ce[11]+Ce[10],9),Ce[9]^=he(Ce[8]+Ce[11],13),Ce[10]^=he(Ce[9]+Ce[8],18),Ce[12]^=he(Ce[15]+Ce[14],7),Ce[13]^=he(Ce[12]+Ce[15],9),Ce[14]^=he(Ce[13]+Ce[12],13),Ce[15]^=he(Ce[14]+Ce[13],18);for(let ke=0;ke<16;++ke)$e[ke]+=Ce[ke]}function me($e,Ce,ke,Pe){for(let Ue=0;Ue<Pe;Ue++)ke[Ue]^=$e[Ce+Ue]}function xe($e,Ce,ke,Pe,Ue){for(;Ue--;)ke[Pe++]=$e[Ce++]}function Ee($e){if(!$e||typeof $e.length!="number")return!1;for(let Ce=0;Ce<$e.length;Ce++){const ke=$e[Ce];if(typeof ke!="number"||ke%1||ke<0||ke>=256)return!1}return!0}function Se($e,Ce){if(typeof $e!="number"||$e%1)throw new Error("invalid "+Ce);return $e}function Me($e,Ce,ke,Pe,Ue,qe,He){if(ke=Se(ke,"N"),Pe=Se(Pe,"r"),Ue=Se(Ue,"p"),qe=Se(qe,"dkLen"),ke===0||ke&ke-1)throw new Error("N must be power of 2");if(ke>2147483647/128/Pe)throw new Error("N too large");if(Pe>2147483647/128/Ue)throw new Error("r too large");if(!Ee($e))throw new Error("password must be an array or buffer");if($e=Array.prototype.slice.call($e),!Ee(Ce))throw new Error("salt must be an array or buffer");Ce=Array.prototype.slice.call(Ce);let Ve=ae($e,Ce,Ue*128*Pe);const Ye=new Uint32Array(Ue*32*Pe);for(let Fe=0;Fe<Ye.length;Fe++){const Ie=Fe*4;Ye[Fe]=(Ve[Ie+3]&255)<<24|(Ve[Ie+2]&255)<<16|(Ve[Ie+1]&255)<<8|(Ve[Ie+0]&255)<<0}const Qe=new Uint32Array(64*Pe),Ke=new Uint32Array(32*Pe*ke),Pt=32*Pe,_e=new Uint32Array(16),se=new Uint32Array(16),ce=Ue*ke*2;let de=0,pe=null,ve=!1,we=0,Ae=0,ge,ue;const be=He?parseInt(1e3/Pe):4294967295,Re=typeof setImmediate<"u"?setImmediate:setTimeout,Ne=function(){if(ve)return He(new Error("cancelled"),de/ce);let Fe;switch(we){case 0:ue=Ae*32*Pe,xe(Ye,ue,Qe,0,Pt),we=1,ge=0;case 1:Fe=ke-ge,Fe>be&&(Fe=be);for(let je=0;je<Fe;je++)xe(Qe,0,Ke,(ge+je)*Pt,Pt),le(Qe,Pt,Pe,_e,se);if(ge+=Fe,de+=Fe,He){const je=parseInt(1e3*de/ce);if(je!==pe){if(ve=He(null,de/ce),ve)break;pe=je}}if(ge<ke)break;ge=0,we=2;case 2:Fe=ke-ge,Fe>be&&(Fe=be);for(let je=0;je<Fe;je++){const Te=(2*Pe-1)*16,De=Qe[Te]&ke-1;me(Ke,De*Pt,Qe,Pt),le(Qe,Pt,Pe,_e,se)}if(ge+=Fe,de+=Fe,He){const je=parseInt(1e3*de/ce);if(je!==pe){if(ve=He(null,de/ce),ve)break;pe=je}}if(ge<ke)break;if(xe(Qe,0,Ye,ue,Pt),Ae++,Ae<Ue){we=0;break}Ve=[];for(let je=0;je<Ye.length;je++)Ve.push(Ye[je]>>0&255),Ve.push(Ye[je]>>8&255),Ve.push(Ye[je]>>16&255),Ve.push(Ye[je]>>24&255);const Ie=ae($e,Ve,qe);return He&&He(null,1,Ie),Ie}He&&Re(Ne)};if(!He)for(;;){const Fe=Ne();if(Fe!=null)return Fe}Ne()}const Be={scrypt:function($e,Ce,ke,Pe,Ue,qe,He){return new Promise(function(Ve,Ye){let Qe=0;He&&He(0),Me($e,Ce,ke,Pe,Ue,qe,function(Ke,Pt,_e){if(Ke)Ye(Ke);else if(_e)He&&Qe!==1&&He(1),Ve(new Uint8Array(_e));else if(He&&Pt!==Qe)return Qe=Pt,He(Pt)})})},syncScrypt:function($e,Ce,ke,Pe,Ue,qe){return new Uint8Array(Me($e,Ce,ke,Pe,Ue,qe))}};c.exports=Be})()})(scrypt$1);var scryptExports=scrypt$1.exports;const scrypt=getDefaultExportFromCjs$2(scryptExports);var __awaiter$g=function(c,t,n,ie){function fe(ae){return ae instanceof n?ae:new n(function(le){le(ae)})}return new(n||(n=Promise))(function(ae,le){function he(xe){try{me(ie.next(xe))}catch(Ee){le(Ee)}}function ye(xe){try{me(ie.throw(xe))}catch(Ee){le(Ee)}}function me(xe){xe.done?ae(xe.value):fe(xe.value).then(he,ye)}me((ie=ie.apply(c,t||[])).next())})};const logger$9=new Logger(version$c);function hasMnemonic$1(c){return c!=null&&c.mnemonic&&c.mnemonic.phrase}class KeystoreAccount extends Description{isKeystoreAccount(t){return!!(t&&t._isKeystoreAccount)}}function _decrypt(c,t,n){if(searchPath(c,"crypto/cipher")==="aes-128-ctr"){const fe=looseArrayify(searchPath(c,"crypto/cipherparams/iv")),ae=new aes$1.Counter(fe),le=new aes$1.ModeOfOperation.ctr(t,ae);return arrayify(le.decrypt(n))}return null}function _getAccount(c,t){const n=looseArrayify(searchPath(c,"crypto/ciphertext"));if(hexlify(keccak256$1(concat$1([t.slice(16,32),n]))).substring(2)!==searchPath(c,"crypto/mac").toLowerCase())throw new Error("invalid password");const fe=_decrypt(c,t.slice(0,16),n);fe||logger$9.throwError("unsupported cipher",Logger.errors.UNSUPPORTED_OPERATION,{operation:"decrypt"});const ae=t.slice(32,64),le=computeAddress(fe);if(c.address){let ye=c.address.toLowerCase();if(ye.substring(0,2)!=="0x"&&(ye="0x"+ye),getAddress$1(ye)!==le)throw new Error("address mismatch")}const he={_isKeystoreAccount:!0,address:le,privateKey:hexlify(fe)};if(searchPath(c,"x-ethers/version")==="0.1"){const ye=looseArrayify(searchPath(c,"x-ethers/mnemonicCiphertext")),me=looseArrayify(searchPath(c,"x-ethers/mnemonicCounter")),xe=new aes$1.Counter(me),Ee=new aes$1.ModeOfOperation.ctr(ae,xe),Se=searchPath(c,"x-ethers/path")||defaultPath,Me=searchPath(c,"x-ethers/locale")||"en",Be=arrayify(Ee.decrypt(ye));try{const $e=entropyToMnemonic(Be,Me),Ce=HDNode.fromMnemonic($e,null,Me).derivePath(Se);if(Ce.privateKey!=he.privateKey)throw new Error("mnemonic mismatch");he.mnemonic=Ce.mnemonic}catch($e){if($e.code!==Logger.errors.INVALID_ARGUMENT||$e.argument!=="wordlist")throw $e}}return new KeystoreAccount(he)}function pbkdf2Sync(c,t,n,ie,fe){return arrayify(pbkdf2$1(c,t,n,ie,fe))}function pbkdf2(c,t,n,ie,fe){return Promise.resolve(pbkdf2Sync(c,t,n,ie,fe))}function _computeKdfKey(c,t,n,ie,fe){const ae=getPassword(t),le=searchPath(c,"crypto/kdf");if(le&&typeof le=="string"){const he=function(ye,me){return logger$9.throwArgumentError("invalid key-derivation function parameters",ye,me)};if(le.toLowerCase()==="scrypt"){const ye=looseArrayify(searchPath(c,"crypto/kdfparams/salt")),me=parseInt(searchPath(c,"crypto/kdfparams/n")),xe=parseInt(searchPath(c,"crypto/kdfparams/r")),Ee=parseInt(searchPath(c,"crypto/kdfparams/p"));(!me||!xe||!Ee)&&he("kdf",le),me&me-1&&he("N",me);const Se=parseInt(searchPath(c,"crypto/kdfparams/dklen"));return Se!==32&&he("dklen",Se),ie(ae,ye,me,xe,Ee,64,fe)}else if(le.toLowerCase()==="pbkdf2"){const ye=looseArrayify(searchPath(c,"crypto/kdfparams/salt"));let me=null;const xe=searchPath(c,"crypto/kdfparams/prf");xe==="hmac-sha256"?me="sha256":xe==="hmac-sha512"?me="sha512":he("prf",xe);const Ee=parseInt(searchPath(c,"crypto/kdfparams/c")),Se=parseInt(searchPath(c,"crypto/kdfparams/dklen"));return Se!==32&&he("dklen",Se),n(ae,ye,Ee,Se,me)}}return logger$9.throwArgumentError("unsupported key-derivation function","kdf",le)}function decryptSync(c,t){const n=JSON.parse(c),ie=_computeKdfKey(n,t,pbkdf2Sync,scrypt.syncScrypt);return _getAccount(n,ie)}function decrypt(c,t,n){return __awaiter$g(this,void 0,void 0,function*(){const ie=JSON.parse(c),fe=yield _computeKdfKey(ie,t,pbkdf2,scrypt.scrypt,n);return _getAccount(ie,fe)})}function encrypt(c,t,n,ie){try{if(getAddress$1(c.address)!==computeAddress(c.privateKey))throw new Error("address/privateKey mismatch");if(hasMnemonic$1(c)){const Ce=c.mnemonic;if(HDNode.fromMnemonic(Ce.phrase,null,Ce.locale).derivePath(Ce.path||defaultPath).privateKey!=c.privateKey)throw new Error("mnemonic mismatch")}}catch(Ce){return Promise.reject(Ce)}typeof n=="function"&&!ie&&(ie=n,n={}),n||(n={});const fe=arrayify(c.privateKey),ae=getPassword(t);let le=null,he=null,ye=null;if(hasMnemonic$1(c)){const Ce=c.mnemonic;le=arrayify(mnemonicToEntropy(Ce.phrase,Ce.locale||"en")),he=Ce.path||defaultPath,ye=Ce.locale||"en"}let me=n.client;me||(me="ethers.js");let xe=null;n.salt?xe=arrayify(n.salt):xe=randomBytes$1(32);let Ee=null;if(n.iv){if(Ee=arrayify(n.iv),Ee.length!==16)throw new Error("invalid iv")}else Ee=randomBytes$1(16);let Se=null;if(n.uuid){if(Se=arrayify(n.uuid),Se.length!==16)throw new Error("invalid uuid")}else Se=randomBytes$1(16);let Me=1<<17,Be=8,$e=1;return n.scrypt&&(n.scrypt.N&&(Me=n.scrypt.N),n.scrypt.r&&(Be=n.scrypt.r),n.scrypt.p&&($e=n.scrypt.p)),scrypt.scrypt(ae,xe,Me,Be,$e,64,ie).then(Ce=>{Ce=arrayify(Ce);const ke=Ce.slice(0,16),Pe=Ce.slice(16,32),Ue=Ce.slice(32,64),qe=new aes$1.Counter(Ee),He=new aes$1.ModeOfOperation.ctr(ke,qe),Ve=arrayify(He.encrypt(fe)),Ye=keccak256$1(concat$1([Pe,Ve])),Qe={address:c.address.substring(2).toLowerCase(),id:uuidV4(Se),version:3,crypto:{cipher:"aes-128-ctr",cipherparams:{iv:hexlify(Ee).substring(2)},ciphertext:hexlify(Ve).substring(2),kdf:"scrypt",kdfparams:{salt:hexlify(xe).substring(2),n:Me,dklen:32,p:$e,r:Be},mac:Ye.substring(2)}};if(le){const Ke=randomBytes$1(16),Pt=new aes$1.Counter(Ke),_e=new aes$1.ModeOfOperation.ctr(Ue,Pt),se=arrayify(_e.encrypt(le)),ce=new Date,de=ce.getUTCFullYear()+"-"+zpad(ce.getUTCMonth()+1,2)+"-"+zpad(ce.getUTCDate(),2)+"T"+zpad(ce.getUTCHours(),2)+"-"+zpad(ce.getUTCMinutes(),2)+"-"+zpad(ce.getUTCSeconds(),2)+".0Z";Qe["x-ethers"]={client:me,gethFilename:"UTC--"+de+"--"+Qe.address,mnemonicCounter:hexlify(Ke).substring(2),mnemonicCiphertext:hexlify(se).substring(2),path:he,locale:ye,version:"0.1"}}return JSON.stringify(Qe)})}function decryptJsonWallet(c,t,n){if(isCrowdsaleWallet(c)){n&&n(0);const ie=decrypt$1(c,t);return n&&n(1),Promise.resolve(ie)}return isKeystoreWallet(c)?decrypt(c,t,n):Promise.reject(new Error("invalid JSON wallet"))}function decryptJsonWalletSync(c,t){if(isCrowdsaleWallet(c))return decrypt$1(c,t);if(isKeystoreWallet(c))return decryptSync(c,t);throw new Error("invalid JSON wallet")}const lib_esm$4=Object.freeze(Object.defineProperty({__proto__:null,decryptCrowdsale:decrypt$1,decryptJsonWallet,decryptJsonWalletSync,decryptKeystore:decrypt,decryptKeystoreSync:decryptSync,encryptKeystore:encrypt,getJsonWalletAddress,isCrowdsaleWallet,isKeystoreWallet},Symbol.toStringTag,{value:"Module"})),version$b="wallet/5.8.0";var __awaiter$f=function(c,t,n,ie){function fe(ae){return ae instanceof n?ae:new n(function(le){le(ae)})}return new(n||(n=Promise))(function(ae,le){function he(xe){try{me(ie.next(xe))}catch(Ee){le(Ee)}}function ye(xe){try{me(ie.throw(xe))}catch(Ee){le(Ee)}}function me(xe){xe.done?ae(xe.value):fe(xe.value).then(he,ye)}me((ie=ie.apply(c,t||[])).next())})};const logger$8=new Logger(version$b);function isAccount(c){return c!=null&&isHexString(c.privateKey,32)&&c.address!=null}function hasMnemonic(c){const t=c.mnemonic;return t&&t.phrase}class Wallet extends Signer{constructor(t,n){if(super(),isAccount(t)){const ie=new SigningKey(t.privateKey);if(defineReadOnly(this,"_signingKey",()=>ie),defineReadOnly(this,"address",computeAddress(this.publicKey)),this.address!==getAddress$1(t.address)&&logger$8.throwArgumentError("privateKey/address mismatch","privateKey","[REDACTED]"),hasMnemonic(t)){const fe=t.mnemonic;defineReadOnly(this,"_mnemonic",()=>({phrase:fe.phrase,path:fe.path||defaultPath,locale:fe.locale||"en"}));const ae=this.mnemonic,le=HDNode.fromMnemonic(ae.phrase,null,ae.locale).derivePath(ae.path);computeAddress(le.privateKey)!==this.address&&logger$8.throwArgumentError("mnemonic/address mismatch","privateKey","[REDACTED]")}else defineReadOnly(this,"_mnemonic",()=>null)}else{if(SigningKey.isSigningKey(t))t.curve!=="secp256k1"&&logger$8.throwArgumentError("unsupported curve; must be secp256k1","privateKey","[REDACTED]"),defineReadOnly(this,"_signingKey",()=>t);else{typeof t=="string"&&t.match(/^[0-9a-f]*$/i)&&t.length===64&&(t="0x"+t);const ie=new SigningKey(t);defineReadOnly(this,"_signingKey",()=>ie)}defineReadOnly(this,"_mnemonic",()=>null),defineReadOnly(this,"address",computeAddress(this.publicKey))}n&&!Provider.isProvider(n)&&logger$8.throwArgumentError("invalid provider","provider",n),defineReadOnly(this,"provider",n||null)}get mnemonic(){return this._mnemonic()}get privateKey(){return this._signingKey().privateKey}get publicKey(){return this._signingKey().publicKey}getAddress(){return Promise.resolve(this.address)}connect(t){return new Wallet(this,t)}signTransaction(t){return resolveProperties(t).then(n=>{n.from!=null&&(getAddress$1(n.from)!==this.address&&logger$8.throwArgumentError("transaction from address mismatch","transaction.from",t.from),delete n.from);const ie=this._signingKey().signDigest(keccak256$1(serialize$1(n)));return serialize$1(n,ie)})}signMessage(t){return __awaiter$f(this,void 0,void 0,function*(){return joinSignature(this._signingKey().signDigest(hashMessage(t)))})}_signTypedData(t,n,ie){return __awaiter$f(this,void 0,void 0,function*(){const fe=yield TypedDataEncoder.resolveNames(t,n,ie,ae=>(this.provider==null&&logger$8.throwError("cannot resolve ENS names without a provider",Logger.errors.UNSUPPORTED_OPERATION,{operation:"resolveName",value:ae}),this.provider.resolveName(ae)));return joinSignature(this._signingKey().signDigest(TypedDataEncoder.hash(fe.domain,n,fe.value)))})}encrypt(t,n,ie){if(typeof n=="function"&&!ie&&(ie=n,n={}),ie&&typeof ie!="function")throw new Error("invalid callback");return n||(n={}),encrypt(this,t,n,ie)}static createRandom(t){let n=randomBytes$1(16);t||(t={}),t.extraEntropy&&(n=arrayify(hexDataSlice(keccak256$1(concat$1([n,t.extraEntropy])),0,16)));const ie=entropyToMnemonic(n,t.locale);return Wallet.fromMnemonic(ie,t.path,t.locale)}static fromEncryptedJson(t,n,ie){return decryptJsonWallet(t,n,ie).then(fe=>new Wallet(fe))}static fromEncryptedJsonSync(t,n){return new Wallet(decryptJsonWalletSync(t,n))}static fromMnemonic(t,n,ie){return n||(n=defaultPath),new Wallet(HDNode.fromMnemonic(t,null,ie).derivePath(n))}}function verifyMessage(c,t){return recoverAddress(hashMessage(c),t)}function verifyTypedData(c,t,n,ie){return recoverAddress(TypedDataEncoder.hash(c,t,n),ie)}const lib_esm$3=Object.freeze(Object.defineProperty({__proto__:null,Wallet,verifyMessage,verifyTypedData},Symbol.toStringTag,{value:"Module"})),version$a="networks/5.8.0",logger$7=new Logger(version$a);function isRenetworkable(c){return c&&typeof c.renetwork=="function"}function ethDefaultProvider(c){const t=function(n,ie){ie==null&&(ie={});const fe=[];if(n.InfuraProvider&&ie.infura!=="-")try{fe.push(new n.InfuraProvider(c,ie.infura))}catch{}if(n.EtherscanProvider&&ie.etherscan!=="-")try{fe.push(new n.EtherscanProvider(c,ie.etherscan))}catch{}if(n.AlchemyProvider&&ie.alchemy!=="-")try{fe.push(new n.AlchemyProvider(c,ie.alchemy))}catch{}if(n.PocketProvider&&ie.pocket!=="-"){const ae=["goerli","ropsten","rinkeby","sepolia"];try{const le=new n.PocketProvider(c,ie.pocket);le.network&&ae.indexOf(le.network.name)===-1&&fe.push(le)}catch{}}if(n.CloudflareProvider&&ie.cloudflare!=="-")try{fe.push(new n.CloudflareProvider(c))}catch{}if(n.AnkrProvider&&ie.ankr!=="-")try{const ae=["ropsten"],le=new n.AnkrProvider(c,ie.ankr);le.network&&ae.indexOf(le.network.name)===-1&&fe.push(le)}catch{}if(n.QuickNodeProvider&&ie.quicknode!=="-")try{fe.push(new n.QuickNodeProvider(c,ie.quicknode))}catch{}if(fe.length===0)return null;if(n.FallbackProvider){let ae=1;return ie.quorum!=null?ae=ie.quorum:c==="homestead"&&(ae=2),new n.FallbackProvider(fe,ae)}return fe[0]};return t.renetwork=function(n){return ethDefaultProvider(n)},t}function etcDefaultProvider(c,t){const n=function(ie,fe){return ie.JsonRpcProvider?new ie.JsonRpcProvider(c,t):null};return n.renetwork=function(ie){return etcDefaultProvider(c,ie)},n}const homestead={chainId:1,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"homestead",_defaultProvider:ethDefaultProvider("homestead")},ropsten={chainId:3,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"ropsten",_defaultProvider:ethDefaultProvider("ropsten")},classicMordor={chainId:63,name:"classicMordor",_defaultProvider:etcDefaultProvider("https://www.ethercluster.com/mordor","classicMordor")},networks$2={unspecified:{chainId:0,name:"unspecified"},homestead,mainnet:homestead,morden:{chainId:2,name:"morden"},ropsten,testnet:ropsten,rinkeby:{chainId:4,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"rinkeby",_defaultProvider:ethDefaultProvider("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:ethDefaultProvider("kovan")},goerli:{chainId:5,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"goerli",_defaultProvider:ethDefaultProvider("goerli")},kintsugi:{chainId:1337702,name:"kintsugi"},sepolia:{chainId:11155111,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"sepolia",_defaultProvider:ethDefaultProvider("sepolia")},holesky:{chainId:17e3,name:"holesky",_defaultProvider:ethDefaultProvider("holesky")},classic:{chainId:61,name:"classic",_defaultProvider:etcDefaultProvider("https://www.ethercluster.com/etc","classic")},classicMorden:{chainId:62,name:"classicMorden"},classicMordor,classicTestnet:classicMordor,classicKotti:{chainId:6,name:"classicKotti",_defaultProvider:etcDefaultProvider("https://www.ethercluster.com/kotti","classicKotti")},xdai:{chainId:100,name:"xdai"},matic:{chainId:137,name:"matic",_defaultProvider:ethDefaultProvider("matic")},maticmum:{chainId:80001,name:"maticmum",_defaultProvider:ethDefaultProvider("maticmum")},optimism:{chainId:10,name:"optimism",_defaultProvider:ethDefaultProvider("optimism")},"optimism-kovan":{chainId:69,name:"optimism-kovan"},"optimism-goerli":{chainId:420,name:"optimism-goerli"},"optimism-sepolia":{chainId:11155420,name:"optimism-sepolia"},arbitrum:{chainId:42161,name:"arbitrum"},"arbitrum-rinkeby":{chainId:421611,name:"arbitrum-rinkeby"},"arbitrum-goerli":{chainId:421613,name:"arbitrum-goerli"},"arbitrum-sepolia":{chainId:421614,name:"arbitrum-sepolia"},bnb:{chainId:56,name:"bnb"},bnbt:{chainId:97,name:"bnbt"}};function getNetwork(c){if(c==null)return null;if(typeof c=="number"){for(const ie in networks$2){const fe=networks$2[ie];if(fe.chainId===c)return{name:fe.name,chainId:fe.chainId,ensAddress:fe.ensAddress||null,_defaultProvider:fe._defaultProvider||null}}return{chainId:c,name:"unknown"}}if(typeof c=="string"){const ie=networks$2[c];return ie==null?null:{name:ie.name,chainId:ie.chainId,ensAddress:ie.ensAddress,_defaultProvider:ie._defaultProvider||null}}const t=networks$2[c.name];if(!t)return typeof c.chainId!="number"&&logger$7.throwArgumentError("invalid network chainId","network",c),c;c.chainId!==0&&c.chainId!==t.chainId&&logger$7.throwArgumentError("network chainId mismatch","network",c);let n=c._defaultProvider||null;return n==null&&t._defaultProvider&&(isRenetworkable(t._defaultProvider)?n=t._defaultProvider.renetwork(c):n=t._defaultProvider),{name:c.name,chainId:t.chainId,ensAddress:c.ensAddress||t.ensAddress||null,_defaultProvider:n}}const version$9="web/5.8.0";var __awaiter$e=function(c,t,n,ie){function fe(ae){return ae instanceof n?ae:new n(function(le){le(ae)})}return new(n||(n=Promise))(function(ae,le){function he(xe){try{me(ie.next(xe))}catch(Ee){le(Ee)}}function ye(xe){try{me(ie.throw(xe))}catch(Ee){le(Ee)}}function me(xe){xe.done?ae(xe.value):fe(xe.value).then(he,ye)}me((ie=ie.apply(c,t||[])).next())})};function getUrl(c,t){return __awaiter$e(this,void 0,void 0,function*(){t==null&&(t={});const n={method:t.method||"GET",headers:t.headers||{},body:t.body||void 0};if(t.skipFetchSetup!==!0&&(n.mode="cors",n.cache="no-cache",n.credentials="same-origin",n.redirect="follow",n.referrer="client"),t.fetchOptions!=null){const le=t.fetchOptions;le.mode&&(n.mode=le.mode),le.cache&&(n.cache=le.cache),le.credentials&&(n.credentials=le.credentials),le.redirect&&(n.redirect=le.redirect),le.referrer&&(n.referrer=le.referrer)}const ie=yield fetch(c,n),fe=yield ie.arrayBuffer(),ae={};return ie.headers.forEach?ie.headers.forEach((le,he)=>{ae[he.toLowerCase()]=le}):ie.headers.keys().forEach(le=>{ae[le.toLowerCase()]=ie.headers.get(le)}),{headers:ae,statusCode:ie.status,statusMessage:ie.statusText,body:arrayify(new Uint8Array(fe))}})}var __awaiter$d=function(c,t,n,ie){function fe(ae){return ae instanceof n?ae:new n(function(le){le(ae)})}return new(n||(n=Promise))(function(ae,le){function he(xe){try{me(ie.next(xe))}catch(Ee){le(Ee)}}function ye(xe){try{me(ie.throw(xe))}catch(Ee){le(Ee)}}function me(xe){xe.done?ae(xe.value):fe(xe.value).then(he,ye)}me((ie=ie.apply(c,t||[])).next())})};const logger$6=new Logger(version$9);function staller(c){return new Promise(t=>{setTimeout(t,c)})}function bodyify(c,t){if(c==null)return null;if(typeof c=="string")return c;if(isBytesLike(c)){if(t&&(t.split("/")[0]==="text"||t.split(";")[0].trim()==="application/json"))try{return toUtf8String(c)}catch{}return hexlify(c)}return c}function unpercent(c){return toUtf8Bytes(c.replace(/%([0-9a-f][0-9a-f])/gi,(t,n)=>String.fromCharCode(parseInt(n,16))))}function _fetchData(c,t,n){const ie=typeof c=="object"&&c.throttleLimit!=null?c.throttleLimit:12;logger$6.assertArgument(ie>0&&ie%1===0,"invalid connection throttle limit","connection.throttleLimit",ie);const fe=typeof c=="object"?c.throttleCallback:null,ae=typeof c=="object"&&typeof c.throttleSlotInterval=="number"?c.throttleSlotInterval:100;logger$6.assertArgument(ae>0&&ae%1===0,"invalid connection throttle slot interval","connection.throttleSlotInterval",ae);const le=typeof c=="object"?!!c.errorPassThrough:!1,he={};let ye=null;const me={method:"GET"};let xe=!1,Ee=2*60*1e3;if(typeof c=="string")ye=c;else if(typeof c=="object"){if((c==null||c.url==null)&&logger$6.throwArgumentError("missing URL","connection.url",c),ye=c.url,typeof c.timeout=="number"&&c.timeout>0&&(Ee=c.timeout),c.headers)for(const ke in c.headers)he[ke.toLowerCase()]={key:ke,value:String(c.headers[ke])},["if-none-match","if-modified-since"].indexOf(ke.toLowerCase())>=0&&(xe=!0);if(me.allowGzip=!!c.allowGzip,c.user!=null&&c.password!=null){ye.substring(0,6)!=="https:"&&c.allowInsecureAuthentication!==!0&&logger$6.throwError("basic authentication requires a secure https url",Logger.errors.INVALID_ARGUMENT,{argument:"url",url:ye,user:c.user,password:"[REDACTED]"});const ke=c.user+":"+c.password;he.authorization={key:"Authorization",value:"Basic "+encode$5(toUtf8Bytes(ke))}}c.skipFetchSetup!=null&&(me.skipFetchSetup=!!c.skipFetchSetup),c.fetchOptions!=null&&(me.fetchOptions=shallowCopy(c.fetchOptions))}const Se=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),Me=ye?ye.match(Se):null;if(Me)try{const ke={statusCode:200,statusMessage:"OK",headers:{"content-type":Me[1]||"text/plain"},body:Me[2]?decode$6(Me[3]):unpercent(Me[3])};let Pe=ke.body;return n&&(Pe=n(ke.body,ke)),Promise.resolve(Pe)}catch(ke){logger$6.throwError("processing response error",Logger.errors.SERVER_ERROR,{body:bodyify(Me[1],Me[2]),error:ke,requestBody:null,requestMethod:"GET",url:ye})}t&&(me.method="POST",me.body=t,he["content-type"]==null&&(he["content-type"]={key:"Content-Type",value:"application/octet-stream"}),he["content-length"]==null&&(he["content-length"]={key:"Content-Length",value:String(t.length)}));const Be={};Object.keys(he).forEach(ke=>{const Pe=he[ke];Be[Pe.key]=Pe.value}),me.headers=Be;const $e=function(){let ke=null;return{promise:new Promise(function(qe,He){Ee&&(ke=setTimeout(()=>{ke!=null&&(ke=null,He(logger$6.makeError("timeout",Logger.errors.TIMEOUT,{requestBody:bodyify(me.body,Be["content-type"]),requestMethod:me.method,timeout:Ee,url:ye})))},Ee))}),cancel:function(){ke!=null&&(clearTimeout(ke),ke=null)}}}(),Ce=function(){return __awaiter$d(this,void 0,void 0,function*(){for(let ke=0;ke<ie;ke++){let Pe=null;try{if(Pe=yield getUrl(ye,me),ke<ie){if(Pe.statusCode===301||Pe.statusCode===302){const qe=Pe.headers.location||"";if(me.method==="GET"&&qe.match(/^https:/)){ye=Pe.headers.location;continue}}else if(Pe.statusCode===429){let qe=!0;if(fe&&(qe=yield fe(ke,ye)),qe){let He=0;const Ve=Pe.headers["retry-after"];typeof Ve=="string"&&Ve.match(/^[1-9][0-9]*$/)?He=parseInt(Ve)*1e3:He=ae*parseInt(String(Math.random()*Math.pow(2,ke))),yield staller(He);continue}}}}catch(qe){Pe=qe.response,Pe==null&&($e.cancel(),logger$6.throwError("missing response",Logger.errors.SERVER_ERROR,{requestBody:bodyify(me.body,Be["content-type"]),requestMethod:me.method,serverError:qe,url:ye}))}let Ue=Pe.body;if(xe&&Pe.statusCode===304?Ue=null:!le&&(Pe.statusCode<200||Pe.statusCode>=300)&&($e.cancel(),logger$6.throwError("bad response",Logger.errors.SERVER_ERROR,{status:Pe.statusCode,headers:Pe.headers,body:bodyify(Ue,Pe.headers?Pe.headers["content-type"]:null),requestBody:bodyify(me.body,Be["content-type"]),requestMethod:me.method,url:ye})),n)try{const qe=yield n(Ue,Pe);return $e.cancel(),qe}catch(qe){if(qe.throttleRetry&&ke<ie){let He=!0;if(fe&&(He=yield fe(ke,ye)),He){const Ve=ae*parseInt(String(Math.random()*Math.pow(2,ke)));yield staller(Ve);continue}}$e.cancel(),logger$6.throwError("processing response error",Logger.errors.SERVER_ERROR,{body:bodyify(Ue,Pe.headers?Pe.headers["content-type"]:null),error:qe,requestBody:bodyify(me.body,Be["content-type"]),requestMethod:me.method,url:ye})}return $e.cancel(),Ue}return logger$6.throwError("failed response",Logger.errors.SERVER_ERROR,{requestBody:bodyify(me.body,Be["content-type"]),requestMethod:me.method,url:ye})})}();return Promise.race([$e.promise,Ce])}function fetchJson(c,t,n){let ie=(ae,le)=>{let he=null;if(ae!=null)try{he=JSON.parse(toUtf8String(ae))}catch(ye){logger$6.throwError("invalid JSON",Logger.errors.SERVER_ERROR,{body:ae,error:ye})}return n&&(he=n(he,le)),he},fe=null;if(t!=null){fe=toUtf8Bytes(t);const ae=typeof c=="string"?{url:c}:shallowCopy(c);ae.headers?Object.keys(ae.headers).filter(he=>he.toLowerCase()==="content-type").length!==0||(ae.headers=shallowCopy(ae.headers),ae.headers["content-type"]="application/json"):ae.headers={"content-type":"application/json"},c=ae}return _fetchData(c,fe,ie)}function poll(c,t){return t||(t={}),t=shallowCopy(t),t.floor==null&&(t.floor=0),t.ceiling==null&&(t.ceiling=1e4),t.interval==null&&(t.interval=250),new Promise(function(n,ie){let fe=null,ae=!1;const le=()=>ae?!1:(ae=!0,fe&&clearTimeout(fe),!0);t.timeout&&(fe=setTimeout(()=>{le()&&ie(new Error("timeout"))},t.timeout));const he=t.retryLimit;let ye=0;function me(){return c().then(function(xe){if(xe!==void 0)le()&&n(xe);else if(t.oncePoll)t.oncePoll.once("poll",me);else if(t.onceBlock)t.onceBlock.once("block",me);else if(!ae){if(ye++,ye>he){le()&&ie(new Error("retry limit reached"));return}let Ee=t.interval*parseInt(String(Math.random()*Math.pow(2,ye)));Ee<t.floor&&(Ee=t.floor),Ee>t.ceiling&&(Ee=t.ceiling),setTimeout(me,Ee)}return null},function(xe){le()&&ie(xe)})}me()})}const lib_esm$2=Object.freeze(Object.defineProperty({__proto__:null,_fetchData,fetchJson,poll},Symbol.toStringTag,{value:"Module"}));var ALPHABET$2="qpzry9x8gf2tvdw0s3jn54khce6mua7l",ALPHABET_MAP$1={};for(var z$3=0;z$3<ALPHABET$2.length;z$3++){var x$2=ALPHABET$2.charAt(z$3);if(ALPHABET_MAP$1[x$2]!==void 0)throw new TypeError(x$2+" is ambiguous");ALPHABET_MAP$1[x$2]=z$3}function polymodStep$1(c){var t=c>>25;return(c&33554431)<<5^-(t>>0&1)&996825010^-(t>>1&1)&642813549^-(t>>2&1)&513874426^-(t>>3&1)&1027748829^-(t>>4&1)&705979059}function prefixChk$1(c){for(var t=1,n=0;n<c.length;++n){var ie=c.charCodeAt(n);if(ie<33||ie>126)return"Invalid prefix ("+c+")";t=polymodStep$1(t)^ie>>5}for(t=polymodStep$1(t),n=0;n<c.length;++n){var fe=c.charCodeAt(n);t=polymodStep$1(t)^fe&31}return t}function encode$4(c,t,n){if(n=n||90,c.length+7+t.length>n)throw new TypeError("Exceeds length limit");c=c.toLowerCase();var ie=prefixChk$1(c);if(typeof ie=="string")throw new Error(ie);for(var fe=c+"1",ae=0;ae<t.length;++ae){var le=t[ae];if(le>>5)throw new Error("Non 5-bit word");ie=polymodStep$1(ie)^le,fe+=ALPHABET$2.charAt(le)}for(ae=0;ae<6;++ae)ie=polymodStep$1(ie);for(ie^=1,ae=0;ae<6;++ae){var he=ie>>(5-ae)*5&31;fe+=ALPHABET$2.charAt(he)}return fe}function __decode(c,t){if(t=t||90,c.length<8)return c+" too short";if(c.length>t)return"Exceeds length limit";var n=c.toLowerCase(),ie=c.toUpperCase();if(c!==n&&c!==ie)return"Mixed-case string "+c;c=n;var fe=c.lastIndexOf("1");if(fe===-1)return"No separator character for "+c;if(fe===0)return"Missing prefix for "+c;var ae=c.slice(0,fe),le=c.slice(fe+1);if(le.length<6)return"Data too short";var he=prefixChk$1(ae);if(typeof he=="string")return he;for(var ye=[],me=0;me<le.length;++me){var xe=le.charAt(me),Ee=ALPHABET_MAP$1[xe];if(Ee===void 0)return"Unknown character "+xe;he=polymodStep$1(he)^Ee,!(me+6>=le.length)&&ye.push(Ee)}return he!==1?"Invalid checksum for "+c:{prefix:ae,words:ye}}function decodeUnsafe(){var c=__decode.apply(null,arguments);if(typeof c=="object")return c}function decode$5(c){var t=__decode.apply(null,arguments);if(typeof t=="object")return t;throw new Error(t)}function convert$1(c,t,n,ie){for(var fe=0,ae=0,le=(1<<n)-1,he=[],ye=0;ye<c.length;++ye)for(fe=fe<<t|c[ye],ae+=t;ae>=n;)ae-=n,he.push(fe>>ae&le);if(ie)ae>0&&he.push(fe<<n-ae&le);else{if(ae>=t)return"Excess padding";if(fe<<n-ae&le)return"Non-zero padding"}return he}function toWordsUnsafe(c){var t=convert$1(c,8,5,!0);if(Array.isArray(t))return t}function toWords$1(c){var t=convert$1(c,8,5,!0);if(Array.isArray(t))return t;throw new Error(t)}function fromWordsUnsafe$1(c){var t=convert$1(c,5,8,!1);if(Array.isArray(t))return t}function fromWords$1(c){var t=convert$1(c,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}var bech32$1={decodeUnsafe,decode:decode$5,encode:encode$4,toWordsUnsafe,toWords:toWords$1,fromWordsUnsafe:fromWordsUnsafe$1,fromWords:fromWords$1};const bech32$2=getDefaultExportFromCjs$2(bech32$1),version$8="providers/5.8.0",logger$5=new Logger(version$8);class Formatter{constructor(){this.formats=this.getDefaultFormats()}getDefaultFormats(){const t={},n=this.address.bind(this),ie=this.bigNumber.bind(this),fe=this.blockTag.bind(this),ae=this.data.bind(this),le=this.hash.bind(this),he=this.hex.bind(this),ye=this.number.bind(this),me=this.type.bind(this),xe=Ee=>this.data(Ee,!0);return t.transaction={hash:le,type:me,accessList:Formatter.allowNull(this.accessList.bind(this),null),blockHash:Formatter.allowNull(le,null),blockNumber:Formatter.allowNull(ye,null),transactionIndex:Formatter.allowNull(ye,null),confirmations:Formatter.allowNull(ye,null),from:n,gasPrice:Formatter.allowNull(ie),maxPriorityFeePerGas:Formatter.allowNull(ie),maxFeePerGas:Formatter.allowNull(ie),gasLimit:ie,to:Formatter.allowNull(n,null),value:ie,nonce:ye,data:ae,r:Formatter.allowNull(this.uint256),s:Formatter.allowNull(this.uint256),v:Formatter.allowNull(ye),creates:Formatter.allowNull(n,null),raw:Formatter.allowNull(ae)},t.transactionRequest={from:Formatter.allowNull(n),nonce:Formatter.allowNull(ye),gasLimit:Formatter.allowNull(ie),gasPrice:Formatter.allowNull(ie),maxPriorityFeePerGas:Formatter.allowNull(ie),maxFeePerGas:Formatter.allowNull(ie),to:Formatter.allowNull(n),value:Formatter.allowNull(ie),data:Formatter.allowNull(xe),type:Formatter.allowNull(ye),accessList:Formatter.allowNull(this.accessList.bind(this),null)},t.receiptLog={transactionIndex:ye,blockNumber:ye,transactionHash:le,address:n,topics:Formatter.arrayOf(le),data:ae,logIndex:ye,blockHash:le},t.receipt={to:Formatter.allowNull(this.address,null),from:Formatter.allowNull(this.address,null),contractAddress:Formatter.allowNull(n,null),transactionIndex:ye,root:Formatter.allowNull(he),gasUsed:ie,logsBloom:Formatter.allowNull(ae),blockHash:le,transactionHash:le,logs:Formatter.arrayOf(this.receiptLog.bind(this)),blockNumber:ye,confirmations:Formatter.allowNull(ye,null),cumulativeGasUsed:ie,effectiveGasPrice:Formatter.allowNull(ie),status:Formatter.allowNull(ye),type:me},t.block={hash:Formatter.allowNull(le),parentHash:le,number:ye,timestamp:ye,nonce:Formatter.allowNull(he),difficulty:this.difficulty.bind(this),gasLimit:ie,gasUsed:ie,miner:Formatter.allowNull(n),extraData:ae,transactions:Formatter.allowNull(Formatter.arrayOf(le)),baseFeePerGas:Formatter.allowNull(ie)},t.blockWithTransactions=shallowCopy(t.block),t.blockWithTransactions.transactions=Formatter.allowNull(Formatter.arrayOf(this.transactionResponse.bind(this))),t.filter={fromBlock:Formatter.allowNull(fe,void 0),toBlock:Formatter.allowNull(fe,void 0),blockHash:Formatter.allowNull(le,void 0),address:Formatter.allowNull(n,void 0),topics:Formatter.allowNull(this.topics.bind(this),void 0)},t.filterLog={blockNumber:Formatter.allowNull(ye),blockHash:Formatter.allowNull(le),transactionIndex:ye,removed:Formatter.allowNull(this.boolean.bind(this)),address:n,data:Formatter.allowFalsish(ae,"0x"),topics:Formatter.arrayOf(le),transactionHash:le,logIndex:ye},t}accessList(t){return accessListify(t||[])}number(t){return t==="0x"?0:BigNumber.from(t).toNumber()}type(t){return t==="0x"||t==null?0:BigNumber.from(t).toNumber()}bigNumber(t){return BigNumber.from(t)}boolean(t){if(typeof t=="boolean")return t;if(typeof t=="string"){if(t=t.toLowerCase(),t==="true")return!0;if(t==="false")return!1}throw new Error("invalid boolean - "+t)}hex(t,n){return typeof t=="string"&&(!n&&t.substring(0,2)!=="0x"&&(t="0x"+t),isHexString(t))?t.toLowerCase():logger$5.throwArgumentError("invalid hash","value",t)}data(t,n){const ie=this.hex(t,n);if(ie.length%2!==0)throw new Error("invalid data; odd-length - "+t);return ie}address(t){return getAddress$1(t)}callAddress(t){if(!isHexString(t,32))return null;const n=getAddress$1(hexDataSlice(t,12));return n===AddressZero?null:n}contractAddress(t){return getContractAddress(t)}blockTag(t){if(t==null)return"latest";if(t==="earliest")return"0x0";switch(t){case"earliest":return"0x0";case"latest":case"pending":case"safe":case"finalized":return t}if(typeof t=="number"||isHexString(t))return hexValue(t);throw new Error("invalid blockTag")}hash(t,n){const ie=this.hex(t,n);return hexDataLength(ie)!==32?logger$5.throwArgumentError("invalid hash","value",t):ie}difficulty(t){if(t==null)return null;const n=BigNumber.from(t);try{return n.toNumber()}catch{}return null}uint256(t){if(!isHexString(t))throw new Error("invalid uint256");return hexZeroPad(t,32)}_block(t,n){t.author!=null&&t.miner==null&&(t.miner=t.author);const ie=t._difficulty!=null?t._difficulty:t.difficulty,fe=Formatter.check(n,t);return fe._difficulty=ie==null?null:BigNumber.from(ie),fe}block(t){return this._block(t,this.formats.block)}blockWithTransactions(t){return this._block(t,this.formats.blockWithTransactions)}transactionRequest(t){return Formatter.check(this.formats.transactionRequest,t)}transactionResponse(t){t.gas!=null&&t.gasLimit==null&&(t.gasLimit=t.gas),t.to&&BigNumber.from(t.to).isZero()&&(t.to="0x0000000000000000000000000000000000000000"),t.input!=null&&t.data==null&&(t.data=t.input),t.to==null&&t.creates==null&&(t.creates=this.contractAddress(t)),(t.type===1||t.type===2)&&t.accessList==null&&(t.accessList=[]);const n=Formatter.check(this.formats.transaction,t);if(t.chainId!=null){let ie=t.chainId;isHexString(ie)&&(ie=BigNumber.from(ie).toNumber()),n.chainId=ie}else{let ie=t.networkId;ie==null&&n.v==null&&(ie=t.chainId),isHexString(ie)&&(ie=BigNumber.from(ie).toNumber()),typeof ie!="number"&&n.v!=null&&(ie=(n.v-35)/2,ie<0&&(ie=0),ie=parseInt(ie)),typeof ie!="number"&&(ie=0),n.chainId=ie}return n.blockHash&&n.blockHash.replace(/0/g,"")==="x"&&(n.blockHash=null),n}transaction(t){return parse$2(t)}receiptLog(t){return Formatter.check(this.formats.receiptLog,t)}receipt(t){const n=Formatter.check(this.formats.receipt,t);if(n.root!=null)if(n.root.length<=4){const ie=BigNumber.from(n.root).toNumber();ie===0||ie===1?(n.status!=null&&n.status!==ie&&logger$5.throwArgumentError("alt-root-status/status mismatch","value",{root:n.root,status:n.status}),n.status=ie,delete n.root):logger$5.throwArgumentError("invalid alt-root-status","value.root",n.root)}else n.root.length!==66&&logger$5.throwArgumentError("invalid root hash","value.root",n.root);return n.status!=null&&(n.byzantium=!0),n}topics(t){return Array.isArray(t)?t.map(n=>this.topics(n)):t!=null?this.hash(t,!0):null}filter(t){return Formatter.check(this.formats.filter,t)}filterLog(t){return Formatter.check(this.formats.filterLog,t)}static check(t,n){const ie={};for(const fe in t)try{const ae=t[fe](n[fe]);ae!==void 0&&(ie[fe]=ae)}catch(ae){throw ae.checkKey=fe,ae.checkValue=n[fe],ae}return ie}static allowNull(t,n){return function(ie){return ie==null?n:t(ie)}}static allowFalsish(t,n){return function(ie){return ie?t(ie):n}}static arrayOf(t){return function(n){if(!Array.isArray(n))throw new Error("not an array");const ie=[];return n.forEach(function(fe){ie.push(t(fe))}),ie}}}var __awaiter$c=function(c,t,n,ie){function fe(ae){return ae instanceof n?ae:new n(function(le){le(ae)})}return new(n||(n=Promise))(function(ae,le){function he(xe){try{me(ie.next(xe))}catch(Ee){le(Ee)}}function ye(xe){try{me(ie.throw(xe))}catch(Ee){le(Ee)}}function me(xe){xe.done?ae(xe.value):fe(xe.value).then(he,ye)}me((ie=ie.apply(c,t||[])).next())})};const logger$4=new Logger(version$8),MAX_CCIP_REDIRECTS=10;function checkTopic(c){return c==null?"null":(hexDataLength(c)!==32&&logger$4.throwArgumentError("invalid topic","topic",c),c.toLowerCase())}function serializeTopics(c){for(c=c.slice();c.length>0&&c[c.length-1]==null;)c.pop();return c.map(t=>{if(Array.isArray(t)){const n={};t.forEach(fe=>{n[checkTopic(fe)]=!0});const ie=Object.keys(n);return ie.sort(),ie.join("|")}else return checkTopic(t)}).join("&")}function deserializeTopics(c){return c===""?[]:c.split(/&/g).map(t=>{if(t==="")return[];const n=t.split("|").map(ie=>ie==="null"?null:ie);return n.length===1?n[0]:n})}function getEventTag(c){if(typeof c=="string"){if(c=c.toLowerCase(),hexDataLength(c)===32)return"tx:"+c;if(c.indexOf(":")===-1)return c}else{if(Array.isArray(c))return"filter:*:"+serializeTopics(c);if(ForkEvent.isForkEvent(c))throw logger$4.warn("not implemented"),new Error("not implemented");if(c&&typeof c=="object")return"filter:"+(c.address||"*")+":"+serializeTopics(c.topics||[])}throw new Error("invalid event - "+c)}function getTime(){return new Date().getTime()}function stall(c){return new Promise(t=>{setTimeout(t,c)})}const PollableEvents=["block","network","pending","poll"];let Event$1=class{constructor(t,n,ie){defineReadOnly(this,"tag",t),defineReadOnly(this,"listener",n),defineReadOnly(this,"once",ie),this._lastBlockNumber=-2,this._inflight=!1}get event(){switch(this.type){case"tx":return this.hash;case"filter":return this.filter}return this.tag}get type(){return this.tag.split(":")[0]}get hash(){const t=this.tag.split(":");return t[0]!=="tx"?null:t[1]}get filter(){const t=this.tag.split(":");if(t[0]!=="filter")return null;const n=t[1],ie=deserializeTopics(t[2]),fe={};return ie.length>0&&(fe.topics=ie),n&&n!=="*"&&(fe.address=n),fe}pollable(){return this.tag.indexOf(":")>=0||PollableEvents.indexOf(this.tag)>=0}};const coinInfos={0:{symbol:"btc",p2pkh:0,p2sh:5,prefix:"bc"},2:{symbol:"ltc",p2pkh:48,p2sh:50,prefix:"ltc"},3:{symbol:"doge",p2pkh:30,p2sh:22},60:{symbol:"eth",ilk:"eth"},61:{symbol:"etc",ilk:"eth"},700:{symbol:"xdai",ilk:"eth"}};function bytes32ify(c){return hexZeroPad(BigNumber.from(c).toHexString(),32)}function base58Encode(c){return Base58.encode(concat$1([c,hexDataSlice(sha256$7(sha256$7(c)),0,4)]))}const matcherIpfs=new RegExp("^(ipfs)://(.*)$","i"),matchers=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),matcherIpfs,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];function _parseString(c,t){try{return toUtf8String(_parseBytes(c,t))}catch{}return null}function _parseBytes(c,t){if(c==="0x")return null;const n=BigNumber.from(hexDataSlice(c,t,t+32)).toNumber(),ie=BigNumber.from(hexDataSlice(c,n,n+32)).toNumber();return hexDataSlice(c,n+32,n+32+ie)}function getIpfsLink(c){return c.match(/^ipfs:\/\/ipfs\//i)?c=c.substring(12):c.match(/^ipfs:\/\//i)?c=c.substring(7):logger$4.throwArgumentError("unsupported IPFS format","link",c),`https://gateway.ipfs.io/ipfs/${c}`}function numPad(c){const t=arrayify(c);if(t.length>32)throw new Error("internal; should not happen");const n=new Uint8Array(32);return n.set(t,32-t.length),n}function bytesPad(c){if(c.length%32===0)return c;const t=new Uint8Array(Math.ceil(c.length/32)*32);return t.set(c),t}function encodeBytes(c){const t=[];let n=0;for(let ie=0;ie<c.length;ie++)t.push(null),n+=32;for(let ie=0;ie<c.length;ie++){const fe=arrayify(c[ie]);t[ie]=numPad(n),t.push(numPad(fe.length)),t.push(bytesPad(fe)),n+=32+Math.ceil(fe.length/32)*32}return hexConcat(t)}class Resolver{constructor(t,n,ie,fe){defineReadOnly(this,"provider",t),defineReadOnly(this,"name",ie),defineReadOnly(this,"address",t.formatter.address(n)),defineReadOnly(this,"_resolvedAddress",fe)}supportsWildcard(){return this._supportsEip2544||(this._supportsEip2544=this.provider.call({to:this.address,data:"0x01ffc9a79061b92300000000000000000000000000000000000000000000000000000000"}).then(t=>BigNumber.from(t).eq(1)).catch(t=>{if(t.code===Logger.errors.CALL_EXCEPTION)return!1;throw this._supportsEip2544=null,t})),this._supportsEip2544}_fetch(t,n){return __awaiter$c(this,void 0,void 0,function*(){const ie={to:this.address,ccipReadEnabled:!0,data:hexConcat([t,namehash$1(this.name),n||"0x"])};let fe=!1;(yield this.supportsWildcard())&&(fe=!0,ie.data=hexConcat(["0x9061b923",encodeBytes([dnsEncode(this.name),ie.data])]));try{let ae=yield this.provider.call(ie);return arrayify(ae).length%32===4&&logger$4.throwError("resolver threw error",Logger.errors.CALL_EXCEPTION,{transaction:ie,data:ae}),fe&&(ae=_parseBytes(ae,0)),ae}catch(ae){if(ae.code===Logger.errors.CALL_EXCEPTION)return null;throw ae}})}_fetchBytes(t,n){return __awaiter$c(this,void 0,void 0,function*(){const ie=yield this._fetch(t,n);return ie!=null?_parseBytes(ie,0):null})}_getAddress(t,n){const ie=coinInfos[String(t)];if(ie==null&&logger$4.throwError(`unsupported coin type: ${t}`,Logger.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${t})`}),ie.ilk==="eth")return this.provider.formatter.address(n);const fe=arrayify(n);if(ie.p2pkh!=null){const ae=n.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/);if(ae){const le=parseInt(ae[1],16);if(ae[2].length===le*2&&le>=1&&le<=75)return base58Encode(concat$1([[ie.p2pkh],"0x"+ae[2]]))}}if(ie.p2sh!=null){const ae=n.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/);if(ae){const le=parseInt(ae[1],16);if(ae[2].length===le*2&&le>=1&&le<=75)return base58Encode(concat$1([[ie.p2sh],"0x"+ae[2]]))}}if(ie.prefix!=null){const ae=fe[1];let le=fe[0];if(le===0?ae!==20&&ae!==32&&(le=-1):le=-1,le>=0&&fe.length===2+ae&&ae>=1&&ae<=75){const he=bech32$2.toWords(fe.slice(2));return he.unshift(le),bech32$2.encode(ie.prefix,he)}}return null}getAddress(t){return __awaiter$c(this,void 0,void 0,function*(){if(t==null&&(t=60),t===60)try{const fe=yield this._fetch("0x3b3b57de");return fe==="0x"||fe===HashZero?null:this.provider.formatter.callAddress(fe)}catch(fe){if(fe.code===Logger.errors.CALL_EXCEPTION)return null;throw fe}const n=yield this._fetchBytes("0xf1cb7e06",bytes32ify(t));if(n==null||n==="0x")return null;const ie=this._getAddress(t,n);return ie==null&&logger$4.throwError("invalid or unsupported coin data",Logger.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${t})`,coinType:t,data:n}),ie})}getAvatar(){return __awaiter$c(this,void 0,void 0,function*(){const t=[{type:"name",content:this.name}];try{const n=yield this.getText("avatar");if(n==null)return null;for(let ie=0;ie<matchers.length;ie++){const fe=n.match(matchers[ie]);if(fe==null)continue;const ae=fe[1].toLowerCase();switch(ae){case"https":return t.push({type:"url",content:n}),{linkage:t,url:n};case"data":return t.push({type:"data",content:n}),{linkage:t,url:n};case"ipfs":return t.push({type:"ipfs",content:n}),{linkage:t,url:getIpfsLink(n)};case"erc721":case"erc1155":{const le=ae==="erc721"?"0xc87b56dd":"0x0e89341c";t.push({type:ae,content:n});const he=this._resolvedAddress||(yield this.getAddress()),ye=(fe[2]||"").split("/");if(ye.length!==2)return null;const me=yield this.provider.formatter.address(ye[0]),xe=hexZeroPad(BigNumber.from(ye[1]).toHexString(),32);if(ae==="erc721"){const $e=this.provider.formatter.callAddress(yield this.provider.call({to:me,data:hexConcat(["0x6352211e",xe])}));if(he!==$e)return null;t.push({type:"owner",content:$e})}else if(ae==="erc1155"){const $e=BigNumber.from(yield this.provider.call({to:me,data:hexConcat(["0x00fdd58e",hexZeroPad(he,32),xe])}));if($e.isZero())return null;t.push({type:"balance",content:$e.toString()})}const Ee={to:this.provider.formatter.address(ye[0]),data:hexConcat([le,xe])};let Se=_parseString(yield this.provider.call(Ee),0);if(Se==null)return null;t.push({type:"metadata-url-base",content:Se}),ae==="erc1155"&&(Se=Se.replace("{id}",xe.substring(2)),t.push({type:"metadata-url-expanded",content:Se})),Se.match(/^ipfs:/i)&&(Se=getIpfsLink(Se)),t.push({type:"metadata-url",content:Se});const Me=yield fetchJson(Se);if(!Me)return null;t.push({type:"metadata",content:JSON.stringify(Me)});let Be=Me.image;if(typeof Be!="string")return null;if(!Be.match(/^(https:\/\/|data:)/i)){if(Be.match(matcherIpfs)==null)return null;t.push({type:"url-ipfs",content:Be}),Be=getIpfsLink(Be)}return t.push({type:"url",content:Be}),{linkage:t,url:Be}}}}}catch{}return null})}getContentHash(){return __awaiter$c(this,void 0,void 0,function*(){const t=yield this._fetchBytes("0xbc1c58d1");if(t==null||t==="0x")return null;const n=t.match(/^0xe3010170(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(n){const le=parseInt(n[3],16);if(n[4].length===le*2)return"ipfs://"+Base58.encode("0x"+n[1])}const ie=t.match(/^0xe5010172(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(ie){const le=parseInt(ie[3],16);if(ie[4].length===le*2)return"ipns://"+Base58.encode("0x"+ie[1])}const fe=t.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(fe&&fe[1].length===32*2)return"bzz://"+fe[1];const ae=t.match(/^0x90b2c605([0-9a-f]*)$/);if(ae&&ae[1].length===34*2){const le={"=":"","+":"-","/":"_"};return"sia://"+encode$5("0x"+ae[1]).replace(/[=+\/]/g,ye=>le[ye])}return logger$4.throwError("invalid or unsupported content hash data",Logger.errors.UNSUPPORTED_OPERATION,{operation:"getContentHash()",data:t})})}getText(t){return __awaiter$c(this,void 0,void 0,function*(){let n=toUtf8Bytes(t);n=concat$1([bytes32ify(64),bytes32ify(n.length),n]),n.length%32!==0&&(n=concat$1([n,hexZeroPad("0x",32-t.length%32)]));const ie=yield this._fetchBytes("0x59d1d43c",hexlify(n));return ie==null||ie==="0x"?null:toUtf8String(ie)})}}let defaultFormatter=null,nextPollId=1;class BaseProvider extends Provider{constructor(t){if(super(),this._events=[],this._emitted={block:-2},this.disableCcipRead=!1,this.formatter=new.target.getFormatter(),defineReadOnly(this,"anyNetwork",t==="any"),this.anyNetwork&&(t=this.detectNetwork()),t instanceof Promise)this._networkPromise=t,t.catch(n=>{}),this._ready().catch(n=>{});else{const n=getStatic(new.target,"getNetwork")(t);n?(defineReadOnly(this,"_network",n),this.emit("network",n,null)):logger$4.throwArgumentError("invalid network","network",t)}this._maxInternalBlockNumber=-1024,this._lastBlockNumber=-2,this._maxFilterBlockRange=10,this._pollingInterval=4e3,this._fastQueryDate=0}_ready(){return __awaiter$c(this,void 0,void 0,function*(){if(this._network==null){let t=null;if(this._networkPromise)try{t=yield this._networkPromise}catch{}t==null&&(t=yield this.detectNetwork()),t||logger$4.throwError("no network detected",Logger.errors.UNKNOWN_ERROR,{}),this._network==null&&(this.anyNetwork?this._network=t:defineReadOnly(this,"_network",t),this.emit("network",t,null))}return this._network})}get ready(){return poll(()=>this._ready().then(t=>t,t=>{if(!(t.code===Logger.errors.NETWORK_ERROR&&t.event==="noNetwork"))throw t}))}static getFormatter(){return defaultFormatter==null&&(defaultFormatter=new Formatter),defaultFormatter}static getNetwork(t){return getNetwork(t??"homestead")}ccipReadFetch(t,n,ie){return __awaiter$c(this,void 0,void 0,function*(){if(this.disableCcipRead||ie.length===0)return null;const fe=t.to.toLowerCase(),ae=n.toLowerCase(),le=[];for(let he=0;he<ie.length;he++){const ye=ie[he],me=ye.replace("{sender}",fe).replace("{data}",ae),xe=ye.indexOf("{data}")>=0?null:JSON.stringify({data:ae,sender:fe}),Ee=yield fetchJson({url:me,errorPassThrough:!0},xe,(Me,Be)=>(Me.status=Be.statusCode,Me));if(Ee.data)return Ee.data;const Se=Ee.message||"unknown error";if(Ee.status>=400&&Ee.status<500)return logger$4.throwError(`response not found during CCIP fetch: ${Se}`,Logger.errors.SERVER_ERROR,{url:ye,errorMessage:Se});le.push(Se)}return logger$4.throwError(`error encountered during CCIP fetch: ${le.map(he=>JSON.stringify(he)).join(", ")}`,Logger.errors.SERVER_ERROR,{urls:ie,errorMessages:le})})}_getInternalBlockNumber(t){return __awaiter$c(this,void 0,void 0,function*(){if(yield this._ready(),t>0)for(;this._internalBlockNumber;){const fe=this._internalBlockNumber;try{const ae=yield fe;if(getTime()-ae.respTime<=t)return ae.blockNumber;break}catch{if(this._internalBlockNumber===fe)break}}const n=getTime(),ie=resolveProperties({blockNumber:this.perform("getBlockNumber",{}),networkError:this.getNetwork().then(fe=>null,fe=>fe)}).then(({blockNumber:fe,networkError:ae})=>{if(ae)throw this._internalBlockNumber===ie&&(this._internalBlockNumber=null),ae;const le=getTime();return fe=BigNumber.from(fe).toNumber(),fe<this._maxInternalBlockNumber&&(fe=this._maxInternalBlockNumber),this._maxInternalBlockNumber=fe,this._setFastBlockNumber(fe),{blockNumber:fe,reqTime:n,respTime:le}});return this._internalBlockNumber=ie,ie.catch(fe=>{this._internalBlockNumber===ie&&(this._internalBlockNumber=null)}),(yield ie).blockNumber})}poll(){return __awaiter$c(this,void 0,void 0,function*(){const t=nextPollId++,n=[];let ie=null;try{ie=yield this._getInternalBlockNumber(100+this.pollingInterval/2)}catch(fe){this.emit("error",fe);return}if(this._setFastBlockNumber(ie),this.emit("poll",t,ie),ie===this._lastBlockNumber){this.emit("didPoll",t);return}if(this._emitted.block===-2&&(this._emitted.block=ie-1),Math.abs(this._emitted.block-ie)>1e3)logger$4.warn(`network block skew detected; skipping block events (emitted=${this._emitted.block} blockNumber${ie})`),this.emit("error",logger$4.makeError("network block skew detected",Logger.errors.NETWORK_ERROR,{blockNumber:ie,event:"blockSkew",previousBlockNumber:this._emitted.block})),this.emit("block",ie);else for(let fe=this._emitted.block+1;fe<=ie;fe++)this.emit("block",fe);this._emitted.block!==ie&&(this._emitted.block=ie,Object.keys(this._emitted).forEach(fe=>{if(fe==="block")return;const ae=this._emitted[fe];ae!=="pending"&&ie-ae>12&&delete this._emitted[fe]})),this._lastBlockNumber===-2&&(this._lastBlockNumber=ie-1),this._events.forEach(fe=>{switch(fe.type){case"tx":{const ae=fe.hash;let le=this.getTransactionReceipt(ae).then(he=>(!he||he.blockNumber==null||(this._emitted["t:"+ae]=he.blockNumber,this.emit(ae,he)),null)).catch(he=>{this.emit("error",he)});n.push(le);break}case"filter":{if(!fe._inflight){fe._inflight=!0,fe._lastBlockNumber===-2&&(fe._lastBlockNumber=ie-1);const ae=fe.filter;ae.fromBlock=fe._lastBlockNumber+1,ae.toBlock=ie;const le=ae.toBlock-this._maxFilterBlockRange;le>ae.fromBlock&&(ae.fromBlock=le),ae.fromBlock<0&&(ae.fromBlock=0);const he=this.getLogs(ae).then(ye=>{fe._inflight=!1,ye.length!==0&&ye.forEach(me=>{me.blockNumber>fe._lastBlockNumber&&(fe._lastBlockNumber=me.blockNumber),this._emitted["b:"+me.blockHash]=me.blockNumber,this._emitted["t:"+me.transactionHash]=me.blockNumber,this.emit(ae,me)})}).catch(ye=>{this.emit("error",ye),fe._inflight=!1});n.push(he)}break}}}),this._lastBlockNumber=ie,Promise.all(n).then(()=>{this.emit("didPoll",t)}).catch(fe=>{this.emit("error",fe)})})}resetEventsBlock(t){this._lastBlockNumber=t-1,this.polling&&this.poll()}get network(){return this._network}detectNetwork(){return __awaiter$c(this,void 0,void 0,function*(){return logger$4.throwError("provider does not support network detection",Logger.errors.UNSUPPORTED_OPERATION,{operation:"provider.detectNetwork"})})}getNetwork(){return __awaiter$c(this,void 0,void 0,function*(){const t=yield this._ready(),n=yield this.detectNetwork();if(t.chainId!==n.chainId){if(this.anyNetwork)return this._network=n,this._lastBlockNumber=-2,this._fastBlockNumber=null,this._fastBlockNumberPromise=null,this._fastQueryDate=0,this._emitted.block=-2,this._maxInternalBlockNumber=-1024,this._internalBlockNumber=null,this.emit("network",n,t),yield stall(0),this._network;const ie=logger$4.makeError("underlying network changed",Logger.errors.NETWORK_ERROR,{event:"changed",network:t,detectedNetwork:n});throw this.emit("error",ie),ie}return t})}get blockNumber(){return this._getInternalBlockNumber(100+this.pollingInterval/2).then(t=>{this._setFastBlockNumber(t)},t=>{}),this._fastBlockNumber!=null?this._fastBlockNumber:-1}get polling(){return this._poller!=null}set polling(t){t&&!this._poller?(this._poller=setInterval(()=>{this.poll()},this.pollingInterval),this._bootstrapPoll||(this._bootstrapPoll=setTimeout(()=>{this.poll(),this._bootstrapPoll=setTimeout(()=>{this._poller||this.poll(),this._bootstrapPoll=null},this.pollingInterval)},0))):!t&&this._poller&&(clearInterval(this._poller),this._poller=null)}get pollingInterval(){return this._pollingInterval}set pollingInterval(t){if(typeof t!="number"||t<=0||parseInt(String(t))!=t)throw new Error("invalid polling interval");this._pollingInterval=t,this._poller&&(clearInterval(this._poller),this._poller=setInterval(()=>{this.poll()},this._pollingInterval))}_getFastBlockNumber(){const t=getTime();return t-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=t,this._fastBlockNumberPromise=this.getBlockNumber().then(n=>((this._fastBlockNumber==null||n>this._fastBlockNumber)&&(this._fastBlockNumber=n),this._fastBlockNumber))),this._fastBlockNumberPromise}_setFastBlockNumber(t){this._fastBlockNumber!=null&&t<this._fastBlockNumber||(this._fastQueryDate=getTime(),(this._fastBlockNumber==null||t>this._fastBlockNumber)&&(this._fastBlockNumber=t,this._fastBlockNumberPromise=Promise.resolve(t)))}waitForTransaction(t,n,ie){return __awaiter$c(this,void 0,void 0,function*(){return this._waitForTransaction(t,n??1,ie||0,null)})}_waitForTransaction(t,n,ie,fe){return __awaiter$c(this,void 0,void 0,function*(){const ae=yield this.getTransactionReceipt(t);return(ae?ae.confirmations:0)>=n?ae:new Promise((le,he)=>{const ye=[];let me=!1;const xe=function(){return me?!0:(me=!0,ye.forEach(Se=>{Se()}),!1)},Ee=Se=>{Se.confirmations<n||xe()||le(Se)};if(this.on(t,Ee),ye.push(()=>{this.removeListener(t,Ee)}),fe){let Se=fe.startBlock,Me=null;const Be=$e=>__awaiter$c(this,void 0,void 0,function*(){me||(yield stall(1e3),this.getTransactionCount(fe.from).then(Ce=>__awaiter$c(this,void 0,void 0,function*(){if(!me){if(Ce<=fe.nonce)Se=$e;else{{const ke=yield this.getTransaction(t);if(ke&&ke.blockNumber!=null)return}for(Me==null&&(Me=Se-3,Me<fe.startBlock&&(Me=fe.startBlock));Me<=$e;){if(me)return;const ke=yield this.getBlockWithTransactions(Me);for(let Pe=0;Pe<ke.transactions.length;Pe++){const Ue=ke.transactions[Pe];if(Ue.hash===t)return;if(Ue.from===fe.from&&Ue.nonce===fe.nonce){if(me)return;const qe=yield this.waitForTransaction(Ue.hash,n);if(xe())return;let He="replaced";Ue.data===fe.data&&Ue.to===fe.to&&Ue.value.eq(fe.value)?He="repriced":Ue.data==="0x"&&Ue.from===Ue.to&&Ue.value.isZero()&&(He="cancelled"),he(logger$4.makeError("transaction was replaced",Logger.errors.TRANSACTION_REPLACED,{cancelled:He==="replaced"||He==="cancelled",reason:He,replacement:this._wrapTransaction(Ue),hash:t,receipt:qe}));return}}Me++}}me||this.once("block",Be)}}),Ce=>{me||this.once("block",Be)}))});if(me)return;this.once("block",Be),ye.push(()=>{this.removeListener("block",Be)})}if(typeof ie=="number"&&ie>0){const Se=setTimeout(()=>{xe()||he(logger$4.makeError("timeout exceeded",Logger.errors.TIMEOUT,{timeout:ie}))},ie);Se.unref&&Se.unref(),ye.push(()=>{clearTimeout(Se)})}})})}getBlockNumber(){return __awaiter$c(this,void 0,void 0,function*(){return this._getInternalBlockNumber(0)})}getGasPrice(){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const t=yield this.perform("getGasPrice",{});try{return BigNumber.from(t)}catch(n){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getGasPrice",result:t,error:n})}})}getBalance(t,n){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const ie=yield resolveProperties({address:this._getAddress(t),blockTag:this._getBlockTag(n)}),fe=yield this.perform("getBalance",ie);try{return BigNumber.from(fe)}catch(ae){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getBalance",params:ie,result:fe,error:ae})}})}getTransactionCount(t,n){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const ie=yield resolveProperties({address:this._getAddress(t),blockTag:this._getBlockTag(n)}),fe=yield this.perform("getTransactionCount",ie);try{return BigNumber.from(fe).toNumber()}catch(ae){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getTransactionCount",params:ie,result:fe,error:ae})}})}getCode(t,n){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const ie=yield resolveProperties({address:this._getAddress(t),blockTag:this._getBlockTag(n)}),fe=yield this.perform("getCode",ie);try{return hexlify(fe)}catch(ae){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getCode",params:ie,result:fe,error:ae})}})}getStorageAt(t,n,ie){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const fe=yield resolveProperties({address:this._getAddress(t),blockTag:this._getBlockTag(ie),position:Promise.resolve(n).then(le=>hexValue(le))}),ae=yield this.perform("getStorageAt",fe);try{return hexlify(ae)}catch(le){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getStorageAt",params:fe,result:ae,error:le})}})}_wrapTransaction(t,n,ie){if(n!=null&&hexDataLength(n)!==32)throw new Error("invalid response - sendTransaction");const fe=t;return n!=null&&t.hash!==n&&logger$4.throwError("Transaction hash mismatch from Provider.sendTransaction.",Logger.errors.UNKNOWN_ERROR,{expectedHash:t.hash,returnedHash:n}),fe.wait=(ae,le)=>__awaiter$c(this,void 0,void 0,function*(){ae==null&&(ae=1),le==null&&(le=0);let he;ae!==0&&ie!=null&&(he={data:t.data,from:t.from,nonce:t.nonce,to:t.to,value:t.value,startBlock:ie});const ye=yield this._waitForTransaction(t.hash,ae,le,he);return ye==null&&ae===0?null:(this._emitted["t:"+t.hash]=ye.blockNumber,ye.status===0&&logger$4.throwError("transaction failed",Logger.errors.CALL_EXCEPTION,{transactionHash:t.hash,transaction:t,receipt:ye}),ye)}),fe}sendTransaction(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const n=yield Promise.resolve(t).then(ae=>hexlify(ae)),ie=this.formatter.transaction(t);ie.confirmations==null&&(ie.confirmations=0);const fe=yield this._getInternalBlockNumber(100+2*this.pollingInterval);try{const ae=yield this.perform("sendTransaction",{signedTransaction:n});return this._wrapTransaction(ie,ae,fe)}catch(ae){throw ae.transaction=ie,ae.transactionHash=ie.hash,ae}})}_getTransactionRequest(t){return __awaiter$c(this,void 0,void 0,function*(){const n=yield t,ie={};return["from","to"].forEach(fe=>{n[fe]!=null&&(ie[fe]=Promise.resolve(n[fe]).then(ae=>ae?this._getAddress(ae):null))}),["gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","value"].forEach(fe=>{n[fe]!=null&&(ie[fe]=Promise.resolve(n[fe]).then(ae=>ae?BigNumber.from(ae):null))}),["type"].forEach(fe=>{n[fe]!=null&&(ie[fe]=Promise.resolve(n[fe]).then(ae=>ae??null))}),n.accessList&&(ie.accessList=this.formatter.accessList(n.accessList)),["data"].forEach(fe=>{n[fe]!=null&&(ie[fe]=Promise.resolve(n[fe]).then(ae=>ae?hexlify(ae):null))}),this.formatter.transactionRequest(yield resolveProperties(ie))})}_getFilter(t){return __awaiter$c(this,void 0,void 0,function*(){t=yield t;const n={};return t.address!=null&&(n.address=this._getAddress(t.address)),["blockHash","topics"].forEach(ie=>{t[ie]!=null&&(n[ie]=t[ie])}),["fromBlock","toBlock"].forEach(ie=>{t[ie]!=null&&(n[ie]=this._getBlockTag(t[ie]))}),this.formatter.filter(yield resolveProperties(n))})}_call(t,n,ie){return __awaiter$c(this,void 0,void 0,function*(){ie>=MAX_CCIP_REDIRECTS&&logger$4.throwError("CCIP read exceeded maximum redirections",Logger.errors.SERVER_ERROR,{redirects:ie,transaction:t});const fe=t.to,ae=yield this.perform("call",{transaction:t,blockTag:n});if(ie>=0&&n==="latest"&&fe!=null&&ae.substring(0,10)==="0x556f1830"&&hexDataLength(ae)%32===4)try{const le=hexDataSlice(ae,4),he=hexDataSlice(le,0,32);BigNumber.from(he).eq(fe)||logger$4.throwError("CCIP Read sender did not match",Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:ae});const ye=[],me=BigNumber.from(hexDataSlice(le,32,64)).toNumber(),xe=BigNumber.from(hexDataSlice(le,me,me+32)).toNumber(),Ee=hexDataSlice(le,me+32);for(let ke=0;ke<xe;ke++){const Pe=_parseString(Ee,ke*32);Pe==null&&logger$4.throwError("CCIP Read contained corrupt URL string",Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:ae}),ye.push(Pe)}const Se=_parseBytes(le,64);BigNumber.from(hexDataSlice(le,100,128)).isZero()||logger$4.throwError("CCIP Read callback selector included junk",Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:ae});const Me=hexDataSlice(le,96,100),Be=_parseBytes(le,128),$e=yield this.ccipReadFetch(t,Se,ye);$e==null&&logger$4.throwError("CCIP Read disabled or provided no URLs",Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:ae});const Ce={to:fe,data:hexConcat([Me,encodeBytes([$e,Be])])};return this._call(Ce,n,ie+1)}catch(le){if(le.code===Logger.errors.SERVER_ERROR)throw le}try{return hexlify(ae)}catch(le){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"call",params:{transaction:t,blockTag:n},result:ae,error:le})}})}call(t,n){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const ie=yield resolveProperties({transaction:this._getTransactionRequest(t),blockTag:this._getBlockTag(n),ccipReadEnabled:Promise.resolve(t.ccipReadEnabled)});return this._call(ie.transaction,ie.blockTag,ie.ccipReadEnabled?0:-1)})}estimateGas(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const n=yield resolveProperties({transaction:this._getTransactionRequest(t)}),ie=yield this.perform("estimateGas",n);try{return BigNumber.from(ie)}catch(fe){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"estimateGas",params:n,result:ie,error:fe})}})}_getAddress(t){return __awaiter$c(this,void 0,void 0,function*(){t=yield t,typeof t!="string"&&logger$4.throwArgumentError("invalid address or ENS name","name",t);const n=yield this.resolveName(t);return n==null&&logger$4.throwError("ENS name not configured",Logger.errors.UNSUPPORTED_OPERATION,{operation:`resolveName(${JSON.stringify(t)})`}),n})}_getBlock(t,n){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork(),t=yield t;let ie=-128;const fe={includeTransactions:!!n};if(isHexString(t,32))fe.blockHash=t;else try{fe.blockTag=yield this._getBlockTag(t),isHexString(fe.blockTag)&&(ie=parseInt(fe.blockTag.substring(2),16))}catch{logger$4.throwArgumentError("invalid block hash or block tag","blockHashOrBlockTag",t)}return poll(()=>__awaiter$c(this,void 0,void 0,function*(){const ae=yield this.perform("getBlock",fe);if(ae==null)return fe.blockHash!=null&&this._emitted["b:"+fe.blockHash]==null||fe.blockTag!=null&&ie>this._emitted.block?null:void 0;if(n){let le=null;for(let ye=0;ye<ae.transactions.length;ye++){const me=ae.transactions[ye];if(me.blockNumber==null)me.confirmations=0;else if(me.confirmations==null){le==null&&(le=yield this._getInternalBlockNumber(100+2*this.pollingInterval));let xe=le-me.blockNumber+1;xe<=0&&(xe=1),me.confirmations=xe}}const he=this.formatter.blockWithTransactions(ae);return he.transactions=he.transactions.map(ye=>this._wrapTransaction(ye)),he}return this.formatter.block(ae)}),{oncePoll:this})})}getBlock(t){return this._getBlock(t,!1)}getBlockWithTransactions(t){return this._getBlock(t,!0)}getTransaction(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork(),t=yield t;const n={transactionHash:this.formatter.hash(t,!0)};return poll(()=>__awaiter$c(this,void 0,void 0,function*(){const ie=yield this.perform("getTransaction",n);if(ie==null)return this._emitted["t:"+t]==null?null:void 0;const fe=this.formatter.transactionResponse(ie);if(fe.blockNumber==null)fe.confirmations=0;else if(fe.confirmations==null){let le=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-fe.blockNumber+1;le<=0&&(le=1),fe.confirmations=le}return this._wrapTransaction(fe)}),{oncePoll:this})})}getTransactionReceipt(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork(),t=yield t;const n={transactionHash:this.formatter.hash(t,!0)};return poll(()=>__awaiter$c(this,void 0,void 0,function*(){const ie=yield this.perform("getTransactionReceipt",n);if(ie==null)return this._emitted["t:"+t]==null?null:void 0;if(ie.blockHash==null)return;const fe=this.formatter.receipt(ie);if(fe.blockNumber==null)fe.confirmations=0;else if(fe.confirmations==null){let le=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-fe.blockNumber+1;le<=0&&(le=1),fe.confirmations=le}return fe}),{oncePoll:this})})}getLogs(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const n=yield resolveProperties({filter:this._getFilter(t)}),ie=yield this.perform("getLogs",n);return ie.forEach(fe=>{fe.removed==null&&(fe.removed=!1)}),Formatter.arrayOf(this.formatter.filterLog.bind(this.formatter))(ie)})}getEtherPrice(){return __awaiter$c(this,void 0,void 0,function*(){return yield this.getNetwork(),this.perform("getEtherPrice",{})})}_getBlockTag(t){return __awaiter$c(this,void 0,void 0,function*(){if(t=yield t,typeof t=="number"&&t<0){t%1&&logger$4.throwArgumentError("invalid BlockTag","blockTag",t);let n=yield this._getInternalBlockNumber(100+2*this.pollingInterval);return n+=t,n<0&&(n=0),this.formatter.blockTag(n)}return this.formatter.blockTag(t)})}getResolver(t){return __awaiter$c(this,void 0,void 0,function*(){let n=t;for(;;){if(n===""||n==="."||t!=="eth"&&n==="eth")return null;const ie=yield this._getResolver(n,"getResolver");if(ie!=null){const fe=new Resolver(this,ie,t);return n!==t&&!(yield fe.supportsWildcard())?null:fe}n=n.split(".").slice(1).join(".")}})}_getResolver(t,n){return __awaiter$c(this,void 0,void 0,function*(){n==null&&(n="ENS");const ie=yield this.getNetwork();ie.ensAddress||logger$4.throwError("network does not support ENS",Logger.errors.UNSUPPORTED_OPERATION,{operation:n,network:ie.name});try{const fe=yield this.call({to:ie.ensAddress,data:"0x0178b8bf"+namehash$1(t).substring(2)});return this.formatter.callAddress(fe)}catch{}return null})}resolveName(t){return __awaiter$c(this,void 0,void 0,function*(){t=yield t;try{return Promise.resolve(this.formatter.address(t))}catch(ie){if(isHexString(t))throw ie}typeof t!="string"&&logger$4.throwArgumentError("invalid ENS name","name",t);const n=yield this.getResolver(t);return n?yield n.getAddress():null})}lookupAddress(t){return __awaiter$c(this,void 0,void 0,function*(){t=yield t,t=this.formatter.address(t);const n=t.substring(2).toLowerCase()+".addr.reverse",ie=yield this._getResolver(n,"lookupAddress");if(ie==null)return null;const fe=_parseString(yield this.call({to:ie,data:"0x691f3431"+namehash$1(n).substring(2)}),0);return(yield this.resolveName(fe))!=t?null:fe})}getAvatar(t){return __awaiter$c(this,void 0,void 0,function*(){let n=null;if(isHexString(t)){const ae=this.formatter.address(t).substring(2).toLowerCase()+".addr.reverse",le=yield this._getResolver(ae,"getAvatar");if(!le)return null;n=new Resolver(this,le,ae);try{const he=yield n.getAvatar();if(he)return he.url}catch(he){if(he.code!==Logger.errors.CALL_EXCEPTION)throw he}try{const he=_parseString(yield this.call({to:le,data:"0x691f3431"+namehash$1(ae).substring(2)}),0);n=yield this.getResolver(he)}catch(he){if(he.code!==Logger.errors.CALL_EXCEPTION)throw he;return null}}else if(n=yield this.getResolver(t),!n)return null;const ie=yield n.getAvatar();return ie==null?null:ie.url})}perform(t,n){return logger$4.throwError(t+" not implemented",Logger.errors.NOT_IMPLEMENTED,{operation:t})}_startEvent(t){this.polling=this._events.filter(n=>n.pollable()).length>0}_stopEvent(t){this.polling=this._events.filter(n=>n.pollable()).length>0}_addEventListener(t,n,ie){const fe=new Event$1(getEventTag(t),n,ie);return this._events.push(fe),this._startEvent(fe),this}on(t,n){return this._addEventListener(t,n,!1)}once(t,n){return this._addEventListener(t,n,!0)}emit(t,...n){let ie=!1,fe=[],ae=getEventTag(t);return this._events=this._events.filter(le=>le.tag!==ae?!0:(setTimeout(()=>{le.listener.apply(this,n)},0),ie=!0,le.once?(fe.push(le),!1):!0)),fe.forEach(le=>{this._stopEvent(le)}),ie}listenerCount(t){if(!t)return this._events.length;let n=getEventTag(t);return this._events.filter(ie=>ie.tag===n).length}listeners(t){if(t==null)return this._events.map(ie=>ie.listener);let n=getEventTag(t);return this._events.filter(ie=>ie.tag===n).map(ie=>ie.listener)}off(t,n){if(n==null)return this.removeAllListeners(t);const ie=[];let fe=!1,ae=getEventTag(t);return this._events=this._events.filter(le=>le.tag!==ae||le.listener!=n||fe?!0:(fe=!0,ie.push(le),!1)),ie.forEach(le=>{this._stopEvent(le)}),this}removeAllListeners(t){let n=[];if(t==null)n=this._events,this._events=[];else{const ie=getEventTag(t);this._events=this._events.filter(fe=>fe.tag!==ie?!0:(n.push(fe),!1))}return n.forEach(ie=>{this._stopEvent(ie)}),this}}var __awaiter$b=function(c,t,n,ie){function fe(ae){return ae instanceof n?ae:new n(function(le){le(ae)})}return new(n||(n=Promise))(function(ae,le){function he(xe){try{me(ie.next(xe))}catch(Ee){le(Ee)}}function ye(xe){try{me(ie.throw(xe))}catch(Ee){le(Ee)}}function me(xe){xe.done?ae(xe.value):fe(xe.value).then(he,ye)}me((ie=ie.apply(c,t||[])).next())})};const logger$3=new Logger(version$8),errorGas=["call","estimateGas"];function spelunk(c,t){if(c==null)return null;if(typeof c.message=="string"&&c.message.match("reverted")){const n=isHexString(c.data)?c.data:null;if(!t||n)return{message:c.message,data:n}}if(typeof c=="object"){for(const n in c){const ie=spelunk(c[n],t);if(ie)return ie}return null}if(typeof c=="string")try{return spelunk(JSON.parse(c),t)}catch{}return null}function checkError(c,t,n){const ie=n.transaction||n.signedTransaction;if(c==="call"){const ae=spelunk(t,!0);if(ae)return ae.data;logger$3.throwError("missing revert data in call exception; Transaction reverted without a reason string",Logger.errors.CALL_EXCEPTION,{data:"0x",transaction:ie,error:t})}if(c==="estimateGas"){let ae=spelunk(t.body,!1);ae==null&&(ae=spelunk(t,!1)),ae&&logger$3.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",Logger.errors.UNPREDICTABLE_GAS_LIMIT,{reason:ae.message,method:c,transaction:ie,error:t})}let fe=t.message;throw t.code===Logger.errors.SERVER_ERROR&&t.error&&typeof t.error.message=="string"?fe=t.error.message:typeof t.body=="string"?fe=t.body:typeof t.responseText=="string"&&(fe=t.responseText),fe=(fe||"").toLowerCase(),fe.match(/insufficient funds|base fee exceeds gas limit|InsufficientFunds/i)&&logger$3.throwError("insufficient funds for intrinsic transaction cost",Logger.errors.INSUFFICIENT_FUNDS,{error:t,method:c,transaction:ie}),fe.match(/nonce (is )?too low/i)&&logger$3.throwError("nonce has already been used",Logger.errors.NONCE_EXPIRED,{error:t,method:c,transaction:ie}),fe.match(/replacement transaction underpriced|transaction gas price.*too low/i)&&logger$3.throwError("replacement fee too low",Logger.errors.REPLACEMENT_UNDERPRICED,{error:t,method:c,transaction:ie}),fe.match(/only replay-protected/i)&&logger$3.throwError("legacy pre-eip-155 transactions not supported",Logger.errors.UNSUPPORTED_OPERATION,{error:t,method:c,transaction:ie}),errorGas.indexOf(c)>=0&&fe.match(/gas required exceeds allowance|always failing transaction|execution reverted|revert/)&&logger$3.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",Logger.errors.UNPREDICTABLE_GAS_LIMIT,{error:t,method:c,transaction:ie}),t}function timer(c){return new Promise(function(t){setTimeout(t,c)})}function getResult(c){if(c.error){const t=new Error(c.error.message);throw t.code=c.error.code,t.data=c.error.data,t}return c.result}function getLowerCase(c){return c&&c.toLowerCase()}const _constructorGuard={};class JsonRpcSigner extends Signer{constructor(t,n,ie){if(super(),t!==_constructorGuard)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");defineReadOnly(this,"provider",n),ie==null&&(ie=0),typeof ie=="string"?(defineReadOnly(this,"_address",this.provider.formatter.address(ie)),defineReadOnly(this,"_index",null)):typeof ie=="number"?(defineReadOnly(this,"_index",ie),defineReadOnly(this,"_address",null)):logger$3.throwArgumentError("invalid address or index","addressOrIndex",ie)}connect(t){return logger$3.throwError("cannot alter JSON-RPC Signer connection",Logger.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new UncheckedJsonRpcSigner(_constructorGuard,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then(t=>(t.length<=this._index&&logger$3.throwError("unknown account #"+this._index,Logger.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(t[this._index])))}sendUncheckedTransaction(t){t=shallowCopy(t);const n=this.getAddress().then(ie=>(ie&&(ie=ie.toLowerCase()),ie));if(t.gasLimit==null){const ie=shallowCopy(t);ie.from=n,t.gasLimit=this.provider.estimateGas(ie)}return t.to!=null&&(t.to=Promise.resolve(t.to).then(ie=>__awaiter$b(this,void 0,void 0,function*(){if(ie==null)return null;const fe=yield this.provider.resolveName(ie);return fe==null&&logger$3.throwArgumentError("provided ENS name resolves to null","tx.to",ie),fe}))),resolveProperties({tx:resolveProperties(t),sender:n}).then(({tx:ie,sender:fe})=>{ie.from!=null?ie.from.toLowerCase()!==fe&&logger$3.throwArgumentError("from address mismatch","transaction",t):ie.from=fe;const ae=this.provider.constructor.hexlifyTransaction(ie,{from:!0});return this.provider.send("eth_sendTransaction",[ae]).then(le=>le,le=>(typeof le.message=="string"&&le.message.match(/user denied/i)&&logger$3.throwError("user rejected transaction",Logger.errors.ACTION_REJECTED,{action:"sendTransaction",transaction:ie}),checkError("sendTransaction",le,ae)))})}signTransaction(t){return logger$3.throwError("signing transactions is unsupported",Logger.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(t){return __awaiter$b(this,void 0,void 0,function*(){const n=yield this.provider._getInternalBlockNumber(100+2*this.provider.pollingInterval),ie=yield this.sendUncheckedTransaction(t);try{return yield poll(()=>__awaiter$b(this,void 0,void 0,function*(){const fe=yield this.provider.getTransaction(ie);if(fe!==null)return this.provider._wrapTransaction(fe,ie,n)}),{oncePoll:this.provider})}catch(fe){throw fe.transactionHash=ie,fe}})}signMessage(t){return __awaiter$b(this,void 0,void 0,function*(){const n=typeof t=="string"?toUtf8Bytes(t):t,ie=yield this.getAddress();try{return yield this.provider.send("personal_sign",[hexlify(n),ie.toLowerCase()])}catch(fe){throw typeof fe.message=="string"&&fe.message.match(/user denied/i)&&logger$3.throwError("user rejected signing",Logger.errors.ACTION_REJECTED,{action:"signMessage",from:ie,messageData:t}),fe}})}_legacySignMessage(t){return __awaiter$b(this,void 0,void 0,function*(){const n=typeof t=="string"?toUtf8Bytes(t):t,ie=yield this.getAddress();try{return yield this.provider.send("eth_sign",[ie.toLowerCase(),hexlify(n)])}catch(fe){throw typeof fe.message=="string"&&fe.message.match(/user denied/i)&&logger$3.throwError("user rejected signing",Logger.errors.ACTION_REJECTED,{action:"_legacySignMessage",from:ie,messageData:t}),fe}})}_signTypedData(t,n,ie){return __awaiter$b(this,void 0,void 0,function*(){const fe=yield TypedDataEncoder.resolveNames(t,n,ie,le=>this.provider.resolveName(le)),ae=yield this.getAddress();try{return yield this.provider.send("eth_signTypedData_v4",[ae.toLowerCase(),JSON.stringify(TypedDataEncoder.getPayload(fe.domain,n,fe.value))])}catch(le){throw typeof le.message=="string"&&le.message.match(/user denied/i)&&logger$3.throwError("user rejected signing",Logger.errors.ACTION_REJECTED,{action:"_signTypedData",from:ae,messageData:{domain:fe.domain,types:n,value:fe.value}}),le}})}unlock(t){return __awaiter$b(this,void 0,void 0,function*(){const n=this.provider,ie=yield this.getAddress();return n.send("personal_unlockAccount",[ie.toLowerCase(),t,null])})}}class UncheckedJsonRpcSigner extends JsonRpcSigner{sendTransaction(t){return this.sendUncheckedTransaction(t).then(n=>({hash:n,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:ie=>this.provider.waitForTransaction(n,ie)}))}}const allowedTransactionKeys={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0,type:!0,accessList:!0,maxFeePerGas:!0,maxPriorityFeePerGas:!0};class JsonRpcProvider extends BaseProvider{constructor(t,n){let ie=n;ie==null&&(ie=new Promise((fe,ae)=>{setTimeout(()=>{this.detectNetwork().then(le=>{fe(le)},le=>{ae(le)})},0)})),super(ie),t||(t=getStatic(this.constructor,"defaultUrl")()),typeof t=="string"?defineReadOnly(this,"connection",Object.freeze({url:t})):defineReadOnly(this,"connection",Object.freeze(shallowCopy(t))),this._nextId=42}get _cache(){return this._eventLoopCache==null&&(this._eventLoopCache={}),this._eventLoopCache}static defaultUrl(){return"http://localhost:8545"}detectNetwork(){return this._cache.detectNetwork||(this._cache.detectNetwork=this._uncachedDetectNetwork(),setTimeout(()=>{this._cache.detectNetwork=null},0)),this._cache.detectNetwork}_uncachedDetectNetwork(){return __awaiter$b(this,void 0,void 0,function*(){yield timer(0);let t=null;try{t=yield this.send("eth_chainId",[])}catch{try{t=yield this.send("net_version",[])}catch{}}if(t!=null){const n=getStatic(this.constructor,"getNetwork");try{return n(BigNumber.from(t).toNumber())}catch(ie){return logger$3.throwError("could not detect network",Logger.errors.NETWORK_ERROR,{chainId:t,event:"invalidNetwork",serverError:ie})}}return logger$3.throwError("could not detect network",Logger.errors.NETWORK_ERROR,{event:"noNetwork"})})}getSigner(t){return new JsonRpcSigner(_constructorGuard,this,t)}getUncheckedSigner(t){return this.getSigner(t).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then(t=>t.map(n=>this.formatter.address(n)))}send(t,n){const ie={method:t,params:n,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:deepCopy(ie),provider:this});const fe=["eth_chainId","eth_blockNumber"].indexOf(t)>=0;if(fe&&this._cache[t])return this._cache[t];const ae=fetchJson(this.connection,JSON.stringify(ie),getResult).then(le=>(this.emit("debug",{action:"response",request:ie,response:le,provider:this}),le),le=>{throw this.emit("debug",{action:"response",error:le,request:ie,provider:this}),le});return fe&&(this._cache[t]=ae,setTimeout(()=>{this._cache[t]=null},0)),ae}prepareRequest(t,n){switch(t){case"getBlockNumber":return["eth_blockNumber",[]];case"getGasPrice":return["eth_gasPrice",[]];case"getBalance":return["eth_getBalance",[getLowerCase(n.address),n.blockTag]];case"getTransactionCount":return["eth_getTransactionCount",[getLowerCase(n.address),n.blockTag]];case"getCode":return["eth_getCode",[getLowerCase(n.address),n.blockTag]];case"getStorageAt":return["eth_getStorageAt",[getLowerCase(n.address),hexZeroPad(n.position,32),n.blockTag]];case"sendTransaction":return["eth_sendRawTransaction",[n.signedTransaction]];case"getBlock":return n.blockTag?["eth_getBlockByNumber",[n.blockTag,!!n.includeTransactions]]:n.blockHash?["eth_getBlockByHash",[n.blockHash,!!n.includeTransactions]]:null;case"getTransaction":return["eth_getTransactionByHash",[n.transactionHash]];case"getTransactionReceipt":return["eth_getTransactionReceipt",[n.transactionHash]];case"call":return["eth_call",[getStatic(this.constructor,"hexlifyTransaction")(n.transaction,{from:!0}),n.blockTag]];case"estimateGas":return["eth_estimateGas",[getStatic(this.constructor,"hexlifyTransaction")(n.transaction,{from:!0})]];case"getLogs":return n.filter&&n.filter.address!=null&&(n.filter.address=getLowerCase(n.filter.address)),["eth_getLogs",[n.filter]]}return null}perform(t,n){return __awaiter$b(this,void 0,void 0,function*(){if(t==="call"||t==="estimateGas"){const fe=n.transaction;if(fe&&fe.type!=null&&BigNumber.from(fe.type).isZero()&&fe.maxFeePerGas==null&&fe.maxPriorityFeePerGas==null){const ae=yield this.getFeeData();ae.maxFeePerGas==null&&ae.maxPriorityFeePerGas==null&&(n=shallowCopy(n),n.transaction=shallowCopy(fe),delete n.transaction.type)}}const ie=this.prepareRequest(t,n);ie==null&&logger$3.throwError(t+" not implemented",Logger.errors.NOT_IMPLEMENTED,{operation:t});try{return yield this.send(ie[0],ie[1])}catch(fe){return checkError(t,fe,n)}})}_startEvent(t){t.tag==="pending"&&this._startPending(),super._startEvent(t)}_startPending(){if(this._pendingFilter!=null)return;const t=this,n=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=n,n.then(function(ie){function fe(){t.send("eth_getFilterChanges",[ie]).then(function(ae){if(t._pendingFilter!=n)return null;let le=Promise.resolve();return ae.forEach(function(he){t._emitted["t:"+he.toLowerCase()]="pending",le=le.then(function(){return t.getTransaction(he).then(function(ye){return t.emit("pending",ye),null})})}),le.then(function(){return timer(1e3)})}).then(function(){if(t._pendingFilter!=n){t.send("eth_uninstallFilter",[ie]);return}return setTimeout(function(){fe()},0),null}).catch(ae=>{})}return fe(),ie}).catch(ie=>{})}_stopEvent(t){t.tag==="pending"&&this.listenerCount("pending")===0&&(this._pendingFilter=null),super._stopEvent(t)}static hexlifyTransaction(t,n){const ie=shallowCopy(allowedTransactionKeys);if(n)for(const ae in n)n[ae]&&(ie[ae]=!0);checkProperties(t,ie);const fe={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(function(ae){if(t[ae]==null)return;const le=hexValue(BigNumber.from(t[ae]));ae==="gasLimit"&&(ae="gas"),fe[ae]=le}),["from","to","data"].forEach(function(ae){t[ae]!=null&&(fe[ae]=hexlify(t[ae]))}),t.accessList&&(fe.accessList=accessListify(t.accessList)),fe}}const logger$2=new Logger(version$8);let _nextId=1;function buildWeb3LegacyFetcher(c,t){const n="Web3LegacyFetcher";return function(ie,fe){const ae={method:ie,params:fe,id:_nextId++,jsonrpc:"2.0"};return new Promise((le,he)=>{this.emit("debug",{action:"request",fetcher:n,request:deepCopy(ae),provider:this}),t(ae,(ye,me)=>{if(ye)return this.emit("debug",{action:"response",fetcher:n,error:ye,request:ae,provider:this}),he(ye);if(this.emit("debug",{action:"response",fetcher:n,request:ae,response:me,provider:this}),me.error){const xe=new Error(me.error.message);return xe.code=me.error.code,xe.data=me.error.data,he(xe)}le(me.result)})})}}function buildEip1193Fetcher(c){return function(t,n){n==null&&(n=[]);const ie={method:t,params:n};return this.emit("debug",{action:"request",fetcher:"Eip1193Fetcher",request:deepCopy(ie),provider:this}),c.request(ie).then(fe=>(this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:ie,response:fe,provider:this}),fe),fe=>{throw this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:ie,error:fe,provider:this}),fe})}}class Web3Provider extends JsonRpcProvider{constructor(t,n){t==null&&logger$2.throwArgumentError("missing provider","provider",t);let ie=null,fe=null,ae=null;typeof t=="function"?(ie="unknown:",fe=t):(ie=t.host||t.path||"",!ie&&t.isMetaMask&&(ie="metamask"),ae=t,t.request?(ie===""&&(ie="eip-1193:"),fe=buildEip1193Fetcher(t)):t.sendAsync?fe=buildWeb3LegacyFetcher(t,t.sendAsync.bind(t)):t.send?fe=buildWeb3LegacyFetcher(t,t.send.bind(t)):logger$2.throwArgumentError("unsupported provider","provider",t),ie||(ie="unknown:")),super(ie,n),defineReadOnly(this,"jsonRpcFetchFunc",fe),defineReadOnly(this,"provider",ae)}send(t,n){return this.jsonRpcFetchFunc(t,n)}}const version$7="solidity/5.8.0",regexBytes=new RegExp("^bytes([0-9]+)$"),regexNumber=new RegExp("^(u?int)([0-9]*)$"),regexArray=new RegExp("^(.*)\\[([0-9]*)\\]$"),Zeros="0000000000000000000000000000000000000000000000000000000000000000",logger$1=new Logger(version$7);function _pack(c,t,n){switch(c){case"address":return n?zeroPad(t,32):arrayify(t);case"string":return toUtf8Bytes(t);case"bytes":return arrayify(t);case"bool":return t=t?"0x01":"0x00",n?zeroPad(t,32):arrayify(t)}let ie=c.match(regexNumber);if(ie){let fe=parseInt(ie[2]||"256");return(ie[2]&&String(fe)!==ie[2]||fe%8!==0||fe===0||fe>256)&&logger$1.throwArgumentError("invalid number type","type",c),n&&(fe=256),t=BigNumber.from(t).toTwos(fe),zeroPad(t,fe/8)}if(ie=c.match(regexBytes),ie){const fe=parseInt(ie[1]);return(String(fe)!==ie[1]||fe===0||fe>32)&&logger$1.throwArgumentError("invalid bytes type","type",c),arrayify(t).byteLength!==fe&&logger$1.throwArgumentError(`invalid value for ${c}`,"value",t),n?arrayify((t+Zeros).substring(0,66)):t}if(ie=c.match(regexArray),ie&&Array.isArray(t)){const fe=ie[1];parseInt(ie[2]||String(t.length))!=t.length&&logger$1.throwArgumentError(`invalid array length for ${c}`,"value",t);const le=[];return t.forEach(function(he){le.push(_pack(fe,he,!0))}),concat$1(le)}return logger$1.throwArgumentError("invalid type","type",c)}function pack(c,t){c.length!=t.length&&logger$1.throwArgumentError("wrong number of values; expected ${ types.length }","values",t);const n=[];return c.forEach(function(ie,fe){n.push(_pack(ie,t[fe]))}),hexlify(concat$1(n))}function keccak256(c,t){return keccak256$1(pack(c,t))}function sha256$6(c,t){return sha256$7(pack(c,t))}const lib_esm$1=Object.freeze(Object.defineProperty({__proto__:null,keccak256,pack,sha256:sha256$6},Symbol.toStringTag,{value:"Module"})),version$6="units/5.8.0",logger=new Logger(version$6),names$2=["wei","kwei","mwei","gwei","szabo","finney","ether"];function commify(c){const t=String(c).split(".");(t.length>2||!t[0].match(/^-?[0-9]*$/)||t[1]&&!t[1].match(/^[0-9]*$/)||c==="."||c==="-.")&&logger.throwArgumentError("invalid value","value",c);let n=t[0],ie="";for(n.substring(0,1)==="-"&&(ie="-",n=n.substring(1));n.substring(0,1)==="0";)n=n.substring(1);n===""&&(n="0");let fe="";for(t.length===2&&(fe="."+(t[1]||"0"));fe.length>2&&fe[fe.length-1]==="0";)fe=fe.substring(0,fe.length-1);const ae=[];for(;n.length;)if(n.length<=3){ae.unshift(n);break}else{const le=n.length-3;ae.unshift(n.substring(le)),n=n.substring(0,le)}return ie+ae.join(",")+fe}function formatUnits(c,t){if(typeof t=="string"){const n=names$2.indexOf(t);n!==-1&&(t=3*n)}return formatFixed(c,t??18)}function parseUnits(c,t){if(typeof c!="string"&&logger.throwArgumentError("value must be a string","value",c),typeof t=="string"){const n=names$2.indexOf(t);n!==-1&&(t=3*n)}return parseFixed(c,t??18)}function formatEther(c){return formatUnits(c,18)}function parseEther(c){return parseUnits(c,18)}const lib_esm=Object.freeze(Object.defineProperty({__proto__:null,commify,formatEther,formatUnits,parseEther,parseUnits},Symbol.toStringTag,{value:"Module"}));var NFTType=(c=>(c[c.ERC1155=0]="ERC1155",c[c.ERC721=1]="ERC721",c))(NFTType||{}),ProductType=(c=>(c[c.DIGITAL=0]="DIGITAL",c[c.POD=1]="POD",c[c.PHYSICAL=2]="PHYSICAL",c))(ProductType||{});class HTTPError extends Error{constructor(n,ie,fe){const ae=n.status||n.status===0?n.status:"",le=n.statusText??"",he=`${ae} ${le}`.trim(),ye=he?`status code ${he}`:"an unknown error";super(`Request failed with ${ye}: ${ie.method} ${ie.url}`);Xn(this,"response");Xn(this,"request");Xn(this,"options");this.name="HTTPError",this.response=n,this.request=ie,this.options=fe}}class TimeoutError extends Error{constructor(n){super(`Request timed out: ${n.method} ${n.url}`);Xn(this,"request");this.name="TimeoutError",this.request=n}}const supportsRequestStreams=(()=>{let c=!1,t=!1;const n=typeof globalThis.ReadableStream=="function",ie=typeof globalThis.Request=="function";if(n&&ie)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return c=!0,"half"}}).headers.has("Content-Type")}catch(fe){if(fe instanceof Error&&fe.message==="unsupported BodyInit type")return!1;throw fe}return c&&!t})(),supportsAbortController=typeof globalThis.AbortController=="function",supportsAbortSignal=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",supportsResponseStreams=typeof globalThis.ReadableStream=="function",supportsFormData=typeof globalThis.FormData=="function",requestMethods=["get","post","put","patch","head","delete"],responseTypes={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},maxSafeTimeout=2147483647,usualFormBoundarySize=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,stop=Symbol("stop"),kyOptionKeys={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},requestOptionsRegistry={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0},getBodySize=c=>{if(!c)return 0;if(c instanceof FormData){let t=0;for(const[n,ie]of c)t+=usualFormBoundarySize,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${n}"`).length,t+=typeof ie=="string"?new TextEncoder().encode(ie).length:ie.size;return t}if(c instanceof Blob)return c.size;if(c instanceof ArrayBuffer)return c.byteLength;if(typeof c=="string")return new TextEncoder().encode(c).length;if(c instanceof URLSearchParams)return new TextEncoder().encode(c.toString()).length;if("byteLength"in c)return c.byteLength;if(typeof c=="object"&&c!==null)try{const t=JSON.stringify(c);return new TextEncoder().encode(t).length}catch{return 0}return 0},withProgress=(c,t,n)=>{let ie,fe=0;return c.pipeThrough(new TransformStream({transform(ae,le){if(le.enqueue(ae),ie){fe+=ie.byteLength;let he=t===0?0:fe/t;he>=1&&(he=1-Number.EPSILON),n==null||n({percent:he,totalBytes:Math.max(t,fe),transferredBytes:fe},ie)}ie=ae},flush(){ie&&(fe+=ie.byteLength,n==null||n({percent:1,totalBytes:Math.max(t,fe),transferredBytes:fe},ie))}}))},streamResponse=(c,t)=>{if(!c.body)return c;if(c.status===204)return new Response(null,{status:c.status,statusText:c.statusText,headers:c.headers});const n=Number(c.headers.get("content-length"))||0;return new Response(withProgress(c.body,n,t),{status:c.status,statusText:c.statusText,headers:c.headers})},streamRequest=(c,t,n)=>{if(!c.body)return c;const ie=getBodySize(n??c.body);return new Request(c,{duplex:"half",body:withProgress(c.body,ie,t)})},isObject$2=c=>c!==null&&typeof c=="object",validateAndMerge=(...c)=>{for(const t of c)if((!isObject$2(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return deepMerge({},...c)},mergeHeaders=(c={},t={})=>{const n=new globalThis.Headers(c),ie=t instanceof globalThis.Headers,fe=new globalThis.Headers(t);for(const[ae,le]of fe.entries())ie&&le==="undefined"||le===void 0?n.delete(ae):n.set(ae,le);return n};function newHookValue(c,t,n){return Object.hasOwn(t,n)&&t[n]===void 0?[]:deepMerge(c[n]??[],t[n]??[])}const mergeHooks=(c={},t={})=>({beforeRequest:newHookValue(c,t,"beforeRequest"),beforeRetry:newHookValue(c,t,"beforeRetry"),afterResponse:newHookValue(c,t,"afterResponse"),beforeError:newHookValue(c,t,"beforeError")}),deepMerge=(...c)=>{let t={},n={},ie={};for(const fe of c)if(Array.isArray(fe))Array.isArray(t)||(t=[]),t=[...t,...fe];else if(isObject$2(fe)){for(let[ae,le]of Object.entries(fe))isObject$2(le)&&ae in t&&(le=deepMerge(t[ae],le)),t={...t,[ae]:le};isObject$2(fe.hooks)&&(ie=mergeHooks(ie,fe.hooks),t.hooks=ie),isObject$2(fe.headers)&&(n=mergeHeaders(n,fe.headers),t.headers=n)}return t},normalizeRequestMethod=c=>requestMethods.includes(c)?c.toUpperCase():c,retryMethods=["get","put","head","delete","options","trace"],retryStatusCodes=[408,413,429,500,502,503,504],retryAfterStatusCodes=[413,429,503],defaultRetryOptions={limit:2,methods:retryMethods,statusCodes:retryStatusCodes,afterStatusCodes:retryAfterStatusCodes,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:c=>.3*2**(c-1)*1e3},normalizeRetryOptions=(c={})=>{if(typeof c=="number")return{...defaultRetryOptions,limit:c};if(c.methods&&!Array.isArray(c.methods))throw new Error("retry.methods must be an array");if(c.statusCodes&&!Array.isArray(c.statusCodes))throw new Error("retry.statusCodes must be an array");return{...defaultRetryOptions,...c}};async function timeout(c,t,n,ie){return new Promise((fe,ae)=>{const le=setTimeout(()=>{n&&n.abort(),ae(new TimeoutError(c))},ie.timeout);ie.fetch(c,t).then(fe).catch(ae).then(()=>{clearTimeout(le)})})}async function delay(c,{signal:t}){return new Promise((n,ie)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",fe,{once:!0}));function fe(){clearTimeout(ae),ie(t.reason)}const ae=setTimeout(()=>{t==null||t.removeEventListener("abort",fe),n()},c)})}const findUnknownOptions=(c,t)=>{const n={};for(const ie in t)!(ie in requestOptionsRegistry)&&!(ie in kyOptionKeys)&&!(ie in c)&&(n[ie]=t[ie]);return n},hasSearchParameters=c=>c===void 0?!1:Array.isArray(c)?c.length>0:c instanceof URLSearchParams?c.size>0:typeof c=="object"?Object.keys(c).length>0:typeof c=="string"?c.trim().length>0:!!c;var ei,oi;const Yn=class Yn{constructor(t,n={}){Xn(this,"request");Xn(this,"abortController");Xn(this,"_retryCount",0);Xn(this,"_input");Xn(this,"_options");Xn(this,"_originalRequest");var ie,fe,ae;if(this._input=t,this._options={...n,headers:mergeHeaders(this._input.headers,n.headers),hooks:mergeHooks({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},n.hooks),method:normalizeRequestMethod(n.method??this._input.method??"GET"),prefixUrl:String(n.prefixUrl||""),retry:normalizeRetryOptions(n.retry),throwHttpErrors:n.throwHttpErrors!==!1,timeout:n.timeout??1e4,fetch:n.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(supportsAbortController&&supportsAbortSignal){const le=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=le?AbortSignal.any([le,this.abortController.signal]):this.abortController.signal}if(supportsRequestStreams&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=((fe=(ie=this._options).stringifyJson)==null?void 0:fe.call(ie,this._options.json))??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),hasSearchParameters(this._options.searchParams)){const he="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(ai(ae=Yn,ei,oi).call(ae,this._options.searchParams)).toString()),ye=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,he);(supportsFormData&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(ye,{...this.request}),this._options)}if(this._options.onUploadProgress){if(typeof this._options.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!supportsRequestStreams)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=streamRequest(this.request,this._options.onUploadProgress,this._options.body))}}static create(t,n){var he,ye;const ie=new Yn(t,n),fe=async()=>{if(typeof ie._options.timeout=="number"&&ie._options.timeout>maxSafeTimeout)throw new RangeError(`The \`timeout\` option cannot be greater than ${maxSafeTimeout}`);await Promise.resolve();let me=await ie._fetch();for(const xe of ie._options.hooks.afterResponse){const Ee=await xe(ie.request,ie._options,ie._decorateResponse(me.clone()));Ee instanceof globalThis.Response&&(me=Ee)}if(ie._decorateResponse(me),!me.ok&&ie._options.throwHttpErrors){let xe=new HTTPError(me,ie.request,ie._options);for(const Ee of ie._options.hooks.beforeError)xe=await Ee(xe);throw xe}if(ie._options.onDownloadProgress){if(typeof ie._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!supportsResponseStreams)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return streamResponse(me.clone(),ie._options.onDownloadProgress)}return me},le=(ie._options.retry.methods.includes(ie.request.method.toLowerCase())?ie._retry(fe):fe()).finally(async()=>{var Ee,Se;const me=ie._originalRequest,xe=[];me&&!me.bodyUsed&&xe.push((Ee=me.body)==null?void 0:Ee.cancel()),ie.request.bodyUsed||xe.push((Se=ie.request.body)==null?void 0:Se.cancel()),await Promise.all(xe)});for(const[me,xe]of Object.entries(responseTypes))me==="bytes"&&typeof((ye=(he=globalThis.Response)==null?void 0:he.prototype)==null?void 0:ye.bytes)!="function"||(le[me]=async()=>{ie.request.headers.set("accept",ie.request.headers.get("accept")||xe);const Ee=await le;if(me==="json"){if(Ee.status===204)return"";const Se=await Ee.text();return Se===""?"":n.parseJson?n.parseJson(Se):JSON.parse(Se)}return Ee[me]()});return le}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof TimeoutError)throw t;if(t instanceof HTTPError){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;const ie=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(ie&&this._options.retry.afterStatusCodes.includes(t.response.status)){let fe=Number(ie)*1e3;Number.isNaN(fe)?fe=Date.parse(ie)-Date.now():fe>=Date.parse("2024-01-01")&&(fe-=Date.now());const ae=this._options.retry.maxRetryAfter??fe;return fe<ae?fe:ae}if(t.response.status===413)throw t}const n=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,n)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(n){const ie=Math.min(this._calculateRetryDelay(n),maxSafeTimeout);if(this._retryCount<1)throw n;await delay(ie,{signal:this._options.signal});for(const fe of this._options.hooks.beforeRetry)if(await fe({request:this.request,options:this._options,error:n,retryCount:this._retryCount})===stop)return;return this._retry(t)}}async _fetch(){for(const n of this._options.hooks.beforeRequest){const ie=await n(this.request,this._options);if(ie instanceof Request){this.request=ie;break}if(ie instanceof Response)return ie}const t=findUnknownOptions(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):timeout(this._originalRequest,t,this.abortController,this._options)}};ei=new WeakSet,oi=function(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,n])=>n!==void 0)):t},ii(Yn,ei);let Ky=Yn;/*! MIT License © Sindre Sorhus */const createInstance=c=>{const t=(n,ie)=>Ky.create(n,validateAndMerge(c,ie));for(const n of requestMethods)t[n]=(ie,fe)=>Ky.create(ie,validateAndMerge(c,fe,{method:n}));return t.create=n=>createInstance(validateAndMerge(n)),t.extend=n=>(typeof n=="function"&&(n=n(c??{})),createInstance(validateAndMerge(c,n))),t.stop=stop,t},ky=createInstance();async function uploadMetadata(c,t,n){return(await(await n.post("uploader/cdn-upload-json",{json:{data:c,key:`record-metadata/${t}.json`}})).json()).url}async function startRecord(c,t,n,ie,fe,ae){return(await(await ae.post("web3/record/transactions",{json:{uris:fe,network:ie,data:{productId:c,skuIds:t},productId:c,skuIds:t,metadata:{},shopId:n,txType:"RECORD"}})).json()).data.id}async function getShopInfo(c,t,n){const ie=(await(await n.get(`shops/v2/public/${t}`)).json()).data.deployedContracts.filter(fe=>fe.type===c);return ie.length===0?{nftContractAddress:"",shopContractAddress:""}:{nftContractAddress:ie[0].deployedNFTAddress,shopContractAddress:ie[0].deployedShopAddress}}async function deleteRecordTransaction(c,t){await t.delete(`web3/record/transactions/${c}`)}async function web3Callback(c,t,n,ie){const fe={"X-API-KEY":"ho8homr9e8p4fwii7tjiz41xs4hlbl2h4i"};return(await(await ky.create({headers:fe,prefixUrl:n==="TESTNET"?"https://web3dev.droplinked.com/":"https://web3.droplinked.com/"}).post("transactions",{json:{transaction_id:c,callback_url:ie,chain:t,network:n},headers:fe})).json()).data}async function getProductData(c,t){return(await(await t.get(`product-v2/public/${c}`)).json()).data}async function transformProductData(c,t){const n=await getProductData(c,t);if(!n||n.skus.length===0)throw new Error("Product not found or no SKUs available");return{productData:{acceptsManageWallet:!0,commission:n.affiliate.commissionPercent||0,description:n.description,productTitle:n.title,royalty:n.skus[0].royalty||0,type:ProductType[n.type.toUpperCase()]||ProductType.DIGITAL},skuData:n.skus.map(ie=>{var fe;return{amount:ie.inventory.quantity,imageUrl:((fe=n.images[n.defaultImageIndex])==null?void 0:fe.original)||"",skuID:ie.id,skuProperties:ie}})}}async function updateUris(c,t,n){return(await(await n.put(`web3/record/transactions/${c}/uris`,{json:{uris:t}})).json()).data}async function updateHash(c,t,n,ie){return(await(await ie.put(`web3/${c}/transactions/${t}/hash`,{json:{transactionHash:n}})).json()).data}async function getProductDataForRecord(c,t){if(!c)throw new InvalidParametersException(Chains.BASE,"Product ID is required");let n,ie=[];try{const{productData:fe,skuData:ae}=await transformProductData(c,t);n=fe,ie=ae}catch(fe){throw new Error(`Failed to fetch product data: ${fe}`)}if(!n||ie.length===0)throw new Error("Product not found or no SKUs available");return{productData:n,skuData:ie}}async function getNonce(c,t){return await(await t.get(`web3/auth/nonce?wallet=${c}`)).json()}async function getAddress(c,t,n){const ie=fe=>fe.charAt(0).toUpperCase()+fe.slice(1).toLowerCase();try{const fe=t===Network.TESTNET?"apiv3dev":"apiv3",ae=ie(c),le=ie(Network[t]),he=`https://${fe}.droplinked.com/storage/${ae}${le}ContractAddress${n}`;return(await await ky.get(he).json()).value}catch(fe){throw console.error(`Failed to fetch ${n.toLowerCase()} address:`,fe),new Error(`Unable to get ${n.toLowerCase()} address`)}}async function getDeployerAddress(c,t){return getAddress(c,t,"Deployer")}async function getProxyAddress(c,t){return getAddress(c,t,"Proxy")}async function startPayment(c,t,n,ie,fe){return(await(await fe.post("web3/payment/transactions",{json:{network:n,token:t,shopId:ie,orderId:c}})).json()).data.id}async function getCartData(c,t,n,ie){const fe=await(await ie.get(`web3/payment/distribution/${c}/${t}/${n}`)).json();return{paymentData:fe.data,orderID:fe.orderID}}async function getPurchaseSignature(c,t,n){const ie=await(await n.get(`nfts/by-order?orderId=${c}&skuId=${t}`)).json();return console.log("Purchase signature response:",ie),{signature:ie.purchaseSignature,shopContractAddress:ie.shopContractAddress,networkName:ie.networkName,nftId:ie._id}}async function sendClaim(c,t,n){return await(await n.post("nfts/transfer",{json:{transactionId:t,nftId:c}})).json()}async function getShopByteCode(){try{return String((await await ky.get("https://apiv3dev.droplinked.com/storage/shopByteCodeType0").json()).value)}catch(c){throw console.error(`Failed to get shop bytecode: ${c}`),new Error("Unable to get shop bytecode")}}async function getShopDeployInfo(c,t){const n=(await(await t.get(`shops/v2/public/${c}`)).json()).data;return{name:n.name,description:n.description,logo:n.logo,url:n.url,deployedContracts:n.deployedContracts}}const shopABI=[{inputs:[{internalType:"string",name:"_shopName",type:"string"},{internalType:"string",name:"_shopAddress",type:"string"},{internalType:"address",name:"_shopOwner",type:"address"},{internalType:"string",name:"_shopLogo",type:"string"},{internalType:"string",name:"_shopDescription",type:"string"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"AccessDenied",type:"error"},{inputs:[],name:"AffiliatePOD",type:"error"},{inputs:[],name:"AlreadyClaimed",type:"error"},{inputs:[{internalType:"address",name:"requester",type:"address"},{internalType:"uint256",name:"productId",type:"uint256"}],name:"AlreadyRequested",type:"error"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"producer",type:"address"}],name:"NotEnoughTokens",type:"error"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"OwnableInvalidOwner",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"OwnableUnauthorizedAccount",type:"error"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"ProductDoesntExist",type:"error"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"ProductExists",type:"error"},{inputs:[],name:"ReentrancyGuardReentrantCall",type:"error"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"RequestAlreadyConfirmed",type:"error"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"RequestDoesntExist",type:"error"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"RequestNotConfirmed",type:"error"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"}],name:"ShopDoesNotOwnToken",type:"error"},{inputs:[],name:"oldPrice",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"requestId",type:"uint256"},{indexed:!0,internalType:"address",name:"approver",type:"address"}],name:"AffiliateRequestApproved",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"requestId",type:"uint256"},{indexed:!0,internalType:"address",name:"disapprover",type:"address"}],name:"AffiliateRequestDisapproved",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"requestId",type:"uint256"},{indexed:!0,internalType:"uint256",name:"productId",type:"uint256"},{indexed:!1,internalType:"address",name:"requester",type:"address"}],name:"AffiliateRequested",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"count",type:"uint256"}],name:"BatchProductRegistered",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"productId",type:"uint256"},{indexed:!0,internalType:"address",name:"claimer",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"ProductClaimed",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"productId",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!1,internalType:"string",name:"uri",type:"string"}],name:"ProductRegistered",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"productId",type:"uint256"},{indexed:!0,internalType:"address",name:"owner",type:"address"}],name:"ProductUnregistered",type:"event"},{inputs:[],name:"affiliateRequestCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"affiliateRequests",outputs:[{internalType:"address",name:"publisher",type:"address"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"bool",name:"isConfirmed",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"approveRequest",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"manager",type:"address"},{internalType:"bytes",name:"signature",type:"bytes"},{components:[{components:[{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"uint256",name:"nullifier",type:"uint256"}],internalType:"struct PurchasedItem[]",name:"cart",type:"tuple[]"},{internalType:"address",name:"shop",type:"address"}],internalType:"struct PurchaseSignature",name:"purchaseSignature",type:"tuple"}],name:"claimPurchase",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"disapproveRequest",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"droplinkedManagerWallet",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"getAffiliate",outputs:[{components:[{internalType:"address",name:"publisher",type:"address"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"bool",name:"isConfirmed",type:"bool"}],internalType:"struct AffiliateRequest",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAffiliateRequestCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"messageHash",type:"bytes32"}],name:"getEthSignedMessageHash",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"pure",type:"function"},{inputs:[{components:[{components:[{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"uint256",name:"nullifier",type:"uint256"}],internalType:"struct PurchasedItem[]",name:"cart",type:"tuple[]"},{internalType:"address",name:"shop",type:"address"}],internalType:"struct PurchaseSignature",name:"data",type:"tuple"}],name:"getMessageHash",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"getProduct",outputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],internalType:"struct Product",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[],name:"getProductCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],internalType:"struct Product",name:"product",type:"tuple"}],name:"getProductId",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"nftAddress",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getProductIdV2",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint256",name:"affiliateId",type:"uint256"}],name:"getProductViaAffiliateId",outputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],internalType:"struct Product",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopAddress",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopDescription",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopLogo",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopName",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopOwner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"address",name:"requester",type:"address"}],name:"isRequestSubmited",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"managers",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"address",name:"nftAddress",type:"address"},{internalType:"string",name:"uri",type:"string"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bool",name:"accepted",type:"bool"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"},{internalType:"uint256",name:"royalty",type:"uint256"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"}],internalType:"struct RecordData",name:"mintData",type:"tuple"}],name:"mintAndRegister",outputs:[{internalType:"uint256",name:"productId",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"nftAddress",type:"address"},{internalType:"string",name:"uri",type:"string"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bool",name:"accepted",type:"bool"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"},{internalType:"uint256",name:"royalty",type:"uint256"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"}],internalType:"struct RecordData[]",name:"recordData",type:"tuple[]"}],name:"mintAndRegisterBatch",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"nullifiers",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC1155BatchReceived",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC1155Received",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC721Received",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"productCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"products",outputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"ethSignedMessageHash",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"recoverSigner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"pure",type:"function"},{inputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],internalType:"struct Product",name:"p",type:"tuple"}],name:"registerProduct",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"requestAffiliate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"manager",type:"address"}],name:"revokeManager",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"manager",type:"address"}],name:"setManager",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"shopInfo",outputs:[{internalType:"string",name:"shopName",type:"string"},{internalType:"string",name:"shopAddress",type:"string"},{internalType:"string",name:"shopLogo",type:"string"},{internalType:"string",name:"shopDescription",type:"string"},{internalType:"address",name:"shopOwner",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"sig",type:"bytes"}],name:"splitSignature",outputs:[{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"},{internalType:"uint8",name:"v",type:"uint8"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newManager",type:"address"}],name:"transferManagerShip",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"unregisterProduct",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newManagerWallet",type:"address"}],name:"updateDroplinkedManagerWallet",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"signer",type:"address"},{internalType:"bytes",name:"signature",type:"bytes"},{components:[{components:[{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"uint256",name:"nullifier",type:"uint256"}],internalType:"struct PurchasedItem[]",name:"cart",type:"tuple[]"},{internalType:"address",name:"shop",type:"address"}],internalType:"struct PurchaseSignature",name:"data",type:"tuple"}],name:"verifyPurchase",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"pure",type:"function"}];function getTransactionLink({blockchain:c,transactionHash:t,isTestnet:n=!1}){const ie=t.trim();switch(c.toUpperCase()){case"CASPER":return`https://${n?"testnet.":""}cspr.live/deploy/${ie}`;case"STACKS":return`https://explorer.hiro.so/txid/${ie}?chain=${n?"testnet":"mainnet"}`;case"POLYGON":return`https://${n?"amoy.":""}polygonscan.com/tx/${ie}`;case"XRPLSIDECHAIN":return`https://evm-sidechain.xrpl.org/tx/${ie}`;case"BINANCE":return`https://${n?"testnet.":""}bscscan.com/tx/${ie}`;case"NEAR":return`https://explorer.${n?"testnet":"mainnet"}.aurora.dev/tx/${ie}`;case"BASE":return`https://base${n?"-sepolia":""}.blockscout.com/tx/${ie}`;case"LINEA":return`https://${n?"sepolia.":""}lineascan.build/tx/${ie}`;case"ETH":return`https://${n?"sepolia.":""}etherscan.io/tx/${ie}`;case"SOLANA":return`https://explorer.solana.com/tx/${ie}?cluster=${n?"devnet":"mainnet"}`;case"REDBELLY":return n?`https://redbelly.testnet.routescan.io/tx/${ie}`:`https://redbelly.routescan.io/tx/${ie}`;case"SKALE":return`https://${n?"giant-half-dual-testnet.explorer.testnet.skalenodes.com":"honorable-steel-rasalhague.explorer.mainnet.skalenodes.com"}/tx/${ie}`;case"BITLAYER":return n?`https://testnet.btrscan.com/tx/${ie}`:`https://www.btrscan.com/tx/${ie}`;default:return""}}async function ensureWalletOnChainFromConfig(c,t,n){const ie=t[n];if(!ie)throw new Error(`Network config not found for ${t.name} (${n})`);const fe=c.provider;if(!(fe!=null&&fe.request))throw new Error("Provider does not support network switching");const ae=await c.getNetwork(),le=Number(ie.chainId);if(ae.chainId===le)return;try{await fe.request({method:"wallet_switchEthereumChain",params:[{chainId:ie.chainId}]})}catch(ye){if(ye.code===4902)await fe.request({method:"wallet_addEthereumChain",params:[{chainId:ie.chainId,chainName:ie.chainName,rpcUrls:ie.rpcUrls,nativeCurrency:ie.nativeCurrency}]});else throw ye}if((await c.getNetwork()).chainId!==le)throw new Error(`Failed to switch to ${t.name} (${n})`)}function getBaseUrl(c){return c===Network.MAINNET?"https://apiv3.droplinked.com":c===Network.TESTNET?"https://apiv3dev.droplinked.com":"http://127.0.0.1:3000"}async function getGasPrice(c){return(await c.getGasPrice()).toBigInt()}const deployerABI=[{inputs:[],name:"InvalidInitialization",type:"error"},{inputs:[],name:"NotInitializing",type:"error"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"OwnableInvalidOwner",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"OwnableUnauthorizedAccount",type:"error"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"newFee",type:"uint256"}],name:"DroplinkedFeeUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"newHeartBeat",type:"uint256"}],name:"HeartBeatUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint64",name:"version",type:"uint64"}],name:"Initialized",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"shop",type:"address"},{indexed:!1,internalType:"address",name:"nftContract",type:"address"}],name:"ShopDeployed",type:"event"},{inputs:[{internalType:"bytes",name:"bytecode",type:"bytes"},{internalType:"bytes32",name:"salt",type:"bytes32"}],name:"deployShop",outputs:[{internalType:"address",name:"shop",type:"address"},{internalType:"address",name:"nftContract",type:"address"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"droplinkedFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"droplinkedWallet",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getDroplinkedFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getHeartBeat",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"heartBeat",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"_heartBeat",type:"uint256"},{internalType:"address",name:"_droplinkedWallet",type:"address"},{internalType:"uint256",name:"_droplinkedFee",type:"uint256"}],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"nftContracts",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"shopOwner",type:"address"},{internalType:"uint256",name:"",type:"uint256"}],name:"nftOwners",outputs:[{internalType:"address",name:"nftContracts",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"newFee",type:"uint256"}],name:"setDroplinkedFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"newHeartBeat",type:"uint256"}],name:"setHeartBeat",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"shopAddresses",outputs:[{internalType:"contract IDropShop",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"shopCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"shopOwner",type:"address"},{internalType:"uint256",name:"",type:"uint256"}],name:"shopOwners",outputs:[{internalType:"address",name:"shops",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"}],sixify=c=>c.toString().padStart(6,"0");async function getConstructorArgs(c,t,n){return[c.shopName||"",c.shopAddress||"",n,c.shopLogo||"",c.shopDescription||"",t]}async function deployEVMShop(c,t,n){console.log({...c,...t,...n});const{modalInterface:ie}=t,{chain:fe,network:ae,provider:le}=c,he=le.getSigner(),ye=await getDeployerAddress(fe,ae),me=new Contract(ye,deployerABI,he),xe=await getShopByteCode(),Ee=await he.getAddress(),Se="0x"+Ee.split("0x")[1]+"000000000000000000"+sixify(Math.floor(Math.random()*1e6)+1),Me=await getConstructorArgs(n,ye,Ee),Be=defaultAbiCoder.encode(["string","string","address","string","string","address"],Me);try{let $e;const Ce=xe+Be.split("0x")[1];console.log({fullBytecode:Ce}),c.chain!==Chains.SKALE?(await me.callStatic.deployShop(Ce,Se),$e=await me.deployShop(Ce,Se,{})):$e=await me.deployShop(Ce,Se);const Ue=(await $e.wait()).logs.map(Ve=>{try{return me.interface.parseLog(Ve)}catch{return null}}).filter(Ve=>Ve!=null).find(Ve=>Ve.name==="ShopDeployed"),qe=Ue.args.shop,He=Ue.args.nftContract;return{transactionHash:$e.hash,deployedShopAddress:qe,deployedNFTAddress:He}}catch($e){if(ie.error("Error during shop deployment",`${$e.message||$e}`),$e.code.toString()==="ACTION_REJECTED")throw new UserDeniedException("Deployer");try{const Ce=me.interface.parseError($e.data);throw ie.error("Contract error",`${Ce}`),Ce}catch(Ce){throw ie.error("Unhandled error during shop deployment.",`${Ce||$e}`),new Error(Ce||"Unknown error occurred.")}}}function getRecordData(c,t,n){const{acceptsManageWallet:ie,amount:fe,royalty:ae,type:le}=c;return{nftAddress:n,uri:t,amount:fe,accepted:ie,affiliatePercentage:ae,royalty:ae,nftType:NFTType.ERC1155,productType:le}}async function prepareRecordData(c,t,n,ie){const{nftContract:fe}=ie;if(!fe)throw new InvalidParametersException(c.chain,"nftContract");const{description:ae}=n,{skuID:le}=t,he={...t,...n},ye={...he.skuProperties},me={name:he.productTitle,description:ae,image:he.imageUrl,properties:ye},xe=await uploadMetadata(me,le,ie.axiosInstance);return getRecordData(he,xe,fe)}async function doRecordProduct(c,t,n,ie){const{modalInterface:fe,nftContract:ae,shopContractAddress:le}=t;if(!ae||!le)throw fe.error("Invalid Parameters","nftContract||shopContractAddress"),new InvalidParametersException(c.chain,"nftContract||shopContractAddress");fe.changeStep("Connecting to wallet");const he=c.provider.getSigner(),ye=new Contract(le,shopABI,he);try{fe.changeStep("Preparing products for recording");const me=await Promise.all(ie.map(Ee=>prepareRecordData(c,Ee,n,t)));let xe;return c.chain!==Chains.SKALE?(await ye.callStatic.mintAndRegisterBatch(me),fe.changeStep("Recording products on blockchain"),xe=await ye.mintAndRegisterBatch(me)):(fe.changeStep("Recording products on blockchain"),xe=await ye.mintAndRegisterBatch(me)),fe.changeStep("Waiting for transaction confirmation"),await xe.wait(),{transactionHash:xe.hash,metadataUrls:me.map(Ee=>Ee.uri)}}catch(me){if(me.code&&me.code.toString()==="ACTION_REJECTED")throw t.modalInterface.error("Transaction Rejected","ACTION_REJECTED"),new Error("Transaction Rejected");try{if(me.data&&me.data!=="0x"){const xe=ye.interface.parseError(me.data);throw xe.name==="OwnableUnauthorizedAccount"?(t.modalInterface.error("Unauthorized","OwnableUnauthorizedAccount"),new Unauthorized(c.chain,"record",await he.getAddress(),le)):(t.modalInterface.error(xe.name,xe.args.join(", ")),t.modalInterface.error(me,xe.name),me)}else throw fe.error("Transaction reverted without reason",`${me}`),me}catch(xe){throw fe.error("Unexpected error",`${xe}`),xe}}}async function recordProduct({productId:c,chain:t,axiosInstance:n,shopId:ie,network:fe,stepizer:ae,provider:le}){let he="",ye="";if(ae.changeStep("Starting record process"),ie!==""){const Me=await getShopInfo(t,ie,n);he=Me.nftContractAddress,ye=Me.shopContractAddress}const me=new Web3Provider(le,"any");if(!he||!ye){ae.changeStep("Deploying shop contract");const Me={chain:t,network:fe,provider:me},Be={axiosInstance:n,modalInterface:ae,nftContract:"",shopContractAddress:""},{description:$e,logo:Ce,name:ke,url:Pe,deployedContracts:Ue}=await getShopDeployInfo(ie,n),{deployedNFTAddress:qe,deployedShopAddress:He,transactionHash:Ve}=await deployEVMShop(Me,Be,{shopName:ke,shopAddress:Pe,shopLogo:Ce,shopDescription:$e}),Ye=[...Ue||[],{type:t,deployedShopAddress:He,transactionId:Ve,deployedNFTAddress:qe,isCircle:!1,platform:"DROPLINKED",status:"SUCCESS"}];console.log({newDeployedContracts:Ye}),he=qe,ye=He,ae.changeStep("Shop deployed successfully")}await ensureWalletOnChainFromConfig(me,getChainByName(t),fe);const{productData:xe,skuData:Ee}=await getProductDataForRecord(c,n);if(!ie)throw new InvalidParametersException(t,"shopId");const Se=await startRecord(c,Ee.map(Me=>Me.skuID),ie,t,[],n);try{const $e=await doRecordProduct({chain:t,network:fe,provider:me},{axiosInstance:n,modalInterface:ae,nftContract:he,shopContractAddress:ye},xe,Ee);await updateUris(Se,$e.metadataUrls,n),await updateHash("record",Se,$e.transactionHash,n);const Ce=`${getBaseUrl(fe)}/web3/record/callback/events/${Se}`;if(!await web3Callback($e.transactionHash,t,Network[fe],Ce))throw new Web3CallbackFailedException("Record");return{...$e,transactionId:Se,transactionHashUrl:getTransactionLink({blockchain:t,transactionHash:$e.transactionHash,isTestnet:fe!==Network.MAINNET})}}catch(Me){throw console.error("Error during recording process:",Me),await deleteRecordTransaction(Se,n),Me}}var utils$e={};const require$$0$3=getAugmentedNamespace(lib_esm$b),require$$1$2=getAugmentedNamespace(lib_esm$f),require$$2$3=getAugmentedNamespace(lib_esm$d),require$$3=getAugmentedNamespace(lib_esm$8),require$$4$3=getAugmentedNamespace(lib_esm$j),require$$5=getAugmentedNamespace(lib_esm$c),require$$6$2=getAugmentedNamespace(lib_esm$6),require$$7=getAugmentedNamespace(lib_esm$4),require$$8=getAugmentedNamespace(lib_esm$h),require$$9=getAugmentedNamespace(lib_esm$k),require$$10=getAugmentedNamespace(lib_esm$7),require$$11$1=getAugmentedNamespace(lib_esm$1),require$$12=getAugmentedNamespace(lib_esm$5),require$$13=getAugmentedNamespace(lib_esm$i),require$$14=getAugmentedNamespace(lib_esm$g),require$$15=getAugmentedNamespace(lib_esm$a),require$$16=getAugmentedNamespace(lib_esm$e),require$$17$1=getAugmentedNamespace(lib_esm$9),require$$18=getAugmentedNamespace(lib_esm),require$$19=getAugmentedNamespace(lib_esm$3),require$$20=getAugmentedNamespace(lib_esm$2);(function(c){var t=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(_e,se,ce,de){de===void 0&&(de=ce),Object.defineProperty(_e,de,{enumerable:!0,get:function(){return se[ce]}})}:function(_e,se,ce,de){de===void 0&&(de=ce),_e[de]=se[ce]}),n=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(_e,se){Object.defineProperty(_e,"default",{enumerable:!0,value:se})}:function(_e,se){_e.default=se}),ie=commonjsGlobal&&commonjsGlobal.__importStar||function(_e){if(_e&&_e.__esModule)return _e;var se={};if(_e!=null)for(var ce in _e)ce!=="default"&&Object.prototype.hasOwnProperty.call(_e,ce)&&t(se,_e,ce);return n(se,_e),se};Object.defineProperty(c,"__esModule",{value:!0}),c.formatBytes32String=c.Utf8ErrorFuncs=c.toUtf8String=c.toUtf8CodePoints=c.toUtf8Bytes=c._toEscapedUtf8String=c.nameprep=c.hexDataSlice=c.hexDataLength=c.hexZeroPad=c.hexValue=c.hexStripZeros=c.hexConcat=c.isHexString=c.hexlify=c.base64=c.base58=c.TransactionDescription=c.LogDescription=c.Interface=c.SigningKey=c.HDNode=c.defaultPath=c.isBytesLike=c.isBytes=c.zeroPad=c.stripZeros=c.concat=c.arrayify=c.shallowCopy=c.resolveProperties=c.getStatic=c.defineReadOnly=c.deepCopy=c.checkProperties=c.poll=c.fetchJson=c._fetchData=c.RLP=c.Logger=c.checkResultErrors=c.FormatTypes=c.ParamType=c.FunctionFragment=c.EventFragment=c.ErrorFragment=c.ConstructorFragment=c.Fragment=c.defaultAbiCoder=c.AbiCoder=void 0,c.Indexed=c.Utf8ErrorReason=c.UnicodeNormalizationForm=c.SupportedAlgorithm=c.mnemonicToSeed=c.isValidMnemonic=c.entropyToMnemonic=c.mnemonicToEntropy=c.getAccountPath=c.verifyTypedData=c.verifyMessage=c.recoverPublicKey=c.computePublicKey=c.recoverAddress=c.computeAddress=c.getJsonWalletAddress=c.TransactionTypes=c.serializeTransaction=c.parseTransaction=c.accessListify=c.joinSignature=c.splitSignature=c.soliditySha256=c.solidityKeccak256=c.solidityPack=c.shuffled=c.randomBytes=c.sha512=c.sha256=c.ripemd160=c.keccak256=c.computeHmac=c.commify=c.parseUnits=c.formatUnits=c.parseEther=c.formatEther=c.isAddress=c.getCreate2Address=c.getContractAddress=c.getIcapAddress=c.getAddress=c._TypedDataEncoder=c.id=c.isValidName=c.namehash=c.hashMessage=c.dnsEncode=c.parseBytes32String=void 0;var fe=require$$0$3;Object.defineProperty(c,"AbiCoder",{enumerable:!0,get:function(){return fe.AbiCoder}}),Object.defineProperty(c,"checkResultErrors",{enumerable:!0,get:function(){return fe.checkResultErrors}}),Object.defineProperty(c,"ConstructorFragment",{enumerable:!0,get:function(){return fe.ConstructorFragment}}),Object.defineProperty(c,"defaultAbiCoder",{enumerable:!0,get:function(){return fe.defaultAbiCoder}}),Object.defineProperty(c,"ErrorFragment",{enumerable:!0,get:function(){return fe.ErrorFragment}}),Object.defineProperty(c,"EventFragment",{enumerable:!0,get:function(){return fe.EventFragment}}),Object.defineProperty(c,"FormatTypes",{enumerable:!0,get:function(){return fe.FormatTypes}}),Object.defineProperty(c,"Fragment",{enumerable:!0,get:function(){return fe.Fragment}}),Object.defineProperty(c,"FunctionFragment",{enumerable:!0,get:function(){return fe.FunctionFragment}}),Object.defineProperty(c,"Indexed",{enumerable:!0,get:function(){return fe.Indexed}}),Object.defineProperty(c,"Interface",{enumerable:!0,get:function(){return fe.Interface}}),Object.defineProperty(c,"LogDescription",{enumerable:!0,get:function(){return fe.LogDescription}}),Object.defineProperty(c,"ParamType",{enumerable:!0,get:function(){return fe.ParamType}}),Object.defineProperty(c,"TransactionDescription",{enumerable:!0,get:function(){return fe.TransactionDescription}});var ae=require$$1$2;Object.defineProperty(c,"getAddress",{enumerable:!0,get:function(){return ae.getAddress}}),Object.defineProperty(c,"getCreate2Address",{enumerable:!0,get:function(){return ae.getCreate2Address}}),Object.defineProperty(c,"getContractAddress",{enumerable:!0,get:function(){return ae.getContractAddress}}),Object.defineProperty(c,"getIcapAddress",{enumerable:!0,get:function(){return ae.getIcapAddress}}),Object.defineProperty(c,"isAddress",{enumerable:!0,get:function(){return ae.isAddress}});var le=ie(require$$2$3);c.base64=le;var he=require$$3;Object.defineProperty(c,"base58",{enumerable:!0,get:function(){return he.Base58}});var ye=require$$4$3;Object.defineProperty(c,"arrayify",{enumerable:!0,get:function(){return ye.arrayify}}),Object.defineProperty(c,"concat",{enumerable:!0,get:function(){return ye.concat}}),Object.defineProperty(c,"hexConcat",{enumerable:!0,get:function(){return ye.hexConcat}}),Object.defineProperty(c,"hexDataSlice",{enumerable:!0,get:function(){return ye.hexDataSlice}}),Object.defineProperty(c,"hexDataLength",{enumerable:!0,get:function(){return ye.hexDataLength}}),Object.defineProperty(c,"hexlify",{enumerable:!0,get:function(){return ye.hexlify}}),Object.defineProperty(c,"hexStripZeros",{enumerable:!0,get:function(){return ye.hexStripZeros}}),Object.defineProperty(c,"hexValue",{enumerable:!0,get:function(){return ye.hexValue}}),Object.defineProperty(c,"hexZeroPad",{enumerable:!0,get:function(){return ye.hexZeroPad}}),Object.defineProperty(c,"isBytes",{enumerable:!0,get:function(){return ye.isBytes}}),Object.defineProperty(c,"isBytesLike",{enumerable:!0,get:function(){return ye.isBytesLike}}),Object.defineProperty(c,"isHexString",{enumerable:!0,get:function(){return ye.isHexString}}),Object.defineProperty(c,"joinSignature",{enumerable:!0,get:function(){return ye.joinSignature}}),Object.defineProperty(c,"zeroPad",{enumerable:!0,get:function(){return ye.zeroPad}}),Object.defineProperty(c,"splitSignature",{enumerable:!0,get:function(){return ye.splitSignature}}),Object.defineProperty(c,"stripZeros",{enumerable:!0,get:function(){return ye.stripZeros}});var me=require$$5;Object.defineProperty(c,"_TypedDataEncoder",{enumerable:!0,get:function(){return me._TypedDataEncoder}}),Object.defineProperty(c,"dnsEncode",{enumerable:!0,get:function(){return me.dnsEncode}}),Object.defineProperty(c,"hashMessage",{enumerable:!0,get:function(){return me.hashMessage}}),Object.defineProperty(c,"id",{enumerable:!0,get:function(){return me.id}}),Object.defineProperty(c,"isValidName",{enumerable:!0,get:function(){return me.isValidName}}),Object.defineProperty(c,"namehash",{enumerable:!0,get:function(){return me.namehash}});var xe=require$$6$2;Object.defineProperty(c,"defaultPath",{enumerable:!0,get:function(){return xe.defaultPath}}),Object.defineProperty(c,"entropyToMnemonic",{enumerable:!0,get:function(){return xe.entropyToMnemonic}}),Object.defineProperty(c,"getAccountPath",{enumerable:!0,get:function(){return xe.getAccountPath}}),Object.defineProperty(c,"HDNode",{enumerable:!0,get:function(){return xe.HDNode}}),Object.defineProperty(c,"isValidMnemonic",{enumerable:!0,get:function(){return xe.isValidMnemonic}}),Object.defineProperty(c,"mnemonicToEntropy",{enumerable:!0,get:function(){return xe.mnemonicToEntropy}}),Object.defineProperty(c,"mnemonicToSeed",{enumerable:!0,get:function(){return xe.mnemonicToSeed}});var Ee=require$$7;Object.defineProperty(c,"getJsonWalletAddress",{enumerable:!0,get:function(){return Ee.getJsonWalletAddress}});var Se=require$$8;Object.defineProperty(c,"keccak256",{enumerable:!0,get:function(){return Se.keccak256}});var Me=require$$9;Object.defineProperty(c,"Logger",{enumerable:!0,get:function(){return Me.Logger}});var Be=require$$10;Object.defineProperty(c,"computeHmac",{enumerable:!0,get:function(){return Be.computeHmac}}),Object.defineProperty(c,"ripemd160",{enumerable:!0,get:function(){return Be.ripemd160}}),Object.defineProperty(c,"sha256",{enumerable:!0,get:function(){return Be.sha256}}),Object.defineProperty(c,"sha512",{enumerable:!0,get:function(){return Be.sha512}});var $e=require$$11$1;Object.defineProperty(c,"solidityKeccak256",{enumerable:!0,get:function(){return $e.keccak256}}),Object.defineProperty(c,"solidityPack",{enumerable:!0,get:function(){return $e.pack}}),Object.defineProperty(c,"soliditySha256",{enumerable:!0,get:function(){return $e.sha256}});var Ce=require$$12;Object.defineProperty(c,"randomBytes",{enumerable:!0,get:function(){return Ce.randomBytes}}),Object.defineProperty(c,"shuffled",{enumerable:!0,get:function(){return Ce.shuffled}});var ke=require$$13;Object.defineProperty(c,"checkProperties",{enumerable:!0,get:function(){return ke.checkProperties}}),Object.defineProperty(c,"deepCopy",{enumerable:!0,get:function(){return ke.deepCopy}}),Object.defineProperty(c,"defineReadOnly",{enumerable:!0,get:function(){return ke.defineReadOnly}}),Object.defineProperty(c,"getStatic",{enumerable:!0,get:function(){return ke.getStatic}}),Object.defineProperty(c,"resolveProperties",{enumerable:!0,get:function(){return ke.resolveProperties}}),Object.defineProperty(c,"shallowCopy",{enumerable:!0,get:function(){return ke.shallowCopy}});var Pe=ie(require$$14);c.RLP=Pe;var Ue=require$$15;Object.defineProperty(c,"computePublicKey",{enumerable:!0,get:function(){return Ue.computePublicKey}}),Object.defineProperty(c,"recoverPublicKey",{enumerable:!0,get:function(){return Ue.recoverPublicKey}}),Object.defineProperty(c,"SigningKey",{enumerable:!0,get:function(){return Ue.SigningKey}});var qe=require$$16;Object.defineProperty(c,"formatBytes32String",{enumerable:!0,get:function(){return qe.formatBytes32String}}),Object.defineProperty(c,"nameprep",{enumerable:!0,get:function(){return qe.nameprep}}),Object.defineProperty(c,"parseBytes32String",{enumerable:!0,get:function(){return qe.parseBytes32String}}),Object.defineProperty(c,"_toEscapedUtf8String",{enumerable:!0,get:function(){return qe._toEscapedUtf8String}}),Object.defineProperty(c,"toUtf8Bytes",{enumerable:!0,get:function(){return qe.toUtf8Bytes}}),Object.defineProperty(c,"toUtf8CodePoints",{enumerable:!0,get:function(){return qe.toUtf8CodePoints}}),Object.defineProperty(c,"toUtf8String",{enumerable:!0,get:function(){return qe.toUtf8String}}),Object.defineProperty(c,"Utf8ErrorFuncs",{enumerable:!0,get:function(){return qe.Utf8ErrorFuncs}});var He=require$$17$1;Object.defineProperty(c,"accessListify",{enumerable:!0,get:function(){return He.accessListify}}),Object.defineProperty(c,"computeAddress",{enumerable:!0,get:function(){return He.computeAddress}}),Object.defineProperty(c,"parseTransaction",{enumerable:!0,get:function(){return He.parse}}),Object.defineProperty(c,"recoverAddress",{enumerable:!0,get:function(){return He.recoverAddress}}),Object.defineProperty(c,"serializeTransaction",{enumerable:!0,get:function(){return He.serialize}}),Object.defineProperty(c,"TransactionTypes",{enumerable:!0,get:function(){return He.TransactionTypes}});var Ve=require$$18;Object.defineProperty(c,"commify",{enumerable:!0,get:function(){return Ve.commify}}),Object.defineProperty(c,"formatEther",{enumerable:!0,get:function(){return Ve.formatEther}}),Object.defineProperty(c,"parseEther",{enumerable:!0,get:function(){return Ve.parseEther}}),Object.defineProperty(c,"formatUnits",{enumerable:!0,get:function(){return Ve.formatUnits}}),Object.defineProperty(c,"parseUnits",{enumerable:!0,get:function(){return Ve.parseUnits}});var Ye=require$$19;Object.defineProperty(c,"verifyMessage",{enumerable:!0,get:function(){return Ye.verifyMessage}}),Object.defineProperty(c,"verifyTypedData",{enumerable:!0,get:function(){return Ye.verifyTypedData}});var Qe=require$$20;Object.defineProperty(c,"_fetchData",{enumerable:!0,get:function(){return Qe._fetchData}}),Object.defineProperty(c,"fetchJson",{enumerable:!0,get:function(){return Qe.fetchJson}}),Object.defineProperty(c,"poll",{enumerable:!0,get:function(){return Qe.poll}});var Ke=require$$10;Object.defineProperty(c,"SupportedAlgorithm",{enumerable:!0,get:function(){return Ke.SupportedAlgorithm}});var Pt=require$$16;Object.defineProperty(c,"UnicodeNormalizationForm",{enumerable:!0,get:function(){return Pt.UnicodeNormalizationForm}}),Object.defineProperty(c,"Utf8ErrorReason",{enumerable:!0,get:function(){return Pt.Utf8ErrorReason}})})(utils$e);const ZERO_ADDRESS="0x0000000000000000000000000000000000000000",SkaleUsdcAddressForTestnet="0x2aebcdc4f9f9149a50422fff86198cb0939ea165",SkaleUsdcAddressForMainnet="0x7Cf76E740Cb23b99337b21F392F22c47Ad910c67",erc20ABI=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"allowance",type:"uint256"},{internalType:"uint256",name:"needed",type:"uint256"}],name:"ERC20InsufficientAllowance",type:"error"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"uint256",name:"balance",type:"uint256"},{internalType:"uint256",name:"needed",type:"uint256"}],name:"ERC20InsufficientBalance",type:"error"},{inputs:[{internalType:"address",name:"approver",type:"address"}],name:"ERC20InvalidApprover",type:"error"},{inputs:[{internalType:"address",name:"receiver",type:"address"}],name:"ERC20InvalidReceiver",type:"error"},{inputs:[{internalType:"address",name:"sender",type:"address"}],name:"ERC20InvalidSender",type:"error"},{inputs:[{internalType:"address",name:"spender",type:"address"}],name:"ERC20InvalidSpender",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"}],paymentProxyABI=[{inputs:[{internalType:"uint256",name:"_heartBeat",type:"uint256"},{internalType:"address",name:"_chainLinkProvider",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"OwnableInvalidOwner",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"OwnableUnauthorizedAccount",type:"error"},{inputs:[{internalType:"uint256",name:"priceTimestamp",type:"uint256"},{internalType:"uint256",name:"currentTimestamp",type:"uint256"}],name:"oldPrice",type:"error"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"newHeartBeat",type:"uint256"}],name:"HeartBeatChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"ProductPurchased",type:"event"},{inputs:[{internalType:"uint256",name:"_heartBeat",type:"uint256"}],name:"changeHeartBeat",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256[]",name:"tbdValues",type:"uint256[]"},{internalType:"address[]",name:"tbdReceivers",type:"address[]"},{internalType:"address",name:"currency",type:"address"},{internalType:"uint80",name:"roundId",type:"uint80"},{internalType:"string",name:"memo",type:"string"}],name:"droplinkedPurchase",outputs:[],stateMutability:"payable",type:"function"},{inputs:[],name:"heartBeat",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"}];async function handleCustomTokenApproval(c,t,n,ie,fe){if(!c.tokenAddress)throw new InvalidParametersException(Chains.BASE,"Token address is not set");try{const ae=new Contract(c.tokenAddress,erc20ABI,n),le=await ae.balanceOf(ie),he=c.tbdValues.reduce((me,xe)=>me.add(BigNumber.from(xe)),BigNumber.from(0));if(le.lt(he))throw new InsufficientBalanceException;fe.changeStep("Approving token");const ye=await ae.approve(t,MaxUint256$1);fe.changeStep("awaiting confirmation"),await ye.wait(),fe.changeStep("Token approval confirmed")}catch(ae){handleError(ae,fe)}}const droplinkedPayment=async function(c,t,n){const{modalInterface:ie}=t,{provider:fe,chain:ae,network:le}=c;if(!n.tbdReceivers.every(utils$e.isAddress))throw new InvalidParametersException(ae,"Invalid receiver address found");n.chainLinkRoundId=n.chainLinkRoundId||"0";const he=n.tokenAddress&&n.tokenAddress!==ZERO_ADDRESS;if(he){if(!n.tbdValues.every(Se=>BigNumber.from(Se).gt(0)))throw new InvalidParametersException(ae,"tbdValues must be positive numbers")}else if(!n.tbdValues.every(Se=>Se>0))throw new InvalidParametersException(ae,"tbdValues must be positive numbers");const ye=fe.getSigner(),me=await ye.getAddress();if(!n.tbdValues)throw new InvalidParametersException(ae,`Invalid tbdValues: ${n.tbdValues}`);if(!n.tbdReceivers)throw new InvalidParametersException(ae,`Invalid tbdReceivers: ${n.tbdReceivers}`);if(!n.memo)throw new InvalidParametersException(ae,`Memo is required for payment, current memo: ${n.memo}`);if(n.tbdReceivers.length!==n.tbdValues.length)throw new InvalidParametersException(ae,"tbdReceivers and tbdValues must be the same length");let xe;try{xe=await getProxyAddress(ae,le)}catch(Se){throw new Error("Failed to get contract address: "+Se.message)}let Ee;try{Ee=new Contract(xe,paymentProxyABI,ye)}catch(Se){throw new Error("Failed to create contract instance: "+Se.message)}try{if(console.log(`
9
+ `)}static register(t,n){n||(n=t.locale)}}const words="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo";let wordlist=null;function loadWords(c){if(wordlist==null&&(wordlist=words.replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),Wordlist.check(c)!=="0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"))throw wordlist=null,new Error("BIP39 Wordlist for en (English) FAILED")}class LangEn extends Wordlist{constructor(){super("en")}getWord(t){return loadWords(this),wordlist[t]}getWordIndex(t){return loadWords(this),wordlist.indexOf(t)}}const langEn=new LangEn;Wordlist.register(langEn);const wordlists={en:langEn},version$e="hdnode/5.8.0",logger$c=new Logger(version$e),N$3=BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),MasterSecret=toUtf8Bytes("Bitcoin seed"),HardenedBit=2147483648;function getUpperMask(c){return(1<<c)-1<<8-c}function getLowerMask(c){return(1<<c)-1}function bytes32(c){return hexZeroPad(hexlify(c),32)}function base58check(c){return Base58.encode(concat$1([c,hexDataSlice(sha256$7(sha256$7(c)),0,4)]))}function getWordlist(c){if(c==null)return wordlists.en;if(typeof c=="string"){const t=wordlists[c];return t==null&&logger$c.throwArgumentError("unknown locale","wordlist",c),t}return c}const _constructorGuard$1={},defaultPath="m/44'/60'/0'/0/0";class HDNode{constructor(t,n,ie,fe,ae,le,he,ye){if(t!==_constructorGuard$1)throw new Error("HDNode constructor cannot be called directly");if(n){const me=new SigningKey(n);defineReadOnly(this,"privateKey",me.privateKey),defineReadOnly(this,"publicKey",me.compressedPublicKey)}else defineReadOnly(this,"privateKey",null),defineReadOnly(this,"publicKey",hexlify(ie));defineReadOnly(this,"parentFingerprint",fe),defineReadOnly(this,"fingerprint",hexDataSlice(ripemd160$1(sha256$7(this.publicKey)),0,4)),defineReadOnly(this,"address",computeAddress(this.publicKey)),defineReadOnly(this,"chainCode",ae),defineReadOnly(this,"index",le),defineReadOnly(this,"depth",he),ye==null?(defineReadOnly(this,"mnemonic",null),defineReadOnly(this,"path",null)):typeof ye=="string"?(defineReadOnly(this,"mnemonic",null),defineReadOnly(this,"path",ye)):(defineReadOnly(this,"mnemonic",ye),defineReadOnly(this,"path",ye.path))}get extendedKey(){if(this.depth>=256)throw new Error("Depth too large!");return base58check(concat$1([this.privateKey!=null?"0x0488ADE4":"0x0488B21E",hexlify(this.depth),this.parentFingerprint,hexZeroPad(hexlify(this.index),4),this.chainCode,this.privateKey!=null?concat$1(["0x00",this.privateKey]):this.publicKey]))}neuter(){return new HDNode(_constructorGuard$1,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,this.path)}_derive(t){if(t>4294967295)throw new Error("invalid index - "+String(t));let n=this.path;n&&(n+="/"+(t&~HardenedBit));const ie=new Uint8Array(37);if(t&HardenedBit){if(!this.privateKey)throw new Error("cannot derive child of neutered node");ie.set(arrayify(this.privateKey),1),n&&(n+="'")}else ie.set(arrayify(this.publicKey));for(let Ee=24;Ee>=0;Ee-=8)ie[33+(Ee>>3)]=t>>24-Ee&255;const fe=arrayify(computeHmac(SupportedAlgorithm.sha512,this.chainCode,ie)),ae=fe.slice(0,32),le=fe.slice(32);let he=null,ye=null;this.privateKey?he=bytes32(BigNumber.from(ae).add(this.privateKey).mod(N$3)):ye=new SigningKey(hexlify(ae))._addPoint(this.publicKey);let me=n;const xe=this.mnemonic;return xe&&(me=Object.freeze({phrase:xe.phrase,path:n,locale:xe.locale||"en"})),new HDNode(_constructorGuard$1,he,ye,this.fingerprint,bytes32(le),t,this.depth+1,me)}derivePath(t){const n=t.split("/");if(n.length===0||n[0]==="m"&&this.depth!==0)throw new Error("invalid path - "+t);n[0]==="m"&&n.shift();let ie=this;for(let fe=0;fe<n.length;fe++){const ae=n[fe];if(ae.match(/^[0-9]+'$/)){const le=parseInt(ae.substring(0,ae.length-1));if(le>=HardenedBit)throw new Error("invalid path index - "+ae);ie=ie._derive(HardenedBit+le)}else if(ae.match(/^[0-9]+$/)){const le=parseInt(ae);if(le>=HardenedBit)throw new Error("invalid path index - "+ae);ie=ie._derive(le)}else throw new Error("invalid path component - "+ae)}return ie}static _fromSeed(t,n){const ie=arrayify(t);if(ie.length<16||ie.length>64)throw new Error("invalid seed");const fe=arrayify(computeHmac(SupportedAlgorithm.sha512,MasterSecret,ie));return new HDNode(_constructorGuard$1,bytes32(fe.slice(0,32)),null,"0x00000000",bytes32(fe.slice(32)),0,0,n)}static fromMnemonic(t,n,ie){return ie=getWordlist(ie),t=entropyToMnemonic(mnemonicToEntropy(t,ie),ie),HDNode._fromSeed(mnemonicToSeed(t,n),{phrase:t,path:"m",locale:ie.locale})}static fromSeed(t){return HDNode._fromSeed(t,null)}static fromExtendedKey(t){const n=Base58.decode(t);(n.length!==82||base58check(n.slice(0,78))!==t)&&logger$c.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");const ie=n[4],fe=hexlify(n.slice(5,9)),ae=parseInt(hexlify(n.slice(9,13)).substring(2),16),le=hexlify(n.slice(13,45)),he=n.slice(45,78);switch(hexlify(n.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new HDNode(_constructorGuard$1,null,hexlify(he),fe,le,ae,ie,null);case"0x0488ade4":case"0x04358394 ":if(he[0]!==0)break;return new HDNode(_constructorGuard$1,hexlify(he.slice(1)),null,fe,le,ae,ie,null)}return logger$c.throwArgumentError("invalid extended key","extendedKey","[REDACTED]")}}function mnemonicToSeed(c,t){t||(t="");const n=toUtf8Bytes("mnemonic"+t,UnicodeNormalizationForm.NFKD);return pbkdf2$1(toUtf8Bytes(c,UnicodeNormalizationForm.NFKD),n,2048,64,"sha512")}function mnemonicToEntropy(c,t){t=getWordlist(t),logger$c.checkNormalize();const n=t.split(c);if(n.length%3!==0)throw new Error("invalid mnemonic");const ie=arrayify(new Uint8Array(Math.ceil(11*n.length/8)));let fe=0;for(let me=0;me<n.length;me++){let xe=t.getWordIndex(n[me].normalize("NFKD"));if(xe===-1)throw new Error("invalid mnemonic");for(let Ee=0;Ee<11;Ee++)xe&1<<10-Ee&&(ie[fe>>3]|=1<<7-fe%8),fe++}const ae=32*n.length/3,le=n.length/3,he=getUpperMask(le);if((arrayify(sha256$7(ie.slice(0,ae/8)))[0]&he)!==(ie[ie.length-1]&he))throw new Error("invalid checksum");return hexlify(ie.slice(0,ae/8))}function entropyToMnemonic(c,t){if(t=getWordlist(t),c=arrayify(c),c.length%4!==0||c.length<16||c.length>32)throw new Error("invalid entropy");const n=[0];let ie=11;for(let le=0;le<c.length;le++)ie>8?(n[n.length-1]<<=8,n[n.length-1]|=c[le],ie-=8):(n[n.length-1]<<=ie,n[n.length-1]|=c[le]>>8-ie,n.push(c[le]&getLowerMask(8-ie)),ie+=3);const fe=c.length/4,ae=arrayify(sha256$7(c))[0]&getUpperMask(fe);return n[n.length-1]<<=fe,n[n.length-1]|=ae>>8-fe,t.join(n.map(le=>t.getWord(le)))}function isValidMnemonic(c,t){try{return mnemonicToEntropy(c,t),!0}catch{}return!1}function getAccountPath(c){return(typeof c!="number"||c<0||c>=HardenedBit||c%1)&&logger$c.throwArgumentError("invalid account index","index",c),`m/44'/60'/${c}'/0/0`}const lib_esm$6=Object.freeze(Object.defineProperty({__proto__:null,HDNode,defaultPath,entropyToMnemonic,getAccountPath,isValidMnemonic,mnemonicToEntropy,mnemonicToSeed},Symbol.toStringTag,{value:"Module"})),version$d="random/5.8.0",logger$b=new Logger(version$d);function getGlobal(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof globalThis<"u")return globalThis;throw new Error("unable to locate global object")}const anyGlobal=getGlobal();let crypto$3=anyGlobal.crypto||anyGlobal.msCrypto;(!crypto$3||!crypto$3.getRandomValues)&&(logger$b.warn("WARNING: Missing strong random number source"),crypto$3={getRandomValues:function(c){return logger$b.throwError("no secure random source avaialble",Logger.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}});function randomBytes$1(c){(c<=0||c>1024||c%1||c!=c)&&logger$b.throwArgumentError("invalid length","length",c);const t=new Uint8Array(c);return crypto$3.getRandomValues(t),arrayify(t)}function shuffled(c){c=c.slice();for(let t=c.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1)),ie=c[t];c[t]=c[n],c[n]=ie}return c}const lib_esm$5=Object.freeze(Object.defineProperty({__proto__:null,randomBytes:randomBytes$1,shuffled},Symbol.toStringTag,{value:"Module"}));var aesJs={exports:{}};(function(c,t){(function(n){function ie(be){return parseInt(be)===be}function fe(be){if(!ie(be.length))return!1;for(var Re=0;Re<be.length;Re++)if(!ie(be[Re])||be[Re]<0||be[Re]>255)return!1;return!0}function ae(be,Re){if(be.buffer&&ArrayBuffer.isView(be)&&be.name==="Uint8Array")return Re&&(be.slice?be=be.slice():be=Array.prototype.slice.call(be)),be;if(Array.isArray(be)){if(!fe(be))throw new Error("Array contains invalid value: "+be);return new Uint8Array(be)}if(ie(be.length)&&fe(be))return new Uint8Array(be);throw new Error("unsupported array-like object")}function le(be){return new Uint8Array(be)}function he(be,Re,Ne,Fe,Ie){(Fe!=null||Ie!=null)&&(be.slice?be=be.slice(Fe,Ie):be=Array.prototype.slice.call(be,Fe,Ie)),Re.set(be,Ne)}var ye=function(){function be(Ne){var Fe=[],Ie=0;for(Ne=encodeURI(Ne);Ie<Ne.length;){var je=Ne.charCodeAt(Ie++);je===37?(Fe.push(parseInt(Ne.substr(Ie,2),16)),Ie+=2):Fe.push(je)}return ae(Fe)}function Re(Ne){for(var Fe=[],Ie=0;Ie<Ne.length;){var je=Ne[Ie];je<128?(Fe.push(String.fromCharCode(je)),Ie++):je>191&&je<224?(Fe.push(String.fromCharCode((je&31)<<6|Ne[Ie+1]&63)),Ie+=2):(Fe.push(String.fromCharCode((je&15)<<12|(Ne[Ie+1]&63)<<6|Ne[Ie+2]&63)),Ie+=3)}return Fe.join("")}return{toBytes:be,fromBytes:Re}}(),me=function(){function be(Fe){for(var Ie=[],je=0;je<Fe.length;je+=2)Ie.push(parseInt(Fe.substr(je,2),16));return Ie}var Re="0123456789abcdef";function Ne(Fe){for(var Ie=[],je=0;je<Fe.length;je++){var Te=Fe[je];Ie.push(Re[(Te&240)>>4]+Re[Te&15])}return Ie.join("")}return{toBytes:be,fromBytes:Ne}}(),xe={16:10,24:12,32:14},Ee=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],Se=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],Me=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],Be=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],$e=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],Ce=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],ke=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],Pe=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],Ue=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],qe=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],He=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],Ve=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],Ye=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],Qe=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],Ke=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function Pt(be){for(var Re=[],Ne=0;Ne<be.length;Ne+=4)Re.push(be[Ne]<<24|be[Ne+1]<<16|be[Ne+2]<<8|be[Ne+3]);return Re}var _e=function(be){if(!(this instanceof _e))throw Error("AES must be instanitated with `new`");Object.defineProperty(this,"key",{value:ae(be,!0)}),this._prepare()};_e.prototype._prepare=function(){var be=xe[this.key.length];if(be==null)throw new Error("invalid key size (must be 16, 24 or 32 bytes)");this._Ke=[],this._Kd=[];for(var Re=0;Re<=be;Re++)this._Ke.push([0,0,0,0]),this._Kd.push([0,0,0,0]);for(var Ne=(be+1)*4,Fe=this.key.length/4,Ie=Pt(this.key),je,Re=0;Re<Fe;Re++)je=Re>>2,this._Ke[je][Re%4]=Ie[Re],this._Kd[be-je][Re%4]=Ie[Re];for(var Te=0,De=Fe,ze;De<Ne;){if(ze=Ie[Fe-1],Ie[0]^=Se[ze>>16&255]<<24^Se[ze>>8&255]<<16^Se[ze&255]<<8^Se[ze>>24&255]^Ee[Te]<<24,Te+=1,Fe!=8)for(var Re=1;Re<Fe;Re++)Ie[Re]^=Ie[Re-1];else{for(var Re=1;Re<Fe/2;Re++)Ie[Re]^=Ie[Re-1];ze=Ie[Fe/2-1],Ie[Fe/2]^=Se[ze&255]^Se[ze>>8&255]<<8^Se[ze>>16&255]<<16^Se[ze>>24&255]<<24;for(var Re=Fe/2+1;Re<Fe;Re++)Ie[Re]^=Ie[Re-1]}for(var Re=0,Xe,Rt;Re<Fe&&De<Ne;)Xe=De>>2,Rt=De%4,this._Ke[Xe][Rt]=Ie[Re],this._Kd[be-Xe][Rt]=Ie[Re++],De++}for(var Xe=1;Xe<be;Xe++)for(var Rt=0;Rt<4;Rt++)ze=this._Kd[Xe][Rt],this._Kd[Xe][Rt]=Ve[ze>>24&255]^Ye[ze>>16&255]^Qe[ze>>8&255]^Ke[ze&255]},_e.prototype.encrypt=function(be){if(be.length!=16)throw new Error("invalid plaintext size (must be 16 bytes)");for(var Re=this._Ke.length-1,Ne=[0,0,0,0],Fe=Pt(be),Ie=0;Ie<4;Ie++)Fe[Ie]^=this._Ke[0][Ie];for(var je=1;je<Re;je++){for(var Ie=0;Ie<4;Ie++)Ne[Ie]=Be[Fe[Ie]>>24&255]^$e[Fe[(Ie+1)%4]>>16&255]^Ce[Fe[(Ie+2)%4]>>8&255]^ke[Fe[(Ie+3)%4]&255]^this._Ke[je][Ie];Fe=Ne.slice()}for(var Te=le(16),De,Ie=0;Ie<4;Ie++)De=this._Ke[Re][Ie],Te[4*Ie]=(Se[Fe[Ie]>>24&255]^De>>24)&255,Te[4*Ie+1]=(Se[Fe[(Ie+1)%4]>>16&255]^De>>16)&255,Te[4*Ie+2]=(Se[Fe[(Ie+2)%4]>>8&255]^De>>8)&255,Te[4*Ie+3]=(Se[Fe[(Ie+3)%4]&255]^De)&255;return Te},_e.prototype.decrypt=function(be){if(be.length!=16)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var Re=this._Kd.length-1,Ne=[0,0,0,0],Fe=Pt(be),Ie=0;Ie<4;Ie++)Fe[Ie]^=this._Kd[0][Ie];for(var je=1;je<Re;je++){for(var Ie=0;Ie<4;Ie++)Ne[Ie]=Pe[Fe[Ie]>>24&255]^Ue[Fe[(Ie+3)%4]>>16&255]^qe[Fe[(Ie+2)%4]>>8&255]^He[Fe[(Ie+1)%4]&255]^this._Kd[je][Ie];Fe=Ne.slice()}for(var Te=le(16),De,Ie=0;Ie<4;Ie++)De=this._Kd[Re][Ie],Te[4*Ie]=(Me[Fe[Ie]>>24&255]^De>>24)&255,Te[4*Ie+1]=(Me[Fe[(Ie+3)%4]>>16&255]^De>>16)&255,Te[4*Ie+2]=(Me[Fe[(Ie+2)%4]>>8&255]^De>>8)&255,Te[4*Ie+3]=(Me[Fe[(Ie+1)%4]&255]^De)&255;return Te};var se=function(be){if(!(this instanceof se))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new _e(be)};se.prototype.encrypt=function(be){if(be=ae(be),be.length%16!==0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var Re=le(be.length),Ne=le(16),Fe=0;Fe<be.length;Fe+=16)he(be,Ne,0,Fe,Fe+16),Ne=this._aes.encrypt(Ne),he(Ne,Re,Fe);return Re},se.prototype.decrypt=function(be){if(be=ae(be),be.length%16!==0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var Re=le(be.length),Ne=le(16),Fe=0;Fe<be.length;Fe+=16)he(be,Ne,0,Fe,Fe+16),Ne=this._aes.decrypt(Ne),he(Ne,Re,Fe);return Re};var ce=function(be,Re){if(!(this instanceof ce))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Block Chaining",this.name="cbc",!Re)Re=le(16);else if(Re.length!=16)throw new Error("invalid initialation vector size (must be 16 bytes)");this._lastCipherblock=ae(Re,!0),this._aes=new _e(be)};ce.prototype.encrypt=function(be){if(be=ae(be),be.length%16!==0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var Re=le(be.length),Ne=le(16),Fe=0;Fe<be.length;Fe+=16){he(be,Ne,0,Fe,Fe+16);for(var Ie=0;Ie<16;Ie++)Ne[Ie]^=this._lastCipherblock[Ie];this._lastCipherblock=this._aes.encrypt(Ne),he(this._lastCipherblock,Re,Fe)}return Re},ce.prototype.decrypt=function(be){if(be=ae(be),be.length%16!==0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var Re=le(be.length),Ne=le(16),Fe=0;Fe<be.length;Fe+=16){he(be,Ne,0,Fe,Fe+16),Ne=this._aes.decrypt(Ne);for(var Ie=0;Ie<16;Ie++)Re[Fe+Ie]=Ne[Ie]^this._lastCipherblock[Ie];he(be,this._lastCipherblock,0,Fe,Fe+16)}return Re};var de=function(be,Re,Ne){if(!(this instanceof de))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Feedback",this.name="cfb",!Re)Re=le(16);else if(Re.length!=16)throw new Error("invalid initialation vector size (must be 16 size)");Ne||(Ne=1),this.segmentSize=Ne,this._shiftRegister=ae(Re,!0),this._aes=new _e(be)};de.prototype.encrypt=function(be){if(be.length%this.segmentSize!=0)throw new Error("invalid plaintext size (must be segmentSize bytes)");for(var Re=ae(be,!0),Ne,Fe=0;Fe<Re.length;Fe+=this.segmentSize){Ne=this._aes.encrypt(this._shiftRegister);for(var Ie=0;Ie<this.segmentSize;Ie++)Re[Fe+Ie]^=Ne[Ie];he(this._shiftRegister,this._shiftRegister,0,this.segmentSize),he(Re,this._shiftRegister,16-this.segmentSize,Fe,Fe+this.segmentSize)}return Re},de.prototype.decrypt=function(be){if(be.length%this.segmentSize!=0)throw new Error("invalid ciphertext size (must be segmentSize bytes)");for(var Re=ae(be,!0),Ne,Fe=0;Fe<Re.length;Fe+=this.segmentSize){Ne=this._aes.encrypt(this._shiftRegister);for(var Ie=0;Ie<this.segmentSize;Ie++)Re[Fe+Ie]^=Ne[Ie];he(this._shiftRegister,this._shiftRegister,0,this.segmentSize),he(be,this._shiftRegister,16-this.segmentSize,Fe,Fe+this.segmentSize)}return Re};var pe=function(be,Re){if(!(this instanceof pe))throw Error("AES must be instanitated with `new`");if(this.description="Output Feedback",this.name="ofb",!Re)Re=le(16);else if(Re.length!=16)throw new Error("invalid initialation vector size (must be 16 bytes)");this._lastPrecipher=ae(Re,!0),this._lastPrecipherIndex=16,this._aes=new _e(be)};pe.prototype.encrypt=function(be){for(var Re=ae(be,!0),Ne=0;Ne<Re.length;Ne++)this._lastPrecipherIndex===16&&(this._lastPrecipher=this._aes.encrypt(this._lastPrecipher),this._lastPrecipherIndex=0),Re[Ne]^=this._lastPrecipher[this._lastPrecipherIndex++];return Re},pe.prototype.decrypt=pe.prototype.encrypt;var ve=function(be){if(!(this instanceof ve))throw Error("Counter must be instanitated with `new`");be!==0&&!be&&(be=1),typeof be=="number"?(this._counter=le(16),this.setValue(be)):this.setBytes(be)};ve.prototype.setValue=function(be){if(typeof be!="number"||parseInt(be)!=be)throw new Error("invalid counter value (must be an integer)");for(var Re=15;Re>=0;--Re)this._counter[Re]=be%256,be=be>>8},ve.prototype.setBytes=function(be){if(be=ae(be,!0),be.length!=16)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=be},ve.prototype.increment=function(){for(var be=15;be>=0;be--)if(this._counter[be]===255)this._counter[be]=0;else{this._counter[be]++;break}};var we=function(be,Re){if(!(this instanceof we))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",Re instanceof ve||(Re=new ve(Re)),this._counter=Re,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new _e(be)};we.prototype.encrypt=function(be){for(var Re=ae(be,!0),Ne=0;Ne<Re.length;Ne++)this._remainingCounterIndex===16&&(this._remainingCounter=this._aes.encrypt(this._counter._counter),this._remainingCounterIndex=0,this._counter.increment()),Re[Ne]^=this._remainingCounter[this._remainingCounterIndex++];return Re},we.prototype.decrypt=we.prototype.encrypt;function Ae(be){be=ae(be,!0);var Re=16-be.length%16,Ne=le(be.length+Re);he(be,Ne);for(var Fe=be.length;Fe<Ne.length;Fe++)Ne[Fe]=Re;return Ne}function ge(be){if(be=ae(be,!0),be.length<16)throw new Error("PKCS#7 invalid length");var Re=be[be.length-1];if(Re>16)throw new Error("PKCS#7 padding byte out of range");for(var Ne=be.length-Re,Fe=0;Fe<Re;Fe++)if(be[Ne+Fe]!==Re)throw new Error("PKCS#7 invalid padding byte");var Ie=le(Ne);return he(be,Ie,0,0,Ne),Ie}var ue={AES:_e,Counter:ve,ModeOfOperation:{ecb:se,cbc:ce,cfb:de,ofb:pe,ctr:we},utils:{hex:me,utf8:ye},padding:{pkcs7:{pad:Ae,strip:ge}},_arrayTest:{coerceArray:ae,createArray:le,copyArray:he}};c.exports=ue})()})(aesJs);var aesJsExports=aesJs.exports;const aes$1=getDefaultExportFromCjs$2(aesJsExports),version$c="json-wallets/5.8.0";function looseArrayify(c){return typeof c=="string"&&c.substring(0,2)!=="0x"&&(c="0x"+c),arrayify(c)}function zpad(c,t){for(c=String(c);c.length<t;)c="0"+c;return c}function getPassword(c){return typeof c=="string"?toUtf8Bytes(c,UnicodeNormalizationForm.NFKC):arrayify(c)}function searchPath(c,t){let n=c;const ie=t.toLowerCase().split("/");for(let fe=0;fe<ie.length;fe++){let ae=null;for(const le in n)if(le.toLowerCase()===ie[fe]){ae=n[le];break}if(ae===null)return null;n=ae}return n}function uuidV4(c){const t=arrayify(c);t[6]=t[6]&15|64,t[8]=t[8]&63|128;const n=hexlify(t);return[n.substring(2,10),n.substring(10,14),n.substring(14,18),n.substring(18,22),n.substring(22,34)].join("-")}const logger$a=new Logger(version$c);class CrowdsaleAccount extends Description{isCrowdsaleAccount(t){return!!(t&&t._isCrowdsaleAccount)}}function decrypt$1(c,t){const n=JSON.parse(c);t=getPassword(t);const ie=getAddress$1(searchPath(n,"ethaddr")),fe=looseArrayify(searchPath(n,"encseed"));(!fe||fe.length%16!==0)&&logger$a.throwArgumentError("invalid encseed","json",c);const ae=arrayify(pbkdf2$1(t,t,2e3,32,"sha256")).slice(0,16),le=fe.slice(0,16),he=fe.slice(16),ye=new aes$1.ModeOfOperation.cbc(ae,le),me=aes$1.padding.pkcs7.strip(arrayify(ye.decrypt(he)));let xe="";for(let Me=0;Me<me.length;Me++)xe+=String.fromCharCode(me[Me]);const Ee=toUtf8Bytes(xe),Se=keccak256$1(Ee);return new CrowdsaleAccount({_isCrowdsaleAccount:!0,address:ie,privateKey:Se})}function isCrowdsaleWallet(c){let t=null;try{t=JSON.parse(c)}catch{return!1}return t.encseed&&t.ethaddr}function isKeystoreWallet(c){let t=null;try{t=JSON.parse(c)}catch{return!1}return!(!t.version||parseInt(t.version)!==t.version||parseInt(t.version)!==3)}function getJsonWalletAddress(c){if(isCrowdsaleWallet(c))try{return getAddress$1(JSON.parse(c).ethaddr)}catch{return null}if(isKeystoreWallet(c))try{return getAddress$1(JSON.parse(c).address)}catch{return null}return null}var scrypt$1={exports:{}};(function(c,t){(function(n){function fe($e){const Ce=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]);let ke=1779033703,Pe=3144134277,Ue=1013904242,qe=2773480762,He=1359893119,Ve=2600822924,Ye=528734635,Qe=1541459225;const Ke=new Uint32Array(64);function Pt(we){let Ae=0,ge=we.length;for(;ge>=64;){let ue=ke,be=Pe,Re=Ue,Ne=qe,Fe=He,Ie=Ve,je=Ye,Te=Qe,De,ze,Xe,Rt,Oe;for(ze=0;ze<16;ze++)Xe=Ae+ze*4,Ke[ze]=(we[Xe]&255)<<24|(we[Xe+1]&255)<<16|(we[Xe+2]&255)<<8|we[Xe+3]&255;for(ze=16;ze<64;ze++)De=Ke[ze-2],Rt=(De>>>17|De<<15)^(De>>>19|De<<13)^De>>>10,De=Ke[ze-15],Oe=(De>>>7|De<<25)^(De>>>18|De<<14)^De>>>3,Ke[ze]=(Rt+Ke[ze-7]|0)+(Oe+Ke[ze-16]|0)|0;for(ze=0;ze<64;ze++)Rt=(((Fe>>>6|Fe<<26)^(Fe>>>11|Fe<<21)^(Fe>>>25|Fe<<7))+(Fe&Ie^~Fe&je)|0)+(Te+(Ce[ze]+Ke[ze]|0)|0)|0,Oe=((ue>>>2|ue<<30)^(ue>>>13|ue<<19)^(ue>>>22|ue<<10))+(ue&be^ue&Re^be&Re)|0,Te=je,je=Ie,Ie=Fe,Fe=Ne+Rt|0,Ne=Re,Re=be,be=ue,ue=Rt+Oe|0;ke=ke+ue|0,Pe=Pe+be|0,Ue=Ue+Re|0,qe=qe+Ne|0,He=He+Fe|0,Ve=Ve+Ie|0,Ye=Ye+je|0,Qe=Qe+Te|0,Ae+=64,ge-=64}}Pt($e);let _e,se=$e.length%64,ce=$e.length/536870912|0,de=$e.length<<3,pe=se<56?56:120,ve=$e.slice($e.length-se,$e.length);for(ve.push(128),_e=se+1;_e<pe;_e++)ve.push(0);return ve.push(ce>>>24&255),ve.push(ce>>>16&255),ve.push(ce>>>8&255),ve.push(ce>>>0&255),ve.push(de>>>24&255),ve.push(de>>>16&255),ve.push(de>>>8&255),ve.push(de>>>0&255),Pt(ve),[ke>>>24&255,ke>>>16&255,ke>>>8&255,ke>>>0&255,Pe>>>24&255,Pe>>>16&255,Pe>>>8&255,Pe>>>0&255,Ue>>>24&255,Ue>>>16&255,Ue>>>8&255,Ue>>>0&255,qe>>>24&255,qe>>>16&255,qe>>>8&255,qe>>>0&255,He>>>24&255,He>>>16&255,He>>>8&255,He>>>0&255,Ve>>>24&255,Ve>>>16&255,Ve>>>8&255,Ve>>>0&255,Ye>>>24&255,Ye>>>16&255,Ye>>>8&255,Ye>>>0&255,Qe>>>24&255,Qe>>>16&255,Qe>>>8&255,Qe>>>0&255]}function ae($e,Ce,ke){$e=$e.length<=64?$e:fe($e);const Pe=64+Ce.length+4,Ue=new Array(Pe),qe=new Array(64);let He,Ve=[];for(He=0;He<64;He++)Ue[He]=54;for(He=0;He<$e.length;He++)Ue[He]^=$e[He];for(He=0;He<Ce.length;He++)Ue[64+He]=Ce[He];for(He=Pe-4;He<Pe;He++)Ue[He]=0;for(He=0;He<64;He++)qe[He]=92;for(He=0;He<$e.length;He++)qe[He]^=$e[He];function Ye(){for(let Qe=Pe-1;Qe>=Pe-4;Qe--){if(Ue[Qe]++,Ue[Qe]<=255)return;Ue[Qe]=0}}for(;ke>=32;)Ye(),Ve=Ve.concat(fe(qe.concat(fe(Ue)))),ke-=32;return ke>0&&(Ye(),Ve=Ve.concat(fe(qe.concat(fe(Ue))).slice(0,ke))),Ve}function le($e,Ce,ke,Pe,Ue){let qe;for(xe($e,(2*ke-1)*16,Ue,0,16),qe=0;qe<2*ke;qe++)me($e,qe*16,Ue,16),ye(Ue,Pe),xe(Ue,0,$e,Ce+qe*16,16);for(qe=0;qe<ke;qe++)xe($e,Ce+qe*2*16,$e,qe*16,16);for(qe=0;qe<ke;qe++)xe($e,Ce+(qe*2+1)*16,$e,(qe+ke)*16,16)}function he($e,Ce){return $e<<Ce|$e>>>32-Ce}function ye($e,Ce){xe($e,0,Ce,0,16);for(let ke=8;ke>0;ke-=2)Ce[4]^=he(Ce[0]+Ce[12],7),Ce[8]^=he(Ce[4]+Ce[0],9),Ce[12]^=he(Ce[8]+Ce[4],13),Ce[0]^=he(Ce[12]+Ce[8],18),Ce[9]^=he(Ce[5]+Ce[1],7),Ce[13]^=he(Ce[9]+Ce[5],9),Ce[1]^=he(Ce[13]+Ce[9],13),Ce[5]^=he(Ce[1]+Ce[13],18),Ce[14]^=he(Ce[10]+Ce[6],7),Ce[2]^=he(Ce[14]+Ce[10],9),Ce[6]^=he(Ce[2]+Ce[14],13),Ce[10]^=he(Ce[6]+Ce[2],18),Ce[3]^=he(Ce[15]+Ce[11],7),Ce[7]^=he(Ce[3]+Ce[15],9),Ce[11]^=he(Ce[7]+Ce[3],13),Ce[15]^=he(Ce[11]+Ce[7],18),Ce[1]^=he(Ce[0]+Ce[3],7),Ce[2]^=he(Ce[1]+Ce[0],9),Ce[3]^=he(Ce[2]+Ce[1],13),Ce[0]^=he(Ce[3]+Ce[2],18),Ce[6]^=he(Ce[5]+Ce[4],7),Ce[7]^=he(Ce[6]+Ce[5],9),Ce[4]^=he(Ce[7]+Ce[6],13),Ce[5]^=he(Ce[4]+Ce[7],18),Ce[11]^=he(Ce[10]+Ce[9],7),Ce[8]^=he(Ce[11]+Ce[10],9),Ce[9]^=he(Ce[8]+Ce[11],13),Ce[10]^=he(Ce[9]+Ce[8],18),Ce[12]^=he(Ce[15]+Ce[14],7),Ce[13]^=he(Ce[12]+Ce[15],9),Ce[14]^=he(Ce[13]+Ce[12],13),Ce[15]^=he(Ce[14]+Ce[13],18);for(let ke=0;ke<16;++ke)$e[ke]+=Ce[ke]}function me($e,Ce,ke,Pe){for(let Ue=0;Ue<Pe;Ue++)ke[Ue]^=$e[Ce+Ue]}function xe($e,Ce,ke,Pe,Ue){for(;Ue--;)ke[Pe++]=$e[Ce++]}function Ee($e){if(!$e||typeof $e.length!="number")return!1;for(let Ce=0;Ce<$e.length;Ce++){const ke=$e[Ce];if(typeof ke!="number"||ke%1||ke<0||ke>=256)return!1}return!0}function Se($e,Ce){if(typeof $e!="number"||$e%1)throw new Error("invalid "+Ce);return $e}function Me($e,Ce,ke,Pe,Ue,qe,He){if(ke=Se(ke,"N"),Pe=Se(Pe,"r"),Ue=Se(Ue,"p"),qe=Se(qe,"dkLen"),ke===0||ke&ke-1)throw new Error("N must be power of 2");if(ke>2147483647/128/Pe)throw new Error("N too large");if(Pe>2147483647/128/Ue)throw new Error("r too large");if(!Ee($e))throw new Error("password must be an array or buffer");if($e=Array.prototype.slice.call($e),!Ee(Ce))throw new Error("salt must be an array or buffer");Ce=Array.prototype.slice.call(Ce);let Ve=ae($e,Ce,Ue*128*Pe);const Ye=new Uint32Array(Ue*32*Pe);for(let Fe=0;Fe<Ye.length;Fe++){const Ie=Fe*4;Ye[Fe]=(Ve[Ie+3]&255)<<24|(Ve[Ie+2]&255)<<16|(Ve[Ie+1]&255)<<8|(Ve[Ie+0]&255)<<0}const Qe=new Uint32Array(64*Pe),Ke=new Uint32Array(32*Pe*ke),Pt=32*Pe,_e=new Uint32Array(16),se=new Uint32Array(16),ce=Ue*ke*2;let de=0,pe=null,ve=!1,we=0,Ae=0,ge,ue;const be=He?parseInt(1e3/Pe):4294967295,Re=typeof setImmediate<"u"?setImmediate:setTimeout,Ne=function(){if(ve)return He(new Error("cancelled"),de/ce);let Fe;switch(we){case 0:ue=Ae*32*Pe,xe(Ye,ue,Qe,0,Pt),we=1,ge=0;case 1:Fe=ke-ge,Fe>be&&(Fe=be);for(let je=0;je<Fe;je++)xe(Qe,0,Ke,(ge+je)*Pt,Pt),le(Qe,Pt,Pe,_e,se);if(ge+=Fe,de+=Fe,He){const je=parseInt(1e3*de/ce);if(je!==pe){if(ve=He(null,de/ce),ve)break;pe=je}}if(ge<ke)break;ge=0,we=2;case 2:Fe=ke-ge,Fe>be&&(Fe=be);for(let je=0;je<Fe;je++){const Te=(2*Pe-1)*16,De=Qe[Te]&ke-1;me(Ke,De*Pt,Qe,Pt),le(Qe,Pt,Pe,_e,se)}if(ge+=Fe,de+=Fe,He){const je=parseInt(1e3*de/ce);if(je!==pe){if(ve=He(null,de/ce),ve)break;pe=je}}if(ge<ke)break;if(xe(Qe,0,Ye,ue,Pt),Ae++,Ae<Ue){we=0;break}Ve=[];for(let je=0;je<Ye.length;je++)Ve.push(Ye[je]>>0&255),Ve.push(Ye[je]>>8&255),Ve.push(Ye[je]>>16&255),Ve.push(Ye[je]>>24&255);const Ie=ae($e,Ve,qe);return He&&He(null,1,Ie),Ie}He&&Re(Ne)};if(!He)for(;;){const Fe=Ne();if(Fe!=null)return Fe}Ne()}const Be={scrypt:function($e,Ce,ke,Pe,Ue,qe,He){return new Promise(function(Ve,Ye){let Qe=0;He&&He(0),Me($e,Ce,ke,Pe,Ue,qe,function(Ke,Pt,_e){if(Ke)Ye(Ke);else if(_e)He&&Qe!==1&&He(1),Ve(new Uint8Array(_e));else if(He&&Pt!==Qe)return Qe=Pt,He(Pt)})})},syncScrypt:function($e,Ce,ke,Pe,Ue,qe){return new Uint8Array(Me($e,Ce,ke,Pe,Ue,qe))}};c.exports=Be})()})(scrypt$1);var scryptExports=scrypt$1.exports;const scrypt=getDefaultExportFromCjs$2(scryptExports);var __awaiter$g=function(c,t,n,ie){function fe(ae){return ae instanceof n?ae:new n(function(le){le(ae)})}return new(n||(n=Promise))(function(ae,le){function he(xe){try{me(ie.next(xe))}catch(Ee){le(Ee)}}function ye(xe){try{me(ie.throw(xe))}catch(Ee){le(Ee)}}function me(xe){xe.done?ae(xe.value):fe(xe.value).then(he,ye)}me((ie=ie.apply(c,t||[])).next())})};const logger$9=new Logger(version$c);function hasMnemonic$1(c){return c!=null&&c.mnemonic&&c.mnemonic.phrase}class KeystoreAccount extends Description{isKeystoreAccount(t){return!!(t&&t._isKeystoreAccount)}}function _decrypt(c,t,n){if(searchPath(c,"crypto/cipher")==="aes-128-ctr"){const fe=looseArrayify(searchPath(c,"crypto/cipherparams/iv")),ae=new aes$1.Counter(fe),le=new aes$1.ModeOfOperation.ctr(t,ae);return arrayify(le.decrypt(n))}return null}function _getAccount(c,t){const n=looseArrayify(searchPath(c,"crypto/ciphertext"));if(hexlify(keccak256$1(concat$1([t.slice(16,32),n]))).substring(2)!==searchPath(c,"crypto/mac").toLowerCase())throw new Error("invalid password");const fe=_decrypt(c,t.slice(0,16),n);fe||logger$9.throwError("unsupported cipher",Logger.errors.UNSUPPORTED_OPERATION,{operation:"decrypt"});const ae=t.slice(32,64),le=computeAddress(fe);if(c.address){let ye=c.address.toLowerCase();if(ye.substring(0,2)!=="0x"&&(ye="0x"+ye),getAddress$1(ye)!==le)throw new Error("address mismatch")}const he={_isKeystoreAccount:!0,address:le,privateKey:hexlify(fe)};if(searchPath(c,"x-ethers/version")==="0.1"){const ye=looseArrayify(searchPath(c,"x-ethers/mnemonicCiphertext")),me=looseArrayify(searchPath(c,"x-ethers/mnemonicCounter")),xe=new aes$1.Counter(me),Ee=new aes$1.ModeOfOperation.ctr(ae,xe),Se=searchPath(c,"x-ethers/path")||defaultPath,Me=searchPath(c,"x-ethers/locale")||"en",Be=arrayify(Ee.decrypt(ye));try{const $e=entropyToMnemonic(Be,Me),Ce=HDNode.fromMnemonic($e,null,Me).derivePath(Se);if(Ce.privateKey!=he.privateKey)throw new Error("mnemonic mismatch");he.mnemonic=Ce.mnemonic}catch($e){if($e.code!==Logger.errors.INVALID_ARGUMENT||$e.argument!=="wordlist")throw $e}}return new KeystoreAccount(he)}function pbkdf2Sync(c,t,n,ie,fe){return arrayify(pbkdf2$1(c,t,n,ie,fe))}function pbkdf2(c,t,n,ie,fe){return Promise.resolve(pbkdf2Sync(c,t,n,ie,fe))}function _computeKdfKey(c,t,n,ie,fe){const ae=getPassword(t),le=searchPath(c,"crypto/kdf");if(le&&typeof le=="string"){const he=function(ye,me){return logger$9.throwArgumentError("invalid key-derivation function parameters",ye,me)};if(le.toLowerCase()==="scrypt"){const ye=looseArrayify(searchPath(c,"crypto/kdfparams/salt")),me=parseInt(searchPath(c,"crypto/kdfparams/n")),xe=parseInt(searchPath(c,"crypto/kdfparams/r")),Ee=parseInt(searchPath(c,"crypto/kdfparams/p"));(!me||!xe||!Ee)&&he("kdf",le),me&me-1&&he("N",me);const Se=parseInt(searchPath(c,"crypto/kdfparams/dklen"));return Se!==32&&he("dklen",Se),ie(ae,ye,me,xe,Ee,64,fe)}else if(le.toLowerCase()==="pbkdf2"){const ye=looseArrayify(searchPath(c,"crypto/kdfparams/salt"));let me=null;const xe=searchPath(c,"crypto/kdfparams/prf");xe==="hmac-sha256"?me="sha256":xe==="hmac-sha512"?me="sha512":he("prf",xe);const Ee=parseInt(searchPath(c,"crypto/kdfparams/c")),Se=parseInt(searchPath(c,"crypto/kdfparams/dklen"));return Se!==32&&he("dklen",Se),n(ae,ye,Ee,Se,me)}}return logger$9.throwArgumentError("unsupported key-derivation function","kdf",le)}function decryptSync(c,t){const n=JSON.parse(c),ie=_computeKdfKey(n,t,pbkdf2Sync,scrypt.syncScrypt);return _getAccount(n,ie)}function decrypt(c,t,n){return __awaiter$g(this,void 0,void 0,function*(){const ie=JSON.parse(c),fe=yield _computeKdfKey(ie,t,pbkdf2,scrypt.scrypt,n);return _getAccount(ie,fe)})}function encrypt(c,t,n,ie){try{if(getAddress$1(c.address)!==computeAddress(c.privateKey))throw new Error("address/privateKey mismatch");if(hasMnemonic$1(c)){const Ce=c.mnemonic;if(HDNode.fromMnemonic(Ce.phrase,null,Ce.locale).derivePath(Ce.path||defaultPath).privateKey!=c.privateKey)throw new Error("mnemonic mismatch")}}catch(Ce){return Promise.reject(Ce)}typeof n=="function"&&!ie&&(ie=n,n={}),n||(n={});const fe=arrayify(c.privateKey),ae=getPassword(t);let le=null,he=null,ye=null;if(hasMnemonic$1(c)){const Ce=c.mnemonic;le=arrayify(mnemonicToEntropy(Ce.phrase,Ce.locale||"en")),he=Ce.path||defaultPath,ye=Ce.locale||"en"}let me=n.client;me||(me="ethers.js");let xe=null;n.salt?xe=arrayify(n.salt):xe=randomBytes$1(32);let Ee=null;if(n.iv){if(Ee=arrayify(n.iv),Ee.length!==16)throw new Error("invalid iv")}else Ee=randomBytes$1(16);let Se=null;if(n.uuid){if(Se=arrayify(n.uuid),Se.length!==16)throw new Error("invalid uuid")}else Se=randomBytes$1(16);let Me=1<<17,Be=8,$e=1;return n.scrypt&&(n.scrypt.N&&(Me=n.scrypt.N),n.scrypt.r&&(Be=n.scrypt.r),n.scrypt.p&&($e=n.scrypt.p)),scrypt.scrypt(ae,xe,Me,Be,$e,64,ie).then(Ce=>{Ce=arrayify(Ce);const ke=Ce.slice(0,16),Pe=Ce.slice(16,32),Ue=Ce.slice(32,64),qe=new aes$1.Counter(Ee),He=new aes$1.ModeOfOperation.ctr(ke,qe),Ve=arrayify(He.encrypt(fe)),Ye=keccak256$1(concat$1([Pe,Ve])),Qe={address:c.address.substring(2).toLowerCase(),id:uuidV4(Se),version:3,crypto:{cipher:"aes-128-ctr",cipherparams:{iv:hexlify(Ee).substring(2)},ciphertext:hexlify(Ve).substring(2),kdf:"scrypt",kdfparams:{salt:hexlify(xe).substring(2),n:Me,dklen:32,p:$e,r:Be},mac:Ye.substring(2)}};if(le){const Ke=randomBytes$1(16),Pt=new aes$1.Counter(Ke),_e=new aes$1.ModeOfOperation.ctr(Ue,Pt),se=arrayify(_e.encrypt(le)),ce=new Date,de=ce.getUTCFullYear()+"-"+zpad(ce.getUTCMonth()+1,2)+"-"+zpad(ce.getUTCDate(),2)+"T"+zpad(ce.getUTCHours(),2)+"-"+zpad(ce.getUTCMinutes(),2)+"-"+zpad(ce.getUTCSeconds(),2)+".0Z";Qe["x-ethers"]={client:me,gethFilename:"UTC--"+de+"--"+Qe.address,mnemonicCounter:hexlify(Ke).substring(2),mnemonicCiphertext:hexlify(se).substring(2),path:he,locale:ye,version:"0.1"}}return JSON.stringify(Qe)})}function decryptJsonWallet(c,t,n){if(isCrowdsaleWallet(c)){n&&n(0);const ie=decrypt$1(c,t);return n&&n(1),Promise.resolve(ie)}return isKeystoreWallet(c)?decrypt(c,t,n):Promise.reject(new Error("invalid JSON wallet"))}function decryptJsonWalletSync(c,t){if(isCrowdsaleWallet(c))return decrypt$1(c,t);if(isKeystoreWallet(c))return decryptSync(c,t);throw new Error("invalid JSON wallet")}const lib_esm$4=Object.freeze(Object.defineProperty({__proto__:null,decryptCrowdsale:decrypt$1,decryptJsonWallet,decryptJsonWalletSync,decryptKeystore:decrypt,decryptKeystoreSync:decryptSync,encryptKeystore:encrypt,getJsonWalletAddress,isCrowdsaleWallet,isKeystoreWallet},Symbol.toStringTag,{value:"Module"})),version$b="wallet/5.8.0";var __awaiter$f=function(c,t,n,ie){function fe(ae){return ae instanceof n?ae:new n(function(le){le(ae)})}return new(n||(n=Promise))(function(ae,le){function he(xe){try{me(ie.next(xe))}catch(Ee){le(Ee)}}function ye(xe){try{me(ie.throw(xe))}catch(Ee){le(Ee)}}function me(xe){xe.done?ae(xe.value):fe(xe.value).then(he,ye)}me((ie=ie.apply(c,t||[])).next())})};const logger$8=new Logger(version$b);function isAccount(c){return c!=null&&isHexString(c.privateKey,32)&&c.address!=null}function hasMnemonic(c){const t=c.mnemonic;return t&&t.phrase}class Wallet extends Signer{constructor(t,n){if(super(),isAccount(t)){const ie=new SigningKey(t.privateKey);if(defineReadOnly(this,"_signingKey",()=>ie),defineReadOnly(this,"address",computeAddress(this.publicKey)),this.address!==getAddress$1(t.address)&&logger$8.throwArgumentError("privateKey/address mismatch","privateKey","[REDACTED]"),hasMnemonic(t)){const fe=t.mnemonic;defineReadOnly(this,"_mnemonic",()=>({phrase:fe.phrase,path:fe.path||defaultPath,locale:fe.locale||"en"}));const ae=this.mnemonic,le=HDNode.fromMnemonic(ae.phrase,null,ae.locale).derivePath(ae.path);computeAddress(le.privateKey)!==this.address&&logger$8.throwArgumentError("mnemonic/address mismatch","privateKey","[REDACTED]")}else defineReadOnly(this,"_mnemonic",()=>null)}else{if(SigningKey.isSigningKey(t))t.curve!=="secp256k1"&&logger$8.throwArgumentError("unsupported curve; must be secp256k1","privateKey","[REDACTED]"),defineReadOnly(this,"_signingKey",()=>t);else{typeof t=="string"&&t.match(/^[0-9a-f]*$/i)&&t.length===64&&(t="0x"+t);const ie=new SigningKey(t);defineReadOnly(this,"_signingKey",()=>ie)}defineReadOnly(this,"_mnemonic",()=>null),defineReadOnly(this,"address",computeAddress(this.publicKey))}n&&!Provider.isProvider(n)&&logger$8.throwArgumentError("invalid provider","provider",n),defineReadOnly(this,"provider",n||null)}get mnemonic(){return this._mnemonic()}get privateKey(){return this._signingKey().privateKey}get publicKey(){return this._signingKey().publicKey}getAddress(){return Promise.resolve(this.address)}connect(t){return new Wallet(this,t)}signTransaction(t){return resolveProperties(t).then(n=>{n.from!=null&&(getAddress$1(n.from)!==this.address&&logger$8.throwArgumentError("transaction from address mismatch","transaction.from",t.from),delete n.from);const ie=this._signingKey().signDigest(keccak256$1(serialize$1(n)));return serialize$1(n,ie)})}signMessage(t){return __awaiter$f(this,void 0,void 0,function*(){return joinSignature(this._signingKey().signDigest(hashMessage(t)))})}_signTypedData(t,n,ie){return __awaiter$f(this,void 0,void 0,function*(){const fe=yield TypedDataEncoder.resolveNames(t,n,ie,ae=>(this.provider==null&&logger$8.throwError("cannot resolve ENS names without a provider",Logger.errors.UNSUPPORTED_OPERATION,{operation:"resolveName",value:ae}),this.provider.resolveName(ae)));return joinSignature(this._signingKey().signDigest(TypedDataEncoder.hash(fe.domain,n,fe.value)))})}encrypt(t,n,ie){if(typeof n=="function"&&!ie&&(ie=n,n={}),ie&&typeof ie!="function")throw new Error("invalid callback");return n||(n={}),encrypt(this,t,n,ie)}static createRandom(t){let n=randomBytes$1(16);t||(t={}),t.extraEntropy&&(n=arrayify(hexDataSlice(keccak256$1(concat$1([n,t.extraEntropy])),0,16)));const ie=entropyToMnemonic(n,t.locale);return Wallet.fromMnemonic(ie,t.path,t.locale)}static fromEncryptedJson(t,n,ie){return decryptJsonWallet(t,n,ie).then(fe=>new Wallet(fe))}static fromEncryptedJsonSync(t,n){return new Wallet(decryptJsonWalletSync(t,n))}static fromMnemonic(t,n,ie){return n||(n=defaultPath),new Wallet(HDNode.fromMnemonic(t,null,ie).derivePath(n))}}function verifyMessage(c,t){return recoverAddress(hashMessage(c),t)}function verifyTypedData(c,t,n,ie){return recoverAddress(TypedDataEncoder.hash(c,t,n),ie)}const lib_esm$3=Object.freeze(Object.defineProperty({__proto__:null,Wallet,verifyMessage,verifyTypedData},Symbol.toStringTag,{value:"Module"})),version$a="networks/5.8.0",logger$7=new Logger(version$a);function isRenetworkable(c){return c&&typeof c.renetwork=="function"}function ethDefaultProvider(c){const t=function(n,ie){ie==null&&(ie={});const fe=[];if(n.InfuraProvider&&ie.infura!=="-")try{fe.push(new n.InfuraProvider(c,ie.infura))}catch{}if(n.EtherscanProvider&&ie.etherscan!=="-")try{fe.push(new n.EtherscanProvider(c,ie.etherscan))}catch{}if(n.AlchemyProvider&&ie.alchemy!=="-")try{fe.push(new n.AlchemyProvider(c,ie.alchemy))}catch{}if(n.PocketProvider&&ie.pocket!=="-"){const ae=["goerli","ropsten","rinkeby","sepolia"];try{const le=new n.PocketProvider(c,ie.pocket);le.network&&ae.indexOf(le.network.name)===-1&&fe.push(le)}catch{}}if(n.CloudflareProvider&&ie.cloudflare!=="-")try{fe.push(new n.CloudflareProvider(c))}catch{}if(n.AnkrProvider&&ie.ankr!=="-")try{const ae=["ropsten"],le=new n.AnkrProvider(c,ie.ankr);le.network&&ae.indexOf(le.network.name)===-1&&fe.push(le)}catch{}if(n.QuickNodeProvider&&ie.quicknode!=="-")try{fe.push(new n.QuickNodeProvider(c,ie.quicknode))}catch{}if(fe.length===0)return null;if(n.FallbackProvider){let ae=1;return ie.quorum!=null?ae=ie.quorum:c==="homestead"&&(ae=2),new n.FallbackProvider(fe,ae)}return fe[0]};return t.renetwork=function(n){return ethDefaultProvider(n)},t}function etcDefaultProvider(c,t){const n=function(ie,fe){return ie.JsonRpcProvider?new ie.JsonRpcProvider(c,t):null};return n.renetwork=function(ie){return etcDefaultProvider(c,ie)},n}const homestead={chainId:1,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"homestead",_defaultProvider:ethDefaultProvider("homestead")},ropsten={chainId:3,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"ropsten",_defaultProvider:ethDefaultProvider("ropsten")},classicMordor={chainId:63,name:"classicMordor",_defaultProvider:etcDefaultProvider("https://www.ethercluster.com/mordor","classicMordor")},networks$2={unspecified:{chainId:0,name:"unspecified"},homestead,mainnet:homestead,morden:{chainId:2,name:"morden"},ropsten,testnet:ropsten,rinkeby:{chainId:4,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"rinkeby",_defaultProvider:ethDefaultProvider("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:ethDefaultProvider("kovan")},goerli:{chainId:5,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"goerli",_defaultProvider:ethDefaultProvider("goerli")},kintsugi:{chainId:1337702,name:"kintsugi"},sepolia:{chainId:11155111,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"sepolia",_defaultProvider:ethDefaultProvider("sepolia")},holesky:{chainId:17e3,name:"holesky",_defaultProvider:ethDefaultProvider("holesky")},classic:{chainId:61,name:"classic",_defaultProvider:etcDefaultProvider("https://www.ethercluster.com/etc","classic")},classicMorden:{chainId:62,name:"classicMorden"},classicMordor,classicTestnet:classicMordor,classicKotti:{chainId:6,name:"classicKotti",_defaultProvider:etcDefaultProvider("https://www.ethercluster.com/kotti","classicKotti")},xdai:{chainId:100,name:"xdai"},matic:{chainId:137,name:"matic",_defaultProvider:ethDefaultProvider("matic")},maticmum:{chainId:80001,name:"maticmum",_defaultProvider:ethDefaultProvider("maticmum")},optimism:{chainId:10,name:"optimism",_defaultProvider:ethDefaultProvider("optimism")},"optimism-kovan":{chainId:69,name:"optimism-kovan"},"optimism-goerli":{chainId:420,name:"optimism-goerli"},"optimism-sepolia":{chainId:11155420,name:"optimism-sepolia"},arbitrum:{chainId:42161,name:"arbitrum"},"arbitrum-rinkeby":{chainId:421611,name:"arbitrum-rinkeby"},"arbitrum-goerli":{chainId:421613,name:"arbitrum-goerli"},"arbitrum-sepolia":{chainId:421614,name:"arbitrum-sepolia"},bnb:{chainId:56,name:"bnb"},bnbt:{chainId:97,name:"bnbt"}};function getNetwork(c){if(c==null)return null;if(typeof c=="number"){for(const ie in networks$2){const fe=networks$2[ie];if(fe.chainId===c)return{name:fe.name,chainId:fe.chainId,ensAddress:fe.ensAddress||null,_defaultProvider:fe._defaultProvider||null}}return{chainId:c,name:"unknown"}}if(typeof c=="string"){const ie=networks$2[c];return ie==null?null:{name:ie.name,chainId:ie.chainId,ensAddress:ie.ensAddress,_defaultProvider:ie._defaultProvider||null}}const t=networks$2[c.name];if(!t)return typeof c.chainId!="number"&&logger$7.throwArgumentError("invalid network chainId","network",c),c;c.chainId!==0&&c.chainId!==t.chainId&&logger$7.throwArgumentError("network chainId mismatch","network",c);let n=c._defaultProvider||null;return n==null&&t._defaultProvider&&(isRenetworkable(t._defaultProvider)?n=t._defaultProvider.renetwork(c):n=t._defaultProvider),{name:c.name,chainId:t.chainId,ensAddress:c.ensAddress||t.ensAddress||null,_defaultProvider:n}}const version$9="web/5.8.0";var __awaiter$e=function(c,t,n,ie){function fe(ae){return ae instanceof n?ae:new n(function(le){le(ae)})}return new(n||(n=Promise))(function(ae,le){function he(xe){try{me(ie.next(xe))}catch(Ee){le(Ee)}}function ye(xe){try{me(ie.throw(xe))}catch(Ee){le(Ee)}}function me(xe){xe.done?ae(xe.value):fe(xe.value).then(he,ye)}me((ie=ie.apply(c,t||[])).next())})};function getUrl(c,t){return __awaiter$e(this,void 0,void 0,function*(){t==null&&(t={});const n={method:t.method||"GET",headers:t.headers||{},body:t.body||void 0};if(t.skipFetchSetup!==!0&&(n.mode="cors",n.cache="no-cache",n.credentials="same-origin",n.redirect="follow",n.referrer="client"),t.fetchOptions!=null){const le=t.fetchOptions;le.mode&&(n.mode=le.mode),le.cache&&(n.cache=le.cache),le.credentials&&(n.credentials=le.credentials),le.redirect&&(n.redirect=le.redirect),le.referrer&&(n.referrer=le.referrer)}const ie=yield fetch(c,n),fe=yield ie.arrayBuffer(),ae={};return ie.headers.forEach?ie.headers.forEach((le,he)=>{ae[he.toLowerCase()]=le}):ie.headers.keys().forEach(le=>{ae[le.toLowerCase()]=ie.headers.get(le)}),{headers:ae,statusCode:ie.status,statusMessage:ie.statusText,body:arrayify(new Uint8Array(fe))}})}var __awaiter$d=function(c,t,n,ie){function fe(ae){return ae instanceof n?ae:new n(function(le){le(ae)})}return new(n||(n=Promise))(function(ae,le){function he(xe){try{me(ie.next(xe))}catch(Ee){le(Ee)}}function ye(xe){try{me(ie.throw(xe))}catch(Ee){le(Ee)}}function me(xe){xe.done?ae(xe.value):fe(xe.value).then(he,ye)}me((ie=ie.apply(c,t||[])).next())})};const logger$6=new Logger(version$9);function staller(c){return new Promise(t=>{setTimeout(t,c)})}function bodyify(c,t){if(c==null)return null;if(typeof c=="string")return c;if(isBytesLike(c)){if(t&&(t.split("/")[0]==="text"||t.split(";")[0].trim()==="application/json"))try{return toUtf8String(c)}catch{}return hexlify(c)}return c}function unpercent(c){return toUtf8Bytes(c.replace(/%([0-9a-f][0-9a-f])/gi,(t,n)=>String.fromCharCode(parseInt(n,16))))}function _fetchData(c,t,n){const ie=typeof c=="object"&&c.throttleLimit!=null?c.throttleLimit:12;logger$6.assertArgument(ie>0&&ie%1===0,"invalid connection throttle limit","connection.throttleLimit",ie);const fe=typeof c=="object"?c.throttleCallback:null,ae=typeof c=="object"&&typeof c.throttleSlotInterval=="number"?c.throttleSlotInterval:100;logger$6.assertArgument(ae>0&&ae%1===0,"invalid connection throttle slot interval","connection.throttleSlotInterval",ae);const le=typeof c=="object"?!!c.errorPassThrough:!1,he={};let ye=null;const me={method:"GET"};let xe=!1,Ee=2*60*1e3;if(typeof c=="string")ye=c;else if(typeof c=="object"){if((c==null||c.url==null)&&logger$6.throwArgumentError("missing URL","connection.url",c),ye=c.url,typeof c.timeout=="number"&&c.timeout>0&&(Ee=c.timeout),c.headers)for(const ke in c.headers)he[ke.toLowerCase()]={key:ke,value:String(c.headers[ke])},["if-none-match","if-modified-since"].indexOf(ke.toLowerCase())>=0&&(xe=!0);if(me.allowGzip=!!c.allowGzip,c.user!=null&&c.password!=null){ye.substring(0,6)!=="https:"&&c.allowInsecureAuthentication!==!0&&logger$6.throwError("basic authentication requires a secure https url",Logger.errors.INVALID_ARGUMENT,{argument:"url",url:ye,user:c.user,password:"[REDACTED]"});const ke=c.user+":"+c.password;he.authorization={key:"Authorization",value:"Basic "+encode$5(toUtf8Bytes(ke))}}c.skipFetchSetup!=null&&(me.skipFetchSetup=!!c.skipFetchSetup),c.fetchOptions!=null&&(me.fetchOptions=shallowCopy(c.fetchOptions))}const Se=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),Me=ye?ye.match(Se):null;if(Me)try{const ke={statusCode:200,statusMessage:"OK",headers:{"content-type":Me[1]||"text/plain"},body:Me[2]?decode$6(Me[3]):unpercent(Me[3])};let Pe=ke.body;return n&&(Pe=n(ke.body,ke)),Promise.resolve(Pe)}catch(ke){logger$6.throwError("processing response error",Logger.errors.SERVER_ERROR,{body:bodyify(Me[1],Me[2]),error:ke,requestBody:null,requestMethod:"GET",url:ye})}t&&(me.method="POST",me.body=t,he["content-type"]==null&&(he["content-type"]={key:"Content-Type",value:"application/octet-stream"}),he["content-length"]==null&&(he["content-length"]={key:"Content-Length",value:String(t.length)}));const Be={};Object.keys(he).forEach(ke=>{const Pe=he[ke];Be[Pe.key]=Pe.value}),me.headers=Be;const $e=function(){let ke=null;return{promise:new Promise(function(qe,He){Ee&&(ke=setTimeout(()=>{ke!=null&&(ke=null,He(logger$6.makeError("timeout",Logger.errors.TIMEOUT,{requestBody:bodyify(me.body,Be["content-type"]),requestMethod:me.method,timeout:Ee,url:ye})))},Ee))}),cancel:function(){ke!=null&&(clearTimeout(ke),ke=null)}}}(),Ce=function(){return __awaiter$d(this,void 0,void 0,function*(){for(let ke=0;ke<ie;ke++){let Pe=null;try{if(Pe=yield getUrl(ye,me),ke<ie){if(Pe.statusCode===301||Pe.statusCode===302){const qe=Pe.headers.location||"";if(me.method==="GET"&&qe.match(/^https:/)){ye=Pe.headers.location;continue}}else if(Pe.statusCode===429){let qe=!0;if(fe&&(qe=yield fe(ke,ye)),qe){let He=0;const Ve=Pe.headers["retry-after"];typeof Ve=="string"&&Ve.match(/^[1-9][0-9]*$/)?He=parseInt(Ve)*1e3:He=ae*parseInt(String(Math.random()*Math.pow(2,ke))),yield staller(He);continue}}}}catch(qe){Pe=qe.response,Pe==null&&($e.cancel(),logger$6.throwError("missing response",Logger.errors.SERVER_ERROR,{requestBody:bodyify(me.body,Be["content-type"]),requestMethod:me.method,serverError:qe,url:ye}))}let Ue=Pe.body;if(xe&&Pe.statusCode===304?Ue=null:!le&&(Pe.statusCode<200||Pe.statusCode>=300)&&($e.cancel(),logger$6.throwError("bad response",Logger.errors.SERVER_ERROR,{status:Pe.statusCode,headers:Pe.headers,body:bodyify(Ue,Pe.headers?Pe.headers["content-type"]:null),requestBody:bodyify(me.body,Be["content-type"]),requestMethod:me.method,url:ye})),n)try{const qe=yield n(Ue,Pe);return $e.cancel(),qe}catch(qe){if(qe.throttleRetry&&ke<ie){let He=!0;if(fe&&(He=yield fe(ke,ye)),He){const Ve=ae*parseInt(String(Math.random()*Math.pow(2,ke)));yield staller(Ve);continue}}$e.cancel(),logger$6.throwError("processing response error",Logger.errors.SERVER_ERROR,{body:bodyify(Ue,Pe.headers?Pe.headers["content-type"]:null),error:qe,requestBody:bodyify(me.body,Be["content-type"]),requestMethod:me.method,url:ye})}return $e.cancel(),Ue}return logger$6.throwError("failed response",Logger.errors.SERVER_ERROR,{requestBody:bodyify(me.body,Be["content-type"]),requestMethod:me.method,url:ye})})}();return Promise.race([$e.promise,Ce])}function fetchJson(c,t,n){let ie=(ae,le)=>{let he=null;if(ae!=null)try{he=JSON.parse(toUtf8String(ae))}catch(ye){logger$6.throwError("invalid JSON",Logger.errors.SERVER_ERROR,{body:ae,error:ye})}return n&&(he=n(he,le)),he},fe=null;if(t!=null){fe=toUtf8Bytes(t);const ae=typeof c=="string"?{url:c}:shallowCopy(c);ae.headers?Object.keys(ae.headers).filter(he=>he.toLowerCase()==="content-type").length!==0||(ae.headers=shallowCopy(ae.headers),ae.headers["content-type"]="application/json"):ae.headers={"content-type":"application/json"},c=ae}return _fetchData(c,fe,ie)}function poll(c,t){return t||(t={}),t=shallowCopy(t),t.floor==null&&(t.floor=0),t.ceiling==null&&(t.ceiling=1e4),t.interval==null&&(t.interval=250),new Promise(function(n,ie){let fe=null,ae=!1;const le=()=>ae?!1:(ae=!0,fe&&clearTimeout(fe),!0);t.timeout&&(fe=setTimeout(()=>{le()&&ie(new Error("timeout"))},t.timeout));const he=t.retryLimit;let ye=0;function me(){return c().then(function(xe){if(xe!==void 0)le()&&n(xe);else if(t.oncePoll)t.oncePoll.once("poll",me);else if(t.onceBlock)t.onceBlock.once("block",me);else if(!ae){if(ye++,ye>he){le()&&ie(new Error("retry limit reached"));return}let Ee=t.interval*parseInt(String(Math.random()*Math.pow(2,ye)));Ee<t.floor&&(Ee=t.floor),Ee>t.ceiling&&(Ee=t.ceiling),setTimeout(me,Ee)}return null},function(xe){le()&&ie(xe)})}me()})}const lib_esm$2=Object.freeze(Object.defineProperty({__proto__:null,_fetchData,fetchJson,poll},Symbol.toStringTag,{value:"Module"}));var ALPHABET$2="qpzry9x8gf2tvdw0s3jn54khce6mua7l",ALPHABET_MAP$1={};for(var z$3=0;z$3<ALPHABET$2.length;z$3++){var x$2=ALPHABET$2.charAt(z$3);if(ALPHABET_MAP$1[x$2]!==void 0)throw new TypeError(x$2+" is ambiguous");ALPHABET_MAP$1[x$2]=z$3}function polymodStep$1(c){var t=c>>25;return(c&33554431)<<5^-(t>>0&1)&996825010^-(t>>1&1)&642813549^-(t>>2&1)&513874426^-(t>>3&1)&1027748829^-(t>>4&1)&705979059}function prefixChk$1(c){for(var t=1,n=0;n<c.length;++n){var ie=c.charCodeAt(n);if(ie<33||ie>126)return"Invalid prefix ("+c+")";t=polymodStep$1(t)^ie>>5}for(t=polymodStep$1(t),n=0;n<c.length;++n){var fe=c.charCodeAt(n);t=polymodStep$1(t)^fe&31}return t}function encode$4(c,t,n){if(n=n||90,c.length+7+t.length>n)throw new TypeError("Exceeds length limit");c=c.toLowerCase();var ie=prefixChk$1(c);if(typeof ie=="string")throw new Error(ie);for(var fe=c+"1",ae=0;ae<t.length;++ae){var le=t[ae];if(le>>5)throw new Error("Non 5-bit word");ie=polymodStep$1(ie)^le,fe+=ALPHABET$2.charAt(le)}for(ae=0;ae<6;++ae)ie=polymodStep$1(ie);for(ie^=1,ae=0;ae<6;++ae){var he=ie>>(5-ae)*5&31;fe+=ALPHABET$2.charAt(he)}return fe}function __decode(c,t){if(t=t||90,c.length<8)return c+" too short";if(c.length>t)return"Exceeds length limit";var n=c.toLowerCase(),ie=c.toUpperCase();if(c!==n&&c!==ie)return"Mixed-case string "+c;c=n;var fe=c.lastIndexOf("1");if(fe===-1)return"No separator character for "+c;if(fe===0)return"Missing prefix for "+c;var ae=c.slice(0,fe),le=c.slice(fe+1);if(le.length<6)return"Data too short";var he=prefixChk$1(ae);if(typeof he=="string")return he;for(var ye=[],me=0;me<le.length;++me){var xe=le.charAt(me),Ee=ALPHABET_MAP$1[xe];if(Ee===void 0)return"Unknown character "+xe;he=polymodStep$1(he)^Ee,!(me+6>=le.length)&&ye.push(Ee)}return he!==1?"Invalid checksum for "+c:{prefix:ae,words:ye}}function decodeUnsafe(){var c=__decode.apply(null,arguments);if(typeof c=="object")return c}function decode$5(c){var t=__decode.apply(null,arguments);if(typeof t=="object")return t;throw new Error(t)}function convert$1(c,t,n,ie){for(var fe=0,ae=0,le=(1<<n)-1,he=[],ye=0;ye<c.length;++ye)for(fe=fe<<t|c[ye],ae+=t;ae>=n;)ae-=n,he.push(fe>>ae&le);if(ie)ae>0&&he.push(fe<<n-ae&le);else{if(ae>=t)return"Excess padding";if(fe<<n-ae&le)return"Non-zero padding"}return he}function toWordsUnsafe(c){var t=convert$1(c,8,5,!0);if(Array.isArray(t))return t}function toWords$1(c){var t=convert$1(c,8,5,!0);if(Array.isArray(t))return t;throw new Error(t)}function fromWordsUnsafe$1(c){var t=convert$1(c,5,8,!1);if(Array.isArray(t))return t}function fromWords$1(c){var t=convert$1(c,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}var bech32$1={decodeUnsafe,decode:decode$5,encode:encode$4,toWordsUnsafe,toWords:toWords$1,fromWordsUnsafe:fromWordsUnsafe$1,fromWords:fromWords$1};const bech32$2=getDefaultExportFromCjs$2(bech32$1),version$8="providers/5.8.0",logger$5=new Logger(version$8);class Formatter{constructor(){this.formats=this.getDefaultFormats()}getDefaultFormats(){const t={},n=this.address.bind(this),ie=this.bigNumber.bind(this),fe=this.blockTag.bind(this),ae=this.data.bind(this),le=this.hash.bind(this),he=this.hex.bind(this),ye=this.number.bind(this),me=this.type.bind(this),xe=Ee=>this.data(Ee,!0);return t.transaction={hash:le,type:me,accessList:Formatter.allowNull(this.accessList.bind(this),null),blockHash:Formatter.allowNull(le,null),blockNumber:Formatter.allowNull(ye,null),transactionIndex:Formatter.allowNull(ye,null),confirmations:Formatter.allowNull(ye,null),from:n,gasPrice:Formatter.allowNull(ie),maxPriorityFeePerGas:Formatter.allowNull(ie),maxFeePerGas:Formatter.allowNull(ie),gasLimit:ie,to:Formatter.allowNull(n,null),value:ie,nonce:ye,data:ae,r:Formatter.allowNull(this.uint256),s:Formatter.allowNull(this.uint256),v:Formatter.allowNull(ye),creates:Formatter.allowNull(n,null),raw:Formatter.allowNull(ae)},t.transactionRequest={from:Formatter.allowNull(n),nonce:Formatter.allowNull(ye),gasLimit:Formatter.allowNull(ie),gasPrice:Formatter.allowNull(ie),maxPriorityFeePerGas:Formatter.allowNull(ie),maxFeePerGas:Formatter.allowNull(ie),to:Formatter.allowNull(n),value:Formatter.allowNull(ie),data:Formatter.allowNull(xe),type:Formatter.allowNull(ye),accessList:Formatter.allowNull(this.accessList.bind(this),null)},t.receiptLog={transactionIndex:ye,blockNumber:ye,transactionHash:le,address:n,topics:Formatter.arrayOf(le),data:ae,logIndex:ye,blockHash:le},t.receipt={to:Formatter.allowNull(this.address,null),from:Formatter.allowNull(this.address,null),contractAddress:Formatter.allowNull(n,null),transactionIndex:ye,root:Formatter.allowNull(he),gasUsed:ie,logsBloom:Formatter.allowNull(ae),blockHash:le,transactionHash:le,logs:Formatter.arrayOf(this.receiptLog.bind(this)),blockNumber:ye,confirmations:Formatter.allowNull(ye,null),cumulativeGasUsed:ie,effectiveGasPrice:Formatter.allowNull(ie),status:Formatter.allowNull(ye),type:me},t.block={hash:Formatter.allowNull(le),parentHash:le,number:ye,timestamp:ye,nonce:Formatter.allowNull(he),difficulty:this.difficulty.bind(this),gasLimit:ie,gasUsed:ie,miner:Formatter.allowNull(n),extraData:ae,transactions:Formatter.allowNull(Formatter.arrayOf(le)),baseFeePerGas:Formatter.allowNull(ie)},t.blockWithTransactions=shallowCopy(t.block),t.blockWithTransactions.transactions=Formatter.allowNull(Formatter.arrayOf(this.transactionResponse.bind(this))),t.filter={fromBlock:Formatter.allowNull(fe,void 0),toBlock:Formatter.allowNull(fe,void 0),blockHash:Formatter.allowNull(le,void 0),address:Formatter.allowNull(n,void 0),topics:Formatter.allowNull(this.topics.bind(this),void 0)},t.filterLog={blockNumber:Formatter.allowNull(ye),blockHash:Formatter.allowNull(le),transactionIndex:ye,removed:Formatter.allowNull(this.boolean.bind(this)),address:n,data:Formatter.allowFalsish(ae,"0x"),topics:Formatter.arrayOf(le),transactionHash:le,logIndex:ye},t}accessList(t){return accessListify(t||[])}number(t){return t==="0x"?0:BigNumber.from(t).toNumber()}type(t){return t==="0x"||t==null?0:BigNumber.from(t).toNumber()}bigNumber(t){return BigNumber.from(t)}boolean(t){if(typeof t=="boolean")return t;if(typeof t=="string"){if(t=t.toLowerCase(),t==="true")return!0;if(t==="false")return!1}throw new Error("invalid boolean - "+t)}hex(t,n){return typeof t=="string"&&(!n&&t.substring(0,2)!=="0x"&&(t="0x"+t),isHexString(t))?t.toLowerCase():logger$5.throwArgumentError("invalid hash","value",t)}data(t,n){const ie=this.hex(t,n);if(ie.length%2!==0)throw new Error("invalid data; odd-length - "+t);return ie}address(t){return getAddress$1(t)}callAddress(t){if(!isHexString(t,32))return null;const n=getAddress$1(hexDataSlice(t,12));return n===AddressZero?null:n}contractAddress(t){return getContractAddress(t)}blockTag(t){if(t==null)return"latest";if(t==="earliest")return"0x0";switch(t){case"earliest":return"0x0";case"latest":case"pending":case"safe":case"finalized":return t}if(typeof t=="number"||isHexString(t))return hexValue(t);throw new Error("invalid blockTag")}hash(t,n){const ie=this.hex(t,n);return hexDataLength(ie)!==32?logger$5.throwArgumentError("invalid hash","value",t):ie}difficulty(t){if(t==null)return null;const n=BigNumber.from(t);try{return n.toNumber()}catch{}return null}uint256(t){if(!isHexString(t))throw new Error("invalid uint256");return hexZeroPad(t,32)}_block(t,n){t.author!=null&&t.miner==null&&(t.miner=t.author);const ie=t._difficulty!=null?t._difficulty:t.difficulty,fe=Formatter.check(n,t);return fe._difficulty=ie==null?null:BigNumber.from(ie),fe}block(t){return this._block(t,this.formats.block)}blockWithTransactions(t){return this._block(t,this.formats.blockWithTransactions)}transactionRequest(t){return Formatter.check(this.formats.transactionRequest,t)}transactionResponse(t){t.gas!=null&&t.gasLimit==null&&(t.gasLimit=t.gas),t.to&&BigNumber.from(t.to).isZero()&&(t.to="0x0000000000000000000000000000000000000000"),t.input!=null&&t.data==null&&(t.data=t.input),t.to==null&&t.creates==null&&(t.creates=this.contractAddress(t)),(t.type===1||t.type===2)&&t.accessList==null&&(t.accessList=[]);const n=Formatter.check(this.formats.transaction,t);if(t.chainId!=null){let ie=t.chainId;isHexString(ie)&&(ie=BigNumber.from(ie).toNumber()),n.chainId=ie}else{let ie=t.networkId;ie==null&&n.v==null&&(ie=t.chainId),isHexString(ie)&&(ie=BigNumber.from(ie).toNumber()),typeof ie!="number"&&n.v!=null&&(ie=(n.v-35)/2,ie<0&&(ie=0),ie=parseInt(ie)),typeof ie!="number"&&(ie=0),n.chainId=ie}return n.blockHash&&n.blockHash.replace(/0/g,"")==="x"&&(n.blockHash=null),n}transaction(t){return parse$2(t)}receiptLog(t){return Formatter.check(this.formats.receiptLog,t)}receipt(t){const n=Formatter.check(this.formats.receipt,t);if(n.root!=null)if(n.root.length<=4){const ie=BigNumber.from(n.root).toNumber();ie===0||ie===1?(n.status!=null&&n.status!==ie&&logger$5.throwArgumentError("alt-root-status/status mismatch","value",{root:n.root,status:n.status}),n.status=ie,delete n.root):logger$5.throwArgumentError("invalid alt-root-status","value.root",n.root)}else n.root.length!==66&&logger$5.throwArgumentError("invalid root hash","value.root",n.root);return n.status!=null&&(n.byzantium=!0),n}topics(t){return Array.isArray(t)?t.map(n=>this.topics(n)):t!=null?this.hash(t,!0):null}filter(t){return Formatter.check(this.formats.filter,t)}filterLog(t){return Formatter.check(this.formats.filterLog,t)}static check(t,n){const ie={};for(const fe in t)try{const ae=t[fe](n[fe]);ae!==void 0&&(ie[fe]=ae)}catch(ae){throw ae.checkKey=fe,ae.checkValue=n[fe],ae}return ie}static allowNull(t,n){return function(ie){return ie==null?n:t(ie)}}static allowFalsish(t,n){return function(ie){return ie?t(ie):n}}static arrayOf(t){return function(n){if(!Array.isArray(n))throw new Error("not an array");const ie=[];return n.forEach(function(fe){ie.push(t(fe))}),ie}}}var __awaiter$c=function(c,t,n,ie){function fe(ae){return ae instanceof n?ae:new n(function(le){le(ae)})}return new(n||(n=Promise))(function(ae,le){function he(xe){try{me(ie.next(xe))}catch(Ee){le(Ee)}}function ye(xe){try{me(ie.throw(xe))}catch(Ee){le(Ee)}}function me(xe){xe.done?ae(xe.value):fe(xe.value).then(he,ye)}me((ie=ie.apply(c,t||[])).next())})};const logger$4=new Logger(version$8),MAX_CCIP_REDIRECTS=10;function checkTopic(c){return c==null?"null":(hexDataLength(c)!==32&&logger$4.throwArgumentError("invalid topic","topic",c),c.toLowerCase())}function serializeTopics(c){for(c=c.slice();c.length>0&&c[c.length-1]==null;)c.pop();return c.map(t=>{if(Array.isArray(t)){const n={};t.forEach(fe=>{n[checkTopic(fe)]=!0});const ie=Object.keys(n);return ie.sort(),ie.join("|")}else return checkTopic(t)}).join("&")}function deserializeTopics(c){return c===""?[]:c.split(/&/g).map(t=>{if(t==="")return[];const n=t.split("|").map(ie=>ie==="null"?null:ie);return n.length===1?n[0]:n})}function getEventTag(c){if(typeof c=="string"){if(c=c.toLowerCase(),hexDataLength(c)===32)return"tx:"+c;if(c.indexOf(":")===-1)return c}else{if(Array.isArray(c))return"filter:*:"+serializeTopics(c);if(ForkEvent.isForkEvent(c))throw logger$4.warn("not implemented"),new Error("not implemented");if(c&&typeof c=="object")return"filter:"+(c.address||"*")+":"+serializeTopics(c.topics||[])}throw new Error("invalid event - "+c)}function getTime(){return new Date().getTime()}function stall(c){return new Promise(t=>{setTimeout(t,c)})}const PollableEvents=["block","network","pending","poll"];let Event$1=class{constructor(t,n,ie){defineReadOnly(this,"tag",t),defineReadOnly(this,"listener",n),defineReadOnly(this,"once",ie),this._lastBlockNumber=-2,this._inflight=!1}get event(){switch(this.type){case"tx":return this.hash;case"filter":return this.filter}return this.tag}get type(){return this.tag.split(":")[0]}get hash(){const t=this.tag.split(":");return t[0]!=="tx"?null:t[1]}get filter(){const t=this.tag.split(":");if(t[0]!=="filter")return null;const n=t[1],ie=deserializeTopics(t[2]),fe={};return ie.length>0&&(fe.topics=ie),n&&n!=="*"&&(fe.address=n),fe}pollable(){return this.tag.indexOf(":")>=0||PollableEvents.indexOf(this.tag)>=0}};const coinInfos={0:{symbol:"btc",p2pkh:0,p2sh:5,prefix:"bc"},2:{symbol:"ltc",p2pkh:48,p2sh:50,prefix:"ltc"},3:{symbol:"doge",p2pkh:30,p2sh:22},60:{symbol:"eth",ilk:"eth"},61:{symbol:"etc",ilk:"eth"},700:{symbol:"xdai",ilk:"eth"}};function bytes32ify(c){return hexZeroPad(BigNumber.from(c).toHexString(),32)}function base58Encode(c){return Base58.encode(concat$1([c,hexDataSlice(sha256$7(sha256$7(c)),0,4)]))}const matcherIpfs=new RegExp("^(ipfs)://(.*)$","i"),matchers=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),matcherIpfs,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];function _parseString(c,t){try{return toUtf8String(_parseBytes(c,t))}catch{}return null}function _parseBytes(c,t){if(c==="0x")return null;const n=BigNumber.from(hexDataSlice(c,t,t+32)).toNumber(),ie=BigNumber.from(hexDataSlice(c,n,n+32)).toNumber();return hexDataSlice(c,n+32,n+32+ie)}function getIpfsLink(c){return c.match(/^ipfs:\/\/ipfs\//i)?c=c.substring(12):c.match(/^ipfs:\/\//i)?c=c.substring(7):logger$4.throwArgumentError("unsupported IPFS format","link",c),`https://gateway.ipfs.io/ipfs/${c}`}function numPad(c){const t=arrayify(c);if(t.length>32)throw new Error("internal; should not happen");const n=new Uint8Array(32);return n.set(t,32-t.length),n}function bytesPad(c){if(c.length%32===0)return c;const t=new Uint8Array(Math.ceil(c.length/32)*32);return t.set(c),t}function encodeBytes(c){const t=[];let n=0;for(let ie=0;ie<c.length;ie++)t.push(null),n+=32;for(let ie=0;ie<c.length;ie++){const fe=arrayify(c[ie]);t[ie]=numPad(n),t.push(numPad(fe.length)),t.push(bytesPad(fe)),n+=32+Math.ceil(fe.length/32)*32}return hexConcat(t)}class Resolver{constructor(t,n,ie,fe){defineReadOnly(this,"provider",t),defineReadOnly(this,"name",ie),defineReadOnly(this,"address",t.formatter.address(n)),defineReadOnly(this,"_resolvedAddress",fe)}supportsWildcard(){return this._supportsEip2544||(this._supportsEip2544=this.provider.call({to:this.address,data:"0x01ffc9a79061b92300000000000000000000000000000000000000000000000000000000"}).then(t=>BigNumber.from(t).eq(1)).catch(t=>{if(t.code===Logger.errors.CALL_EXCEPTION)return!1;throw this._supportsEip2544=null,t})),this._supportsEip2544}_fetch(t,n){return __awaiter$c(this,void 0,void 0,function*(){const ie={to:this.address,ccipReadEnabled:!0,data:hexConcat([t,namehash$1(this.name),n||"0x"])};let fe=!1;(yield this.supportsWildcard())&&(fe=!0,ie.data=hexConcat(["0x9061b923",encodeBytes([dnsEncode(this.name),ie.data])]));try{let ae=yield this.provider.call(ie);return arrayify(ae).length%32===4&&logger$4.throwError("resolver threw error",Logger.errors.CALL_EXCEPTION,{transaction:ie,data:ae}),fe&&(ae=_parseBytes(ae,0)),ae}catch(ae){if(ae.code===Logger.errors.CALL_EXCEPTION)return null;throw ae}})}_fetchBytes(t,n){return __awaiter$c(this,void 0,void 0,function*(){const ie=yield this._fetch(t,n);return ie!=null?_parseBytes(ie,0):null})}_getAddress(t,n){const ie=coinInfos[String(t)];if(ie==null&&logger$4.throwError(`unsupported coin type: ${t}`,Logger.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${t})`}),ie.ilk==="eth")return this.provider.formatter.address(n);const fe=arrayify(n);if(ie.p2pkh!=null){const ae=n.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/);if(ae){const le=parseInt(ae[1],16);if(ae[2].length===le*2&&le>=1&&le<=75)return base58Encode(concat$1([[ie.p2pkh],"0x"+ae[2]]))}}if(ie.p2sh!=null){const ae=n.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/);if(ae){const le=parseInt(ae[1],16);if(ae[2].length===le*2&&le>=1&&le<=75)return base58Encode(concat$1([[ie.p2sh],"0x"+ae[2]]))}}if(ie.prefix!=null){const ae=fe[1];let le=fe[0];if(le===0?ae!==20&&ae!==32&&(le=-1):le=-1,le>=0&&fe.length===2+ae&&ae>=1&&ae<=75){const he=bech32$2.toWords(fe.slice(2));return he.unshift(le),bech32$2.encode(ie.prefix,he)}}return null}getAddress(t){return __awaiter$c(this,void 0,void 0,function*(){if(t==null&&(t=60),t===60)try{const fe=yield this._fetch("0x3b3b57de");return fe==="0x"||fe===HashZero?null:this.provider.formatter.callAddress(fe)}catch(fe){if(fe.code===Logger.errors.CALL_EXCEPTION)return null;throw fe}const n=yield this._fetchBytes("0xf1cb7e06",bytes32ify(t));if(n==null||n==="0x")return null;const ie=this._getAddress(t,n);return ie==null&&logger$4.throwError("invalid or unsupported coin data",Logger.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${t})`,coinType:t,data:n}),ie})}getAvatar(){return __awaiter$c(this,void 0,void 0,function*(){const t=[{type:"name",content:this.name}];try{const n=yield this.getText("avatar");if(n==null)return null;for(let ie=0;ie<matchers.length;ie++){const fe=n.match(matchers[ie]);if(fe==null)continue;const ae=fe[1].toLowerCase();switch(ae){case"https":return t.push({type:"url",content:n}),{linkage:t,url:n};case"data":return t.push({type:"data",content:n}),{linkage:t,url:n};case"ipfs":return t.push({type:"ipfs",content:n}),{linkage:t,url:getIpfsLink(n)};case"erc721":case"erc1155":{const le=ae==="erc721"?"0xc87b56dd":"0x0e89341c";t.push({type:ae,content:n});const he=this._resolvedAddress||(yield this.getAddress()),ye=(fe[2]||"").split("/");if(ye.length!==2)return null;const me=yield this.provider.formatter.address(ye[0]),xe=hexZeroPad(BigNumber.from(ye[1]).toHexString(),32);if(ae==="erc721"){const $e=this.provider.formatter.callAddress(yield this.provider.call({to:me,data:hexConcat(["0x6352211e",xe])}));if(he!==$e)return null;t.push({type:"owner",content:$e})}else if(ae==="erc1155"){const $e=BigNumber.from(yield this.provider.call({to:me,data:hexConcat(["0x00fdd58e",hexZeroPad(he,32),xe])}));if($e.isZero())return null;t.push({type:"balance",content:$e.toString()})}const Ee={to:this.provider.formatter.address(ye[0]),data:hexConcat([le,xe])};let Se=_parseString(yield this.provider.call(Ee),0);if(Se==null)return null;t.push({type:"metadata-url-base",content:Se}),ae==="erc1155"&&(Se=Se.replace("{id}",xe.substring(2)),t.push({type:"metadata-url-expanded",content:Se})),Se.match(/^ipfs:/i)&&(Se=getIpfsLink(Se)),t.push({type:"metadata-url",content:Se});const Me=yield fetchJson(Se);if(!Me)return null;t.push({type:"metadata",content:JSON.stringify(Me)});let Be=Me.image;if(typeof Be!="string")return null;if(!Be.match(/^(https:\/\/|data:)/i)){if(Be.match(matcherIpfs)==null)return null;t.push({type:"url-ipfs",content:Be}),Be=getIpfsLink(Be)}return t.push({type:"url",content:Be}),{linkage:t,url:Be}}}}}catch{}return null})}getContentHash(){return __awaiter$c(this,void 0,void 0,function*(){const t=yield this._fetchBytes("0xbc1c58d1");if(t==null||t==="0x")return null;const n=t.match(/^0xe3010170(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(n){const le=parseInt(n[3],16);if(n[4].length===le*2)return"ipfs://"+Base58.encode("0x"+n[1])}const ie=t.match(/^0xe5010172(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(ie){const le=parseInt(ie[3],16);if(ie[4].length===le*2)return"ipns://"+Base58.encode("0x"+ie[1])}const fe=t.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(fe&&fe[1].length===32*2)return"bzz://"+fe[1];const ae=t.match(/^0x90b2c605([0-9a-f]*)$/);if(ae&&ae[1].length===34*2){const le={"=":"","+":"-","/":"_"};return"sia://"+encode$5("0x"+ae[1]).replace(/[=+\/]/g,ye=>le[ye])}return logger$4.throwError("invalid or unsupported content hash data",Logger.errors.UNSUPPORTED_OPERATION,{operation:"getContentHash()",data:t})})}getText(t){return __awaiter$c(this,void 0,void 0,function*(){let n=toUtf8Bytes(t);n=concat$1([bytes32ify(64),bytes32ify(n.length),n]),n.length%32!==0&&(n=concat$1([n,hexZeroPad("0x",32-t.length%32)]));const ie=yield this._fetchBytes("0x59d1d43c",hexlify(n));return ie==null||ie==="0x"?null:toUtf8String(ie)})}}let defaultFormatter=null,nextPollId=1;class BaseProvider extends Provider{constructor(t){if(super(),this._events=[],this._emitted={block:-2},this.disableCcipRead=!1,this.formatter=new.target.getFormatter(),defineReadOnly(this,"anyNetwork",t==="any"),this.anyNetwork&&(t=this.detectNetwork()),t instanceof Promise)this._networkPromise=t,t.catch(n=>{}),this._ready().catch(n=>{});else{const n=getStatic(new.target,"getNetwork")(t);n?(defineReadOnly(this,"_network",n),this.emit("network",n,null)):logger$4.throwArgumentError("invalid network","network",t)}this._maxInternalBlockNumber=-1024,this._lastBlockNumber=-2,this._maxFilterBlockRange=10,this._pollingInterval=4e3,this._fastQueryDate=0}_ready(){return __awaiter$c(this,void 0,void 0,function*(){if(this._network==null){let t=null;if(this._networkPromise)try{t=yield this._networkPromise}catch{}t==null&&(t=yield this.detectNetwork()),t||logger$4.throwError("no network detected",Logger.errors.UNKNOWN_ERROR,{}),this._network==null&&(this.anyNetwork?this._network=t:defineReadOnly(this,"_network",t),this.emit("network",t,null))}return this._network})}get ready(){return poll(()=>this._ready().then(t=>t,t=>{if(!(t.code===Logger.errors.NETWORK_ERROR&&t.event==="noNetwork"))throw t}))}static getFormatter(){return defaultFormatter==null&&(defaultFormatter=new Formatter),defaultFormatter}static getNetwork(t){return getNetwork(t??"homestead")}ccipReadFetch(t,n,ie){return __awaiter$c(this,void 0,void 0,function*(){if(this.disableCcipRead||ie.length===0)return null;const fe=t.to.toLowerCase(),ae=n.toLowerCase(),le=[];for(let he=0;he<ie.length;he++){const ye=ie[he],me=ye.replace("{sender}",fe).replace("{data}",ae),xe=ye.indexOf("{data}")>=0?null:JSON.stringify({data:ae,sender:fe}),Ee=yield fetchJson({url:me,errorPassThrough:!0},xe,(Me,Be)=>(Me.status=Be.statusCode,Me));if(Ee.data)return Ee.data;const Se=Ee.message||"unknown error";if(Ee.status>=400&&Ee.status<500)return logger$4.throwError(`response not found during CCIP fetch: ${Se}`,Logger.errors.SERVER_ERROR,{url:ye,errorMessage:Se});le.push(Se)}return logger$4.throwError(`error encountered during CCIP fetch: ${le.map(he=>JSON.stringify(he)).join(", ")}`,Logger.errors.SERVER_ERROR,{urls:ie,errorMessages:le})})}_getInternalBlockNumber(t){return __awaiter$c(this,void 0,void 0,function*(){if(yield this._ready(),t>0)for(;this._internalBlockNumber;){const fe=this._internalBlockNumber;try{const ae=yield fe;if(getTime()-ae.respTime<=t)return ae.blockNumber;break}catch{if(this._internalBlockNumber===fe)break}}const n=getTime(),ie=resolveProperties({blockNumber:this.perform("getBlockNumber",{}),networkError:this.getNetwork().then(fe=>null,fe=>fe)}).then(({blockNumber:fe,networkError:ae})=>{if(ae)throw this._internalBlockNumber===ie&&(this._internalBlockNumber=null),ae;const le=getTime();return fe=BigNumber.from(fe).toNumber(),fe<this._maxInternalBlockNumber&&(fe=this._maxInternalBlockNumber),this._maxInternalBlockNumber=fe,this._setFastBlockNumber(fe),{blockNumber:fe,reqTime:n,respTime:le}});return this._internalBlockNumber=ie,ie.catch(fe=>{this._internalBlockNumber===ie&&(this._internalBlockNumber=null)}),(yield ie).blockNumber})}poll(){return __awaiter$c(this,void 0,void 0,function*(){const t=nextPollId++,n=[];let ie=null;try{ie=yield this._getInternalBlockNumber(100+this.pollingInterval/2)}catch(fe){this.emit("error",fe);return}if(this._setFastBlockNumber(ie),this.emit("poll",t,ie),ie===this._lastBlockNumber){this.emit("didPoll",t);return}if(this._emitted.block===-2&&(this._emitted.block=ie-1),Math.abs(this._emitted.block-ie)>1e3)logger$4.warn(`network block skew detected; skipping block events (emitted=${this._emitted.block} blockNumber${ie})`),this.emit("error",logger$4.makeError("network block skew detected",Logger.errors.NETWORK_ERROR,{blockNumber:ie,event:"blockSkew",previousBlockNumber:this._emitted.block})),this.emit("block",ie);else for(let fe=this._emitted.block+1;fe<=ie;fe++)this.emit("block",fe);this._emitted.block!==ie&&(this._emitted.block=ie,Object.keys(this._emitted).forEach(fe=>{if(fe==="block")return;const ae=this._emitted[fe];ae!=="pending"&&ie-ae>12&&delete this._emitted[fe]})),this._lastBlockNumber===-2&&(this._lastBlockNumber=ie-1),this._events.forEach(fe=>{switch(fe.type){case"tx":{const ae=fe.hash;let le=this.getTransactionReceipt(ae).then(he=>(!he||he.blockNumber==null||(this._emitted["t:"+ae]=he.blockNumber,this.emit(ae,he)),null)).catch(he=>{this.emit("error",he)});n.push(le);break}case"filter":{if(!fe._inflight){fe._inflight=!0,fe._lastBlockNumber===-2&&(fe._lastBlockNumber=ie-1);const ae=fe.filter;ae.fromBlock=fe._lastBlockNumber+1,ae.toBlock=ie;const le=ae.toBlock-this._maxFilterBlockRange;le>ae.fromBlock&&(ae.fromBlock=le),ae.fromBlock<0&&(ae.fromBlock=0);const he=this.getLogs(ae).then(ye=>{fe._inflight=!1,ye.length!==0&&ye.forEach(me=>{me.blockNumber>fe._lastBlockNumber&&(fe._lastBlockNumber=me.blockNumber),this._emitted["b:"+me.blockHash]=me.blockNumber,this._emitted["t:"+me.transactionHash]=me.blockNumber,this.emit(ae,me)})}).catch(ye=>{this.emit("error",ye),fe._inflight=!1});n.push(he)}break}}}),this._lastBlockNumber=ie,Promise.all(n).then(()=>{this.emit("didPoll",t)}).catch(fe=>{this.emit("error",fe)})})}resetEventsBlock(t){this._lastBlockNumber=t-1,this.polling&&this.poll()}get network(){return this._network}detectNetwork(){return __awaiter$c(this,void 0,void 0,function*(){return logger$4.throwError("provider does not support network detection",Logger.errors.UNSUPPORTED_OPERATION,{operation:"provider.detectNetwork"})})}getNetwork(){return __awaiter$c(this,void 0,void 0,function*(){const t=yield this._ready(),n=yield this.detectNetwork();if(t.chainId!==n.chainId){if(this.anyNetwork)return this._network=n,this._lastBlockNumber=-2,this._fastBlockNumber=null,this._fastBlockNumberPromise=null,this._fastQueryDate=0,this._emitted.block=-2,this._maxInternalBlockNumber=-1024,this._internalBlockNumber=null,this.emit("network",n,t),yield stall(0),this._network;const ie=logger$4.makeError("underlying network changed",Logger.errors.NETWORK_ERROR,{event:"changed",network:t,detectedNetwork:n});throw this.emit("error",ie),ie}return t})}get blockNumber(){return this._getInternalBlockNumber(100+this.pollingInterval/2).then(t=>{this._setFastBlockNumber(t)},t=>{}),this._fastBlockNumber!=null?this._fastBlockNumber:-1}get polling(){return this._poller!=null}set polling(t){t&&!this._poller?(this._poller=setInterval(()=>{this.poll()},this.pollingInterval),this._bootstrapPoll||(this._bootstrapPoll=setTimeout(()=>{this.poll(),this._bootstrapPoll=setTimeout(()=>{this._poller||this.poll(),this._bootstrapPoll=null},this.pollingInterval)},0))):!t&&this._poller&&(clearInterval(this._poller),this._poller=null)}get pollingInterval(){return this._pollingInterval}set pollingInterval(t){if(typeof t!="number"||t<=0||parseInt(String(t))!=t)throw new Error("invalid polling interval");this._pollingInterval=t,this._poller&&(clearInterval(this._poller),this._poller=setInterval(()=>{this.poll()},this._pollingInterval))}_getFastBlockNumber(){const t=getTime();return t-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=t,this._fastBlockNumberPromise=this.getBlockNumber().then(n=>((this._fastBlockNumber==null||n>this._fastBlockNumber)&&(this._fastBlockNumber=n),this._fastBlockNumber))),this._fastBlockNumberPromise}_setFastBlockNumber(t){this._fastBlockNumber!=null&&t<this._fastBlockNumber||(this._fastQueryDate=getTime(),(this._fastBlockNumber==null||t>this._fastBlockNumber)&&(this._fastBlockNumber=t,this._fastBlockNumberPromise=Promise.resolve(t)))}waitForTransaction(t,n,ie){return __awaiter$c(this,void 0,void 0,function*(){return this._waitForTransaction(t,n??1,ie||0,null)})}_waitForTransaction(t,n,ie,fe){return __awaiter$c(this,void 0,void 0,function*(){const ae=yield this.getTransactionReceipt(t);return(ae?ae.confirmations:0)>=n?ae:new Promise((le,he)=>{const ye=[];let me=!1;const xe=function(){return me?!0:(me=!0,ye.forEach(Se=>{Se()}),!1)},Ee=Se=>{Se.confirmations<n||xe()||le(Se)};if(this.on(t,Ee),ye.push(()=>{this.removeListener(t,Ee)}),fe){let Se=fe.startBlock,Me=null;const Be=$e=>__awaiter$c(this,void 0,void 0,function*(){me||(yield stall(1e3),this.getTransactionCount(fe.from).then(Ce=>__awaiter$c(this,void 0,void 0,function*(){if(!me){if(Ce<=fe.nonce)Se=$e;else{{const ke=yield this.getTransaction(t);if(ke&&ke.blockNumber!=null)return}for(Me==null&&(Me=Se-3,Me<fe.startBlock&&(Me=fe.startBlock));Me<=$e;){if(me)return;const ke=yield this.getBlockWithTransactions(Me);for(let Pe=0;Pe<ke.transactions.length;Pe++){const Ue=ke.transactions[Pe];if(Ue.hash===t)return;if(Ue.from===fe.from&&Ue.nonce===fe.nonce){if(me)return;const qe=yield this.waitForTransaction(Ue.hash,n);if(xe())return;let He="replaced";Ue.data===fe.data&&Ue.to===fe.to&&Ue.value.eq(fe.value)?He="repriced":Ue.data==="0x"&&Ue.from===Ue.to&&Ue.value.isZero()&&(He="cancelled"),he(logger$4.makeError("transaction was replaced",Logger.errors.TRANSACTION_REPLACED,{cancelled:He==="replaced"||He==="cancelled",reason:He,replacement:this._wrapTransaction(Ue),hash:t,receipt:qe}));return}}Me++}}me||this.once("block",Be)}}),Ce=>{me||this.once("block",Be)}))});if(me)return;this.once("block",Be),ye.push(()=>{this.removeListener("block",Be)})}if(typeof ie=="number"&&ie>0){const Se=setTimeout(()=>{xe()||he(logger$4.makeError("timeout exceeded",Logger.errors.TIMEOUT,{timeout:ie}))},ie);Se.unref&&Se.unref(),ye.push(()=>{clearTimeout(Se)})}})})}getBlockNumber(){return __awaiter$c(this,void 0,void 0,function*(){return this._getInternalBlockNumber(0)})}getGasPrice(){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const t=yield this.perform("getGasPrice",{});try{return BigNumber.from(t)}catch(n){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getGasPrice",result:t,error:n})}})}getBalance(t,n){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const ie=yield resolveProperties({address:this._getAddress(t),blockTag:this._getBlockTag(n)}),fe=yield this.perform("getBalance",ie);try{return BigNumber.from(fe)}catch(ae){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getBalance",params:ie,result:fe,error:ae})}})}getTransactionCount(t,n){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const ie=yield resolveProperties({address:this._getAddress(t),blockTag:this._getBlockTag(n)}),fe=yield this.perform("getTransactionCount",ie);try{return BigNumber.from(fe).toNumber()}catch(ae){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getTransactionCount",params:ie,result:fe,error:ae})}})}getCode(t,n){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const ie=yield resolveProperties({address:this._getAddress(t),blockTag:this._getBlockTag(n)}),fe=yield this.perform("getCode",ie);try{return hexlify(fe)}catch(ae){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getCode",params:ie,result:fe,error:ae})}})}getStorageAt(t,n,ie){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const fe=yield resolveProperties({address:this._getAddress(t),blockTag:this._getBlockTag(ie),position:Promise.resolve(n).then(le=>hexValue(le))}),ae=yield this.perform("getStorageAt",fe);try{return hexlify(ae)}catch(le){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getStorageAt",params:fe,result:ae,error:le})}})}_wrapTransaction(t,n,ie){if(n!=null&&hexDataLength(n)!==32)throw new Error("invalid response - sendTransaction");const fe=t;return n!=null&&t.hash!==n&&logger$4.throwError("Transaction hash mismatch from Provider.sendTransaction.",Logger.errors.UNKNOWN_ERROR,{expectedHash:t.hash,returnedHash:n}),fe.wait=(ae,le)=>__awaiter$c(this,void 0,void 0,function*(){ae==null&&(ae=1),le==null&&(le=0);let he;ae!==0&&ie!=null&&(he={data:t.data,from:t.from,nonce:t.nonce,to:t.to,value:t.value,startBlock:ie});const ye=yield this._waitForTransaction(t.hash,ae,le,he);return ye==null&&ae===0?null:(this._emitted["t:"+t.hash]=ye.blockNumber,ye.status===0&&logger$4.throwError("transaction failed",Logger.errors.CALL_EXCEPTION,{transactionHash:t.hash,transaction:t,receipt:ye}),ye)}),fe}sendTransaction(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const n=yield Promise.resolve(t).then(ae=>hexlify(ae)),ie=this.formatter.transaction(t);ie.confirmations==null&&(ie.confirmations=0);const fe=yield this._getInternalBlockNumber(100+2*this.pollingInterval);try{const ae=yield this.perform("sendTransaction",{signedTransaction:n});return this._wrapTransaction(ie,ae,fe)}catch(ae){throw ae.transaction=ie,ae.transactionHash=ie.hash,ae}})}_getTransactionRequest(t){return __awaiter$c(this,void 0,void 0,function*(){const n=yield t,ie={};return["from","to"].forEach(fe=>{n[fe]!=null&&(ie[fe]=Promise.resolve(n[fe]).then(ae=>ae?this._getAddress(ae):null))}),["gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","value"].forEach(fe=>{n[fe]!=null&&(ie[fe]=Promise.resolve(n[fe]).then(ae=>ae?BigNumber.from(ae):null))}),["type"].forEach(fe=>{n[fe]!=null&&(ie[fe]=Promise.resolve(n[fe]).then(ae=>ae??null))}),n.accessList&&(ie.accessList=this.formatter.accessList(n.accessList)),["data"].forEach(fe=>{n[fe]!=null&&(ie[fe]=Promise.resolve(n[fe]).then(ae=>ae?hexlify(ae):null))}),this.formatter.transactionRequest(yield resolveProperties(ie))})}_getFilter(t){return __awaiter$c(this,void 0,void 0,function*(){t=yield t;const n={};return t.address!=null&&(n.address=this._getAddress(t.address)),["blockHash","topics"].forEach(ie=>{t[ie]!=null&&(n[ie]=t[ie])}),["fromBlock","toBlock"].forEach(ie=>{t[ie]!=null&&(n[ie]=this._getBlockTag(t[ie]))}),this.formatter.filter(yield resolveProperties(n))})}_call(t,n,ie){return __awaiter$c(this,void 0,void 0,function*(){ie>=MAX_CCIP_REDIRECTS&&logger$4.throwError("CCIP read exceeded maximum redirections",Logger.errors.SERVER_ERROR,{redirects:ie,transaction:t});const fe=t.to,ae=yield this.perform("call",{transaction:t,blockTag:n});if(ie>=0&&n==="latest"&&fe!=null&&ae.substring(0,10)==="0x556f1830"&&hexDataLength(ae)%32===4)try{const le=hexDataSlice(ae,4),he=hexDataSlice(le,0,32);BigNumber.from(he).eq(fe)||logger$4.throwError("CCIP Read sender did not match",Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:ae});const ye=[],me=BigNumber.from(hexDataSlice(le,32,64)).toNumber(),xe=BigNumber.from(hexDataSlice(le,me,me+32)).toNumber(),Ee=hexDataSlice(le,me+32);for(let ke=0;ke<xe;ke++){const Pe=_parseString(Ee,ke*32);Pe==null&&logger$4.throwError("CCIP Read contained corrupt URL string",Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:ae}),ye.push(Pe)}const Se=_parseBytes(le,64);BigNumber.from(hexDataSlice(le,100,128)).isZero()||logger$4.throwError("CCIP Read callback selector included junk",Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:ae});const Me=hexDataSlice(le,96,100),Be=_parseBytes(le,128),$e=yield this.ccipReadFetch(t,Se,ye);$e==null&&logger$4.throwError("CCIP Read disabled or provided no URLs",Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:ae});const Ce={to:fe,data:hexConcat([Me,encodeBytes([$e,Be])])};return this._call(Ce,n,ie+1)}catch(le){if(le.code===Logger.errors.SERVER_ERROR)throw le}try{return hexlify(ae)}catch(le){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"call",params:{transaction:t,blockTag:n},result:ae,error:le})}})}call(t,n){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const ie=yield resolveProperties({transaction:this._getTransactionRequest(t),blockTag:this._getBlockTag(n),ccipReadEnabled:Promise.resolve(t.ccipReadEnabled)});return this._call(ie.transaction,ie.blockTag,ie.ccipReadEnabled?0:-1)})}estimateGas(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const n=yield resolveProperties({transaction:this._getTransactionRequest(t)}),ie=yield this.perform("estimateGas",n);try{return BigNumber.from(ie)}catch(fe){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"estimateGas",params:n,result:ie,error:fe})}})}_getAddress(t){return __awaiter$c(this,void 0,void 0,function*(){t=yield t,typeof t!="string"&&logger$4.throwArgumentError("invalid address or ENS name","name",t);const n=yield this.resolveName(t);return n==null&&logger$4.throwError("ENS name not configured",Logger.errors.UNSUPPORTED_OPERATION,{operation:`resolveName(${JSON.stringify(t)})`}),n})}_getBlock(t,n){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork(),t=yield t;let ie=-128;const fe={includeTransactions:!!n};if(isHexString(t,32))fe.blockHash=t;else try{fe.blockTag=yield this._getBlockTag(t),isHexString(fe.blockTag)&&(ie=parseInt(fe.blockTag.substring(2),16))}catch{logger$4.throwArgumentError("invalid block hash or block tag","blockHashOrBlockTag",t)}return poll(()=>__awaiter$c(this,void 0,void 0,function*(){const ae=yield this.perform("getBlock",fe);if(ae==null)return fe.blockHash!=null&&this._emitted["b:"+fe.blockHash]==null||fe.blockTag!=null&&ie>this._emitted.block?null:void 0;if(n){let le=null;for(let ye=0;ye<ae.transactions.length;ye++){const me=ae.transactions[ye];if(me.blockNumber==null)me.confirmations=0;else if(me.confirmations==null){le==null&&(le=yield this._getInternalBlockNumber(100+2*this.pollingInterval));let xe=le-me.blockNumber+1;xe<=0&&(xe=1),me.confirmations=xe}}const he=this.formatter.blockWithTransactions(ae);return he.transactions=he.transactions.map(ye=>this._wrapTransaction(ye)),he}return this.formatter.block(ae)}),{oncePoll:this})})}getBlock(t){return this._getBlock(t,!1)}getBlockWithTransactions(t){return this._getBlock(t,!0)}getTransaction(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork(),t=yield t;const n={transactionHash:this.formatter.hash(t,!0)};return poll(()=>__awaiter$c(this,void 0,void 0,function*(){const ie=yield this.perform("getTransaction",n);if(ie==null)return this._emitted["t:"+t]==null?null:void 0;const fe=this.formatter.transactionResponse(ie);if(fe.blockNumber==null)fe.confirmations=0;else if(fe.confirmations==null){let le=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-fe.blockNumber+1;le<=0&&(le=1),fe.confirmations=le}return this._wrapTransaction(fe)}),{oncePoll:this})})}getTransactionReceipt(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork(),t=yield t;const n={transactionHash:this.formatter.hash(t,!0)};return poll(()=>__awaiter$c(this,void 0,void 0,function*(){const ie=yield this.perform("getTransactionReceipt",n);if(ie==null)return this._emitted["t:"+t]==null?null:void 0;if(ie.blockHash==null)return;const fe=this.formatter.receipt(ie);if(fe.blockNumber==null)fe.confirmations=0;else if(fe.confirmations==null){let le=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-fe.blockNumber+1;le<=0&&(le=1),fe.confirmations=le}return fe}),{oncePoll:this})})}getLogs(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const n=yield resolveProperties({filter:this._getFilter(t)}),ie=yield this.perform("getLogs",n);return ie.forEach(fe=>{fe.removed==null&&(fe.removed=!1)}),Formatter.arrayOf(this.formatter.filterLog.bind(this.formatter))(ie)})}getEtherPrice(){return __awaiter$c(this,void 0,void 0,function*(){return yield this.getNetwork(),this.perform("getEtherPrice",{})})}_getBlockTag(t){return __awaiter$c(this,void 0,void 0,function*(){if(t=yield t,typeof t=="number"&&t<0){t%1&&logger$4.throwArgumentError("invalid BlockTag","blockTag",t);let n=yield this._getInternalBlockNumber(100+2*this.pollingInterval);return n+=t,n<0&&(n=0),this.formatter.blockTag(n)}return this.formatter.blockTag(t)})}getResolver(t){return __awaiter$c(this,void 0,void 0,function*(){let n=t;for(;;){if(n===""||n==="."||t!=="eth"&&n==="eth")return null;const ie=yield this._getResolver(n,"getResolver");if(ie!=null){const fe=new Resolver(this,ie,t);return n!==t&&!(yield fe.supportsWildcard())?null:fe}n=n.split(".").slice(1).join(".")}})}_getResolver(t,n){return __awaiter$c(this,void 0,void 0,function*(){n==null&&(n="ENS");const ie=yield this.getNetwork();ie.ensAddress||logger$4.throwError("network does not support ENS",Logger.errors.UNSUPPORTED_OPERATION,{operation:n,network:ie.name});try{const fe=yield this.call({to:ie.ensAddress,data:"0x0178b8bf"+namehash$1(t).substring(2)});return this.formatter.callAddress(fe)}catch{}return null})}resolveName(t){return __awaiter$c(this,void 0,void 0,function*(){t=yield t;try{return Promise.resolve(this.formatter.address(t))}catch(ie){if(isHexString(t))throw ie}typeof t!="string"&&logger$4.throwArgumentError("invalid ENS name","name",t);const n=yield this.getResolver(t);return n?yield n.getAddress():null})}lookupAddress(t){return __awaiter$c(this,void 0,void 0,function*(){t=yield t,t=this.formatter.address(t);const n=t.substring(2).toLowerCase()+".addr.reverse",ie=yield this._getResolver(n,"lookupAddress");if(ie==null)return null;const fe=_parseString(yield this.call({to:ie,data:"0x691f3431"+namehash$1(n).substring(2)}),0);return(yield this.resolveName(fe))!=t?null:fe})}getAvatar(t){return __awaiter$c(this,void 0,void 0,function*(){let n=null;if(isHexString(t)){const ae=this.formatter.address(t).substring(2).toLowerCase()+".addr.reverse",le=yield this._getResolver(ae,"getAvatar");if(!le)return null;n=new Resolver(this,le,ae);try{const he=yield n.getAvatar();if(he)return he.url}catch(he){if(he.code!==Logger.errors.CALL_EXCEPTION)throw he}try{const he=_parseString(yield this.call({to:le,data:"0x691f3431"+namehash$1(ae).substring(2)}),0);n=yield this.getResolver(he)}catch(he){if(he.code!==Logger.errors.CALL_EXCEPTION)throw he;return null}}else if(n=yield this.getResolver(t),!n)return null;const ie=yield n.getAvatar();return ie==null?null:ie.url})}perform(t,n){return logger$4.throwError(t+" not implemented",Logger.errors.NOT_IMPLEMENTED,{operation:t})}_startEvent(t){this.polling=this._events.filter(n=>n.pollable()).length>0}_stopEvent(t){this.polling=this._events.filter(n=>n.pollable()).length>0}_addEventListener(t,n,ie){const fe=new Event$1(getEventTag(t),n,ie);return this._events.push(fe),this._startEvent(fe),this}on(t,n){return this._addEventListener(t,n,!1)}once(t,n){return this._addEventListener(t,n,!0)}emit(t,...n){let ie=!1,fe=[],ae=getEventTag(t);return this._events=this._events.filter(le=>le.tag!==ae?!0:(setTimeout(()=>{le.listener.apply(this,n)},0),ie=!0,le.once?(fe.push(le),!1):!0)),fe.forEach(le=>{this._stopEvent(le)}),ie}listenerCount(t){if(!t)return this._events.length;let n=getEventTag(t);return this._events.filter(ie=>ie.tag===n).length}listeners(t){if(t==null)return this._events.map(ie=>ie.listener);let n=getEventTag(t);return this._events.filter(ie=>ie.tag===n).map(ie=>ie.listener)}off(t,n){if(n==null)return this.removeAllListeners(t);const ie=[];let fe=!1,ae=getEventTag(t);return this._events=this._events.filter(le=>le.tag!==ae||le.listener!=n||fe?!0:(fe=!0,ie.push(le),!1)),ie.forEach(le=>{this._stopEvent(le)}),this}removeAllListeners(t){let n=[];if(t==null)n=this._events,this._events=[];else{const ie=getEventTag(t);this._events=this._events.filter(fe=>fe.tag!==ie?!0:(n.push(fe),!1))}return n.forEach(ie=>{this._stopEvent(ie)}),this}}var __awaiter$b=function(c,t,n,ie){function fe(ae){return ae instanceof n?ae:new n(function(le){le(ae)})}return new(n||(n=Promise))(function(ae,le){function he(xe){try{me(ie.next(xe))}catch(Ee){le(Ee)}}function ye(xe){try{me(ie.throw(xe))}catch(Ee){le(Ee)}}function me(xe){xe.done?ae(xe.value):fe(xe.value).then(he,ye)}me((ie=ie.apply(c,t||[])).next())})};const logger$3=new Logger(version$8),errorGas=["call","estimateGas"];function spelunk(c,t){if(c==null)return null;if(typeof c.message=="string"&&c.message.match("reverted")){const n=isHexString(c.data)?c.data:null;if(!t||n)return{message:c.message,data:n}}if(typeof c=="object"){for(const n in c){const ie=spelunk(c[n],t);if(ie)return ie}return null}if(typeof c=="string")try{return spelunk(JSON.parse(c),t)}catch{}return null}function checkError(c,t,n){const ie=n.transaction||n.signedTransaction;if(c==="call"){const ae=spelunk(t,!0);if(ae)return ae.data;logger$3.throwError("missing revert data in call exception; Transaction reverted without a reason string",Logger.errors.CALL_EXCEPTION,{data:"0x",transaction:ie,error:t})}if(c==="estimateGas"){let ae=spelunk(t.body,!1);ae==null&&(ae=spelunk(t,!1)),ae&&logger$3.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",Logger.errors.UNPREDICTABLE_GAS_LIMIT,{reason:ae.message,method:c,transaction:ie,error:t})}let fe=t.message;throw t.code===Logger.errors.SERVER_ERROR&&t.error&&typeof t.error.message=="string"?fe=t.error.message:typeof t.body=="string"?fe=t.body:typeof t.responseText=="string"&&(fe=t.responseText),fe=(fe||"").toLowerCase(),fe.match(/insufficient funds|base fee exceeds gas limit|InsufficientFunds/i)&&logger$3.throwError("insufficient funds for intrinsic transaction cost",Logger.errors.INSUFFICIENT_FUNDS,{error:t,method:c,transaction:ie}),fe.match(/nonce (is )?too low/i)&&logger$3.throwError("nonce has already been used",Logger.errors.NONCE_EXPIRED,{error:t,method:c,transaction:ie}),fe.match(/replacement transaction underpriced|transaction gas price.*too low/i)&&logger$3.throwError("replacement fee too low",Logger.errors.REPLACEMENT_UNDERPRICED,{error:t,method:c,transaction:ie}),fe.match(/only replay-protected/i)&&logger$3.throwError("legacy pre-eip-155 transactions not supported",Logger.errors.UNSUPPORTED_OPERATION,{error:t,method:c,transaction:ie}),errorGas.indexOf(c)>=0&&fe.match(/gas required exceeds allowance|always failing transaction|execution reverted|revert/)&&logger$3.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",Logger.errors.UNPREDICTABLE_GAS_LIMIT,{error:t,method:c,transaction:ie}),t}function timer(c){return new Promise(function(t){setTimeout(t,c)})}function getResult(c){if(c.error){const t=new Error(c.error.message);throw t.code=c.error.code,t.data=c.error.data,t}return c.result}function getLowerCase(c){return c&&c.toLowerCase()}const _constructorGuard={};class JsonRpcSigner extends Signer{constructor(t,n,ie){if(super(),t!==_constructorGuard)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");defineReadOnly(this,"provider",n),ie==null&&(ie=0),typeof ie=="string"?(defineReadOnly(this,"_address",this.provider.formatter.address(ie)),defineReadOnly(this,"_index",null)):typeof ie=="number"?(defineReadOnly(this,"_index",ie),defineReadOnly(this,"_address",null)):logger$3.throwArgumentError("invalid address or index","addressOrIndex",ie)}connect(t){return logger$3.throwError("cannot alter JSON-RPC Signer connection",Logger.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new UncheckedJsonRpcSigner(_constructorGuard,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then(t=>(t.length<=this._index&&logger$3.throwError("unknown account #"+this._index,Logger.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(t[this._index])))}sendUncheckedTransaction(t){t=shallowCopy(t);const n=this.getAddress().then(ie=>(ie&&(ie=ie.toLowerCase()),ie));if(t.gasLimit==null){const ie=shallowCopy(t);ie.from=n,t.gasLimit=this.provider.estimateGas(ie)}return t.to!=null&&(t.to=Promise.resolve(t.to).then(ie=>__awaiter$b(this,void 0,void 0,function*(){if(ie==null)return null;const fe=yield this.provider.resolveName(ie);return fe==null&&logger$3.throwArgumentError("provided ENS name resolves to null","tx.to",ie),fe}))),resolveProperties({tx:resolveProperties(t),sender:n}).then(({tx:ie,sender:fe})=>{ie.from!=null?ie.from.toLowerCase()!==fe&&logger$3.throwArgumentError("from address mismatch","transaction",t):ie.from=fe;const ae=this.provider.constructor.hexlifyTransaction(ie,{from:!0});return this.provider.send("eth_sendTransaction",[ae]).then(le=>le,le=>(typeof le.message=="string"&&le.message.match(/user denied/i)&&logger$3.throwError("user rejected transaction",Logger.errors.ACTION_REJECTED,{action:"sendTransaction",transaction:ie}),checkError("sendTransaction",le,ae)))})}signTransaction(t){return logger$3.throwError("signing transactions is unsupported",Logger.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(t){return __awaiter$b(this,void 0,void 0,function*(){const n=yield this.provider._getInternalBlockNumber(100+2*this.provider.pollingInterval),ie=yield this.sendUncheckedTransaction(t);try{return yield poll(()=>__awaiter$b(this,void 0,void 0,function*(){const fe=yield this.provider.getTransaction(ie);if(fe!==null)return this.provider._wrapTransaction(fe,ie,n)}),{oncePoll:this.provider})}catch(fe){throw fe.transactionHash=ie,fe}})}signMessage(t){return __awaiter$b(this,void 0,void 0,function*(){const n=typeof t=="string"?toUtf8Bytes(t):t,ie=yield this.getAddress();try{return yield this.provider.send("personal_sign",[hexlify(n),ie.toLowerCase()])}catch(fe){throw typeof fe.message=="string"&&fe.message.match(/user denied/i)&&logger$3.throwError("user rejected signing",Logger.errors.ACTION_REJECTED,{action:"signMessage",from:ie,messageData:t}),fe}})}_legacySignMessage(t){return __awaiter$b(this,void 0,void 0,function*(){const n=typeof t=="string"?toUtf8Bytes(t):t,ie=yield this.getAddress();try{return yield this.provider.send("eth_sign",[ie.toLowerCase(),hexlify(n)])}catch(fe){throw typeof fe.message=="string"&&fe.message.match(/user denied/i)&&logger$3.throwError("user rejected signing",Logger.errors.ACTION_REJECTED,{action:"_legacySignMessage",from:ie,messageData:t}),fe}})}_signTypedData(t,n,ie){return __awaiter$b(this,void 0,void 0,function*(){const fe=yield TypedDataEncoder.resolveNames(t,n,ie,le=>this.provider.resolveName(le)),ae=yield this.getAddress();try{return yield this.provider.send("eth_signTypedData_v4",[ae.toLowerCase(),JSON.stringify(TypedDataEncoder.getPayload(fe.domain,n,fe.value))])}catch(le){throw typeof le.message=="string"&&le.message.match(/user denied/i)&&logger$3.throwError("user rejected signing",Logger.errors.ACTION_REJECTED,{action:"_signTypedData",from:ae,messageData:{domain:fe.domain,types:n,value:fe.value}}),le}})}unlock(t){return __awaiter$b(this,void 0,void 0,function*(){const n=this.provider,ie=yield this.getAddress();return n.send("personal_unlockAccount",[ie.toLowerCase(),t,null])})}}class UncheckedJsonRpcSigner extends JsonRpcSigner{sendTransaction(t){return this.sendUncheckedTransaction(t).then(n=>({hash:n,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:ie=>this.provider.waitForTransaction(n,ie)}))}}const allowedTransactionKeys={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0,type:!0,accessList:!0,maxFeePerGas:!0,maxPriorityFeePerGas:!0};class JsonRpcProvider extends BaseProvider{constructor(t,n){let ie=n;ie==null&&(ie=new Promise((fe,ae)=>{setTimeout(()=>{this.detectNetwork().then(le=>{fe(le)},le=>{ae(le)})},0)})),super(ie),t||(t=getStatic(this.constructor,"defaultUrl")()),typeof t=="string"?defineReadOnly(this,"connection",Object.freeze({url:t})):defineReadOnly(this,"connection",Object.freeze(shallowCopy(t))),this._nextId=42}get _cache(){return this._eventLoopCache==null&&(this._eventLoopCache={}),this._eventLoopCache}static defaultUrl(){return"http://localhost:8545"}detectNetwork(){return this._cache.detectNetwork||(this._cache.detectNetwork=this._uncachedDetectNetwork(),setTimeout(()=>{this._cache.detectNetwork=null},0)),this._cache.detectNetwork}_uncachedDetectNetwork(){return __awaiter$b(this,void 0,void 0,function*(){yield timer(0);let t=null;try{t=yield this.send("eth_chainId",[])}catch{try{t=yield this.send("net_version",[])}catch{}}if(t!=null){const n=getStatic(this.constructor,"getNetwork");try{return n(BigNumber.from(t).toNumber())}catch(ie){return logger$3.throwError("could not detect network",Logger.errors.NETWORK_ERROR,{chainId:t,event:"invalidNetwork",serverError:ie})}}return logger$3.throwError("could not detect network",Logger.errors.NETWORK_ERROR,{event:"noNetwork"})})}getSigner(t){return new JsonRpcSigner(_constructorGuard,this,t)}getUncheckedSigner(t){return this.getSigner(t).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then(t=>t.map(n=>this.formatter.address(n)))}send(t,n){const ie={method:t,params:n,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:deepCopy(ie),provider:this});const fe=["eth_chainId","eth_blockNumber"].indexOf(t)>=0;if(fe&&this._cache[t])return this._cache[t];const ae=fetchJson(this.connection,JSON.stringify(ie),getResult).then(le=>(this.emit("debug",{action:"response",request:ie,response:le,provider:this}),le),le=>{throw this.emit("debug",{action:"response",error:le,request:ie,provider:this}),le});return fe&&(this._cache[t]=ae,setTimeout(()=>{this._cache[t]=null},0)),ae}prepareRequest(t,n){switch(t){case"getBlockNumber":return["eth_blockNumber",[]];case"getGasPrice":return["eth_gasPrice",[]];case"getBalance":return["eth_getBalance",[getLowerCase(n.address),n.blockTag]];case"getTransactionCount":return["eth_getTransactionCount",[getLowerCase(n.address),n.blockTag]];case"getCode":return["eth_getCode",[getLowerCase(n.address),n.blockTag]];case"getStorageAt":return["eth_getStorageAt",[getLowerCase(n.address),hexZeroPad(n.position,32),n.blockTag]];case"sendTransaction":return["eth_sendRawTransaction",[n.signedTransaction]];case"getBlock":return n.blockTag?["eth_getBlockByNumber",[n.blockTag,!!n.includeTransactions]]:n.blockHash?["eth_getBlockByHash",[n.blockHash,!!n.includeTransactions]]:null;case"getTransaction":return["eth_getTransactionByHash",[n.transactionHash]];case"getTransactionReceipt":return["eth_getTransactionReceipt",[n.transactionHash]];case"call":return["eth_call",[getStatic(this.constructor,"hexlifyTransaction")(n.transaction,{from:!0}),n.blockTag]];case"estimateGas":return["eth_estimateGas",[getStatic(this.constructor,"hexlifyTransaction")(n.transaction,{from:!0})]];case"getLogs":return n.filter&&n.filter.address!=null&&(n.filter.address=getLowerCase(n.filter.address)),["eth_getLogs",[n.filter]]}return null}perform(t,n){return __awaiter$b(this,void 0,void 0,function*(){if(t==="call"||t==="estimateGas"){const fe=n.transaction;if(fe&&fe.type!=null&&BigNumber.from(fe.type).isZero()&&fe.maxFeePerGas==null&&fe.maxPriorityFeePerGas==null){const ae=yield this.getFeeData();ae.maxFeePerGas==null&&ae.maxPriorityFeePerGas==null&&(n=shallowCopy(n),n.transaction=shallowCopy(fe),delete n.transaction.type)}}const ie=this.prepareRequest(t,n);ie==null&&logger$3.throwError(t+" not implemented",Logger.errors.NOT_IMPLEMENTED,{operation:t});try{return yield this.send(ie[0],ie[1])}catch(fe){return checkError(t,fe,n)}})}_startEvent(t){t.tag==="pending"&&this._startPending(),super._startEvent(t)}_startPending(){if(this._pendingFilter!=null)return;const t=this,n=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=n,n.then(function(ie){function fe(){t.send("eth_getFilterChanges",[ie]).then(function(ae){if(t._pendingFilter!=n)return null;let le=Promise.resolve();return ae.forEach(function(he){t._emitted["t:"+he.toLowerCase()]="pending",le=le.then(function(){return t.getTransaction(he).then(function(ye){return t.emit("pending",ye),null})})}),le.then(function(){return timer(1e3)})}).then(function(){if(t._pendingFilter!=n){t.send("eth_uninstallFilter",[ie]);return}return setTimeout(function(){fe()},0),null}).catch(ae=>{})}return fe(),ie}).catch(ie=>{})}_stopEvent(t){t.tag==="pending"&&this.listenerCount("pending")===0&&(this._pendingFilter=null),super._stopEvent(t)}static hexlifyTransaction(t,n){const ie=shallowCopy(allowedTransactionKeys);if(n)for(const ae in n)n[ae]&&(ie[ae]=!0);checkProperties(t,ie);const fe={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(function(ae){if(t[ae]==null)return;const le=hexValue(BigNumber.from(t[ae]));ae==="gasLimit"&&(ae="gas"),fe[ae]=le}),["from","to","data"].forEach(function(ae){t[ae]!=null&&(fe[ae]=hexlify(t[ae]))}),t.accessList&&(fe.accessList=accessListify(t.accessList)),fe}}const logger$2=new Logger(version$8);let _nextId=1;function buildWeb3LegacyFetcher(c,t){const n="Web3LegacyFetcher";return function(ie,fe){const ae={method:ie,params:fe,id:_nextId++,jsonrpc:"2.0"};return new Promise((le,he)=>{this.emit("debug",{action:"request",fetcher:n,request:deepCopy(ae),provider:this}),t(ae,(ye,me)=>{if(ye)return this.emit("debug",{action:"response",fetcher:n,error:ye,request:ae,provider:this}),he(ye);if(this.emit("debug",{action:"response",fetcher:n,request:ae,response:me,provider:this}),me.error){const xe=new Error(me.error.message);return xe.code=me.error.code,xe.data=me.error.data,he(xe)}le(me.result)})})}}function buildEip1193Fetcher(c){return function(t,n){n==null&&(n=[]);const ie={method:t,params:n};return this.emit("debug",{action:"request",fetcher:"Eip1193Fetcher",request:deepCopy(ie),provider:this}),c.request(ie).then(fe=>(this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:ie,response:fe,provider:this}),fe),fe=>{throw this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:ie,error:fe,provider:this}),fe})}}class Web3Provider extends JsonRpcProvider{constructor(t,n){t==null&&logger$2.throwArgumentError("missing provider","provider",t);let ie=null,fe=null,ae=null;typeof t=="function"?(ie="unknown:",fe=t):(ie=t.host||t.path||"",!ie&&t.isMetaMask&&(ie="metamask"),ae=t,t.request?(ie===""&&(ie="eip-1193:"),fe=buildEip1193Fetcher(t)):t.sendAsync?fe=buildWeb3LegacyFetcher(t,t.sendAsync.bind(t)):t.send?fe=buildWeb3LegacyFetcher(t,t.send.bind(t)):logger$2.throwArgumentError("unsupported provider","provider",t),ie||(ie="unknown:")),super(ie,n),defineReadOnly(this,"jsonRpcFetchFunc",fe),defineReadOnly(this,"provider",ae)}send(t,n){return this.jsonRpcFetchFunc(t,n)}}const version$7="solidity/5.8.0",regexBytes=new RegExp("^bytes([0-9]+)$"),regexNumber=new RegExp("^(u?int)([0-9]*)$"),regexArray=new RegExp("^(.*)\\[([0-9]*)\\]$"),Zeros="0000000000000000000000000000000000000000000000000000000000000000",logger$1=new Logger(version$7);function _pack(c,t,n){switch(c){case"address":return n?zeroPad(t,32):arrayify(t);case"string":return toUtf8Bytes(t);case"bytes":return arrayify(t);case"bool":return t=t?"0x01":"0x00",n?zeroPad(t,32):arrayify(t)}let ie=c.match(regexNumber);if(ie){let fe=parseInt(ie[2]||"256");return(ie[2]&&String(fe)!==ie[2]||fe%8!==0||fe===0||fe>256)&&logger$1.throwArgumentError("invalid number type","type",c),n&&(fe=256),t=BigNumber.from(t).toTwos(fe),zeroPad(t,fe/8)}if(ie=c.match(regexBytes),ie){const fe=parseInt(ie[1]);return(String(fe)!==ie[1]||fe===0||fe>32)&&logger$1.throwArgumentError("invalid bytes type","type",c),arrayify(t).byteLength!==fe&&logger$1.throwArgumentError(`invalid value for ${c}`,"value",t),n?arrayify((t+Zeros).substring(0,66)):t}if(ie=c.match(regexArray),ie&&Array.isArray(t)){const fe=ie[1];parseInt(ie[2]||String(t.length))!=t.length&&logger$1.throwArgumentError(`invalid array length for ${c}`,"value",t);const le=[];return t.forEach(function(he){le.push(_pack(fe,he,!0))}),concat$1(le)}return logger$1.throwArgumentError("invalid type","type",c)}function pack(c,t){c.length!=t.length&&logger$1.throwArgumentError("wrong number of values; expected ${ types.length }","values",t);const n=[];return c.forEach(function(ie,fe){n.push(_pack(ie,t[fe]))}),hexlify(concat$1(n))}function keccak256(c,t){return keccak256$1(pack(c,t))}function sha256$6(c,t){return sha256$7(pack(c,t))}const lib_esm$1=Object.freeze(Object.defineProperty({__proto__:null,keccak256,pack,sha256:sha256$6},Symbol.toStringTag,{value:"Module"})),version$6="units/5.8.0",logger=new Logger(version$6),names$2=["wei","kwei","mwei","gwei","szabo","finney","ether"];function commify(c){const t=String(c).split(".");(t.length>2||!t[0].match(/^-?[0-9]*$/)||t[1]&&!t[1].match(/^[0-9]*$/)||c==="."||c==="-.")&&logger.throwArgumentError("invalid value","value",c);let n=t[0],ie="";for(n.substring(0,1)==="-"&&(ie="-",n=n.substring(1));n.substring(0,1)==="0";)n=n.substring(1);n===""&&(n="0");let fe="";for(t.length===2&&(fe="."+(t[1]||"0"));fe.length>2&&fe[fe.length-1]==="0";)fe=fe.substring(0,fe.length-1);const ae=[];for(;n.length;)if(n.length<=3){ae.unshift(n);break}else{const le=n.length-3;ae.unshift(n.substring(le)),n=n.substring(0,le)}return ie+ae.join(",")+fe}function formatUnits(c,t){if(typeof t=="string"){const n=names$2.indexOf(t);n!==-1&&(t=3*n)}return formatFixed(c,t??18)}function parseUnits(c,t){if(typeof c!="string"&&logger.throwArgumentError("value must be a string","value",c),typeof t=="string"){const n=names$2.indexOf(t);n!==-1&&(t=3*n)}return parseFixed(c,t??18)}function formatEther(c){return formatUnits(c,18)}function parseEther(c){return parseUnits(c,18)}const lib_esm=Object.freeze(Object.defineProperty({__proto__:null,commify,formatEther,formatUnits,parseEther,parseUnits},Symbol.toStringTag,{value:"Module"}));var NFTType=(c=>(c[c.ERC1155=0]="ERC1155",c[c.ERC721=1]="ERC721",c))(NFTType||{}),ProductType=(c=>(c[c.DIGITAL=0]="DIGITAL",c[c.POD=1]="POD",c[c.PHYSICAL=2]="PHYSICAL",c))(ProductType||{});class HTTPError extends Error{constructor(n,ie,fe){const ae=n.status||n.status===0?n.status:"",le=n.statusText??"",he=`${ae} ${le}`.trim(),ye=he?`status code ${he}`:"an unknown error";super(`Request failed with ${ye}: ${ie.method} ${ie.url}`);Xn(this,"response");Xn(this,"request");Xn(this,"options");this.name="HTTPError",this.response=n,this.request=ie,this.options=fe}}class TimeoutError extends Error{constructor(n){super(`Request timed out: ${n.method} ${n.url}`);Xn(this,"request");this.name="TimeoutError",this.request=n}}const supportsRequestStreams=(()=>{let c=!1,t=!1;const n=typeof globalThis.ReadableStream=="function",ie=typeof globalThis.Request=="function";if(n&&ie)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return c=!0,"half"}}).headers.has("Content-Type")}catch(fe){if(fe instanceof Error&&fe.message==="unsupported BodyInit type")return!1;throw fe}return c&&!t})(),supportsAbortController=typeof globalThis.AbortController=="function",supportsAbortSignal=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",supportsResponseStreams=typeof globalThis.ReadableStream=="function",supportsFormData=typeof globalThis.FormData=="function",requestMethods=["get","post","put","patch","head","delete"],responseTypes={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},maxSafeTimeout=2147483647,usualFormBoundarySize=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,stop=Symbol("stop"),kyOptionKeys={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},requestOptionsRegistry={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0},getBodySize=c=>{if(!c)return 0;if(c instanceof FormData){let t=0;for(const[n,ie]of c)t+=usualFormBoundarySize,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${n}"`).length,t+=typeof ie=="string"?new TextEncoder().encode(ie).length:ie.size;return t}if(c instanceof Blob)return c.size;if(c instanceof ArrayBuffer)return c.byteLength;if(typeof c=="string")return new TextEncoder().encode(c).length;if(c instanceof URLSearchParams)return new TextEncoder().encode(c.toString()).length;if("byteLength"in c)return c.byteLength;if(typeof c=="object"&&c!==null)try{const t=JSON.stringify(c);return new TextEncoder().encode(t).length}catch{return 0}return 0},withProgress=(c,t,n)=>{let ie,fe=0;return c.pipeThrough(new TransformStream({transform(ae,le){if(le.enqueue(ae),ie){fe+=ie.byteLength;let he=t===0?0:fe/t;he>=1&&(he=1-Number.EPSILON),n==null||n({percent:he,totalBytes:Math.max(t,fe),transferredBytes:fe},ie)}ie=ae},flush(){ie&&(fe+=ie.byteLength,n==null||n({percent:1,totalBytes:Math.max(t,fe),transferredBytes:fe},ie))}}))},streamResponse=(c,t)=>{if(!c.body)return c;if(c.status===204)return new Response(null,{status:c.status,statusText:c.statusText,headers:c.headers});const n=Number(c.headers.get("content-length"))||0;return new Response(withProgress(c.body,n,t),{status:c.status,statusText:c.statusText,headers:c.headers})},streamRequest=(c,t,n)=>{if(!c.body)return c;const ie=getBodySize(n??c.body);return new Request(c,{duplex:"half",body:withProgress(c.body,ie,t)})},isObject$2=c=>c!==null&&typeof c=="object",validateAndMerge=(...c)=>{for(const t of c)if((!isObject$2(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return deepMerge({},...c)},mergeHeaders=(c={},t={})=>{const n=new globalThis.Headers(c),ie=t instanceof globalThis.Headers,fe=new globalThis.Headers(t);for(const[ae,le]of fe.entries())ie&&le==="undefined"||le===void 0?n.delete(ae):n.set(ae,le);return n};function newHookValue(c,t,n){return Object.hasOwn(t,n)&&t[n]===void 0?[]:deepMerge(c[n]??[],t[n]??[])}const mergeHooks=(c={},t={})=>({beforeRequest:newHookValue(c,t,"beforeRequest"),beforeRetry:newHookValue(c,t,"beforeRetry"),afterResponse:newHookValue(c,t,"afterResponse"),beforeError:newHookValue(c,t,"beforeError")}),deepMerge=(...c)=>{let t={},n={},ie={};for(const fe of c)if(Array.isArray(fe))Array.isArray(t)||(t=[]),t=[...t,...fe];else if(isObject$2(fe)){for(let[ae,le]of Object.entries(fe))isObject$2(le)&&ae in t&&(le=deepMerge(t[ae],le)),t={...t,[ae]:le};isObject$2(fe.hooks)&&(ie=mergeHooks(ie,fe.hooks),t.hooks=ie),isObject$2(fe.headers)&&(n=mergeHeaders(n,fe.headers),t.headers=n)}return t},normalizeRequestMethod=c=>requestMethods.includes(c)?c.toUpperCase():c,retryMethods=["get","put","head","delete","options","trace"],retryStatusCodes=[408,413,429,500,502,503,504],retryAfterStatusCodes=[413,429,503],defaultRetryOptions={limit:2,methods:retryMethods,statusCodes:retryStatusCodes,afterStatusCodes:retryAfterStatusCodes,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:c=>.3*2**(c-1)*1e3},normalizeRetryOptions=(c={})=>{if(typeof c=="number")return{...defaultRetryOptions,limit:c};if(c.methods&&!Array.isArray(c.methods))throw new Error("retry.methods must be an array");if(c.statusCodes&&!Array.isArray(c.statusCodes))throw new Error("retry.statusCodes must be an array");return{...defaultRetryOptions,...c}};async function timeout(c,t,n,ie){return new Promise((fe,ae)=>{const le=setTimeout(()=>{n&&n.abort(),ae(new TimeoutError(c))},ie.timeout);ie.fetch(c,t).then(fe).catch(ae).then(()=>{clearTimeout(le)})})}async function delay(c,{signal:t}){return new Promise((n,ie)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",fe,{once:!0}));function fe(){clearTimeout(ae),ie(t.reason)}const ae=setTimeout(()=>{t==null||t.removeEventListener("abort",fe),n()},c)})}const findUnknownOptions=(c,t)=>{const n={};for(const ie in t)!(ie in requestOptionsRegistry)&&!(ie in kyOptionKeys)&&!(ie in c)&&(n[ie]=t[ie]);return n},hasSearchParameters=c=>c===void 0?!1:Array.isArray(c)?c.length>0:c instanceof URLSearchParams?c.size>0:typeof c=="object"?Object.keys(c).length>0:typeof c=="string"?c.trim().length>0:!!c;var ei,oi;const Yn=class Yn{constructor(t,n={}){Xn(this,"request");Xn(this,"abortController");Xn(this,"_retryCount",0);Xn(this,"_input");Xn(this,"_options");Xn(this,"_originalRequest");var ie,fe,ae;if(this._input=t,this._options={...n,headers:mergeHeaders(this._input.headers,n.headers),hooks:mergeHooks({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},n.hooks),method:normalizeRequestMethod(n.method??this._input.method??"GET"),prefixUrl:String(n.prefixUrl||""),retry:normalizeRetryOptions(n.retry),throwHttpErrors:n.throwHttpErrors!==!1,timeout:n.timeout??1e4,fetch:n.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(supportsAbortController&&supportsAbortSignal){const le=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=le?AbortSignal.any([le,this.abortController.signal]):this.abortController.signal}if(supportsRequestStreams&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=((fe=(ie=this._options).stringifyJson)==null?void 0:fe.call(ie,this._options.json))??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),hasSearchParameters(this._options.searchParams)){const he="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(ai(ae=Yn,ei,oi).call(ae,this._options.searchParams)).toString()),ye=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,he);(supportsFormData&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(ye,{...this.request}),this._options)}if(this._options.onUploadProgress){if(typeof this._options.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!supportsRequestStreams)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=streamRequest(this.request,this._options.onUploadProgress,this._options.body))}}static create(t,n){var he,ye;const ie=new Yn(t,n),fe=async()=>{if(typeof ie._options.timeout=="number"&&ie._options.timeout>maxSafeTimeout)throw new RangeError(`The \`timeout\` option cannot be greater than ${maxSafeTimeout}`);await Promise.resolve();let me=await ie._fetch();for(const xe of ie._options.hooks.afterResponse){const Ee=await xe(ie.request,ie._options,ie._decorateResponse(me.clone()));Ee instanceof globalThis.Response&&(me=Ee)}if(ie._decorateResponse(me),!me.ok&&ie._options.throwHttpErrors){let xe=new HTTPError(me,ie.request,ie._options);for(const Ee of ie._options.hooks.beforeError)xe=await Ee(xe);throw xe}if(ie._options.onDownloadProgress){if(typeof ie._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!supportsResponseStreams)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return streamResponse(me.clone(),ie._options.onDownloadProgress)}return me},le=(ie._options.retry.methods.includes(ie.request.method.toLowerCase())?ie._retry(fe):fe()).finally(async()=>{var Ee,Se;const me=ie._originalRequest,xe=[];me&&!me.bodyUsed&&xe.push((Ee=me.body)==null?void 0:Ee.cancel()),ie.request.bodyUsed||xe.push((Se=ie.request.body)==null?void 0:Se.cancel()),await Promise.all(xe)});for(const[me,xe]of Object.entries(responseTypes))me==="bytes"&&typeof((ye=(he=globalThis.Response)==null?void 0:he.prototype)==null?void 0:ye.bytes)!="function"||(le[me]=async()=>{ie.request.headers.set("accept",ie.request.headers.get("accept")||xe);const Ee=await le;if(me==="json"){if(Ee.status===204)return"";const Se=await Ee.text();return Se===""?"":n.parseJson?n.parseJson(Se):JSON.parse(Se)}return Ee[me]()});return le}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof TimeoutError)throw t;if(t instanceof HTTPError){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;const ie=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(ie&&this._options.retry.afterStatusCodes.includes(t.response.status)){let fe=Number(ie)*1e3;Number.isNaN(fe)?fe=Date.parse(ie)-Date.now():fe>=Date.parse("2024-01-01")&&(fe-=Date.now());const ae=this._options.retry.maxRetryAfter??fe;return fe<ae?fe:ae}if(t.response.status===413)throw t}const n=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,n)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(n){const ie=Math.min(this._calculateRetryDelay(n),maxSafeTimeout);if(this._retryCount<1)throw n;await delay(ie,{signal:this._options.signal});for(const fe of this._options.hooks.beforeRetry)if(await fe({request:this.request,options:this._options,error:n,retryCount:this._retryCount})===stop)return;return this._retry(t)}}async _fetch(){for(const n of this._options.hooks.beforeRequest){const ie=await n(this.request,this._options);if(ie instanceof Request){this.request=ie;break}if(ie instanceof Response)return ie}const t=findUnknownOptions(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):timeout(this._originalRequest,t,this.abortController,this._options)}};ei=new WeakSet,oi=function(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,n])=>n!==void 0)):t},ii(Yn,ei);let Ky=Yn;/*! MIT License © Sindre Sorhus */const createInstance=c=>{const t=(n,ie)=>Ky.create(n,validateAndMerge(c,ie));for(const n of requestMethods)t[n]=(ie,fe)=>Ky.create(ie,validateAndMerge(c,fe,{method:n}));return t.create=n=>createInstance(validateAndMerge(n)),t.extend=n=>(typeof n=="function"&&(n=n(c??{})),createInstance(validateAndMerge(c,n))),t.stop=stop,t},ky=createInstance();async function uploadMetadata(c,t,n){return(await(await n.post("uploader/cdn-upload-json",{json:{data:c,key:`record-metadata/${t}.json`}})).json()).url}async function startRecord(c,t,n,ie,fe,ae){return(await(await ae.post("web3/record/transactions",{json:{uris:fe,network:ie,data:{productId:c,skuIds:t},productId:c,skuIds:t,metadata:{},shopId:n,txType:"RECORD"}})).json()).data.id}async function getShopInfo(c,t,n){const ie=(await(await n.get(`shops/v2/public/${t}`)).json()).data.deployedContracts.filter(fe=>fe.type===c);return ie.length===0?{nftContractAddress:"",shopContractAddress:""}:{nftContractAddress:ie[0].deployedNFTAddress,shopContractAddress:ie[0].deployedShopAddress}}async function deleteRecordTransaction(c,t){await t.delete(`web3/record/transactions/${c}`)}async function web3Callback(c,t,n,ie){const fe={"X-API-KEY":"ho8homr9e8p4fwii7tjiz41xs4hlbl2h4i"};return(await(await ky.create({headers:fe,prefixUrl:n==="TESTNET"?"https://web3dev.droplinked.com/":"https://web3.droplinked.com/"}).post("transactions",{json:{transaction_id:c,callback_url:ie,chain:t,network:n},headers:fe})).json()).data}async function getProductData(c,t){return(await(await t.get(`product-v2/public/${c}`)).json()).data}async function transformProductData(c,t){const n=await getProductData(c,t);if(!n||n.skus.length===0)throw new Error("Product not found or no SKUs available");return{productData:{acceptsManageWallet:!0,commission:n.affiliate.commissionPercent||0,description:n.description,productTitle:n.title,royalty:n.skus[0].royalty||0,type:ProductType[n.type.toUpperCase()]||ProductType.DIGITAL},skuData:n.skus.map(ie=>{var fe;return{amount:ie.inventory.quantity,imageUrl:((fe=n.images[n.defaultImageIndex])==null?void 0:fe.original)||"",skuID:ie.id,skuProperties:ie}})}}async function updateUris(c,t,n){return(await(await n.put(`web3/record/transactions/${c}/uris`,{json:{uris:t}})).json()).data}async function updateHash(c,t,n,ie){return(await(await ie.put(`web3/${c}/transactions/${t}/hash`,{json:{transactionHash:n}})).json()).data}async function getProductDataForRecord(c,t){if(!c)throw new InvalidParametersException(Chains.BASE,"Product ID is required");let n,ie=[];try{const{productData:fe,skuData:ae}=await transformProductData(c,t);n=fe,ie=ae}catch(fe){throw new Error(`Failed to fetch product data: ${fe}`)}if(!n||ie.length===0)throw new Error("Product not found or no SKUs available");return{productData:n,skuData:ie}}async function getNonce(c,t){return await(await t.get(`web3/auth/nonce?wallet=${c}`)).json()}async function getAddress(c,t,n){const ie=fe=>fe.charAt(0).toUpperCase()+fe.slice(1).toLowerCase();try{const fe=t===Network.TESTNET?"apiv3dev":"apiv3",ae=ie(c),le=ie(Network[t]),he=`https://${fe}.droplinked.com/storage/${ae}${le}ContractAddress${n}`;return(await await ky.get(he).json()).value}catch(fe){throw console.error(`Failed to fetch ${n.toLowerCase()} address:`,fe),new Error(`Unable to get ${n.toLowerCase()} address`)}}async function getDeployerAddress(c,t){return getAddress(c,t,"Deployer")}async function getProxyAddress(c,t){return getAddress(c,t,"Proxy")}async function startPayment(c,t,n,ie,fe){return(await(await fe.post("web3/payment/transactions",{json:{network:n,token:t,shopId:ie,orderId:c}})).json()).data.id}async function getCartData(c,t,n,ie){const fe=await(await ie.get(`web3/payment/distribution/${c}/${t}/${n}`)).json();return{paymentData:fe.data,orderID:fe.orderID}}async function getPurchaseSignature(c,t,n){const ie=await(await n.get(`nfts/by-order?orderId=${c}&skuId=${t}`)).json();return console.log("Purchase signature response:",ie),{signature:ie.purchaseSignature,shopContractAddress:ie.shopContractAddress,networkName:ie.networkName,nftId:ie._id,claimed:ie.claimed}}async function sendClaim(c,t,n){return await(await n.post("nfts/transfer",{json:{transactionId:t,nftId:c}})).json()}async function getShopByteCode(){try{return String((await await ky.get("https://apiv3dev.droplinked.com/storage/shopByteCodeType0").json()).value)}catch(c){throw console.error(`Failed to get shop bytecode: ${c}`),new Error("Unable to get shop bytecode")}}async function getShopDeployInfo(c,t){const n=(await(await t.get(`shops/v2/public/${c}`)).json()).data;return{name:n.name,description:n.description,logo:n.logo,url:n.url,deployedContracts:n.deployedContracts}}const shopABI=[{inputs:[{internalType:"string",name:"_shopName",type:"string"},{internalType:"string",name:"_shopAddress",type:"string"},{internalType:"address",name:"_shopOwner",type:"address"},{internalType:"string",name:"_shopLogo",type:"string"},{internalType:"string",name:"_shopDescription",type:"string"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"AccessDenied",type:"error"},{inputs:[],name:"AffiliatePOD",type:"error"},{inputs:[],name:"AlreadyClaimed",type:"error"},{inputs:[{internalType:"address",name:"requester",type:"address"},{internalType:"uint256",name:"productId",type:"uint256"}],name:"AlreadyRequested",type:"error"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"producer",type:"address"}],name:"NotEnoughTokens",type:"error"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"OwnableInvalidOwner",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"OwnableUnauthorizedAccount",type:"error"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"ProductDoesntExist",type:"error"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"ProductExists",type:"error"},{inputs:[],name:"ReentrancyGuardReentrantCall",type:"error"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"RequestAlreadyConfirmed",type:"error"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"RequestDoesntExist",type:"error"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"RequestNotConfirmed",type:"error"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"}],name:"ShopDoesNotOwnToken",type:"error"},{inputs:[],name:"oldPrice",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"requestId",type:"uint256"},{indexed:!0,internalType:"address",name:"approver",type:"address"}],name:"AffiliateRequestApproved",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"requestId",type:"uint256"},{indexed:!0,internalType:"address",name:"disapprover",type:"address"}],name:"AffiliateRequestDisapproved",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"requestId",type:"uint256"},{indexed:!0,internalType:"uint256",name:"productId",type:"uint256"},{indexed:!1,internalType:"address",name:"requester",type:"address"}],name:"AffiliateRequested",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"count",type:"uint256"}],name:"BatchProductRegistered",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"productId",type:"uint256"},{indexed:!0,internalType:"address",name:"claimer",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"ProductClaimed",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"productId",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!1,internalType:"string",name:"uri",type:"string"}],name:"ProductRegistered",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"productId",type:"uint256"},{indexed:!0,internalType:"address",name:"owner",type:"address"}],name:"ProductUnregistered",type:"event"},{inputs:[],name:"affiliateRequestCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"affiliateRequests",outputs:[{internalType:"address",name:"publisher",type:"address"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"bool",name:"isConfirmed",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"approveRequest",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"manager",type:"address"},{internalType:"bytes",name:"signature",type:"bytes"},{components:[{components:[{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"uint256",name:"nullifier",type:"uint256"}],internalType:"struct PurchasedItem[]",name:"cart",type:"tuple[]"},{internalType:"address",name:"shop",type:"address"}],internalType:"struct PurchaseSignature",name:"purchaseSignature",type:"tuple"}],name:"claimPurchase",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"disapproveRequest",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"droplinkedManagerWallet",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"getAffiliate",outputs:[{components:[{internalType:"address",name:"publisher",type:"address"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"bool",name:"isConfirmed",type:"bool"}],internalType:"struct AffiliateRequest",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAffiliateRequestCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"messageHash",type:"bytes32"}],name:"getEthSignedMessageHash",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"pure",type:"function"},{inputs:[{components:[{components:[{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"uint256",name:"nullifier",type:"uint256"}],internalType:"struct PurchasedItem[]",name:"cart",type:"tuple[]"},{internalType:"address",name:"shop",type:"address"}],internalType:"struct PurchaseSignature",name:"data",type:"tuple"}],name:"getMessageHash",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"getProduct",outputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],internalType:"struct Product",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[],name:"getProductCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],internalType:"struct Product",name:"product",type:"tuple"}],name:"getProductId",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"nftAddress",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getProductIdV2",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint256",name:"affiliateId",type:"uint256"}],name:"getProductViaAffiliateId",outputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],internalType:"struct Product",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopAddress",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopDescription",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopLogo",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopName",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopOwner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"address",name:"requester",type:"address"}],name:"isRequestSubmited",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"managers",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"address",name:"nftAddress",type:"address"},{internalType:"string",name:"uri",type:"string"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bool",name:"accepted",type:"bool"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"},{internalType:"uint256",name:"royalty",type:"uint256"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"}],internalType:"struct RecordData",name:"mintData",type:"tuple"}],name:"mintAndRegister",outputs:[{internalType:"uint256",name:"productId",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"nftAddress",type:"address"},{internalType:"string",name:"uri",type:"string"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bool",name:"accepted",type:"bool"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"},{internalType:"uint256",name:"royalty",type:"uint256"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"}],internalType:"struct RecordData[]",name:"recordData",type:"tuple[]"}],name:"mintAndRegisterBatch",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"nullifiers",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC1155BatchReceived",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC1155Received",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC721Received",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"productCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"products",outputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"ethSignedMessageHash",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"recoverSigner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"pure",type:"function"},{inputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],internalType:"struct Product",name:"p",type:"tuple"}],name:"registerProduct",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"requestAffiliate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"manager",type:"address"}],name:"revokeManager",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"manager",type:"address"}],name:"setManager",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"shopInfo",outputs:[{internalType:"string",name:"shopName",type:"string"},{internalType:"string",name:"shopAddress",type:"string"},{internalType:"string",name:"shopLogo",type:"string"},{internalType:"string",name:"shopDescription",type:"string"},{internalType:"address",name:"shopOwner",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"sig",type:"bytes"}],name:"splitSignature",outputs:[{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"},{internalType:"uint8",name:"v",type:"uint8"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newManager",type:"address"}],name:"transferManagerShip",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"unregisterProduct",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newManagerWallet",type:"address"}],name:"updateDroplinkedManagerWallet",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"signer",type:"address"},{internalType:"bytes",name:"signature",type:"bytes"},{components:[{components:[{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"uint256",name:"nullifier",type:"uint256"}],internalType:"struct PurchasedItem[]",name:"cart",type:"tuple[]"},{internalType:"address",name:"shop",type:"address"}],internalType:"struct PurchaseSignature",name:"data",type:"tuple"}],name:"verifyPurchase",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"pure",type:"function"}];function getTransactionLink({blockchain:c,transactionHash:t,isTestnet:n=!1}){const ie=t.trim();switch(c.toUpperCase()){case"CASPER":return`https://${n?"testnet.":""}cspr.live/deploy/${ie}`;case"STACKS":return`https://explorer.hiro.so/txid/${ie}?chain=${n?"testnet":"mainnet"}`;case"POLYGON":return`https://${n?"amoy.":""}polygonscan.com/tx/${ie}`;case"XRPLSIDECHAIN":return`https://evm-sidechain.xrpl.org/tx/${ie}`;case"BINANCE":return`https://${n?"testnet.":""}bscscan.com/tx/${ie}`;case"NEAR":return`https://explorer.${n?"testnet":"mainnet"}.aurora.dev/tx/${ie}`;case"BASE":return`https://base${n?"-sepolia":""}.blockscout.com/tx/${ie}`;case"LINEA":return`https://${n?"sepolia.":""}lineascan.build/tx/${ie}`;case"ETH":return`https://${n?"sepolia.":""}etherscan.io/tx/${ie}`;case"SOLANA":return`https://explorer.solana.com/tx/${ie}?cluster=${n?"devnet":"mainnet"}`;case"REDBELLY":return n?`https://redbelly.testnet.routescan.io/tx/${ie}`:`https://redbelly.routescan.io/tx/${ie}`;case"SKALE":return`https://${n?"giant-half-dual-testnet.explorer.testnet.skalenodes.com":"honorable-steel-rasalhague.explorer.mainnet.skalenodes.com"}/tx/${ie}`;case"BITLAYER":return n?`https://testnet.btrscan.com/tx/${ie}`:`https://www.btrscan.com/tx/${ie}`;default:return""}}async function ensureWalletOnChainFromConfig(c,t,n){const ie=t[n];if(!ie)throw new Error(`Network config not found for ${t.name} (${n})`);const fe=c.provider;if(!(fe!=null&&fe.request))throw new Error("Provider does not support network switching");const ae=await c.getNetwork(),le=Number(ie.chainId);if(ae.chainId===le)return;try{await fe.request({method:"wallet_switchEthereumChain",params:[{chainId:ie.chainId}]})}catch(ye){if(ye.code===4902)await fe.request({method:"wallet_addEthereumChain",params:[{chainId:ie.chainId,chainName:ie.chainName,rpcUrls:ie.rpcUrls,nativeCurrency:ie.nativeCurrency}]});else throw ye}if((await c.getNetwork()).chainId!==le)throw new Error(`Failed to switch to ${t.name} (${n})`)}function getBaseUrl(c){return c===Network.MAINNET?"https://apiv3.droplinked.com":c===Network.TESTNET?"https://apiv3dev.droplinked.com":"http://127.0.0.1:3000"}async function getGasPrice(c){return(await c.getGasPrice()).toBigInt()}const deployerABI=[{inputs:[],name:"InvalidInitialization",type:"error"},{inputs:[],name:"NotInitializing",type:"error"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"OwnableInvalidOwner",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"OwnableUnauthorizedAccount",type:"error"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"newFee",type:"uint256"}],name:"DroplinkedFeeUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"newHeartBeat",type:"uint256"}],name:"HeartBeatUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint64",name:"version",type:"uint64"}],name:"Initialized",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"shop",type:"address"},{indexed:!1,internalType:"address",name:"nftContract",type:"address"}],name:"ShopDeployed",type:"event"},{inputs:[{internalType:"bytes",name:"bytecode",type:"bytes"},{internalType:"bytes32",name:"salt",type:"bytes32"}],name:"deployShop",outputs:[{internalType:"address",name:"shop",type:"address"},{internalType:"address",name:"nftContract",type:"address"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"droplinkedFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"droplinkedWallet",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getDroplinkedFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getHeartBeat",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"heartBeat",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"_heartBeat",type:"uint256"},{internalType:"address",name:"_droplinkedWallet",type:"address"},{internalType:"uint256",name:"_droplinkedFee",type:"uint256"}],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"nftContracts",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"shopOwner",type:"address"},{internalType:"uint256",name:"",type:"uint256"}],name:"nftOwners",outputs:[{internalType:"address",name:"nftContracts",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"newFee",type:"uint256"}],name:"setDroplinkedFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"newHeartBeat",type:"uint256"}],name:"setHeartBeat",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"shopAddresses",outputs:[{internalType:"contract IDropShop",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"shopCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"shopOwner",type:"address"},{internalType:"uint256",name:"",type:"uint256"}],name:"shopOwners",outputs:[{internalType:"address",name:"shops",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"}],sixify=c=>c.toString().padStart(6,"0");async function getConstructorArgs(c,t,n){return[c.shopName||"",c.shopAddress||"",n,c.shopLogo||"",c.shopDescription||"",t]}async function deployEVMShop(c,t,n){console.log({...c,...t,...n});const{modalInterface:ie}=t,{chain:fe,network:ae,provider:le}=c,he=le.getSigner(),ye=await getDeployerAddress(fe,ae),me=new Contract(ye,deployerABI,he),xe=await getShopByteCode(),Ee=await he.getAddress(),Se="0x"+Ee.split("0x")[1]+"000000000000000000"+sixify(Math.floor(Math.random()*1e6)+1),Me=await getConstructorArgs(n,ye,Ee),Be=defaultAbiCoder.encode(["string","string","address","string","string","address"],Me);try{let $e;const Ce=xe+Be.split("0x")[1];console.log({fullBytecode:Ce}),c.chain!==Chains.SKALE?(await me.callStatic.deployShop(Ce,Se),$e=await me.deployShop(Ce,Se,{})):$e=await me.deployShop(Ce,Se);const Ue=(await $e.wait()).logs.map(Ve=>{try{return me.interface.parseLog(Ve)}catch{return null}}).filter(Ve=>Ve!=null).find(Ve=>Ve.name==="ShopDeployed"),qe=Ue.args.shop,He=Ue.args.nftContract;return{transactionHash:$e.hash,deployedShopAddress:qe,deployedNFTAddress:He}}catch($e){if(ie.error("Error during shop deployment",`${$e.message||$e}`),$e.code.toString()==="ACTION_REJECTED")throw new UserDeniedException("Deployer");try{const Ce=me.interface.parseError($e.data);throw ie.error("Contract error",`${Ce}`),Ce}catch(Ce){throw ie.error("Unhandled error during shop deployment.",`${Ce||$e}`),new Error(Ce||"Unknown error occurred.")}}}function getRecordData(c,t,n){const{acceptsManageWallet:ie,amount:fe,royalty:ae,type:le}=c;return{nftAddress:n,uri:t,amount:fe,accepted:ie,affiliatePercentage:ae,royalty:ae,nftType:NFTType.ERC1155,productType:le}}async function prepareRecordData(c,t,n,ie){const{nftContract:fe}=ie;if(!fe)throw new InvalidParametersException(c.chain,"nftContract");const{description:ae}=n,{skuID:le}=t,he={...t,...n},ye={...he.skuProperties},me={name:he.productTitle,description:ae,image:he.imageUrl,properties:ye},xe=await uploadMetadata(me,le,ie.axiosInstance);return getRecordData(he,xe,fe)}async function doRecordProduct(c,t,n,ie){const{modalInterface:fe,nftContract:ae,shopContractAddress:le}=t;if(!ae||!le)throw fe.error("Invalid Parameters","nftContract||shopContractAddress"),new InvalidParametersException(c.chain,"nftContract||shopContractAddress");fe.changeStep("Connecting to wallet");const he=c.provider.getSigner(),ye=new Contract(le,shopABI,he);try{fe.changeStep("Preparing products for recording");const me=await Promise.all(ie.map(Ee=>prepareRecordData(c,Ee,n,t)));let xe;return c.chain!==Chains.SKALE?(await ye.callStatic.mintAndRegisterBatch(me),fe.changeStep("Recording products on blockchain"),xe=await ye.mintAndRegisterBatch(me)):(fe.changeStep("Recording products on blockchain"),xe=await ye.mintAndRegisterBatch(me)),fe.changeStep("Waiting for transaction confirmation"),await xe.wait(),{transactionHash:xe.hash,metadataUrls:me.map(Ee=>Ee.uri)}}catch(me){if(me.code&&me.code.toString()==="ACTION_REJECTED")throw t.modalInterface.error("Transaction Rejected","ACTION_REJECTED"),new Error("Transaction Rejected");try{if(me.data&&me.data!=="0x"){const xe=ye.interface.parseError(me.data);throw xe.name==="OwnableUnauthorizedAccount"?(t.modalInterface.error("Unauthorized","OwnableUnauthorizedAccount"),new Unauthorized(c.chain,"record",await he.getAddress(),le)):(t.modalInterface.error(xe.name,xe.args.join(", ")),t.modalInterface.error(me,xe.name),me)}else throw fe.error("Transaction reverted without reason",`${me}`),me}catch(xe){throw fe.error("Unexpected error",`${xe}`),xe}}}async function recordProduct({productId:c,chain:t,axiosInstance:n,shopId:ie,network:fe,stepizer:ae,provider:le}){let he="",ye="";if(ae.changeStep("Starting record process"),ie!==""){const Me=await getShopInfo(t,ie,n);he=Me.nftContractAddress,ye=Me.shopContractAddress}const me=new Web3Provider(le,"any");if(!he||!ye){ae.changeStep("Deploying shop contract");const Me={chain:t,network:fe,provider:me},Be={axiosInstance:n,modalInterface:ae,nftContract:"",shopContractAddress:""},{description:$e,logo:Ce,name:ke,url:Pe,deployedContracts:Ue}=await getShopDeployInfo(ie,n),{deployedNFTAddress:qe,deployedShopAddress:He,transactionHash:Ve}=await deployEVMShop(Me,Be,{shopName:ke,shopAddress:Pe,shopLogo:Ce,shopDescription:$e}),Ye=[...Ue||[],{type:t,deployedShopAddress:He,transactionId:Ve,deployedNFTAddress:qe,isCircle:!1,platform:"DROPLINKED",status:"SUCCESS"}];console.log({newDeployedContracts:Ye}),he=qe,ye=He,ae.changeStep("Shop deployed successfully")}await ensureWalletOnChainFromConfig(me,getChainByName(t),fe);const{productData:xe,skuData:Ee}=await getProductDataForRecord(c,n);if(!ie)throw new InvalidParametersException(t,"shopId");const Se=await startRecord(c,Ee.map(Me=>Me.skuID),ie,t,[],n);try{const $e=await doRecordProduct({chain:t,network:fe,provider:me},{axiosInstance:n,modalInterface:ae,nftContract:he,shopContractAddress:ye},xe,Ee);await updateUris(Se,$e.metadataUrls,n),await updateHash("record",Se,$e.transactionHash,n);const Ce=`${getBaseUrl(fe)}/web3/record/callback/events/${Se}`;if(!await web3Callback($e.transactionHash,t,Network[fe],Ce))throw new Web3CallbackFailedException("Record");return{...$e,transactionId:Se,transactionHashUrl:getTransactionLink({blockchain:t,transactionHash:$e.transactionHash,isTestnet:fe!==Network.MAINNET})}}catch(Me){throw console.error("Error during recording process:",Me),await deleteRecordTransaction(Se,n),Me}}var utils$e={};const require$$0$3=getAugmentedNamespace(lib_esm$b),require$$1$2=getAugmentedNamespace(lib_esm$f),require$$2$3=getAugmentedNamespace(lib_esm$d),require$$3=getAugmentedNamespace(lib_esm$8),require$$4$3=getAugmentedNamespace(lib_esm$j),require$$5=getAugmentedNamespace(lib_esm$c),require$$6$2=getAugmentedNamespace(lib_esm$6),require$$7=getAugmentedNamespace(lib_esm$4),require$$8=getAugmentedNamespace(lib_esm$h),require$$9=getAugmentedNamespace(lib_esm$k),require$$10=getAugmentedNamespace(lib_esm$7),require$$11$1=getAugmentedNamespace(lib_esm$1),require$$12=getAugmentedNamespace(lib_esm$5),require$$13=getAugmentedNamespace(lib_esm$i),require$$14=getAugmentedNamespace(lib_esm$g),require$$15=getAugmentedNamespace(lib_esm$a),require$$16=getAugmentedNamespace(lib_esm$e),require$$17$1=getAugmentedNamespace(lib_esm$9),require$$18=getAugmentedNamespace(lib_esm),require$$19=getAugmentedNamespace(lib_esm$3),require$$20=getAugmentedNamespace(lib_esm$2);(function(c){var t=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(_e,se,ce,de){de===void 0&&(de=ce),Object.defineProperty(_e,de,{enumerable:!0,get:function(){return se[ce]}})}:function(_e,se,ce,de){de===void 0&&(de=ce),_e[de]=se[ce]}),n=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(_e,se){Object.defineProperty(_e,"default",{enumerable:!0,value:se})}:function(_e,se){_e.default=se}),ie=commonjsGlobal&&commonjsGlobal.__importStar||function(_e){if(_e&&_e.__esModule)return _e;var se={};if(_e!=null)for(var ce in _e)ce!=="default"&&Object.prototype.hasOwnProperty.call(_e,ce)&&t(se,_e,ce);return n(se,_e),se};Object.defineProperty(c,"__esModule",{value:!0}),c.formatBytes32String=c.Utf8ErrorFuncs=c.toUtf8String=c.toUtf8CodePoints=c.toUtf8Bytes=c._toEscapedUtf8String=c.nameprep=c.hexDataSlice=c.hexDataLength=c.hexZeroPad=c.hexValue=c.hexStripZeros=c.hexConcat=c.isHexString=c.hexlify=c.base64=c.base58=c.TransactionDescription=c.LogDescription=c.Interface=c.SigningKey=c.HDNode=c.defaultPath=c.isBytesLike=c.isBytes=c.zeroPad=c.stripZeros=c.concat=c.arrayify=c.shallowCopy=c.resolveProperties=c.getStatic=c.defineReadOnly=c.deepCopy=c.checkProperties=c.poll=c.fetchJson=c._fetchData=c.RLP=c.Logger=c.checkResultErrors=c.FormatTypes=c.ParamType=c.FunctionFragment=c.EventFragment=c.ErrorFragment=c.ConstructorFragment=c.Fragment=c.defaultAbiCoder=c.AbiCoder=void 0,c.Indexed=c.Utf8ErrorReason=c.UnicodeNormalizationForm=c.SupportedAlgorithm=c.mnemonicToSeed=c.isValidMnemonic=c.entropyToMnemonic=c.mnemonicToEntropy=c.getAccountPath=c.verifyTypedData=c.verifyMessage=c.recoverPublicKey=c.computePublicKey=c.recoverAddress=c.computeAddress=c.getJsonWalletAddress=c.TransactionTypes=c.serializeTransaction=c.parseTransaction=c.accessListify=c.joinSignature=c.splitSignature=c.soliditySha256=c.solidityKeccak256=c.solidityPack=c.shuffled=c.randomBytes=c.sha512=c.sha256=c.ripemd160=c.keccak256=c.computeHmac=c.commify=c.parseUnits=c.formatUnits=c.parseEther=c.formatEther=c.isAddress=c.getCreate2Address=c.getContractAddress=c.getIcapAddress=c.getAddress=c._TypedDataEncoder=c.id=c.isValidName=c.namehash=c.hashMessage=c.dnsEncode=c.parseBytes32String=void 0;var fe=require$$0$3;Object.defineProperty(c,"AbiCoder",{enumerable:!0,get:function(){return fe.AbiCoder}}),Object.defineProperty(c,"checkResultErrors",{enumerable:!0,get:function(){return fe.checkResultErrors}}),Object.defineProperty(c,"ConstructorFragment",{enumerable:!0,get:function(){return fe.ConstructorFragment}}),Object.defineProperty(c,"defaultAbiCoder",{enumerable:!0,get:function(){return fe.defaultAbiCoder}}),Object.defineProperty(c,"ErrorFragment",{enumerable:!0,get:function(){return fe.ErrorFragment}}),Object.defineProperty(c,"EventFragment",{enumerable:!0,get:function(){return fe.EventFragment}}),Object.defineProperty(c,"FormatTypes",{enumerable:!0,get:function(){return fe.FormatTypes}}),Object.defineProperty(c,"Fragment",{enumerable:!0,get:function(){return fe.Fragment}}),Object.defineProperty(c,"FunctionFragment",{enumerable:!0,get:function(){return fe.FunctionFragment}}),Object.defineProperty(c,"Indexed",{enumerable:!0,get:function(){return fe.Indexed}}),Object.defineProperty(c,"Interface",{enumerable:!0,get:function(){return fe.Interface}}),Object.defineProperty(c,"LogDescription",{enumerable:!0,get:function(){return fe.LogDescription}}),Object.defineProperty(c,"ParamType",{enumerable:!0,get:function(){return fe.ParamType}}),Object.defineProperty(c,"TransactionDescription",{enumerable:!0,get:function(){return fe.TransactionDescription}});var ae=require$$1$2;Object.defineProperty(c,"getAddress",{enumerable:!0,get:function(){return ae.getAddress}}),Object.defineProperty(c,"getCreate2Address",{enumerable:!0,get:function(){return ae.getCreate2Address}}),Object.defineProperty(c,"getContractAddress",{enumerable:!0,get:function(){return ae.getContractAddress}}),Object.defineProperty(c,"getIcapAddress",{enumerable:!0,get:function(){return ae.getIcapAddress}}),Object.defineProperty(c,"isAddress",{enumerable:!0,get:function(){return ae.isAddress}});var le=ie(require$$2$3);c.base64=le;var he=require$$3;Object.defineProperty(c,"base58",{enumerable:!0,get:function(){return he.Base58}});var ye=require$$4$3;Object.defineProperty(c,"arrayify",{enumerable:!0,get:function(){return ye.arrayify}}),Object.defineProperty(c,"concat",{enumerable:!0,get:function(){return ye.concat}}),Object.defineProperty(c,"hexConcat",{enumerable:!0,get:function(){return ye.hexConcat}}),Object.defineProperty(c,"hexDataSlice",{enumerable:!0,get:function(){return ye.hexDataSlice}}),Object.defineProperty(c,"hexDataLength",{enumerable:!0,get:function(){return ye.hexDataLength}}),Object.defineProperty(c,"hexlify",{enumerable:!0,get:function(){return ye.hexlify}}),Object.defineProperty(c,"hexStripZeros",{enumerable:!0,get:function(){return ye.hexStripZeros}}),Object.defineProperty(c,"hexValue",{enumerable:!0,get:function(){return ye.hexValue}}),Object.defineProperty(c,"hexZeroPad",{enumerable:!0,get:function(){return ye.hexZeroPad}}),Object.defineProperty(c,"isBytes",{enumerable:!0,get:function(){return ye.isBytes}}),Object.defineProperty(c,"isBytesLike",{enumerable:!0,get:function(){return ye.isBytesLike}}),Object.defineProperty(c,"isHexString",{enumerable:!0,get:function(){return ye.isHexString}}),Object.defineProperty(c,"joinSignature",{enumerable:!0,get:function(){return ye.joinSignature}}),Object.defineProperty(c,"zeroPad",{enumerable:!0,get:function(){return ye.zeroPad}}),Object.defineProperty(c,"splitSignature",{enumerable:!0,get:function(){return ye.splitSignature}}),Object.defineProperty(c,"stripZeros",{enumerable:!0,get:function(){return ye.stripZeros}});var me=require$$5;Object.defineProperty(c,"_TypedDataEncoder",{enumerable:!0,get:function(){return me._TypedDataEncoder}}),Object.defineProperty(c,"dnsEncode",{enumerable:!0,get:function(){return me.dnsEncode}}),Object.defineProperty(c,"hashMessage",{enumerable:!0,get:function(){return me.hashMessage}}),Object.defineProperty(c,"id",{enumerable:!0,get:function(){return me.id}}),Object.defineProperty(c,"isValidName",{enumerable:!0,get:function(){return me.isValidName}}),Object.defineProperty(c,"namehash",{enumerable:!0,get:function(){return me.namehash}});var xe=require$$6$2;Object.defineProperty(c,"defaultPath",{enumerable:!0,get:function(){return xe.defaultPath}}),Object.defineProperty(c,"entropyToMnemonic",{enumerable:!0,get:function(){return xe.entropyToMnemonic}}),Object.defineProperty(c,"getAccountPath",{enumerable:!0,get:function(){return xe.getAccountPath}}),Object.defineProperty(c,"HDNode",{enumerable:!0,get:function(){return xe.HDNode}}),Object.defineProperty(c,"isValidMnemonic",{enumerable:!0,get:function(){return xe.isValidMnemonic}}),Object.defineProperty(c,"mnemonicToEntropy",{enumerable:!0,get:function(){return xe.mnemonicToEntropy}}),Object.defineProperty(c,"mnemonicToSeed",{enumerable:!0,get:function(){return xe.mnemonicToSeed}});var Ee=require$$7;Object.defineProperty(c,"getJsonWalletAddress",{enumerable:!0,get:function(){return Ee.getJsonWalletAddress}});var Se=require$$8;Object.defineProperty(c,"keccak256",{enumerable:!0,get:function(){return Se.keccak256}});var Me=require$$9;Object.defineProperty(c,"Logger",{enumerable:!0,get:function(){return Me.Logger}});var Be=require$$10;Object.defineProperty(c,"computeHmac",{enumerable:!0,get:function(){return Be.computeHmac}}),Object.defineProperty(c,"ripemd160",{enumerable:!0,get:function(){return Be.ripemd160}}),Object.defineProperty(c,"sha256",{enumerable:!0,get:function(){return Be.sha256}}),Object.defineProperty(c,"sha512",{enumerable:!0,get:function(){return Be.sha512}});var $e=require$$11$1;Object.defineProperty(c,"solidityKeccak256",{enumerable:!0,get:function(){return $e.keccak256}}),Object.defineProperty(c,"solidityPack",{enumerable:!0,get:function(){return $e.pack}}),Object.defineProperty(c,"soliditySha256",{enumerable:!0,get:function(){return $e.sha256}});var Ce=require$$12;Object.defineProperty(c,"randomBytes",{enumerable:!0,get:function(){return Ce.randomBytes}}),Object.defineProperty(c,"shuffled",{enumerable:!0,get:function(){return Ce.shuffled}});var ke=require$$13;Object.defineProperty(c,"checkProperties",{enumerable:!0,get:function(){return ke.checkProperties}}),Object.defineProperty(c,"deepCopy",{enumerable:!0,get:function(){return ke.deepCopy}}),Object.defineProperty(c,"defineReadOnly",{enumerable:!0,get:function(){return ke.defineReadOnly}}),Object.defineProperty(c,"getStatic",{enumerable:!0,get:function(){return ke.getStatic}}),Object.defineProperty(c,"resolveProperties",{enumerable:!0,get:function(){return ke.resolveProperties}}),Object.defineProperty(c,"shallowCopy",{enumerable:!0,get:function(){return ke.shallowCopy}});var Pe=ie(require$$14);c.RLP=Pe;var Ue=require$$15;Object.defineProperty(c,"computePublicKey",{enumerable:!0,get:function(){return Ue.computePublicKey}}),Object.defineProperty(c,"recoverPublicKey",{enumerable:!0,get:function(){return Ue.recoverPublicKey}}),Object.defineProperty(c,"SigningKey",{enumerable:!0,get:function(){return Ue.SigningKey}});var qe=require$$16;Object.defineProperty(c,"formatBytes32String",{enumerable:!0,get:function(){return qe.formatBytes32String}}),Object.defineProperty(c,"nameprep",{enumerable:!0,get:function(){return qe.nameprep}}),Object.defineProperty(c,"parseBytes32String",{enumerable:!0,get:function(){return qe.parseBytes32String}}),Object.defineProperty(c,"_toEscapedUtf8String",{enumerable:!0,get:function(){return qe._toEscapedUtf8String}}),Object.defineProperty(c,"toUtf8Bytes",{enumerable:!0,get:function(){return qe.toUtf8Bytes}}),Object.defineProperty(c,"toUtf8CodePoints",{enumerable:!0,get:function(){return qe.toUtf8CodePoints}}),Object.defineProperty(c,"toUtf8String",{enumerable:!0,get:function(){return qe.toUtf8String}}),Object.defineProperty(c,"Utf8ErrorFuncs",{enumerable:!0,get:function(){return qe.Utf8ErrorFuncs}});var He=require$$17$1;Object.defineProperty(c,"accessListify",{enumerable:!0,get:function(){return He.accessListify}}),Object.defineProperty(c,"computeAddress",{enumerable:!0,get:function(){return He.computeAddress}}),Object.defineProperty(c,"parseTransaction",{enumerable:!0,get:function(){return He.parse}}),Object.defineProperty(c,"recoverAddress",{enumerable:!0,get:function(){return He.recoverAddress}}),Object.defineProperty(c,"serializeTransaction",{enumerable:!0,get:function(){return He.serialize}}),Object.defineProperty(c,"TransactionTypes",{enumerable:!0,get:function(){return He.TransactionTypes}});var Ve=require$$18;Object.defineProperty(c,"commify",{enumerable:!0,get:function(){return Ve.commify}}),Object.defineProperty(c,"formatEther",{enumerable:!0,get:function(){return Ve.formatEther}}),Object.defineProperty(c,"parseEther",{enumerable:!0,get:function(){return Ve.parseEther}}),Object.defineProperty(c,"formatUnits",{enumerable:!0,get:function(){return Ve.formatUnits}}),Object.defineProperty(c,"parseUnits",{enumerable:!0,get:function(){return Ve.parseUnits}});var Ye=require$$19;Object.defineProperty(c,"verifyMessage",{enumerable:!0,get:function(){return Ye.verifyMessage}}),Object.defineProperty(c,"verifyTypedData",{enumerable:!0,get:function(){return Ye.verifyTypedData}});var Qe=require$$20;Object.defineProperty(c,"_fetchData",{enumerable:!0,get:function(){return Qe._fetchData}}),Object.defineProperty(c,"fetchJson",{enumerable:!0,get:function(){return Qe.fetchJson}}),Object.defineProperty(c,"poll",{enumerable:!0,get:function(){return Qe.poll}});var Ke=require$$10;Object.defineProperty(c,"SupportedAlgorithm",{enumerable:!0,get:function(){return Ke.SupportedAlgorithm}});var Pt=require$$16;Object.defineProperty(c,"UnicodeNormalizationForm",{enumerable:!0,get:function(){return Pt.UnicodeNormalizationForm}}),Object.defineProperty(c,"Utf8ErrorReason",{enumerable:!0,get:function(){return Pt.Utf8ErrorReason}})})(utils$e);const ZERO_ADDRESS="0x0000000000000000000000000000000000000000",SkaleUsdcAddressForTestnet="0x2aebcdc4f9f9149a50422fff86198cb0939ea165",SkaleUsdcAddressForMainnet="0x7Cf76E740Cb23b99337b21F392F22c47Ad910c67",erc20ABI=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"allowance",type:"uint256"},{internalType:"uint256",name:"needed",type:"uint256"}],name:"ERC20InsufficientAllowance",type:"error"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"uint256",name:"balance",type:"uint256"},{internalType:"uint256",name:"needed",type:"uint256"}],name:"ERC20InsufficientBalance",type:"error"},{inputs:[{internalType:"address",name:"approver",type:"address"}],name:"ERC20InvalidApprover",type:"error"},{inputs:[{internalType:"address",name:"receiver",type:"address"}],name:"ERC20InvalidReceiver",type:"error"},{inputs:[{internalType:"address",name:"sender",type:"address"}],name:"ERC20InvalidSender",type:"error"},{inputs:[{internalType:"address",name:"spender",type:"address"}],name:"ERC20InvalidSpender",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"}],paymentProxyABI=[{inputs:[{internalType:"uint256",name:"_heartBeat",type:"uint256"},{internalType:"address",name:"_chainLinkProvider",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"OwnableInvalidOwner",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"OwnableUnauthorizedAccount",type:"error"},{inputs:[{internalType:"uint256",name:"priceTimestamp",type:"uint256"},{internalType:"uint256",name:"currentTimestamp",type:"uint256"}],name:"oldPrice",type:"error"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"newHeartBeat",type:"uint256"}],name:"HeartBeatChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"ProductPurchased",type:"event"},{inputs:[{internalType:"uint256",name:"_heartBeat",type:"uint256"}],name:"changeHeartBeat",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256[]",name:"tbdValues",type:"uint256[]"},{internalType:"address[]",name:"tbdReceivers",type:"address[]"},{internalType:"address",name:"currency",type:"address"},{internalType:"uint80",name:"roundId",type:"uint80"},{internalType:"string",name:"memo",type:"string"}],name:"droplinkedPurchase",outputs:[],stateMutability:"payable",type:"function"},{inputs:[],name:"heartBeat",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"}];async function handleCustomTokenApproval(c,t,n,ie,fe){if(!c.tokenAddress)throw new InvalidParametersException(Chains.BASE,"Token address is not set");try{const ae=new Contract(c.tokenAddress,erc20ABI,n),le=await ae.balanceOf(ie),he=c.tbdValues.reduce((me,xe)=>me.add(BigNumber.from(xe)),BigNumber.from(0));if(le.lt(he))throw new InsufficientBalanceException;fe.changeStep("Approving token");const ye=await ae.approve(t,MaxUint256$1);fe.changeStep("awaiting confirmation"),await ye.wait(),fe.changeStep("Token approval confirmed")}catch(ae){handleError(ae,fe)}}const droplinkedPayment=async function(c,t,n){const{modalInterface:ie}=t,{provider:fe,chain:ae,network:le}=c;if(!n.tbdReceivers.every(utils$e.isAddress))throw new InvalidParametersException(ae,"Invalid receiver address found");n.chainLinkRoundId=n.chainLinkRoundId||"0";const he=n.tokenAddress&&n.tokenAddress!==ZERO_ADDRESS;if(he){if(!n.tbdValues.every(Se=>BigNumber.from(Se).gt(0)))throw new InvalidParametersException(ae,"tbdValues must be positive numbers")}else if(!n.tbdValues.every(Se=>Se>0))throw new InvalidParametersException(ae,"tbdValues must be positive numbers");const ye=fe.getSigner(),me=await ye.getAddress();if(!n.tbdValues)throw new InvalidParametersException(ae,`Invalid tbdValues: ${n.tbdValues}`);if(!n.tbdReceivers)throw new InvalidParametersException(ae,`Invalid tbdReceivers: ${n.tbdReceivers}`);if(!n.memo)throw new InvalidParametersException(ae,`Memo is required for payment, current memo: ${n.memo}`);if(n.tbdReceivers.length!==n.tbdValues.length)throw new InvalidParametersException(ae,"tbdReceivers and tbdValues must be the same length");let xe;try{xe=await getProxyAddress(ae,le)}catch(Se){throw new Error("Failed to get contract address: "+Se.message)}let Ee;try{Ee=new Contract(xe,paymentProxyABI,ye)}catch(Se){throw new Error("Failed to create contract instance: "+Se.message)}try{if(console.log(`
10
10
  Purchase Details:
11
11
  data.tbdValues: ${n.tbdValues}
12
12
  data.tbdReceivers: ${n.tbdReceivers}
@@ -14,7 +14,7 @@
14
14
  data.chainLinkRoundId: ${n.chainLinkRoundId}
15
15
  data.memo: ${n.memo}
16
16
  data.totalPrice: ${Number(n.totalPrice)}
17
- `),ae===Chains.SKALE)return await skalePayment(n,le,ye,Ee,me,xe,ie);he?await handleCustomTokenApproval(n,xe,ye,me,ie):n.tbdValues=n.tbdValues.map(Ue=>parseInt(Ue.toString(),10));try{await Ee.callStatic.droplinkedPurchase(n.tbdValues,n.tbdReceivers,n.tokenAddress,n.chainLinkRoundId,n.memo,{value:he?BigNumber.from(0):n.totalPrice})}catch(Ue){throw new Error("Transaction will fail: "+Ue.message)}let Se;try{Se=await getGasPrice(fe)}catch(Ue){throw new Error("Failed to get gas price: "+Ue.message)}let Me;try{Me=await Ee.estimateGas.droplinkedPurchase(n.tbdValues,n.tbdReceivers,n.tokenAddress,n.chainLinkRoundId,n.memo,{value:he?BigNumber.from(0):n.totalPrice})}catch(Ue){throw new Error(`Gas estimation failed: ${Ue.message}. Please check the transaction parameters.`)}const Be=Me.mul(105).div(100),$e=he?BigNumber.from(0):BigNumber.from(n.totalPrice);let Ce;try{Ce=await fe.getBalance(me)}catch(Ue){throw new Error("Failed to get user balance: "+Ue.message)}const ke=$e.add(Be.mul(Se));if(Ce.lt(ke))throw new InsufficientBalanceException;ie.changeStep("Sending Payment Transaction");const Pe=await Ee.droplinkedPurchase(n.tbdValues,n.tbdReceivers,n.tokenAddress,n.chainLinkRoundId,n.memo,{gasLimit:Be,value:he?BigNumber.from(0):n.totalPrice});return ie.changeStep("Awaiting transaction"),await Pe.wait(),ie.success("Payment Successful"),{transactionHash:Pe.hash,cryptoAmount:n.totalPrice}}catch(Se){handleError(Se,ie)}},skalePayment=async function(c,t,n,ie,fe,ae,le){try{const he=t===Network.TESTNET?SkaleUsdcAddressForTestnet:SkaleUsdcAddressForMainnet;return c.tokenAddress=he,await handleCustomTokenApproval(c,ae,n,fe,le),{transactionHash:(await ie.droplinkedPurchase(c.tbdValues,c.tbdReceivers,he,"0",c.memo)).hash,cryptoAmount:c.totalPrice}}catch(he){handleError(he,le)}};function handleError(c,t){var n;throw c instanceof Error?((n=c.code)==null?void 0:n.toString())==="ACTION_REJECTED"||c.message.includes("User denied")||c.message.includes("User cancelled transaction")?(t.error("Transaction rejected by user","User Denied"),new UserDeniedException("Metamask*")):c.message.includes("insufficient funds")||c.message.includes("gas * price + value")||c.code==="INSUFFICIENT_FUNDS"?(t.error("Insufficient balance to complete the transaction","Insufficient Balance"),new InsufficientBalanceException):c:(t.error("An unknown error occurred","Unknown Error"),new Error("An unknown error occurred"))}async function payment({chain:c,orderID:t,paymentToken:n,axiosInstance:ie,shopId:fe,network:ae,provider:le,stepizer:he}){const ye=new Web3Provider(le,"any");if(await ensureWalletOnChainFromConfig(ye,getChainByName(c),ae),!fe)throw new InvalidParametersException(c,"shopId not found");const me=await startPayment(t,n,c,fe,ie),xe=await getCartData(t,n,c,ie),Ee=xe.paymentData,Be=await droplinkedPayment({chain:c,network:ae,provider:ye},{modalInterface:he},Ee);if(await updateHash("payment",me,Be.transactionHash,ie),!await web3Callback(Be.transactionHash,c,Network[ae],`${getBaseUrl(ae)}/web3/payment/callback/${me}/${Be.transactionHash}`))throw new Web3CallbackFailedException(Actions.Payment);return{...Be,orderID:xe.orderID,transactionId:me}}const DROPLINKED_MANAGER="0x2F86E1B1A69D259b9609b40E3cbEBEa29946f979";async function doClaimNFT(c,t,n){const{modalInterface:ie}=n,fe=t.provider.getSigner();ie.changeStep("Claiming NFTs");const ae=new Contract(n.shopContractAddress,shopABI,fe);try{console.log(DROPLINKED_MANAGER,c.signature.signature,{cart:c.signature.purchaseData.map(ye=>({amount:ye.amount,productId:ye.productId,nullifier:ye.nullifier})),shop:n.shopContractAddress});const le=c.signature.purchaseData.map(ye=>({amount:ye.amount,productId:BigNumber.from(ye.productId),nullifier:BigNumber.from(ye.nullifier)}));ie.changeStep("Sending Transaction");const he=await ae.claimPurchase(DROPLINKED_MANAGER,c.signature.signature,{cart:le,shop:n.shopContractAddress});return ie.changeStep("Waiting for confirmation"),await he.wait(),ie.changeStep("NFT Claimed!"),{transactionHash:he.hash}}catch(le){if(console.error(le),le.code&&le.code.toString()==="ACTION_REJECTED")throw n.modalInterface.error("Transaction Rejected","Transaction Rejected by the user"),new UserDeniedException("Transaction Rejected");try{const he=ae.interface.parseError(le.data);throw he.name==="OwnableUnauthorizedAccount"&&n.modalInterface.error(he.name,he.name),n.modalInterface.error(le,le),le}catch(he){throw ie.error("Unexpected error occurred",`An unexpected error occurred: ${he}`),he}}}async function claimNFT({provider:c,axiosInstance:t,stepizer:n,orderId:ie,skuId:fe,network:ae}){const le=new Web3Provider(c,"any"),{shopContractAddress:he,signature:ye,networkName:me,nftId:xe}=await getPurchaseSignature(ie,fe,t);await ensureWalletOnChainFromConfig(le,getChainByName(me),ae);const Be=await doClaimNFT({signature:ye},{provider:le},{axiosInstance:t,modalInterface:n,nftContract:"",shopContractAddress:he});return await sendClaim(xe,Be.transactionHash,t),Be}class EVMBaseWallet extends Web3Wallet{constructor(t,n){super(t.wallet,t.group,n),this.provider=null,this.cfg=t}async initializeProvider(){this.provider=await getEvmProviderByWalletName(this.cfg.wallet),console.log(`Initialized ${this.name} EVM Provider.`)}async login({chain:t,network:n}){if(!this.provider)throw this.stepizer.error("Provider Error","Provider not initialized"),new ProviderException(this.name);try{this.stepizer.changeStep("Connecting to wallet..."),console.log(`Login on ${t} ${n}`);const ie=await this.provider.request({method:"eth_requestAccounts"});if(!Array.isArray(ie)||ie.length===0)throw new ProviderException("Evm Wallet");return this.stepizer.success("Wallet connected"),{address:ie[0]}}catch(ie){throw console.error(ie),ie instanceof UserDeniedException?(this.stepizer.error("User denied the request",""),ie):(this.stepizer.error("An error occurred while connecting to the wallet",""),ie)}}async isWalletConnected(){if(!this.provider)return!1;try{const t=await this.provider.request({method:"eth_accounts"});return Array.isArray(t)&&t.length>0}catch{return!1}}async getConnectedAccounts(){if(!this.provider)return[];const t=await this.provider.request({method:"eth_accounts"});return Array.isArray(t)?t:[]}async recordProduct({productId:t,chain:n,axiosInstance:ie,shopId:fe,network:ae}){if(console.log(`Recording for ${t} on ${n}`),!this.provider)throw this.stepizer.error("Provider Error","Provider not initialized"),new ProviderException(this.name);return recordProduct({axiosInstance:ie,chain:n,network:ae,productId:t,provider:this.provider,shopId:fe,stepizer:this.stepizer})}async auth({chain:t,network:n,axiosInstance:ie}){if(console.log(`Authentication process ${t}`),!this.provider)throw this.stepizer.error("Provider Error","Provider not initialized"),new ProviderException(this.name);const fe=this.provider,ae=this.stepizer,le=new Web3Provider(this.provider,"any");try{if(ae.changeStep("Connecting to wallet..."),!await this.isWalletConnected())try{return await fe.request({method:"eth_requestAccounts"})}catch(Me){throw console.error(Me),new UserDeniedException(this.name)}const he=(await this.login({chain:t,network:n})).address;ae.changeStep("Signing message...");const ye=await getNonce(he,ie),me=new Date().toLocaleString(),xe=`Welcome to Droplinked! Please sign this message to verify your ownership over your wallet and log in. - Nonce: ${ye} - Date: ${me}`,Se=await le.getSigner().signMessage(xe);return ae.success("Authentication successful!"),{address:he,signature:Se,nonce:ye,date:me}}catch(he){throw console.error(he),he instanceof UserDeniedException?(ae.error("User denied the request",""),he):(ae.error("An error occurred while connecting to the wallet",""),he)}}async claimNFT({orderId:t,skuId:n,axiosInstance:ie,network:fe}){if(console.log(`ClaimNFT process for order: ${t} - sku: ${n}`),!this.provider)throw this.stepizer.error("Provider Error","Provider not initialized"),new ProviderException(this.name);return claimNFT({axiosInstance:ie,network:fe,orderId:t,provider:this.provider,skuId:n,stepizer:this.stepizer})}async payment({chain:t,network:n,orderID:ie,paymentToken:fe,shopId:ae,axiosInstance:le}){if(!this.supportsToken(t,fe))throw new TokenNotSupportedException(this.name,fe);if(this.stepizer.changeStep("Starting payment process"),!this.provider)throw this.stepizer.error("Provider Error","Provider not initialized"),new ProviderException(this.name);return await payment({axiosInstance:le,chain:t,network:n,orderID:ie,paymentToken:fe,provider:this.provider,shopId:ae,stepizer:this.stepizer})}async isWalletInstalled(){let t=!1;const n=this.name;function ie(fe){var le,he;const ae=fe.detail;((he=(le=ae==null?void 0:ae.info)==null?void 0:le.name)==null?void 0:he.toLowerCase())===n.toLowerCase()&&(t=!0)}return window.addEventListener("eip6963:announceProvider",ie),window.dispatchEvent(new Event("eip6963:requestProvider")),await new Promise(fe=>setTimeout(fe,700)),window.removeEventListener("eip6963:announceProvider",ie),t}getInstallationLink(){return this.cfg.installationLink}}var Wallets=(c=>(c.Metamask="Metamask",c.Phantom="Phantom",c.TrustWallet="Trust Wallet",c.UnstoppableDomains="Unstoppable Domains",c.XION="Xion",c))(Wallets||{});class MetamaskEVMWallet extends EVMBaseWallet{constructor(t){super({group:Groups.EVM,installationLink:{website:"https://metamask.io/download",chrome:"https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn",firefox:"https://addons.mozilla.org/en-US/firefox/addon/ether-metamask/"},wallet:Wallets.Metamask},t)}supportsToken(t,n){return console.log(`Checking support for ${n} on ${t}`),!!this.supportsChain(t)}supportsChain(t){return isChainInGroup(t,Groups.EVM)}}var __classPrivateFieldGet=function(c,t,n,ie){if(n==="a"&&!ie)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?c!==t||!ie:!t.has(c))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?ie:n==="a"?ie.call(c):ie?ie.value:t.get(c)},__classPrivateFieldSet=function(c,t,n,ie,fe){if(ie==="m")throw new TypeError("Private method is not writable");if(ie==="a"&&!fe)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?c!==t||!fe:!t.has(c))throw new TypeError("Cannot write private member to an object whose class did not declare it");return ie==="a"?fe.call(c,n):fe?fe.value=n:t.set(c,n),n},_AppReadyEvent_detail;let wallets;const registeredWalletsSet=new Set;function addRegisteredWallet(c){cachedWalletsArray=void 0,registeredWalletsSet.add(c)}function removeRegisteredWallet(c){cachedWalletsArray=void 0,registeredWalletsSet.delete(c)}const listeners={};function getWallets(){if(wallets||(wallets=Object.freeze({register,get:get$1,on}),typeof window>"u"))return wallets;const c=Object.freeze({register});try{window.addEventListener("wallet-standard:register-wallet",({detail:t})=>t(c))}catch(t){console.error(`wallet-standard:register-wallet event listener could not be added
17
+ `),ae===Chains.SKALE)return await skalePayment(n,le,ye,Ee,me,xe,ie);he?await handleCustomTokenApproval(n,xe,ye,me,ie):n.tbdValues=n.tbdValues.map(Ue=>parseInt(Ue.toString(),10));try{await Ee.callStatic.droplinkedPurchase(n.tbdValues,n.tbdReceivers,n.tokenAddress,n.chainLinkRoundId,n.memo,{value:he?BigNumber.from(0):n.totalPrice})}catch(Ue){throw new Error("Transaction will fail: "+Ue.message)}let Se;try{Se=await getGasPrice(fe)}catch(Ue){throw new Error("Failed to get gas price: "+Ue.message)}let Me;try{Me=await Ee.estimateGas.droplinkedPurchase(n.tbdValues,n.tbdReceivers,n.tokenAddress,n.chainLinkRoundId,n.memo,{value:he?BigNumber.from(0):n.totalPrice})}catch(Ue){throw new Error(`Gas estimation failed: ${Ue.message}. Please check the transaction parameters.`)}const Be=Me.mul(105).div(100),$e=he?BigNumber.from(0):BigNumber.from(n.totalPrice);let Ce;try{Ce=await fe.getBalance(me)}catch(Ue){throw new Error("Failed to get user balance: "+Ue.message)}const ke=$e.add(Be.mul(Se));if(Ce.lt(ke))throw new InsufficientBalanceException;ie.changeStep("Sending Payment Transaction");const Pe=await Ee.droplinkedPurchase(n.tbdValues,n.tbdReceivers,n.tokenAddress,n.chainLinkRoundId,n.memo,{gasLimit:Be,value:he?BigNumber.from(0):n.totalPrice});return ie.changeStep("Awaiting transaction"),await Pe.wait(),ie.success("Payment Successful"),{transactionHash:Pe.hash,cryptoAmount:n.totalPrice}}catch(Se){handleError(Se,ie)}},skalePayment=async function(c,t,n,ie,fe,ae,le){try{const he=t===Network.TESTNET?SkaleUsdcAddressForTestnet:SkaleUsdcAddressForMainnet;return c.tokenAddress=he,await handleCustomTokenApproval(c,ae,n,fe,le),{transactionHash:(await ie.droplinkedPurchase(c.tbdValues,c.tbdReceivers,he,"0",c.memo)).hash,cryptoAmount:c.totalPrice}}catch(he){handleError(he,le)}};function handleError(c,t){var n;throw c instanceof Error?((n=c.code)==null?void 0:n.toString())==="ACTION_REJECTED"||c.message.includes("User denied")||c.message.includes("User cancelled transaction")?(t.error("Transaction rejected by user","User Denied"),new UserDeniedException("Metamask*")):c.message.includes("insufficient funds")||c.message.includes("gas * price + value")||c.code==="INSUFFICIENT_FUNDS"?(t.error("Insufficient balance to complete the transaction","Insufficient Balance"),new InsufficientBalanceException):c:(t.error("An unknown error occurred","Unknown Error"),new Error("An unknown error occurred"))}async function payment({chain:c,orderID:t,paymentToken:n,axiosInstance:ie,shopId:fe,network:ae,provider:le,stepizer:he}){const ye=new Web3Provider(le,"any");if(await ensureWalletOnChainFromConfig(ye,getChainByName(c),ae),!fe)throw new InvalidParametersException(c,"shopId not found");const me=await startPayment(t,n,c,fe,ie),xe=await getCartData(t,n,c,ie),Ee=xe.paymentData,Be=await droplinkedPayment({chain:c,network:ae,provider:ye},{modalInterface:he},Ee);if(await updateHash("payment",me,Be.transactionHash,ie),!await web3Callback(Be.transactionHash,c,Network[ae],`${getBaseUrl(ae)}/web3/payment/callback/${me}/${Be.transactionHash}`))throw new Web3CallbackFailedException(Actions.Payment);return{...Be,orderID:xe.orderID,transactionId:me}}const DROPLINKED_MANAGER="0x2F86E1B1A69D259b9609b40E3cbEBEa29946f979";async function doClaimNFT(c,t,n){const{modalInterface:ie}=n,fe=t.provider.getSigner();ie.changeStep("Claiming NFTs");const ae=new Contract(n.shopContractAddress,shopABI,fe);try{console.log(DROPLINKED_MANAGER,c.signature.signature,{cart:c.signature.purchaseData.map(ye=>({amount:ye.amount,productId:ye.productId,nullifier:ye.nullifier})),shop:n.shopContractAddress});const le=c.signature.purchaseData.map(ye=>({amount:ye.amount,productId:BigNumber.from(ye.productId),nullifier:BigNumber.from(ye.nullifier)}));ie.changeStep("Sending Transaction");const he=await ae.claimPurchase(DROPLINKED_MANAGER,c.signature.signature,{cart:le,shop:n.shopContractAddress});return ie.changeStep("Waiting for confirmation"),await he.wait(),ie.changeStep("NFT Claimed!"),{transactionHash:he.hash}}catch(le){if(console.error(le),le.code&&le.code.toString()==="ACTION_REJECTED")throw n.modalInterface.error("Transaction Rejected","Transaction Rejected by the user"),new UserDeniedException("Transaction Rejected");try{const he=ae.interface.parseError(le.data);throw he.name==="OwnableUnauthorizedAccount"&&n.modalInterface.error("Ownable Error",he.name),n.modalInterface.error(le,le),le}catch(he){throw console.log("Could not parse error with ABI, showing generic error",he),ie.error("Unexpected error occurred","An unexpected error occurred, please try again. If the issue persists, contact support."),he}}}async function claimNFT({provider:c,axiosInstance:t,stepizer:n,orderId:ie,skuId:fe,network:ae}){const le=new Web3Provider(c,"any"),{shopContractAddress:he,signature:ye,networkName:me,nftId:xe,claimed:Ee}=await getPurchaseSignature(ie,fe,t);if(Ee)throw n.error("Already Claimed","This NFT has already been claimed for this order."),new Error("NFT already claimed");await ensureWalletOnChainFromConfig(le,getChainByName(me),ae);const $e=await doClaimNFT({signature:ye},{provider:le},{axiosInstance:t,modalInterface:n,nftContract:"",shopContractAddress:he});return await sendClaim(xe,$e.transactionHash,t),$e}class EVMBaseWallet extends Web3Wallet{constructor(t,n){super(t.wallet,t.group,n),this.provider=null,this.cfg=t}async initializeProvider(){this.provider=await getEvmProviderByWalletName(this.cfg.wallet),console.log(`Initialized ${this.name} EVM Provider.`)}async login({chain:t,network:n}){if(!this.provider)throw this.stepizer.error("Provider Error","Provider not initialized"),new ProviderException(this.name);try{this.stepizer.changeStep("Connecting to wallet..."),console.log(`Login on ${t} ${n}`);const ie=await this.provider.request({method:"eth_requestAccounts"});if(!Array.isArray(ie)||ie.length===0)throw new ProviderException("Evm Wallet");return this.stepizer.success("Wallet connected"),{address:ie[0]}}catch(ie){throw console.error(ie),ie instanceof UserDeniedException?(this.stepizer.error("User denied the request",""),ie):(this.stepizer.error("An error occurred while connecting to the wallet",""),ie)}}async isWalletConnected(){if(!this.provider)return!1;try{const t=await this.provider.request({method:"eth_accounts"});return Array.isArray(t)&&t.length>0}catch{return!1}}async getConnectedAccounts(){if(!this.provider)return[];const t=await this.provider.request({method:"eth_accounts"});return Array.isArray(t)?t:[]}async recordProduct({productId:t,chain:n,axiosInstance:ie,shopId:fe,network:ae}){if(console.log(`Recording for ${t} on ${n}`),!this.provider)throw this.stepizer.error("Provider Error","Provider not initialized"),new ProviderException(this.name);return recordProduct({axiosInstance:ie,chain:n,network:ae,productId:t,provider:this.provider,shopId:fe,stepizer:this.stepizer})}async auth({chain:t,network:n,axiosInstance:ie}){if(console.log(`Authentication process ${t}`),!this.provider)throw this.stepizer.error("Provider Error","Provider not initialized"),new ProviderException(this.name);const fe=this.provider,ae=this.stepizer,le=new Web3Provider(this.provider,"any");try{if(ae.changeStep("Connecting to wallet..."),!await this.isWalletConnected())try{return await fe.request({method:"eth_requestAccounts"})}catch(Me){throw console.error(Me),new UserDeniedException(this.name)}const he=(await this.login({chain:t,network:n})).address;ae.changeStep("Signing message...");const ye=await getNonce(he,ie),me=new Date().toLocaleString(),xe=`Welcome to Droplinked! Please sign this message to verify your ownership over your wallet and log in. - Nonce: ${ye} - Date: ${me}`,Se=await le.getSigner().signMessage(xe);return ae.success("Authentication successful!"),{address:he,signature:Se,nonce:ye,date:me}}catch(he){throw console.error(he),he instanceof UserDeniedException?(ae.error("User denied the request",""),he):(ae.error("An error occurred while connecting to the wallet",""),he)}}async claimNFT({orderId:t,skuId:n,axiosInstance:ie,network:fe}){if(console.log(`ClaimNFT process for order: ${t} - sku: ${n}`),!this.provider)throw this.stepizer.error("Provider Error","Provider not initialized"),new ProviderException(this.name);return claimNFT({axiosInstance:ie,network:fe,orderId:t,provider:this.provider,skuId:n,stepizer:this.stepizer})}async payment({chain:t,network:n,orderID:ie,paymentToken:fe,shopId:ae,axiosInstance:le}){if(!this.supportsToken(t,fe))throw new TokenNotSupportedException(this.name,fe);if(this.stepizer.changeStep("Starting payment process"),!this.provider)throw this.stepizer.error("Provider Error","Provider not initialized"),new ProviderException(this.name);return await payment({axiosInstance:le,chain:t,network:n,orderID:ie,paymentToken:fe,provider:this.provider,shopId:ae,stepizer:this.stepizer})}async isWalletInstalled(){let t=!1;const n=this.name;function ie(fe){var le,he;const ae=fe.detail;((he=(le=ae==null?void 0:ae.info)==null?void 0:le.name)==null?void 0:he.toLowerCase())===n.toLowerCase()&&(t=!0)}return window.addEventListener("eip6963:announceProvider",ie),window.dispatchEvent(new Event("eip6963:requestProvider")),await new Promise(fe=>setTimeout(fe,700)),window.removeEventListener("eip6963:announceProvider",ie),t}getInstallationLink(){return this.cfg.installationLink}}var Wallets=(c=>(c.Metamask="Metamask",c.Phantom="Phantom",c.TrustWallet="Trust Wallet",c.UnstoppableDomains="Unstoppable Domains",c.XION="Xion",c))(Wallets||{});class MetamaskEVMWallet extends EVMBaseWallet{constructor(t){super({group:Groups.EVM,installationLink:{website:"https://metamask.io/download",chrome:"https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn",firefox:"https://addons.mozilla.org/en-US/firefox/addon/ether-metamask/"},wallet:Wallets.Metamask},t)}supportsToken(t,n){return console.log(`Checking support for ${n} on ${t}`),!!this.supportsChain(t)}supportsChain(t){return isChainInGroup(t,Groups.EVM)}}var __classPrivateFieldGet=function(c,t,n,ie){if(n==="a"&&!ie)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?c!==t||!ie:!t.has(c))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?ie:n==="a"?ie.call(c):ie?ie.value:t.get(c)},__classPrivateFieldSet=function(c,t,n,ie,fe){if(ie==="m")throw new TypeError("Private method is not writable");if(ie==="a"&&!fe)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?c!==t||!fe:!t.has(c))throw new TypeError("Cannot write private member to an object whose class did not declare it");return ie==="a"?fe.call(c,n):fe?fe.value=n:t.set(c,n),n},_AppReadyEvent_detail;let wallets;const registeredWalletsSet=new Set;function addRegisteredWallet(c){cachedWalletsArray=void 0,registeredWalletsSet.add(c)}function removeRegisteredWallet(c){cachedWalletsArray=void 0,registeredWalletsSet.delete(c)}const listeners={};function getWallets(){if(wallets||(wallets=Object.freeze({register,get:get$1,on}),typeof window>"u"))return wallets;const c=Object.freeze({register});try{window.addEventListener("wallet-standard:register-wallet",({detail:t})=>t(c))}catch(t){console.error(`wallet-standard:register-wallet event listener could not be added
18
18
  `,t)}try{window.dispatchEvent(new AppReadyEvent(c))}catch(t){console.error(`wallet-standard:app-ready event could not be dispatched
19
19
  `,t)}return wallets}function register(...c){var t;return c=c.filter(n=>!registeredWalletsSet.has(n)),c.length?(c.forEach(n=>addRegisteredWallet(n)),(t=listeners.register)==null||t.forEach(n=>guard(()=>n(...c))),function(){var ie;c.forEach(fe=>removeRegisteredWallet(fe)),(ie=listeners.unregister)==null||ie.forEach(fe=>guard(()=>fe(...c)))}):()=>{}}let cachedWalletsArray;function get$1(){return cachedWalletsArray||(cachedWalletsArray=[...registeredWalletsSet]),cachedWalletsArray}function on(c,t){var n;return(n=listeners[c])!=null&&n.push(t)||(listeners[c]=[t]),function(){var fe;listeners[c]=(fe=listeners[c])==null?void 0:fe.filter(ae=>t!==ae)}}function guard(c){try{c()}catch(t){console.error(t)}}class AppReadyEvent extends Event{get detail(){return __classPrivateFieldGet(this,_AppReadyEvent_detail,"f")}get type(){return"wallet-standard:app-ready"}constructor(t){super("wallet-standard:app-ready",{bubbles:!1,cancelable:!1,composed:!1}),_AppReadyEvent_detail.set(this,void 0),__classPrivateFieldSet(this,_AppReadyEvent_detail,t,"f")}preventDefault(){throw new Error("preventDefault cannot be called")}stopImmediatePropagation(){throw new Error("stopImmediatePropagation cannot be called")}stopPropagation(){throw new Error("stopPropagation cannot be called")}}_AppReadyEvent_detail=new WeakMap;const crypto$2=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function isBytes(c){return c instanceof Uint8Array||ArrayBuffer.isView(c)&&c.constructor.name==="Uint8Array"}function anumber(c){if(!Number.isSafeInteger(c)||c<0)throw new Error("positive integer expected, got "+c)}function abytes(c,...t){if(!isBytes(c))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(c.length))throw new Error("Uint8Array expected of length "+t+", got length="+c.length)}function ahash(c){if(typeof c!="function"||typeof c.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");anumber(c.outputLen),anumber(c.blockLen)}function aexists(c,t=!0){if(c.destroyed)throw new Error("Hash instance has been destroyed");if(t&&c.finished)throw new Error("Hash#digest() has already been called")}function aoutput(c,t){abytes(c);const n=t.outputLen;if(c.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function clean(...c){for(let t=0;t<c.length;t++)c[t].fill(0)}function createView(c){return new DataView(c.buffer,c.byteOffset,c.byteLength)}function rotr(c,t){return c<<32-t|c>>>t}const hasHexBuiltin=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",hexes=Array.from({length:256},(c,t)=>t.toString(16).padStart(2,"0"));function bytesToHex(c){if(abytes(c),hasHexBuiltin)return c.toHex();let t="";for(let n=0;n<c.length;n++)t+=hexes[c[n]];return t}const asciis={_0:48,_9:57,A:65,F:70,a:97,f:102};function asciiToBase16(c){if(c>=asciis._0&&c<=asciis._9)return c-asciis._0;if(c>=asciis.A&&c<=asciis.F)return c-(asciis.A-10);if(c>=asciis.a&&c<=asciis.f)return c-(asciis.a-10)}function hexToBytes(c){if(typeof c!="string")throw new Error("hex string expected, got "+typeof c);if(hasHexBuiltin)return Uint8Array.fromHex(c);const t=c.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const ie=new Uint8Array(n);for(let fe=0,ae=0;fe<n;fe++,ae+=2){const le=asciiToBase16(c.charCodeAt(ae)),he=asciiToBase16(c.charCodeAt(ae+1));if(le===void 0||he===void 0){const ye=c[ae]+c[ae+1];throw new Error('hex string expected, got non-hex character "'+ye+'" at index '+ae)}ie[fe]=le*16+he}return ie}function utf8ToBytes(c){if(typeof c!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(c))}function toBytes(c){return typeof c=="string"&&(c=utf8ToBytes(c)),abytes(c),c}function concatBytes(...c){let t=0;for(let ie=0;ie<c.length;ie++){const fe=c[ie];abytes(fe),t+=fe.length}const n=new Uint8Array(t);for(let ie=0,fe=0;ie<c.length;ie++){const ae=c[ie];n.set(ae,fe),fe+=ae.length}return n}class Hash{}function createHasher(c){const t=ie=>c().update(toBytes(ie)).digest(),n=c();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>c(),t}function randomBytes(c=32){if(crypto$2&&typeof crypto$2.getRandomValues=="function")return crypto$2.getRandomValues(new Uint8Array(c));if(crypto$2&&typeof crypto$2.randomBytes=="function")return Uint8Array.from(crypto$2.randomBytes(c));throw new Error("crypto.getRandomValues must be defined")}function setBigUint64(c,t,n,ie){if(typeof c.setBigUint64=="function")return c.setBigUint64(t,n,ie);const fe=BigInt(32),ae=BigInt(4294967295),le=Number(n>>fe&ae),he=Number(n&ae),ye=ie?4:0,me=ie?0:4;c.setUint32(t+ye,le,ie),c.setUint32(t+me,he,ie)}function Chi(c,t,n){return c&t^~c&n}function Maj(c,t,n){return c&t^c&n^t&n}class HashMD extends Hash{constructor(t,n,ie,fe){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=n,this.padOffset=ie,this.isLE=fe,this.buffer=new Uint8Array(t),this.view=createView(this.buffer)}update(t){aexists(this),t=toBytes(t),abytes(t);const{view:n,buffer:ie,blockLen:fe}=this,ae=t.length;for(let le=0;le<ae;){const he=Math.min(fe-this.pos,ae-le);if(he===fe){const ye=createView(t);for(;fe<=ae-le;le+=fe)this.process(ye,le);continue}ie.set(t.subarray(le,le+he),this.pos),this.pos+=he,le+=he,this.pos===fe&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){aexists(this),aoutput(t,this),this.finished=!0;const{buffer:n,view:ie,blockLen:fe,isLE:ae}=this;let{pos:le}=this;n[le++]=128,clean(this.buffer.subarray(le)),this.padOffset>fe-le&&(this.process(ie,0),le=0);for(let Ee=le;Ee<fe;Ee++)n[Ee]=0;setBigUint64(ie,fe-8,BigInt(this.length*8),ae),this.process(ie,0);const he=createView(t),ye=this.outputLen;if(ye%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const me=ye/4,xe=this.get();if(me>xe.length)throw new Error("_sha2: outputLen bigger than state");for(let Ee=0;Ee<me;Ee++)he.setUint32(4*Ee,xe[Ee],ae)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const ie=t.slice(0,n);return this.destroy(),ie}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:ie,length:fe,finished:ae,destroyed:le,pos:he}=this;return t.destroyed=le,t.finished=ae,t.length=fe,t.pos=he,fe%n&&t.buffer.set(ie),t}clone(){return this._cloneInto()}}const SHA256_IV=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),SHA512_IV=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),U32_MASK64=BigInt(2**32-1),_32n=BigInt(32);function fromBig(c,t=!1){return t?{h:Number(c&U32_MASK64),l:Number(c>>_32n&U32_MASK64)}:{h:Number(c>>_32n&U32_MASK64)|0,l:Number(c&U32_MASK64)|0}}function split(c,t=!1){const n=c.length;let ie=new Uint32Array(n),fe=new Uint32Array(n);for(let ae=0;ae<n;ae++){const{h:le,l:he}=fromBig(c[ae],t);[ie[ae],fe[ae]]=[le,he]}return[ie,fe]}const shrSH=(c,t,n)=>c>>>n,shrSL=(c,t,n)=>c<<32-n|t>>>n,rotrSH=(c,t,n)=>c>>>n|t<<32-n,rotrSL=(c,t,n)=>c<<32-n|t>>>n,rotrBH=(c,t,n)=>c<<64-n|t>>>n-32,rotrBL=(c,t,n)=>c>>>n-32|t<<64-n;function add(c,t,n,ie){const fe=(t>>>0)+(ie>>>0);return{h:c+n+(fe/2**32|0)|0,l:fe|0}}const add3L=(c,t,n)=>(c>>>0)+(t>>>0)+(n>>>0),add3H=(c,t,n,ie)=>t+n+ie+(c/2**32|0)|0,add4L=(c,t,n,ie)=>(c>>>0)+(t>>>0)+(n>>>0)+(ie>>>0),add4H=(c,t,n,ie,fe)=>t+n+ie+fe+(c/2**32|0)|0,add5L=(c,t,n,ie,fe)=>(c>>>0)+(t>>>0)+(n>>>0)+(ie>>>0)+(fe>>>0),add5H=(c,t,n,ie,fe,ae)=>t+n+ie+fe+ae+(c/2**32|0)|0,SHA256_K=Uint32Array.from([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]),SHA256_W=new Uint32Array(64);class SHA256 extends HashMD{constructor(t=32){super(64,t,8,!1),this.A=SHA256_IV[0]|0,this.B=SHA256_IV[1]|0,this.C=SHA256_IV[2]|0,this.D=SHA256_IV[3]|0,this.E=SHA256_IV[4]|0,this.F=SHA256_IV[5]|0,this.G=SHA256_IV[6]|0,this.H=SHA256_IV[7]|0}get(){const{A:t,B:n,C:ie,D:fe,E:ae,F:le,G:he,H:ye}=this;return[t,n,ie,fe,ae,le,he,ye]}set(t,n,ie,fe,ae,le,he,ye){this.A=t|0,this.B=n|0,this.C=ie|0,this.D=fe|0,this.E=ae|0,this.F=le|0,this.G=he|0,this.H=ye|0}process(t,n){for(let Ee=0;Ee<16;Ee++,n+=4)SHA256_W[Ee]=t.getUint32(n,!1);for(let Ee=16;Ee<64;Ee++){const Se=SHA256_W[Ee-15],Me=SHA256_W[Ee-2],Be=rotr(Se,7)^rotr(Se,18)^Se>>>3,$e=rotr(Me,17)^rotr(Me,19)^Me>>>10;SHA256_W[Ee]=$e+SHA256_W[Ee-7]+Be+SHA256_W[Ee-16]|0}let{A:ie,B:fe,C:ae,D:le,E:he,F:ye,G:me,H:xe}=this;for(let Ee=0;Ee<64;Ee++){const Se=rotr(he,6)^rotr(he,11)^rotr(he,25),Me=xe+Se+Chi(he,ye,me)+SHA256_K[Ee]+SHA256_W[Ee]|0,$e=(rotr(ie,2)^rotr(ie,13)^rotr(ie,22))+Maj(ie,fe,ae)|0;xe=me,me=ye,ye=he,he=le+Me|0,le=ae,ae=fe,fe=ie,ie=Me+$e|0}ie=ie+this.A|0,fe=fe+this.B|0,ae=ae+this.C|0,le=le+this.D|0,he=he+this.E|0,ye=ye+this.F|0,me=me+this.G|0,xe=xe+this.H|0,this.set(ie,fe,ae,le,he,ye,me,xe)}roundClean(){clean(SHA256_W)}destroy(){this.set(0,0,0,0,0,0,0,0),clean(this.buffer)}}const K512=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(c=>BigInt(c))),SHA512_Kh=K512[0],SHA512_Kl=K512[1],SHA512_W_H=new Uint32Array(80),SHA512_W_L=new Uint32Array(80);class SHA512 extends HashMD{constructor(t=64){super(128,t,16,!1),this.Ah=SHA512_IV[0]|0,this.Al=SHA512_IV[1]|0,this.Bh=SHA512_IV[2]|0,this.Bl=SHA512_IV[3]|0,this.Ch=SHA512_IV[4]|0,this.Cl=SHA512_IV[5]|0,this.Dh=SHA512_IV[6]|0,this.Dl=SHA512_IV[7]|0,this.Eh=SHA512_IV[8]|0,this.El=SHA512_IV[9]|0,this.Fh=SHA512_IV[10]|0,this.Fl=SHA512_IV[11]|0,this.Gh=SHA512_IV[12]|0,this.Gl=SHA512_IV[13]|0,this.Hh=SHA512_IV[14]|0,this.Hl=SHA512_IV[15]|0}get(){const{Ah:t,Al:n,Bh:ie,Bl:fe,Ch:ae,Cl:le,Dh:he,Dl:ye,Eh:me,El:xe,Fh:Ee,Fl:Se,Gh:Me,Gl:Be,Hh:$e,Hl:Ce}=this;return[t,n,ie,fe,ae,le,he,ye,me,xe,Ee,Se,Me,Be,$e,Ce]}set(t,n,ie,fe,ae,le,he,ye,me,xe,Ee,Se,Me,Be,$e,Ce){this.Ah=t|0,this.Al=n|0,this.Bh=ie|0,this.Bl=fe|0,this.Ch=ae|0,this.Cl=le|0,this.Dh=he|0,this.Dl=ye|0,this.Eh=me|0,this.El=xe|0,this.Fh=Ee|0,this.Fl=Se|0,this.Gh=Me|0,this.Gl=Be|0,this.Hh=$e|0,this.Hl=Ce|0}process(t,n){for(let Ue=0;Ue<16;Ue++,n+=4)SHA512_W_H[Ue]=t.getUint32(n),SHA512_W_L[Ue]=t.getUint32(n+=4);for(let Ue=16;Ue<80;Ue++){const qe=SHA512_W_H[Ue-15]|0,He=SHA512_W_L[Ue-15]|0,Ve=rotrSH(qe,He,1)^rotrSH(qe,He,8)^shrSH(qe,He,7),Ye=rotrSL(qe,He,1)^rotrSL(qe,He,8)^shrSL(qe,He,7),Qe=SHA512_W_H[Ue-2]|0,Ke=SHA512_W_L[Ue-2]|0,Pt=rotrSH(Qe,Ke,19)^rotrBH(Qe,Ke,61)^shrSH(Qe,Ke,6),_e=rotrSL(Qe,Ke,19)^rotrBL(Qe,Ke,61)^shrSL(Qe,Ke,6),se=add4L(Ye,_e,SHA512_W_L[Ue-7],SHA512_W_L[Ue-16]),ce=add4H(se,Ve,Pt,SHA512_W_H[Ue-7],SHA512_W_H[Ue-16]);SHA512_W_H[Ue]=ce|0,SHA512_W_L[Ue]=se|0}let{Ah:ie,Al:fe,Bh:ae,Bl:le,Ch:he,Cl:ye,Dh:me,Dl:xe,Eh:Ee,El:Se,Fh:Me,Fl:Be,Gh:$e,Gl:Ce,Hh:ke,Hl:Pe}=this;for(let Ue=0;Ue<80;Ue++){const qe=rotrSH(Ee,Se,14)^rotrSH(Ee,Se,18)^rotrBH(Ee,Se,41),He=rotrSL(Ee,Se,14)^rotrSL(Ee,Se,18)^rotrBL(Ee,Se,41),Ve=Ee&Me^~Ee&$e,Ye=Se&Be^~Se&Ce,Qe=add5L(Pe,He,Ye,SHA512_Kl[Ue],SHA512_W_L[Ue]),Ke=add5H(Qe,ke,qe,Ve,SHA512_Kh[Ue],SHA512_W_H[Ue]),Pt=Qe|0,_e=rotrSH(ie,fe,28)^rotrBH(ie,fe,34)^rotrBH(ie,fe,39),se=rotrSL(ie,fe,28)^rotrBL(ie,fe,34)^rotrBL(ie,fe,39),ce=ie&ae^ie&he^ae&he,de=fe&le^fe&ye^le&ye;ke=$e|0,Pe=Ce|0,$e=Me|0,Ce=Be|0,Me=Ee|0,Be=Se|0,{h:Ee,l:Se}=add(me|0,xe|0,Ke|0,Pt|0),me=he|0,xe=ye|0,he=ae|0,ye=le|0,ae=ie|0,le=fe|0;const pe=add3L(Pt,se,de);ie=add3H(pe,Ke,_e,ce),fe=pe|0}({h:ie,l:fe}=add(this.Ah|0,this.Al|0,ie|0,fe|0)),{h:ae,l:le}=add(this.Bh|0,this.Bl|0,ae|0,le|0),{h:he,l:ye}=add(this.Ch|0,this.Cl|0,he|0,ye|0),{h:me,l:xe}=add(this.Dh|0,this.Dl|0,me|0,xe|0),{h:Ee,l:Se}=add(this.Eh|0,this.El|0,Ee|0,Se|0),{h:Me,l:Be}=add(this.Fh|0,this.Fl|0,Me|0,Be|0),{h:$e,l:Ce}=add(this.Gh|0,this.Gl|0,$e|0,Ce|0),{h:ke,l:Pe}=add(this.Hh|0,this.Hl|0,ke|0,Pe|0),this.set(ie,fe,ae,le,he,ye,me,xe,Ee,Se,Me,Be,$e,Ce,ke,Pe)}roundClean(){clean(SHA512_W_H,SHA512_W_L)}destroy(){clean(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const sha256$5=createHasher(()=>new SHA256),sha512$3=createHasher(()=>new SHA512);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$4=BigInt(0),_1n$5=BigInt(1);function _abool2(c,t=""){if(typeof c!="boolean"){const n=t&&`"${t}"`;throw new Error(n+"expected boolean, got type="+typeof c)}return c}function _abytes2(c,t,n=""){const ie=isBytes(c),fe=c==null?void 0:c.length,ae=t!==void 0;if(!ie||ae&&fe!==t){const le=n&&`"${n}" `,he=ae?` of length ${t}`:"",ye=ie?`length=${fe}`:`type=${typeof c}`;throw new Error(le+"expected Uint8Array"+he+", got "+ye)}return c}function numberToHexUnpadded(c){const t=c.toString(16);return t.length&1?"0"+t:t}function hexToNumber(c){if(typeof c!="string")throw new Error("hex string expected, got "+typeof c);return c===""?_0n$4:BigInt("0x"+c)}function bytesToNumberBE(c){return hexToNumber(bytesToHex(c))}function bytesToNumberLE(c){return abytes(c),hexToNumber(bytesToHex(Uint8Array.from(c).reverse()))}function numberToBytesBE(c,t){return hexToBytes(c.toString(16).padStart(t*2,"0"))}function numberToBytesLE(c,t){return numberToBytesBE(c,t).reverse()}function ensureBytes(c,t,n){let ie;if(typeof t=="string")try{ie=hexToBytes(t)}catch(ae){throw new Error(c+" must be hex string or Uint8Array, cause: "+ae)}else if(isBytes(t))ie=Uint8Array.from(t);else throw new Error(c+" must be hex string or Uint8Array");const fe=ie.length;if(typeof n=="number"&&fe!==n)throw new Error(c+" of length "+n+" expected, got "+fe);return ie}function copyBytes(c){return Uint8Array.from(c)}const isPosBig=c=>typeof c=="bigint"&&_0n$4<=c;function inRange$1(c,t,n){return isPosBig(c)&&isPosBig(t)&&isPosBig(n)&&t<=c&&c<n}function aInRange(c,t,n,ie){if(!inRange$1(t,n,ie))throw new Error("expected valid "+c+": "+n+" <= n < "+ie+", got "+t)}function bitLen(c){let t;for(t=0;c>_0n$4;c>>=_1n$5,t+=1);return t}const bitMask=c=>(_1n$5<<BigInt(c))-_1n$5;function createHmacDrbg(c,t,n){if(typeof c!="number"||c<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");const ie=Me=>new Uint8Array(Me),fe=Me=>Uint8Array.of(Me);let ae=ie(c),le=ie(c),he=0;const ye=()=>{ae.fill(1),le.fill(0),he=0},me=(...Me)=>n(le,ae,...Me),xe=(Me=ie(0))=>{le=me(fe(0),Me),ae=me(),Me.length!==0&&(le=me(fe(1),Me),ae=me())},Ee=()=>{if(he++>=1e3)throw new Error("drbg: tried 1000 values");let Me=0;const Be=[];for(;Me<t;){ae=me();const $e=ae.slice();Be.push($e),Me+=ae.length}return concatBytes(...Be)};return(Me,Be)=>{ye(),xe(Me);let $e;for(;!($e=Be(Ee()));)xe();return ye(),$e}}function _validateObject(c,t,n={}){if(!c||typeof c!="object")throw new Error("expected valid options object");function ie(fe,ae,le){const he=c[fe];if(le&&he===void 0)return;const ye=typeof he;if(ye!==ae||he===null)throw new Error(`param "${fe}" is invalid: expected ${ae}, got ${ye}`)}Object.entries(t).forEach(([fe,ae])=>ie(fe,ae,!1)),Object.entries(n).forEach(([fe,ae])=>ie(fe,ae,!0))}function memoized(c){const t=new WeakMap;return(n,...ie)=>{const fe=t.get(n);if(fe!==void 0)return fe;const ae=c(n,...ie);return t.set(n,ae),ae}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$3=BigInt(0),_1n$4=BigInt(1),_2n$4=BigInt(2),_3n$1=BigInt(3),_4n$1=BigInt(4),_5n$1=BigInt(5),_7n=BigInt(7),_8n$2=BigInt(8),_9n=BigInt(9),_16n=BigInt(16);function mod(c,t){const n=c%t;return n>=_0n$3?n:t+n}function pow2(c,t,n){let ie=c;for(;t-- >_0n$3;)ie*=ie,ie%=n;return ie}function invert(c,t){if(c===_0n$3)throw new Error("invert: expected non-zero number");if(t<=_0n$3)throw new Error("invert: expected positive modulus, got "+t);let n=mod(c,t),ie=t,fe=_0n$3,ae=_1n$4;for(;n!==_0n$3;){const he=ie/n,ye=ie%n,me=fe-ae*he;ie=n,n=ye,fe=ae,ae=me}if(ie!==_1n$4)throw new Error("invert: does not exist");return mod(fe,t)}function assertIsSquare(c,t,n){if(!c.eql(c.sqr(t),n))throw new Error("Cannot find square root")}function sqrt3mod4(c,t){const n=(c.ORDER+_1n$4)/_4n$1,ie=c.pow(t,n);return assertIsSquare(c,ie,t),ie}function sqrt5mod8(c,t){const n=(c.ORDER-_5n$1)/_8n$2,ie=c.mul(t,_2n$4),fe=c.pow(ie,n),ae=c.mul(t,fe),le=c.mul(c.mul(ae,_2n$4),fe),he=c.mul(ae,c.sub(le,c.ONE));return assertIsSquare(c,he,t),he}function sqrt9mod16(c){const t=Field(c),n=tonelliShanks(c),ie=n(t,t.neg(t.ONE)),fe=n(t,ie),ae=n(t,t.neg(ie)),le=(c+_7n)/_16n;return(he,ye)=>{let me=he.pow(ye,le),xe=he.mul(me,ie);const Ee=he.mul(me,fe),Se=he.mul(me,ae),Me=he.eql(he.sqr(xe),ye),Be=he.eql(he.sqr(Ee),ye);me=he.cmov(me,xe,Me),xe=he.cmov(Se,Ee,Be);const $e=he.eql(he.sqr(xe),ye),Ce=he.cmov(me,xe,$e);return assertIsSquare(he,Ce,ye),Ce}}function tonelliShanks(c){if(c<_3n$1)throw new Error("sqrt is not defined for small field");let t=c-_1n$4,n=0;for(;t%_2n$4===_0n$3;)t/=_2n$4,n++;let ie=_2n$4;const fe=Field(c);for(;FpLegendre(fe,ie)===1;)if(ie++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return sqrt3mod4;let ae=fe.pow(ie,t);const le=(t+_1n$4)/_2n$4;return function(ye,me){if(ye.is0(me))return me;if(FpLegendre(ye,me)!==1)throw new Error("Cannot find square root");let xe=n,Ee=ye.mul(ye.ONE,ae),Se=ye.pow(me,t),Me=ye.pow(me,le);for(;!ye.eql(Se,ye.ONE);){if(ye.is0(Se))return ye.ZERO;let Be=1,$e=ye.sqr(Se);for(;!ye.eql($e,ye.ONE);)if(Be++,$e=ye.sqr($e),Be===xe)throw new Error("Cannot find square root");const Ce=_1n$4<<BigInt(xe-Be-1),ke=ye.pow(Ee,Ce);xe=Be,Ee=ye.sqr(ke),Se=ye.mul(Se,Ee),Me=ye.mul(Me,ke)}return Me}}function FpSqrt(c){return c%_4n$1===_3n$1?sqrt3mod4:c%_8n$2===_5n$1?sqrt5mod8:c%_16n===_9n?sqrt9mod16(c):tonelliShanks(c)}const isNegativeLE=(c,t)=>(mod(c,t)&_1n$4)===_1n$4,FIELD_FIELDS=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function validateField(c){const t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},n=FIELD_FIELDS.reduce((ie,fe)=>(ie[fe]="function",ie),t);return _validateObject(c,n),c}function FpPow(c,t,n){if(n<_0n$3)throw new Error("invalid exponent, negatives unsupported");if(n===_0n$3)return c.ONE;if(n===_1n$4)return t;let ie=c.ONE,fe=t;for(;n>_0n$3;)n&_1n$4&&(ie=c.mul(ie,fe)),fe=c.sqr(fe),n>>=_1n$4;return ie}function FpInvertBatch(c,t,n=!1){const ie=new Array(t.length).fill(n?c.ZERO:void 0),fe=t.reduce((le,he,ye)=>c.is0(he)?le:(ie[ye]=le,c.mul(le,he)),c.ONE),ae=c.inv(fe);return t.reduceRight((le,he,ye)=>c.is0(he)?le:(ie[ye]=c.mul(le,ie[ye]),c.mul(le,he)),ae),ie}function FpLegendre(c,t){const n=(c.ORDER-_1n$4)/_2n$4,ie=c.pow(t,n),fe=c.eql(ie,c.ONE),ae=c.eql(ie,c.ZERO),le=c.eql(ie,c.neg(c.ONE));if(!fe&&!ae&&!le)throw new Error("invalid Legendre symbol result");return fe?1:ae?0:-1}function nLength(c,t){t!==void 0&&anumber(t);const n=t!==void 0?t:c.toString(2).length,ie=Math.ceil(n/8);return{nBitLength:n,nByteLength:ie}}function Field(c,t,n=!1,ie={}){if(c<=_0n$3)throw new Error("invalid field: expected ORDER > 0, got "+c);let fe,ae,le=!1,he;if(typeof t=="object"&&t!=null){if(ie.sqrt||n)throw new Error("cannot specify opts in two arguments");const Se=t;Se.BITS&&(fe=Se.BITS),Se.sqrt&&(ae=Se.sqrt),typeof Se.isLE=="boolean"&&(n=Se.isLE),typeof Se.modFromBytes=="boolean"&&(le=Se.modFromBytes),he=Se.allowedLengths}else typeof t=="number"&&(fe=t),ie.sqrt&&(ae=ie.sqrt);const{nBitLength:ye,nByteLength:me}=nLength(c,fe);if(me>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let xe;const Ee=Object.freeze({ORDER:c,isLE:n,BITS:ye,BYTES:me,MASK:bitMask(ye),ZERO:_0n$3,ONE:_1n$4,allowedLengths:he,create:Se=>mod(Se,c),isValid:Se=>{if(typeof Se!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof Se);return _0n$3<=Se&&Se<c},is0:Se=>Se===_0n$3,isValidNot0:Se=>!Ee.is0(Se)&&Ee.isValid(Se),isOdd:Se=>(Se&_1n$4)===_1n$4,neg:Se=>mod(-Se,c),eql:(Se,Me)=>Se===Me,sqr:Se=>mod(Se*Se,c),add:(Se,Me)=>mod(Se+Me,c),sub:(Se,Me)=>mod(Se-Me,c),mul:(Se,Me)=>mod(Se*Me,c),pow:(Se,Me)=>FpPow(Ee,Se,Me),div:(Se,Me)=>mod(Se*invert(Me,c),c),sqrN:Se=>Se*Se,addN:(Se,Me)=>Se+Me,subN:(Se,Me)=>Se-Me,mulN:(Se,Me)=>Se*Me,inv:Se=>invert(Se,c),sqrt:ae||(Se=>(xe||(xe=FpSqrt(c)),xe(Ee,Se))),toBytes:Se=>n?numberToBytesLE(Se,me):numberToBytesBE(Se,me),fromBytes:(Se,Me=!0)=>{if(he){if(!he.includes(Se.length)||Se.length>me)throw new Error("Field.fromBytes: expected "+he+" bytes, got "+Se.length);const $e=new Uint8Array(me);$e.set(Se,n?0:$e.length-Se.length),Se=$e}if(Se.length!==me)throw new Error("Field.fromBytes: expected "+me+" bytes, got "+Se.length);let Be=n?bytesToNumberLE(Se):bytesToNumberBE(Se);if(le&&(Be=mod(Be,c)),!Me&&!Ee.isValid(Be))throw new Error("invalid field element: outside of range 0..ORDER");return Be},invertBatch:Se=>FpInvertBatch(Ee,Se),cmov:(Se,Me,Be)=>Be?Me:Se});return Object.freeze(Ee)}function getFieldBytesLength(c){if(typeof c!="bigint")throw new Error("field order must be bigint");const t=c.toString(2).length;return Math.ceil(t/8)}function getMinHashLength(c){const t=getFieldBytesLength(c);return t+Math.ceil(t/2)}function mapHashToField(c,t,n=!1){const ie=c.length,fe=getFieldBytesLength(t),ae=getMinHashLength(t);if(ie<16||ie<ae||ie>1024)throw new Error("expected "+ae+"-1024 bytes of input, got "+ie);const le=n?bytesToNumberLE(c):bytesToNumberBE(c),he=mod(le,t-_1n$4)+_1n$4;return n?numberToBytesLE(he,fe):numberToBytesBE(he,fe)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$2=BigInt(0),_1n$3=BigInt(1);function negateCt(c,t){const n=t.negate();return c?n:t}function normalizeZ(c,t){const n=FpInvertBatch(c.Fp,t.map(ie=>ie.Z));return t.map((ie,fe)=>c.fromAffine(ie.toAffine(n[fe])))}function validateW(c,t){if(!Number.isSafeInteger(c)||c<=0||c>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+c)}function calcWOpts(c,t){validateW(c,t);const n=Math.ceil(t/c)+1,ie=2**(c-1),fe=2**c,ae=bitMask(c),le=BigInt(c);return{windows:n,windowSize:ie,mask:ae,maxNumber:fe,shiftBy:le}}function calcOffsets(c,t,n){const{windowSize:ie,mask:fe,maxNumber:ae,shiftBy:le}=n;let he=Number(c&fe),ye=c>>le;he>ie&&(he-=ae,ye+=_1n$3);const me=t*ie,xe=me+Math.abs(he)-1,Ee=he===0,Se=he<0,Me=t%2!==0;return{nextN:ye,offset:xe,isZero:Ee,isNeg:Se,isNegF:Me,offsetF:me}}function validateMSMPoints(c,t){if(!Array.isArray(c))throw new Error("array expected");c.forEach((n,ie)=>{if(!(n instanceof t))throw new Error("invalid point at index "+ie)})}function validateMSMScalars(c,t){if(!Array.isArray(c))throw new Error("array of scalars expected");c.forEach((n,ie)=>{if(!t.isValid(n))throw new Error("invalid scalar at index "+ie)})}const pointPrecomputes=new WeakMap,pointWindowSizes=new WeakMap;function getW(c){return pointWindowSizes.get(c)||1}function assert0(c){if(c!==_0n$2)throw new Error("invalid wNAF")}class wNAF{constructor(t,n){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=n}_unsafeLadder(t,n,ie=this.ZERO){let fe=t;for(;n>_0n$2;)n&_1n$3&&(ie=ie.add(fe)),fe=fe.double(),n>>=_1n$3;return ie}precomputeWindow(t,n){const{windows:ie,windowSize:fe}=calcWOpts(n,this.bits),ae=[];let le=t,he=le;for(let ye=0;ye<ie;ye++){he=le,ae.push(he);for(let me=1;me<fe;me++)he=he.add(le),ae.push(he);le=he.double()}return ae}wNAF(t,n,ie){if(!this.Fn.isValid(ie))throw new Error("invalid scalar");let fe=this.ZERO,ae=this.BASE;const le=calcWOpts(t,this.bits);for(let he=0;he<le.windows;he++){const{nextN:ye,offset:me,isZero:xe,isNeg:Ee,isNegF:Se,offsetF:Me}=calcOffsets(ie,he,le);ie=ye,xe?ae=ae.add(negateCt(Se,n[Me])):fe=fe.add(negateCt(Ee,n[me]))}return assert0(ie),{p:fe,f:ae}}wNAFUnsafe(t,n,ie,fe=this.ZERO){const ae=calcWOpts(t,this.bits);for(let le=0;le<ae.windows&&ie!==_0n$2;le++){const{nextN:he,offset:ye,isZero:me,isNeg:xe}=calcOffsets(ie,le,ae);if(ie=he,!me){const Ee=n[ye];fe=fe.add(xe?Ee.negate():Ee)}}return assert0(ie),fe}getPrecomputes(t,n,ie){let fe=pointPrecomputes.get(n);return fe||(fe=this.precomputeWindow(n,t),t!==1&&(typeof ie=="function"&&(fe=ie(fe)),pointPrecomputes.set(n,fe))),fe}cached(t,n,ie){const fe=getW(t);return this.wNAF(fe,this.getPrecomputes(fe,t,ie),n)}unsafe(t,n,ie,fe){const ae=getW(t);return ae===1?this._unsafeLadder(t,n,fe):this.wNAFUnsafe(ae,this.getPrecomputes(ae,t,ie),n,fe)}createCache(t,n){validateW(n,this.bits),pointWindowSizes.set(t,n),pointPrecomputes.delete(t)}hasCache(t){return getW(t)!==1}}function mulEndoUnsafe(c,t,n,ie){let fe=t,ae=c.ZERO,le=c.ZERO;for(;n>_0n$2||ie>_0n$2;)n&_1n$3&&(ae=ae.add(fe)),ie&_1n$3&&(le=le.add(fe)),fe=fe.double(),n>>=_1n$3,ie>>=_1n$3;return{p1:ae,p2:le}}function pippenger(c,t,n,ie){validateMSMPoints(n,c),validateMSMScalars(ie,t);const fe=n.length,ae=ie.length;if(fe!==ae)throw new Error("arrays of points and scalars must have equal length");const le=c.ZERO,he=bitLen(BigInt(fe));let ye=1;he>12?ye=he-3:he>4?ye=he-2:he>0&&(ye=2);const me=bitMask(ye),xe=new Array(Number(me)+1).fill(le),Ee=Math.floor((t.BITS-1)/ye)*ye;let Se=le;for(let Me=Ee;Me>=0;Me-=ye){xe.fill(le);for(let $e=0;$e<ae;$e++){const Ce=ie[$e],ke=Number(Ce>>BigInt(Me)&me);xe[ke]=xe[ke].add(n[$e])}let Be=le;for(let $e=xe.length-1,Ce=le;$e>0;$e--)Ce=Ce.add(xe[$e]),Be=Be.add(Ce);if(Se=Se.add(Be),Me!==0)for(let $e=0;$e<ye;$e++)Se=Se.double()}return Se}function createField(c,t,n){if(t){if(t.ORDER!==c)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return validateField(t),t}else return Field(c,{isLE:n})}function _createCurveFields(c,t,n={},ie){if(ie===void 0&&(ie=c==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${c} CURVE object`);for(const ye of["p","n","h"]){const me=t[ye];if(!(typeof me=="bigint"&&me>_0n$2))throw new Error(`CURVE.${ye} must be positive bigint`)}const fe=createField(t.p,n.Fp,ie),ae=createField(t.n,n.Fn,ie),he=["Gx","Gy","a",c==="weierstrass"?"b":"d"];for(const ye of he)if(!fe.isValid(t[ye]))throw new Error(`CURVE.${ye} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:fe,Fn:ae}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _0n$1=BigInt(0),_1n$2=BigInt(1),_2n$3=BigInt(2),_8n$1=BigInt(8);function isEdValidXY(c,t,n,ie){const fe=c.sqr(n),ae=c.sqr(ie),le=c.add(c.mul(t.a,fe),ae),he=c.add(c.ONE,c.mul(t.d,c.mul(fe,ae)));return c.eql(le,he)}function edwards$1(c,t={}){const n=_createCurveFields("edwards",c,t,t.FpFnLE),{Fp:ie,Fn:fe}=n;let ae=n.CURVE;const{h:le}=ae;_validateObject(t,{},{uvRatio:"function"});const he=_2n$3<<BigInt(fe.BYTES*8)-_1n$2,ye=Ce=>ie.create(Ce),me=t.uvRatio||((Ce,ke)=>{try{return{isValid:!0,value:ie.sqrt(ie.div(Ce,ke))}}catch{return{isValid:!1,value:_0n$1}}});if(!isEdValidXY(ie,ae,ae.Gx,ae.Gy))throw new Error("bad curve params: generator point");function xe(Ce,ke,Pe=!1){const Ue=Pe?_1n$2:_0n$1;return aInRange("coordinate "+Ce,ke,Ue,he),ke}function Ee(Ce){if(!(Ce instanceof Be))throw new Error("ExtendedPoint expected")}const Se=memoized((Ce,ke)=>{const{X:Pe,Y:Ue,Z:qe}=Ce,He=Ce.is0();ke==null&&(ke=He?_8n$1:ie.inv(qe));const Ve=ye(Pe*ke),Ye=ye(Ue*ke),Qe=ie.mul(qe,ke);if(He)return{x:_0n$1,y:_1n$2};if(Qe!==_1n$2)throw new Error("invZ was invalid");return{x:Ve,y:Ye}}),Me=memoized(Ce=>{const{a:ke,d:Pe}=ae;if(Ce.is0())throw new Error("bad point: ZERO");const{X:Ue,Y:qe,Z:He,T:Ve}=Ce,Ye=ye(Ue*Ue),Qe=ye(qe*qe),Ke=ye(He*He),Pt=ye(Ke*Ke),_e=ye(Ye*ke),se=ye(Ke*ye(_e+Qe)),ce=ye(Pt+ye(Pe*ye(Ye*Qe)));if(se!==ce)throw new Error("bad point: equation left != right (1)");const de=ye(Ue*qe),pe=ye(He*Ve);if(de!==pe)throw new Error("bad point: equation left != right (2)");return!0});class Be{constructor(ke,Pe,Ue,qe){this.X=xe("x",ke),this.Y=xe("y",Pe),this.Z=xe("z",Ue,!0),this.T=xe("t",qe),Object.freeze(this)}static CURVE(){return ae}static fromAffine(ke){if(ke instanceof Be)throw new Error("extended point not allowed");const{x:Pe,y:Ue}=ke||{};return xe("x",Pe),xe("y",Ue),new Be(Pe,Ue,_1n$2,ye(Pe*Ue))}static fromBytes(ke,Pe=!1){const Ue=ie.BYTES,{a:qe,d:He}=ae;ke=copyBytes(_abytes2(ke,Ue,"point")),_abool2(Pe,"zip215");const Ve=copyBytes(ke),Ye=ke[Ue-1];Ve[Ue-1]=Ye&-129;const Qe=bytesToNumberLE(Ve),Ke=Pe?he:ie.ORDER;aInRange("point.y",Qe,_0n$1,Ke);const Pt=ye(Qe*Qe),_e=ye(Pt-_1n$2),se=ye(He*Pt-qe);let{isValid:ce,value:de}=me(_e,se);if(!ce)throw new Error("bad point: invalid y coordinate");const pe=(de&_1n$2)===_1n$2,ve=(Ye&128)!==0;if(!Pe&&de===_0n$1&&ve)throw new Error("bad point: x=0 and x_0=1");return ve!==pe&&(de=ye(-de)),Be.fromAffine({x:de,y:Qe})}static fromHex(ke,Pe=!1){return Be.fromBytes(ensureBytes("point",ke),Pe)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(ke=8,Pe=!0){return $e.createCache(this,ke),Pe||this.multiply(_2n$3),this}assertValidity(){Me(this)}equals(ke){Ee(ke);const{X:Pe,Y:Ue,Z:qe}=this,{X:He,Y:Ve,Z:Ye}=ke,Qe=ye(Pe*Ye),Ke=ye(He*qe),Pt=ye(Ue*Ye),_e=ye(Ve*qe);return Qe===Ke&&Pt===_e}is0(){return this.equals(Be.ZERO)}negate(){return new Be(ye(-this.X),this.Y,this.Z,ye(-this.T))}double(){const{a:ke}=ae,{X:Pe,Y:Ue,Z:qe}=this,He=ye(Pe*Pe),Ve=ye(Ue*Ue),Ye=ye(_2n$3*ye(qe*qe)),Qe=ye(ke*He),Ke=Pe+Ue,Pt=ye(ye(Ke*Ke)-He-Ve),_e=Qe+Ve,se=_e-Ye,ce=Qe-Ve,de=ye(Pt*se),pe=ye(_e*ce),ve=ye(Pt*ce),we=ye(se*_e);return new Be(de,pe,we,ve)}add(ke){Ee(ke);const{a:Pe,d:Ue}=ae,{X:qe,Y:He,Z:Ve,T:Ye}=this,{X:Qe,Y:Ke,Z:Pt,T:_e}=ke,se=ye(qe*Qe),ce=ye(He*Ke),de=ye(Ye*Ue*_e),pe=ye(Ve*Pt),ve=ye((qe+He)*(Qe+Ke)-se-ce),we=pe-de,Ae=pe+de,ge=ye(ce-Pe*se),ue=ye(ve*we),be=ye(Ae*ge),Re=ye(ve*ge),Ne=ye(we*Ae);return new Be(ue,be,Ne,Re)}subtract(ke){return this.add(ke.negate())}multiply(ke){if(!fe.isValidNot0(ke))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:Pe,f:Ue}=$e.cached(this,ke,qe=>normalizeZ(Be,qe));return normalizeZ(Be,[Pe,Ue])[0]}multiplyUnsafe(ke,Pe=Be.ZERO){if(!fe.isValid(ke))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return ke===_0n$1?Be.ZERO:this.is0()||ke===_1n$2?this:$e.unsafe(this,ke,Ue=>normalizeZ(Be,Ue),Pe)}isSmallOrder(){return this.multiplyUnsafe(le).is0()}isTorsionFree(){return $e.unsafe(this,ae.n).is0()}toAffine(ke){return Se(this,ke)}clearCofactor(){return le===_1n$2?this:this.multiplyUnsafe(le)}toBytes(){const{x:ke,y:Pe}=this.toAffine(),Ue=ie.toBytes(Pe);return Ue[Ue.length-1]|=ke&_1n$2?128:0,Ue}toHex(){return bytesToHex(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(ke){return normalizeZ(Be,ke)}static msm(ke,Pe){return pippenger(Be,fe,ke,Pe)}_setWindowSize(ke){this.precompute(ke)}toRawBytes(){return this.toBytes()}}Be.BASE=new Be(ae.Gx,ae.Gy,_1n$2,ye(ae.Gx*ae.Gy)),Be.ZERO=new Be(_0n$1,_1n$2,_1n$2,_0n$1),Be.Fp=ie,Be.Fn=fe;const $e=new wNAF(Be,fe.BITS);return Be.BASE.precompute(8),Be}function eddsa$1(c,t,n={}){if(typeof t!="function")throw new Error('"hash" function param is required');_validateObject(n,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:ie}=n,{BASE:fe,Fp:ae,Fn:le}=c,he=n.randomBytes||randomBytes,ye=n.adjustScalarBytes||(Ke=>Ke),me=n.domain||((Ke,Pt,_e)=>{if(_abool2(_e,"phflag"),Pt.length||_e)throw new Error("Contexts/pre-hash are not supported");return Ke});function xe(Ke){return le.create(bytesToNumberLE(Ke))}function Ee(Ke){const Pt=Ue.secretKey;Ke=ensureBytes("private key",Ke,Pt);const _e=ensureBytes("hashed private key",t(Ke),2*Pt),se=ye(_e.slice(0,Pt)),ce=_e.slice(Pt,2*Pt),de=xe(se);return{head:se,prefix:ce,scalar:de}}function Se(Ke){const{head:Pt,prefix:_e,scalar:se}=Ee(Ke),ce=fe.multiply(se),de=ce.toBytes();return{head:Pt,prefix:_e,scalar:se,point:ce,pointBytes:de}}function Me(Ke){return Se(Ke).pointBytes}function Be(Ke=Uint8Array.of(),...Pt){const _e=concatBytes(...Pt);return xe(t(me(_e,ensureBytes("context",Ke),!!ie)))}function $e(Ke,Pt,_e={}){Ke=ensureBytes("message",Ke),ie&&(Ke=ie(Ke));const{prefix:se,scalar:ce,pointBytes:de}=Se(Pt),pe=Be(_e.context,se,Ke),ve=fe.multiply(pe).toBytes(),we=Be(_e.context,ve,de,Ke),Ae=le.create(pe+we*ce);if(!le.isValid(Ae))throw new Error("sign failed: invalid s");const ge=concatBytes(ve,le.toBytes(Ae));return _abytes2(ge,Ue.signature,"result")}const Ce={zip215:!0};function ke(Ke,Pt,_e,se=Ce){const{context:ce,zip215:de}=se,pe=Ue.signature;Ke=ensureBytes("signature",Ke,pe),Pt=ensureBytes("message",Pt),_e=ensureBytes("publicKey",_e,Ue.publicKey),de!==void 0&&_abool2(de,"zip215"),ie&&(Pt=ie(Pt));const ve=pe/2,we=Ke.subarray(0,ve),Ae=bytesToNumberLE(Ke.subarray(ve,pe));let ge,ue,be;try{ge=c.fromBytes(_e,de),ue=c.fromBytes(we,de),be=fe.multiplyUnsafe(Ae)}catch{return!1}if(!de&&ge.isSmallOrder())return!1;const Re=Be(ce,ue.toBytes(),ge.toBytes(),Pt);return ue.add(ge.multiplyUnsafe(Re)).subtract(be).clearCofactor().is0()}const Pe=ae.BYTES,Ue={secretKey:Pe,publicKey:Pe,signature:2*Pe,seed:Pe};function qe(Ke=he(Ue.seed)){return _abytes2(Ke,Ue.seed,"seed")}function He(Ke){const Pt=Qe.randomSecretKey(Ke);return{secretKey:Pt,publicKey:Me(Pt)}}function Ve(Ke){return isBytes(Ke)&&Ke.length===le.BYTES}function Ye(Ke,Pt){try{return!!c.fromBytes(Ke,Pt)}catch{return!1}}const Qe={getExtendedPublicKey:Se,randomSecretKey:qe,isValidSecretKey:Ve,isValidPublicKey:Ye,toMontgomery(Ke){const{y:Pt}=c.fromBytes(Ke),_e=Ue.publicKey,se=_e===32;if(!se&&_e!==57)throw new Error("only defined for 25519 and 448");const ce=se?ae.div(_1n$2+Pt,_1n$2-Pt):ae.div(Pt-_1n$2,Pt+_1n$2);return ae.toBytes(ce)},toMontgomerySecret(Ke){const Pt=Ue.secretKey;_abytes2(Ke,Pt);const _e=t(Ke.subarray(0,Pt));return ye(_e).subarray(0,Pt)},randomPrivateKey:qe,precompute(Ke=8,Pt=c.BASE){return Pt.precompute(Ke,!1)}};return Object.freeze({keygen:He,getPublicKey:Me,sign:$e,verify:ke,utils:Qe,Point:c,lengths:Ue})}function _eddsa_legacy_opts_to_new(c){const t={a:c.a,d:c.d,p:c.Fp.ORDER,n:c.n,h:c.h,Gx:c.Gx,Gy:c.Gy},n=c.Fp,ie=Field(t.n,c.nBitLength,!0),fe={Fp:n,Fn:ie,uvRatio:c.uvRatio},ae={randomBytes:c.randomBytes,adjustScalarBytes:c.adjustScalarBytes,domain:c.domain,prehash:c.prehash,mapToCurve:c.mapToCurve};return{CURVE:t,curveOpts:fe,hash:c.hash,eddsaOpts:ae}}function _eddsa_new_output_to_legacy(c,t){const n=t.Point;return Object.assign({},t,{ExtendedPoint:n,CURVE:c,nBitLength:n.Fn.BITS,nByteLength:n.Fn.BYTES})}function twistedEdwards(c){const{CURVE:t,curveOpts:n,hash:ie,eddsaOpts:fe}=_eddsa_legacy_opts_to_new(c),ae=edwards$1(t,n),le=eddsa$1(ae,ie,fe);return _eddsa_new_output_to_legacy(c,le)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _1n$1=BigInt(1),_2n$2=BigInt(2);BigInt(3);const _5n=BigInt(5),_8n=BigInt(8),ed25519_CURVE_p=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),ed25519_CURVE={p:ed25519_CURVE_p,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:_8n,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function ed25519_pow_2_252_3(c){const t=BigInt(10),n=BigInt(20),ie=BigInt(40),fe=BigInt(80),ae=ed25519_CURVE_p,he=c*c%ae*c%ae,ye=pow2(he,_2n$2,ae)*he%ae,me=pow2(ye,_1n$1,ae)*c%ae,xe=pow2(me,_5n,ae)*me%ae,Ee=pow2(xe,t,ae)*xe%ae,Se=pow2(Ee,n,ae)*Ee%ae,Me=pow2(Se,ie,ae)*Se%ae,Be=pow2(Me,fe,ae)*Me%ae,$e=pow2(Be,fe,ae)*Me%ae,Ce=pow2($e,t,ae)*xe%ae;return{pow_p_5_8:pow2(Ce,_2n$2,ae)*c%ae,b2:he}}function adjustScalarBytes(c){return c[0]&=248,c[31]&=127,c[31]|=64,c}const ED25519_SQRT_M1=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function uvRatio(c,t){const n=ed25519_CURVE_p,ie=mod(t*t*t,n),fe=mod(ie*ie*t,n),ae=ed25519_pow_2_252_3(c*fe).pow_p_5_8;let le=mod(c*ie*ae,n);const he=mod(t*le*le,n),ye=le,me=mod(le*ED25519_SQRT_M1,n),xe=he===c,Ee=he===mod(-c,n),Se=he===mod(-c*ED25519_SQRT_M1,n);return xe&&(le=ye),(Ee||Se)&&(le=me),isNegativeLE(le,n)&&(le=mod(-le,n)),{isValid:xe||Ee,value:le}}const Fp=Field(ed25519_CURVE.p,{isLE:!0}),ed25519Defaults={...ed25519_CURVE,Fp,hash:sha512$3,adjustScalarBytes,uvRatio},ed25519=twistedEdwards(ed25519Defaults);var safeBuffer$2={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(c,t){var n=require$$0$4,ie=n.Buffer;function fe(le,he){for(var ye in le)he[ye]=le[ye]}ie.from&&ie.alloc&&ie.allocUnsafe&&ie.allocUnsafeSlow?c.exports=n:(fe(n,t),t.Buffer=ae);function ae(le,he,ye){return ie(le,he,ye)}ae.prototype=Object.create(ie.prototype),fe(ie,ae),ae.from=function(le,he,ye){if(typeof le=="number")throw new TypeError("Argument must not be a number");return ie(le,he,ye)},ae.alloc=function(le,he,ye){if(typeof le!="number")throw new TypeError("Argument must be a number");var me=ie(le);return he!==void 0?typeof ye=="string"?me.fill(he,ye):me.fill(he):me.fill(0),me},ae.allocUnsafe=function(le){if(typeof le!="number")throw new TypeError("Argument must be a number");return ie(le)},ae.allocUnsafeSlow=function(le){if(typeof le!="number")throw new TypeError("Argument must be a number");return n.SlowBuffer(le)}})(safeBuffer$2,safeBuffer$2.exports);var safeBufferExports=safeBuffer$2.exports,_Buffer=safeBufferExports.Buffer;function base$4(c){if(c.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var ie=0;ie<c.length;ie++){var fe=c.charAt(ie),ae=fe.charCodeAt(0);if(t[ae]!==255)throw new TypeError(fe+" is ambiguous");t[ae]=ie}var le=c.length,he=c.charAt(0),ye=Math.log(le)/Math.log(256),me=Math.log(256)/Math.log(le);function xe(Me){if((Array.isArray(Me)||Me instanceof Uint8Array)&&(Me=_Buffer.from(Me)),!_Buffer.isBuffer(Me))throw new TypeError("Expected Buffer");if(Me.length===0)return"";for(var Be=0,$e=0,Ce=0,ke=Me.length;Ce!==ke&&Me[Ce]===0;)Ce++,Be++;for(var Pe=(ke-Ce)*me+1>>>0,Ue=new Uint8Array(Pe);Ce!==ke;){for(var qe=Me[Ce],He=0,Ve=Pe-1;(qe!==0||He<$e)&&Ve!==-1;Ve--,He++)qe+=256*Ue[Ve]>>>0,Ue[Ve]=qe%le>>>0,qe=qe/le>>>0;if(qe!==0)throw new Error("Non-zero carry");$e=He,Ce++}for(var Ye=Pe-$e;Ye!==Pe&&Ue[Ye]===0;)Ye++;for(var Qe=he.repeat(Be);Ye<Pe;++Ye)Qe+=c.charAt(Ue[Ye]);return Qe}function Ee(Me){if(typeof Me!="string")throw new TypeError("Expected String");if(Me.length===0)return _Buffer.alloc(0);for(var Be=0,$e=0,Ce=0;Me[Be]===he;)$e++,Be++;for(var ke=(Me.length-Be)*ye+1>>>0,Pe=new Uint8Array(ke);Be<Me.length;){var Ue=Me.charCodeAt(Be);if(Ue>255)return;var qe=t[Ue];if(qe===255)return;for(var He=0,Ve=ke-1;(qe!==0||He<Ce)&&Ve!==-1;Ve--,He++)qe+=le*Pe[Ve]>>>0,Pe[Ve]=qe%256>>>0,qe=qe/256>>>0;if(qe!==0)throw new Error("Non-zero carry");Ce=He,Be++}for(var Ye=ke-Ce;Ye!==ke&&Pe[Ye]===0;)Ye++;var Qe=_Buffer.allocUnsafe($e+(ke-Ye));Qe.fill(0,0,$e);for(var Ke=$e;Ye!==ke;)Qe[Ke++]=Pe[Ye++];return Qe}function Se(Me){var Be=Ee(Me);if(Be)return Be;throw new Error("Non-base"+le+" character")}return{encode:xe,decodeUnsafe:Ee,decode:Se}}var src$7=base$4;const e$1=getDefaultExportFromCjs$2(src$7);var basex=src$7,ALPHABET$1="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",bs58=basex(ALPHABET$1);const o$1=getDefaultExportFromCjs$2(bs58),sha256$4=sha256$5;var lib={};function inRange(c,t,n){return t<=c&&c<=n}function ToDictionary(c){if(c===void 0)return{};if(c===Object(c))return c;throw TypeError("Could not convert argument to dictionary")}function stringToCodePoints(c){for(var t=String(c),n=t.length,ie=0,fe=[];ie<n;){var ae=t.charCodeAt(ie);if(ae<55296||ae>57343)fe.push(ae);else if(56320<=ae&&ae<=57343)fe.push(65533);else if(55296<=ae&&ae<=56319)if(ie===n-1)fe.push(65533);else{var le=c.charCodeAt(ie+1);if(56320<=le&&le<=57343){var he=ae&1023,ye=le&1023;fe.push(65536+(he<<10)+ye),ie+=1}else fe.push(65533)}ie+=1}return fe}function codePointsToString(c){for(var t="",n=0;n<c.length;++n){var ie=c[n];ie<=65535?t+=String.fromCharCode(ie):(ie-=65536,t+=String.fromCharCode((ie>>10)+55296,(ie&1023)+56320))}return t}var end_of_stream=-1;function Stream(c){this.tokens=[].slice.call(c)}Stream.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():end_of_stream},prepend:function(c){if(Array.isArray(c))for(var t=c;t.length;)this.tokens.unshift(t.pop());else this.tokens.unshift(c)},push:function(c){if(Array.isArray(c))for(var t=c;t.length;)this.tokens.push(t.shift());else this.tokens.push(c)}};var finished=-1;function decoderError(c,t){if(c)throw TypeError("Decoder error");return t||65533}var DEFAULT_ENCODING="utf-8";function TextDecoder$1(c,t){if(!(this instanceof TextDecoder$1))return new TextDecoder$1(c,t);if(c=c!==void 0?String(c).toLowerCase():DEFAULT_ENCODING,c!==DEFAULT_ENCODING)throw new Error("Encoding not supported. Only utf-8 is supported");t=ToDictionary(t),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!t.fatal,this._ignoreBOM=!!t.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}TextDecoder$1.prototype={decode:function(t,n){var ie;typeof t=="object"&&t instanceof ArrayBuffer?ie=new Uint8Array(t):typeof t=="object"&&"buffer"in t&&t.buffer instanceof ArrayBuffer?ie=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):ie=new Uint8Array(0),n=ToDictionary(n),this._streaming||(this._decoder=new UTF8Decoder({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!n.stream;for(var fe=new Stream(ie),ae=[],le;!fe.endOfStream()&&(le=this._decoder.handler(fe,fe.read()),le!==finished);)le!==null&&(Array.isArray(le)?ae.push.apply(ae,le):ae.push(le));if(!this._streaming){do{if(le=this._decoder.handler(fe,fe.read()),le===finished)break;le!==null&&(Array.isArray(le)?ae.push.apply(ae,le):ae.push(le))}while(!fe.endOfStream());this._decoder=null}return ae.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(ae[0]===65279?(this._BOMseen=!0,ae.shift()):this._BOMseen=!0),codePointsToString(ae)}};function TextEncoder$1(c,t){if(!(this instanceof TextEncoder$1))return new TextEncoder$1(c,t);if(c=c!==void 0?String(c).toLowerCase():DEFAULT_ENCODING,c!==DEFAULT_ENCODING)throw new Error("Encoding not supported. Only utf-8 is supported");t=ToDictionary(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}TextEncoder$1.prototype={encode:function(t,n){t=t?String(t):"",n=ToDictionary(n),this._streaming||(this._encoder=new UTF8Encoder(this._options)),this._streaming=!!n.stream;for(var ie=[],fe=new Stream(stringToCodePoints(t)),ae;!fe.endOfStream()&&(ae=this._encoder.handler(fe,fe.read()),ae!==finished);)Array.isArray(ae)?ie.push.apply(ie,ae):ie.push(ae);if(!this._streaming){for(;ae=this._encoder.handler(fe,fe.read()),ae!==finished;)Array.isArray(ae)?ie.push.apply(ie,ae):ie.push(ae);this._encoder=null}return new Uint8Array(ie)}};function UTF8Decoder(c){var t=c.fatal,n=0,ie=0,fe=0,ae=128,le=191;this.handler=function(he,ye){if(ye===end_of_stream&&fe!==0)return fe=0,decoderError(t);if(ye===end_of_stream)return finished;if(fe===0){if(inRange(ye,0,127))return ye;if(inRange(ye,194,223))fe=1,n=ye-192;else if(inRange(ye,224,239))ye===224&&(ae=160),ye===237&&(le=159),fe=2,n=ye-224;else if(inRange(ye,240,244))ye===240&&(ae=144),ye===244&&(le=143),fe=3,n=ye-240;else return decoderError(t);return n=n<<6*fe,null}if(!inRange(ye,ae,le))return n=fe=ie=0,ae=128,le=191,he.prepend(ye),decoderError(t);if(ae=128,le=191,ie+=1,n+=ye-128<<6*(fe-ie),ie!==fe)return null;var me=n;return n=fe=ie=0,me}}function UTF8Encoder(c){c.fatal,this.handler=function(t,n){if(n===end_of_stream)return finished;if(inRange(n,0,127))return n;var ie,fe;inRange(n,128,2047)?(ie=1,fe=192):inRange(n,2048,65535)?(ie=2,fe=224):inRange(n,65536,1114111)&&(ie=3,fe=240);for(var ae=[(n>>6*ie)+fe];ie>0;){var le=n>>6*(ie-1);ae.push(128|le&63),ie-=1}return ae}}const encoding$1=Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:TextDecoder$1,TextEncoder:TextEncoder$1},Symbol.toStringTag,{value:"Module"})),require$$2$2=getAugmentedNamespace(encoding$1);var __createBinding$9=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(c,t,n,ie){ie===void 0&&(ie=n),Object.defineProperty(c,ie,{enumerable:!0,get:function(){return t[n]}})}:function(c,t,n,ie){ie===void 0&&(ie=n),c[ie]=t[n]}),__setModuleDefault$9=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(c,t){Object.defineProperty(c,"default",{enumerable:!0,value:t})}:function(c,t){c.default=t}),__decorate=commonjsGlobal&&commonjsGlobal.__decorate||function(c,t,n,ie){var fe=arguments.length,ae=fe<3?t:ie===null?ie=Object.getOwnPropertyDescriptor(t,n):ie,le;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")ae=Reflect.decorate(c,t,n,ie);else for(var he=c.length-1;he>=0;he--)(le=c[he])&&(ae=(fe<3?le(ae):fe>3?le(t,n,ae):le(t,n))||ae);return fe>3&&ae&&Object.defineProperty(t,n,ae),ae},__importStar$9=commonjsGlobal&&commonjsGlobal.__importStar||function(c){if(c&&c.__esModule)return c;var t={};if(c!=null)for(var n in c)n!=="default"&&Object.hasOwnProperty.call(c,n)&&__createBinding$9(t,c,n);return __setModuleDefault$9(t,c),t},__importDefault$9=commonjsGlobal&&commonjsGlobal.__importDefault||function(c){return c&&c.__esModule?c:{default:c}};Object.defineProperty(lib,"__esModule",{value:!0});var deserializeUnchecked_1=lib.deserializeUnchecked=deserialize_1=lib.deserialize=serialize_1=lib.serialize=lib.BinaryReader=lib.BinaryWriter=lib.BorshError=lib.baseDecode=lib.baseEncode=void 0;const bn_js_1$1=__importDefault$9(bnExports$3),bs58_1=__importDefault$9(bs58),encoding=__importStar$9(require$$2$2),ResolvedTextDecoder=typeof TextDecoder!="function"?encoding.TextDecoder:TextDecoder,textDecoder=new ResolvedTextDecoder("utf-8",{fatal:!0});function baseEncode(c){return typeof c=="string"&&(c=Buffer$7.from(c,"utf8")),bs58_1.default.encode(Buffer$7.from(c))}lib.baseEncode=baseEncode;function baseDecode(c){return Buffer$7.from(bs58_1.default.decode(c))}lib.baseDecode=baseDecode;const INITIAL_LENGTH=1024;class BorshError extends Error{constructor(t){super(t),this.fieldPath=[],this.originalMessage=t}addToFieldPath(t){this.fieldPath.splice(0,0,t),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}lib.BorshError=BorshError;class BinaryWriter{constructor(){this.buf=Buffer$7.alloc(INITIAL_LENGTH),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer$7.concat([this.buf,Buffer$7.alloc(INITIAL_LENGTH)]))}writeU8(t){this.maybeResize(),this.buf.writeUInt8(t,this.length),this.length+=1}writeU16(t){this.maybeResize(),this.buf.writeUInt16LE(t,this.length),this.length+=2}writeU32(t){this.maybeResize(),this.buf.writeUInt32LE(t,this.length),this.length+=4}writeU64(t){this.maybeResize(),this.writeBuffer(Buffer$7.from(new bn_js_1$1.default(t).toArray("le",8)))}writeU128(t){this.maybeResize(),this.writeBuffer(Buffer$7.from(new bn_js_1$1.default(t).toArray("le",16)))}writeU256(t){this.maybeResize(),this.writeBuffer(Buffer$7.from(new bn_js_1$1.default(t).toArray("le",32)))}writeU512(t){this.maybeResize(),this.writeBuffer(Buffer$7.from(new bn_js_1$1.default(t).toArray("le",64)))}writeBuffer(t){this.buf=Buffer$7.concat([Buffer$7.from(this.buf.subarray(0,this.length)),t,Buffer$7.alloc(INITIAL_LENGTH)]),this.length+=t.length}writeString(t){this.maybeResize();const n=Buffer$7.from(t,"utf8");this.writeU32(n.length),this.writeBuffer(n)}writeFixedArray(t){this.writeBuffer(Buffer$7.from(t))}writeArray(t,n){this.maybeResize(),this.writeU32(t.length);for(const ie of t)this.maybeResize(),n(ie)}toArray(){return this.buf.subarray(0,this.length)}}lib.BinaryWriter=BinaryWriter;function handlingRangeError(c,t,n){const ie=n.value;n.value=function(...fe){try{return ie.apply(this,fe)}catch(ae){if(ae instanceof RangeError){const le=ae.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(le)>=0)throw new BorshError("Reached the end of buffer when deserializing")}throw ae}}}class BinaryReader{constructor(t){this.buf=t,this.offset=0}readU8(){const t=this.buf.readUInt8(this.offset);return this.offset+=1,t}readU16(){const t=this.buf.readUInt16LE(this.offset);return this.offset+=2,t}readU32(){const t=this.buf.readUInt32LE(this.offset);return this.offset+=4,t}readU64(){const t=this.readBuffer(8);return new bn_js_1$1.default(t,"le")}readU128(){const t=this.readBuffer(16);return new bn_js_1$1.default(t,"le")}readU256(){const t=this.readBuffer(32);return new bn_js_1$1.default(t,"le")}readU512(){const t=this.readBuffer(64);return new bn_js_1$1.default(t,"le")}readBuffer(t){if(this.offset+t>this.buf.length)throw new BorshError(`Expected buffer length ${t} isn't within bounds`);const n=this.buf.slice(this.offset,this.offset+t);return this.offset+=t,n}readString(){const t=this.readU32(),n=this.readBuffer(t);try{return textDecoder.decode(n)}catch(ie){throw new BorshError(`Error decoding UTF-8 string: ${ie}`)}}readFixedArray(t){return new Uint8Array(this.readBuffer(t))}readArray(t){const n=this.readU32(),ie=Array();for(let fe=0;fe<n;++fe)ie.push(t());return ie}}__decorate([handlingRangeError],BinaryReader.prototype,"readU8",null);__decorate([handlingRangeError],BinaryReader.prototype,"readU16",null);__decorate([handlingRangeError],BinaryReader.prototype,"readU32",null);__decorate([handlingRangeError],BinaryReader.prototype,"readU64",null);__decorate([handlingRangeError],BinaryReader.prototype,"readU128",null);__decorate([handlingRangeError],BinaryReader.prototype,"readU256",null);__decorate([handlingRangeError],BinaryReader.prototype,"readU512",null);__decorate([handlingRangeError],BinaryReader.prototype,"readString",null);__decorate([handlingRangeError],BinaryReader.prototype,"readFixedArray",null);__decorate([handlingRangeError],BinaryReader.prototype,"readArray",null);lib.BinaryReader=BinaryReader;function capitalizeFirstLetter(c){return c.charAt(0).toUpperCase()+c.slice(1)}function serializeField(c,t,n,ie,fe){try{if(typeof ie=="string")fe[`write${capitalizeFirstLetter(ie)}`](n);else if(ie instanceof Array)if(typeof ie[0]=="number"){if(n.length!==ie[0])throw new BorshError(`Expecting byte array of length ${ie[0]}, but got ${n.length} bytes`);fe.writeFixedArray(n)}else if(ie.length===2&&typeof ie[1]=="number"){if(n.length!==ie[1])throw new BorshError(`Expecting byte array of length ${ie[1]}, but got ${n.length} bytes`);for(let ae=0;ae<ie[1];ae++)serializeField(c,null,n[ae],ie[0],fe)}else fe.writeArray(n,ae=>{serializeField(c,t,ae,ie[0],fe)});else if(ie.kind!==void 0)switch(ie.kind){case"option":{n==null?fe.writeU8(0):(fe.writeU8(1),serializeField(c,t,n,ie.type,fe));break}case"map":{fe.writeU32(n.size),n.forEach((ae,le)=>{serializeField(c,t,le,ie.key,fe),serializeField(c,t,ae,ie.value,fe)});break}default:throw new BorshError(`FieldType ${ie} unrecognized`)}else serializeStruct(c,n,fe)}catch(ae){throw ae instanceof BorshError&&ae.addToFieldPath(t),ae}}function serializeStruct(c,t,n){if(typeof t.borshSerialize=="function"){t.borshSerialize(n);return}const ie=c.get(t.constructor);if(!ie)throw new BorshError(`Class ${t.constructor.name} is missing in schema`);if(ie.kind==="struct")ie.fields.map(([fe,ae])=>{serializeField(c,fe,t[fe],ae,n)});else if(ie.kind==="enum"){const fe=t[ie.field];for(let ae=0;ae<ie.values.length;++ae){const[le,he]=ie.values[ae];if(le===fe){n.writeU8(ae),serializeField(c,le,t[le],he,n);break}}}else throw new BorshError(`Unexpected schema kind: ${ie.kind} for ${t.constructor.name}`)}function serialize(c,t,n=BinaryWriter){const ie=new n;return serializeStruct(c,t,ie),ie.toArray()}var serialize_1=lib.serialize=serialize;function deserializeField(c,t,n,ie){try{if(typeof n=="string")return ie[`read${capitalizeFirstLetter(n)}`]();if(n instanceof Array){if(typeof n[0]=="number")return ie.readFixedArray(n[0]);if(typeof n[1]=="number"){const fe=[];for(let ae=0;ae<n[1];ae++)fe.push(deserializeField(c,null,n[0],ie));return fe}else return ie.readArray(()=>deserializeField(c,t,n[0],ie))}if(n.kind==="option")return ie.readU8()?deserializeField(c,t,n.type,ie):void 0;if(n.kind==="map"){let fe=new Map;const ae=ie.readU32();for(let le=0;le<ae;le++){const he=deserializeField(c,t,n.key,ie),ye=deserializeField(c,t,n.value,ie);fe.set(he,ye)}return fe}return deserializeStruct(c,n,ie)}catch(fe){throw fe instanceof BorshError&&fe.addToFieldPath(t),fe}}function deserializeStruct(c,t,n){if(typeof t.borshDeserialize=="function")return t.borshDeserialize(n);const ie=c.get(t);if(!ie)throw new BorshError(`Class ${t.name} is missing in schema`);if(ie.kind==="struct"){const fe={};for(const[ae,le]of c.get(t).fields)fe[ae]=deserializeField(c,ae,le,n);return new t(fe)}if(ie.kind==="enum"){const fe=n.readU8();if(fe>=ie.values.length)throw new BorshError(`Enum index: ${fe} is out of range`);const[ae,le]=ie.values[fe],he=deserializeField(c,ae,le,n);return new t({[ae]:he})}throw new BorshError(`Unexpected schema kind: ${ie.kind} for ${t.constructor.name}`)}function deserialize(c,t,n,ie=BinaryReader){const fe=new ie(n),ae=deserializeStruct(c,t,fe);if(fe.offset<n.length)throw new BorshError(`Unexpected ${n.length-fe.offset} bytes after deserialized data`);return ae}var deserialize_1=lib.deserialize=deserialize;function deserializeUnchecked(c,t,n,ie=BinaryReader){const fe=new ie(n);return deserializeStruct(c,t,fe)}deserializeUnchecked_1=lib.deserializeUnchecked=deserializeUnchecked;var Layout$1={};Object.defineProperty(Layout$1,"__esModule",{value:!0});Layout$1.s16=Layout$1.s8=Layout$1.nu64be=Layout$1.u48be=Layout$1.u40be=Layout$1.u32be=Layout$1.u24be=Layout$1.u16be=nu64=Layout$1.nu64=Layout$1.u48=Layout$1.u40=u32=Layout$1.u32=Layout$1.u24=u16=Layout$1.u16=u8=Layout$1.u8=offset=Layout$1.offset=Layout$1.greedy=Layout$1.Constant=Layout$1.UTF8=Layout$1.CString=Layout$1.Blob=Layout$1.Boolean=Layout$1.BitField=Layout$1.BitStructure=Layout$1.VariantLayout=Layout$1.Union=Layout$1.UnionLayoutDiscriminator=Layout$1.UnionDiscriminator=Layout$1.Structure=Layout$1.Sequence=Layout$1.DoubleBE=Layout$1.Double=Layout$1.FloatBE=Layout$1.Float=Layout$1.NearInt64BE=Layout$1.NearInt64=Layout$1.NearUInt64BE=Layout$1.NearUInt64=Layout$1.IntBE=Layout$1.Int=Layout$1.UIntBE=Layout$1.UInt=Layout$1.OffsetLayout=Layout$1.GreedyCount=Layout$1.ExternalLayout=Layout$1.bindConstructorLayout=Layout$1.nameWithProperty=Layout$1.Layout=Layout$1.uint8ArrayToBuffer=Layout$1.checkUint8Array=void 0;Layout$1.constant=Layout$1.utf8=Layout$1.cstr=blob=Layout$1.blob=Layout$1.unionLayoutDiscriminator=Layout$1.union=seq=Layout$1.seq=Layout$1.bits=struct=Layout$1.struct=Layout$1.f64be=Layout$1.f64=Layout$1.f32be=Layout$1.f32=Layout$1.ns64be=Layout$1.s48be=Layout$1.s40be=Layout$1.s32be=Layout$1.s24be=Layout$1.s16be=ns64=Layout$1.ns64=Layout$1.s48=Layout$1.s40=Layout$1.s32=Layout$1.s24=void 0;const buffer_1=require$$0$4;function checkUint8Array(c){if(!(c instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}Layout$1.checkUint8Array=checkUint8Array;function uint8ArrayToBuffer(c){return checkUint8Array(c),buffer_1.Buffer.from(c.buffer,c.byteOffset,c.length)}Layout$1.uint8ArrayToBuffer=uint8ArrayToBuffer;class Layout{constructor(t,n){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=n}makeDestinationObject(){return{}}getSpan(t,n){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const n=Object.create(this.constructor.prototype);return Object.assign(n,this),n.property=t,n}fromArray(t){}}Layout$1.Layout=Layout;function nameWithProperty(c,t){return t.property?c+"["+t.property+"]":c}Layout$1.nameWithProperty=nameWithProperty;function bindConstructorLayout(c,t){if(typeof c!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(c,"layout_"))throw new Error("Class is already bound to a layout");if(!(t&&t instanceof Layout))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(t,"boundConstructor_"))throw new Error("layout is already bound to a constructor");c.layout_=t,t.boundConstructor_=c,t.makeDestinationObject=()=>new c,Object.defineProperty(c.prototype,"encode",{value(n,ie){return t.encode(this,n,ie)},writable:!0}),Object.defineProperty(c,"decode",{value(n,ie){return t.decode(n,ie)},writable:!0})}Layout$1.bindConstructorLayout=bindConstructorLayout;class ExternalLayout extends Layout{isCount(){throw new Error("ExternalLayout is abstract")}}Layout$1.ExternalLayout=ExternalLayout;class GreedyCount extends ExternalLayout{constructor(t=1,n){if(!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,n),this.elementSpan=t}isCount(){return!0}decode(t,n=0){checkUint8Array(t);const ie=t.length-n;return Math.floor(ie/this.elementSpan)}encode(t,n,ie){return 0}}Layout$1.GreedyCount=GreedyCount;class OffsetLayout extends ExternalLayout{constructor(t,n=0,ie){if(!(t instanceof Layout))throw new TypeError("layout must be a Layout");if(!Number.isInteger(n))throw new TypeError("offset must be integer or undefined");super(t.span,ie||t.property),this.layout=t,this.offset=n}isCount(){return this.layout instanceof UInt||this.layout instanceof UIntBE}decode(t,n=0){return this.layout.decode(t,n+this.offset)}encode(t,n,ie=0){return this.layout.encode(t,n,ie+this.offset)}}Layout$1.OffsetLayout=OffsetLayout;class UInt extends Layout{constructor(t,n){if(super(t,n),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,n=0){return uint8ArrayToBuffer(t).readUIntLE(n,this.span)}encode(t,n,ie=0){return uint8ArrayToBuffer(n).writeUIntLE(t,ie,this.span),this.span}}Layout$1.UInt=UInt;class UIntBE extends Layout{constructor(t,n){if(super(t,n),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,n=0){return uint8ArrayToBuffer(t).readUIntBE(n,this.span)}encode(t,n,ie=0){return uint8ArrayToBuffer(n).writeUIntBE(t,ie,this.span),this.span}}Layout$1.UIntBE=UIntBE;class Int extends Layout{constructor(t,n){if(super(t,n),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,n=0){return uint8ArrayToBuffer(t).readIntLE(n,this.span)}encode(t,n,ie=0){return uint8ArrayToBuffer(n).writeIntLE(t,ie,this.span),this.span}}Layout$1.Int=Int;class IntBE extends Layout{constructor(t,n){if(super(t,n),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,n=0){return uint8ArrayToBuffer(t).readIntBE(n,this.span)}encode(t,n,ie=0){return uint8ArrayToBuffer(n).writeIntBE(t,ie,this.span),this.span}}Layout$1.IntBE=IntBE;const V2E32=Math.pow(2,32);function divmodInt64(c){const t=Math.floor(c/V2E32),n=c-t*V2E32;return{hi32:t,lo32:n}}function roundedInt64(c,t){return c*V2E32+t}class NearUInt64 extends Layout{constructor(t){super(8,t)}decode(t,n=0){const ie=uint8ArrayToBuffer(t),fe=ie.readUInt32LE(n),ae=ie.readUInt32LE(n+4);return roundedInt64(ae,fe)}encode(t,n,ie=0){const fe=divmodInt64(t),ae=uint8ArrayToBuffer(n);return ae.writeUInt32LE(fe.lo32,ie),ae.writeUInt32LE(fe.hi32,ie+4),8}}Layout$1.NearUInt64=NearUInt64;class NearUInt64BE extends Layout{constructor(t){super(8,t)}decode(t,n=0){const ie=uint8ArrayToBuffer(t),fe=ie.readUInt32BE(n),ae=ie.readUInt32BE(n+4);return roundedInt64(fe,ae)}encode(t,n,ie=0){const fe=divmodInt64(t),ae=uint8ArrayToBuffer(n);return ae.writeUInt32BE(fe.hi32,ie),ae.writeUInt32BE(fe.lo32,ie+4),8}}Layout$1.NearUInt64BE=NearUInt64BE;class NearInt64 extends Layout{constructor(t){super(8,t)}decode(t,n=0){const ie=uint8ArrayToBuffer(t),fe=ie.readUInt32LE(n),ae=ie.readInt32LE(n+4);return roundedInt64(ae,fe)}encode(t,n,ie=0){const fe=divmodInt64(t),ae=uint8ArrayToBuffer(n);return ae.writeUInt32LE(fe.lo32,ie),ae.writeInt32LE(fe.hi32,ie+4),8}}Layout$1.NearInt64=NearInt64;class NearInt64BE extends Layout{constructor(t){super(8,t)}decode(t,n=0){const ie=uint8ArrayToBuffer(t),fe=ie.readInt32BE(n),ae=ie.readUInt32BE(n+4);return roundedInt64(fe,ae)}encode(t,n,ie=0){const fe=divmodInt64(t),ae=uint8ArrayToBuffer(n);return ae.writeInt32BE(fe.hi32,ie),ae.writeUInt32BE(fe.lo32,ie+4),8}}Layout$1.NearInt64BE=NearInt64BE;class Float extends Layout{constructor(t){super(4,t)}decode(t,n=0){return uint8ArrayToBuffer(t).readFloatLE(n)}encode(t,n,ie=0){return uint8ArrayToBuffer(n).writeFloatLE(t,ie),4}}Layout$1.Float=Float;class FloatBE extends Layout{constructor(t){super(4,t)}decode(t,n=0){return uint8ArrayToBuffer(t).readFloatBE(n)}encode(t,n,ie=0){return uint8ArrayToBuffer(n).writeFloatBE(t,ie),4}}Layout$1.FloatBE=FloatBE;class Double extends Layout{constructor(t){super(8,t)}decode(t,n=0){return uint8ArrayToBuffer(t).readDoubleLE(n)}encode(t,n,ie=0){return uint8ArrayToBuffer(n).writeDoubleLE(t,ie),8}}Layout$1.Double=Double;class DoubleBE extends Layout{constructor(t){super(8,t)}decode(t,n=0){return uint8ArrayToBuffer(t).readDoubleBE(n)}encode(t,n,ie=0){return uint8ArrayToBuffer(n).writeDoubleBE(t,ie),8}}Layout$1.DoubleBE=DoubleBE;class Sequence extends Layout{constructor(t,n,ie){if(!(t instanceof Layout))throw new TypeError("elementLayout must be a Layout");if(!(n instanceof ExternalLayout&&n.isCount()||Number.isInteger(n)&&0<=n))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let fe=-1;!(n instanceof ExternalLayout)&&0<t.span&&(fe=n*t.span),super(fe,ie),this.elementLayout=t,this.count=n}getSpan(t,n=0){if(0<=this.span)return this.span;let ie=0,fe=this.count;if(fe instanceof ExternalLayout&&(fe=fe.decode(t,n)),0<this.elementLayout.span)ie=fe*this.elementLayout.span;else{let ae=0;for(;ae<fe;)ie+=this.elementLayout.getSpan(t,n+ie),++ae}return ie}decode(t,n=0){const ie=[];let fe=0,ae=this.count;for(ae instanceof ExternalLayout&&(ae=ae.decode(t,n));fe<ae;)ie.push(this.elementLayout.decode(t,n)),n+=this.elementLayout.getSpan(t,n),fe+=1;return ie}encode(t,n,ie=0){const fe=this.elementLayout,ae=t.reduce((le,he)=>le+fe.encode(he,n,ie+le),0);return this.count instanceof ExternalLayout&&this.count.encode(t.length,n,ie),ae}}Layout$1.Sequence=Sequence;class Structure extends Layout{constructor(t,n,ie){if(!(Array.isArray(t)&&t.reduce((ae,le)=>ae&&le instanceof Layout,!0)))throw new TypeError("fields must be array of Layout instances");typeof n=="boolean"&&ie===void 0&&(ie=n,n=void 0);for(const ae of t)if(0>ae.span&&ae.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let fe=-1;try{fe=t.reduce((ae,le)=>ae+le.getSpan(),0)}catch{}super(fe,n),this.fields=t,this.decodePrefixes=!!ie}getSpan(t,n=0){if(0<=this.span)return this.span;let ie=0;try{ie=this.fields.reduce((fe,ae)=>{const le=ae.getSpan(t,n);return n+=le,fe+le},0)}catch{throw new RangeError("indeterminate span")}return ie}decode(t,n=0){checkUint8Array(t);const ie=this.makeDestinationObject();for(const fe of this.fields)if(fe.property!==void 0&&(ie[fe.property]=fe.decode(t,n)),n+=fe.getSpan(t,n),this.decodePrefixes&&t.length===n)break;return ie}encode(t,n,ie=0){const fe=ie;let ae=0,le=0;for(const he of this.fields){let ye=he.span;if(le=0<ye?ye:0,he.property!==void 0){const me=t[he.property];me!==void 0&&(le=he.encode(me,n,ie),0>ye&&(ye=he.getSpan(n,ie)))}ae=ie,ie+=ye}return ae+le-fe}fromArray(t){const n=this.makeDestinationObject();for(const ie of this.fields)ie.property!==void 0&&0<t.length&&(n[ie.property]=t.shift());return n}layoutFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const n of this.fields)if(n.property===t)return n}offsetOf(t){if(typeof t!="string")throw new TypeError("property must be string");let n=0;for(const ie of this.fields){if(ie.property===t)return n;0>ie.span?n=-1:0<=n&&(n+=ie.span)}}}Layout$1.Structure=Structure;class UnionDiscriminator{constructor(t){this.property=t}decode(t,n){throw new Error("UnionDiscriminator is abstract")}encode(t,n,ie){throw new Error("UnionDiscriminator is abstract")}}Layout$1.UnionDiscriminator=UnionDiscriminator;class UnionLayoutDiscriminator extends UnionDiscriminator{constructor(t,n){if(!(t instanceof ExternalLayout&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(n||t.property||"variant"),this.layout=t}decode(t,n){return this.layout.decode(t,n)}encode(t,n,ie){return this.layout.encode(t,n,ie)}}Layout$1.UnionLayoutDiscriminator=UnionLayoutDiscriminator;class Union extends Layout{constructor(t,n,ie){let fe;if(t instanceof UInt||t instanceof UIntBE)fe=new UnionLayoutDiscriminator(new OffsetLayout(t));else if(t instanceof ExternalLayout&&t.isCount())fe=new UnionLayoutDiscriminator(t);else if(t instanceof UnionDiscriminator)fe=t;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(n===void 0&&(n=null),!(n===null||n instanceof Layout))throw new TypeError("defaultLayout must be null or a Layout");if(n!==null){if(0>n.span)throw new Error("defaultLayout must have constant span");n.property===void 0&&(n=n.replicate("content"))}let ae=-1;n&&(ae=n.span,0<=ae&&(t instanceof UInt||t instanceof UIntBE)&&(ae+=fe.layout.span)),super(ae,ie),this.discriminator=fe,this.usesPrefixDiscriminator=t instanceof UInt||t instanceof UIntBE,this.defaultLayout=n,this.registry={};let le=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(he){return le(he)},this.configGetSourceVariant=function(he){le=he.bind(this)}}getSpan(t,n=0){if(0<=this.span)return this.span;const ie=this.getVariant(t,n);if(!ie)throw new Error("unable to determine span for unrecognized variant");return ie.getSpan(t,n)}defaultGetSourceVariant(t){if(Object.prototype.hasOwnProperty.call(t,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(t,this.defaultLayout.property))return;const n=this.registry[t[this.discriminator.property]];if(n&&(!n.layout||n.property&&Object.prototype.hasOwnProperty.call(t,n.property)))return n}else for(const n in this.registry){const ie=this.registry[n];if(ie.property&&Object.prototype.hasOwnProperty.call(t,ie.property))return ie}throw new Error("unable to infer src variant")}decode(t,n=0){let ie;const fe=this.discriminator,ae=fe.decode(t,n),le=this.registry[ae];if(le===void 0){const he=this.defaultLayout;let ye=0;this.usesPrefixDiscriminator&&(ye=fe.layout.span),ie=this.makeDestinationObject(),ie[fe.property]=ae,ie[he.property]=he.decode(t,n+ye)}else ie=le.decode(t,n);return ie}encode(t,n,ie=0){const fe=this.getSourceVariant(t);if(fe===void 0){const ae=this.discriminator,le=this.defaultLayout;let he=0;return this.usesPrefixDiscriminator&&(he=ae.layout.span),ae.encode(t[ae.property],n,ie),he+le.encode(t[le.property],n,ie+he)}return fe.encode(t,n,ie)}addVariant(t,n,ie){const fe=new VariantLayout(this,t,n,ie);return this.registry[t]=fe,fe}getVariant(t,n=0){let ie;return t instanceof Uint8Array?ie=this.discriminator.decode(t,n):ie=t,this.registry[ie]}}Layout$1.Union=Union;class VariantLayout extends Layout{constructor(t,n,ie,fe){if(!(t instanceof Union))throw new TypeError("union must be a Union");if(!Number.isInteger(n)||0>n)throw new TypeError("variant must be a (non-negative) integer");if(typeof ie=="string"&&fe===void 0&&(fe=ie,ie=null),ie){if(!(ie instanceof Layout))throw new TypeError("layout must be a Layout");if(t.defaultLayout!==null&&0<=ie.span&&ie.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof fe!="string")throw new TypeError("variant must have a String property")}let ae=t.span;0>t.span&&(ae=ie?ie.span:0,0<=ae&&t.usesPrefixDiscriminator&&(ae+=t.discriminator.layout.span)),super(ae,fe),this.union=t,this.variant=n,this.layout=ie||null}getSpan(t,n=0){if(0<=this.span)return this.span;let ie=0;this.union.usesPrefixDiscriminator&&(ie=this.union.discriminator.layout.span);let fe=0;return this.layout&&(fe=this.layout.getSpan(t,n+ie)),ie+fe}decode(t,n=0){const ie=this.makeDestinationObject();if(this!==this.union.getVariant(t,n))throw new Error("variant mismatch");let fe=0;return this.union.usesPrefixDiscriminator&&(fe=this.union.discriminator.layout.span),this.layout?ie[this.property]=this.layout.decode(t,n+fe):this.property?ie[this.property]=!0:this.union.usesPrefixDiscriminator&&(ie[this.union.discriminator.property]=this.variant),ie}encode(t,n,ie=0){let fe=0;if(this.union.usesPrefixDiscriminator&&(fe=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(t,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,n,ie);let ae=fe;if(this.layout&&(this.layout.encode(t[this.property],n,ie+fe),ae+=this.layout.getSpan(n,ie+fe),0<=this.union.span&&ae>this.union.span))throw new Error("encoded variant overruns containing union");return ae}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}Layout$1.VariantLayout=VariantLayout;function fixBitwiseResult(c){return 0>c&&(c+=4294967296),c}class BitStructure extends Layout{constructor(t,n,ie){if(!(t instanceof UInt||t instanceof UIntBE))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof n=="string"&&ie===void 0&&(ie=n,n=!1),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,ie),this.word=t,this.msb=!!n,this.fields=[];let fe=0;this._packedSetValue=function(ae){return fe=fixBitwiseResult(ae),this},this._packedGetValue=function(){return fe}}decode(t,n=0){const ie=this.makeDestinationObject(),fe=this.word.decode(t,n);this._packedSetValue(fe);for(const ae of this.fields)ae.property!==void 0&&(ie[ae.property]=ae.decode(t));return ie}encode(t,n,ie=0){const fe=this.word.decode(n,ie);this._packedSetValue(fe);for(const ae of this.fields)if(ae.property!==void 0){const le=t[ae.property];le!==void 0&&ae.encode(le)}return this.word.encode(this._packedGetValue(),n,ie)}addField(t,n){const ie=new BitField(this,t,n);return this.fields.push(ie),ie}addBoolean(t){const n=new Boolean$1(this,t);return this.fields.push(n),n}fieldFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const n of this.fields)if(n.property===t)return n}}Layout$1.BitStructure=BitStructure;class BitField{constructor(t,n,ie){if(!(t instanceof BitStructure))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(n)||0>=n)throw new TypeError("bits must be positive integer");const fe=8*t.span,ae=t.fields.reduce((le,he)=>le+he.bits,0);if(n+ae>fe)throw new Error("bits too long for span remainder ("+(fe-ae)+" of "+fe+" remain)");this.container=t,this.bits=n,this.valueMask=(1<<n)-1,n===32&&(this.valueMask=4294967295),this.start=ae,this.container.msb&&(this.start=fe-ae-n),this.wordMask=fixBitwiseResult(this.valueMask<<this.start),this.property=ie}decode(t,n){const ie=this.container._packedGetValue();return fixBitwiseResult(ie&this.wordMask)>>>this.start}encode(t){if(typeof t!="number"||!Number.isInteger(t)||t!==fixBitwiseResult(t&this.valueMask))throw new TypeError(nameWithProperty("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const n=this.container._packedGetValue(),ie=fixBitwiseResult(t<<this.start);this.container._packedSetValue(fixBitwiseResult(n&~this.wordMask)|ie)}}Layout$1.BitField=BitField;let Boolean$1=class extends BitField{constructor(t,n){super(t,1,n)}decode(t,n){return!!super.decode(t,n)}encode(t){typeof t=="boolean"&&(t=+t),super.encode(t)}};Layout$1.Boolean=Boolean$1;let Blob$1=class extends Layout{constructor(t,n){if(!(t instanceof ExternalLayout&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let ie=-1;t instanceof ExternalLayout||(ie=t),super(ie,n),this.length=t}getSpan(t,n){let ie=this.span;return 0>ie&&(ie=this.length.decode(t,n)),ie}decode(t,n=0){let ie=this.span;return 0>ie&&(ie=this.length.decode(t,n)),uint8ArrayToBuffer(t).slice(n,n+ie)}encode(t,n,ie){let fe=this.length;if(this.length instanceof ExternalLayout&&(fe=t.length),!(t instanceof Uint8Array&&fe===t.length))throw new TypeError(nameWithProperty("Blob.encode",this)+" requires (length "+fe+") Uint8Array as src");if(ie+fe>n.length)throw new RangeError("encoding overruns Uint8Array");const ae=uint8ArrayToBuffer(t);return uint8ArrayToBuffer(n).write(ae.toString("hex"),ie,fe,"hex"),this.length instanceof ExternalLayout&&this.length.encode(fe,n,ie),fe}};Layout$1.Blob=Blob$1;class CString extends Layout{constructor(t){super(-1,t)}getSpan(t,n=0){checkUint8Array(t);let ie=n;for(;ie<t.length&&t[ie]!==0;)ie+=1;return 1+ie-n}decode(t,n=0){const ie=this.getSpan(t,n);return uint8ArrayToBuffer(t).slice(n,n+ie-1).toString("utf-8")}encode(t,n,ie=0){typeof t!="string"&&(t=String(t));const fe=buffer_1.Buffer.from(t,"utf8"),ae=fe.length;if(ie+ae>n.length)throw new RangeError("encoding overruns Buffer");const le=uint8ArrayToBuffer(n);return fe.copy(le,ie),le[ie+ae]=0,ae+1}}Layout$1.CString=CString;class UTF8 extends Layout{constructor(t,n){if(typeof t=="string"&&n===void 0&&(n=t,t=void 0),t===void 0)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,n),this.maxSpan=t}getSpan(t,n=0){return checkUint8Array(t),t.length-n}decode(t,n=0){const ie=this.getSpan(t,n);if(0<=this.maxSpan&&this.maxSpan<ie)throw new RangeError("text length exceeds maxSpan");return uint8ArrayToBuffer(t).slice(n,n+ie).toString("utf-8")}encode(t,n,ie=0){typeof t!="string"&&(t=String(t));const fe=buffer_1.Buffer.from(t,"utf8"),ae=fe.length;if(0<=this.maxSpan&&this.maxSpan<ae)throw new RangeError("text length exceeds maxSpan");if(ie+ae>n.length)throw new RangeError("encoding overruns Buffer");return fe.copy(uint8ArrayToBuffer(n),ie),ae}}Layout$1.UTF8=UTF8;class Constant extends Layout{constructor(t,n){super(0,n),this.value=t}decode(t,n){return this.value}encode(t,n,ie){return 0}}Layout$1.Constant=Constant;Layout$1.greedy=(c,t)=>new GreedyCount(c,t);var offset=Layout$1.offset=(c,t,n)=>new OffsetLayout(c,t,n),u8=Layout$1.u8=c=>new UInt(1,c),u16=Layout$1.u16=c=>new UInt(2,c);Layout$1.u24=c=>new UInt(3,c);var u32=Layout$1.u32=c=>new UInt(4,c);Layout$1.u40=c=>new UInt(5,c);Layout$1.u48=c=>new UInt(6,c);var nu64=Layout$1.nu64=c=>new NearUInt64(c);Layout$1.u16be=c=>new UIntBE(2,c);Layout$1.u24be=c=>new UIntBE(3,c);Layout$1.u32be=c=>new UIntBE(4,c);Layout$1.u40be=c=>new UIntBE(5,c);Layout$1.u48be=c=>new UIntBE(6,c);Layout$1.nu64be=c=>new NearUInt64BE(c);Layout$1.s8=c=>new Int(1,c);Layout$1.s16=c=>new Int(2,c);Layout$1.s24=c=>new Int(3,c);Layout$1.s32=c=>new Int(4,c);Layout$1.s40=c=>new Int(5,c);Layout$1.s48=c=>new Int(6,c);var ns64=Layout$1.ns64=c=>new NearInt64(c);Layout$1.s16be=c=>new IntBE(2,c);Layout$1.s24be=c=>new IntBE(3,c);Layout$1.s32be=c=>new IntBE(4,c);Layout$1.s40be=c=>new IntBE(5,c);Layout$1.s48be=c=>new IntBE(6,c);Layout$1.ns64be=c=>new NearInt64BE(c);Layout$1.f32=c=>new Float(c);Layout$1.f32be=c=>new FloatBE(c);Layout$1.f64=c=>new Double(c);Layout$1.f64be=c=>new DoubleBE(c);var struct=Layout$1.struct=(c,t,n)=>new Structure(c,t,n);Layout$1.bits=(c,t,n)=>new BitStructure(c,t,n);var seq=Layout$1.seq=(c,t,n)=>new Sequence(c,t,n);Layout$1.union=(c,t,n)=>new Union(c,t,n);Layout$1.unionLayoutDiscriminator=(c,t)=>new UnionLayoutDiscriminator(c,t);var blob=Layout$1.blob=(c,t)=>new Blob$1(c,t);Layout$1.cstr=c=>new CString(c);Layout$1.utf8=(c,t)=>new UTF8(c,t);Layout$1.constant=(c,t)=>new Constant(c,t);var browser$d={};Object.defineProperty(browser$d,"__esModule",{value:!0});function toBigIntLE(c){{const t=Buffer$7.from(c);t.reverse();const n=t.toString("hex");return n.length===0?BigInt(0):BigInt(`0x${n}`)}}var toBigIntLE_1=browser$d.toBigIntLE=toBigIntLE;function toBigIntBE(c){{const t=c.toString("hex");return t.length===0?BigInt(0):BigInt(`0x${t}`)}}browser$d.toBigIntBE=toBigIntBE;function toBufferLE(c,t){{const n=c.toString(16),ie=Buffer$7.from(n.padStart(t*2,"0").slice(0,t*2),"hex");return ie.reverse(),ie}}var toBufferLE_1=browser$d.toBufferLE=toBufferLE;function toBufferBE(c,t){{const n=c.toString(16);return Buffer$7.from(n.padStart(t*2,"0").slice(0,t*2),"hex")}}browser$d.toBufferBE=toBufferBE;class StructError extends TypeError{constructor(t,n){let ie;const{message:fe,explanation:ae,...le}=t,{path:he}=t,ye=he.length===0?fe:`At path: ${he.join(".")} -- ${fe}`;super(ae??ye),ae!=null&&(this.cause=ye),Object.assign(this,le),this.name=this.constructor.name,this.failures=()=>ie??(ie=[t,...n()])}}function isIterable(c){return isObject$1(c)&&typeof c[Symbol.iterator]=="function"}function isObject$1(c){return typeof c=="object"&&c!=null}function isNonArrayObject(c){return isObject$1(c)&&!Array.isArray(c)}function print$2(c){return typeof c=="symbol"?c.toString():typeof c=="string"?JSON.stringify(c):`${c}`}function shiftIterator(c){const{done:t,value:n}=c.next();return t?void 0:n}function toFailure(c,t,n,ie){if(c===!0)return;c===!1?c={}:typeof c=="string"&&(c={message:c});const{path:fe,branch:ae}=t,{type:le}=n,{refinement:he,message:ye=`Expected a value of type \`${le}\`${he?` with refinement \`${he}\``:""}, but received: \`${print$2(ie)}\``}=c;return{value:ie,type:le,refinement:he,key:fe[fe.length-1],path:fe,branch:ae,...c,message:ye}}function*toFailures(c,t,n,ie){isIterable(c)||(c=[c]);for(const fe of c){const ae=toFailure(fe,t,n,ie);ae&&(yield ae)}}function*run(c,t,n={}){const{path:ie=[],branch:fe=[c],coerce:ae=!1,mask:le=!1}=n,he={path:ie,branch:fe,mask:le};ae&&(c=t.coercer(c,he));let ye="valid";for(const me of t.validator(c,he))me.explanation=n.message,ye="not_valid",yield[me,void 0];for(let[me,xe,Ee]of t.entries(c,he)){const Se=run(xe,Ee,{path:me===void 0?ie:[...ie,me],branch:me===void 0?fe:[...fe,xe],coerce:ae,mask:le,message:n.message});for(const Me of Se)Me[0]?(ye=Me[0].refinement!=null?"not_refined":"not_valid",yield[Me[0],void 0]):ae&&(xe=Me[1],me===void 0?c=xe:c instanceof Map?c.set(me,xe):c instanceof Set?c.add(xe):isObject$1(c)&&(xe!==void 0||me in c)&&(c[me]=xe))}if(ye!=="not_valid")for(const me of t.refiner(c,he))me.explanation=n.message,ye="not_refined",yield[me,void 0];ye==="valid"&&(yield[void 0,c])}let Struct$1=class{constructor(t){const{type:n,schema:ie,validator:fe,refiner:ae,coercer:le=ye=>ye,entries:he=function*(){}}=t;this.type=n,this.schema=ie,this.entries=he,this.coercer=le,fe?this.validator=(ye,me)=>{const xe=fe(ye,me);return toFailures(xe,me,this,ye)}:this.validator=()=>[],ae?this.refiner=(ye,me)=>{const xe=ae(ye,me);return toFailures(xe,me,this,ye)}:this.refiner=()=>[]}assert(t,n){return assert$a(t,this,n)}create(t,n){return create(t,this,n)}is(t){return is(t,this)}mask(t,n){return mask(t,this,n)}validate(t,n={}){return validate$1(t,this,n)}};function assert$a(c,t,n){const ie=validate$1(c,t,{message:n});if(ie[0])throw ie[0]}function create(c,t,n){const ie=validate$1(c,t,{coerce:!0,message:n});if(ie[0])throw ie[0];return ie[1]}function mask(c,t,n){const ie=validate$1(c,t,{coerce:!0,mask:!0,message:n});if(ie[0])throw ie[0];return ie[1]}function is(c,t){return!validate$1(c,t)[0]}function validate$1(c,t,n={}){const ie=run(c,t,n),fe=shiftIterator(ie);return fe[0]?[new StructError(fe[0],function*(){for(const le of ie)le[0]&&(yield le[0])}),void 0]:[void 0,fe[1]]}function define(c,t){return new Struct$1({type:c,schema:null,validator:t})}function any(){return define("any",()=>!0)}function array(c){return new Struct$1({type:"array",schema:c,*entries(t){if(c&&Array.isArray(t))for(const[n,ie]of t.entries())yield[n,ie,c]},coercer(t){return Array.isArray(t)?t.slice():t},validator(t){return Array.isArray(t)||`Expected an array value, but received: ${print$2(t)}`}})}function boolean(){return define("boolean",c=>typeof c=="boolean")}function instance(c){return define("instance",t=>t instanceof c||`Expected a \`${c.name}\` instance, but received: ${print$2(t)}`)}function literal(c){const t=print$2(c),n=typeof c;return new Struct$1({type:"literal",schema:n==="string"||n==="number"||n==="boolean"?c:null,validator(ie){return ie===c||`Expected the literal \`${t}\`, but received: ${print$2(ie)}`}})}function never(){return define("never",()=>!1)}function nullable(c){return new Struct$1({...c,validator:(t,n)=>t===null||c.validator(t,n),refiner:(t,n)=>t===null||c.refiner(t,n)})}function number(){return define("number",c=>typeof c=="number"&&!isNaN(c)||`Expected a number, but received: ${print$2(c)}`)}function optional(c){return new Struct$1({...c,validator:(t,n)=>t===void 0||c.validator(t,n),refiner:(t,n)=>t===void 0||c.refiner(t,n)})}function record(c,t){return new Struct$1({type:"record",schema:null,*entries(n){if(isObject$1(n))for(const ie in n){const fe=n[ie];yield[ie,ie,c],yield[ie,fe,t]}},validator(n){return isNonArrayObject(n)||`Expected an object, but received: ${print$2(n)}`},coercer(n){return isNonArrayObject(n)?{...n}:n}})}function string(){return define("string",c=>typeof c=="string"||`Expected a string, but received: ${print$2(c)}`)}function tuple(c){const t=never();return new Struct$1({type:"tuple",schema:null,*entries(n){if(Array.isArray(n)){const ie=Math.max(c.length,n.length);for(let fe=0;fe<ie;fe++)yield[fe,n[fe],c[fe]||t]}},validator(n){return Array.isArray(n)||`Expected an array, but received: ${print$2(n)}`},coercer(n){return Array.isArray(n)?n.slice():n}})}function type$1(c){const t=Object.keys(c);return new Struct$1({type:"type",schema:c,*entries(n){if(isObject$1(n))for(const ie of t)yield[ie,n[ie],c[ie]]},validator(n){return isNonArrayObject(n)||`Expected an object, but received: ${print$2(n)}`},coercer(n){return isNonArrayObject(n)?{...n}:n}})}function union(c){const t=c.map(n=>n.type).join(" | ");return new Struct$1({type:"union",schema:null,coercer(n,ie){for(const fe of c){const[ae,le]=fe.validate(n,{coerce:!0,mask:ie.mask});if(!ae)return le}return n},validator(n,ie){const fe=[];for(const ae of c){const[...le]=run(n,ae,ie),[he]=le;if(he[0])for(const[ye]of le)ye&&fe.push(ye);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${print$2(n)}`,...fe]}})}function unknown(){return define("unknown",()=>!0)}function coerce(c,t,n){return new Struct$1({...c,coercer:(ie,fe)=>is(ie,t)?c.coercer(n(ie,fe),fe):c.coercer(ie,fe)})}var getRandomValues,rnds8=new Uint8Array(16);function rng(){if(!getRandomValues&&(getRandomValues=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!getRandomValues))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return getRandomValues(rnds8)}const REGEX$1=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function validate(c){return typeof c=="string"&&REGEX$1.test(c)}var byteToHex=[];for(var i$2=0;i$2<256;++i$2)byteToHex.push((i$2+256).toString(16).substr(1));function stringify(c){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(byteToHex[c[t+0]]+byteToHex[c[t+1]]+byteToHex[c[t+2]]+byteToHex[c[t+3]]+"-"+byteToHex[c[t+4]]+byteToHex[c[t+5]]+"-"+byteToHex[c[t+6]]+byteToHex[c[t+7]]+"-"+byteToHex[c[t+8]]+byteToHex[c[t+9]]+"-"+byteToHex[c[t+10]]+byteToHex[c[t+11]]+byteToHex[c[t+12]]+byteToHex[c[t+13]]+byteToHex[c[t+14]]+byteToHex[c[t+15]]).toLowerCase();if(!validate(n))throw TypeError("Stringified UUID is invalid");return n}var _nodeId,_clockseq,_lastMSecs=0,_lastNSecs=0;function v1(c,t,n){var ie=t&&n||0,fe=t||new Array(16);c=c||{};var ae=c.node||_nodeId,le=c.clockseq!==void 0?c.clockseq:_clockseq;if(ae==null||le==null){var he=c.random||(c.rng||rng)();ae==null&&(ae=_nodeId=[he[0]|1,he[1],he[2],he[3],he[4],he[5]]),le==null&&(le=_clockseq=(he[6]<<8|he[7])&16383)}var ye=c.msecs!==void 0?c.msecs:Date.now(),me=c.nsecs!==void 0?c.nsecs:_lastNSecs+1,xe=ye-_lastMSecs+(me-_lastNSecs)/1e4;if(xe<0&&c.clockseq===void 0&&(le=le+1&16383),(xe<0||ye>_lastMSecs)&&c.nsecs===void 0&&(me=0),me>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs=ye,_lastNSecs=me,_clockseq=le,ye+=122192928e5;var Ee=((ye&268435455)*1e4+me)%4294967296;fe[ie++]=Ee>>>24&255,fe[ie++]=Ee>>>16&255,fe[ie++]=Ee>>>8&255,fe[ie++]=Ee&255;var Se=ye/4294967296*1e4&268435455;fe[ie++]=Se>>>8&255,fe[ie++]=Se&255,fe[ie++]=Se>>>24&15|16,fe[ie++]=Se>>>16&255,fe[ie++]=le>>>8|128,fe[ie++]=le&255;for(var Me=0;Me<6;++Me)fe[ie+Me]=ae[Me];return t||stringify(fe)}function parse$1(c){if(!validate(c))throw TypeError("Invalid UUID");var t,n=new Uint8Array(16);return n[0]=(t=parseInt(c.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=t&255,n[4]=(t=parseInt(c.slice(9,13),16))>>>8,n[5]=t&255,n[6]=(t=parseInt(c.slice(14,18),16))>>>8,n[7]=t&255,n[8]=(t=parseInt(c.slice(19,23),16))>>>8,n[9]=t&255,n[10]=(t=parseInt(c.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=t&255,n}function stringToBytes(c){c=unescape(encodeURIComponent(c));for(var t=[],n=0;n<c.length;++n)t.push(c.charCodeAt(n));return t}var DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",URL$1="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function v35(c,t,n){function ie(fe,ae,le,he){if(typeof fe=="string"&&(fe=stringToBytes(fe)),typeof ae=="string"&&(ae=parse$1(ae)),ae.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var ye=new Uint8Array(16+fe.length);if(ye.set(ae),ye.set(fe,ae.length),ye=n(ye),ye[6]=ye[6]&15|t,ye[8]=ye[8]&63|128,le){he=he||0;for(var me=0;me<16;++me)le[he+me]=ye[me];return le}return stringify(ye)}try{ie.name=c}catch{}return ie.DNS=DNS,ie.URL=URL$1,ie}function md5$3(c){if(typeof c=="string"){var t=unescape(encodeURIComponent(c));c=new Uint8Array(t.length);for(var n=0;n<t.length;++n)c[n]=t.charCodeAt(n)}return md5ToHexEncodedArray(wordsToMd5(bytesToWords(c),c.length*8))}function md5ToHexEncodedArray(c){for(var t=[],n=c.length*32,ie="0123456789abcdef",fe=0;fe<n;fe+=8){var ae=c[fe>>5]>>>fe%32&255,le=parseInt(ie.charAt(ae>>>4&15)+ie.charAt(ae&15),16);t.push(le)}return t}function getOutputLength(c){return(c+64>>>9<<4)+14+1}function wordsToMd5(c,t){c[t>>5]|=128<<t%32,c[getOutputLength(t)-1]=t;for(var n=1732584193,ie=-271733879,fe=-1732584194,ae=271733878,le=0;le<c.length;le+=16){var he=n,ye=ie,me=fe,xe=ae;n=md5ff(n,ie,fe,ae,c[le],7,-680876936),ae=md5ff(ae,n,ie,fe,c[le+1],12,-389564586),fe=md5ff(fe,ae,n,ie,c[le+2],17,606105819),ie=md5ff(ie,fe,ae,n,c[le+3],22,-1044525330),n=md5ff(n,ie,fe,ae,c[le+4],7,-176418897),ae=md5ff(ae,n,ie,fe,c[le+5],12,1200080426),fe=md5ff(fe,ae,n,ie,c[le+6],17,-1473231341),ie=md5ff(ie,fe,ae,n,c[le+7],22,-45705983),n=md5ff(n,ie,fe,ae,c[le+8],7,1770035416),ae=md5ff(ae,n,ie,fe,c[le+9],12,-1958414417),fe=md5ff(fe,ae,n,ie,c[le+10],17,-42063),ie=md5ff(ie,fe,ae,n,c[le+11],22,-1990404162),n=md5ff(n,ie,fe,ae,c[le+12],7,1804603682),ae=md5ff(ae,n,ie,fe,c[le+13],12,-40341101),fe=md5ff(fe,ae,n,ie,c[le+14],17,-1502002290),ie=md5ff(ie,fe,ae,n,c[le+15],22,1236535329),n=md5gg(n,ie,fe,ae,c[le+1],5,-165796510),ae=md5gg(ae,n,ie,fe,c[le+6],9,-1069501632),fe=md5gg(fe,ae,n,ie,c[le+11],14,643717713),ie=md5gg(ie,fe,ae,n,c[le],20,-373897302),n=md5gg(n,ie,fe,ae,c[le+5],5,-701558691),ae=md5gg(ae,n,ie,fe,c[le+10],9,38016083),fe=md5gg(fe,ae,n,ie,c[le+15],14,-660478335),ie=md5gg(ie,fe,ae,n,c[le+4],20,-405537848),n=md5gg(n,ie,fe,ae,c[le+9],5,568446438),ae=md5gg(ae,n,ie,fe,c[le+14],9,-1019803690),fe=md5gg(fe,ae,n,ie,c[le+3],14,-187363961),ie=md5gg(ie,fe,ae,n,c[le+8],20,1163531501),n=md5gg(n,ie,fe,ae,c[le+13],5,-1444681467),ae=md5gg(ae,n,ie,fe,c[le+2],9,-51403784),fe=md5gg(fe,ae,n,ie,c[le+7],14,1735328473),ie=md5gg(ie,fe,ae,n,c[le+12],20,-1926607734),n=md5hh(n,ie,fe,ae,c[le+5],4,-378558),ae=md5hh(ae,n,ie,fe,c[le+8],11,-2022574463),fe=md5hh(fe,ae,n,ie,c[le+11],16,1839030562),ie=md5hh(ie,fe,ae,n,c[le+14],23,-35309556),n=md5hh(n,ie,fe,ae,c[le+1],4,-1530992060),ae=md5hh(ae,n,ie,fe,c[le+4],11,1272893353),fe=md5hh(fe,ae,n,ie,c[le+7],16,-155497632),ie=md5hh(ie,fe,ae,n,c[le+10],23,-1094730640),n=md5hh(n,ie,fe,ae,c[le+13],4,681279174),ae=md5hh(ae,n,ie,fe,c[le],11,-358537222),fe=md5hh(fe,ae,n,ie,c[le+3],16,-722521979),ie=md5hh(ie,fe,ae,n,c[le+6],23,76029189),n=md5hh(n,ie,fe,ae,c[le+9],4,-640364487),ae=md5hh(ae,n,ie,fe,c[le+12],11,-421815835),fe=md5hh(fe,ae,n,ie,c[le+15],16,530742520),ie=md5hh(ie,fe,ae,n,c[le+2],23,-995338651),n=md5ii(n,ie,fe,ae,c[le],6,-198630844),ae=md5ii(ae,n,ie,fe,c[le+7],10,1126891415),fe=md5ii(fe,ae,n,ie,c[le+14],15,-1416354905),ie=md5ii(ie,fe,ae,n,c[le+5],21,-57434055),n=md5ii(n,ie,fe,ae,c[le+12],6,1700485571),ae=md5ii(ae,n,ie,fe,c[le+3],10,-1894986606),fe=md5ii(fe,ae,n,ie,c[le+10],15,-1051523),ie=md5ii(ie,fe,ae,n,c[le+1],21,-2054922799),n=md5ii(n,ie,fe,ae,c[le+8],6,1873313359),ae=md5ii(ae,n,ie,fe,c[le+15],10,-30611744),fe=md5ii(fe,ae,n,ie,c[le+6],15,-1560198380),ie=md5ii(ie,fe,ae,n,c[le+13],21,1309151649),n=md5ii(n,ie,fe,ae,c[le+4],6,-145523070),ae=md5ii(ae,n,ie,fe,c[le+11],10,-1120210379),fe=md5ii(fe,ae,n,ie,c[le+2],15,718787259),ie=md5ii(ie,fe,ae,n,c[le+9],21,-343485551),n=safeAdd(n,he),ie=safeAdd(ie,ye),fe=safeAdd(fe,me),ae=safeAdd(ae,xe)}return[n,ie,fe,ae]}function bytesToWords(c){if(c.length===0)return[];for(var t=c.length*8,n=new Uint32Array(getOutputLength(t)),ie=0;ie<t;ie+=8)n[ie>>5]|=(c[ie/8]&255)<<ie%32;return n}function safeAdd(c,t){var n=(c&65535)+(t&65535),ie=(c>>16)+(t>>16)+(n>>16);return ie<<16|n&65535}function bitRotateLeft(c,t){return c<<t|c>>>32-t}function md5cmn(c,t,n,ie,fe,ae){return safeAdd(bitRotateLeft(safeAdd(safeAdd(t,c),safeAdd(ie,ae)),fe),n)}function md5ff(c,t,n,ie,fe,ae,le){return md5cmn(t&n|~t&ie,c,t,fe,ae,le)}function md5gg(c,t,n,ie,fe,ae,le){return md5cmn(t&ie|n&~ie,c,t,fe,ae,le)}function md5hh(c,t,n,ie,fe,ae,le){return md5cmn(t^n^ie,c,t,fe,ae,le)}function md5ii(c,t,n,ie,fe,ae,le){return md5cmn(n^(t|~ie),c,t,fe,ae,le)}var v3=v35("v3",48,md5$3);function v4(c,t,n){c=c||{};var ie=c.random||(c.rng||rng)();if(ie[6]=ie[6]&15|64,ie[8]=ie[8]&63|128,t){n=n||0;for(var fe=0;fe<16;++fe)t[n+fe]=ie[fe];return t}return stringify(ie)}function f$1(c,t,n,ie){switch(c){case 0:return t&n^~t&ie;case 1:return t^n^ie;case 2:return t&n^t&ie^n&ie;case 3:return t^n^ie}}function ROTL(c,t){return c<<t|c>>>32-t}function sha1$3(c){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof c=="string"){var ie=unescape(encodeURIComponent(c));c=[];for(var fe=0;fe<ie.length;++fe)c.push(ie.charCodeAt(fe))}else Array.isArray(c)||(c=Array.prototype.slice.call(c));c.push(128);for(var ae=c.length/4+2,le=Math.ceil(ae/16),he=new Array(le),ye=0;ye<le;++ye){for(var me=new Uint32Array(16),xe=0;xe<16;++xe)me[xe]=c[ye*64+xe*4]<<24|c[ye*64+xe*4+1]<<16|c[ye*64+xe*4+2]<<8|c[ye*64+xe*4+3];he[ye]=me}he[le-1][14]=(c.length-1)*8/Math.pow(2,32),he[le-1][14]=Math.floor(he[le-1][14]),he[le-1][15]=(c.length-1)*8&4294967295;for(var Ee=0;Ee<le;++Ee){for(var Se=new Uint32Array(80),Me=0;Me<16;++Me)Se[Me]=he[Ee][Me];for(var Be=16;Be<80;++Be)Se[Be]=ROTL(Se[Be-3]^Se[Be-8]^Se[Be-14]^Se[Be-16],1);for(var $e=n[0],Ce=n[1],ke=n[2],Pe=n[3],Ue=n[4],qe=0;qe<80;++qe){var He=Math.floor(qe/20),Ve=ROTL($e,5)+f$1(He,Ce,ke,Pe)+Ue+t[He]+Se[qe]>>>0;Ue=Pe,Pe=ke,ke=ROTL(Ce,30)>>>0,Ce=$e,$e=Ve}n[0]=n[0]+$e>>>0,n[1]=n[1]+Ce>>>0,n[2]=n[2]+ke>>>0,n[3]=n[3]+Pe>>>0,n[4]=n[4]+Ue>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,n[0]&255,n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,n[1]&255,n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,n[2]&255,n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,n[3]&255,n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,n[4]&255]}var v5=v35("v5",80,sha1$3);const nil="00000000-0000-0000-0000-000000000000";function version$5(c){if(!validate(c))throw TypeError("Invalid UUID");return parseInt(c.substr(14,1),16)}const esmBrowser=Object.freeze(Object.defineProperty({__proto__:null,NIL:nil,parse:parse$1,stringify,v1,v3,v4,v5,validate,version:version$5},Symbol.toStringTag,{value:"Module"})),require$$0$2=getAugmentedNamespace(esmBrowser),uuid$1=require$$0$2.v4,generateRequest$1=function(c,t,n,ie){if(typeof c!="string")throw new TypeError(c+" must be a string");ie=ie||{};const fe=typeof ie.version=="number"?ie.version:2;if(fe!==1&&fe!==2)throw new TypeError(fe+" must be 1 or 2");const ae={method:c};if(fe===2&&(ae.jsonrpc="2.0"),t){if(typeof t!="object"&&!Array.isArray(t))throw new TypeError(t+" must be an object, array or omitted");ae.params=t}if(typeof n>"u"){const le=typeof ie.generator=="function"?ie.generator:function(){return uuid$1()};ae.id=le(ae,ie)}else fe===2&&n===null?ie.notificationIdNull&&(ae.id=null):ae.id=n;return ae};var generateRequest_1=generateRequest$1;const uuid=require$$0$2.v4,generateRequest=generateRequest_1,ClientBrowser=function(c,t){if(!(this instanceof ClientBrowser))return new ClientBrowser(c,t);t||(t={}),this.options={reviver:typeof t.reviver<"u"?t.reviver:null,replacer:typeof t.replacer<"u"?t.replacer:null,generator:typeof t.generator<"u"?t.generator:function(){return uuid()},version:typeof t.version<"u"?t.version:2,notificationIdNull:typeof t.notificationIdNull=="boolean"?t.notificationIdNull:!1},this.callServer=c};var browser$c=ClientBrowser;ClientBrowser.prototype.request=function(c,t,n,ie){const fe=this;let ae=null;const le=Array.isArray(c)&&typeof t=="function";if(this.options.version===1&&le)throw new TypeError("JSON-RPC 1.0 does not support batching");if(le||!le&&c&&typeof c=="object"&&typeof t=="function")ie=t,ae=c;else{typeof n=="function"&&(ie=n,n=void 0);const me=typeof ie=="function";try{ae=generateRequest(c,t,n,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(xe){if(me)return ie(xe);throw xe}if(!me)return ae}let ye;try{ye=JSON.stringify(ae,this.options.replacer)}catch(me){return ie(me)}return this.callServer(ye,function(me,xe){fe._parseResponse(me,xe,ie)}),ae};ClientBrowser.prototype._parseResponse=function(c,t,n){if(c){n(c);return}if(!t)return n();let ie;try{ie=JSON.parse(t,this.options.reviver)}catch(fe){return n(fe)}if(n.length===3)if(Array.isArray(ie)){const fe=function(le){return typeof le.error<"u"},ae=function(le){return!fe(le)};return n(null,ie.filter(fe),ie.filter(ae))}else return n(null,ie.error,ie.result);n(null,ie)};const RpcClient=getDefaultExportFromCjs$2(browser$c);var eventemitter3={exports:{}};(function(c){var t=Object.prototype.hasOwnProperty,n="~";function ie(){}Object.create&&(ie.prototype=Object.create(null),new ie().__proto__||(n=!1));function fe(ye,me,xe){this.fn=ye,this.context=me,this.once=xe||!1}function ae(ye,me,xe,Ee,Se){if(typeof xe!="function")throw new TypeError("The listener must be a function");var Me=new fe(xe,Ee||ye,Se),Be=n?n+me:me;return ye._events[Be]?ye._events[Be].fn?ye._events[Be]=[ye._events[Be],Me]:ye._events[Be].push(Me):(ye._events[Be]=Me,ye._eventsCount++),ye}function le(ye,me){--ye._eventsCount===0?ye._events=new ie:delete ye._events[me]}function he(){this._events=new ie,this._eventsCount=0}he.prototype.eventNames=function(){var me=[],xe,Ee;if(this._eventsCount===0)return me;for(Ee in xe=this._events)t.call(xe,Ee)&&me.push(n?Ee.slice(1):Ee);return Object.getOwnPropertySymbols?me.concat(Object.getOwnPropertySymbols(xe)):me},he.prototype.listeners=function(me){var xe=n?n+me:me,Ee=this._events[xe];if(!Ee)return[];if(Ee.fn)return[Ee.fn];for(var Se=0,Me=Ee.length,Be=new Array(Me);Se<Me;Se++)Be[Se]=Ee[Se].fn;return Be},he.prototype.listenerCount=function(me){var xe=n?n+me:me,Ee=this._events[xe];return Ee?Ee.fn?1:Ee.length:0},he.prototype.emit=function(me,xe,Ee,Se,Me,Be){var $e=n?n+me:me;if(!this._events[$e])return!1;var Ce=this._events[$e],ke=arguments.length,Pe,Ue;if(Ce.fn){switch(Ce.once&&this.removeListener(me,Ce.fn,void 0,!0),ke){case 1:return Ce.fn.call(Ce.context),!0;case 2:return Ce.fn.call(Ce.context,xe),!0;case 3:return Ce.fn.call(Ce.context,xe,Ee),!0;case 4:return Ce.fn.call(Ce.context,xe,Ee,Se),!0;case 5:return Ce.fn.call(Ce.context,xe,Ee,Se,Me),!0;case 6:return Ce.fn.call(Ce.context,xe,Ee,Se,Me,Be),!0}for(Ue=1,Pe=new Array(ke-1);Ue<ke;Ue++)Pe[Ue-1]=arguments[Ue];Ce.fn.apply(Ce.context,Pe)}else{var qe=Ce.length,He;for(Ue=0;Ue<qe;Ue++)switch(Ce[Ue].once&&this.removeListener(me,Ce[Ue].fn,void 0,!0),ke){case 1:Ce[Ue].fn.call(Ce[Ue].context);break;case 2:Ce[Ue].fn.call(Ce[Ue].context,xe);break;case 3:Ce[Ue].fn.call(Ce[Ue].context,xe,Ee);break;case 4:Ce[Ue].fn.call(Ce[Ue].context,xe,Ee,Se);break;default:if(!Pe)for(He=1,Pe=new Array(ke-1);He<ke;He++)Pe[He-1]=arguments[He];Ce[Ue].fn.apply(Ce[Ue].context,Pe)}}return!0},he.prototype.on=function(me,xe,Ee){return ae(this,me,xe,Ee,!1)},he.prototype.once=function(me,xe,Ee){return ae(this,me,xe,Ee,!0)},he.prototype.removeListener=function(me,xe,Ee,Se){var Me=n?n+me:me;if(!this._events[Me])return this;if(!xe)return le(this,Me),this;var Be=this._events[Me];if(Be.fn)Be.fn===xe&&(!Se||Be.once)&&(!Ee||Be.context===Ee)&&le(this,Me);else{for(var $e=0,Ce=[],ke=Be.length;$e<ke;$e++)(Be[$e].fn!==xe||Se&&!Be[$e].once||Ee&&Be[$e].context!==Ee)&&Ce.push(Be[$e]);Ce.length?this._events[Me]=Ce.length===1?Ce[0]:Ce:le(this,Me)}return this},he.prototype.removeAllListeners=function(me){var xe;return me?(xe=n?n+me:me,this._events[xe]&&le(this,xe)):(this._events=new ie,this._eventsCount=0),this},he.prototype.off=he.prototype.removeListener,he.prototype.addListener=he.prototype.on,he.prefixed=n,he.EventEmitter=he,c.exports=he})(eventemitter3);var eventemitter3Exports=eventemitter3.exports;const EventEmitter=getDefaultExportFromCjs$2(eventemitter3Exports);var WebSocketBrowserImpl=class extends EventEmitter{constructor(t,n,ie){super();Xn(this,"socket");this.socket=new window.WebSocket(t,ie),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=fe=>this.emit("message",fe.data),this.socket.onerror=fe=>this.emit("error",fe),this.socket.onclose=fe=>{this.emit("close",fe.code,fe.reason)}}send(t,n,ie){const fe=ie||n;try{this.socket.send(t),fe()}catch(ae){fe(ae)}}close(t,n){this.socket.close(t,n)}addEventListener(t,n,ie){this.socket.addEventListener(t,n,ie)}};function WebSocket(c,t){return new WebSocketBrowserImpl(c,t)}var DefaultDataPack=class{encode(c){return JSON.stringify(c)}decode(c){return JSON.parse(c)}},CommonClient=class extends EventEmitter{constructor(t,n="ws://localhost:8080",{autoconnect:ie=!0,reconnect:fe=!0,reconnect_interval:ae=1e3,max_reconnects:le=5,...he}={},ye,me){super();Xn(this,"address");Xn(this,"rpc_id");Xn(this,"queue");Xn(this,"options");Xn(this,"autoconnect");Xn(this,"ready");Xn(this,"reconnect");Xn(this,"reconnect_timer_id");Xn(this,"reconnect_interval");Xn(this,"max_reconnects");Xn(this,"rest_options");Xn(this,"current_reconnects");Xn(this,"generate_request_id");Xn(this,"socket");Xn(this,"webSocketFactory");Xn(this,"dataPack");this.webSocketFactory=t,this.queue={},this.rpc_id=0,this.address=n,this.autoconnect=ie,this.ready=!1,this.reconnect=fe,this.reconnect_timer_id=void 0,this.reconnect_interval=ae,this.max_reconnects=le,this.rest_options=he,this.current_reconnects=0,this.generate_request_id=ye||(()=>typeof this.rpc_id=="number"?++this.rpc_id:Number(this.rpc_id)+1),me?this.dataPack=me:this.dataPack=new DefaultDataPack,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(t,n,ie,fe){return!fe&&typeof ie=="object"&&(fe=ie,ie=null),new Promise((ae,le)=>{if(!this.ready)return le(new Error("socket not ready"));const he=this.generate_request_id(t,n),ye={jsonrpc:"2.0",method:t,params:n||void 0,id:he};this.socket.send(this.dataPack.encode(ye),fe,me=>{if(me)return le(me);this.queue[he]={promise:[ae,le]},ie&&(this.queue[he].timeout=setTimeout(()=>{delete this.queue[he],le(new Error("reply timeout"))},ie))})})}async login(t){const n=await this.call("rpc.login",t);if(!n)throw new Error("authentication failed");return n}async listMethods(){return await this.call("__listMethods")}notify(t,n){return new Promise((ie,fe)=>{if(!this.ready)return fe(new Error("socket not ready"));const ae={jsonrpc:"2.0",method:t,params:n};this.socket.send(this.dataPack.encode(ae),le=>{if(le)return fe(le);ie()})})}async subscribe(t){typeof t=="string"&&(t=[t]);const n=await this.call("rpc.on",t);if(typeof t=="string"&&n[t]!=="ok")throw new Error("Failed subscribing to an event '"+t+"' with: "+n[t]);return n}async unsubscribe(t){typeof t=="string"&&(t=[t]);const n=await this.call("rpc.off",t);if(typeof t=="string"&&n[t]!=="ok")throw new Error("Failed unsubscribing from an event with: "+n);return n}close(t,n){this.socket&&this.socket.close(t||1e3,n)}setAutoReconnect(t){this.reconnect=t}setReconnectInterval(t){this.reconnect_interval=t}setMaxReconnects(t){this.max_reconnects=t}getCurrentReconnects(){return this.current_reconnects}getMaxReconnects(){return this.max_reconnects}isReconnecting(){return this.reconnect_timer_id!==void 0}willReconnect(){return this.reconnect&&(this.max_reconnects===0||this.current_reconnects<this.max_reconnects)}_connect(t,n){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(t,n),this.socket.addEventListener("open",()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0}),this.socket.addEventListener("message",({data:ie})=>{ie instanceof ArrayBuffer&&(ie=Buffer$1$1.from(ie).toString());try{ie=this.dataPack.decode(ie)}catch{return}if(ie.notification&&this.listeners(ie.notification).length){if(!Object.keys(ie.params).length)return this.emit(ie.notification);const fe=[ie.notification];if(ie.params.constructor===Object)fe.push(ie.params);else for(let ae=0;ae<ie.params.length;ae++)fe.push(ie.params[ae]);return Promise.resolve().then(()=>{this.emit.apply(this,fe)})}if(!this.queue[ie.id])return ie.method?Promise.resolve().then(()=>{this.emit(ie.method,ie==null?void 0:ie.params)}):void 0;"error"in ie=="result"in ie&&this.queue[ie.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[ie.id].timeout&&clearTimeout(this.queue[ie.id].timeout),ie.error?this.queue[ie.id].promise[1](ie.error):this.queue[ie.id].promise[0](ie.result),delete this.queue[ie.id]}),this.socket.addEventListener("error",ie=>this.emit("error",ie)),this.socket.addEventListener("close",({code:ie,reason:fe})=>{this.ready&&setTimeout(()=>this.emit("close",ie,fe),0),this.ready=!1,this.socket=void 0,ie!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)?this.reconnect_timer_id=setTimeout(()=>this._connect(t,n),this.reconnect_interval):this.reconnect&&this.max_reconnects>0&&this.current_reconnects>=this.max_reconnects&&setTimeout(()=>this.emit("max_reconnects_reached",ie,fe),1))})}};class HMAC extends Hash{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,ahash(t);const ie=toBytes(n);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const fe=this.blockLen,ae=new Uint8Array(fe);ae.set(ie.length>fe?t.create().update(ie).digest():ie);for(let le=0;le<ae.length;le++)ae[le]^=54;this.iHash.update(ae),this.oHash=t.create();for(let le=0;le<ae.length;le++)ae[le]^=106;this.oHash.update(ae),clean(ae)}update(t){return aexists(this),this.iHash.update(t),this}digestInto(t){aexists(this),abytes(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:ie,finished:fe,destroyed:ae,blockLen:le,outputLen:he}=this;return t=t,t.finished=fe,t.destroyed=ae,t.blockLen=le,t.outputLen=he,t.oHash=n._cloneInto(t.oHash),t.iHash=ie._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const hmac=(c,t,n)=>new HMAC(c,t).update(n).digest();hmac.create=(c,t)=>new HMAC(c,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const divNearest=(c,t)=>(c+(c>=0?t:-t)/_2n$1)/t;function _splitEndoScalar(c,t,n){const[[ie,fe],[ae,le]]=t,he=divNearest(le*c,n),ye=divNearest(-fe*c,n);let me=c-he*ie-ye*ae,xe=-he*fe-ye*le;const Ee=me<_0n,Se=xe<_0n;Ee&&(me=-me),Se&&(xe=-xe);const Me=bitMask(Math.ceil(bitLen(n)/2))+_1n;if(me<_0n||me>=Me||xe<_0n||xe>=Me)throw new Error("splitScalar (endomorphism): failed, k="+c);return{k1neg:Ee,k1:me,k2neg:Se,k2:xe}}function validateSigFormat(c){if(!["compact","recovered","der"].includes(c))throw new Error('Signature format must be "compact", "recovered", or "der"');return c}function validateSigOpts(c,t){const n={};for(let ie of Object.keys(t))n[ie]=c[ie]===void 0?t[ie]:c[ie];return _abool2(n.lowS,"lowS"),_abool2(n.prehash,"prehash"),n.format!==void 0&&validateSigFormat(n.format),n}class DERErr extends Error{constructor(t=""){super(t)}}const DER={Err:DERErr,_tlv:{encode:(c,t)=>{const{Err:n}=DER;if(c<0||c>256)throw new n("tlv.encode: wrong tag");if(t.length&1)throw new n("tlv.encode: unpadded data");const ie=t.length/2,fe=numberToHexUnpadded(ie);if(fe.length/2&128)throw new n("tlv.encode: long form length too big");const ae=ie>127?numberToHexUnpadded(fe.length/2|128):"";return numberToHexUnpadded(c)+ae+fe+t},decode(c,t){const{Err:n}=DER;let ie=0;if(c<0||c>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[ie++]!==c)throw new n("tlv.decode: wrong tlv");const fe=t[ie++],ae=!!(fe&128);let le=0;if(!ae)le=fe;else{const ye=fe&127;if(!ye)throw new n("tlv.decode(long): indefinite length not supported");if(ye>4)throw new n("tlv.decode(long): byte length is too big");const me=t.subarray(ie,ie+ye);if(me.length!==ye)throw new n("tlv.decode: length bytes not complete");if(me[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const xe of me)le=le<<8|xe;if(ie+=ye,le<128)throw new n("tlv.decode(long): not minimal encoding")}const he=t.subarray(ie,ie+le);if(he.length!==le)throw new n("tlv.decode: wrong value length");return{v:he,l:t.subarray(ie+le)}}},_int:{encode(c){const{Err:t}=DER;if(c<_0n)throw new t("integer: negative integers are not allowed");let n=numberToHexUnpadded(c);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(c){const{Err:t}=DER;if(c[0]&128)throw new t("invalid signature integer: negative");if(c[0]===0&&!(c[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return bytesToNumberBE(c)}},toSig(c){const{Err:t,_int:n,_tlv:ie}=DER,fe=ensureBytes("signature",c),{v:ae,l:le}=ie.decode(48,fe);if(le.length)throw new t("invalid signature: left bytes after parsing");const{v:he,l:ye}=ie.decode(2,ae),{v:me,l:xe}=ie.decode(2,ye);if(xe.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(he),s:n.decode(me)}},hexFromSig(c){const{_tlv:t,_int:n}=DER,ie=t.encode(2,n.encode(c.r)),fe=t.encode(2,n.encode(c.s)),ae=ie+fe;return t.encode(48,ae)}},_0n=BigInt(0),_1n=BigInt(1),_2n$1=BigInt(2),_3n=BigInt(3),_4n=BigInt(4);function _normFnElement(c,t){const{BYTES:n}=c;let ie;if(typeof t=="bigint")ie=t;else{let fe=ensureBytes("private key",t);try{ie=c.fromBytes(fe)}catch{throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof t}`)}}if(!c.isValidNot0(ie))throw new Error("invalid private key: out of range [1..N-1]");return ie}function weierstrassN(c,t={}){const n=_createCurveFields("weierstrass",c,t),{Fp:ie,Fn:fe}=n;let ae=n.CURVE;const{h:le,n:he}=ae;_validateObject(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:ye}=t;if(ye&&(!ie.is0(ae.a)||typeof ye.beta!="bigint"||!Array.isArray(ye.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const me=getWLengths(ie,fe);function xe(){if(!ie.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function Ee(se,ce,de){const{x:pe,y:ve}=ce.toAffine(),we=ie.toBytes(pe);if(_abool2(de,"isCompressed"),de){xe();const Ae=!ie.isOdd(ve);return concatBytes(pprefix(Ae),we)}else return concatBytes(Uint8Array.of(4),we,ie.toBytes(ve))}function Se(se){_abytes2(se,void 0,"Point");const{publicKey:ce,publicKeyUncompressed:de}=me,pe=se.length,ve=se[0],we=se.subarray(1);if(pe===ce&&(ve===2||ve===3)){const Ae=ie.fromBytes(we);if(!ie.isValid(Ae))throw new Error("bad point: is not on curve, wrong x");const ge=$e(Ae);let ue;try{ue=ie.sqrt(ge)}catch(Ne){const Fe=Ne instanceof Error?": "+Ne.message:"";throw new Error("bad point: is not on curve, sqrt error"+Fe)}xe();const be=ie.isOdd(ue);return(ve&1)===1!==be&&(ue=ie.neg(ue)),{x:Ae,y:ue}}else if(pe===de&&ve===4){const Ae=ie.BYTES,ge=ie.fromBytes(we.subarray(0,Ae)),ue=ie.fromBytes(we.subarray(Ae,Ae*2));if(!Ce(ge,ue))throw new Error("bad point: is not on curve");return{x:ge,y:ue}}else throw new Error(`bad point: got length ${pe}, expected compressed=${ce} or uncompressed=${de}`)}const Me=t.toBytes||Ee,Be=t.fromBytes||Se;function $e(se){const ce=ie.sqr(se),de=ie.mul(ce,se);return ie.add(ie.add(de,ie.mul(se,ae.a)),ae.b)}function Ce(se,ce){const de=ie.sqr(ce),pe=$e(se);return ie.eql(de,pe)}if(!Ce(ae.Gx,ae.Gy))throw new Error("bad curve params: generator point");const ke=ie.mul(ie.pow(ae.a,_3n),_4n),Pe=ie.mul(ie.sqr(ae.b),BigInt(27));if(ie.is0(ie.add(ke,Pe)))throw new Error("bad curve params: a or b");function Ue(se,ce,de=!1){if(!ie.isValid(ce)||de&&ie.is0(ce))throw new Error(`bad point coordinate ${se}`);return ce}function qe(se){if(!(se instanceof Ke))throw new Error("ProjectivePoint expected")}function He(se){if(!ye||!ye.basises)throw new Error("no endo");return _splitEndoScalar(se,ye.basises,fe.ORDER)}const Ve=memoized((se,ce)=>{const{X:de,Y:pe,Z:ve}=se;if(ie.eql(ve,ie.ONE))return{x:de,y:pe};const we=se.is0();ce==null&&(ce=we?ie.ONE:ie.inv(ve));const Ae=ie.mul(de,ce),ge=ie.mul(pe,ce),ue=ie.mul(ve,ce);if(we)return{x:ie.ZERO,y:ie.ZERO};if(!ie.eql(ue,ie.ONE))throw new Error("invZ was invalid");return{x:Ae,y:ge}}),Ye=memoized(se=>{if(se.is0()){if(t.allowInfinityPoint&&!ie.is0(se.Y))return;throw new Error("bad point: ZERO")}const{x:ce,y:de}=se.toAffine();if(!ie.isValid(ce)||!ie.isValid(de))throw new Error("bad point: x or y not field elements");if(!Ce(ce,de))throw new Error("bad point: equation left != right");if(!se.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function Qe(se,ce,de,pe,ve){return de=new Ke(ie.mul(de.X,se),de.Y,de.Z),ce=negateCt(pe,ce),de=negateCt(ve,de),ce.add(de)}class Ke{constructor(ce,de,pe){this.X=Ue("x",ce),this.Y=Ue("y",de,!0),this.Z=Ue("z",pe),Object.freeze(this)}static CURVE(){return ae}static fromAffine(ce){const{x:de,y:pe}=ce||{};if(!ce||!ie.isValid(de)||!ie.isValid(pe))throw new Error("invalid affine point");if(ce instanceof Ke)throw new Error("projective point not allowed");return ie.is0(de)&&ie.is0(pe)?Ke.ZERO:new Ke(de,pe,ie.ONE)}static fromBytes(ce){const de=Ke.fromAffine(Be(_abytes2(ce,void 0,"point")));return de.assertValidity(),de}static fromHex(ce){return Ke.fromBytes(ensureBytes("pointHex",ce))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(ce=8,de=!0){return _e.createCache(this,ce),de||this.multiply(_3n),this}assertValidity(){Ye(this)}hasEvenY(){const{y:ce}=this.toAffine();if(!ie.isOdd)throw new Error("Field doesn't support isOdd");return!ie.isOdd(ce)}equals(ce){qe(ce);const{X:de,Y:pe,Z:ve}=this,{X:we,Y:Ae,Z:ge}=ce,ue=ie.eql(ie.mul(de,ge),ie.mul(we,ve)),be=ie.eql(ie.mul(pe,ge),ie.mul(Ae,ve));return ue&&be}negate(){return new Ke(this.X,ie.neg(this.Y),this.Z)}double(){const{a:ce,b:de}=ae,pe=ie.mul(de,_3n),{X:ve,Y:we,Z:Ae}=this;let ge=ie.ZERO,ue=ie.ZERO,be=ie.ZERO,Re=ie.mul(ve,ve),Ne=ie.mul(we,we),Fe=ie.mul(Ae,Ae),Ie=ie.mul(ve,we);return Ie=ie.add(Ie,Ie),be=ie.mul(ve,Ae),be=ie.add(be,be),ge=ie.mul(ce,be),ue=ie.mul(pe,Fe),ue=ie.add(ge,ue),ge=ie.sub(Ne,ue),ue=ie.add(Ne,ue),ue=ie.mul(ge,ue),ge=ie.mul(Ie,ge),be=ie.mul(pe,be),Fe=ie.mul(ce,Fe),Ie=ie.sub(Re,Fe),Ie=ie.mul(ce,Ie),Ie=ie.add(Ie,be),be=ie.add(Re,Re),Re=ie.add(be,Re),Re=ie.add(Re,Fe),Re=ie.mul(Re,Ie),ue=ie.add(ue,Re),Fe=ie.mul(we,Ae),Fe=ie.add(Fe,Fe),Re=ie.mul(Fe,Ie),ge=ie.sub(ge,Re),be=ie.mul(Fe,Ne),be=ie.add(be,be),be=ie.add(be,be),new Ke(ge,ue,be)}add(ce){qe(ce);const{X:de,Y:pe,Z:ve}=this,{X:we,Y:Ae,Z:ge}=ce;let ue=ie.ZERO,be=ie.ZERO,Re=ie.ZERO;const Ne=ae.a,Fe=ie.mul(ae.b,_3n);let Ie=ie.mul(de,we),je=ie.mul(pe,Ae),Te=ie.mul(ve,ge),De=ie.add(de,pe),ze=ie.add(we,Ae);De=ie.mul(De,ze),ze=ie.add(Ie,je),De=ie.sub(De,ze),ze=ie.add(de,ve);let Xe=ie.add(we,ge);return ze=ie.mul(ze,Xe),Xe=ie.add(Ie,Te),ze=ie.sub(ze,Xe),Xe=ie.add(pe,ve),ue=ie.add(Ae,ge),Xe=ie.mul(Xe,ue),ue=ie.add(je,Te),Xe=ie.sub(Xe,ue),Re=ie.mul(Ne,ze),ue=ie.mul(Fe,Te),Re=ie.add(ue,Re),ue=ie.sub(je,Re),Re=ie.add(je,Re),be=ie.mul(ue,Re),je=ie.add(Ie,Ie),je=ie.add(je,Ie),Te=ie.mul(Ne,Te),ze=ie.mul(Fe,ze),je=ie.add(je,Te),Te=ie.sub(Ie,Te),Te=ie.mul(Ne,Te),ze=ie.add(ze,Te),Ie=ie.mul(je,ze),be=ie.add(be,Ie),Ie=ie.mul(Xe,ze),ue=ie.mul(De,ue),ue=ie.sub(ue,Ie),Ie=ie.mul(De,je),Re=ie.mul(Xe,Re),Re=ie.add(Re,Ie),new Ke(ue,be,Re)}subtract(ce){return this.add(ce.negate())}is0(){return this.equals(Ke.ZERO)}multiply(ce){const{endo:de}=t;if(!fe.isValidNot0(ce))throw new Error("invalid scalar: out of range");let pe,ve;const we=Ae=>_e.cached(this,Ae,ge=>normalizeZ(Ke,ge));if(de){const{k1neg:Ae,k1:ge,k2neg:ue,k2:be}=He(ce),{p:Re,f:Ne}=we(ge),{p:Fe,f:Ie}=we(be);ve=Ne.add(Ie),pe=Qe(de.beta,Re,Fe,Ae,ue)}else{const{p:Ae,f:ge}=we(ce);pe=Ae,ve=ge}return normalizeZ(Ke,[pe,ve])[0]}multiplyUnsafe(ce){const{endo:de}=t,pe=this;if(!fe.isValid(ce))throw new Error("invalid scalar: out of range");if(ce===_0n||pe.is0())return Ke.ZERO;if(ce===_1n)return pe;if(_e.hasCache(this))return this.multiply(ce);if(de){const{k1neg:ve,k1:we,k2neg:Ae,k2:ge}=He(ce),{p1:ue,p2:be}=mulEndoUnsafe(Ke,pe,we,ge);return Qe(de.beta,ue,be,ve,Ae)}else return _e.unsafe(pe,ce)}multiplyAndAddUnsafe(ce,de,pe){const ve=this.multiplyUnsafe(de).add(ce.multiplyUnsafe(pe));return ve.is0()?void 0:ve}toAffine(ce){return Ve(this,ce)}isTorsionFree(){const{isTorsionFree:ce}=t;return le===_1n?!0:ce?ce(Ke,this):_e.unsafe(this,he).is0()}clearCofactor(){const{clearCofactor:ce}=t;return le===_1n?this:ce?ce(Ke,this):this.multiplyUnsafe(le)}isSmallOrder(){return this.multiplyUnsafe(le).is0()}toBytes(ce=!0){return _abool2(ce,"isCompressed"),this.assertValidity(),Me(Ke,this,ce)}toHex(ce=!0){return bytesToHex(this.toBytes(ce))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(ce=!0){return this.toBytes(ce)}_setWindowSize(ce){this.precompute(ce)}static normalizeZ(ce){return normalizeZ(Ke,ce)}static msm(ce,de){return pippenger(Ke,fe,ce,de)}static fromPrivateKey(ce){return Ke.BASE.multiply(_normFnElement(fe,ce))}}Ke.BASE=new Ke(ae.Gx,ae.Gy,ie.ONE),Ke.ZERO=new Ke(ie.ZERO,ie.ONE,ie.ZERO),Ke.Fp=ie,Ke.Fn=fe;const Pt=fe.BITS,_e=new wNAF(Ke,t.endo?Math.ceil(Pt/2):Pt);return Ke.BASE.precompute(8),Ke}function pprefix(c){return Uint8Array.of(c?2:3)}function getWLengths(c,t){return{secretKey:t.BYTES,publicKey:1+c.BYTES,publicKeyUncompressed:1+2*c.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function ecdh(c,t={}){const{Fn:n}=c,ie=t.randomBytes||randomBytes,fe=Object.assign(getWLengths(c.Fp,n),{seed:getMinHashLength(n.ORDER)});function ae(Me){try{return!!_normFnElement(n,Me)}catch{return!1}}function le(Me,Be){const{publicKey:$e,publicKeyUncompressed:Ce}=fe;try{const ke=Me.length;return Be===!0&&ke!==$e||Be===!1&&ke!==Ce?!1:!!c.fromBytes(Me)}catch{return!1}}function he(Me=ie(fe.seed)){return mapHashToField(_abytes2(Me,fe.seed,"seed"),n.ORDER)}function ye(Me,Be=!0){return c.BASE.multiply(_normFnElement(n,Me)).toBytes(Be)}function me(Me){const Be=he(Me);return{secretKey:Be,publicKey:ye(Be)}}function xe(Me){if(typeof Me=="bigint")return!1;if(Me instanceof c)return!0;const{secretKey:Be,publicKey:$e,publicKeyUncompressed:Ce}=fe;if(n.allowedLengths||Be===$e)return;const ke=ensureBytes("key",Me).length;return ke===$e||ke===Ce}function Ee(Me,Be,$e=!0){if(xe(Me)===!0)throw new Error("first arg must be private key");if(xe(Be)===!1)throw new Error("second arg must be public key");const Ce=_normFnElement(n,Me);return c.fromHex(Be).multiply(Ce).toBytes($e)}return Object.freeze({getPublicKey:ye,getSharedSecret:Ee,keygen:me,Point:c,utils:{isValidSecretKey:ae,isValidPublicKey:le,randomSecretKey:he,isValidPrivateKey:ae,randomPrivateKey:he,normPrivateKeyToScalar:Me=>_normFnElement(n,Me),precompute(Me=8,Be=c.BASE){return Be.precompute(Me,!1)}},lengths:fe})}function ecdsa(c,t,n={}){ahash(t),_validateObject(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const ie=n.randomBytes||randomBytes,fe=n.hmac||((de,...pe)=>hmac(t,de,concatBytes(...pe))),{Fp:ae,Fn:le}=c,{ORDER:he,BITS:ye}=le,{keygen:me,getPublicKey:xe,getSharedSecret:Ee,utils:Se,lengths:Me}=ecdh(c,n),Be={prehash:!1,lowS:typeof n.lowS=="boolean"?n.lowS:!1,format:void 0,extraEntropy:!1},$e="compact";function Ce(de){const pe=he>>_1n;return de>pe}function ke(de,pe){if(!le.isValidNot0(pe))throw new Error(`invalid signature ${de}: out of range 1..Point.Fn.ORDER`);return pe}function Pe(de,pe){validateSigFormat(pe);const ve=Me.signature,we=pe==="compact"?ve:pe==="recovered"?ve+1:void 0;return _abytes2(de,we,`${pe} signature`)}class Ue{constructor(pe,ve,we){this.r=ke("r",pe),this.s=ke("s",ve),we!=null&&(this.recovery=we),Object.freeze(this)}static fromBytes(pe,ve=$e){Pe(pe,ve);let we;if(ve==="der"){const{r:be,s:Re}=DER.toSig(_abytes2(pe));return new Ue(be,Re)}ve==="recovered"&&(we=pe[0],ve="compact",pe=pe.subarray(1));const Ae=le.BYTES,ge=pe.subarray(0,Ae),ue=pe.subarray(Ae,Ae*2);return new Ue(le.fromBytes(ge),le.fromBytes(ue),we)}static fromHex(pe,ve){return this.fromBytes(hexToBytes(pe),ve)}addRecoveryBit(pe){return new Ue(this.r,this.s,pe)}recoverPublicKey(pe){const ve=ae.ORDER,{r:we,s:Ae,recovery:ge}=this;if(ge==null||![0,1,2,3].includes(ge))throw new Error("recovery id invalid");if(he*_2n$1<ve&&ge>1)throw new Error("recovery id is ambiguous for h>1 curve");const be=ge===2||ge===3?we+he:we;if(!ae.isValid(be))throw new Error("recovery id 2 or 3 invalid");const Re=ae.toBytes(be),Ne=c.fromBytes(concatBytes(pprefix((ge&1)===0),Re)),Fe=le.inv(be),Ie=He(ensureBytes("msgHash",pe)),je=le.create(-Ie*Fe),Te=le.create(Ae*Fe),De=c.BASE.multiplyUnsafe(je).add(Ne.multiplyUnsafe(Te));if(De.is0())throw new Error("point at infinify");return De.assertValidity(),De}hasHighS(){return Ce(this.s)}toBytes(pe=$e){if(validateSigFormat(pe),pe==="der")return hexToBytes(DER.hexFromSig(this));const ve=le.toBytes(this.r),we=le.toBytes(this.s);if(pe==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return concatBytes(Uint8Array.of(this.recovery),ve,we)}return concatBytes(ve,we)}toHex(pe){return bytesToHex(this.toBytes(pe))}assertValidity(){}static fromCompact(pe){return Ue.fromBytes(ensureBytes("sig",pe),"compact")}static fromDER(pe){return Ue.fromBytes(ensureBytes("sig",pe),"der")}normalizeS(){return this.hasHighS()?new Ue(this.r,le.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return bytesToHex(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return bytesToHex(this.toBytes("compact"))}}const qe=n.bits2int||function(pe){if(pe.length>8192)throw new Error("input is too large");const ve=bytesToNumberBE(pe),we=pe.length*8-ye;return we>0?ve>>BigInt(we):ve},He=n.bits2int_modN||function(pe){return le.create(qe(pe))},Ve=bitMask(ye);function Ye(de){return aInRange("num < 2^"+ye,de,_0n,Ve),le.toBytes(de)}function Qe(de,pe){return _abytes2(de,void 0,"message"),pe?_abytes2(t(de),void 0,"prehashed message"):de}function Ke(de,pe,ve){if(["recovered","canonical"].some(je=>je in ve))throw new Error("sign() legacy options not supported");const{lowS:we,prehash:Ae,extraEntropy:ge}=validateSigOpts(ve,Be);de=Qe(de,Ae);const ue=He(de),be=_normFnElement(le,pe),Re=[Ye(be),Ye(ue)];if(ge!=null&&ge!==!1){const je=ge===!0?ie(Me.secretKey):ge;Re.push(ensureBytes("extraEntropy",je))}const Ne=concatBytes(...Re),Fe=ue;function Ie(je){const Te=qe(je);if(!le.isValidNot0(Te))return;const De=le.inv(Te),ze=c.BASE.multiply(Te).toAffine(),Xe=le.create(ze.x);if(Xe===_0n)return;const Rt=le.create(De*le.create(Fe+Xe*be));if(Rt===_0n)return;let Oe=(ze.x===Xe?0:2)|Number(ze.y&_1n),Ze=Rt;return we&&Ce(Rt)&&(Ze=le.neg(Rt),Oe^=1),new Ue(Xe,Ze,Oe)}return{seed:Ne,k2sig:Ie}}function Pt(de,pe,ve={}){de=ensureBytes("message",de);const{seed:we,k2sig:Ae}=Ke(de,pe,ve);return createHmacDrbg(t.outputLen,le.BYTES,fe)(we,Ae)}function _e(de){let pe;const ve=typeof de=="string"||isBytes(de),we=!ve&&de!==null&&typeof de=="object"&&typeof de.r=="bigint"&&typeof de.s=="bigint";if(!ve&&!we)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(we)pe=new Ue(de.r,de.s);else if(ve){try{pe=Ue.fromBytes(ensureBytes("sig",de),"der")}catch(Ae){if(!(Ae instanceof DER.Err))throw Ae}if(!pe)try{pe=Ue.fromBytes(ensureBytes("sig",de),"compact")}catch{return!1}}return pe||!1}function se(de,pe,ve,we={}){const{lowS:Ae,prehash:ge,format:ue}=validateSigOpts(we,Be);if(ve=ensureBytes("publicKey",ve),pe=Qe(ensureBytes("message",pe),ge),"strict"in we)throw new Error("options.strict was renamed to lowS");const be=ue===void 0?_e(de):Ue.fromBytes(ensureBytes("sig",de),ue);if(be===!1)return!1;try{const Re=c.fromBytes(ve);if(Ae&&be.hasHighS())return!1;const{r:Ne,s:Fe}=be,Ie=He(pe),je=le.inv(Fe),Te=le.create(Ie*je),De=le.create(Ne*je),ze=c.BASE.multiplyUnsafe(Te).add(Re.multiplyUnsafe(De));return ze.is0()?!1:le.create(ze.x)===Ne}catch{return!1}}function ce(de,pe,ve={}){const{prehash:we}=validateSigOpts(ve,Be);return pe=Qe(pe,we),Ue.fromBytes(de,"recovered").recoverPublicKey(pe).toBytes()}return Object.freeze({keygen:me,getPublicKey:xe,getSharedSecret:Ee,utils:Se,lengths:Me,Point:c,sign:Pt,verify:se,recoverPublicKey:ce,Signature:Ue,hash:t})}function _weierstrass_legacy_opts_to_new(c){const t={a:c.a,b:c.b,p:c.Fp.ORDER,n:c.n,h:c.h,Gx:c.Gx,Gy:c.Gy},n=c.Fp;let ie=c.allowedPrivateKeyLengths?Array.from(new Set(c.allowedPrivateKeyLengths.map(le=>Math.ceil(le/2)))):void 0;const fe=Field(t.n,{BITS:c.nBitLength,allowedLengths:ie,modFromBytes:c.wrapPrivateKey}),ae={Fp:n,Fn:fe,allowInfinityPoint:c.allowInfinityPoint,endo:c.endo,isTorsionFree:c.isTorsionFree,clearCofactor:c.clearCofactor,fromBytes:c.fromBytes,toBytes:c.toBytes};return{CURVE:t,curveOpts:ae}}function _ecdsa_legacy_opts_to_new(c){const{CURVE:t,curveOpts:n}=_weierstrass_legacy_opts_to_new(c),ie={hmac:c.hmac,randomBytes:c.randomBytes,lowS:c.lowS,bits2int:c.bits2int,bits2int_modN:c.bits2int_modN};return{CURVE:t,curveOpts:n,hash:c.hash,ecdsaOpts:ie}}function _ecdsa_new_output_to_legacy(c,t){const n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},c,nLength(n.Fn.ORDER,n.Fn.BITS))})}function weierstrass(c){const{CURVE:t,curveOpts:n,hash:ie,ecdsaOpts:fe}=_ecdsa_legacy_opts_to_new(c),ae=weierstrassN(t,n),le=ecdsa(ae,ie,fe);return _ecdsa_new_output_to_legacy(c,le)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function createCurve(c,t){const n=ie=>weierstrass({...c,hash:ie});return{...n(t),create:n}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const secp256k1_CURVE={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},secp256k1_ENDO={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},_2n=BigInt(2);function sqrtMod(c){const t=secp256k1_CURVE.p,n=BigInt(3),ie=BigInt(6),fe=BigInt(11),ae=BigInt(22),le=BigInt(23),he=BigInt(44),ye=BigInt(88),me=c*c*c%t,xe=me*me*c%t,Ee=pow2(xe,n,t)*xe%t,Se=pow2(Ee,n,t)*xe%t,Me=pow2(Se,_2n,t)*me%t,Be=pow2(Me,fe,t)*Me%t,$e=pow2(Be,ae,t)*Be%t,Ce=pow2($e,he,t)*$e%t,ke=pow2(Ce,ye,t)*Ce%t,Pe=pow2(ke,he,t)*$e%t,Ue=pow2(Pe,n,t)*xe%t,qe=pow2(Ue,le,t)*Be%t,He=pow2(qe,ie,t)*me%t,Ve=pow2(He,_2n,t);if(!Fpk1.eql(Fpk1.sqr(Ve),c))throw new Error("Cannot find square root");return Ve}const Fpk1=Field(secp256k1_CURVE.p,{sqrt:sqrtMod}),secp256k1$1=createCurve({...secp256k1_CURVE,Fp:Fpk1,lowS:!0,endo:secp256k1_ENDO},sha256$5);ed25519.utils.randomPrivateKey;ed25519.getPublicKey;function isOnCurve(c){try{return ed25519.ExtendedPoint.fromHex(c),!0}catch{return!1}}const sign$2=(c,t)=>ed25519.sign(c,t.slice(0,32)),verify$1=ed25519.verify,toBuffer$1=c=>Buffer$1$1.isBuffer(c)?c:c instanceof Uint8Array?Buffer$1$1.from(c.buffer,c.byteOffset,c.byteLength):Buffer$1$1.from(c);class Struct{constructor(t){Object.assign(this,t)}encode(){return Buffer$1$1.from(serialize_1(SOLANA_SCHEMA,this))}static decode(t){return deserialize_1(SOLANA_SCHEMA,this,t)}static decodeUnchecked(t){return deserializeUnchecked_1(SOLANA_SCHEMA,this,t)}}const SOLANA_SCHEMA=new Map;var _PublicKey;const MAX_SEED_LENGTH=32,PUBLIC_KEY_LENGTH=32;function isPublicKeyData(c){return c._bn!==void 0}let uniquePublicKeyCounter=1;class PublicKey extends Struct{constructor(t){if(super({}),this._bn=void 0,isPublicKeyData(t))this._bn=t._bn;else{if(typeof t=="string"){const n=o$1.decode(t);if(n.length!=PUBLIC_KEY_LENGTH)throw new Error("Invalid public key input");this._bn=new BN$8(n)}else this._bn=new BN$8(t);if(this._bn.byteLength()>PUBLIC_KEY_LENGTH)throw new Error("Invalid public key input")}}static unique(){const t=new PublicKey(uniquePublicKeyCounter);return uniquePublicKeyCounter+=1,new PublicKey(t.toBuffer())}equals(t){return this._bn.eq(t._bn)}toBase58(){return o$1.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const t=this.toBuffer();return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}toBuffer(){const t=this._bn.toArrayLike(Buffer$1$1);if(t.length===PUBLIC_KEY_LENGTH)return t;const n=Buffer$1$1.alloc(32);return t.copy(n,32-t.length),n}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(t,n,ie){const fe=Buffer$1$1.concat([t.toBuffer(),Buffer$1$1.from(n),ie.toBuffer()]),ae=sha256$4(fe);return new PublicKey(ae)}static createProgramAddressSync(t,n){let ie=Buffer$1$1.alloc(0);t.forEach(function(ae){if(ae.length>MAX_SEED_LENGTH)throw new TypeError("Max seed length exceeded");ie=Buffer$1$1.concat([ie,toBuffer$1(ae)])}),ie=Buffer$1$1.concat([ie,n.toBuffer(),Buffer$1$1.from("ProgramDerivedAddress")]);const fe=sha256$4(ie);if(isOnCurve(fe))throw new Error("Invalid seeds, address must fall off the curve");return new PublicKey(fe)}static async createProgramAddress(t,n){return this.createProgramAddressSync(t,n)}static findProgramAddressSync(t,n){let ie=255,fe;for(;ie!=0;){try{const ae=t.concat(Buffer$1$1.from([ie]));fe=this.createProgramAddressSync(ae,n)}catch(ae){if(ae instanceof TypeError)throw ae;ie--;continue}return[fe,ie]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(t,n){return this.findProgramAddressSync(t,n)}static isOnCurve(t){const n=new PublicKey(t);return isOnCurve(n.toBytes())}}_PublicKey=PublicKey;PublicKey.default=new _PublicKey("11111111111111111111111111111111");SOLANA_SCHEMA.set(PublicKey,{kind:"struct",fields:[["_bn","u256"]]});new PublicKey("BPFLoader1111111111111111111111111111111111");const PACKET_DATA_SIZE=1232,VERSION_PREFIX_MASK=127,SIGNATURE_LENGTH_IN_BYTES=64;class TransactionExpiredBlockheightExceededError extends Error{constructor(t){super(`Signature ${t} has expired: block height exceeded.`),this.signature=void 0,this.signature=t}}Object.defineProperty(TransactionExpiredBlockheightExceededError.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class TransactionExpiredTimeoutError extends Error{constructor(t,n){super(`Transaction was not confirmed in ${n.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${t} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=t}}Object.defineProperty(TransactionExpiredTimeoutError.prototype,"name",{value:"TransactionExpiredTimeoutError"});class TransactionExpiredNonceInvalidError extends Error{constructor(t){super(`Signature ${t} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=t}}Object.defineProperty(TransactionExpiredNonceInvalidError.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class MessageAccountKeys{constructor(t,n){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=t,this.accountKeysFromLookups=n}keySegments(){const t=[this.staticAccountKeys];return this.accountKeysFromLookups&&(t.push(this.accountKeysFromLookups.writable),t.push(this.accountKeysFromLookups.readonly)),t}get(t){for(const n of this.keySegments()){if(t<n.length)return n[t];t-=n.length}}get length(){return this.keySegments().flat().length}compileInstructions(t){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const ie=new Map;this.keySegments().flat().forEach((ae,le)=>{ie.set(ae.toBase58(),le)});const fe=ae=>{const le=ie.get(ae.toBase58());if(le===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return le};return t.map(ae=>({programIdIndex:fe(ae.programId),accountKeyIndexes:ae.keys.map(le=>fe(le.pubkey)),data:ae.data}))}}const publicKey$1=(c="publicKey")=>blob(32,c),signature$2=(c="signature")=>blob(64,c),rustString=(c="string")=>{const t=struct([u32("length"),u32("lengthPadding"),blob(offset(u32(),-8),"chars")],c),n=t.decode.bind(t),ie=t.encode.bind(t),fe=t;return fe.decode=(ae,le)=>n(ae,le).chars.toString(),fe.encode=(ae,le,he)=>{const ye={chars:Buffer$1$1.from(ae,"utf8")};return ie(ye,le,he)},fe.alloc=ae=>u32().span+u32().span+Buffer$1$1.from(ae,"utf8").length,fe},authorized=(c="authorized")=>struct([publicKey$1("staker"),publicKey$1("withdrawer")],c),lockup=(c="lockup")=>struct([ns64("unixTimestamp"),ns64("epoch"),publicKey$1("custodian")],c),voteInit=(c="voteInit")=>struct([publicKey$1("nodePubkey"),publicKey$1("authorizedVoter"),publicKey$1("authorizedWithdrawer"),u8("commission")],c),voteAuthorizeWithSeedArgs=(c="voteAuthorizeWithSeedArgs")=>struct([u32("voteAuthorizationType"),publicKey$1("currentAuthorityDerivedKeyOwnerPubkey"),rustString("currentAuthorityDerivedKeySeed"),publicKey$1("newAuthorized")],c);function getAlloc(c,t){const n=fe=>{if(fe.span>=0)return fe.span;if(typeof fe.alloc=="function")return fe.alloc(t[fe.property]);if("count"in fe&&"elementLayout"in fe){const ae=t[fe.property];if(Array.isArray(ae))return ae.length*n(fe.elementLayout)}else if("fields"in fe)return getAlloc({layout:fe},t[fe.property]);return 0};let ie=0;return c.layout.fields.forEach(fe=>{ie+=n(fe)}),ie}function decodeLength(c){let t=0,n=0;for(;;){let ie=c.shift();if(t|=(ie&127)<<n*7,n+=1,!(ie&128))break}return t}function encodeLength(c,t){let n=t;for(;;){let ie=n&127;if(n>>=7,n==0){c.push(ie);break}else ie|=128,c.push(ie)}}function assert$9(c,t){if(!c)throw new Error(t||"Assertion failed")}class CompiledKeys{constructor(t,n){this.payer=void 0,this.keyMetaMap=void 0,this.payer=t,this.keyMetaMap=n}static compile(t,n){const ie=new Map,fe=le=>{const he=le.toBase58();let ye=ie.get(he);return ye===void 0&&(ye={isSigner:!1,isWritable:!1,isInvoked:!1},ie.set(he,ye)),ye},ae=fe(n);ae.isSigner=!0,ae.isWritable=!0;for(const le of t){fe(le.programId).isInvoked=!0;for(const he of le.keys){const ye=fe(he.pubkey);ye.isSigner||(ye.isSigner=he.isSigner),ye.isWritable||(ye.isWritable=he.isWritable)}}return new CompiledKeys(n,ie)}getMessageComponents(){const t=[...this.keyMetaMap.entries()];assert$9(t.length<=256,"Max static account keys length exceeded");const n=t.filter(([,ye])=>ye.isSigner&&ye.isWritable),ie=t.filter(([,ye])=>ye.isSigner&&!ye.isWritable),fe=t.filter(([,ye])=>!ye.isSigner&&ye.isWritable),ae=t.filter(([,ye])=>!ye.isSigner&&!ye.isWritable),le={numRequiredSignatures:n.length+ie.length,numReadonlySignedAccounts:ie.length,numReadonlyUnsignedAccounts:ae.length};{assert$9(n.length>0,"Expected at least one writable signer key");const[ye]=n[0];assert$9(ye===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const he=[...n.map(([ye])=>new PublicKey(ye)),...ie.map(([ye])=>new PublicKey(ye)),...fe.map(([ye])=>new PublicKey(ye)),...ae.map(([ye])=>new PublicKey(ye))];return[le,he]}extractTableLookup(t){const[n,ie]=this.drainKeysFoundInLookupTable(t.state.addresses,le=>!le.isSigner&&!le.isInvoked&&le.isWritable),[fe,ae]=this.drainKeysFoundInLookupTable(t.state.addresses,le=>!le.isSigner&&!le.isInvoked&&!le.isWritable);if(!(n.length===0&&fe.length===0))return[{accountKey:t.key,writableIndexes:n,readonlyIndexes:fe},{writable:ie,readonly:ae}]}drainKeysFoundInLookupTable(t,n){const ie=new Array,fe=new Array;for(const[ae,le]of this.keyMetaMap.entries())if(n(le)){const he=new PublicKey(ae),ye=t.findIndex(me=>me.equals(he));ye>=0&&(assert$9(ye<256,"Max lookup table index exceeded"),ie.push(ye),fe.push(he),this.keyMetaMap.delete(ae))}return[ie,fe]}}const END_OF_BUFFER_ERROR_MESSAGE="Reached end of buffer unexpectedly";function guardedShift(c){if(c.length===0)throw new Error(END_OF_BUFFER_ERROR_MESSAGE);return c.shift()}function guardedSplice(c,...t){const[n]=t;if(t.length===2?n+(t[1]??0)>c.length:n>=c.length)throw new Error(END_OF_BUFFER_ERROR_MESSAGE);return c.splice(...t)}class Message{constructor(t){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=t.header,this.accountKeys=t.accountKeys.map(n=>new PublicKey(n)),this.recentBlockhash=t.recentBlockhash,this.instructions=t.instructions,this.instructions.forEach(n=>this.indexToProgramIds.set(n.programIdIndex,this.accountKeys[n.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:o$1.decode(t.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new MessageAccountKeys(this.staticAccountKeys)}static compile(t){const n=CompiledKeys.compile(t.instructions,t.payerKey),[ie,fe]=n.getMessageComponents(),le=new MessageAccountKeys(fe).compileInstructions(t.instructions).map(he=>({programIdIndex:he.programIdIndex,accounts:he.accountKeyIndexes,data:o$1.encode(he.data)}));return new Message({header:ie,accountKeys:fe,recentBlockhash:t.recentBlockhash,instructions:le})}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const n=this.header.numRequiredSignatures;if(t>=this.header.numRequiredSignatures){const ie=t-n,ae=this.accountKeys.length-n-this.header.numReadonlyUnsignedAccounts;return ie<ae}else{const ie=n-this.header.numReadonlySignedAccounts;return t<ie}}isProgramId(t){return this.indexToProgramIds.has(t)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((t,n)=>!this.isProgramId(n))}serialize(){const t=this.accountKeys.length;let n=[];encodeLength(n,t);const ie=this.instructions.map(Ee=>{const{accounts:Se,programIdIndex:Me}=Ee,Be=Array.from(o$1.decode(Ee.data));let $e=[];encodeLength($e,Se.length);let Ce=[];return encodeLength(Ce,Be.length),{programIdIndex:Me,keyIndicesCount:Buffer$1$1.from($e),keyIndices:Se,dataLength:Buffer$1$1.from(Ce),data:Be}});let fe=[];encodeLength(fe,ie.length);let ae=Buffer$1$1.alloc(PACKET_DATA_SIZE);Buffer$1$1.from(fe).copy(ae);let le=fe.length;ie.forEach(Ee=>{const Me=struct([u8("programIdIndex"),blob(Ee.keyIndicesCount.length,"keyIndicesCount"),seq(u8("keyIndex"),Ee.keyIndices.length,"keyIndices"),blob(Ee.dataLength.length,"dataLength"),seq(u8("userdatum"),Ee.data.length,"data")]).encode(Ee,ae,le);le+=Me}),ae=ae.slice(0,le);const he=struct([blob(1,"numRequiredSignatures"),blob(1,"numReadonlySignedAccounts"),blob(1,"numReadonlyUnsignedAccounts"),blob(n.length,"keyCount"),seq(publicKey$1("key"),t,"keys"),publicKey$1("recentBlockhash")]),ye={numRequiredSignatures:Buffer$1$1.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:Buffer$1$1.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:Buffer$1$1.from([this.header.numReadonlyUnsignedAccounts]),keyCount:Buffer$1$1.from(n),keys:this.accountKeys.map(Ee=>toBuffer$1(Ee.toBytes())),recentBlockhash:o$1.decode(this.recentBlockhash)};let me=Buffer$1$1.alloc(2048);const xe=he.encode(ye,me);return ae.copy(me,xe),me.slice(0,xe+ae.length)}static from(t){let n=[...t];const ie=guardedShift(n);if(ie!==(ie&VERSION_PREFIX_MASK))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const fe=guardedShift(n),ae=guardedShift(n),le=decodeLength(n);let he=[];for(let Se=0;Se<le;Se++){const Me=guardedSplice(n,0,PUBLIC_KEY_LENGTH);he.push(new PublicKey(Buffer$1$1.from(Me)))}const ye=guardedSplice(n,0,PUBLIC_KEY_LENGTH),me=decodeLength(n);let xe=[];for(let Se=0;Se<me;Se++){const Me=guardedShift(n),Be=decodeLength(n),$e=guardedSplice(n,0,Be),Ce=decodeLength(n),ke=guardedSplice(n,0,Ce),Pe=o$1.encode(Buffer$1$1.from(ke));xe.push({programIdIndex:Me,accounts:$e,data:Pe})}const Ee={header:{numRequiredSignatures:ie,numReadonlySignedAccounts:fe,numReadonlyUnsignedAccounts:ae},recentBlockhash:o$1.encode(Buffer$1$1.from(ye)),accountKeys:he,instructions:xe};return new Message(Ee)}}class MessageV0{constructor(t){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=t.header,this.staticAccountKeys=t.staticAccountKeys,this.recentBlockhash=t.recentBlockhash,this.compiledInstructions=t.compiledInstructions,this.addressTableLookups=t.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let t=0;for(const n of this.addressTableLookups)t+=n.readonlyIndexes.length+n.writableIndexes.length;return t}getAccountKeys(t){let n;if(t&&"accountKeysFromLookups"in t&&t.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=t.accountKeysFromLookups.writable.length+t.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");n=t.accountKeysFromLookups}else if(t&&"addressLookupTableAccounts"in t&&t.addressLookupTableAccounts)n=this.resolveAddressTableLookups(t.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new MessageAccountKeys(this.staticAccountKeys,n)}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const n=this.header.numRequiredSignatures,ie=this.staticAccountKeys.length;if(t>=ie){const fe=t-ie,ae=this.addressTableLookups.reduce((le,he)=>le+he.writableIndexes.length,0);return fe<ae}else if(t>=this.header.numRequiredSignatures){const fe=t-n,le=ie-n-this.header.numReadonlyUnsignedAccounts;return fe<le}else{const fe=n-this.header.numReadonlySignedAccounts;return t<fe}}resolveAddressTableLookups(t){const n={writable:[],readonly:[]};for(const ie of this.addressTableLookups){const fe=t.find(ae=>ae.key.equals(ie.accountKey));if(!fe)throw new Error(`Failed to find address lookup table account for table key ${ie.accountKey.toBase58()}`);for(const ae of ie.writableIndexes)if(ae<fe.state.addresses.length)n.writable.push(fe.state.addresses[ae]);else throw new Error(`Failed to find address for index ${ae} in address lookup table ${ie.accountKey.toBase58()}`);for(const ae of ie.readonlyIndexes)if(ae<fe.state.addresses.length)n.readonly.push(fe.state.addresses[ae]);else throw new Error(`Failed to find address for index ${ae} in address lookup table ${ie.accountKey.toBase58()}`)}return n}static compile(t){const n=CompiledKeys.compile(t.instructions,t.payerKey),ie=new Array,fe={writable:new Array,readonly:new Array},ae=t.addressLookupTableAccounts||[];for(const xe of ae){const Ee=n.extractTableLookup(xe);if(Ee!==void 0){const[Se,{writable:Me,readonly:Be}]=Ee;ie.push(Se),fe.writable.push(...Me),fe.readonly.push(...Be)}}const[le,he]=n.getMessageComponents(),me=new MessageAccountKeys(he,fe).compileInstructions(t.instructions);return new MessageV0({header:le,staticAccountKeys:he,recentBlockhash:t.recentBlockhash,compiledInstructions:me,addressTableLookups:ie})}serialize(){const t=Array();encodeLength(t,this.staticAccountKeys.length);const n=this.serializeInstructions(),ie=Array();encodeLength(ie,this.compiledInstructions.length);const fe=this.serializeAddressTableLookups(),ae=Array();encodeLength(ae,this.addressTableLookups.length);const le=struct([u8("prefix"),struct([u8("numRequiredSignatures"),u8("numReadonlySignedAccounts"),u8("numReadonlyUnsignedAccounts")],"header"),blob(t.length,"staticAccountKeysLength"),seq(publicKey$1(),this.staticAccountKeys.length,"staticAccountKeys"),publicKey$1("recentBlockhash"),blob(ie.length,"instructionsLength"),blob(n.length,"serializedInstructions"),blob(ae.length,"addressTableLookupsLength"),blob(fe.length,"serializedAddressTableLookups")]),he=new Uint8Array(PACKET_DATA_SIZE),me=le.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(t),staticAccountKeys:this.staticAccountKeys.map(xe=>xe.toBytes()),recentBlockhash:o$1.decode(this.recentBlockhash),instructionsLength:new Uint8Array(ie),serializedInstructions:n,addressTableLookupsLength:new Uint8Array(ae),serializedAddressTableLookups:fe},he);return he.slice(0,me)}serializeInstructions(){let t=0;const n=new Uint8Array(PACKET_DATA_SIZE);for(const ie of this.compiledInstructions){const fe=Array();encodeLength(fe,ie.accountKeyIndexes.length);const ae=Array();encodeLength(ae,ie.data.length);const le=struct([u8("programIdIndex"),blob(fe.length,"encodedAccountKeyIndexesLength"),seq(u8(),ie.accountKeyIndexes.length,"accountKeyIndexes"),blob(ae.length,"encodedDataLength"),blob(ie.data.length,"data")]);t+=le.encode({programIdIndex:ie.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(fe),accountKeyIndexes:ie.accountKeyIndexes,encodedDataLength:new Uint8Array(ae),data:ie.data},n,t)}return n.slice(0,t)}serializeAddressTableLookups(){let t=0;const n=new Uint8Array(PACKET_DATA_SIZE);for(const ie of this.addressTableLookups){const fe=Array();encodeLength(fe,ie.writableIndexes.length);const ae=Array();encodeLength(ae,ie.readonlyIndexes.length);const le=struct([publicKey$1("accountKey"),blob(fe.length,"encodedWritableIndexesLength"),seq(u8(),ie.writableIndexes.length,"writableIndexes"),blob(ae.length,"encodedReadonlyIndexesLength"),seq(u8(),ie.readonlyIndexes.length,"readonlyIndexes")]);t+=le.encode({accountKey:ie.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(fe),writableIndexes:ie.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(ae),readonlyIndexes:ie.readonlyIndexes},n,t)}return n.slice(0,t)}static deserialize(t){let n=[...t];const ie=guardedShift(n),fe=ie&VERSION_PREFIX_MASK;assert$9(ie!==fe,"Expected versioned message but received legacy message");const ae=fe;assert$9(ae===0,`Expected versioned message with version 0 but found version ${ae}`);const le={numRequiredSignatures:guardedShift(n),numReadonlySignedAccounts:guardedShift(n),numReadonlyUnsignedAccounts:guardedShift(n)},he=[],ye=decodeLength(n);for(let Be=0;Be<ye;Be++)he.push(new PublicKey(guardedSplice(n,0,PUBLIC_KEY_LENGTH)));const me=o$1.encode(guardedSplice(n,0,PUBLIC_KEY_LENGTH)),xe=decodeLength(n),Ee=[];for(let Be=0;Be<xe;Be++){const $e=guardedShift(n),Ce=decodeLength(n),ke=guardedSplice(n,0,Ce),Pe=decodeLength(n),Ue=new Uint8Array(guardedSplice(n,0,Pe));Ee.push({programIdIndex:$e,accountKeyIndexes:ke,data:Ue})}const Se=decodeLength(n),Me=[];for(let Be=0;Be<Se;Be++){const $e=new PublicKey(guardedSplice(n,0,PUBLIC_KEY_LENGTH)),Ce=decodeLength(n),ke=guardedSplice(n,0,Ce),Pe=decodeLength(n),Ue=guardedSplice(n,0,Pe);Me.push({accountKey:$e,writableIndexes:ke,readonlyIndexes:Ue})}return new MessageV0({header:le,staticAccountKeys:he,recentBlockhash:me,compiledInstructions:Ee,addressTableLookups:Me})}}const VersionedMessage={deserializeMessageVersion(c){const t=c[0],n=t&VERSION_PREFIX_MASK;return n===t?"legacy":n},deserialize:c=>{const t=VersionedMessage.deserializeMessageVersion(c);if(t==="legacy")return Message.from(c);if(t===0)return MessageV0.deserialize(c);throw new Error(`Transaction message version ${t} deserialization is not supported`)}};let TransactionStatus=function(c){return c[c.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",c[c.PROCESSED=1]="PROCESSED",c[c.TIMED_OUT=2]="TIMED_OUT",c[c.NONCE_INVALID=3]="NONCE_INVALID",c}({});const DEFAULT_SIGNATURE=Buffer$1$1.alloc(SIGNATURE_LENGTH_IN_BYTES).fill(0);class TransactionInstruction{constructor(t){this.keys=void 0,this.programId=void 0,this.data=Buffer$1$1.alloc(0),this.programId=t.programId,this.keys=t.keys,t.data&&(this.data=t.data)}toJSON(){return{keys:this.keys.map(({pubkey:t,isSigner:n,isWritable:ie})=>({pubkey:t.toJSON(),isSigner:n,isWritable:ie})),programId:this.programId.toJSON(),data:[...this.data]}}}class Transaction{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(t){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!!t)if(t.feePayer&&(this.feePayer=t.feePayer),t.signatures&&(this.signatures=t.signatures),Object.prototype.hasOwnProperty.call(t,"nonceInfo")){const{minContextSlot:n,nonceInfo:ie}=t;this.minNonceContextSlot=n,this.nonceInfo=ie}else if(Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")){const{blockhash:n,lastValidBlockHeight:ie}=t;this.recentBlockhash=n,this.lastValidBlockHeight=ie}else{const{recentBlockhash:n,nonceInfo:ie}=t;ie&&(this.nonceInfo=ie),this.recentBlockhash=n}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(t=>t.toJSON()),signers:this.signatures.map(({publicKey:t})=>t.toJSON())}}add(...t){if(t.length===0)throw new Error("No instructions");return t.forEach(n=>{"instructions"in n?this.instructions=this.instructions.concat(n.instructions):"data"in n&&"programId"in n&&"keys"in n?this.instructions.push(n):this.instructions.push(new TransactionInstruction(n))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let t,n;if(this.nonceInfo?(t=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?n=[this.nonceInfo.nonceInstruction,...this.instructions]:n=this.instructions):(t=this.recentBlockhash,n=this.instructions),!t)throw new Error("Transaction recentBlockhash required");n.length<1&&console.warn("No instructions provided");let ie;if(this.feePayer)ie=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)ie=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let $e=0;$e<n.length;$e++)if(n[$e].programId===void 0)throw new Error(`Transaction instruction index ${$e} has undefined program id`);const fe=[],ae=[];n.forEach($e=>{$e.keys.forEach(ke=>{ae.push({...ke})});const Ce=$e.programId.toString();fe.includes(Ce)||fe.push(Ce)}),fe.forEach($e=>{ae.push({pubkey:new PublicKey($e),isSigner:!1,isWritable:!1})});const le=[];ae.forEach($e=>{const Ce=$e.pubkey.toString(),ke=le.findIndex(Pe=>Pe.pubkey.toString()===Ce);ke>-1?(le[ke].isWritable=le[ke].isWritable||$e.isWritable,le[ke].isSigner=le[ke].isSigner||$e.isSigner):le.push($e)}),le.sort(function($e,Ce){if($e.isSigner!==Ce.isSigner)return $e.isSigner?-1:1;if($e.isWritable!==Ce.isWritable)return $e.isWritable?-1:1;const ke={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return $e.pubkey.toBase58().localeCompare(Ce.pubkey.toBase58(),"en",ke)});const he=le.findIndex($e=>$e.pubkey.equals(ie));if(he>-1){const[$e]=le.splice(he,1);$e.isSigner=!0,$e.isWritable=!0,le.unshift($e)}else le.unshift({pubkey:ie,isSigner:!0,isWritable:!0});for(const $e of this.signatures){const Ce=le.findIndex(ke=>ke.pubkey.equals($e.publicKey));if(Ce>-1)le[Ce].isSigner||(le[Ce].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw new Error(`unknown signer: ${$e.publicKey.toString()}`)}let ye=0,me=0,xe=0;const Ee=[],Se=[];le.forEach(({pubkey:$e,isSigner:Ce,isWritable:ke})=>{Ce?(Ee.push($e.toString()),ye+=1,ke||(me+=1)):(Se.push($e.toString()),ke||(xe+=1))});const Me=Ee.concat(Se),Be=n.map($e=>{const{data:Ce,programId:ke}=$e;return{programIdIndex:Me.indexOf(ke.toString()),accounts:$e.keys.map(Pe=>Me.indexOf(Pe.pubkey.toString())),data:o$1.encode(Ce)}});return Be.forEach($e=>{assert$9($e.programIdIndex>=0),$e.accounts.forEach(Ce=>assert$9(Ce>=0))}),new Message({header:{numRequiredSignatures:ye,numReadonlySignedAccounts:me,numReadonlyUnsignedAccounts:xe},accountKeys:Me,recentBlockhash:t,instructions:Be})}_compile(){const t=this.compileMessage(),n=t.accountKeys.slice(0,t.header.numRequiredSignatures);return this.signatures.length===n.length&&this.signatures.every((fe,ae)=>n[ae].equals(fe.publicKey))||(this.signatures=n.map(ie=>({signature:null,publicKey:ie}))),t}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(t){return(await t.getFeeForMessage(this.compileMessage())).value}setSigners(...t){if(t.length===0)throw new Error("No signers");const n=new Set;this.signatures=t.filter(ie=>{const fe=ie.toString();return n.has(fe)?!1:(n.add(fe),!0)}).map(ie=>({signature:null,publicKey:ie}))}sign(...t){if(t.length===0)throw new Error("No signers");const n=new Set,ie=[];for(const ae of t){const le=ae.publicKey.toString();n.has(le)||(n.add(le),ie.push(ae))}this.signatures=ie.map(ae=>({signature:null,publicKey:ae.publicKey}));const fe=this._compile();this._partialSign(fe,...ie)}partialSign(...t){if(t.length===0)throw new Error("No signers");const n=new Set,ie=[];for(const ae of t){const le=ae.publicKey.toString();n.has(le)||(n.add(le),ie.push(ae))}const fe=this._compile();this._partialSign(fe,...ie)}_partialSign(t,...n){const ie=t.serialize();n.forEach(fe=>{const ae=sign$2(ie,fe.secretKey);this._addSignature(fe.publicKey,toBuffer$1(ae))})}addSignature(t,n){this._compile(),this._addSignature(t,n)}_addSignature(t,n){assert$9(n.length===64);const ie=this.signatures.findIndex(fe=>t.equals(fe.publicKey));if(ie<0)throw new Error(`unknown signer: ${t.toString()}`);this.signatures[ie].signature=Buffer$1$1.from(n)}verifySignatures(t=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),t)}_getMessageSignednessErrors(t,n){const ie={};for(const{signature:fe,publicKey:ae}of this.signatures)fe===null?n&&(ie.missing||(ie.missing=[])).push(ae):verify$1(fe,t,ae.toBytes())||(ie.invalid||(ie.invalid=[])).push(ae);return ie.invalid||ie.missing?ie:void 0}serialize(t){const{requireAllSignatures:n,verifySignatures:ie}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},t),fe=this.serializeMessage();if(ie){const ae=this._getMessageSignednessErrors(fe,n);if(ae){let le="Signature verification failed.";throw ae.invalid&&(le+=`
20
20
  Invalid signature for public key${ae.invalid.length===1?"":"(s)"} [\`${ae.invalid.map(he=>he.toBase58()).join("`, `")}\`].`),ae.missing&&(le+=`