coinley-checkout 0.4.3 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,10 +8,10 @@ const la=BigInt(0),ca=BigInt(1);function ua(t){return Qs(t.Fp,ia.reduce(((t,e)=>
8
8
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:ha,hexToBytes:da}=zs,pa={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(t){const{Err:e}=pa;if(t.length<2||2!==t[0])throw new e("Invalid signature integer tag");const r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(128&n[0])throw new e("Invalid signature integer: negative");if(0===n[0]&&!(128&n[1]))throw new e("Invalid signature integer: unnecessary leading zero");return{d:ha(n),l:t.subarray(r+2)}},toSig(t){const{Err:e}=pa,r="string"==typeof t?da(t):t;if(!(r instanceof Uint8Array))throw new Error("ui8a expected");let n=r.length;if(n<2||48!=r[0])throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");const{d:i,l:s}=pa._parseInt(r.subarray(2)),{d:a,l:o}=pa._parseInt(s);if(o.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s:a}},hexFromSig(t){const e=t=>8&Number.parseInt(t[0],16)?"00"+t:t,r=t=>{const e=t.toString(16);return 1&e.length?`0${e}`:e},n=e(r(t.s)),i=e(r(t.r)),s=n.length/2,a=i.length/2,o=r(s),l=r(a);return`30${r(a+s+4)}02${l}${i}02${o}${n}`}},fa=BigInt(0),ga=BigInt(1);BigInt(2);const ma=BigInt(3);function _a(t){const e=function(t){const e=ua(t);Qs(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof r||"bigint"!=typeof r.beta||"function"!=typeof r.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze(__spreadValues({},e))}(t),{Fp:r}=e,n=e.toBytes||((t,e,n)=>{const i=e.toAffine();return Us(Uint8Array.from([4]),r.toBytes(i.x),r.toBytes(i.y))}),i=e.fromBytes||(t=>{const e=t.subarray(1);return{x:r.fromBytes(e.subarray(0,r.BYTES)),y:r.fromBytes(e.subarray(r.BYTES,2*r.BYTES))}});function s(t){const{a:n,b:i}=e,s=r.sqr(t),a=r.mul(s,t);return r.add(r.add(a,r.mul(t,n)),i)}if(!r.eql(r.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function a(t){return"bigint"==typeof t&&fa<t&&t<e.n}function o(t){if(!a(t))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(t){const{allowedPrivateKeyLengths:r,nByteLength:n,wrapPrivateKey:i,n:s}=e;if(r&&"bigint"!=typeof t){if(t instanceof Uint8Array&&(t=Cs(t)),"string"!=typeof t||!r.includes(t.length))throw new Error("Invalid key");t=t.padStart(2*n,"0")}let a;try{a="bigint"==typeof t?t:Ms(Fs("private key",t,n))}catch(l){throw new Error(`private key must be ${n} bytes, hex or bigint, not ${typeof t}`)}return i&&(a=$s(a,s)),o(a),a}const c=new Map;function u(t){if(!(t instanceof h))throw new Error("ProjectivePoint expected")}class h{constructor(t,e,n){if(this.px=t,this.py=e,this.pz=n,null==t||!r.isValid(t))throw new Error("x required");if(null==e||!r.isValid(e))throw new Error("y required");if(null==n||!r.isValid(n))throw new Error("z required")}static fromAffine(t){const{x:e,y:n}=t||{};if(!t||!r.isValid(e)||!r.isValid(n))throw new Error("invalid affine point");if(t instanceof h)throw new Error("projective point not allowed");const i=t=>r.eql(t,r.ZERO);return i(e)&&i(n)?h.ZERO:new h(e,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(h.fromAffine)}static fromHex(t){const e=h.fromAffine(i(Fs("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return h.BASE.multiply(l(t))}_setWindowSize(t){this._WINDOW_SIZE=t,c.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:t,y:n}=this.toAffine();if(!r.isValid(t)||!r.isValid(n))throw new Error("bad point: x or y not FE");const i=r.sqr(n),a=s(t);if(!r.eql(i,a))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:t}=this.toAffine();if(r.isOdd)return!r.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){u(t);const{px:e,py:n,pz:i}=this,{px:s,py:a,pz:o}=t,l=r.eql(r.mul(e,o),r.mul(s,i)),c=r.eql(r.mul(n,o),r.mul(a,i));return l&&c}negate(){return new h(this.px,r.neg(this.py),this.pz)}double(){const{a:t,b:n}=e,i=r.mul(n,ma),{px:s,py:a,pz:o}=this;let l=r.ZERO,c=r.ZERO,u=r.ZERO,d=r.mul(s,s),p=r.mul(a,a),f=r.mul(o,o),g=r.mul(s,a);return g=r.add(g,g),u=r.mul(s,o),u=r.add(u,u),l=r.mul(t,u),c=r.mul(i,f),c=r.add(l,c),l=r.sub(p,c),c=r.add(p,c),c=r.mul(l,c),l=r.mul(g,l),u=r.mul(i,u),f=r.mul(t,f),g=r.sub(d,f),g=r.mul(t,g),g=r.add(g,u),u=r.add(d,d),d=r.add(u,d),d=r.add(d,f),d=r.mul(d,g),c=r.add(c,d),f=r.mul(a,o),f=r.add(f,f),d=r.mul(f,g),l=r.sub(l,d),u=r.mul(f,p),u=r.add(u,u),u=r.add(u,u),new h(l,c,u)}add(t){u(t);const{px:n,py:i,pz:s}=this,{px:a,py:o,pz:l}=t;let c=r.ZERO,d=r.ZERO,p=r.ZERO;const f=e.a,g=r.mul(e.b,ma);let m=r.mul(n,a),_=r.mul(i,o),y=r.mul(s,l),v=r.add(n,i),w=r.add(a,o);v=r.mul(v,w),w=r.add(m,_),v=r.sub(v,w),w=r.add(n,s);let b=r.add(a,l);return w=r.mul(w,b),b=r.add(m,y),w=r.sub(w,b),b=r.add(i,s),c=r.add(o,l),b=r.mul(b,c),c=r.add(_,y),b=r.sub(b,c),p=r.mul(f,w),c=r.mul(g,y),p=r.add(c,p),c=r.sub(_,p),p=r.add(_,p),d=r.mul(c,p),_=r.add(m,m),_=r.add(_,m),y=r.mul(f,y),w=r.mul(g,w),_=r.add(_,y),y=r.sub(m,y),y=r.mul(f,y),w=r.add(w,y),m=r.mul(_,w),d=r.add(d,m),m=r.mul(b,w),c=r.mul(v,c),c=r.sub(c,m),m=r.mul(v,_),p=r.mul(b,p),p=r.add(p,m),new h(c,d,p)}subtract(t){return this.add(t.negate())}is0(){return this.equals(h.ZERO)}wNAF(t){return p.wNAFCached(this,c,t,(t=>{const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(h.fromAffine)}))}multiplyUnsafe(t){const n=h.ZERO;if(t===fa)return n;if(o(t),t===ga)return this;const{endo:i}=e;if(!i)return p.unsafeLadder(this,t);let{k1neg:s,k1:a,k2neg:l,k2:c}=i.splitScalar(t),u=n,d=n,f=this;for(;a>fa||c>fa;)a&ga&&(u=u.add(f)),c&ga&&(d=d.add(f)),f=f.double(),a>>=ga,c>>=ga;return s&&(u=u.negate()),l&&(d=d.negate()),d=new h(r.mul(d.px,i.beta),d.py,d.pz),u.add(d)}multiply(t){o(t);let n,i,s=t;const{endo:a}=e;if(a){const{k1neg:t,k1:e,k2neg:o,k2:l}=a.splitScalar(s);let{p:c,f:u}=this.wNAF(e),{p:d,f:f}=this.wNAF(l);c=p.constTimeNegate(t,c),d=p.constTimeNegate(o,d),d=new h(r.mul(d.px,a.beta),d.py,d.pz),n=c.add(d),i=u.add(f)}else{const{p:t,f:e}=this.wNAF(s);n=t,i=e}return h.normalizeZ([n,i])[0]}multiplyAndAddUnsafe(t,e,r){const n=h.BASE,i=(t,e)=>e!==fa&&e!==ga&&t.equals(n)?t.multiply(e):t.multiplyUnsafe(e),s=i(this,e).add(i(t,r));return s.is0()?void 0:s}toAffine(t){const{px:e,py:n,pz:i}=this,s=this.is0();null==t&&(t=s?r.ONE:r.inv(i));const a=r.mul(e,t),o=r.mul(n,t),l=r.mul(i,t);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(l,r.ONE))throw new Error("invZ was invalid");return{x:a,y:o}}isTorsionFree(){const{h:t,isTorsionFree:r}=e;if(t===ga)return!0;if(r)return r(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:r}=e;return t===ga?this:r?r(h,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return this.assertValidity(),n(h,this,t)}toHex(t=!0){return Cs(this.toRawBytes(t))}}h.BASE=new h(e.Gx,e.Gy,r.ONE),h.ZERO=new h(r.ZERO,r.ONE,r.ZERO);const d=e.nBitLength,p=function(t,e){const r=(t,e)=>{const r=e.negate();return t?r:e},n=t=>({windows:Math.ceil(e/t)+1,windowSize:__pow(2,t-1)});return{constTimeNegate:r,unsafeLadder(e,r){let n=t.ZERO,i=e;for(;r>la;)r&ca&&(n=n.add(i)),i=i.double(),r>>=ca;return n},precomputeWindow(t,e){const{windows:r,windowSize:i}=n(e),s=[];let a=t,o=a;for(let n=0;n<r;n++){o=a,s.push(o);for(let t=1;t<i;t++)o=o.add(a),s.push(o);a=o.double()}return s},wNAF(e,i,s){const{windows:a,windowSize:o}=n(e);let l=t.ZERO,c=t.BASE;const u=BigInt(__pow(2,e)-1),h=__pow(2,e),d=BigInt(e);for(let t=0;t<a;t++){const e=t*o;let n=Number(s&u);s>>=d,n>o&&(n-=h,s+=ca);const a=e,p=e+Math.abs(n)-1,f=t%2!=0,g=n<0;0===n?c=c.add(r(f,i[a])):l=l.add(r(g,i[p]))}return{p:l,f:c}},wNAFCached(t,e,r,n){const i=t._WINDOW_SIZE||1;let s=e.get(t);return s||(s=this.precomputeWindow(t,i),1!==i&&e.set(t,n(s))),this.wNAF(i,s,r)}}}(h,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:l,weierstrassEquation:s,isWithinCurveOrder:a}}function ya(t){const e=function(t){const e=ua(t);return Qs(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze(__spreadValues({lowS:!0},e))}(t),{Fp:r,n:n}=e,i=r.BYTES+1,s=2*r.BYTES+1;function a(t){return $s(t,n)}function o(t){return ra(t,n)}const{ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:u,isWithinCurveOrder:h}=_a(__spreadProps(__spreadValues({},e),{toBytes(t,e,n){const i=e.toAffine(),s=r.toBytes(i.x),a=Us;return n?a(Uint8Array.from([e.hasEvenY()?2:3]),s):a(Uint8Array.from([4]),s,r.toBytes(i.y))},fromBytes(t){const e=t.length,n=t[0],a=t.subarray(1);if(e!==i||2!==n&&3!==n){if(e===s&&4===n){return{x:r.fromBytes(a.subarray(0,r.BYTES)),y:r.fromBytes(a.subarray(r.BYTES,2*r.BYTES))}}throw new Error(`Point of length ${e} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}{const t=Ms(a);if(!(fa<(o=t)&&o<r.ORDER))throw new Error("Point is not on curve");const e=u(t);let i=r.sqrt(e);return!(1&~n)!==((i&ga)===ga)&&(i=r.neg(i)),{x:t,y:i}}var o}})),d=t=>Cs(Bs(t,e.nByteLength));function p(t){return t>n>>ga}const f=(t,e,r)=>Ms(t.slice(e,r));class g{constructor(t,e,r){this.r=t,this.s=e,this.recovery=r,this.assertValidity()}static fromCompact(t){const r=e.nByteLength;return t=Fs("compactSignature",t,2*r),new g(f(t,0,r),f(t,r,2*r))}static fromDER(t){const{r:e,s:r}=pa.toSig(Fs("DER",t));return new g(e,r)}assertValidity(){if(!h(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!h(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(t){return new g(this.r,this.s,t)}recoverPublicKey(t){const{r:n,s:i,recovery:s}=this,c=v(Fs("msgHash",t));if(null==s||![0,1,2,3].includes(s))throw new Error("recovery id invalid");const u=2===s||3===s?n+e.n:n;if(u>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const h=1&s?"03":"02",p=l.fromHex(h+d(u)),f=o(u),g=a(-c*f),m=a(i*f),_=l.BASE.multiplyAndAddUnsafe(p,g,m);if(!_)throw new Error("point at infinify");return _.assertValidity(),_}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Gs(this.toDERHex())}toDERHex(){return pa.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Gs(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}const m={isValidPrivateKey(t){try{return c(t),!0}catch(e){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{const t=oa(e.n);return function(t,e,r=!1){const n=t.length,i=aa(e),s=oa(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);const a=$s(r?Ms(t):Is(t),e-Js)+Js;return r?Os(a,i):Bs(a,i)}(e.randomBytes(t),e.n)},precompute:(t=8,e=l.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function _(t){const e=t instanceof Uint8Array,r="string"==typeof t,n=(e||r)&&t.length;return e?n===i||n===s:r?n===2*i||n===2*s:t instanceof l}const y=e.bits2int||function(t){const r=Ms(t),n=8*t.length-e.nBitLength;return n>0?r>>BigInt(n):r},v=e.bits2int_modN||function(t){return a(y(t))},w=Ls(e.nBitLength);function b(t){if("bigint"!=typeof t)throw new Error("bigint expected");if(!(fa<=t&&t<w))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Bs(t,e.nByteLength)}function A(t,n,i=E){if(["recovered","canonical"].some((t=>t in i)))throw new Error("sign() legacy options not supported");const{hash:s,randomBytes:u}=e;let{lowS:d,prehash:f,extraEntropy:m}=i;null==d&&(d=!0),t=Fs("msgHash",t),f&&(t=Fs("prehashed msgHash",s(t)));const _=v(t),w=c(n),A=[b(w),b(_)];if(null!=m){const t=!0===m?u(r.BYTES):m;A.push(Fs("extraEntropy",t))}const x=Us(...A),k=_;return{seed:x,k2sig:function(t){const e=y(t);if(!h(e))return;const r=o(e),n=l.BASE.multiply(e).toAffine(),i=a(n.x);if(i===fa)return;const s=a(r*a(k+i*w));if(s===fa)return;let c=(n.x===i?0:2)|Number(n.y&ga),u=s;return d&&p(s)&&(u=function(t){return p(t)?a(-t):t}(s),c^=1),new g(i,u,c)}}}const E={lowS:e.lowS,prehash:!1},x={lowS:e.lowS,prehash:!1};return l.BASE._setWindowSize(8),{CURVE:e,getPublicKey:function(t,e=!0){return l.fromPrivateKey(t).toRawBytes(e)},getSharedSecret:function(t,e,r=!0){if(_(t))throw new Error("first arg must be private key");if(!_(e))throw new Error("second arg must be public key");return l.fromHex(e).multiply(c(t)).toRawBytes(r)},sign:function(t,r,n=E){const{seed:i,k2sig:s}=A(t,r,n),a=e;return Hs(a.hash.outputLen,a.nByteLength,a.hmac)(i,s)},verify:function(t,r,n,i=x){var s;const c=t;if(r=Fs("msgHash",r),n=Fs("publicKey",n),"strict"in i)throw new Error("options.strict was renamed to lowS");const{lowS:u,prehash:h}=i;let d,p;try{if("string"==typeof c||c instanceof Uint8Array)try{d=g.fromDER(c)}catch(E){if(!(E instanceof pa.Err))throw E;d=g.fromCompact(c)}else{if("object"!=typeof c||"bigint"!=typeof c.r||"bigint"!=typeof c.s)throw new Error("PARSE");{const{r:t,s:e}=c;d=new g(t,e)}}p=l.fromHex(n)}catch(k){if("PARSE"===k.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(u&&d.hasHighS())return!1;h&&(r=e.hash(r));const{r:f,s:m}=d,_=v(r),y=o(m),w=a(_*y),b=a(f*y),A=null==(s=l.BASE.multiplyAndAddUnsafe(p,w,b))?void 0:s.toAffine();return!!A&&a(A.x)===f},ProjectivePoint:l,Signature:g,utils:m}}
9
9
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function va(t){return{hash:t,hmac:(e,...r)=>Ri(t,e,function(...t){const e=new Uint8Array(t.reduce(((t,e)=>t+e.length),0));let r=0;return t.forEach((t=>{if(!Ei(t))throw new Error("Uint8Array expected");e.set(t,r),r+=t.length})),e}(...r)),randomBytes:Ci}}BigInt(4);
10
10
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
11
- const wa=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ba=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Aa=BigInt(1),Ea=BigInt(2),xa=(t,e)=>(t+e/Ea)/e;const ka=function(t,e,r=!1,n={}){if(t<=Vs)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:i,nByteLength:s}=sa(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const a=na(t),o=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:Ls(i),ZERO:Vs,ONE:Js,create:e=>$s(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("Invalid field element: expected bigint, got "+typeof e);return Vs<=e&&e<t},is0:t=>t===Vs,isOdd:t=>(t&Js)===Js,neg:e=>$s(-e,t),eql:(t,e)=>t===e,sqr:e=>$s(e*e,t),add:(e,r)=>$s(e+r,t),sub:(e,r)=>$s(e-r,t),mul:(e,r)=>$s(e*r,t),pow:(t,e)=>function(t,e,r){if(r<Vs)throw new Error("Expected power > 0");if(r===Vs)return t.ONE;if(r===Js)return e;let n=t.ONE,i=e;for(;r>Vs;)r&Js&&(n=t.mul(n,i)),i=t.sqr(i),r>>=Js;return n}(o,t,e),div:(e,r)=>$s(e*ra(r,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>ra(e,t),sqrt:n.sqrt||(t=>a(o,t)),invertBatch:t=>function(t,e){const r=new Array(e.length),n=e.reduce(((e,n,i)=>t.is0(n)?e:(r[i]=e,t.mul(e,n))),t.ONE),i=t.inv(n);return e.reduceRight(((e,n,i)=>t.is0(n)?e:(r[i]=t.mul(e,r[i]),t.mul(e,n))),i),r}(o,t),cmov:(t,e,r)=>r?e:t,toBytes:t=>r?Os(t,s):Bs(t,s),fromBytes:t=>{if(t.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${t.length}`);return r?Is(t):Ms(t)}});return Object.freeze(o)}(wa,void 0,void 0,{sqrt:function(t){const e=wa,r=BigInt(3),n=BigInt(6),i=BigInt(11),s=BigInt(22),a=BigInt(23),o=BigInt(44),l=BigInt(88),c=t*t*t%e,u=c*c*t%e,h=ea(u,r,e)*u%e,d=ea(h,r,e)*u%e,p=ea(d,Ea,e)*c%e,f=ea(p,i,e)*p%e,g=ea(f,s,e)*f%e,m=ea(g,o,e)*g%e,_=ea(m,l,e)*m%e,y=ea(_,o,e)*g%e,v=ea(y,r,e)*u%e,w=ea(v,a,e)*f%e,b=ea(w,n,e)*c%e,A=ea(b,Ea,e);if(!ka.eql(ka.sqr(A),t))throw new Error("Cannot find square root");return A}}),Sa=function(t,e){const r=e=>ya(__spreadValues(__spreadValues({},t),va(e)));return Object.freeze(__spreadProps(__spreadValues({},r(e)),{create:r}))}({a:BigInt(0),b:BigInt(7),Fp:ka,n:ba,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=ba,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Aa*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,a=BigInt("0x100000000000000000000000000000000"),o=xa(s*t,e),l=xa(-n*t,e);let c=$s(t-o*r-l*i,e),u=$s(-o*n-l*s,e);const h=c>a,d=u>a;if(h&&(c=e-c),d&&(u=e-u),c>a||u>a)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:h,k1:c,k2neg:d,k2:u}}}},Ui);BigInt(0),Sa.ProjectivePoint;const Na="0x0000000000000000000000000000000000000000",Pa="0x0000000000000000000000000000000000000000000000000000000000000000",Ca=BigInt(0),Ta=BigInt(1),Ra=BigInt(2),Ga=BigInt(27),Ma=BigInt(28),Ia=BigInt(35),Ba={};function Oa(t){return Yr(hn(t),32)}const Fa=class t{constructor(t,e,r,n){__privateAdd(this,nt,void 0),__privateAdd(this,it,void 0),__privateAdd(this,st,void 0),__privateAdd(this,at,void 0),Lr(t,Ba,"Signature"),__privateSet(this,nt,e),__privateSet(this,it,r),__privateSet(this,st,n),__privateSet(this,at,null)}get r(){return __privateGet(this,nt)}set r(t){Or(32===Kr(t),"invalid r","value",t),__privateSet(this,nt,Vr(t))}get s(){return __privateGet(this,it)}set s(t){Or(32===Kr(t),"invalid s","value",t);const e=Vr(t);Or(parseInt(e.substring(0,3))<8,"non-canonical s","value",e),__privateSet(this,it,e)}get v(){return __privateGet(this,st)}set v(t){const e=cn(t,"value");Or(27===e||28===e,"invalid v","v",t),__privateSet(this,st,e)}get networkV(){return __privateGet(this,at)}get legacyChainId(){const e=this.networkV;return null==e?null:t.getChainId(e)}get yParity(){return 27===this.v?0:1}get yParityAndS(){const t=jr(this.s);return this.yParity&&(t[0]|=128),Vr(t)}get compactSerialized(){return Jr([this.r,this.yParityAndS])}get serialized(){return Jr([this.r,this.s,this.yParity?"0x1c":"0x1b"])}[Symbol.for("nodejs.util.inspect.custom")](){return`Signature { r: "${this.r}", s: "${this.s}", yParity: ${this.yParity}, networkV: ${this.networkV} }`}clone(){const e=new t(Ba,this.r,this.s,this.v);return this.networkV&&__privateSet(e,at,this.networkV),e}toJSON(){const t=this.networkV;return{_type:"signature",networkV:null!=t?t.toString():null,r:this.r,s:this.s,v:this.v}}static getChainId(t){const e=sn(t,"v");return e==Ga||e==Ma?Ca:(Or(e>=Ia,"invalid EIP-155 v","v",t),(e-Ia)/Ra)}static getChainIdV(t,e){return sn(t)*Ra+BigInt(35+e-27)}static getNormalizedV(t){const e=sn(t);return e===Ca||e===Ga?27:e===Ta||e===Ma?28:(Or(e>=Ia,"invalid v","v",t),e&Ta?27:28)}static from(e){function r(t,r){Or(t,r,"signature",e)}if(null==e)return new t(Ba,Pa,Pa,27);if("string"==typeof e){const n=jr(e,"signature");if(64===n.length){const e=Vr(n.slice(0,32)),r=n.slice(32,64),i=128&r[0]?28:27;return r[0]&=127,new t(Ba,e,Vr(r),i)}if(65===n.length){const e=Vr(n.slice(0,32)),i=n.slice(32,64);r(!(128&i[0]),"non-canonical s");const s=t.getNormalizedV(n[64]);return new t(Ba,e,Vr(i),s)}r(!1,"invalid raw signature length")}if(e instanceof t)return e.clone();const n=e.r;r(null!=n,"missing r");const i=Oa(n),s=function(t,e){if(null!=t)return Oa(t);if(null!=e){r(Wr(e,32),"invalid yParityAndS");const t=jr(e);return t[0]&=127,Vr(t)}r(!1,"missing s")}(e.s,e.yParityAndS);r(!(128&jr(s)[0]),"non-canonical s");const{networkV:a,v:o}=function(e,n,i){if(null!=e){const r=sn(e);return{networkV:r>=Ia?r:void 0,v:t.getNormalizedV(r)}}if(null!=n)return r(Wr(n,32),"invalid yParityAndS"),{v:128&jr(n)[0]?28:27};if(null!=i){switch(cn(i,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}r(!1,"invalid yParity")}r(!1,"missing v")}(e.v,e.yParityAndS,e.yParity),l=new t(Ba,i,s,o);return a&&__privateSet(l,at,a),r(null==e.yParity||cn(e.yParity,"sig.yParity")===l.yParity,"yParity mismatch"),r(null==e.yParityAndS||e.yParityAndS===l.yParityAndS,"yParityAndS mismatch"),l}};nt=new WeakMap,it=new WeakMap,st=new WeakMap,at=new WeakMap;let Ua=Fa;ot=new WeakMap;let La=class t{constructor(t){__privateAdd(this,ot,void 0),Or(32===Kr(t),"invalid private key","privateKey","[REDACTED]"),__privateSet(this,ot,Vr(t))}get privateKey(){return __privateGet(this,ot)}get publicKey(){return t.computePublicKey(__privateGet(this,ot))}get compressedPublicKey(){return t.computePublicKey(__privateGet(this,ot),!0)}sign(t){Or(32===Kr(t),"invalid digest length","digest",t);const e=Sa.sign(Hr(t),Hr(__privateGet(this,ot)),{lowS:!0});return Ua.from({r:un(e.r,32),s:un(e.s,32),v:e.recovery?28:27})}computeSharedSecret(e){const r=t.computePublicKey(e);return Vr(Sa.getSharedSecret(Hr(__privateGet(this,ot)),jr(r),!1))}static computePublicKey(t,e){let r=jr(t,"key");if(32===r.length){return Vr(Sa.getPublicKey(r,!!e))}if(64===r.length){const t=new Uint8Array(65);t[0]=4,t.set(r,1),r=t}return Vr(Sa.ProjectivePoint.fromHex(r).toRawBytes(e))}static recoverPublicKey(t,e){Or(32===Kr(t),"invalid digest length","digest",t);const r=Ua.from(e);let n=Sa.Signature.fromCompact(Hr(Jr([r.r,r.s])));n=n.addRecoveryBit(r.yParity);const i=n.recoverPublicKey(Hr(t));return Or(null!=i,"invalid signature for digest","signature",e),"0x"+i.toHex(!1)}static addPoints(e,r,n){const i=Sa.ProjectivePoint.fromHex(t.computePublicKey(e).substring(2)),s=Sa.ProjectivePoint.fromHex(t.computePublicKey(r).substring(2));return"0x"+i.add(s).toHex(!!n)}};const Da=BigInt(0),ja=BigInt(36);function Ha(t){const e=(t=t.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let i=0;i<40;i++)r[i]=e[i].charCodeAt(0);const n=jr(vs(r));for(let i=0;i<40;i+=2)n[i>>1]>>4>=8&&(e[i]=e[i].toUpperCase()),(15&n[i>>1])>=8&&(e[i+1]=e[i+1].toUpperCase());return"0x"+e.join("")}const Wa={};for(let Np=0;Np<10;Np++)Wa[String(Np)]=String(Np);for(let Np=0;Np<26;Np++)Wa[String.fromCharCode(65+Np)]=String(10+Np);const Qa=function(){const t={};for(let e=0;e<36;e++){t["0123456789abcdefghijklmnopqrstuvwxyz"[e]]=BigInt(e)}return t}();function za(t){if(Or("string"==typeof t,"invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/)){t.startsWith("0x")||(t="0x"+t);const e=Ha(t);return Or(!t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===t,"bad address checksum","address",t),e}if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){Or(t.substring(2,4)===function(t){let e=(t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00").split("").map((t=>Wa[t])).join("");for(;e.length>=15;){let t=e.substring(0,15);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}(t),"bad icap checksum","address",t);let e=function(t){t=t.toLowerCase();let e=Da;for(let r=0;r<t.length;r++)e=e*ja+Qa[t[r]];return e}(t.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return Ha("0x"+e)}Or(!1,"invalid address","address",t)}function Va(t){return t&&"function"==typeof t.getAddress}function Ja(t,e){return __async(this,null,(function*(){const r=yield e;return null!=r&&"0x0000000000000000000000000000000000000000"!==r||(Br("string"!=typeof t,"unconfigured name","UNCONFIGURED_NAME",{value:t}),Or(!1,"invalid AddressLike value; did not resolve to a value address","target",t)),za(r)}))}function Ka(t,e){return"string"==typeof t?t.match(/^0x[0-9a-f]{40}$/i)?za(t):(Br(null!=e,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),Ja(t,e.resolveName(t))):Va(t)?Ja(t,t.getAddress()):t&&"function"==typeof t.then?Ja(t,t):void Or(!1,"unsupported addressable value","target",t)}const qa={};function Za(t,e){let r=!1;return e<0&&(r=!0,e*=-1),new $a(qa,`${r?"":"u"}int${e}`,t,{signed:r,width:e})}function Ya(t,e){return new $a(qa,`bytes${e||""}`,t,{size:e})}const Xa=Symbol.for("_ethers_typed");lt=new WeakMap;let $a=class t{constructor(t,e,r,n){__publicField(this,"type"),__publicField(this,"value"),__privateAdd(this,lt,void 0),__publicField(this,"_typedSymbol"),null==n&&(n=null),Lr(qa,t,"Typed"),Tr(this,{_typedSymbol:Xa,type:e,value:r}),__privateSet(this,lt,n),this.format()}format(){if("array"===this.type)throw new Error("");if("dynamicArray"===this.type)throw new Error("");return"tuple"===this.type?`tuple(${this.value.map((t=>t.format())).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return"string"===this.type}get tupleName(){if("tuple"!==this.type)throw TypeError("not a tuple");return __privateGet(this,lt)}get arrayLength(){if("array"!==this.type)throw TypeError("not an array");return!0===__privateGet(this,lt)?-1:!1===__privateGet(this,lt)?this.value.length:null}static from(e,r){return new t(qa,e,r)}static uint8(t){return Za(t,8)}static uint16(t){return Za(t,16)}static uint24(t){return Za(t,24)}static uint32(t){return Za(t,32)}static uint40(t){return Za(t,40)}static uint48(t){return Za(t,48)}static uint56(t){return Za(t,56)}static uint64(t){return Za(t,64)}static uint72(t){return Za(t,72)}static uint80(t){return Za(t,80)}static uint88(t){return Za(t,88)}static uint96(t){return Za(t,96)}static uint104(t){return Za(t,104)}static uint112(t){return Za(t,112)}static uint120(t){return Za(t,120)}static uint128(t){return Za(t,128)}static uint136(t){return Za(t,136)}static uint144(t){return Za(t,144)}static uint152(t){return Za(t,152)}static uint160(t){return Za(t,160)}static uint168(t){return Za(t,168)}static uint176(t){return Za(t,176)}static uint184(t){return Za(t,184)}static uint192(t){return Za(t,192)}static uint200(t){return Za(t,200)}static uint208(t){return Za(t,208)}static uint216(t){return Za(t,216)}static uint224(t){return Za(t,224)}static uint232(t){return Za(t,232)}static uint240(t){return Za(t,240)}static uint248(t){return Za(t,248)}static uint256(t){return Za(t,256)}static uint(t){return Za(t,256)}static int8(t){return Za(t,-8)}static int16(t){return Za(t,-16)}static int24(t){return Za(t,-24)}static int32(t){return Za(t,-32)}static int40(t){return Za(t,-40)}static int48(t){return Za(t,-48)}static int56(t){return Za(t,-56)}static int64(t){return Za(t,-64)}static int72(t){return Za(t,-72)}static int80(t){return Za(t,-80)}static int88(t){return Za(t,-88)}static int96(t){return Za(t,-96)}static int104(t){return Za(t,-104)}static int112(t){return Za(t,-112)}static int120(t){return Za(t,-120)}static int128(t){return Za(t,-128)}static int136(t){return Za(t,-136)}static int144(t){return Za(t,-144)}static int152(t){return Za(t,-152)}static int160(t){return Za(t,-160)}static int168(t){return Za(t,-168)}static int176(t){return Za(t,-176)}static int184(t){return Za(t,-184)}static int192(t){return Za(t,-192)}static int200(t){return Za(t,-200)}static int208(t){return Za(t,-208)}static int216(t){return Za(t,-216)}static int224(t){return Za(t,-224)}static int232(t){return Za(t,-232)}static int240(t){return Za(t,-240)}static int248(t){return Za(t,-248)}static int256(t){return Za(t,-256)}static int(t){return Za(t,-256)}static bytes1(t){return Ya(t,1)}static bytes2(t){return Ya(t,2)}static bytes3(t){return Ya(t,3)}static bytes4(t){return Ya(t,4)}static bytes5(t){return Ya(t,5)}static bytes6(t){return Ya(t,6)}static bytes7(t){return Ya(t,7)}static bytes8(t){return Ya(t,8)}static bytes9(t){return Ya(t,9)}static bytes10(t){return Ya(t,10)}static bytes11(t){return Ya(t,11)}static bytes12(t){return Ya(t,12)}static bytes13(t){return Ya(t,13)}static bytes14(t){return Ya(t,14)}static bytes15(t){return Ya(t,15)}static bytes16(t){return Ya(t,16)}static bytes17(t){return Ya(t,17)}static bytes18(t){return Ya(t,18)}static bytes19(t){return Ya(t,19)}static bytes20(t){return Ya(t,20)}static bytes21(t){return Ya(t,21)}static bytes22(t){return Ya(t,22)}static bytes23(t){return Ya(t,23)}static bytes24(t){return Ya(t,24)}static bytes25(t){return Ya(t,25)}static bytes26(t){return Ya(t,26)}static bytes27(t){return Ya(t,27)}static bytes28(t){return Ya(t,28)}static bytes29(t){return Ya(t,29)}static bytes30(t){return Ya(t,30)}static bytes31(t){return Ya(t,31)}static bytes32(t){return Ya(t,32)}static address(e){return new t(qa,"address",e)}static bool(e){return new t(qa,"bool",!!e)}static bytes(e){return new t(qa,"bytes",e)}static string(e){return new t(qa,"string",e)}static array(t,e){throw new Error("not implemented yet")}static tuple(t,e){throw new Error("not implemented yet")}static overrides(e){return new t(qa,"overrides",Object.assign({},e))}static isTyped(t){return t&&"object"==typeof t&&"_typedSymbol"in t&&t._typedSymbol===Xa}static dereference(e,r){if(t.isTyped(e)){if(e.type!==r)throw new Error(`invalid type: expecetd ${r}, got ${e.type}`);return e.value}return e}};class to extends gi{constructor(t){super("address","address",t,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(t,e){let r=$a.dereference(e,"string");try{r=za(r)}catch(n){return this._throwError(n.message,e)}return t.writeValue(r)}decode(t){return za(un(t.readValue(),20))}}class eo extends gi{constructor(t){super(t.name,t.type,"_",t.dynamic),__publicField(this,"coder"),this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,e){return this.coder.encode(t,e)}decode(t){return this.coder.decode(t)}}function ro(t,e,r){let n=[];if(Array.isArray(r))n=r;else if(r&&"object"==typeof r){let t={};n=e.map((e=>{const n=e.localName;return Br(n,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:e},value:r}),Br(!t[n],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:e},value:r}),t[n]=!0,r[n]}))}else Or(!1,"invalid tuple value","tuple",r);Or(e.length===n.length,"types/value length mismatch","tuple",r);let i=new mi,s=new mi,a=[];e.forEach(((t,e)=>{let r=n[e];if(t.dynamic){let e=s.length;t.encode(s,r);let n=i.writeUpdatableValue();a.push((t=>{n(t+e)}))}else t.encode(i,r)})),a.forEach((t=>{t(i.length)}));let o=t.appendWriter(i);return o+=t.appendWriter(s),o}function no(t,e){let r=[],n=[],i=t.subReader(0);return e.forEach((e=>{let s=null;if(e.dynamic){let r=t.readIndex(),n=i.subReader(r);try{s=e.decode(n)}catch(a){if(Gr(a,"BUFFER_OVERRUN"))throw a;s=a,s.baseType=e.name,s.name=e.localName,s.type=e.type}}else try{s=e.decode(t)}catch(a){if(Gr(a,"BUFFER_OVERRUN"))throw a;s=a,s.baseType=e.name,s.name=e.localName,s.type=e.type}if(null==s)throw new Error("investigate");r.push(s),n.push(e.localName||null)})),pi.fromItems(r,n)}class io extends gi{constructor(t,e,r){super("array",t.type+"["+(e>=0?e:"")+"]",r,-1===e||t.dynamic),__publicField(this,"coder"),__publicField(this,"length"),Tr(this,{coder:t,length:e})}defaultValue(){const t=this.coder.defaultValue(),e=[];for(let r=0;r<this.length;r++)e.push(t);return e}encode(t,e){const r=$a.dereference(e,"array");Array.isArray(r)||this._throwError("expected array value",r);let n=this.length;-1===n&&(n=r.length,t.writeValue(r.length)),Fr(r.length,n,"coder array"+(this.localName?" "+this.localName:""));let i=[];for(let s=0;s<r.length;s++)i.push(this.coder);return ro(t,i,r)}decode(t){let e=this.length;-1===e&&(e=t.readIndex(),Br(e*ii<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:e*ii,length:t.dataLength}));let r=[];for(let n=0;n<e;n++)r.push(new eo(this.coder));return no(t,r)}}class so extends gi{constructor(t){super("bool","bool",t,!1)}defaultValue(){return!1}encode(t,e){const r=$a.dereference(e,"bool");return t.writeValue(r?1:0)}decode(t){return!!t.readValue()}}class ao extends gi{constructor(t,e){super(t,t,e,!0)}defaultValue(){return"0x"}encode(t,e){e=Hr(e);let r=t.writeValue(e.length);return r+=t.writeBytes(e),r}decode(t){return t.readBytes(t.readIndex(),!0)}}class oo extends ao{constructor(t){super("bytes",t)}decode(t){return Vr(super.decode(t))}}class lo extends gi{constructor(t,e){let r="bytes"+String(t);super(r,r,e,!1),__publicField(this,"size"),Tr(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+2*this.size)}encode(t,e){let r=Hr($a.dereference(e,this.type));return r.length!==this.size&&this._throwError("incorrect data length",e),t.writeBytes(r)}decode(t){return Vr(t.readBytes(this.size))}}const co=new Uint8Array([]);class uo extends gi{constructor(t){super("null","",t,!1)}defaultValue(){return null}encode(t,e){return null!=e&&this._throwError("not null",e),t.writeBytes(co)}decode(t){return t.readBytes(0),null}}const ho=BigInt(0),po=BigInt(1),fo=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class go extends gi{constructor(t,e,r){const n=(e?"int":"uint")+8*t;super(n,n,r,!1),__publicField(this,"size"),__publicField(this,"signed"),Tr(this,{size:t,signed:e},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,e){let r=sn($a.dereference(e,this.type)),n=nn(fo,256);if(this.signed){let t=nn(n,8*this.size-1);(r>t||r<-(t+po))&&this._throwError("value out-of-bounds",e),r=rn(r,256)}else(r<ho||r>nn(n,8*this.size))&&this._throwError("value out-of-bounds",e);return t.writeValue(r)}decode(t){let e=nn(t.readValue(),8*this.size);return this.signed&&(e=en(e,8*this.size)),e}}class mo extends ao{constructor(t){super("string",t)}defaultValue(){return""}encode(t,e){return super.encode(t,yn($a.dereference(e,"string")))}decode(t){return vn(super.decode(t))}}class _o extends gi{constructor(t,e){let r=!1;const n=[];t.forEach((t=>{t.dynamic&&(r=!0),n.push(t.type)}));super("tuple","tuple("+n.join(",")+")",e,r),__publicField(this,"coders"),Tr(this,{coders:Object.freeze(t.slice())})}defaultValue(){const t=[];this.coders.forEach((e=>{t.push(e.defaultValue())}));const e=this.coders.reduce(((t,e)=>{const r=e.localName;return r&&(t[r]||(t[r]=0),t[r]++),t}),{});return this.coders.forEach(((r,n)=>{let i=r.localName;i&&1===e[i]&&("length"===i&&(i="_length"),null==t[i]&&(t[i]=t[n]))})),Object.freeze(t)}encode(t,e){const r=$a.dereference(e,"tuple");return ro(t,this.coders,r)}decode(t){return no(t,this.coders)}}function yo(t,e){return{address:za(t),storageKeys:e.map(((t,e)=>(Or(Wr(t,32),"invalid slot",`storageKeys[${e}]`,t),t.toLowerCase())))}}function vo(t){if(Array.isArray(t))return t.map(((e,r)=>Array.isArray(e)?(Or(2===e.length,"invalid slot set",`value[${r}]`,e),yo(e[0],e[1])):(Or(null!=e&&"object"==typeof e,"invalid address-slot set","value",t),yo(e.address,e.storageKeys))));Or(null!=t&&"object"==typeof t,"invalid access list","value",t);const e=Object.keys(t).map((e=>{const r=t[e].reduce(((t,e)=>(t[e]=!0,t)),{});return yo(e,Object.keys(r).sort())}));return e.sort(((t,e)=>t.address.localeCompare(e.address))),e}function wo(t){return{address:za(t.address),nonce:sn(null!=t.nonce?t.nonce:0),chainId:sn(null!=t.chainId?t.chainId:0),signature:Ua.from(t.signature)}}function bo(t,e){return function(t){let e;return e="string"==typeof t?La.computePublicKey(t,!1):t.publicKey,za(vs("0x"+e.substring(4)).substring(26))}(La.recoverPublicKey(t,e))}const Ao=BigInt(0),Eo=BigInt(2),xo=BigInt(27),ko=BigInt(28),So=BigInt(35),No=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Po=131072;function Co(t,e){let r=t.toString(16);for(;r.length<2;)r="0"+r;return r+=Es(e).substring(4),"0x"+r}function To(t){return"0x"===t?null:za(t)}function Ro(t,e){try{return vo(t)}catch(r){Or(!1,r.message,e,t)}}function Go(t,e){try{if(!Array.isArray(t))throw new Error("authorizationList: invalid array");const e=[];for(let r=0;r<t.length;r++){const n=t[r];if(!Array.isArray(n))throw new Error(`authorization[${r}]: invalid array`);if(6!==n.length)throw new Error(`authorization[${r}]: wrong length`);if(!n[1])throw new Error(`authorization[${r}]: null address`);e.push({address:To(n[1]),nonce:Io(n[2],"nonce"),chainId:Io(n[0],"chainId"),signature:Ua.from({yParity:Mo(n[3],"yParity"),r:Yr(n[4],32),s:Yr(n[5],32)})})}return e}catch(r){Or(!1,r.message,e,t)}}function Mo(t,e){return"0x"===t?0:cn(t,e)}function Io(t,e){if("0x"===t)return Ao;const r=sn(t,e);return Or(r<=No,"value exceeds uint size",e,r),r}function Bo(t,e){const r=sn(t,"value"),n=hn(r);return Or(n.length<=32,"value too large",`tx.${e}`,r),n}function Oo(t){return vo(t).map((t=>[t.address,t.storageKeys]))}function Fo(t,e){Or(Array.isArray(t),`invalid ${e}`,"value",t);for(let r=0;r<t.length;r++)Or(Wr(t[r],32),"invalid ${ param } hash",`value[${r}]`,t[r]);return t}function Uo(t,e){let r;try{if(r=Mo(e[0],"yParity"),0!==r&&1!==r)throw new Error("bad yParity")}catch(a){Or(!1,"invalid yParity","yParity",e[0])}const n=Yr(e[1],32),i=Yr(e[2],32),s=Ua.from({r:n,s:i,yParity:r});t.signature=s}ct=new WeakMap,ut=new WeakMap,ht=new WeakMap,dt=new WeakMap,pt=new WeakMap,ft=new WeakMap,gt=new WeakMap,mt=new WeakMap,_t=new WeakMap,yt=new WeakMap,vt=new WeakMap,wt=new WeakMap,bt=new WeakMap,At=new WeakMap,Et=new WeakMap,xt=new WeakMap,kt=new WeakMap,St=new WeakSet,Nt=function(t,e){Br(!t||null!=this.signature,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const r=t?this.signature:null;switch(this.inferType()){case 0:return function(t,e){const r=[Bo(t.nonce,"nonce"),Bo(t.gasPrice||0,"gasPrice"),Bo(t.gasLimit,"gasLimit"),t.to||"0x",Bo(t.value,"value"),t.data];let n=Ao;if(t.chainId!=Ao)n=sn(t.chainId,"tx.chainId"),Or(!e||null==e.networkV||e.legacyChainId===n,"tx.chainId/sig.v mismatch","sig",e);else if(t.signature){const e=t.signature.legacyChainId;null!=e&&(n=e)}if(!e)return n!==Ao&&(r.push(hn(n)),r.push("0x"),r.push("0x")),ei(r);let i=BigInt(27+e.yParity);return n!==Ao?i=Ua.getChainIdV(n,e.v):BigInt(e.v)!==i&&Or(!1,"tx.chainId/sig.v mismatch","sig",e),r.push(hn(i)),r.push(hn(e.r)),r.push(hn(e.s)),ei(r)}(this,r);case 1:return function(t,e){const r=[Bo(t.chainId,"chainId"),Bo(t.nonce,"nonce"),Bo(t.gasPrice||0,"gasPrice"),Bo(t.gasLimit,"gasLimit"),t.to||"0x",Bo(t.value,"value"),t.data,Oo(t.accessList||[])];return e&&(r.push(Bo(e.yParity,"recoveryParam")),r.push(hn(e.r)),r.push(hn(e.s))),Jr(["0x01",ei(r)])}(this,r);case 2:return function(t,e){const r=[Bo(t.chainId,"chainId"),Bo(t.nonce,"nonce"),Bo(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Bo(t.maxFeePerGas||0,"maxFeePerGas"),Bo(t.gasLimit,"gasLimit"),t.to||"0x",Bo(t.value,"value"),t.data,Oo(t.accessList||[])];return e&&(r.push(Bo(e.yParity,"yParity")),r.push(hn(e.r)),r.push(hn(e.s))),Jr(["0x02",ei(r)])}(this,r);case 3:return function(t,e,r){const n=[Bo(t.chainId,"chainId"),Bo(t.nonce,"nonce"),Bo(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Bo(t.maxFeePerGas||0,"maxFeePerGas"),Bo(t.gasLimit,"gasLimit"),t.to||Na,Bo(t.value,"value"),t.data,Oo(t.accessList||[]),Bo(t.maxFeePerBlobGas||0,"maxFeePerBlobGas"),Fo(t.blobVersionedHashes||[],"blobVersionedHashes")];return e&&(n.push(Bo(e.yParity,"yParity")),n.push(hn(e.r)),n.push(hn(e.s)),r)?Jr(["0x03",ei([n,r.map((t=>t.data)),r.map((t=>t.commitment)),r.map((t=>t.proof))])]):Jr(["0x03",ei(n)])}(this,r,e?this.blobs:null);case 4:return function(t,e){const r=[Bo(t.chainId,"chainId"),Bo(t.nonce,"nonce"),Bo(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Bo(t.maxFeePerGas||0,"maxFeePerGas"),Bo(t.gasLimit,"gasLimit"),t.to||"0x",Bo(t.value,"value"),t.data,Oo(t.accessList||[]),(n=t.authorizationList||[],n.map((t=>[Bo(t.chainId,"chainId"),t.address,Bo(t.nonce,"nonce"),Bo(t.signature.yParity,"yParity"),t.signature.r,t.signature.s])))];var n;return e&&(r.push(Bo(e.yParity,"yParity")),r.push(hn(e.r)),r.push(hn(e.s))),Jr(["0x04",ei(r)])}(this,r)}Br(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})};let Lo=class t{constructor(){__privateAdd(this,St),__privateAdd(this,ct,void 0),__privateAdd(this,ut,void 0),__privateAdd(this,ht,void 0),__privateAdd(this,dt,void 0),__privateAdd(this,pt,void 0),__privateAdd(this,ft,void 0),__privateAdd(this,gt,void 0),__privateAdd(this,mt,void 0),__privateAdd(this,_t,void 0),__privateAdd(this,yt,void 0),__privateAdd(this,vt,void 0),__privateAdd(this,wt,void 0),__privateAdd(this,bt,void 0),__privateAdd(this,At,void 0),__privateAdd(this,Et,void 0),__privateAdd(this,xt,void 0),__privateAdd(this,kt,void 0),__privateSet(this,ct,null),__privateSet(this,ut,null),__privateSet(this,dt,0),__privateSet(this,pt,Ao),__privateSet(this,ft,null),__privateSet(this,gt,null),__privateSet(this,mt,null),__privateSet(this,ht,"0x"),__privateSet(this,_t,Ao),__privateSet(this,yt,Ao),__privateSet(this,vt,null),__privateSet(this,wt,null),__privateSet(this,bt,null),__privateSet(this,At,null),__privateSet(this,Et,null),__privateSet(this,xt,null),__privateSet(this,kt,null)}get type(){return __privateGet(this,ct)}set type(t){switch(t){case null:__privateSet(this,ct,null);break;case 0:case"legacy":__privateSet(this,ct,0);break;case 1:case"berlin":case"eip-2930":__privateSet(this,ct,1);break;case 2:case"london":case"eip-1559":__privateSet(this,ct,2);break;case 3:case"cancun":case"eip-4844":__privateSet(this,ct,3);break;case 4:case"pectra":case"eip-7702":__privateSet(this,ct,4);break;default:Or(!1,"unsupported transaction type","type",t)}}get typeName(){switch(this.type){case 0:return"legacy";case 1:return"eip-2930";case 2:return"eip-1559";case 3:return"eip-4844";case 4:return"eip-7702"}return null}get to(){const t=__privateGet(this,ut);return null==t&&3===this.type?Na:t}set to(t){__privateSet(this,ut,null==t?null:za(t))}get nonce(){return __privateGet(this,dt)}set nonce(t){__privateSet(this,dt,cn(t,"value"))}get gasLimit(){return __privateGet(this,pt)}set gasLimit(t){__privateSet(this,pt,sn(t))}get gasPrice(){const t=__privateGet(this,ft);return null!=t||0!==this.type&&1!==this.type?t:Ao}set gasPrice(t){__privateSet(this,ft,null==t?null:sn(t,"gasPrice"))}get maxPriorityFeePerGas(){const t=__privateGet(this,gt);return null==t?2===this.type||3===this.type?Ao:null:t}set maxPriorityFeePerGas(t){__privateSet(this,gt,null==t?null:sn(t,"maxPriorityFeePerGas"))}get maxFeePerGas(){const t=__privateGet(this,mt);return null==t?2===this.type||3===this.type?Ao:null:t}set maxFeePerGas(t){__privateSet(this,mt,null==t?null:sn(t,"maxFeePerGas"))}get data(){return __privateGet(this,ht)}set data(t){__privateSet(this,ht,Vr(t))}get value(){return __privateGet(this,_t)}set value(t){__privateSet(this,_t,sn(t,"value"))}get chainId(){return __privateGet(this,yt)}set chainId(t){__privateSet(this,yt,sn(t))}get signature(){return __privateGet(this,vt)||null}set signature(t){__privateSet(this,vt,null==t?null:Ua.from(t))}get accessList(){const t=__privateGet(this,wt)||null;return null==t?1===this.type||2===this.type||3===this.type?[]:null:t}set accessList(t){__privateSet(this,wt,null==t?null:vo(t))}get authorizationList(){const t=__privateGet(this,kt)||null;return null==t&&4===this.type?[]:t}set authorizationList(t){__privateSet(this,kt,null==t?null:t.map((t=>wo(t))))}get maxFeePerBlobGas(){const t=__privateGet(this,bt);return null==t&&3===this.type?Ao:t}set maxFeePerBlobGas(t){__privateSet(this,bt,null==t?null:sn(t,"maxFeePerBlobGas"))}get blobVersionedHashes(){let t=__privateGet(this,At);return null==t&&3===this.type?[]:t}set blobVersionedHashes(t){if(null!=t){Or(Array.isArray(t),"blobVersionedHashes must be an Array","value",t),t=t.slice();for(let e=0;e<t.length;e++)Or(Wr(t[e],32),"invalid blobVersionedHash",`value[${e}]`,t[e])}__privateSet(this,At,t)}get blobs(){return null==__privateGet(this,xt)?null:__privateGet(this,xt).map((t=>Object.assign({},t)))}set blobs(t){if(null==t)return void __privateSet(this,xt,null);const e=[],r=[];for(let n=0;n<t.length;n++){const i=t[n];if(Qr(i)){Br(__privateGet(this,Et),"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let t=jr(i);if(Or(t.length<=Po,"blob is too large",`blobs[${n}]`,i),t.length!==Po){const e=new Uint8Array(Po);e.set(t),t=e}const s=__privateGet(this,Et).blobToKzgCommitment(t),a=Vr(__privateGet(this,Et).computeBlobKzgProof(t,s));e.push({data:Vr(t),commitment:Vr(s),proof:a}),r.push(Co(1,s))}else{const t=Vr(i.commitment);e.push({data:Vr(i.data),commitment:t,proof:Vr(i.proof)}),r.push(Co(1,t))}}__privateSet(this,xt,e),__privateSet(this,At,r)}get kzg(){return __privateGet(this,Et)}set kzg(t){__privateSet(this,Et,null==t?null:function(t){return{blobToKzgCommitment:e=>{if("computeBlobProof"in t){if("blobToKzgCommitment"in t&&"function"==typeof t.blobToKzgCommitment)return jr(t.blobToKzgCommitment(Vr(e)))}else if("blobToKzgCommitment"in t&&"function"==typeof t.blobToKzgCommitment)return jr(t.blobToKzgCommitment(e));if("blobToKZGCommitment"in t&&"function"==typeof t.blobToKZGCommitment)return jr(t.blobToKZGCommitment(Vr(e)));Or(!1,"unsupported KZG library","kzg",t)},computeBlobKzgProof:(e,r)=>"computeBlobProof"in t&&"function"==typeof t.computeBlobProof?jr(t.computeBlobProof(Vr(e),Vr(r))):"computeBlobKzgProof"in t&&"function"==typeof t.computeBlobKzgProof?t.computeBlobKzgProof(e,r):"computeBlobKZGProof"in t&&"function"==typeof t.computeBlobKZGProof?jr(t.computeBlobKZGProof(Vr(e),Vr(r))):void Or(!1,"unsupported KZG library","kzg",t)}}(t))}get hash(){return null==this.signature?null:vs(__privateMethod(this,St,Nt).call(this,!0,!1))}get unsignedHash(){return vs(this.unsignedSerialized)}get from(){return null==this.signature?null:bo(this.unsignedHash,this.signature)}get fromPublicKey(){return null==this.signature?null:La.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return null!=this.signature}get serialized(){return __privateMethod(this,St,Nt).call(this,!0,!0)}get unsignedSerialized(){return __privateMethod(this,St,Nt).call(this,!1,!1)}inferType(){const t=this.inferTypes();return t.indexOf(2)>=0?2:t.pop()}inferTypes(){const t=null!=this.gasPrice,e=null!=this.maxFeePerGas||null!=this.maxPriorityFeePerGas,r=null!=this.accessList,n=null!=__privateGet(this,bt)||__privateGet(this,At);null!=this.maxFeePerGas&&null!=this.maxPriorityFeePerGas&&Br(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),Br(!e||0!==this.type&&1!==this.type,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),Br(0!==this.type||!r,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const i=[];return null!=this.type?i.push(this.type):this.authorizationList&&this.authorizationList.length?i.push(4):e?i.push(2):t?(i.push(1),r||i.push(0)):r?(i.push(1),i.push(2)):(n&&this.to||(i.push(0),i.push(1),i.push(2)),i.push(3)),i.sort(),i}isLegacy(){return 0===this.type}isBerlin(){return 1===this.type}isLondon(){return 2===this.type}isCancun(){return 3===this.type}clone(){return t.from(this)}toJSON(){const t=t=>null==t?null:t.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:t(this.gasLimit),gasPrice:t(this.gasPrice),maxPriorityFeePerGas:t(this.maxPriorityFeePerGas),maxFeePerGas:t(this.maxFeePerGas),value:t(this.value),chainId:t(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from(e){if(null==e)return new t;if("string"==typeof e){const r=jr(e);if(r[0]>=127)return t.from(function(t){const e=Yn(t);Or(Array.isArray(e)&&(9===e.length||6===e.length),"invalid field count for legacy transaction","data",t);const r={type:0,nonce:Mo(e[0],"nonce"),gasPrice:Io(e[1],"gasPrice"),gasLimit:Io(e[2],"gasLimit"),to:To(e[3]),value:Io(e[4],"value"),data:Vr(e[5]),chainId:Ao};if(6===e.length)return r;const n=Io(e[6],"v"),i=Io(e[7],"r"),s=Io(e[8],"s");if(i===Ao&&s===Ao)r.chainId=n;else{let t=(n-So)/Eo;t<Ao&&(t=Ao),r.chainId=t,Or(t!==Ao||n===xo||n===ko,"non-canonical legacy v","v",e[6]),r.signature=Ua.from({r:Yr(e[7],32),s:Yr(e[8],32),v:n})}return r}(r));switch(r[0]){case 1:return t.from(function(t){const e=Yn(jr(t).slice(1));Or(Array.isArray(e)&&(8===e.length||11===e.length),"invalid field count for transaction type: 1","data",Vr(t));const r={type:1,chainId:Io(e[0],"chainId"),nonce:Mo(e[1],"nonce"),gasPrice:Io(e[2],"gasPrice"),gasLimit:Io(e[3],"gasLimit"),to:To(e[4]),value:Io(e[5],"value"),data:Vr(e[6]),accessList:Ro(e[7],"accessList")};return 8===e.length||Uo(r,e.slice(8)),r}(r));case 2:return t.from(function(t){const e=Yn(jr(t).slice(1));Or(Array.isArray(e)&&(9===e.length||12===e.length),"invalid field count for transaction type: 2","data",Vr(t));const r={type:2,chainId:Io(e[0],"chainId"),nonce:Mo(e[1],"nonce"),maxPriorityFeePerGas:Io(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Io(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Io(e[4],"gasLimit"),to:To(e[5]),value:Io(e[6],"value"),data:Vr(e[7]),accessList:Ro(e[8],"accessList")};return 9===e.length||Uo(r,e.slice(9)),r}(r));case 3:return t.from(function(t){let e=Yn(jr(t).slice(1)),r="3",n=null;if(4===e.length&&Array.isArray(e[0])){r="3 (network format)";const t=e[1],i=e[2],s=e[3];Or(Array.isArray(t),"invalid network format: blobs not an array","fields[1]",t),Or(Array.isArray(i),"invalid network format: commitments not an array","fields[2]",i),Or(Array.isArray(s),"invalid network format: proofs not an array","fields[3]",s),Or(t.length===i.length,"invalid network format: blobs/commitments length mismatch","fields",e),Or(t.length===s.length,"invalid network format: blobs/proofs length mismatch","fields",e),n=[];for(let r=0;r<e[1].length;r++)n.push({data:t[r],commitment:i[r],proof:s[r]});e=e[0]}Or(Array.isArray(e)&&(11===e.length||14===e.length),`invalid field count for transaction type: ${r}`,"data",Vr(t));const i={type:3,chainId:Io(e[0],"chainId"),nonce:Mo(e[1],"nonce"),maxPriorityFeePerGas:Io(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Io(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Io(e[4],"gasLimit"),to:To(e[5]),value:Io(e[6],"value"),data:Vr(e[7]),accessList:Ro(e[8],"accessList"),maxFeePerBlobGas:Io(e[9],"maxFeePerBlobGas"),blobVersionedHashes:e[10]};n&&(i.blobs=n),Or(null!=i.to,`invalid address for transaction type: ${r}`,"data",t),Or(Array.isArray(i.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",t);for(let s=0;s<i.blobVersionedHashes.length;s++)Or(Wr(i.blobVersionedHashes[s],32),`invalid blobVersionedHash at index ${s}: must be length 32`,"data",t);return 11===e.length||Uo(i,e.slice(11)),i}(r));case 4:return t.from(function(t){const e=Yn(jr(t).slice(1));Or(Array.isArray(e)&&(10===e.length||13===e.length),"invalid field count for transaction type: 4","data",Vr(t));const r={type:4,chainId:Io(e[0],"chainId"),nonce:Mo(e[1],"nonce"),maxPriorityFeePerGas:Io(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Io(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Io(e[4],"gasLimit"),to:To(e[5]),value:Io(e[6],"value"),data:Vr(e[7]),accessList:Ro(e[8],"accessList"),authorizationList:Go(e[9],"authorizationList")};return 10===e.length||Uo(r,e.slice(10)),r}(r))}Br(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const r=new t;return null!=e.type&&(r.type=e.type),null!=e.to&&(r.to=e.to),null!=e.nonce&&(r.nonce=e.nonce),null!=e.gasLimit&&(r.gasLimit=e.gasLimit),null!=e.gasPrice&&(r.gasPrice=e.gasPrice),null!=e.maxPriorityFeePerGas&&(r.maxPriorityFeePerGas=e.maxPriorityFeePerGas),null!=e.maxFeePerGas&&(r.maxFeePerGas=e.maxFeePerGas),null!=e.maxFeePerBlobGas&&(r.maxFeePerBlobGas=e.maxFeePerBlobGas),null!=e.data&&(r.data=e.data),null!=e.value&&(r.value=e.value),null!=e.chainId&&(r.chainId=e.chainId),null!=e.signature&&(r.signature=Ua.from(e.signature)),null!=e.accessList&&(r.accessList=e.accessList),null!=e.authorizationList&&(r.authorizationList=e.authorizationList),null!=e.blobVersionedHashes&&(r.blobVersionedHashes=e.blobVersionedHashes),null!=e.kzg&&(r.kzg=e.kzg),null!=e.blobs&&(r.blobs=e.blobs),null!=e.hash&&(Or(r.isSigned(),"unsigned transaction cannot define '.hash'","tx",e),Or(r.hash===e.hash,"hash mismatch","tx",e)),null!=e.from&&(Or(r.isSigned(),"unsigned transaction cannot define '.from'","tx",e),Or(r.from.toLowerCase()===(e.from||"").toLowerCase(),"from mismatch","tx",e)),r}};function Do(t){return vs(yn(t))}const jo=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]);function Ho(t){return function(t){let e=0;return()=>t[e++]}(function(t){let e=0;function r(){return t[e++]<<8|t[e++]}let n=r(),i=1,s=[0,1];for(let w=1;w<n;w++)s.push(i+=r());let a=r(),o=e;e+=a;let l=0,c=0;function u(){return 0==l&&(c=c<<8|t[e++],l=8),c>>--l&1}const h=__pow(2,31),d=h>>>1,p=d>>1,f=h-1;let g=0;for(let w=0;w<31;w++)g=g<<1|u();let m=[],_=0,y=h;for(;;){let t=Math.floor(((g-_+1)*i-1)/y),e=0,r=n;for(;r-e>1;){let n=e+r>>>1;t<s[n]?r=n:e=n}if(0==e)break;m.push(e);let a=_+Math.floor(y*s[e]/i),o=_+Math.floor(y*s[e+1]/i)-1;for(;0==((a^o)&d);)g=g<<1&f|u(),a=a<<1&f,o=o<<1&f|1;for(;a&~o&p;)g=g&d|g<<1&f>>>1|u(),a=a<<1^d,o=(o^d)<<1|d|1;_=a,y=1+o-a}let v=n-4;return m.map((e=>{switch(e-v){case 3:return v+65792+(t[o++]<<16|t[o++]<<8|t[o++]);case 2:return v+256+(t[o++]<<8|t[o++]);case 1:return v+t[o++];default:return e-1}}))}(function(t){let e=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach(((t,r)=>e[t.charCodeAt(0)]=r));let r=t.length,n=new Uint8Array(6*r>>3);for(let i=0,s=0,a=0,o=0;i<r;i++)o=o<<6|e[t.charCodeAt(i)],a+=6,a>=8&&(n[s++]=o>>(a-=8));return n}(t)))}function Wo(t){return 1&t?~t>>1:t>>1}function Qo(t,e){let r=Array(t);for(let n=0,i=0;n<t;n++)r[n]=i+=Wo(e());return r}function zo(t,e=0){let r=[];for(;;){let n=t(),i=t();if(!i)break;e+=n;for(let t=0;t<i;t++)r.push(e+t);e+=i+1}return r}function Vo(t){return Ko((()=>{let e=zo(t);if(e.length)return e}))}function Jo(t){let e=[];for(;;){let r=t();if(0==r)break;e.push(Zo(r,t))}for(;;){let r=t()-1;if(r<0)break;e.push(Yo(r,t))}return e.flat()}function Ko(t){let e=[];for(;;){let r=t(e.length);if(!r)break;e.push(r)}return e}function qo(t,e,r){let n=Array(t).fill().map((()=>[]));for(let i=0;i<e;i++)Qo(t,r).forEach(((t,e)=>n[e].push(t)));return n}function Zo(t,e){let r=1+e(),n=e(),i=Ko(e);return qo(i.length,1+t,e).flatMap(((t,e)=>{let[s,...a]=t;return Array(i[e]).fill().map(((t,e)=>{let i=e*n;return[s+e*r,a.map((t=>t+i))]}))}))}function Yo(t,e){return qo(1+e(),1+t,e).map((t=>[t[0],t.slice(1)]))}function Xo(t){return`{${function(t){return t.toString(16).toUpperCase().padStart(2,"0")}(t)}}`}function $o(t){let e=t.length;if(e<4096)return String.fromCodePoint(...t);let r=[];for(let n=0;n<e;)r.push(String.fromCodePoint(...t.slice(n,n+=4096)));return r.join("")}function tl(t,e){let r=t.length,n=r-e.length;for(let i=0;0==n&&i<r;i++)n=t[i]-e[i];return n}const el=44032,rl=4352,nl=4449,il=4519,sl=28,al=588;function ol(t){return t>>24&255}function ll(t){return 16777215&t}let cl,ul,hl,dl;function pl(t){return t>=el&&t<55204}function fl(t,e){if(t>=rl&&t<4371&&e>=nl&&e<4470)return el+(t-rl)*al+(e-nl)*sl;if(pl(t)&&e>il&&e<4547&&(t-el)%sl==0)return t+(e-il);{let r=dl.get(t);return r&&(r=r.get(e),r)?r:-1}}function gl(t){cl||function(){let t=Ho("AEUDTAHBCFQATQDRADAAcgAgADQAFAAsABQAHwAOACQADQARAAoAFwAHABIACAAPAAUACwAFAAwABAAQAAMABwAEAAoABQAIAAIACgABAAQAFAALAAIACwABAAIAAQAHAAMAAwAEAAsADAAMAAwACgANAA0AAwAKAAkABAAdAAYAZwDSAdsDJgC0CkMB8xhZAqfoC190UGcThgBurwf7PT09Pb09AjgJum8OjDllxHYUKXAPxzq6tABAxgK8ysUvWAgMPT09PT09PSs6LT2HcgWXWwFLoSMEEEl5RFVMKvO0XQ8ExDdJMnIgsj26PTQyy8FfEQ8AY8IPAGcEbwRwBHEEcgRzBHQEdQR2BHcEeAR6BHsEfAR+BIAEgfndBQoBYgULAWIFDAFiBNcE2ATZBRAFEQUvBdALFAsVDPcNBw13DYcOMA4xDjMB4BllHI0B2grbAMDpHLkQ7QHVAPRNQQFnGRUEg0yEB2uaJF8AJpIBpob5AERSMAKNoAXqaQLUBMCzEiACnwRZEkkVsS7tANAsBG0RuAQLEPABv9HICTUBXigPZwRBApMDOwAamhtaABqEAY8KvKx3LQ4ArAB8UhwEBAVSagD8AEFZADkBIadVj2UMUgx5Il4ANQC9AxIB1BlbEPMAs30CGxlXAhwZKQIECBc6EbsCoxngzv7UzR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RIwtVSxye2Kf8rM3lhJ5XcBXU9n4v0Oy1RU2M+4qM8AQPVwse8ErNSob5oFPWxuqZnVzo1qB/IBxkM3EVUKFUUlO3e51259GgNcJbCmlvrdjtoTW7rChm1wyCKzpCTwozUUEOIcWLneRLgMXh+SjGSFkAllzbGS5HK7LlfCMRNRDSvbQPjcXaenNYxCvu2Qyznz6StuxVj66SgI0T8B6/sfHAJYZaZ78thjOSIFumNWLQbeZixDCCC+v0YBtkxiBB3jefHqZ/dFHU+crbj6OvS1x/JDD7vlm7zOVPwpUC01nhxZuY/63E7g");cl=new Map(Vo(t).flatMap(((t,e)=>t.map((t=>[t,e+1<<24]))))),ul=new Set(zo(t)),hl=new Map,dl=new Map;for(let[e,r]of Jo(t)){if(!ul.has(e)&&2==r.length){let[t,n]=r,i=dl.get(t);i||(i=new Map,dl.set(t,i)),i.set(n,e)}hl.set(e,r.reverse())}}();let e=[],r=[],n=!1;function i(t){let r=cl.get(t);r&&(n=!0,t|=r),e.push(t)}for(let s of t)for(;;){if(s<128)e.push(s);else if(pl(s)){let t=s-el,e=t%al/sl|0,r=t%sl;i(rl+(t/al|0)),i(nl+e),r>0&&i(il+r)}else{let t=hl.get(s);t?r.push(...t):i(s)}if(!r.length)break;s=r.pop()}if(n&&e.length>1){let t=ol(e[0]);for(let r=1;r<e.length;r++){let n=ol(e[r]);if(0==n||t<=n){t=n;continue}let i=r-1;for(;;){let r=e[i+1];if(e[i+1]=e[i],e[i]=r,!i)break;if(t=ol(e[--i]),t<=n)break}t=ol(e[r])}}return e}function ml(t){return gl(t).map(ll)}function _l(t){return function(t){let e=[],r=[],n=-1,i=0;for(let s of t){let t=ol(s),a=ll(s);if(-1==n)0==t?n=a:e.push(a);else if(i>0&&i>=t)0==t?(e.push(n,...r),r.length=0,n=a):r.push(a),i=t;else{let s=fl(n,a);s>=0?n=s:0==i&&0==t?(e.push(n),n=a):(r.push(a),i=t)}}return n>=0&&e.push(n,...r),e}(gl(t))}const yl=".",vl=t=>Array.from(t);function wl(t,e){return t.P.has(e)||t.Q.has(e)}class bl extends Array{get is_emoji(){return!0}}let Al,El,xl,kl,Sl,Nl,Pl,Cl,Tl,Rl,Gl;function Ml(){if(Al)return;let t=Ho("AEEUdwmgDS8BxQKKAP4BOgDjATAAngDUAIMAoABoAOAAagCOAEQAhABMAHIAOwA9ACsANgAmAGIAHgAuACgAJwAXAC0AGgAjAB8ALwAUACkAEgAeAAkAGwARABkAFgA5ACgALQArADcAFQApABAAHgAiABAAGgAeABMAGAUhBe8BFxREN8sF2wC5AK5HAW8ArQkDzQCuhzc3NzcBP68NEfMABQdHBuw5BV8FYAA9MzkI9r4ZBg7QyQAWA9CeOwLNCjcCjqkChuA/lm+RAsXTAoP6ASfnEQDytQFJAjWVCkeXAOsA6godAB/cwdAUE0WlBCN/AQUCQRjFD/MRBjHxDQSJbw0jBzUAswBxme+tnIcAYwabAysG8QAjAEMMmxcDqgPKQyDXCMMxA7kUQwD3NXOrAKmFIAAfBC0D3x4BJQDBGdUFAhEgVD8JnwmQJiNWYUzrg0oAGwAUAB0AFnNcACkAFgBP9h3gPfsDOWDKneY2ChglX1UDYD30ABsAFAAdABZzIGRAnwDD8wAjAEEMzRbDqgMB2sAFYwXqAtCnAsS4AwpUJKRtFHsadUz9AMMVbwLpABM1NJEX0ZkCgYMBEyMAxRVvAukAEzUBUFAtmUwSAy4DBTER33EftQHfSwB5MxJ/AjkWKQLzL8E/cwBB6QH9LQDPDtO9ASNriQC5DQANAwCK21EFI91zHwCoL9kBqQcHBwcHKzUDowBvAQohPvU3fAQgHwCyAc8CKQMA5zMSezr7ULgFmDp/LzVQBgEGAi8FYQVgt8AFcTtlQhpCWEmfe5tmZ6IAExsDzQ8t+X8rBKtTAltbAn0jsy8Bl6utPWMDTR8Ei2kRANkDBrNHNysDBzECQWUAcwFpJ3kAiyUhAJ0BUb8AL3EfAbfNAz81KUsFWwF3YQZtAm0A+VEfAzEJDQBRSQCzAQBlAHsAM70GD/v3IZWHBwARKQAx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UI2h1MThideGFEOK6YZHPwYzMBvpNC7+ZHxPb7epfefGyIB4JzO9DTNEYnDLVVHdQyvOEVefrk6Uv5kTQYVYWWdqrdcIl7yljwwIWdfQ/y+2QB3eR/qxYObuYyB4gTbo2in4PzarU1sO9nETkmj9/AoxDA+JM3GMqQtJR4jtduHtnoCLxd1gQUscHRB/MoRYIEsP2pDZ9KvHgtlk1iTbWWbHhohwFEYX7y51fUV2nuUmnoUcqnWIQAAgl9LTVX+Bc0QGNEhChxHR4YjfE51PUdGfsSFE6ck7BL3/hTf9jLq4G1IafINxOLKeAtO7quulYvH5YOBc+zX7CrMgWnW47/jfRsWnJjYYoE7xMfWV2HN2iyIqLI");const e=()=>zo(t),r=()=>new Set(e()),n=(t,e)=>e.forEach((e=>t.add(e)));Al=new Map(Jo(t)),El=r(),xl=e(),kl=new Set(e().map((t=>xl[t]))),xl=new Set(xl),Sl=r(),r();let i=Vo(t),s=t();const a=()=>{let t=new Set;return e().forEach((e=>n(t,i[e]))),n(t,e()),t};Nl=Ko((e=>{let r=Ko(t).map((t=>t+96));if(r.length){let n=e>=s;return r[0]-=32,r=$o(r),n&&(r=`Restricted[${r}]`),{N:r,P:a(),Q:a(),M:!t(),R:n}}})),Pl=r(),Cl=new Map;let o=e().concat(vl(Pl)).sort(((t,e)=>t-e));o.forEach(((e,r)=>{let n=t(),i=o[r]=n?o[r-n]:{V:[],M:new Map};i.V.push(e),Pl.has(e)||Cl.set(e,i)}));for(let{V:u,M:h}of new Set(Cl.values())){let t=[];for(let r of u){let e=Nl.filter((t=>wl(t,r))),i=t.find((({G:t})=>e.some((e=>t.has(e)))));i||(i={G:new Set,V:[]},t.push(i)),i.V.push(r),n(i.G,e)}let e=t.flatMap((t=>vl(t.G)));for(let{G:r,V:n}of t){let t=new Set(e.filter((t=>!r.has(t))));for(let e of n)h.set(e,t)}}Tl=new Set;let l=new Set;const c=t=>Tl.has(t)?l.add(t):Tl.add(t);for(let u of Nl){for(let t of u.P)c(t);for(let t of u.Q)c(t)}for(let u of Tl)Cl.has(u)||l.has(u)||Cl.set(u,1);n(Tl,ml(Tl)),Rl=function(t){let e=[],r=zo(t);return function t({S:r,B:n},i,s){if(!(4&r&&s===i[i.length-1])){2&r&&(s=i[i.length-1]),1&r&&e.push(i);for(let e of n)for(let r of e.Q)t(e,[...i,r],s)}}(function e(n){return{S:t(),B:Ko((()=>{let n=zo(t).map((t=>r[t]));if(n.length)return e(n)})),Q:n}}([]),[]),e}(t).map((t=>bl.from(t))).sort(tl),Gl=new Map;for(let u of Rl){let t=[Gl];for(let e of u){let r=t.map((t=>{let r=t.get(e);return r||(r=new Map,t.set(e,r)),r}));65039===e?t.push(...r):t=r}for(let e of t)e.V=u}}function Il(t){return(Fl(t)?"":`${Bl(Ol([t]))} `)+Xo(t)}function Bl(t){return`"${t}"‎`}function Ol(t,e=1/0,r=Xo){let n=[];var i;i=t[0],Ml(),xl.has(i)&&n.push("◌"),t.length>e&&(e>>=1,t=[...t.slice(0,e),8230,...t.slice(-e)]);let s=0,a=t.length;for(let o=0;o<a;o++){let e=t[o];Fl(e)&&(n.push($o(t.slice(s,o))),n.push(r(e)),s=o+1)}return n.push($o(t.slice(s,a))),n.join("")}function Fl(t){return Ml(),Sl.has(t)}function Ul(t){return e=function(t,e,r){if(!t)return[];Ml();let n=0;return t.split(yl).map((t=>{let i=function(t){let e=[];for(let r=0,n=t.length;r<n;){let n=t.codePointAt(r);r+=n<65536?1:2,e.push(n)}return e}(t),s={input:i,offset:n};n+=i.length+1;try{let t,n=s.tokens=function(t,e,r){let n=[],i=[];for(t=t.slice().reverse();t.length;){let s=Wl(t);if(s)i.length&&(n.push(e(i)),i=[]),n.push(r(s));else{let e=t.pop();if(Tl.has(e))i.push(e);else{let t=Al.get(e);if(t)i.push(...t);else if(!El.has(e))throw Ll(e)}}}return i.length&&n.push(e(i)),n}(i,e,r),a=n.length;if(!a)throw new Error("empty label");let o=s.output=n.flat();if(function(t){for(let e=t.lastIndexOf(95);e>0;)if(95!==t[--e])throw new Error("underscore allowed only at start")}(o),!(s.emoji=a>1||n[0].is_emoji)&&o.every((t=>t<128)))!function(t){if(t.length>=4&&45==t[2]&&45==t[3])throw new Error(`invalid label extension: "${$o(t.slice(0,4))}"`)}(o),t="ASCII";else{let e=n.flatMap((t=>t.is_emoji?[]:t));if(e.length){if(xl.has(o[0]))throw jl("leading combining mark");for(let t=1;t<a;t++){let e=n[t];if(!e.is_emoji&&xl.has(e[0]))throw jl(`emoji + combining mark: "${$o(n[t-1])} + ${Ol([e[0]])}"`)}!function(t){let e=t[0],r=jo.get(e);if(r)throw jl(`leading ${r}`);let n=t.length,i=-1;for(let s=1;s<n;s++){e=t[s];let n=jo.get(e);if(n){if(i==s)throw jl(`${r} + ${n}`);i=s+1,r=n}}if(i==n)throw jl(`trailing ${r}`)}(o);let r=vl(new Set(e)),[i]=function(t){let e=Nl;for(let r of t){let t=e.filter((t=>wl(t,r)));if(!t.length)throw Nl.some((t=>wl(t,r)))?Dl(e[0],r):Ll(r);if(e=t,1==t.length)break}return e}(r);!function(t,e){for(let r of e)if(!wl(t,r))throw Dl(t,r);if(t.M){let t=ml(e);for(let e=1,r=t.length;e<r;e++)if(kl.has(t[e])){let n=e+1;for(let i;n<r&&kl.has(i=t[n]);n++)for(let r=e;r<n;r++)if(t[r]==i)throw new Error(`duplicate non-spacing marks: ${Il(i)}`);if(n-e>4)throw new Error(`excessive non-spacing marks: ${Bl(Ol(t.slice(e-1,n)))} (${n-e}/4)`);e=n}}}(i,e),function(t,e){let r,n=[];for(let i of e){let t=Cl.get(i);if(1===t)return;if(t){let e=t.M.get(i);if(r=r?r.filter((t=>e.has(t))):vl(e),!r.length)return}else n.push(i)}if(r)for(let i of r)if(n.every((t=>wl(i,t))))throw new Error(`whole-script confusable: ${t.N}/${i.N}`)}(i,r),t=i.N}else t="Emoji"}s.type=t}catch(a){s.error=a}return s}))}(t,_l,Hl),e.map((({input:t,error:r,output:n})=>{if(r){let n=r.message;throw new Error(1==e.length?n:`Invalid label ${Bl(Ol(t,63))}: ${n}`)}return $o(n)})).join(yl);var e}function Ll(t){return new Error(`disallowed character: ${Il(t)}`)}function Dl(t,e){let r=Il(e),n=Nl.find((t=>t.P.has(e)));return n&&(r=`${n.N} ${r}`),new Error(`illegal mixture: ${t.N} + ${r}`)}function jl(t){return new Error(`illegal placement: ${t}`)}function Hl(t){return t.filter((t=>65039!=t))}function Wl(t,e){let r,n=Gl,i=t.length;for(;i&&(n=n.get(t[--i]),n);){let{V:s}=n;s&&(r=s,e&&e.push(...t.slice(i).reverse()),t.length=i)}return r}const Ql=new Uint8Array(32);function zl(t){return Or(0!==t.length,"invalid ENS name; empty component","comp",t),t}function Vl(t){const e=yn(function(t){try{if(0===t.length)throw new Error("empty label");return Ul(t)}catch(e){Or(!1,`invalid ENS name (${e.message})`,"name",t)}}(t)),r=[];if(0===t.length)return r;let n=0;for(let i=0;i<e.length;i++){46===e[i]&&(r.push(zl(e.slice(n,i))),n=i+1)}return Or(n<e.length,"invalid ENS name; empty component","name",t),r.push(zl(e.slice(n))),r}function Jl(t){Or("string"==typeof t,"invalid ENS name; not a string","name",t),Or(t.length,"invalid ENS name (empty label)","name",t);let e=Ql;const r=Vl(t);for(;r.length;)e=vs(Jr([e,vs(r.pop())]));return Vr(e)}function Kl(t,e){const r=null!=e?e:63;return Or(r<=255,"DNS encoded label cannot exceed 255","length",r),Vr(Jr(Vl(t).map((e=>{Or(e.length<=r,`label ${JSON.stringify(t)} exceeds ${r} bytes`,"name",t);const n=new Uint8Array(e.length+1);return n.set(e,1),n[0]=n.length-1,n}))))+"00"}Ql.fill(0);const ql=new Uint8Array(32);ql.fill(0);const Zl=BigInt(-1),Yl=BigInt(0),Xl=BigInt(1),$l=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const tc=un(Xl,32),ec=un(Yl,32),rc={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},nc=["name","version","chainId","verifyingContract","salt"];function ic(t){return function(e){return Or("string"==typeof e,`invalid domain value for ${JSON.stringify(t)}`,`domain.${t}`,e),e}}const sc={name:ic("name"),version:ic("version"),chainId:function(t){const e=sn(t,"domain.chainId");return Or(e>=0,"invalid chain ID","domain.chainId",t),Number.isSafeInteger(e)?Number(e):dn(e)},verifyingContract:function(t){try{return za(t).toLowerCase()}catch(e){}Or(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(t){const e=jr(t,"domain.salt");return Or(32===e.length,'invalid domain value "salt"',"domain.salt",t),Vr(e)}};function ac(t){{const e=t.match(/^(u?)int(\d+)$/);if(e){const r=""===e[1],n=parseInt(e[2]);Or(n%8==0&&0!==n&&n<=256&&e[2]===String(n),"invalid numeric width","type",t);const i=nn($l,r?n-1:n),s=r?(i+Xl)*Zl:Yl;return function(e){const n=sn(e,"value");return Or(n>=s&&n<=i,`value out-of-bounds for ${t}`,"value",n),un(r?rn(n,256):n,32)}}}{const e=t.match(/^bytes(\d+)$/);if(e){const r=parseInt(e[1]);return Or(0!==r&&r<=32&&e[1]===String(r),"invalid bytes width","type",t),function(e){return Or(jr(e).length===r,`invalid length for ${t}`,"value",e),function(t){const e=jr(t),r=e.length%32;return r?Jr([e,ql.slice(r)]):Vr(e)}(e)}}}switch(t){case"address":return function(t){return Yr(za(t),32)};case"bool":return function(t){return t?tc:ec};case"bytes":return function(t){return vs(t)};case"string":return function(t){return Do(t)}}return null}function oc(t,e){return`${t}(${e.map((({name:t,type:e})=>e+" "+t)).join(",")})`}function lc(t){const e=t.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);return e?{base:e[1],index:e[2]+e[4],array:{base:e[1],prefix:e[1]+e[2],count:e[5]?parseInt(e[5]):-1}}:{base:t}}Pt=new WeakMap,Ct=new WeakMap,Tt=new WeakMap,Rt=new WeakSet,Gt=function(t){{const e=ac(t);if(e)return e}const e=lc(t).array;if(e){const t=e.prefix,r=this.getEncoder(t);return n=>{Or(-1===e.count||e.count===n.length,`array length mismatch; expected length ${e.count}`,"value",n);let i=n.map(r);return __privateGet(this,Ct).has(t)&&(i=i.map(vs)),vs(Jr(i))}}const r=this.types[t];if(r){const e=Do(__privateGet(this,Ct).get(t));return t=>{const n=r.map((({name:e,type:r})=>{const n=this.getEncoder(r)(t[e]);return __privateGet(this,Ct).has(r)?vs(n):n}));return n.unshift(e),Jr(n)}}Or(!1,`unknown type: ${t}`,"type",t)};let cc=class t{constructor(t){__privateAdd(this,Rt),__publicField(this,"primaryType"),__privateAdd(this,Pt,void 0),__privateAdd(this,Ct,void 0),__privateAdd(this,Tt,void 0),__privateSet(this,Ct,new Map),__privateSet(this,Tt,new Map);const e=new Map,r=new Map,n=new Map,i={};Object.keys(t).forEach((s=>{i[s]=t[s].map((({name:e,type:r})=>{let{base:n,index:i}=lc(r);return"int"!==n||t.int||(n="int256"),"uint"!==n||t.uint||(n="uint256"),{name:e,type:n+(i||"")}})),e.set(s,new Set),r.set(s,[]),n.set(s,new Set)})),__privateSet(this,Pt,JSON.stringify(i));for(const a in i){const n=new Set;for(const s of i[a]){Or(!n.has(s.name),`duplicate variable name ${JSON.stringify(s.name)} in ${JSON.stringify(a)}`,"types",t),n.add(s.name);const i=lc(s.type).base;Or(i!==a,`circular type reference to ${JSON.stringify(i)}`,"types",t);ac(i)||(Or(r.has(i),`unknown type ${JSON.stringify(i)}`,"types",t),r.get(i).push(a),e.get(a).add(i))}}const s=Array.from(r.keys()).filter((t=>0===r.get(t).length));Or(0!==s.length,"missing primary type","types",t),Or(1===s.length,`ambiguous primary types or unused types: ${s.map((t=>JSON.stringify(t))).join(", ")}`,"types",t),Tr(this,{primaryType:s[0]}),function i(s,a){Or(!a.has(s),`circular type reference to ${JSON.stringify(s)}`,"types",t),a.add(s);for(const t of e.get(s))if(r.has(t)){i(t,a);for(const e of a)n.get(e).add(t)}a.delete(s)}(this.primaryType,new Set);for(const[a,o]of n){const t=Array.from(o);t.sort(),__privateGet(this,Ct).set(a,oc(a,i[a])+t.map((t=>oc(t,i[t]))).join(""))}}get types(){return JSON.parse(__privateGet(this,Pt))}getEncoder(t){let e=__privateGet(this,Tt).get(t);return e||(e=__privateMethod(this,Rt,Gt).call(this,t),__privateGet(this,Tt).set(t,e)),e}encodeType(t){const e=__privateGet(this,Ct).get(t);return Or(e,`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return vs(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,r){if(ac(t))return r(t,e);const n=lc(t).array;if(n)return Or(-1===n.count||n.count===e.length,`array length mismatch; expected length ${n.count}`,"value",e),e.map((t=>this._visit(n.prefix,t,r)));const i=this.types[t];if(i)return i.reduce(((t,{name:n,type:i})=>(t[n]=this._visit(i,e[n],r),t)),{});Or(!1,`unknown type: ${t}`,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(e){return new t(e)}static getPrimaryType(e){return t.from(e).primaryType}static hashStruct(e,r,n){return t.from(r).hashStruct(e,n)}static hashDomain(e){const r=[];for(const t in e){if(null==e[t])continue;const n=rc[t];Or(n,`invalid typed-data domain key: ${JSON.stringify(t)}`,"domain",e),r.push({name:t,type:n})}return r.sort(((t,e)=>nc.indexOf(t.name)-nc.indexOf(e.name))),t.hashStruct("EIP712Domain",{EIP712Domain:r},e)}static encode(e,r,n){return Jr(["0x1901",t.hashDomain(e),t.from(r).hash(n)])}static hash(e,r,n){return vs(t.encode(e,r,n))}static resolveNames(e,r,n,i){return __async(this,null,(function*(){e=Object.assign({},e);for(const t in e)null==e[t]&&delete e[t];const s={};e.verifyingContract&&!Wr(e.verifyingContract,20)&&(s[e.verifyingContract]="0x");const a=t.from(r);a.visit(n,((t,e)=>("address"!==t||Wr(e,20)||(s[e]="0x"),e)));for(const t in s)s[t]=yield i(t);return e.verifyingContract&&s[e.verifyingContract]&&(e.verifyingContract=s[e.verifyingContract]),n=a.visit(n,((t,e)=>"address"===t&&s[e]?s[e]:e)),{domain:e,value:n}}))}static getPayload(e,r,n){t.hashDomain(e);const i={},s=[];nc.forEach((t=>{const r=e[t];null!=r&&(i[t]=sc[t](r),s.push({name:t,type:rc[t]}))}));const a=t.from(r);r=a.types;const o=Object.assign({},r);return Or(null==o.EIP712Domain,"types must not contain EIP712Domain type","types.EIP712Domain",r),o.EIP712Domain=s,a.encode(n),{types:o,domain:i,primaryType:a.primaryType,message:a.visit(n,((t,e)=>{if(t.match(/^bytes(\d*)/))return Vr(jr(e));if(t.match(/^u?int/))return sn(e).toString();switch(t){case"address":return e.toLowerCase();case"bool":return!!e;case"string":return Or("string"==typeof e,"invalid string","value",e),e}Or(!1,"unsupported type","type",t)}))}}};function uc(t){const e=new Set;return t.forEach((t=>e.add(t))),Object.freeze(e)}const hc=uc("external public payable override".split(" ")),dc="constant external internal payable private public pure view override",pc=uc(dc.split(" ")),fc="constructor error event fallback function receive struct",gc=uc(fc.split(" ")),mc="calldata memory storage payable indexed",_c=uc(mc.split(" ")),yc=uc([fc,mc,"tuple returns",dc].join(" ").split(" ")),vc={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},wc=new RegExp("^(\\s*)"),bc=new RegExp("^([0-9]+)"),Ac=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),Ec=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),xc=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$"),kc=class t{constructor(t){__privateAdd(this,Bt),__privateAdd(this,Mt,void 0),__privateAdd(this,It,void 0),__privateSet(this,Mt,0),__privateSet(this,It,t.slice())}get offset(){return __privateGet(this,Mt)}get length(){return __privateGet(this,It).length-__privateGet(this,Mt)}clone(){return new t(__privateGet(this,It))}reset(){__privateSet(this,Mt,0)}popKeyword(t){const e=this.peek();if("KEYWORD"!==e.type||!t.has(e.text))throw new Error(`expected keyword ${e.text}`);return this.pop().text}popType(t){if(this.peek().type!==t){const e=this.peek();throw new Error(`expected ${t}; got ${e.type} ${JSON.stringify(e.text)}`)}return this.pop().text}popParen(){const t=this.peek();if("OPEN_PAREN"!==t.type)throw new Error("bad start");const e=__privateMethod(this,Bt,Ot).call(this,__privateGet(this,Mt)+1,t.match+1);return __privateSet(this,Mt,t.match+1),e}popParams(){const t=this.peek();if("OPEN_PAREN"!==t.type)throw new Error("bad start");const e=[];for(;__privateGet(this,Mt)<t.match-1;){const t=this.peek().linkNext;e.push(__privateMethod(this,Bt,Ot).call(this,__privateGet(this,Mt)+1,t)),__privateSet(this,Mt,t)}return __privateSet(this,Mt,t.match+1),e}peek(){if(__privateGet(this,Mt)>=__privateGet(this,It).length)throw new Error("out-of-bounds");return __privateGet(this,It)[__privateGet(this,Mt)]}peekKeyword(t){const e=this.peekType("KEYWORD");return null!=e&&t.has(e)?e:null}peekType(t){if(0===this.length)return null;const e=this.peek();return e.type===t?e.text:null}pop(){const t=this.peek();return __privateWrapper(this,Mt)._++,t}toString(){const t=[];for(let e=__privateGet(this,Mt);e<__privateGet(this,It).length;e++){const r=__privateGet(this,It)[e];t.push(`${r.type}:${r.text}`)}return`<TokenString ${t.join(" ")}>`}};Mt=new WeakMap,It=new WeakMap,Bt=new WeakSet,Ot=function(t=0,e=0){return new kc(__privateGet(this,It).slice(t,e).map((e=>Object.freeze(Object.assign({},e,{match:e.match-t,linkBack:e.linkBack-t,linkNext:e.linkNext-t})))))};let Sc=kc;function Nc(t){const e=[],r=e=>{const r=s<t.length?JSON.stringify(t[s]):"$EOI";throw new Error(`invalid token ${r} at ${s}: ${e}`)};let n=[],i=[],s=0;for(;s<t.length;){let a=t.substring(s),o=a.match(wc);o&&(s+=o[1].length,a=t.substring(s));const l={depth:n.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:s,value:-1};e.push(l);let c=vc[a[0]]||"";if(c){if(l.type=c,l.text=a[0],s++,"OPEN_PAREN"===c)n.push(e.length-1),i.push(e.length-1);else if("CLOSE_PAREN"==c)0===n.length&&r("no matching open bracket"),l.match=n.pop(),e[l.match].match=e.length-1,l.depth--,l.linkBack=i.pop(),e[l.linkBack].linkNext=e.length-1;else if("COMMA"===c)l.linkBack=i.pop(),e[l.linkBack].linkNext=e.length-1,i.push(e.length-1);else if("OPEN_BRACKET"===c)l.type="BRACKET";else if("CLOSE_BRACKET"===c){let t=e.pop().text;if(e.length>0&&"NUMBER"===e[e.length-1].type){const r=e.pop().text;t=r+t,e[e.length-1].value=cn(r)}if(0===e.length||"BRACKET"!==e[e.length-1].type)throw new Error("missing opening bracket");e[e.length-1].text+=t}}else if(o=a.match(Ac),o){if(l.text=o[1],s+=l.text.length,yc.has(l.text)){l.type="KEYWORD";continue}if(l.text.match(xc)){l.type="TYPE";continue}l.type="ID"}else{if(o=a.match(bc),!o)throw new Error(`unexpected token ${JSON.stringify(a[0])} at position ${s}`);l.text=o[1],l.type="NUMBER",s+=l.text.length}}return new Sc(e.map((t=>Object.freeze(t))))}function Pc(t,e){let r=[];for(const n in e.keys())t.has(n)&&r.push(n);if(r.length>1)throw new Error(`conflicting types: ${r.join(", ")}`)}function Cc(t,e){if(e.peekKeyword(gc)){const r=e.pop().text;if(r!==t)throw new Error(`expected ${t}, got ${r}`)}return e.popType("ID")}function Tc(t,e){const r=new Set;for(;;){const n=t.peekType("KEYWORD");if(null==n||e&&!e.has(n))break;if(t.pop(),r.has(n))throw new Error(`duplicate keywords: ${JSON.stringify(n)}`);r.add(n)}return Object.freeze(r)}function Rc(t){let e=Tc(t,pc);return Pc(e,uc("constant payable nonpayable".split(" "))),Pc(e,uc("pure view payable nonpayable".split(" "))),e.has("view")?"view":e.has("pure")?"pure":e.has("payable")?"payable":e.has("nonpayable")?"nonpayable":e.has("constant")?"view":"nonpayable"}function Gc(t,e){return t.popParams().map((t=>Vc.from(t,e)))}function Mc(t){if(t.peekType("AT")){if(t.pop(),t.peekType("NUMBER"))return sn(t.pop().text);throw new Error("invalid gas")}return null}function Ic(t){if(t.length)throw new Error(`unexpected tokens at offset ${t.offset}: ${t.toString()}`)}const Bc=new RegExp(/^(.*)\[([0-9]*)\]$/);function Oc(t){const e=t.match(xc);if(Or(e,"invalid type","type",t),"uint"===t)return"uint256";if("int"===t)return"int256";if(e[2]){const r=parseInt(e[2]);Or(0!==r&&r<=32,"invalid bytes length","type",t)}else if(e[3]){const r=parseInt(e[3]);Or(0!==r&&r<=256&&r%8==0,"invalid numeric width","type",t)}return t}const Fc={},Uc=Symbol.for("_ethers_internal"),Lc="_ParamTypeInternal",Dc="_ErrorInternal",jc="_EventInternal",Hc="_ConstructorInternal",Wc="_FallbackInternal",Qc="_FunctionInternal",zc="_StructInternal";Ft=new WeakSet,Ut=function(t,e,r,n){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(-1!==this.arrayLength&&e.length!==this.arrayLength)throw new Error("array is wrong length");const i=this.arrayChildren,s=e.slice();return s.forEach(((e,n)=>{var a;__privateMethod(a=i,Ft,Ut).call(a,t,e,r,(t=>{s[n]=t}))})),void n(s)}if(this.isTuple()){const i=this.components;let s;if(Array.isArray(e))s=e.slice();else{if(null==e||"object"!=typeof e)throw new Error("invalid tuple value");s=i.map((t=>{if(!t.name)throw new Error("cannot use object value with unnamed components");if(!(t.name in e))throw new Error(`missing value for component ${t.name}`);return e[t.name]}))}if(s.length!==this.components.length)throw new Error("array is wrong length");return s.forEach(((e,n)=>{var a;__privateMethod(a=i[n],Ft,Ut).call(a,t,e,r,(t=>{s[n]=t}))})),void n(s)}const i=r(this.type,e);i.then?t.push(function(){return __async(this,null,(function*(){n(yield i)}))}()):n(i)};let Vc=class t{constructor(t,e,r,n,i,s,a,o){if(__privateAdd(this,Ft),__publicField(this,"name"),__publicField(this,"type"),__publicField(this,"baseType"),__publicField(this,"indexed"),__publicField(this,"components"),__publicField(this,"arrayLength"),__publicField(this,"arrayChildren"),Lr(t,Fc,"ParamType"),Object.defineProperty(this,Uc,{value:Lc}),s&&(s=Object.freeze(s.slice())),"array"===n){if(null==a||null==o)throw new Error("")}else if(null!=a||null!=o)throw new Error("");if("tuple"===n){if(null==s)throw new Error("")}else if(null!=s)throw new Error("");Tr(this,{name:e,type:r,baseType:n,indexed:i,components:s,arrayLength:a,arrayChildren:o})}format(t){if(null==t&&(t="sighash"),"json"===t){const e=this.name||"";if(this.isArray()){const t=JSON.parse(this.arrayChildren.format("json"));return t.name=e,t.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(t)}const r={type:"tuple"===this.baseType?"tuple":this.type,name:e};return"boolean"==typeof this.indexed&&(r.indexed=this.indexed),this.isTuple()&&(r.components=this.components.map((e=>JSON.parse(e.format(t))))),JSON.stringify(r)}let e="";return this.isArray()?(e+=this.arrayChildren.format(t),e+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?e+="("+this.components.map((e=>e.format(t))).join("full"===t?", ":",")+")":e+=this.type,"sighash"!==t&&(!0===this.indexed&&(e+=" indexed"),"full"===t&&this.name&&(e+=" "+this.name)),e}isArray(){return"array"===this.baseType}isTuple(){return"tuple"===this.baseType}isIndexable(){return null!=this.indexed}walk(t,e){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(-1!==this.arrayLength&&t.length!==this.arrayLength)throw new Error("array is wrong length");const r=this;return t.map((t=>r.arrayChildren.walk(t,e)))}if(this.isTuple()){if(!Array.isArray(t))throw new Error("invalid tuple value");if(t.length!==this.components.length)throw new Error("array is wrong length");const r=this;return t.map(((t,n)=>r.components[n].walk(t,e)))}return e(this.type,t)}walkAsync(t,e){return __async(this,null,(function*(){const r=[],n=[t];return __privateMethod(this,Ft,Ut).call(this,r,t,e,(t=>{n[0]=t})),r.length&&(yield Promise.all(r)),n[0]}))}static from(e,r){if(t.isParamType(e))return e;if("string"==typeof e)try{return t.from(Nc(e),r)}catch(o){Or(!1,"invalid param type","obj",e)}else if(e instanceof Sc){let n="",i="",s=null;Tc(e,uc(["tuple"])).has("tuple")||e.peekType("OPEN_PAREN")?(i="tuple",s=e.popParams().map((e=>t.from(e))),n=`tuple(${s.map((t=>t.format())).join(",")})`):(n=Oc(e.popType("TYPE")),i=n);let a=null,o=null;for(;e.length&&e.peekType("BRACKET");){const r=e.pop();a=new t(Fc,"",n,i,null,s,o,a),o=r.value,n+=r.text,i="array",s=null}let l=null;if(Tc(e,_c).has("indexed")){if(!r)throw new Error("");l=!0}const c=e.peekType("ID")?e.pop().text:"";if(e.length)throw new Error("leftover tokens");return new t(Fc,c,n,i,l,s,o,a)}const n=e.name;Or(!n||"string"==typeof n&&n.match(Ec),"invalid name","obj.name",n);let i=e.indexed;null!=i&&(Or(r,"parameter cannot be indexed","obj.indexed",e.indexed),i=!!i);let s=e.type,a=s.match(Bc);if(a){const r=parseInt(a[2]||"-1"),o=t.from({type:a[1],components:e.components});return new t(Fc,n||"",s,"array",i,null,r,o)}if("tuple"===s||s.startsWith("tuple(")||s.startsWith("(")){const r=null!=e.components?e.components.map((e=>t.from(e))):null;return new t(Fc,n||"",s,"tuple",i,r,null,null)}return s=Oc(e.type),new t(Fc,n||"",s,s,i,null,null,null)}static isParamType(t){return t&&t[Uc]===Lc}};class Jc{constructor(t,e,r){__publicField(this,"type"),__publicField(this,"inputs"),Lr(t,Fc,"Fragment"),Tr(this,{type:e,inputs:r=Object.freeze(r.slice())})}static from(t){if("string"==typeof t){try{Jc.from(JSON.parse(t))}catch(e){}return Jc.from(Nc(t))}if(t instanceof Sc){switch(t.peekKeyword(gc)){case"constructor":return Xc.from(t);case"error":return Zc.from(t);case"event":return Yc.from(t);case"fallback":case"receive":return $c.from(t);case"function":return tu.from(t);case"struct":return eu.from(t)}}else if("object"==typeof t){switch(t.type){case"constructor":return Xc.from(t);case"error":return Zc.from(t);case"event":return Yc.from(t);case"fallback":case"receive":return $c.from(t);case"function":return tu.from(t);case"struct":return eu.from(t)}Br(!1,`unsupported type: ${t.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}Or(!1,"unsupported frgament object","obj",t)}static isConstructor(t){return Xc.isFragment(t)}static isError(t){return Zc.isFragment(t)}static isEvent(t){return Yc.isFragment(t)}static isFunction(t){return tu.isFragment(t)}static isStruct(t){return eu.isFragment(t)}}class Kc extends Jc{constructor(t,e,r,n){super(t,e,n),__publicField(this,"name"),Or("string"==typeof r&&r.match(Ec),"invalid identifier","name",r),n=Object.freeze(n.slice()),Tr(this,{name:r})}}function qc(t,e){return"("+e.map((e=>e.format(t))).join("full"===t?", ":",")+")"}class Zc extends Kc{constructor(t,e,r){super(t,"error",e,r),Object.defineProperty(this,Uc,{value:Dc})}get selector(){return Do(this.format("sighash")).substring(0,10)}format(t){if(null==t&&(t="sighash"),"json"===t)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});const e=[];return"sighash"!==t&&e.push("error"),e.push(this.name+qc(t,this.inputs)),e.join(" ")}static from(t){if(Zc.isFragment(t))return t;if("string"==typeof t)return Zc.from(Nc(t));if(t instanceof Sc){const e=Cc("error",t),r=Gc(t);return Ic(t),new Zc(Fc,e,r)}return new Zc(Fc,t.name,t.inputs?t.inputs.map(Vc.from):[])}static isFragment(t){return t&&t[Uc]===Dc}}class Yc extends Kc{constructor(t,e,r,n){super(t,"event",e,r),__publicField(this,"anonymous"),Object.defineProperty(this,Uc,{value:jc}),Tr(this,{anonymous:n})}get topicHash(){return Do(this.format("sighash"))}format(t){if(null==t&&(t="sighash"),"json"===t)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});const e=[];return"sighash"!==t&&e.push("event"),e.push(this.name+qc(t,this.inputs)),"sighash"!==t&&this.anonymous&&e.push("anonymous"),e.join(" ")}static getTopicHash(t,e){e=(e||[]).map((t=>Vc.from(t)));return new Yc(Fc,t,e,!1).topicHash}static from(t){if(Yc.isFragment(t))return t;if("string"==typeof t)try{return Yc.from(Nc(t))}catch(e){Or(!1,"invalid event fragment","obj",t)}else if(t instanceof Sc){const e=Cc("event",t),r=Gc(t,!0),n=!!Tc(t,uc(["anonymous"])).has("anonymous");return Ic(t),new Yc(Fc,e,r,n)}return new Yc(Fc,t.name,t.inputs?t.inputs.map((t=>Vc.from(t,!0))):[],!!t.anonymous)}static isFragment(t){return t&&t[Uc]===jc}}class Xc extends Jc{constructor(t,e,r,n,i){super(t,e,r),__publicField(this,"payable"),__publicField(this,"gas"),Object.defineProperty(this,Uc,{value:Hc}),Tr(this,{payable:n,gas:i})}format(t){if(Br(null!=t&&"sighash"!==t,"cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),"json"===t)return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:null!=this.gas?this.gas:void 0,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});const e=[`constructor${qc(t,this.inputs)}`];return this.payable&&e.push("payable"),null!=this.gas&&e.push(`@${this.gas.toString()}`),e.join(" ")}static from(t){if(Xc.isFragment(t))return t;if("string"==typeof t)try{return Xc.from(Nc(t))}catch(e){Or(!1,"invalid constuctor fragment","obj",t)}else if(t instanceof Sc){Tc(t,uc(["constructor"]));const e=Gc(t),r=!!Tc(t,hc).has("payable"),n=Mc(t);return Ic(t),new Xc(Fc,"constructor",e,r,n)}return new Xc(Fc,"constructor",t.inputs?t.inputs.map(Vc.from):[],!!t.payable,null!=t.gas?t.gas:null)}static isFragment(t){return t&&t[Uc]===Hc}}class $c extends Jc{constructor(t,e,r){super(t,"fallback",e),__publicField(this,"payable"),Object.defineProperty(this,Uc,{value:Wc}),Tr(this,{payable:r})}format(t){const e=0===this.inputs.length?"receive":"fallback";if("json"===t){const t=this.payable?"payable":"nonpayable";return JSON.stringify({type:e,stateMutability:t})}return`${e}()${this.payable?" payable":""}`}static from(t){if($c.isFragment(t))return t;if("string"==typeof t)try{return $c.from(Nc(t))}catch(e){Or(!1,"invalid fallback fragment","obj",t)}else if(t instanceof Sc){const e=t.toString();Or(t.peekKeyword(uc(["fallback","receive"])),"type must be fallback or receive","obj",e);if("receive"===t.popKeyword(uc(["fallback","receive"]))){const e=Gc(t);return Or(0===e.length,"receive cannot have arguments","obj.inputs",e),Tc(t,uc(["payable"])),Ic(t),new $c(Fc,[],!0)}let r=Gc(t);r.length?Or(1===r.length&&"bytes"===r[0].type,"invalid fallback inputs","obj.inputs",r.map((t=>t.format("minimal"))).join(", ")):r=[Vc.from("bytes")];const n=Rc(t);if(Or("nonpayable"===n||"payable"===n,"fallback cannot be constants","obj.stateMutability",n),Tc(t,uc(["returns"])).has("returns")){const e=Gc(t);Or(1===e.length&&"bytes"===e[0].type,"invalid fallback outputs","obj.outputs",e.map((t=>t.format("minimal"))).join(", "))}return Ic(t),new $c(Fc,r,"payable"===n)}if("receive"===t.type)return new $c(Fc,[],!0);if("fallback"===t.type){const e=[Vc.from("bytes")],r="payable"===t.stateMutability;return new $c(Fc,e,r)}Or(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[Uc]===Wc}}class tu extends Kc{constructor(t,e,r,n,i,s){super(t,"function",e,n),__publicField(this,"constant"),__publicField(this,"outputs"),__publicField(this,"stateMutability"),__publicField(this,"payable"),__publicField(this,"gas"),Object.defineProperty(this,Uc,{value:Qc});Tr(this,{constant:"view"===r||"pure"===r,gas:s,outputs:i=Object.freeze(i.slice()),payable:"payable"===r,stateMutability:r})}get selector(){return Do(this.format("sighash")).substring(0,10)}format(t){if(null==t&&(t="sighash"),"json"===t)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:null!=this.gas?this.gas:void 0,inputs:this.inputs.map((e=>JSON.parse(e.format(t)))),outputs:this.outputs.map((e=>JSON.parse(e.format(t))))});const e=[];return"sighash"!==t&&e.push("function"),e.push(this.name+qc(t,this.inputs)),"sighash"!==t&&("nonpayable"!==this.stateMutability&&e.push(this.stateMutability),this.outputs&&this.outputs.length&&(e.push("returns"),e.push(qc(t,this.outputs))),null!=this.gas&&e.push(`@${this.gas.toString()}`)),e.join(" ")}static getSelector(t,e){e=(e||[]).map((t=>Vc.from(t)));return new tu(Fc,t,"view",e,[],null).selector}static from(t){if(tu.isFragment(t))return t;if("string"==typeof t)try{return tu.from(Nc(t))}catch(r){Or(!1,"invalid function fragment","obj",t)}else if(t instanceof Sc){const e=Cc("function",t),r=Gc(t),n=Rc(t);let i=[];Tc(t,uc(["returns"])).has("returns")&&(i=Gc(t));const s=Mc(t);return Ic(t),new tu(Fc,e,n,r,i,s)}let e=t.stateMutability;return null==e&&(e="payable","boolean"==typeof t.constant?(e="view",t.constant||(e="payable","boolean"!=typeof t.payable||t.payable||(e="nonpayable"))):"boolean"!=typeof t.payable||t.payable||(e="nonpayable")),new tu(Fc,t.name,e,t.inputs?t.inputs.map(Vc.from):[],t.outputs?t.outputs.map(Vc.from):[],null!=t.gas?t.gas:null)}static isFragment(t){return t&&t[Uc]===Qc}}class eu extends Kc{constructor(t,e,r){super(t,"struct",e,r),Object.defineProperty(this,Uc,{value:zc})}format(){throw new Error("@TODO")}static from(t){if("string"==typeof t)try{return eu.from(Nc(t))}catch(e){Or(!1,"invalid struct fragment","obj",t)}else if(t instanceof Sc){const e=Cc("struct",t),r=Gc(t);return Ic(t),new eu(Fc,e,r)}return new eu(Fc,t.name,t.inputs?t.inputs.map(Vc.from):[])}static isFragment(t){return t&&t[Uc]===zc}}const ru=new Map;ru.set(0,"GENERIC_PANIC"),ru.set(1,"ASSERT_FALSE"),ru.set(17,"OVERFLOW"),ru.set(18,"DIVIDE_BY_ZERO"),ru.set(33,"ENUM_RANGE_ERROR"),ru.set(34,"BAD_STORAGE_DATA"),ru.set(49,"STACK_UNDERFLOW"),ru.set(50,"ARRAY_RANGE_ERROR"),ru.set(65,"OUT_OF_MEMORY"),ru.set(81,"UNINITIALIZED_FUNCTION_CALL");const nu=new RegExp(/^bytes([0-9]*)$/),iu=new RegExp(/^(u?int)([0-9]*)$/);let su=null,au=1024;Lt=new WeakSet,Dt=function(t){if(t.isArray())return new io(__privateMethod(this,Lt,Dt).call(this,t.arrayChildren),t.arrayLength,t.name);if(t.isTuple())return new _o(t.components.map((t=>__privateMethod(this,Lt,Dt).call(this,t))),t.name);switch(t.baseType){case"address":return new to(t.name);case"bool":return new so(t.name);case"string":return new mo(t.name);case"bytes":return new oo(t.name);case"":return new uo(t.name)}let e=t.type.match(iu);if(e){let r=parseInt(e[2]||"256");return Or(0!==r&&r<=256&&r%8==0,"invalid "+e[1]+" bit length","param",t),new go(r/8,"int"===e[1],t.name)}if(e=t.type.match(nu),e){let r=parseInt(e[1]);return Or(0!==r&&r<=32,"invalid bytes length","param",t),new lo(r,t.name)}Or(!1,"invalid type","type",t.type)};let ou=class t{constructor(){__privateAdd(this,Lt)}getDefaultValue(t){const e=t.map((t=>__privateMethod(this,Lt,Dt).call(this,Vc.from(t))));return new _o(e,"_").defaultValue()}encode(t,e){Fr(e.length,t.length,"types/values length mismatch");const r=t.map((t=>__privateMethod(this,Lt,Dt).call(this,Vc.from(t)))),n=new _o(r,"_"),i=new mi;return n.encode(i,e),i.data}decode(t,e,r){const n=t.map((t=>__privateMethod(this,Lt,Dt).call(this,Vc.from(t))));return new _o(n,"_").decode(new _i(e,r,au))}static _setDefaultMaxInflation(t){Or("number"==typeof t&&Number.isInteger(t),"invalid defaultMaxInflation factor","value",t),au=t}static defaultAbiCoder(){return null==su&&(su=new t),su}static getBuiltinCallException(e,r,n){return function(t,e,r,n){let i="missing revert data",s=null,a=null;if(r){i="execution reverted";const t=jr(r);if(r=Vr(r),0===t.length)i+=" (no data present; likely require(false) occurred",s="require(false)";else if(t.length%32!=4)i+=" (could not decode reason; invalid data length)";else if("0x08c379a0"===Vr(t.slice(0,4)))try{s=n.decode(["string"],t.slice(4))[0],a={signature:"Error(string)",name:"Error",args:[s]},i+=`: ${JSON.stringify(s)}`}catch(l){i+=" (could not decode reason; invalid string data)"}else if("0x4e487b71"===Vr(t.slice(0,4)))try{const e=Number(n.decode(["uint256"],t.slice(4))[0]);a={signature:"Panic(uint256)",name:"Panic",args:[e]},s=`Panic due to ${ru.get(e)||"UNKNOWN"}(${e})`,i+=`: ${s}`}catch(l){i+=" (could not decode panic code)"}else i+=" (unknown custom error)"}const o={to:e.to?za(e.to):null,data:e.data||"0x"};return e.from&&(o.from=za(e.from)),Ir(i,"CALL_EXCEPTION",{action:t,data:r,reason:s,transaction:o,invocation:null,revert:a})}(e,r,n,t.defaultAbiCoder())}};class lu{constructor(t,e,r){__publicField(this,"fragment"),__publicField(this,"name"),__publicField(this,"signature"),__publicField(this,"topic"),__publicField(this,"args");const n=t.name,i=t.format();Tr(this,{fragment:t,name:n,signature:i,topic:e,args:r})}}class cu{constructor(t,e,r,n){__publicField(this,"fragment"),__publicField(this,"name"),__publicField(this,"args"),__publicField(this,"signature"),__publicField(this,"selector"),__publicField(this,"value");const i=t.name,s=t.format();Tr(this,{fragment:t,name:i,args:r,signature:s,selector:e,value:n})}}class uu{constructor(t,e,r){__publicField(this,"fragment"),__publicField(this,"name"),__publicField(this,"args"),__publicField(this,"signature"),__publicField(this,"selector");const n=t.name,i=t.format();Tr(this,{fragment:t,name:n,args:r,signature:i,selector:e})}}class hu{constructor(t){__publicField(this,"hash"),__publicField(this,"_isIndexed"),Tr(this,{hash:t,_isIndexed:!0})}static isIndexed(t){return!(!t||!t._isIndexed)}}const du={0:"generic panic",1:"assert(false)",17:"arithmetic overflow",18:"division or modulo by zero",33:"enum overflow",34:"invalid encoded storage byte array accessed",49:"out-of-bounds array access; popping on an empty array",50:"out-of-bounds access of an array or bytesN",65:"out of memory",81:"uninitialized function"},pu={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:t=>`reverted with reason string ${JSON.stringify(t)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:t=>{let e="unknown panic code";return t>=0&&t<=255&&du[t.toString()]&&(e=du[t.toString()]),`reverted with panic code 0x${t.toString(16)} (${e})`}}};jt=new WeakMap,Ht=new WeakMap,Wt=new WeakMap,Qt=new WeakMap,zt=new WeakSet,Vt=function(t,e,r){if(Wr(t)){const e=t.toLowerCase();for(const t of __privateGet(this,Wt).values())if(e===t.selector)return t;return null}if(-1===t.indexOf("(")){const n=[];for(const[e,r]of __privateGet(this,Wt))e.split("(")[0]===t&&n.push(r);if(e){const t=e.length>0?e[e.length-1]:null;let r=e.length,i=!0;$a.isTyped(t)&&"overrides"===t.type&&(i=!1,r--);for(let e=n.length-1;e>=0;e--){const t=n[e].inputs.length;t===r||i&&t===r-1||n.splice(e,1)}for(let s=n.length-1;s>=0;s--){const t=n[s].inputs;for(let r=0;r<e.length;r++)if($a.isTyped(e[r])){if(r>=t.length){if("overrides"===e[r].type)continue;n.splice(s,1);break}if(e[r].type!==t[r].baseType){n.splice(s,1);break}}}}if(1===n.length&&e&&e.length!==n[0].inputs.length){const t=e[e.length-1];(null==t||Array.isArray(t)||"object"!=typeof t)&&n.splice(0,1)}if(0===n.length)return null;if(n.length>1&&r){Or(!1,`ambiguous function description (i.e. matches ${n.map((t=>JSON.stringify(t.format()))).join(", ")})`,"key",t)}return n[0]}const n=__privateGet(this,Wt).get(tu.from(t).format());return n||null},Jt=new WeakSet,Kt=function(t,e,r){if(Wr(t)){const e=t.toLowerCase();for(const t of __privateGet(this,Ht).values())if(e===t.topicHash)return t;return null}if(-1===t.indexOf("(")){const n=[];for(const[e,r]of __privateGet(this,Ht))e.split("(")[0]===t&&n.push(r);if(e){for(let t=n.length-1;t>=0;t--)n[t].inputs.length<e.length&&n.splice(t,1);for(let t=n.length-1;t>=0;t--){const r=n[t].inputs;for(let i=0;i<e.length;i++)if($a.isTyped(e[i])&&e[i].type!==r[i].baseType){n.splice(t,1);break}}}if(0===n.length)return null;if(n.length>1&&r){Or(!1,`ambiguous event description (i.e. matches ${n.map((t=>JSON.stringify(t.format()))).join(", ")})`,"key",t)}return n[0]}const n=__privateGet(this,Ht).get(Yc.from(t).format());return n||null};let fu=class t{constructor(t){__privateAdd(this,zt),__privateAdd(this,Jt),__publicField(this,"fragments"),__publicField(this,"deploy"),__publicField(this,"fallback"),__publicField(this,"receive"),__privateAdd(this,jt,void 0),__privateAdd(this,Ht,void 0),__privateAdd(this,Wt,void 0),__privateAdd(this,Qt,void 0);let e=[];e="string"==typeof t?JSON.parse(t):t,__privateSet(this,Wt,new Map),__privateSet(this,jt,new Map),__privateSet(this,Ht,new Map);const r=[];for(const a of e)try{r.push(Jc.from(a))}catch(s){console.log(`[Warning] Invalid Fragment ${JSON.stringify(a)}:`,s.message)}Tr(this,{fragments:Object.freeze(r)});let n=null,i=!1;__privateSet(this,Qt,this.getAbiCoder()),this.fragments.forEach(((t,e)=>{let r;switch(t.type){case"constructor":return this.deploy?void console.log("duplicate definition - constructor"):void Tr(this,{deploy:t});case"fallback":return void(0===t.inputs.length?i=!0:(Or(!n||t.payable!==n.payable,"conflicting fallback fragments",`fragments[${e}]`,t),n=t,i=n.payable));case"function":r=__privateGet(this,Wt);break;case"event":r=__privateGet(this,Ht);break;case"error":r=__privateGet(this,jt);break;default:return}const s=t.format();r.has(s)||r.set(s,t)})),this.deploy||Tr(this,{deploy:Xc.from("constructor()")}),Tr(this,{fallback:n,receive:i})}format(t){const e=t?"minimal":"full";return this.fragments.map((t=>t.format(e)))}formatJson(){const t=this.fragments.map((t=>t.format("json")));return JSON.stringify(t.map((t=>JSON.parse(t))))}getAbiCoder(){return ou.defaultAbiCoder()}getFunctionName(t){const e=__privateMethod(this,zt,Vt).call(this,t,null,!1);return Or(e,"no matching function","key",t),e.name}hasFunction(t){return!!__privateMethod(this,zt,Vt).call(this,t,null,!1)}getFunction(t,e){return __privateMethod(this,zt,Vt).call(this,t,e||null,!0)}forEachFunction(t){const e=Array.from(__privateGet(this,Wt).keys());e.sort(((t,e)=>t.localeCompare(e)));for(let r=0;r<e.length;r++){const n=e[r];t(__privateGet(this,Wt).get(n),r)}}getEventName(t){const e=__privateMethod(this,Jt,Kt).call(this,t,null,!1);return Or(e,"no matching event","key",t),e.name}hasEvent(t){return!!__privateMethod(this,Jt,Kt).call(this,t,null,!1)}getEvent(t,e){return __privateMethod(this,Jt,Kt).call(this,t,e||null,!0)}forEachEvent(t){const e=Array.from(__privateGet(this,Ht).keys());e.sort(((t,e)=>t.localeCompare(e)));for(let r=0;r<e.length;r++){const n=e[r];t(__privateGet(this,Ht).get(n),r)}}getError(t,e){if(Wr(t)){const e=t.toLowerCase();if(pu[e])return Zc.from(pu[e].signature);for(const t of __privateGet(this,jt).values())if(e===t.selector)return t;return null}if(-1===t.indexOf("(")){const e=[];for(const[r,n]of __privateGet(this,jt))r.split("(")[0]===t&&e.push(n);if(0===e.length)return"Error"===t?Zc.from("error Error(string)"):"Panic"===t?Zc.from("error Panic(uint256)"):null;if(e.length>1){Or(!1,`ambiguous error description (i.e. ${e.map((t=>JSON.stringify(t.format()))).join(", ")})`,"name",t)}return e[0]}if("Error(string)"===(t=Zc.from(t).format()))return Zc.from("error Error(string)");if("Panic(uint256)"===t)return Zc.from("error Panic(uint256)");const r=__privateGet(this,jt).get(t);return r||null}forEachError(t){const e=Array.from(__privateGet(this,jt).keys());e.sort(((t,e)=>t.localeCompare(e)));for(let r=0;r<e.length;r++){const n=e[r];t(__privateGet(this,jt).get(n),r)}}_decodeParams(t,e){return __privateGet(this,Qt).decode(t,e)}_encodeParams(t,e){return __privateGet(this,Qt).encode(t,e)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}decodeErrorResult(t,e){if("string"==typeof t){const e=this.getError(t);Or(e,"unknown error","fragment",t),t=e}return Or(qr(e,0,4)===t.selector,`data signature does not match error ${t.name}.`,"data",e),this._decodeParams(t.inputs,qr(e,4))}encodeErrorResult(t,e){if("string"==typeof t){const e=this.getError(t);Or(e,"unknown error","fragment",t),t=e}return Jr([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionData(t,e){if("string"==typeof t){const e=this.getFunction(t);Or(e,"unknown function","fragment",t),t=e}return Or(qr(e,0,4)===t.selector,`data signature does not match function ${t.name}.`,"data",e),this._decodeParams(t.inputs,qr(e,4))}encodeFunctionData(t,e){if("string"==typeof t){const e=this.getFunction(t);Or(e,"unknown function","fragment",t),t=e}return Jr([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionResult(t,e){if("string"==typeof t){const e=this.getFunction(t);Or(e,"unknown function","fragment",t),t=e}let r="invalid length for result data";const n=Hr(e);if(n.length%32==0)try{return __privateGet(this,Qt).decode(t.outputs,n)}catch(i){r="could not decode result data"}Br(!1,r,"BAD_DATA",{value:Vr(n),info:{method:t.name,signature:t.format()}})}makeError(t,e){const r=jr(t,"data"),n=ou.getBuiltinCallException("call",e,r);if(n.message.startsWith("execution reverted (unknown custom error)")){const t=Vr(r.slice(0,4)),e=this.getError(t);if(e)try{const t=__privateGet(this,Qt).decode(e.inputs,r.slice(4));n.revert={name:e.name,signature:e.format(),args:t},n.reason=n.revert.signature,n.message=`execution reverted: ${n.reason}`}catch(s){n.message="execution reverted (coult not decode custom error)"}}const i=this.parseTransaction(e);return i&&(n.invocation={method:i.name,signature:i.signature,args:i.args}),n}encodeFunctionResult(t,e){if("string"==typeof t){const e=this.getFunction(t);Or(e,"unknown function","fragment",t),t=e}return Vr(__privateGet(this,Qt).encode(t.outputs,e||[]))}encodeFilterTopics(t,e){if("string"==typeof t){const e=this.getEvent(t);Or(e,"unknown event","eventFragment",t),t=e}Br(e.length<=t.inputs.length,`too many arguments for ${t.format()}`,"UNEXPECTED_ARGUMENT",{count:e.length,expectedCount:t.inputs.length});const r=[];t.anonymous||r.push(t.topicHash);const n=(t,e)=>"string"===t.type?Do(e):"bytes"===t.type?vs(Vr(e)):("bool"===t.type&&"boolean"==typeof e?e=e?"0x01":"0x00":t.type.match(/^u?int/)?e=un(e):t.type.match(/^bytes/)?e=Zr(e,32,!1):"address"===t.type&&__privateGet(this,Qt).encode(["address"],[e]),Yr(Vr(e),32));for(e.forEach(((e,i)=>{const s=t.inputs[i];s.indexed?null==e?r.push(null):"array"===s.baseType||"tuple"===s.baseType?Or(!1,"filtering with tuples or arrays not supported","contract."+s.name,e):Array.isArray(e)?r.push(e.map((t=>n(s,t)))):r.push(n(s,e)):Or(null==e,"cannot filter non-indexed parameters; must be null","contract."+s.name,e)}));r.length&&null===r[r.length-1];)r.pop();return r}encodeEventLog(t,e){if("string"==typeof t){const e=this.getEvent(t);Or(e,"unknown event","eventFragment",t),t=e}const r=[],n=[],i=[];return t.anonymous||r.push(t.topicHash),Or(e.length===t.inputs.length,"event arguments/values mismatch","values",e),t.inputs.forEach(((t,s)=>{const a=e[s];if(t.indexed)if("string"===t.type)r.push(Do(a));else if("bytes"===t.type)r.push(vs(a));else{if("tuple"===t.baseType||"array"===t.baseType)throw new Error("not implemented");r.push(__privateGet(this,Qt).encode([t.type],[a]))}else n.push(t),i.push(a)})),{data:__privateGet(this,Qt).encode(n,i),topics:r}}decodeEventLog(t,e,r){if("string"==typeof t){const e=this.getEvent(t);Or(e,"unknown event","eventFragment",t),t=e}if(null!=r&&!t.anonymous){const e=t.topicHash;Or(Wr(r[0],32)&&r[0].toLowerCase()===e,"fragment/topic mismatch","topics[0]",r[0]),r=r.slice(1)}const n=[],i=[],s=[];t.inputs.forEach(((t,e)=>{t.indexed?"string"===t.type||"bytes"===t.type||"tuple"===t.baseType||"array"===t.baseType?(n.push(Vc.from({type:"bytes32",name:t.name})),s.push(!0)):(n.push(t),s.push(!1)):(i.push(t),s.push(!1))}));const a=null!=r?__privateGet(this,Qt).decode(n,Jr(r)):null,o=__privateGet(this,Qt).decode(i,e,!0),l=[],c=[];let u=0,h=0;return t.inputs.forEach(((t,e)=>{let r=null;if(t.indexed)if(null==a)r=new hu(null);else if(s[e])r=new hu(a[h++]);else try{r=a[h++]}catch(n){r=n}else try{r=o[u++]}catch(n){r=n}l.push(r),c.push(t.name||null)})),pi.fromItems(l,c)}parseTransaction(t){const e=jr(t.data,"tx.data"),r=sn(null!=t.value?t.value:0,"tx.value"),n=this.getFunction(Vr(e.slice(0,4)));if(!n)return null;const i=__privateGet(this,Qt).decode(n.inputs,e.slice(4));return new cu(n,n.selector,i,r)}parseCallResult(t){throw new Error("@TODO")}parseLog(t){const e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new lu(e,e.topicHash,this.decodeEventLog(e,t.data,t.topics))}parseError(t){const e=Vr(t),r=this.getError(qr(e,0,4));if(!r)return null;const n=__privateGet(this,Qt).decode(r.inputs,qr(e,4));return new uu(r,r.selector,n)}static from(e){return e instanceof t?e:"string"==typeof e?new t(JSON.parse(e)):"function"==typeof e.formatJson?new t(e.formatJson()):"function"==typeof e.format?new t(e.format("json")):new t(e)}};const gu=BigInt(0);function mu(t){return null==t?null:t}function _u(t){return null==t?null:t.toString()}class yu{constructor(t,e,r){__publicField(this,"gasPrice"),__publicField(this,"maxFeePerGas"),__publicField(this,"maxPriorityFeePerGas"),Tr(this,{gasPrice:mu(t),maxFeePerGas:mu(e),maxPriorityFeePerGas:mu(r)})}toJSON(){const{gasPrice:t,maxFeePerGas:e,maxPriorityFeePerGas:r}=this;return{_type:"FeeData",gasPrice:_u(t),maxFeePerGas:_u(e),maxPriorityFeePerGas:_u(r)}}}function vu(t){const e={};t.to&&(e.to=t.to),t.from&&(e.from=t.from),t.data&&(e.data=Vr(t.data));const r="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const i of r)i in t&&null!=t[i]&&(e[i]=sn(t[i],`request.${i}`));const n="type,nonce".split(/,/);for(const i of n)i in t&&null!=t[i]&&(e[i]=cn(t[i],`request.${i}`));return t.accessList&&(e.accessList=vo(t.accessList)),t.authorizationList&&(e.authorizationList=t.authorizationList.slice()),"blockTag"in t&&(e.blockTag=t.blockTag),"enableCcipRead"in t&&(e.enableCcipRead=!!t.enableCcipRead),"customData"in t&&(e.customData=t.customData),"blobVersionedHashes"in t&&t.blobVersionedHashes&&(e.blobVersionedHashes=t.blobVersionedHashes.slice()),"kzg"in t&&(e.kzg=t.kzg),"blobs"in t&&t.blobs&&(e.blobs=t.blobs.map((t=>Qr(t)?Vr(t):Object.assign({},t)))),e}class wu{constructor(t,e){__publicField(this,"provider"),__publicField(this,"number"),__publicField(this,"hash"),__publicField(this,"timestamp"),__publicField(this,"parentHash"),__publicField(this,"parentBeaconBlockRoot"),__publicField(this,"nonce"),__publicField(this,"difficulty"),__publicField(this,"gasLimit"),__publicField(this,"gasUsed"),__publicField(this,"stateRoot"),__publicField(this,"receiptsRoot"),__publicField(this,"blobGasUsed"),__publicField(this,"excessBlobGas"),__publicField(this,"miner"),__publicField(this,"prevRandao"),__publicField(this,"extraData"),__publicField(this,"baseFeePerGas"),__privateAdd(this,qt,void 0),__privateSet(this,qt,t.transactions.map((t=>"string"!=typeof t?new Eu(t,e):t))),Tr(this,{provider:e,hash:mu(t.hash),number:t.number,timestamp:t.timestamp,parentHash:t.parentHash,parentBeaconBlockRoot:t.parentBeaconBlockRoot,nonce:t.nonce,difficulty:t.difficulty,gasLimit:t.gasLimit,gasUsed:t.gasUsed,blobGasUsed:t.blobGasUsed,excessBlobGas:t.excessBlobGas,miner:t.miner,prevRandao:mu(t.prevRandao),extraData:t.extraData,baseFeePerGas:mu(t.baseFeePerGas),stateRoot:t.stateRoot,receiptsRoot:t.receiptsRoot})}get transactions(){return __privateGet(this,qt).map((t=>"string"==typeof t?t:t.hash))}get prefetchedTransactions(){const t=__privateGet(this,qt).slice();return 0===t.length?[]:(Br("object"==typeof t[0],"transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),t)}toJSON(){const{baseFeePerGas:t,difficulty:e,extraData:r,gasLimit:n,gasUsed:i,hash:s,miner:a,prevRandao:o,nonce:l,number:c,parentHash:u,parentBeaconBlockRoot:h,stateRoot:d,receiptsRoot:p,timestamp:f,transactions:g}=this;return{_type:"Block",baseFeePerGas:_u(t),difficulty:_u(e),extraData:r,gasLimit:_u(n),gasUsed:_u(i),blobGasUsed:_u(this.blobGasUsed),excessBlobGas:_u(this.excessBlobGas),hash:s,miner:a,prevRandao:o,nonce:l,number:c,parentHash:u,timestamp:f,parentBeaconBlockRoot:h,stateRoot:d,receiptsRoot:p,transactions:g}}[Symbol.iterator](){let t=0;const e=this.transactions;return{next:()=>t<this.length?{value:e[t++],done:!1}:{value:void 0,done:!0}}}get length(){return __privateGet(this,qt).length}get date(){return null==this.timestamp?null:new Date(1e3*this.timestamp)}getTransaction(t){return __async(this,null,(function*(){let e;if("number"==typeof t)e=__privateGet(this,qt)[t];else{const r=t.toLowerCase();for(const t of __privateGet(this,qt)){if("string"==typeof t){if(t!==r)continue;e=t;break}if(t.hash===r){e=t;break}}}if(null==e)throw new Error("no such tx");return"string"==typeof e?yield this.provider.getTransaction(e):e}))}getPrefetchedTransaction(t){const e=this.prefetchedTransactions;if("number"==typeof t)return e[t];t=t.toLowerCase();for(const r of e)if(r.hash===t)return r;Or(!1,"no matching transaction","indexOrHash",t)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return{orphan:"drop-block",hash:(t=this).hash,number:t.number};var t}}qt=new WeakMap;class bu{constructor(t,e){__publicField(this,"provider"),__publicField(this,"transactionHash"),__publicField(this,"blockHash"),__publicField(this,"blockNumber"),__publicField(this,"removed"),__publicField(this,"address"),__publicField(this,"data"),__publicField(this,"topics"),__publicField(this,"index"),__publicField(this,"transactionIndex"),this.provider=e;const r=Object.freeze(t.topics.slice());Tr(this,{transactionHash:t.transactionHash,blockHash:t.blockHash,blockNumber:t.blockNumber,removed:t.removed,address:t.address,data:t.data,topics:r,index:t.index,transactionIndex:t.transactionIndex})}toJSON(){const{address:t,blockHash:e,blockNumber:r,data:n,index:i,removed:s,topics:a,transactionHash:o,transactionIndex:l}=this;return{_type:"log",address:t,blockHash:e,blockNumber:r,data:n,index:i,removed:s,topics:a,transactionHash:o,transactionIndex:l}}getBlock(){return __async(this,null,(function*(){const t=yield this.provider.getBlock(this.blockHash);return Br(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}))}getTransaction(){return __async(this,null,(function*(){const t=yield this.provider.getTransaction(this.transactionHash);return Br(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}))}getTransactionReceipt(){return __async(this,null,(function*(){const t=yield this.provider.getTransactionReceipt(this.transactionHash);return Br(!!t,"failed to find transaction receipt","UNKNOWN_ERROR",{}),t}))}removedEvent(){return{orphan:"drop-log",log:{transactionHash:(t=this).transactionHash,blockHash:t.blockHash,blockNumber:t.blockNumber,address:t.address,data:t.data,topics:Object.freeze(t.topics.slice()),index:t.index}};var t}}class Au{constructor(t,e){__publicField(this,"provider"),__publicField(this,"to"),__publicField(this,"from"),__publicField(this,"contractAddress"),__publicField(this,"hash"),__publicField(this,"index"),__publicField(this,"blockHash"),__publicField(this,"blockNumber"),__publicField(this,"logsBloom"),__publicField(this,"gasUsed"),__publicField(this,"blobGasUsed"),__publicField(this,"cumulativeGasUsed"),__publicField(this,"gasPrice"),__publicField(this,"blobGasPrice"),__publicField(this,"type"),__publicField(this,"status"),__publicField(this,"root"),__privateAdd(this,Zt,void 0),__privateSet(this,Zt,Object.freeze(t.logs.map((t=>new bu(t,e)))));let r=gu;null!=t.effectiveGasPrice?r=t.effectiveGasPrice:null!=t.gasPrice&&(r=t.gasPrice),Tr(this,{provider:e,to:t.to,from:t.from,contractAddress:t.contractAddress,hash:t.hash,index:t.index,blockHash:t.blockHash,blockNumber:t.blockNumber,logsBloom:t.logsBloom,gasUsed:t.gasUsed,cumulativeGasUsed:t.cumulativeGasUsed,blobGasUsed:t.blobGasUsed,gasPrice:r,blobGasPrice:t.blobGasPrice,type:t.type,status:t.status,root:t.root})}get logs(){return __privateGet(this,Zt)}toJSON(){const{to:t,from:e,contractAddress:r,hash:n,index:i,blockHash:s,blockNumber:a,logsBloom:o,logs:l,status:c,root:u}=this;return{_type:"TransactionReceipt",blockHash:s,blockNumber:a,contractAddress:r,cumulativeGasUsed:_u(this.cumulativeGasUsed),from:e,gasPrice:_u(this.gasPrice),blobGasUsed:_u(this.blobGasUsed),blobGasPrice:_u(this.blobGasPrice),gasUsed:_u(this.gasUsed),hash:n,index:i,logs:l,logsBloom:o,root:u,status:c,to:t}}get length(){return this.logs.length}[Symbol.iterator](){let t=0;return{next:()=>t<this.length?{value:this.logs[t++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}getBlock(){return __async(this,null,(function*(){const t=yield this.provider.getBlock(this.blockHash);if(null==t)throw new Error("TODO");return t}))}getTransaction(){return __async(this,null,(function*(){const t=yield this.provider.getTransaction(this.hash);if(null==t)throw new Error("TODO");return t}))}getResult(){return __async(this,null,(function*(){return yield this.provider.getTransactionResult(this.hash)}))}confirmations(){return __async(this,null,(function*(){return(yield this.provider.getBlockNumber())-this.blockNumber+1}))}removedEvent(){return ku(this)}reorderedEvent(t){return Br(!t||t.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),xu(this,t)}}Zt=new WeakMap;Yt=new WeakMap;let Eu=class t{constructor(t,e){__publicField(this,"provider"),__publicField(this,"blockNumber"),__publicField(this,"blockHash"),__publicField(this,"index"),__publicField(this,"hash"),__publicField(this,"type"),__publicField(this,"to"),__publicField(this,"from"),__publicField(this,"nonce"),__publicField(this,"gasLimit"),__publicField(this,"gasPrice"),__publicField(this,"maxPriorityFeePerGas"),__publicField(this,"maxFeePerGas"),__publicField(this,"maxFeePerBlobGas"),__publicField(this,"data"),__publicField(this,"value"),__publicField(this,"chainId"),__publicField(this,"signature"),__publicField(this,"accessList"),__publicField(this,"blobVersionedHashes"),__publicField(this,"authorizationList"),__privateAdd(this,Yt,void 0),this.provider=e,this.blockNumber=null!=t.blockNumber?t.blockNumber:null,this.blockHash=null!=t.blockHash?t.blockHash:null,this.hash=t.hash,this.index=t.index,this.type=t.type,this.from=t.from,this.to=t.to||null,this.gasLimit=t.gasLimit,this.nonce=t.nonce,this.data=t.data,this.value=t.value,this.gasPrice=t.gasPrice,this.maxPriorityFeePerGas=null!=t.maxPriorityFeePerGas?t.maxPriorityFeePerGas:null,this.maxFeePerGas=null!=t.maxFeePerGas?t.maxFeePerGas:null,this.maxFeePerBlobGas=null!=t.maxFeePerBlobGas?t.maxFeePerBlobGas:null,this.chainId=t.chainId,this.signature=t.signature,this.accessList=null!=t.accessList?t.accessList:null,this.blobVersionedHashes=null!=t.blobVersionedHashes?t.blobVersionedHashes:null,this.authorizationList=null!=t.authorizationList?t.authorizationList:null,__privateSet(this,Yt,-1)}toJSON(){const{blockNumber:t,blockHash:e,index:r,hash:n,type:i,to:s,from:a,nonce:o,data:l,signature:c,accessList:u,blobVersionedHashes:h}=this;return{_type:"TransactionResponse",accessList:u,blockNumber:t,blockHash:e,blobVersionedHashes:h,chainId:_u(this.chainId),data:l,from:a,gasLimit:_u(this.gasLimit),gasPrice:_u(this.gasPrice),hash:n,maxFeePerGas:_u(this.maxFeePerGas),maxPriorityFeePerGas:_u(this.maxPriorityFeePerGas),maxFeePerBlobGas:_u(this.maxFeePerBlobGas),nonce:o,signature:c,to:s,index:r,type:i,value:_u(this.value)}}getBlock(){return __async(this,null,(function*(){let t=this.blockNumber;if(null==t){const e=yield this.getTransaction();e&&(t=e.blockNumber)}if(null==t)return null;const e=this.provider.getBlock(t);if(null==e)throw new Error("TODO");return e}))}getTransaction(){return __async(this,null,(function*(){return this.provider.getTransaction(this.hash)}))}confirmations(){return __async(this,null,(function*(){if(null==this.blockNumber){const{tx:t,blockNumber:e}=yield Cr({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return null==t||null==t.blockNumber?0:e-t.blockNumber+1}return(yield this.provider.getBlockNumber())-this.blockNumber+1}))}wait(t,e){return __async(this,null,(function*(){const r=null==t?1:t,n=null==e?0:e;let i=__privateGet(this,Yt),s=-1,a=-1===i;const o=()=>__async(this,null,(function*(){if(a)return null;const{blockNumber:t,nonce:e}=yield Cr({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(e<this.nonce)return void(i=t);if(a)return null;const n=yield this.getTransaction();if(!n||null==n.blockNumber)for(-1===s&&(s=i-3,s<__privateGet(this,Yt)&&(s=__privateGet(this,Yt)));s<=t;){if(a)return null;const e=yield this.provider.getBlock(s,!0);if(null==e)return;for(const t of e)if(t===this.hash)return;for(let n=0;n<e.length;n++){const s=yield e.getTransaction(n);if(s.from===this.from&&s.nonce===this.nonce){if(a)return null;const e=yield this.provider.getTransactionReceipt(s.hash);if(null==e)return;if(t-e.blockNumber+1<r)return;let n="replaced";s.data===this.data&&s.to===this.to&&s.value===this.value?n="repriced":"0x"===s.data&&s.from===s.to&&s.value===gu&&(n="cancelled"),Br(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:"replaced"===n||"cancelled"===n,reason:n,replacement:s.replaceableTransaction(i),hash:s.hash,receipt:e})}}s++}})),l=t=>{if(null==t||0!==t.status)return t;Br(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:t.to,from:t.from,data:""},receipt:t})},c=yield this.provider.getTransactionReceipt(this.hash);if(0===r)return l(c);if(c){if(1===r||(yield c.confirmations())>=r)return l(c)}else if(yield o(),0===r)return null;const u=new Promise(((t,e)=>{const s=[],c=()=>{s.forEach((t=>t()))};if(s.push((()=>{a=!0})),n>0){const t=setTimeout((()=>{c(),e(Ir("wait for transaction timeout","TIMEOUT"))}),n);s.push((()=>{clearTimeout(t)}))}const u=n=>__async(this,null,(function*(){if((yield n.confirmations())>=r){c();try{t(l(n))}catch(i){e(i)}}}));if(s.push((()=>{this.provider.off(this.hash,u)})),this.provider.on(this.hash,u),i>=0){const t=()=>__async(this,null,(function*(){try{yield o()}catch(r){if(Gr(r,"TRANSACTION_REPLACED"))return c(),void e(r)}a||this.provider.once("block",t)}));s.push((()=>{this.provider.off("block",t)})),this.provider.once("block",t)}}));return yield u}))}isMined(){return null!=this.blockHash}isLegacy(){return 0===this.type}isBerlin(){return 1===this.type}isLondon(){return 2===this.type}isCancun(){return 3===this.type}removedEvent(){return Br(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),ku(this)}reorderedEvent(t){return Br(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Br(!t||t.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),xu(this,t)}replaceableTransaction(e){Or(Number.isInteger(e)&&e>=0,"invalid startBlock","startBlock",e);const r=new t(this,this.provider);return __privateSet(r,Yt,e),r}};function xu(t,e){return{orphan:"reorder-transaction",tx:t,other:e}}function ku(t){return{orphan:"drop-transaction",tx:t}}class Su extends bu{constructor(t,e,r){super(t,t.provider),__publicField(this,"interface"),__publicField(this,"fragment"),__publicField(this,"args");Tr(this,{args:e.decodeEventLog(r,t.data,t.topics),fragment:r,interface:e})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class Nu extends bu{constructor(t,e){super(t,t.provider),__publicField(this,"error"),Tr(this,{error:e})}}class Pu extends Au{constructor(t,e,r){super(r,e),__privateAdd(this,Xt,void 0),__privateSet(this,Xt,t)}get logs(){return super.logs.map((t=>{const e=t.topics.length?__privateGet(this,Xt).getEvent(t.topics[0]):null;if(e)try{return new Su(t,__privateGet(this,Xt),e)}catch(r){return new Nu(t,r)}return t}))}}Xt=new WeakMap;$t=new WeakMap;let Cu=class t extends Eu{constructor(t,e,r){super(r,e),__privateAdd(this,$t,void 0),__privateSet(this,$t,t)}wait(e,r){return __async(this,null,(function*(){const n=yield __superGet(t.prototype,this,"wait").call(this,e,r);return null==n?null:new Pu(__privateGet(this,$t),this.provider,n)}))}};class Tu extends gn{constructor(t,e,r,n){super(t,e,r),__publicField(this,"log"),Tr(this,{log:n})}getBlock(){return __async(this,null,(function*(){return yield this.log.getBlock()}))}getTransaction(){return __async(this,null,(function*(){return yield this.log.getTransaction()}))}getTransactionReceipt(){return __async(this,null,(function*(){return yield this.log.getTransactionReceipt()}))}}class Ru extends Tu{constructor(t,e,r,n,i){super(t,e,r,new Su(i,t.interface,n));Tr(this,{args:t.interface.decodeEventLog(n,this.log.data,this.log.topics),fragment:n})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const Gu=BigInt(0);function Mu(t){return t&&"function"==typeof t.call}function Iu(t){return t&&"function"==typeof t.estimateGas}function Bu(t){return t&&"function"==typeof t.resolveName}function Ou(t){return t&&"function"==typeof t.sendTransaction}function Fu(t){if(null!=t){if(Bu(t))return t;if(t.provider)return t.provider}}class Uu{constructor(t,e,r){if(__privateAdd(this,te,void 0),__publicField(this,"fragment"),Tr(this,{fragment:e}),e.inputs.length<r.length)throw new Error("too many arguments");const n=Lu(t.runner,"resolveName"),i=Bu(n)?n:null;__privateSet(this,te,function(){return __async(this,null,(function*(){const n=yield Promise.all(e.inputs.map(((t,e)=>null==r[e]?null:t.walkAsync(r[e],((t,e)=>"address"===t?Array.isArray(e)?Promise.all(e.map((t=>Ka(t,i)))):Ka(e,i):e)))));return t.interface.encodeFilterTopics(e,n)}))}())}getTopicFilter(){return __privateGet(this,te)}}function Lu(t,e){return null==t?null:"function"==typeof t[e]?t:t.provider&&"function"==typeof t.provider[e]?t.provider:null}function Du(t){return null==t?null:t.provider||null}function ju(t,e){return __async(this,null,(function*(){const r=$a.dereference(t,"overrides");Or("object"==typeof r,"invalid overrides parameter","overrides",t);const n=vu(r);return Or(null==n.to||(e||[]).indexOf("to")>=0,"cannot override to","overrides.to",n.to),Or(null==n.data||(e||[]).indexOf("data")>=0,"cannot override data","overrides.data",n.data),n.from&&(n.from=n.from),n}))}function Hu(t){const e=function(e){return __async(this,null,(function*(){const r=yield ju(e,["data"]);r.to=yield t.getAddress(),r.from&&(r.from=yield Ka(r.from,Fu(t.runner)));const n=t.interface,i=sn(r.value||Gu,"overrides.value")===Gu,s="0x"===(r.data||"0x");!n.fallback||n.fallback.payable||!n.receive||s||i||Or(!1,"cannot send data to receive or send value to non-payable fallback","overrides",e),Or(n.fallback||s,"cannot send data to receive-only contract","overrides.data",r.data);return Or(n.receive||n.fallback&&n.fallback.payable||i,"cannot send value to non-payable fallback","overrides.value",r.value),Or(n.fallback||s,"cannot send data to receive-only contract","overrides.data",r.data),r}))},r=function(r){return __async(this,null,(function*(){const n=t.runner;Br(Ou(n),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const i=yield n.sendTransaction(yield e(r)),s=Du(t.runner);return new Cu(t.interface,s,i)}))},n=t=>__async(this,null,(function*(){return yield r(t)}));return Tr(n,{_contract:t,estimateGas:function(r){return __async(this,null,(function*(){const n=Lu(t.runner,"estimateGas");return Br(Iu(n),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),yield n.estimateGas(yield e(r))}))},populateTransaction:e,send:r,staticCall:function(r){return __async(this,null,(function*(){const n=Lu(t.runner,"call");Br(Mu(n),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const i=yield e(r);try{return yield n.call(i)}catch(s){if(Mr(s)&&s.data)throw t.interface.makeError(s.data,i);throw s}}))}}),n}function Wu(t,e){const r=function(...r){const n=t.interface.getFunction(e,r);return Br(n,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:r}}),n},n=function(...e){return __async(this,null,(function*(){const n=r(...e);let i={};if(n.inputs.length+1===e.length&&(i=yield ju(e.pop()),i.from&&(i.from=yield Ka(i.from,Fu(t.runner)))),n.inputs.length!==e.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const s=yield function(t,e,r){return __async(this,null,(function*(){const n=Lu(t,"resolveName"),i=Bu(n)?n:null;return yield Promise.all(e.map(((t,e)=>t.walkAsync(r[e],((t,e)=>(e=$a.dereference(e,t),"address"===t?Ka(e,i):e))))))}))}(t.runner,n.inputs,e);return Object.assign({},i,yield Cr({to:t.getAddress(),data:t.interface.encodeFunctionData(n,s)}))}))},i=function(...t){return __async(this,null,(function*(){const e=yield a(...t);return 1===e.length?e[0]:e}))},s=function(...e){return __async(this,null,(function*(){const r=t.runner;Br(Ou(r),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const i=yield r.sendTransaction(yield n(...e)),s=Du(t.runner);return new Cu(t.interface,s,i)}))},a=function(...e){return __async(this,null,(function*(){const i=Lu(t.runner,"call");Br(Mu(i),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const s=yield n(...e);let a="0x";try{a=yield i.call(s)}catch(l){if(Mr(l)&&l.data)throw t.interface.makeError(l.data,s);throw l}const o=r(...e);return t.interface.decodeFunctionResult(o,a)}))},o=(...t)=>__async(this,null,(function*(){return r(...t).constant?yield i(...t):yield s(...t)}));return Tr(o,{name:t.interface.getFunctionName(e),_contract:t,_key:e,getFragment:r,estimateGas:function(...e){return __async(this,null,(function*(){const r=Lu(t.runner,"estimateGas");return Br(Iu(r),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),yield r.estimateGas(yield n(...e))}))},populateTransaction:n,send:s,staticCall:i,staticCallResult:a}),Object.defineProperty(o,"fragment",{configurable:!1,enumerable:!0,get:()=>{const r=t.interface.getFunction(e);return Br(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),r}}),o}te=new WeakMap;const Qu=Symbol.for("_ethersInternal_contract"),zu=new WeakMap;function Vu(t){return zu.get(t[Qu])}function Ju(t,e){return __async(this,null,(function*(){let r,n=null;if(Array.isArray(e)){const n=function(e){if(Wr(e,32))return e;const r=t.interface.getEvent(e);return Or(r,"unknown fragment","name",e),r.topicHash};r=e.map((t=>null==t?null:Array.isArray(t)?t.map(n):n(t)))}else"*"===e?r=[null]:"string"==typeof e?Wr(e,32)?r=[e]:(n=t.interface.getEvent(e),Or(n,"unknown fragment","event",e),r=[n.topicHash]):(i=e)&&"object"==typeof i&&"getTopicFilter"in i&&"function"==typeof i.getTopicFilter&&i.fragment?r=yield e.getTopicFilter():"fragment"in e?(n=e.fragment,r=[n.topicHash]):Or(!1,"unknown event name","event",e);var i;r=r.map((t=>{if(null==t)return null;if(Array.isArray(t)){const e=Array.from(new Set(t.map((t=>t.toLowerCase()))).values());return 1===e.length?e[0]:(e.sort(),e)}return t.toLowerCase()}));return{fragment:n,tag:r.map((t=>null==t?"null":Array.isArray(t)?t.join("|"):t)).join("&"),topics:r}}))}function Ku(t,e){return __async(this,null,(function*(){const{subs:r}=Vu(t);return r.get((yield Ju(t,e)).tag)||null}))}function qu(t,e,r){return __async(this,null,(function*(){const n=Du(t.runner);Br(n,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:i,tag:s,topics:a}=yield Ju(t,r),{addr:o,subs:l}=Vu(t);let c=l.get(s);if(!c){const e={address:o||t,topics:a},u=e=>{let n=i;if(null==n)try{n=t.interface.getEvent(e.topics[0])}catch(s){}if(n){const s=n,a=i?t.interface.decodeEventLog(i,e.data,e.topics):[];Yu(t,r,a,(n=>new Ru(t,n,r,s,e)))}else Yu(t,r,[],(n=>new Tu(t,n,r,e)))};let h=[];c={tag:s,listeners:[],start:()=>{h.length||h.push(n.on(e,u))},stop:()=>__async(this,null,(function*(){if(0==h.length)return;let t=h;h=[],yield Promise.all(t),n.off(e,u)}))},l.set(s,c)}return c}))}let Zu=Promise.resolve();function Yu(t,e,r,n){return __async(this,null,(function*(){try{yield Zu}catch(s){}const i=function(t,e,r,n){return __async(this,null,(function*(){yield Zu;const i=yield Ku(t,e);if(!i)return!1;const a=i.listeners.length;return i.listeners=i.listeners.filter((({listener:e,once:i})=>{const a=Array.from(r);n&&a.push(n(i?null:e));try{e.call(t,...a)}catch(s){}return!i})),0===i.listeners.length&&(i.stop(),Vu(t).subs.delete(i.tag)),a>0}))}(t,e,r,n);return Zu=i,yield i}))}const Xu=["then"];ee=Qu;let $u=class t{constructor(t,e,r,n){__publicField(this,"target"),__publicField(this,"interface"),__publicField(this,"runner"),__publicField(this,"filters"),__publicField(this,ee),__publicField(this,"fallback"),Or("string"==typeof t||Va(t),"invalid value for Contract target","target",t),null==r&&(r=null);const i=fu.from(e);let s;Tr(this,{target:t,runner:r,interface:i}),Object.defineProperty(this,Qu,{value:{}});let a=null,o=null;if(n){const t=Du(r);o=new Cu(this.interface,t,n)}let l=new Map;if("string"==typeof t)if(Wr(t))a=t,s=Promise.resolve(t);else{const e=Lu(r,"resolveName");if(!Bu(e))throw Ir("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});s=e.resolveName(t).then((e=>{if(null==e)throw Ir("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:t});return Vu(this).addr=e,e}))}else s=t.getAddress().then((t=>{if(null==t)throw new Error("TODO");return Vu(this).addr=t,t}));var c,u;c=this,u={addrPromise:s,addr:a,deployTx:o,subs:l},zu.set(c[Qu],u);return Tr(this,{filters:new Proxy({},{get:(t,e,r)=>{if("symbol"==typeof e||Xu.indexOf(e)>=0)return Reflect.get(t,e,r);try{return this.getEvent(e)}catch(n){if(!Gr(n,"INVALID_ARGUMENT")||"key"!==n.argument)throw n}},has:(t,e)=>Xu.indexOf(e)>=0?Reflect.has(t,e):Reflect.has(t,e)||this.interface.hasEvent(String(e))})}),Tr(this,{fallback:i.receive||i.fallback?Hu(this):null}),new Proxy(this,{get:(t,e,r)=>{if("symbol"==typeof e||e in t||Xu.indexOf(e)>=0)return Reflect.get(t,e,r);try{return t.getFunction(e)}catch(n){if(!Gr(n,"INVALID_ARGUMENT")||"key"!==n.argument)throw n}},has:(t,e)=>"symbol"==typeof e||e in t||Xu.indexOf(e)>=0?Reflect.has(t,e):t.interface.hasFunction(e)})}connect(e){return new t(this.target,this.interface,e)}attach(e){return new t(e,this.interface,this.runner)}getAddress(){return __async(this,null,(function*(){return yield Vu(this).addrPromise}))}getDeployedCode(){return __async(this,null,(function*(){const t=Du(this.runner);Br(t,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const e=yield t.getCode(yield this.getAddress());return"0x"===e?null:e}))}waitForDeployment(){return __async(this,null,(function*(){const t=this.deploymentTransaction();if(t)return yield t.wait(),this;if(null!=(yield this.getDeployedCode()))return this;const e=Du(this.runner);return Br(null!=e,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise(((t,r)=>{const n=()=>__async(this,null,(function*(){try{if(null!=(yield this.getDeployedCode()))return t(this);e.once("block",n)}catch(i){r(i)}}));n()}))}))}deploymentTransaction(){return Vu(this).deployTx}getFunction(t){"string"!=typeof t&&(t=t.format());return Wu(this,t)}getEvent(t){return"string"!=typeof t&&(t=t.format()),function(t,e){const r=function(...r){const n=t.interface.getEvent(e,r);return Br(n,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:r}}),n},n=function(...e){return new Uu(t,r(...e),e)};return Tr(n,{name:t.interface.getEventName(e),_contract:t,_key:e,getFragment:r}),Object.defineProperty(n,"fragment",{configurable:!1,enumerable:!0,get:()=>{const r=t.interface.getEvent(e);return Br(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),r}}),n}(this,t)}queryTransaction(t){return __async(this,null,(function*(){throw new Error("@TODO")}))}queryFilter(t,e,r){return __async(this,null,(function*(){null==e&&(e=0),null==r&&(r="latest");const{addr:n,addrPromise:i}=Vu(this),s=n||(yield i),{fragment:a,topics:o}=yield Ju(this,t),l={address:s,topics:o,fromBlock:e,toBlock:r},c=Du(this.runner);return Br(c,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(yield c.getLogs(l)).map((t=>{let e=a;if(null==e)try{e=this.interface.getEvent(t.topics[0])}catch(r){}if(e)try{return new Su(t,this.interface,e)}catch(r){return new Nu(t,r)}return new bu(t,c)}))}))}on(t,e){return __async(this,null,(function*(){const r=yield qu(this,"on",t);return r.listeners.push({listener:e,once:!1}),r.start(),this}))}once(t,e){return __async(this,null,(function*(){const r=yield qu(this,"once",t);return r.listeners.push({listener:e,once:!0}),r.start(),this}))}emit(t,...e){return __async(this,null,(function*(){return yield Yu(this,t,e,null)}))}listenerCount(t){return __async(this,null,(function*(){if(t){const e=yield Ku(this,t);return e?e.listeners.length:0}const{subs:e}=Vu(this);let r=0;for(const{listeners:t}of e.values())r+=t.length;return r}))}listeners(t){return __async(this,null,(function*(){if(t){const e=yield Ku(this,t);return e?e.listeners.map((({listener:t})=>t)):[]}const{subs:e}=Vu(this);let r=[];for(const{listeners:t}of e.values())r=r.concat(t.map((({listener:t})=>t)));return r}))}off(t,e){return __async(this,null,(function*(){const r=yield Ku(this,t);if(!r)return this;if(e){const t=r.listeners.map((({listener:t})=>t)).indexOf(e);t>=0&&r.listeners.splice(t,1)}return null!=e&&0!==r.listeners.length||(r.stop(),Vu(this).subs.delete(r.tag)),this}))}removeAllListeners(t){return __async(this,null,(function*(){if(t){const e=yield Ku(this,t);if(!e)return this;e.stop(),Vu(this).subs.delete(e.tag)}else{const{subs:t}=Vu(this);for(const{tag:e,stop:r}of t.values())r(),t.delete(e)}return this}))}addListener(t,e){return __async(this,null,(function*(){return yield this.on(t,e)}))}removeListener(t,e){return __async(this,null,(function*(){return yield this.off(t,e)}))}static buildClass(e){return class extends t{constructor(t,r=null){super(t,e,r)}}}static from(t,e,r){null==r&&(r=null);return new this(t,e,r)}};class th extends(function(){return $u}()){}function eh(t){return t.match(/^ipfs:\/\/ipfs\//i)?t=t.substring(12):t.match(/^ipfs:\/\//i)?t=t.substring(7):Or(!1,"unsupported IPFS format","link",t),`https://gateway.ipfs.io/ipfs/${t}`}class rh{constructor(t){__publicField(this,"name"),Tr(this,{name:t})}connect(t){return this}supportsCoinType(t){return!1}encodeAddress(t,e){return __async(this,null,(function*(){throw new Error("unsupported coin")}))}decodeAddress(t,e){return __async(this,null,(function*(){throw new Error("unsupported coin")}))}}const nh=new RegExp("^(ipfs)://(.*)$","i"),ih=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),nh,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")],sh=class t{constructor(t,e,r){__privateAdd(this,ie),__publicField(this,"provider"),__publicField(this,"address"),__publicField(this,"name"),__privateAdd(this,re,void 0),__privateAdd(this,ne,void 0),Tr(this,{provider:t,address:e,name:r}),__privateSet(this,re,null),__privateSet(this,ne,new th(e,["function supportsInterface(bytes4) view returns (bool)","function resolve(bytes, bytes) view returns (bytes)","function addr(bytes32) view returns (address)","function addr(bytes32, uint) view returns (bytes)","function text(bytes32, string) view returns (string)","function contenthash(bytes32) view returns (bytes)"],t))}supportsWildcard(){return __async(this,null,(function*(){return null==__privateGet(this,re)&&__privateSet(this,re,(()=>__async(this,null,(function*(){try{return yield __privateGet(this,ne).supportsInterface("0x9061b923")}catch(t){if(Gr(t,"CALL_EXCEPTION"))return!1;throw __privateSet(this,re,null),t}})))()),yield __privateGet(this,re)}))}getAddress(t){return __async(this,null,(function*(){if(null==t&&(t=60),60===t)try{const t=yield __privateMethod(this,ie,se).call(this,"addr(bytes32)");return null==t||t===Na?null:t}catch(i){if(Gr(i,"CALL_EXCEPTION"))return null;throw i}if(t>=0&&t<2147483648){let e=t+2147483648;const r=yield __privateMethod(this,ie,se).call(this,"addr(bytes32,uint)",[e]);if(Wr(r,20))return za(r)}let e=null;for(const s of this.provider.plugins)if(s instanceof rh&&s.supportsCoinType(t)){e=s;break}if(null==e)return null;const r=yield __privateMethod(this,ie,se).call(this,"addr(bytes32,uint)",[t]);if(null==r||"0x"===r)return null;const n=yield e.decodeAddress(t,r);if(null!=n)return n;Br(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${t})`,info:{coinType:t,data:r}})}))}getText(t){return __async(this,null,(function*(){const e=yield __privateMethod(this,ie,se).call(this,"text(bytes32,string)",[t]);return null==e||"0x"===e?null:e}))}getContentHash(){return __async(this,null,(function*(){const t=yield __privateMethod(this,ie,se).call(this,"contenthash(bytes32)");if(null==t||"0x"===t)return null;const e=t.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(e){const t="e3010170"===e[1]?"ipfs":"ipns",r=parseInt(e[4],16);if(e[5].length===2*r)return`${t}://${function(t){const e=jr(t);let r=ln(e),n="";for(;r;)n=pn[Number(r%fn)]+n,r/=fn;for(let i=0;i<e.length&&!e[i];i++)n=pn[0]+n;return n}("0x"+e[2])}`}const r=t.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(r&&64===r[1].length)return`bzz://${r[1]}`;Br(!1,"invalid or unsupported content hash data","UNSUPPORTED_OPERATION",{operation:"getContentHash()",info:{data:t}})}))}getAvatar(){return __async(this,null,(function*(){return(yield this._getAvatar()).url}))}_getAvatar(){return __async(this,null,(function*(){const t=[{type:"name",value:this.name}];try{const n=yield this.getText("avatar");if(null==n)return t.push({type:"!avatar",value:""}),{url:null,linkage:t};t.push({type:"avatar",value:n});for(let i=0;i<ih.length;i++){const s=n.match(ih[i]);if(null==s)continue;const a=s[1].toLowerCase();switch(a){case"https":case"data":return t.push({type:"url",value:n}),{linkage:t,url:n};case"ipfs":{const e=eh(n);return t.push({type:"ipfs",value:n}),t.push({type:"url",value:e}),{linkage:t,url:e}}case"erc721":case"erc1155":{const i="erc721"===a?"tokenURI(uint256)":"uri(uint256)";t.push({type:a,value:n});const o=yield this.getAddress();if(null==o)return t.push({type:"!owner",value:""}),{url:null,linkage:t};const l=(s[2]||"").split("/");if(2!==l.length)return t.push({type:`!${a}caip`,value:s[2]||""}),{url:null,linkage:t};const c=l[1],u=new th(l[0],["function tokenURI(uint) view returns (string)","function ownerOf(uint) view returns (address)","function uri(uint) view returns (string)","function balanceOf(address, uint256) view returns (uint)"],this.provider);if("erc721"===a){const e=yield u.ownerOf(c);if(o!==e)return t.push({type:"!owner",value:e}),{url:null,linkage:t};t.push({type:"owner",value:e})}else if("erc1155"===a){const e=yield u.balanceOf(o,c);if(!e)return t.push({type:"!balance",value:"0"}),{url:null,linkage:t};t.push({type:"balance",value:e.toString()})}let h=yield u[i](c);if(null==h||"0x"===h)return t.push({type:"!metadata-url",value:""}),{url:null,linkage:t};t.push({type:"metadata-url-base",value:h}),"erc1155"===a&&(h=h.replace("{id}",un(c,32).substring(2)),t.push({type:"metadata-url-expanded",value:h})),h.match(/^ipfs:/i)&&(h=eh(h)),t.push({type:"metadata-url",value:h});let d={};const p=yield new Gn(h).send();p.assertOk();try{d=p.bodyJson}catch(e){try{t.push({type:"!metadata",value:p.bodyText})}catch(r){const e=p.body;return e&&t.push({type:"!metadata",value:Vr(e)}),{url:null,linkage:t}}return{url:null,linkage:t}}if(!d)return t.push({type:"!metadata",value:""}),{url:null,linkage:t};t.push({type:"metadata",value:JSON.stringify(d)});let f=d.image;if("string"!=typeof f)return t.push({type:"!imageUrl",value:""}),{url:null,linkage:t};if(f.match(/^(https:\/\/|data:)/i));else{if(null==f.match(nh))return t.push({type:"!imageUrl-ipfs",value:f}),{url:null,linkage:t};t.push({type:"imageUrl-ipfs",value:f}),f=eh(f)}return t.push({type:"url",value:f}),{linkage:t,url:f}}}}}catch(e){}return{linkage:t,url:null}}))}static getEnsAddress(t){return __async(this,null,(function*(){const e=yield t.getNetwork(),r=e.getPlugin("org.ethers.plugins.network.Ens");return Br(r,"network does not support ENS","UNSUPPORTED_OPERATION",{operation:"getEnsAddress",info:{network:e}}),r.address}))}static fromName(e,r){return __async(this,null,(function*(){var n;let i=r;for(;;){if(""===i||"."===i)return null;if("eth"!==r&&"eth"===i)return null;const s=yield __privateMethod(n=t,ae,oe).call(n,e,i);if(null!=s){const n=new t(e,s,r);return i===r||(yield n.supportsWildcard())?n:null}i=i.split(".").slice(1).join(".")}}))}};re=new WeakMap,ne=new WeakMap,ie=new WeakSet,se=function(t,e){return __async(this,null,(function*(){e=(e||[]).slice();const r=__privateGet(this,ne).interface;e.unshift(Jl(this.name));let n=null;(yield this.supportsWildcard())&&(n=r.getFunction(t),Br(n,"missing fragment","UNKNOWN_ERROR",{info:{funcName:t}}),e=[Kl(this.name,255),r.encodeFunctionData(n,e)],t="resolve(bytes,bytes)"),e.push({enableCcipRead:!0});try{const i=yield __privateGet(this,ne)[t](...e);return n?r.decodeFunctionResult(n,i)[0]:i}catch(i){if(!Gr(i,"CALL_EXCEPTION"))throw i}return null}))},ae=new WeakSet,oe=function(t,e){return __async(this,null,(function*(){const r=yield sh.getEnsAddress(t);try{const n=new th(r,["function resolver(bytes32) view returns (address)"],t),i=yield n.resolver(Jl(e),{enableCcipRead:!0});return i===Na?null:i}catch(n){throw n}return null}))},__privateAdd(sh,ae);let ah=sh;const oh=BigInt(0);function lh(t,e){return function(r){return null==r?e:t(r)}}function ch(t,e){return r=>{if(e&&null==r)return null;if(!Array.isArray(r))throw new Error("not an array");return r.map((e=>t(e)))}}function uh(t,e){return r=>{const n={};for(const s in t){let a=s;if(e&&s in e&&!(a in r))for(const t of e[s])if(t in r){a=t;break}try{const e=t[s](r[a]);void 0!==e&&(n[s]=e)}catch(i){Br(!1,`invalid value for value.${s} (${i instanceof Error?i.message:"not-an-error"})`,"BAD_DATA",{value:r})}}return n}}function hh(t){return Or(Wr(t,!0),"invalid data","value",t),t}function dh(t){return Or(Wr(t,32),"invalid hash","value",t),t}const ph=uh({address:za,blockHash:dh,blockNumber:cn,data:hh,index:cn,removed:lh((function(t){switch(t){case!0:case"true":return!0;case!1:case"false":return!1}Or(!1,`invalid boolean; ${JSON.stringify(t)}`,"value",t)}),!1),topics:ch(dh),transactionHash:dh,transactionIndex:cn},{index:["logIndex"]});const fh=uh({hash:lh(dh),parentHash:dh,parentBeaconBlockRoot:lh(dh,null),number:cn,timestamp:cn,nonce:lh(hh),difficulty:sn,gasLimit:sn,gasUsed:sn,stateRoot:lh(dh,null),receiptsRoot:lh(dh,null),blobGasUsed:lh(sn,null),excessBlobGas:lh(sn,null),miner:lh(za),prevRandao:lh(dh,null),extraData:hh,baseFeePerGas:lh(sn)},{prevRandao:["mixHash"]});const gh=uh({transactionIndex:cn,blockNumber:cn,transactionHash:dh,address:za,topics:ch(dh),data:hh,index:cn,blockHash:dh},{index:["logIndex"]});const mh=uh({to:lh(za,null),from:lh(za,null),contractAddress:lh(za,null),index:cn,root:lh(Vr),gasUsed:sn,blobGasUsed:lh(sn,null),logsBloom:lh(hh),blockHash:dh,hash:dh,logs:ch((function(t){return gh(t)})),blockNumber:cn,cumulativeGasUsed:sn,effectiveGasPrice:lh(sn),blobGasPrice:lh(sn,null),status:lh(cn),type:lh(cn,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function _h(t){t.to&&sn(t.to)===oh&&(t.to="0x0000000000000000000000000000000000000000");const e=uh({hash:dh,index:lh(cn,void 0),type:t=>"0x"===t||null==t?0:cn(t),accessList:lh(vo,null),blobVersionedHashes:lh(ch(dh,!0),null),authorizationList:lh(ch((t=>{let e;if(t.signature)e=t.signature;else{let r=t.yParity;"0x1b"===r?r=0:"0x1c"===r&&(r=1),e=Object.assign({},t,{yParity:r})}return{address:za(t.address),chainId:sn(t.chainId),nonce:sn(t.nonce),signature:Ua.from(e)}}),!1),null),blockHash:lh(dh,null),blockNumber:lh(cn,null),transactionIndex:lh(cn,null),from:za,gasPrice:lh(sn),maxPriorityFeePerGas:lh(sn),maxFeePerGas:lh(sn),maxFeePerBlobGas:lh(sn,null),gasLimit:sn,to:lh(za,null),value:sn,nonce:cn,data:hh,creates:lh(za,null),chainId:lh(sn,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(t);if(null==e.to&&null==e.creates&&(e.creates=function(t){const e=za(t.from);let r=sn(t.nonce,"tx.nonce").toString(16);return r="0"===r?"0x":r.length%2?"0x0"+r:"0x"+r,za(qr(vs(ei([e,r])),12))}(e)),1!==t.type&&2!==t.type||null!=t.accessList||(e.accessList=[]),t.signature?e.signature=Ua.from(t.signature):e.signature=Ua.from(t),null==e.chainId){const t=e.signature.legacyChainId;null!=t&&(e.chainId=t)}return e.blockHash&&sn(e.blockHash)===oh&&(e.blockHash=null),e}class yh{constructor(t){__publicField(this,"name"),Tr(this,{name:t})}clone(){return new yh(this.name)}}class vh extends yh{constructor(t,e){null==t&&(t=0),super(`org.ethers.network.plugins.GasCost#${t||0}`),__publicField(this,"effectiveBlock"),__publicField(this,"txBase"),__publicField(this,"txCreate"),__publicField(this,"txDataZero"),__publicField(this,"txDataNonzero"),__publicField(this,"txAccessListStorageKey"),__publicField(this,"txAccessListAddress");const r={effectiveBlock:t};function n(t,n){let i=(e||{})[t];null==i&&(i=n),Or("number"==typeof i,`invalud value for ${t}`,"costs",e),r[t]=i}n("txBase",21e3),n("txCreate",32e3),n("txDataZero",4),n("txDataNonzero",16),n("txAccessListStorageKey",1900),n("txAccessListAddress",2400),Tr(this,r)}clone(){return new vh(this.effectiveBlock,this)}}class wh extends yh{constructor(t,e){super("org.ethers.plugins.network.Ens"),__publicField(this,"address"),__publicField(this,"targetNetwork"),Tr(this,{address:t||"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",targetNetwork:null==e?1:e})}clone(){return new wh(this.address,this.targetNetwork)}}class bh extends yh{constructor(t,e){super("org.ethers.plugins.network.FetchUrlFeeDataPlugin"),__privateAdd(this,le,void 0),__privateAdd(this,ce,void 0),__privateSet(this,le,t),__privateSet(this,ce,e)}get url(){return __privateGet(this,le)}get processFunc(){return __privateGet(this,ce)}clone(){return this}}le=new WeakMap,ce=new WeakMap;const Ah=new Map;ue=new WeakMap,he=new WeakMap,de=new WeakMap;let Eh=class t{constructor(t,e){__privateAdd(this,ue,void 0),__privateAdd(this,he,void 0),__privateAdd(this,de,void 0),__privateSet(this,ue,t),__privateSet(this,he,sn(e)),__privateSet(this,de,new Map)}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return __privateGet(this,ue)}set name(t){__privateSet(this,ue,t)}get chainId(){return __privateGet(this,he)}set chainId(t){__privateSet(this,he,sn(t,"chainId"))}matches(t){if(null==t)return!1;if("string"==typeof t){try{return this.chainId===sn(t)}catch(e){}return this.name===t}if("number"==typeof t||"bigint"==typeof t){try{return this.chainId===sn(t)}catch(e){}return!1}if("object"==typeof t){if(null!=t.chainId){try{return this.chainId===sn(t.chainId)}catch(e){}return!1}return null!=t.name&&this.name===t.name}return!1}get plugins(){return Array.from(__privateGet(this,de).values())}attachPlugin(t){if(__privateGet(this,de).get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return __privateGet(this,de).set(t.name,t.clone()),this}getPlugin(t){return __privateGet(this,de).get(t)||null}getPlugins(t){return this.plugins.filter((e=>e.name.split("#")[0]===t))}clone(){const e=new t(this.name,this.chainId);return this.plugins.forEach((t=>{e.attachPlugin(t.clone())})),e}computeIntrinsicGas(t){const e=this.getPlugin("org.ethers.plugins.network.GasCost")||new vh;let r=e.txBase;if(null==t.to&&(r+=e.txCreate),t.data)for(let n=2;n<t.data.length;n+=2)"00"===t.data.substring(n,n+2)?r+=e.txDataZero:r+=e.txDataNonzero;if(t.accessList){const n=vo(t.accessList);for(const t in n)r+=e.txAccessListAddress+e.txAccessListStorageKey*n[t].storageKeys.length}return r}static from(e){if(function(){if(Sh)return;function t(t,e,r){const n=function(){const n=new Eh(t,e);return null!=r.ensNetwork&&n.attachPlugin(new wh(null,r.ensNetwork)),n.attachPlugin(new vh),(r.plugins||[]).forEach((t=>{n.attachPlugin(t)})),n};Eh.register(t,n),Eh.register(e,n),r.altNames&&r.altNames.forEach((t=>{Eh.register(t,n)}))}Sh=!0,t("mainnet",1,{ensNetwork:1,altNames:["homestead"]}),t("ropsten",3,{ensNetwork:3}),t("rinkeby",4,{ensNetwork:4}),t("goerli",5,{ensNetwork:5}),t("kovan",42,{ensNetwork:42}),t("sepolia",11155111,{ensNetwork:11155111}),t("holesky",17e3,{ensNetwork:17e3}),t("classic",61,{}),t("classicKotti",6,{}),t("arbitrum",42161,{ensNetwork:1}),t("arbitrum-goerli",421613,{}),t("arbitrum-sepolia",421614,{}),t("base",8453,{ensNetwork:1}),t("base-goerli",84531,{}),t("base-sepolia",84532,{}),t("bnb",56,{ensNetwork:1}),t("bnbt",97,{}),t("linea",59144,{ensNetwork:1}),t("linea-goerli",59140,{}),t("linea-sepolia",59141,{}),t("matic",137,{ensNetwork:1,plugins:[kh("https://gasstation.polygon.technology/v2")]}),t("matic-amoy",80002,{}),t("matic-mumbai",80001,{altNames:["maticMumbai","maticmum"],plugins:[kh("https://gasstation-testnet.polygon.technology/v2")]}),t("optimism",10,{ensNetwork:1,plugins:[]}),t("optimism-goerli",420,{}),t("optimism-sepolia",11155420,{}),t("xdai",100,{ensNetwork:1})}(),null==e)return t.from("mainnet");if("number"==typeof e&&(e=BigInt(e)),"string"==typeof e||"bigint"==typeof e){const r=Ah.get(e);if(r)return r();if("bigint"==typeof e)return new t("unknown",e);Or(!1,"unknown network","network",e)}if("function"==typeof e.clone){return e.clone()}if("object"==typeof e){Or("string"==typeof e.name&&"number"==typeof e.chainId,"invalid network object name or chainId","network",e);const r=new t(e.name,e.chainId);return(e.ensAddress||null!=e.ensNetwork)&&r.attachPlugin(new wh(e.ensAddress,e.ensNetwork)),r}Or(!1,"invalid network","network",e)}static register(t,e){"number"==typeof t&&(t=BigInt(t));const r=Ah.get(t);r&&Or(!1,`conflicting network for ${JSON.stringify(r.name)}`,"nameOrChainId",t),Ah.set(t,e)}};function xh(t,e){const r=String(t);if(!r.match(/^[0-9.]+$/))throw new Error(`invalid gwei value: ${t}`);const n=r.split(".");if(1===n.length&&n.push(""),2!==n.length)throw new Error(`invalid gwei value: ${t}`);for(;n[1].length<e;)n[1]+="0";if(n[1].length>9){let t=BigInt(n[1].substring(0,9));n[1].substring(9).match(/^0+$/)||t++,n[1]=t.toString()}return BigInt(n[0]+n[1])}function kh(t){return new bh(t,((t,e,r)=>__async(this,null,(function*(){let e;r.setHeader("User-Agent","ethers");try{const[n,i]=yield Promise.all([r.send(),t()]);e=n;const s=e.bodyJson.standard;return{gasPrice:i.gasPrice,maxFeePerGas:xh(s.maxFee,9),maxPriorityFeePerGas:xh(s.maxPriorityFee,9)}}catch(n){Br(!1,`error encountered with polygon gas station (${JSON.stringify(r.url)})`,"SERVER_ERROR",{request:r,response:e,error:n})}}))))}let Sh=!1;function Nh(t){return JSON.parse(JSON.stringify(t))}class Ph{constructor(t){__privateAdd(this,_e),__privateAdd(this,pe,void 0),__privateAdd(this,fe,void 0),__privateAdd(this,ge,void 0),__privateAdd(this,me,void 0),__privateSet(this,pe,t),__privateSet(this,fe,null),__privateSet(this,ge,4e3),__privateSet(this,me,-2)}get pollingInterval(){return __privateGet(this,ge)}set pollingInterval(t){__privateSet(this,ge,t)}start(){__privateGet(this,fe)||(__privateSet(this,fe,__privateGet(this,pe)._setTimeout(__privateMethod(this,_e,ye).bind(this),__privateGet(this,ge))),__privateMethod(this,_e,ye).call(this))}stop(){__privateGet(this,fe)&&(__privateGet(this,pe)._clearTimeout(__privateGet(this,fe)),__privateSet(this,fe,null))}pause(t){this.stop(),t&&__privateSet(this,me,-2)}resume(){this.start()}}pe=new WeakMap,fe=new WeakMap,ge=new WeakMap,me=new WeakMap,_e=new WeakSet,ye=function(){return __async(this,null,(function*(){try{const t=yield __privateGet(this,pe).getBlockNumber();if(-2===__privateGet(this,me))return void __privateSet(this,me,t);if(t!==__privateGet(this,me)){for(let e=__privateGet(this,me)+1;e<=t;e++){if(null==__privateGet(this,fe))return;yield __privateGet(this,pe).emit("block",e)}__privateSet(this,me,t)}}catch(t){}null!=__privateGet(this,fe)&&__privateSet(this,fe,__privateGet(this,pe)._setTimeout(__privateMethod(this,_e,ye).bind(this),__privateGet(this,ge)))}))};class Ch{constructor(t){__privateAdd(this,ve,void 0),__privateAdd(this,we,void 0),__privateAdd(this,be,void 0),__privateSet(this,ve,t),__privateSet(this,be,!1),__privateSet(this,we,(t=>{this._poll(t,__privateGet(this,ve))}))}_poll(t,e){return __async(this,null,(function*(){throw new Error("sub-classes must override this")}))}start(){__privateGet(this,be)||(__privateSet(this,be,!0),__privateGet(this,we).call(this,-2),__privateGet(this,ve).on("block",__privateGet(this,we)))}stop(){__privateGet(this,be)&&(__privateSet(this,be,!1),__privateGet(this,ve).off("block",__privateGet(this,we)))}pause(t){this.stop()}resume(){this.start()}}ve=new WeakMap,we=new WeakMap,be=new WeakMap;class Th extends Ch{constructor(t,e){super(t),__privateAdd(this,Ae,void 0),__privateAdd(this,Ee,void 0),__privateSet(this,Ae,e),__privateSet(this,Ee,-2)}pause(t){t&&__privateSet(this,Ee,-2),super.pause(t)}_poll(t,e){return __async(this,null,(function*(){const t=yield e.getBlock(__privateGet(this,Ae));null!=t&&(-2===__privateGet(this,Ee)?__privateSet(this,Ee,t.number):t.number>__privateGet(this,Ee)&&(e.emit(__privateGet(this,Ae),t.number),__privateSet(this,Ee,t.number)))}))}}Ae=new WeakMap,Ee=new WeakMap;class Rh extends Ch{constructor(t,e){super(t),__privateAdd(this,xe,void 0),__privateSet(this,xe,Nh(e))}_poll(t,e){return __async(this,null,(function*(){throw new Error("@TODO")}))}}xe=new WeakMap;class Gh extends Ch{constructor(t,e){super(t),__privateAdd(this,ke,void 0),__privateSet(this,ke,e)}_poll(t,e){return __async(this,null,(function*(){const t=yield e.getTransactionReceipt(__privateGet(this,ke));t&&e.emit(__privateGet(this,ke),t)}))}}ke=new WeakMap;class Mh{constructor(t,e){__privateAdd(this,Re),__privateAdd(this,Se,void 0),__privateAdd(this,Ne,void 0),__privateAdd(this,Pe,void 0),__privateAdd(this,Ce,void 0),__privateAdd(this,Te,void 0),__privateSet(this,Se,t),__privateSet(this,Ne,Nh(e)),__privateSet(this,Pe,__privateMethod(this,Re,Ge).bind(this)),__privateSet(this,Ce,!1),__privateSet(this,Te,-2)}start(){__privateGet(this,Ce)||(__privateSet(this,Ce,!0),-2===__privateGet(this,Te)&&__privateGet(this,Se).getBlockNumber().then((t=>{__privateSet(this,Te,t)})),__privateGet(this,Se).on("block",__privateGet(this,Pe)))}stop(){__privateGet(this,Ce)&&(__privateSet(this,Ce,!1),__privateGet(this,Se).off("block",__privateGet(this,Pe)))}pause(t){this.stop(),t&&__privateSet(this,Te,-2)}resume(){this.start()}}Se=new WeakMap,Ne=new WeakMap,Pe=new WeakMap,Ce=new WeakMap,Te=new WeakMap,Re=new WeakSet,Ge=function(t){return __async(this,null,(function*(){if(-2===__privateGet(this,Te))return;const e=Nh(__privateGet(this,Ne));e.fromBlock=__privateGet(this,Te)+1,e.toBlock=t;const r=yield __privateGet(this,Se).getLogs(e);if(0!==r.length)for(const t of r)__privateGet(this,Se).emit(__privateGet(this,Ne),t),__privateSet(this,Te,t.blockNumber);else __privateGet(this,Te)<t-60&&__privateSet(this,Te,t-60)}))};const Ih=BigInt(2);function Bh(t){return t&&"function"==typeof t.then}function Oh(t,e){return t+":"+JSON.stringify(e,((t,e)=>{if(null==e)return"null";if("bigint"==typeof e)return`bigint:${e.toString()}`;if("string"==typeof e)return e.toLowerCase();if("object"==typeof e&&!Array.isArray(e)){const t=Object.keys(e);return t.sort(),t.reduce(((t,r)=>(t[r]=e[r],t)),{})}return e}))}class Fh{constructor(t){__publicField(this,"name"),Tr(this,{name:t})}start(){}stop(){}pause(t){}resume(){}}function Uh(t){return(t=Array.from(new Set(t).values())).sort(),t}function Lh(t,e){return __async(this,null,(function*(){if(null==t)throw new Error("invalid event");if(Array.isArray(t)&&(t={topics:t}),"string"==typeof t)switch(t){case"block":case"debug":case"error":case"finalized":case"network":case"pending":case"safe":return{type:t,tag:t}}if(Wr(t,32)){const e=t.toLowerCase();return{type:"transaction",tag:Oh("tx",{hash:e}),hash:e}}if(t.orphan){const e=t;return{type:"orphan",tag:Oh("orphan",e),filter:(r=e,JSON.parse(JSON.stringify(r)))}}var r;if(t.address||t.topics){const r=t,n={topics:(r.topics||[]).map((t=>null==t?null:Array.isArray(t)?Uh(t.map((t=>t.toLowerCase()))):t.toLowerCase()))};if(r.address){const t=[],i=[],s=r=>{Wr(r)?t.push(r):i.push((()=>__async(this,null,(function*(){t.push(yield Ka(r,e))})))())};Array.isArray(r.address)?r.address.forEach(s):s(r.address),i.length&&(yield Promise.all(i)),n.address=Uh(t.map((t=>t.toLowerCase())))}return{filter:n,tag:Oh("event",n),type:"event"}}Or(!1,"unknown ProviderEvent","event",t)}))}function Dh(){return(new Date).getTime()}const jh={cacheTimeout:250,pollingInterval:4e3};class Hh{constructor(t,e){if(__privateAdd(this,ze),__privateAdd(this,Je),__privateAdd(this,qe),__privateAdd(this,Ye),__privateAdd(this,$e),__privateAdd(this,er),__privateAdd(this,nr),__privateAdd(this,Me,void 0),__privateAdd(this,Ie,void 0),__privateAdd(this,Be,void 0),__privateAdd(this,Oe,void 0),__privateAdd(this,Fe,void 0),__privateAdd(this,Ue,void 0),__privateAdd(this,Le,void 0),__privateAdd(this,De,void 0),__privateAdd(this,je,void 0),__privateAdd(this,He,void 0),__privateAdd(this,We,void 0),__privateAdd(this,Qe,void 0),__privateSet(this,Qe,Object.assign({},jh,e||{})),"any"===t)__privateSet(this,Ue,!0),__privateSet(this,Fe,null);else if(t){const e=Eh.from(t);__privateSet(this,Ue,!1),__privateSet(this,Fe,Promise.resolve(e)),setTimeout((()=>{this.emit("network",e,null)}),0)}else __privateSet(this,Ue,!1),__privateSet(this,Fe,null);__privateSet(this,De,-1),__privateSet(this,Le,new Map),__privateSet(this,Me,new Map),__privateSet(this,Ie,new Map),__privateSet(this,Be,null),__privateSet(this,Oe,!1),__privateSet(this,je,1),__privateSet(this,He,new Map),__privateSet(this,We,!1)}get pollingInterval(){return __privateGet(this,Qe).pollingInterval}get provider(){return this}get plugins(){return Array.from(__privateGet(this,Ie).values())}attachPlugin(t){if(__privateGet(this,Ie).get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return __privateGet(this,Ie).set(t.name,t.connect(this)),this}getPlugin(t){return __privateGet(this,Ie).get(t)||null}get disableCcipRead(){return __privateGet(this,We)}set disableCcipRead(t){__privateSet(this,We,!!t)}ccipReadFetch(t,e,r){return __async(this,null,(function*(){if(this.disableCcipRead||0===r.length||null==t.to)return null;const n=t.to.toLowerCase(),i=e.toLowerCase(),s=[];for(let e=0;e<r.length;e++){const o=r[e],l=o.replace("{sender}",n).replace("{data}",i),c=new Gn(l);-1===o.indexOf("{data}")&&(c.body={data:i,sender:n}),this.emit("debug",{action:"sendCcipReadFetchRequest",request:c,index:e,urls:r});let u,h="unknown error";try{u=yield c.send()}catch(a){s.push(a.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:c,result:{error:a}});continue}try{const t=u.bodyJson;if(t.data)return this.emit("debug",{action:"receiveCcipReadFetchResult",request:c,result:t}),t.data;t.message&&(h=t.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:c,result:t})}catch(a){}Br(u.statusCode<400||u.statusCode>=500,`response not found during CCIP fetch: ${h}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:t,info:{url:o,errorMessage:h}}),s.push(h)}Br(!1,`error encountered during CCIP fetch: ${s.map((t=>JSON.stringify(t))).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:t,info:{urls:r,errorMessages:s}})}))}_wrapBlock(t,e){return new wu(function(t){const e=fh(t);return e.transactions=t.transactions.map((t=>"string"==typeof t?t:_h(t))),e}(t),this)}_wrapLog(t,e){return new bu(function(t){return ph(t)}(t),this)}_wrapTransactionReceipt(t,e){return new Au(function(t){return mh(t)}(t),this)}_wrapTransactionResponse(t,e){return new Eu(_h(t),this)}_detectNetwork(){Br(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}_perform(t){return __async(this,null,(function*(){Br(!1,`unsupported method: ${t.method}`,"UNSUPPORTED_OPERATION",{operation:t.method,info:t})}))}getBlockNumber(){return __async(this,null,(function*(){const t=cn(yield __privateMethod(this,ze,Ve).call(this,{method:"getBlockNumber"}),"%response");return __privateGet(this,De)>=0&&__privateSet(this,De,t),t}))}_getAddress(t){return Ka(t,this)}_getBlockTag(t){if(null==t)return"latest";switch(t){case"earliest":return"0x0";case"finalized":case"latest":case"pending":case"safe":return t}return Wr(t)?Wr(t,32)?t:dn(t):("bigint"==typeof t&&(t=cn(t,"blockTag")),"number"==typeof t?t>=0?dn(t):__privateGet(this,De)>=0?dn(__privateGet(this,De)+t):this.getBlockNumber().then((e=>dn(e+t))):void Or(!1,"invalid blockTag","blockTag",t))}_getFilter(t){const e=(t.topics||[]).map((t=>null==t?null:Array.isArray(t)?Uh(t.map((t=>t.toLowerCase()))):t.toLowerCase())),r="blockHash"in t?t.blockHash:void 0,n=(t,n,i)=>{let s;switch(t.length){case 0:break;case 1:s=t[0];break;default:t.sort(),s=t}if(r&&(null!=n||null!=i))throw new Error("invalid filter");const a={};return s&&(a.address=s),e.length&&(a.topics=e),n&&(a.fromBlock=n),i&&(a.toBlock=i),r&&(a.blockHash=r),a};let i,s,a=[];if(t.address)if(Array.isArray(t.address))for(const o of t.address)a.push(this._getAddress(o));else a.push(this._getAddress(t.address));return"fromBlock"in t&&(i=this._getBlockTag(t.fromBlock)),"toBlock"in t&&(s=this._getBlockTag(t.toBlock)),a.filter((t=>"string"!=typeof t)).length||null!=i&&"string"!=typeof i||null!=s&&"string"!=typeof s?Promise.all([Promise.all(a),i,s]).then((t=>n(t[0],t[1],t[2]))):n(a,i,s)}_getTransactionRequest(t){const e=vu(t),r=[];if(["to","from"].forEach((t=>{if(null==e[t])return;const n=Ka(e[t],this);Bh(n)?r.push(function(){return __async(this,null,(function*(){e[t]=yield n}))}()):e[t]=n})),null!=e.blockTag){const t=this._getBlockTag(e.blockTag);Bh(t)?r.push(function(){return __async(this,null,(function*(){e.blockTag=yield t}))}()):e.blockTag=t}return r.length?function(){return __async(this,null,(function*(){return yield Promise.all(r),e}))}():e}getNetwork(){return __async(this,null,(function*(){if(null==__privateGet(this,Fe)){const t=(()=>__async(this,null,(function*(){try{const t=yield this._detectNetwork();return this.emit("network",t,null),t}catch(e){throw __privateGet(this,Fe)===t&&__privateSet(this,Fe,null),e}})))();return __privateSet(this,Fe,t),(yield t).clone()}const t=__privateGet(this,Fe),[e,r]=yield Promise.all([t,this._detectNetwork()]);return e.chainId!==r.chainId&&(__privateGet(this,Ue)?(this.emit("network",r,e),__privateGet(this,Fe)===t&&__privateSet(this,Fe,Promise.resolve(r))):Br(!1,`network changed: ${e.chainId} => ${r.chainId} `,"NETWORK_ERROR",{event:"changed"})),e.clone()}))}getFeeData(){return __async(this,null,(function*(){const t=yield this.getNetwork(),e=()=>__async(this,null,(function*(){const{_block:e,gasPrice:r,priorityFee:n}=yield Cr({_block:__privateMethod(this,$e,tr).call(this,"latest",!1),gasPrice:(()=>__async(this,null,(function*(){try{return sn(yield __privateMethod(this,ze,Ve).call(this,{method:"getGasPrice"}),"%response")}catch(t){}return null})))(),priorityFee:(()=>__async(this,null,(function*(){try{return sn(yield __privateMethod(this,ze,Ve).call(this,{method:"getPriorityFee"}),"%response")}catch(t){}return null})))()});let i=null,s=null;const a=this._wrapBlock(e,t);return a&&a.baseFeePerGas&&(s=null!=n?n:BigInt("1000000000"),i=a.baseFeePerGas*Ih+s),new yu(r,i,s)})),r=t.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(r){const t=new Gn(r.url),n=yield r.processFunc(e,this,t);return new yu(n.gasPrice,n.maxFeePerGas,n.maxPriorityFeePerGas)}return yield e()}))}estimateGas(t){return __async(this,null,(function*(){let e=this._getTransactionRequest(t);return Bh(e)&&(e=yield e),sn(yield __privateMethod(this,ze,Ve).call(this,{method:"estimateGas",transaction:e}),"%response")}))}call(t){return __async(this,null,(function*(){const{tx:e,blockTag:r}=yield Cr({tx:this._getTransactionRequest(t),blockTag:this._getBlockTag(t.blockTag)});return yield __privateMethod(this,qe,Ze).call(this,__privateMethod(this,Je,Ke).call(this,e,r,t.enableCcipRead?0:-1))}))}getBalance(t,e){return __async(this,null,(function*(){return sn(yield __privateMethod(this,Ye,Xe).call(this,{method:"getBalance"},t,e),"%response")}))}getTransactionCount(t,e){return __async(this,null,(function*(){return cn(yield __privateMethod(this,Ye,Xe).call(this,{method:"getTransactionCount"},t,e),"%response")}))}getCode(t,e){return __async(this,null,(function*(){return Vr(yield __privateMethod(this,Ye,Xe).call(this,{method:"getCode"},t,e))}))}getStorage(t,e,r){return __async(this,null,(function*(){const n=sn(e,"position");return Vr(yield __privateMethod(this,Ye,Xe).call(this,{method:"getStorage",position:n},t,r))}))}broadcastTransaction(t){return __async(this,null,(function*(){const{blockNumber:e,hash:r,network:n}=yield Cr({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:t}),network:this.getNetwork()}),i=Lo.from(t);if(i.hash!==r)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(i,n).replaceableTransaction(e)}))}getBlock(t,e){return __async(this,null,(function*(){const{network:r,params:n}=yield Cr({network:this.getNetwork(),params:__privateMethod(this,$e,tr).call(this,t,!!e)});return null==n?null:this._wrapBlock(n,r)}))}getTransaction(t){return __async(this,null,(function*(){const{network:e,params:r}=yield Cr({network:this.getNetwork(),params:__privateMethod(this,ze,Ve).call(this,{method:"getTransaction",hash:t})});return null==r?null:this._wrapTransactionResponse(r,e)}))}getTransactionReceipt(t){return __async(this,null,(function*(){const{network:e,params:r}=yield Cr({network:this.getNetwork(),params:__privateMethod(this,ze,Ve).call(this,{method:"getTransactionReceipt",hash:t})});if(null==r)return null;if(null==r.gasPrice&&null==r.effectiveGasPrice){const e=yield __privateMethod(this,ze,Ve).call(this,{method:"getTransaction",hash:t});if(null==e)throw new Error("report this; could not find tx or effectiveGasPrice");r.effectiveGasPrice=e.gasPrice}return this._wrapTransactionReceipt(r,e)}))}getTransactionResult(t){return __async(this,null,(function*(){const{result:e}=yield Cr({network:this.getNetwork(),result:__privateMethod(this,ze,Ve).call(this,{method:"getTransactionResult",hash:t})});return null==e?null:Vr(e)}))}getLogs(t){return __async(this,null,(function*(){let e=this._getFilter(t);Bh(e)&&(e=yield e);const{network:r,params:n}=yield Cr({network:this.getNetwork(),params:__privateMethod(this,ze,Ve).call(this,{method:"getLogs",filter:e})});return n.map((t=>this._wrapLog(t,r)))}))}_getProvider(t){Br(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}getResolver(t){return __async(this,null,(function*(){return yield ah.fromName(this,t)}))}getAvatar(t){return __async(this,null,(function*(){const e=yield this.getResolver(t);return e?yield e.getAvatar():null}))}resolveName(t){return __async(this,null,(function*(){const e=yield this.getResolver(t);return e?yield e.getAddress():null}))}lookupAddress(t){return __async(this,null,(function*(){const e=Jl((t=za(t)).substring(2).toLowerCase()+".addr.reverse");try{const r=yield ah.getEnsAddress(this),n=new th(r,["function resolver(bytes32) view returns (address)"],this),i=yield n.resolver(e);if(null==i||i===Na)return null;const s=new th(i,["function name(bytes32) view returns (string)"],this),a=yield s.name(e);return(yield this.resolveName(a))!==t?null:a}catch(r){if(Gr(r,"BAD_DATA")&&"0x"===r.value)return null;if(Gr(r,"CALL_EXCEPTION"))return null;throw r}return null}))}waitForTransaction(t,e,r){return __async(this,null,(function*(){const n=null!=e?e:1;return 0===n?this.getTransactionReceipt(t):new Promise(((e,i)=>__async(this,null,(function*(){let s=null;const a=r=>__async(this,null,(function*(){try{const i=yield this.getTransactionReceipt(t);if(null!=i&&r-i.blockNumber+1>=n)return e(i),void(s&&(clearTimeout(s),s=null))}catch(i){console.log("EEE",i)}this.once("block",a)}));null!=r&&(s=setTimeout((()=>{null!=s&&(s=null,this.off("block",a),i(Ir("timeout","TIMEOUT",{reason:"timeout"})))}),r)),a(yield this.getBlockNumber())}))))}))}waitForBlock(t){return __async(this,null,(function*(){Br(!1,"not implemented yet","NOT_IMPLEMENTED",{operation:"waitForBlock"})}))}_clearTimeout(t){const e=__privateGet(this,He).get(t);e&&(e.timer&&clearTimeout(e.timer),__privateGet(this,He).delete(t))}_setTimeout(t,e){null==e&&(e=0);const r=__privateWrapper(this,je)._++,n=()=>{__privateGet(this,He).delete(r),t()};if(this.paused)__privateGet(this,He).set(r,{timer:null,func:n,time:e});else{const t=setTimeout(n,e);__privateGet(this,He).set(r,{timer:t,func:n,time:Dh()})}return r}_forEachSubscriber(t){for(const e of __privateGet(this,Me).values())t(e.subscriber)}_getSubscriber(t){switch(t.type){case"debug":case"error":case"network":return new Fh(t.type);case"block":{const t=new Ph(this);return t.pollingInterval=this.pollingInterval,t}case"safe":case"finalized":return new Th(this,t.type);case"event":return new Mh(this,t.filter);case"transaction":return new Gh(this,t.hash);case"orphan":return new Rh(this,t.filter)}throw new Error(`unsupported event: ${t.type}`)}_recoverSubscriber(t,e){for(const r of __privateGet(this,Me).values())if(r.subscriber===t){r.started&&r.subscriber.stop(),r.subscriber=e,r.started&&e.start(),null!=__privateGet(this,Be)&&e.pause(__privateGet(this,Be));break}}on(t,e){return __async(this,null,(function*(){const r=yield __privateMethod(this,nr,ir).call(this,t);return r.listeners.push({listener:e,once:!1}),r.started||(r.subscriber.start(),r.started=!0,null!=__privateGet(this,Be)&&r.subscriber.pause(__privateGet(this,Be))),this}))}once(t,e){return __async(this,null,(function*(){const r=yield __privateMethod(this,nr,ir).call(this,t);return r.listeners.push({listener:e,once:!0}),r.started||(r.subscriber.start(),r.started=!0,null!=__privateGet(this,Be)&&r.subscriber.pause(__privateGet(this,Be))),this}))}emit(t,...e){return __async(this,null,(function*(){const r=yield __privateMethod(this,er,rr).call(this,t,e);if(!r||0===r.listeners.length)return!1;const n=r.listeners.length;return r.listeners=r.listeners.filter((({listener:r,once:n})=>{const i=new gn(this,n?null:r,t);try{r.call(this,...e,i)}catch(s){}return!n})),0===r.listeners.length&&(r.started&&r.subscriber.stop(),__privateGet(this,Me).delete(r.tag)),n>0}))}listenerCount(t){return __async(this,null,(function*(){if(t){const e=yield __privateMethod(this,er,rr).call(this,t);return e?e.listeners.length:0}let e=0;for(const{listeners:t}of __privateGet(this,Me).values())e+=t.length;return e}))}listeners(t){return __async(this,null,(function*(){if(t){const e=yield __privateMethod(this,er,rr).call(this,t);return e?e.listeners.map((({listener:t})=>t)):[]}let e=[];for(const{listeners:t}of __privateGet(this,Me).values())e=e.concat(t.map((({listener:t})=>t)));return e}))}off(t,e){return __async(this,null,(function*(){const r=yield __privateMethod(this,er,rr).call(this,t);if(!r)return this;if(e){const t=r.listeners.map((({listener:t})=>t)).indexOf(e);t>=0&&r.listeners.splice(t,1)}return e&&0!==r.listeners.length||(r.started&&r.subscriber.stop(),__privateGet(this,Me).delete(r.tag)),this}))}removeAllListeners(t){return __async(this,null,(function*(){if(t){const{tag:e,started:r,subscriber:n}=yield __privateMethod(this,nr,ir).call(this,t);r&&n.stop(),__privateGet(this,Me).delete(e)}else for(const[t,{started:e,subscriber:r}]of __privateGet(this,Me))e&&r.stop(),__privateGet(this,Me).delete(t);return this}))}addListener(t,e){return __async(this,null,(function*(){return yield this.on(t,e)}))}removeListener(t,e){return __async(this,null,(function*(){return this.off(t,e)}))}get destroyed(){return __privateGet(this,Oe)}destroy(){this.removeAllListeners();for(const t of __privateGet(this,He).keys())this._clearTimeout(t);__privateSet(this,Oe,!0)}get paused(){return null!=__privateGet(this,Be)}set paused(t){!!t!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(t){if(__privateSet(this,De,-1),null!=__privateGet(this,Be)){if(__privateGet(this,Be)==!!t)return;Br(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber((e=>e.pause(t))),__privateSet(this,Be,!!t);for(const e of __privateGet(this,He).values())e.timer&&clearTimeout(e.timer),e.time=Dh()-e.time}resume(){if(null!=__privateGet(this,Be)){this._forEachSubscriber((t=>t.resume())),__privateSet(this,Be,null);for(const t of __privateGet(this,He).values()){let e=t.time;e<0&&(e=0),t.time=Dh(),setTimeout(t.func,e)}}}}function Wh(t,e){try{const r=Qh(t,e);if(r)return vn(r)}catch(r){}return null}function Qh(t,e){if("0x"===t)return null;try{const r=cn(qr(t,e,e+32)),n=cn(qr(t,r,r+32));return qr(t,r+32,r+32+n)}catch(r){}return null}function zh(t){const e=hn(t);if(e.length>32)throw new Error("internal; should not happen");const r=new Uint8Array(32);return r.set(e,32-e.length),r}function Vh(t){if(t.length%32==0)return t;const e=new Uint8Array(32*Math.ceil(t.length/32));return e.set(t),e}Me=new WeakMap,Ie=new WeakMap,Be=new WeakMap,Oe=new WeakMap,Fe=new WeakMap,Ue=new WeakMap,Le=new WeakMap,De=new WeakMap,je=new WeakMap,He=new WeakMap,We=new WeakMap,Qe=new WeakMap,ze=new WeakSet,Ve=function(t){return __async(this,null,(function*(){const e=__privateGet(this,Qe).cacheTimeout;if(e<0)return yield this._perform(t);const r=Oh(t.method,t);let n=__privateGet(this,Le).get(r);return n||(n=this._perform(t),__privateGet(this,Le).set(r,n),setTimeout((()=>{__privateGet(this,Le).get(r)===n&&__privateGet(this,Le).delete(r)}),e)),yield n}))},Je=new WeakSet,Ke=function(t,e,r){return __async(this,null,(function*(){Br(r<10,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},t,{blockTag:e,enableCcipRead:!0})});const n=vu(t);try{return Vr(yield this._perform({method:"call",transaction:n,blockTag:e}))}catch(i){if(!this.disableCcipRead&&Mr(i)&&i.data&&r>=0&&"latest"===e&&null!=n.to&&"0x556f1830"===qr(i.data,0,4)){const t=i.data,a=yield Ka(n.to,this);let o;try{o=function(t){const e={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};Br(Kr(t)>=160,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const r=qr(t,0,32);Br(qr(r,0,12)===qr(qh,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),e.sender=qr(r,12);try{const r=[],n=cn(qr(t,32,64)),i=cn(qr(t,n,n+32)),s=qr(t,n+32);for(let t=0;t<i;t++){const e=Wh(s,32*t);if(null==e)throw new Error("abort");r.push(e)}e.urls=r}catch(i){Br(!1,"corrupt OffchainLookup urls","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup urls"})}try{const r=Qh(t,64);if(null==r)throw new Error("abort");e.calldata=r}catch(i){Br(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}Br(qr(t,100,128)===qr(qh,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),e.selector=qr(t,96,100);try{const r=Qh(t,128);if(null==r)throw new Error("abort");e.extraData=r}catch(i){Br(!1,"corrupt OffchainLookup extraData","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup extraData"})}return e.errorArgs="sender,urls,calldata,selector,extraData".split(/,/).map((t=>e[t])),e}(qr(i.data,4))}catch(s){Br(!1,s.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:n,info:{data:t}})}Br(o.sender.toLowerCase()===a.toLowerCase(),"CCIP Read sender mismatch","CALL_EXCEPTION",{action:"call",data:t,reason:"OffchainLookup",transaction:n,invocation:null,revert:{signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",name:"OffchainLookup",args:o.errorArgs}});const l=yield this.ccipReadFetch(n,o.calldata,o.urls);Br(null!=l,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:n,info:{data:i.data,errorArgs:o.errorArgs}});const c={to:a,data:Jr([o.selector,Kh([l,o.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:c});try{const t=yield __privateMethod(this,Je,Ke).call(this,c,e,r+1);return this.emit("debug",{action:"receiveCcipReadCallResult",transaction:Object.assign({},c),result:t}),t}catch(s){throw this.emit("debug",{action:"receiveCcipReadCallError",transaction:Object.assign({},c),error:s}),s}}throw i}}))},qe=new WeakSet,Ze=function(t){return __async(this,null,(function*(){const{value:e}=yield Cr({network:this.getNetwork(),value:t});return e}))},Ye=new WeakSet,Xe=function(t,e,r){return __async(this,null,(function*(){let n=this._getAddress(e),i=this._getBlockTag(r);return"string"==typeof n&&"string"==typeof i||([n,i]=yield Promise.all([n,i])),yield __privateMethod(this,qe,Ze).call(this,__privateMethod(this,ze,Ve).call(this,Object.assign(t,{address:n,blockTag:i})))}))},$e=new WeakSet,tr=function(t,e){return __async(this,null,(function*(){if(Wr(t,32))return yield __privateMethod(this,ze,Ve).call(this,{method:"getBlock",blockHash:t,includeTransactions:e});let r=this._getBlockTag(t);return"string"!=typeof r&&(r=yield r),yield __privateMethod(this,ze,Ve).call(this,{method:"getBlock",blockTag:r,includeTransactions:e})}))},er=new WeakSet,rr=function(t,e){return __async(this,null,(function*(){let r=yield Lh(t,this);return"event"===r.type&&e&&e.length>0&&!0===e[0].removed&&(r=yield Lh({orphan:"drop-log",log:e[0]},this)),__privateGet(this,Me).get(r.tag)||null}))},nr=new WeakSet,ir=function(t){return __async(this,null,(function*(){const e=yield Lh(t,this),r=e.tag;let n=__privateGet(this,Me).get(r);if(!n){n={subscriber:this._getSubscriber(e),tag:r,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},__privateGet(this,Me).set(r,n)}return n}))};const Jh=new Uint8Array([]);function Kh(t){const e=[];let r=0;for(let n=0;n<t.length;n++)e.push(Jh),r+=32;for(let n=0;n<t.length;n++){const i=jr(t[n]);e[n]=zh(r),e.push(zh(i.length)),e.push(Vh(i)),r+=32+32*Math.ceil(i.length/32)}return Jr(e)}const qh="0x0000000000000000000000000000000000000000000000000000000000000000";function Zh(t,e){if(t.provider)return t.provider;Br(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}function Yh(t,e){return __async(this,null,(function*(){let r=vu(e);if(null!=r.to&&(r.to=Ka(r.to,t)),null!=r.from){const e=r.from;r.from=Promise.all([t.getAddress(),Ka(e,t)]).then((([t,e])=>(Or(t.toLowerCase()===e.toLowerCase(),"transaction from mismatch","tx.from",e),t)))}else r.from=t.getAddress();return yield Cr(r)}))}class Xh{constructor(t){__publicField(this,"provider"),Tr(this,{provider:t||null})}getNonce(t){return __async(this,null,(function*(){return Zh(this,"getTransactionCount").getTransactionCount(yield this.getAddress(),t)}))}populateCall(t){return __async(this,null,(function*(){return yield Yh(this,t)}))}populateTransaction(t){return __async(this,null,(function*(){const e=Zh(this,"populateTransaction"),r=yield Yh(this,t);null==r.nonce&&(r.nonce=yield this.getNonce("pending")),null==r.gasLimit&&(r.gasLimit=yield this.estimateGas(r));const n=yield this.provider.getNetwork();if(null!=r.chainId){Or(sn(r.chainId)===n.chainId,"transaction chainId mismatch","tx.chainId",t.chainId)}else r.chainId=n.chainId;const i=null!=r.maxFeePerGas||null!=r.maxPriorityFeePerGas;if(null==r.gasPrice||2!==r.type&&!i?0!==r.type&&1!==r.type||!i||Or(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",t):Or(!1,"eip-1559 transaction do not support gasPrice","tx",t),2!==r.type&&null!=r.type||null==r.maxFeePerGas||null==r.maxPriorityFeePerGas)if(0===r.type||1===r.type){const t=yield e.getFeeData();Br(null!=t.gasPrice,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),null==r.gasPrice&&(r.gasPrice=t.gasPrice)}else{const t=yield e.getFeeData();if(null==r.type)if(null!=t.maxFeePerGas&&null!=t.maxPriorityFeePerGas)if(r.authorizationList&&r.authorizationList.length?r.type=4:r.type=2,null!=r.gasPrice){const t=r.gasPrice;delete r.gasPrice,r.maxFeePerGas=t,r.maxPriorityFeePerGas=t}else null==r.maxFeePerGas&&(r.maxFeePerGas=t.maxFeePerGas),null==r.maxPriorityFeePerGas&&(r.maxPriorityFeePerGas=t.maxPriorityFeePerGas);else null!=t.gasPrice?(Br(!i,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),null==r.gasPrice&&(r.gasPrice=t.gasPrice),r.type=0):Br(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else 2!==r.type&&3!==r.type&&4!==r.type||(null==r.maxFeePerGas&&(r.maxFeePerGas=t.maxFeePerGas),null==r.maxPriorityFeePerGas&&(r.maxPriorityFeePerGas=t.maxPriorityFeePerGas))}else r.type=2;return yield Cr(r)}))}populateAuthorization(t){return __async(this,null,(function*(){const e=Object.assign({},t);return null==e.chainId&&(e.chainId=(yield Zh(this,"getNetwork").getNetwork()).chainId),null==e.nonce&&(e.nonce=yield this.getNonce()),e}))}estimateGas(t){return __async(this,null,(function*(){return Zh(this,"estimateGas").estimateGas(yield this.populateCall(t))}))}call(t){return __async(this,null,(function*(){return Zh(this,"call").call(yield this.populateCall(t))}))}resolveName(t){return __async(this,null,(function*(){const e=Zh(this,"resolveName");return yield e.resolveName(t)}))}sendTransaction(t){return __async(this,null,(function*(){const e=Zh(this,"sendTransaction"),r=yield this.populateTransaction(t);delete r.from;const n=Lo.from(r);return yield e.broadcastTransaction(yield this.signTransaction(n))}))}authorize(t){Br(!1,"authorization not implemented for this signer","UNSUPPORTED_OPERATION",{operation:"authorize"})}}class $h{constructor(t){__privateAdd(this,hr),__privateAdd(this,pr),__privateAdd(this,sr,void 0),__privateAdd(this,ar,void 0),__privateAdd(this,or,void 0),__privateAdd(this,lr,void 0),__privateAdd(this,cr,void 0),__privateAdd(this,ur,void 0),__privateSet(this,sr,t),__privateSet(this,ar,null),__privateSet(this,or,__privateMethod(this,hr,dr).bind(this)),__privateSet(this,lr,!1),__privateSet(this,cr,null),__privateSet(this,ur,!1)}_subscribe(t){throw new Error("subclasses must override this")}_emitResults(t,e){throw new Error("subclasses must override this")}_recover(t){throw new Error("subclasses must override this")}start(){__privateGet(this,lr)||(__privateSet(this,lr,!0),__privateMethod(this,hr,dr).call(this,-2))}stop(){__privateGet(this,lr)&&(__privateSet(this,lr,!1),__privateSet(this,ur,!0),__privateMethod(this,pr,fr).call(this),__privateGet(this,sr).off("block",__privateGet(this,or)))}pause(t){t&&__privateMethod(this,pr,fr).call(this),__privateGet(this,sr).off("block",__privateGet(this,or))}resume(){this.start()}}sr=new WeakMap,ar=new WeakMap,or=new WeakMap,lr=new WeakMap,cr=new WeakMap,ur=new WeakMap,hr=new WeakSet,dr=function(t){return __async(this,null,(function*(){try{null==__privateGet(this,ar)&&__privateSet(this,ar,this._subscribe(__privateGet(this,sr)));let e=null;try{e=yield __privateGet(this,ar)}catch(t){if(!Gr(t,"UNSUPPORTED_OPERATION")||"eth_newFilter"!==t.operation)throw t}if(null==e)return __privateSet(this,ar,null),void __privateGet(this,sr)._recoverSubscriber(this,this._recover(__privateGet(this,sr)));const r=yield __privateGet(this,sr).getNetwork();if(__privateGet(this,cr)||__privateSet(this,cr,r),__privateGet(this,cr).chainId!==r.chainId)throw new Error("chaid changed");if(__privateGet(this,ur))return;const n=yield __privateGet(this,sr).send("eth_getFilterChanges",[e]);yield this._emitResults(__privateGet(this,sr),n)}catch(t){console.log("@TODO",t)}__privateGet(this,sr).once("block",__privateGet(this,or))}))},pr=new WeakSet,fr=function(){const t=__privateGet(this,ar);t&&(__privateSet(this,ar,null),t.then((t=>{__privateGet(this,sr).destroyed||__privateGet(this,sr).send("eth_uninstallFilter",[t])})))};class td extends $h{constructor(t,e){var r;super(t),__privateAdd(this,gr,void 0),__privateSet(this,gr,(r=e,JSON.parse(JSON.stringify(r))))}_recover(t){return new Mh(t,__privateGet(this,gr))}_subscribe(t){return __async(this,null,(function*(){return yield t.send("eth_newFilter",[__privateGet(this,gr)])}))}_emitResults(t,e){return __async(this,null,(function*(){for(const r of e)t.emit(__privateGet(this,gr),t._wrapLog(r,t._network))}))}}gr=new WeakMap;class ed extends $h{_subscribe(t){return __async(this,null,(function*(){return yield t.send("eth_newPendingTransactionFilter",[])}))}_emitResults(t,e){return __async(this,null,(function*(){for(const r of e)t.emit("pending",r)}))}}const rd="bigint,boolean,function,number,string,symbol".split(/,/g);function nd(t){if(null==t||rd.indexOf(typeof t)>=0)return t;if("function"==typeof t.getAddress)return t;if(Array.isArray(t))return t.map(nd);if("object"==typeof t)return Object.keys(t).reduce(((e,r)=>(e[r]=t[r],e)),{});throw new Error(`should not happen: ${t} (${typeof t})`)}function id(t){return new Promise((e=>{setTimeout(e,t)}))}function sd(t){return t?t.toLowerCase():t}function ad(t){return t&&"number"==typeof t.pollingInterval}const od={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3};class ld extends Xh{constructor(t,e){super(t),__publicField(this,"address"),Tr(this,{address:e=za(e)})}connect(t){Br(!1,"cannot reconnect JsonRpcSigner","UNSUPPORTED_OPERATION",{operation:"signer.connect"})}getAddress(){return __async(this,null,(function*(){return this.address}))}populateTransaction(t){return __async(this,null,(function*(){return yield this.populateCall(t)}))}sendUncheckedTransaction(t){return __async(this,null,(function*(){const e=nd(t),r=[];if(e.from){const n=e.from;r.push((()=>__async(this,null,(function*(){const r=yield Ka(n,this.provider);Or(null!=r&&r.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),e.from=r})))())}else e.from=this.address;if(null==e.gasLimit&&r.push((()=>__async(this,null,(function*(){e.gasLimit=yield this.provider.estimateGas(__spreadProps(__spreadValues({},e),{from:this.address}))})))()),null!=e.to){const t=e.to;r.push((()=>__async(this,null,(function*(){e.to=yield Ka(t,this.provider)})))())}r.length&&(yield Promise.all(r));const n=this.provider.getRpcTransaction(e);return this.provider.send("eth_sendTransaction",[n])}))}sendTransaction(t){return __async(this,null,(function*(){const e=yield this.provider.getBlockNumber(),r=yield this.sendUncheckedTransaction(t);return yield new Promise(((t,n)=>{const i=[1e3,100];let s=0;const a=()=>__async(this,null,(function*(){try{const n=yield this.provider.getTransaction(r);if(null!=n)return void t(n.replaceableTransaction(e))}catch(o){if(Gr(o,"CANCELLED")||Gr(o,"BAD_DATA")||Gr(o,"NETWORK_ERROR")||Gr(o,"UNSUPPORTED_OPERATION"))return null==o.info&&(o.info={}),o.info.sendTransactionHash=r,void n(o);if(Gr(o,"INVALID_ARGUMENT")&&(s++,null==o.info&&(o.info={}),o.info.sendTransactionHash=r,s>10))return void n(o);this.provider.emit("error",Ir("failed to fetch transation after sending (will try again)","UNKNOWN_ERROR",{error:o}))}this.provider._setTimeout((()=>{a()}),i.pop()||4e3)}));a()}))}))}signTransaction(t){return __async(this,null,(function*(){const e=nd(t);if(e.from){const r=yield Ka(e.from,this.provider);Or(null!=r&&r.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),e.from=r}else e.from=this.address;const r=this.provider.getRpcTransaction(e);return yield this.provider.send("eth_signTransaction",[r])}))}signMessage(t){return __async(this,null,(function*(){const e="string"==typeof t?yn(t):t;return yield this.provider.send("personal_sign",[Vr(e),this.address.toLowerCase()])}))}signTypedData(t,e,r){return __async(this,null,(function*(){const n=nd(r),i=yield cc.resolveNames(t,e,n,(t=>__async(this,null,(function*(){const e=yield Ka(t);return Or(null!=e,"TypedData does not support null address","value",t),e}))));return yield this.provider.send("eth_signTypedData_v4",[this.address.toLowerCase(),JSON.stringify(cc.getPayload(i.domain,e,i.value))])}))}unlock(t){return __async(this,null,(function*(){return this.provider.send("personal_unlockAccount",[this.address.toLowerCase(),t,null])}))}_legacySignMessage(t){return __async(this,null,(function*(){const e="string"==typeof t?yn(t):t;return yield this.provider.send("eth_sign",[this.address.toLowerCase(),Vr(e)])}))}}mr=new WeakMap,_r=new WeakMap,yr=new WeakMap,vr=new WeakMap,wr=new WeakMap,br=new WeakMap,Ar=new WeakMap,Er=new WeakSet,xr=function(){if(__privateGet(this,vr))return;const t=1===this._getOption("batchMaxCount")?0:this._getOption("batchStallTime");__privateSet(this,vr,setTimeout((()=>{__privateSet(this,vr,null);const t=__privateGet(this,yr);for(__privateSet(this,yr,[]);t.length;){const e=[t.shift()];for(;t.length&&e.length!==__privateGet(this,mr).batchMaxCount;){e.push(t.shift());if(JSON.stringify(e.map((t=>t.payload))).length>__privateGet(this,mr).batchMaxSize){t.unshift(e.pop());break}}(()=>{__async(this,null,(function*(){const t=1===e.length?e[0].payload:e.map((t=>t.payload));this.emit("debug",{action:"sendRpcPayload",payload:t});try{const r=yield this._send(t);this.emit("debug",{action:"receiveRpcResult",result:r});for(const{resolve:t,reject:n,payload:i}of e){if(this.destroyed){n(Ir("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:i.method}));continue}const e=r.filter((t=>t.id===i.id))[0];if(null!=e)"error"in e?n(this.getRpcError(i,e)):t(e.result);else{const t=Ir("missing response for request","BAD_DATA",{value:r,info:{payload:i}});this.emit("error",t),n(t)}}}catch(r){this.emit("debug",{action:"receiveRpcError",error:r});for(const{reject:t}of e)t(r)}}))})()}}),t))};let cd=class t extends Hh{constructor(t,e){super(t,e),__privateAdd(this,Er),__privateAdd(this,mr,void 0),__privateAdd(this,_r,void 0),__privateAdd(this,yr,void 0),__privateAdd(this,vr,void 0),__privateAdd(this,wr,void 0),__privateAdd(this,br,void 0),__privateAdd(this,Ar,void 0),__privateSet(this,_r,1),__privateSet(this,mr,Object.assign({},od,e||{})),__privateSet(this,yr,[]),__privateSet(this,vr,null),__privateSet(this,br,null),__privateSet(this,Ar,null);{let t=null;const e=new Promise((e=>{t=e}));__privateSet(this,wr,{promise:e,resolve:t})}const r=this._getOption("staticNetwork");"boolean"==typeof r?(Or(!r||"any"!==t,"staticNetwork cannot be used on special network 'any'","options",e),r&&null!=t&&__privateSet(this,br,Eh.from(t))):r&&(Or(null==t||r.matches(t),"staticNetwork MUST match network object","options",e),__privateSet(this,br,r))}_getOption(t){return __privateGet(this,mr)[t]}get _network(){return Br(__privateGet(this,br),"network is not available yet","NETWORK_ERROR"),__privateGet(this,br)}_perform(e){return __async(this,null,(function*(){if("call"===e.method||"estimateGas"===e.method){let t=e.transaction;if(t&&null!=t.type&&sn(t.type)&&null==t.maxFeePerGas&&null==t.maxPriorityFeePerGas){const r=yield this.getFeeData();null==r.maxFeePerGas&&null==r.maxPriorityFeePerGas&&(e=Object.assign({},e,{transaction:Object.assign({},t,{type:void 0})}))}}const r=this.getRpcRequest(e);return null!=r?yield this.send(r.method,r.args):__superGet(t.prototype,this,"_perform").call(this,e)}))}_detectNetwork(){return __async(this,null,(function*(){const t=this._getOption("staticNetwork");if(t){if(!0!==t)return t;if(__privateGet(this,br))return __privateGet(this,br)}return __privateGet(this,Ar)?yield __privateGet(this,Ar):this.ready?(__privateSet(this,Ar,(()=>__async(this,null,(function*(){try{const t=Eh.from(sn(yield this.send("eth_chainId",[])));return __privateSet(this,Ar,null),t}catch(t){throw __privateSet(this,Ar,null),t}})))()),yield __privateGet(this,Ar)):(__privateSet(this,Ar,(()=>__async(this,null,(function*(){const t={id:__privateWrapper(this,_r)._++,method:"eth_chainId",params:[],jsonrpc:"2.0"};let e;this.emit("debug",{action:"sendRpcPayload",payload:t});try{e=(yield this._send(t))[0],__privateSet(this,Ar,null)}catch(r){throw __privateSet(this,Ar,null),this.emit("debug",{action:"receiveRpcError",error:r}),r}if(this.emit("debug",{action:"receiveRpcResult",result:e}),"result"in e)return Eh.from(sn(e.result));throw this.getRpcError(t,e)})))()),yield __privateGet(this,Ar))}))}_start(){null!=__privateGet(this,wr)&&null!=__privateGet(this,wr).resolve&&(__privateGet(this,wr).resolve(),__privateSet(this,wr,null),(()=>{__async(this,null,(function*(){for(;null==__privateGet(this,br)&&!this.destroyed;)try{__privateSet(this,br,yield this._detectNetwork())}catch(t){if(this.destroyed)break;console.log("JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)"),this.emit("error",Ir("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:t}})),yield id(1e3)}__privateMethod(this,Er,xr).call(this)}))})())}_waitUntilReady(){return __async(this,null,(function*(){if(null!=__privateGet(this,wr))return yield __privateGet(this,wr).promise}))}_getSubscriber(t){return"pending"===t.type?new ed(this):"event"===t.type?this._getOption("polling")?new Mh(this,t.filter):new td(this,t.filter):"orphan"===t.type&&"drop-log"===t.filter.orphan?new Fh("orphan"):super._getSubscriber(t)}get ready(){return null==__privateGet(this,wr)}getRpcTransaction(t){const e={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach((r=>{if(null==t[r])return;let n=r;"gasLimit"===r&&(n="gas"),e[n]=dn(sn(t[r],`tx.${r}`))})),["from","to","data"].forEach((r=>{null!=t[r]&&(e[r]=Vr(t[r]))})),t.accessList&&(e.accessList=vo(t.accessList)),t.blobVersionedHashes&&(e.blobVersionedHashes=t.blobVersionedHashes.map((t=>t.toLowerCase()))),t.authorizationList&&(e.authorizationList=t.authorizationList.map((t=>{const e=wo(t);return{address:e.address,nonce:dn(e.nonce),chainId:dn(e.chainId),yParity:dn(e.signature.yParity),r:dn(e.signature.r),s:dn(e.signature.s)}}))),e}getRpcRequest(t){switch(t.method){case"chainId":return{method:"eth_chainId",args:[]};case"getBlockNumber":return{method:"eth_blockNumber",args:[]};case"getGasPrice":return{method:"eth_gasPrice",args:[]};case"getPriorityFee":return{method:"eth_maxPriorityFeePerGas",args:[]};case"getBalance":return{method:"eth_getBalance",args:[sd(t.address),t.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[sd(t.address),t.blockTag]};case"getCode":return{method:"eth_getCode",args:[sd(t.address),t.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[sd(t.address),"0x"+t.position.toString(16),t.blockTag]};case"broadcastTransaction":return{method:"eth_sendRawTransaction",args:[t.signedTransaction]};case"getBlock":if("blockTag"in t)return{method:"eth_getBlockByNumber",args:[t.blockTag,!!t.includeTransactions]};if("blockHash"in t)return{method:"eth_getBlockByHash",args:[t.blockHash,!!t.includeTransactions]};break;case"getTransaction":return{method:"eth_getTransactionByHash",args:[t.hash]};case"getTransactionReceipt":return{method:"eth_getTransactionReceipt",args:[t.hash]};case"call":return{method:"eth_call",args:[this.getRpcTransaction(t.transaction),t.blockTag]};case"estimateGas":return{method:"eth_estimateGas",args:[this.getRpcTransaction(t.transaction)]};case"getLogs":return t.filter&&null!=t.filter.address&&(Array.isArray(t.filter.address)?t.filter.address=t.filter.address.map(sd):t.filter.address=sd(t.filter.address)),{method:"eth_getLogs",args:[t.filter]}}return null}getRpcError(t,e){const{method:r}=t,{error:n}=e;if("eth_estimateGas"===r&&n.message){const e=n.message;if(!e.match(/revert/i)&&e.match(/insufficient funds/i))return Ir("insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.params[0],info:{payload:t,error:n}});if(e.match(/nonce/i)&&e.match(/too low/i))return Ir("nonce has already been used","NONCE_EXPIRED",{transaction:t.params[0],info:{payload:t,error:n}})}if("eth_call"===r||"eth_estimateGas"===r){const e=hd(n),i=ou.getBuiltinCallException("eth_call"===r?"call":"estimateGas",t.params[0],e?e.data:null);return i.info={error:n,payload:t},i}const i=JSON.stringify(function(t){const e=[];return dd(t,e),e}(n));if("string"==typeof n.message&&n.message.match(/user denied|ethers-user-denied/i)){return Ir("user rejected action","ACTION_REJECTED",{action:{eth_sign:"signMessage",personal_sign:"signMessage",eth_signTypedData_v4:"signTypedData",eth_signTransaction:"signTransaction",eth_sendTransaction:"sendTransaction",eth_requestAccounts:"requestAccess",wallet_requestAccounts:"requestAccess"}[r]||"unknown",reason:"rejected",info:{payload:t,error:n}})}if("eth_sendRawTransaction"===r||"eth_sendTransaction"===r){const e=t.params[0];if(i.match(/insufficient funds|base fee exceeds gas limit/i))return Ir("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:e,info:{error:n}});if(i.match(/nonce/i)&&i.match(/too low/i))return Ir("nonce has already been used","NONCE_EXPIRED",{transaction:e,info:{error:n}});if(i.match(/replacement transaction/i)&&i.match(/underpriced/i))return Ir("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:e,info:{error:n}});if(i.match(/only replay-protected/i))return Ir("legacy pre-eip-155 transactions not supported","UNSUPPORTED_OPERATION",{operation:r,info:{transaction:e,info:{error:n}}})}let s=!!i.match(/the method .* does not exist/i);return s||n&&n.details&&n.details.startsWith("Unauthorized method:")&&(s=!0),s?Ir("unsupported operation","UNSUPPORTED_OPERATION",{operation:t.method,info:{error:n,payload:t}}):Ir("could not coalesce error","UNKNOWN_ERROR",{error:n,payload:t})}send(t,e){if(this.destroyed)return Promise.reject(Ir("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t}));const r=__privateWrapper(this,_r)._++,n=new Promise(((n,i)=>{__privateGet(this,yr).push({resolve:n,reject:i,payload:{method:t,params:e,id:r,jsonrpc:"2.0"}})}));return __privateMethod(this,Er,xr).call(this),n}getSigner(t){return __async(this,null,(function*(){null==t&&(t=0);const e=this.send("eth_accounts",[]);if("number"==typeof t){const r=yield e;if(t>=r.length)throw new Error("no such account");return new ld(this,r[t])}const{accounts:r}=yield Cr({network:this.getNetwork(),accounts:e});t=za(t);for(const n of r)if(za(n)===t)return new ld(this,t);throw new Error("invalid account")}))}listAccounts(){return __async(this,null,(function*(){return(yield this.send("eth_accounts",[])).map((t=>new ld(this,t)))}))}destroy(){__privateGet(this,vr)&&(clearTimeout(__privateGet(this,vr)),__privateSet(this,vr,null));for(const{payload:t,reject:e}of __privateGet(this,yr))e(Ir("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t.method}));__privateSet(this,yr,[]),super.destroy()}};class ud extends cd{constructor(t,e){super(t,e),__privateAdd(this,kr,void 0);let r=this._getOption("pollingInterval");null==r&&(r=od.pollingInterval),__privateSet(this,kr,r)}_getSubscriber(t){const e=super._getSubscriber(t);return ad(e)&&(e.pollingInterval=__privateGet(this,kr)),e}get pollingInterval(){return __privateGet(this,kr)}set pollingInterval(t){if(!Number.isInteger(t)||t<0)throw new Error("invalid interval");__privateSet(this,kr,t),this._forEachSubscriber((t=>{ad(t)&&(t.pollingInterval=__privateGet(this,kr))}))}}function hd(t){if(null==t)return null;if("string"==typeof t.message&&t.message.match(/revert/i)&&Wr(t.data))return{message:t.message,data:t.data};if("object"==typeof t){for(const e in t){const r=hd(t[e]);if(r)return r}return null}if("string"==typeof t)try{return hd(JSON.parse(t))}catch(e){}return null}function dd(t,e){if(null!=t){if("string"==typeof t.message&&e.push(t.message),"object"==typeof t)for(const r in t)dd(t[r],e);if("string"==typeof t)try{return dd(JSON.parse(t),e)}catch(r){}}}kr=new WeakMap;Sr=new WeakMap,Nr=new WeakMap;let pd=class t extends ud{constructor(t,e,r){const n=Object.assign({},null!=r?r:{},{batchMaxCount:1});Or(t&&t.request,"invalid EIP-1193 provider","ethereum",t),super(e,n),__privateAdd(this,Sr,void 0),__privateAdd(this,Nr,void 0),__privateSet(this,Nr,null),r&&r.providerInfo&&__privateSet(this,Nr,r.providerInfo),__privateSet(this,Sr,((e,r)=>__async(this,null,(function*(){const n={method:e,params:r};this.emit("debug",{action:"sendEip1193Request",payload:n});try{const e=yield t.request(n);return this.emit("debug",{action:"receiveEip1193Result",result:e}),e}catch(i){const t=new Error(i.message);throw t.code=i.code,t.data=i.data,t.payload=n,this.emit("debug",{action:"receiveEip1193Error",error:t}),t}}))))}get providerInfo(){return __privateGet(this,Nr)}send(e,r){return __async(this,null,(function*(){return yield this._start(),yield __superGet(t.prototype,this,"send").call(this,e,r)}))}_send(t){return __async(this,null,(function*(){Or(!Array.isArray(t),"EIP-1193 does not support batch request","payload",t);try{const e=yield __privateGet(this,Sr).call(this,t.method,t.params||[]);return[{id:t.id,result:e}]}catch(e){return[{id:t.id,error:{code:e.code,data:e.data,message:e.message}}]}}))}getRpcError(t,e){switch((e=JSON.parse(JSON.stringify(e))).error.code||-1){case 4001:e.error.message=`ethers-user-denied: ${e.error.message}`;break;case 4200:e.error.message=`ethers-unsupported: ${e.error.message}`}return super.getRpcError(t,e)}hasSigner(t){return __async(this,null,(function*(){null==t&&(t=0);const e=yield this.send("eth_accounts",[]);return"number"==typeof t?e.length>t:(t=t.toLowerCase(),0!==e.filter((e=>e.toLowerCase()===t)).length)}))}getSigner(e){return __async(this,null,(function*(){if(null==e&&(e=0),!(yield this.hasSigner(e)))try{yield __privateGet(this,Sr).call(this,"eth_requestAccounts",[])}catch(r){const t=r.payload;throw this.getRpcError(t,{id:t.id,error:r})}return yield __superGet(t.prototype,this,"getSigner").call(this,e)}))}static discover(e){return __async(this,null,(function*(){if(null==e&&(e={}),e.provider)return new t(e.provider);const r=e.window?e.window:"undefined"!=typeof window?window:null;if(null==r)return null;const n=e.anyProvider;if(n&&r.ethereum)return new t(r.ethereum);if(!("addEventListener"in r&&"dispatchEvent"in r&&"removeEventListener"in r))return null;const i=e.timeout?e.timeout:300;return 0===i?null:yield new Promise(((s,a)=>{let o=[];const l=t=>{o.push(t.detail),n&&c()},c=()=>{if(clearTimeout(u),o.length)if(e&&e.filter){const r=e.filter(o.map((t=>Object.assign({},t.info))));if(null==r)s(null);else if(r instanceof t)s(r);else{let e=null;if(r.uuid){e=o.filter((t=>r.uuid===t.info.uuid))[0]}if(e){const{provider:r,info:n}=e;s(new t(r,void 0,{providerInfo:n}))}else a(Ir("filter returned unknown info","UNSUPPORTED_OPERATION",{value:r}))}}else{const{provider:e,info:r}=o[0];s(new t(e,void 0,{providerInfo:r}))}else s(null);r.removeEventListener("eip6963:announceProvider",l)},u=setTimeout((()=>{c()}),i);r.addEventListener("eip6963:announceProvider",l),r.dispatchEvent(new Event("eip6963:requestProvider"))}))}))}};const fd={METAMASK:"metamask",TRONLINK:"tronlink",TRUST_WALLET:"trustwallet",LUTE:"lute"},gd={ETHEREUM:"ethereum",BSC:"bsc",TRON:"tron",ALGORAND:"algorand"},md={[gd.ETHEREUM]:{name:"Ethereum Mainnet",chainId:1,symbol:"ETH",decimals:18,rpcUrl:"https://mainnet.infura.io/v3/your-infura-key",blockExplorerUrl:"https://etherscan.io"},[gd.BSC]:{name:"Binance Smart Chain",chainId:56,symbol:"BNB",decimals:18,rpcUrl:"https://bsc-dataseed.binance.org/",blockExplorerUrl:"https://bscscan.com"},[gd.TRON]:{name:"TRON Mainnet",symbol:"TRX",decimals:6,rpcUrl:"https://api.trongrid.io",blockExplorerUrl:"https://tronscan.org"},[gd.ALGORAND]:{name:"Algorand Mainnet",symbol:"ALGO",decimals:6,rpcUrl:"https://mainnet-api.algonode.cloud",blockExplorerUrl:"https://algoexplorer.io"}},_d={USDT:{ethereum:{contractAddress:"0xdAC17F958D2ee523a2206206994597C13D831ec7",decimals:6,symbol:"USDT"},bsc:{contractAddress:"0x55d398326f99059fF775485246999027B3197955",decimals:18,symbol:"USDT"},tron:{contractAddress:"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",decimals:6,symbol:"USDT"},algorand:{assetId:312769,decimals:6,symbol:"USDT"}},USDC:{ethereum:{contractAddress:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",decimals:6,symbol:"USDC"},bsc:{contractAddress:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",decimals:18,symbol:"USDC"},tron:{contractAddress:"TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8",decimals:6,symbol:"USDC"},algorand:{assetId:31566704,decimals:6,symbol:"USDC"}},BNB:{bsc:{decimals:18,symbol:"BNB",isNative:!0}},ETH:{ethereum:{decimals:18,symbol:"ETH",isNative:!0}},TRX:{tron:{decimals:6,symbol:"TRX",isNative:!0}},ALGO:{algorand:{decimals:6,symbol:"ALGO",isNative:!0}}},yd={[gd.ETHEREUM]:[fd.METAMASK,fd.TRUST_WALLET],[gd.BSC]:[fd.METAMASK,fd.TRUST_WALLET],[gd.TRON]:[fd.TRONLINK],[gd.ALGORAND]:[fd.LUTE]},vd=t=>({[fd.METAMASK]:"https://metamask.io/download/",[fd.TRONLINK]:"https://www.tronlink.org/download/",[fd.TRUST_WALLET]:"https://trustwallet.com/download/",[fd.LUTE]:"https://lute.app/download/"}[t]||""),wd=()=>({[fd.METAMASK]:"undefined"!=typeof window&&void 0!==window.ethereum,[fd.TRONLINK]:"undefined"!=typeof window&&void 0!==window.tronWeb,[fd.TRUST_WALLET]:"undefined"!=typeof window&&void 0!==window.ethereum&&!0===window.ethereum.isTrust,[fd.LUTE]:"undefined"!=typeof window&&void 0!==window.lute}),bd=(t=3,e=500)=>__async(this,null,(function*(){let r=0,n=wd();const i=Object.values(n).some((t=>!0===t));for(;!i&&r<t;)console.log(`No wallets detected, retrying (${r+1}/${t})...`),yield new Promise((t=>setTimeout(t,e))),n=wd(),r++;return n})),Ad=()=>{var t;console.log("=== WALLET ENVIRONMENT DEBUG ==="),console.log("ethereum:","undefined"!=typeof window?Boolean(window.ethereum):"Not in browser"),console.log("tronWeb:","undefined"!=typeof window?Boolean(window.tronWeb):"Not in browser"),console.log("lute:","undefined"!=typeof window?Boolean(window.lute):"Not in browser"),"undefined"!=typeof window&&window.ethereum&&console.log("ethereum details:",{isTrust:window.ethereum.isTrust,isMetaMask:window.ethereum.isMetaMask,chainId:window.ethereum.chainId}),"undefined"!=typeof window&&window.tronWeb&&console.log("tronWeb details:",{ready:window.tronWeb.ready,fullNode:null==(t=window.tronWeb.fullNode)?void 0:t.host,defaultAddress:window.tronWeb.defaultAddress});const e=wd();console.log("Detected wallets:",e)},Ed=()=>__async(this,null,(function*(){if(console.log("Connecting to MetaMask wallet..."),!window.ethereum||!window.ethereum.isMetaMask)throw console.error("MetaMask not found."),new Error("MetaMask not detected. Please install MetaMask extension.");try{let e;try{e=new pd(window.ethereum);const t=yield e.send("eth_requestAccounts",[]);if(!t||0===t.length)throw new Error("No accounts found");const r=t[0],n=yield e.getNetwork(),i=Number(n.chainId);let s;switch(i){case 1:s=gd.ETHEREUM;break;case 56:s=gd.BSC;break;default:s=`unknown-${i}`}return{walletType:fd.METAMASK,address:r,provider:e,network:s,isConnected:!0,chainId:i}}catch(t){if(console.log("Trying fallback ethers provider pattern"),window.ethereum.request){const t=yield window.ethereum.request({method:"eth_requestAccounts"});if(!t||0===t.length)throw new Error("No accounts found");const e=t[0],r=yield window.ethereum.request({method:"eth_chainId"}),n=parseInt(r,16);let i;switch(n){case 1:i=gd.ETHEREUM;break;case 56:i=gd.BSC;break;default:i=`unknown-${n}`}return{walletType:fd.METAMASK,address:e,provider:{getSigner:()=>({getAddress:()=>__async(this,null,(function*(){return e})),sendTransaction:t=>__async(this,null,(function*(){return{hash:yield window.ethereum.request({method:"eth_sendTransaction",params:[{from:e,to:t.to,value:t.value?t.value.toString():"0x0",gasLimit:t.gasLimit?t.gasLimit.toString():void 0,data:t.data}]})}}))}),estimateGas:t=>__async(this,null,(function*(){const r=yield window.ethereum.request({method:"eth_estimateGas",params:[{from:e,to:t.to,value:t.value?t.value:"0x0"}]});return{toString:()=>parseInt(r,16).toString(),mul:t=>({div:e=>({toString:()=>Math.floor(parseInt(r,16)*t/e).toString()})})}}))},network:i,isConnected:!0,chainId:n}}throw new Error("Unsupported wallet interface")}}catch(e){throw console.error("Error connecting to MetaMask:",e),e}})),xd=()=>__async(this,null,(function*(){if(console.log("Connecting to Trust Wallet..."),!window.ethereum||!window.ethereum.isTrust)throw console.error("Trust Wallet not found."),new Error("Trust Wallet not detected. Please install Trust Wallet.");try{if(window.ethereum.request){const t=yield window.ethereum.request({method:"eth_requestAccounts"});if(!t||0===t.length)throw new Error("No accounts found");const e=t[0],r=yield window.ethereum.request({method:"eth_chainId"}),n=parseInt(r,16);let i;switch(n){case 1:i=gd.ETHEREUM;break;case 56:i=gd.BSC;break;default:i=`unknown-${n}`}return{walletType:fd.TRUST_WALLET,address:e,provider:{getSigner:()=>({getAddress:()=>__async(this,null,(function*(){return e})),sendTransaction:t=>__async(this,null,(function*(){return{hash:yield window.ethereum.request({method:"eth_sendTransaction",params:[{from:e,to:t.to,value:t.value?t.value.toString():"0x0",gasLimit:t.gasLimit?t.gasLimit.toString():void 0,data:t.data}]})}}))}),estimateGas:t=>__async(this,null,(function*(){const r=yield window.ethereum.request({method:"eth_estimateGas",params:[{from:e,to:t.to,value:t.value?t.value:"0x0"}]});return{toString:()=>parseInt(r,16).toString(),mul:t=>({div:e=>({toString:()=>Math.floor(parseInt(r,16)*t/e).toString()})})}}))},network:i,isConnected:!0,chainId:n}}throw new Error("Unsupported wallet interface")}catch(t){throw console.error("Error connecting to Trust Wallet:",t),t}})),kd=()=>__async(this,null,(function*(){if(console.log("Connecting to TronLink wallet..."),!window.tronWeb)throw console.error("TronWeb not found. Is TronLink installed?"),new Error("TronLink not detected. Please install TronLink extension.");const t=(t=10,e=500)=>__async(this,null,(function*(){for(let r=0;r<t;r++){if(window.tronWeb&&window.tronWeb.ready)return window.tronWeb;console.log(`Waiting for TronWeb to be ready... Attempt ${r+1}/${t}`),yield new Promise((t=>setTimeout(t,e)))}throw new Error("TronWeb took too long to be ready")}));try{const r=yield t();if(!r.defaultAddress||!r.defaultAddress.base58)try{yield window.tronWeb.request({method:"tron_requestAccounts"})}catch(e){throw console.error("Failed to get permission from TronLink:",e),new Error("Please unlock TronLink and approve connection")}const n=r.defaultAddress.base58;return console.log("Connected to TronLink wallet:",n),{walletType:fd.TRONLINK,address:n,provider:r,network:gd.TRON,isConnected:!0}}catch(r){throw console.error("Error connecting to TronLink:",r),r}})),Sd=()=>__async(this,null,(function*(){if(console.log("Connecting to Lute wallet..."),!window.lute)throw console.error("Lute not found."),new Error("Lute not detected. Please install Lute extension.");try{const{address:t}=yield window.lute.connect();if(!t)throw new Error("No address returned. Please unlock Lute wallet.");return console.log("Connected to Lute wallet:",t),{walletType:fd.LUTE,address:t,provider:window.lute,network:gd.ALGORAND,isConnected:!0}}catch(t){throw console.error("Error connecting to Lute wallet:",t),t}})),Nd=t=>__async(this,null,(function*(){switch(console.log("Connecting to wallet:",t),t){case fd.METAMASK:return Ed();case fd.TRONLINK:return kd();case fd.TRUST_WALLET:return xd();case fd.LUTE:return Sd();default:throw new Error(`Unsupported wallet type: ${t}`)}})),Pd=t=>yd[t]||[],Cd=(t,e,r)=>__async(this,null,(function*(){if(console.log("Sending native transaction:",{toAddress:e,amount:r}),!t||!t.provider)throw new Error("Wallet not connected");if(!e)throw new Error("Recipient address not provided");if(!r||isNaN(parseFloat(r))||parseFloat(r)<=0)throw new Error("Invalid amount");try{let s;switch(t.walletType){case fd.METAMASK:case fd.TRUST_WALLET:const a=t.provider,o=a.getSigner(),l=r.toString();let c;try{c=ni(l,18)}catch(n){try{c=(void 0).parseEther(l)}catch(i){const t=parseFloat(l)*Math.pow(10,18);c={toString:()=>t.toLocaleString("fullwide",{useGrouping:!1})}}}console.log("Sending ETH/BNB:",{to:e,value:c.toString()});const u=yield a.estimateGas({to:e,value:c});console.log("Gas estimate:",u.toString());const h="function"==typeof u.mul?u.mul(110).div(100):{toString:()=>Math.floor(1.1*parseInt(u.toString())).toString()};console.log("Using gas limit:",h.toString()),s=yield o.sendTransaction({to:e,value:c,gasLimit:h});break;case fd.TRONLINK:const d=t.provider;if(!d||!d.ready)throw new Error("TronWeb not initialized");const p=d.toSun(r.toString());console.log("Sending TRX:",{to:e,value:p}),s=yield d.trx.sendTransaction(e,p);break;case fd.LUTE:const f=t.provider,g=Math.floor(1e6*parseFloat(r));console.log("Sending Algos:",{to:e,amount:g}),s=yield f.sendPayment({recipient:e,amount:g});break;default:throw new Error(`Unsupported wallet type: ${t.walletType}`)}if(console.log("Transaction sent:",s),s){const t=s.hash||s.txID||s.txId||s;return console.log("Transaction hash:",t),t}throw new Error("No transaction hash returned")}catch(i){throw console.error("Native transaction error:",i),i}})),Td=(t,e,r,n)=>__async(this,null,(function*(){if(console.log("Sending transaction with:",{tokenConfig:e,toAddress:r,amount:n}),!t)throw new Error("Wallet not connected");if(!r)throw new Error("Recipient address not provided");return e&&e.isNative?Cd(t,r,n):Rd(t,e,r,n)})),Rd=(t,e,r,n)=>__async(this,null,(function*(){if(console.log("Sending token transaction with:",{tokenConfig:e,toAddress:r,amount:n}),!t||!t.provider)throw new Error("Wallet not connected");if(!e)throw new Error("Token configuration not provided");if(!r)throw new Error("Recipient address not provided");if(!n||isNaN(parseFloat(n))||parseFloat(n)<=0)throw new Error("Invalid amount");const{contractAddress:i,decimals:s,symbol:a}=e;switch(console.log(`Token: ${a}, Decimals: ${s}, Contract: ${i}`),t.walletType){case fd.TRONLINK:return Md(t,e,r,n);case fd.LUTE:return Id(t,e,r,n);default:return Gd(t,e,r,n)}})),Gd=(t,e,r,n)=>__async(this,null,(function*(){if(console.log("Sending ERC20/BEP20 transaction with:",{tokenConfig:e,toAddress:r,amount:n}),!t||!t.provider)throw new Error("Wallet not connected");const i=t.provider.getSigner(),{contractAddress:s,decimals:a,symbol:o}=e,l=parseFloat(n),c=parseInt(a);let u;try{u=ni(l.toString(),c)}catch(h){try{u=(void 0).parseUnits(l.toString(),c)}catch(d){const t=l*Math.pow(10,c);u={toString:()=>t.toLocaleString("fullwide",{useGrouping:!1})}}}console.log(`Sending ${l} ${o} (${u.toString()} base units) to ${r}`);try{const t=new th(s,["function transfer(address to, uint256 amount) returns (bool)"],i);try{const e=yield t.estimateGas.transfer(r,u);console.log("Gas estimate:",e.toString());const n="USDC"===o?"function"==typeof e.mul?e.mul(120).div(100):{toString:()=>Math.floor(1.2*parseInt(e.toString())).toString()}:"function"==typeof e.mul?e.mul(110).div(100):{toString:()=>Math.floor(1.1*parseInt(e.toString())).toString()};console.log("Using gas limit:",n.toString());const i=yield t.transfer(r,u,{gasLimit:n});return console.log("Transaction sent:",i),i.hash}catch(p){if(console.error("Gas estimation failed:",p),"USDC"===o){console.log("Trying USDC transaction with fixed gas limit");const e=yield t.transfer(r,u,{gasLimit:15e4});return console.log("Transaction sent with fixed gas limit:",e),e.hash}throw new Error(`Transaction would likely fail: ${p.message}`)}}catch(d){throw console.error("ERC20 transaction error:",d),d.message&&d.message.includes("user rejected")?new Error("Transaction rejected by user"):d.message&&d.message.includes("insufficient funds")?new Error("Insufficient funds for transaction"):d}})),Md=(t,e,r,n)=>__async(this,null,(function*(){if(console.log("Sending TRC20 transaction with:",{tokenConfig:e,toAddress:r,amount:n}),!t||!t.provider)throw new Error("Tron wallet not connected");const i=t.provider;if(!i||!i.ready)throw new Error("TronWeb not initialized");if(!e||!e.contractAddress)throw new Error("Invalid token configuration");const{contractAddress:s,decimals:a,symbol:o}=e,l=parseFloat(n),c=parseInt(a),u=(l*Math.pow(10,c)).toString();console.log(`Sending ${l} ${o} (${u} base units) to ${r}`);try{const t=yield i.contract().at(s);if(!t.transfer)throw new Error("Invalid TRC-20 contract");const e=yield t.transfer(r,u).send({feeLimit:1e8,callValue:0,shouldPollResponse:!1});return console.log("TRC20 transaction sent:",e),e}catch(h){throw console.error("TRC20 transaction failed:",h),h.message&&h.message.includes("User rejected")?new Error("Transaction rejected by user"):h.message&&h.message.includes("bandwidth")?new Error("Insufficient energy or bandwidth. Make sure you have enough TRX for fees."):h.message&&h.message.includes("balance")?new Error("Insufficient token balance for transfer"):new Error(`Transaction failed: ${h.message||"Unknown error"}`)}})),Id=(t,e,r,n)=>__async(this,null,(function*(){if(console.log("Sending Algorand asset transaction with:",{tokenConfig:e,toAddress:r,amount:n}),!t||!t.provider)throw new Error("Algorand wallet not connected");const i=t.provider;if(!e||!e.assetId)throw new Error("Invalid token configuration - missing assetId");const{assetId:s,decimals:a,symbol:o}=e,l=parseFloat(n),c=parseInt(a),u=Math.floor(l*Math.pow(10,c));console.log(`Sending ${l} ${o} (${u} base units) to ${r}`);try{const t=yield i.sendAssetTransfer({recipient:r,assetId:s,amount:u});return console.log("Algorand asset transaction sent:",t),t.txId}catch(h){throw console.error("Algorand asset transaction error:",h),h.message&&h.message.includes("rejected")?new Error("Transaction rejected by user"):h.message&&h.message.includes("balance")?new Error("Insufficient asset balance"):h}}));let Bd={apiKey:null,apiSecret:null,apiUrl:"http://localhost:9000",merchantWalletAddresses:{}};const Od=()=>({"Content-Type":"application/json","x-api-key":Bd.apiKey,"x-api-secret":Bd.apiSecret}),Fd=t=>__async(this,null,(function*(){try{if(console.log("Creating payment with data:",t),console.log("API URL:",`${Bd.apiUrl}/api/payments/create`),!t.amount)throw new Error("Payment amount is required");const r=__spreadProps(__spreadValues({},t),{merchantWalletAddresses:__spreadValues(__spreadValues({},Bd.merchantWalletAddresses),t.merchantWalletAddresses)}),n=yield fetch(`${Bd.apiUrl}/api/payments/create`,{method:"POST",headers:Od(),body:JSON.stringify(r)});if(console.log("Create payment response status:",n.status),!n.ok){let t;try{t=yield n.json()}catch(e){throw new Error(`Failed to create payment: ${n.status} ${n.statusText}`)}throw console.error("Error creating payment:",t),new Error(t.error||`Failed to create payment: ${n.status}`)}const i=yield n.json();return console.log("Create payment response data:",i),i}catch(r){throw console.error("Create payment error:",r),r}})),Ud=t=>__async(this,null,(function*(){try{if(console.log("Processing payment with data:",t),!t.paymentId)throw new Error("Payment ID is required");if(!t.transactionHash)throw new Error("Transaction hash is required");console.log("API URL:",`${Bd.apiUrl}/api/payments/process`);const r=yield fetch(`${Bd.apiUrl}/api/payments/process`,{method:"POST",headers:Od(),body:JSON.stringify(t)});if(console.log("Process payment response status:",r.status),!r.ok){let t;try{t=yield r.json()}catch(e){throw new Error(`Failed to process payment: ${r.status} ${r.statusText}`)}throw console.error("Error processing payment:",t),new Error(t.error||`Failed to process payment: ${r.status}`)}const n=yield r.json();return console.log("Process payment response data:",n),n}catch(r){throw console.error("Process payment error:",r),r}}));var Ld={exports:{}},Dd={},jd=e,Hd=Symbol.for("react.element"),Wd=Symbol.for("react.fragment"),Qd=Object.prototype.hasOwnProperty,zd=jd.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Vd={key:!0,ref:!0,__self:!0,__source:!0};function Jd(t,e,r){var n,i={},s=null,a=null;for(n in void 0!==r&&(s=""+r),void 0!==e.key&&(s=""+e.key),void 0!==e.ref&&(a=e.ref),e)Qd.call(e,n)&&!Vd.hasOwnProperty(n)&&(i[n]=e[n]);if(t&&t.defaultProps)for(n in e=t.defaultProps)void 0===i[n]&&(i[n]=e[n]);return{$$typeof:Hd,type:t,key:s,ref:a,props:i,_owner:zd.current}}Dd.Fragment=Wd,Dd.jsx=Jd,Dd.jsxs=Jd,Ld.exports=Dd;var Kd=Ld.exports;const qd=e.createContext(),Zd=e.createContext(),Yd=()=>e.useContext(Zd);var Xd,$d,tp=Object.defineProperty,ep=Object.getOwnPropertySymbols,rp=Object.prototype.hasOwnProperty,np=Object.prototype.propertyIsEnumerable,ip=(t,e,r)=>e in t?tp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,sp=(t,e)=>{for(var r in e||(e={}))rp.call(e,r)&&ip(t,r,e[r]);if(ep)for(var r of ep(e))np.call(e,r)&&ip(t,r,e[r]);return t},ap=(t,e)=>{var r={};for(var n in t)rp.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&ep)for(var n of ep(t))e.indexOf(n)<0&&np.call(t,n)&&(r[n]=t[n]);return r};(t=>{const e=class e{constructor(t,r,n,s){if(this.version=t,this.errorCorrectionLevel=r,this.modules=[],this.isFunction=[],t<e.MIN_VERSION||t>e.MAX_VERSION)throw new RangeError("Version value out of range");if(s<-1||s>7)throw new RangeError("Mask value out of range");this.size=4*t+17;let a=[];for(let e=0;e<this.size;e++)a.push(!1);for(let e=0;e<this.size;e++)this.modules.push(a.slice()),this.isFunction.push(a.slice());this.drawFunctionPatterns();const o=this.addEccAndInterleave(n);if(this.drawCodewords(o),-1==s){let t=1e9;for(let e=0;e<8;e++){this.applyMask(e),this.drawFormatBits(e);const r=this.getPenaltyScore();r<t&&(s=e,t=r),this.applyMask(e)}}i(0<=s&&s<=7),this.mask=s,this.applyMask(s),this.drawFormatBits(s),this.isFunction=[]}static encodeText(r,n){const i=t.QrSegment.makeSegments(r);return e.encodeSegments(i,n)}static encodeBinary(r,n){const i=t.QrSegment.makeBytes(r);return e.encodeSegments([i],n)}static encodeSegments(t,n,s=1,o=40,l=-1,c=!0){if(!(e.MIN_VERSION<=s&&s<=o&&o<=e.MAX_VERSION)||l<-1||l>7)throw new RangeError("Invalid value");let u,h;for(u=s;;u++){const r=8*e.getNumDataCodewords(u,n),i=a.getTotalBits(t,u);if(i<=r){h=i;break}if(u>=o)throw new RangeError("Data too long")}for(const r of[e.Ecc.MEDIUM,e.Ecc.QUARTILE,e.Ecc.HIGH])c&&h<=8*e.getNumDataCodewords(u,r)&&(n=r);let d=[];for(const e of t){r(e.mode.modeBits,4,d),r(e.numChars,e.mode.numCharCountBits(u),d);for(const t of e.getData())d.push(t)}i(d.length==h);const p=8*e.getNumDataCodewords(u,n);i(d.length<=p),r(0,Math.min(4,p-d.length),d),r(0,(8-d.length%8)%8,d),i(d.length%8==0);for(let e=236;d.length<p;e^=253)r(e,8,d);let f=[];for(;8*f.length<d.length;)f.push(0);return d.forEach(((t,e)=>f[e>>>3]|=t<<7-(7&e))),new e(u,n,f,l)}getModule(t,e){return 0<=t&&t<this.size&&0<=e&&e<this.size&&this.modules[e][t]}getModules(){return this.modules}drawFunctionPatterns(){for(let r=0;r<this.size;r++)this.setFunctionModule(6,r,r%2==0),this.setFunctionModule(r,6,r%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const t=this.getAlignmentPatternPositions(),e=t.length;for(let r=0;r<e;r++)for(let n=0;n<e;n++)0==r&&0==n||0==r&&n==e-1||r==e-1&&0==n||this.drawAlignmentPattern(t[r],t[n]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(t){const e=this.errorCorrectionLevel.formatBits<<3|t;let r=e;for(let n=0;n<10;n++)r=r<<1^1335*(r>>>9);const s=21522^(e<<10|r);i(s>>>15==0);for(let i=0;i<=5;i++)this.setFunctionModule(8,i,n(s,i));this.setFunctionModule(8,7,n(s,6)),this.setFunctionModule(8,8,n(s,7)),this.setFunctionModule(7,8,n(s,8));for(let i=9;i<15;i++)this.setFunctionModule(14-i,8,n(s,i));for(let i=0;i<8;i++)this.setFunctionModule(this.size-1-i,8,n(s,i));for(let i=8;i<15;i++)this.setFunctionModule(8,this.size-15+i,n(s,i));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let t=this.version;for(let r=0;r<12;r++)t=t<<1^7973*(t>>>11);const e=this.version<<12|t;i(e>>>18==0);for(let r=0;r<18;r++){const t=n(e,r),i=this.size-11+r%3,s=Math.floor(r/3);this.setFunctionModule(i,s,t),this.setFunctionModule(s,i,t)}}drawFinderPattern(t,e){for(let r=-4;r<=4;r++)for(let n=-4;n<=4;n++){const i=Math.max(Math.abs(n),Math.abs(r)),s=t+n,a=e+r;0<=s&&s<this.size&&0<=a&&a<this.size&&this.setFunctionModule(s,a,2!=i&&4!=i)}}drawAlignmentPattern(t,e){for(let r=-2;r<=2;r++)for(let n=-2;n<=2;n++)this.setFunctionModule(t+n,e+r,1!=Math.max(Math.abs(n),Math.abs(r)))}setFunctionModule(t,e,r){this.modules[e][t]=r,this.isFunction[e][t]=!0}addEccAndInterleave(t){const r=this.version,n=this.errorCorrectionLevel;if(t.length!=e.getNumDataCodewords(r,n))throw new RangeError("Invalid argument");const s=e.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][r],a=e.ECC_CODEWORDS_PER_BLOCK[n.ordinal][r],o=Math.floor(e.getNumRawDataModules(r)/8),l=s-o%s,c=Math.floor(o/s);let u=[];const h=e.reedSolomonComputeDivisor(a);for(let i=0,p=0;i<s;i++){let r=t.slice(p,p+c-a+(i<l?0:1));p+=r.length;const n=e.reedSolomonComputeRemainder(r,h);i<l&&r.push(0),u.push(r.concat(n))}let d=[];for(let e=0;e<u[0].length;e++)u.forEach(((t,r)=>{(e!=c-a||r>=l)&&d.push(t[e])}));return i(d.length==o),d}drawCodewords(t){if(t.length!=Math.floor(e.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let r=0;for(let e=this.size-1;e>=1;e-=2){6==e&&(e=5);for(let i=0;i<this.size;i++)for(let s=0;s<2;s++){const a=e-s,o=!(e+1&2)?this.size-1-i:i;!this.isFunction[o][a]&&r<8*t.length&&(this.modules[o][a]=n(t[r>>>3],7-(7&r)),r++)}}i(r==8*t.length)}applyMask(t){if(t<0||t>7)throw new RangeError("Mask value out of range");for(let e=0;e<this.size;e++)for(let r=0;r<this.size;r++){let n;switch(t){case 0:n=(r+e)%2==0;break;case 1:n=e%2==0;break;case 2:n=r%3==0;break;case 3:n=(r+e)%3==0;break;case 4:n=(Math.floor(r/3)+Math.floor(e/2))%2==0;break;case 5:n=r*e%2+r*e%3==0;break;case 6:n=(r*e%2+r*e%3)%2==0;break;case 7:n=((r+e)%2+r*e%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[e][r]&&n&&(this.modules[e][r]=!this.modules[e][r])}}getPenaltyScore(){let t=0;for(let i=0;i<this.size;i++){let r=!1,n=0,s=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[i][a]==r?(n++,5==n?t+=e.PENALTY_N1:n>5&&t++):(this.finderPenaltyAddHistory(n,s),r||(t+=this.finderPenaltyCountPatterns(s)*e.PENALTY_N3),r=this.modules[i][a],n=1);t+=this.finderPenaltyTerminateAndCount(r,n,s)*e.PENALTY_N3}for(let i=0;i<this.size;i++){let r=!1,n=0,s=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][i]==r?(n++,5==n?t+=e.PENALTY_N1:n>5&&t++):(this.finderPenaltyAddHistory(n,s),r||(t+=this.finderPenaltyCountPatterns(s)*e.PENALTY_N3),r=this.modules[a][i],n=1);t+=this.finderPenaltyTerminateAndCount(r,n,s)*e.PENALTY_N3}for(let i=0;i<this.size-1;i++)for(let r=0;r<this.size-1;r++){const n=this.modules[i][r];n==this.modules[i][r+1]&&n==this.modules[i+1][r]&&n==this.modules[i+1][r+1]&&(t+=e.PENALTY_N2)}let r=0;for(const e of this.modules)r=e.reduce(((t,e)=>t+(e?1:0)),r);const n=this.size*this.size,s=Math.ceil(Math.abs(20*r-10*n)/n)-1;return i(0<=s&&s<=9),t+=s*e.PENALTY_N4,i(0<=t&&t<=2568888),t}getAlignmentPatternPositions(){if(1==this.version)return[];{const t=Math.floor(this.version/7)+2,e=32==this.version?26:2*Math.ceil((4*this.version+4)/(2*t-2));let r=[6];for(let n=this.size-7;r.length<t;n-=e)r.splice(1,0,n);return r}}static getNumRawDataModules(t){if(t<e.MIN_VERSION||t>e.MAX_VERSION)throw new RangeError("Version number out of range");let r=(16*t+128)*t+64;if(t>=2){const e=Math.floor(t/7)+2;r-=(25*e-10)*e-55,t>=7&&(r-=36)}return i(208<=r&&r<=29648),r}static getNumDataCodewords(t,r){return Math.floor(e.getNumRawDataModules(t)/8)-e.ECC_CODEWORDS_PER_BLOCK[r.ordinal][t]*e.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][t]}static reedSolomonComputeDivisor(t){if(t<1||t>255)throw new RangeError("Degree out of range");let r=[];for(let e=0;e<t-1;e++)r.push(0);r.push(1);let n=1;for(let i=0;i<t;i++){for(let t=0;t<r.length;t++)r[t]=e.reedSolomonMultiply(r[t],n),t+1<r.length&&(r[t]^=r[t+1]);n=e.reedSolomonMultiply(n,2)}return r}static reedSolomonComputeRemainder(t,r){let n=r.map((t=>0));for(const i of t){const t=i^n.shift();n.push(0),r.forEach(((r,i)=>n[i]^=e.reedSolomonMultiply(r,t)))}return n}static reedSolomonMultiply(t,e){if(t>>>8!=0||e>>>8!=0)throw new RangeError("Byte out of range");let r=0;for(let n=7;n>=0;n--)r=r<<1^285*(r>>>7),r^=(e>>>n&1)*t;return i(r>>>8==0),r}finderPenaltyCountPatterns(t){const e=t[1];i(e<=3*this.size);const r=e>0&&t[2]==e&&t[3]==3*e&&t[4]==e&&t[5]==e;return(r&&t[0]>=4*e&&t[6]>=e?1:0)+(r&&t[6]>=4*e&&t[0]>=e?1:0)}finderPenaltyTerminateAndCount(t,e,r){return t&&(this.finderPenaltyAddHistory(e,r),e=0),e+=this.size,this.finderPenaltyAddHistory(e,r),this.finderPenaltyCountPatterns(r)}finderPenaltyAddHistory(t,e){0==e[0]&&(t+=this.size),e.pop(),e.unshift(t)}};function r(t,e,r){if(e<0||e>31||t>>>e!=0)throw new RangeError("Value out of range");for(let n=e-1;n>=0;n--)r.push(t>>>n&1)}function n(t,e){return!!(t>>>e&1)}function i(t){if(!t)throw new Error("Assertion error")}e.MIN_VERSION=1,e.MAX_VERSION=40,e.PENALTY_N1=3,e.PENALTY_N2=3,e.PENALTY_N3=40,e.PENALTY_N4=10,e.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],e.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],t.QrCode=e;const s=class t{constructor(t,e,r){if(this.mode=t,this.numChars=e,this.bitData=r,e<0)throw new RangeError("Invalid argument");this.bitData=r.slice()}static makeBytes(e){let n=[];for(const t of e)r(t,8,n);return new t(t.Mode.BYTE,e.length,n)}static makeNumeric(e){if(!t.isNumeric(e))throw new RangeError("String contains non-numeric characters");let n=[];for(let t=0;t<e.length;){const i=Math.min(e.length-t,3);r(parseInt(e.substring(t,t+i),10),3*i+1,n),t+=i}return new t(t.Mode.NUMERIC,e.length,n)}static makeAlphanumeric(e){if(!t.isAlphanumeric(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");let n,i=[];for(n=0;n+2<=e.length;n+=2){let s=45*t.ALPHANUMERIC_CHARSET.indexOf(e.charAt(n));s+=t.ALPHANUMERIC_CHARSET.indexOf(e.charAt(n+1)),r(s,11,i)}return n<e.length&&r(t.ALPHANUMERIC_CHARSET.indexOf(e.charAt(n)),6,i),new t(t.Mode.ALPHANUMERIC,e.length,i)}static makeSegments(e){return""==e?[]:t.isNumeric(e)?[t.makeNumeric(e)]:t.isAlphanumeric(e)?[t.makeAlphanumeric(e)]:[t.makeBytes(t.toUtf8ByteArray(e))]}static makeEci(e){let n=[];if(e<0)throw new RangeError("ECI assignment value out of range");if(e<128)r(e,8,n);else if(e<16384)r(2,2,n),r(e,14,n);else{if(!(e<1e6))throw new RangeError("ECI assignment value out of range");r(6,3,n),r(e,21,n)}return new t(t.Mode.ECI,0,n)}static isNumeric(e){return t.NUMERIC_REGEX.test(e)}static isAlphanumeric(e){return t.ALPHANUMERIC_REGEX.test(e)}getData(){return this.bitData.slice()}static getTotalBits(t,e){let r=0;for(const n of t){const t=n.mode.numCharCountBits(e);if(n.numChars>=1<<t)return 1/0;r+=4+t+n.bitData.length}return r}static toUtf8ByteArray(t){t=encodeURI(t);let e=[];for(let r=0;r<t.length;r++)"%"!=t.charAt(r)?e.push(t.charCodeAt(r)):(e.push(parseInt(t.substring(r+1,r+3),16)),r+=2);return e}};s.NUMERIC_REGEX=/^[0-9]*$/,s.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,s.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let a=s;t.QrSegment=s})(Xd||(Xd={})),(t=>{const e=class{constructor(t,e){this.ordinal=t,this.formatBits=e}};e.LOW=new e(0,1),e.MEDIUM=new e(1,0),e.QUARTILE=new e(2,3),e.HIGH=new e(3,2),t.Ecc=e})(($d=Xd||(Xd={})).QrCode||($d.QrCode={})),(t=>{(t=>{const e=class{constructor(t,e){this.modeBits=t,this.numBitsCharCount=e}numCharCountBits(t){return this.numBitsCharCount[Math.floor((t+7)/17)]}};e.NUMERIC=new e(1,[10,12,14]),e.ALPHANUMERIC=new e(2,[9,11,13]),e.BYTE=new e(4,[8,16,16]),e.KANJI=new e(8,[8,10,12]),e.ECI=new e(7,[0,0,0]),t.Mode=e})(t.QrSegment||(t.QrSegment={}))})(Xd||(Xd={}));var op=Xd,lp={L:op.QrCode.Ecc.LOW,M:op.QrCode.Ecc.MEDIUM,Q:op.QrCode.Ecc.QUARTILE,H:op.QrCode.Ecc.HIGH},cp=128,up="L",hp="#FFFFFF",dp="#000000",pp=!1,fp=1;
11
+ const wa=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ba=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Aa=BigInt(1),Ea=BigInt(2),xa=(t,e)=>(t+e/Ea)/e;const ka=function(t,e,r=!1,n={}){if(t<=Vs)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:i,nByteLength:s}=sa(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const a=na(t),o=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:Ls(i),ZERO:Vs,ONE:Js,create:e=>$s(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("Invalid field element: expected bigint, got "+typeof e);return Vs<=e&&e<t},is0:t=>t===Vs,isOdd:t=>(t&Js)===Js,neg:e=>$s(-e,t),eql:(t,e)=>t===e,sqr:e=>$s(e*e,t),add:(e,r)=>$s(e+r,t),sub:(e,r)=>$s(e-r,t),mul:(e,r)=>$s(e*r,t),pow:(t,e)=>function(t,e,r){if(r<Vs)throw new Error("Expected power > 0");if(r===Vs)return t.ONE;if(r===Js)return e;let n=t.ONE,i=e;for(;r>Vs;)r&Js&&(n=t.mul(n,i)),i=t.sqr(i),r>>=Js;return n}(o,t,e),div:(e,r)=>$s(e*ra(r,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>ra(e,t),sqrt:n.sqrt||(t=>a(o,t)),invertBatch:t=>function(t,e){const r=new Array(e.length),n=e.reduce(((e,n,i)=>t.is0(n)?e:(r[i]=e,t.mul(e,n))),t.ONE),i=t.inv(n);return e.reduceRight(((e,n,i)=>t.is0(n)?e:(r[i]=t.mul(e,r[i]),t.mul(e,n))),i),r}(o,t),cmov:(t,e,r)=>r?e:t,toBytes:t=>r?Os(t,s):Bs(t,s),fromBytes:t=>{if(t.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${t.length}`);return r?Is(t):Ms(t)}});return Object.freeze(o)}(wa,void 0,void 0,{sqrt:function(t){const e=wa,r=BigInt(3),n=BigInt(6),i=BigInt(11),s=BigInt(22),a=BigInt(23),o=BigInt(44),l=BigInt(88),c=t*t*t%e,u=c*c*t%e,h=ea(u,r,e)*u%e,d=ea(h,r,e)*u%e,p=ea(d,Ea,e)*c%e,f=ea(p,i,e)*p%e,g=ea(f,s,e)*f%e,m=ea(g,o,e)*g%e,_=ea(m,l,e)*m%e,y=ea(_,o,e)*g%e,v=ea(y,r,e)*u%e,w=ea(v,a,e)*f%e,b=ea(w,n,e)*c%e,A=ea(b,Ea,e);if(!ka.eql(ka.sqr(A),t))throw new Error("Cannot find square root");return A}}),Sa=function(t,e){const r=e=>ya(__spreadValues(__spreadValues({},t),va(e)));return Object.freeze(__spreadProps(__spreadValues({},r(e)),{create:r}))}({a:BigInt(0),b:BigInt(7),Fp:ka,n:ba,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=ba,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Aa*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,a=BigInt("0x100000000000000000000000000000000"),o=xa(s*t,e),l=xa(-n*t,e);let c=$s(t-o*r-l*i,e),u=$s(-o*n-l*s,e);const h=c>a,d=u>a;if(h&&(c=e-c),d&&(u=e-u),c>a||u>a)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:h,k1:c,k2neg:d,k2:u}}}},Ui);BigInt(0),Sa.ProjectivePoint;const Na="0x0000000000000000000000000000000000000000",Pa="0x0000000000000000000000000000000000000000000000000000000000000000",Ca=BigInt(0),Ta=BigInt(1),Ra=BigInt(2),Ga=BigInt(27),Ma=BigInt(28),Ia=BigInt(35),Ba={};function Oa(t){return Yr(hn(t),32)}const Fa=class t{constructor(t,e,r,n){__privateAdd(this,nt,void 0),__privateAdd(this,it,void 0),__privateAdd(this,st,void 0),__privateAdd(this,at,void 0),Lr(t,Ba,"Signature"),__privateSet(this,nt,e),__privateSet(this,it,r),__privateSet(this,st,n),__privateSet(this,at,null)}get r(){return __privateGet(this,nt)}set r(t){Or(32===Kr(t),"invalid r","value",t),__privateSet(this,nt,Vr(t))}get s(){return __privateGet(this,it)}set s(t){Or(32===Kr(t),"invalid s","value",t);const e=Vr(t);Or(parseInt(e.substring(0,3))<8,"non-canonical s","value",e),__privateSet(this,it,e)}get v(){return __privateGet(this,st)}set v(t){const e=cn(t,"value");Or(27===e||28===e,"invalid v","v",t),__privateSet(this,st,e)}get networkV(){return __privateGet(this,at)}get legacyChainId(){const e=this.networkV;return null==e?null:t.getChainId(e)}get yParity(){return 27===this.v?0:1}get yParityAndS(){const t=jr(this.s);return this.yParity&&(t[0]|=128),Vr(t)}get compactSerialized(){return Jr([this.r,this.yParityAndS])}get serialized(){return Jr([this.r,this.s,this.yParity?"0x1c":"0x1b"])}[Symbol.for("nodejs.util.inspect.custom")](){return`Signature { r: "${this.r}", s: "${this.s}", yParity: ${this.yParity}, networkV: ${this.networkV} }`}clone(){const e=new t(Ba,this.r,this.s,this.v);return this.networkV&&__privateSet(e,at,this.networkV),e}toJSON(){const t=this.networkV;return{_type:"signature",networkV:null!=t?t.toString():null,r:this.r,s:this.s,v:this.v}}static getChainId(t){const e=sn(t,"v");return e==Ga||e==Ma?Ca:(Or(e>=Ia,"invalid EIP-155 v","v",t),(e-Ia)/Ra)}static getChainIdV(t,e){return sn(t)*Ra+BigInt(35+e-27)}static getNormalizedV(t){const e=sn(t);return e===Ca||e===Ga?27:e===Ta||e===Ma?28:(Or(e>=Ia,"invalid v","v",t),e&Ta?27:28)}static from(e){function r(t,r){Or(t,r,"signature",e)}if(null==e)return new t(Ba,Pa,Pa,27);if("string"==typeof e){const n=jr(e,"signature");if(64===n.length){const e=Vr(n.slice(0,32)),r=n.slice(32,64),i=128&r[0]?28:27;return r[0]&=127,new t(Ba,e,Vr(r),i)}if(65===n.length){const e=Vr(n.slice(0,32)),i=n.slice(32,64);r(!(128&i[0]),"non-canonical s");const s=t.getNormalizedV(n[64]);return new t(Ba,e,Vr(i),s)}r(!1,"invalid raw signature length")}if(e instanceof t)return e.clone();const n=e.r;r(null!=n,"missing r");const i=Oa(n),s=function(t,e){if(null!=t)return Oa(t);if(null!=e){r(Wr(e,32),"invalid yParityAndS");const t=jr(e);return t[0]&=127,Vr(t)}r(!1,"missing s")}(e.s,e.yParityAndS);r(!(128&jr(s)[0]),"non-canonical s");const{networkV:a,v:o}=function(e,n,i){if(null!=e){const r=sn(e);return{networkV:r>=Ia?r:void 0,v:t.getNormalizedV(r)}}if(null!=n)return r(Wr(n,32),"invalid yParityAndS"),{v:128&jr(n)[0]?28:27};if(null!=i){switch(cn(i,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}r(!1,"invalid yParity")}r(!1,"missing v")}(e.v,e.yParityAndS,e.yParity),l=new t(Ba,i,s,o);return a&&__privateSet(l,at,a),r(null==e.yParity||cn(e.yParity,"sig.yParity")===l.yParity,"yParity mismatch"),r(null==e.yParityAndS||e.yParityAndS===l.yParityAndS,"yParityAndS mismatch"),l}};nt=new WeakMap,it=new WeakMap,st=new WeakMap,at=new WeakMap;let Ua=Fa;ot=new WeakMap;let La=class t{constructor(t){__privateAdd(this,ot,void 0),Or(32===Kr(t),"invalid private key","privateKey","[REDACTED]"),__privateSet(this,ot,Vr(t))}get privateKey(){return __privateGet(this,ot)}get publicKey(){return t.computePublicKey(__privateGet(this,ot))}get compressedPublicKey(){return t.computePublicKey(__privateGet(this,ot),!0)}sign(t){Or(32===Kr(t),"invalid digest length","digest",t);const e=Sa.sign(Hr(t),Hr(__privateGet(this,ot)),{lowS:!0});return Ua.from({r:un(e.r,32),s:un(e.s,32),v:e.recovery?28:27})}computeSharedSecret(e){const r=t.computePublicKey(e);return Vr(Sa.getSharedSecret(Hr(__privateGet(this,ot)),jr(r),!1))}static computePublicKey(t,e){let r=jr(t,"key");if(32===r.length){return Vr(Sa.getPublicKey(r,!!e))}if(64===r.length){const t=new Uint8Array(65);t[0]=4,t.set(r,1),r=t}return Vr(Sa.ProjectivePoint.fromHex(r).toRawBytes(e))}static recoverPublicKey(t,e){Or(32===Kr(t),"invalid digest length","digest",t);const r=Ua.from(e);let n=Sa.Signature.fromCompact(Hr(Jr([r.r,r.s])));n=n.addRecoveryBit(r.yParity);const i=n.recoverPublicKey(Hr(t));return Or(null!=i,"invalid signature for digest","signature",e),"0x"+i.toHex(!1)}static addPoints(e,r,n){const i=Sa.ProjectivePoint.fromHex(t.computePublicKey(e).substring(2)),s=Sa.ProjectivePoint.fromHex(t.computePublicKey(r).substring(2));return"0x"+i.add(s).toHex(!!n)}};const Da=BigInt(0),ja=BigInt(36);function Ha(t){const e=(t=t.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let i=0;i<40;i++)r[i]=e[i].charCodeAt(0);const n=jr(vs(r));for(let i=0;i<40;i+=2)n[i>>1]>>4>=8&&(e[i]=e[i].toUpperCase()),(15&n[i>>1])>=8&&(e[i+1]=e[i+1].toUpperCase());return"0x"+e.join("")}const Wa={};for(let Np=0;Np<10;Np++)Wa[String(Np)]=String(Np);for(let Np=0;Np<26;Np++)Wa[String.fromCharCode(65+Np)]=String(10+Np);const Qa=function(){const t={};for(let e=0;e<36;e++){t["0123456789abcdefghijklmnopqrstuvwxyz"[e]]=BigInt(e)}return t}();function za(t){if(Or("string"==typeof t,"invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/)){t.startsWith("0x")||(t="0x"+t);const e=Ha(t);return Or(!t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===t,"bad address checksum","address",t),e}if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){Or(t.substring(2,4)===function(t){let e=(t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00").split("").map((t=>Wa[t])).join("");for(;e.length>=15;){let t=e.substring(0,15);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}(t),"bad icap checksum","address",t);let e=function(t){t=t.toLowerCase();let e=Da;for(let r=0;r<t.length;r++)e=e*ja+Qa[t[r]];return e}(t.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return Ha("0x"+e)}Or(!1,"invalid address","address",t)}function Va(t){return t&&"function"==typeof t.getAddress}function Ja(t,e){return __async(this,null,(function*(){const r=yield e;return null!=r&&"0x0000000000000000000000000000000000000000"!==r||(Br("string"!=typeof t,"unconfigured name","UNCONFIGURED_NAME",{value:t}),Or(!1,"invalid AddressLike value; did not resolve to a value address","target",t)),za(r)}))}function Ka(t,e){return"string"==typeof t?t.match(/^0x[0-9a-f]{40}$/i)?za(t):(Br(null!=e,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),Ja(t,e.resolveName(t))):Va(t)?Ja(t,t.getAddress()):t&&"function"==typeof t.then?Ja(t,t):void Or(!1,"unsupported addressable value","target",t)}const qa={};function Za(t,e){let r=!1;return e<0&&(r=!0,e*=-1),new $a(qa,`${r?"":"u"}int${e}`,t,{signed:r,width:e})}function Ya(t,e){return new $a(qa,`bytes${e||""}`,t,{size:e})}const Xa=Symbol.for("_ethers_typed");lt=new WeakMap;let $a=class t{constructor(t,e,r,n){__publicField(this,"type"),__publicField(this,"value"),__privateAdd(this,lt,void 0),__publicField(this,"_typedSymbol"),null==n&&(n=null),Lr(qa,t,"Typed"),Tr(this,{_typedSymbol:Xa,type:e,value:r}),__privateSet(this,lt,n),this.format()}format(){if("array"===this.type)throw new Error("");if("dynamicArray"===this.type)throw new Error("");return"tuple"===this.type?`tuple(${this.value.map((t=>t.format())).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return"string"===this.type}get tupleName(){if("tuple"!==this.type)throw TypeError("not a tuple");return __privateGet(this,lt)}get arrayLength(){if("array"!==this.type)throw TypeError("not an array");return!0===__privateGet(this,lt)?-1:!1===__privateGet(this,lt)?this.value.length:null}static from(e,r){return new t(qa,e,r)}static uint8(t){return Za(t,8)}static uint16(t){return Za(t,16)}static uint24(t){return Za(t,24)}static uint32(t){return Za(t,32)}static uint40(t){return Za(t,40)}static uint48(t){return Za(t,48)}static uint56(t){return Za(t,56)}static uint64(t){return Za(t,64)}static uint72(t){return Za(t,72)}static uint80(t){return Za(t,80)}static uint88(t){return Za(t,88)}static uint96(t){return Za(t,96)}static uint104(t){return Za(t,104)}static uint112(t){return Za(t,112)}static uint120(t){return Za(t,120)}static uint128(t){return Za(t,128)}static uint136(t){return Za(t,136)}static uint144(t){return Za(t,144)}static uint152(t){return Za(t,152)}static uint160(t){return Za(t,160)}static uint168(t){return Za(t,168)}static uint176(t){return Za(t,176)}static uint184(t){return Za(t,184)}static uint192(t){return Za(t,192)}static uint200(t){return Za(t,200)}static uint208(t){return Za(t,208)}static uint216(t){return Za(t,216)}static uint224(t){return Za(t,224)}static uint232(t){return Za(t,232)}static uint240(t){return Za(t,240)}static uint248(t){return Za(t,248)}static uint256(t){return Za(t,256)}static uint(t){return Za(t,256)}static int8(t){return Za(t,-8)}static int16(t){return Za(t,-16)}static int24(t){return Za(t,-24)}static int32(t){return Za(t,-32)}static int40(t){return Za(t,-40)}static int48(t){return Za(t,-48)}static int56(t){return Za(t,-56)}static int64(t){return Za(t,-64)}static int72(t){return Za(t,-72)}static int80(t){return Za(t,-80)}static int88(t){return Za(t,-88)}static int96(t){return Za(t,-96)}static int104(t){return Za(t,-104)}static int112(t){return Za(t,-112)}static int120(t){return Za(t,-120)}static int128(t){return Za(t,-128)}static int136(t){return Za(t,-136)}static int144(t){return Za(t,-144)}static int152(t){return Za(t,-152)}static int160(t){return Za(t,-160)}static int168(t){return Za(t,-168)}static int176(t){return Za(t,-176)}static int184(t){return Za(t,-184)}static int192(t){return Za(t,-192)}static int200(t){return Za(t,-200)}static int208(t){return Za(t,-208)}static int216(t){return Za(t,-216)}static int224(t){return Za(t,-224)}static int232(t){return Za(t,-232)}static int240(t){return Za(t,-240)}static int248(t){return Za(t,-248)}static int256(t){return Za(t,-256)}static int(t){return Za(t,-256)}static bytes1(t){return Ya(t,1)}static bytes2(t){return Ya(t,2)}static bytes3(t){return Ya(t,3)}static bytes4(t){return Ya(t,4)}static bytes5(t){return Ya(t,5)}static bytes6(t){return Ya(t,6)}static bytes7(t){return Ya(t,7)}static bytes8(t){return Ya(t,8)}static bytes9(t){return Ya(t,9)}static bytes10(t){return Ya(t,10)}static bytes11(t){return Ya(t,11)}static bytes12(t){return Ya(t,12)}static bytes13(t){return Ya(t,13)}static bytes14(t){return Ya(t,14)}static bytes15(t){return Ya(t,15)}static bytes16(t){return Ya(t,16)}static bytes17(t){return Ya(t,17)}static bytes18(t){return Ya(t,18)}static bytes19(t){return Ya(t,19)}static bytes20(t){return Ya(t,20)}static bytes21(t){return Ya(t,21)}static bytes22(t){return Ya(t,22)}static bytes23(t){return Ya(t,23)}static bytes24(t){return Ya(t,24)}static bytes25(t){return Ya(t,25)}static bytes26(t){return Ya(t,26)}static bytes27(t){return Ya(t,27)}static bytes28(t){return Ya(t,28)}static bytes29(t){return Ya(t,29)}static bytes30(t){return Ya(t,30)}static bytes31(t){return Ya(t,31)}static bytes32(t){return Ya(t,32)}static address(e){return new t(qa,"address",e)}static bool(e){return new t(qa,"bool",!!e)}static bytes(e){return new t(qa,"bytes",e)}static string(e){return new t(qa,"string",e)}static array(t,e){throw new Error("not implemented yet")}static tuple(t,e){throw new Error("not implemented yet")}static overrides(e){return new t(qa,"overrides",Object.assign({},e))}static isTyped(t){return t&&"object"==typeof t&&"_typedSymbol"in t&&t._typedSymbol===Xa}static dereference(e,r){if(t.isTyped(e)){if(e.type!==r)throw new Error(`invalid type: expecetd ${r}, got ${e.type}`);return e.value}return e}};class to extends gi{constructor(t){super("address","address",t,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(t,e){let r=$a.dereference(e,"string");try{r=za(r)}catch(n){return this._throwError(n.message,e)}return t.writeValue(r)}decode(t){return za(un(t.readValue(),20))}}class eo extends gi{constructor(t){super(t.name,t.type,"_",t.dynamic),__publicField(this,"coder"),this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,e){return this.coder.encode(t,e)}decode(t){return this.coder.decode(t)}}function ro(t,e,r){let n=[];if(Array.isArray(r))n=r;else if(r&&"object"==typeof r){let t={};n=e.map((e=>{const n=e.localName;return Br(n,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:e},value:r}),Br(!t[n],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:e},value:r}),t[n]=!0,r[n]}))}else Or(!1,"invalid tuple value","tuple",r);Or(e.length===n.length,"types/value length mismatch","tuple",r);let i=new mi,s=new mi,a=[];e.forEach(((t,e)=>{let r=n[e];if(t.dynamic){let e=s.length;t.encode(s,r);let n=i.writeUpdatableValue();a.push((t=>{n(t+e)}))}else t.encode(i,r)})),a.forEach((t=>{t(i.length)}));let o=t.appendWriter(i);return o+=t.appendWriter(s),o}function no(t,e){let r=[],n=[],i=t.subReader(0);return e.forEach((e=>{let s=null;if(e.dynamic){let r=t.readIndex(),n=i.subReader(r);try{s=e.decode(n)}catch(a){if(Gr(a,"BUFFER_OVERRUN"))throw a;s=a,s.baseType=e.name,s.name=e.localName,s.type=e.type}}else try{s=e.decode(t)}catch(a){if(Gr(a,"BUFFER_OVERRUN"))throw a;s=a,s.baseType=e.name,s.name=e.localName,s.type=e.type}if(null==s)throw new Error("investigate");r.push(s),n.push(e.localName||null)})),pi.fromItems(r,n)}class io extends gi{constructor(t,e,r){super("array",t.type+"["+(e>=0?e:"")+"]",r,-1===e||t.dynamic),__publicField(this,"coder"),__publicField(this,"length"),Tr(this,{coder:t,length:e})}defaultValue(){const t=this.coder.defaultValue(),e=[];for(let r=0;r<this.length;r++)e.push(t);return e}encode(t,e){const r=$a.dereference(e,"array");Array.isArray(r)||this._throwError("expected array value",r);let n=this.length;-1===n&&(n=r.length,t.writeValue(r.length)),Fr(r.length,n,"coder array"+(this.localName?" "+this.localName:""));let i=[];for(let s=0;s<r.length;s++)i.push(this.coder);return ro(t,i,r)}decode(t){let e=this.length;-1===e&&(e=t.readIndex(),Br(e*ii<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:e*ii,length:t.dataLength}));let r=[];for(let n=0;n<e;n++)r.push(new eo(this.coder));return no(t,r)}}class so extends gi{constructor(t){super("bool","bool",t,!1)}defaultValue(){return!1}encode(t,e){const r=$a.dereference(e,"bool");return t.writeValue(r?1:0)}decode(t){return!!t.readValue()}}class ao extends gi{constructor(t,e){super(t,t,e,!0)}defaultValue(){return"0x"}encode(t,e){e=Hr(e);let r=t.writeValue(e.length);return r+=t.writeBytes(e),r}decode(t){return t.readBytes(t.readIndex(),!0)}}class oo extends ao{constructor(t){super("bytes",t)}decode(t){return Vr(super.decode(t))}}class lo extends gi{constructor(t,e){let r="bytes"+String(t);super(r,r,e,!1),__publicField(this,"size"),Tr(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+2*this.size)}encode(t,e){let r=Hr($a.dereference(e,this.type));return r.length!==this.size&&this._throwError("incorrect data length",e),t.writeBytes(r)}decode(t){return Vr(t.readBytes(this.size))}}const co=new Uint8Array([]);class uo extends gi{constructor(t){super("null","",t,!1)}defaultValue(){return null}encode(t,e){return null!=e&&this._throwError("not null",e),t.writeBytes(co)}decode(t){return t.readBytes(0),null}}const ho=BigInt(0),po=BigInt(1),fo=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class go extends gi{constructor(t,e,r){const n=(e?"int":"uint")+8*t;super(n,n,r,!1),__publicField(this,"size"),__publicField(this,"signed"),Tr(this,{size:t,signed:e},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,e){let r=sn($a.dereference(e,this.type)),n=nn(fo,256);if(this.signed){let t=nn(n,8*this.size-1);(r>t||r<-(t+po))&&this._throwError("value out-of-bounds",e),r=rn(r,256)}else(r<ho||r>nn(n,8*this.size))&&this._throwError("value out-of-bounds",e);return t.writeValue(r)}decode(t){let e=nn(t.readValue(),8*this.size);return this.signed&&(e=en(e,8*this.size)),e}}class mo extends ao{constructor(t){super("string",t)}defaultValue(){return""}encode(t,e){return super.encode(t,yn($a.dereference(e,"string")))}decode(t){return vn(super.decode(t))}}class _o extends gi{constructor(t,e){let r=!1;const n=[];t.forEach((t=>{t.dynamic&&(r=!0),n.push(t.type)}));super("tuple","tuple("+n.join(",")+")",e,r),__publicField(this,"coders"),Tr(this,{coders:Object.freeze(t.slice())})}defaultValue(){const t=[];this.coders.forEach((e=>{t.push(e.defaultValue())}));const e=this.coders.reduce(((t,e)=>{const r=e.localName;return r&&(t[r]||(t[r]=0),t[r]++),t}),{});return this.coders.forEach(((r,n)=>{let i=r.localName;i&&1===e[i]&&("length"===i&&(i="_length"),null==t[i]&&(t[i]=t[n]))})),Object.freeze(t)}encode(t,e){const r=$a.dereference(e,"tuple");return ro(t,this.coders,r)}decode(t){return no(t,this.coders)}}function yo(t,e){return{address:za(t),storageKeys:e.map(((t,e)=>(Or(Wr(t,32),"invalid slot",`storageKeys[${e}]`,t),t.toLowerCase())))}}function vo(t){if(Array.isArray(t))return t.map(((e,r)=>Array.isArray(e)?(Or(2===e.length,"invalid slot set",`value[${r}]`,e),yo(e[0],e[1])):(Or(null!=e&&"object"==typeof e,"invalid address-slot set","value",t),yo(e.address,e.storageKeys))));Or(null!=t&&"object"==typeof t,"invalid access list","value",t);const e=Object.keys(t).map((e=>{const r=t[e].reduce(((t,e)=>(t[e]=!0,t)),{});return yo(e,Object.keys(r).sort())}));return e.sort(((t,e)=>t.address.localeCompare(e.address))),e}function wo(t){return{address:za(t.address),nonce:sn(null!=t.nonce?t.nonce:0),chainId:sn(null!=t.chainId?t.chainId:0),signature:Ua.from(t.signature)}}function bo(t,e){return function(t){let e;return e="string"==typeof t?La.computePublicKey(t,!1):t.publicKey,za(vs("0x"+e.substring(4)).substring(26))}(La.recoverPublicKey(t,e))}const Ao=BigInt(0),Eo=BigInt(2),xo=BigInt(27),ko=BigInt(28),So=BigInt(35),No=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Po=131072;function Co(t,e){let r=t.toString(16);for(;r.length<2;)r="0"+r;return r+=Es(e).substring(4),"0x"+r}function To(t){return"0x"===t?null:za(t)}function Ro(t,e){try{return vo(t)}catch(r){Or(!1,r.message,e,t)}}function Go(t,e){try{if(!Array.isArray(t))throw new Error("authorizationList: invalid array");const e=[];for(let r=0;r<t.length;r++){const n=t[r];if(!Array.isArray(n))throw new Error(`authorization[${r}]: invalid array`);if(6!==n.length)throw new Error(`authorization[${r}]: wrong length`);if(!n[1])throw new Error(`authorization[${r}]: null address`);e.push({address:To(n[1]),nonce:Io(n[2],"nonce"),chainId:Io(n[0],"chainId"),signature:Ua.from({yParity:Mo(n[3],"yParity"),r:Yr(n[4],32),s:Yr(n[5],32)})})}return e}catch(r){Or(!1,r.message,e,t)}}function Mo(t,e){return"0x"===t?0:cn(t,e)}function Io(t,e){if("0x"===t)return Ao;const r=sn(t,e);return Or(r<=No,"value exceeds uint size",e,r),r}function Bo(t,e){const r=sn(t,"value"),n=hn(r);return Or(n.length<=32,"value too large",`tx.${e}`,r),n}function Oo(t){return vo(t).map((t=>[t.address,t.storageKeys]))}function Fo(t,e){Or(Array.isArray(t),`invalid ${e}`,"value",t);for(let r=0;r<t.length;r++)Or(Wr(t[r],32),"invalid ${ param } hash",`value[${r}]`,t[r]);return t}function Uo(t,e){let r;try{if(r=Mo(e[0],"yParity"),0!==r&&1!==r)throw new Error("bad yParity")}catch(a){Or(!1,"invalid yParity","yParity",e[0])}const n=Yr(e[1],32),i=Yr(e[2],32),s=Ua.from({r:n,s:i,yParity:r});t.signature=s}ct=new WeakMap,ut=new WeakMap,ht=new WeakMap,dt=new WeakMap,pt=new WeakMap,ft=new WeakMap,gt=new WeakMap,mt=new WeakMap,_t=new WeakMap,yt=new WeakMap,vt=new WeakMap,wt=new WeakMap,bt=new WeakMap,At=new WeakMap,Et=new WeakMap,xt=new WeakMap,kt=new WeakMap,St=new WeakSet,Nt=function(t,e){Br(!t||null!=this.signature,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const r=t?this.signature:null;switch(this.inferType()){case 0:return function(t,e){const r=[Bo(t.nonce,"nonce"),Bo(t.gasPrice||0,"gasPrice"),Bo(t.gasLimit,"gasLimit"),t.to||"0x",Bo(t.value,"value"),t.data];let n=Ao;if(t.chainId!=Ao)n=sn(t.chainId,"tx.chainId"),Or(!e||null==e.networkV||e.legacyChainId===n,"tx.chainId/sig.v mismatch","sig",e);else if(t.signature){const e=t.signature.legacyChainId;null!=e&&(n=e)}if(!e)return n!==Ao&&(r.push(hn(n)),r.push("0x"),r.push("0x")),ei(r);let i=BigInt(27+e.yParity);return n!==Ao?i=Ua.getChainIdV(n,e.v):BigInt(e.v)!==i&&Or(!1,"tx.chainId/sig.v mismatch","sig",e),r.push(hn(i)),r.push(hn(e.r)),r.push(hn(e.s)),ei(r)}(this,r);case 1:return function(t,e){const r=[Bo(t.chainId,"chainId"),Bo(t.nonce,"nonce"),Bo(t.gasPrice||0,"gasPrice"),Bo(t.gasLimit,"gasLimit"),t.to||"0x",Bo(t.value,"value"),t.data,Oo(t.accessList||[])];return e&&(r.push(Bo(e.yParity,"recoveryParam")),r.push(hn(e.r)),r.push(hn(e.s))),Jr(["0x01",ei(r)])}(this,r);case 2:return function(t,e){const r=[Bo(t.chainId,"chainId"),Bo(t.nonce,"nonce"),Bo(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Bo(t.maxFeePerGas||0,"maxFeePerGas"),Bo(t.gasLimit,"gasLimit"),t.to||"0x",Bo(t.value,"value"),t.data,Oo(t.accessList||[])];return e&&(r.push(Bo(e.yParity,"yParity")),r.push(hn(e.r)),r.push(hn(e.s))),Jr(["0x02",ei(r)])}(this,r);case 3:return function(t,e,r){const n=[Bo(t.chainId,"chainId"),Bo(t.nonce,"nonce"),Bo(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Bo(t.maxFeePerGas||0,"maxFeePerGas"),Bo(t.gasLimit,"gasLimit"),t.to||Na,Bo(t.value,"value"),t.data,Oo(t.accessList||[]),Bo(t.maxFeePerBlobGas||0,"maxFeePerBlobGas"),Fo(t.blobVersionedHashes||[],"blobVersionedHashes")];return e&&(n.push(Bo(e.yParity,"yParity")),n.push(hn(e.r)),n.push(hn(e.s)),r)?Jr(["0x03",ei([n,r.map((t=>t.data)),r.map((t=>t.commitment)),r.map((t=>t.proof))])]):Jr(["0x03",ei(n)])}(this,r,e?this.blobs:null);case 4:return function(t,e){const r=[Bo(t.chainId,"chainId"),Bo(t.nonce,"nonce"),Bo(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Bo(t.maxFeePerGas||0,"maxFeePerGas"),Bo(t.gasLimit,"gasLimit"),t.to||"0x",Bo(t.value,"value"),t.data,Oo(t.accessList||[]),(n=t.authorizationList||[],n.map((t=>[Bo(t.chainId,"chainId"),t.address,Bo(t.nonce,"nonce"),Bo(t.signature.yParity,"yParity"),t.signature.r,t.signature.s])))];var n;return e&&(r.push(Bo(e.yParity,"yParity")),r.push(hn(e.r)),r.push(hn(e.s))),Jr(["0x04",ei(r)])}(this,r)}Br(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})};let Lo=class t{constructor(){__privateAdd(this,St),__privateAdd(this,ct,void 0),__privateAdd(this,ut,void 0),__privateAdd(this,ht,void 0),__privateAdd(this,dt,void 0),__privateAdd(this,pt,void 0),__privateAdd(this,ft,void 0),__privateAdd(this,gt,void 0),__privateAdd(this,mt,void 0),__privateAdd(this,_t,void 0),__privateAdd(this,yt,void 0),__privateAdd(this,vt,void 0),__privateAdd(this,wt,void 0),__privateAdd(this,bt,void 0),__privateAdd(this,At,void 0),__privateAdd(this,Et,void 0),__privateAdd(this,xt,void 0),__privateAdd(this,kt,void 0),__privateSet(this,ct,null),__privateSet(this,ut,null),__privateSet(this,dt,0),__privateSet(this,pt,Ao),__privateSet(this,ft,null),__privateSet(this,gt,null),__privateSet(this,mt,null),__privateSet(this,ht,"0x"),__privateSet(this,_t,Ao),__privateSet(this,yt,Ao),__privateSet(this,vt,null),__privateSet(this,wt,null),__privateSet(this,bt,null),__privateSet(this,At,null),__privateSet(this,Et,null),__privateSet(this,xt,null),__privateSet(this,kt,null)}get type(){return __privateGet(this,ct)}set type(t){switch(t){case null:__privateSet(this,ct,null);break;case 0:case"legacy":__privateSet(this,ct,0);break;case 1:case"berlin":case"eip-2930":__privateSet(this,ct,1);break;case 2:case"london":case"eip-1559":__privateSet(this,ct,2);break;case 3:case"cancun":case"eip-4844":__privateSet(this,ct,3);break;case 4:case"pectra":case"eip-7702":__privateSet(this,ct,4);break;default:Or(!1,"unsupported transaction type","type",t)}}get typeName(){switch(this.type){case 0:return"legacy";case 1:return"eip-2930";case 2:return"eip-1559";case 3:return"eip-4844";case 4:return"eip-7702"}return null}get to(){const t=__privateGet(this,ut);return null==t&&3===this.type?Na:t}set to(t){__privateSet(this,ut,null==t?null:za(t))}get nonce(){return __privateGet(this,dt)}set nonce(t){__privateSet(this,dt,cn(t,"value"))}get gasLimit(){return __privateGet(this,pt)}set gasLimit(t){__privateSet(this,pt,sn(t))}get gasPrice(){const t=__privateGet(this,ft);return null!=t||0!==this.type&&1!==this.type?t:Ao}set gasPrice(t){__privateSet(this,ft,null==t?null:sn(t,"gasPrice"))}get maxPriorityFeePerGas(){const t=__privateGet(this,gt);return null==t?2===this.type||3===this.type?Ao:null:t}set maxPriorityFeePerGas(t){__privateSet(this,gt,null==t?null:sn(t,"maxPriorityFeePerGas"))}get maxFeePerGas(){const t=__privateGet(this,mt);return null==t?2===this.type||3===this.type?Ao:null:t}set maxFeePerGas(t){__privateSet(this,mt,null==t?null:sn(t,"maxFeePerGas"))}get data(){return __privateGet(this,ht)}set data(t){__privateSet(this,ht,Vr(t))}get value(){return __privateGet(this,_t)}set value(t){__privateSet(this,_t,sn(t,"value"))}get chainId(){return __privateGet(this,yt)}set chainId(t){__privateSet(this,yt,sn(t))}get signature(){return __privateGet(this,vt)||null}set signature(t){__privateSet(this,vt,null==t?null:Ua.from(t))}get accessList(){const t=__privateGet(this,wt)||null;return null==t?1===this.type||2===this.type||3===this.type?[]:null:t}set accessList(t){__privateSet(this,wt,null==t?null:vo(t))}get authorizationList(){const t=__privateGet(this,kt)||null;return null==t&&4===this.type?[]:t}set authorizationList(t){__privateSet(this,kt,null==t?null:t.map((t=>wo(t))))}get maxFeePerBlobGas(){const t=__privateGet(this,bt);return null==t&&3===this.type?Ao:t}set maxFeePerBlobGas(t){__privateSet(this,bt,null==t?null:sn(t,"maxFeePerBlobGas"))}get blobVersionedHashes(){let t=__privateGet(this,At);return null==t&&3===this.type?[]:t}set blobVersionedHashes(t){if(null!=t){Or(Array.isArray(t),"blobVersionedHashes must be an Array","value",t),t=t.slice();for(let e=0;e<t.length;e++)Or(Wr(t[e],32),"invalid blobVersionedHash",`value[${e}]`,t[e])}__privateSet(this,At,t)}get blobs(){return null==__privateGet(this,xt)?null:__privateGet(this,xt).map((t=>Object.assign({},t)))}set blobs(t){if(null==t)return void __privateSet(this,xt,null);const e=[],r=[];for(let n=0;n<t.length;n++){const i=t[n];if(Qr(i)){Br(__privateGet(this,Et),"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let t=jr(i);if(Or(t.length<=Po,"blob is too large",`blobs[${n}]`,i),t.length!==Po){const e=new Uint8Array(Po);e.set(t),t=e}const s=__privateGet(this,Et).blobToKzgCommitment(t),a=Vr(__privateGet(this,Et).computeBlobKzgProof(t,s));e.push({data:Vr(t),commitment:Vr(s),proof:a}),r.push(Co(1,s))}else{const t=Vr(i.commitment);e.push({data:Vr(i.data),commitment:t,proof:Vr(i.proof)}),r.push(Co(1,t))}}__privateSet(this,xt,e),__privateSet(this,At,r)}get kzg(){return __privateGet(this,Et)}set kzg(t){__privateSet(this,Et,null==t?null:function(t){return{blobToKzgCommitment:e=>{if("computeBlobProof"in t){if("blobToKzgCommitment"in t&&"function"==typeof t.blobToKzgCommitment)return jr(t.blobToKzgCommitment(Vr(e)))}else if("blobToKzgCommitment"in t&&"function"==typeof t.blobToKzgCommitment)return jr(t.blobToKzgCommitment(e));if("blobToKZGCommitment"in t&&"function"==typeof t.blobToKZGCommitment)return jr(t.blobToKZGCommitment(Vr(e)));Or(!1,"unsupported KZG library","kzg",t)},computeBlobKzgProof:(e,r)=>"computeBlobProof"in t&&"function"==typeof t.computeBlobProof?jr(t.computeBlobProof(Vr(e),Vr(r))):"computeBlobKzgProof"in t&&"function"==typeof t.computeBlobKzgProof?t.computeBlobKzgProof(e,r):"computeBlobKZGProof"in t&&"function"==typeof t.computeBlobKZGProof?jr(t.computeBlobKZGProof(Vr(e),Vr(r))):void Or(!1,"unsupported KZG library","kzg",t)}}(t))}get hash(){return null==this.signature?null:vs(__privateMethod(this,St,Nt).call(this,!0,!1))}get unsignedHash(){return vs(this.unsignedSerialized)}get from(){return null==this.signature?null:bo(this.unsignedHash,this.signature)}get fromPublicKey(){return null==this.signature?null:La.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return null!=this.signature}get serialized(){return __privateMethod(this,St,Nt).call(this,!0,!0)}get unsignedSerialized(){return __privateMethod(this,St,Nt).call(this,!1,!1)}inferType(){const t=this.inferTypes();return t.indexOf(2)>=0?2:t.pop()}inferTypes(){const t=null!=this.gasPrice,e=null!=this.maxFeePerGas||null!=this.maxPriorityFeePerGas,r=null!=this.accessList,n=null!=__privateGet(this,bt)||__privateGet(this,At);null!=this.maxFeePerGas&&null!=this.maxPriorityFeePerGas&&Br(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),Br(!e||0!==this.type&&1!==this.type,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),Br(0!==this.type||!r,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const i=[];return null!=this.type?i.push(this.type):this.authorizationList&&this.authorizationList.length?i.push(4):e?i.push(2):t?(i.push(1),r||i.push(0)):r?(i.push(1),i.push(2)):(n&&this.to||(i.push(0),i.push(1),i.push(2)),i.push(3)),i.sort(),i}isLegacy(){return 0===this.type}isBerlin(){return 1===this.type}isLondon(){return 2===this.type}isCancun(){return 3===this.type}clone(){return t.from(this)}toJSON(){const t=t=>null==t?null:t.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:t(this.gasLimit),gasPrice:t(this.gasPrice),maxPriorityFeePerGas:t(this.maxPriorityFeePerGas),maxFeePerGas:t(this.maxFeePerGas),value:t(this.value),chainId:t(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from(e){if(null==e)return new t;if("string"==typeof e){const r=jr(e);if(r[0]>=127)return t.from(function(t){const e=Yn(t);Or(Array.isArray(e)&&(9===e.length||6===e.length),"invalid field count for legacy transaction","data",t);const r={type:0,nonce:Mo(e[0],"nonce"),gasPrice:Io(e[1],"gasPrice"),gasLimit:Io(e[2],"gasLimit"),to:To(e[3]),value:Io(e[4],"value"),data:Vr(e[5]),chainId:Ao};if(6===e.length)return r;const n=Io(e[6],"v"),i=Io(e[7],"r"),s=Io(e[8],"s");if(i===Ao&&s===Ao)r.chainId=n;else{let t=(n-So)/Eo;t<Ao&&(t=Ao),r.chainId=t,Or(t!==Ao||n===xo||n===ko,"non-canonical legacy v","v",e[6]),r.signature=Ua.from({r:Yr(e[7],32),s:Yr(e[8],32),v:n})}return r}(r));switch(r[0]){case 1:return t.from(function(t){const e=Yn(jr(t).slice(1));Or(Array.isArray(e)&&(8===e.length||11===e.length),"invalid field count for transaction type: 1","data",Vr(t));const r={type:1,chainId:Io(e[0],"chainId"),nonce:Mo(e[1],"nonce"),gasPrice:Io(e[2],"gasPrice"),gasLimit:Io(e[3],"gasLimit"),to:To(e[4]),value:Io(e[5],"value"),data:Vr(e[6]),accessList:Ro(e[7],"accessList")};return 8===e.length||Uo(r,e.slice(8)),r}(r));case 2:return t.from(function(t){const e=Yn(jr(t).slice(1));Or(Array.isArray(e)&&(9===e.length||12===e.length),"invalid field count for transaction type: 2","data",Vr(t));const r={type:2,chainId:Io(e[0],"chainId"),nonce:Mo(e[1],"nonce"),maxPriorityFeePerGas:Io(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Io(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Io(e[4],"gasLimit"),to:To(e[5]),value:Io(e[6],"value"),data:Vr(e[7]),accessList:Ro(e[8],"accessList")};return 9===e.length||Uo(r,e.slice(9)),r}(r));case 3:return t.from(function(t){let e=Yn(jr(t).slice(1)),r="3",n=null;if(4===e.length&&Array.isArray(e[0])){r="3 (network format)";const t=e[1],i=e[2],s=e[3];Or(Array.isArray(t),"invalid network format: blobs not an array","fields[1]",t),Or(Array.isArray(i),"invalid network format: commitments not an array","fields[2]",i),Or(Array.isArray(s),"invalid network format: proofs not an array","fields[3]",s),Or(t.length===i.length,"invalid network format: blobs/commitments length mismatch","fields",e),Or(t.length===s.length,"invalid network format: blobs/proofs length mismatch","fields",e),n=[];for(let r=0;r<e[1].length;r++)n.push({data:t[r],commitment:i[r],proof:s[r]});e=e[0]}Or(Array.isArray(e)&&(11===e.length||14===e.length),`invalid field count for transaction type: ${r}`,"data",Vr(t));const i={type:3,chainId:Io(e[0],"chainId"),nonce:Mo(e[1],"nonce"),maxPriorityFeePerGas:Io(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Io(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Io(e[4],"gasLimit"),to:To(e[5]),value:Io(e[6],"value"),data:Vr(e[7]),accessList:Ro(e[8],"accessList"),maxFeePerBlobGas:Io(e[9],"maxFeePerBlobGas"),blobVersionedHashes:e[10]};n&&(i.blobs=n),Or(null!=i.to,`invalid address for transaction type: ${r}`,"data",t),Or(Array.isArray(i.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",t);for(let s=0;s<i.blobVersionedHashes.length;s++)Or(Wr(i.blobVersionedHashes[s],32),`invalid blobVersionedHash at index ${s}: must be length 32`,"data",t);return 11===e.length||Uo(i,e.slice(11)),i}(r));case 4:return t.from(function(t){const e=Yn(jr(t).slice(1));Or(Array.isArray(e)&&(10===e.length||13===e.length),"invalid field count for transaction type: 4","data",Vr(t));const r={type:4,chainId:Io(e[0],"chainId"),nonce:Mo(e[1],"nonce"),maxPriorityFeePerGas:Io(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Io(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Io(e[4],"gasLimit"),to:To(e[5]),value:Io(e[6],"value"),data:Vr(e[7]),accessList:Ro(e[8],"accessList"),authorizationList:Go(e[9],"authorizationList")};return 10===e.length||Uo(r,e.slice(10)),r}(r))}Br(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const r=new t;return null!=e.type&&(r.type=e.type),null!=e.to&&(r.to=e.to),null!=e.nonce&&(r.nonce=e.nonce),null!=e.gasLimit&&(r.gasLimit=e.gasLimit),null!=e.gasPrice&&(r.gasPrice=e.gasPrice),null!=e.maxPriorityFeePerGas&&(r.maxPriorityFeePerGas=e.maxPriorityFeePerGas),null!=e.maxFeePerGas&&(r.maxFeePerGas=e.maxFeePerGas),null!=e.maxFeePerBlobGas&&(r.maxFeePerBlobGas=e.maxFeePerBlobGas),null!=e.data&&(r.data=e.data),null!=e.value&&(r.value=e.value),null!=e.chainId&&(r.chainId=e.chainId),null!=e.signature&&(r.signature=Ua.from(e.signature)),null!=e.accessList&&(r.accessList=e.accessList),null!=e.authorizationList&&(r.authorizationList=e.authorizationList),null!=e.blobVersionedHashes&&(r.blobVersionedHashes=e.blobVersionedHashes),null!=e.kzg&&(r.kzg=e.kzg),null!=e.blobs&&(r.blobs=e.blobs),null!=e.hash&&(Or(r.isSigned(),"unsigned transaction cannot define '.hash'","tx",e),Or(r.hash===e.hash,"hash mismatch","tx",e)),null!=e.from&&(Or(r.isSigned(),"unsigned transaction cannot define '.from'","tx",e),Or(r.from.toLowerCase()===(e.from||"").toLowerCase(),"from mismatch","tx",e)),r}};function Do(t){return vs(yn(t))}const jo=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]);function Ho(t){return function(t){let e=0;return()=>t[e++]}(function(t){let e=0;function r(){return t[e++]<<8|t[e++]}let n=r(),i=1,s=[0,1];for(let w=1;w<n;w++)s.push(i+=r());let a=r(),o=e;e+=a;let l=0,c=0;function u(){return 0==l&&(c=c<<8|t[e++],l=8),c>>--l&1}const h=__pow(2,31),d=h>>>1,p=d>>1,f=h-1;let g=0;for(let w=0;w<31;w++)g=g<<1|u();let m=[],_=0,y=h;for(;;){let t=Math.floor(((g-_+1)*i-1)/y),e=0,r=n;for(;r-e>1;){let n=e+r>>>1;t<s[n]?r=n:e=n}if(0==e)break;m.push(e);let a=_+Math.floor(y*s[e]/i),o=_+Math.floor(y*s[e+1]/i)-1;for(;0==((a^o)&d);)g=g<<1&f|u(),a=a<<1&f,o=o<<1&f|1;for(;a&~o&p;)g=g&d|g<<1&f>>>1|u(),a=a<<1^d,o=(o^d)<<1|d|1;_=a,y=1+o-a}let v=n-4;return m.map((e=>{switch(e-v){case 3:return v+65792+(t[o++]<<16|t[o++]<<8|t[o++]);case 2:return v+256+(t[o++]<<8|t[o++]);case 1:return v+t[o++];default:return e-1}}))}(function(t){let e=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach(((t,r)=>e[t.charCodeAt(0)]=r));let r=t.length,n=new Uint8Array(6*r>>3);for(let i=0,s=0,a=0,o=0;i<r;i++)o=o<<6|e[t.charCodeAt(i)],a+=6,a>=8&&(n[s++]=o>>(a-=8));return n}(t)))}function Wo(t){return 1&t?~t>>1:t>>1}function Qo(t,e){let r=Array(t);for(let n=0,i=0;n<t;n++)r[n]=i+=Wo(e());return r}function zo(t,e=0){let r=[];for(;;){let n=t(),i=t();if(!i)break;e+=n;for(let t=0;t<i;t++)r.push(e+t);e+=i+1}return r}function Vo(t){return Ko((()=>{let e=zo(t);if(e.length)return e}))}function Jo(t){let e=[];for(;;){let r=t();if(0==r)break;e.push(Zo(r,t))}for(;;){let r=t()-1;if(r<0)break;e.push(Yo(r,t))}return e.flat()}function Ko(t){let e=[];for(;;){let r=t(e.length);if(!r)break;e.push(r)}return e}function qo(t,e,r){let n=Array(t).fill().map((()=>[]));for(let i=0;i<e;i++)Qo(t,r).forEach(((t,e)=>n[e].push(t)));return n}function Zo(t,e){let r=1+e(),n=e(),i=Ko(e);return qo(i.length,1+t,e).flatMap(((t,e)=>{let[s,...a]=t;return Array(i[e]).fill().map(((t,e)=>{let i=e*n;return[s+e*r,a.map((t=>t+i))]}))}))}function Yo(t,e){return qo(1+e(),1+t,e).map((t=>[t[0],t.slice(1)]))}function Xo(t){return`{${function(t){return t.toString(16).toUpperCase().padStart(2,"0")}(t)}}`}function $o(t){let e=t.length;if(e<4096)return String.fromCodePoint(...t);let r=[];for(let n=0;n<e;)r.push(String.fromCodePoint(...t.slice(n,n+=4096)));return r.join("")}function tl(t,e){let r=t.length,n=r-e.length;for(let i=0;0==n&&i<r;i++)n=t[i]-e[i];return n}const el=44032,rl=4352,nl=4449,il=4519,sl=28,al=588;function ol(t){return t>>24&255}function ll(t){return 16777215&t}let cl,ul,hl,dl;function pl(t){return t>=el&&t<55204}function fl(t,e){if(t>=rl&&t<4371&&e>=nl&&e<4470)return el+(t-rl)*al+(e-nl)*sl;if(pl(t)&&e>il&&e<4547&&(t-el)%sl==0)return t+(e-il);{let r=dl.get(t);return r&&(r=r.get(e),r)?r:-1}}function gl(t){cl||function(){let t=Ho("AEUDTAHBCFQATQDRADAAcgAgADQAFAAsABQAHwAOACQADQARAAoAFwAHABIACAAPAAUACwAFAAwABAAQAAMABwAEAAoABQAIAAIACgABAAQAFAALAAIACwABAAIAAQAHAAMAAwAEAAsADAAMAAwACgANAA0AAwAKAAkABAAdAAYAZwDSAdsDJgC0CkMB8xhZAqfoC190UGcThgBurwf7PT09Pb09AjgJum8OjDllxHYUKXAPxzq6tABAxgK8ysUvWAgMPT09PT09PSs6LT2HcgWXWwFLoSMEEEl5RFVMKvO0XQ8ExDdJMnIgsj26PTQyy8FfEQ8AY8IPAGcEbwRwBHEEcgRzBHQEdQR2BHcEeAR6BHsEfAR+BIAEgfndBQoBYgULAWIFDAFiBNcE2ATZBRAFEQUvBdALFAsVDPcNBw13DYcOMA4xDjMB4BllHI0B2grbAMDpHLkQ7QHVAPRNQQFnGRUEg0yEB2uaJF8AJpIBpob5AERSMAKNoAXqaQLUBMCzEiACnwRZEkkVsS7tANAsBG0RuAQLEPABv9HICTUBXigPZwRBApMDOwAamhtaABqEAY8KvKx3LQ4ArAB8UhwEBAVSagD8AEFZADkBIadVj2UMUgx5Il4ANQC9AxIB1BlbEPMAs30CGxlXAhwZKQIECBc6EbsCoxngzv7UzRQA8M0BawL6ZwkN7wABAD33OQRcsgLJCjMCjqUChtw/km+NAsXPAoP2BT84PwURAK0RAvptb6cApQS/OMMey5HJS84UdxpxTPkCogVFITaTOwERAK5pAvkNBOVyA7q3BKlOJSALAgUIBRcEdASpBXqzABXFSWZOawLCOqw//AolCZdvv3dSBkEQGyelEPcMMwG1ATsN7UvYBPEGOwTJH30Z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SgI0T8B6/sfHAJYZaZ78thjOSIFumNWLQbeZixDCCC+v0YBtkxiBB3jefHqZ/dFHU+crbj6OvS1x/JDD7vlm7zOVPwpUC01nhxZuY/63E7g");cl=new Map(Vo(t).flatMap(((t,e)=>t.map((t=>[t,e+1<<24]))))),ul=new Set(zo(t)),hl=new Map,dl=new Map;for(let[e,r]of Jo(t)){if(!ul.has(e)&&2==r.length){let[t,n]=r,i=dl.get(t);i||(i=new Map,dl.set(t,i)),i.set(n,e)}hl.set(e,r.reverse())}}();let e=[],r=[],n=!1;function i(t){let r=cl.get(t);r&&(n=!0,t|=r),e.push(t)}for(let s of t)for(;;){if(s<128)e.push(s);else if(pl(s)){let t=s-el,e=t%al/sl|0,r=t%sl;i(rl+(t/al|0)),i(nl+e),r>0&&i(il+r)}else{let t=hl.get(s);t?r.push(...t):i(s)}if(!r.length)break;s=r.pop()}if(n&&e.length>1){let t=ol(e[0]);for(let r=1;r<e.length;r++){let n=ol(e[r]);if(0==n||t<=n){t=n;continue}let i=r-1;for(;;){let r=e[i+1];if(e[i+1]=e[i],e[i]=r,!i)break;if(t=ol(e[--i]),t<=n)break}t=ol(e[r])}}return e}function ml(t){return gl(t).map(ll)}function _l(t){return function(t){let e=[],r=[],n=-1,i=0;for(let s of t){let t=ol(s),a=ll(s);if(-1==n)0==t?n=a:e.push(a);else if(i>0&&i>=t)0==t?(e.push(n,...r),r.length=0,n=a):r.push(a),i=t;else{let s=fl(n,a);s>=0?n=s:0==i&&0==t?(e.push(n),n=a):(r.push(a),i=t)}}return n>=0&&e.push(n,...r),e}(gl(t))}const yl=".",vl=t=>Array.from(t);function wl(t,e){return t.P.has(e)||t.Q.has(e)}class bl extends Array{get is_emoji(){return!0}}let Al,El,xl,kl,Sl,Nl,Pl,Cl,Tl,Rl,Gl;function Ml(){if(Al)return;let t=Ho("AEEUdwmgDS8BxQKKAP4BOgDjATAAngDUAIMAoABoAOAAagCOAEQAhABMAHIAOwA9ACsANgAmAGIAHgAuACgAJwA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Hgtlk1iTbWWbHhohwFEYX7y51fUV2nuUmnoUcqnWIQAAgl9LTVX+Bc0QGNEhChxHR4YjfE51PUdGfsSFE6ck7BL3/hTf9jLq4G1IafINxOLKeAtO7quulYvH5YOBc+zX7CrMgWnW47/jfRsWnJjYYoE7xMfWV2HN2iyIqLI");const e=()=>zo(t),r=()=>new Set(e()),n=(t,e)=>e.forEach((e=>t.add(e)));Al=new Map(Jo(t)),El=r(),xl=e(),kl=new Set(e().map((t=>xl[t]))),xl=new Set(xl),Sl=r(),r();let i=Vo(t),s=t();const a=()=>{let t=new Set;return e().forEach((e=>n(t,i[e]))),n(t,e()),t};Nl=Ko((e=>{let r=Ko(t).map((t=>t+96));if(r.length){let n=e>=s;return r[0]-=32,r=$o(r),n&&(r=`Restricted[${r}]`),{N:r,P:a(),Q:a(),M:!t(),R:n}}})),Pl=r(),Cl=new Map;let o=e().concat(vl(Pl)).sort(((t,e)=>t-e));o.forEach(((e,r)=>{let n=t(),i=o[r]=n?o[r-n]:{V:[],M:new Map};i.V.push(e),Pl.has(e)||Cl.set(e,i)}));for(let{V:u,M:h}of new Set(Cl.values())){let t=[];for(let r of u){let e=Nl.filter((t=>wl(t,r))),i=t.find((({G:t})=>e.some((e=>t.has(e)))));i||(i={G:new Set,V:[]},t.push(i)),i.V.push(r),n(i.G,e)}let e=t.flatMap((t=>vl(t.G)));for(let{G:r,V:n}of t){let t=new Set(e.filter((t=>!r.has(t))));for(let e of n)h.set(e,t)}}Tl=new Set;let l=new Set;const c=t=>Tl.has(t)?l.add(t):Tl.add(t);for(let u of Nl){for(let t of u.P)c(t);for(let t of u.Q)c(t)}for(let u of Tl)Cl.has(u)||l.has(u)||Cl.set(u,1);n(Tl,ml(Tl)),Rl=function(t){let e=[],r=zo(t);return function t({S:r,B:n},i,s){if(!(4&r&&s===i[i.length-1])){2&r&&(s=i[i.length-1]),1&r&&e.push(i);for(let e of n)for(let r of e.Q)t(e,[...i,r],s)}}(function e(n){return{S:t(),B:Ko((()=>{let n=zo(t).map((t=>r[t]));if(n.length)return e(n)})),Q:n}}([]),[]),e}(t).map((t=>bl.from(t))).sort(tl),Gl=new Map;for(let u of Rl){let t=[Gl];for(let e of u){let r=t.map((t=>{let r=t.get(e);return r||(r=new Map,t.set(e,r)),r}));65039===e?t.push(...r):t=r}for(let e of t)e.V=u}}function Il(t){return(Fl(t)?"":`${Bl(Ol([t]))} `)+Xo(t)}function Bl(t){return`"${t}"‎`}function Ol(t,e=1/0,r=Xo){let n=[];var i;i=t[0],Ml(),xl.has(i)&&n.push("◌"),t.length>e&&(e>>=1,t=[...t.slice(0,e),8230,...t.slice(-e)]);let s=0,a=t.length;for(let o=0;o<a;o++){let e=t[o];Fl(e)&&(n.push($o(t.slice(s,o))),n.push(r(e)),s=o+1)}return n.push($o(t.slice(s,a))),n.join("")}function Fl(t){return Ml(),Sl.has(t)}function Ul(t){return e=function(t,e,r){if(!t)return[];Ml();let n=0;return t.split(yl).map((t=>{let i=function(t){let e=[];for(let r=0,n=t.length;r<n;){let n=t.codePointAt(r);r+=n<65536?1:2,e.push(n)}return e}(t),s={input:i,offset:n};n+=i.length+1;try{let t,n=s.tokens=function(t,e,r){let n=[],i=[];for(t=t.slice().reverse();t.length;){let s=Wl(t);if(s)i.length&&(n.push(e(i)),i=[]),n.push(r(s));else{let e=t.pop();if(Tl.has(e))i.push(e);else{let t=Al.get(e);if(t)i.push(...t);else if(!El.has(e))throw Ll(e)}}}return i.length&&n.push(e(i)),n}(i,e,r),a=n.length;if(!a)throw new Error("empty label");let o=s.output=n.flat();if(function(t){for(let e=t.lastIndexOf(95);e>0;)if(95!==t[--e])throw new Error("underscore allowed only at start")}(o),!(s.emoji=a>1||n[0].is_emoji)&&o.every((t=>t<128)))!function(t){if(t.length>=4&&45==t[2]&&45==t[3])throw new Error(`invalid label extension: "${$o(t.slice(0,4))}"`)}(o),t="ASCII";else{let e=n.flatMap((t=>t.is_emoji?[]:t));if(e.length){if(xl.has(o[0]))throw jl("leading combining mark");for(let t=1;t<a;t++){let e=n[t];if(!e.is_emoji&&xl.has(e[0]))throw jl(`emoji + combining mark: "${$o(n[t-1])} + ${Ol([e[0]])}"`)}!function(t){let e=t[0],r=jo.get(e);if(r)throw jl(`leading ${r}`);let n=t.length,i=-1;for(let s=1;s<n;s++){e=t[s];let n=jo.get(e);if(n){if(i==s)throw jl(`${r} + ${n}`);i=s+1,r=n}}if(i==n)throw jl(`trailing ${r}`)}(o);let r=vl(new Set(e)),[i]=function(t){let e=Nl;for(let r of t){let t=e.filter((t=>wl(t,r)));if(!t.length)throw Nl.some((t=>wl(t,r)))?Dl(e[0],r):Ll(r);if(e=t,1==t.length)break}return e}(r);!function(t,e){for(let r of e)if(!wl(t,r))throw Dl(t,r);if(t.M){let t=ml(e);for(let e=1,r=t.length;e<r;e++)if(kl.has(t[e])){let n=e+1;for(let i;n<r&&kl.has(i=t[n]);n++)for(let r=e;r<n;r++)if(t[r]==i)throw new Error(`duplicate non-spacing marks: ${Il(i)}`);if(n-e>4)throw new Error(`excessive non-spacing marks: ${Bl(Ol(t.slice(e-1,n)))} (${n-e}/4)`);e=n}}}(i,e),function(t,e){let r,n=[];for(let i of e){let t=Cl.get(i);if(1===t)return;if(t){let e=t.M.get(i);if(r=r?r.filter((t=>e.has(t))):vl(e),!r.length)return}else n.push(i)}if(r)for(let i of r)if(n.every((t=>wl(i,t))))throw new Error(`whole-script confusable: ${t.N}/${i.N}`)}(i,r),t=i.N}else t="Emoji"}s.type=t}catch(a){s.error=a}return s}))}(t,_l,Hl),e.map((({input:t,error:r,output:n})=>{if(r){let n=r.message;throw new Error(1==e.length?n:`Invalid label ${Bl(Ol(t,63))}: ${n}`)}return $o(n)})).join(yl);var e}function Ll(t){return new Error(`disallowed character: ${Il(t)}`)}function Dl(t,e){let r=Il(e),n=Nl.find((t=>t.P.has(e)));return n&&(r=`${n.N} ${r}`),new Error(`illegal mixture: ${t.N} + ${r}`)}function jl(t){return new Error(`illegal placement: ${t}`)}function Hl(t){return t.filter((t=>65039!=t))}function Wl(t,e){let r,n=Gl,i=t.length;for(;i&&(n=n.get(t[--i]),n);){let{V:s}=n;s&&(r=s,e&&e.push(...t.slice(i).reverse()),t.length=i)}return r}const Ql=new Uint8Array(32);function zl(t){return Or(0!==t.length,"invalid ENS name; empty component","comp",t),t}function Vl(t){const e=yn(function(t){try{if(0===t.length)throw new Error("empty label");return Ul(t)}catch(e){Or(!1,`invalid ENS name (${e.message})`,"name",t)}}(t)),r=[];if(0===t.length)return r;let n=0;for(let i=0;i<e.length;i++){46===e[i]&&(r.push(zl(e.slice(n,i))),n=i+1)}return Or(n<e.length,"invalid ENS name; empty component","name",t),r.push(zl(e.slice(n))),r}function Jl(t){Or("string"==typeof t,"invalid ENS name; not a string","name",t),Or(t.length,"invalid ENS name (empty label)","name",t);let e=Ql;const r=Vl(t);for(;r.length;)e=vs(Jr([e,vs(r.pop())]));return Vr(e)}function Kl(t,e){const r=null!=e?e:63;return Or(r<=255,"DNS encoded label cannot exceed 255","length",r),Vr(Jr(Vl(t).map((e=>{Or(e.length<=r,`label ${JSON.stringify(t)} exceeds ${r} bytes`,"name",t);const n=new Uint8Array(e.length+1);return n.set(e,1),n[0]=n.length-1,n}))))+"00"}Ql.fill(0);const ql=new Uint8Array(32);ql.fill(0);const Zl=BigInt(-1),Yl=BigInt(0),Xl=BigInt(1),$l=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const tc=un(Xl,32),ec=un(Yl,32),rc={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},nc=["name","version","chainId","verifyingContract","salt"];function ic(t){return function(e){return Or("string"==typeof e,`invalid domain value for ${JSON.stringify(t)}`,`domain.${t}`,e),e}}const sc={name:ic("name"),version:ic("version"),chainId:function(t){const e=sn(t,"domain.chainId");return Or(e>=0,"invalid chain ID","domain.chainId",t),Number.isSafeInteger(e)?Number(e):dn(e)},verifyingContract:function(t){try{return za(t).toLowerCase()}catch(e){}Or(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(t){const e=jr(t,"domain.salt");return Or(32===e.length,'invalid domain value "salt"',"domain.salt",t),Vr(e)}};function ac(t){{const e=t.match(/^(u?)int(\d+)$/);if(e){const r=""===e[1],n=parseInt(e[2]);Or(n%8==0&&0!==n&&n<=256&&e[2]===String(n),"invalid numeric width","type",t);const i=nn($l,r?n-1:n),s=r?(i+Xl)*Zl:Yl;return function(e){const n=sn(e,"value");return Or(n>=s&&n<=i,`value out-of-bounds for ${t}`,"value",n),un(r?rn(n,256):n,32)}}}{const e=t.match(/^bytes(\d+)$/);if(e){const r=parseInt(e[1]);return Or(0!==r&&r<=32&&e[1]===String(r),"invalid bytes width","type",t),function(e){return Or(jr(e).length===r,`invalid length for ${t}`,"value",e),function(t){const e=jr(t),r=e.length%32;return r?Jr([e,ql.slice(r)]):Vr(e)}(e)}}}switch(t){case"address":return function(t){return Yr(za(t),32)};case"bool":return function(t){return t?tc:ec};case"bytes":return function(t){return vs(t)};case"string":return function(t){return Do(t)}}return null}function oc(t,e){return`${t}(${e.map((({name:t,type:e})=>e+" "+t)).join(",")})`}function lc(t){const e=t.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);return e?{base:e[1],index:e[2]+e[4],array:{base:e[1],prefix:e[1]+e[2],count:e[5]?parseInt(e[5]):-1}}:{base:t}}Pt=new WeakMap,Ct=new WeakMap,Tt=new WeakMap,Rt=new WeakSet,Gt=function(t){{const e=ac(t);if(e)return e}const e=lc(t).array;if(e){const t=e.prefix,r=this.getEncoder(t);return n=>{Or(-1===e.count||e.count===n.length,`array length mismatch; expected length ${e.count}`,"value",n);let i=n.map(r);return __privateGet(this,Ct).has(t)&&(i=i.map(vs)),vs(Jr(i))}}const r=this.types[t];if(r){const e=Do(__privateGet(this,Ct).get(t));return t=>{const n=r.map((({name:e,type:r})=>{const n=this.getEncoder(r)(t[e]);return __privateGet(this,Ct).has(r)?vs(n):n}));return n.unshift(e),Jr(n)}}Or(!1,`unknown type: ${t}`,"type",t)};let cc=class t{constructor(t){__privateAdd(this,Rt),__publicField(this,"primaryType"),__privateAdd(this,Pt,void 0),__privateAdd(this,Ct,void 0),__privateAdd(this,Tt,void 0),__privateSet(this,Ct,new Map),__privateSet(this,Tt,new Map);const e=new Map,r=new Map,n=new Map,i={};Object.keys(t).forEach((s=>{i[s]=t[s].map((({name:e,type:r})=>{let{base:n,index:i}=lc(r);return"int"!==n||t.int||(n="int256"),"uint"!==n||t.uint||(n="uint256"),{name:e,type:n+(i||"")}})),e.set(s,new Set),r.set(s,[]),n.set(s,new Set)})),__privateSet(this,Pt,JSON.stringify(i));for(const a in i){const n=new Set;for(const s of i[a]){Or(!n.has(s.name),`duplicate variable name ${JSON.stringify(s.name)} in ${JSON.stringify(a)}`,"types",t),n.add(s.name);const i=lc(s.type).base;Or(i!==a,`circular type reference to ${JSON.stringify(i)}`,"types",t);ac(i)||(Or(r.has(i),`unknown type ${JSON.stringify(i)}`,"types",t),r.get(i).push(a),e.get(a).add(i))}}const s=Array.from(r.keys()).filter((t=>0===r.get(t).length));Or(0!==s.length,"missing primary type","types",t),Or(1===s.length,`ambiguous primary types or unused types: ${s.map((t=>JSON.stringify(t))).join(", ")}`,"types",t),Tr(this,{primaryType:s[0]}),function i(s,a){Or(!a.has(s),`circular type reference to ${JSON.stringify(s)}`,"types",t),a.add(s);for(const t of e.get(s))if(r.has(t)){i(t,a);for(const e of a)n.get(e).add(t)}a.delete(s)}(this.primaryType,new Set);for(const[a,o]of n){const t=Array.from(o);t.sort(),__privateGet(this,Ct).set(a,oc(a,i[a])+t.map((t=>oc(t,i[t]))).join(""))}}get types(){return JSON.parse(__privateGet(this,Pt))}getEncoder(t){let e=__privateGet(this,Tt).get(t);return e||(e=__privateMethod(this,Rt,Gt).call(this,t),__privateGet(this,Tt).set(t,e)),e}encodeType(t){const e=__privateGet(this,Ct).get(t);return Or(e,`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return vs(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,r){if(ac(t))return r(t,e);const n=lc(t).array;if(n)return Or(-1===n.count||n.count===e.length,`array length mismatch; expected length ${n.count}`,"value",e),e.map((t=>this._visit(n.prefix,t,r)));const i=this.types[t];if(i)return i.reduce(((t,{name:n,type:i})=>(t[n]=this._visit(i,e[n],r),t)),{});Or(!1,`unknown type: ${t}`,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(e){return new t(e)}static getPrimaryType(e){return t.from(e).primaryType}static hashStruct(e,r,n){return t.from(r).hashStruct(e,n)}static hashDomain(e){const r=[];for(const t in e){if(null==e[t])continue;const n=rc[t];Or(n,`invalid typed-data domain key: ${JSON.stringify(t)}`,"domain",e),r.push({name:t,type:n})}return r.sort(((t,e)=>nc.indexOf(t.name)-nc.indexOf(e.name))),t.hashStruct("EIP712Domain",{EIP712Domain:r},e)}static encode(e,r,n){return Jr(["0x1901",t.hashDomain(e),t.from(r).hash(n)])}static hash(e,r,n){return vs(t.encode(e,r,n))}static resolveNames(e,r,n,i){return __async(this,null,(function*(){e=Object.assign({},e);for(const t in e)null==e[t]&&delete e[t];const s={};e.verifyingContract&&!Wr(e.verifyingContract,20)&&(s[e.verifyingContract]="0x");const a=t.from(r);a.visit(n,((t,e)=>("address"!==t||Wr(e,20)||(s[e]="0x"),e)));for(const t in s)s[t]=yield i(t);return e.verifyingContract&&s[e.verifyingContract]&&(e.verifyingContract=s[e.verifyingContract]),n=a.visit(n,((t,e)=>"address"===t&&s[e]?s[e]:e)),{domain:e,value:n}}))}static getPayload(e,r,n){t.hashDomain(e);const i={},s=[];nc.forEach((t=>{const r=e[t];null!=r&&(i[t]=sc[t](r),s.push({name:t,type:rc[t]}))}));const a=t.from(r);r=a.types;const o=Object.assign({},r);return Or(null==o.EIP712Domain,"types must not contain EIP712Domain type","types.EIP712Domain",r),o.EIP712Domain=s,a.encode(n),{types:o,domain:i,primaryType:a.primaryType,message:a.visit(n,((t,e)=>{if(t.match(/^bytes(\d*)/))return Vr(jr(e));if(t.match(/^u?int/))return sn(e).toString();switch(t){case"address":return e.toLowerCase();case"bool":return!!e;case"string":return Or("string"==typeof e,"invalid string","value",e),e}Or(!1,"unsupported type","type",t)}))}}};function uc(t){const e=new Set;return t.forEach((t=>e.add(t))),Object.freeze(e)}const hc=uc("external public payable override".split(" ")),dc="constant external internal payable private public pure view override",pc=uc(dc.split(" ")),fc="constructor error event fallback function receive struct",gc=uc(fc.split(" ")),mc="calldata memory storage payable indexed",_c=uc(mc.split(" ")),yc=uc([fc,mc,"tuple returns",dc].join(" ").split(" ")),vc={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},wc=new RegExp("^(\\s*)"),bc=new RegExp("^([0-9]+)"),Ac=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),Ec=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),xc=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$"),kc=class t{constructor(t){__privateAdd(this,Bt),__privateAdd(this,Mt,void 0),__privateAdd(this,It,void 0),__privateSet(this,Mt,0),__privateSet(this,It,t.slice())}get offset(){return __privateGet(this,Mt)}get length(){return __privateGet(this,It).length-__privateGet(this,Mt)}clone(){return new t(__privateGet(this,It))}reset(){__privateSet(this,Mt,0)}popKeyword(t){const e=this.peek();if("KEYWORD"!==e.type||!t.has(e.text))throw new Error(`expected keyword ${e.text}`);return this.pop().text}popType(t){if(this.peek().type!==t){const e=this.peek();throw new Error(`expected ${t}; got ${e.type} ${JSON.stringify(e.text)}`)}return this.pop().text}popParen(){const t=this.peek();if("OPEN_PAREN"!==t.type)throw new Error("bad start");const e=__privateMethod(this,Bt,Ot).call(this,__privateGet(this,Mt)+1,t.match+1);return __privateSet(this,Mt,t.match+1),e}popParams(){const t=this.peek();if("OPEN_PAREN"!==t.type)throw new Error("bad start");const e=[];for(;__privateGet(this,Mt)<t.match-1;){const t=this.peek().linkNext;e.push(__privateMethod(this,Bt,Ot).call(this,__privateGet(this,Mt)+1,t)),__privateSet(this,Mt,t)}return __privateSet(this,Mt,t.match+1),e}peek(){if(__privateGet(this,Mt)>=__privateGet(this,It).length)throw new Error("out-of-bounds");return __privateGet(this,It)[__privateGet(this,Mt)]}peekKeyword(t){const e=this.peekType("KEYWORD");return null!=e&&t.has(e)?e:null}peekType(t){if(0===this.length)return null;const e=this.peek();return e.type===t?e.text:null}pop(){const t=this.peek();return __privateWrapper(this,Mt)._++,t}toString(){const t=[];for(let e=__privateGet(this,Mt);e<__privateGet(this,It).length;e++){const r=__privateGet(this,It)[e];t.push(`${r.type}:${r.text}`)}return`<TokenString ${t.join(" ")}>`}};Mt=new WeakMap,It=new WeakMap,Bt=new WeakSet,Ot=function(t=0,e=0){return new kc(__privateGet(this,It).slice(t,e).map((e=>Object.freeze(Object.assign({},e,{match:e.match-t,linkBack:e.linkBack-t,linkNext:e.linkNext-t})))))};let Sc=kc;function Nc(t){const e=[],r=e=>{const r=s<t.length?JSON.stringify(t[s]):"$EOI";throw new Error(`invalid token ${r} at ${s}: ${e}`)};let n=[],i=[],s=0;for(;s<t.length;){let a=t.substring(s),o=a.match(wc);o&&(s+=o[1].length,a=t.substring(s));const l={depth:n.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:s,value:-1};e.push(l);let c=vc[a[0]]||"";if(c){if(l.type=c,l.text=a[0],s++,"OPEN_PAREN"===c)n.push(e.length-1),i.push(e.length-1);else if("CLOSE_PAREN"==c)0===n.length&&r("no matching open bracket"),l.match=n.pop(),e[l.match].match=e.length-1,l.depth--,l.linkBack=i.pop(),e[l.linkBack].linkNext=e.length-1;else if("COMMA"===c)l.linkBack=i.pop(),e[l.linkBack].linkNext=e.length-1,i.push(e.length-1);else if("OPEN_BRACKET"===c)l.type="BRACKET";else if("CLOSE_BRACKET"===c){let t=e.pop().text;if(e.length>0&&"NUMBER"===e[e.length-1].type){const r=e.pop().text;t=r+t,e[e.length-1].value=cn(r)}if(0===e.length||"BRACKET"!==e[e.length-1].type)throw new Error("missing opening bracket");e[e.length-1].text+=t}}else if(o=a.match(Ac),o){if(l.text=o[1],s+=l.text.length,yc.has(l.text)){l.type="KEYWORD";continue}if(l.text.match(xc)){l.type="TYPE";continue}l.type="ID"}else{if(o=a.match(bc),!o)throw new Error(`unexpected token ${JSON.stringify(a[0])} at position ${s}`);l.text=o[1],l.type="NUMBER",s+=l.text.length}}return new Sc(e.map((t=>Object.freeze(t))))}function Pc(t,e){let r=[];for(const n in e.keys())t.has(n)&&r.push(n);if(r.length>1)throw new Error(`conflicting types: ${r.join(", ")}`)}function Cc(t,e){if(e.peekKeyword(gc)){const r=e.pop().text;if(r!==t)throw new Error(`expected ${t}, got ${r}`)}return e.popType("ID")}function Tc(t,e){const r=new Set;for(;;){const n=t.peekType("KEYWORD");if(null==n||e&&!e.has(n))break;if(t.pop(),r.has(n))throw new Error(`duplicate keywords: ${JSON.stringify(n)}`);r.add(n)}return Object.freeze(r)}function Rc(t){let e=Tc(t,pc);return Pc(e,uc("constant payable nonpayable".split(" "))),Pc(e,uc("pure view payable nonpayable".split(" "))),e.has("view")?"view":e.has("pure")?"pure":e.has("payable")?"payable":e.has("nonpayable")?"nonpayable":e.has("constant")?"view":"nonpayable"}function Gc(t,e){return t.popParams().map((t=>Vc.from(t,e)))}function Mc(t){if(t.peekType("AT")){if(t.pop(),t.peekType("NUMBER"))return sn(t.pop().text);throw new Error("invalid gas")}return null}function Ic(t){if(t.length)throw new Error(`unexpected tokens at offset ${t.offset}: ${t.toString()}`)}const Bc=new RegExp(/^(.*)\[([0-9]*)\]$/);function Oc(t){const e=t.match(xc);if(Or(e,"invalid type","type",t),"uint"===t)return"uint256";if("int"===t)return"int256";if(e[2]){const r=parseInt(e[2]);Or(0!==r&&r<=32,"invalid bytes length","type",t)}else if(e[3]){const r=parseInt(e[3]);Or(0!==r&&r<=256&&r%8==0,"invalid numeric width","type",t)}return t}const Fc={},Uc=Symbol.for("_ethers_internal"),Lc="_ParamTypeInternal",Dc="_ErrorInternal",jc="_EventInternal",Hc="_ConstructorInternal",Wc="_FallbackInternal",Qc="_FunctionInternal",zc="_StructInternal";Ft=new WeakSet,Ut=function(t,e,r,n){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(-1!==this.arrayLength&&e.length!==this.arrayLength)throw new Error("array is wrong length");const i=this.arrayChildren,s=e.slice();return s.forEach(((e,n)=>{var a;__privateMethod(a=i,Ft,Ut).call(a,t,e,r,(t=>{s[n]=t}))})),void n(s)}if(this.isTuple()){const i=this.components;let s;if(Array.isArray(e))s=e.slice();else{if(null==e||"object"!=typeof e)throw new Error("invalid tuple value");s=i.map((t=>{if(!t.name)throw new Error("cannot use object value with unnamed components");if(!(t.name in e))throw new Error(`missing value for component ${t.name}`);return e[t.name]}))}if(s.length!==this.components.length)throw new Error("array is wrong length");return s.forEach(((e,n)=>{var a;__privateMethod(a=i[n],Ft,Ut).call(a,t,e,r,(t=>{s[n]=t}))})),void n(s)}const i=r(this.type,e);i.then?t.push(function(){return __async(this,null,(function*(){n(yield i)}))}()):n(i)};let Vc=class t{constructor(t,e,r,n,i,s,a,o){if(__privateAdd(this,Ft),__publicField(this,"name"),__publicField(this,"type"),__publicField(this,"baseType"),__publicField(this,"indexed"),__publicField(this,"components"),__publicField(this,"arrayLength"),__publicField(this,"arrayChildren"),Lr(t,Fc,"ParamType"),Object.defineProperty(this,Uc,{value:Lc}),s&&(s=Object.freeze(s.slice())),"array"===n){if(null==a||null==o)throw new Error("")}else if(null!=a||null!=o)throw new Error("");if("tuple"===n){if(null==s)throw new Error("")}else if(null!=s)throw new Error("");Tr(this,{name:e,type:r,baseType:n,indexed:i,components:s,arrayLength:a,arrayChildren:o})}format(t){if(null==t&&(t="sighash"),"json"===t){const e=this.name||"";if(this.isArray()){const t=JSON.parse(this.arrayChildren.format("json"));return t.name=e,t.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(t)}const r={type:"tuple"===this.baseType?"tuple":this.type,name:e};return"boolean"==typeof this.indexed&&(r.indexed=this.indexed),this.isTuple()&&(r.components=this.components.map((e=>JSON.parse(e.format(t))))),JSON.stringify(r)}let e="";return this.isArray()?(e+=this.arrayChildren.format(t),e+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?e+="("+this.components.map((e=>e.format(t))).join("full"===t?", ":",")+")":e+=this.type,"sighash"!==t&&(!0===this.indexed&&(e+=" indexed"),"full"===t&&this.name&&(e+=" "+this.name)),e}isArray(){return"array"===this.baseType}isTuple(){return"tuple"===this.baseType}isIndexable(){return null!=this.indexed}walk(t,e){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(-1!==this.arrayLength&&t.length!==this.arrayLength)throw new Error("array is wrong length");const r=this;return t.map((t=>r.arrayChildren.walk(t,e)))}if(this.isTuple()){if(!Array.isArray(t))throw new Error("invalid tuple value");if(t.length!==this.components.length)throw new Error("array is wrong length");const r=this;return t.map(((t,n)=>r.components[n].walk(t,e)))}return e(this.type,t)}walkAsync(t,e){return __async(this,null,(function*(){const r=[],n=[t];return __privateMethod(this,Ft,Ut).call(this,r,t,e,(t=>{n[0]=t})),r.length&&(yield Promise.all(r)),n[0]}))}static from(e,r){if(t.isParamType(e))return e;if("string"==typeof e)try{return t.from(Nc(e),r)}catch(o){Or(!1,"invalid param type","obj",e)}else if(e instanceof Sc){let n="",i="",s=null;Tc(e,uc(["tuple"])).has("tuple")||e.peekType("OPEN_PAREN")?(i="tuple",s=e.popParams().map((e=>t.from(e))),n=`tuple(${s.map((t=>t.format())).join(",")})`):(n=Oc(e.popType("TYPE")),i=n);let a=null,o=null;for(;e.length&&e.peekType("BRACKET");){const r=e.pop();a=new t(Fc,"",n,i,null,s,o,a),o=r.value,n+=r.text,i="array",s=null}let l=null;if(Tc(e,_c).has("indexed")){if(!r)throw new Error("");l=!0}const c=e.peekType("ID")?e.pop().text:"";if(e.length)throw new Error("leftover tokens");return new t(Fc,c,n,i,l,s,o,a)}const n=e.name;Or(!n||"string"==typeof n&&n.match(Ec),"invalid name","obj.name",n);let i=e.indexed;null!=i&&(Or(r,"parameter cannot be indexed","obj.indexed",e.indexed),i=!!i);let s=e.type,a=s.match(Bc);if(a){const r=parseInt(a[2]||"-1"),o=t.from({type:a[1],components:e.components});return new t(Fc,n||"",s,"array",i,null,r,o)}if("tuple"===s||s.startsWith("tuple(")||s.startsWith("(")){const r=null!=e.components?e.components.map((e=>t.from(e))):null;return new t(Fc,n||"",s,"tuple",i,r,null,null)}return s=Oc(e.type),new t(Fc,n||"",s,s,i,null,null,null)}static isParamType(t){return t&&t[Uc]===Lc}};class Jc{constructor(t,e,r){__publicField(this,"type"),__publicField(this,"inputs"),Lr(t,Fc,"Fragment"),Tr(this,{type:e,inputs:r=Object.freeze(r.slice())})}static from(t){if("string"==typeof t){try{Jc.from(JSON.parse(t))}catch(e){}return Jc.from(Nc(t))}if(t instanceof Sc){switch(t.peekKeyword(gc)){case"constructor":return Xc.from(t);case"error":return Zc.from(t);case"event":return Yc.from(t);case"fallback":case"receive":return $c.from(t);case"function":return tu.from(t);case"struct":return eu.from(t)}}else if("object"==typeof t){switch(t.type){case"constructor":return Xc.from(t);case"error":return Zc.from(t);case"event":return Yc.from(t);case"fallback":case"receive":return $c.from(t);case"function":return tu.from(t);case"struct":return eu.from(t)}Br(!1,`unsupported type: ${t.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}Or(!1,"unsupported frgament object","obj",t)}static isConstructor(t){return Xc.isFragment(t)}static isError(t){return Zc.isFragment(t)}static isEvent(t){return Yc.isFragment(t)}static isFunction(t){return tu.isFragment(t)}static isStruct(t){return eu.isFragment(t)}}class Kc extends Jc{constructor(t,e,r,n){super(t,e,n),__publicField(this,"name"),Or("string"==typeof r&&r.match(Ec),"invalid identifier","name",r),n=Object.freeze(n.slice()),Tr(this,{name:r})}}function qc(t,e){return"("+e.map((e=>e.format(t))).join("full"===t?", ":",")+")"}class Zc extends Kc{constructor(t,e,r){super(t,"error",e,r),Object.defineProperty(this,Uc,{value:Dc})}get selector(){return Do(this.format("sighash")).substring(0,10)}format(t){if(null==t&&(t="sighash"),"json"===t)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});const e=[];return"sighash"!==t&&e.push("error"),e.push(this.name+qc(t,this.inputs)),e.join(" ")}static from(t){if(Zc.isFragment(t))return t;if("string"==typeof t)return Zc.from(Nc(t));if(t instanceof Sc){const e=Cc("error",t),r=Gc(t);return Ic(t),new Zc(Fc,e,r)}return new Zc(Fc,t.name,t.inputs?t.inputs.map(Vc.from):[])}static isFragment(t){return t&&t[Uc]===Dc}}class Yc extends Kc{constructor(t,e,r,n){super(t,"event",e,r),__publicField(this,"anonymous"),Object.defineProperty(this,Uc,{value:jc}),Tr(this,{anonymous:n})}get topicHash(){return Do(this.format("sighash"))}format(t){if(null==t&&(t="sighash"),"json"===t)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});const e=[];return"sighash"!==t&&e.push("event"),e.push(this.name+qc(t,this.inputs)),"sighash"!==t&&this.anonymous&&e.push("anonymous"),e.join(" ")}static getTopicHash(t,e){e=(e||[]).map((t=>Vc.from(t)));return new Yc(Fc,t,e,!1).topicHash}static from(t){if(Yc.isFragment(t))return t;if("string"==typeof t)try{return Yc.from(Nc(t))}catch(e){Or(!1,"invalid event fragment","obj",t)}else if(t instanceof Sc){const e=Cc("event",t),r=Gc(t,!0),n=!!Tc(t,uc(["anonymous"])).has("anonymous");return Ic(t),new Yc(Fc,e,r,n)}return new Yc(Fc,t.name,t.inputs?t.inputs.map((t=>Vc.from(t,!0))):[],!!t.anonymous)}static isFragment(t){return t&&t[Uc]===jc}}class Xc extends Jc{constructor(t,e,r,n,i){super(t,e,r),__publicField(this,"payable"),__publicField(this,"gas"),Object.defineProperty(this,Uc,{value:Hc}),Tr(this,{payable:n,gas:i})}format(t){if(Br(null!=t&&"sighash"!==t,"cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),"json"===t)return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:null!=this.gas?this.gas:void 0,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});const e=[`constructor${qc(t,this.inputs)}`];return this.payable&&e.push("payable"),null!=this.gas&&e.push(`@${this.gas.toString()}`),e.join(" ")}static from(t){if(Xc.isFragment(t))return t;if("string"==typeof t)try{return Xc.from(Nc(t))}catch(e){Or(!1,"invalid constuctor fragment","obj",t)}else if(t instanceof Sc){Tc(t,uc(["constructor"]));const e=Gc(t),r=!!Tc(t,hc).has("payable"),n=Mc(t);return Ic(t),new Xc(Fc,"constructor",e,r,n)}return new Xc(Fc,"constructor",t.inputs?t.inputs.map(Vc.from):[],!!t.payable,null!=t.gas?t.gas:null)}static isFragment(t){return t&&t[Uc]===Hc}}class $c extends Jc{constructor(t,e,r){super(t,"fallback",e),__publicField(this,"payable"),Object.defineProperty(this,Uc,{value:Wc}),Tr(this,{payable:r})}format(t){const e=0===this.inputs.length?"receive":"fallback";if("json"===t){const t=this.payable?"payable":"nonpayable";return JSON.stringify({type:e,stateMutability:t})}return`${e}()${this.payable?" payable":""}`}static from(t){if($c.isFragment(t))return t;if("string"==typeof t)try{return $c.from(Nc(t))}catch(e){Or(!1,"invalid fallback fragment","obj",t)}else if(t instanceof Sc){const e=t.toString();Or(t.peekKeyword(uc(["fallback","receive"])),"type must be fallback or receive","obj",e);if("receive"===t.popKeyword(uc(["fallback","receive"]))){const e=Gc(t);return Or(0===e.length,"receive cannot have arguments","obj.inputs",e),Tc(t,uc(["payable"])),Ic(t),new $c(Fc,[],!0)}let r=Gc(t);r.length?Or(1===r.length&&"bytes"===r[0].type,"invalid fallback inputs","obj.inputs",r.map((t=>t.format("minimal"))).join(", ")):r=[Vc.from("bytes")];const n=Rc(t);if(Or("nonpayable"===n||"payable"===n,"fallback cannot be constants","obj.stateMutability",n),Tc(t,uc(["returns"])).has("returns")){const e=Gc(t);Or(1===e.length&&"bytes"===e[0].type,"invalid fallback outputs","obj.outputs",e.map((t=>t.format("minimal"))).join(", "))}return Ic(t),new $c(Fc,r,"payable"===n)}if("receive"===t.type)return new $c(Fc,[],!0);if("fallback"===t.type){const e=[Vc.from("bytes")],r="payable"===t.stateMutability;return new $c(Fc,e,r)}Or(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[Uc]===Wc}}class tu extends Kc{constructor(t,e,r,n,i,s){super(t,"function",e,n),__publicField(this,"constant"),__publicField(this,"outputs"),__publicField(this,"stateMutability"),__publicField(this,"payable"),__publicField(this,"gas"),Object.defineProperty(this,Uc,{value:Qc});Tr(this,{constant:"view"===r||"pure"===r,gas:s,outputs:i=Object.freeze(i.slice()),payable:"payable"===r,stateMutability:r})}get selector(){return Do(this.format("sighash")).substring(0,10)}format(t){if(null==t&&(t="sighash"),"json"===t)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:null!=this.gas?this.gas:void 0,inputs:this.inputs.map((e=>JSON.parse(e.format(t)))),outputs:this.outputs.map((e=>JSON.parse(e.format(t))))});const e=[];return"sighash"!==t&&e.push("function"),e.push(this.name+qc(t,this.inputs)),"sighash"!==t&&("nonpayable"!==this.stateMutability&&e.push(this.stateMutability),this.outputs&&this.outputs.length&&(e.push("returns"),e.push(qc(t,this.outputs))),null!=this.gas&&e.push(`@${this.gas.toString()}`)),e.join(" ")}static getSelector(t,e){e=(e||[]).map((t=>Vc.from(t)));return new tu(Fc,t,"view",e,[],null).selector}static from(t){if(tu.isFragment(t))return t;if("string"==typeof t)try{return tu.from(Nc(t))}catch(r){Or(!1,"invalid function fragment","obj",t)}else if(t instanceof Sc){const e=Cc("function",t),r=Gc(t),n=Rc(t);let i=[];Tc(t,uc(["returns"])).has("returns")&&(i=Gc(t));const s=Mc(t);return Ic(t),new tu(Fc,e,n,r,i,s)}let e=t.stateMutability;return null==e&&(e="payable","boolean"==typeof t.constant?(e="view",t.constant||(e="payable","boolean"!=typeof t.payable||t.payable||(e="nonpayable"))):"boolean"!=typeof t.payable||t.payable||(e="nonpayable")),new tu(Fc,t.name,e,t.inputs?t.inputs.map(Vc.from):[],t.outputs?t.outputs.map(Vc.from):[],null!=t.gas?t.gas:null)}static isFragment(t){return t&&t[Uc]===Qc}}class eu extends Kc{constructor(t,e,r){super(t,"struct",e,r),Object.defineProperty(this,Uc,{value:zc})}format(){throw new Error("@TODO")}static from(t){if("string"==typeof t)try{return eu.from(Nc(t))}catch(e){Or(!1,"invalid struct fragment","obj",t)}else if(t instanceof Sc){const e=Cc("struct",t),r=Gc(t);return Ic(t),new eu(Fc,e,r)}return new eu(Fc,t.name,t.inputs?t.inputs.map(Vc.from):[])}static isFragment(t){return t&&t[Uc]===zc}}const ru=new Map;ru.set(0,"GENERIC_PANIC"),ru.set(1,"ASSERT_FALSE"),ru.set(17,"OVERFLOW"),ru.set(18,"DIVIDE_BY_ZERO"),ru.set(33,"ENUM_RANGE_ERROR"),ru.set(34,"BAD_STORAGE_DATA"),ru.set(49,"STACK_UNDERFLOW"),ru.set(50,"ARRAY_RANGE_ERROR"),ru.set(65,"OUT_OF_MEMORY"),ru.set(81,"UNINITIALIZED_FUNCTION_CALL");const nu=new RegExp(/^bytes([0-9]*)$/),iu=new RegExp(/^(u?int)([0-9]*)$/);let su=null,au=1024;Lt=new WeakSet,Dt=function(t){if(t.isArray())return new io(__privateMethod(this,Lt,Dt).call(this,t.arrayChildren),t.arrayLength,t.name);if(t.isTuple())return new _o(t.components.map((t=>__privateMethod(this,Lt,Dt).call(this,t))),t.name);switch(t.baseType){case"address":return new to(t.name);case"bool":return new so(t.name);case"string":return new mo(t.name);case"bytes":return new oo(t.name);case"":return new uo(t.name)}let e=t.type.match(iu);if(e){let r=parseInt(e[2]||"256");return Or(0!==r&&r<=256&&r%8==0,"invalid "+e[1]+" bit length","param",t),new go(r/8,"int"===e[1],t.name)}if(e=t.type.match(nu),e){let r=parseInt(e[1]);return Or(0!==r&&r<=32,"invalid bytes length","param",t),new lo(r,t.name)}Or(!1,"invalid type","type",t.type)};let ou=class t{constructor(){__privateAdd(this,Lt)}getDefaultValue(t){const e=t.map((t=>__privateMethod(this,Lt,Dt).call(this,Vc.from(t))));return new _o(e,"_").defaultValue()}encode(t,e){Fr(e.length,t.length,"types/values length mismatch");const r=t.map((t=>__privateMethod(this,Lt,Dt).call(this,Vc.from(t)))),n=new _o(r,"_"),i=new mi;return n.encode(i,e),i.data}decode(t,e,r){const n=t.map((t=>__privateMethod(this,Lt,Dt).call(this,Vc.from(t))));return new _o(n,"_").decode(new _i(e,r,au))}static _setDefaultMaxInflation(t){Or("number"==typeof t&&Number.isInteger(t),"invalid defaultMaxInflation factor","value",t),au=t}static defaultAbiCoder(){return null==su&&(su=new t),su}static getBuiltinCallException(e,r,n){return function(t,e,r,n){let i="missing revert data",s=null,a=null;if(r){i="execution reverted";const t=jr(r);if(r=Vr(r),0===t.length)i+=" (no data present; likely require(false) occurred",s="require(false)";else if(t.length%32!=4)i+=" (could not decode reason; invalid data length)";else if("0x08c379a0"===Vr(t.slice(0,4)))try{s=n.decode(["string"],t.slice(4))[0],a={signature:"Error(string)",name:"Error",args:[s]},i+=`: ${JSON.stringify(s)}`}catch(l){i+=" (could not decode reason; invalid string data)"}else if("0x4e487b71"===Vr(t.slice(0,4)))try{const e=Number(n.decode(["uint256"],t.slice(4))[0]);a={signature:"Panic(uint256)",name:"Panic",args:[e]},s=`Panic due to ${ru.get(e)||"UNKNOWN"}(${e})`,i+=`: ${s}`}catch(l){i+=" (could not decode panic code)"}else i+=" (unknown custom error)"}const o={to:e.to?za(e.to):null,data:e.data||"0x"};return e.from&&(o.from=za(e.from)),Ir(i,"CALL_EXCEPTION",{action:t,data:r,reason:s,transaction:o,invocation:null,revert:a})}(e,r,n,t.defaultAbiCoder())}};class lu{constructor(t,e,r){__publicField(this,"fragment"),__publicField(this,"name"),__publicField(this,"signature"),__publicField(this,"topic"),__publicField(this,"args");const n=t.name,i=t.format();Tr(this,{fragment:t,name:n,signature:i,topic:e,args:r})}}class cu{constructor(t,e,r,n){__publicField(this,"fragment"),__publicField(this,"name"),__publicField(this,"args"),__publicField(this,"signature"),__publicField(this,"selector"),__publicField(this,"value");const i=t.name,s=t.format();Tr(this,{fragment:t,name:i,args:r,signature:s,selector:e,value:n})}}class uu{constructor(t,e,r){__publicField(this,"fragment"),__publicField(this,"name"),__publicField(this,"args"),__publicField(this,"signature"),__publicField(this,"selector");const n=t.name,i=t.format();Tr(this,{fragment:t,name:n,args:r,signature:i,selector:e})}}class hu{constructor(t){__publicField(this,"hash"),__publicField(this,"_isIndexed"),Tr(this,{hash:t,_isIndexed:!0})}static isIndexed(t){return!(!t||!t._isIndexed)}}const du={0:"generic panic",1:"assert(false)",17:"arithmetic overflow",18:"division or modulo by zero",33:"enum overflow",34:"invalid encoded storage byte array accessed",49:"out-of-bounds array access; popping on an empty array",50:"out-of-bounds access of an array or bytesN",65:"out of memory",81:"uninitialized function"},pu={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:t=>`reverted with reason string ${JSON.stringify(t)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:t=>{let e="unknown panic code";return t>=0&&t<=255&&du[t.toString()]&&(e=du[t.toString()]),`reverted with panic code 0x${t.toString(16)} (${e})`}}};jt=new WeakMap,Ht=new WeakMap,Wt=new WeakMap,Qt=new WeakMap,zt=new WeakSet,Vt=function(t,e,r){if(Wr(t)){const e=t.toLowerCase();for(const t of __privateGet(this,Wt).values())if(e===t.selector)return t;return null}if(-1===t.indexOf("(")){const n=[];for(const[e,r]of __privateGet(this,Wt))e.split("(")[0]===t&&n.push(r);if(e){const t=e.length>0?e[e.length-1]:null;let r=e.length,i=!0;$a.isTyped(t)&&"overrides"===t.type&&(i=!1,r--);for(let e=n.length-1;e>=0;e--){const t=n[e].inputs.length;t===r||i&&t===r-1||n.splice(e,1)}for(let s=n.length-1;s>=0;s--){const t=n[s].inputs;for(let r=0;r<e.length;r++)if($a.isTyped(e[r])){if(r>=t.length){if("overrides"===e[r].type)continue;n.splice(s,1);break}if(e[r].type!==t[r].baseType){n.splice(s,1);break}}}}if(1===n.length&&e&&e.length!==n[0].inputs.length){const t=e[e.length-1];(null==t||Array.isArray(t)||"object"!=typeof t)&&n.splice(0,1)}if(0===n.length)return null;if(n.length>1&&r){Or(!1,`ambiguous function description (i.e. matches ${n.map((t=>JSON.stringify(t.format()))).join(", ")})`,"key",t)}return n[0]}const n=__privateGet(this,Wt).get(tu.from(t).format());return n||null},Jt=new WeakSet,Kt=function(t,e,r){if(Wr(t)){const e=t.toLowerCase();for(const t of __privateGet(this,Ht).values())if(e===t.topicHash)return t;return null}if(-1===t.indexOf("(")){const n=[];for(const[e,r]of __privateGet(this,Ht))e.split("(")[0]===t&&n.push(r);if(e){for(let t=n.length-1;t>=0;t--)n[t].inputs.length<e.length&&n.splice(t,1);for(let t=n.length-1;t>=0;t--){const r=n[t].inputs;for(let i=0;i<e.length;i++)if($a.isTyped(e[i])&&e[i].type!==r[i].baseType){n.splice(t,1);break}}}if(0===n.length)return null;if(n.length>1&&r){Or(!1,`ambiguous event description (i.e. matches ${n.map((t=>JSON.stringify(t.format()))).join(", ")})`,"key",t)}return n[0]}const n=__privateGet(this,Ht).get(Yc.from(t).format());return n||null};let fu=class t{constructor(t){__privateAdd(this,zt),__privateAdd(this,Jt),__publicField(this,"fragments"),__publicField(this,"deploy"),__publicField(this,"fallback"),__publicField(this,"receive"),__privateAdd(this,jt,void 0),__privateAdd(this,Ht,void 0),__privateAdd(this,Wt,void 0),__privateAdd(this,Qt,void 0);let e=[];e="string"==typeof t?JSON.parse(t):t,__privateSet(this,Wt,new Map),__privateSet(this,jt,new Map),__privateSet(this,Ht,new Map);const r=[];for(const a of e)try{r.push(Jc.from(a))}catch(s){console.log(`[Warning] Invalid Fragment ${JSON.stringify(a)}:`,s.message)}Tr(this,{fragments:Object.freeze(r)});let n=null,i=!1;__privateSet(this,Qt,this.getAbiCoder()),this.fragments.forEach(((t,e)=>{let r;switch(t.type){case"constructor":return this.deploy?void console.log("duplicate definition - constructor"):void Tr(this,{deploy:t});case"fallback":return void(0===t.inputs.length?i=!0:(Or(!n||t.payable!==n.payable,"conflicting fallback fragments",`fragments[${e}]`,t),n=t,i=n.payable));case"function":r=__privateGet(this,Wt);break;case"event":r=__privateGet(this,Ht);break;case"error":r=__privateGet(this,jt);break;default:return}const s=t.format();r.has(s)||r.set(s,t)})),this.deploy||Tr(this,{deploy:Xc.from("constructor()")}),Tr(this,{fallback:n,receive:i})}format(t){const e=t?"minimal":"full";return this.fragments.map((t=>t.format(e)))}formatJson(){const t=this.fragments.map((t=>t.format("json")));return JSON.stringify(t.map((t=>JSON.parse(t))))}getAbiCoder(){return ou.defaultAbiCoder()}getFunctionName(t){const e=__privateMethod(this,zt,Vt).call(this,t,null,!1);return Or(e,"no matching function","key",t),e.name}hasFunction(t){return!!__privateMethod(this,zt,Vt).call(this,t,null,!1)}getFunction(t,e){return __privateMethod(this,zt,Vt).call(this,t,e||null,!0)}forEachFunction(t){const e=Array.from(__privateGet(this,Wt).keys());e.sort(((t,e)=>t.localeCompare(e)));for(let r=0;r<e.length;r++){const n=e[r];t(__privateGet(this,Wt).get(n),r)}}getEventName(t){const e=__privateMethod(this,Jt,Kt).call(this,t,null,!1);return Or(e,"no matching event","key",t),e.name}hasEvent(t){return!!__privateMethod(this,Jt,Kt).call(this,t,null,!1)}getEvent(t,e){return __privateMethod(this,Jt,Kt).call(this,t,e||null,!0)}forEachEvent(t){const e=Array.from(__privateGet(this,Ht).keys());e.sort(((t,e)=>t.localeCompare(e)));for(let r=0;r<e.length;r++){const n=e[r];t(__privateGet(this,Ht).get(n),r)}}getError(t,e){if(Wr(t)){const e=t.toLowerCase();if(pu[e])return Zc.from(pu[e].signature);for(const t of __privateGet(this,jt).values())if(e===t.selector)return t;return null}if(-1===t.indexOf("(")){const e=[];for(const[r,n]of __privateGet(this,jt))r.split("(")[0]===t&&e.push(n);if(0===e.length)return"Error"===t?Zc.from("error Error(string)"):"Panic"===t?Zc.from("error Panic(uint256)"):null;if(e.length>1){Or(!1,`ambiguous error description (i.e. ${e.map((t=>JSON.stringify(t.format()))).join(", ")})`,"name",t)}return e[0]}if("Error(string)"===(t=Zc.from(t).format()))return Zc.from("error Error(string)");if("Panic(uint256)"===t)return Zc.from("error Panic(uint256)");const r=__privateGet(this,jt).get(t);return r||null}forEachError(t){const e=Array.from(__privateGet(this,jt).keys());e.sort(((t,e)=>t.localeCompare(e)));for(let r=0;r<e.length;r++){const n=e[r];t(__privateGet(this,jt).get(n),r)}}_decodeParams(t,e){return __privateGet(this,Qt).decode(t,e)}_encodeParams(t,e){return __privateGet(this,Qt).encode(t,e)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}decodeErrorResult(t,e){if("string"==typeof t){const e=this.getError(t);Or(e,"unknown error","fragment",t),t=e}return Or(qr(e,0,4)===t.selector,`data signature does not match error ${t.name}.`,"data",e),this._decodeParams(t.inputs,qr(e,4))}encodeErrorResult(t,e){if("string"==typeof t){const e=this.getError(t);Or(e,"unknown error","fragment",t),t=e}return Jr([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionData(t,e){if("string"==typeof t){const e=this.getFunction(t);Or(e,"unknown function","fragment",t),t=e}return Or(qr(e,0,4)===t.selector,`data signature does not match function ${t.name}.`,"data",e),this._decodeParams(t.inputs,qr(e,4))}encodeFunctionData(t,e){if("string"==typeof t){const e=this.getFunction(t);Or(e,"unknown function","fragment",t),t=e}return Jr([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionResult(t,e){if("string"==typeof t){const e=this.getFunction(t);Or(e,"unknown function","fragment",t),t=e}let r="invalid length for result data";const n=Hr(e);if(n.length%32==0)try{return __privateGet(this,Qt).decode(t.outputs,n)}catch(i){r="could not decode result data"}Br(!1,r,"BAD_DATA",{value:Vr(n),info:{method:t.name,signature:t.format()}})}makeError(t,e){const r=jr(t,"data"),n=ou.getBuiltinCallException("call",e,r);if(n.message.startsWith("execution reverted (unknown custom error)")){const t=Vr(r.slice(0,4)),e=this.getError(t);if(e)try{const t=__privateGet(this,Qt).decode(e.inputs,r.slice(4));n.revert={name:e.name,signature:e.format(),args:t},n.reason=n.revert.signature,n.message=`execution reverted: ${n.reason}`}catch(s){n.message="execution reverted (coult not decode custom error)"}}const i=this.parseTransaction(e);return i&&(n.invocation={method:i.name,signature:i.signature,args:i.args}),n}encodeFunctionResult(t,e){if("string"==typeof t){const e=this.getFunction(t);Or(e,"unknown function","fragment",t),t=e}return Vr(__privateGet(this,Qt).encode(t.outputs,e||[]))}encodeFilterTopics(t,e){if("string"==typeof t){const e=this.getEvent(t);Or(e,"unknown event","eventFragment",t),t=e}Br(e.length<=t.inputs.length,`too many arguments for ${t.format()}`,"UNEXPECTED_ARGUMENT",{count:e.length,expectedCount:t.inputs.length});const r=[];t.anonymous||r.push(t.topicHash);const n=(t,e)=>"string"===t.type?Do(e):"bytes"===t.type?vs(Vr(e)):("bool"===t.type&&"boolean"==typeof e?e=e?"0x01":"0x00":t.type.match(/^u?int/)?e=un(e):t.type.match(/^bytes/)?e=Zr(e,32,!1):"address"===t.type&&__privateGet(this,Qt).encode(["address"],[e]),Yr(Vr(e),32));for(e.forEach(((e,i)=>{const s=t.inputs[i];s.indexed?null==e?r.push(null):"array"===s.baseType||"tuple"===s.baseType?Or(!1,"filtering with tuples or arrays not supported","contract."+s.name,e):Array.isArray(e)?r.push(e.map((t=>n(s,t)))):r.push(n(s,e)):Or(null==e,"cannot filter non-indexed parameters; must be null","contract."+s.name,e)}));r.length&&null===r[r.length-1];)r.pop();return r}encodeEventLog(t,e){if("string"==typeof t){const e=this.getEvent(t);Or(e,"unknown event","eventFragment",t),t=e}const r=[],n=[],i=[];return t.anonymous||r.push(t.topicHash),Or(e.length===t.inputs.length,"event arguments/values mismatch","values",e),t.inputs.forEach(((t,s)=>{const a=e[s];if(t.indexed)if("string"===t.type)r.push(Do(a));else if("bytes"===t.type)r.push(vs(a));else{if("tuple"===t.baseType||"array"===t.baseType)throw new Error("not implemented");r.push(__privateGet(this,Qt).encode([t.type],[a]))}else n.push(t),i.push(a)})),{data:__privateGet(this,Qt).encode(n,i),topics:r}}decodeEventLog(t,e,r){if("string"==typeof t){const e=this.getEvent(t);Or(e,"unknown event","eventFragment",t),t=e}if(null!=r&&!t.anonymous){const e=t.topicHash;Or(Wr(r[0],32)&&r[0].toLowerCase()===e,"fragment/topic mismatch","topics[0]",r[0]),r=r.slice(1)}const n=[],i=[],s=[];t.inputs.forEach(((t,e)=>{t.indexed?"string"===t.type||"bytes"===t.type||"tuple"===t.baseType||"array"===t.baseType?(n.push(Vc.from({type:"bytes32",name:t.name})),s.push(!0)):(n.push(t),s.push(!1)):(i.push(t),s.push(!1))}));const a=null!=r?__privateGet(this,Qt).decode(n,Jr(r)):null,o=__privateGet(this,Qt).decode(i,e,!0),l=[],c=[];let u=0,h=0;return t.inputs.forEach(((t,e)=>{let r=null;if(t.indexed)if(null==a)r=new hu(null);else if(s[e])r=new hu(a[h++]);else try{r=a[h++]}catch(n){r=n}else try{r=o[u++]}catch(n){r=n}l.push(r),c.push(t.name||null)})),pi.fromItems(l,c)}parseTransaction(t){const e=jr(t.data,"tx.data"),r=sn(null!=t.value?t.value:0,"tx.value"),n=this.getFunction(Vr(e.slice(0,4)));if(!n)return null;const i=__privateGet(this,Qt).decode(n.inputs,e.slice(4));return new cu(n,n.selector,i,r)}parseCallResult(t){throw new Error("@TODO")}parseLog(t){const e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new lu(e,e.topicHash,this.decodeEventLog(e,t.data,t.topics))}parseError(t){const e=Vr(t),r=this.getError(qr(e,0,4));if(!r)return null;const n=__privateGet(this,Qt).decode(r.inputs,qr(e,4));return new uu(r,r.selector,n)}static from(e){return e instanceof t?e:"string"==typeof e?new t(JSON.parse(e)):"function"==typeof e.formatJson?new t(e.formatJson()):"function"==typeof e.format?new t(e.format("json")):new t(e)}};const gu=BigInt(0);function mu(t){return null==t?null:t}function _u(t){return null==t?null:t.toString()}class yu{constructor(t,e,r){__publicField(this,"gasPrice"),__publicField(this,"maxFeePerGas"),__publicField(this,"maxPriorityFeePerGas"),Tr(this,{gasPrice:mu(t),maxFeePerGas:mu(e),maxPriorityFeePerGas:mu(r)})}toJSON(){const{gasPrice:t,maxFeePerGas:e,maxPriorityFeePerGas:r}=this;return{_type:"FeeData",gasPrice:_u(t),maxFeePerGas:_u(e),maxPriorityFeePerGas:_u(r)}}}function vu(t){const e={};t.to&&(e.to=t.to),t.from&&(e.from=t.from),t.data&&(e.data=Vr(t.data));const r="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const i of r)i in t&&null!=t[i]&&(e[i]=sn(t[i],`request.${i}`));const n="type,nonce".split(/,/);for(const i of n)i in t&&null!=t[i]&&(e[i]=cn(t[i],`request.${i}`));return t.accessList&&(e.accessList=vo(t.accessList)),t.authorizationList&&(e.authorizationList=t.authorizationList.slice()),"blockTag"in t&&(e.blockTag=t.blockTag),"enableCcipRead"in t&&(e.enableCcipRead=!!t.enableCcipRead),"customData"in t&&(e.customData=t.customData),"blobVersionedHashes"in t&&t.blobVersionedHashes&&(e.blobVersionedHashes=t.blobVersionedHashes.slice()),"kzg"in t&&(e.kzg=t.kzg),"blobs"in t&&t.blobs&&(e.blobs=t.blobs.map((t=>Qr(t)?Vr(t):Object.assign({},t)))),e}class wu{constructor(t,e){__publicField(this,"provider"),__publicField(this,"number"),__publicField(this,"hash"),__publicField(this,"timestamp"),__publicField(this,"parentHash"),__publicField(this,"parentBeaconBlockRoot"),__publicField(this,"nonce"),__publicField(this,"difficulty"),__publicField(this,"gasLimit"),__publicField(this,"gasUsed"),__publicField(this,"stateRoot"),__publicField(this,"receiptsRoot"),__publicField(this,"blobGasUsed"),__publicField(this,"excessBlobGas"),__publicField(this,"miner"),__publicField(this,"prevRandao"),__publicField(this,"extraData"),__publicField(this,"baseFeePerGas"),__privateAdd(this,qt,void 0),__privateSet(this,qt,t.transactions.map((t=>"string"!=typeof t?new Eu(t,e):t))),Tr(this,{provider:e,hash:mu(t.hash),number:t.number,timestamp:t.timestamp,parentHash:t.parentHash,parentBeaconBlockRoot:t.parentBeaconBlockRoot,nonce:t.nonce,difficulty:t.difficulty,gasLimit:t.gasLimit,gasUsed:t.gasUsed,blobGasUsed:t.blobGasUsed,excessBlobGas:t.excessBlobGas,miner:t.miner,prevRandao:mu(t.prevRandao),extraData:t.extraData,baseFeePerGas:mu(t.baseFeePerGas),stateRoot:t.stateRoot,receiptsRoot:t.receiptsRoot})}get transactions(){return __privateGet(this,qt).map((t=>"string"==typeof t?t:t.hash))}get prefetchedTransactions(){const t=__privateGet(this,qt).slice();return 0===t.length?[]:(Br("object"==typeof t[0],"transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),t)}toJSON(){const{baseFeePerGas:t,difficulty:e,extraData:r,gasLimit:n,gasUsed:i,hash:s,miner:a,prevRandao:o,nonce:l,number:c,parentHash:u,parentBeaconBlockRoot:h,stateRoot:d,receiptsRoot:p,timestamp:f,transactions:g}=this;return{_type:"Block",baseFeePerGas:_u(t),difficulty:_u(e),extraData:r,gasLimit:_u(n),gasUsed:_u(i),blobGasUsed:_u(this.blobGasUsed),excessBlobGas:_u(this.excessBlobGas),hash:s,miner:a,prevRandao:o,nonce:l,number:c,parentHash:u,timestamp:f,parentBeaconBlockRoot:h,stateRoot:d,receiptsRoot:p,transactions:g}}[Symbol.iterator](){let t=0;const e=this.transactions;return{next:()=>t<this.length?{value:e[t++],done:!1}:{value:void 0,done:!0}}}get length(){return __privateGet(this,qt).length}get date(){return null==this.timestamp?null:new Date(1e3*this.timestamp)}getTransaction(t){return __async(this,null,(function*(){let e;if("number"==typeof t)e=__privateGet(this,qt)[t];else{const r=t.toLowerCase();for(const t of __privateGet(this,qt)){if("string"==typeof t){if(t!==r)continue;e=t;break}if(t.hash===r){e=t;break}}}if(null==e)throw new Error("no such tx");return"string"==typeof e?yield this.provider.getTransaction(e):e}))}getPrefetchedTransaction(t){const e=this.prefetchedTransactions;if("number"==typeof t)return e[t];t=t.toLowerCase();for(const r of e)if(r.hash===t)return r;Or(!1,"no matching transaction","indexOrHash",t)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return{orphan:"drop-block",hash:(t=this).hash,number:t.number};var t}}qt=new WeakMap;class bu{constructor(t,e){__publicField(this,"provider"),__publicField(this,"transactionHash"),__publicField(this,"blockHash"),__publicField(this,"blockNumber"),__publicField(this,"removed"),__publicField(this,"address"),__publicField(this,"data"),__publicField(this,"topics"),__publicField(this,"index"),__publicField(this,"transactionIndex"),this.provider=e;const r=Object.freeze(t.topics.slice());Tr(this,{transactionHash:t.transactionHash,blockHash:t.blockHash,blockNumber:t.blockNumber,removed:t.removed,address:t.address,data:t.data,topics:r,index:t.index,transactionIndex:t.transactionIndex})}toJSON(){const{address:t,blockHash:e,blockNumber:r,data:n,index:i,removed:s,topics:a,transactionHash:o,transactionIndex:l}=this;return{_type:"log",address:t,blockHash:e,blockNumber:r,data:n,index:i,removed:s,topics:a,transactionHash:o,transactionIndex:l}}getBlock(){return __async(this,null,(function*(){const t=yield this.provider.getBlock(this.blockHash);return Br(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}))}getTransaction(){return __async(this,null,(function*(){const t=yield this.provider.getTransaction(this.transactionHash);return Br(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}))}getTransactionReceipt(){return __async(this,null,(function*(){const t=yield this.provider.getTransactionReceipt(this.transactionHash);return Br(!!t,"failed to find transaction receipt","UNKNOWN_ERROR",{}),t}))}removedEvent(){return{orphan:"drop-log",log:{transactionHash:(t=this).transactionHash,blockHash:t.blockHash,blockNumber:t.blockNumber,address:t.address,data:t.data,topics:Object.freeze(t.topics.slice()),index:t.index}};var t}}class Au{constructor(t,e){__publicField(this,"provider"),__publicField(this,"to"),__publicField(this,"from"),__publicField(this,"contractAddress"),__publicField(this,"hash"),__publicField(this,"index"),__publicField(this,"blockHash"),__publicField(this,"blockNumber"),__publicField(this,"logsBloom"),__publicField(this,"gasUsed"),__publicField(this,"blobGasUsed"),__publicField(this,"cumulativeGasUsed"),__publicField(this,"gasPrice"),__publicField(this,"blobGasPrice"),__publicField(this,"type"),__publicField(this,"status"),__publicField(this,"root"),__privateAdd(this,Zt,void 0),__privateSet(this,Zt,Object.freeze(t.logs.map((t=>new bu(t,e)))));let r=gu;null!=t.effectiveGasPrice?r=t.effectiveGasPrice:null!=t.gasPrice&&(r=t.gasPrice),Tr(this,{provider:e,to:t.to,from:t.from,contractAddress:t.contractAddress,hash:t.hash,index:t.index,blockHash:t.blockHash,blockNumber:t.blockNumber,logsBloom:t.logsBloom,gasUsed:t.gasUsed,cumulativeGasUsed:t.cumulativeGasUsed,blobGasUsed:t.blobGasUsed,gasPrice:r,blobGasPrice:t.blobGasPrice,type:t.type,status:t.status,root:t.root})}get logs(){return __privateGet(this,Zt)}toJSON(){const{to:t,from:e,contractAddress:r,hash:n,index:i,blockHash:s,blockNumber:a,logsBloom:o,logs:l,status:c,root:u}=this;return{_type:"TransactionReceipt",blockHash:s,blockNumber:a,contractAddress:r,cumulativeGasUsed:_u(this.cumulativeGasUsed),from:e,gasPrice:_u(this.gasPrice),blobGasUsed:_u(this.blobGasUsed),blobGasPrice:_u(this.blobGasPrice),gasUsed:_u(this.gasUsed),hash:n,index:i,logs:l,logsBloom:o,root:u,status:c,to:t}}get length(){return this.logs.length}[Symbol.iterator](){let t=0;return{next:()=>t<this.length?{value:this.logs[t++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}getBlock(){return __async(this,null,(function*(){const t=yield this.provider.getBlock(this.blockHash);if(null==t)throw new Error("TODO");return t}))}getTransaction(){return __async(this,null,(function*(){const t=yield this.provider.getTransaction(this.hash);if(null==t)throw new Error("TODO");return t}))}getResult(){return __async(this,null,(function*(){return yield this.provider.getTransactionResult(this.hash)}))}confirmations(){return __async(this,null,(function*(){return(yield this.provider.getBlockNumber())-this.blockNumber+1}))}removedEvent(){return ku(this)}reorderedEvent(t){return Br(!t||t.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),xu(this,t)}}Zt=new WeakMap;Yt=new WeakMap;let Eu=class t{constructor(t,e){__publicField(this,"provider"),__publicField(this,"blockNumber"),__publicField(this,"blockHash"),__publicField(this,"index"),__publicField(this,"hash"),__publicField(this,"type"),__publicField(this,"to"),__publicField(this,"from"),__publicField(this,"nonce"),__publicField(this,"gasLimit"),__publicField(this,"gasPrice"),__publicField(this,"maxPriorityFeePerGas"),__publicField(this,"maxFeePerGas"),__publicField(this,"maxFeePerBlobGas"),__publicField(this,"data"),__publicField(this,"value"),__publicField(this,"chainId"),__publicField(this,"signature"),__publicField(this,"accessList"),__publicField(this,"blobVersionedHashes"),__publicField(this,"authorizationList"),__privateAdd(this,Yt,void 0),this.provider=e,this.blockNumber=null!=t.blockNumber?t.blockNumber:null,this.blockHash=null!=t.blockHash?t.blockHash:null,this.hash=t.hash,this.index=t.index,this.type=t.type,this.from=t.from,this.to=t.to||null,this.gasLimit=t.gasLimit,this.nonce=t.nonce,this.data=t.data,this.value=t.value,this.gasPrice=t.gasPrice,this.maxPriorityFeePerGas=null!=t.maxPriorityFeePerGas?t.maxPriorityFeePerGas:null,this.maxFeePerGas=null!=t.maxFeePerGas?t.maxFeePerGas:null,this.maxFeePerBlobGas=null!=t.maxFeePerBlobGas?t.maxFeePerBlobGas:null,this.chainId=t.chainId,this.signature=t.signature,this.accessList=null!=t.accessList?t.accessList:null,this.blobVersionedHashes=null!=t.blobVersionedHashes?t.blobVersionedHashes:null,this.authorizationList=null!=t.authorizationList?t.authorizationList:null,__privateSet(this,Yt,-1)}toJSON(){const{blockNumber:t,blockHash:e,index:r,hash:n,type:i,to:s,from:a,nonce:o,data:l,signature:c,accessList:u,blobVersionedHashes:h}=this;return{_type:"TransactionResponse",accessList:u,blockNumber:t,blockHash:e,blobVersionedHashes:h,chainId:_u(this.chainId),data:l,from:a,gasLimit:_u(this.gasLimit),gasPrice:_u(this.gasPrice),hash:n,maxFeePerGas:_u(this.maxFeePerGas),maxPriorityFeePerGas:_u(this.maxPriorityFeePerGas),maxFeePerBlobGas:_u(this.maxFeePerBlobGas),nonce:o,signature:c,to:s,index:r,type:i,value:_u(this.value)}}getBlock(){return __async(this,null,(function*(){let t=this.blockNumber;if(null==t){const e=yield this.getTransaction();e&&(t=e.blockNumber)}if(null==t)return null;const e=this.provider.getBlock(t);if(null==e)throw new Error("TODO");return e}))}getTransaction(){return __async(this,null,(function*(){return this.provider.getTransaction(this.hash)}))}confirmations(){return __async(this,null,(function*(){if(null==this.blockNumber){const{tx:t,blockNumber:e}=yield Cr({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return null==t||null==t.blockNumber?0:e-t.blockNumber+1}return(yield this.provider.getBlockNumber())-this.blockNumber+1}))}wait(t,e){return __async(this,null,(function*(){const r=null==t?1:t,n=null==e?0:e;let i=__privateGet(this,Yt),s=-1,a=-1===i;const o=()=>__async(this,null,(function*(){if(a)return null;const{blockNumber:t,nonce:e}=yield Cr({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(e<this.nonce)return void(i=t);if(a)return null;const n=yield this.getTransaction();if(!n||null==n.blockNumber)for(-1===s&&(s=i-3,s<__privateGet(this,Yt)&&(s=__privateGet(this,Yt)));s<=t;){if(a)return null;const e=yield this.provider.getBlock(s,!0);if(null==e)return;for(const t of e)if(t===this.hash)return;for(let n=0;n<e.length;n++){const s=yield e.getTransaction(n);if(s.from===this.from&&s.nonce===this.nonce){if(a)return null;const e=yield this.provider.getTransactionReceipt(s.hash);if(null==e)return;if(t-e.blockNumber+1<r)return;let n="replaced";s.data===this.data&&s.to===this.to&&s.value===this.value?n="repriced":"0x"===s.data&&s.from===s.to&&s.value===gu&&(n="cancelled"),Br(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:"replaced"===n||"cancelled"===n,reason:n,replacement:s.replaceableTransaction(i),hash:s.hash,receipt:e})}}s++}})),l=t=>{if(null==t||0!==t.status)return t;Br(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:t.to,from:t.from,data:""},receipt:t})},c=yield this.provider.getTransactionReceipt(this.hash);if(0===r)return l(c);if(c){if(1===r||(yield c.confirmations())>=r)return l(c)}else if(yield o(),0===r)return null;const u=new Promise(((t,e)=>{const s=[],c=()=>{s.forEach((t=>t()))};if(s.push((()=>{a=!0})),n>0){const t=setTimeout((()=>{c(),e(Ir("wait for transaction timeout","TIMEOUT"))}),n);s.push((()=>{clearTimeout(t)}))}const u=n=>__async(this,null,(function*(){if((yield n.confirmations())>=r){c();try{t(l(n))}catch(i){e(i)}}}));if(s.push((()=>{this.provider.off(this.hash,u)})),this.provider.on(this.hash,u),i>=0){const t=()=>__async(this,null,(function*(){try{yield o()}catch(r){if(Gr(r,"TRANSACTION_REPLACED"))return c(),void e(r)}a||this.provider.once("block",t)}));s.push((()=>{this.provider.off("block",t)})),this.provider.once("block",t)}}));return yield u}))}isMined(){return null!=this.blockHash}isLegacy(){return 0===this.type}isBerlin(){return 1===this.type}isLondon(){return 2===this.type}isCancun(){return 3===this.type}removedEvent(){return Br(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),ku(this)}reorderedEvent(t){return Br(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Br(!t||t.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),xu(this,t)}replaceableTransaction(e){Or(Number.isInteger(e)&&e>=0,"invalid startBlock","startBlock",e);const r=new t(this,this.provider);return __privateSet(r,Yt,e),r}};function xu(t,e){return{orphan:"reorder-transaction",tx:t,other:e}}function ku(t){return{orphan:"drop-transaction",tx:t}}class Su extends bu{constructor(t,e,r){super(t,t.provider),__publicField(this,"interface"),__publicField(this,"fragment"),__publicField(this,"args");Tr(this,{args:e.decodeEventLog(r,t.data,t.topics),fragment:r,interface:e})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class Nu extends bu{constructor(t,e){super(t,t.provider),__publicField(this,"error"),Tr(this,{error:e})}}class Pu extends Au{constructor(t,e,r){super(r,e),__privateAdd(this,Xt,void 0),__privateSet(this,Xt,t)}get logs(){return super.logs.map((t=>{const e=t.topics.length?__privateGet(this,Xt).getEvent(t.topics[0]):null;if(e)try{return new Su(t,__privateGet(this,Xt),e)}catch(r){return new Nu(t,r)}return t}))}}Xt=new WeakMap;$t=new WeakMap;let Cu=class t extends Eu{constructor(t,e,r){super(r,e),__privateAdd(this,$t,void 0),__privateSet(this,$t,t)}wait(e,r){return __async(this,null,(function*(){const n=yield __superGet(t.prototype,this,"wait").call(this,e,r);return null==n?null:new Pu(__privateGet(this,$t),this.provider,n)}))}};class Tu extends gn{constructor(t,e,r,n){super(t,e,r),__publicField(this,"log"),Tr(this,{log:n})}getBlock(){return __async(this,null,(function*(){return yield this.log.getBlock()}))}getTransaction(){return __async(this,null,(function*(){return yield this.log.getTransaction()}))}getTransactionReceipt(){return __async(this,null,(function*(){return yield this.log.getTransactionReceipt()}))}}class Ru extends Tu{constructor(t,e,r,n,i){super(t,e,r,new Su(i,t.interface,n));Tr(this,{args:t.interface.decodeEventLog(n,this.log.data,this.log.topics),fragment:n})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const Gu=BigInt(0);function Mu(t){return t&&"function"==typeof t.call}function Iu(t){return t&&"function"==typeof t.estimateGas}function Bu(t){return t&&"function"==typeof t.resolveName}function Ou(t){return t&&"function"==typeof t.sendTransaction}function Fu(t){if(null!=t){if(Bu(t))return t;if(t.provider)return t.provider}}class Uu{constructor(t,e,r){if(__privateAdd(this,te,void 0),__publicField(this,"fragment"),Tr(this,{fragment:e}),e.inputs.length<r.length)throw new Error("too many arguments");const n=Lu(t.runner,"resolveName"),i=Bu(n)?n:null;__privateSet(this,te,function(){return __async(this,null,(function*(){const n=yield Promise.all(e.inputs.map(((t,e)=>null==r[e]?null:t.walkAsync(r[e],((t,e)=>"address"===t?Array.isArray(e)?Promise.all(e.map((t=>Ka(t,i)))):Ka(e,i):e)))));return t.interface.encodeFilterTopics(e,n)}))}())}getTopicFilter(){return __privateGet(this,te)}}function Lu(t,e){return null==t?null:"function"==typeof t[e]?t:t.provider&&"function"==typeof t.provider[e]?t.provider:null}function Du(t){return null==t?null:t.provider||null}function ju(t,e){return __async(this,null,(function*(){const r=$a.dereference(t,"overrides");Or("object"==typeof r,"invalid overrides parameter","overrides",t);const n=vu(r);return Or(null==n.to||(e||[]).indexOf("to")>=0,"cannot override to","overrides.to",n.to),Or(null==n.data||(e||[]).indexOf("data")>=0,"cannot override data","overrides.data",n.data),n.from&&(n.from=n.from),n}))}function Hu(t){const e=function(e){return __async(this,null,(function*(){const r=yield ju(e,["data"]);r.to=yield t.getAddress(),r.from&&(r.from=yield Ka(r.from,Fu(t.runner)));const n=t.interface,i=sn(r.value||Gu,"overrides.value")===Gu,s="0x"===(r.data||"0x");!n.fallback||n.fallback.payable||!n.receive||s||i||Or(!1,"cannot send data to receive or send value to non-payable fallback","overrides",e),Or(n.fallback||s,"cannot send data to receive-only contract","overrides.data",r.data);return Or(n.receive||n.fallback&&n.fallback.payable||i,"cannot send value to non-payable fallback","overrides.value",r.value),Or(n.fallback||s,"cannot send data to receive-only contract","overrides.data",r.data),r}))},r=function(r){return __async(this,null,(function*(){const n=t.runner;Br(Ou(n),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const i=yield n.sendTransaction(yield e(r)),s=Du(t.runner);return new Cu(t.interface,s,i)}))},n=t=>__async(this,null,(function*(){return yield r(t)}));return Tr(n,{_contract:t,estimateGas:function(r){return __async(this,null,(function*(){const n=Lu(t.runner,"estimateGas");return Br(Iu(n),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),yield n.estimateGas(yield e(r))}))},populateTransaction:e,send:r,staticCall:function(r){return __async(this,null,(function*(){const n=Lu(t.runner,"call");Br(Mu(n),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const i=yield e(r);try{return yield n.call(i)}catch(s){if(Mr(s)&&s.data)throw t.interface.makeError(s.data,i);throw s}}))}}),n}function Wu(t,e){const r=function(...r){const n=t.interface.getFunction(e,r);return Br(n,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:r}}),n},n=function(...e){return __async(this,null,(function*(){const n=r(...e);let i={};if(n.inputs.length+1===e.length&&(i=yield ju(e.pop()),i.from&&(i.from=yield Ka(i.from,Fu(t.runner)))),n.inputs.length!==e.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const s=yield function(t,e,r){return __async(this,null,(function*(){const n=Lu(t,"resolveName"),i=Bu(n)?n:null;return yield Promise.all(e.map(((t,e)=>t.walkAsync(r[e],((t,e)=>(e=$a.dereference(e,t),"address"===t?Ka(e,i):e))))))}))}(t.runner,n.inputs,e);return Object.assign({},i,yield Cr({to:t.getAddress(),data:t.interface.encodeFunctionData(n,s)}))}))},i=function(...t){return __async(this,null,(function*(){const e=yield a(...t);return 1===e.length?e[0]:e}))},s=function(...e){return __async(this,null,(function*(){const r=t.runner;Br(Ou(r),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const i=yield r.sendTransaction(yield n(...e)),s=Du(t.runner);return new Cu(t.interface,s,i)}))},a=function(...e){return __async(this,null,(function*(){const i=Lu(t.runner,"call");Br(Mu(i),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const s=yield n(...e);let a="0x";try{a=yield i.call(s)}catch(l){if(Mr(l)&&l.data)throw t.interface.makeError(l.data,s);throw l}const o=r(...e);return t.interface.decodeFunctionResult(o,a)}))},o=(...t)=>__async(this,null,(function*(){return r(...t).constant?yield i(...t):yield s(...t)}));return Tr(o,{name:t.interface.getFunctionName(e),_contract:t,_key:e,getFragment:r,estimateGas:function(...e){return __async(this,null,(function*(){const r=Lu(t.runner,"estimateGas");return Br(Iu(r),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),yield r.estimateGas(yield n(...e))}))},populateTransaction:n,send:s,staticCall:i,staticCallResult:a}),Object.defineProperty(o,"fragment",{configurable:!1,enumerable:!0,get:()=>{const r=t.interface.getFunction(e);return Br(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),r}}),o}te=new WeakMap;const Qu=Symbol.for("_ethersInternal_contract"),zu=new WeakMap;function Vu(t){return zu.get(t[Qu])}function Ju(t,e){return __async(this,null,(function*(){let r,n=null;if(Array.isArray(e)){const n=function(e){if(Wr(e,32))return e;const r=t.interface.getEvent(e);return Or(r,"unknown fragment","name",e),r.topicHash};r=e.map((t=>null==t?null:Array.isArray(t)?t.map(n):n(t)))}else"*"===e?r=[null]:"string"==typeof e?Wr(e,32)?r=[e]:(n=t.interface.getEvent(e),Or(n,"unknown fragment","event",e),r=[n.topicHash]):(i=e)&&"object"==typeof i&&"getTopicFilter"in i&&"function"==typeof i.getTopicFilter&&i.fragment?r=yield e.getTopicFilter():"fragment"in e?(n=e.fragment,r=[n.topicHash]):Or(!1,"unknown event name","event",e);var i;r=r.map((t=>{if(null==t)return null;if(Array.isArray(t)){const e=Array.from(new Set(t.map((t=>t.toLowerCase()))).values());return 1===e.length?e[0]:(e.sort(),e)}return t.toLowerCase()}));return{fragment:n,tag:r.map((t=>null==t?"null":Array.isArray(t)?t.join("|"):t)).join("&"),topics:r}}))}function Ku(t,e){return __async(this,null,(function*(){const{subs:r}=Vu(t);return r.get((yield Ju(t,e)).tag)||null}))}function qu(t,e,r){return __async(this,null,(function*(){const n=Du(t.runner);Br(n,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:i,tag:s,topics:a}=yield Ju(t,r),{addr:o,subs:l}=Vu(t);let c=l.get(s);if(!c){const e={address:o||t,topics:a},u=e=>{let n=i;if(null==n)try{n=t.interface.getEvent(e.topics[0])}catch(s){}if(n){const s=n,a=i?t.interface.decodeEventLog(i,e.data,e.topics):[];Yu(t,r,a,(n=>new Ru(t,n,r,s,e)))}else Yu(t,r,[],(n=>new Tu(t,n,r,e)))};let h=[];c={tag:s,listeners:[],start:()=>{h.length||h.push(n.on(e,u))},stop:()=>__async(this,null,(function*(){if(0==h.length)return;let t=h;h=[],yield Promise.all(t),n.off(e,u)}))},l.set(s,c)}return c}))}let Zu=Promise.resolve();function Yu(t,e,r,n){return __async(this,null,(function*(){try{yield Zu}catch(s){}const i=function(t,e,r,n){return __async(this,null,(function*(){yield Zu;const i=yield Ku(t,e);if(!i)return!1;const a=i.listeners.length;return i.listeners=i.listeners.filter((({listener:e,once:i})=>{const a=Array.from(r);n&&a.push(n(i?null:e));try{e.call(t,...a)}catch(s){}return!i})),0===i.listeners.length&&(i.stop(),Vu(t).subs.delete(i.tag)),a>0}))}(t,e,r,n);return Zu=i,yield i}))}const Xu=["then"];ee=Qu;let $u=class t{constructor(t,e,r,n){__publicField(this,"target"),__publicField(this,"interface"),__publicField(this,"runner"),__publicField(this,"filters"),__publicField(this,ee),__publicField(this,"fallback"),Or("string"==typeof t||Va(t),"invalid value for Contract target","target",t),null==r&&(r=null);const i=fu.from(e);let s;Tr(this,{target:t,runner:r,interface:i}),Object.defineProperty(this,Qu,{value:{}});let a=null,o=null;if(n){const t=Du(r);o=new Cu(this.interface,t,n)}let l=new Map;if("string"==typeof t)if(Wr(t))a=t,s=Promise.resolve(t);else{const e=Lu(r,"resolveName");if(!Bu(e))throw Ir("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});s=e.resolveName(t).then((e=>{if(null==e)throw Ir("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:t});return Vu(this).addr=e,e}))}else s=t.getAddress().then((t=>{if(null==t)throw new Error("TODO");return Vu(this).addr=t,t}));var c,u;c=this,u={addrPromise:s,addr:a,deployTx:o,subs:l},zu.set(c[Qu],u);return Tr(this,{filters:new Proxy({},{get:(t,e,r)=>{if("symbol"==typeof e||Xu.indexOf(e)>=0)return Reflect.get(t,e,r);try{return this.getEvent(e)}catch(n){if(!Gr(n,"INVALID_ARGUMENT")||"key"!==n.argument)throw n}},has:(t,e)=>Xu.indexOf(e)>=0?Reflect.has(t,e):Reflect.has(t,e)||this.interface.hasEvent(String(e))})}),Tr(this,{fallback:i.receive||i.fallback?Hu(this):null}),new Proxy(this,{get:(t,e,r)=>{if("symbol"==typeof e||e in t||Xu.indexOf(e)>=0)return Reflect.get(t,e,r);try{return t.getFunction(e)}catch(n){if(!Gr(n,"INVALID_ARGUMENT")||"key"!==n.argument)throw n}},has:(t,e)=>"symbol"==typeof e||e in t||Xu.indexOf(e)>=0?Reflect.has(t,e):t.interface.hasFunction(e)})}connect(e){return new t(this.target,this.interface,e)}attach(e){return new t(e,this.interface,this.runner)}getAddress(){return __async(this,null,(function*(){return yield Vu(this).addrPromise}))}getDeployedCode(){return __async(this,null,(function*(){const t=Du(this.runner);Br(t,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const e=yield t.getCode(yield this.getAddress());return"0x"===e?null:e}))}waitForDeployment(){return __async(this,null,(function*(){const t=this.deploymentTransaction();if(t)return yield t.wait(),this;if(null!=(yield this.getDeployedCode()))return this;const e=Du(this.runner);return Br(null!=e,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise(((t,r)=>{const n=()=>__async(this,null,(function*(){try{if(null!=(yield this.getDeployedCode()))return t(this);e.once("block",n)}catch(i){r(i)}}));n()}))}))}deploymentTransaction(){return Vu(this).deployTx}getFunction(t){"string"!=typeof t&&(t=t.format());return Wu(this,t)}getEvent(t){return"string"!=typeof t&&(t=t.format()),function(t,e){const r=function(...r){const n=t.interface.getEvent(e,r);return Br(n,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:r}}),n},n=function(...e){return new Uu(t,r(...e),e)};return Tr(n,{name:t.interface.getEventName(e),_contract:t,_key:e,getFragment:r}),Object.defineProperty(n,"fragment",{configurable:!1,enumerable:!0,get:()=>{const r=t.interface.getEvent(e);return Br(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),r}}),n}(this,t)}queryTransaction(t){return __async(this,null,(function*(){throw new Error("@TODO")}))}queryFilter(t,e,r){return __async(this,null,(function*(){null==e&&(e=0),null==r&&(r="latest");const{addr:n,addrPromise:i}=Vu(this),s=n||(yield i),{fragment:a,topics:o}=yield Ju(this,t),l={address:s,topics:o,fromBlock:e,toBlock:r},c=Du(this.runner);return Br(c,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(yield c.getLogs(l)).map((t=>{let e=a;if(null==e)try{e=this.interface.getEvent(t.topics[0])}catch(r){}if(e)try{return new Su(t,this.interface,e)}catch(r){return new Nu(t,r)}return new bu(t,c)}))}))}on(t,e){return __async(this,null,(function*(){const r=yield qu(this,"on",t);return r.listeners.push({listener:e,once:!1}),r.start(),this}))}once(t,e){return __async(this,null,(function*(){const r=yield qu(this,"once",t);return r.listeners.push({listener:e,once:!0}),r.start(),this}))}emit(t,...e){return __async(this,null,(function*(){return yield Yu(this,t,e,null)}))}listenerCount(t){return __async(this,null,(function*(){if(t){const e=yield Ku(this,t);return e?e.listeners.length:0}const{subs:e}=Vu(this);let r=0;for(const{listeners:t}of e.values())r+=t.length;return r}))}listeners(t){return __async(this,null,(function*(){if(t){const e=yield Ku(this,t);return e?e.listeners.map((({listener:t})=>t)):[]}const{subs:e}=Vu(this);let r=[];for(const{listeners:t}of e.values())r=r.concat(t.map((({listener:t})=>t)));return r}))}off(t,e){return __async(this,null,(function*(){const r=yield Ku(this,t);if(!r)return this;if(e){const t=r.listeners.map((({listener:t})=>t)).indexOf(e);t>=0&&r.listeners.splice(t,1)}return null!=e&&0!==r.listeners.length||(r.stop(),Vu(this).subs.delete(r.tag)),this}))}removeAllListeners(t){return __async(this,null,(function*(){if(t){const e=yield Ku(this,t);if(!e)return this;e.stop(),Vu(this).subs.delete(e.tag)}else{const{subs:t}=Vu(this);for(const{tag:e,stop:r}of t.values())r(),t.delete(e)}return this}))}addListener(t,e){return __async(this,null,(function*(){return yield this.on(t,e)}))}removeListener(t,e){return __async(this,null,(function*(){return yield this.off(t,e)}))}static buildClass(e){return class extends t{constructor(t,r=null){super(t,e,r)}}}static from(t,e,r){null==r&&(r=null);return new this(t,e,r)}};class th extends(function(){return $u}()){}function eh(t){return t.match(/^ipfs:\/\/ipfs\//i)?t=t.substring(12):t.match(/^ipfs:\/\//i)?t=t.substring(7):Or(!1,"unsupported IPFS format","link",t),`https://gateway.ipfs.io/ipfs/${t}`}class rh{constructor(t){__publicField(this,"name"),Tr(this,{name:t})}connect(t){return this}supportsCoinType(t){return!1}encodeAddress(t,e){return __async(this,null,(function*(){throw new Error("unsupported coin")}))}decodeAddress(t,e){return __async(this,null,(function*(){throw new Error("unsupported coin")}))}}const nh=new RegExp("^(ipfs)://(.*)$","i"),ih=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),nh,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")],sh=class t{constructor(t,e,r){__privateAdd(this,ie),__publicField(this,"provider"),__publicField(this,"address"),__publicField(this,"name"),__privateAdd(this,re,void 0),__privateAdd(this,ne,void 0),Tr(this,{provider:t,address:e,name:r}),__privateSet(this,re,null),__privateSet(this,ne,new th(e,["function supportsInterface(bytes4) view returns (bool)","function resolve(bytes, bytes) view returns (bytes)","function addr(bytes32) view returns (address)","function addr(bytes32, uint) view returns (bytes)","function text(bytes32, string) view returns (string)","function contenthash(bytes32) view returns (bytes)"],t))}supportsWildcard(){return __async(this,null,(function*(){return null==__privateGet(this,re)&&__privateSet(this,re,(()=>__async(this,null,(function*(){try{return yield __privateGet(this,ne).supportsInterface("0x9061b923")}catch(t){if(Gr(t,"CALL_EXCEPTION"))return!1;throw __privateSet(this,re,null),t}})))()),yield __privateGet(this,re)}))}getAddress(t){return __async(this,null,(function*(){if(null==t&&(t=60),60===t)try{const t=yield __privateMethod(this,ie,se).call(this,"addr(bytes32)");return null==t||t===Na?null:t}catch(i){if(Gr(i,"CALL_EXCEPTION"))return null;throw i}if(t>=0&&t<2147483648){let e=t+2147483648;const r=yield __privateMethod(this,ie,se).call(this,"addr(bytes32,uint)",[e]);if(Wr(r,20))return za(r)}let e=null;for(const s of this.provider.plugins)if(s instanceof rh&&s.supportsCoinType(t)){e=s;break}if(null==e)return null;const r=yield __privateMethod(this,ie,se).call(this,"addr(bytes32,uint)",[t]);if(null==r||"0x"===r)return null;const n=yield e.decodeAddress(t,r);if(null!=n)return n;Br(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${t})`,info:{coinType:t,data:r}})}))}getText(t){return __async(this,null,(function*(){const e=yield __privateMethod(this,ie,se).call(this,"text(bytes32,string)",[t]);return null==e||"0x"===e?null:e}))}getContentHash(){return __async(this,null,(function*(){const t=yield __privateMethod(this,ie,se).call(this,"contenthash(bytes32)");if(null==t||"0x"===t)return null;const e=t.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(e){const t="e3010170"===e[1]?"ipfs":"ipns",r=parseInt(e[4],16);if(e[5].length===2*r)return`${t}://${function(t){const e=jr(t);let r=ln(e),n="";for(;r;)n=pn[Number(r%fn)]+n,r/=fn;for(let i=0;i<e.length&&!e[i];i++)n=pn[0]+n;return n}("0x"+e[2])}`}const r=t.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(r&&64===r[1].length)return`bzz://${r[1]}`;Br(!1,"invalid or unsupported content hash data","UNSUPPORTED_OPERATION",{operation:"getContentHash()",info:{data:t}})}))}getAvatar(){return __async(this,null,(function*(){return(yield this._getAvatar()).url}))}_getAvatar(){return __async(this,null,(function*(){const t=[{type:"name",value:this.name}];try{const n=yield this.getText("avatar");if(null==n)return t.push({type:"!avatar",value:""}),{url:null,linkage:t};t.push({type:"avatar",value:n});for(let i=0;i<ih.length;i++){const s=n.match(ih[i]);if(null==s)continue;const a=s[1].toLowerCase();switch(a){case"https":case"data":return t.push({type:"url",value:n}),{linkage:t,url:n};case"ipfs":{const e=eh(n);return t.push({type:"ipfs",value:n}),t.push({type:"url",value:e}),{linkage:t,url:e}}case"erc721":case"erc1155":{const i="erc721"===a?"tokenURI(uint256)":"uri(uint256)";t.push({type:a,value:n});const o=yield this.getAddress();if(null==o)return t.push({type:"!owner",value:""}),{url:null,linkage:t};const l=(s[2]||"").split("/");if(2!==l.length)return t.push({type:`!${a}caip`,value:s[2]||""}),{url:null,linkage:t};const c=l[1],u=new th(l[0],["function tokenURI(uint) view returns (string)","function ownerOf(uint) view returns (address)","function uri(uint) view returns (string)","function balanceOf(address, uint256) view returns (uint)"],this.provider);if("erc721"===a){const e=yield u.ownerOf(c);if(o!==e)return t.push({type:"!owner",value:e}),{url:null,linkage:t};t.push({type:"owner",value:e})}else if("erc1155"===a){const e=yield u.balanceOf(o,c);if(!e)return t.push({type:"!balance",value:"0"}),{url:null,linkage:t};t.push({type:"balance",value:e.toString()})}let h=yield u[i](c);if(null==h||"0x"===h)return t.push({type:"!metadata-url",value:""}),{url:null,linkage:t};t.push({type:"metadata-url-base",value:h}),"erc1155"===a&&(h=h.replace("{id}",un(c,32).substring(2)),t.push({type:"metadata-url-expanded",value:h})),h.match(/^ipfs:/i)&&(h=eh(h)),t.push({type:"metadata-url",value:h});let d={};const p=yield new Gn(h).send();p.assertOk();try{d=p.bodyJson}catch(e){try{t.push({type:"!metadata",value:p.bodyText})}catch(r){const e=p.body;return e&&t.push({type:"!metadata",value:Vr(e)}),{url:null,linkage:t}}return{url:null,linkage:t}}if(!d)return t.push({type:"!metadata",value:""}),{url:null,linkage:t};t.push({type:"metadata",value:JSON.stringify(d)});let f=d.image;if("string"!=typeof f)return t.push({type:"!imageUrl",value:""}),{url:null,linkage:t};if(f.match(/^(https:\/\/|data:)/i));else{if(null==f.match(nh))return t.push({type:"!imageUrl-ipfs",value:f}),{url:null,linkage:t};t.push({type:"imageUrl-ipfs",value:f}),f=eh(f)}return t.push({type:"url",value:f}),{linkage:t,url:f}}}}}catch(e){}return{linkage:t,url:null}}))}static getEnsAddress(t){return __async(this,null,(function*(){const e=yield t.getNetwork(),r=e.getPlugin("org.ethers.plugins.network.Ens");return Br(r,"network does not support ENS","UNSUPPORTED_OPERATION",{operation:"getEnsAddress",info:{network:e}}),r.address}))}static fromName(e,r){return __async(this,null,(function*(){var n;let i=r;for(;;){if(""===i||"."===i)return null;if("eth"!==r&&"eth"===i)return null;const s=yield __privateMethod(n=t,ae,oe).call(n,e,i);if(null!=s){const n=new t(e,s,r);return i===r||(yield n.supportsWildcard())?n:null}i=i.split(".").slice(1).join(".")}}))}};re=new WeakMap,ne=new WeakMap,ie=new WeakSet,se=function(t,e){return __async(this,null,(function*(){e=(e||[]).slice();const r=__privateGet(this,ne).interface;e.unshift(Jl(this.name));let n=null;(yield this.supportsWildcard())&&(n=r.getFunction(t),Br(n,"missing fragment","UNKNOWN_ERROR",{info:{funcName:t}}),e=[Kl(this.name,255),r.encodeFunctionData(n,e)],t="resolve(bytes,bytes)"),e.push({enableCcipRead:!0});try{const i=yield __privateGet(this,ne)[t](...e);return n?r.decodeFunctionResult(n,i)[0]:i}catch(i){if(!Gr(i,"CALL_EXCEPTION"))throw i}return null}))},ae=new WeakSet,oe=function(t,e){return __async(this,null,(function*(){const r=yield sh.getEnsAddress(t);try{const n=new th(r,["function resolver(bytes32) view returns (address)"],t),i=yield n.resolver(Jl(e),{enableCcipRead:!0});return i===Na?null:i}catch(n){throw n}return null}))},__privateAdd(sh,ae);let ah=sh;const oh=BigInt(0);function lh(t,e){return function(r){return null==r?e:t(r)}}function ch(t,e){return r=>{if(e&&null==r)return null;if(!Array.isArray(r))throw new Error("not an array");return r.map((e=>t(e)))}}function uh(t,e){return r=>{const n={};for(const s in t){let a=s;if(e&&s in e&&!(a in r))for(const t of e[s])if(t in r){a=t;break}try{const e=t[s](r[a]);void 0!==e&&(n[s]=e)}catch(i){Br(!1,`invalid value for value.${s} (${i instanceof Error?i.message:"not-an-error"})`,"BAD_DATA",{value:r})}}return n}}function hh(t){return Or(Wr(t,!0),"invalid data","value",t),t}function dh(t){return Or(Wr(t,32),"invalid hash","value",t),t}const ph=uh({address:za,blockHash:dh,blockNumber:cn,data:hh,index:cn,removed:lh((function(t){switch(t){case!0:case"true":return!0;case!1:case"false":return!1}Or(!1,`invalid boolean; ${JSON.stringify(t)}`,"value",t)}),!1),topics:ch(dh),transactionHash:dh,transactionIndex:cn},{index:["logIndex"]});const fh=uh({hash:lh(dh),parentHash:dh,parentBeaconBlockRoot:lh(dh,null),number:cn,timestamp:cn,nonce:lh(hh),difficulty:sn,gasLimit:sn,gasUsed:sn,stateRoot:lh(dh,null),receiptsRoot:lh(dh,null),blobGasUsed:lh(sn,null),excessBlobGas:lh(sn,null),miner:lh(za),prevRandao:lh(dh,null),extraData:hh,baseFeePerGas:lh(sn)},{prevRandao:["mixHash"]});const gh=uh({transactionIndex:cn,blockNumber:cn,transactionHash:dh,address:za,topics:ch(dh),data:hh,index:cn,blockHash:dh},{index:["logIndex"]});const mh=uh({to:lh(za,null),from:lh(za,null),contractAddress:lh(za,null),index:cn,root:lh(Vr),gasUsed:sn,blobGasUsed:lh(sn,null),logsBloom:lh(hh),blockHash:dh,hash:dh,logs:ch((function(t){return gh(t)})),blockNumber:cn,cumulativeGasUsed:sn,effectiveGasPrice:lh(sn),blobGasPrice:lh(sn,null),status:lh(cn),type:lh(cn,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function _h(t){t.to&&sn(t.to)===oh&&(t.to="0x0000000000000000000000000000000000000000");const e=uh({hash:dh,index:lh(cn,void 0),type:t=>"0x"===t||null==t?0:cn(t),accessList:lh(vo,null),blobVersionedHashes:lh(ch(dh,!0),null),authorizationList:lh(ch((t=>{let e;if(t.signature)e=t.signature;else{let r=t.yParity;"0x1b"===r?r=0:"0x1c"===r&&(r=1),e=Object.assign({},t,{yParity:r})}return{address:za(t.address),chainId:sn(t.chainId),nonce:sn(t.nonce),signature:Ua.from(e)}}),!1),null),blockHash:lh(dh,null),blockNumber:lh(cn,null),transactionIndex:lh(cn,null),from:za,gasPrice:lh(sn),maxPriorityFeePerGas:lh(sn),maxFeePerGas:lh(sn),maxFeePerBlobGas:lh(sn,null),gasLimit:sn,to:lh(za,null),value:sn,nonce:cn,data:hh,creates:lh(za,null),chainId:lh(sn,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(t);if(null==e.to&&null==e.creates&&(e.creates=function(t){const e=za(t.from);let r=sn(t.nonce,"tx.nonce").toString(16);return r="0"===r?"0x":r.length%2?"0x0"+r:"0x"+r,za(qr(vs(ei([e,r])),12))}(e)),1!==t.type&&2!==t.type||null!=t.accessList||(e.accessList=[]),t.signature?e.signature=Ua.from(t.signature):e.signature=Ua.from(t),null==e.chainId){const t=e.signature.legacyChainId;null!=t&&(e.chainId=t)}return e.blockHash&&sn(e.blockHash)===oh&&(e.blockHash=null),e}class yh{constructor(t){__publicField(this,"name"),Tr(this,{name:t})}clone(){return new yh(this.name)}}class vh extends yh{constructor(t,e){null==t&&(t=0),super(`org.ethers.network.plugins.GasCost#${t||0}`),__publicField(this,"effectiveBlock"),__publicField(this,"txBase"),__publicField(this,"txCreate"),__publicField(this,"txDataZero"),__publicField(this,"txDataNonzero"),__publicField(this,"txAccessListStorageKey"),__publicField(this,"txAccessListAddress");const r={effectiveBlock:t};function n(t,n){let i=(e||{})[t];null==i&&(i=n),Or("number"==typeof i,`invalud value for ${t}`,"costs",e),r[t]=i}n("txBase",21e3),n("txCreate",32e3),n("txDataZero",4),n("txDataNonzero",16),n("txAccessListStorageKey",1900),n("txAccessListAddress",2400),Tr(this,r)}clone(){return new vh(this.effectiveBlock,this)}}class wh extends yh{constructor(t,e){super("org.ethers.plugins.network.Ens"),__publicField(this,"address"),__publicField(this,"targetNetwork"),Tr(this,{address:t||"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",targetNetwork:null==e?1:e})}clone(){return new wh(this.address,this.targetNetwork)}}class bh extends yh{constructor(t,e){super("org.ethers.plugins.network.FetchUrlFeeDataPlugin"),__privateAdd(this,le,void 0),__privateAdd(this,ce,void 0),__privateSet(this,le,t),__privateSet(this,ce,e)}get url(){return __privateGet(this,le)}get processFunc(){return __privateGet(this,ce)}clone(){return this}}le=new WeakMap,ce=new WeakMap;const Ah=new Map;ue=new WeakMap,he=new WeakMap,de=new WeakMap;let Eh=class t{constructor(t,e){__privateAdd(this,ue,void 0),__privateAdd(this,he,void 0),__privateAdd(this,de,void 0),__privateSet(this,ue,t),__privateSet(this,he,sn(e)),__privateSet(this,de,new Map)}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return __privateGet(this,ue)}set name(t){__privateSet(this,ue,t)}get chainId(){return __privateGet(this,he)}set chainId(t){__privateSet(this,he,sn(t,"chainId"))}matches(t){if(null==t)return!1;if("string"==typeof t){try{return this.chainId===sn(t)}catch(e){}return this.name===t}if("number"==typeof t||"bigint"==typeof t){try{return this.chainId===sn(t)}catch(e){}return!1}if("object"==typeof t){if(null!=t.chainId){try{return this.chainId===sn(t.chainId)}catch(e){}return!1}return null!=t.name&&this.name===t.name}return!1}get plugins(){return Array.from(__privateGet(this,de).values())}attachPlugin(t){if(__privateGet(this,de).get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return __privateGet(this,de).set(t.name,t.clone()),this}getPlugin(t){return __privateGet(this,de).get(t)||null}getPlugins(t){return this.plugins.filter((e=>e.name.split("#")[0]===t))}clone(){const e=new t(this.name,this.chainId);return this.plugins.forEach((t=>{e.attachPlugin(t.clone())})),e}computeIntrinsicGas(t){const e=this.getPlugin("org.ethers.plugins.network.GasCost")||new vh;let r=e.txBase;if(null==t.to&&(r+=e.txCreate),t.data)for(let n=2;n<t.data.length;n+=2)"00"===t.data.substring(n,n+2)?r+=e.txDataZero:r+=e.txDataNonzero;if(t.accessList){const n=vo(t.accessList);for(const t in n)r+=e.txAccessListAddress+e.txAccessListStorageKey*n[t].storageKeys.length}return r}static from(e){if(function(){if(Sh)return;function t(t,e,r){const n=function(){const n=new Eh(t,e);return null!=r.ensNetwork&&n.attachPlugin(new wh(null,r.ensNetwork)),n.attachPlugin(new vh),(r.plugins||[]).forEach((t=>{n.attachPlugin(t)})),n};Eh.register(t,n),Eh.register(e,n),r.altNames&&r.altNames.forEach((t=>{Eh.register(t,n)}))}Sh=!0,t("mainnet",1,{ensNetwork:1,altNames:["homestead"]}),t("ropsten",3,{ensNetwork:3}),t("rinkeby",4,{ensNetwork:4}),t("goerli",5,{ensNetwork:5}),t("kovan",42,{ensNetwork:42}),t("sepolia",11155111,{ensNetwork:11155111}),t("holesky",17e3,{ensNetwork:17e3}),t("classic",61,{}),t("classicKotti",6,{}),t("arbitrum",42161,{ensNetwork:1}),t("arbitrum-goerli",421613,{}),t("arbitrum-sepolia",421614,{}),t("base",8453,{ensNetwork:1}),t("base-goerli",84531,{}),t("base-sepolia",84532,{}),t("bnb",56,{ensNetwork:1}),t("bnbt",97,{}),t("linea",59144,{ensNetwork:1}),t("linea-goerli",59140,{}),t("linea-sepolia",59141,{}),t("matic",137,{ensNetwork:1,plugins:[kh("https://gasstation.polygon.technology/v2")]}),t("matic-amoy",80002,{}),t("matic-mumbai",80001,{altNames:["maticMumbai","maticmum"],plugins:[kh("https://gasstation-testnet.polygon.technology/v2")]}),t("optimism",10,{ensNetwork:1,plugins:[]}),t("optimism-goerli",420,{}),t("optimism-sepolia",11155420,{}),t("xdai",100,{ensNetwork:1})}(),null==e)return t.from("mainnet");if("number"==typeof e&&(e=BigInt(e)),"string"==typeof e||"bigint"==typeof e){const r=Ah.get(e);if(r)return r();if("bigint"==typeof e)return new t("unknown",e);Or(!1,"unknown network","network",e)}if("function"==typeof e.clone){return e.clone()}if("object"==typeof e){Or("string"==typeof e.name&&"number"==typeof e.chainId,"invalid network object name or chainId","network",e);const r=new t(e.name,e.chainId);return(e.ensAddress||null!=e.ensNetwork)&&r.attachPlugin(new wh(e.ensAddress,e.ensNetwork)),r}Or(!1,"invalid network","network",e)}static register(t,e){"number"==typeof t&&(t=BigInt(t));const r=Ah.get(t);r&&Or(!1,`conflicting network for ${JSON.stringify(r.name)}`,"nameOrChainId",t),Ah.set(t,e)}};function xh(t,e){const r=String(t);if(!r.match(/^[0-9.]+$/))throw new Error(`invalid gwei value: ${t}`);const n=r.split(".");if(1===n.length&&n.push(""),2!==n.length)throw new Error(`invalid gwei value: ${t}`);for(;n[1].length<e;)n[1]+="0";if(n[1].length>9){let t=BigInt(n[1].substring(0,9));n[1].substring(9).match(/^0+$/)||t++,n[1]=t.toString()}return BigInt(n[0]+n[1])}function kh(t){return new bh(t,((t,e,r)=>__async(this,null,(function*(){let e;r.setHeader("User-Agent","ethers");try{const[n,i]=yield Promise.all([r.send(),t()]);e=n;const s=e.bodyJson.standard;return{gasPrice:i.gasPrice,maxFeePerGas:xh(s.maxFee,9),maxPriorityFeePerGas:xh(s.maxPriorityFee,9)}}catch(n){Br(!1,`error encountered with polygon gas station (${JSON.stringify(r.url)})`,"SERVER_ERROR",{request:r,response:e,error:n})}}))))}let Sh=!1;function Nh(t){return JSON.parse(JSON.stringify(t))}class Ph{constructor(t){__privateAdd(this,_e),__privateAdd(this,pe,void 0),__privateAdd(this,fe,void 0),__privateAdd(this,ge,void 0),__privateAdd(this,me,void 0),__privateSet(this,pe,t),__privateSet(this,fe,null),__privateSet(this,ge,4e3),__privateSet(this,me,-2)}get pollingInterval(){return __privateGet(this,ge)}set pollingInterval(t){__privateSet(this,ge,t)}start(){__privateGet(this,fe)||(__privateSet(this,fe,__privateGet(this,pe)._setTimeout(__privateMethod(this,_e,ye).bind(this),__privateGet(this,ge))),__privateMethod(this,_e,ye).call(this))}stop(){__privateGet(this,fe)&&(__privateGet(this,pe)._clearTimeout(__privateGet(this,fe)),__privateSet(this,fe,null))}pause(t){this.stop(),t&&__privateSet(this,me,-2)}resume(){this.start()}}pe=new WeakMap,fe=new WeakMap,ge=new WeakMap,me=new WeakMap,_e=new WeakSet,ye=function(){return __async(this,null,(function*(){try{const t=yield __privateGet(this,pe).getBlockNumber();if(-2===__privateGet(this,me))return void __privateSet(this,me,t);if(t!==__privateGet(this,me)){for(let e=__privateGet(this,me)+1;e<=t;e++){if(null==__privateGet(this,fe))return;yield __privateGet(this,pe).emit("block",e)}__privateSet(this,me,t)}}catch(t){}null!=__privateGet(this,fe)&&__privateSet(this,fe,__privateGet(this,pe)._setTimeout(__privateMethod(this,_e,ye).bind(this),__privateGet(this,ge)))}))};class Ch{constructor(t){__privateAdd(this,ve,void 0),__privateAdd(this,we,void 0),__privateAdd(this,be,void 0),__privateSet(this,ve,t),__privateSet(this,be,!1),__privateSet(this,we,(t=>{this._poll(t,__privateGet(this,ve))}))}_poll(t,e){return __async(this,null,(function*(){throw new Error("sub-classes must override this")}))}start(){__privateGet(this,be)||(__privateSet(this,be,!0),__privateGet(this,we).call(this,-2),__privateGet(this,ve).on("block",__privateGet(this,we)))}stop(){__privateGet(this,be)&&(__privateSet(this,be,!1),__privateGet(this,ve).off("block",__privateGet(this,we)))}pause(t){this.stop()}resume(){this.start()}}ve=new WeakMap,we=new WeakMap,be=new WeakMap;class Th extends Ch{constructor(t,e){super(t),__privateAdd(this,Ae,void 0),__privateAdd(this,Ee,void 0),__privateSet(this,Ae,e),__privateSet(this,Ee,-2)}pause(t){t&&__privateSet(this,Ee,-2),super.pause(t)}_poll(t,e){return __async(this,null,(function*(){const t=yield e.getBlock(__privateGet(this,Ae));null!=t&&(-2===__privateGet(this,Ee)?__privateSet(this,Ee,t.number):t.number>__privateGet(this,Ee)&&(e.emit(__privateGet(this,Ae),t.number),__privateSet(this,Ee,t.number)))}))}}Ae=new WeakMap,Ee=new WeakMap;class Rh extends Ch{constructor(t,e){super(t),__privateAdd(this,xe,void 0),__privateSet(this,xe,Nh(e))}_poll(t,e){return __async(this,null,(function*(){throw new Error("@TODO")}))}}xe=new WeakMap;class Gh extends Ch{constructor(t,e){super(t),__privateAdd(this,ke,void 0),__privateSet(this,ke,e)}_poll(t,e){return __async(this,null,(function*(){const t=yield e.getTransactionReceipt(__privateGet(this,ke));t&&e.emit(__privateGet(this,ke),t)}))}}ke=new WeakMap;class Mh{constructor(t,e){__privateAdd(this,Re),__privateAdd(this,Se,void 0),__privateAdd(this,Ne,void 0),__privateAdd(this,Pe,void 0),__privateAdd(this,Ce,void 0),__privateAdd(this,Te,void 0),__privateSet(this,Se,t),__privateSet(this,Ne,Nh(e)),__privateSet(this,Pe,__privateMethod(this,Re,Ge).bind(this)),__privateSet(this,Ce,!1),__privateSet(this,Te,-2)}start(){__privateGet(this,Ce)||(__privateSet(this,Ce,!0),-2===__privateGet(this,Te)&&__privateGet(this,Se).getBlockNumber().then((t=>{__privateSet(this,Te,t)})),__privateGet(this,Se).on("block",__privateGet(this,Pe)))}stop(){__privateGet(this,Ce)&&(__privateSet(this,Ce,!1),__privateGet(this,Se).off("block",__privateGet(this,Pe)))}pause(t){this.stop(),t&&__privateSet(this,Te,-2)}resume(){this.start()}}Se=new WeakMap,Ne=new WeakMap,Pe=new WeakMap,Ce=new WeakMap,Te=new WeakMap,Re=new WeakSet,Ge=function(t){return __async(this,null,(function*(){if(-2===__privateGet(this,Te))return;const e=Nh(__privateGet(this,Ne));e.fromBlock=__privateGet(this,Te)+1,e.toBlock=t;const r=yield __privateGet(this,Se).getLogs(e);if(0!==r.length)for(const t of r)__privateGet(this,Se).emit(__privateGet(this,Ne),t),__privateSet(this,Te,t.blockNumber);else __privateGet(this,Te)<t-60&&__privateSet(this,Te,t-60)}))};const Ih=BigInt(2);function Bh(t){return t&&"function"==typeof t.then}function Oh(t,e){return t+":"+JSON.stringify(e,((t,e)=>{if(null==e)return"null";if("bigint"==typeof e)return`bigint:${e.toString()}`;if("string"==typeof e)return e.toLowerCase();if("object"==typeof e&&!Array.isArray(e)){const t=Object.keys(e);return t.sort(),t.reduce(((t,r)=>(t[r]=e[r],t)),{})}return e}))}class Fh{constructor(t){__publicField(this,"name"),Tr(this,{name:t})}start(){}stop(){}pause(t){}resume(){}}function Uh(t){return(t=Array.from(new Set(t).values())).sort(),t}function Lh(t,e){return __async(this,null,(function*(){if(null==t)throw new Error("invalid event");if(Array.isArray(t)&&(t={topics:t}),"string"==typeof t)switch(t){case"block":case"debug":case"error":case"finalized":case"network":case"pending":case"safe":return{type:t,tag:t}}if(Wr(t,32)){const e=t.toLowerCase();return{type:"transaction",tag:Oh("tx",{hash:e}),hash:e}}if(t.orphan){const e=t;return{type:"orphan",tag:Oh("orphan",e),filter:(r=e,JSON.parse(JSON.stringify(r)))}}var r;if(t.address||t.topics){const r=t,n={topics:(r.topics||[]).map((t=>null==t?null:Array.isArray(t)?Uh(t.map((t=>t.toLowerCase()))):t.toLowerCase()))};if(r.address){const t=[],i=[],s=r=>{Wr(r)?t.push(r):i.push((()=>__async(this,null,(function*(){t.push(yield Ka(r,e))})))())};Array.isArray(r.address)?r.address.forEach(s):s(r.address),i.length&&(yield Promise.all(i)),n.address=Uh(t.map((t=>t.toLowerCase())))}return{filter:n,tag:Oh("event",n),type:"event"}}Or(!1,"unknown ProviderEvent","event",t)}))}function Dh(){return(new Date).getTime()}const jh={cacheTimeout:250,pollingInterval:4e3};class Hh{constructor(t,e){if(__privateAdd(this,ze),__privateAdd(this,Je),__privateAdd(this,qe),__privateAdd(this,Ye),__privateAdd(this,$e),__privateAdd(this,er),__privateAdd(this,nr),__privateAdd(this,Me,void 0),__privateAdd(this,Ie,void 0),__privateAdd(this,Be,void 0),__privateAdd(this,Oe,void 0),__privateAdd(this,Fe,void 0),__privateAdd(this,Ue,void 0),__privateAdd(this,Le,void 0),__privateAdd(this,De,void 0),__privateAdd(this,je,void 0),__privateAdd(this,He,void 0),__privateAdd(this,We,void 0),__privateAdd(this,Qe,void 0),__privateSet(this,Qe,Object.assign({},jh,e||{})),"any"===t)__privateSet(this,Ue,!0),__privateSet(this,Fe,null);else if(t){const e=Eh.from(t);__privateSet(this,Ue,!1),__privateSet(this,Fe,Promise.resolve(e)),setTimeout((()=>{this.emit("network",e,null)}),0)}else __privateSet(this,Ue,!1),__privateSet(this,Fe,null);__privateSet(this,De,-1),__privateSet(this,Le,new Map),__privateSet(this,Me,new Map),__privateSet(this,Ie,new Map),__privateSet(this,Be,null),__privateSet(this,Oe,!1),__privateSet(this,je,1),__privateSet(this,He,new Map),__privateSet(this,We,!1)}get pollingInterval(){return __privateGet(this,Qe).pollingInterval}get provider(){return this}get plugins(){return Array.from(__privateGet(this,Ie).values())}attachPlugin(t){if(__privateGet(this,Ie).get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return __privateGet(this,Ie).set(t.name,t.connect(this)),this}getPlugin(t){return __privateGet(this,Ie).get(t)||null}get disableCcipRead(){return __privateGet(this,We)}set disableCcipRead(t){__privateSet(this,We,!!t)}ccipReadFetch(t,e,r){return __async(this,null,(function*(){if(this.disableCcipRead||0===r.length||null==t.to)return null;const n=t.to.toLowerCase(),i=e.toLowerCase(),s=[];for(let e=0;e<r.length;e++){const o=r[e],l=o.replace("{sender}",n).replace("{data}",i),c=new Gn(l);-1===o.indexOf("{data}")&&(c.body={data:i,sender:n}),this.emit("debug",{action:"sendCcipReadFetchRequest",request:c,index:e,urls:r});let u,h="unknown error";try{u=yield c.send()}catch(a){s.push(a.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:c,result:{error:a}});continue}try{const t=u.bodyJson;if(t.data)return this.emit("debug",{action:"receiveCcipReadFetchResult",request:c,result:t}),t.data;t.message&&(h=t.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:c,result:t})}catch(a){}Br(u.statusCode<400||u.statusCode>=500,`response not found during CCIP fetch: ${h}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:t,info:{url:o,errorMessage:h}}),s.push(h)}Br(!1,`error encountered during CCIP fetch: ${s.map((t=>JSON.stringify(t))).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:t,info:{urls:r,errorMessages:s}})}))}_wrapBlock(t,e){return new wu(function(t){const e=fh(t);return e.transactions=t.transactions.map((t=>"string"==typeof t?t:_h(t))),e}(t),this)}_wrapLog(t,e){return new bu(function(t){return ph(t)}(t),this)}_wrapTransactionReceipt(t,e){return new Au(function(t){return mh(t)}(t),this)}_wrapTransactionResponse(t,e){return new Eu(_h(t),this)}_detectNetwork(){Br(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}_perform(t){return __async(this,null,(function*(){Br(!1,`unsupported method: ${t.method}`,"UNSUPPORTED_OPERATION",{operation:t.method,info:t})}))}getBlockNumber(){return __async(this,null,(function*(){const t=cn(yield __privateMethod(this,ze,Ve).call(this,{method:"getBlockNumber"}),"%response");return __privateGet(this,De)>=0&&__privateSet(this,De,t),t}))}_getAddress(t){return Ka(t,this)}_getBlockTag(t){if(null==t)return"latest";switch(t){case"earliest":return"0x0";case"finalized":case"latest":case"pending":case"safe":return t}return Wr(t)?Wr(t,32)?t:dn(t):("bigint"==typeof t&&(t=cn(t,"blockTag")),"number"==typeof t?t>=0?dn(t):__privateGet(this,De)>=0?dn(__privateGet(this,De)+t):this.getBlockNumber().then((e=>dn(e+t))):void Or(!1,"invalid blockTag","blockTag",t))}_getFilter(t){const e=(t.topics||[]).map((t=>null==t?null:Array.isArray(t)?Uh(t.map((t=>t.toLowerCase()))):t.toLowerCase())),r="blockHash"in t?t.blockHash:void 0,n=(t,n,i)=>{let s;switch(t.length){case 0:break;case 1:s=t[0];break;default:t.sort(),s=t}if(r&&(null!=n||null!=i))throw new Error("invalid filter");const a={};return s&&(a.address=s),e.length&&(a.topics=e),n&&(a.fromBlock=n),i&&(a.toBlock=i),r&&(a.blockHash=r),a};let i,s,a=[];if(t.address)if(Array.isArray(t.address))for(const o of t.address)a.push(this._getAddress(o));else a.push(this._getAddress(t.address));return"fromBlock"in t&&(i=this._getBlockTag(t.fromBlock)),"toBlock"in t&&(s=this._getBlockTag(t.toBlock)),a.filter((t=>"string"!=typeof t)).length||null!=i&&"string"!=typeof i||null!=s&&"string"!=typeof s?Promise.all([Promise.all(a),i,s]).then((t=>n(t[0],t[1],t[2]))):n(a,i,s)}_getTransactionRequest(t){const e=vu(t),r=[];if(["to","from"].forEach((t=>{if(null==e[t])return;const n=Ka(e[t],this);Bh(n)?r.push(function(){return __async(this,null,(function*(){e[t]=yield n}))}()):e[t]=n})),null!=e.blockTag){const t=this._getBlockTag(e.blockTag);Bh(t)?r.push(function(){return __async(this,null,(function*(){e.blockTag=yield t}))}()):e.blockTag=t}return r.length?function(){return __async(this,null,(function*(){return yield Promise.all(r),e}))}():e}getNetwork(){return __async(this,null,(function*(){if(null==__privateGet(this,Fe)){const t=(()=>__async(this,null,(function*(){try{const t=yield this._detectNetwork();return this.emit("network",t,null),t}catch(e){throw __privateGet(this,Fe)===t&&__privateSet(this,Fe,null),e}})))();return __privateSet(this,Fe,t),(yield t).clone()}const t=__privateGet(this,Fe),[e,r]=yield Promise.all([t,this._detectNetwork()]);return e.chainId!==r.chainId&&(__privateGet(this,Ue)?(this.emit("network",r,e),__privateGet(this,Fe)===t&&__privateSet(this,Fe,Promise.resolve(r))):Br(!1,`network changed: ${e.chainId} => ${r.chainId} `,"NETWORK_ERROR",{event:"changed"})),e.clone()}))}getFeeData(){return __async(this,null,(function*(){const t=yield this.getNetwork(),e=()=>__async(this,null,(function*(){const{_block:e,gasPrice:r,priorityFee:n}=yield Cr({_block:__privateMethod(this,$e,tr).call(this,"latest",!1),gasPrice:(()=>__async(this,null,(function*(){try{return sn(yield __privateMethod(this,ze,Ve).call(this,{method:"getGasPrice"}),"%response")}catch(t){}return null})))(),priorityFee:(()=>__async(this,null,(function*(){try{return sn(yield __privateMethod(this,ze,Ve).call(this,{method:"getPriorityFee"}),"%response")}catch(t){}return null})))()});let i=null,s=null;const a=this._wrapBlock(e,t);return a&&a.baseFeePerGas&&(s=null!=n?n:BigInt("1000000000"),i=a.baseFeePerGas*Ih+s),new yu(r,i,s)})),r=t.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(r){const t=new Gn(r.url),n=yield r.processFunc(e,this,t);return new yu(n.gasPrice,n.maxFeePerGas,n.maxPriorityFeePerGas)}return yield e()}))}estimateGas(t){return __async(this,null,(function*(){let e=this._getTransactionRequest(t);return Bh(e)&&(e=yield e),sn(yield __privateMethod(this,ze,Ve).call(this,{method:"estimateGas",transaction:e}),"%response")}))}call(t){return __async(this,null,(function*(){const{tx:e,blockTag:r}=yield Cr({tx:this._getTransactionRequest(t),blockTag:this._getBlockTag(t.blockTag)});return yield __privateMethod(this,qe,Ze).call(this,__privateMethod(this,Je,Ke).call(this,e,r,t.enableCcipRead?0:-1))}))}getBalance(t,e){return __async(this,null,(function*(){return sn(yield __privateMethod(this,Ye,Xe).call(this,{method:"getBalance"},t,e),"%response")}))}getTransactionCount(t,e){return __async(this,null,(function*(){return cn(yield __privateMethod(this,Ye,Xe).call(this,{method:"getTransactionCount"},t,e),"%response")}))}getCode(t,e){return __async(this,null,(function*(){return Vr(yield __privateMethod(this,Ye,Xe).call(this,{method:"getCode"},t,e))}))}getStorage(t,e,r){return __async(this,null,(function*(){const n=sn(e,"position");return Vr(yield __privateMethod(this,Ye,Xe).call(this,{method:"getStorage",position:n},t,r))}))}broadcastTransaction(t){return __async(this,null,(function*(){const{blockNumber:e,hash:r,network:n}=yield Cr({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:t}),network:this.getNetwork()}),i=Lo.from(t);if(i.hash!==r)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(i,n).replaceableTransaction(e)}))}getBlock(t,e){return __async(this,null,(function*(){const{network:r,params:n}=yield Cr({network:this.getNetwork(),params:__privateMethod(this,$e,tr).call(this,t,!!e)});return null==n?null:this._wrapBlock(n,r)}))}getTransaction(t){return __async(this,null,(function*(){const{network:e,params:r}=yield Cr({network:this.getNetwork(),params:__privateMethod(this,ze,Ve).call(this,{method:"getTransaction",hash:t})});return null==r?null:this._wrapTransactionResponse(r,e)}))}getTransactionReceipt(t){return __async(this,null,(function*(){const{network:e,params:r}=yield Cr({network:this.getNetwork(),params:__privateMethod(this,ze,Ve).call(this,{method:"getTransactionReceipt",hash:t})});if(null==r)return null;if(null==r.gasPrice&&null==r.effectiveGasPrice){const e=yield __privateMethod(this,ze,Ve).call(this,{method:"getTransaction",hash:t});if(null==e)throw new Error("report this; could not find tx or effectiveGasPrice");r.effectiveGasPrice=e.gasPrice}return this._wrapTransactionReceipt(r,e)}))}getTransactionResult(t){return __async(this,null,(function*(){const{result:e}=yield Cr({network:this.getNetwork(),result:__privateMethod(this,ze,Ve).call(this,{method:"getTransactionResult",hash:t})});return null==e?null:Vr(e)}))}getLogs(t){return __async(this,null,(function*(){let e=this._getFilter(t);Bh(e)&&(e=yield e);const{network:r,params:n}=yield Cr({network:this.getNetwork(),params:__privateMethod(this,ze,Ve).call(this,{method:"getLogs",filter:e})});return n.map((t=>this._wrapLog(t,r)))}))}_getProvider(t){Br(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}getResolver(t){return __async(this,null,(function*(){return yield ah.fromName(this,t)}))}getAvatar(t){return __async(this,null,(function*(){const e=yield this.getResolver(t);return e?yield e.getAvatar():null}))}resolveName(t){return __async(this,null,(function*(){const e=yield this.getResolver(t);return e?yield e.getAddress():null}))}lookupAddress(t){return __async(this,null,(function*(){const e=Jl((t=za(t)).substring(2).toLowerCase()+".addr.reverse");try{const r=yield ah.getEnsAddress(this),n=new th(r,["function resolver(bytes32) view returns (address)"],this),i=yield n.resolver(e);if(null==i||i===Na)return null;const s=new th(i,["function name(bytes32) view returns (string)"],this),a=yield s.name(e);return(yield this.resolveName(a))!==t?null:a}catch(r){if(Gr(r,"BAD_DATA")&&"0x"===r.value)return null;if(Gr(r,"CALL_EXCEPTION"))return null;throw r}return null}))}waitForTransaction(t,e,r){return __async(this,null,(function*(){const n=null!=e?e:1;return 0===n?this.getTransactionReceipt(t):new Promise(((e,i)=>__async(this,null,(function*(){let s=null;const a=r=>__async(this,null,(function*(){try{const i=yield this.getTransactionReceipt(t);if(null!=i&&r-i.blockNumber+1>=n)return e(i),void(s&&(clearTimeout(s),s=null))}catch(i){console.log("EEE",i)}this.once("block",a)}));null!=r&&(s=setTimeout((()=>{null!=s&&(s=null,this.off("block",a),i(Ir("timeout","TIMEOUT",{reason:"timeout"})))}),r)),a(yield this.getBlockNumber())}))))}))}waitForBlock(t){return __async(this,null,(function*(){Br(!1,"not implemented yet","NOT_IMPLEMENTED",{operation:"waitForBlock"})}))}_clearTimeout(t){const e=__privateGet(this,He).get(t);e&&(e.timer&&clearTimeout(e.timer),__privateGet(this,He).delete(t))}_setTimeout(t,e){null==e&&(e=0);const r=__privateWrapper(this,je)._++,n=()=>{__privateGet(this,He).delete(r),t()};if(this.paused)__privateGet(this,He).set(r,{timer:null,func:n,time:e});else{const t=setTimeout(n,e);__privateGet(this,He).set(r,{timer:t,func:n,time:Dh()})}return r}_forEachSubscriber(t){for(const e of __privateGet(this,Me).values())t(e.subscriber)}_getSubscriber(t){switch(t.type){case"debug":case"error":case"network":return new Fh(t.type);case"block":{const t=new Ph(this);return t.pollingInterval=this.pollingInterval,t}case"safe":case"finalized":return new Th(this,t.type);case"event":return new Mh(this,t.filter);case"transaction":return new Gh(this,t.hash);case"orphan":return new Rh(this,t.filter)}throw new Error(`unsupported event: ${t.type}`)}_recoverSubscriber(t,e){for(const r of __privateGet(this,Me).values())if(r.subscriber===t){r.started&&r.subscriber.stop(),r.subscriber=e,r.started&&e.start(),null!=__privateGet(this,Be)&&e.pause(__privateGet(this,Be));break}}on(t,e){return __async(this,null,(function*(){const r=yield __privateMethod(this,nr,ir).call(this,t);return r.listeners.push({listener:e,once:!1}),r.started||(r.subscriber.start(),r.started=!0,null!=__privateGet(this,Be)&&r.subscriber.pause(__privateGet(this,Be))),this}))}once(t,e){return __async(this,null,(function*(){const r=yield __privateMethod(this,nr,ir).call(this,t);return r.listeners.push({listener:e,once:!0}),r.started||(r.subscriber.start(),r.started=!0,null!=__privateGet(this,Be)&&r.subscriber.pause(__privateGet(this,Be))),this}))}emit(t,...e){return __async(this,null,(function*(){const r=yield __privateMethod(this,er,rr).call(this,t,e);if(!r||0===r.listeners.length)return!1;const n=r.listeners.length;return r.listeners=r.listeners.filter((({listener:r,once:n})=>{const i=new gn(this,n?null:r,t);try{r.call(this,...e,i)}catch(s){}return!n})),0===r.listeners.length&&(r.started&&r.subscriber.stop(),__privateGet(this,Me).delete(r.tag)),n>0}))}listenerCount(t){return __async(this,null,(function*(){if(t){const e=yield __privateMethod(this,er,rr).call(this,t);return e?e.listeners.length:0}let e=0;for(const{listeners:t}of __privateGet(this,Me).values())e+=t.length;return e}))}listeners(t){return __async(this,null,(function*(){if(t){const e=yield __privateMethod(this,er,rr).call(this,t);return e?e.listeners.map((({listener:t})=>t)):[]}let e=[];for(const{listeners:t}of __privateGet(this,Me).values())e=e.concat(t.map((({listener:t})=>t)));return e}))}off(t,e){return __async(this,null,(function*(){const r=yield __privateMethod(this,er,rr).call(this,t);if(!r)return this;if(e){const t=r.listeners.map((({listener:t})=>t)).indexOf(e);t>=0&&r.listeners.splice(t,1)}return e&&0!==r.listeners.length||(r.started&&r.subscriber.stop(),__privateGet(this,Me).delete(r.tag)),this}))}removeAllListeners(t){return __async(this,null,(function*(){if(t){const{tag:e,started:r,subscriber:n}=yield __privateMethod(this,nr,ir).call(this,t);r&&n.stop(),__privateGet(this,Me).delete(e)}else for(const[t,{started:e,subscriber:r}]of __privateGet(this,Me))e&&r.stop(),__privateGet(this,Me).delete(t);return this}))}addListener(t,e){return __async(this,null,(function*(){return yield this.on(t,e)}))}removeListener(t,e){return __async(this,null,(function*(){return this.off(t,e)}))}get destroyed(){return __privateGet(this,Oe)}destroy(){this.removeAllListeners();for(const t of __privateGet(this,He).keys())this._clearTimeout(t);__privateSet(this,Oe,!0)}get paused(){return null!=__privateGet(this,Be)}set paused(t){!!t!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(t){if(__privateSet(this,De,-1),null!=__privateGet(this,Be)){if(__privateGet(this,Be)==!!t)return;Br(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber((e=>e.pause(t))),__privateSet(this,Be,!!t);for(const e of __privateGet(this,He).values())e.timer&&clearTimeout(e.timer),e.time=Dh()-e.time}resume(){if(null!=__privateGet(this,Be)){this._forEachSubscriber((t=>t.resume())),__privateSet(this,Be,null);for(const t of __privateGet(this,He).values()){let e=t.time;e<0&&(e=0),t.time=Dh(),setTimeout(t.func,e)}}}}function Wh(t,e){try{const r=Qh(t,e);if(r)return vn(r)}catch(r){}return null}function Qh(t,e){if("0x"===t)return null;try{const r=cn(qr(t,e,e+32)),n=cn(qr(t,r,r+32));return qr(t,r+32,r+32+n)}catch(r){}return null}function zh(t){const e=hn(t);if(e.length>32)throw new Error("internal; should not happen");const r=new Uint8Array(32);return r.set(e,32-e.length),r}function Vh(t){if(t.length%32==0)return t;const e=new Uint8Array(32*Math.ceil(t.length/32));return e.set(t),e}Me=new WeakMap,Ie=new WeakMap,Be=new WeakMap,Oe=new WeakMap,Fe=new WeakMap,Ue=new WeakMap,Le=new WeakMap,De=new WeakMap,je=new WeakMap,He=new WeakMap,We=new WeakMap,Qe=new WeakMap,ze=new WeakSet,Ve=function(t){return __async(this,null,(function*(){const e=__privateGet(this,Qe).cacheTimeout;if(e<0)return yield this._perform(t);const r=Oh(t.method,t);let n=__privateGet(this,Le).get(r);return n||(n=this._perform(t),__privateGet(this,Le).set(r,n),setTimeout((()=>{__privateGet(this,Le).get(r)===n&&__privateGet(this,Le).delete(r)}),e)),yield n}))},Je=new WeakSet,Ke=function(t,e,r){return __async(this,null,(function*(){Br(r<10,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},t,{blockTag:e,enableCcipRead:!0})});const n=vu(t);try{return Vr(yield this._perform({method:"call",transaction:n,blockTag:e}))}catch(i){if(!this.disableCcipRead&&Mr(i)&&i.data&&r>=0&&"latest"===e&&null!=n.to&&"0x556f1830"===qr(i.data,0,4)){const t=i.data,a=yield Ka(n.to,this);let o;try{o=function(t){const e={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};Br(Kr(t)>=160,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const r=qr(t,0,32);Br(qr(r,0,12)===qr(qh,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),e.sender=qr(r,12);try{const r=[],n=cn(qr(t,32,64)),i=cn(qr(t,n,n+32)),s=qr(t,n+32);for(let t=0;t<i;t++){const e=Wh(s,32*t);if(null==e)throw new Error("abort");r.push(e)}e.urls=r}catch(i){Br(!1,"corrupt OffchainLookup urls","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup urls"})}try{const r=Qh(t,64);if(null==r)throw new Error("abort");e.calldata=r}catch(i){Br(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}Br(qr(t,100,128)===qr(qh,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),e.selector=qr(t,96,100);try{const r=Qh(t,128);if(null==r)throw new Error("abort");e.extraData=r}catch(i){Br(!1,"corrupt OffchainLookup extraData","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup extraData"})}return e.errorArgs="sender,urls,calldata,selector,extraData".split(/,/).map((t=>e[t])),e}(qr(i.data,4))}catch(s){Br(!1,s.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:n,info:{data:t}})}Br(o.sender.toLowerCase()===a.toLowerCase(),"CCIP Read sender mismatch","CALL_EXCEPTION",{action:"call",data:t,reason:"OffchainLookup",transaction:n,invocation:null,revert:{signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",name:"OffchainLookup",args:o.errorArgs}});const l=yield this.ccipReadFetch(n,o.calldata,o.urls);Br(null!=l,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:n,info:{data:i.data,errorArgs:o.errorArgs}});const c={to:a,data:Jr([o.selector,Kh([l,o.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:c});try{const t=yield __privateMethod(this,Je,Ke).call(this,c,e,r+1);return this.emit("debug",{action:"receiveCcipReadCallResult",transaction:Object.assign({},c),result:t}),t}catch(s){throw this.emit("debug",{action:"receiveCcipReadCallError",transaction:Object.assign({},c),error:s}),s}}throw i}}))},qe=new WeakSet,Ze=function(t){return __async(this,null,(function*(){const{value:e}=yield Cr({network:this.getNetwork(),value:t});return e}))},Ye=new WeakSet,Xe=function(t,e,r){return __async(this,null,(function*(){let n=this._getAddress(e),i=this._getBlockTag(r);return"string"==typeof n&&"string"==typeof i||([n,i]=yield Promise.all([n,i])),yield __privateMethod(this,qe,Ze).call(this,__privateMethod(this,ze,Ve).call(this,Object.assign(t,{address:n,blockTag:i})))}))},$e=new WeakSet,tr=function(t,e){return __async(this,null,(function*(){if(Wr(t,32))return yield __privateMethod(this,ze,Ve).call(this,{method:"getBlock",blockHash:t,includeTransactions:e});let r=this._getBlockTag(t);return"string"!=typeof r&&(r=yield r),yield __privateMethod(this,ze,Ve).call(this,{method:"getBlock",blockTag:r,includeTransactions:e})}))},er=new WeakSet,rr=function(t,e){return __async(this,null,(function*(){let r=yield Lh(t,this);return"event"===r.type&&e&&e.length>0&&!0===e[0].removed&&(r=yield Lh({orphan:"drop-log",log:e[0]},this)),__privateGet(this,Me).get(r.tag)||null}))},nr=new WeakSet,ir=function(t){return __async(this,null,(function*(){const e=yield Lh(t,this),r=e.tag;let n=__privateGet(this,Me).get(r);if(!n){n={subscriber:this._getSubscriber(e),tag:r,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},__privateGet(this,Me).set(r,n)}return n}))};const Jh=new Uint8Array([]);function Kh(t){const e=[];let r=0;for(let n=0;n<t.length;n++)e.push(Jh),r+=32;for(let n=0;n<t.length;n++){const i=jr(t[n]);e[n]=zh(r),e.push(zh(i.length)),e.push(Vh(i)),r+=32+32*Math.ceil(i.length/32)}return Jr(e)}const qh="0x0000000000000000000000000000000000000000000000000000000000000000";function Zh(t,e){if(t.provider)return t.provider;Br(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}function Yh(t,e){return __async(this,null,(function*(){let r=vu(e);if(null!=r.to&&(r.to=Ka(r.to,t)),null!=r.from){const e=r.from;r.from=Promise.all([t.getAddress(),Ka(e,t)]).then((([t,e])=>(Or(t.toLowerCase()===e.toLowerCase(),"transaction from mismatch","tx.from",e),t)))}else r.from=t.getAddress();return yield Cr(r)}))}class Xh{constructor(t){__publicField(this,"provider"),Tr(this,{provider:t||null})}getNonce(t){return __async(this,null,(function*(){return Zh(this,"getTransactionCount").getTransactionCount(yield this.getAddress(),t)}))}populateCall(t){return __async(this,null,(function*(){return yield Yh(this,t)}))}populateTransaction(t){return __async(this,null,(function*(){const e=Zh(this,"populateTransaction"),r=yield Yh(this,t);null==r.nonce&&(r.nonce=yield this.getNonce("pending")),null==r.gasLimit&&(r.gasLimit=yield this.estimateGas(r));const n=yield this.provider.getNetwork();if(null!=r.chainId){Or(sn(r.chainId)===n.chainId,"transaction chainId mismatch","tx.chainId",t.chainId)}else r.chainId=n.chainId;const i=null!=r.maxFeePerGas||null!=r.maxPriorityFeePerGas;if(null==r.gasPrice||2!==r.type&&!i?0!==r.type&&1!==r.type||!i||Or(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",t):Or(!1,"eip-1559 transaction do not support gasPrice","tx",t),2!==r.type&&null!=r.type||null==r.maxFeePerGas||null==r.maxPriorityFeePerGas)if(0===r.type||1===r.type){const t=yield e.getFeeData();Br(null!=t.gasPrice,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),null==r.gasPrice&&(r.gasPrice=t.gasPrice)}else{const t=yield e.getFeeData();if(null==r.type)if(null!=t.maxFeePerGas&&null!=t.maxPriorityFeePerGas)if(r.authorizationList&&r.authorizationList.length?r.type=4:r.type=2,null!=r.gasPrice){const t=r.gasPrice;delete r.gasPrice,r.maxFeePerGas=t,r.maxPriorityFeePerGas=t}else null==r.maxFeePerGas&&(r.maxFeePerGas=t.maxFeePerGas),null==r.maxPriorityFeePerGas&&(r.maxPriorityFeePerGas=t.maxPriorityFeePerGas);else null!=t.gasPrice?(Br(!i,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),null==r.gasPrice&&(r.gasPrice=t.gasPrice),r.type=0):Br(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else 2!==r.type&&3!==r.type&&4!==r.type||(null==r.maxFeePerGas&&(r.maxFeePerGas=t.maxFeePerGas),null==r.maxPriorityFeePerGas&&(r.maxPriorityFeePerGas=t.maxPriorityFeePerGas))}else r.type=2;return yield Cr(r)}))}populateAuthorization(t){return __async(this,null,(function*(){const e=Object.assign({},t);return null==e.chainId&&(e.chainId=(yield Zh(this,"getNetwork").getNetwork()).chainId),null==e.nonce&&(e.nonce=yield this.getNonce()),e}))}estimateGas(t){return __async(this,null,(function*(){return Zh(this,"estimateGas").estimateGas(yield this.populateCall(t))}))}call(t){return __async(this,null,(function*(){return Zh(this,"call").call(yield this.populateCall(t))}))}resolveName(t){return __async(this,null,(function*(){const e=Zh(this,"resolveName");return yield e.resolveName(t)}))}sendTransaction(t){return __async(this,null,(function*(){const e=Zh(this,"sendTransaction"),r=yield this.populateTransaction(t);delete r.from;const n=Lo.from(r);return yield e.broadcastTransaction(yield this.signTransaction(n))}))}authorize(t){Br(!1,"authorization not implemented for this signer","UNSUPPORTED_OPERATION",{operation:"authorize"})}}class $h{constructor(t){__privateAdd(this,hr),__privateAdd(this,pr),__privateAdd(this,sr,void 0),__privateAdd(this,ar,void 0),__privateAdd(this,or,void 0),__privateAdd(this,lr,void 0),__privateAdd(this,cr,void 0),__privateAdd(this,ur,void 0),__privateSet(this,sr,t),__privateSet(this,ar,null),__privateSet(this,or,__privateMethod(this,hr,dr).bind(this)),__privateSet(this,lr,!1),__privateSet(this,cr,null),__privateSet(this,ur,!1)}_subscribe(t){throw new Error("subclasses must override this")}_emitResults(t,e){throw new Error("subclasses must override this")}_recover(t){throw new Error("subclasses must override this")}start(){__privateGet(this,lr)||(__privateSet(this,lr,!0),__privateMethod(this,hr,dr).call(this,-2))}stop(){__privateGet(this,lr)&&(__privateSet(this,lr,!1),__privateSet(this,ur,!0),__privateMethod(this,pr,fr).call(this),__privateGet(this,sr).off("block",__privateGet(this,or)))}pause(t){t&&__privateMethod(this,pr,fr).call(this),__privateGet(this,sr).off("block",__privateGet(this,or))}resume(){this.start()}}sr=new WeakMap,ar=new WeakMap,or=new WeakMap,lr=new WeakMap,cr=new WeakMap,ur=new WeakMap,hr=new WeakSet,dr=function(t){return __async(this,null,(function*(){try{null==__privateGet(this,ar)&&__privateSet(this,ar,this._subscribe(__privateGet(this,sr)));let e=null;try{e=yield __privateGet(this,ar)}catch(t){if(!Gr(t,"UNSUPPORTED_OPERATION")||"eth_newFilter"!==t.operation)throw t}if(null==e)return __privateSet(this,ar,null),void __privateGet(this,sr)._recoverSubscriber(this,this._recover(__privateGet(this,sr)));const r=yield __privateGet(this,sr).getNetwork();if(__privateGet(this,cr)||__privateSet(this,cr,r),__privateGet(this,cr).chainId!==r.chainId)throw new Error("chaid changed");if(__privateGet(this,ur))return;const n=yield __privateGet(this,sr).send("eth_getFilterChanges",[e]);yield this._emitResults(__privateGet(this,sr),n)}catch(t){console.log("@TODO",t)}__privateGet(this,sr).once("block",__privateGet(this,or))}))},pr=new WeakSet,fr=function(){const t=__privateGet(this,ar);t&&(__privateSet(this,ar,null),t.then((t=>{__privateGet(this,sr).destroyed||__privateGet(this,sr).send("eth_uninstallFilter",[t])})))};class td extends $h{constructor(t,e){var r;super(t),__privateAdd(this,gr,void 0),__privateSet(this,gr,(r=e,JSON.parse(JSON.stringify(r))))}_recover(t){return new Mh(t,__privateGet(this,gr))}_subscribe(t){return __async(this,null,(function*(){return yield t.send("eth_newFilter",[__privateGet(this,gr)])}))}_emitResults(t,e){return __async(this,null,(function*(){for(const r of e)t.emit(__privateGet(this,gr),t._wrapLog(r,t._network))}))}}gr=new WeakMap;class ed extends $h{_subscribe(t){return __async(this,null,(function*(){return yield t.send("eth_newPendingTransactionFilter",[])}))}_emitResults(t,e){return __async(this,null,(function*(){for(const r of e)t.emit("pending",r)}))}}const rd="bigint,boolean,function,number,string,symbol".split(/,/g);function nd(t){if(null==t||rd.indexOf(typeof t)>=0)return t;if("function"==typeof t.getAddress)return t;if(Array.isArray(t))return t.map(nd);if("object"==typeof t)return Object.keys(t).reduce(((e,r)=>(e[r]=t[r],e)),{});throw new Error(`should not happen: ${t} (${typeof t})`)}function id(t){return new Promise((e=>{setTimeout(e,t)}))}function sd(t){return t?t.toLowerCase():t}function ad(t){return t&&"number"==typeof t.pollingInterval}const od={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3};class ld extends Xh{constructor(t,e){super(t),__publicField(this,"address"),Tr(this,{address:e=za(e)})}connect(t){Br(!1,"cannot reconnect JsonRpcSigner","UNSUPPORTED_OPERATION",{operation:"signer.connect"})}getAddress(){return __async(this,null,(function*(){return this.address}))}populateTransaction(t){return __async(this,null,(function*(){return yield this.populateCall(t)}))}sendUncheckedTransaction(t){return __async(this,null,(function*(){const e=nd(t),r=[];if(e.from){const n=e.from;r.push((()=>__async(this,null,(function*(){const r=yield Ka(n,this.provider);Or(null!=r&&r.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),e.from=r})))())}else e.from=this.address;if(null==e.gasLimit&&r.push((()=>__async(this,null,(function*(){e.gasLimit=yield this.provider.estimateGas(__spreadProps(__spreadValues({},e),{from:this.address}))})))()),null!=e.to){const t=e.to;r.push((()=>__async(this,null,(function*(){e.to=yield Ka(t,this.provider)})))())}r.length&&(yield Promise.all(r));const n=this.provider.getRpcTransaction(e);return this.provider.send("eth_sendTransaction",[n])}))}sendTransaction(t){return __async(this,null,(function*(){const e=yield this.provider.getBlockNumber(),r=yield this.sendUncheckedTransaction(t);return yield new Promise(((t,n)=>{const i=[1e3,100];let s=0;const a=()=>__async(this,null,(function*(){try{const n=yield this.provider.getTransaction(r);if(null!=n)return void t(n.replaceableTransaction(e))}catch(o){if(Gr(o,"CANCELLED")||Gr(o,"BAD_DATA")||Gr(o,"NETWORK_ERROR")||Gr(o,"UNSUPPORTED_OPERATION"))return null==o.info&&(o.info={}),o.info.sendTransactionHash=r,void n(o);if(Gr(o,"INVALID_ARGUMENT")&&(s++,null==o.info&&(o.info={}),o.info.sendTransactionHash=r,s>10))return void n(o);this.provider.emit("error",Ir("failed to fetch transation after sending (will try again)","UNKNOWN_ERROR",{error:o}))}this.provider._setTimeout((()=>{a()}),i.pop()||4e3)}));a()}))}))}signTransaction(t){return __async(this,null,(function*(){const e=nd(t);if(e.from){const r=yield Ka(e.from,this.provider);Or(null!=r&&r.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),e.from=r}else e.from=this.address;const r=this.provider.getRpcTransaction(e);return yield this.provider.send("eth_signTransaction",[r])}))}signMessage(t){return __async(this,null,(function*(){const e="string"==typeof t?yn(t):t;return yield this.provider.send("personal_sign",[Vr(e),this.address.toLowerCase()])}))}signTypedData(t,e,r){return __async(this,null,(function*(){const n=nd(r),i=yield cc.resolveNames(t,e,n,(t=>__async(this,null,(function*(){const e=yield Ka(t);return Or(null!=e,"TypedData does not support null address","value",t),e}))));return yield this.provider.send("eth_signTypedData_v4",[this.address.toLowerCase(),JSON.stringify(cc.getPayload(i.domain,e,i.value))])}))}unlock(t){return __async(this,null,(function*(){return this.provider.send("personal_unlockAccount",[this.address.toLowerCase(),t,null])}))}_legacySignMessage(t){return __async(this,null,(function*(){const e="string"==typeof t?yn(t):t;return yield this.provider.send("eth_sign",[this.address.toLowerCase(),Vr(e)])}))}}mr=new WeakMap,_r=new WeakMap,yr=new WeakMap,vr=new WeakMap,wr=new WeakMap,br=new WeakMap,Ar=new WeakMap,Er=new WeakSet,xr=function(){if(__privateGet(this,vr))return;const t=1===this._getOption("batchMaxCount")?0:this._getOption("batchStallTime");__privateSet(this,vr,setTimeout((()=>{__privateSet(this,vr,null);const t=__privateGet(this,yr);for(__privateSet(this,yr,[]);t.length;){const e=[t.shift()];for(;t.length&&e.length!==__privateGet(this,mr).batchMaxCount;){e.push(t.shift());if(JSON.stringify(e.map((t=>t.payload))).length>__privateGet(this,mr).batchMaxSize){t.unshift(e.pop());break}}(()=>{__async(this,null,(function*(){const t=1===e.length?e[0].payload:e.map((t=>t.payload));this.emit("debug",{action:"sendRpcPayload",payload:t});try{const r=yield this._send(t);this.emit("debug",{action:"receiveRpcResult",result:r});for(const{resolve:t,reject:n,payload:i}of e){if(this.destroyed){n(Ir("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:i.method}));continue}const e=r.filter((t=>t.id===i.id))[0];if(null!=e)"error"in e?n(this.getRpcError(i,e)):t(e.result);else{const t=Ir("missing response for request","BAD_DATA",{value:r,info:{payload:i}});this.emit("error",t),n(t)}}}catch(r){this.emit("debug",{action:"receiveRpcError",error:r});for(const{reject:t}of e)t(r)}}))})()}}),t))};let cd=class t extends Hh{constructor(t,e){super(t,e),__privateAdd(this,Er),__privateAdd(this,mr,void 0),__privateAdd(this,_r,void 0),__privateAdd(this,yr,void 0),__privateAdd(this,vr,void 0),__privateAdd(this,wr,void 0),__privateAdd(this,br,void 0),__privateAdd(this,Ar,void 0),__privateSet(this,_r,1),__privateSet(this,mr,Object.assign({},od,e||{})),__privateSet(this,yr,[]),__privateSet(this,vr,null),__privateSet(this,br,null),__privateSet(this,Ar,null);{let t=null;const e=new Promise((e=>{t=e}));__privateSet(this,wr,{promise:e,resolve:t})}const r=this._getOption("staticNetwork");"boolean"==typeof r?(Or(!r||"any"!==t,"staticNetwork cannot be used on special network 'any'","options",e),r&&null!=t&&__privateSet(this,br,Eh.from(t))):r&&(Or(null==t||r.matches(t),"staticNetwork MUST match network object","options",e),__privateSet(this,br,r))}_getOption(t){return __privateGet(this,mr)[t]}get _network(){return Br(__privateGet(this,br),"network is not available yet","NETWORK_ERROR"),__privateGet(this,br)}_perform(e){return __async(this,null,(function*(){if("call"===e.method||"estimateGas"===e.method){let t=e.transaction;if(t&&null!=t.type&&sn(t.type)&&null==t.maxFeePerGas&&null==t.maxPriorityFeePerGas){const r=yield this.getFeeData();null==r.maxFeePerGas&&null==r.maxPriorityFeePerGas&&(e=Object.assign({},e,{transaction:Object.assign({},t,{type:void 0})}))}}const r=this.getRpcRequest(e);return null!=r?yield this.send(r.method,r.args):__superGet(t.prototype,this,"_perform").call(this,e)}))}_detectNetwork(){return __async(this,null,(function*(){const t=this._getOption("staticNetwork");if(t){if(!0!==t)return t;if(__privateGet(this,br))return __privateGet(this,br)}return __privateGet(this,Ar)?yield __privateGet(this,Ar):this.ready?(__privateSet(this,Ar,(()=>__async(this,null,(function*(){try{const t=Eh.from(sn(yield this.send("eth_chainId",[])));return __privateSet(this,Ar,null),t}catch(t){throw __privateSet(this,Ar,null),t}})))()),yield __privateGet(this,Ar)):(__privateSet(this,Ar,(()=>__async(this,null,(function*(){const t={id:__privateWrapper(this,_r)._++,method:"eth_chainId",params:[],jsonrpc:"2.0"};let e;this.emit("debug",{action:"sendRpcPayload",payload:t});try{e=(yield this._send(t))[0],__privateSet(this,Ar,null)}catch(r){throw __privateSet(this,Ar,null),this.emit("debug",{action:"receiveRpcError",error:r}),r}if(this.emit("debug",{action:"receiveRpcResult",result:e}),"result"in e)return Eh.from(sn(e.result));throw this.getRpcError(t,e)})))()),yield __privateGet(this,Ar))}))}_start(){null!=__privateGet(this,wr)&&null!=__privateGet(this,wr).resolve&&(__privateGet(this,wr).resolve(),__privateSet(this,wr,null),(()=>{__async(this,null,(function*(){for(;null==__privateGet(this,br)&&!this.destroyed;)try{__privateSet(this,br,yield this._detectNetwork())}catch(t){if(this.destroyed)break;console.log("JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)"),this.emit("error",Ir("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:t}})),yield id(1e3)}__privateMethod(this,Er,xr).call(this)}))})())}_waitUntilReady(){return __async(this,null,(function*(){if(null!=__privateGet(this,wr))return yield __privateGet(this,wr).promise}))}_getSubscriber(t){return"pending"===t.type?new ed(this):"event"===t.type?this._getOption("polling")?new Mh(this,t.filter):new td(this,t.filter):"orphan"===t.type&&"drop-log"===t.filter.orphan?new Fh("orphan"):super._getSubscriber(t)}get ready(){return null==__privateGet(this,wr)}getRpcTransaction(t){const e={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach((r=>{if(null==t[r])return;let n=r;"gasLimit"===r&&(n="gas"),e[n]=dn(sn(t[r],`tx.${r}`))})),["from","to","data"].forEach((r=>{null!=t[r]&&(e[r]=Vr(t[r]))})),t.accessList&&(e.accessList=vo(t.accessList)),t.blobVersionedHashes&&(e.blobVersionedHashes=t.blobVersionedHashes.map((t=>t.toLowerCase()))),t.authorizationList&&(e.authorizationList=t.authorizationList.map((t=>{const e=wo(t);return{address:e.address,nonce:dn(e.nonce),chainId:dn(e.chainId),yParity:dn(e.signature.yParity),r:dn(e.signature.r),s:dn(e.signature.s)}}))),e}getRpcRequest(t){switch(t.method){case"chainId":return{method:"eth_chainId",args:[]};case"getBlockNumber":return{method:"eth_blockNumber",args:[]};case"getGasPrice":return{method:"eth_gasPrice",args:[]};case"getPriorityFee":return{method:"eth_maxPriorityFeePerGas",args:[]};case"getBalance":return{method:"eth_getBalance",args:[sd(t.address),t.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[sd(t.address),t.blockTag]};case"getCode":return{method:"eth_getCode",args:[sd(t.address),t.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[sd(t.address),"0x"+t.position.toString(16),t.blockTag]};case"broadcastTransaction":return{method:"eth_sendRawTransaction",args:[t.signedTransaction]};case"getBlock":if("blockTag"in t)return{method:"eth_getBlockByNumber",args:[t.blockTag,!!t.includeTransactions]};if("blockHash"in t)return{method:"eth_getBlockByHash",args:[t.blockHash,!!t.includeTransactions]};break;case"getTransaction":return{method:"eth_getTransactionByHash",args:[t.hash]};case"getTransactionReceipt":return{method:"eth_getTransactionReceipt",args:[t.hash]};case"call":return{method:"eth_call",args:[this.getRpcTransaction(t.transaction),t.blockTag]};case"estimateGas":return{method:"eth_estimateGas",args:[this.getRpcTransaction(t.transaction)]};case"getLogs":return t.filter&&null!=t.filter.address&&(Array.isArray(t.filter.address)?t.filter.address=t.filter.address.map(sd):t.filter.address=sd(t.filter.address)),{method:"eth_getLogs",args:[t.filter]}}return null}getRpcError(t,e){const{method:r}=t,{error:n}=e;if("eth_estimateGas"===r&&n.message){const e=n.message;if(!e.match(/revert/i)&&e.match(/insufficient funds/i))return Ir("insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.params[0],info:{payload:t,error:n}});if(e.match(/nonce/i)&&e.match(/too low/i))return Ir("nonce has already been used","NONCE_EXPIRED",{transaction:t.params[0],info:{payload:t,error:n}})}if("eth_call"===r||"eth_estimateGas"===r){const e=hd(n),i=ou.getBuiltinCallException("eth_call"===r?"call":"estimateGas",t.params[0],e?e.data:null);return i.info={error:n,payload:t},i}const i=JSON.stringify(function(t){const e=[];return dd(t,e),e}(n));if("string"==typeof n.message&&n.message.match(/user denied|ethers-user-denied/i)){return Ir("user rejected action","ACTION_REJECTED",{action:{eth_sign:"signMessage",personal_sign:"signMessage",eth_signTypedData_v4:"signTypedData",eth_signTransaction:"signTransaction",eth_sendTransaction:"sendTransaction",eth_requestAccounts:"requestAccess",wallet_requestAccounts:"requestAccess"}[r]||"unknown",reason:"rejected",info:{payload:t,error:n}})}if("eth_sendRawTransaction"===r||"eth_sendTransaction"===r){const e=t.params[0];if(i.match(/insufficient funds|base fee exceeds gas limit/i))return Ir("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:e,info:{error:n}});if(i.match(/nonce/i)&&i.match(/too low/i))return Ir("nonce has already been used","NONCE_EXPIRED",{transaction:e,info:{error:n}});if(i.match(/replacement transaction/i)&&i.match(/underpriced/i))return Ir("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:e,info:{error:n}});if(i.match(/only replay-protected/i))return Ir("legacy pre-eip-155 transactions not supported","UNSUPPORTED_OPERATION",{operation:r,info:{transaction:e,info:{error:n}}})}let s=!!i.match(/the method .* does not exist/i);return s||n&&n.details&&n.details.startsWith("Unauthorized method:")&&(s=!0),s?Ir("unsupported operation","UNSUPPORTED_OPERATION",{operation:t.method,info:{error:n,payload:t}}):Ir("could not coalesce error","UNKNOWN_ERROR",{error:n,payload:t})}send(t,e){if(this.destroyed)return Promise.reject(Ir("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t}));const r=__privateWrapper(this,_r)._++,n=new Promise(((n,i)=>{__privateGet(this,yr).push({resolve:n,reject:i,payload:{method:t,params:e,id:r,jsonrpc:"2.0"}})}));return __privateMethod(this,Er,xr).call(this),n}getSigner(t){return __async(this,null,(function*(){null==t&&(t=0);const e=this.send("eth_accounts",[]);if("number"==typeof t){const r=yield e;if(t>=r.length)throw new Error("no such account");return new ld(this,r[t])}const{accounts:r}=yield Cr({network:this.getNetwork(),accounts:e});t=za(t);for(const n of r)if(za(n)===t)return new ld(this,t);throw new Error("invalid account")}))}listAccounts(){return __async(this,null,(function*(){return(yield this.send("eth_accounts",[])).map((t=>new ld(this,t)))}))}destroy(){__privateGet(this,vr)&&(clearTimeout(__privateGet(this,vr)),__privateSet(this,vr,null));for(const{payload:t,reject:e}of __privateGet(this,yr))e(Ir("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t.method}));__privateSet(this,yr,[]),super.destroy()}};class ud extends cd{constructor(t,e){super(t,e),__privateAdd(this,kr,void 0);let r=this._getOption("pollingInterval");null==r&&(r=od.pollingInterval),__privateSet(this,kr,r)}_getSubscriber(t){const e=super._getSubscriber(t);return ad(e)&&(e.pollingInterval=__privateGet(this,kr)),e}get pollingInterval(){return __privateGet(this,kr)}set pollingInterval(t){if(!Number.isInteger(t)||t<0)throw new Error("invalid interval");__privateSet(this,kr,t),this._forEachSubscriber((t=>{ad(t)&&(t.pollingInterval=__privateGet(this,kr))}))}}function hd(t){if(null==t)return null;if("string"==typeof t.message&&t.message.match(/revert/i)&&Wr(t.data))return{message:t.message,data:t.data};if("object"==typeof t){for(const e in t){const r=hd(t[e]);if(r)return r}return null}if("string"==typeof t)try{return hd(JSON.parse(t))}catch(e){}return null}function dd(t,e){if(null!=t){if("string"==typeof t.message&&e.push(t.message),"object"==typeof t)for(const r in t)dd(t[r],e);if("string"==typeof t)try{return dd(JSON.parse(t),e)}catch(r){}}}kr=new WeakMap;Sr=new WeakMap,Nr=new WeakMap;let pd=class t extends ud{constructor(t,e,r){const n=Object.assign({},null!=r?r:{},{batchMaxCount:1});Or(t&&t.request,"invalid EIP-1193 provider","ethereum",t),super(e,n),__privateAdd(this,Sr,void 0),__privateAdd(this,Nr,void 0),__privateSet(this,Nr,null),r&&r.providerInfo&&__privateSet(this,Nr,r.providerInfo),__privateSet(this,Sr,((e,r)=>__async(this,null,(function*(){const n={method:e,params:r};this.emit("debug",{action:"sendEip1193Request",payload:n});try{const e=yield t.request(n);return this.emit("debug",{action:"receiveEip1193Result",result:e}),e}catch(i){const t=new Error(i.message);throw t.code=i.code,t.data=i.data,t.payload=n,this.emit("debug",{action:"receiveEip1193Error",error:t}),t}}))))}get providerInfo(){return __privateGet(this,Nr)}send(e,r){return __async(this,null,(function*(){return yield this._start(),yield __superGet(t.prototype,this,"send").call(this,e,r)}))}_send(t){return __async(this,null,(function*(){Or(!Array.isArray(t),"EIP-1193 does not support batch request","payload",t);try{const e=yield __privateGet(this,Sr).call(this,t.method,t.params||[]);return[{id:t.id,result:e}]}catch(e){return[{id:t.id,error:{code:e.code,data:e.data,message:e.message}}]}}))}getRpcError(t,e){switch((e=JSON.parse(JSON.stringify(e))).error.code||-1){case 4001:e.error.message=`ethers-user-denied: ${e.error.message}`;break;case 4200:e.error.message=`ethers-unsupported: ${e.error.message}`}return super.getRpcError(t,e)}hasSigner(t){return __async(this,null,(function*(){null==t&&(t=0);const e=yield this.send("eth_accounts",[]);return"number"==typeof t?e.length>t:(t=t.toLowerCase(),0!==e.filter((e=>e.toLowerCase()===t)).length)}))}getSigner(e){return __async(this,null,(function*(){if(null==e&&(e=0),!(yield this.hasSigner(e)))try{yield __privateGet(this,Sr).call(this,"eth_requestAccounts",[])}catch(r){const t=r.payload;throw this.getRpcError(t,{id:t.id,error:r})}return yield __superGet(t.prototype,this,"getSigner").call(this,e)}))}static discover(e){return __async(this,null,(function*(){if(null==e&&(e={}),e.provider)return new t(e.provider);const r=e.window?e.window:"undefined"!=typeof window?window:null;if(null==r)return null;const n=e.anyProvider;if(n&&r.ethereum)return new t(r.ethereum);if(!("addEventListener"in r&&"dispatchEvent"in r&&"removeEventListener"in r))return null;const i=e.timeout?e.timeout:300;return 0===i?null:yield new Promise(((s,a)=>{let o=[];const l=t=>{o.push(t.detail),n&&c()},c=()=>{if(clearTimeout(u),o.length)if(e&&e.filter){const r=e.filter(o.map((t=>Object.assign({},t.info))));if(null==r)s(null);else if(r instanceof t)s(r);else{let e=null;if(r.uuid){e=o.filter((t=>r.uuid===t.info.uuid))[0]}if(e){const{provider:r,info:n}=e;s(new t(r,void 0,{providerInfo:n}))}else a(Ir("filter returned unknown info","UNSUPPORTED_OPERATION",{value:r}))}}else{const{provider:e,info:r}=o[0];s(new t(e,void 0,{providerInfo:r}))}else s(null);r.removeEventListener("eip6963:announceProvider",l)},u=setTimeout((()=>{c()}),i);r.addEventListener("eip6963:announceProvider",l),r.dispatchEvent(new Event("eip6963:requestProvider"))}))}))}};const fd={METAMASK:"metamask",TRONLINK:"tronlink",TRUST_WALLET:"trustwallet",LUTE:"lute"},gd={ETHEREUM:"ethereum",BSC:"bsc",TRON:"tron",ALGORAND:"algorand"},md={[gd.ETHEREUM]:{name:"Ethereum Mainnet",chainId:1,symbol:"ETH",decimals:18,rpcUrl:"https://mainnet.infura.io/v3/your-infura-key",blockExplorerUrl:"https://etherscan.io"},[gd.BSC]:{name:"Binance Smart Chain",chainId:56,symbol:"BNB",decimals:18,rpcUrl:"https://bsc-dataseed.binance.org/",blockExplorerUrl:"https://bscscan.com"},[gd.TRON]:{name:"TRON Mainnet",symbol:"TRX",decimals:6,rpcUrl:"https://api.trongrid.io",blockExplorerUrl:"https://tronscan.org"},[gd.ALGORAND]:{name:"Algorand Mainnet",symbol:"ALGO",decimals:6,rpcUrl:"https://mainnet-api.algonode.cloud",blockExplorerUrl:"https://algoexplorer.io"}},_d={USDT:{ethereum:{contractAddress:"0xdAC17F958D2ee523a2206206994597C13D831ec7",decimals:6,symbol:"USDT"},bsc:{contractAddress:"0x55d398326f99059fF775485246999027B3197955",decimals:18,symbol:"USDT"},tron:{contractAddress:"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",decimals:6,symbol:"USDT"},algorand:{assetId:312769,decimals:6,symbol:"USDT"}},USDC:{ethereum:{contractAddress:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",decimals:6,symbol:"USDC"},bsc:{contractAddress:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",decimals:18,symbol:"USDC"},tron:{contractAddress:"TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8",decimals:6,symbol:"USDC"},algorand:{assetId:31566704,decimals:6,symbol:"USDC"}},BNB:{bsc:{decimals:18,symbol:"BNB",isNative:!0}},ETH:{ethereum:{decimals:18,symbol:"ETH",isNative:!0}},TRX:{tron:{decimals:6,symbol:"TRX",isNative:!0}},ALGO:{algorand:{decimals:6,symbol:"ALGO",isNative:!0}}},yd={[gd.ETHEREUM]:[fd.METAMASK,fd.TRUST_WALLET],[gd.BSC]:[fd.METAMASK,fd.TRUST_WALLET],[gd.TRON]:[fd.TRONLINK],[gd.ALGORAND]:[fd.LUTE]},vd=t=>({[fd.METAMASK]:"https://metamask.io/download/",[fd.TRONLINK]:"https://www.tronlink.org/download/",[fd.TRUST_WALLET]:"https://trustwallet.com/download/",[fd.LUTE]:"https://lute.app/download/"}[t]||""),wd=()=>({[fd.METAMASK]:"undefined"!=typeof window&&void 0!==window.ethereum,[fd.TRONLINK]:"undefined"!=typeof window&&void 0!==window.tronWeb,[fd.TRUST_WALLET]:"undefined"!=typeof window&&void 0!==window.ethereum&&!0===window.ethereum.isTrust,[fd.LUTE]:"undefined"!=typeof window&&void 0!==window.lute}),bd=(t=3,e=500)=>__async(this,null,(function*(){let r=0,n=wd();const i=Object.values(n).some((t=>!0===t));for(;!i&&r<t;)console.log(`No wallets detected, retrying (${r+1}/${t})...`),yield new Promise((t=>setTimeout(t,e))),n=wd(),r++;return n})),Ad=()=>{var t;console.log("=== WALLET ENVIRONMENT DEBUG ==="),console.log("ethereum:","undefined"!=typeof window?Boolean(window.ethereum):"Not in browser"),console.log("tronWeb:","undefined"!=typeof window?Boolean(window.tronWeb):"Not in browser"),console.log("lute:","undefined"!=typeof window?Boolean(window.lute):"Not in browser"),"undefined"!=typeof window&&window.ethereum&&console.log("ethereum details:",{isTrust:window.ethereum.isTrust,isMetaMask:window.ethereum.isMetaMask,chainId:window.ethereum.chainId}),"undefined"!=typeof window&&window.tronWeb&&console.log("tronWeb details:",{ready:window.tronWeb.ready,fullNode:null==(t=window.tronWeb.fullNode)?void 0:t.host,defaultAddress:window.tronWeb.defaultAddress});const e=wd();console.log("Detected wallets:",e)},Ed=()=>__async(this,null,(function*(){if(console.log("Connecting to MetaMask wallet..."),!window.ethereum||!window.ethereum.isMetaMask)throw console.error("MetaMask not found."),new Error("MetaMask not detected. Please install MetaMask extension.");try{let e;try{e=new pd(window.ethereum);const t=yield e.send("eth_requestAccounts",[]);if(!t||0===t.length)throw new Error("No accounts found");const r=t[0],n=yield e.getNetwork(),i=Number(n.chainId);let s;switch(i){case 1:s=gd.ETHEREUM;break;case 56:s=gd.BSC;break;default:s=`unknown-${i}`}return{walletType:fd.METAMASK,address:r,provider:e,network:s,isConnected:!0,chainId:i}}catch(t){if(console.log("Trying fallback ethers provider pattern"),window.ethereum.request){const t=yield window.ethereum.request({method:"eth_requestAccounts"});if(!t||0===t.length)throw new Error("No accounts found");const e=t[0],r=yield window.ethereum.request({method:"eth_chainId"}),n=parseInt(r,16);let i;switch(n){case 1:i=gd.ETHEREUM;break;case 56:i=gd.BSC;break;default:i=`unknown-${n}`}return{walletType:fd.METAMASK,address:e,provider:{getSigner:()=>({getAddress:()=>__async(this,null,(function*(){return e})),sendTransaction:t=>__async(this,null,(function*(){return{hash:yield window.ethereum.request({method:"eth_sendTransaction",params:[{from:e,to:t.to,value:t.value?t.value.toString():"0x0",gasLimit:t.gasLimit?t.gasLimit.toString():void 0,data:t.data}]})}}))}),estimateGas:t=>__async(this,null,(function*(){const r=yield window.ethereum.request({method:"eth_estimateGas",params:[{from:e,to:t.to,value:t.value?t.value:"0x0"}]});return{toString:()=>parseInt(r,16).toString(),mul:t=>({div:e=>({toString:()=>Math.floor(parseInt(r,16)*t/e).toString()})})}}))},network:i,isConnected:!0,chainId:n}}throw new Error("Unsupported wallet interface")}}catch(e){throw console.error("Error connecting to MetaMask:",e),e}})),xd=()=>__async(this,null,(function*(){if(console.log("Connecting to Trust Wallet..."),!window.ethereum||!window.ethereum.isTrust)throw console.error("Trust Wallet not found."),new Error("Trust Wallet not detected. Please install Trust Wallet.");try{if(window.ethereum.request){const t=yield window.ethereum.request({method:"eth_requestAccounts"});if(!t||0===t.length)throw new Error("No accounts found");const e=t[0],r=yield window.ethereum.request({method:"eth_chainId"}),n=parseInt(r,16);let i;switch(n){case 1:i=gd.ETHEREUM;break;case 56:i=gd.BSC;break;default:i=`unknown-${n}`}return{walletType:fd.TRUST_WALLET,address:e,provider:{getSigner:()=>({getAddress:()=>__async(this,null,(function*(){return e})),sendTransaction:t=>__async(this,null,(function*(){return{hash:yield window.ethereum.request({method:"eth_sendTransaction",params:[{from:e,to:t.to,value:t.value?t.value.toString():"0x0",gasLimit:t.gasLimit?t.gasLimit.toString():void 0,data:t.data}]})}}))}),estimateGas:t=>__async(this,null,(function*(){const r=yield window.ethereum.request({method:"eth_estimateGas",params:[{from:e,to:t.to,value:t.value?t.value:"0x0"}]});return{toString:()=>parseInt(r,16).toString(),mul:t=>({div:e=>({toString:()=>Math.floor(parseInt(r,16)*t/e).toString()})})}}))},network:i,isConnected:!0,chainId:n}}throw new Error("Unsupported wallet interface")}catch(t){throw console.error("Error connecting to Trust Wallet:",t),t}})),kd=()=>__async(this,null,(function*(){if(console.log("Connecting to TronLink wallet..."),!window.tronWeb)throw console.error("TronWeb not found. Is TronLink installed?"),new Error("TronLink not detected. Please install TronLink extension.");const t=(t=10,e=500)=>__async(this,null,(function*(){for(let r=0;r<t;r++){if(window.tronWeb&&window.tronWeb.ready)return window.tronWeb;console.log(`Waiting for TronWeb to be ready... Attempt ${r+1}/${t}`),yield new Promise((t=>setTimeout(t,e)))}throw new Error("TronWeb took too long to be ready")}));try{const r=yield t();if(!r.defaultAddress||!r.defaultAddress.base58)try{yield window.tronWeb.request({method:"tron_requestAccounts"})}catch(e){throw console.error("Failed to get permission from TronLink:",e),new Error("Please unlock TronLink and approve connection")}const n=r.defaultAddress.base58;return console.log("Connected to TronLink wallet:",n),{walletType:fd.TRONLINK,address:n,provider:r,network:gd.TRON,isConnected:!0}}catch(r){throw console.error("Error connecting to TronLink:",r),r}})),Sd=()=>__async(this,null,(function*(){if(console.log("Connecting to Lute wallet..."),!window.lute)throw console.error("Lute not found."),new Error("Lute not detected. Please install Lute extension.");try{const{address:t}=yield window.lute.connect();if(!t)throw new Error("No address returned. Please unlock Lute wallet.");return console.log("Connected to Lute wallet:",t),{walletType:fd.LUTE,address:t,provider:window.lute,network:gd.ALGORAND,isConnected:!0}}catch(t){throw console.error("Error connecting to Lute wallet:",t),t}})),Nd=t=>__async(this,null,(function*(){switch(console.log("Connecting to wallet:",t),t){case fd.METAMASK:return Ed();case fd.TRONLINK:return kd();case fd.TRUST_WALLET:return xd();case fd.LUTE:return Sd();default:throw new Error(`Unsupported wallet type: ${t}`)}})),Pd=t=>yd[t]||[],Cd=(t,e,r)=>__async(this,null,(function*(){if(console.log("Sending native transaction:",{toAddress:e,amount:r}),!t||!t.provider)throw new Error("Wallet not connected");if(!e)throw new Error("Recipient address not provided");if(!r||isNaN(parseFloat(r))||parseFloat(r)<=0)throw new Error("Invalid amount");try{let s;switch(t.walletType){case fd.METAMASK:case fd.TRUST_WALLET:const a=t.provider,o=a.getSigner(),l=r.toString();let c;try{c=ni(l,18)}catch(n){try{c=(void 0).parseEther(l)}catch(i){const t=parseFloat(l)*Math.pow(10,18);c={toString:()=>t.toLocaleString("fullwide",{useGrouping:!1})}}}console.log("Sending ETH/BNB:",{to:e,value:c.toString()});const u=yield a.estimateGas({to:e,value:c});console.log("Gas estimate:",u.toString());const h="function"==typeof u.mul?u.mul(110).div(100):{toString:()=>Math.floor(1.1*parseInt(u.toString())).toString()};console.log("Using gas limit:",h.toString()),s=yield o.sendTransaction({to:e,value:c,gasLimit:h});break;case fd.TRONLINK:const d=t.provider;if(!d||!d.ready)throw new Error("TronWeb not initialized");const p=d.toSun(r.toString());console.log("Sending TRX:",{to:e,value:p}),s=yield d.trx.sendTransaction(e,p);break;case fd.LUTE:const f=t.provider,g=Math.floor(1e6*parseFloat(r));console.log("Sending Algos:",{to:e,amount:g}),s=yield f.sendPayment({recipient:e,amount:g});break;default:throw new Error(`Unsupported wallet type: ${t.walletType}`)}if(console.log("Transaction sent:",s),s){const t=s.hash||s.txID||s.txId||s;return console.log("Transaction hash:",t),t}throw new Error("No transaction hash returned")}catch(i){throw console.error("Native transaction error:",i),i}})),Td=(t,e,r,n)=>__async(this,null,(function*(){if(console.log("Sending transaction with:",{tokenConfig:e,toAddress:r,amount:n}),!t)throw new Error("Wallet not connected");if(!r)throw new Error("Recipient address not provided");return e&&e.isNative?Cd(t,r,n):Rd(t,e,r,n)})),Rd=(t,e,r,n)=>__async(this,null,(function*(){if(console.log("Sending token transaction with:",{tokenConfig:e,toAddress:r,amount:n}),!t||!t.provider)throw new Error("Wallet not connected");if(!e)throw new Error("Token configuration not provided");if(!r)throw new Error("Recipient address not provided");if(!n||isNaN(parseFloat(n))||parseFloat(n)<=0)throw new Error("Invalid amount");const{contractAddress:i,decimals:s,symbol:a}=e;switch(console.log(`Token: ${a}, Decimals: ${s}, Contract: ${i}`),t.walletType){case fd.TRONLINK:return Md(t,e,r,n);case fd.LUTE:return Id(t,e,r,n);default:return Gd(t,e,r,n)}})),Gd=(t,e,r,n)=>__async(this,null,(function*(){if(console.log("Sending ERC20/BEP20 transaction with:",{tokenConfig:e,toAddress:r,amount:n}),!t||!t.provider)throw new Error("Wallet not connected");const i=t.provider.getSigner(),{contractAddress:s,decimals:a,symbol:o}=e,l=parseFloat(n),c=parseInt(a);let u;try{u=ni(l.toString(),c)}catch(h){try{u=(void 0).parseUnits(l.toString(),c)}catch(d){const t=l*Math.pow(10,c);u={toString:()=>t.toLocaleString("fullwide",{useGrouping:!1})}}}console.log(`Sending ${l} ${o} (${u.toString()} base units) to ${r}`);try{const t=new th(s,["function transfer(address to, uint256 amount) returns (bool)"],i);try{const e=yield t.estimateGas.transfer(r,u);console.log("Gas estimate:",e.toString());const n="USDC"===o?"function"==typeof e.mul?e.mul(120).div(100):{toString:()=>Math.floor(1.2*parseInt(e.toString())).toString()}:"function"==typeof e.mul?e.mul(110).div(100):{toString:()=>Math.floor(1.1*parseInt(e.toString())).toString()};console.log("Using gas limit:",n.toString());const i=yield t.transfer(r,u,{gasLimit:n});return console.log("Transaction sent:",i),i.hash}catch(p){if(console.error("Gas estimation failed:",p),"USDC"===o){console.log("Trying USDC transaction with fixed gas limit");const e=yield t.transfer(r,u,{gasLimit:15e4});return console.log("Transaction sent with fixed gas limit:",e),e.hash}throw new Error(`Transaction would likely fail: ${p.message}`)}}catch(d){throw console.error("ERC20 transaction error:",d),d.message&&d.message.includes("user rejected")?new Error("Transaction rejected by user"):d.message&&d.message.includes("insufficient funds")?new Error("Insufficient funds for transaction"):d}})),Md=(t,e,r,n)=>__async(this,null,(function*(){if(console.log("Sending TRC20 transaction with:",{tokenConfig:e,toAddress:r,amount:n}),!t||!t.provider)throw new Error("Tron wallet not connected");const i=t.provider;if(!i||!i.ready)throw new Error("TronWeb not initialized");if(!e||!e.contractAddress)throw new Error("Invalid token configuration");const{contractAddress:s,decimals:a,symbol:o}=e,l=parseFloat(n),c=parseInt(a),u=(l*Math.pow(10,c)).toString();console.log(`Sending ${l} ${o} (${u} base units) to ${r}`);try{const t=yield i.contract().at(s);if(!t.transfer)throw new Error("Invalid TRC-20 contract");const e=yield t.transfer(r,u).send({feeLimit:1e8,callValue:0,shouldPollResponse:!1});return console.log("TRC20 transaction sent:",e),e}catch(h){throw console.error("TRC20 transaction failed:",h),h.message&&h.message.includes("User rejected")?new Error("Transaction rejected by user"):h.message&&h.message.includes("bandwidth")?new Error("Insufficient energy or bandwidth. Make sure you have enough TRX for fees."):h.message&&h.message.includes("balance")?new Error("Insufficient token balance for transfer"):new Error(`Transaction failed: ${h.message||"Unknown error"}`)}})),Id=(t,e,r,n)=>__async(this,null,(function*(){if(console.log("Sending Algorand asset transaction with:",{tokenConfig:e,toAddress:r,amount:n}),!t||!t.provider)throw new Error("Algorand wallet not connected");const i=t.provider;if(!e||!e.assetId)throw new Error("Invalid token configuration - missing assetId");const{assetId:s,decimals:a,symbol:o}=e,l=parseFloat(n),c=parseInt(a),u=Math.floor(l*Math.pow(10,c));console.log(`Sending ${l} ${o} (${u} base units) to ${r}`);try{const t=yield i.sendAssetTransfer({recipient:r,assetId:s,amount:u});return console.log("Algorand asset transaction sent:",t),t.txId}catch(h){throw console.error("Algorand asset transaction error:",h),h.message&&h.message.includes("rejected")?new Error("Transaction rejected by user"):h.message&&h.message.includes("balance")?new Error("Insufficient asset balance"):h}}));let Bd={apiKey:null,apiSecret:null,apiUrl:"https://coinleyserver-production.up.railway.app",merchantWalletAddresses:{}};const Od=()=>({"Content-Type":"application/json","x-api-key":Bd.apiKey,"x-api-secret":Bd.apiSecret}),Fd=t=>__async(this,null,(function*(){try{if(console.log("Creating payment with data:",t),console.log("API URL:",`${Bd.apiUrl}/api/payments/create`),!t.amount)throw new Error("Payment amount is required");const r=__spreadProps(__spreadValues({},t),{merchantWalletAddresses:__spreadValues(__spreadValues({},Bd.merchantWalletAddresses),t.merchantWalletAddresses)}),n=yield fetch(`${Bd.apiUrl}/api/payments/create`,{method:"POST",headers:Od(),body:JSON.stringify(r)});if(console.log("Create payment response status:",n.status),!n.ok){let t;try{t=yield n.json()}catch(e){throw new Error(`Failed to create payment: ${n.status} ${n.statusText}`)}throw console.error("Error creating payment:",t),new Error(t.error||`Failed to create payment: ${n.status}`)}const i=yield n.json();return console.log("Create payment response data:",i),i}catch(r){throw console.error("Create payment error:",r),r}})),Ud=t=>__async(this,null,(function*(){try{if(console.log("Processing payment with data:",t),!t.paymentId)throw new Error("Payment ID is required");if(!t.transactionHash)throw new Error("Transaction hash is required");console.log("API URL:",`${Bd.apiUrl}/api/payments/process`);const r=yield fetch(`${Bd.apiUrl}/api/payments/process`,{method:"POST",headers:Od(),body:JSON.stringify(t)});if(console.log("Process payment response status:",r.status),!r.ok){let t;try{t=yield r.json()}catch(e){throw new Error(`Failed to process payment: ${r.status} ${r.statusText}`)}throw console.error("Error processing payment:",t),new Error(t.error||`Failed to process payment: ${r.status}`)}const n=yield r.json();return console.log("Process payment response data:",n),n}catch(r){throw console.error("Process payment error:",r),r}}));var Ld={exports:{}},Dd={},jd=e,Hd=Symbol.for("react.element"),Wd=Symbol.for("react.fragment"),Qd=Object.prototype.hasOwnProperty,zd=jd.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Vd={key:!0,ref:!0,__self:!0,__source:!0};function Jd(t,e,r){var n,i={},s=null,a=null;for(n in void 0!==r&&(s=""+r),void 0!==e.key&&(s=""+e.key),void 0!==e.ref&&(a=e.ref),e)Qd.call(e,n)&&!Vd.hasOwnProperty(n)&&(i[n]=e[n]);if(t&&t.defaultProps)for(n in e=t.defaultProps)void 0===i[n]&&(i[n]=e[n]);return{$$typeof:Hd,type:t,key:s,ref:a,props:i,_owner:zd.current}}Dd.Fragment=Wd,Dd.jsx=Jd,Dd.jsxs=Jd,Ld.exports=Dd;var Kd=Ld.exports;const qd=e.createContext(),Zd=e.createContext(),Yd=()=>e.useContext(Zd);var Xd,$d,tp=Object.defineProperty,ep=Object.getOwnPropertySymbols,rp=Object.prototype.hasOwnProperty,np=Object.prototype.propertyIsEnumerable,ip=(t,e,r)=>e in t?tp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,sp=(t,e)=>{for(var r in e||(e={}))rp.call(e,r)&&ip(t,r,e[r]);if(ep)for(var r of ep(e))np.call(e,r)&&ip(t,r,e[r]);return t},ap=(t,e)=>{var r={};for(var n in t)rp.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&ep)for(var n of ep(t))e.indexOf(n)<0&&np.call(t,n)&&(r[n]=t[n]);return r};(t=>{const e=class e{constructor(t,r,n,s){if(this.version=t,this.errorCorrectionLevel=r,this.modules=[],this.isFunction=[],t<e.MIN_VERSION||t>e.MAX_VERSION)throw new RangeError("Version value out of range");if(s<-1||s>7)throw new RangeError("Mask value out of range");this.size=4*t+17;let a=[];for(let e=0;e<this.size;e++)a.push(!1);for(let e=0;e<this.size;e++)this.modules.push(a.slice()),this.isFunction.push(a.slice());this.drawFunctionPatterns();const o=this.addEccAndInterleave(n);if(this.drawCodewords(o),-1==s){let t=1e9;for(let e=0;e<8;e++){this.applyMask(e),this.drawFormatBits(e);const r=this.getPenaltyScore();r<t&&(s=e,t=r),this.applyMask(e)}}i(0<=s&&s<=7),this.mask=s,this.applyMask(s),this.drawFormatBits(s),this.isFunction=[]}static encodeText(r,n){const i=t.QrSegment.makeSegments(r);return e.encodeSegments(i,n)}static encodeBinary(r,n){const i=t.QrSegment.makeBytes(r);return e.encodeSegments([i],n)}static encodeSegments(t,n,s=1,o=40,l=-1,c=!0){if(!(e.MIN_VERSION<=s&&s<=o&&o<=e.MAX_VERSION)||l<-1||l>7)throw new RangeError("Invalid value");let u,h;for(u=s;;u++){const r=8*e.getNumDataCodewords(u,n),i=a.getTotalBits(t,u);if(i<=r){h=i;break}if(u>=o)throw new RangeError("Data too long")}for(const r of[e.Ecc.MEDIUM,e.Ecc.QUARTILE,e.Ecc.HIGH])c&&h<=8*e.getNumDataCodewords(u,r)&&(n=r);let d=[];for(const e of t){r(e.mode.modeBits,4,d),r(e.numChars,e.mode.numCharCountBits(u),d);for(const t of e.getData())d.push(t)}i(d.length==h);const p=8*e.getNumDataCodewords(u,n);i(d.length<=p),r(0,Math.min(4,p-d.length),d),r(0,(8-d.length%8)%8,d),i(d.length%8==0);for(let e=236;d.length<p;e^=253)r(e,8,d);let f=[];for(;8*f.length<d.length;)f.push(0);return d.forEach(((t,e)=>f[e>>>3]|=t<<7-(7&e))),new e(u,n,f,l)}getModule(t,e){return 0<=t&&t<this.size&&0<=e&&e<this.size&&this.modules[e][t]}getModules(){return this.modules}drawFunctionPatterns(){for(let r=0;r<this.size;r++)this.setFunctionModule(6,r,r%2==0),this.setFunctionModule(r,6,r%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const t=this.getAlignmentPatternPositions(),e=t.length;for(let r=0;r<e;r++)for(let n=0;n<e;n++)0==r&&0==n||0==r&&n==e-1||r==e-1&&0==n||this.drawAlignmentPattern(t[r],t[n]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(t){const e=this.errorCorrectionLevel.formatBits<<3|t;let r=e;for(let n=0;n<10;n++)r=r<<1^1335*(r>>>9);const s=21522^(e<<10|r);i(s>>>15==0);for(let i=0;i<=5;i++)this.setFunctionModule(8,i,n(s,i));this.setFunctionModule(8,7,n(s,6)),this.setFunctionModule(8,8,n(s,7)),this.setFunctionModule(7,8,n(s,8));for(let i=9;i<15;i++)this.setFunctionModule(14-i,8,n(s,i));for(let i=0;i<8;i++)this.setFunctionModule(this.size-1-i,8,n(s,i));for(let i=8;i<15;i++)this.setFunctionModule(8,this.size-15+i,n(s,i));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let t=this.version;for(let r=0;r<12;r++)t=t<<1^7973*(t>>>11);const e=this.version<<12|t;i(e>>>18==0);for(let r=0;r<18;r++){const t=n(e,r),i=this.size-11+r%3,s=Math.floor(r/3);this.setFunctionModule(i,s,t),this.setFunctionModule(s,i,t)}}drawFinderPattern(t,e){for(let r=-4;r<=4;r++)for(let n=-4;n<=4;n++){const i=Math.max(Math.abs(n),Math.abs(r)),s=t+n,a=e+r;0<=s&&s<this.size&&0<=a&&a<this.size&&this.setFunctionModule(s,a,2!=i&&4!=i)}}drawAlignmentPattern(t,e){for(let r=-2;r<=2;r++)for(let n=-2;n<=2;n++)this.setFunctionModule(t+n,e+r,1!=Math.max(Math.abs(n),Math.abs(r)))}setFunctionModule(t,e,r){this.modules[e][t]=r,this.isFunction[e][t]=!0}addEccAndInterleave(t){const r=this.version,n=this.errorCorrectionLevel;if(t.length!=e.getNumDataCodewords(r,n))throw new RangeError("Invalid argument");const s=e.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][r],a=e.ECC_CODEWORDS_PER_BLOCK[n.ordinal][r],o=Math.floor(e.getNumRawDataModules(r)/8),l=s-o%s,c=Math.floor(o/s);let u=[];const h=e.reedSolomonComputeDivisor(a);for(let i=0,p=0;i<s;i++){let r=t.slice(p,p+c-a+(i<l?0:1));p+=r.length;const n=e.reedSolomonComputeRemainder(r,h);i<l&&r.push(0),u.push(r.concat(n))}let d=[];for(let e=0;e<u[0].length;e++)u.forEach(((t,r)=>{(e!=c-a||r>=l)&&d.push(t[e])}));return i(d.length==o),d}drawCodewords(t){if(t.length!=Math.floor(e.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let r=0;for(let e=this.size-1;e>=1;e-=2){6==e&&(e=5);for(let i=0;i<this.size;i++)for(let s=0;s<2;s++){const a=e-s,o=!(e+1&2)?this.size-1-i:i;!this.isFunction[o][a]&&r<8*t.length&&(this.modules[o][a]=n(t[r>>>3],7-(7&r)),r++)}}i(r==8*t.length)}applyMask(t){if(t<0||t>7)throw new RangeError("Mask value out of range");for(let e=0;e<this.size;e++)for(let r=0;r<this.size;r++){let n;switch(t){case 0:n=(r+e)%2==0;break;case 1:n=e%2==0;break;case 2:n=r%3==0;break;case 3:n=(r+e)%3==0;break;case 4:n=(Math.floor(r/3)+Math.floor(e/2))%2==0;break;case 5:n=r*e%2+r*e%3==0;break;case 6:n=(r*e%2+r*e%3)%2==0;break;case 7:n=((r+e)%2+r*e%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[e][r]&&n&&(this.modules[e][r]=!this.modules[e][r])}}getPenaltyScore(){let t=0;for(let i=0;i<this.size;i++){let r=!1,n=0,s=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[i][a]==r?(n++,5==n?t+=e.PENALTY_N1:n>5&&t++):(this.finderPenaltyAddHistory(n,s),r||(t+=this.finderPenaltyCountPatterns(s)*e.PENALTY_N3),r=this.modules[i][a],n=1);t+=this.finderPenaltyTerminateAndCount(r,n,s)*e.PENALTY_N3}for(let i=0;i<this.size;i++){let r=!1,n=0,s=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][i]==r?(n++,5==n?t+=e.PENALTY_N1:n>5&&t++):(this.finderPenaltyAddHistory(n,s),r||(t+=this.finderPenaltyCountPatterns(s)*e.PENALTY_N3),r=this.modules[a][i],n=1);t+=this.finderPenaltyTerminateAndCount(r,n,s)*e.PENALTY_N3}for(let i=0;i<this.size-1;i++)for(let r=0;r<this.size-1;r++){const n=this.modules[i][r];n==this.modules[i][r+1]&&n==this.modules[i+1][r]&&n==this.modules[i+1][r+1]&&(t+=e.PENALTY_N2)}let r=0;for(const e of this.modules)r=e.reduce(((t,e)=>t+(e?1:0)),r);const n=this.size*this.size,s=Math.ceil(Math.abs(20*r-10*n)/n)-1;return i(0<=s&&s<=9),t+=s*e.PENALTY_N4,i(0<=t&&t<=2568888),t}getAlignmentPatternPositions(){if(1==this.version)return[];{const t=Math.floor(this.version/7)+2,e=32==this.version?26:2*Math.ceil((4*this.version+4)/(2*t-2));let r=[6];for(let n=this.size-7;r.length<t;n-=e)r.splice(1,0,n);return r}}static getNumRawDataModules(t){if(t<e.MIN_VERSION||t>e.MAX_VERSION)throw new RangeError("Version number out of range");let r=(16*t+128)*t+64;if(t>=2){const e=Math.floor(t/7)+2;r-=(25*e-10)*e-55,t>=7&&(r-=36)}return i(208<=r&&r<=29648),r}static getNumDataCodewords(t,r){return Math.floor(e.getNumRawDataModules(t)/8)-e.ECC_CODEWORDS_PER_BLOCK[r.ordinal][t]*e.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][t]}static reedSolomonComputeDivisor(t){if(t<1||t>255)throw new RangeError("Degree out of range");let r=[];for(let e=0;e<t-1;e++)r.push(0);r.push(1);let n=1;for(let i=0;i<t;i++){for(let t=0;t<r.length;t++)r[t]=e.reedSolomonMultiply(r[t],n),t+1<r.length&&(r[t]^=r[t+1]);n=e.reedSolomonMultiply(n,2)}return r}static reedSolomonComputeRemainder(t,r){let n=r.map((t=>0));for(const i of t){const t=i^n.shift();n.push(0),r.forEach(((r,i)=>n[i]^=e.reedSolomonMultiply(r,t)))}return n}static reedSolomonMultiply(t,e){if(t>>>8!=0||e>>>8!=0)throw new RangeError("Byte out of range");let r=0;for(let n=7;n>=0;n--)r=r<<1^285*(r>>>7),r^=(e>>>n&1)*t;return i(r>>>8==0),r}finderPenaltyCountPatterns(t){const e=t[1];i(e<=3*this.size);const r=e>0&&t[2]==e&&t[3]==3*e&&t[4]==e&&t[5]==e;return(r&&t[0]>=4*e&&t[6]>=e?1:0)+(r&&t[6]>=4*e&&t[0]>=e?1:0)}finderPenaltyTerminateAndCount(t,e,r){return t&&(this.finderPenaltyAddHistory(e,r),e=0),e+=this.size,this.finderPenaltyAddHistory(e,r),this.finderPenaltyCountPatterns(r)}finderPenaltyAddHistory(t,e){0==e[0]&&(t+=this.size),e.pop(),e.unshift(t)}};function r(t,e,r){if(e<0||e>31||t>>>e!=0)throw new RangeError("Value out of range");for(let n=e-1;n>=0;n--)r.push(t>>>n&1)}function n(t,e){return!!(t>>>e&1)}function i(t){if(!t)throw new Error("Assertion error")}e.MIN_VERSION=1,e.MAX_VERSION=40,e.PENALTY_N1=3,e.PENALTY_N2=3,e.PENALTY_N3=40,e.PENALTY_N4=10,e.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],e.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],t.QrCode=e;const s=class t{constructor(t,e,r){if(this.mode=t,this.numChars=e,this.bitData=r,e<0)throw new RangeError("Invalid argument");this.bitData=r.slice()}static makeBytes(e){let n=[];for(const t of e)r(t,8,n);return new t(t.Mode.BYTE,e.length,n)}static makeNumeric(e){if(!t.isNumeric(e))throw new RangeError("String contains non-numeric characters");let n=[];for(let t=0;t<e.length;){const i=Math.min(e.length-t,3);r(parseInt(e.substring(t,t+i),10),3*i+1,n),t+=i}return new t(t.Mode.NUMERIC,e.length,n)}static makeAlphanumeric(e){if(!t.isAlphanumeric(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");let n,i=[];for(n=0;n+2<=e.length;n+=2){let s=45*t.ALPHANUMERIC_CHARSET.indexOf(e.charAt(n));s+=t.ALPHANUMERIC_CHARSET.indexOf(e.charAt(n+1)),r(s,11,i)}return n<e.length&&r(t.ALPHANUMERIC_CHARSET.indexOf(e.charAt(n)),6,i),new t(t.Mode.ALPHANUMERIC,e.length,i)}static makeSegments(e){return""==e?[]:t.isNumeric(e)?[t.makeNumeric(e)]:t.isAlphanumeric(e)?[t.makeAlphanumeric(e)]:[t.makeBytes(t.toUtf8ByteArray(e))]}static makeEci(e){let n=[];if(e<0)throw new RangeError("ECI assignment value out of range");if(e<128)r(e,8,n);else if(e<16384)r(2,2,n),r(e,14,n);else{if(!(e<1e6))throw new RangeError("ECI assignment value out of range");r(6,3,n),r(e,21,n)}return new t(t.Mode.ECI,0,n)}static isNumeric(e){return t.NUMERIC_REGEX.test(e)}static isAlphanumeric(e){return t.ALPHANUMERIC_REGEX.test(e)}getData(){return this.bitData.slice()}static getTotalBits(t,e){let r=0;for(const n of t){const t=n.mode.numCharCountBits(e);if(n.numChars>=1<<t)return 1/0;r+=4+t+n.bitData.length}return r}static toUtf8ByteArray(t){t=encodeURI(t);let e=[];for(let r=0;r<t.length;r++)"%"!=t.charAt(r)?e.push(t.charCodeAt(r)):(e.push(parseInt(t.substring(r+1,r+3),16)),r+=2);return e}};s.NUMERIC_REGEX=/^[0-9]*$/,s.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,s.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let a=s;t.QrSegment=s})(Xd||(Xd={})),(t=>{const e=class{constructor(t,e){this.ordinal=t,this.formatBits=e}};e.LOW=new e(0,1),e.MEDIUM=new e(1,0),e.QUARTILE=new e(2,3),e.HIGH=new e(3,2),t.Ecc=e})(($d=Xd||(Xd={})).QrCode||($d.QrCode={})),(t=>{(t=>{const e=class{constructor(t,e){this.modeBits=t,this.numBitsCharCount=e}numCharCountBits(t){return this.numBitsCharCount[Math.floor((t+7)/17)]}};e.NUMERIC=new e(1,[10,12,14]),e.ALPHANUMERIC=new e(2,[9,11,13]),e.BYTE=new e(4,[8,16,16]),e.KANJI=new e(8,[8,10,12]),e.ECI=new e(7,[0,0,0]),t.Mode=e})(t.QrSegment||(t.QrSegment={}))})(Xd||(Xd={}));var op=Xd,lp={L:op.QrCode.Ecc.LOW,M:op.QrCode.Ecc.MEDIUM,Q:op.QrCode.Ecc.QUARTILE,H:op.QrCode.Ecc.HIGH},cp=128,up="L",hp="#FFFFFF",dp="#000000",pp=!1,fp=1;
12
12
  /**
13
13
  * @license qrcode.react
14
14
  * Copyright (c) Paul O'Shannessy
15
15
  * SPDX-License-Identifier: ISC
16
- */function gp(t,e=0){const r=[];return t.forEach((function(t,n){let i=null;t.forEach((function(s,a){if(!s&&null!==i)return r.push(`M${i+e} ${n+e}h${a-i}v1H${i+e}z`),void(i=null);if(a!==t.length-1)s&&null===i&&(i=a);else{if(!s)return;null===i?r.push(`M${a+e},${n+e} h1v1H${a+e}z`):r.push(`M${i+e},${n+e} h${a+1-i}v1H${i+e}z`)}}))})),r.join("")}function mp(t,e){return t.slice().map(((t,r)=>r<e.y||r>=e.y+e.h?t:t.map(((t,r)=>(r<e.x||r>=e.x+e.w)&&t))))}function _p({value:t,level:r,minVersion:n,includeMargin:i,marginSize:s,imageSettings:a,size:o,boostLevel:l}){let c=e.useMemo((()=>{const e=(Array.isArray(t)?t:[t]).reduce(((t,e)=>(t.push(...op.QrSegment.makeSegments(e)),t)),[]);return op.QrCode.encodeSegments(e,lp[r],n,void 0,void 0,l)}),[t,r,n,l]);const{cells:u,margin:h,numCells:d,calculatedImageSettings:p}=e.useMemo((()=>{let t=c.getModules();const e=function(t,e){return null!=e?Math.max(Math.floor(e),0):t?4:0}(i,s),r=t.length+2*e,n=function(t,e,r,n){if(null==n)return null;const i=t.length+2*r,s=Math.floor(.1*e),a=i/e,o=(n.width||s)*a,l=(n.height||s)*a,c=null==n.x?t.length/2-o/2:n.x*a,u=null==n.y?t.length/2-l/2:n.y*a,h=null==n.opacity?1:n.opacity;let d=null;if(n.excavate){let t=Math.floor(c),e=Math.floor(u);d={x:t,y:e,w:Math.ceil(o+c-t),h:Math.ceil(l+u-e)}}return{x:c,y:u,h:l,w:o,excavation:d,opacity:h,crossOrigin:n.crossOrigin}}(t,o,e,a);return{cells:t,margin:e,numCells:r,calculatedImageSettings:n}}),[c,o,a,i,s]);return{qrcode:c,margin:h,cells:u,numCells:d,calculatedImageSettings:p}}var yp=function(){try{(new Path2D).addPath(new Path2D)}catch(t){return!1}return!0}();e.forwardRef((function(t,r){const n=t,{value:i,size:s=cp,level:a=up,bgColor:o=hp,fgColor:l=dp,includeMargin:c=pp,minVersion:u=fp,boostLevel:h,marginSize:d,imageSettings:p}=n,f=ap(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:g}=f,m=ap(f,["style"]),_=null==p?void 0:p.src,y=e.useRef(null),v=e.useRef(null),w=e.useCallback((t=>{y.current=t,"function"==typeof r?r(t):r&&(r.current=t)}),[r]),[b,A]=e.useState(!1),{margin:E,cells:x,numCells:k,calculatedImageSettings:S}=_p({value:i,level:a,minVersion:u,boostLevel:h,includeMargin:c,marginSize:d,imageSettings:p,size:s});e.useEffect((()=>{if(null!=y.current){const t=y.current,e=t.getContext("2d");if(!e)return;let r=x;const n=v.current,i=null!=S&&null!==n&&n.complete&&0!==n.naturalHeight&&0!==n.naturalWidth;i&&null!=S.excavation&&(r=mp(x,S.excavation));const a=window.devicePixelRatio||1;t.height=t.width=s*a;const c=s/k*a;e.scale(c,c),e.fillStyle=o,e.fillRect(0,0,k,k),e.fillStyle=l,yp?e.fill(new Path2D(gp(r,E))):x.forEach((function(t,r){t.forEach((function(t,n){t&&e.fillRect(n+E,r+E,1,1)}))})),S&&(e.globalAlpha=S.opacity),i&&e.drawImage(n,S.x+E,S.y+E,S.w,S.h)}})),e.useEffect((()=>{A(!1)}),[_]);const N=sp({height:s,width:s},g);let P=null;return null!=_&&(P=e.createElement("img",{src:_,key:_,style:{display:"none"},onLoad:()=>{A(!0)},ref:v,crossOrigin:null==S?void 0:S.crossOrigin})),e.createElement(e.Fragment,null,e.createElement("canvas",sp({style:N,height:s,width:s,ref:w,role:"img"},m)),P)})).displayName="QRCodeCanvas";var vp=e.forwardRef((function(t,r){const n=t,{value:i,size:s=cp,level:a=up,bgColor:o=hp,fgColor:l=dp,includeMargin:c=pp,minVersion:u=fp,boostLevel:h,title:d,marginSize:p,imageSettings:f}=n,g=ap(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:m,cells:_,numCells:y,calculatedImageSettings:v}=_p({value:i,level:a,minVersion:u,boostLevel:h,includeMargin:c,marginSize:p,imageSettings:f,size:s});let w=_,b=null;null!=f&&null!=v&&(null!=v.excavation&&(w=mp(_,v.excavation)),b=e.createElement("image",{href:f.src,height:v.h,width:v.w,x:v.x+m,y:v.y+m,preserveAspectRatio:"none",opacity:v.opacity,crossOrigin:v.crossOrigin}));const A=gp(w,m);return e.createElement("svg",sp({height:s,width:s,viewBox:`0 0 ${y} ${y}`,ref:r,role:"img"},g),!!d&&e.createElement("title",null,d),e.createElement("path",{fill:o,d:`M0,0 h${y}v${y}H0z`,shapeRendering:"crispEdges"}),e.createElement("path",{fill:l,d:A,shapeRendering:"crispEdges"}),b)}));vp.displayName="QRCodeSVG";const wp=({walletAddress:t,amount:r,currency:n,network:i,theme:s="light",size:a=200})=>{const[o,l]=e.useState(""),[c,u]=e.useState(null);e.useEffect((()=>{if(t&&"No address configured"!==t)try{let e;switch(i){case"tron":e="TRX"===n?`tronlink://transfer?to=${t}&amount=${r}`:t;break;case"algorand":e=`algorand://${t}?amount=${Math.floor(1e6*parseFloat(r))}`;break;case"bsc":if("BNB"===n)e=`ethereum:${t}@56?value=${p(r)}`;else{const i=h(n,"bsc");e=i?`ethereum:${i}/transfer?address=${t}&uint256=${d(r,n)}@56`:t}break;default:if("ETH"===n)e=`ethereum:${t}@1?value=${p(r)}`;else{const i=h(n,"ethereum");e=i?`ethereum:${i}/transfer?address=${t}&uint256=${d(r,n)}`:t}}l(e),u(null)}catch(e){console.error("Error generating QR code:",e),u("Error generating payment QR code")}else u("No wallet address configured for this network")}),[t,r,n,i]);const h=(t,e)=>{var r;return(null==(r={ethereum:{USDT:"0xdAC17F958D2ee523a2206206994597C13D831ec7",USDC:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},bsc:{USDT:"0x55d398326f99059fF775485246999027B3197955",USDC:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"},tron:{USDT:"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",USDC:"TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8"}}[e])?void 0:r[t])||""},d=(t,e)=>{const r="USDT"===e||"USDC"===e?6:18;return Math.floor(parseFloat(t)*Math.pow(10,r)).toString()},p=t=>Math.floor(1e18*parseFloat(t)).toString(),f=t=>({ethereum:"Ethereum",bsc:"BSC",tron:"Tron",algorand:"Algorand"}[t]||t);return Kd.jsxs("div",{className:"flex flex-col items-center",children:[c?Kd.jsxs("div",{className:"p-4 rounded-lg bg-red-100 mb-3 text-red-700 text-center",children:[Kd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 mx-auto mb-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Kd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),Kd.jsx("p",{className:"font-medium",children:c})]}):Kd.jsx("div",{className:"p-4 rounded-lg bg-white mb-3 shadow-sm border",children:o&&Kd.jsx(vp,{value:o,size:a,bgColor:"dark"===s?"#374151":"#FFFFFF",fgColor:"dark"===s?"#FFFFFF":"#000000",level:"H",includeMargin:!0})}),Kd.jsxs("div",{className:"text-center text-sm text-gray-700 mb-4",children:[Kd.jsxs("p",{className:"font-semibold text-gray-800 flex items-center justify-center",children:[Kd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Kd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v1m6 11h2m-6 0h-2v4m0-11v3m0 0h.01M12 12h4.01M12 12h-4.01M12 12V8.01"})}),"Scan to Pay with ",n]}),Kd.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Scan with your ",f(i)," wallet app"]})]}),Kd.jsxs("div",{className:"w-full mb-4 p-3 bg-gray-50 rounded-lg",children:[Kd.jsxs("div",{className:"flex justify-between items-center",children:[Kd.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Amount to Pay:"}),Kd.jsxs("span",{className:"text-lg font-bold text-[#7042D2]",children:[r," ",n]})]}),Kd.jsxs("div",{className:"flex justify-between items-center mt-1",children:[Kd.jsx("span",{className:"text-xs text-gray-500",children:"Network:"}),Kd.jsx("span",{className:"text-xs font-medium text-gray-700",children:f(i)})]})]}),!c&&Kd.jsxs("div",{className:"w-full mb-4",children:[Kd.jsx("p",{className:"text-xs text-gray-500 mb-1 text-center",children:"Or copy wallet address:"}),Kd.jsx("div",{className:"text-xs font-mono p-2 rounded bg-gray-100 text-gray-700 break-all text-center select-all cursor-pointer border",onClick:()=>{var e;return null==(e=navigator.clipboard)?void 0:e.writeText(t)},title:"Click to copy",children:t})]}),Kd.jsx("div",{className:"w-full",children:Kd.jsxs("div",{className:"p-3 rounded bg-blue-50 border border-blue-200",children:[Kd.jsxs("h4",{className:"text-sm font-medium mb-2 text-blue-800 flex items-center",children:[Kd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Kd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),"Payment Instructions"]}),Kd.jsxs("ol",{className:"text-xs space-y-1 text-blue-700",children:[Kd.jsxs("li",{children:["1. Open your crypto wallet app (",(g=i,{ethereum:["MetaMask","Trust Wallet","Coinbase Wallet"],bsc:["MetaMask","Trust Wallet","SafePal"],tron:["TronLink","Trust Wallet"],algorand:["Pera Wallet","MyAlgo Wallet"]}[g]||["MetaMask","Trust Wallet"]).join(", "),")"]}),Kd.jsx("li",{children:"2. Scan the QR code above or copy the wallet address"}),Kd.jsxs("li",{children:["3. Send exactly ",Kd.jsxs("strong",{children:[r," ",n]})," on ",f(i)," network"]}),Kd.jsx("li",{children:'4. Click "I have sent the payment" button below after sending'})]}),Kd.jsx("div",{className:"mt-3 p-2 bg-yellow-50 border border-yellow-200 rounded",children:Kd.jsxs("p",{className:"text-xs text-yellow-800",children:[Kd.jsx("strong",{children:"Important:"})," Make sure you're sending on the correct network (",f(i),") and using the exact amount shown above."]})})]})})]});var g},bp=({status:t,message:e,theme:r="light"})=>Kd.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[Kd.jsx("div",{className:"mb-4",children:(()=>{switch(t){case"processing":return Kd.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-4 border-t-blue-500 border-blue-500/20"});case"success":return Kd.jsx("div",{className:"rounded-full h-12 w-12 bg-green-100 flex items-center justify-center",children:Kd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 text-green-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:Kd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})});case"error":return Kd.jsx("div",{className:"rounded-full h-12 w-12 bg-red-100 flex items-center justify-center",children:Kd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:Kd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})});default:return null}})()}),Kd.jsx("h3",{className:"text-xl font-bold mb-2 "+("dark"===r?"text-white":"text-gray-900"),children:(()=>{switch(t){case"processing":return"Processing Payment";case"success":return"Payment Successful";case"error":return"Payment Failed";default:return"Unknown Status"}})()}),Kd.jsx("p",{className:`text-center ${(()=>{switch(t){case"processing":return"dark"===r?"text-blue-300":"text-blue-600";case"success":return"dark"===r?"text-green-300":"text-green-600";case"error":return"dark"===r?"text-red-300":"text-red-600";default:return"dark"===r?"text-gray-300":"text-gray-600"}})()}`,children:e}),"processing"===t&&Kd.jsx("div",{className:"mt-4 text-xs "+("dark"===r?"text-gray-400":"text-gray-500"),children:"This may take a few moments. Please do not close this window."}),"success"===t&&Kd.jsx("div",{className:"mt-4 p-2 rounded "+("dark"===r?"bg-gray-700":"bg-gray-100"),children:Kd.jsx("p",{className:"text-xs "+("dark"===r?"text-gray-300":"text-gray-600"),children:"Your payment has been successfully processed. You will receive a confirmation shortly."})})]}),Ap=({onSelect:t,selected:r,theme:n="light",supportedNetworks:i=[]})=>{const[s,a]=e.useState(gd.ETHEREUM),[o,l]=e.useState({}),[c,u]=e.useState(!1);e.useEffect((()=>{l(wd())}),[]);const h=[{id:gd.ETHEREUM,name:"Ethereum",description:"ERC-20 tokens"},{id:gd.BSC,name:"BSC (Binance Smart Chain)",description:"BEP-20 tokens"},{id:gd.TRON,name:"Tron",description:"TRC-20 tokens"},{id:gd.ALGORAND,name:"Algorand",description:"ASA tokens"}],d=(t=>{const e=[];switch(t){case gd.ETHEREUM:e.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:gd.ETHEREUM},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:gd.ETHEREUM},{id:"PYUSD",name:"PYUSD",description:"PayPal USD",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/28492.png",network:gd.ETHEREUM},{id:"FRAX",name:"FRAX",description:"Frax",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6952.png",network:gd.ETHEREUM},{id:"USDP",name:"USDP",description:"Pax Dollar",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6662.png",network:gd.ETHEREUM},{id:"DAI",name:"DAI",description:"Dai Stablecoin",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4943.png",network:gd.ETHEREUM},{id:"ETH",name:"ETH",description:"Ethereum",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTcyJyRKN0dRJWVZqoLzYgkRHdJsxKGq8nHUw&s",network:gd.ETHEREUM});break;case gd.BSC:e.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:gd.BSC},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:gd.BSC},{id:"BUSD",name:"BUSD",description:"Binance USD",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4687.png",network:gd.BSC},{id:"FRAX",name:"FRAX",description:"Frax",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6952.png",network:gd.BSC},{id:"BNB",name:"BNB",description:"Binance Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRHSjyW2sSnBhwztCwVW97i1BtV40g7heMMxg&s",network:gd.BSC});break;case gd.TRON:e.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:gd.TRON},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:gd.TRON},{id:"USDJ",name:"USDJ",description:"JUST Stablecoin",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/5446.png",network:gd.TRON},{id:"TRX",name:"TRX",description:"Tron",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQKLpLNsGRHbZfCUXAjZLPSp_YFZvX5dMnAoA&s",network:gd.TRON});break;case gd.ALGORAND:e.push({id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:gd.ALGORAND},{id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:gd.ALGORAND},{id:"ALGO",name:"ALGO",description:"Algorand",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4030.png",network:gd.ALGORAND})}return e})(s),p=c?d:d.slice(0,4);function f(t){switch(t){case gd.ETHEREUM:case gd.BSC:return fd.METAMASK;case gd.TRON:return fd.TRONLINK;case gd.ALGORAND:return fd.LUTE;default:return fd.METAMASK}}return Kd.jsxs("div",{children:[Kd.jsx("h3",{className:"text-lg font-medium mb-4 "+("dark"===n?"text-white":"text-gray-800"),children:"Select Payment Method"}),Kd.jsxs("div",{className:"mb-6",children:[Kd.jsx("label",{className:"block text-sm font-medium mb-2 "+("dark"===n?"text-white":"text-gray-700"),children:"Blockchain Network"}),Kd.jsx("select",{value:s,onChange:e=>{return n=e.target.value,a(n),u(!1),void((null==r?void 0:r.network)!==n&&t(null));var n},className:`w-full p-3 rounded-lg border transition-colors ${"dark"===n?"bg-gray-700 border-gray-600 text-white focus:border-[#7042D2]":"bg-white border-gray-300 text-gray-900 focus:border-[#7042D2]"} focus:outline-none focus:ring-2 focus:ring-[#7042D2] focus:ring-opacity-50`,children:h.filter((t=>0===i.length||i.includes(t.id))).map((t=>Kd.jsxs("option",{value:t.id,children:[t.name," - ",t.description]},t.id)))})]}),Kd.jsxs("div",{className:"mb-4",children:[Kd.jsx("label",{className:"block text-sm font-medium mb-3 "+("dark"===n?"text-white":"text-gray-700"),children:"Choose Cryptocurrency"}),Kd.jsx("div",{className:"grid grid-cols-2 gap-3 mb-4",children:p.map((e=>Kd.jsx("button",{onClick:()=>(e=>{var r;t({currency:e.id,network:s,tokenConfig:null==(r=_d[e.id])?void 0:r[s],method:e})})(e),className:"p-4 rounded-lg transition-all duration-200 border-2 "+((null==r?void 0:r.currency)===e.id&&(null==r?void 0:r.network)===s?"dark"===n?"bg-blue-900/30 border-[#7042D2] ring-2 ring-[#7042D2] ring-opacity-50":"bg-blue-50 border-[#7042D2] ring-2 ring-[#7042D2] ring-opacity-50":"dark"===n?"bg-gray-700 hover:bg-gray-600 border-gray-600 hover:border-gray-500":"bg-white hover:bg-gray-50 border-gray-200 hover:border-gray-300"),children:Kd.jsxs("div",{className:"flex flex-col items-center text-center",children:[Kd.jsx("div",{className:"flex-shrink-0 h-10 w-10 bg-white rounded-full flex items-center justify-center mb-2 shadow-sm",children:Kd.jsx("img",{src:e.logo,alt:e.name,className:"h-6 w-6"})}),Kd.jsxs("div",{children:[Kd.jsx("h4",{className:"font-medium text-sm "+("dark"===n?"text-white":"text-gray-900"),children:e.name}),Kd.jsx("p",{className:"text-xs "+("dark"===n?"text-gray-300":"text-gray-500"),children:e.description})]}),(null==r?void 0:r.currency)===e.id&&(null==r?void 0:r.network)===s&&Kd.jsx("div",{className:"mt-2",children:Kd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-[#7042D2]",viewBox:"0 0 20 20",fill:"currentColor",children:Kd.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})})]})},`${e.id}-${e.network}`)))}),d.length>4&&Kd.jsx("button",{onClick:()=>u(!c),className:"w-full py-2 px-4 rounded-lg text-sm font-medium transition-colors "+("dark"===n?"bg-gray-700 text-gray-300 hover:bg-gray-600":"bg-gray-100 text-gray-600 hover:bg-gray-200"),children:c?"Show Less":`Show More (${d.length-4} more)`})]}),Kd.jsx("div",{className:"p-3 rounded-lg text-sm "+("dark"===n?"bg-gray-800 text-gray-300":"bg-gray-50 text-gray-600"),children:Kd.jsxs("div",{className:"flex items-center",children:[Kd.jsx("div",{className:"w-2 h-2 rounded-full mr-2 "+(o[f(s)]?"bg-green-500":"bg-red-500")}),Kd.jsx("span",{className:"text-xs",children:function(t){const e=f(t),r=o[e],n={[fd.METAMASK]:"MetaMask",[fd.TRONLINK]:"TronLink",[fd.TRUST_WALLET]:"Trust Wallet",[fd.LUTE]:"Lute Wallet"};return r?`${n[e]} detected - Ready to pay`:`${n[e]} required - Please install to continue`}(s)})]})})]})},Ep=({isOpen:t,onClose:r,payment:n,paymentStatus:i,selectedPaymentMethod:s,onPaymentMethodSelect:a,onPayment:o,onBack:l,error:c,theme:u="light",merchantName:h,transactionHash:d,walletConnection:p,onConnectWallet:f,testMode:g=!1,supportedNetworks:m=[],availableWallets:_={},supportedWallets:y=[],step:v="select-currency",merchantWalletAddresses:w={},debug:b=!1})=>{const[A,E]=e.useState("wallet"),x=t=>({ethereum:"Ethereum",bsc:"BSC",tron:"Tron",algorand:"Algorand"}[t]||t),k=t=>({[fd.METAMASK]:"MetaMask",[fd.TRONLINK]:"TronLink",[fd.TRUST_WALLET]:"Trust Wallet",[fd.LUTE]:"Lute Wallet"}[t]||t),S=t=>({[fd.METAMASK]:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT3ymr3UNKopfI0NmUY95Dr-0589vG-91KuAA&s",[fd.TRONLINK]:"https://www.tronlink.org/images/logo.png",[fd.TRUST_WALLET]:"https://trustwallet.com/assets/images/trust_logotype.svg",[fd.LUTE]:"https://lute.app/logo.png"}[t]||"");return t?Kd.jsx("div",{className:"fixed inset-0 z-50 overflow-y-auto bg-black/50",children:Kd.jsx("div",{className:"flex min-h-screen items-center justify-center p-4",children:Kd.jsxs("div",{className:"relative p-6 w-full max-w-md mx-auto rounded-lg shadow-xl bg-white text-gray-800",children:[Kd.jsxs("div",{className:"flex justify-between items-center mb-6 bg-[#F1ECFB] p-3 rounded-xl",children:[Kd.jsx("div",{className:"flex items-center",children:Kd.jsx("h2",{className:"text-xl font-bold text-gray-900",children:Kd.jsx("img",{src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJQAAAAkCAYAAABv9hOhAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAmVSURBVHgB7Vzdcdu4Fv5I+X2VCoK83pkb2xVc2ikgTgVWKog8twDJBexYrsBKBXYKWJtbQWRnZl+NrWC172txcQBQBA8B/kiKV87qm4FFgMAhAX48ODg4dISOGB4/XKsfObl9e+Y9n3wViHt3QHY5ud2fYId1caDSJyc/V+kMW4q4S2VFFurcCR0Oj+/H3kq9vSv1VyDDKX5s0Fh8VSlTifrcx/cByR046QRbjE6EQmnQok9aGzlQ+QRZluDHh1BJaWFNKsJApQvs0JlQc+e4jzgelqX1HNUczfHjQqCqkRLsUCWU0jL94buHE659LGQ5G51SfafAUcfZn572Sv63hKZL1u6lYeYpk9jBo6HieKysgmulbR6VAX7lEmuSHpLWkU5tIoVW+3q6cxEhdbOaqMcPF4gzNVVEI2VsJXi5oHE4d/JSpY/YwUOoRYkwA1qxWWPcIvtSlhDbc/FBWc5i+RbblR8ZsGaKzDIJPKV42Rir9EqlNzZJ7OCzoRZTlG0lTYalBlosbsr1o33zg4JQijBKm6V0WLgRtN1hm+DSaruXDq6x//XY4wX0oJWNo9R5VF61xL1rRY4jIsrw6F4iioQuz7JX5nz8Wh2bulGU0o+2kziZMqSTu7X9UwLGCBZOGWnEFOWXoQk0ZZ945FCS+D4QKN873W8Kv122Kv6Jfmns+QrJITl89+09cwH0LakOkS3OEPWuS42yrHiQiydjX8Q9IqVw6kjVdh1bI1FphPoV1RTGvpFryklVulTpJnD+jrX/aK9NeET5YR7Z+7lC+Jr0sD9gvQeeoF2/PjrXIfI9orxqpfEboxmkGFyn6yzsN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3BXQWEz3UNqoSquhCmJtTXbg4vjXDQFDjLtZD+pUjPQtA+F0021eRu/40NKz7ADtuMkB8urWtU/Yzq9u1UaQ+pow0WTzdV77hDlGgZgmuQLdT8HBmi1Hjfl3HnO2wbEhT2qWDniAeNIdD+z6jqQlXcuHL6MMHFYpEuDfYo2sSUtsPzQiDs6CQySTQgRldkWU6UKf+KRROxOaR4h5cF0kzk+pm2qdydUJF2D8yXH3NyPP21tf9dbYdOkDAOU3JFtF6R76EraO9PrfJC39hZv5NidG835b085Eb3qi4G/A2inrQKnVgMFAAAAABJRU5ErkJggg==",className:"w-32",alt:"Coinley Logo"})})}),Kd.jsx("button",{onClick:r,className:"text-gray-500 hover:text-gray-700 focus:outline-none",children:Kd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Kd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),Kd.jsxs("div",{className:"mb-6 bg-[#F1ECFB] p-3 rounded-xl",children:[n&&Kd.jsxs("div",{className:"mb-6 p-4 rounded-lg",children:[Kd.jsxs("p",{className:"text-lg text-gray-800 font-semibold",children:["PAY: ",h]}),Kd.jsxs("div",{className:"flex justify-between items-center mt-2 bg-gray-100 px-3 rounded-lg",children:[Kd.jsx("span",{className:"font-medium text-gray-700",children:"Amount:"}),Kd.jsxs("span",{className:"font-bold text-xl text-[#7042D2]",children:["$",(P=n.totalAmount||n.amount,parseFloat(P).toFixed(2))]})]}),Kd.jsx("div",{className:"text-xs mt-1 text-right",children:Kd.jsxs("span",{className:"text-gray-500",children:["Payment ID: ",n.id?n.id.slice(0,8):"","..."]})})]}),b&&Kd.jsx("div",{className:"mb-2 text-right",children:Kd.jsx("button",{onClick:()=>{console.log("=== DEBUG INFO ==="),console.log("Current step:",v),console.log("Payment method:",s),console.log("Wallet connection:",p),Ad()},className:"text-xs bg-gray-200 p-1 rounded",children:"Debug"})}),"select-currency"===v&&Kd.jsxs("div",{children:[Kd.jsx(Ap,{onSelect:a,selected:s,theme:u,supportedNetworks:m}),s&&Kd.jsx("div",{className:"mt-6",children:Kd.jsxs("button",{onClick:()=>{console.log("Proceed button clicked, calling onPaymentMethodSelect"),a(s)},className:"w-full py-3 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-lg transition-colors",disabled:!s,children:["Proceed with ",s.currency," on ",x(s.network)]})})]}),"confirm"===v&&s&&n&&Kd.jsxs("div",{children:[Kd.jsxs("div",{className:"p-4 rounded-lg mb-4 bg-gray-100",children:[Kd.jsx("h3",{className:"text-lg font-medium mb-2 text-gray-800",children:"Payment Details"}),Kd.jsxs("div",{className:"space-y-2",children:[Kd.jsxs("div",{className:"flex justify-between",children:[Kd.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Currency:"}),Kd.jsx("span",{className:"font-medium",children:s.currency})]}),Kd.jsxs("div",{className:"flex justify-between",children:[Kd.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Network:"}),Kd.jsx("span",{className:"font-medium",children:x(s.network)})]}),Kd.jsxs("div",{className:"flex justify-between",children:[Kd.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Fee:"}),Kd.jsx("span",{className:"font-medium",children:"1.75%"})]})]})]}),Kd.jsx("div",{className:"mb-4",children:Kd.jsxs("div",{className:"flex border-b border-gray-200",children:[Kd.jsx("button",{onClick:()=>E("wallet"),className:"py-2 px-4 text-sm font-medium "+("wallet"===A?"border-b-2 border-[#7042D2] text-[#7042D2]":"text-gray-500 hover:text-gray-700"),children:"Connect Wallet"}),Kd.jsx("button",{onClick:()=>E("qrcode"),className:"py-2 px-4 text-sm font-medium "+("qrcode"===A?"border-b-2 border-[#7042D2] text-[#7042D2]":"text-gray-500 hover:text-gray-700"),children:"QR Code"})]})}),g?Kd.jsx("div",{className:"p-4 rounded-lg mb-4 bg-blue-50",children:Kd.jsxs("div",{className:"flex items-center",children:[Kd.jsx("div",{className:"bg-[#7042D2] rounded-full p-2 mr-3",children:Kd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Kd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),Kd.jsxs("div",{children:[Kd.jsx("h3",{className:"font-medium text-gray-800",children:"Test Mode Payment"}),Kd.jsx("p",{className:"text-sm text-gray-600",children:'Click "Pay Now" to simulate a successful payment'})]})]})}):"qrcode"===A?Kd.jsx("div",{className:"mb-4",children:Kd.jsx(wp,{walletAddress:(()=>{if(!s)return"No network selected";const t=w[s.network];return t||((null==n?void 0:n.recipientWallet)?n.recipientWallet:"No wallet address configured for this network")})(),amount:n.totalAmount||n.amount,currency:s.currency,network:s.network,theme:u})}):Kd.jsxs("div",{className:"space-y-3 mb-4",children:[0===y.length?Kd.jsx("div",{className:"p-4 rounded-lg bg-yellow-50",children:Kd.jsxs("div",{className:"flex items-center",children:[Kd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 text-yellow-500 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Kd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),Kd.jsxs("div",{children:[Kd.jsx("h3",{className:"font-medium text-gray-800",children:"No Compatible Wallets"}),Kd.jsxs("p",{className:"text-sm text-gray-600",children:["No wallets detected for ",x(s.network)," network"]})]})]})}):y.map((t=>Kd.jsx("div",{className:"p-4 rounded-lg bg-blue-50",children:Kd.jsxs("div",{className:"flex items-center justify-between",children:[Kd.jsxs("div",{className:"flex items-center",children:[Kd.jsx("img",{src:S(t),alt:k(t),className:"w-8 h-8 mr-3",onError:t=>{t.target.style.display="none"}}),Kd.jsxs("div",{children:[Kd.jsx("h3",{className:"font-medium text-gray-800",children:k(t)}),Kd.jsxs("p",{className:"text-sm text-gray-600",children:["Pay with ",k(t)]})]})]}),(null==p?void 0:p.walletType)===t?Kd.jsxs("div",{className:"flex items-center space-x-2",children:[Kd.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),Kd.jsx("span",{className:"text-sm text-green-600",children:"Connected"})]}):Kd.jsx("button",{onClick:()=>{console.log("Connect wallet button clicked for:",t),f(t)},className:"py-2 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-md text-sm",children:"Connect"})]})},t))),Kd.jsx("div",{className:"space-y-2",children:Object.entries(_).filter((([t,e])=>!e)).map((([t])=>Kd.jsx("div",{className:"p-3 rounded-lg bg-gray-50",children:Kd.jsxs("div",{className:"flex items-center justify-between",children:[Kd.jsxs("span",{className:"text-sm text-gray-600",children:[k(t)," not detected"]}),Kd.jsx("a",{href:vd(t),target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#7042D2] hover:underline",children:"Install"})]})},t)))})]}),c&&Kd.jsx("div",{className:"p-3 rounded-lg bg-red-50 mb-4 text-red-600 text-sm",children:c}),Kd.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[Kd.jsx("button",{type:"button",onClick:l,className:"w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-[#7042D2] font-medium rounded-md",children:"Back"}),Kd.jsx("button",{type:"button",onClick:()=>o("qrcode"===A),className:"w-full py-2 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-md",disabled:!g&&"wallet"===A&&!p,children:"qrcode"===A?"I have sent the payment":"Pay Now"})]})]}),"processing"===v&&Kd.jsx(bp,{status:"processing",theme:u,message:"Processing your payment..."}),"success"===v&&Kd.jsxs("div",{children:[Kd.jsx(bp,{status:"success",theme:u,message:"Payment successful!"}),d&&Kd.jsxs("div",{className:"mt-4 p-3 rounded-lg bg-gray-100",children:[Kd.jsx("p",{className:"text-xs text-gray-600 mb-1",children:"Transaction Hash:"}),Kd.jsx("p",{className:"text-sm font-mono break-all text-gray-800",children:(N=d,N?N.length<=14?N:`${N.slice(0,8)}...${N.slice(-6)}`:"")}),s&&Kd.jsx("a",{href:`${xp(s.network)}/${kp(s.network)}/${d}`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#7042D2] mt-2 inline-block",children:"View on Explorer →"})]})]}),"error"===v&&Kd.jsxs("div",{children:[Kd.jsx(bp,{status:"error",theme:u,message:c||"An error occurred while processing your payment."}),Kd.jsx("button",{type:"button",onClick:l,className:"mt-4 w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-gray-800 font-medium rounded-md",children:"Try Again"})]})]}),Kd.jsx("div",{className:"text-center text-xs text-gray-500",children:Kd.jsxs("p",{children:["Powered by ",Kd.jsx("span",{className:"text-[#7042D2]",children:"Coinley"})," - Secure Cryptocurrency Payments"]})})]})})}):null;var N,P},xp=t=>({ethereum:"https://etherscan.io",bsc:"https://bscscan.com",tron:"https://tronscan.org",algorand:"https://algoexplorer.io"}[t]||"https://etherscan.io"),kp=t=>({ethereum:"tx",bsc:"tx",tron:"transaction",algorand:"tx"}[t]||"tx"),Sp=e.forwardRef((({apiKey:t,apiSecret:r,apiUrl:n,customerEmail:i,merchantName:s="Merchant",merchantWalletAddresses:a={},onSuccess:o,onError:l,onClose:c,theme:u,autoOpen:h=!1,debug:d=!1,testMode:p=!1,supportedNetworks:f=[],preferredNetwork:g=gd.ETHEREUM,preferredWallet:m=fd.METAMASK},_)=>{const y=Yd(),{theme:v}=e.useContext(qd),[w,b]=e.useState(h),[A,E]=e.useState(null),[x,k]=e.useState("idle"),[S,N]=e.useState(null),[P,C]=e.useState(null),[T,R]=e.useState(null),[G,M]=e.useState(null),[I,B]=e.useState({}),[O,F]=e.useState("select-currency");t||null==y||y.apiKey,r||null==y||y.apiSecret,n||null==y||y.apiUrl;const U=u||v,L=d||(null==y?void 0:y.debug),D=f.length>0?f:[gd.ETHEREUM,gd.BSC,gd.TRON,gd.ALGORAND];e.useImperativeHandle(_,(()=>({open:t=>{H(t)},close:()=>{W()},getPayment:()=>A,getWalletConnection:()=>G,debugWallets:()=>Ad()})));const j=(t,e)=>{L&&console.log(`[Coinley SDK] ${t}`,e)};e.useEffect((()=>{if("undefined"!=typeof window){(()=>__async(this,null,(function*(){const t=yield bd(3,1e3);B(t),j("Available wallets detected:",t)})))()}}),[L]);const H=t=>__async(this,null,(function*(){if(!t||!t.amount)return C("Payment amount is required"),void(l&&l(new Error("Payment amount is required")));k("loading"),b(!0),F("select-currency");try{j("Creating payment with details:",t);const e=yield Fd({amount:t.amount,currency:t.currency||"USDT",network:t.network||g,customerEmail:t.customerEmail||i,callbackUrl:t.callbackUrl,metadata:t.metadata||{},merchantWalletAddresses:__spreadValues(__spreadValues({},a),t.merchantWalletAddresses)});j("Payment created:",e),E(e.payment),k("idle"),C(null),j("Payment created and state updated")}catch(e){j("Error creating payment:",e),C(e.message||"Failed to create payment"),k("error"),l&&l(e)}})),W=()=>{b(!1),R(null),M(null),N(null),F("select-currency"),c&&c()};return Kd.jsx(Kd.Fragment,{children:w&&Kd.jsx(Ep,{isOpen:w,onClose:W,payment:A,paymentStatus:x,selectedPaymentMethod:S,onPaymentMethodSelect:t=>{console.log("=== PAYMENT METHOD SELECTION DEBUG ==="),console.log("1. Payment method selected:",t),console.log("2. Current step before:",O),j("Payment method selected:",t),N(t),F("confirm"),console.log("3. Step should now be: confirm"),console.log("=== END PAYMENT METHOD SELECTION DEBUG ===")},onPayment:()=>__async(this,null,(function*(){var t,e;if(A&&S)if(G||p){j("Starting payment process..."),k("loading"),R(null),F("processing");try{let r;if(p)j("Test mode: Generating mock transaction..."),r=`test_${Date.now().toString(16)}_${Math.random().toString(16).substring(2,10)}`;else{const n=a[S.network];if(!n)throw new Error(`No merchant wallet address configured for ${S.network}`);j("Sending transaction through wallet..."),r=yield Td(G,{to:n,amount:A.amount,tokenAddress:null==(t=S.tokenConfig)?void 0:t.address,tokenDecimals:null==(e=S.tokenConfig)?void 0:e.decimals,currency:S.currency,network:S.network})}j("Transaction hash:",r),R(r),j("Processing payment with backend...");const n=yield Ud({paymentId:A.id,transactionHash:r,network:S.network,currency:S.currency,senderAddress:null==G?void 0:G.address});j("Payment processed successfully:",n),k("success"),F("success"),o&&(j("Calling onSuccess callback..."),o(A.id,r,{network:S.network,currency:S.currency,amount:A.amount}))}catch(r){j("Payment error:",r),C(r.message||"Failed to process payment"),k("error"),F("error"),l&&l(r)}}else C("Please connect your wallet first");else C("Missing payment information")})),onBack:()=>{"confirm"===O?(F("select-currency"),M(null)):"error"===O&&F("confirm")},error:P,theme:U,merchantName:s,transactionHash:T,walletConnection:G,onConnectWallet:t=>__async(this,null,(function*(){if(console.log("=== WALLET CONNECTION DEBUG ==="),console.log("1. Wallet type requested:",t),console.log("2. Selected payment method:",S),console.log("3. Available wallets:",I),console.log("4. Current step:",O),!S)return console.error("No payment method selected"),void C("Please select a payment method first");try{console.log("5. Attempting to connect wallet..."),C(null),j("Connecting wallet:",{walletType:t,network:S.network});const e=yield Nd(t,S.network);M(e),C(null),console.log("6. Connection successful:",e),j("Wallet connected successfully:",e)}catch(e){console.error("7. Connection failed:",e),j("Wallet connection error:",e),C(e.message||"Failed to connect wallet")}console.log("=== END WALLET CONNECTION DEBUG ===")})),testMode:p,supportedNetworks:D,availableWallets:I,supportedWallets:S?Pd(S.network):[],step:O,merchantWalletAddresses:a,debug:L})})}));Sp.displayName="CoinleyCheckout";t.CoinleyCheckout=Sp,t.CoinleyModal=Ep,t.CoinleyProvider=({apiKey:t,apiSecret:r,apiUrl:n="http://localhost:9000",merchantWalletAddress:i=null,merchantSolWalletAddress:s=null,debug:a=!1,children:o})=>{const[l,c]=e.useState(!1),[u,h]=e.useState(null),[d,p]=e.useState(null);e.useEffect((()=>{var e;if(t&&r)try{e={apiKey:t,apiSecret:r,apiUrl:n,merchantWalletAddress:i,merchantSolWalletAddress:s},Bd=__spreadValues(__spreadValues({},Bd),e),console.log("API initialized with:",{apiUrl:Bd.apiUrl,apiKey:Bd.apiKey?`${Bd.apiKey.substring(0,6)}...`:null,hasWalletAddresses:Object.keys(Bd.merchantWalletAddresses||{}).length>0}),c(!0),a&&console.log("Coinley SDK initialized with:",{apiKey:t,apiUrl:n,merchantWalletAddress:i?`${i.substring(0,6)}...${i.substring(i.length-4)}`:"Not provided",merchantSolWalletAddress:s?`${s.substring(0,6)}...${s.substring(s.length-4)}`:"Not provided"})}catch(o){h(o.message),a&&console.error("Coinley SDK initialization error:",o)}else h("API key and secret are required")}),[t,r,n,i,s,a]);const f={apiKey:t,apiSecret:r,apiUrl:n,merchantWalletAddress:i,merchantSolWalletAddress:s,isInitialized:l,error:u,debug:a,paymentData:d,storePaymentData:t=>(p(t),t)};return Kd.jsx(Zd.Provider,{value:f,children:o})},t.DEFAULT_CONFIG={apiUrl:"http://localhost:9000",debug:!1,testMode:!1,theme:"light",supportedNetworks:["ethereum","bsc","tron","algorand"]},t.NETWORK_CONFIG=md,t.NETWORK_TYPES=gd,t.PaymentMethods=Ap,t.PaymentStatus=bp,t.QRCode=wp,t.TOKEN_CONFIG=_d,t.ThemeProvider=({initialTheme:t="light",children:r})=>{const[n,i]=e.useState(t);return e.useEffect((()=>{document.documentElement.classList.remove("light","dark"),document.documentElement.classList.add(n)}),[n]),Kd.jsx(qd.Provider,{value:{theme:n,setTheme:i,toggleTheme:()=>{i((t=>"light"===t?"dark":"light"))}},children:r})},t.WALLET_TYPES=fd,t.connectWallet=Nd,t.createPayment=Fd,t.detectWallets=wd,t.generateMockTransactionHash=(t="ethereum")=>`${{ethereum:"0x",bsc:"0x",tron:"",algorand:""}[t]||"0x"}${Array.from({length:64},(()=>Math.floor(16*Math.random()).toString(16))).join("")}`,t.getMerchantProfile=()=>__async(this,null,(function*(){try{const e=yield fetch(`${Bd.apiUrl}/api/merchants/profile`,{method:"GET",headers:Od()});if(!e.ok){let r;try{r=yield e.json()}catch(t){throw new Error(`Failed to get merchant profile: ${e.status} ${e.statusText}`)}throw new Error(r.error||`Failed to get merchant profile: ${e.status}`)}const r=yield e.json();return r.merchant&&r.merchant.walletAddresses&&(Bd.merchantWalletAddresses=__spreadValues(__spreadValues({},Bd.merchantWalletAddresses),r.merchant.walletAddresses)),r}catch(e){throw console.error("Get merchant profile error:",e),e}})),t.getPayment=t=>__async(this,null,(function*(){try{if(console.log("Getting payment:",t),!t)throw new Error("Payment ID is required");const r=yield fetch(`${Bd.apiUrl}/api/payments/${t}`,{method:"GET",headers:Od()});if(!r.ok){let t;try{t=yield r.json()}catch(e){throw new Error(`Failed to get payment: ${r.status} ${r.statusText}`)}throw console.error("Error getting payment:",t),new Error(t.error||`Failed to get payment: ${r.status}`)}const n=yield r.json();return console.log("Get payment response:",n),n}catch(r){throw console.error("Get payment error:",r),r}})),t.getSupportedNetworks=()=>__async(this,null,(function*(){try{const e=yield fetch(`${Bd.apiUrl}/api/networks`,{method:"GET",headers:Od()});if(!e.ok){let r;try{r=yield e.json()}catch(t){throw new Error(`Failed to get networks: ${e.status} ${e.statusText}`)}throw new Error(r.error||`Failed to get networks: ${e.status}`)}return yield e.json()}catch(e){throw console.error("Get supported networks error:",e),e}})),t.getSupportedWalletsForNetwork=Pd,t.getWalletInstallUrl=vd,t.processPayment=Ud,t.sendTransaction=Td,t.useCoinley=Yd,t.validateWalletAddress=(t,e)=>__async(this,null,(function*(){try{const n=yield fetch(`${Bd.apiUrl}/api/wallets/validate`,{method:"POST",headers:Od(),body:JSON.stringify({address:t,network:e})});if(!n.ok){let t;try{t=yield n.json()}catch(r){throw new Error(`Failed to validate address: ${n.status} ${n.statusText}`)}throw new Error(t.error||`Failed to validate address: ${n.status}`)}return yield n.json()}catch(n){throw console.error("Validate wallet address error:",n),n}})),Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
16
+ */function gp(t,e=0){const r=[];return t.forEach((function(t,n){let i=null;t.forEach((function(s,a){if(!s&&null!==i)return r.push(`M${i+e} ${n+e}h${a-i}v1H${i+e}z`),void(i=null);if(a!==t.length-1)s&&null===i&&(i=a);else{if(!s)return;null===i?r.push(`M${a+e},${n+e} h1v1H${a+e}z`):r.push(`M${i+e},${n+e} h${a+1-i}v1H${i+e}z`)}}))})),r.join("")}function mp(t,e){return t.slice().map(((t,r)=>r<e.y||r>=e.y+e.h?t:t.map(((t,r)=>(r<e.x||r>=e.x+e.w)&&t))))}function _p({value:t,level:r,minVersion:n,includeMargin:i,marginSize:s,imageSettings:a,size:o,boostLevel:l}){let c=e.useMemo((()=>{const e=(Array.isArray(t)?t:[t]).reduce(((t,e)=>(t.push(...op.QrSegment.makeSegments(e)),t)),[]);return op.QrCode.encodeSegments(e,lp[r],n,void 0,void 0,l)}),[t,r,n,l]);const{cells:u,margin:h,numCells:d,calculatedImageSettings:p}=e.useMemo((()=>{let t=c.getModules();const e=function(t,e){return null!=e?Math.max(Math.floor(e),0):t?4:0}(i,s),r=t.length+2*e,n=function(t,e,r,n){if(null==n)return null;const i=t.length+2*r,s=Math.floor(.1*e),a=i/e,o=(n.width||s)*a,l=(n.height||s)*a,c=null==n.x?t.length/2-o/2:n.x*a,u=null==n.y?t.length/2-l/2:n.y*a,h=null==n.opacity?1:n.opacity;let d=null;if(n.excavate){let t=Math.floor(c),e=Math.floor(u);d={x:t,y:e,w:Math.ceil(o+c-t),h:Math.ceil(l+u-e)}}return{x:c,y:u,h:l,w:o,excavation:d,opacity:h,crossOrigin:n.crossOrigin}}(t,o,e,a);return{cells:t,margin:e,numCells:r,calculatedImageSettings:n}}),[c,o,a,i,s]);return{qrcode:c,margin:h,cells:u,numCells:d,calculatedImageSettings:p}}var yp=function(){try{(new Path2D).addPath(new Path2D)}catch(t){return!1}return!0}();e.forwardRef((function(t,r){const n=t,{value:i,size:s=cp,level:a=up,bgColor:o=hp,fgColor:l=dp,includeMargin:c=pp,minVersion:u=fp,boostLevel:h,marginSize:d,imageSettings:p}=n,f=ap(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:g}=f,m=ap(f,["style"]),_=null==p?void 0:p.src,y=e.useRef(null),v=e.useRef(null),w=e.useCallback((t=>{y.current=t,"function"==typeof r?r(t):r&&(r.current=t)}),[r]),[b,A]=e.useState(!1),{margin:E,cells:x,numCells:k,calculatedImageSettings:S}=_p({value:i,level:a,minVersion:u,boostLevel:h,includeMargin:c,marginSize:d,imageSettings:p,size:s});e.useEffect((()=>{if(null!=y.current){const t=y.current,e=t.getContext("2d");if(!e)return;let r=x;const n=v.current,i=null!=S&&null!==n&&n.complete&&0!==n.naturalHeight&&0!==n.naturalWidth;i&&null!=S.excavation&&(r=mp(x,S.excavation));const a=window.devicePixelRatio||1;t.height=t.width=s*a;const c=s/k*a;e.scale(c,c),e.fillStyle=o,e.fillRect(0,0,k,k),e.fillStyle=l,yp?e.fill(new Path2D(gp(r,E))):x.forEach((function(t,r){t.forEach((function(t,n){t&&e.fillRect(n+E,r+E,1,1)}))})),S&&(e.globalAlpha=S.opacity),i&&e.drawImage(n,S.x+E,S.y+E,S.w,S.h)}})),e.useEffect((()=>{A(!1)}),[_]);const N=sp({height:s,width:s},g);let P=null;return null!=_&&(P=e.createElement("img",{src:_,key:_,style:{display:"none"},onLoad:()=>{A(!0)},ref:v,crossOrigin:null==S?void 0:S.crossOrigin})),e.createElement(e.Fragment,null,e.createElement("canvas",sp({style:N,height:s,width:s,ref:w,role:"img"},m)),P)})).displayName="QRCodeCanvas";var vp=e.forwardRef((function(t,r){const n=t,{value:i,size:s=cp,level:a=up,bgColor:o=hp,fgColor:l=dp,includeMargin:c=pp,minVersion:u=fp,boostLevel:h,title:d,marginSize:p,imageSettings:f}=n,g=ap(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:m,cells:_,numCells:y,calculatedImageSettings:v}=_p({value:i,level:a,minVersion:u,boostLevel:h,includeMargin:c,marginSize:p,imageSettings:f,size:s});let w=_,b=null;null!=f&&null!=v&&(null!=v.excavation&&(w=mp(_,v.excavation)),b=e.createElement("image",{href:f.src,height:v.h,width:v.w,x:v.x+m,y:v.y+m,preserveAspectRatio:"none",opacity:v.opacity,crossOrigin:v.crossOrigin}));const A=gp(w,m);return e.createElement("svg",sp({height:s,width:s,viewBox:`0 0 ${y} ${y}`,ref:r,role:"img"},g),!!d&&e.createElement("title",null,d),e.createElement("path",{fill:o,d:`M0,0 h${y}v${y}H0z`,shapeRendering:"crispEdges"}),e.createElement("path",{fill:l,d:A,shapeRendering:"crispEdges"}),b)}));vp.displayName="QRCodeSVG";const wp=({walletAddress:t,amount:r,currency:n,network:i,theme:s="light",size:a=200})=>{const[o,l]=e.useState(""),[c,u]=e.useState(null);e.useEffect((()=>{if(t&&"No address configured"!==t)try{let e;switch(i){case"tron":e="TRX"===n?`tronlink://transfer?to=${t}&amount=${r}`:t;break;case"algorand":e=`algorand://${t}?amount=${Math.floor(1e6*parseFloat(r))}`;break;case"bsc":if("BNB"===n)e=`ethereum:${t}@56?value=${p(r)}`;else{const i=h(n,"bsc");e=i?`ethereum:${i}/transfer?address=${t}&uint256=${d(r,n)}@56`:t}break;default:if("ETH"===n)e=`ethereum:${t}@1?value=${p(r)}`;else{const i=h(n,"ethereum");e=i?`ethereum:${i}/transfer?address=${t}&uint256=${d(r,n)}`:t}}l(e),u(null)}catch(e){console.error("Error generating QR code:",e),u("Error generating payment QR code")}else u("No wallet address configured for this network")}),[t,r,n,i]);const h=(t,e)=>{var r;return(null==(r={ethereum:{USDT:"0xdAC17F958D2ee523a2206206994597C13D831ec7",USDC:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},bsc:{USDT:"0x55d398326f99059fF775485246999027B3197955",USDC:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"},tron:{USDT:"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",USDC:"TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8"}}[e])?void 0:r[t])||""},d=(t,e)=>{const r="USDT"===e||"USDC"===e?6:18;return Math.floor(parseFloat(t)*Math.pow(10,r)).toString()},p=t=>Math.floor(1e18*parseFloat(t)).toString(),f=t=>({ethereum:"Ethereum",bsc:"BSC",tron:"Tron",algorand:"Algorand"}[t]||t);return Kd.jsxs("div",{className:"flex flex-col items-center",children:[c?Kd.jsxs("div",{className:"p-4 rounded-lg bg-red-100 mb-3 text-red-700 text-center",children:[Kd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 mx-auto mb-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Kd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),Kd.jsx("p",{className:"font-medium",children:c})]}):Kd.jsx("div",{className:"p-4 rounded-lg bg-white mb-3 shadow-sm border",children:o&&Kd.jsx(vp,{value:o,size:a,bgColor:"dark"===s?"#374151":"#FFFFFF",fgColor:"dark"===s?"#FFFFFF":"#000000",level:"H",includeMargin:!0})}),Kd.jsxs("div",{className:"text-center text-sm text-gray-700 mb-4",children:[Kd.jsxs("p",{className:"font-semibold text-gray-800 flex items-center justify-center",children:[Kd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Kd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v1m6 11h2m-6 0h-2v4m0-11v3m0 0h.01M12 12h4.01M12 12h-4.01M12 12V8.01"})}),"Scan to Pay with ",n]}),Kd.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Scan with your ",f(i)," wallet app"]})]}),Kd.jsxs("div",{className:"w-full mb-4 p-3 bg-gray-50 rounded-lg",children:[Kd.jsxs("div",{className:"flex justify-between items-center",children:[Kd.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Amount to Pay:"}),Kd.jsxs("span",{className:"text-lg font-bold text-[#7042D2]",children:[r," ",n]})]}),Kd.jsxs("div",{className:"flex justify-between items-center mt-1",children:[Kd.jsx("span",{className:"text-xs text-gray-500",children:"Network:"}),Kd.jsx("span",{className:"text-xs font-medium text-gray-700",children:f(i)})]})]}),!c&&Kd.jsxs("div",{className:"w-full mb-4",children:[Kd.jsx("p",{className:"text-xs text-gray-500 mb-1 text-center",children:"Or copy wallet address:"}),Kd.jsx("div",{className:"text-xs font-mono p-2 rounded bg-gray-100 text-gray-700 break-all text-center select-all cursor-pointer border",onClick:()=>{var e;return null==(e=navigator.clipboard)?void 0:e.writeText(t)},title:"Click to copy",children:t})]}),Kd.jsx("div",{className:"w-full",children:Kd.jsxs("div",{className:"p-3 rounded bg-blue-50 border border-blue-200",children:[Kd.jsxs("h4",{className:"text-sm font-medium mb-2 text-blue-800 flex items-center",children:[Kd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Kd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),"Payment Instructions"]}),Kd.jsxs("ol",{className:"text-xs space-y-1 text-blue-700",children:[Kd.jsxs("li",{children:["1. Open your crypto wallet app (",(g=i,{ethereum:["MetaMask","Trust Wallet","Coinbase Wallet"],bsc:["MetaMask","Trust Wallet","SafePal"],tron:["TronLink","Trust Wallet"],algorand:["Pera Wallet","MyAlgo Wallet"]}[g]||["MetaMask","Trust Wallet"]).join(", "),")"]}),Kd.jsx("li",{children:"2. Scan the QR code above or copy the wallet address"}),Kd.jsxs("li",{children:["3. Send exactly ",Kd.jsxs("strong",{children:[r," ",n]})," on ",f(i)," network"]}),Kd.jsx("li",{children:'4. Click "I have sent the payment" button below after sending'})]}),Kd.jsx("div",{className:"mt-3 p-2 bg-yellow-50 border border-yellow-200 rounded",children:Kd.jsxs("p",{className:"text-xs text-yellow-800",children:[Kd.jsx("strong",{children:"Important:"})," Make sure you're sending on the correct network (",f(i),") and using the exact amount shown above."]})})]})})]});var g},bp=({status:t,message:e,theme:r="light"})=>Kd.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[Kd.jsx("div",{className:"mb-4",children:(()=>{switch(t){case"processing":return Kd.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-4 border-t-blue-500 border-blue-500/20"});case"success":return Kd.jsx("div",{className:"rounded-full h-12 w-12 bg-green-100 flex items-center justify-center",children:Kd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 text-green-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:Kd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})});case"error":return Kd.jsx("div",{className:"rounded-full h-12 w-12 bg-red-100 flex items-center justify-center",children:Kd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:Kd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})});default:return null}})()}),Kd.jsx("h3",{className:"text-xl font-bold mb-2 "+("dark"===r?"text-white":"text-gray-900"),children:(()=>{switch(t){case"processing":return"Processing Payment";case"success":return"Payment Successful";case"error":return"Payment Failed";default:return"Unknown Status"}})()}),Kd.jsx("p",{className:`text-center ${(()=>{switch(t){case"processing":return"dark"===r?"text-blue-300":"text-blue-600";case"success":return"dark"===r?"text-green-300":"text-green-600";case"error":return"dark"===r?"text-red-300":"text-red-600";default:return"dark"===r?"text-gray-300":"text-gray-600"}})()}`,children:e}),"processing"===t&&Kd.jsx("div",{className:"mt-4 text-xs "+("dark"===r?"text-gray-400":"text-gray-500"),children:"This may take a few moments. Please do not close this window."}),"success"===t&&Kd.jsx("div",{className:"mt-4 p-2 rounded "+("dark"===r?"bg-gray-700":"bg-gray-100"),children:Kd.jsx("p",{className:"text-xs "+("dark"===r?"text-gray-300":"text-gray-600"),children:"Your payment has been successfully processed. You will receive a confirmation shortly."})})]}),Ap=({onSelect:t,selected:r,theme:n="light",supportedNetworks:i=[]})=>{const[s,a]=e.useState(gd.ETHEREUM),[o,l]=e.useState({}),[c,u]=e.useState(!1);e.useEffect((()=>{l(wd())}),[]);const h=[{id:gd.ETHEREUM,name:"Ethereum",description:"ERC-20 tokens"},{id:gd.BSC,name:"BSC (Binance Smart Chain)",description:"BEP-20 tokens"},{id:gd.TRON,name:"Tron",description:"TRC-20 tokens"},{id:gd.ALGORAND,name:"Algorand",description:"ASA tokens"}],d=(t=>{const e=[];switch(t){case gd.ETHEREUM:e.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:gd.ETHEREUM},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:gd.ETHEREUM},{id:"PYUSD",name:"PYUSD",description:"PayPal USD",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/28492.png",network:gd.ETHEREUM},{id:"FRAX",name:"FRAX",description:"Frax",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6952.png",network:gd.ETHEREUM},{id:"USDP",name:"USDP",description:"Pax Dollar",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6662.png",network:gd.ETHEREUM},{id:"DAI",name:"DAI",description:"Dai Stablecoin",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4943.png",network:gd.ETHEREUM},{id:"ETH",name:"ETH",description:"Ethereum",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTcyJyRKN0dRJWVZqoLzYgkRHdJsxKGq8nHUw&s",network:gd.ETHEREUM});break;case gd.BSC:e.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:gd.BSC},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:gd.BSC},{id:"BUSD",name:"BUSD",description:"Binance USD",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4687.png",network:gd.BSC},{id:"FRAX",name:"FRAX",description:"Frax",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6952.png",network:gd.BSC},{id:"BNB",name:"BNB",description:"Binance Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRHSjyW2sSnBhwztCwVW97i1BtV40g7heMMxg&s",network:gd.BSC});break;case gd.TRON:e.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:gd.TRON},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:gd.TRON},{id:"USDJ",name:"USDJ",description:"JUST Stablecoin",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/5446.png",network:gd.TRON},{id:"TRX",name:"TRX",description:"Tron",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQKLpLNsGRHbZfCUXAjZLPSp_YFZvX5dMnAoA&s",network:gd.TRON});break;case gd.ALGORAND:e.push({id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:gd.ALGORAND},{id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:gd.ALGORAND},{id:"ALGO",name:"ALGO",description:"Algorand",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4030.png",network:gd.ALGORAND})}return e})(s),p=c?d:d.slice(0,4);function f(t){switch(t){case gd.ETHEREUM:case gd.BSC:return fd.METAMASK;case gd.TRON:return fd.TRONLINK;case gd.ALGORAND:return fd.LUTE;default:return fd.METAMASK}}return Kd.jsxs("div",{children:[Kd.jsx("h3",{className:"text-lg font-medium mb-4 "+("dark"===n?"text-white":"text-gray-800"),children:"Select Payment Method"}),Kd.jsxs("div",{className:"mb-6",children:[Kd.jsx("label",{className:"block text-sm font-medium mb-2 "+("dark"===n?"text-white":"text-gray-700"),children:"Blockchain Network"}),Kd.jsx("select",{value:s,onChange:e=>{return n=e.target.value,a(n),u(!1),void((null==r?void 0:r.network)!==n&&t(null));var n},className:`w-full p-3 rounded-lg border transition-colors ${"dark"===n?"bg-gray-700 border-gray-600 text-white focus:border-[#7042D2]":"bg-white border-gray-300 text-gray-900 focus:border-[#7042D2]"} focus:outline-none focus:ring-2 focus:ring-[#7042D2] focus:ring-opacity-50`,children:h.filter((t=>0===i.length||i.includes(t.id))).map((t=>Kd.jsxs("option",{value:t.id,children:[t.name," - ",t.description]},t.id)))})]}),Kd.jsxs("div",{className:"mb-4",children:[Kd.jsx("label",{className:"block text-sm font-medium mb-3 "+("dark"===n?"text-white":"text-gray-700"),children:"Choose Cryptocurrency"}),Kd.jsx("div",{className:"grid grid-cols-2 gap-3 mb-4",children:p.map((e=>Kd.jsx("button",{onClick:()=>(e=>{var r;t({currency:e.id,network:s,tokenConfig:null==(r=_d[e.id])?void 0:r[s],method:e})})(e),className:"p-4 rounded-lg transition-all duration-200 border-2 "+((null==r?void 0:r.currency)===e.id&&(null==r?void 0:r.network)===s?"dark"===n?"bg-blue-900/30 border-[#7042D2] ring-2 ring-[#7042D2] ring-opacity-50":"bg-blue-50 border-[#7042D2] ring-2 ring-[#7042D2] ring-opacity-50":"dark"===n?"bg-gray-700 hover:bg-gray-600 border-gray-600 hover:border-gray-500":"bg-white hover:bg-gray-50 border-gray-200 hover:border-gray-300"),children:Kd.jsxs("div",{className:"flex flex-col items-center text-center",children:[Kd.jsx("div",{className:"flex-shrink-0 h-10 w-10 bg-white rounded-full flex items-center justify-center mb-2 shadow-sm",children:Kd.jsx("img",{src:e.logo,alt:e.name,className:"h-6 w-6"})}),Kd.jsxs("div",{children:[Kd.jsx("h4",{className:"font-medium text-sm "+("dark"===n?"text-white":"text-gray-900"),children:e.name}),Kd.jsx("p",{className:"text-xs "+("dark"===n?"text-gray-300":"text-gray-500"),children:e.description})]}),(null==r?void 0:r.currency)===e.id&&(null==r?void 0:r.network)===s&&Kd.jsx("div",{className:"mt-2",children:Kd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-[#7042D2]",viewBox:"0 0 20 20",fill:"currentColor",children:Kd.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})})]})},`${e.id}-${e.network}`)))}),d.length>4&&Kd.jsx("button",{onClick:()=>u(!c),className:"w-full py-2 px-4 rounded-lg text-sm font-medium transition-colors "+("dark"===n?"bg-gray-700 text-gray-300 hover:bg-gray-600":"bg-gray-100 text-gray-600 hover:bg-gray-200"),children:c?"Show Less":`Show More (${d.length-4} more)`})]}),Kd.jsx("div",{className:"p-3 rounded-lg text-sm "+("dark"===n?"bg-gray-800 text-gray-300":"bg-gray-50 text-gray-600"),children:Kd.jsxs("div",{className:"flex items-center",children:[Kd.jsx("div",{className:"w-2 h-2 rounded-full mr-2 "+(o[f(s)]?"bg-green-500":"bg-red-500")}),Kd.jsx("span",{className:"text-xs",children:function(t){const e=f(t),r=o[e],n={[fd.METAMASK]:"MetaMask",[fd.TRONLINK]:"TronLink",[fd.TRUST_WALLET]:"Trust Wallet",[fd.LUTE]:"Lute Wallet"};return r?`${n[e]} detected - Ready to pay`:`${n[e]} required - Please install to continue`}(s)})]})})]})},Ep=({isOpen:t,onClose:r,payment:n,paymentStatus:i,selectedPaymentMethod:s,onPaymentMethodSelect:a,onPayment:o,onBack:l,error:c,theme:u="light",merchantName:h,transactionHash:d,walletConnection:p,onConnectWallet:f,testMode:g=!1,supportedNetworks:m=[],availableWallets:_={},supportedWallets:y=[],step:v="select-currency",merchantWalletAddresses:w={},debug:b=!1})=>{const[A,E]=e.useState("wallet"),x=t=>({ethereum:"Ethereum",bsc:"BSC",tron:"Tron",algorand:"Algorand"}[t]||t),k=t=>({[fd.METAMASK]:"MetaMask",[fd.TRONLINK]:"TronLink",[fd.TRUST_WALLET]:"Trust Wallet",[fd.LUTE]:"Lute Wallet"}[t]||t),S=t=>({[fd.METAMASK]:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT3ymr3UNKopfI0NmUY95Dr-0589vG-91KuAA&s",[fd.TRONLINK]:"https://www.tronlink.org/images/logo.png",[fd.TRUST_WALLET]:"https://trustwallet.com/assets/images/trust_logotype.svg",[fd.LUTE]:"https://lute.app/logo.png"}[t]||"");return t?Kd.jsx("div",{className:"fixed inset-0 z-50 overflow-y-auto bg-black/50",children:Kd.jsx("div",{className:"flex min-h-screen items-center justify-center p-4",children:Kd.jsxs("div",{className:"relative p-6 w-full max-w-md mx-auto rounded-lg shadow-xl bg-white text-gray-800",children:[Kd.jsxs("div",{className:"flex justify-between items-center mb-6 bg-[#F1ECFB] p-3 rounded-xl",children:[Kd.jsx("div",{className:"flex items-center",children:Kd.jsx("h2",{className:"text-xl font-bold text-gray-900",children:Kd.jsx("img",{src:"data:image/png;base64,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IdD+z6jqQlXcuHL6MMHFYpEuDfYo2sSUtsPzQiDs6CQySTQgRldkWU6UKf+KRROxOaR4h5cF0kzk+pm2qdydUJF2D8yXH3NyPP21tf9dbYdOkDAOU3JFtF6R76EraO9PrfJC39hZv5NidG835b085Eb3qi4G/A2inrQKnVgMFAAAAABJRU5ErkJggg==",className:"w-32",alt:"Coinley Logo"})})}),Kd.jsx("button",{onClick:r,className:"text-gray-500 hover:text-gray-700 focus:outline-none",children:Kd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Kd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),Kd.jsxs("div",{className:"mb-6 bg-[#F1ECFB] p-3 rounded-xl",children:[n&&Kd.jsxs("div",{className:"mb-6 p-4 rounded-lg",children:[Kd.jsxs("p",{className:"text-lg text-gray-800 font-semibold",children:["PAY: ",h]}),Kd.jsxs("div",{className:"flex justify-between items-center mt-2 bg-gray-100 px-3 rounded-lg",children:[Kd.jsx("span",{className:"font-medium text-gray-700",children:"Amount:"}),Kd.jsxs("span",{className:"font-bold text-xl text-[#7042D2]",children:["$",(P=n.totalAmount||n.amount,parseFloat(P).toFixed(2))]})]}),Kd.jsx("div",{className:"text-xs mt-1 text-right",children:Kd.jsxs("span",{className:"text-gray-500",children:["Payment ID: ",n.id?n.id.slice(0,8):"","..."]})})]}),b&&Kd.jsx("div",{className:"mb-2 text-right",children:Kd.jsx("button",{onClick:()=>{console.log("=== DEBUG INFO ==="),console.log("Current step:",v),console.log("Payment method:",s),console.log("Wallet connection:",p),Ad()},className:"text-xs bg-gray-200 p-1 rounded",children:"Debug"})}),"select-currency"===v&&Kd.jsxs("div",{children:[Kd.jsx(Ap,{onSelect:a,selected:s,theme:u,supportedNetworks:m}),s&&Kd.jsx("div",{className:"mt-6",children:Kd.jsxs("button",{onClick:()=>{console.log("Proceed button clicked, calling onPaymentMethodSelect"),a(s)},className:"w-full py-3 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-lg transition-colors",disabled:!s,children:["Proceed with ",s.currency," on ",x(s.network)]})})]}),"confirm"===v&&s&&n&&Kd.jsxs("div",{children:[Kd.jsxs("div",{className:"p-4 rounded-lg mb-4 bg-gray-100",children:[Kd.jsx("h3",{className:"text-lg font-medium mb-2 text-gray-800",children:"Payment Details"}),Kd.jsxs("div",{className:"space-y-2",children:[Kd.jsxs("div",{className:"flex justify-between",children:[Kd.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Currency:"}),Kd.jsx("span",{className:"font-medium",children:s.currency})]}),Kd.jsxs("div",{className:"flex justify-between",children:[Kd.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Network:"}),Kd.jsx("span",{className:"font-medium",children:x(s.network)})]}),Kd.jsxs("div",{className:"flex justify-between",children:[Kd.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Fee:"}),Kd.jsx("span",{className:"font-medium",children:"1.75%"})]})]})]}),Kd.jsx("div",{className:"mb-4",children:Kd.jsxs("div",{className:"flex border-b border-gray-200",children:[Kd.jsx("button",{onClick:()=>E("wallet"),className:"py-2 px-4 text-sm font-medium "+("wallet"===A?"border-b-2 border-[#7042D2] text-[#7042D2]":"text-gray-500 hover:text-gray-700"),children:"Connect Wallet"}),Kd.jsx("button",{onClick:()=>E("qrcode"),className:"py-2 px-4 text-sm font-medium "+("qrcode"===A?"border-b-2 border-[#7042D2] text-[#7042D2]":"text-gray-500 hover:text-gray-700"),children:"QR Code"})]})}),g?Kd.jsx("div",{className:"p-4 rounded-lg mb-4 bg-blue-50",children:Kd.jsxs("div",{className:"flex items-center",children:[Kd.jsx("div",{className:"bg-[#7042D2] rounded-full p-2 mr-3",children:Kd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Kd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),Kd.jsxs("div",{children:[Kd.jsx("h3",{className:"font-medium text-gray-800",children:"Test Mode Payment"}),Kd.jsx("p",{className:"text-sm text-gray-600",children:'Click "Pay Now" to simulate a successful payment'})]})]})}):"qrcode"===A?Kd.jsx("div",{className:"mb-4",children:Kd.jsx(wp,{walletAddress:(()=>{if(!s)return"No network selected";const t=w[s.network];return t||((null==n?void 0:n.recipientWallet)?n.recipientWallet:"No wallet address configured for this network")})(),amount:n.totalAmount||n.amount,currency:s.currency,network:s.network,theme:u})}):Kd.jsxs("div",{className:"space-y-3 mb-4",children:[0===y.length?Kd.jsx("div",{className:"p-4 rounded-lg bg-yellow-50",children:Kd.jsxs("div",{className:"flex items-center",children:[Kd.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 text-yellow-500 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Kd.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),Kd.jsxs("div",{children:[Kd.jsx("h3",{className:"font-medium text-gray-800",children:"No Compatible Wallets"}),Kd.jsxs("p",{className:"text-sm text-gray-600",children:["No wallets detected for ",x(s.network)," network"]})]})]})}):y.map((t=>Kd.jsx("div",{className:"p-4 rounded-lg bg-blue-50",children:Kd.jsxs("div",{className:"flex items-center justify-between",children:[Kd.jsxs("div",{className:"flex items-center",children:[Kd.jsx("img",{src:S(t),alt:k(t),className:"w-8 h-8 mr-3",onError:t=>{t.target.style.display="none"}}),Kd.jsxs("div",{children:[Kd.jsx("h3",{className:"font-medium text-gray-800",children:k(t)}),Kd.jsxs("p",{className:"text-sm text-gray-600",children:["Pay with ",k(t)]})]})]}),(null==p?void 0:p.walletType)===t?Kd.jsxs("div",{className:"flex items-center space-x-2",children:[Kd.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),Kd.jsx("span",{className:"text-sm text-green-600",children:"Connected"})]}):Kd.jsx("button",{onClick:()=>{console.log("Connect wallet button clicked for:",t),f(t)},className:"py-2 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-md text-sm",children:"Connect"})]})},t))),Kd.jsx("div",{className:"space-y-2",children:Object.entries(_).filter((([t,e])=>!e)).map((([t])=>Kd.jsx("div",{className:"p-3 rounded-lg bg-gray-50",children:Kd.jsxs("div",{className:"flex items-center justify-between",children:[Kd.jsxs("span",{className:"text-sm text-gray-600",children:[k(t)," not detected"]}),Kd.jsx("a",{href:vd(t),target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#7042D2] hover:underline",children:"Install"})]})},t)))})]}),c&&Kd.jsx("div",{className:"p-3 rounded-lg bg-red-50 mb-4 text-red-600 text-sm",children:c}),Kd.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[Kd.jsx("button",{type:"button",onClick:l,className:"w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-[#7042D2] font-medium rounded-md",children:"Back"}),Kd.jsx("button",{type:"button",onClick:()=>o("qrcode"===A),className:"w-full py-2 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-md",disabled:!g&&"wallet"===A&&!p,children:"qrcode"===A?"I have sent the payment":"Pay Now"})]})]}),"processing"===v&&Kd.jsx(bp,{status:"processing",theme:u,message:"Processing your payment..."}),"success"===v&&Kd.jsxs("div",{children:[Kd.jsx(bp,{status:"success",theme:u,message:"Payment successful!"}),d&&Kd.jsxs("div",{className:"mt-4 p-3 rounded-lg bg-gray-100",children:[Kd.jsx("p",{className:"text-xs text-gray-600 mb-1",children:"Transaction Hash:"}),Kd.jsx("p",{className:"text-sm font-mono break-all text-gray-800",children:(N=d,N?N.length<=14?N:`${N.slice(0,8)}...${N.slice(-6)}`:"")}),s&&Kd.jsx("a",{href:`${xp(s.network)}/${kp(s.network)}/${d}`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#7042D2] mt-2 inline-block",children:"View on Explorer →"})]})]}),"error"===v&&Kd.jsxs("div",{children:[Kd.jsx(bp,{status:"error",theme:u,message:c||"An error occurred while processing your payment."}),Kd.jsx("button",{type:"button",onClick:l,className:"mt-4 w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-gray-800 font-medium rounded-md",children:"Try Again"})]})]}),Kd.jsx("div",{className:"text-center text-xs text-gray-500",children:Kd.jsxs("p",{children:["Powered by ",Kd.jsx("span",{className:"text-[#7042D2]",children:"Coinley"})," - Secure Cryptocurrency Payments"]})})]})})}):null;var N,P},xp=t=>({ethereum:"https://etherscan.io",bsc:"https://bscscan.com",tron:"https://tronscan.org",algorand:"https://algoexplorer.io"}[t]||"https://etherscan.io"),kp=t=>({ethereum:"tx",bsc:"tx",tron:"transaction",algorand:"tx"}[t]||"tx"),Sp=e.forwardRef((({apiKey:t,apiSecret:r,apiUrl:n,customerEmail:i,merchantName:s="Merchant",merchantWalletAddresses:a={},onSuccess:o,onError:l,onClose:c,theme:u,autoOpen:h=!1,debug:d=!1,testMode:p=!1,supportedNetworks:f=[],preferredNetwork:g=gd.ETHEREUM,preferredWallet:m=fd.METAMASK},_)=>{const y=Yd(),{theme:v}=e.useContext(qd),[w,b]=e.useState(h),[A,E]=e.useState(null),[x,k]=e.useState("idle"),[S,N]=e.useState(null),[P,C]=e.useState(null),[T,R]=e.useState(null),[G,M]=e.useState(null),[I,B]=e.useState({}),[O,F]=e.useState("select-currency");t||null==y||y.apiKey,r||null==y||y.apiSecret,n||null==y||y.apiUrl;const U=u||v,L=d||(null==y?void 0:y.debug),D=f.length>0?f:[gd.ETHEREUM,gd.BSC,gd.TRON,gd.ALGORAND];e.useImperativeHandle(_,(()=>({open:t=>{H(t)},close:()=>{W()},getPayment:()=>A,getWalletConnection:()=>G,debugWallets:()=>Ad()})));const j=(t,e)=>{L&&console.log(`[Coinley SDK] ${t}`,e)};e.useEffect((()=>{if("undefined"!=typeof window){(()=>__async(this,null,(function*(){const t=yield bd(3,1e3);B(t),j("Available wallets detected:",t)})))()}}),[L]);const H=t=>__async(this,null,(function*(){if(!t||!t.amount)return C("Payment amount is required"),void(l&&l(new Error("Payment amount is required")));k("loading"),b(!0),F("select-currency");try{j("Creating payment with details:",t);const e=yield Fd({amount:t.amount,currency:t.currency||"USDT",network:t.network||g,customerEmail:t.customerEmail||i,callbackUrl:t.callbackUrl,metadata:t.metadata||{},merchantWalletAddresses:__spreadValues(__spreadValues({},a),t.merchantWalletAddresses)});j("Payment created:",e),E(e.payment),k("idle"),C(null),j("Payment created and state updated")}catch(e){j("Error creating payment:",e),C(e.message||"Failed to create payment"),k("error"),l&&l(e)}})),W=()=>{b(!1),R(null),M(null),N(null),F("select-currency"),c&&c()};return Kd.jsx(Kd.Fragment,{children:w&&Kd.jsx(Ep,{isOpen:w,onClose:W,payment:A,paymentStatus:x,selectedPaymentMethod:S,onPaymentMethodSelect:t=>{console.log("=== PAYMENT METHOD SELECTION DEBUG ==="),console.log("1. Payment method selected:",t),console.log("2. Current step before:",O),j("Payment method selected:",t),N(t),F("confirm"),console.log("3. Step should now be: confirm"),console.log("=== END PAYMENT METHOD SELECTION DEBUG ===")},onPayment:()=>__async(this,null,(function*(){var t,e;if(A&&S)if(G||p){j("Starting payment process..."),k("loading"),R(null),F("processing");try{let r;if(p)j("Test mode: Generating mock transaction..."),r=`test_${Date.now().toString(16)}_${Math.random().toString(16).substring(2,10)}`;else{const n=a[S.network];if(!n)throw new Error(`No merchant wallet address configured for ${S.network}`);j("Sending transaction through wallet..."),r=yield Td(G,{to:n,amount:A.amount,tokenAddress:null==(t=S.tokenConfig)?void 0:t.address,tokenDecimals:null==(e=S.tokenConfig)?void 0:e.decimals,currency:S.currency,network:S.network})}j("Transaction hash:",r),R(r),j("Processing payment with backend...");const n=yield Ud({paymentId:A.id,transactionHash:r,network:S.network,currency:S.currency,senderAddress:null==G?void 0:G.address});j("Payment processed successfully:",n),k("success"),F("success"),o&&(j("Calling onSuccess callback..."),o(A.id,r,{network:S.network,currency:S.currency,amount:A.amount}))}catch(r){j("Payment error:",r),C(r.message||"Failed to process payment"),k("error"),F("error"),l&&l(r)}}else C("Please connect your wallet first");else C("Missing payment information")})),onBack:()=>{"confirm"===O?(F("select-currency"),M(null)):"error"===O&&F("confirm")},error:P,theme:U,merchantName:s,transactionHash:T,walletConnection:G,onConnectWallet:t=>__async(this,null,(function*(){if(console.log("=== WALLET CONNECTION DEBUG ==="),console.log("1. Wallet type requested:",t),console.log("2. Selected payment method:",S),console.log("3. Available wallets:",I),console.log("4. Current step:",O),!S)return console.error("No payment method selected"),void C("Please select a payment method first");try{console.log("5. Attempting to connect wallet..."),C(null),j("Connecting wallet:",{walletType:t,network:S.network});const e=yield Nd(t,S.network);M(e),C(null),console.log("6. Connection successful:",e),j("Wallet connected successfully:",e)}catch(e){console.error("7. Connection failed:",e),j("Wallet connection error:",e),C(e.message||"Failed to connect wallet")}console.log("=== END WALLET CONNECTION DEBUG ===")})),testMode:p,supportedNetworks:D,availableWallets:I,supportedWallets:S?Pd(S.network):[],step:O,merchantWalletAddresses:a,debug:L})})}));Sp.displayName="CoinleyCheckout";t.CoinleyCheckout=Sp,t.CoinleyModal=Ep,t.CoinleyProvider=({apiKey:t,apiSecret:r,apiUrl:n="https://coinleyserver-production.up.railway.app",merchantWalletAddress:i=null,merchantSolWalletAddress:s=null,debug:a=!1,children:o})=>{const[l,c]=e.useState(!1),[u,h]=e.useState(null),[d,p]=e.useState(null);e.useEffect((()=>{var e;if(t&&r)try{e={apiKey:t,apiSecret:r,apiUrl:n,merchantWalletAddress:i,merchantSolWalletAddress:s},Bd=__spreadValues(__spreadValues({},Bd),e),console.log("API initialized with:",{apiUrl:Bd.apiUrl,apiKey:Bd.apiKey?`${Bd.apiKey.substring(0,6)}...`:null,hasWalletAddresses:Object.keys(Bd.merchantWalletAddresses||{}).length>0}),c(!0),a&&console.log("Coinley SDK initialized with:",{apiKey:t,apiUrl:n,merchantWalletAddress:i?`${i.substring(0,6)}...${i.substring(i.length-4)}`:"Not provided",merchantSolWalletAddress:s?`${s.substring(0,6)}...${s.substring(s.length-4)}`:"Not provided"})}catch(o){h(o.message),a&&console.error("Coinley SDK initialization error:",o)}else h("API key and secret are required")}),[t,r,n,i,s,a]);const f={apiKey:t,apiSecret:r,apiUrl:n,merchantWalletAddress:i,merchantSolWalletAddress:s,isInitialized:l,error:u,debug:a,paymentData:d,storePaymentData:t=>(p(t),t)};return Kd.jsx(Zd.Provider,{value:f,children:o})},t.DEFAULT_CONFIG={apiUrl:"https://coinleyserver-production.up.railway.app",debug:!1,testMode:!1,theme:"light",supportedNetworks:["ethereum","bsc","tron","algorand"]},t.NETWORK_CONFIG=md,t.NETWORK_TYPES=gd,t.PaymentMethods=Ap,t.PaymentStatus=bp,t.QRCode=wp,t.TOKEN_CONFIG=_d,t.ThemeProvider=({initialTheme:t="light",children:r})=>{const[n,i]=e.useState(t);return e.useEffect((()=>{document.documentElement.classList.remove("light","dark"),document.documentElement.classList.add(n)}),[n]),Kd.jsx(qd.Provider,{value:{theme:n,setTheme:i,toggleTheme:()=>{i((t=>"light"===t?"dark":"light"))}},children:r})},t.WALLET_TYPES=fd,t.connectWallet=Nd,t.createPayment=Fd,t.detectWallets=wd,t.generateMockTransactionHash=(t="ethereum")=>`${{ethereum:"0x",bsc:"0x",tron:"",algorand:""}[t]||"0x"}${Array.from({length:64},(()=>Math.floor(16*Math.random()).toString(16))).join("")}`,t.getMerchantProfile=()=>__async(this,null,(function*(){try{const e=yield fetch(`${Bd.apiUrl}/api/merchants/profile`,{method:"GET",headers:Od()});if(!e.ok){let r;try{r=yield e.json()}catch(t){throw new Error(`Failed to get merchant profile: ${e.status} ${e.statusText}`)}throw new Error(r.error||`Failed to get merchant profile: ${e.status}`)}const r=yield e.json();return r.merchant&&r.merchant.walletAddresses&&(Bd.merchantWalletAddresses=__spreadValues(__spreadValues({},Bd.merchantWalletAddresses),r.merchant.walletAddresses)),r}catch(e){throw console.error("Get merchant profile error:",e),e}})),t.getPayment=t=>__async(this,null,(function*(){try{if(console.log("Getting payment:",t),!t)throw new Error("Payment ID is required");const r=yield fetch(`${Bd.apiUrl}/api/payments/${t}`,{method:"GET",headers:Od()});if(!r.ok){let t;try{t=yield r.json()}catch(e){throw new Error(`Failed to get payment: ${r.status} ${r.statusText}`)}throw console.error("Error getting payment:",t),new Error(t.error||`Failed to get payment: ${r.status}`)}const n=yield r.json();return console.log("Get payment response:",n),n}catch(r){throw console.error("Get payment error:",r),r}})),t.getSupportedNetworks=()=>__async(this,null,(function*(){try{const e=yield fetch(`${Bd.apiUrl}/api/networks`,{method:"GET",headers:Od()});if(!e.ok){let r;try{r=yield e.json()}catch(t){throw new Error(`Failed to get networks: ${e.status} ${e.statusText}`)}throw new Error(r.error||`Failed to get networks: ${e.status}`)}return yield e.json()}catch(e){throw console.error("Get supported networks error:",e),e}})),t.getSupportedWalletsForNetwork=Pd,t.getWalletInstallUrl=vd,t.processPayment=Ud,t.sendTransaction=Td,t.useCoinley=Yd,t.validateWalletAddress=(t,e)=>__async(this,null,(function*(){try{const n=yield fetch(`${Bd.apiUrl}/api/wallets/validate`,{method:"POST",headers:Od(),body:JSON.stringify({address:t,network:e})});if(!n.ok){let t;try{t=yield n.json()}catch(r){throw new Error(`Failed to validate address: ${n.status} ${n.statusText}`)}throw new Error(t.error||`Failed to validate address: ${n.status}`)}return yield n.json()}catch(n){throw console.error("Validate wallet address error:",n),n}})),Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
17
17
  //# sourceMappingURL=coinley-checkout.umd.js.map