>>22,n=s}n>>>=22,t.words[i-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},A.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){var e;if(y[t])return y[t];if("k256"===t)e=new A;else if("p224"===t)e=new w;else if("p192"===t)e=new x;else if("p25519"===t)e=new M;else throw Error("Unknown prime "+t);return y[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){r((t.negative|e.negative)==0,"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(f(t,t.umod(this.m)._forceRed(this)),t)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return 0>r.cmpn(0)&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return 0>r.cmpn(0)&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var s=this.m.subn(1),o=0;!s.isZero()&&0===s.andln(1);)o++,s.iushrn(1);r(!s.isZero());var a=new n(1).toRed(this),f=a.redNeg(),h=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new n(2*u*u).toRed(this);0!==this.pow(u,h).cmp(f);)u.redIAdd(f);for(var l=this.pow(u,s),c=this.pow(t,s.addn(1).iushrn(1)),d=this.pow(t,s),p=o;0!==d.cmp(a);){for(var g=d,m=0;0!==g.cmp(a);m++)g=g.redSqr();r(m=0;i--){for(var h=e.words[i],u=f-1;u>=0;u--){var l=h>>u&1;if(s!==r[0]&&(s=this.sqr(s)),0===l&&0===o){a=0;continue}o<<=1,o|=l,4!=++a&&(0!==i||0!==u)||(s=this.mul(s,r[o]),a=0,o=0)}f=26}return s},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new I(t)},i(I,E),I.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},I.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},I.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):0>n.cmpn(0)&&(s=n.iadd(this.m)),s._forceRed(this)},I.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=r.isub(i).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):0>s.cmpn(0)&&(o=s.iadd(this.m)),o._forceRed(this)},I.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(ij,iE);var iJ=ij.exports;let iG="bignumber/5.7.0";var iY=iJ.BN;let iV=new iO(iG),iW={},iX=!1;class iZ{constructor(t,e){t!==iW&&iV.throwError("cannot call constructor directly; use BigNumber.from",iO.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return i0(i1(this).fromTwos(t))}toTwos(t){return i0(i1(this).toTwos(t))}abs(){return"-"===this._hex[0]?iZ.from(this._hex.substring(1)):this}add(t){return i0(i1(this).add(i1(t)))}sub(t){return i0(i1(this).sub(i1(t)))}div(t){return iZ.from(t).isZero()&&i2("division-by-zero","div"),i0(i1(this).div(i1(t)))}mul(t){return i0(i1(this).mul(i1(t)))}mod(t){let e=i1(t);return e.isNeg()&&i2("division-by-zero","mod"),i0(i1(this).umod(e))}pow(t){let e=i1(t);return e.isNeg()&&i2("negative-power","pow"),i0(i1(this).pow(e))}and(t){let e=i1(t);return(this.isNegative()||e.isNeg())&&i2("unbound-bitwise-result","and"),i0(i1(this).and(e))}or(t){let e=i1(t);return(this.isNegative()||e.isNeg())&&i2("unbound-bitwise-result","or"),i0(i1(this).or(e))}xor(t){let e=i1(t);return(this.isNegative()||e.isNeg())&&i2("unbound-bitwise-result","xor"),i0(i1(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&i2("negative-width","mask"),i0(i1(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&i2("negative-width","shl"),i0(i1(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&i2("negative-width","shr"),i0(i1(this).shrn(t))}eq(t){return i1(this).eq(i1(t))}lt(t){return i1(this).lt(i1(t))}lte(t){return i1(this).lte(i1(t))}gt(t){return i1(this).gt(i1(t))}gte(t){return i1(this).gte(i1(t))}isNegative(){return"-"===this._hex[0]}isZero(){return i1(this).isZero()}toNumber(){try{return i1(this).toNumber()}catch{i2("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return iV.throwError("this platform does not support BigInt",iO.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?iX||(iX=!0,iV.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?iV.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",iO.errors.UNEXPECTED_ARGUMENT,{}):iV.throwError("BigNumber.toString does not accept parameters",iO.errors.UNEXPECTED_ARGUMENT,{})),i1(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof iZ)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new iZ(iW,i$(t)):t.match(/^-?[0-9]+$/)?new iZ(iW,i$(new iY(t))):iV.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&i2("underflow","BigNumber.from",t),(t>=0x1fffffffffffff||t<=-0x1fffffffffffff)&&i2("overflow","BigNumber.from",t),iZ.from(String(t));if("bigint"==typeof t)return iZ.from(t.toString());if(iq(t))return iZ.from(iH(t));if(t){if(t.toHexString){let e=t.toHexString();if("string"==typeof e)return iZ.from(e)}else{let e=t._hex;if(null==e&&"BigNumber"===t.type&&(e=t.hex),"string"==typeof e&&(iz(e)||"-"===e[0]&&iz(e.substring(1))))return iZ.from(e)}}return iV.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!!(t&&t._isBigNumber)}}function i$(t){if("string"!=typeof t)return i$(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&iV.throwArgumentError("invalid hex","value",t),"0x00"===(t=i$(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function i0(t){return iZ.from(i$(t))}function i1(t){let e=iZ.from(t).toHexString();return"-"===e[0]?new iY("-"+e.substring(3),16):new iY(e.substring(2),16)}function i2(t,e,r){let i={fault:t,operation:e};return null!=r&&(i.value=r),iV.throwError(t,iO.errors.NUMERIC_FAULT,i)}let i3=new iO(iG),i6={},i8=iZ.from(0),i5=iZ.from(-1);function i4(t,e,r,i){let n={fault:e,operation:r};return void 0!==i&&(n.value=i),i3.throwError(t,iO.errors.NUMERIC_FAULT,n)}let i9="0";for(;i9.length<256;)i9+=i9;function i7(t){if("number"!=typeof t)try{t=iZ.from(t).toNumber()}catch{}return"number"==typeof t&&t>=0&&t<=256&&!(t%1)?"1"+i9.substring(0,t):i3.throwArgumentError("invalid decimal size","decimals",t)}function nt(t,e){null==e&&(e=0);let r=i7(e),i=(t=iZ.from(t)).lt(i8);i&&(t=t.mul(i5));let n=t.mod(r).toString();for(;n.length2&&i3.throwArgumentError("too many decimal points","value",t);let s=n[0],o=n[1];for(s||(s="0"),o||(o="0");"0"===o[o.length-1];)o=o.substring(0,o.length-1);for(o.length>r.length-1&&i4("fractional component exceeds decimals","underflow","parseFixed"),""===o&&(o="0");o.lengthnull==t[e]?i:(typeof t[e]!==r&&i3.throwArgumentError("invalid fixed format ("+e+" not "+r+")","format."+e,t[e]),t[e]);e=n("signed","boolean",e),r=n("width","number",r),i=n("decimals","number",i)}return r%8&&i3.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",r),i>80&&i3.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",i),new nr(i6,e,r,i)}}class ni{constructor(t,e,r,i){t!==i6&&i3.throwError("cannot use FixedNumber constructor; use FixedNumber.from",iO.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=i,this._hex=e,this._value=r,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(t){this.format.name!==t.format.name&&i3.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",t)}addUnsafe(t){this._checkFormat(t);let e=ne(this._value,this.format.decimals),r=ne(t._value,t.format.decimals);return ni.fromValue(e.add(r),this.format.decimals,this.format)}subUnsafe(t){this._checkFormat(t);let e=ne(this._value,this.format.decimals),r=ne(t._value,t.format.decimals);return ni.fromValue(e.sub(r),this.format.decimals,this.format)}mulUnsafe(t){this._checkFormat(t);let e=ne(this._value,this.format.decimals),r=ne(t._value,t.format.decimals);return ni.fromValue(e.mul(r).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(t){this._checkFormat(t);let e=ne(this._value,this.format.decimals),r=ne(t._value,t.format.decimals);return ni.fromValue(e.mul(this.format._multiplier).div(r),this.format.decimals,this.format)}floor(){let t=this.toString().split(".");1===t.length&&t.push("0");let e=ni.from(t[0],this.format),r=!t[1].match(/^(0*)$/);return this.isNegative()&&r&&(e=e.subUnsafe(nn.toFormat(e.format))),e}ceiling(){let t=this.toString().split(".");1===t.length&&t.push("0");let e=ni.from(t[0],this.format),r=!t[1].match(/^(0*)$/);return!this.isNegative()&&r&&(e=e.addUnsafe(nn.toFormat(e.format))),e}round(t){null==t&&(t=0);let e=this.toString().split(".");if(1===e.length&&e.push("0"),(t<0||t>80||t%1)&&i3.throwArgumentError("invalid decimal count","decimals",t),e[1].length<=t)return this;let r=ni.from("1"+i9.substring(0,t),this.format),i=ns.toFormat(this.format);return this.mulUnsafe(r).addUnsafe(i).floor().divUnsafe(r)}isZero(){return"0.0"===this._value||"0"===this._value}isNegative(){return"-"===this._value[0]}toString(){return this._value}toHexString(t){return null==t?this._hex:(t%8&&i3.throwArgumentError("invalid byte width","width",t),iQ(iZ.from(this._hex).fromTwos(this.format.width).toTwos(t).toHexString(),t/8))}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(t){return ni.fromString(this._value,t)}static fromValue(t,e,r){var i;return null!=r||null==e||null!=(i=e)&&(iZ.isBigNumber(i)||"number"==typeof i&&i%1==0||"string"==typeof i&&i.match(/^-?[0-9]+$/)||iz(i)||"bigint"==typeof i||iq(i))||(r=e,e=null),null==e&&(e=0),null==r&&(r="fixed"),ni.fromString(nt(t,e),nr.from(r))}static fromString(t,e){null==e&&(e="fixed");let r=nr.from(e),i=ne(t,r.decimals);!r.signed&&i.lt(i8)&&i4("unsigned value cannot be negative","overflow","value",t);let n=null;return n=r.signed?i.toTwos(r.width).toHexString():iQ(n=i.toHexString(),r.width/8),new ni(i6,n,nt(i,r.decimals),r)}static fromBytes(t,e){null==e&&(e="fixed");let r=nr.from(e);if(iF(t).length>r.width/8)throw Error("overflow");let i=iZ.from(t);r.signed&&(i=i.fromTwos(r.width));let n=i.toTwos((r.signed?0:1)+r.width).toHexString();return new ni(i6,n,nt(i,r.decimals),r)}static from(t,e){if("string"==typeof t)return ni.fromString(t,e);if(iq(t))return ni.fromBytes(t,e);try{return ni.fromValue(t,0,e)}catch(t){if(t.code!==iO.errors.INVALID_ARGUMENT)throw t}return i3.throwArgumentError("invalid FixedNumber value","value",t)}static isFixedNumber(t){return!!(t&&t._isFixedNumber)}}let nn=ni.from(1),ns=ni.from("0.5"),no=new iO("strings/5.7.0");(b=W||(W={})).current="",b.NFC="NFC",b.NFD="NFD",b.NFKC="NFKC",b.NFKD="NFKD",(A=X||(X={})).UNEXPECTED_CONTINUE="unexpected continuation byte",A.BAD_PREFIX="bad codepoint prefix",A.OVERRUN="string overrun",A.MISSING_CONTINUE="missing continuation byte",A.OUT_OF_RANGE="out of UTF-8 range",A.UTF16_SURROGATE="UTF-16 surrogate",A.OVERLONG="overlong representation";function na(t,e,r,i,n){if(t===X.BAD_PREFIX||t===X.UNEXPECTED_CONTINUE){let t=0;for(let i=e+1;i>6==2;i++)t++;return t}return t===X.OVERRUN?r.length-e-1:0}Object.freeze({error:function(t,e,r,i,n){return no.throwArgumentError(`invalid codepoint at offset ${e}; ${t}`,"bytes",r)},ignore:na,replace:function(t,e,r,i,n){return t===X.OVERLONG?(i.push(n),0):(i.push(65533),na(t,e,r))}});function nf(t,e){e||(e=function(t){return[parseInt(t,16)]});let r=0,i={};return t.split(",").forEach(t=>{let n=t.split(":");i[r+=parseInt(n[0],16)]=e(n[1])}),i}function nh(t){let e=0;return t.split(",").map(t=>{let r=t.split("-");return 1===r.length?r[1]="0":""===r[1]&&(r[1]="1"),{l:e+parseInt(r[0],16),h:e=parseInt(r[1],16)}})}nh("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"),"ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(t=>parseInt(t,16)),nf("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"),nf("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"),nf("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",function(t){if(t.length%4!=0)throw Error("bad data");let e=[];for(let r=0;r0&&Array.isArray(t)?n(t,e-1):r.push(t)})};return n(t,e),r}function nc(t,e){let r=Array(t);for(let i=0,n=-1;ie[t]):r}function np(t,e,r){let i=Array(t).fill(void 0).map(()=>[]);for(let n=0;n>1:i>>1}return r})(t,r).forEach((t,e)=>i[e].push(t));return i}let ng=function(){var t;let e;return t=function(t){let e=0;function r(){return t[e++]<<8|t[e++]}let i=r(),n=1,s=[0,1];for(let t=1;t>--f&1}let l=0x40000000,c=0x20000000,d=0x7fffffff,p=0;for(let t=0;t<31;t++)p=p<<1|u();let g=[],m=0,v=0x80000000;for(;;){let t=Math.floor(((p-m+1)*n-1)/v),e=0,r=i;for(;r-e>1;){let i=e+r>>>1;t>>1|u(),o=o<<1^l,a=(a^l)<<1|l|1;m=o,v=1+a-o}let y=i-4;return g.map(e=>{switch(e-y){case 3:return y+65792+(t[a++]<<16|t[a++]<<8|t[a++]);case 2:return y+256+(t[a++]<<8|t[a++]);case 1:return y+t[a++];default:return e-1}})}(function(t){t=atob(t);let e=[];for(let r=0;rt[e++]}();nd(ng),nd(ng),function(t){let e=[];for(;;){let r=t();if(0==r)break;e.push(function(t,e){let r=1+e(),i=e(),n=function(t){let e=[];for(;;){let r=t();if(0==r)break;e.push(r)}return e}(e);return nl(np(n.length,1+t,e).map((t,e)=>{let s=t[0],o=t.slice(1);return Array(n[e]).fill(void 0).map((t,e)=>{let n=e*i;return[s+e*r,o.map(t=>t+n)]})}))}(r,t))}for(;;){let r=t()-1;if(r<0)break;e.push(function(t,e){return np(1+e(),1+t,e).map(t=>[t[0],t.slice(1)])}(r,t))}(function(t){let e={};for(let r=0;rt-e),function t(){let e=[];for(;;){let r=nd(w,n);if(0==r.length)break;e.push({set:new Set(r),node:t()})}e.sort((t,e)=>e.set.size-t.set.size);let r=w();return{branches:e,valid:r%3,fe0f:!!(1&(r=r/3|0)),save:1==(r>>=1),check:2==r}}(),new iO(nu),new Uint8Array(32).fill(0);new iO("rlp/5.7.0"),new iO("address/5.7.0");let nm={};for(let t=0;t<10;t++)nm[String(t)]=String(t);for(let t=0;t<26;t++)nm[String.fromCharCode(65+t)]=String(10+t);x=0x1fffffffffffff,Math.log10;new iO("properties/5.7.0"),new iO(nu),new Uint8Array(32).fill(0),iZ.from(-1);let nv=iZ.from(0),ny=iZ.from(1);iZ.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),iQ(ny.toHexString(),32),iQ(nv.toHexString(),32);var nb={},nA={};function nw(t,e){if(!t)throw Error(e||"Assertion failed")}nw.equal=function(t,e,r){if(t!=e)throw Error(r||"Assertion failed: "+t+" != "+e)};var nx={exports:{}};"function"==typeof Object.create?nx.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:nx.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}};var nM=nx.exports;nA.inherits=nM;nA.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t){if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/ig,"")).length%2!=0&&(t="0"+t),n=0;n>6|192:((s=t,o=n,(64512&s.charCodeAt(o))!=55296||o<0||o+1>=s.length||(64512&s.charCodeAt(o+1))!=56320)?r[i++]=a>>12|224:(a=65536+((1023&a)<<10)+(1023&t.charCodeAt(++n)),r[i++]=a>>18|240,r[i++]=a>>12&63|128),r[i++]=a>>6&63|128),r[i++]=63&a|128)}}else for(n=0;n>>24|t>>>8&65280|t<<8&0xff0000|(255&t)<<24)>>>0}nA.toHex=function(t){for(var e="",r=0;r>>0;return o};nA.split32=function(t,e){for(var r=Array(4*t.length),i=0,n=0;i>>24,r[n+1]=s>>>16&255,r[n+2]=s>>>8&255,r[n+3]=255&s):(r[n+3]=s>>>24,r[n+2]=s>>>16&255,r[n+1]=s>>>8&255,r[n]=255&s)}return r};nA.rotr32=function(t,e){return t>>>e|t<<32-e};nA.rotl32=function(t,e){return t<>>32-e};nA.sum32=function(t,e){return t+e>>>0};nA.sum32_3=function(t,e,r){return t+e+r>>>0};nA.sum32_4=function(t,e,r,i){return t+e+r+i>>>0};nA.sum32_5=function(t,e,r,i,n){return t+e+r+i+n>>>0};nA.sum64=function(t,e,r,i){var n=t[e],s=i+t[e+1]>>>0;t[e]=(s>>0,t[e+1]=s};nA.sum64_hi=function(t,e,r,i){return(e+i>>>0>>0};nA.sum64_lo=function(t,e,r,i){return e+i>>>0};nA.sum64_4_hi=function(t,e,r,i,n,s,o,a){var f,h=e;return f=0+((h=h+i>>>0)>>0)>>0)>>0};nA.sum64_4_lo=function(t,e,r,i,n,s,o,a){return e+i+s+a>>>0};nA.sum64_5_hi=function(t,e,r,i,n,s,o,a,f,h){var u,l=e;return u=0+((l=l+i>>>0)>>0)>>0)>>0)>>0};nA.sum64_5_lo=function(t,e,r,i,n,s,o,a,f,h){return e+i+s+a+h>>>0};nA.rotr64_hi=function(t,e,r){return(e<<32-r|t>>>r)>>>0};nA.rotr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0};nA.shr64_hi=function(t,e,r){return t>>>r};nA.shr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0};var n_={};function nN(){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}n_.BlockHash=nN,nN.prototype.update=function(t,e){if(t=nA.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=nA.join32(t,0,t.length-r,this.endian);for(var i=0;i>>24&255,i[n++]=t>>>16&255,i[n++]=t>>>8&255,i[n++]=255&t}else for(i[n++]=255&t,i[n++]=t>>>8&255,i[n++]=t>>>16&255,i[n++]=t>>>24&255,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,s=8;s>>3};nB.g1_256=function(t){return nR(t,17)^nR(t,19)^t>>>10};var nD=nA.rotl32,nU=nA.sum32,nk=nA.sum32_5,nq=nB.ft_1,nF=n_.BlockHash,nz=[0x5a827999,0x6ed9eba1,0x8f1bbcdc,0xca62c1d6];function nL(){if(!(this instanceof nL))return new nL;nF.call(this),this.h=[0x67452301,0xefcdab89,0x98badcfe,0x10325476,0xc3d2e1f0],this.W=Array(80)}nA.inherits(nL,nF);nL.blockSize=512,nL.outSize=160,nL.hmacStrength=80,nL.padLength=64,nL.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;ithis.blockSize&&(t=new this.Hash().update(t).digest()),nw(t.length<=this.blockSize);for(var e=t.length;e>8,o=255&n;s?r.push(s,o):r.push(o)}return r},e.zero2=r,e.toHex=i,e.encode=function(t,e){return"hex"===e?i(t):t}}),sM=sb(function(t,e){e.assert=sA,e.toArray=sx.toArray,e.zero2=sx.zero2,e.toHex=sx.toHex,e.encode=sx.encode;e.getNAF=function(t,e,r){var i=Array(Math.max(t.bitLength(),r)+1);i.fill(0);for(var n=1<(n>>1)-1?(n>>1)-f:f,s.isubn(a)):a=0,i[o]=a,s.iushrn(1)}return i};e.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var i,n=0,s=0;t.cmpn(-n)>0||e.cmpn(-s)>0;){var o,a,f=t.andln(3)+n&3,h=e.andln(3)+s&3;3===f&&(f=-1),3===h&&(h=-1),o=1&f?(3==(i=t.andln(7)+n&7)||5===i)&&2===h?-f:f:0,r[0].push(o),a=1&h?(3==(i=e.andln(7)+s&7)||5===i)&&2===f?-h:h:0,r[1].push(a),2*n===o+1&&(n=1-n),2*s===a+1&&(s=1-s),t.iushrn(1),e.iushrn(1)}return r};e.cachedProperty=function(t,e,r){var i="_"+e;t.prototype[e]=function(){return void 0!==this[i]?this[i]:this[i]=r.call(this)}};e.parseBytes=function(t){return"string"==typeof t?e.toArray(t,"hex"):t};e.intFromLE=function(t){return new iJ(t,"hex","le")}}),sE=sM.getNAF,sI=sM.getJSF,sS=sM.assert;function s_(t,e){this.type=t,this.p=new iJ(e.p,16),this.red=e.prime?iJ.red(e.prime):iJ.mont(this.p),this.zero=new iJ(0).toRed(this.red),this.one=new iJ(1).toRed(this.red),this.two=new iJ(2).toRed(this.red),this.n=e.n&&new iJ(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=[,,,,],this._wnafT2=[,,,,],this._wnafT3=[,,,,],this._wnafT4=[,,,,],this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function sN(t,e){this.curve=t,this.type=e,this.precomputed=null}s_.prototype.point=function(){throw Error("Not implemented")},s_.prototype.validate=function(){throw Error("Not implemented")},s_.prototype._fixedNafMul=function(t,e){sS(t.precomputed);var r=t._getDoubles(),i=sE(e,1,this._bitLength),n=(1<=s;f--)o=(o<<1)+i[f];a.push(o)}for(var h=this.jpoint(null,null,null),u=this.jpoint(null,null,null),l=n;l>0;l--){for(s=0;s=0;a--){for(var f=0;a>=0&&0===s[a];a--)f++;if(a>=0&&f++,o=o.dblp(f),a<0)break;var h=s[a];sS(0!==h),o="affine"===t.type?h>0?o.mixedAdd(n[h-1>>1]):o.mixedAdd(n[-h-1>>1].neg()):h>0?o.add(n[h-1>>1]):o.add(n[-h-1>>1].neg())}return"affine"===t.type?o.toP():o},s_.prototype._wnafMulAdd=function(t,e,r,i,n){var s,o,a,f=this._wnafT1,h=this._wnafT2,u=this._wnafT3,l=0;for(s=0;s=1;s-=2){var d=s-1,p=s;if(1!==f[d]||1!==f[p]){u[d]=sE(r[d],f[d],this._bitLength),u[p]=sE(r[p],f[p],this._bitLength),l=Math.max(u[d].length,l),l=Math.max(u[p].length,l);continue}var g=[e[d],null,null,e[p]];0===e[d].y.cmp(e[p].y)?(g[1]=e[d].add(e[p]),g[2]=e[d].toJ().mixedAdd(e[p].neg())):0===e[d].y.cmp(e[p].y.redNeg())?(g[1]=e[d].toJ().mixedAdd(e[p]),g[2]=e[d].add(e[p].neg())):(g[1]=e[d].toJ().mixedAdd(e[p]),g[2]=e[d].toJ().mixedAdd(e[p].neg()));var m=[-3,-1,-5,-7,0,7,5,1,3],v=sI(r[d],r[p]);for(l=Math.max(v[0].length,l),u[d]=Array(l),u[p]=Array(l),o=0;o=0;s--){for(var x=0;s>=0;){var M=!0;for(o=0;o=0&&x++,A=A.dblp(x),s<0)break;for(o=0;o0?a=h[o][E-1>>1]:E<0&&(a=h[o][-E-1>>1].neg()),A="affine"===a.type?A.mixedAdd(a):A.add(a))}}for(s=0;s=Math.ceil((t.bitLength()+1)/e.step)},sN.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,n=0;nn[0].cmp(n[1])?n[0]:n[1]).toRed(this.red)}if(t.lambda)r=new iJ(t.lambda,16);else{var s=this._getEndoRoots(this.n);0===this.g.mul(s[0]).x.cmp(this.g.x.redMul(e))?r=s[0]:(r=s[1],sB(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return i=t.basis?t.basis.map(function(t){return{a:new iJ(t.a,16),b:new iJ(t.b,16)}}):this._getEndoBasis(r),{beta:e,lambda:r,basis:i}}},sR.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:iJ.mont(t),r=new iJ(2).toRed(e).redInvm(),i=r.redNeg(),n=new iJ(3).toRed(e).redNeg().redSqrt().redMul(r);return[i.redAdd(n).fromRed(),i.redSub(n).fromRed()]},sR.prototype._getEndoBasis=function(t){for(var e,r,i,n,s,o,a,f,h,u=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=t,c=this.n.clone(),d=new iJ(1),p=new iJ(0),g=new iJ(0),m=new iJ(1),v=0;0!==l.cmpn(0);){var y=c.div(l);f=c.sub(y.mul(l)),h=g.sub(y.mul(d));var b=m.sub(y.mul(p));if(!i&&0>f.cmp(u))e=a.neg(),r=d,i=f.neg(),n=h;else if(i&&2==++v)break;a=f,c=l,l=f,g=d,d=h,m=p,p=b}s=f.neg(),o=h;var A=i.sqr().add(n.sqr());return s.sqr().add(o.sqr()).cmp(A)>=0&&(s=e,o=r),i.negative&&(i=i.neg(),n=n.neg()),s.negative&&(s=s.neg(),o=o.neg()),[{a:i,b:n},{a:s,b:o}]},sR.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],i=e[1],n=i.b.mul(t).divRound(this.n),s=r.b.neg().mul(t).divRound(this.n),o=n.mul(r.a),a=s.mul(i.a),f=n.mul(r.b),h=s.mul(i.b);return{k1:t.sub(o).sub(a),k2:f.add(h).neg()}},sR.prototype.pointFromX=function(t,e){(t=new iJ(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),i=r.redSqrt();if(0!==i.redSqr().redSub(r).cmp(this.zero))throw Error("invalid point");var n=i.fromRed().isOdd();return(e&&!n||!e&&n)&&(i=i.redNeg()),this.point(t,i)},sR.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,i=this.a.redMul(e),n=e.redSqr().redMul(e).redIAdd(i).redIAdd(this.b);return 0===r.redSqr().redISub(n).cmpn(0)},sR.prototype._endoWnafMulAdd=function(t,e,r){for(var i=this._endoWnafT1,n=this._endoWnafT2,s=0;s":""},sP.prototype.isInfinity=function(){return this.inf},sP.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)||0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),i=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},sP.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),i=t.redInvm(),n=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(i),s=n.redSqr().redISub(this.x.redAdd(this.x)),o=n.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,o)},sP.prototype.getX=function(){return this.x.fromRed()},sP.prototype.getY=function(){return this.y.fromRed()},sP.prototype.mul=function(t){return t=new iJ(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)},sP.prototype.mulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n):this.curve._wnafMulAdd(1,i,n,2)},sP.prototype.jmulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n,!0):this.curve._wnafMulAdd(1,i,n,2,!0)},sP.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},sP.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,i=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return e},sP.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},sC(sO,s_.BasePoint),sR.prototype.jpoint=function(t,e,r){return new sO(this,t,e,r)},sO.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),i=this.y.redMul(e).redMul(t);return this.curve.point(r,i)},sO.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},sO.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(e),n=t.x.redMul(r),s=this.y.redMul(e.redMul(t.z)),o=t.y.redMul(r.redMul(this.z)),a=i.redSub(n),f=s.redSub(o);if(0===a.cmpn(0))return 0!==f.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=a.redSqr(),u=h.redMul(a),l=i.redMul(h),c=f.redSqr().redIAdd(u).redISub(l).redISub(l),d=f.redMul(l.redISub(c)).redISub(s.redMul(u)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(c,d,p)},sO.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,i=t.x.redMul(e),n=this.y,s=t.y.redMul(e).redMul(this.z),o=r.redSub(i),a=n.redSub(s);if(0===o.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var f=o.redSqr(),h=f.redMul(o),u=r.redMul(f),l=a.redSqr().redIAdd(h).redISub(u).redISub(u),c=a.redMul(u.redISub(l)).redISub(n.redMul(h)),d=this.z.redMul(o);return this.curve.jpoint(l,c,d)},sO.prototype.dblp=function(t){if(0===t||this.isInfinity())return this;if(!t)return this.dbl();if(this.curve.zeroA||this.curve.threeA){var e,r=this;for(e=0;e=0)return!1;if(r.redIAdd(n),0===this.x.cmp(r))return!0}},sO.prototype.inspect=function(){return this.isInfinity()?"":""},sO.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var sT=sb(function(t,e){e.base=s_,e.short=sR,e.mont=null,e.edwards=null}),sD=sb(function(t,e){var r,i=sM.assert;function n(t){"short"===t.type?this.curve=new sT.short(t):"edwards"===t.type?this.curve=new sT.edwards(t):this.curve=new sT.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function s(t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get:function(){var i=new n(r);return Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:i}),i}})}e.PresetCurve=n,s("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:nb.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("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:nb.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("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:nb.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("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:nb.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"]}),s("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:nb.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"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:nb.sha256,gRed:!1,g:["9"]}),s("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:nb.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=null.crash()}catch{r=void 0}s("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:nb.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})});function sU(t){if(!(this instanceof sU))return new sU(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=sx.toArray(t.entropy,t.entropyEnc||"hex"),r=sx.toArray(t.nonce,t.nonceEnc||"hex"),i=sx.toArray(t.pers,t.persEnc||"hex");sA(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}sU.prototype._init=function(t,e,r){var i=t.concat(e).concat(r);this.K=Array(this.outLen/8),this.V=Array(this.outLen/8);for(var n=0;n=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},sU.prototype.generate=function(t,e,r,i){if(this._reseed>this.reseedInterval)throw Error("Reseed is required");"string"!=typeof e&&(i=r,r=e,e=null),r&&(r=sx.toArray(r,i||"hex"),this._update(r));for(var n=[];n.length"};var sF=sM.assert;function sz(t,e){if(t instanceof sz)return t;this._importDER(t,e)||(sF(t.r&&t.s,"Signature without r or s"),this.r=new iJ(t.r,16),this.s=new iJ(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}function sL(){this.place=0}function sH(t,e){var r=t[e.place++];if(!(128&r))return r;var i=15&r;if(0===i||i>4)return!1;for(var n=0,s=0,o=e.place;s>>=0;return!(n<=127)&&(e.place=o,n)}function sQ(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}sz.prototype._importDER=function(t,e){t=sM.toArray(t,e);var r=new sL;if(48!==t[r.place++])return!1;var i=sH(t,r);if(!1===i||i+r.place!==t.length||2!==t[r.place++])return!1;var n=sH(t,r);if(!1===n)return!1;var s=t.slice(r.place,n+r.place);if(r.place+=n,2!==t[r.place++])return!1;var o=sH(t,r);if(!1===o||t.length!==o+r.place)return!1;var a=t.slice(r.place,o+r.place);if(0===s[0]){if(!(128&s[1]))return!1;else s=s.slice(1)}if(0===a[0]){if(!(128&a[1]))return!1;else a=a.slice(1)}return this.r=new iJ(s),this.s=new iJ(a),this.recoveryParam=null,!0},sz.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=sQ(e),r=sQ(r);!r[0]&&!(128&r[1]);)r=r.slice(1);var i=[2];sj(i,e.length),(i=i.concat(e)).push(2),sj(i,r.length);var n=i.concat(r),s=[48];return sj(s,n.length),s=s.concat(n),sM.encode(s,t)};var sK=function(){throw Error("unsupported")},sJ=sM.assert;function sG(t){if(!(this instanceof sG))return new sG(t);"string"==typeof t&&(sJ(Object.prototype.hasOwnProperty.call(sD,t),"Unknown curve "+t),t=sD[t]),t instanceof sD.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}sG.prototype.keyPair=function(t){return new sq(this,t)},sG.prototype.keyFromPrivate=function(t,e){return sq.fromPrivate(this,t,e)},sG.prototype.keyFromPublic=function(t,e){return sq.fromPublic(this,t,e)},sG.prototype.genKeyPair=function(t){t||(t={});for(var e=new sU({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||sK(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),i=this.n.sub(new iJ(2));;){var n=new iJ(e.generate(r));if(!(n.cmp(i)>0))return n.iaddn(1),this.keyFromPrivate(n)}},sG.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},sG.prototype.sign=function(t,e,r,i){"object"==typeof r&&(i=r,r=null),i||(i={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new iJ(t,16));for(var n=this.n.byteLength(),s=e.getPrivate().toArray("be",n),o=t.toArray("be",n),a=new sU({hash:this.hash,entropy:s,nonce:o,pers:i.pers,persEnc:i.persEnc||"utf8"}),f=this.n.sub(new iJ(1)),h=0;;h++){var u=i.k?i.k(h):new iJ(a.generate(this.n.byteLength()));if(!(0>=(u=this._truncateToN(u,!0)).cmpn(1)||u.cmp(f)>=0)){var l=this.g.mul(u);if(!l.isInfinity()){var c=l.getX(),d=c.umod(this.n);if(0!==d.cmpn(0)){var p=u.invm(this.n).mul(d.mul(e.getPrivate()).iadd(t));if(0!==(p=p.umod(this.n)).cmpn(0)){var g=(l.getY().isOdd()?1:0)|(0!==c.cmp(d)?2:0);return i.canonical&&p.cmp(this.nh)>0&&(p=this.n.sub(p),g^=1),new sz({r:d,s:p,recoveryParam:g})}}}}}},sG.prototype.verify=function(t,e,r,i){t=this._truncateToN(new iJ(t,16)),r=this.keyFromPublic(r,i);var n=(e=new sz(e,"hex")).r,s=e.s;if(0>n.cmpn(1)||n.cmp(this.n)>=0||0>s.cmpn(1)||s.cmp(this.n)>=0)return!1;var o,a=s.invm(this.n),f=a.mul(t).umod(this.n),h=a.mul(n).umod(this.n);return this.curve._maxwellTrick?!(o=this.g.jmulAdd(f,r.getPublic(),h)).isInfinity()&&o.eqXToP(n):!(o=this.g.mulAdd(f,r.getPublic(),h)).isInfinity()&&0===o.getX().umod(this.n).cmp(n)},sG.prototype.recoverPubKey=function(t,e,r,i){sJ((3&r)===r,"The recovery param is more than two bits"),e=new sz(e,i);var n=this.n,s=new iJ(t),o=e.r,a=e.s,f=1&r,h=r>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&h)throw Error("Unable to find sencond key candinate");o=h?this.curve.pointFromX(o.add(this.curve.n),f):this.curve.pointFromX(o,f);var u=e.r.invm(n),l=n.sub(s).mul(u).umod(n),c=a.mul(u).umod(n);return this.g.mulAdd(l,o,c)},sG.prototype.getKeyRecoveryParam=function(t,e,r,i){if(null!==(e=new sz(e,i)).recoveryParam)return e.recoveryParam;for(var n,s=0;s<4;s++){try{n=this.recoverPubKey(t,e,s)}catch{continue}if(n.eq(r))return s}throw Error("Unable to find valid recovery factor")},sb(function(t,e){e.version="6.5.4",e.utils=sM,e.rand=function(){throw Error("unsupported")},e.curve=sT,e.curves=sD,e.ec=sG,e.eddsa=null}).ec,new iO("signing-key/5.7.0");new iO("transactions/5.7.0"),(E=Z||(Z={}))[E.legacy=0]="legacy",E[E.eip2930=1]="eip2930",E[E.eip1559=2]="eip1559",Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;let sY="base10",sV="base16",sW="base64pad",sX="utf8";function sZ(){let t=(0,tv.randomBytes)(32);return(0,tA.BB)(t,sV)}function s$(t){let e=(0,ty.hash)((0,tA.mL)(t,sX));return(0,tA.BB)(e,sV)}function s0(t){return Number((0,tA.BB)(t,sY))}function s1(t){let e=(0,tA.mL)(t,sW),r=e.slice(0,1);if(1===s0(r)){let t=33,i=45,n=e.slice(1,t),s=e.slice(t,i);return{type:r,sealed:e.slice(i),iv:s,senderPublicKey:n}}let i=13,n=e.slice(1,i);return{type:r,sealed:e.slice(i),iv:n}}function s2(t){let e=t?.type||0;if(1===e){if(typeof t?.senderPublicKey>"u")throw Error("missing sender public key");if(typeof t?.receiverPublicKey>"u")throw Error("missing receiver public key")}return{type:e,senderPublicKey:t?.senderPublicKey,receiverPublicKey:t?.receiverPublicKey}}function s3(t){return 1===t.type&&"string"==typeof t.senderPublicKey&&"string"==typeof t.receiverPublicKey}function s6(t){return t?.relay||{protocol:"irn"}}function s8(t){let e=ir.i[t];if(typeof e>"u")throw Error(`Relay Protocol not supported: ${t}`);return e}var s5=Object.defineProperty,s4=Object.defineProperties,s9=Object.getOwnPropertyDescriptors,s7=Object.getOwnPropertySymbols,ot=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable,or=(t,e,r)=>e in t?s5(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,oi=(t,e)=>{for(var r in e||(e={}))ot.call(e,r)&&or(t,r,e[r]);if(s7)for(var r of s7(e))oe.call(e,r)&&or(t,r,e[r]);return t},on=(t,e)=>s4(t,s9(e));function os(t){let e=(t=(t=t.includes("wc://")?t.replace("wc://",""):t).includes("wc:")?t.replace("wc:",""):t).indexOf(":"),r=-1!==t.indexOf("?")?t.indexOf("?"):void 0,i=t.substring(0,e),n=t.substring(e+1,r).split("@"),s="u">typeof r?t.substring(r):"",o=tp.parse(s),a="string"==typeof o.methods?o.methods.split(","):void 0;return{protocol:i,topic:function(t){return t.startsWith("//")?t.substring(2):t}(n[0]),version:parseInt(n[1],10),symKey:o.symKey,relay:function(t,e="-"){let r={},i="relay"+e;return Object.keys(t).forEach(e=>{if(e.startsWith(i)){let n=e.replace(i,""),s=t[e];r[n]=s}}),r}(o),methods:a,expiryTimestamp:o.expiryTimestamp?parseInt(o.expiryTimestamp,10):void 0}}Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;let oo={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},oa={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function of(t,e){let{message:r,code:i}=oa[t];return{message:e?`${r} ${e}`:r,code:i}}function oh(t,e){let{message:r,code:i}=oo[t];return{message:e?`${r} ${e}`:r,code:i}}function ou(t){return typeof t>"u"}function ol(t,e){return!!(e&&ou(t))||"string"==typeof t&&!!t.trim().length}function oc(t){return"u">typeof t}function od(){let t=im();return new Promise(e=>{switch(t){case ic.browser:e(function(){return ig()&&navigator?.onLine}());break;case ic.reactNative:e(op());break;case ic.node:e(function(){return!0}());break;default:e(!0)}})}async function op(){if(ip()&&"u">typeof r.g&&null!=r.g&&r.g.NetInfo){let t=await (null==r.g?void 0:r.g.NetInfo.fetch());return t?.isConnected}return!0}var og=r("71499"),om=r("56186");let ov=()=>"u">typeof WebSocket||"u">typeof r.g&&"u">typeof r.g.WebSocket||"u">typeof window&&"u">typeof window.WebSocket||"u">typeof self&&"u">typeof self.WebSocket,oy=t=>t.split("?")[0],ob="u">typeof WebSocket?WebSocket:"u">typeof r.g&&"u">typeof r.g.WebSocket?r.g.WebSocket:"u">typeof window&&"u">typeof window.WebSocket?window.WebSocket:"u">typeof self&&"u">typeof self.WebSocket?self.WebSocket:r(72030);class oA{constructor(t){if(this.url=t,this.events=new th.EventEmitter,this.registering=!1,!(0,om.isWsUrl)(t))throw Error(`Provided URL is not compatible with WebSocket connection: ${t}`);this.url=t}get connected(){return"u">typeof this.socket}get connecting(){return this.registering}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async open(t=this.url){await this.register(t)}async close(){return new Promise((t,e)=>{if(typeof this.socket>"u"){e(Error("Connection already closed"));return}this.socket.onclose=e=>{this.onClose(e),t()},this.socket.close()})}async send(t){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send((0,r7.u)(t))}catch(e){this.onError(t.id,e)}}register(t=this.url){if(!(0,om.isWsUrl)(t))throw Error(`Provided URL is not compatible with WebSocket connection: ${t}`);if(this.registering){let t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((t,e)=>{this.events.once("register_error",t=>{this.resetMaxListeners(),e(t)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return e(Error("WebSocket connection is missing or invalid"));t(this.socket)})})}return this.url=t,this.registering=!0,new Promise((e,r)=>{let i=new URLSearchParams(t).get("origin"),n=(0,om.isReactNative)()?{headers:{origin:i}}:{rejectUnauthorized:!(0,om.isLocalhostUrl)(t)},s=new ob(t,[],n);ov()?s.onerror=t=>{r(this.emitError(t.error))}:s.on("error",t=>{r(this.emitError(t))}),s.onopen=()=>{this.onOpen(s),e(s)}})}onOpen(t){t.onmessage=t=>this.onPayload(t),t.onclose=t=>this.onClose(t),this.socket=t,this.registering=!1,this.events.emit("open")}onClose(t){this.socket=void 0,this.registering=!1,this.events.emit("close",t)}onPayload(t){if(typeof t.data>"u")return;let e="string"==typeof t.data?(0,r7.D)(t.data):t.data;this.events.emit("payload",e)}onError(t,e){let r=this.parseError(e),i=r.message||r.toString(),n=(0,om.formatJsonRpcError)(t,i);this.events.emit("payload",n)}parseError(t,e=this.url){return(0,om.parseConnectionError)(t,oy(e),"WS")}resetMaxListeners(){this.events.getMaxListeners()>10&&this.events.setMaxListeners(10)}emitError(t){let e=this.parseError(Error(t?.message||`WebSocket connection failed for host: ${oy(this.url)}`));return this.events.emit("register_error",e),e}}var ow=r("72307"),ox=r.n(ow),oM=r("80204"),oE=r.n(oM),oI=r(34155),oS=function(t,e){if(t.length>=255)throw TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i>>0,o=new Uint8Array(s);t[e];){var u=r[t.charCodeAt(e)];if(255===u)return;for(var l=0,c=s-1;(0!==u||l>>0,o[c]=u%256>>>0,u=u/256>>>0;if(0!==u)throw Error("Non-zero carry");n=l,e++}if(" "!==t[e]){for(var d=s-n;d!==s&&0===o[d];)d++;for(var p=new Uint8Array(i+(s-d)),g=i;d!==s;)p[g++]=o[d++];return p}}}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw TypeError("Expected Uint8Array");if(0===e.length)return"";for(var r=0,i=0,n=0,s=e.length;n!==s&&0===e[n];)n++,r++;for(var o=(s-n)*u+1>>>0,h=new Uint8Array(o);n!==s;){for(var l=e[n],c=0,d=o-1;(0!==l||c>>0,h[d]=l%a>>>0,l=l/a>>>0;if(0!==l)throw Error("Non-zero carry");i=c,n++}for(var p=o-i;p!==o&&0===h[p];)p++;for(var g=f.repeat(r);p{if(t instanceof Uint8Array&&"Uint8Array"===t.constructor.name)return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw Error("Unknown type, must be binary type")},oN=t=>new TextEncoder().encode(t),oC=t=>new TextDecoder().decode(t);class oB{constructor(t,e,r){this.name=t,this.prefix=e,this.baseEncode=r}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}class oR{constructor(t,e,r){if(this.name=t,this.prefix=e,void 0===e.codePointAt(0))throw Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=r}decode(t){if("string"==typeof t){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(t){return oO(this,t)}}class oP{constructor(t){this.decoders=t}or(t){return oO(this,t)}decode(t){let e=t[0],r=this.decoders[e];if(r)return r.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}let oO=(t,e)=>new oP({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class oT{constructor(t,e,r,i){this.name=t,this.prefix=e,this.baseEncode=r,this.baseDecode=i,this.encoder=new oB(t,e,r),this.decoder=new oR(t,e,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}let oD=({name:t,prefix:e,encode:r,decode:i})=>new oT(t,e,r,i),oU=({prefix:t,name:e,alphabet:r})=>{let{encode:i,decode:n}=oS(r,e);return oD({prefix:t,name:e,encode:i,decode:t=>o_(n(t))})},ok=(t,e,r,i)=>{let n={};for(let t=0;t=8&&(a-=8,o[h++]=255&f>>a)}if(a>=r||255&f<<8-a)throw SyntaxError("Unexpected end of data");return o},oq=(t,e,r)=>{let i="="===e[e.length-1],n=(1<r;)o-=r,s+=e[n&a>>o];if(o&&(s+=e[n&a<oD({prefix:e,name:t,encode:t=>oq(t,i,r),decode:e=>ok(e,i,r,t)});var oz=Object.freeze({__proto__:null,identity:oD({prefix:"\0",name:"identity",encode:t=>oC(t),decode:t=>oN(t)})}),oL=Object.freeze({__proto__:null,base2:oF({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1})}),oH=Object.freeze({__proto__:null,base8:oF({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3})}),oQ=Object.freeze({__proto__:null,base10:oU({prefix:"9",name:"base10",alphabet:"0123456789"})});let oj=oF({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4});var oK=Object.freeze({__proto__:null,base16:oj,base16upper:oF({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4})});let oJ=oF({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),oG=oF({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),oY=oF({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),oV=oF({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),oW=oF({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),oX=oF({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),oZ=oF({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),o$=oF({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5});var o0=Object.freeze({__proto__:null,base32:oJ,base32upper:oG,base32pad:oY,base32padupper:oV,base32hex:oW,base32hexupper:oX,base32hexpad:oZ,base32hexpadupper:o$,base32z:oF({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5})});let o1=oU({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"});var o2=Object.freeze({__proto__:null,base36:o1,base36upper:oU({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"})});let o3=oU({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"});var o6=Object.freeze({__proto__:null,base58btc:o3,base58flickr:oU({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"})});let o8=oF({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),o5=oF({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),o4=oF({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6});var o9=Object.freeze({__proto__:null,base64:o8,base64pad:o5,base64url:o4,base64urlpad:oF({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6})});let o7=Array.from("\uD83D\uDE80\uD83E\uDE90☄\uD83D\uDEF0\uD83C\uDF0C\uD83C\uDF11\uD83C\uDF12\uD83C\uDF13\uD83C\uDF14\uD83C\uDF15\uD83C\uDF16\uD83C\uDF17\uD83C\uDF18\uD83C\uDF0D\uD83C\uDF0F\uD83C\uDF0E\uD83D\uDC09☀\uD83D\uDCBB\uD83D\uDDA5\uD83D\uDCBE\uD83D\uDCBF\uD83D\uDE02❤\uD83D\uDE0D\uD83E\uDD23\uD83D\uDE0A\uD83D\uDE4F\uD83D\uDC95\uD83D\uDE2D\uD83D\uDE18\uD83D\uDC4D\uD83D\uDE05\uD83D\uDC4F\uD83D\uDE01\uD83D\uDD25\uD83E\uDD70\uD83D\uDC94\uD83D\uDC96\uD83D\uDC99\uD83D\uDE22\uD83E\uDD14\uD83D\uDE06\uD83D\uDE44\uD83D\uDCAA\uD83D\uDE09☺\uD83D\uDC4C\uD83E\uDD17\uD83D\uDC9C\uD83D\uDE14\uD83D\uDE0E\uD83D\uDE07\uD83C\uDF39\uD83E\uDD26\uD83C\uDF89\uD83D\uDC9E✌✨\uD83E\uDD37\uD83D\uDE31\uD83D\uDE0C\uD83C\uDF38\uD83D\uDE4C\uD83D\uDE0B\uD83D\uDC97\uD83D\uDC9A\uD83D\uDE0F\uD83D\uDC9B\uD83D\uDE42\uD83D\uDC93\uD83E\uDD29\uD83D\uDE04\uD83D\uDE00\uD83D\uDDA4\uD83D\uDE03\uD83D\uDCAF\uD83D\uDE48\uD83D\uDC47\uD83C\uDFB6\uD83D\uDE12\uD83E\uDD2D❣\uD83D\uDE1C\uD83D\uDC8B\uD83D\uDC40\uD83D\uDE2A\uD83D\uDE11\uD83D\uDCA5\uD83D\uDE4B\uD83D\uDE1E\uD83D\uDE29\uD83D\uDE21\uD83E\uDD2A\uD83D\uDC4A\uD83E\uDD73\uD83D\uDE25\uD83E\uDD24\uD83D\uDC49\uD83D\uDC83\uD83D\uDE33✋\uD83D\uDE1A\uD83D\uDE1D\uD83D\uDE34\uD83C\uDF1F\uD83D\uDE2C\uD83D\uDE43\uD83C\uDF40\uD83C\uDF37\uD83D\uDE3B\uD83D\uDE13⭐✅\uD83E\uDD7A\uD83C\uDF08\uD83D\uDE08\uD83E\uDD18\uD83D\uDCA6✔\uD83D\uDE23\uD83C\uDFC3\uD83D\uDC90☹\uD83C\uDF8A\uD83D\uDC98\uD83D\uDE20☝\uD83D\uDE15\uD83C\uDF3A\uD83C\uDF82\uD83C\uDF3B\uD83D\uDE10\uD83D\uDD95\uD83D\uDC9D\uD83D\uDE4A\uD83D\uDE39\uD83D\uDDE3\uD83D\uDCAB\uD83D\uDC80\uD83D\uDC51\uD83C\uDFB5\uD83E\uDD1E\uD83D\uDE1B\uD83D\uDD34\uD83D\uDE24\uD83C\uDF3C\uD83D\uDE2B⚽\uD83E\uDD19☕\uD83C\uDFC6\uD83E\uDD2B\uD83D\uDC48\uD83D\uDE2E\uD83D\uDE46\uD83C\uDF7B\uD83C\uDF43\uD83D\uDC36\uD83D\uDC81\uD83D\uDE32\uD83C\uDF3F\uD83E\uDDE1\uD83C\uDF81⚡\uD83C\uDF1E\uD83C\uDF88❌✊\uD83D\uDC4B\uD83D\uDE30\uD83E\uDD28\uD83D\uDE36\uD83E\uDD1D\uD83D\uDEB6\uD83D\uDCB0\uD83C\uDF53\uD83D\uDCA2\uD83E\uDD1F\uD83D\uDE41\uD83D\uDEA8\uD83D\uDCA8\uD83E\uDD2C✈\uD83C\uDF80\uD83C\uDF7A\uD83E\uDD13\uD83D\uDE19\uD83D\uDC9F\uD83C\uDF31\uD83D\uDE16\uD83D\uDC76\uD83E\uDD74▶➡❓\uD83D\uDC8E\uD83D\uDCB8⬇\uD83D\uDE28\uD83C\uDF1A\uD83E\uDD8B\uD83D\uDE37\uD83D\uDD7A⚠\uD83D\uDE45\uD83D\uDE1F\uD83D\uDE35\uD83D\uDC4E\uD83E\uDD32\uD83E\uDD20\uD83E\uDD27\uD83D\uDCCC\uD83D\uDD35\uD83D\uDC85\uD83E\uDDD0\uD83D\uDC3E\uD83C\uDF52\uD83D\uDE17\uD83E\uDD11\uD83C\uDF0A\uD83E\uDD2F\uD83D\uDC37☎\uD83D\uDCA7\uD83D\uDE2F\uD83D\uDC86\uD83D\uDC46\uD83C\uDFA4\uD83D\uDE47\uD83C\uDF51❄\uD83C\uDF34\uD83D\uDCA3\uD83D\uDC38\uD83D\uDC8C\uD83D\uDCCD\uD83E\uDD40\uD83E\uDD22\uD83D\uDC45\uD83D\uDCA1\uD83D\uDCA9\uD83D\uDC50\uD83D\uDCF8\uD83D\uDC7B\uD83E\uDD10\uD83E\uDD2E\uD83C\uDFBC\uD83E\uDD75\uD83D\uDEA9\uD83C\uDF4E\uD83C\uDF4A\uD83D\uDC7C\uD83D\uDC8D\uD83D\uDCE3\uD83E\uDD42"),at=o7.reduce((t,e,r)=>(t[r]=e,t),[]),ae=o7.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);var ar=Object.freeze({__proto__:null,base256emoji:oD({prefix:"\uD83D\uDE80",name:"base256emoji",encode:function(t){return t.reduce((t,e)=>t+=at[e],"")},decode:function(t){let e=[];for(let r of t){let t=ae[r.codePointAt(0)];if(void 0===t)throw Error(`Non-base256emoji character: ${r}`);e.push(t)}return new Uint8Array(e)}})}),ai=-128;function an(t,e,r){e=e||[],r=r||0;for(var i=r;t>=0x80000000;)e[r++]=255&t|128,t/=128;for(;t&ai;)e[r++]=255&t|128,t>>>=7;return e[r]=0|t,an.bytes=r-i+1,e}function as(t,e){var r,i=0,e=e||0,n=0,s=e,o=t.length;do{if(s>=o)throw as.bytes=0,RangeError("Could not decode varint");r=t[s++],i+=n<28?(127&r)<=128);return as.bytes=s-e,i}var ao=an,aa=function(t){return t<128?1:t<16384?2:t<2097152?3:t<0x10000000?4:t<0x800000000?5:t<0x40000000000?6:t<0x2000000000000?7:t<0x100000000000000?8:t<0x8000000000000000?9:10};let af=(t,e,r=0)=>(ao(t,e,r),e),ah=t=>aa(t),au=(t,e)=>{let r=e.byteLength,i=ah(t),n=i+ah(r),s=new Uint8Array(n+r);return af(t,s,0),af(r,s,i),s.set(e,n),new al(t,r,e,s)};class al{constructor(t,e,r,i){this.code=t,this.size=e,this.digest=r,this.bytes=i}}let ac=({name:t,code:e,encode:r})=>new ad(t,e,r);class ad{constructor(t,e,r){this.name=t,this.code=e,this.encode=r}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?au(this.code,e):e.then(t=>au(this.code,t))}throw Error("Unknown type, must be binary type")}}let ap=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),ag=ac({name:"sha2-256",code:18,encode:ap("SHA-256")});var am=Object.freeze({__proto__:null,sha256:ag,sha512:ac({name:"sha2-512",code:19,encode:ap("SHA-512")})}),av=Object.freeze({__proto__:null,identity:{code:0,name:"identity",encode:o_,digest:t=>au(0,o_(t))}});new TextEncoder,new TextDecoder;let ay={...oz,...oL,...oH,...oQ,...oK,...o0,...o2,...o6,...o9,...ar};function ab(t){return null!=globalThis.Buffer?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}({...am,...av});function aA(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}let aw=aA("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),ax=aA("ascii","a",t=>{let e="a";for(let r=0;r{let e=function(t=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?ab(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}((t=t.substring(1)).length);for(let r=0;r{if(!this.initialized){let t=await this.getKeyChain();"u">typeof t&&(this.keychain=t),this.initialized=!0}},this.has=t=>(this.isInitialized(),this.keychain.has(t)),this.set=async(t,e)=>{this.isInitialized(),this.keychain.set(t,e),await this.persist()},this.get=t=>{this.isInitialized();let e=this.keychain.get(t);if(typeof e>"u"){let{message:e}=of("NO_MATCHING_KEY",`${this.name}: ${t}`);throw Error(e)}return e},this.del=async t=>{this.isInitialized(),this.keychain.delete(t),await this.persist()},this.core=t,this.logger=(0,rX.Ep)(e,this.name)}get context(){return(0,rX.Fd)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(t){await this.core.storage.setItem(this.storageKey,iv(t))}async getKeyChain(){let t=await this.core.storage.getItem(this.storageKey);return"u">typeof t?iy(t):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){let{message:t}=of("NOT_INITIALIZED",this.name);throw Error(t)}}}class aG{constructor(t,e,r){this.core=t,this.logger=e,this.name="crypto",this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=t=>(this.isInitialized(),this.keychain.has(t)),this.getClientId=async()=>{this.isInitialized();let t=await this.getClientSeed(),e=it.generateKeyPair(t);return it.encodeIss(e.publicKey)},this.generateKeyPair=()=>{this.isInitialized();let t=function(){let t=tb.generateKeyPair();return{privateKey:(0,tA.BB)(t.secretKey,sV),publicKey:(0,tA.BB)(t.publicKey,sV)}}();return this.setPrivateKey(t.publicKey,t.privateKey)},this.signJWT=async t=>{this.isInitialized();let e=await this.getClientSeed(),r=it.generateKeyPair(e),i=sZ();return await it.signJWT(i,t,aC,r)},this.generateSharedKey=(t,e,r)=>{this.isInitialized();let i=function(t,e){let r=tb.sharedKey((0,tA.mL)(t,sV),(0,tA.mL)(e,sV),!0),i=new tm.HKDF(ty.SHA256,r).expand(32);return(0,tA.BB)(i,sV)}(this.getPrivateKey(t),e);return this.setSymKey(i,r)},this.setSymKey=async(t,e)=>{this.isInitialized();let r=e||function(t){let e=(0,ty.hash)((0,tA.mL)(t,sV));return(0,tA.BB)(e,sV)}(t);return await this.keychain.set(r,t),r},this.deleteKeyPair=async t=>{this.isInitialized(),await this.keychain.del(t)},this.deleteSymKey=async t=>{this.isInitialized(),await this.keychain.del(t)},this.encode=async(t,e,r)=>{this.isInitialized();let i=s2(r),n=(0,r7.u)(e);if(s3(i)){let e=i.senderPublicKey,r=i.receiverPublicKey;t=await this.generateSharedKey(e,r)}let s=this.getSymKey(t),{type:o,senderPublicKey:a}=i;return function(t){var e;let r=(e="u">typeof t.type?t.type:0,(0,tA.mL)(`${e}`,sY));if(1===s0(r)&&typeof t.senderPublicKey>"u")throw Error("Missing sender public key for type 1 envelope");let i="u">typeof t.senderPublicKey?(0,tA.mL)(t.senderPublicKey,sV):void 0,n="u">typeof t.iv?(0,tA.mL)(t.iv,sV):(0,tv.randomBytes)(12);return function(t){if(1===s0(t.type)){if(typeof t.senderPublicKey>"u")throw Error("Missing sender public key for type 1 envelope");return(0,tA.BB)((0,tA.zo)([t.type,t.senderPublicKey,t.iv,t.sealed]),sW)}return(0,tA.BB)((0,tA.zo)([t.type,t.iv,t.sealed]),sW)}({type:r,sealed:new tg.ChaCha20Poly1305((0,tA.mL)(t.symKey,sV)).seal(n,(0,tA.mL)(t.message,sX)),iv:n,senderPublicKey:i})}({type:o,symKey:s,message:n,senderPublicKey:a})},this.decode=async(t,e,r)=>{this.isInitialized();let i=function(t,e){let r=s1(t);return s2({type:s0(r.type),senderPublicKey:"u">typeof r.senderPublicKey?(0,tA.BB)(r.senderPublicKey,sV):void 0,receiverPublicKey:e?.receiverPublicKey})}(e,r);if(s3(i)){let e=i.receiverPublicKey,r=i.senderPublicKey;t=await this.generateSharedKey(e,r)}try{let r=this.getSymKey(t),i=function(t){let e=new tg.ChaCha20Poly1305((0,tA.mL)(t.symKey,sV)),{sealed:r,iv:i}=s1(t.encoded),n=e.open(i,r);if(null===n)throw Error("Failed to decrypt");return(0,tA.BB)(n,sX)}({symKey:r,encoded:e});return(0,r7.D)(i)}catch(e){this.logger.error(`Failed to decode message from topic: '${t}', clientId: '${await this.getClientId()}'`),this.logger.error(e)}},this.getPayloadType=t=>s0(s1(t).type),this.getPayloadSenderPublicKey=t=>{let e=s1(t);return e.senderPublicKey?(0,tA.BB)(e.senderPublicKey,sV):void 0},this.core=t,this.logger=(0,rX.Ep)(e,this.name),this.keychain=r||new aJ(this.core,this.logger)}get context(){return(0,rX.Fd)(this.logger)}async setPrivateKey(t,e){return await this.keychain.set(t,e),t}getPrivateKey(t){return this.keychain.get(t)}async getClientSeed(){let t="";try{t=this.keychain.get(aN)}catch{t=sZ(),await this.keychain.set(aN,t)}return function(t,e="utf8"){let r=aM[e];if(!r)throw Error(`Unsupported encoding "${e}"`);return("utf8"===e||"utf-8"===e)&&null!=globalThis.Buffer&&null!=globalThis.Buffer.from?ab(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}(t,"base16")}getSymKey(t){return this.keychain.get(t)}isInitialized(){if(!this.initialized){let{message:t}=of("NOT_INITIALIZED",this.name);throw Error(t)}}}class aY extends r1{constructor(t,e){super(t,e),this.logger=t,this.core=e,this.messages=new Map,this.name="messages",this.version="0.3",this.initialized=!1,this.storagePrefix=aI,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{let t=await this.getRelayerMessages();"u">typeof t&&(this.messages=t),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(t){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(t)}finally{this.initialized=!0}}},this.set=async(t,e)=>{this.isInitialized();let r=s$(e),i=this.messages.get(t);return typeof i>"u"&&(i={}),"u">typeof i[r]||(i[r]=e,this.messages.set(t,i),await this.persist()),r},this.get=t=>{this.isInitialized();let e=this.messages.get(t);return typeof e>"u"&&(e={}),e},this.has=(t,e)=>{this.isInitialized();let r=this.get(t);return"u">typeof r[s$(e)]},this.del=async t=>{this.isInitialized(),this.messages.delete(t),await this.persist()},this.logger=(0,rX.Ep)(t,this.name),this.core=e}get context(){return(0,rX.Fd)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(t){await this.core.storage.setItem(this.storageKey,iv(t))}async getRelayerMessages(){let t=await this.core.storage.getItem(this.storageKey);return"u">typeof t?iy(t):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){let{message:t}=of("NOT_INITIALIZED",this.name);throw Error(t)}}}class aV extends r2{constructor(t,e){super(t,e),this.relayer=t,this.logger=e,this.events=new th.EventEmitter,this.name="publisher",this.queue=new Map,this.publishTimeout=(0,tl.toMiliseconds)(tl.ONE_MINUTE),this.failedPublishTimeout=(0,tl.toMiliseconds)(tl.ONE_SECOND),this.needsTransportRestart=!1,this.publish=async(t,e,r)=>{var i;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:t,message:e,opts:r}});let n=r?.ttl||aB,s=s6(r),o=r?.prompt||!1,a=r?.tag||0,f=r?.id||(0,om.getBigIntRpcId)().toString(),h={topic:t,message:e,opts:{ttl:n,relay:s,prompt:o,tag:a,id:f}},u=`Failed to publish payload, please try again. id:${f} tag:${a}`,l=Date.now(),c,d=1;try{for(;void 0===c;){if(Date.now()-l>this.publishTimeout)throw Error(u);this.logger.trace({id:f,attempts:d},`publisher.publish - attempt ${d}`),c=await await ib(this.rpcPublish(t,e,n,s,o,a,f).catch(t=>this.logger.warn(t)),this.publishTimeout,u),d++,c||await new Promise(t=>setTimeout(t,this.failedPublishTimeout))}this.relayer.events.emit(aO.publish,h),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:f,topic:t,message:e,opts:r}})}catch(t){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(t),null!=(i=r?.internal)&&i.throwOnFailedPublish)throw t;this.queue.set(f,h)}},this.on=(t,e)=>{this.events.on(t,e)},this.once=(t,e)=>{this.events.once(t,e)},this.off=(t,e)=>{this.events.off(t,e)},this.removeListener=(t,e)=>{this.events.removeListener(t,e)},this.relayer=t,this.logger=(0,rX.Ep)(e,this.name),this.registerEventListeners()}get context(){return(0,rX.Fd)(this.logger)}rpcPublish(t,e,r,i,n,s,o){var a,f,h,u;let l={method:s8(i.protocol).publish,params:{topic:t,message:e,ttl:r,prompt:n,tag:s},id:o};return ou(null==(a=l.params)?void 0:a.prompt)&&(null==(f=l.params)||delete f.prompt),ou(null==(h=l.params)?void 0:h.tag)&&(null==(u=l.params)||delete u.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:l}),this.relayer.request(l)}removeRequestFromQueue(t){this.queue.delete(t)}checkQueue(){this.queue.forEach(async t=>{let{topic:e,message:r,opts:i}=t;await this.publish(e,r,i)})}registerEventListeners(){this.relayer.core.heartbeat.on(rW.HEARTBEAT_EVENTS.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(aO.connection_stalled);return}this.checkQueue()}),this.relayer.on(aO.message_ack,t=>{this.removeRequestFromQueue(t.id.toString())})}}class aW{constructor(){this.map=new Map,this.set=(t,e)=>{let r=this.get(t);this.exists(t,e)||this.map.set(t,[...r,e])},this.get=t=>this.map.get(t)||[],this.exists=(t,e)=>this.get(t).includes(e),this.delete=(t,e)=>{if(typeof e>"u"){this.map.delete(t);return}if(!this.map.has(t))return;let r=this.get(t);if(!this.exists(t,e))return;let i=r.filter(t=>t!==e);if(!i.length){this.map.delete(t);return}this.map.set(t,i)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var aX=Object.defineProperty,aZ=Object.defineProperties,a$=Object.getOwnPropertyDescriptors,a0=Object.getOwnPropertySymbols,a1=Object.prototype.hasOwnProperty,a2=Object.prototype.propertyIsEnumerable,a3=(t,e,r)=>e in t?aX(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,a6=(t,e)=>{for(var r in e||(e={}))a1.call(e,r)&&a3(t,r,e[r]);if(a0)for(var r of a0(e))a2.call(e,r)&&a3(t,r,e[r]);return t},a8=(t,e)=>aZ(t,a$(e));class a5 extends r8{constructor(t,e){super(t,e),this.relayer=t,this.logger=e,this.subscriptions=new Map,this.topicMap=new aW,this.events=new th.EventEmitter,this.name="subscription",this.version="0.3",this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=aI,this.subscribeTimeout=(0,tl.toMiliseconds)(tl.ONE_MINUTE),this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId())},this.subscribe=async(t,e)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:t,opts:e}});try{let r=s6(e),i={topic:t,relay:r};this.pending.set(t,i);let n=await this.rpcSubscribe(t,r);return"string"==typeof n&&(this.onSubscribe(n,i),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:t,opts:e}})),n}catch(t){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(t),t}},this.unsubscribe=async(t,e)=>{await this.restartToComplete(),this.isInitialized(),"u">typeof e?.id?await this.unsubscribeById(t,e.id,e):await this.unsubscribeByTopic(t,e)},this.isSubscribed=async t=>{if(this.topics.includes(t))return!0;let e=`${this.pendingSubscriptionWatchLabel}_${t}`;return await new Promise((r,i)=>{let n=new tl.Watch;n.start(e);let s=setInterval(()=>{!this.pending.has(t)&&this.topics.includes(t)&&(clearInterval(s),n.stop(e),r(!0)),n.elapsed(e)>=ak&&(clearInterval(s),n.stop(e),i(Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(t,e)=>{this.events.on(t,e)},this.once=(t,e)=>{this.events.once(t,e)},this.off=(t,e)=>{this.events.off(t,e)},this.removeListener=(t,e)=>{this.events.removeListener(t,e)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=t,this.logger=(0,rX.Ep)(e,this.name),this.clientId=""}get context(){return(0,rX.Fd)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(t,e){let r=!1;try{r=this.getSubscription(t).topic===e}catch{}return r}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(t,e){let r=this.topicMap.get(t);await Promise.all(r.map(async r=>await this.unsubscribeById(t,r,e)))}async unsubscribeById(t,e,r){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:e,opts:r}});try{let i=s6(r);await this.rpcUnsubscribe(t,e,i);let n=oh("USER_DISCONNECTED",`${this.name}, ${t}`);await this.onUnsubscribe(t,e,n),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:e,opts:r}})}catch(t){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(t),t}}async rpcSubscribe(t,e){let r={method:s8(e.protocol).subscribe,params:{topic:t}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});try{return await await ib(this.relayer.request(r).catch(t=>this.logger.warn(t)),this.subscribeTimeout)?s$(t+this.clientId):null}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(aO.connection_stalled)}return null}async rpcBatchSubscribe(t){if(!t.length)return;let e={method:s8(t[0].relay.protocol).batchSubscribe,params:{topics:t.map(t=>t.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:e});try{return await await ib(this.relayer.request(e).catch(t=>this.logger.warn(t)),this.subscribeTimeout)}catch{this.relayer.events.emit(aO.connection_stalled)}}rpcUnsubscribe(t,e,r){let i={method:s8(r.protocol).unsubscribe,params:{topic:t,id:e}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.request(i)}onSubscribe(t,e){this.setSubscription(t,a8(a6({},e),{id:t})),this.pending.delete(e.topic)}onBatchSubscribe(t){t.length&&t.forEach(t=>{this.setSubscription(t.id,a6({},t)),this.pending.delete(t.topic)})}async onUnsubscribe(t,e,r){this.events.removeAllListeners(e),this.hasSubscription(e,t)&&this.deleteSubscription(e,r),await this.relayer.messages.del(t)}async setRelayerSubscriptions(t){await this.relayer.core.storage.setItem(this.storageKey,t)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(t,e){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:t,subscription:e}),this.addSubscription(t,e)}addSubscription(t,e){this.subscriptions.set(t,a6({},e)),this.topicMap.set(e.topic,t),this.events.emit(aU.created,e)}getSubscription(t){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:t});let e=this.subscriptions.get(t);if(!e){let{message:e}=of("NO_MATCHING_KEY",`${this.name}: ${t}`);throw Error(e)}return e}deleteSubscription(t,e){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:t,reason:e});let r=this.getSubscription(t);this.subscriptions.delete(t),this.topicMap.delete(r.topic,t),this.events.emit(aU.deleted,a8(a6({},r),{reason:e}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(aU.sync)}async reset(){if(this.cached.length){let t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let e=0;e"u"||!t.length)return;if(this.subscriptions.size){let{message:t}=of("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),Error(t)}this.cached=t,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(t){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(t)}}async batchSubscribe(t){var e,r;if(!t.length)return;let i=await this.rpcBatchSubscribe(t);Array.isArray(e=i)&&this.onBatchSubscribe(i.map((e,r)=>a8(a6({},t[r]),{id:e})))}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||!this.relayer.connected)return;let t=[];this.pending.forEach(e=>{t.push(e)}),await this.batchSubscribe(t)}registerEventListeners(){this.relayer.core.heartbeat.on(rW.HEARTBEAT_EVENTS.pulse,async()=>{await this.checkPending()}),this.events.on(aU.created,async t=>{let e=aU.created;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),await this.persist()}),this.events.on(aU.deleted,async t=>{let e=aU.deleted;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),await this.persist()})}isInitialized(){if(!this.initialized){let{message:t}=of("NOT_INITIALIZED",this.name);throw Error(t)}}async restartToComplete(){this.restartInProgress&&await new Promise(t=>{let e=setInterval(()=>{this.restartInProgress||(clearInterval(e),t())},this.pollingInterval)})}}var a4=Object.defineProperty,a9=Object.getOwnPropertySymbols,a7=Object.prototype.hasOwnProperty,ft=Object.prototype.propertyIsEnumerable,fe=(t,e,r)=>e in t?a4(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,fr=(t,e)=>{for(var r in e||(e={}))a7.call(e,r)&&fe(t,r,e[r]);if(a9)for(var r of a9(e))ft.call(e,r)&&fe(t,r,e[r]);return t};class fi extends r3{constructor(t){super(t),this.protocol="wc",this.version=2,this.events=new th.EventEmitter,this.name="relayer",this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","socket stalled","interrupted"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.heartBeatTimeout=(0,tl.toMiliseconds)(tl.THIRTY_SECONDS+tl.ONE_SECOND),this.request=async t=>{var e,r;this.logger.debug("Publishing Request Payload");let i=t.id||(0,om.getBigIntRpcId)().toString();await this.toEstablishConnection();try{let n=this.provider.request(t);this.requestsInFlight.set(i,{promise:n,request:t}),this.logger.trace({id:i,method:t.method,topic:null==(e=t.params)?void 0:e.topic},"relayer.request - attempt to publish...");let s=await new Promise(async(t,e)=>{let r=()=>{e(Error(`relayer.request - publish interrupted, id: ${i}`))};this.provider.on(aT.disconnect,r);let s=await n;this.provider.off(aT.disconnect,r),t(s)});return this.logger.trace({id:i,method:t.method,topic:null==(r=t.params)?void 0:r.topic},"relayer.request - published"),s}catch(t){throw this.logger.debug(`Failed to Publish Request: ${i}`),t}finally{this.requestsInFlight.delete(i)}},this.resetPingTimeout=()=>{if(id())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var t,e,r;null==(r=null==(e=null==(t=this.provider)?void 0:t.connection)?void 0:e.socket)||r.terminate()},this.heartBeatTimeout)}catch(t){this.logger.warn(t)}},this.onPayloadHandler=t=>{this.onProviderPayload(t),this.resetPingTimeout()},this.onConnectHandler=()=>{this.startPingTimeout(),this.events.emit(aO.connect)},this.onDisconnectHandler=()=>{this.onProviderDisconnect()},this.onProviderErrorHandler=t=>{this.logger.error(t),this.events.emit(aO.error,t),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(aT.payload,this.onPayloadHandler),this.provider.on(aT.connect,this.onConnectHandler),this.provider.on(aT.disconnect,this.onDisconnectHandler),this.provider.on(aT.error,this.onProviderErrorHandler)},this.core=t.core,this.logger="u">typeof t.logger&&"string"!=typeof t.logger?(0,rX.Ep)(t.logger,this.name):(0,rX.gw)((0,rX.jI)({level:t.logger||"error"})),this.messages=new aY(this.logger,t.core),this.subscriber=new a5(this,this.logger),this.publisher=new aV(this,this.logger),this.relayUrl=t?.relayUrl||aR,this.projectId=t.projectId,this.bundleId=function(){var t;try{return ip()&&"u">typeof r.g&&"u">typeof(null==r.g?void 0:r.g.Application)?null==(t=r.g.Application)?void 0:t.applicationId:void 0}catch{return}}(),this.provider={}}async init(){this.logger.trace("Initialized"),this.registerEventListeners(),await this.createProvider(),await Promise.all([this.messages.init(),this.subscriber.init()]);try{await this.transportOpen()}catch{this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${aP}...`),await this.restartTransport(aP)}this.initialized=!0,setTimeout(async()=>{0===this.subscriber.topics.length&&0===this.subscriber.pending.size&&(this.logger.info("No topics subscribed to after init, closing transport"),await this.transportClose(),this.transportExplicitlyClosed=!1)},1e4)}get context(){return(0,rX.Fd)(this.logger)}get connected(){var t,e,r;return(null==(r=null==(e=null==(t=this.provider)?void 0:t.connection)?void 0:e.socket)?void 0:r.readyState)===1}get connecting(){var t,e,r;return(null==(r=null==(e=null==(t=this.provider)?void 0:t.connection)?void 0:e.socket)?void 0:r.readyState)===0}async publish(t,e,r){this.isInitialized(),await this.publisher.publish(t,e,r),await this.recordMessageEvent({topic:t,message:e,publishedAt:Date.now()})}async subscribe(t,e){var r;this.isInitialized();let i=(null==(r=this.subscriber.topicMap.get(t))?void 0:r[0])||"",n,s=e=>{e.topic===t&&(this.subscriber.off(aU.created,s),n())};return await Promise.all([new Promise(t=>{n=t,this.subscriber.on(aU.created,s)}),new Promise(async r=>{i=await this.subscriber.subscribe(t,e)||i,r()})]),i}async unsubscribe(t,e){this.isInitialized(),await this.subscriber.unsubscribe(t,e)}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async transportDisconnect(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{await Promise.all(Array.from(this.requestsInFlight.values()).map(t=>t.promise))}catch(t){this.logger.warn(t)}this.hasExperiencedNetworkDisruption||this.connected?await ib(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(t){await this.confirmOnlineStateOrThrow(),t&&t!==this.relayUrl&&(this.relayUrl=t,await this.transportDisconnect(),await this.createProvider()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{await new Promise(async(t,e)=>{let r=()=>{this.provider.off(aT.disconnect,r),e(Error("Connection interrupted while trying to subscribe"))};this.provider.on(aT.disconnect,r),await ib(this.provider.connect(),(0,tl.toMiliseconds)(tl.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(t=>{e(t)}),await this.subscriber.start(),this.hasExperiencedNetworkDisruption=!1,t()})}catch(t){this.logger.error(t);if(!this.isConnectionStalled(t.message))throw t}finally{this.connectionAttemptInProgress=!1}}async restartTransport(t){this.connectionAttemptInProgress||(this.relayUrl=t||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.createProvider(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await od())throw Error("No internet connection detected. Please restart your network and try again.")}startPingTimeout(){var t,e,r,i,n;if(id())try{null!=(e=null==(t=this.provider)?void 0:t.connection)&&e.socket&&(null==(n=null==(i=null==(r=this.provider)?void 0:r.connection)?void 0:i.socket)||n.once("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(t){this.logger.warn(t)}}isConnectionStalled(t){return this.staleConnectionErrors.some(e=>t.includes(e))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();let t=await this.core.crypto.signJWT(this.relayUrl);this.provider=new og.r(new oA(function({protocol:t,version:e,relayUrl:i,sdkVersion:n,auth:s,projectId:o,useOnCloseEvent:a,bundleId:f}){var h,u;let l;let c=i.split("?"),d=function(t,e,i){let n=function(){if(im()===ic.reactNative&&"u">typeof r.g&&"u">typeof(null==r.g?void 0:r.g.Platform)){let{OS:t,Version:e}=r.g.Platform;return[t,e].join("-")}let t=(0,ie.qY)();if(null===t)return"unknown";let e=t.os?t.os.replace(" ","").toLowerCase():"unknown";return"browser"===t.type?[e,t.name,t.version].join("-"):[e,t.version].join("-")}(),s=function(){var t;let e=im();return e===ic.browser?[e,(null==(t=(0,tc.getLocation)())?void 0:t.host)||"unknown"].join(":"):e}();return[[t,e].join("-"),["js",i].join("-"),n,s].join("/")}(t,e,n),p=(h=c[1]||"",u={auth:s,ua:d,projectId:o,useOnCloseEvent:a||void 0,origin:f||void 0},l=il(il({},l=tp.parse(h)),u),h=tp.stringify(l));return c[0]+"?"+p}({sdkVersion:"2.12.1",protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:t,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(t){let{topic:e,message:r}=t;await this.messages.set(e,r)}async shouldIgnoreMessageEvent(t){let{topic:e,message:r}=t;if(!r||0===r.length)return this.logger.debug(`Ignoring invalid/empty message: ${r}`),!0;if(!await this.subscriber.isSubscribed(e))return this.logger.debug(`Ignoring message for non-subscribed topic ${e}`),!0;let i=this.messages.has(e,r);return i&&this.logger.debug(`Ignoring duplicate message: ${r}`),i}async onProviderPayload(t){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:t}),(0,om.isJsonRpcRequest)(t)){if(!t.method.endsWith("_subscription"))return;let e=t.params,{topic:r,message:i,publishedAt:n}=e.data,s={topic:r,message:i,publishedAt:n};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(fr({type:"event",event:e.id},s)),this.events.emit(e.id,s),await this.acknowledgePayload(t),await this.onMessageEvent(s)}else(0,om.isJsonRpcResponse)(t)&&this.events.emit(aO.message_ack,t)}async onMessageEvent(t){await this.shouldIgnoreMessageEvent(t)||(this.events.emit(aO.message,t),await this.recordMessageEvent(t))}async acknowledgePayload(t){let e=(0,om.formatJsonRpcResult)(t.id,!0);await this.provider.connection.send(e)}unregisterProviderListeners(){this.provider.off(aT.payload,this.onPayloadHandler),this.provider.off(aT.connect,this.onConnectHandler),this.provider.off(aT.disconnect,this.onDisconnectHandler),this.provider.off(aT.error,this.onProviderErrorHandler)}async registerEventListeners(){let t=await od();!function(t){switch(im()){case ic.browser:(function(t){!ip()&&ig()&&(window.addEventListener("online",()=>t(!0)),window.addEventListener("offline",()=>t(!1)))})(t);break;case ic.reactNative:(function(t){ip()&&"u">typeof r.g&&null!=r.g&&r.g.NetInfo&&r.g?.NetInfo.addEventListener(e=>t(e?.isConnected))})(t);case ic.node:}}(async e=>{t!==e&&(t=e,e?await this.restartTransport().catch(t=>this.logger.error(t)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),this.events.emit(aO.disconnect),this.connectionAttemptInProgress=!1,this.transportExplicitlyClosed||setTimeout(async()=>{await this.transportOpen().catch(t=>this.logger.error(t))},(0,tl.toMiliseconds)(aD))}isInitialized(){if(!this.initialized){let{message:t}=of("NOT_INITIALIZED",this.name);throw Error(t)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),this.connected||(this.connectionAttemptInProgress&&await new Promise(t=>{let e=setInterval(()=>{this.connected&&(clearInterval(e),t())},this.connectionStatusPollingInterval)}),await this.transportOpen())}}var fn=Object.defineProperty,fs=Object.getOwnPropertySymbols,fo=Object.prototype.hasOwnProperty,fa=Object.prototype.propertyIsEnumerable,ff=(t,e,r)=>e in t?fn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,fh=(t,e)=>{for(var r in e||(e={}))fo.call(e,r)&&ff(t,r,e[r]);if(fs)for(var r of fs(e))fa.call(e,r)&&ff(t,r,e[r]);return t};class fu extends r6{constructor(t,e,r,i=aI,n){super(t,e,r,i),this.core=t,this.logger=e,this.name=r,this.map=new Map,this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=aI,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(t=>{var e,r,i;this.getKey&&null!==t&&!ou(t)?this.map.set(this.getKey(t),t):(e=t,null==(r=e?.proposer)?void 0:r.publicKey)?this.map.set(t.id,t):(i=t,i?.topic&&this.map.set(t.topic,t))}),this.cached=[],this.initialized=!0)},this.set=async(t,e)=>{this.isInitialized(),this.map.has(t)?await this.update(t,e):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:t,value:e}),this.map.set(t,e),await this.persist())},this.get=t=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:t}),this.getData(t)),this.getAll=t=>(this.isInitialized(),t?this.values.filter(e=>Object.keys(t).every(r=>ox()(e[r],t[r]))):this.values),this.update=async(t,e)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:t,update:e});let r=fh(fh({},this.getData(t)),e);this.map.set(t,r),await this.persist()},this.delete=async(t,e)=>{this.isInitialized(),this.map.has(t)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:t,reason:e}),this.map.delete(t),this.addToRecentlyDeleted(t),await this.persist())},this.logger=(0,rX.Ep)(e,this.name),this.storagePrefix=i,this.getKey=n}get context(){return(0,rX.Fd)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(t){this.recentlyDeleted.push(t),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(t){await this.core.storage.setItem(this.storageKey,t)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(t){let e=this.map.get(t);if(!e){if(this.recentlyDeleted.includes(t)){let{message:e}=of("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${t}`);throw this.logger.error(e),Error(e)}let{message:e}=of("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.error(e),Error(e)}return e}async persist(){await this.setDataStore(this.values)}async restore(){try{let t=await this.getDataStore();if(typeof t>"u"||!t.length)return;if(this.map.size){let{message:t}=of("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),Error(t)}this.cached=t,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(t){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(t)}}isInitialized(){if(!this.initialized){let{message:t}=of("NOT_INITIALIZED",this.name);throw Error(t)}}}class fl{constructor(t,e){this.core=t,this.logger=e,this.name="pairing",this.version="0.3",this.events=new(tu()),this.initialized=!1,this.storagePrefix=aI,this.ignoredPayloadTypes=[1],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:t})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...t])]},this.create=async t=>{var e;this.isInitialized();let r=sZ(),i=await this.core.crypto.setSymKey(r),n=iw(tl.FIVE_MINUTES),s={protocol:"irn"},o=(e={protocol:this.core.protocol,version:this.core.version,topic:i,symKey:r,relay:s,expiryTimestamp:n,methods:t?.methods},`${e.protocol}:${e.topic}@${e.version}?`+tp.stringify(oi(on(oi({symKey:e.symKey},function(t,e="-"){let r={};return Object.keys(t).forEach(i=>{t[i]&&(r["relay"+e+i]=t[i])}),r}(e.relay)),{expiryTimestamp:e.expiryTimestamp}),e.methods?{methods:e.methods.join(",")}:{})));return await this.pairings.set(i,{topic:i,expiry:n,relay:s,active:!1}),await this.core.relayer.subscribe(i),this.core.expirer.set(i,n),{topic:i,uri:o}},this.pair=async t=>{this.isInitialized(),this.isValidPair(t);let{topic:e,symKey:r,relay:i,expiryTimestamp:n,methods:s}=os(t.uri);if(this.pairings.keys.includes(e)&&this.pairings.get(e).active)throw Error(`Pairing already exists: ${e}. Please try again with a new connection URI.`);let o=n||iw(tl.FIVE_MINUTES),a={topic:e,relay:i,expiry:o,active:!1,methods:s};return await this.pairings.set(e,a),this.core.expirer.set(e,o),t.activatePairing&&await this.activate({topic:e}),this.events.emit(aF.create,a),this.core.crypto.keychain.has(e)||await this.core.crypto.setSymKey(r,e),await this.core.relayer.subscribe(e,{relay:i}),a},this.activate=async({topic:t})=>{this.isInitialized();let e=iw(tl.THIRTY_DAYS);await this.pairings.update(t,{active:!0,expiry:e}),this.core.expirer.set(t,e)},this.ping=async t=>{this.isInitialized(),await this.isValidPing(t);let{topic:e}=t;if(this.pairings.keys.includes(e)){let t=await this.sendRequest(e,"wc_pairingPing",{}),{done:r,resolve:i,reject:n}=function(t=tl.FIVE_MINUTES,e){let r,i,n;let s=(0,tl.toMiliseconds)(t||tl.FIVE_MINUTES);return{resolve:t=>{n&&r&&(clearTimeout(n),r(t))},reject:t=>{n&&i&&(clearTimeout(n),i(t))},done:()=>new Promise((t,e)=>{n=setTimeout(()=>{e(Error(void 0))},s),r=t,i=e})}}();this.events.once(iM("pairing_ping",t),({error:t})=>{t?n(t):i()}),await r()}},this.updateExpiry=async({topic:t,expiry:e})=>{this.isInitialized(),await this.pairings.update(t,{expiry:e})},this.updateMetadata=async({topic:t,metadata:e})=>{this.isInitialized(),await this.pairings.update(t,{peerMetadata:e})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async t=>{this.isInitialized(),await this.isValidDisconnect(t);let{topic:e}=t;this.pairings.keys.includes(e)&&(await this.sendRequest(e,"wc_pairingDelete",oh("USER_DISCONNECTED")),await this.deletePairing(e))},this.sendRequest=async(t,e,r)=>{let i=(0,om.formatJsonRpcRequest)(e,r),n=await this.core.crypto.encode(t,i),s=aq[e].req;return this.core.history.set(t,i),this.core.relayer.publish(t,n,s),i.id},this.sendResult=async(t,e,r)=>{let i=(0,om.formatJsonRpcResult)(t,r),n=await this.core.crypto.encode(e,i),s=aq[(await this.core.history.get(e,t)).request.method].res;await this.core.relayer.publish(e,n,s),await this.core.history.resolve(i)},this.sendError=async(t,e,r)=>{let i=(0,om.formatJsonRpcError)(t,r),n=await this.core.crypto.encode(e,i),s=await this.core.history.get(e,t),o=aq[s.request.method]?aq[s.request.method].res:aq.unregistered_method.res;await this.core.relayer.publish(e,n,o),await this.core.history.resolve(i)},this.deletePairing=async(t,e)=>{await this.core.relayer.unsubscribe(t),await Promise.all([this.pairings.delete(t,oh("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(t),e?Promise.resolve():this.core.expirer.del(t)])},this.cleanup=async()=>{let t=this.pairings.getAll().filter(t=>ix(t.expiry));await Promise.all(t.map(t=>this.deletePairing(t.topic)))},this.onRelayEventRequest=t=>{let{topic:e,payload:r}=t;switch(r.method){case"wc_pairingPing":return this.onPairingPingRequest(e,r);case"wc_pairingDelete":return this.onPairingDeleteRequest(e,r);default:return this.onUnknownRpcMethodRequest(e,r)}},this.onRelayEventResponse=async t=>{let{topic:e,payload:r}=t,i=(await this.core.history.get(e,r.id)).request.method;if("wc_pairingPing"===i)return this.onPairingPingResponse(e,r);return this.onUnknownRpcMethodResponse(i)},this.onPairingPingRequest=async(t,e)=>{let{id:r}=e;try{this.isValidPing({topic:t}),await this.sendResult(r,t,!0),this.events.emit(aF.ping,{id:r,topic:t})}catch(e){await this.sendError(r,t,e),this.logger.error(e)}},this.onPairingPingResponse=(t,e)=>{let{id:r}=e;setTimeout(()=>{(0,om.isJsonRpcResult)(e)?this.events.emit(iM("pairing_ping",r),{}):(0,om.isJsonRpcError)(e)&&this.events.emit(iM("pairing_ping",r),{error:e.error})},500)},this.onPairingDeleteRequest=async(t,e)=>{let{id:r}=e;try{this.isValidDisconnect({topic:t}),await this.deletePairing(t),this.events.emit(aF.delete,{id:r,topic:t})}catch(e){await this.sendError(r,t,e),this.logger.error(e)}},this.onUnknownRpcMethodRequest=async(t,e)=>{let{id:r,method:i}=e;try{if(this.registeredMethods.includes(i))return;let e=oh("WC_METHOD_UNSUPPORTED",i);await this.sendError(r,t,e),this.logger.error(e)}catch(e){await this.sendError(r,t,e),this.logger.error(e)}},this.onUnknownRpcMethodResponse=t=>{this.registeredMethods.includes(t)||this.logger.error(oh("WC_METHOD_UNSUPPORTED",t))},this.isValidPair=t=>{var e;if(!oc(t)){let{message:e}=of("MISSING_OR_INVALID",`pair() params: ${t}`);throw Error(e)}if(!function(t){if(ol(t,!1))try{return"u">typeof new URL(t)}catch{}return!1}(t.uri)){let{message:e}=of("MISSING_OR_INVALID",`pair() uri: ${t.uri}`);throw Error(e)}let r=os(t.uri);if(!(null!=(e=r?.relay)&&e.protocol)){let{message:t}=of("MISSING_OR_INVALID","pair() uri#relay-protocol");throw Error(t)}if(!(null!=r&&r.symKey)){let{message:t}=of("MISSING_OR_INVALID","pair() uri#symKey");throw Error(t)}if(null!=r&&r.expiryTimestamp&&(0,tl.toMiliseconds)(r?.expiryTimestamp){if(!oc(t)){let{message:e}=of("MISSING_OR_INVALID",`ping() params: ${t}`);throw Error(e)}let{topic:e}=t;await this.isValidPairingTopic(e)},this.isValidDisconnect=async t=>{if(!oc(t)){let{message:e}=of("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw Error(e)}let{topic:e}=t;await this.isValidPairingTopic(e)},this.isValidPairingTopic=async t=>{if(!ol(t,!1)){let{message:e}=of("MISSING_OR_INVALID",`pairing topic should be a string: ${t}`);throw Error(e)}if(!this.pairings.keys.includes(t)){let{message:e}=of("NO_MATCHING_KEY",`pairing topic doesn't exist: ${t}`);throw Error(e)}if(ix(this.pairings.get(t).expiry)){await this.deletePairing(t);let{message:e}=of("EXPIRED",`pairing topic: ${t}`);throw Error(e)}},this.core=t,this.logger=(0,rX.Ep)(e,this.name),this.pairings=new fu(this.core,this.logger,this.name,this.storagePrefix)}get context(){return(0,rX.Fd)(this.logger)}isInitialized(){if(!this.initialized){let{message:t}=of("NOT_INITIALIZED",this.name);throw Error(t)}}registerRelayerEvents(){this.core.relayer.on(aO.message,async t=>{let{topic:e,message:r}=t;if(!this.pairings.keys.includes(e)||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(r)))return;let i=await this.core.crypto.decode(e,r);try{(0,om.isJsonRpcRequest)(i)?(this.core.history.set(e,i),this.onRelayEventRequest({topic:e,payload:i})):(0,om.isJsonRpcResponse)(i)&&(await this.core.history.resolve(i),await this.onRelayEventResponse({topic:e,payload:i}),this.core.history.delete(e,i.id))}catch(t){this.logger.error(t)}})}registerExpirerEvents(){this.core.expirer.on(aL.expired,async t=>{let{topic:e}=function(t){let[e,r]=t.split(":"),i={id:void 0,topic:void 0};if("topic"===e&&"string"==typeof r)i.topic=r;else if("id"===e&&Number.isInteger(Number(r)))i.id=Number(r);else throw Error(`Invalid target, expected id:number or topic:string, got ${e}:${r}`);return i}(t.target);e&&this.pairings.keys.includes(e)&&(await this.deletePairing(e,!0),this.events.emit(aF.expire,{topic:e}))})}}class fc extends r0{constructor(t,e){super(t,e),this.core=t,this.logger=e,this.records=new Map,this.events=new th.EventEmitter,this.name="history",this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=aI,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(t=>this.records.set(t.id,t)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(t,e,r)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:t,request:e,chainId:r}),this.records.has(e.id))return;let i={id:e.id,topic:t,request:{method:e.method,params:e.params||null},chainId:r,expiry:iw(tl.THIRTY_DAYS)};this.records.set(i.id,i),this.persist(),this.events.emit(az.created,i)},this.resolve=async t=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:t}),!this.records.has(t.id))return;let e=await this.getRecord(t.id);typeof e.response>"u"&&(e.response=(0,om.isJsonRpcError)(t)?{error:t.error}:{result:t.result},this.records.set(e.id,e),this.persist(),this.events.emit(az.updated,e))},this.get=async(t,e)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:t,id:e}),await this.getRecord(e)),this.delete=(t,e)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:e}),this.values.forEach(r=>{r.topic===t&&(!("u">typeof e)||r.id===e)&&(this.records.delete(r.id),this.events.emit(az.deleted,r))}),this.persist()},this.exists=async(t,e)=>(this.isInitialized(),!!this.records.has(e)&&(await this.getRecord(e)).topic===t),this.on=(t,e)=>{this.events.on(t,e)},this.once=(t,e)=>{this.events.once(t,e)},this.off=(t,e)=>{this.events.off(t,e)},this.removeListener=(t,e)=>{this.events.removeListener(t,e)},this.logger=(0,rX.Ep)(e,this.name)}get context(){return(0,rX.Fd)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){let t=[];return this.values.forEach(e=>{if("u">typeof e.response)return;let r={topic:e.topic,request:(0,om.formatJsonRpcRequest)(e.request.method,e.request.params,e.id),chainId:e.chainId};return t.push(r)}),t}async setJsonRpcRecords(t){await this.core.storage.setItem(this.storageKey,t)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(t){this.isInitialized();let e=this.records.get(t);if(!e){let{message:e}=of("NO_MATCHING_KEY",`${this.name}: ${t}`);throw Error(e)}return e}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(az.sync)}async restore(){try{let t=await this.getJsonRpcRecords();if(typeof t>"u"||!t.length)return;if(this.records.size){let{message:t}=of("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),Error(t)}this.cached=t,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(t){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(t)}}registerEventListeners(){this.events.on(az.created,t=>{let e=az.created;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,record:t})}),this.events.on(az.updated,t=>{let e=az.updated;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,record:t})}),this.events.on(az.deleted,t=>{let e=az.deleted;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,record:t})}),this.core.heartbeat.on(rW.HEARTBEAT_EVENTS.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let t=!1;this.records.forEach(e=>{(0,tl.toMiliseconds)(e.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${e.id}`),this.records.delete(e.id),this.events.emit(az.deleted,e,!1),t=!0)}),t&&this.persist()}catch(t){this.logger.warn(t)}}isInitialized(){if(!this.initialized){let{message:t}=of("NOT_INITIALIZED",this.name);throw Error(t)}}}class fd extends r5{constructor(t,e){super(t,e),this.core=t,this.logger=e,this.expirations=new Map,this.events=new th.EventEmitter,this.name="expirer",this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=aI,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(t=>this.expirations.set(t.target,t)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=t=>{try{let e=this.formatTarget(t);return"u">typeof this.getExpiration(e)}catch{return!1}},this.set=(t,e)=>{this.isInitialized();let r=this.formatTarget(t),i={target:r,expiry:e};this.expirations.set(r,i),this.checkExpiry(r,i),this.events.emit(aL.created,{target:r,expiration:i})},this.get=t=>{this.isInitialized();let e=this.formatTarget(t);return this.getExpiration(e)},this.del=t=>{if(this.isInitialized(),this.has(t)){let e=this.formatTarget(t),r=this.getExpiration(e);this.expirations.delete(e),this.events.emit(aL.deleted,{target:e,expiration:r})}},this.on=(t,e)=>{this.events.on(t,e)},this.once=(t,e)=>{this.events.once(t,e)},this.off=(t,e)=>{this.events.off(t,e)},this.removeListener=(t,e)=>{this.events.removeListener(t,e)},this.logger=(0,rX.Ep)(e,this.name)}get context(){return(0,rX.Fd)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(t){if("string"==typeof t)return iA("topic",t);if("number"==typeof t)return iA("id",t);let{message:e}=of("UNKNOWN_TYPE",`Target type: ${typeof t}`);throw Error(e)}async setExpirations(t){await this.core.storage.setItem(this.storageKey,t)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(aL.sync)}async restore(){try{let t=await this.getExpirations();if(typeof t>"u"||!t.length)return;if(this.expirations.size){let{message:t}=of("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),Error(t)}this.cached=t,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(t){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(t)}}getExpiration(t){let e=this.expirations.get(t);if(!e){let{message:e}=of("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.warn(e),Error(e)}return e}checkExpiry(t,e){let{expiry:r}=e;(0,tl.toMiliseconds)(r)-Date.now()<=0&&this.expire(t,e)}expire(t,e){this.expirations.delete(t),this.events.emit(aL.expired,{target:t,expiration:e})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((t,e)=>this.checkExpiry(e,t))}registerEventListeners(){this.core.heartbeat.on(rW.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on(aL.created,t=>{let e=aL.created;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),this.persist()}),this.events.on(aL.expired,t=>{let e=aL.expired;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),this.persist()}),this.events.on(aL.deleted,t=>{let e=aL.deleted;this.logger.info(`Emitting ${e}`),this.logger.debug({type:"event",event:e,data:t}),this.persist()})}isInitialized(){if(!this.initialized){let{message:t}=of("NOT_INITIALIZED",this.name);throw Error(t)}}}class fp extends r4{constructor(t,e){super(t,e),this.projectId=t,this.logger=e,this.name=aH,this.initialized=!1,this.queue=[],this.verifyDisabled=!1,this.init=async t=>{if(this.verifyDisabled||ip()||!ig())return;let e=this.getVerifyUrl(t?.verifyUrl);this.verifyUrl!==e&&this.removeIframe(),this.verifyUrl=e;try{await this.createIframe()}catch(t){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(t)}if(!this.initialized){this.removeIframe(),this.verifyUrl=aj;try{await this.createIframe()}catch(t){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(t),this.verifyDisabled=!0}}},this.register=async t=>{this.initialized?this.sendPost(t.attestationId):(this.addToQueue(t.attestationId),await this.init())},this.resolve=async t=>{let e;if(this.isDevEnv)return"";let r=this.getVerifyUrl(t?.verifyUrl);try{e=await this.fetchAttestation(t.attestationId,r)}catch(i){this.logger.info(`failed to resolve attestation: ${t.attestationId} from url: ${r}`),this.logger.info(i),e=await this.fetchAttestation(t.attestationId,aj)}return e},this.fetchAttestation=async(t,e)=>{this.logger.info(`resolving attestation: ${t} from url: ${e}`);let r=this.startAbortTimer(2*tl.ONE_SECOND),i=await fetch(`${e}/attestation/${t}`,{signal:this.abortController.signal});return clearTimeout(r),200===i.status?await i.json():void 0},this.addToQueue=t=>{this.queue.push(t)},this.processQueue=()=>{0!==this.queue.length&&(this.queue.forEach(t=>this.sendPost(t)),this.queue=[])},this.sendPost=t=>{var e;try{if(!this.iframe)return;null==(e=this.iframe.contentWindow)||e.postMessage(t,"*"),this.logger.info(`postMessage sent: ${t} ${this.verifyUrl}`)}catch{}},this.createIframe=async()=>{let t;let e=r=>{"verify_ready"===r.data&&(this.onInit(),window.removeEventListener("message",e),t())};await Promise.race([new Promise(r=>{let i=document.getElementById(aH);if(i)return this.iframe=i,this.onInit(),r();window.addEventListener("message",e);let n=document.createElement("iframe");n.id=aH,n.src=`${this.verifyUrl}/${this.projectId}`,n.style.display="none",document.body.append(n),this.iframe=n,t=r}),new Promise((t,r)=>setTimeout(()=>{window.removeEventListener("message",e),r("verify iframe load timeout")},(0,tl.toMiliseconds)(tl.FIVE_SECONDS)))])},this.onInit=()=>{this.initialized=!0,this.processQueue()},this.removeIframe=()=>{this.iframe&&(this.iframe.remove(),this.iframe=void 0,this.initialized=!1)},this.getVerifyUrl=t=>{let e=t||aQ;return aK.includes(e)||(this.logger.info(`verify url: ${e}, not included in trusted list, assigning default: ${aQ}`),e=aQ),e},this.logger=(0,rX.Ep)(e,this.name),this.verifyUrl=aQ,this.abortController=new AbortController,this.isDevEnv=id()&&oI.env.IS_VITEST}get context(){return(0,rX.Fd)(this.logger)}startAbortTimer(t){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),(0,tl.toMiliseconds)(t))}}class fg extends r9{constructor(t,e){super(t,e),this.projectId=t,this.logger=e,this.context="echo",this.registerDeviceToken=async t=>{let{clientId:e,token:r,notificationType:i,enableEncrypted:n=!1}=t,s=`https://echo.walletconnect.com/${this.projectId}/clients`;await oE()(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:e,type:i,token:r,always_raw:n})})},this.logger=(0,rX.Ep)(e,this.context)}}var fm=Object.defineProperty,fv=Object.getOwnPropertySymbols,fy=Object.prototype.hasOwnProperty,fb=Object.prototype.propertyIsEnumerable,fA=(t,e,r)=>e in t?fm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,fw=(t,e)=>{for(var r in e||(e={}))fy.call(e,r)&&fA(t,r,e[r]);if(fv)for(var r of fv(e))fb.call(e,r)&&fA(t,r,e[r]);return t};class fx extends r${constructor(t){var e;super(t),this.protocol="wc",this.version=2,this.name=aE,this.events=new th.EventEmitter,this.initialized=!1,this.on=(t,e)=>this.events.on(t,e),this.once=(t,e)=>this.events.once(t,e),this.off=(t,e)=>this.events.off(t,e),this.removeListener=(t,e)=>this.events.removeListener(t,e),this.projectId=t?.projectId,this.relayUrl=t?.relayUrl||aR,this.customStoragePrefix=null!=t&&t.customStoragePrefix?`:${t.customStoragePrefix}`:"";let r=(0,rX.jI)({level:"string"==typeof t?.logger&&t.logger?t.logger:aS.logger}),{logger:i,chunkLoggerController:n}=(0,rX.Rt)({opts:r,maxSizeInBytes:t?.maxLogBlobSizeInBytes,loggerOverride:t?.logger});this.logChunkController=n,null!=(e=this.logChunkController)&&e.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var t,e;null!=(t=this.logChunkController)&&t.downloadLogsBlobInBrowser&&(null==(e=this.logChunkController)||e.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=(0,rX.Ep)(i,this.name),this.heartbeat=new rW.HeartBeat,this.crypto=new aG(this,this.logger,t?.keychain),this.history=new fc(this,this.logger),this.expirer=new fd(this,this.logger),this.storage=null!=t&&t.storage?t.storage:new rV.Z(fw(fw({},a_),t?.storageOptions)),this.relayer=new fi({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new fl(this,this.logger),this.verify=new fp(this.projectId||"",this.logger),this.echoClient=new fg(this.projectId||"",this.logger)}static async init(t){let e=new fx(t);await e.initialize();let r=await e.crypto.getClientId();return await e.storage.setItem("WALLETCONNECT_CLIENT_ID",r),e}get context(){return(0,rX.Fd)(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var t;return null==(t=this.logChunkController)?void 0:t.logsToBlob({clientId:await this.crypto.getClientId()})}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.initialized=!0,this.logger.info("Core Initialization Success")}catch(t){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,t),this.logger.error(t.message),t}}}class fM{constructor(t){this.opts=t,this.protocol="wc",this.version=2}}class fE{constructor(t){this.client=t}}var fI=r(34155),fS=r(48764).Buffer;function f_(t){let[e,r]=t.split(":");return{namespace:e,reference:r}}function fN(t,e){return t.includes(":")?[t]:e.chains||[]}Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;let fC={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"};function fB(){return"u">typeof fI&&"u">typeof fI.versions&&"u">typeof fI.versions.node}function fR(){return!fB()&&!!(0,tc.getNavigator)()&&!!(0,tc.getDocument)()}function fP(t,e){return t.filter(t=>e.includes(t)).length===t.length}function fO(t=tl.FIVE_MINUTES,e){let r,i,n;let s=(0,tl.toMiliseconds)(t||tl.FIVE_MINUTES);return{resolve:t=>{n&&r&&(clearTimeout(n),r(t))},reject:t=>{n&&i&&(clearTimeout(n),i(t))},done:()=>new Promise((t,o)=>{n=setTimeout(()=>{o(Error(e))},s),r=t,i=o})}}function fT(t,e){return(0,tl.fromMiliseconds)((e||Date.now())+(0,tl.toMiliseconds)(t))}function fD(t){return Date.now()>=(0,tl.toMiliseconds)(t)}function fU(t,e){return`${t}${e?`:${e}`:""}`}async function fk({id:t,topic:e,wcDeepLink:i}){try{if(!i)return;let n="string"==typeof i?JSON.parse(i):i,s=n?.href;if("string"!=typeof s)return;s.endsWith("/")&&(s=s.slice(0,-1));let o=`${s}/wc?requestId=${t}&sessionTopic=${e}`,a=!(0,tc.getDocument)()&&(0,tc.getNavigator)()&&"ReactNative"===navigator.product?fC.reactNative:fB()?fC.node:fR()?fC.browser:fC.unknown;a===fC.browser?o.startsWith("https://")||o.startsWith("http://")?window.open(o,"_blank","noreferrer noopener"):window.open(o,"_self","noreferrer noopener"):a===fC.reactNative&&"u">typeof(null==r.g?void 0:r.g.Linking)&&await r.g.Linking.openURL(o)}catch(t){console.error(t)}}async function fq(t,e){try{return await t.getItem(e)||(fR()?localStorage.getItem(e):void 0)}catch(t){console.error(t)}}var fF="u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof r.g?r.g:"u">typeof self?self:{},fz={exports:{}};I=fz,function(){var t="input is invalid type",e="object"==typeof window,r=e?window:{};r.JS_SHA3_NO_WINDOW&&(e=!1);var i=!e&&"object"==typeof self;!r.JS_SHA3_NO_NODE_JS&&"object"==typeof fI&&fI.versions&&fI.versions.node?r=fF:i&&(r=self);var n=!r.JS_SHA3_NO_COMMON_JS&&I.exports,s=!r.JS_SHA3_NO_ARRAY_BUFFER&&"u">typeof ArrayBuffer,o="0123456789abcdef".split(""),a=[4,1024,262144,0x4000000],f=[0,8,16,24],h=[1,0,32898,0,32906,0x80000000,0x80008000,0x80000000,32907,0,0x80000001,0,0x80008081,0x80000000,32777,0x80000000,138,0,136,0,0x80008009,0,0x8000000a,0,0x8000808b,0,139,0x80000000,32905,0x80000000,32771,0x80000000,32770,0x80000000,128,0x80000000,32778,0,0x8000000a,0x80000000,0x80008081,0x80000000,32896,0x80000000,0x80000001,0,0x80008008,0x80000000],u=[224,256,384,512],l=[128,256],c=["hex","buffer","arrayBuffer","array","digest"],d={128:168,256:136};(r.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),s&&(r.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});for(var p=function(t,e,r){return function(i){return new B(t,e,t).update(i)[r]()}},g=function(t,e,r){return function(i,n){return new B(t,e,n).update(i)[r]()}},m=function(t,e,r){return function(e,i,n,s){return w["cshake"+t].update(e,i,n,s)[r]()}},v=function(t,e,r){return function(e,i,n,s){return w["kmac"+t].update(e,i,n,s)[r]()}},y=function(t,e,r,i){for(var n=0;n