coinley-checkout 0.4.4 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/coinley-checkout.es.js +6339 -16902
- package/dist/coinley-checkout.es.js.map +1 -1
- package/dist/coinley-checkout.umd.js +3 -12
- package/dist/coinley-checkout.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
@@ -1,17 +1,8 @@
|
|
1
|
-
var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__reflectGet=Reflect.get,__pow=Math.pow,__defNormalProp=(t,e,r)=>e in t?__defProp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,__spreadValues=(t,e)=>{for(var r in e||(e={}))__hasOwnProp.call(e,r)&&__defNormalProp(t,r,e[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(e))__propIsEnum.call(e,r)&&__defNormalProp(t,r,e[r]);return t},__spreadProps=(t,e)=>__defProps(t,__getOwnPropDescs(e)),__publicField=(t,e,r)=>(__defNormalProp(t,"symbol"!=typeof e?e+"":e,r),r),__accessCheck=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},__privateGet=(t,e,r)=>(__accessCheck(t,e,"read from private field"),r?r.call(t):e.get(t)),__privateAdd=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},__privateSet=(t,e,r,n)=>(__accessCheck(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),__privateWrapper=(t,e,r,n)=>({set _(n){__privateSet(t,e,n,r)},get _(){return __privateGet(t,e,n)}}),__privateMethod=(t,e,r)=>(__accessCheck(t,e,"access private method"),r),__superGet=(t,e,r)=>__reflectGet(__getProtoOf(t),r,e),__async=(t,e,r)=>new Promise(((n,i)=>{var s=t=>{try{o(r.next(t))}catch(e){i(e)}},a=t=>{try{o(r.throw(t))}catch(e){i(e)}},o=t=>t.done?n(t.value):Promise.resolve(t.value).then(s,a);o((r=r.apply(t,e)).next())}));!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).CoinleyCheckout={},t.React)}(this,(function(t,e){var r,n,i,s,a,o,l,c,u,h,d,p,f,g,m,_,y,v,w,b,A,E,x,k,S,N,P,C,T,R,G,M,I,B,O,F,U,L,D,j,H,W,Q,z,V,J,K,q,Z,Y,X,$,tt,et,rt,nt,it,st,at,ot,lt,ct,ut,ht,dt,pt,ft,gt,mt,_t,yt,vt,wt,bt,At,Et,xt,kt,St,Nt,Pt,Ct,Tt,Rt,Gt,Mt,It,Bt,Ot,Ft,Ut,Lt,Dt,jt,Ht,Wt,Qt,zt,Vt,Jt,Kt,qt,Zt,Yt,Xt,$t,te,ee,re,ne,ie,se,ae,oe,le,ce,ue,he,de,pe,fe,ge,me,_e,ye,ve,we,be,Ae,Ee,xe,ke,Se,Ne,Pe,Ce,Te,Re,Ge,Me,Ie,Be,Oe,Fe,Ue,Le,De,je,He,We,Qe,ze,Ve,Je,Ke,qe,Ze,Ye,Xe,$e,tr,er,rr,nr,ir,sr,ar,or,lr,cr,ur,hr,dr,pr,fr,gr,mr,_r,yr,vr,wr,br,Ar,Er,xr,kr,Sr,Nr;function Pr(t,e,r){const n=e.split("|").map((t=>t.trim()));for(let s=0;s<n.length;s++)switch(e){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof t===e)return}const i=new Error(`invalid value for type ${e}`);throw i.code="INVALID_ARGUMENT",i.argument=`value.${r}`,i.value=t,i}function Cr(t){return __async(this,null,(function*(){const e=Object.keys(t);return(yield Promise.all(e.map((e=>Promise.resolve(t[e]))))).reduce(((t,r,n)=>(t[e[n]]=r,t)),{})}))}function Tr(t,e,r){for(let n in e){let i=e[n];const s=r?r[n]:null;s&&Pr(i,s,n),Object.defineProperty(t,n,{enumerable:!0,value:i,writable:!1})}}function Rr(t,e){if(null==t)return"null";if(null==e&&(e=new Set),"object"==typeof t){if(e.has(t))return"[Circular]";e.add(t)}if(Array.isArray(t))return"[ "+t.map((t=>Rr(t,e))).join(", ")+" ]";if(t instanceof Uint8Array){const e="0123456789abcdef";let r="0x";for(let n=0;n<t.length;n++)r+=e[t[n]>>4],r+=e[15&t[n]];return r}if("object"==typeof t&&"function"==typeof t.toJSON)return Rr(t.toJSON(),e);switch(typeof t){case"boolean":case"number":case"symbol":return t.toString();case"bigint":return BigInt(t).toString();case"string":return JSON.stringify(t);case"object":{const r=Object.keys(t);return r.sort(),"{ "+r.map((r=>`${Rr(r,e)}: ${Rr(t[r],e)}`)).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function Gr(t,e){return t&&t.code===e}function Mr(t){return Gr(t,"CALL_EXCEPTION")}function Ir(t,e,r){let n,i=t;{const n=[];if(r){if("message"in r||"code"in r||"name"in r)throw new Error(`value will overwrite populated values: ${Rr(r)}`);for(const t in r){if("shortMessage"===t)continue;const e=r[t];n.push(t+"="+Rr(e))}}n.push(`code=${e}`),n.push("version=6.14.3"),n.length&&(t+=" ("+n.join(", ")+")")}switch(e){case"INVALID_ARGUMENT":n=new TypeError(t);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":n=new RangeError(t);break;default:n=new Error(t)}return Tr(n,{code:e}),r&&Object.assign(n,r),null==n.shortMessage&&Tr(n,{shortMessage:i}),n}function Br(t,e,r,n){if(!t)throw Ir(e,r,n)}function Or(t,e,r,n){Br(t,e,"INVALID_ARGUMENT",{argument:r,value:n})}function Fr(t,e,r){null==r&&(r=""),r&&(r=": "+r),Br(t>=e,"missing argument"+r,"MISSING_ARGUMENT",{count:t,expectedCount:e}),Br(t<=e,"too many arguments"+r,"UNEXPECTED_ARGUMENT",{count:t,expectedCount:e})}const Ur=["NFD","NFC","NFKD","NFKC"].reduce(((t,e)=>{try{if("test"!=="test".normalize(e))throw new Error("bad");if("NFD"===e){const t=String.fromCharCode(233).normalize("NFD");if(t!==String.fromCharCode(101,769))throw new Error("broken")}t.push(e)}catch(r){}return t}),[]);function Lr(t,e,r){if(null==r&&(r=""),t!==e){let t=r,e="new";r&&(t+=".",e+=" "+r),Br(!1,`private constructor; use ${t}from* methods`,"UNSUPPORTED_OPERATION",{operation:e})}}function Dr(t,e,r){if(t instanceof Uint8Array)return r?new Uint8Array(t):t;if("string"==typeof t&&t.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const e=new Uint8Array((t.length-2)/2);let r=2;for(let n=0;n<e.length;n++)e[n]=parseInt(t.substring(r,r+2),16),r+=2;return e}Or(!1,"invalid BytesLike value",e||"value",t)}function jr(t,e){return Dr(t,e,!1)}function Hr(t,e){return Dr(t,e,!0)}function Wr(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(("number"!=typeof e||t.length===2+2*e)&&(!0!==e||t.length%2==0))}function Qr(t){return Wr(t,!0)||t instanceof Uint8Array}const zr="0123456789abcdef";function Vr(t){const e=jr(t);let r="0x";for(let n=0;n<e.length;n++){const t=e[n];r+=zr[(240&t)>>4]+zr[15&t]}return r}function Jr(t){return"0x"+t.map((t=>Vr(t).substring(2))).join("")}function Kr(t){return Wr(t,!0)?(t.length-2)/2:jr(t).length}function qr(t,e,r){const n=jr(t);return null!=r&&r>n.length&&Br(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:r}),Vr(n.slice(null==e?0:e,null==r?n.length:r))}function Zr(t,e,r){const n=jr(t);Br(e>=n.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(n),length:e,offset:e+1});const i=new Uint8Array(e);return i.fill(0),r?i.set(n,e-n.length):i.set(n,0),Vr(i)}function Yr(t,e){return Zr(t,e,!0)}const Xr=BigInt(0),$r=BigInt(1),tn=9007199254740991;function en(t,e){const r=an(t,"value"),n=BigInt(cn(e,"width"));if(Br(r>>n===Xr,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:t}),r>>n-$r){return-((~r&($r<<n)-$r)+$r)}return r}function rn(t,e){let r=sn(t,"value");const n=BigInt(cn(e,"width")),i=$r<<n-$r;if(r<Xr){r=-r,Br(r<=i,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t});return(~r&($r<<n)-$r)+$r}return Br(r<i,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t}),r}function nn(t,e){const r=an(t,"value"),n=BigInt(cn(e,"bits"));return r&($r<<n)-$r}function sn(t,e){switch(typeof t){case"bigint":return t;case"number":return Or(Number.isInteger(t),"underflow",e||"value",t),Or(t>=-tn&&t<=tn,"overflow",e||"value",t),BigInt(t);case"string":try{if(""===t)throw new Error("empty string");return"-"===t[0]&&"-"!==t[1]?-BigInt(t.substring(1)):BigInt(t)}catch(r){Or(!1,`invalid BigNumberish string: ${r.message}`,e||"value",t)}}Or(!1,"invalid BigNumberish value",e||"value",t)}function an(t,e){const r=sn(t,e);return Br(r>=Xr,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:t}),r}const on="0123456789abcdef";function ln(t){if(t instanceof Uint8Array){let e="0x0";for(const r of t)e+=on[r>>4],e+=on[15&r];return BigInt(e)}return sn(t)}function cn(t,e){switch(typeof t){case"bigint":return Or(t>=-tn&&t<=tn,"overflow",e||"value",t),Number(t);case"number":return Or(Number.isInteger(t),"underflow",e||"value",t),Or(t>=-tn&&t<=tn,"overflow",e||"value",t),t;case"string":try{if(""===t)throw new Error("empty string");return cn(BigInt(t),e)}catch(r){Or(!1,`invalid numeric string: ${r.message}`,e||"value",t)}}Or(!1,"invalid numeric value",e||"value",t)}function un(t,e){let r=an(t,"value").toString(16);if(null==e)r.length%2&&(r="0"+r);else{const n=cn(e,"width");for(Br(2*n>=r.length,`value exceeds width (${n} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:t});r.length<2*n;)r="0"+r}return"0x"+r}function hn(t){const e=an(t,"value");if(e===Xr)return new Uint8Array([]);let r=e.toString(16);r.length%2&&(r="0"+r);const n=new Uint8Array(r.length/2);for(let i=0;i<n.length;i++){const t=2*i;n[i]=parseInt(r.substring(t,t+2),16)}return n}function dn(t){let e=Vr(Qr(t)?t:hn(t)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return""===e&&(e="0"),"0x"+e}const pn="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const fn=BigInt(58);class gn{constructor(t,e,n){__publicField(this,"filter"),__publicField(this,"emitter"),__privateAdd(this,r,void 0),__privateSet(this,r,e),Tr(this,{emitter:t,filter:n})}removeListener(){return __async(this,null,(function*(){null!=__privateGet(this,r)&&(yield this.emitter.off(this.filter,__privateGet(this,r)))}))}}function mn(t,e,r,n,i){if("BAD_PREFIX"===t||"UNEXPECTED_CONTINUE"===t){let t=0;for(let n=e+1;n<r.length&&r[n]>>6==2;n++)t++;return t}return"OVERRUN"===t?r.length-e-1:0}r=new WeakMap;const _n=Object.freeze({error:function(t,e,r,n,i){Or(!1,`invalid codepoint at offset ${e}; ${t}`,"bytes",r)},ignore:mn,replace:function(t,e,r,n,i){return"OVERLONG"===t?(Or("number"==typeof i,"invalid bad code point for replacement","badCodepoint",i),n.push(i),0):(n.push(65533),mn(t,e,r))}});function yn(t,e){Or("string"==typeof t,"invalid string value","str",t),null!=e&&(!function(t){Br(Ur.indexOf(t)>=0,"platform missing String.prototype.normalize","UNSUPPORTED_OPERATION",{operation:"String.prototype.normalize",info:{form:t}})}(e),t=t.normalize(e));let r=[];for(let n=0;n<t.length;n++){const e=t.charCodeAt(n);if(e<128)r.push(e);else if(e<2048)r.push(e>>6|192),r.push(63&e|128);else if(55296==(64512&e)){n++;const i=t.charCodeAt(n);Or(n<t.length&&56320==(64512&i),"invalid surrogate pair","str",t);const s=65536+((1023&e)<<10)+(1023&i);r.push(s>>18|240),r.push(s>>12&63|128),r.push(s>>6&63|128),r.push(63&s|128)}else r.push(e>>12|224),r.push(e>>6&63|128),r.push(63&e|128)}return new Uint8Array(r)}function vn(t,e){return r=function(t,e){null==e&&(e=_n.error);const r=jr(t,"bytes"),n=[];let i=0;for(;i<r.length;){const t=r[i++];if(!(t>>7)){n.push(t);continue}let s=null,a=null;if(192==(224&t))s=1,a=127;else if(224==(240&t))s=2,a=2047;else{if(240!=(248&t)){i+=e(128==(192&t)?"UNEXPECTED_CONTINUE":"BAD_PREFIX",i-1,r,n);continue}s=3,a=65535}if(i-1+s>=r.length){i+=e("OVERRUN",i-1,r,n);continue}let o=t&(1<<8-s-1)-1;for(let l=0;l<s;l++){let t=r[i];if(128!=(192&t)){i+=e("MISSING_CONTINUE",i,r,n),o=null;break}o=o<<6|63&t,i++}null!==o&&(o>1114111?i+=e("OUT_OF_RANGE",i-1-s,r,n,o):o>=55296&&o<=57343?i+=e("UTF16_SURROGATE",i-1-s,r,n,o):o<=a?i+=e("OVERLONG",i-1-s,r,n,o):n.push(o))}return n}(t,e),r.map((t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t))))).join("");var r}function wn(t){return function(e,r){return __async(this,null,(function*(){Br(null==r||!r.cancelled,"request cancelled before sending","CANCELLED");const n=e.url.split(":")[0].toLowerCase();Br("http"===n||"https"===n,`unsupported protocol ${n}`,"UNSUPPORTED_OPERATION",{info:{protocol:n},operation:"request"}),Br("https"===n||!e.credentials||e.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"});let i=null;const s=new AbortController,a=setTimeout((()=>{i=Ir("request timeout","TIMEOUT"),s.abort()}),e.timeout);r&&r.addListener((()=>{i=Ir("request cancelled","CANCELLED"),s.abort()}));const o=Object.assign({},t,{method:e.method,headers:new Headers(Array.from(e)),body:e.body||void 0,signal:s.signal});let l;try{l=yield fetch(e.url,o)}catch(d){if(clearTimeout(a),i)throw i;throw d}clearTimeout(a);const c={};l.headers.forEach(((t,e)=>{c[e.toLowerCase()]=t}));const u=yield l.arrayBuffer(),h=null==u?null:new Uint8Array(u);return{statusCode:l.status,statusMessage:l.statusText,headers:c,body:h}}))}}let bn=wn();const An=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),En=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let xn=!1;function kn(t,e){return __async(this,null,(function*(){try{const e=t.match(An);if(!e)throw new Error("invalid data");return new In(200,"OK",{"content-type":e[1]||"text/plain"},e[2]?function(t){t=atob(t);const e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return jr(e)}(e[3]):yn(e[3].replace(/%([0-9a-f][0-9a-f])/gi,((t,e)=>String.fromCharCode(parseInt(e,16))))))}catch(e){return new In(599,"BAD REQUEST (invalid data: URI)",{},null,new Gn(t))}}))}function Sn(t){return function(e,r){return __async(this,null,(function*(){try{const r=e.match(En);if(!r)throw new Error("invalid link");return new Gn(`${t}${r[2]}`)}catch(r){return new In(599,"BAD REQUEST (invalid IPFS URI)",{},null,new Gn(e))}}))}}const Nn={data:kn,ipfs:Sn("https://gateway.ipfs.io/ipfs/")},Pn=new WeakMap;class Cn{constructor(t){__privateAdd(this,n,void 0),__privateAdd(this,i,void 0),__privateSet(this,n,[]),__privateSet(this,i,!1),Pn.set(t,(()=>{if(!__privateGet(this,i)){__privateSet(this,i,!0);for(const t of __privateGet(this,n))setTimeout((()=>{t()}),0);__privateSet(this,n,[])}}))}addListener(t){Br(!__privateGet(this,i),"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),__privateGet(this,n).push(t)}get cancelled(){return __privateGet(this,i)}checkSignal(){Br(!this.cancelled,"cancelled","CANCELLED",{})}}function Tn(t){if(null==t)throw new Error("missing signal; should not happen");return t.checkSignal(),t}n=new WeakMap,i=new WeakMap;const Rn=class t{constructor(t){__privateAdd(this,w),__privateAdd(this,s,void 0),__privateAdd(this,a,void 0),__privateAdd(this,o,void 0),__privateAdd(this,l,void 0),__privateAdd(this,c,void 0),__privateAdd(this,u,void 0),__privateAdd(this,h,void 0),__privateAdd(this,d,void 0),__privateAdd(this,p,void 0),__privateAdd(this,f,void 0),__privateAdd(this,g,void 0),__privateAdd(this,m,void 0),__privateAdd(this,_,void 0),__privateAdd(this,y,void 0),__privateAdd(this,v,void 0),__privateSet(this,u,String(t)),__privateSet(this,s,!1),__privateSet(this,a,!0),__privateSet(this,o,{}),__privateSet(this,l,""),__privateSet(this,c,3e5),__privateSet(this,y,{slotInterval:250,maxAttempts:12}),__privateSet(this,v,null)}get url(){return __privateGet(this,u)}set url(t){__privateSet(this,u,String(t))}get body(){return null==__privateGet(this,h)?null:new Uint8Array(__privateGet(this,h))}set body(t){if(null==t)__privateSet(this,h,void 0),__privateSet(this,d,void 0);else if("string"==typeof t)__privateSet(this,h,yn(t)),__privateSet(this,d,"text/plain");else if(t instanceof Uint8Array)__privateSet(this,h,t),__privateSet(this,d,"application/octet-stream");else{if("object"!=typeof t)throw new Error("invalid body");__privateSet(this,h,yn(JSON.stringify(t))),__privateSet(this,d,"application/json")}}hasBody(){return null!=__privateGet(this,h)}get method(){return __privateGet(this,l)?__privateGet(this,l):this.hasBody()?"POST":"GET"}set method(t){null==t&&(t=""),__privateSet(this,l,String(t).toUpperCase())}get headers(){const t=Object.assign({},__privateGet(this,o));return __privateGet(this,p)&&(t.authorization=`Basic ${function(t){const e=jr(t);let r="";for(let n=0;n<e.length;n++)r+=String.fromCharCode(e[n]);return btoa(r)}(yn(__privateGet(this,p)))}`),this.allowGzip&&(t["accept-encoding"]="gzip"),null==t["content-type"]&&__privateGet(this,d)&&(t["content-type"]=__privateGet(this,d)),this.body&&(t["content-length"]=String(this.body.length)),t}getHeader(t){return this.headers[t.toLowerCase()]}setHeader(t,e){__privateGet(this,o)[String(t).toLowerCase()]=String(e)}clearHeaders(){__privateSet(this,o,{})}[Symbol.iterator](){const t=this.headers,e=Object.keys(t);let r=0;return{next:()=>{if(r<e.length){const n=e[r++];return{value:[n,t[n]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return __privateGet(this,p)||null}setCredentials(t,e){Or(!t.match(/:/),"invalid basic authentication username","username","[REDACTED]"),__privateSet(this,p,`${t}:${e}`)}get allowGzip(){return __privateGet(this,a)}set allowGzip(t){__privateSet(this,a,!!t)}get allowInsecureAuthentication(){return!!__privateGet(this,s)}set allowInsecureAuthentication(t){__privateSet(this,s,!!t)}get timeout(){return __privateGet(this,c)}set timeout(t){Or(t>=0,"timeout must be non-zero","timeout",t),__privateSet(this,c,t)}get preflightFunc(){return __privateGet(this,f)||null}set preflightFunc(t){__privateSet(this,f,t)}get processFunc(){return __privateGet(this,g)||null}set processFunc(t){__privateSet(this,g,t)}get retryFunc(){return __privateGet(this,m)||null}set retryFunc(t){__privateSet(this,m,t)}get getUrlFunc(){return __privateGet(this,v)||bn}set getUrlFunc(t){__privateSet(this,v,t)}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${__privateGet(this,h)?Vr(__privateGet(this,h)):"null"}>`}setThrottleParams(t){null!=t.slotInterval&&(__privateGet(this,y).slotInterval=t.slotInterval),null!=t.maxAttempts&&(__privateGet(this,y).maxAttempts=t.maxAttempts)}send(){return Br(null==__privateGet(this,_),"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),__privateSet(this,_,new Cn(this)),__privateMethod(this,w,b).call(this,0,Bn()+this.timeout,0,this,new In(0,"",{},null,this))}cancel(){Br(null!=__privateGet(this,_),"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const t=Pn.get(this);if(!t)throw new Error("missing signal; should not happen");t()}redirect(e){const r=this.url.split(":")[0].toLowerCase(),n=e.split(":")[0].toLowerCase();Br("GET"===this.method&&("https"!==r||"http"!==n)&&e.match(/^https?:/),"unsupported redirect","UNSUPPORTED_OPERATION",{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(e)})`});const i=new t(e);return i.method="GET",i.allowGzip=this.allowGzip,i.timeout=this.timeout,__privateSet(i,o,Object.assign({},__privateGet(this,o))),__privateGet(this,h)&&__privateSet(i,h,new Uint8Array(__privateGet(this,h))),__privateSet(i,d,__privateGet(this,d)),i}clone(){const e=new t(this.url);return __privateSet(e,l,__privateGet(this,l)),__privateGet(this,h)&&__privateSet(e,h,__privateGet(this,h)),__privateSet(e,d,__privateGet(this,d)),__privateSet(e,o,Object.assign({},__privateGet(this,o))),__privateSet(e,p,__privateGet(this,p)),this.allowGzip&&(e.allowGzip=!0),e.timeout=this.timeout,this.allowInsecureAuthentication&&(e.allowInsecureAuthentication=!0),__privateSet(e,f,__privateGet(this,f)),__privateSet(e,g,__privateGet(this,g)),__privateSet(e,m,__privateGet(this,m)),__privateSet(e,y,Object.assign({},__privateGet(this,y))),__privateSet(e,v,__privateGet(this,v)),e}static lockConfig(){xn=!0}static getGateway(t){return Nn[t.toLowerCase()]||null}static registerGateway(t,e){if("http"===(t=t.toLowerCase())||"https"===t)throw new Error(`cannot intercept ${t}; use registerGetUrl`);if(xn)throw new Error("gateways locked");Nn[t]=e}static registerGetUrl(t){if(xn)throw new Error("gateways locked");bn=t}static createGetUrlFunc(t){return wn(t)}static createDataGateway(){return kn}static createIpfsGatewayFunc(t){return Sn(t)}};s=new WeakMap,a=new WeakMap,o=new WeakMap,l=new WeakMap,c=new WeakMap,u=new WeakMap,h=new WeakMap,d=new WeakMap,p=new WeakMap,f=new WeakMap,g=new WeakMap,m=new WeakMap,_=new WeakMap,y=new WeakMap,v=new WeakMap,w=new WeakSet,b=function(t,e,r,n,i){return __async(this,null,(function*(){var s,a,o;if(t>=__privateGet(this,y).maxAttempts)return i.makeServerError("exceeded maximum retry limit");Br(Bn()<=e,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:n}),r>0&&(yield function(t){return new Promise((e=>setTimeout(e,t)))}(r));let l=this.clone();const c=(l.url.split(":")[0]||"").toLowerCase();if(c in Nn){const t=yield Nn[c](l.url,Tn(__privateGet(n,_)));if(t instanceof In){let e=t;if(this.processFunc){Tn(__privateGet(n,_));try{e=yield this.processFunc(l,e)}catch(d){null!=d.throttle&&"number"==typeof d.stall||e.makeServerError("error in post-processing function",d).assertOk()}}return e}l=t}this.preflightFunc&&(l=yield this.preflightFunc(l));const u=yield this.getUrlFunc(l,Tn(__privateGet(n,_)));let h=new In(u.statusCode,u.statusMessage,u.headers,u.body,n);if(301===h.statusCode||302===h.statusCode){try{const r=h.headers.location||"";return __privateMethod(s=l.redirect(r),w,b).call(s,t+1,e,0,n,h)}catch(d){}return h}if(429===h.statusCode&&(null==this.retryFunc||(yield this.retryFunc(l,h,t)))){const r=h.headers["retry-after"];let i=__privateGet(this,y).slotInterval*Math.trunc(Math.random()*Math.pow(2,t));return"string"==typeof r&&r.match(/^[1-9][0-9]*$/)&&(i=parseInt(r)),__privateMethod(a=l.clone(),w,b).call(a,t+1,e,i,n,h)}if(this.processFunc){Tn(__privateGet(n,_));try{h=yield this.processFunc(l,h)}catch(d){null!=d.throttle&&"number"==typeof d.stall||h.makeServerError("error in post-processing function",d).assertOk();let r=__privateGet(this,y).slotInterval*Math.trunc(Math.random()*Math.pow(2,t));return d.stall>=0&&(r=d.stall),__privateMethod(o=l.clone(),w,b).call(o,t+1,e,r,n,h)}}return h}))};let Gn=Rn;const Mn=class t{constructor(t,e,r,n,i){__privateAdd(this,A,void 0),__privateAdd(this,E,void 0),__privateAdd(this,x,void 0),__privateAdd(this,k,void 0),__privateAdd(this,S,void 0),__privateAdd(this,N,void 0),__privateSet(this,A,t),__privateSet(this,E,e),__privateSet(this,x,Object.keys(r).reduce(((t,e)=>(t[e.toLowerCase()]=String(r[e]),t)),{})),__privateSet(this,k,null==n?null:new Uint8Array(n)),__privateSet(this,S,i||null),__privateSet(this,N,{message:""})}toString(){return`<FetchResponse status=${this.statusCode} body=${__privateGet(this,k)?Vr(__privateGet(this,k)):"null"}>`}get statusCode(){return __privateGet(this,A)}get statusMessage(){return __privateGet(this,E)}get headers(){return Object.assign({},__privateGet(this,x))}get body(){return null==__privateGet(this,k)?null:new Uint8Array(__privateGet(this,k))}get bodyText(){try{return null==__privateGet(this,k)?"":vn(__privateGet(this,k))}catch(t){Br(!1,"response body is not valid UTF-8 data","UNSUPPORTED_OPERATION",{operation:"bodyText",info:{response:this}})}}get bodyJson(){try{return JSON.parse(this.bodyText)}catch(t){Br(!1,"response body is not valid JSON","UNSUPPORTED_OPERATION",{operation:"bodyJson",info:{response:this}})}}[Symbol.iterator](){const t=this.headers,e=Object.keys(t);let r=0;return{next:()=>{if(r<e.length){const n=e[r++];return{value:[n,t[n]],done:!1}}return{value:void 0,done:!0}}}}makeServerError(e,r){let n;n=e?`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${e})`:`CLIENT ESCALATED SERVER ERROR (${e=`${this.statusCode} ${this.statusMessage}`})`;const i=new t(599,n,this.headers,this.body,__privateGet(this,S)||void 0);return __privateSet(i,N,{message:e,error:r}),i}throwThrottleError(t,e){null==e?e=-1:Or(Number.isInteger(e)&&e>=0,"invalid stall timeout","stall",e);const r=new Error(t||"throttling requests");throw Tr(r,{stall:e,throttle:!0}),r}getHeader(t){return this.headers[t.toLowerCase()]}hasBody(){return null!=__privateGet(this,k)}get request(){return __privateGet(this,S)}ok(){return""===__privateGet(this,N).message&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:t,error:e}=__privateGet(this,N);""===t&&(t=`server response ${this.statusCode} ${this.statusMessage}`);let r=null;this.request&&(r=this.request.url);let n=null;try{__privateGet(this,k)&&(n=vn(__privateGet(this,k)))}catch(i){}Br(!1,t,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:e,info:{requestUrl:r,responseBody:n,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}};A=new WeakMap,E=new WeakMap,x=new WeakMap,k=new WeakMap,S=new WeakMap,N=new WeakMap;let In=Mn;function Bn(){return(new Date).getTime()}const On=BigInt(-1),Fn=BigInt(0),Un=BigInt(1),Ln=BigInt(5),Dn={};let jn="0000";for(;jn.length<80;)jn+=jn;function Hn(t){let e=jn;for(;e.length<t;)e+=e;return BigInt("1"+e.substring(0,t))}function Wn(t,e,r){const n=BigInt(e.width);if(e.signed){const e=Un<<n-Un;Br(null==r||t>=-e&&t<e,"overflow","NUMERIC_FAULT",{operation:r,fault:"overflow",value:t}),t=t>Fn?en(nn(t,n),n):-en(nn(-t,n),n)}else{const e=Un<<n;Br(null==r||t>=0&&t<e,"overflow","NUMERIC_FAULT",{operation:r,fault:"overflow",value:t}),t=(t%e+e)%e&e-Un}return t}function Qn(t){"number"==typeof t&&(t=`fixed128x${t}`);let e=!0,r=128,n=18;if("string"==typeof t)if("fixed"===t);else if("ufixed"===t)e=!1;else{const i=t.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);Or(i,"invalid fixed format","format",t),e="u"!==i[1],r=parseInt(i[2]),n=parseInt(i[3])}else if(t){const i=t,s=(t,e,r)=>null==i[t]?r:(Or(typeof i[t]===e,"invalid fixed format ("+t+" not "+e+")","format."+t,i[t]),i[t]);e=s("signed","boolean",e),r=s("width","number",r),n=s("decimals","number",n)}Or(r%8==0,"invalid FixedNumber width (not byte aligned)","format.width",r),Or(n<=80,"invalid FixedNumber decimals (too large)","format.decimals",n);return{signed:e,width:r,decimals:n,name:(e?"":"u")+"fixed"+String(r)+"x"+String(n)}}const zn=class t{constructor(t,e,r){__privateAdd(this,R),__privateAdd(this,M),__privateAdd(this,B),__privateAdd(this,F),__privateAdd(this,L),__privateAdd(this,j),__publicField(this,"format"),__privateAdd(this,P,void 0),__privateAdd(this,C,void 0),__privateAdd(this,T,void 0),__publicField(this,"_value"),Lr(t,Dn,"FixedNumber"),__privateSet(this,C,e),__privateSet(this,P,r);const n=function(t,e){let r="";t<Fn&&(r="-",t*=On);let n=t.toString();if(0===e)return r+n;for(;n.length<=e;)n=jn+n;const i=n.length-e;for(n=n.substring(0,i)+"."+n.substring(i);"0"===n[0]&&"."!==n[1];)n=n.substring(1);for(;"0"===n[n.length-1]&&"."!==n[n.length-2];)n=n.substring(0,n.length-1);return r+n}(e,r.decimals);Tr(this,{format:r.name,_value:n}),__privateSet(this,T,Hn(r.decimals))}get signed(){return __privateGet(this,P).signed}get width(){return __privateGet(this,P).width}get decimals(){return __privateGet(this,P).decimals}get value(){return __privateGet(this,C)}addUnsafe(t){return __privateMethod(this,B,O).call(this,t)}add(t){return __privateMethod(this,B,O).call(this,t,"add")}subUnsafe(t){return __privateMethod(this,F,U).call(this,t)}sub(t){return __privateMethod(this,F,U).call(this,t,"sub")}mulUnsafe(t){return __privateMethod(this,L,D).call(this,t)}mul(t){return __privateMethod(this,L,D).call(this,t,"mul")}mulSignal(t){__privateMethod(this,R,G).call(this,t);const e=__privateGet(this,C)*__privateGet(t,C);return Br(e%__privateGet(this,T)===Fn,"precision lost during signalling mul","NUMERIC_FAULT",{operation:"mulSignal",fault:"underflow",value:this}),__privateMethod(this,M,I).call(this,e/__privateGet(this,T),"mulSignal")}divUnsafe(t){return __privateMethod(this,j,H).call(this,t)}div(t){return __privateMethod(this,j,H).call(this,t,"div")}divSignal(t){Br(__privateGet(t,C)!==Fn,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),__privateMethod(this,R,G).call(this,t);const e=__privateGet(this,C)*__privateGet(this,T);return Br(e%__privateGet(t,C)===Fn,"precision lost during signalling div","NUMERIC_FAULT",{operation:"divSignal",fault:"underflow",value:this}),__privateMethod(this,M,I).call(this,e/__privateGet(t,C),"divSignal")}cmp(t){let e=this.value,r=t.value;const n=this.decimals-t.decimals;return n>0?r*=Hn(n):n<0&&(e*=Hn(-n)),e<r?-1:e>r?1:0}eq(t){return 0===this.cmp(t)}lt(t){return this.cmp(t)<0}lte(t){return this.cmp(t)<=0}gt(t){return this.cmp(t)>0}gte(t){return this.cmp(t)>=0}floor(){let t=__privateGet(this,C);return __privateGet(this,C)<Fn&&(t-=__privateGet(this,T)-Un),t=__privateGet(this,C)/__privateGet(this,T)*__privateGet(this,T),__privateMethod(this,M,I).call(this,t,"floor")}ceiling(){let t=__privateGet(this,C);return __privateGet(this,C)>Fn&&(t+=__privateGet(this,T)-Un),t=__privateGet(this,C)/__privateGet(this,T)*__privateGet(this,T),__privateMethod(this,M,I).call(this,t,"ceiling")}round(e){if(null==e&&(e=0),e>=this.decimals)return this;const r=this.decimals-e,n=Ln*Hn(r-1);let i=this.value+n;const s=Hn(r);return i=i/s*s,Wn(i,__privateGet(this,P),"round"),new t(Dn,i,__privateGet(this,P))}isZero(){return __privateGet(this,C)===Fn}isNegative(){return __privateGet(this,C)<Fn}toString(){return this._value}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return t.fromString(this.toString(),e)}static fromValue(e,r,n){const i=null==r?0:cn(r),s=Qn(n);let a=sn(e,"value");const o=i-s.decimals;if(o>0){const t=Hn(o);Br(a%t===Fn,"value loses precision for format","NUMERIC_FAULT",{operation:"fromValue",fault:"underflow",value:e}),a/=t}else o<0&&(a*=Hn(-o));return Wn(a,s,"fromValue"),new t(Dn,a,s)}static fromString(e,r){const n=e.match(/^(-?)([0-9]*)\.?([0-9]*)$/);Or(n&&n[2].length+n[3].length>0,"invalid FixedNumber string value","value",e);const i=Qn(r);let s=n[2]||"0",a=n[3]||"";for(;a.length<i.decimals;)a+=jn;Br(a.substring(i.decimals).match(/^0*$/),"too many decimals for format","NUMERIC_FAULT",{operation:"fromString",fault:"underflow",value:e}),a=a.substring(0,i.decimals);const o=BigInt(n[1]+s+a);return Wn(o,i,"fromString"),new t(Dn,o,i)}static fromBytes(e,r){let n=ln(jr(e,"value"));const i=Qn(r);return i.signed&&(n=en(n,i.width)),Wn(n,i,"fromBytes"),new t(Dn,n,i)}};P=new WeakMap,C=new WeakMap,T=new WeakMap,R=new WeakSet,G=function(t){Or(this.format===t.format,"incompatible format; use fixedNumber.toFormat","other",t)},M=new WeakSet,I=function(t,e){return t=Wn(t,__privateGet(this,P),e),new zn(Dn,t,__privateGet(this,P))},B=new WeakSet,O=function(t,e){return __privateMethod(this,R,G).call(this,t),__privateMethod(this,M,I).call(this,__privateGet(this,C)+__privateGet(t,C),e)},F=new WeakSet,U=function(t,e){return __privateMethod(this,R,G).call(this,t),__privateMethod(this,M,I).call(this,__privateGet(this,C)-__privateGet(t,C),e)},L=new WeakSet,D=function(t,e){return __privateMethod(this,R,G).call(this,t),__privateMethod(this,M,I).call(this,__privateGet(this,C)*__privateGet(t,C)/__privateGet(this,T),e)},j=new WeakSet,H=function(t,e){return Br(__privateGet(t,C)!==Fn,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),__privateMethod(this,R,G).call(this,t),__privateMethod(this,M,I).call(this,__privateGet(this,C)*__privateGet(this,T)/__privateGet(t,C),e)};let Vn=zn;function Jn(t){let e=t.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function Kn(t,e,r){let n=0;for(let i=0;i<r;i++)n=256*n+t[e+i];return n}function qn(t,e,r,n){const i=[];for(;r<e+1+n;){const s=Zn(t,r);i.push(s.result),Br((r+=s.consumed)<=e+1+n,"child data too short","BUFFER_OVERRUN",{buffer:t,length:n,offset:e})}return{consumed:1+n,result:i}}function Zn(t,e){Br(0!==t.length,"data too short","BUFFER_OVERRUN",{buffer:t,length:0,offset:1});const r=e=>{Br(e<=t.length,"data short segment too short","BUFFER_OVERRUN",{buffer:t,length:t.length,offset:e})};if(t[e]>=248){const n=t[e]-247;r(e+1+n);const i=Kn(t,e+1,n);return r(e+1+n+i),qn(t,e,e+1+n,n+i)}if(t[e]>=192){const n=t[e]-192;return r(e+1+n),qn(t,e,e+1,n)}if(t[e]>=184){const n=t[e]-183;r(e+1+n);const i=Kn(t,e+1,n);r(e+1+n+i);return{consumed:1+n+i,result:Vr(t.slice(e+1+n,e+1+n+i))}}if(t[e]>=128){const n=t[e]-128;r(e+1+n);return{consumed:1+n,result:Vr(t.slice(e+1,e+1+n))}}return{consumed:1,result:Jn(t[e])}}function Yn(t){const e=jr(t,"data"),r=Zn(e,0);return Or(r.consumed===e.length,"unexpected junk after rlp payload","data",t),r.result}function Xn(t){const e=[];for(;t;)e.unshift(255&t),t>>=8;return e}function $n(t){if(Array.isArray(t)){let e=[];if(t.forEach((function(t){e=e.concat($n(t))})),e.length<=55)return e.unshift(192+e.length),e;const r=Xn(e.length);return r.unshift(247+r.length),r.concat(e)}const e=Array.prototype.slice.call(jr(t,"object"));if(1===e.length&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const r=Xn(e.length);return r.unshift(183+r.length),r.concat(e)}const ti="0123456789abcdef";function ei(t){let e="0x";for(const r of $n(t))e+=ti[r>>4],e+=ti[15&r];return e}const ri=["wei","kwei","mwei","gwei","szabo","finney","ether"];function ni(t,e){Or("string"==typeof t,"value must be a string","value",t);let r=18;if("string"==typeof e){const t=ri.indexOf(e);Or(t>=0,"invalid unit","unit",e),r=3*t}else null!=e&&(r=cn(e,"unit"));return Vn.fromString(t,{decimals:r,width:512}).value}const ii=32,si=new Uint8Array(ii),ai=["then"],oi={},li=new WeakMap;function ci(t){return li.get(t)}function ui(t,e){li.set(t,e)}function hi(t,e){const r=new Error(`deferred error during ABI decoding triggered accessing ${t}`);throw r.error=e,r}function di(t,e,r){return t.indexOf(null)>=0?e.map(((t,e)=>t instanceof pi?di(ci(t),t,r):t)):t.reduce(((t,n,i)=>{let s=e.getValue(n);return n in t||(r&&s instanceof pi&&(s=di(ci(s),s,r)),t[n]=s),t}),{})}W=new WeakMap;let pi=class t extends Array{constructor(...t){const e=t[0];let r=t[1],n=(t[2]||[]).slice(),i=!0;e!==oi&&(r=t,n=[],i=!1),super(r.length),__privateAdd(this,W,void 0),r.forEach(((t,e)=>{this[e]=t}));const s=n.reduce(((t,e)=>("string"==typeof e&&t.set(e,(t.get(e)||0)+1),t)),new Map);if(ui(this,Object.freeze(r.map(((t,e)=>{const r=n[e];return null!=r&&1===s.get(r)?r:null})))),__privateSet(this,W,[]),null==__privateGet(this,W)&&__privateGet(this,W),!i)return;Object.freeze(this);const a=new Proxy(this,{get:(t,e,r)=>{if("string"==typeof e){if(e.match(/^[0-9]+$/)){const r=cn(e,"%index");if(r<0||r>=this.length)throw new RangeError("out of result range");const n=t[r];return n instanceof Error&&hi(`index ${r}`,n),n}if(ai.indexOf(e)>=0)return Reflect.get(t,e,r);const n=t[e];if(n instanceof Function)return function(...e){return n.apply(this===r?t:this,e)};if(!(e in t))return t.getValue.apply(this===r?t:this,[e])}return Reflect.get(t,e,r)}});return ui(a,ci(this)),a}toArray(e){const r=[];return this.forEach(((n,i)=>{n instanceof Error&&hi(`index ${i}`,n),e&&n instanceof t&&(n=n.toArray(e)),r.push(n)})),r}toObject(t){const e=ci(this);return e.reduce(((r,n,i)=>(Br(null!=n,`value at index ${i} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),di(e,this,t))),{})}slice(e,r){null==e&&(e=0),e<0&&(e+=this.length)<0&&(e=0),null==r&&(r=this.length),r<0&&(r+=this.length)<0&&(r=0),r>this.length&&(r=this.length);const n=ci(this),i=[],s=[];for(let t=e;t<r;t++)i.push(this[t]),s.push(n[t]);return new t(oi,i,s)}filter(e,r){const n=ci(this),i=[],s=[];for(let t=0;t<this.length;t++){const a=this[t];a instanceof Error&&hi(`index ${t}`,a),e.call(r,a,t,this)&&(i.push(a),s.push(n[t]))}return new t(oi,i,s)}map(t,e){const r=[];for(let n=0;n<this.length;n++){const i=this[n];i instanceof Error&&hi(`index ${n}`,i),r.push(t.call(e,i,n,this))}return r}getValue(t){const e=ci(this).indexOf(t);if(-1===e)return;const r=this[e];return r instanceof Error&&hi(`property ${JSON.stringify(t)}`,r.error),r}static fromItems(e,r){return new t(oi,e,r)}};function fi(t){let e=hn(t);return Br(e.length<=ii,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:ii,offset:e.length}),e.length!==ii&&(e=Hr(Jr([si.slice(e.length%ii),e]))),e}class gi{constructor(t,e,r,n){__publicField(this,"name"),__publicField(this,"type"),__publicField(this,"localName"),__publicField(this,"dynamic"),Tr(this,{name:t,type:e,localName:r,dynamic:n},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(t,e){Or(!1,t,this.localName,e)}}class mi{constructor(){__privateAdd(this,V),__privateAdd(this,Q,void 0),__privateAdd(this,z,void 0),__privateSet(this,Q,[]),__privateSet(this,z,0)}get data(){return Jr(__privateGet(this,Q))}get length(){return __privateGet(this,z)}appendWriter(t){return __privateMethod(this,V,J).call(this,Hr(t.data))}writeBytes(t){let e=Hr(t);const r=e.length%ii;return r&&(e=Hr(Jr([e,si.slice(r)]))),__privateMethod(this,V,J).call(this,e)}writeValue(t){return __privateMethod(this,V,J).call(this,fi(t))}writeUpdatableValue(){const t=__privateGet(this,Q).length;return __privateGet(this,Q).push(si),__privateSet(this,z,__privateGet(this,z)+ii),e=>{__privateGet(this,Q)[t]=fi(e)}}}Q=new WeakMap,z=new WeakMap,V=new WeakSet,J=function(t){return __privateGet(this,Q).push(t),__privateSet(this,z,__privateGet(this,z)+t.length),t.length};K=new WeakMap,q=new WeakMap,Z=new WeakMap,Y=new WeakMap,X=new WeakMap,$=new WeakSet,tt=function(t){var e;if(__privateGet(this,Y))return __privateMethod(e=__privateGet(this,Y),$,tt).call(e,t);__privateSet(this,Z,__privateGet(this,Z)+t),Br(__privateGet(this,X)<1||__privateGet(this,Z)<=__privateGet(this,X)*this.dataLength,`compressed ABI data exceeds inflation ratio of ${__privateGet(this,X)} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:Hr(__privateGet(this,K)),offset:__privateGet(this,q),length:t,info:{bytesRead:__privateGet(this,Z),dataLength:this.dataLength}})},et=new WeakSet,rt=function(t,e,r){let n=Math.ceil(e/ii)*ii;return __privateGet(this,q)+n>__privateGet(this,K).length&&(this.allowLoose&&r&&__privateGet(this,q)+e<=__privateGet(this,K).length?n=e:Br(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:Hr(__privateGet(this,K)),length:__privateGet(this,K).length,offset:__privateGet(this,q)+n})),__privateGet(this,K).slice(__privateGet(this,q),__privateGet(this,q)+n)};let _i=class t{constructor(t,e,r){__privateAdd(this,$),__privateAdd(this,et),__publicField(this,"allowLoose"),__privateAdd(this,K,void 0),__privateAdd(this,q,void 0),__privateAdd(this,Z,void 0),__privateAdd(this,Y,void 0),__privateAdd(this,X,void 0),Tr(this,{allowLoose:!!e}),__privateSet(this,K,Hr(t)),__privateSet(this,Z,0),__privateSet(this,Y,null),__privateSet(this,X,null!=r?r:1024),__privateSet(this,q,0)}get data(){return Vr(__privateGet(this,K))}get dataLength(){return __privateGet(this,K).length}get consumed(){return __privateGet(this,q)}get bytes(){return new Uint8Array(__privateGet(this,K))}subReader(e){const r=new t(__privateGet(this,K).slice(__privateGet(this,q)+e),this.allowLoose,__privateGet(this,X));return __privateSet(r,Y,this),r}readBytes(t,e){let r=__privateMethod(this,et,rt).call(this,0,t,!!e);return __privateMethod(this,$,tt).call(this,t),__privateSet(this,q,__privateGet(this,q)+r.length),r.slice(0,t)}readValue(){return ln(this.readBytes(ii))}readIndex(){return cn(ln(this.readBytes(ii)))}};function yi(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function vi(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function wi(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function bi(t,e){vi(t);const r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}const Ai="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,Ei=t=>t instanceof Uint8Array,xi=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),ki=(t,e)=>t<<32-e|t>>>e;
|
2
|
-
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");function Si(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),!Ei(t))throw new Error("expected Uint8Array, got "+typeof t);return t}class Ni{clone(){return this._cloneInto()}}function Pi(t){const e=e=>t().update(Si(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Ci(t=32){if(Ai&&"function"==typeof Ai.getRandomValues)return Ai.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}class Ti extends Ni{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");yi(t.outputLen),yi(t.blockLen)}(t);const r=Si(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,i=new Uint8Array(n);i.set(r.length>n?t.create().update(r).digest():r);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(t){return wi(this),this.iHash.update(t),this}digestInto(t){wi(this),vi(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:n,destroyed:i,blockLen:s,outputLen:a}=this;return t.finished=n,t.destroyed=i,t.blockLen=s,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Ri=(t,e,r)=>new Ti(t,e).update(r).digest();Ri.create=(t,e)=>new Ti(t,e);class Gi extends Ni{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=xi(this.buffer)}update(t){wi(this);const{view:e,buffer:r,blockLen:n}=this,i=(t=Si(t)).length;for(let s=0;s<i;){const a=Math.min(n-this.pos,i-s);if(a!==n)r.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===n&&(this.process(e,0),this.pos=0);else{const e=xi(t);for(;n<=i-s;s+=n)this.process(e,s)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){wi(this),bi(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:n,isLE:i}=this;let{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>n-s&&(this.process(r,0),s=0);for(let u=s;u<n;u++)e[u]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),s=BigInt(4294967295),a=Number(r>>i&s),o=Number(r&s),l=n?4:0,c=n?0:4;t.setUint32(e+l,a,n),t.setUint32(e+c,o,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const a=xi(t),o=this.outputLen;if(o%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=o/4,c=this.get();if(l>c.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,c[u],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:s,pos:a}=this;return t.length=n,t.pos=a,t.finished=i,t.destroyed=s,n%e&&t.buffer.set(r),t}}const Mi=(t,e,r)=>t&e^t&r^e&r,Ii=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Bi=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Oi=new Uint32Array(64);class Fi extends Gi{constructor(){super(64,32,8,!1),this.A=0|Bi[0],this.B=0|Bi[1],this.C=0|Bi[2],this.D=0|Bi[3],this.E=0|Bi[4],this.F=0|Bi[5],this.G=0|Bi[6],this.H=0|Bi[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:s,G:a,H:o}=this;return[t,e,r,n,i,s,a,o]}set(t,e,r,n,i,s,a,o){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|s,this.G=0|a,this.H=0|o}process(t,e){for(let h=0;h<16;h++,e+=4)Oi[h]=t.getUint32(e,!1);for(let h=16;h<64;h++){const t=Oi[h-15],e=Oi[h-2],r=ki(t,7)^ki(t,18)^t>>>3,n=ki(e,17)^ki(e,19)^e>>>10;Oi[h]=n+Oi[h-7]+r+Oi[h-16]|0}let{A:r,B:n,C:i,D:s,E:a,F:o,G:l,H:c}=this;for(let h=0;h<64;h++){const t=c+(ki(a,6)^ki(a,11)^ki(a,25))+((u=a)&o^~u&l)+Ii[h]+Oi[h]|0,e=(ki(r,2)^ki(r,13)^ki(r,22))+Mi(r,n,i)|0;c=l,l=o,o=a,a=s+t|0,s=i,i=n,n=r,r=t+e|0}var u;r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,o=o+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(r,n,i,s,a,o,l,c)}roundClean(){Oi.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Ui=Pi((()=>new Fi)),Li=BigInt(__pow(2,32)-1),Di=BigInt(32);function ji(t,e=!1){return e?{h:Number(t&Li),l:Number(t>>Di&Li)}:{h:0|Number(t>>Di&Li),l:0|Number(t&Li)}}function Hi(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:s,l:a}=ji(t[i],e);[r[i],n[i]]=[s,a]}return[r,n]}const Wi=(t,e,r)=>t<<r|e>>>32-r,Qi=(t,e,r)=>e<<r|t>>>32-r,zi=(t,e,r)=>e<<r-32|t>>>64-r,Vi=(t,e,r)=>t<<r-32|e>>>64-r;const Ji={fromBig:ji,split:Hi,toBig:(t,e)=>BigInt(t>>>0)<<Di|BigInt(e>>>0),shrSH:(t,e,r)=>t>>>r,shrSL:(t,e,r)=>t<<32-r|e>>>r,rotrSH:(t,e,r)=>t>>>r|e<<32-r,rotrSL:(t,e,r)=>t<<32-r|e>>>r,rotrBH:(t,e,r)=>t<<64-r|e>>>r-32,rotrBL:(t,e,r)=>t>>>r-32|e<<64-r,rotr32H:(t,e)=>e,rotr32L:(t,e)=>t,rotlSH:Wi,rotlSL:Qi,rotlBH:zi,rotlBL:Vi,add:function(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/__pow(2,32)|0)|0,l:0|i}},add3L:(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),add3H:(t,e,r,n)=>e+r+n+(t/__pow(2,32)|0)|0,add4L:(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),add4H:(t,e,r,n,i)=>e+r+n+i+(t/__pow(2,32)|0)|0,add5H:(t,e,r,n,i,s)=>e+r+n+i+s+(t/__pow(2,32)|0)|0,add5L:(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0)},[Ki,qi]=(()=>Ji.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((t=>BigInt(t)))))(),Zi=new Uint32Array(80),Yi=new Uint32Array(80);class Xi extends Gi{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:e,Bh:r,Bl:n,Ch:i,Cl:s,Dh:a,Dl:o,Eh:l,El:c,Fh:u,Fl:h,Gh:d,Gl:p,Hh:f,Hl:g}=this;return[t,e,r,n,i,s,a,o,l,c,u,h,d,p,f,g]}set(t,e,r,n,i,s,a,o,l,c,u,h,d,p,f,g){this.Ah=0|t,this.Al=0|e,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|s,this.Dh=0|a,this.Dl=0|o,this.Eh=0|l,this.El=0|c,this.Fh=0|u,this.Fl=0|h,this.Gh=0|d,this.Gl=0|p,this.Hh=0|f,this.Hl=0|g}process(t,e){for(let y=0;y<16;y++,e+=4)Zi[y]=t.getUint32(e),Yi[y]=t.getUint32(e+=4);for(let y=16;y<80;y++){const t=0|Zi[y-15],e=0|Yi[y-15],r=Ji.rotrSH(t,e,1)^Ji.rotrSH(t,e,8)^Ji.shrSH(t,e,7),n=Ji.rotrSL(t,e,1)^Ji.rotrSL(t,e,8)^Ji.shrSL(t,e,7),i=0|Zi[y-2],s=0|Yi[y-2],a=Ji.rotrSH(i,s,19)^Ji.rotrBH(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),({h:m,l:_}=Ji.add(0|this.Hh,0|this.Hl,0|m,0|_)),this.set(r,n,i,s,a,o,l,c,u,h,d,p,f,g,m,_)}roundClean(){Zi.fill(0),Yi.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const $i=Pi((()=>new Xi));const ts=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")}();ts.crypto||ts.msCrypto;const[es,rs,ns]=[[],[],[]],is=BigInt(0),ss=BigInt(1),as=BigInt(2),os=BigInt(7),ls=BigInt(256),cs=BigInt(113);for(let Np=0,Pp=ss,Cp=1,Tp=0;Np<24;Np++){[Cp,Tp]=[Tp,(2*Cp+3*Tp)%5],es.push(2*(5*Tp+Cp)),rs.push((Np+1)*(Np+2)/2%64);let t=is;for(let e=0;e<7;e++)Pp=(Pp<<ss^(Pp>>os)*cs)%ls,Pp&as&&(t^=ss<<(ss<<BigInt(e))-ss);ns.push(t)}const[us,hs]=Hi(ns,!0),ds=(t,e,r)=>r>32?zi(t,e,r):Wi(t,e,r),ps=(t,e,r)=>r>32?Vi(t,e,r):Qi(t,e,r);class fs extends Ni{constructor(t,e,r,n=!1,i=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=r,this.enableXOF=n,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,yi(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var s;this.state=new Uint8Array(200),this.state32=(s=this.state,new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4)))}keccak(){!function(t,e=24){const r=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let n=0;n<10;n++)r[n]=t[n]^t[n+10]^t[n+20]^t[n+30]^t[n+40];for(let n=0;n<10;n+=2){const e=(n+8)%10,i=(n+2)%10,s=r[i],a=r[i+1],o=ds(s,a,1)^r[e],l=ps(s,a,1)^r[e+1];for(let r=0;r<50;r+=10)t[n+r]^=o,t[n+r+1]^=l}let e=t[2],i=t[3];for(let r=0;r<24;r++){const n=rs[r],s=ds(e,i,n),a=ps(e,i,n),o=es[r];e=t[o],i=t[o+1],t[o]=s,t[o+1]=a}for(let n=0;n<50;n+=10){for(let e=0;e<10;e++)r[e]=t[n+e];for(let e=0;e<10;e++)t[n+e]^=~r[(e+2)%10]&r[(e+4)%10]}t[0]^=us[n],t[1]^=hs[n]}r.fill(0)}(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){wi(this);const{blockLen:e,state:r}=this,n=(t=Si(t)).length;for(let i=0;i<n;){const s=Math.min(e-this.pos,n-i);for(let e=0;e<s;e++)r[this.pos++]^=t[i++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:r,blockLen:n}=this;t[r]^=e,128&e&&r===n-1&&this.keccak(),t[n-1]^=128,this.keccak()}writeInto(t){wi(this,!1),vi(t),this.finish();const e=this.state,{blockLen:r}=this;for(let n=0,i=t.length;n<i;){this.posOut>=r&&this.keccak();const s=Math.min(r-this.posOut,i-n);t.set(e.subarray(this.posOut,this.posOut+s),n),this.posOut+=s,n+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return yi(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(bi(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:r,outputLen:n,rounds:i,enableXOF:s}=this;return t||(t=new fs(e,r,n,s,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=n,t.enableXOF=s,t.destroyed=this.destroyed,t}}const gs=((t,e,r)=>Pi((()=>new fs(e,t,r))))(1,136,32);let ms=!1;const _s=function(t){return gs(t)};let ys=_s;function vs(t){const e=jr(t,"data");return Vr(ys(e))}vs._=_s,vs.lock=function(){ms=!0},vs.register=function(t){if(ms)throw new TypeError("keccak256 is locked");ys=t},Object.freeze(vs);const ws=function(t){return function(t){switch(t){case"sha256":return Ui.create();case"sha512":return $i.create()}Or(!1,"invalid hashing algorithm name","algorithm",t)}("sha256").update(t).digest()};let bs=ws,As=!1;function Es(t){const e=jr(t,"data");return Vr(bs(e))}Es._=ws,Es.lock=function(){As=!0},Es.register=function(t){if(As)throw new Error("sha256 is locked");bs=t},Object.freeze(Es),Object.freeze(Es);
|
3
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
4
|
-
const xs=BigInt(0),ks=BigInt(1),Ss=BigInt(2),Ns=t=>t instanceof Uint8Array,Ps=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function Cs(t){if(!Ns(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=Ps[t[r]];return e}function Ts(t){const e=t.toString(16);return 1&e.length?`0${e}`:e}function Rs(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return BigInt(""===t?"0":`0x${t}`)}function Gs(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(e/2);for(let n=0;n<r.length;n++){const e=2*n,i=t.slice(e,e+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");r[n]=s}return r}function Ms(t){return Rs(Cs(t))}function Is(t){if(!Ns(t))throw new Error("Uint8Array expected");return Rs(Cs(Uint8Array.from(t).reverse()))}function Bs(t,e){return Gs(t.toString(16).padStart(2*e,"0"))}function Os(t,e){return Bs(t,e).reverse()}function Fs(t,e,r){let n;if("string"==typeof e)try{n=Gs(e)}catch(s){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${s}`)}else{if(!Ns(e))throw new Error(`${t} must be hex string or Uint8Array`);n=Uint8Array.from(e)}const i=n.length;if("number"==typeof r&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}function Us(...t){const e=new Uint8Array(t.reduce(((t,e)=>t+e.length),0));let r=0;return t.forEach((t=>{if(!Ns(t))throw new Error("Uint8Array expected");e.set(t,r),r+=t.length})),e}const Ls=t=>(Ss<<BigInt(t-1))-ks,Ds=t=>new Uint8Array(t),js=t=>Uint8Array.from(t);function Hs(t,e,r){if("number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");let n=Ds(t),i=Ds(t),s=0;const a=()=>{n.fill(1),i.fill(0),s=0},o=(...t)=>r(i,n,...t),l=(t=Ds())=>{i=o(js([0]),t),n=o(),0!==t.length&&(i=o(js([1]),t),n=o())},c=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const r=[];for(;t<e;){n=o();const e=n.slice();r.push(e),t+=n.length}return Us(...r)};return(t,e)=>{let r;for(a(),l(t);!(r=e(c()));)l();return a(),r}}const Ws={bigint:t=>"bigint"==typeof t,function:t=>"function"==typeof t,boolean:t=>"boolean"==typeof t,string:t=>"string"==typeof t,stringOrUint8Array:t=>"string"==typeof t||t instanceof Uint8Array,isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};function Qs(t,e,r={}){const n=(e,r,n)=>{const i=Ws[r];if("function"!=typeof i)throw new Error(`Invalid validator "${r}", expected function`);const s=t[e];if(!(n&&void 0===s||i(s,t)))throw new Error(`Invalid param ${String(e)}=${s} (${typeof s}), expected ${r}`)};for(const[i,s]of Object.entries(e))n(i,s,!1);for(const[i,s]of Object.entries(r))n(i,s,!0);return t}const zs=Object.freeze(Object.defineProperty({__proto__:null,bitGet:function(t,e){return t>>BigInt(e)&ks},bitLen:function(t){let e;for(e=0;t>xs;t>>=ks,e+=1);return e},bitMask:Ls,bitSet:(t,e,r)=>t|(r?ks:xs)<<BigInt(e),bytesToHex:Cs,bytesToNumberBE:Ms,bytesToNumberLE:Is,concatBytes:Us,createHmacDrbg:Hs,ensureBytes:Fs,equalBytes:function(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0},hexToBytes:Gs,hexToNumber:Rs,numberToBytesBE:Bs,numberToBytesLE:Os,numberToHexUnpadded:Ts,numberToVarBytesBE:function(t){return Gs(Ts(t))},utf8ToBytes:function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))},validateObject:Qs},Symbol.toStringTag,{value:"Module"})),Vs=BigInt(0),Js=BigInt(1),Ks=BigInt(2),qs=BigInt(3),Zs=BigInt(4),Ys=BigInt(5),Xs=BigInt(8);
|
5
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function $s(t,e){const r=t%e;return r>=Vs?r:e+r}function ta(t,e,r){if(r<=Vs||e<Vs)throw new Error("Expected power/modulo > 0");if(r===Js)return Vs;let n=Js;for(;e>Vs;)e&Js&&(n=n*t%r),t=t*t%r,e>>=Js;return n}function ea(t,e,r){let n=t;for(;e-- >Vs;)n*=n,n%=r;return n}function ra(t,e){if(t===Vs||e<=Vs)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=$s(t,e),n=e,i=Vs,s=Js;for(;r!==Vs;){const t=n%r,e=i-s*(n/r);n=r,r=t,i=s,s=e}if(n!==Js)throw new Error("invert: does not exist");return $s(i,e)}function na(t){if(t%Zs===qs){const e=(t+Js)/Zs;return function(t,r){const n=t.pow(r,e);if(!t.eql(t.sqr(n),r))throw new Error("Cannot find square root");return n}}if(t%Xs===Ys){const e=(t-Ys)/Xs;return function(t,r){const n=t.mul(r,Ks),i=t.pow(n,e),s=t.mul(r,i),a=t.mul(t.mul(s,Ks),i),o=t.mul(s,t.sub(a,t.ONE));if(!t.eql(t.sqr(o),r))throw new Error("Cannot find square root");return o}}return function(t){const e=(t-Js)/Ks;let r,n,i;for(r=t-Js,n=0;r%Ks===Vs;r/=Ks,n++);for(i=Ks;i<t&&ta(i,e,t)!==t-Js;i++);if(1===n){const e=(t+Js)/Zs;return function(t,r){const n=t.pow(r,e);if(!t.eql(t.sqr(n),r))throw new Error("Cannot find square root");return n}}const s=(r+Js)/Ks;return function(t,a){if(t.pow(a,e)===t.neg(t.ONE))throw new Error("Cannot find square root");let o=n,l=t.pow(t.mul(t.ONE,i),r),c=t.pow(a,s),u=t.pow(a,r);for(;!t.eql(u,t.ONE);){if(t.eql(u,t.ZERO))return t.ZERO;let e=1;for(let n=t.sqr(u);e<o&&!t.eql(n,t.ONE);e++)n=t.sqr(n);const r=t.pow(l,Js<<BigInt(o-e-1));l=t.sqr(r),c=t.mul(c,r),u=t.mul(u,l),o=e}return c}}(t)}BigInt(9),BigInt(16);const ia=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function sa(t,e){const r=void 0!==e?e:t.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function aa(t){if("bigint"!=typeof t)throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function oa(t){const e=aa(t);return e+Math.ceil(e/2)}
|
6
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
7
|
-
const la=BigInt(0),ca=BigInt(1);function ua(t){return Qs(t.Fp,ia.reduce(((t,e)=>(t[e]="function",t)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),Qs(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze(__spreadValues(__spreadValues(__spreadValues({},sa(t.n,t.nBitLength)),t),{p:t.Fp.ORDER}))}
|
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
|
-
/*! 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
|
-
/*! 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+BIAEgfndBQoBYgULAWIFDAFiBNcE2ATZBRAFEQUvBdALFAsVDPcNBw13DYcOMA4xDjMB4BllHI0B2grbAMDpHLkQ7QHVAPRNQQFnGRUEg0yEB2uaJF8AJpIBpob5AERSMAKNoAXqaQLUBMCzEiACnwRZEkkVsS7tANAsBG0RuAQLEPABv9HICTUBXigPZwRBApMDOwAamhtaABqEAY8KvKx3LQ4ArAB8UhwEBAVSagD8AEFZADkBIadVj2UMUgx5Il4ANQC9AxIB1BlbEPMAs30CGxlXAhwZKQIECBc6EbsCoxngzv7UzRQA8M0BawL6ZwkN7wABAD33OQRcsgLJCjMCjqUChtw/km+NAsXPAoP2BT84PwURAK0RAvptb6cApQS/OMMey5HJS84UdxpxTPkCogVFITaTOwERAK5pAvkNBOVyA7q3BKlOJSALAgUIBRcEdASpBXqzABXFSWZOawLCOqw//AolCZdvv3dSBk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RNRDSvbQPjcXaenNYxCvu2Qyznz6StuxVj66SgI0T8B6/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("AEEUdwmgDS8BxQKKAP4BOgDjATAAngDUAIMAoABoAOAAagCOAEQ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HtnoCLxd1gQUscHRB/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:"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;
|
1
|
+
var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__reflectGet=Reflect.get,__pow=Math.pow,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__publicField=(e,t,r)=>(__defNormalProp(e,"symbol"!=typeof t?t+"":t,r),r),__accessCheck=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},__privateGet=(e,t,r)=>(__accessCheck(e,t,"read from private field"),r?r.call(e):t.get(e)),__privateAdd=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},__privateSet=(e,t,r,n)=>(__accessCheck(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),__privateWrapper=(e,t,r,n)=>({set _(n){__privateSet(e,t,n,r)},get _(){return __privateGet(e,t,n)}}),__privateMethod=(e,t,r)=>(__accessCheck(e,t,"access private method"),r),__superGet=(e,t,r)=>__reflectGet(__getProtoOf(e),r,t),__async=(e,t,r)=>new Promise(((n,s)=>{var i=e=>{try{a(r.next(e))}catch(t){s(t)}},o=e=>{try{a(r.throw(e))}catch(t){s(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,o);a((r=r.apply(e,t)).next())}));!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).CoinleyCheckout={},e.React)}(this,(function(e,t){var r,n,s,i,o,a,l,c,u,d,h,p,f,m,g,y,_,b,w,v,x,E,N,k,A,T,S,R,O,C,P,M,F,j,U,L,I,G,D,B,W,$,z,V,H,K,q,J,Q,X,Y,Z,ee;function te(e,t,r){const n=t.split("|").map((e=>e.trim()));for(let i=0;i<n.length;i++)switch(t){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof e===t)return}const s=new Error(`invalid value for type ${t}`);throw s.code="INVALID_ARGUMENT",s.argument=`value.${r}`,s.value=e,s}function re(e){return __async(this,null,(function*(){const t=Object.keys(e);return(yield Promise.all(t.map((t=>Promise.resolve(e[t]))))).reduce(((e,r,n)=>(e[t[n]]=r,e)),{})}))}function ne(e,t,r){for(let n in t){let s=t[n];const i=r?r[n]:null;i&&te(s,i,n),Object.defineProperty(e,n,{enumerable:!0,value:s,writable:!1})}}function se(e,t){if(null==e)return"null";if(null==t&&(t=new Set),"object"==typeof e){if(t.has(e))return"[Circular]";t.add(e)}if(Array.isArray(e))return"[ "+e.map((e=>se(e,t))).join(", ")+" ]";if(e instanceof Uint8Array){const t="0123456789abcdef";let r="0x";for(let n=0;n<e.length;n++)r+=t[e[n]>>4],r+=t[15&e[n]];return r}if("object"==typeof e&&"function"==typeof e.toJSON)return se(e.toJSON(),t);switch(typeof e){case"boolean":case"number":case"symbol":return e.toString();case"bigint":return BigInt(e).toString();case"string":return JSON.stringify(e);case"object":{const r=Object.keys(e);return r.sort(),"{ "+r.map((r=>`${se(r,t)}: ${se(e[r],t)}`)).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function ie(e,t){return e&&e.code===t}function oe(e){return ie(e,"CALL_EXCEPTION")}function ae(e,t,r){let n,s=e;{const n=[];if(r){if("message"in r||"code"in r||"name"in r)throw new Error(`value will overwrite populated values: ${se(r)}`);for(const e in r){if("shortMessage"===e)continue;const t=r[e];n.push(e+"="+se(t))}}n.push(`code=${t}`),n.push("version=6.14.3"),n.length&&(e+=" ("+n.join(", ")+")")}switch(t){case"INVALID_ARGUMENT":n=new TypeError(e);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":n=new RangeError(e);break;default:n=new Error(e)}return ne(n,{code:t}),r&&Object.assign(n,r),null==n.shortMessage&&ne(n,{shortMessage:s}),n}function le(e,t,r,n){if(!e)throw ae(t,r,n)}function ce(e,t,r,n){le(e,t,"INVALID_ARGUMENT",{argument:r,value:n})}function ue(e,t,r){null==r&&(r=""),r&&(r=": "+r),le(e>=t,"missing argument"+r,"MISSING_ARGUMENT",{count:e,expectedCount:t}),le(e<=t,"too many arguments"+r,"UNEXPECTED_ARGUMENT",{count:e,expectedCount:t})}const de=["NFD","NFC","NFKD","NFKC"].reduce(((e,t)=>{try{if("test"!=="test".normalize(t))throw new Error("bad");if("NFD"===t){const e=String.fromCharCode(233).normalize("NFD");if(e!==String.fromCharCode(101,769))throw new Error("broken")}e.push(t)}catch(r){}return e}),[]);function he(e,t,r){if(null==r&&(r=""),e!==t){let e=r,t="new";r&&(e+=".",t+=" "+r),le(!1,`private constructor; use ${e}from* methods`,"UNSUPPORTED_OPERATION",{operation:t})}}function pe(e,t,r){if(e instanceof Uint8Array)return r?new Uint8Array(e):e;if("string"==typeof e&&e.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const t=new Uint8Array((e.length-2)/2);let r=2;for(let n=0;n<t.length;n++)t[n]=parseInt(e.substring(r,r+2),16),r+=2;return t}ce(!1,"invalid BytesLike value",t||"value",e)}function fe(e,t){return pe(e,t,!1)}function me(e,t){return pe(e,t,!0)}function ge(e,t){return!("string"!=typeof e||!e.match(/^0x[0-9A-Fa-f]*$/))&&(("number"!=typeof t||e.length===2+2*t)&&(!0!==t||e.length%2==0))}const ye="0123456789abcdef";function _e(e){const t=fe(e);let r="0x";for(let n=0;n<t.length;n++){const e=t[n];r+=ye[(240&e)>>4]+ye[15&e]}return r}function be(e){return"0x"+e.map((e=>_e(e).substring(2))).join("")}function we(e,t,r){const n=fe(e);return null!=r&&r>n.length&&le(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:r}),_e(n.slice(null==t?0:t,null==r?n.length:r))}function ve(e,t,r){const n=fe(e);le(t>=n.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(n),length:t,offset:t+1});const s=new Uint8Array(t);return s.fill(0),r?s.set(n,t-n.length):s.set(n,0),_e(s)}const xe=BigInt(0),Ee=BigInt(1),Ne=9007199254740991;function ke(e,t){const r=Se(e,"value"),n=BigInt(Ce(t,"width"));if(le(r>>n===xe,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:e}),r>>n-Ee){return-((~r&(Ee<<n)-Ee)+Ee)}return r}function Ae(e,t){const r=Se(e,"value"),n=BigInt(Ce(t,"bits"));return r&(Ee<<n)-Ee}function Te(e,t){switch(typeof e){case"bigint":return e;case"number":return ce(Number.isInteger(e),"underflow",t||"value",e),ce(e>=-Ne&&e<=Ne,"overflow",t||"value",e),BigInt(e);case"string":try{if(""===e)throw new Error("empty string");return"-"===e[0]&&"-"!==e[1]?-BigInt(e.substring(1)):BigInt(e)}catch(r){ce(!1,`invalid BigNumberish string: ${r.message}`,t||"value",e)}}ce(!1,"invalid BigNumberish value",t||"value",e)}function Se(e,t){const r=Te(e,t);return le(r>=xe,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:e}),r}const Re="0123456789abcdef";function Oe(e){if(e instanceof Uint8Array){let t="0x0";for(const r of e)t+=Re[r>>4],t+=Re[15&r];return BigInt(t)}return Te(e)}function Ce(e,t){switch(typeof e){case"bigint":return ce(e>=-Ne&&e<=Ne,"overflow",t||"value",e),Number(e);case"number":return ce(Number.isInteger(e),"underflow",t||"value",e),ce(e>=-Ne&&e<=Ne,"overflow",t||"value",e),e;case"string":try{if(""===e)throw new Error("empty string");return Ce(BigInt(e),t)}catch(r){ce(!1,`invalid numeric string: ${r.message}`,t||"value",e)}}ce(!1,"invalid numeric value",t||"value",e)}function Pe(e,t){let r=Se(e,"value").toString(16);if(null==t)r.length%2&&(r="0"+r);else{const n=Ce(t,"width");for(le(2*n>=r.length,`value exceeds width (${n} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:e});r.length<2*n;)r="0"+r}return"0x"+r}class Me{constructor(e,t,n){__publicField(this,"filter"),__publicField(this,"emitter"),__privateAdd(this,r,void 0),__privateSet(this,r,t),ne(this,{emitter:e,filter:n})}removeListener(){return __async(this,null,(function*(){null!=__privateGet(this,r)&&(yield this.emitter.off(this.filter,__privateGet(this,r)))}))}}function Fe(e,t,r,n,s){if("BAD_PREFIX"===e||"UNEXPECTED_CONTINUE"===e){let e=0;for(let n=t+1;n<r.length&&r[n]>>6==2;n++)e++;return e}return"OVERRUN"===e?r.length-t-1:0}r=new WeakMap;const je=Object.freeze({error:function(e,t,r,n,s){ce(!1,`invalid codepoint at offset ${t}; ${e}`,"bytes",r)},ignore:Fe,replace:function(e,t,r,n,s){return"OVERLONG"===e?(ce("number"==typeof s,"invalid bad code point for replacement","badCodepoint",s),n.push(s),0):(n.push(65533),Fe(e,t,r))}});function Ue(e,t){ce("string"==typeof e,"invalid string value","str",e),null!=t&&(!function(e){le(de.indexOf(e)>=0,"platform missing String.prototype.normalize","UNSUPPORTED_OPERATION",{operation:"String.prototype.normalize",info:{form:e}})}(t),e=e.normalize(t));let r=[];for(let n=0;n<e.length;n++){const t=e.charCodeAt(n);if(t<128)r.push(t);else if(t<2048)r.push(t>>6|192),r.push(63&t|128);else if(55296==(64512&t)){n++;const s=e.charCodeAt(n);ce(n<e.length&&56320==(64512&s),"invalid surrogate pair","str",e);const i=65536+((1023&t)<<10)+(1023&s);r.push(i>>18|240),r.push(i>>12&63|128),r.push(i>>6&63|128),r.push(63&i|128)}else r.push(t>>12|224),r.push(t>>6&63|128),r.push(63&t|128)}return new Uint8Array(r)}function Le(e,t){return r=function(e,t){null==t&&(t=je.error);const r=fe(e,"bytes"),n=[];let s=0;for(;s<r.length;){const e=r[s++];if(!(e>>7)){n.push(e);continue}let i=null,o=null;if(192==(224&e))i=1,o=127;else if(224==(240&e))i=2,o=2047;else{if(240!=(248&e)){s+=t(128==(192&e)?"UNEXPECTED_CONTINUE":"BAD_PREFIX",s-1,r,n);continue}i=3,o=65535}if(s-1+i>=r.length){s+=t("OVERRUN",s-1,r,n);continue}let a=e&(1<<8-i-1)-1;for(let l=0;l<i;l++){let e=r[s];if(128!=(192&e)){s+=t("MISSING_CONTINUE",s,r,n),a=null;break}a=a<<6|63&e,s++}null!==a&&(a>1114111?s+=t("OUT_OF_RANGE",s-1-i,r,n,a):a>=55296&&a<=57343?s+=t("UTF16_SURROGATE",s-1-i,r,n,a):a<=o?s+=t("OVERLONG",s-1-i,r,n,a):n.push(a))}return n}(e,t),r.map((e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10&1023),56320+(1023&e))))).join("");var r}const Ie=BigInt(-1),Ge=BigInt(0),De=BigInt(1),Be=BigInt(5),We={};let $e="0000";for(;$e.length<80;)$e+=$e;function ze(e){let t=$e;for(;t.length<e;)t+=t;return BigInt("1"+t.substring(0,e))}function Ve(e,t,r){const n=BigInt(t.width);if(t.signed){const t=De<<n-De;le(null==r||e>=-t&&e<t,"overflow","NUMERIC_FAULT",{operation:r,fault:"overflow",value:e}),e=e>Ge?ke(Ae(e,n),n):-ke(Ae(-e,n),n)}else{const t=De<<n;le(null==r||e>=0&&e<t,"overflow","NUMERIC_FAULT",{operation:r,fault:"overflow",value:e}),e=(e%t+t)%t&t-De}return e}function He(e){"number"==typeof e&&(e=`fixed128x${e}`);let t=!0,r=128,n=18;if("string"==typeof e)if("fixed"===e);else if("ufixed"===e)t=!1;else{const s=e.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);ce(s,"invalid fixed format","format",e),t="u"!==s[1],r=parseInt(s[2]),n=parseInt(s[3])}else if(e){const s=e,i=(e,t,r)=>null==s[e]?r:(ce(typeof s[e]===t,"invalid fixed format ("+e+" not "+t+")","format."+e,s[e]),s[e]);t=i("signed","boolean",t),r=i("width","number",r),n=i("decimals","number",n)}ce(r%8==0,"invalid FixedNumber width (not byte aligned)","format.width",r),ce(n<=80,"invalid FixedNumber decimals (too large)","format.decimals",n);return{signed:t,width:r,decimals:n,name:(t?"":"u")+"fixed"+String(r)+"x"+String(n)}}const Ke=class e{constructor(e,t,r){__privateAdd(this,o),__privateAdd(this,l),__privateAdd(this,u),__privateAdd(this,h),__privateAdd(this,f),__privateAdd(this,g),__publicField(this,"format"),__privateAdd(this,n,void 0),__privateAdd(this,s,void 0),__privateAdd(this,i,void 0),__publicField(this,"_value"),he(e,We,"FixedNumber"),__privateSet(this,s,t),__privateSet(this,n,r);const a=function(e,t){let r="";e<Ge&&(r="-",e*=Ie);let n=e.toString();if(0===t)return r+n;for(;n.length<=t;)n=$e+n;const s=n.length-t;for(n=n.substring(0,s)+"."+n.substring(s);"0"===n[0]&&"."!==n[1];)n=n.substring(1);for(;"0"===n[n.length-1]&&"."!==n[n.length-2];)n=n.substring(0,n.length-1);return r+n}(t,r.decimals);ne(this,{format:r.name,_value:a}),__privateSet(this,i,ze(r.decimals))}get signed(){return __privateGet(this,n).signed}get width(){return __privateGet(this,n).width}get decimals(){return __privateGet(this,n).decimals}get value(){return __privateGet(this,s)}addUnsafe(e){return __privateMethod(this,u,d).call(this,e)}add(e){return __privateMethod(this,u,d).call(this,e,"add")}subUnsafe(e){return __privateMethod(this,h,p).call(this,e)}sub(e){return __privateMethod(this,h,p).call(this,e,"sub")}mulUnsafe(e){return __privateMethod(this,f,m).call(this,e)}mul(e){return __privateMethod(this,f,m).call(this,e,"mul")}mulSignal(e){__privateMethod(this,o,a).call(this,e);const t=__privateGet(this,s)*__privateGet(e,s);return le(t%__privateGet(this,i)===Ge,"precision lost during signalling mul","NUMERIC_FAULT",{operation:"mulSignal",fault:"underflow",value:this}),__privateMethod(this,l,c).call(this,t/__privateGet(this,i),"mulSignal")}divUnsafe(e){return __privateMethod(this,g,y).call(this,e)}div(e){return __privateMethod(this,g,y).call(this,e,"div")}divSignal(e){le(__privateGet(e,s)!==Ge,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),__privateMethod(this,o,a).call(this,e);const t=__privateGet(this,s)*__privateGet(this,i);return le(t%__privateGet(e,s)===Ge,"precision lost during signalling div","NUMERIC_FAULT",{operation:"divSignal",fault:"underflow",value:this}),__privateMethod(this,l,c).call(this,t/__privateGet(e,s),"divSignal")}cmp(e){let t=this.value,r=e.value;const n=this.decimals-e.decimals;return n>0?r*=ze(n):n<0&&(t*=ze(-n)),t<r?-1:t>r?1:0}eq(e){return 0===this.cmp(e)}lt(e){return this.cmp(e)<0}lte(e){return this.cmp(e)<=0}gt(e){return this.cmp(e)>0}gte(e){return this.cmp(e)>=0}floor(){let e=__privateGet(this,s);return __privateGet(this,s)<Ge&&(e-=__privateGet(this,i)-De),e=__privateGet(this,s)/__privateGet(this,i)*__privateGet(this,i),__privateMethod(this,l,c).call(this,e,"floor")}ceiling(){let e=__privateGet(this,s);return __privateGet(this,s)>Ge&&(e+=__privateGet(this,i)-De),e=__privateGet(this,s)/__privateGet(this,i)*__privateGet(this,i),__privateMethod(this,l,c).call(this,e,"ceiling")}round(t){if(null==t&&(t=0),t>=this.decimals)return this;const r=this.decimals-t,s=Be*ze(r-1);let i=this.value+s;const o=ze(r);return i=i/o*o,Ve(i,__privateGet(this,n),"round"),new e(We,i,__privateGet(this,n))}isZero(){return __privateGet(this,s)===Ge}isNegative(){return __privateGet(this,s)<Ge}toString(){return this._value}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(t){return e.fromString(this.toString(),t)}static fromValue(t,r,n){const s=null==r?0:Ce(r),i=He(n);let o=Te(t,"value");const a=s-i.decimals;if(a>0){const e=ze(a);le(o%e===Ge,"value loses precision for format","NUMERIC_FAULT",{operation:"fromValue",fault:"underflow",value:t}),o/=e}else a<0&&(o*=ze(-a));return Ve(o,i,"fromValue"),new e(We,o,i)}static fromString(t,r){const n=t.match(/^(-?)([0-9]*)\.?([0-9]*)$/);ce(n&&n[2].length+n[3].length>0,"invalid FixedNumber string value","value",t);const s=He(r);let i=n[2]||"0",o=n[3]||"";for(;o.length<s.decimals;)o+=$e;le(o.substring(s.decimals).match(/^0*$/),"too many decimals for format","NUMERIC_FAULT",{operation:"fromString",fault:"underflow",value:t}),o=o.substring(0,s.decimals);const a=BigInt(n[1]+i+o);return Ve(a,s,"fromString"),new e(We,a,s)}static fromBytes(t,r){let n=Oe(fe(t,"value"));const s=He(r);return s.signed&&(n=ke(n,s.width)),Ve(n,s,"fromBytes"),new e(We,n,s)}};n=new WeakMap,s=new WeakMap,i=new WeakMap,o=new WeakSet,a=function(e){ce(this.format===e.format,"incompatible format; use fixedNumber.toFormat","other",e)},l=new WeakSet,c=function(e,t){return e=Ve(e,__privateGet(this,n),t),new Ke(We,e,__privateGet(this,n))},u=new WeakSet,d=function(e,t){return __privateMethod(this,o,a).call(this,e),__privateMethod(this,l,c).call(this,__privateGet(this,s)+__privateGet(e,s),t)},h=new WeakSet,p=function(e,t){return __privateMethod(this,o,a).call(this,e),__privateMethod(this,l,c).call(this,__privateGet(this,s)-__privateGet(e,s),t)},f=new WeakSet,m=function(e,t){return __privateMethod(this,o,a).call(this,e),__privateMethod(this,l,c).call(this,__privateGet(this,s)*__privateGet(e,s)/__privateGet(this,i),t)},g=new WeakSet,y=function(e,t){return le(__privateGet(e,s)!==Ge,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),__privateMethod(this,o,a).call(this,e),__privateMethod(this,l,c).call(this,__privateGet(this,s)*__privateGet(this,i)/__privateGet(e,s),t)};let qe=Ke;const Je=["wei","kwei","mwei","gwei","szabo","finney","ether"];function Qe(e,t){ce("string"==typeof e,"value must be a string","value",e);let r=18;if("string"==typeof t){const e=Je.indexOf(t);ce(e>=0,"invalid unit","unit",t),r=3*e}else null!=t&&(r=Ce(t,"unit"));return qe.fromString(e,{decimals:r,width:512}).value}function Xe(e){return Qe(e,18)}const Ye=32,Ze=new Uint8Array(Ye),et=["then"],tt={},rt=new WeakMap;function nt(e){return rt.get(e)}function st(e,t){rt.set(e,t)}function it(e,t){const r=new Error(`deferred error during ABI decoding triggered accessing ${e}`);throw r.error=t,r}function ot(e,t,r){return e.indexOf(null)>=0?t.map(((e,t)=>e instanceof at?ot(nt(e),e,r):e)):e.reduce(((e,n,s)=>{let i=t.getValue(n);return n in e||(r&&i instanceof at&&(i=ot(nt(i),i,r)),e[n]=i),e}),{})}_=new WeakMap;let at=class e extends Array{constructor(...e){const t=e[0];let r=e[1],n=(e[2]||[]).slice(),s=!0;t!==tt&&(r=e,n=[],s=!1),super(r.length),__privateAdd(this,_,void 0),r.forEach(((e,t)=>{this[t]=e}));const i=n.reduce(((e,t)=>("string"==typeof t&&e.set(t,(e.get(t)||0)+1),e)),new Map);if(st(this,Object.freeze(r.map(((e,t)=>{const r=n[t];return null!=r&&1===i.get(r)?r:null})))),__privateSet(this,_,[]),null==__privateGet(this,_)&&__privateGet(this,_),!s)return;Object.freeze(this);const o=new Proxy(this,{get:(e,t,r)=>{if("string"==typeof t){if(t.match(/^[0-9]+$/)){const r=Ce(t,"%index");if(r<0||r>=this.length)throw new RangeError("out of result range");const n=e[r];return n instanceof Error&&it(`index ${r}`,n),n}if(et.indexOf(t)>=0)return Reflect.get(e,t,r);const n=e[t];if(n instanceof Function)return function(...t){return n.apply(this===r?e:this,t)};if(!(t in e))return e.getValue.apply(this===r?e:this,[t])}return Reflect.get(e,t,r)}});return st(o,nt(this)),o}toArray(t){const r=[];return this.forEach(((n,s)=>{n instanceof Error&&it(`index ${s}`,n),t&&n instanceof e&&(n=n.toArray(t)),r.push(n)})),r}toObject(e){const t=nt(this);return t.reduce(((r,n,s)=>(le(null!=n,`value at index ${s} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),ot(t,this,e))),{})}slice(t,r){null==t&&(t=0),t<0&&(t+=this.length)<0&&(t=0),null==r&&(r=this.length),r<0&&(r+=this.length)<0&&(r=0),r>this.length&&(r=this.length);const n=nt(this),s=[],i=[];for(let e=t;e<r;e++)s.push(this[e]),i.push(n[e]);return new e(tt,s,i)}filter(t,r){const n=nt(this),s=[],i=[];for(let e=0;e<this.length;e++){const o=this[e];o instanceof Error&&it(`index ${e}`,o),t.call(r,o,e,this)&&(s.push(o),i.push(n[e]))}return new e(tt,s,i)}map(e,t){const r=[];for(let n=0;n<this.length;n++){const s=this[n];s instanceof Error&&it(`index ${n}`,s),r.push(e.call(t,s,n,this))}return r}getValue(e){const t=nt(this).indexOf(e);if(-1===t)return;const r=this[t];return r instanceof Error&&it(`property ${JSON.stringify(e)}`,r.error),r}static fromItems(t,r){return new e(tt,t,r)}};function lt(e){let t=function(e){const t=Se(e,"value");if(t===xe)return new Uint8Array([]);let r=t.toString(16);r.length%2&&(r="0"+r);const n=new Uint8Array(r.length/2);for(let s=0;s<n.length;s++){const e=2*s;n[s]=parseInt(r.substring(e,e+2),16)}return n}(e);return le(t.length<=Ye,"value out-of-bounds","BUFFER_OVERRUN",{buffer:t,length:Ye,offset:t.length}),t.length!==Ye&&(t=me(be([Ze.slice(t.length%Ye),t]))),t}class ct{constructor(e,t,r,n){__publicField(this,"name"),__publicField(this,"type"),__publicField(this,"localName"),__publicField(this,"dynamic"),ne(this,{name:e,type:t,localName:r,dynamic:n},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(e,t){ce(!1,e,this.localName,t)}}class ut{constructor(){__privateAdd(this,v),__privateAdd(this,b,void 0),__privateAdd(this,w,void 0),__privateSet(this,b,[]),__privateSet(this,w,0)}get data(){return be(__privateGet(this,b))}get length(){return __privateGet(this,w)}appendWriter(e){return __privateMethod(this,v,x).call(this,me(e.data))}writeBytes(e){let t=me(e);const r=t.length%Ye;return r&&(t=me(be([t,Ze.slice(r)]))),__privateMethod(this,v,x).call(this,t)}writeValue(e){return __privateMethod(this,v,x).call(this,lt(e))}writeUpdatableValue(){const e=__privateGet(this,b).length;return __privateGet(this,b).push(Ze),__privateSet(this,w,__privateGet(this,w)+Ye),t=>{__privateGet(this,b)[e]=lt(t)}}}b=new WeakMap,w=new WeakMap,v=new WeakSet,x=function(e){return __privateGet(this,b).push(e),__privateSet(this,w,__privateGet(this,w)+e.length),e.length};E=new WeakMap,N=new WeakMap,k=new WeakMap,A=new WeakMap,T=new WeakMap,S=new WeakSet,R=function(e){var t;if(__privateGet(this,A))return __privateMethod(t=__privateGet(this,A),S,R).call(t,e);__privateSet(this,k,__privateGet(this,k)+e),le(__privateGet(this,T)<1||__privateGet(this,k)<=__privateGet(this,T)*this.dataLength,`compressed ABI data exceeds inflation ratio of ${__privateGet(this,T)} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:me(__privateGet(this,E)),offset:__privateGet(this,N),length:e,info:{bytesRead:__privateGet(this,k),dataLength:this.dataLength}})},O=new WeakSet,C=function(e,t,r){let n=Math.ceil(t/Ye)*Ye;return __privateGet(this,N)+n>__privateGet(this,E).length&&(this.allowLoose&&r&&__privateGet(this,N)+t<=__privateGet(this,E).length?n=t:le(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:me(__privateGet(this,E)),length:__privateGet(this,E).length,offset:__privateGet(this,N)+n})),__privateGet(this,E).slice(__privateGet(this,N),__privateGet(this,N)+n)};let dt=class e{constructor(e,t,r){__privateAdd(this,S),__privateAdd(this,O),__publicField(this,"allowLoose"),__privateAdd(this,E,void 0),__privateAdd(this,N,void 0),__privateAdd(this,k,void 0),__privateAdd(this,A,void 0),__privateAdd(this,T,void 0),ne(this,{allowLoose:!!t}),__privateSet(this,E,me(e)),__privateSet(this,k,0),__privateSet(this,A,null),__privateSet(this,T,null!=r?r:1024),__privateSet(this,N,0)}get data(){return _e(__privateGet(this,E))}get dataLength(){return __privateGet(this,E).length}get consumed(){return __privateGet(this,N)}get bytes(){return new Uint8Array(__privateGet(this,E))}subReader(t){const r=new e(__privateGet(this,E).slice(__privateGet(this,N)+t),this.allowLoose,__privateGet(this,T));return __privateSet(r,A,this),r}readBytes(e,t){let r=__privateMethod(this,O,C).call(this,0,e,!!t);return __privateMethod(this,S,R).call(this,e),__privateSet(this,N,__privateGet(this,N)+r.length),r.slice(0,e)}readValue(){return Oe(this.readBytes(Ye))}readIndex(){return Ce(Oe(this.readBytes(Ye)))}};function ht(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function pt(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function ft(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");function mt(e){if("string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),!(e instanceof Uint8Array))throw new Error("expected Uint8Array, got "+typeof e);return e}class gt{clone(){return this._cloneInto()}}const yt=BigInt(__pow(2,32)-1),_t=BigInt(32);function bt(e,t=!1){return t?{h:Number(e&yt),l:Number(e>>_t&yt)}:{h:0|Number(e>>_t&yt),l:0|Number(e&yt)}}function wt(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let s=0;s<e.length;s++){const{h:i,l:o}=bt(e[s],t);[r[s],n[s]]=[i,o]}return[r,n]}const[vt,xt,Et]=[[],[],[]],Nt=BigInt(0),kt=BigInt(1),At=BigInt(2),Tt=BigInt(7),St=BigInt(256),Rt=BigInt(113);for(let xi=0,Ei=kt,Ni=1,ki=0;xi<24;xi++){[Ni,ki]=[ki,(2*Ni+3*ki)%5],vt.push(2*(5*ki+Ni)),xt.push((xi+1)*(xi+2)/2%64);let e=Nt;for(let t=0;t<7;t++)Ei=(Ei<<kt^(Ei>>Tt)*Rt)%St,Ei&At&&(e^=kt<<(kt<<BigInt(t))-kt);Et.push(e)}const[Ot,Ct]=wt(Et,!0),Pt=(e,t,r)=>r>32?((e,t,r)=>t<<r-32|e>>>64-r)(e,t,r):((e,t,r)=>e<<r|t>>>32-r)(e,t,r),Mt=(e,t,r)=>r>32?((e,t,r)=>e<<r-32|t>>>64-r)(e,t,r):((e,t,r)=>t<<r|e>>>32-r)(e,t,r);class Ft extends gt{constructor(e,t,r,n=!1,s=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=n,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,ht(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var i;this.state=new Uint8Array(200),this.state32=(i=this.state,new Uint32Array(i.buffer,i.byteOffset,Math.floor(i.byteLength/4)))}keccak(){!function(e,t=24){const r=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let n=0;n<10;n++)r[n]=e[n]^e[n+10]^e[n+20]^e[n+30]^e[n+40];for(let n=0;n<10;n+=2){const t=(n+8)%10,s=(n+2)%10,i=r[s],o=r[s+1],a=Pt(i,o,1)^r[t],l=Mt(i,o,1)^r[t+1];for(let r=0;r<50;r+=10)e[n+r]^=a,e[n+r+1]^=l}let t=e[2],s=e[3];for(let r=0;r<24;r++){const n=xt[r],i=Pt(t,s,n),o=Mt(t,s,n),a=vt[r];t=e[a],s=e[a+1],e[a]=i,e[a+1]=o}for(let n=0;n<50;n+=10){for(let t=0;t<10;t++)r[t]=e[n+t];for(let t=0;t<10;t++)e[n+t]^=~r[(t+2)%10]&r[(t+4)%10]}e[0]^=Ot[n],e[1]^=Ct[n]}r.fill(0)}(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){ft(this);const{blockLen:t,state:r}=this,n=(e=mt(e)).length;for(let s=0;s<n;){const i=Math.min(t-this.pos,n-s);for(let t=0;t<i;t++)r[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:n}=this;e[r]^=t,128&t&&r===n-1&&this.keccak(),e[n-1]^=128,this.keccak()}writeInto(e){ft(this,!1),pt(e),this.finish();const t=this.state,{blockLen:r}=this;for(let n=0,s=e.length;n<s;){this.posOut>=r&&this.keccak();const i=Math.min(r-this.posOut,s-n);e.set(t.subarray(this.posOut,this.posOut+i),n),this.posOut+=i,n+=i}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return ht(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(function(e,t){pt(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}
|
2
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:n,rounds:s,enableXOF:i}=this;return e||(e=new Ft(t,r,n,i,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=r,e.outputLen=n,e.enableXOF=i,e.destroyed=this.destroyed,e}}const jt=((e,t,r)=>function(e){const t=t=>e().update(mt(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}((()=>new Ft(t,e,r))))(1,136,32);let Ut=!1;const Lt=function(e){return jt(e)};let It=Lt;function Gt(e){const t=fe(e,"data");return _e(It(t))}Gt._=Lt,Gt.lock=function(){Ut=!0},Gt.register=function(e){if(Ut)throw new TypeError("keccak256 is locked");It=e},Object.freeze(Gt);const Dt=BigInt(0),Bt=BigInt(36);function Wt(e){const t=(e=e.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let s=0;s<40;s++)r[s]=t[s].charCodeAt(0);const n=fe(Gt(r));for(let s=0;s<40;s+=2)n[s>>1]>>4>=8&&(t[s]=t[s].toUpperCase()),(15&n[s>>1])>=8&&(t[s+1]=t[s+1].toUpperCase());return"0x"+t.join("")}const $t={};for(let xi=0;xi<10;xi++)$t[String(xi)]=String(xi);for(let xi=0;xi<26;xi++)$t[String.fromCharCode(65+xi)]=String(10+xi);const zt=function(){const e={};for(let t=0;t<36;t++){e["0123456789abcdefghijklmnopqrstuvwxyz"[t]]=BigInt(t)}return e}();function Vt(e){if(ce("string"==typeof e,"invalid address","address",e),e.match(/^(0x)?[0-9a-fA-F]{40}$/)){e.startsWith("0x")||(e="0x"+e);const t=Wt(e);return ce(!e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||t===e,"bad address checksum","address",e),t}if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){ce(e.substring(2,4)===function(e){let t=(e=(e=e.toUpperCase()).substring(4)+e.substring(0,2)+"00").split("").map((e=>$t[e])).join("");for(;t.length>=15;){let e=t.substring(0,15);t=parseInt(e,10)%97+t.substring(e.length)}let r=String(98-parseInt(t,10)%97);for(;r.length<2;)r="0"+r;return r}(e),"bad icap checksum","address",e);let t=function(e){e=e.toLowerCase();let t=Dt;for(let r=0;r<e.length;r++)t=t*Bt+zt[e[r]];return t}(e.substring(4)).toString(16);for(;t.length<40;)t="0"+t;return Wt("0x"+t)}ce(!1,"invalid address","address",e)}function Ht(e){return e&&"function"==typeof e.getAddress}function Kt(e,t){return __async(this,null,(function*(){const r=yield t;return null!=r&&"0x0000000000000000000000000000000000000000"!==r||(le("string"!=typeof e,"unconfigured name","UNCONFIGURED_NAME",{value:e}),ce(!1,"invalid AddressLike value; did not resolve to a value address","target",e)),Vt(r)}))}function qt(e,t){return"string"==typeof e?e.match(/^0x[0-9a-f]{40}$/i)?Vt(e):(le(null!=t,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),Kt(e,t.resolveName(e))):Ht(e)?Kt(e,e.getAddress()):e&&"function"==typeof e.then?Kt(e,e):void ce(!1,"unsupported addressable value","target",e)}const Jt={};function Qt(e,t){let r=!1;return t<0&&(r=!0,t*=-1),new Zt(Jt,`${r?"":"u"}int${t}`,e,{signed:r,width:t})}function Xt(e,t){return new Zt(Jt,`bytes${t||""}`,e,{size:t})}const Yt=Symbol.for("_ethers_typed");P=new WeakMap;let Zt=class e{constructor(e,t,r,n){__publicField(this,"type"),__publicField(this,"value"),__privateAdd(this,P,void 0),__publicField(this,"_typedSymbol"),null==n&&(n=null),he(Jt,e,"Typed"),ne(this,{_typedSymbol:Yt,type:t,value:r}),__privateSet(this,P,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((e=>e.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,P)}get arrayLength(){if("array"!==this.type)throw TypeError("not an array");return!0===__privateGet(this,P)?-1:!1===__privateGet(this,P)?this.value.length:null}static from(t,r){return new e(Jt,t,r)}static uint8(e){return Qt(e,8)}static uint16(e){return Qt(e,16)}static uint24(e){return Qt(e,24)}static uint32(e){return Qt(e,32)}static uint40(e){return Qt(e,40)}static uint48(e){return Qt(e,48)}static uint56(e){return Qt(e,56)}static uint64(e){return Qt(e,64)}static uint72(e){return Qt(e,72)}static uint80(e){return Qt(e,80)}static uint88(e){return Qt(e,88)}static uint96(e){return Qt(e,96)}static uint104(e){return Qt(e,104)}static uint112(e){return Qt(e,112)}static uint120(e){return Qt(e,120)}static uint128(e){return Qt(e,128)}static uint136(e){return Qt(e,136)}static uint144(e){return Qt(e,144)}static uint152(e){return Qt(e,152)}static uint160(e){return Qt(e,160)}static uint168(e){return Qt(e,168)}static uint176(e){return Qt(e,176)}static uint184(e){return Qt(e,184)}static uint192(e){return Qt(e,192)}static uint200(e){return Qt(e,200)}static uint208(e){return Qt(e,208)}static uint216(e){return Qt(e,216)}static uint224(e){return Qt(e,224)}static uint232(e){return Qt(e,232)}static uint240(e){return Qt(e,240)}static uint248(e){return Qt(e,248)}static uint256(e){return Qt(e,256)}static uint(e){return Qt(e,256)}static int8(e){return Qt(e,-8)}static int16(e){return Qt(e,-16)}static int24(e){return Qt(e,-24)}static int32(e){return Qt(e,-32)}static int40(e){return Qt(e,-40)}static int48(e){return Qt(e,-48)}static int56(e){return Qt(e,-56)}static int64(e){return Qt(e,-64)}static int72(e){return Qt(e,-72)}static int80(e){return Qt(e,-80)}static int88(e){return Qt(e,-88)}static int96(e){return Qt(e,-96)}static int104(e){return Qt(e,-104)}static int112(e){return Qt(e,-112)}static int120(e){return Qt(e,-120)}static int128(e){return Qt(e,-128)}static int136(e){return Qt(e,-136)}static int144(e){return Qt(e,-144)}static int152(e){return Qt(e,-152)}static int160(e){return Qt(e,-160)}static int168(e){return Qt(e,-168)}static int176(e){return Qt(e,-176)}static int184(e){return Qt(e,-184)}static int192(e){return Qt(e,-192)}static int200(e){return Qt(e,-200)}static int208(e){return Qt(e,-208)}static int216(e){return Qt(e,-216)}static int224(e){return Qt(e,-224)}static int232(e){return Qt(e,-232)}static int240(e){return Qt(e,-240)}static int248(e){return Qt(e,-248)}static int256(e){return Qt(e,-256)}static int(e){return Qt(e,-256)}static bytes1(e){return Xt(e,1)}static bytes2(e){return Xt(e,2)}static bytes3(e){return Xt(e,3)}static bytes4(e){return Xt(e,4)}static bytes5(e){return Xt(e,5)}static bytes6(e){return Xt(e,6)}static bytes7(e){return Xt(e,7)}static bytes8(e){return Xt(e,8)}static bytes9(e){return Xt(e,9)}static bytes10(e){return Xt(e,10)}static bytes11(e){return Xt(e,11)}static bytes12(e){return Xt(e,12)}static bytes13(e){return Xt(e,13)}static bytes14(e){return Xt(e,14)}static bytes15(e){return Xt(e,15)}static bytes16(e){return Xt(e,16)}static bytes17(e){return Xt(e,17)}static bytes18(e){return Xt(e,18)}static bytes19(e){return Xt(e,19)}static bytes20(e){return Xt(e,20)}static bytes21(e){return Xt(e,21)}static bytes22(e){return Xt(e,22)}static bytes23(e){return Xt(e,23)}static bytes24(e){return Xt(e,24)}static bytes25(e){return Xt(e,25)}static bytes26(e){return Xt(e,26)}static bytes27(e){return Xt(e,27)}static bytes28(e){return Xt(e,28)}static bytes29(e){return Xt(e,29)}static bytes30(e){return Xt(e,30)}static bytes31(e){return Xt(e,31)}static bytes32(e){return Xt(e,32)}static address(t){return new e(Jt,"address",t)}static bool(t){return new e(Jt,"bool",!!t)}static bytes(t){return new e(Jt,"bytes",t)}static string(t){return new e(Jt,"string",t)}static array(e,t){throw new Error("not implemented yet")}static tuple(e,t){throw new Error("not implemented yet")}static overrides(t){return new e(Jt,"overrides",Object.assign({},t))}static isTyped(e){return e&&"object"==typeof e&&"_typedSymbol"in e&&e._typedSymbol===Yt}static dereference(t,r){if(e.isTyped(t)){if(t.type!==r)throw new Error(`invalid type: expecetd ${r}, got ${t.type}`);return t.value}return t}};class er extends ct{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){let r=Zt.dereference(t,"string");try{r=Vt(r)}catch(n){return this._throwError(n.message,t)}return e.writeValue(r)}decode(e){return Vt(Pe(e.readValue(),20))}}class tr extends ct{constructor(e){super(e.name,e.type,"_",e.dynamic),__publicField(this,"coder"),this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,t){return this.coder.encode(e,t)}decode(e){return this.coder.decode(e)}}function rr(e,t,r){let n=[];if(Array.isArray(r))n=r;else if(r&&"object"==typeof r){let e={};n=t.map((t=>{const n=t.localName;return le(n,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:t},value:r}),le(!e[n],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:t},value:r}),e[n]=!0,r[n]}))}else ce(!1,"invalid tuple value","tuple",r);ce(t.length===n.length,"types/value length mismatch","tuple",r);let s=new ut,i=new ut,o=[];t.forEach(((e,t)=>{let r=n[t];if(e.dynamic){let t=i.length;e.encode(i,r);let n=s.writeUpdatableValue();o.push((e=>{n(e+t)}))}else e.encode(s,r)})),o.forEach((e=>{e(s.length)}));let a=e.appendWriter(s);return a+=e.appendWriter(i),a}function nr(e,t){let r=[],n=[],s=e.subReader(0);return t.forEach((t=>{let i=null;if(t.dynamic){let r=e.readIndex(),n=s.subReader(r);try{i=t.decode(n)}catch(o){if(ie(o,"BUFFER_OVERRUN"))throw o;i=o,i.baseType=t.name,i.name=t.localName,i.type=t.type}}else try{i=t.decode(e)}catch(o){if(ie(o,"BUFFER_OVERRUN"))throw o;i=o,i.baseType=t.name,i.name=t.localName,i.type=t.type}if(null==i)throw new Error("investigate");r.push(i),n.push(t.localName||null)})),at.fromItems(r,n)}class sr extends ct{constructor(e,t,r){super("array",e.type+"["+(t>=0?t:"")+"]",r,-1===t||e.dynamic),__publicField(this,"coder"),__publicField(this,"length"),ne(this,{coder:e,length:t})}defaultValue(){const e=this.coder.defaultValue(),t=[];for(let r=0;r<this.length;r++)t.push(e);return t}encode(e,t){const r=Zt.dereference(t,"array");Array.isArray(r)||this._throwError("expected array value",r);let n=this.length;-1===n&&(n=r.length,e.writeValue(r.length)),ue(r.length,n,"coder array"+(this.localName?" "+this.localName:""));let s=[];for(let i=0;i<r.length;i++)s.push(this.coder);return rr(e,s,r)}decode(e){let t=this.length;-1===t&&(t=e.readIndex(),le(t*Ye<=e.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:e.bytes,offset:t*Ye,length:e.dataLength}));let r=[];for(let n=0;n<t;n++)r.push(new tr(this.coder));return nr(e,r)}}class ir extends ct{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){const r=Zt.dereference(t,"bool");return e.writeValue(r?1:0)}decode(e){return!!e.readValue()}}class or extends ct{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=me(t);let r=e.writeValue(t.length);return r+=e.writeBytes(t),r}decode(e){return e.readBytes(e.readIndex(),!0)}}class ar extends or{constructor(e){super("bytes",e)}decode(e){return _e(super.decode(e))}}class lr extends ct{constructor(e,t){let r="bytes"+String(e);super(r,r,t,!1),__publicField(this,"size"),ne(this,{size:e},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+2*this.size)}encode(e,t){let r=me(Zt.dereference(t,this.type));return r.length!==this.size&&this._throwError("incorrect data length",t),e.writeBytes(r)}decode(e){return _e(e.readBytes(this.size))}}const cr=new Uint8Array([]);class ur extends ct{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return null!=t&&this._throwError("not null",t),e.writeBytes(cr)}decode(e){return e.readBytes(0),null}}const dr=BigInt(0),hr=BigInt(1),pr=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class fr extends ct{constructor(e,t,r){const n=(t?"int":"uint")+8*e;super(n,n,r,!1),__publicField(this,"size"),__publicField(this,"signed"),ne(this,{size:e,signed:t},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(e,t){let r=Te(Zt.dereference(t,this.type)),n=Ae(pr,256);if(this.signed){let e=Ae(n,8*this.size-1);(r>e||r<-(e+hr))&&this._throwError("value out-of-bounds",t),r=function(e,t){let r=Te(e,"value");const n=BigInt(Ce(t,"width")),s=Ee<<n-Ee;if(r<xe)return r=-r,le(r<=s,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:e}),(~r&(Ee<<n)-Ee)+Ee;return le(r<s,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:e}),r}(r,256)}else(r<dr||r>Ae(n,8*this.size))&&this._throwError("value out-of-bounds",t);return e.writeValue(r)}decode(e){let t=Ae(e.readValue(),8*this.size);return this.signed&&(t=ke(t,8*this.size)),t}}class mr extends or{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,Ue(Zt.dereference(t,"string")))}decode(e){return Le(super.decode(e))}}class gr extends ct{constructor(e,t){let r=!1;const n=[];e.forEach((e=>{e.dynamic&&(r=!0),n.push(e.type)}));super("tuple","tuple("+n.join(",")+")",t,r),__publicField(this,"coders"),ne(this,{coders:Object.freeze(e.slice())})}defaultValue(){const e=[];this.coders.forEach((t=>{e.push(t.defaultValue())}));const t=this.coders.reduce(((e,t)=>{const r=t.localName;return r&&(e[r]||(e[r]=0),e[r]++),e}),{});return this.coders.forEach(((r,n)=>{let s=r.localName;s&&1===t[s]&&("length"===s&&(s="_length"),null==e[s]&&(e[s]=e[n]))})),Object.freeze(e)}encode(e,t){const r=Zt.dereference(t,"tuple");return rr(e,this.coders,r)}decode(e){return nr(e,this.coders)}}function yr(e,t){return{address:Vt(e),storageKeys:t.map(((e,t)=>(ce(ge(e,32),"invalid slot",`storageKeys[${t}]`,e),e.toLowerCase())))}}function _r(e){return Gt(Ue(e))}function br(e){const t=new Set;return e.forEach((e=>t.add(e))),Object.freeze(t)}const wr=br("external public payable override".split(" ")),vr="constant external internal payable private public pure view override",xr=br(vr.split(" ")),Er="constructor error event fallback function receive struct",Nr=br(Er.split(" ")),kr="calldata memory storage payable indexed",Ar=br(kr.split(" ")),Tr=br([Er,kr,"tuple returns",vr].join(" ").split(" ")),Sr={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},Rr=new RegExp("^(\\s*)"),Or=new RegExp("^([0-9]+)"),Cr=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),Pr=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),Mr=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$"),Fr=class e{constructor(e){__privateAdd(this,j),__privateAdd(this,M,void 0),__privateAdd(this,F,void 0),__privateSet(this,M,0),__privateSet(this,F,e.slice())}get offset(){return __privateGet(this,M)}get length(){return __privateGet(this,F).length-__privateGet(this,M)}clone(){return new e(__privateGet(this,F))}reset(){__privateSet(this,M,0)}popKeyword(e){const t=this.peek();if("KEYWORD"!==t.type||!e.has(t.text))throw new Error(`expected keyword ${t.text}`);return this.pop().text}popType(e){if(this.peek().type!==e){const t=this.peek();throw new Error(`expected ${e}; got ${t.type} ${JSON.stringify(t.text)}`)}return this.pop().text}popParen(){const e=this.peek();if("OPEN_PAREN"!==e.type)throw new Error("bad start");const t=__privateMethod(this,j,U).call(this,__privateGet(this,M)+1,e.match+1);return __privateSet(this,M,e.match+1),t}popParams(){const e=this.peek();if("OPEN_PAREN"!==e.type)throw new Error("bad start");const t=[];for(;__privateGet(this,M)<e.match-1;){const e=this.peek().linkNext;t.push(__privateMethod(this,j,U).call(this,__privateGet(this,M)+1,e)),__privateSet(this,M,e)}return __privateSet(this,M,e.match+1),t}peek(){if(__privateGet(this,M)>=__privateGet(this,F).length)throw new Error("out-of-bounds");return __privateGet(this,F)[__privateGet(this,M)]}peekKeyword(e){const t=this.peekType("KEYWORD");return null!=t&&e.has(t)?t:null}peekType(e){if(0===this.length)return null;const t=this.peek();return t.type===e?t.text:null}pop(){const e=this.peek();return __privateWrapper(this,M)._++,e}toString(){const e=[];for(let t=__privateGet(this,M);t<__privateGet(this,F).length;t++){const r=__privateGet(this,F)[t];e.push(`${r.type}:${r.text}`)}return`<TokenString ${e.join(" ")}>`}};M=new WeakMap,F=new WeakMap,j=new WeakSet,U=function(e=0,t=0){return new Fr(__privateGet(this,F).slice(e,t).map((t=>Object.freeze(Object.assign({},t,{match:t.match-e,linkBack:t.linkBack-e,linkNext:t.linkNext-e})))))};let jr=Fr;function Ur(e){const t=[],r=t=>{const r=i<e.length?JSON.stringify(e[i]):"$EOI";throw new Error(`invalid token ${r} at ${i}: ${t}`)};let n=[],s=[],i=0;for(;i<e.length;){let o=e.substring(i),a=o.match(Rr);a&&(i+=a[1].length,o=e.substring(i));const l={depth:n.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:i,value:-1};t.push(l);let c=Sr[o[0]]||"";if(c){if(l.type=c,l.text=o[0],i++,"OPEN_PAREN"===c)n.push(t.length-1),s.push(t.length-1);else if("CLOSE_PAREN"==c)0===n.length&&r("no matching open bracket"),l.match=n.pop(),t[l.match].match=t.length-1,l.depth--,l.linkBack=s.pop(),t[l.linkBack].linkNext=t.length-1;else if("COMMA"===c)l.linkBack=s.pop(),t[l.linkBack].linkNext=t.length-1,s.push(t.length-1);else if("OPEN_BRACKET"===c)l.type="BRACKET";else if("CLOSE_BRACKET"===c){let e=t.pop().text;if(t.length>0&&"NUMBER"===t[t.length-1].type){const r=t.pop().text;e=r+e,t[t.length-1].value=Ce(r)}if(0===t.length||"BRACKET"!==t[t.length-1].type)throw new Error("missing opening bracket");t[t.length-1].text+=e}}else if(a=o.match(Cr),a){if(l.text=a[1],i+=l.text.length,Tr.has(l.text)){l.type="KEYWORD";continue}if(l.text.match(Mr)){l.type="TYPE";continue}l.type="ID"}else{if(a=o.match(Or),!a)throw new Error(`unexpected token ${JSON.stringify(o[0])} at position ${i}`);l.text=a[1],l.type="NUMBER",i+=l.text.length}}return new jr(t.map((e=>Object.freeze(e))))}function Lr(e,t){let r=[];for(const n in t.keys())e.has(n)&&r.push(n);if(r.length>1)throw new Error(`conflicting types: ${r.join(", ")}`)}function Ir(e,t){if(t.peekKeyword(Nr)){const r=t.pop().text;if(r!==e)throw new Error(`expected ${e}, got ${r}`)}return t.popType("ID")}function Gr(e,t){const r=new Set;for(;;){const n=e.peekType("KEYWORD");if(null==n||t&&!t.has(n))break;if(e.pop(),r.has(n))throw new Error(`duplicate keywords: ${JSON.stringify(n)}`);r.add(n)}return Object.freeze(r)}function Dr(e){let t=Gr(e,xr);return Lr(t,br("constant payable nonpayable".split(" "))),Lr(t,br("pure view payable nonpayable".split(" "))),t.has("view")?"view":t.has("pure")?"pure":t.has("payable")?"payable":t.has("nonpayable")?"nonpayable":t.has("constant")?"view":"nonpayable"}function Br(e,t){return e.popParams().map((e=>tn.from(e,t)))}function Wr(e){if(e.peekType("AT")){if(e.pop(),e.peekType("NUMBER"))return Te(e.pop().text);throw new Error("invalid gas")}return null}function $r(e){if(e.length)throw new Error(`unexpected tokens at offset ${e.offset}: ${e.toString()}`)}const zr=new RegExp(/^(.*)\[([0-9]*)\]$/);function Vr(e){const t=e.match(Mr);if(ce(t,"invalid type","type",e),"uint"===e)return"uint256";if("int"===e)return"int256";if(t[2]){const r=parseInt(t[2]);ce(0!==r&&r<=32,"invalid bytes length","type",e)}else if(t[3]){const r=parseInt(t[3]);ce(0!==r&&r<=256&&r%8==0,"invalid numeric width","type",e)}return e}const Hr={},Kr=Symbol.for("_ethers_internal"),qr="_ParamTypeInternal",Jr="_ErrorInternal",Qr="_EventInternal",Xr="_ConstructorInternal",Yr="_FallbackInternal",Zr="_FunctionInternal",en="_StructInternal";L=new WeakSet,I=function(e,t,r,n){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 s=this.arrayChildren,i=t.slice();return i.forEach(((t,n)=>{var o;__privateMethod(o=s,L,I).call(o,e,t,r,(e=>{i[n]=e}))})),void n(i)}if(this.isTuple()){const s=this.components;let i;if(Array.isArray(t))i=t.slice();else{if(null==t||"object"!=typeof t)throw new Error("invalid tuple value");i=s.map((e=>{if(!e.name)throw new Error("cannot use object value with unnamed components");if(!(e.name in t))throw new Error(`missing value for component ${e.name}`);return t[e.name]}))}if(i.length!==this.components.length)throw new Error("array is wrong length");return i.forEach(((t,n)=>{var o;__privateMethod(o=s[n],L,I).call(o,e,t,r,(e=>{i[n]=e}))})),void n(i)}const s=r(this.type,t);s.then?e.push(function(){return __async(this,null,(function*(){n(yield s)}))}()):n(s)};let tn=class e{constructor(e,t,r,n,s,i,o,a){if(__privateAdd(this,L),__publicField(this,"name"),__publicField(this,"type"),__publicField(this,"baseType"),__publicField(this,"indexed"),__publicField(this,"components"),__publicField(this,"arrayLength"),__publicField(this,"arrayChildren"),he(e,Hr,"ParamType"),Object.defineProperty(this,Kr,{value:qr}),i&&(i=Object.freeze(i.slice())),"array"===n){if(null==o||null==a)throw new Error("")}else if(null!=o||null!=a)throw new Error("");if("tuple"===n){if(null==i)throw new Error("")}else if(null!=i)throw new Error("");ne(this,{name:t,type:r,baseType:n,indexed:s,components:i,arrayLength:o,arrayChildren:a})}format(e){if(null==e&&(e="sighash"),"json"===e){const t=this.name||"";if(this.isArray()){const e=JSON.parse(this.arrayChildren.format("json"));return e.name=t,e.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(e)}const r={type:"tuple"===this.baseType?"tuple":this.type,name:t};return"boolean"==typeof this.indexed&&(r.indexed=this.indexed),this.isTuple()&&(r.components=this.components.map((t=>JSON.parse(t.format(e))))),JSON.stringify(r)}let t="";return this.isArray()?(t+=this.arrayChildren.format(e),t+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?t+="("+this.components.map((t=>t.format(e))).join("full"===e?", ":",")+")":t+=this.type,"sighash"!==e&&(!0===this.indexed&&(t+=" indexed"),"full"===e&&this.name&&(t+=" "+this.name)),t}isArray(){return"array"===this.baseType}isTuple(){return"tuple"===this.baseType}isIndexable(){return null!=this.indexed}walk(e,t){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 r=this;return e.map((e=>r.arrayChildren.walk(e,t)))}if(this.isTuple()){if(!Array.isArray(e))throw new Error("invalid tuple value");if(e.length!==this.components.length)throw new Error("array is wrong length");const r=this;return e.map(((e,n)=>r.components[n].walk(e,t)))}return t(this.type,e)}walkAsync(e,t){return __async(this,null,(function*(){const r=[],n=[e];return __privateMethod(this,L,I).call(this,r,e,t,(e=>{n[0]=e})),r.length&&(yield Promise.all(r)),n[0]}))}static from(t,r){if(e.isParamType(t))return t;if("string"==typeof t)try{return e.from(Ur(t),r)}catch(a){ce(!1,"invalid param type","obj",t)}else if(t instanceof jr){let n="",s="",i=null;Gr(t,br(["tuple"])).has("tuple")||t.peekType("OPEN_PAREN")?(s="tuple",i=t.popParams().map((t=>e.from(t))),n=`tuple(${i.map((e=>e.format())).join(",")})`):(n=Vr(t.popType("TYPE")),s=n);let o=null,a=null;for(;t.length&&t.peekType("BRACKET");){const r=t.pop();o=new e(Hr,"",n,s,null,i,a,o),a=r.value,n+=r.text,s="array",i=null}let l=null;if(Gr(t,Ar).has("indexed")){if(!r)throw new Error("");l=!0}const c=t.peekType("ID")?t.pop().text:"";if(t.length)throw new Error("leftover tokens");return new e(Hr,c,n,s,l,i,a,o)}const n=t.name;ce(!n||"string"==typeof n&&n.match(Pr),"invalid name","obj.name",n);let s=t.indexed;null!=s&&(ce(r,"parameter cannot be indexed","obj.indexed",t.indexed),s=!!s);let i=t.type,o=i.match(zr);if(o){const r=parseInt(o[2]||"-1"),a=e.from({type:o[1],components:t.components});return new e(Hr,n||"",i,"array",s,null,r,a)}if("tuple"===i||i.startsWith("tuple(")||i.startsWith("(")){const r=null!=t.components?t.components.map((t=>e.from(t))):null;return new e(Hr,n||"",i,"tuple",s,r,null,null)}return i=Vr(t.type),new e(Hr,n||"",i,i,s,null,null,null)}static isParamType(e){return e&&e[Kr]===qr}};class rn{constructor(e,t,r){__publicField(this,"type"),__publicField(this,"inputs"),he(e,Hr,"Fragment"),ne(this,{type:t,inputs:r=Object.freeze(r.slice())})}static from(e){if("string"==typeof e){try{rn.from(JSON.parse(e))}catch(t){}return rn.from(Ur(e))}if(e instanceof jr){switch(e.peekKeyword(Nr)){case"constructor":return ln.from(e);case"error":return on.from(e);case"event":return an.from(e);case"fallback":case"receive":return cn.from(e);case"function":return un.from(e);case"struct":return dn.from(e)}}else if("object"==typeof e){switch(e.type){case"constructor":return ln.from(e);case"error":return on.from(e);case"event":return an.from(e);case"fallback":case"receive":return cn.from(e);case"function":return un.from(e);case"struct":return dn.from(e)}le(!1,`unsupported type: ${e.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}ce(!1,"unsupported frgament object","obj",e)}static isConstructor(e){return ln.isFragment(e)}static isError(e){return on.isFragment(e)}static isEvent(e){return an.isFragment(e)}static isFunction(e){return un.isFragment(e)}static isStruct(e){return dn.isFragment(e)}}class nn extends rn{constructor(e,t,r,n){super(e,t,n),__publicField(this,"name"),ce("string"==typeof r&&r.match(Pr),"invalid identifier","name",r),n=Object.freeze(n.slice()),ne(this,{name:r})}}function sn(e,t){return"("+t.map((t=>t.format(e))).join("full"===e?", ":",")+")"}class on extends nn{constructor(e,t,r){super(e,"error",t,r),Object.defineProperty(this,Kr,{value:Jr})}get selector(){return _r(this.format("sighash")).substring(0,10)}format(e){if(null==e&&(e="sighash"),"json"===e)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map((t=>JSON.parse(t.format(e))))});const t=[];return"sighash"!==e&&t.push("error"),t.push(this.name+sn(e,this.inputs)),t.join(" ")}static from(e){if(on.isFragment(e))return e;if("string"==typeof e)return on.from(Ur(e));if(e instanceof jr){const t=Ir("error",e),r=Br(e);return $r(e),new on(Hr,t,r)}return new on(Hr,e.name,e.inputs?e.inputs.map(tn.from):[])}static isFragment(e){return e&&e[Kr]===Jr}}class an extends nn{constructor(e,t,r,n){super(e,"event",t,r),__publicField(this,"anonymous"),Object.defineProperty(this,Kr,{value:Qr}),ne(this,{anonymous:n})}get topicHash(){return _r(this.format("sighash"))}format(e){if(null==e&&(e="sighash"),"json"===e)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map((t=>JSON.parse(t.format(e))))});const t=[];return"sighash"!==e&&t.push("event"),t.push(this.name+sn(e,this.inputs)),"sighash"!==e&&this.anonymous&&t.push("anonymous"),t.join(" ")}static getTopicHash(e,t){t=(t||[]).map((e=>tn.from(e)));return new an(Hr,e,t,!1).topicHash}static from(e){if(an.isFragment(e))return e;if("string"==typeof e)try{return an.from(Ur(e))}catch(t){ce(!1,"invalid event fragment","obj",e)}else if(e instanceof jr){const t=Ir("event",e),r=Br(e,!0),n=!!Gr(e,br(["anonymous"])).has("anonymous");return $r(e),new an(Hr,t,r,n)}return new an(Hr,e.name,e.inputs?e.inputs.map((e=>tn.from(e,!0))):[],!!e.anonymous)}static isFragment(e){return e&&e[Kr]===Qr}}class ln extends rn{constructor(e,t,r,n,s){super(e,t,r),__publicField(this,"payable"),__publicField(this,"gas"),Object.defineProperty(this,Kr,{value:Xr}),ne(this,{payable:n,gas:s})}format(e){if(le(null!=e&&"sighash"!==e,"cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),"json"===e)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((t=>JSON.parse(t.format(e))))});const t=[`constructor${sn(e,this.inputs)}`];return this.payable&&t.push("payable"),null!=this.gas&&t.push(`@${this.gas.toString()}`),t.join(" ")}static from(e){if(ln.isFragment(e))return e;if("string"==typeof e)try{return ln.from(Ur(e))}catch(t){ce(!1,"invalid constuctor fragment","obj",e)}else if(e instanceof jr){Gr(e,br(["constructor"]));const t=Br(e),r=!!Gr(e,wr).has("payable"),n=Wr(e);return $r(e),new ln(Hr,"constructor",t,r,n)}return new ln(Hr,"constructor",e.inputs?e.inputs.map(tn.from):[],!!e.payable,null!=e.gas?e.gas:null)}static isFragment(e){return e&&e[Kr]===Xr}}class cn extends rn{constructor(e,t,r){super(e,"fallback",t),__publicField(this,"payable"),Object.defineProperty(this,Kr,{value:Yr}),ne(this,{payable:r})}format(e){const t=0===this.inputs.length?"receive":"fallback";if("json"===e){const e=this.payable?"payable":"nonpayable";return JSON.stringify({type:t,stateMutability:e})}return`${t}()${this.payable?" payable":""}`}static from(e){if(cn.isFragment(e))return e;if("string"==typeof e)try{return cn.from(Ur(e))}catch(t){ce(!1,"invalid fallback fragment","obj",e)}else if(e instanceof jr){const t=e.toString();ce(e.peekKeyword(br(["fallback","receive"])),"type must be fallback or receive","obj",t);if("receive"===e.popKeyword(br(["fallback","receive"]))){const t=Br(e);return ce(0===t.length,"receive cannot have arguments","obj.inputs",t),Gr(e,br(["payable"])),$r(e),new cn(Hr,[],!0)}let r=Br(e);r.length?ce(1===r.length&&"bytes"===r[0].type,"invalid fallback inputs","obj.inputs",r.map((e=>e.format("minimal"))).join(", ")):r=[tn.from("bytes")];const n=Dr(e);if(ce("nonpayable"===n||"payable"===n,"fallback cannot be constants","obj.stateMutability",n),Gr(e,br(["returns"])).has("returns")){const t=Br(e);ce(1===t.length&&"bytes"===t[0].type,"invalid fallback outputs","obj.outputs",t.map((e=>e.format("minimal"))).join(", "))}return $r(e),new cn(Hr,r,"payable"===n)}if("receive"===e.type)return new cn(Hr,[],!0);if("fallback"===e.type){const t=[tn.from("bytes")],r="payable"===e.stateMutability;return new cn(Hr,t,r)}ce(!1,"invalid fallback description","obj",e)}static isFragment(e){return e&&e[Kr]===Yr}}class un extends nn{constructor(e,t,r,n,s,i){super(e,"function",t,n),__publicField(this,"constant"),__publicField(this,"outputs"),__publicField(this,"stateMutability"),__publicField(this,"payable"),__publicField(this,"gas"),Object.defineProperty(this,Kr,{value:Zr});ne(this,{constant:"view"===r||"pure"===r,gas:i,outputs:s=Object.freeze(s.slice()),payable:"payable"===r,stateMutability:r})}get selector(){return _r(this.format("sighash")).substring(0,10)}format(e){if(null==e&&(e="sighash"),"json"===e)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((t=>JSON.parse(t.format(e)))),outputs:this.outputs.map((t=>JSON.parse(t.format(e))))});const t=[];return"sighash"!==e&&t.push("function"),t.push(this.name+sn(e,this.inputs)),"sighash"!==e&&("nonpayable"!==this.stateMutability&&t.push(this.stateMutability),this.outputs&&this.outputs.length&&(t.push("returns"),t.push(sn(e,this.outputs))),null!=this.gas&&t.push(`@${this.gas.toString()}`)),t.join(" ")}static getSelector(e,t){t=(t||[]).map((e=>tn.from(e)));return new un(Hr,e,"view",t,[],null).selector}static from(e){if(un.isFragment(e))return e;if("string"==typeof e)try{return un.from(Ur(e))}catch(r){ce(!1,"invalid function fragment","obj",e)}else if(e instanceof jr){const t=Ir("function",e),r=Br(e),n=Dr(e);let s=[];Gr(e,br(["returns"])).has("returns")&&(s=Br(e));const i=Wr(e);return $r(e),new un(Hr,t,n,r,s,i)}let t=e.stateMutability;return null==t&&(t="payable","boolean"==typeof e.constant?(t="view",e.constant||(t="payable","boolean"!=typeof e.payable||e.payable||(t="nonpayable"))):"boolean"!=typeof e.payable||e.payable||(t="nonpayable")),new un(Hr,e.name,t,e.inputs?e.inputs.map(tn.from):[],e.outputs?e.outputs.map(tn.from):[],null!=e.gas?e.gas:null)}static isFragment(e){return e&&e[Kr]===Zr}}class dn extends nn{constructor(e,t,r){super(e,"struct",t,r),Object.defineProperty(this,Kr,{value:en})}format(){throw new Error("@TODO")}static from(e){if("string"==typeof e)try{return dn.from(Ur(e))}catch(t){ce(!1,"invalid struct fragment","obj",e)}else if(e instanceof jr){const t=Ir("struct",e),r=Br(e);return $r(e),new dn(Hr,t,r)}return new dn(Hr,e.name,e.inputs?e.inputs.map(tn.from):[])}static isFragment(e){return e&&e[Kr]===en}}const hn=new Map;hn.set(0,"GENERIC_PANIC"),hn.set(1,"ASSERT_FALSE"),hn.set(17,"OVERFLOW"),hn.set(18,"DIVIDE_BY_ZERO"),hn.set(33,"ENUM_RANGE_ERROR"),hn.set(34,"BAD_STORAGE_DATA"),hn.set(49,"STACK_UNDERFLOW"),hn.set(50,"ARRAY_RANGE_ERROR"),hn.set(65,"OUT_OF_MEMORY"),hn.set(81,"UNINITIALIZED_FUNCTION_CALL");const pn=new RegExp(/^bytes([0-9]*)$/),fn=new RegExp(/^(u?int)([0-9]*)$/);let mn=null,gn=1024;G=new WeakSet,D=function(e){if(e.isArray())return new sr(__privateMethod(this,G,D).call(this,e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new gr(e.components.map((e=>__privateMethod(this,G,D).call(this,e))),e.name);switch(e.baseType){case"address":return new er(e.name);case"bool":return new ir(e.name);case"string":return new mr(e.name);case"bytes":return new ar(e.name);case"":return new ur(e.name)}let t=e.type.match(fn);if(t){let r=parseInt(t[2]||"256");return ce(0!==r&&r<=256&&r%8==0,"invalid "+t[1]+" bit length","param",e),new fr(r/8,"int"===t[1],e.name)}if(t=e.type.match(pn),t){let r=parseInt(t[1]);return ce(0!==r&&r<=32,"invalid bytes length","param",e),new lr(r,e.name)}ce(!1,"invalid type","type",e.type)};let yn=class e{constructor(){__privateAdd(this,G)}getDefaultValue(e){const t=e.map((e=>__privateMethod(this,G,D).call(this,tn.from(e))));return new gr(t,"_").defaultValue()}encode(e,t){ue(t.length,e.length,"types/values length mismatch");const r=e.map((e=>__privateMethod(this,G,D).call(this,tn.from(e)))),n=new gr(r,"_"),s=new ut;return n.encode(s,t),s.data}decode(e,t,r){const n=e.map((e=>__privateMethod(this,G,D).call(this,tn.from(e))));return new gr(n,"_").decode(new dt(t,r,gn))}static _setDefaultMaxInflation(e){ce("number"==typeof e&&Number.isInteger(e),"invalid defaultMaxInflation factor","value",e),gn=e}static defaultAbiCoder(){return null==mn&&(mn=new e),mn}static getBuiltinCallException(t,r,n){return function(e,t,r,n){let s="missing revert data",i=null,o=null;if(r){s="execution reverted";const e=fe(r);if(r=_e(r),0===e.length)s+=" (no data present; likely require(false) occurred",i="require(false)";else if(e.length%32!=4)s+=" (could not decode reason; invalid data length)";else if("0x08c379a0"===_e(e.slice(0,4)))try{i=n.decode(["string"],e.slice(4))[0],o={signature:"Error(string)",name:"Error",args:[i]},s+=`: ${JSON.stringify(i)}`}catch(l){s+=" (could not decode reason; invalid string data)"}else if("0x4e487b71"===_e(e.slice(0,4)))try{const t=Number(n.decode(["uint256"],e.slice(4))[0]);o={signature:"Panic(uint256)",name:"Panic",args:[t]},i=`Panic due to ${hn.get(t)||"UNKNOWN"}(${t})`,s+=`: ${i}`}catch(l){s+=" (could not decode panic code)"}else s+=" (unknown custom error)"}const a={to:t.to?Vt(t.to):null,data:t.data||"0x"};return t.from&&(a.from=Vt(t.from)),ae(s,"CALL_EXCEPTION",{action:e,data:r,reason:i,transaction:a,invocation:null,revert:o})}(t,r,n,e.defaultAbiCoder())}};class _n{constructor(e,t,r){__publicField(this,"fragment"),__publicField(this,"name"),__publicField(this,"signature"),__publicField(this,"topic"),__publicField(this,"args");const n=e.name,s=e.format();ne(this,{fragment:e,name:n,signature:s,topic:t,args:r})}}class bn{constructor(e,t,r,n){__publicField(this,"fragment"),__publicField(this,"name"),__publicField(this,"args"),__publicField(this,"signature"),__publicField(this,"selector"),__publicField(this,"value");const s=e.name,i=e.format();ne(this,{fragment:e,name:s,args:r,signature:i,selector:t,value:n})}}class wn{constructor(e,t,r){__publicField(this,"fragment"),__publicField(this,"name"),__publicField(this,"args"),__publicField(this,"signature"),__publicField(this,"selector");const n=e.name,s=e.format();ne(this,{fragment:e,name:n,args:r,signature:s,selector:t})}}class vn{constructor(e){__publicField(this,"hash"),__publicField(this,"_isIndexed"),ne(this,{hash:e,_isIndexed:!0})}static isIndexed(e){return!(!e||!e._isIndexed)}}const xn={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"},En={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:e=>`reverted with reason string ${JSON.stringify(e)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:e=>{let t="unknown panic code";return e>=0&&e<=255&&xn[e.toString()]&&(t=xn[e.toString()]),`reverted with panic code 0x${e.toString(16)} (${t})`}}};B=new WeakMap,W=new WeakMap,$=new WeakMap,z=new WeakMap,V=new WeakSet,H=function(e,t,r){if(ge(e)){const t=e.toLowerCase();for(const e of __privateGet(this,$).values())if(t===e.selector)return e;return null}if(-1===e.indexOf("(")){const n=[];for(const[t,r]of __privateGet(this,$))t.split("(")[0]===e&&n.push(r);if(t){const e=t.length>0?t[t.length-1]:null;let r=t.length,s=!0;Zt.isTyped(e)&&"overrides"===e.type&&(s=!1,r--);for(let t=n.length-1;t>=0;t--){const e=n[t].inputs.length;e===r||s&&e===r-1||n.splice(t,1)}for(let i=n.length-1;i>=0;i--){const e=n[i].inputs;for(let r=0;r<t.length;r++)if(Zt.isTyped(t[r])){if(r>=e.length){if("overrides"===t[r].type)continue;n.splice(i,1);break}if(t[r].type!==e[r].baseType){n.splice(i,1);break}}}}if(1===n.length&&t&&t.length!==n[0].inputs.length){const e=t[t.length-1];(null==e||Array.isArray(e)||"object"!=typeof e)&&n.splice(0,1)}if(0===n.length)return null;if(n.length>1&&r){ce(!1,`ambiguous function description (i.e. matches ${n.map((e=>JSON.stringify(e.format()))).join(", ")})`,"key",e)}return n[0]}const n=__privateGet(this,$).get(un.from(e).format());return n||null},K=new WeakSet,q=function(e,t,r){if(ge(e)){const t=e.toLowerCase();for(const e of __privateGet(this,W).values())if(t===e.topicHash)return e;return null}if(-1===e.indexOf("(")){const n=[];for(const[t,r]of __privateGet(this,W))t.split("(")[0]===e&&n.push(r);if(t){for(let e=n.length-1;e>=0;e--)n[e].inputs.length<t.length&&n.splice(e,1);for(let e=n.length-1;e>=0;e--){const r=n[e].inputs;for(let s=0;s<t.length;s++)if(Zt.isTyped(t[s])&&t[s].type!==r[s].baseType){n.splice(e,1);break}}}if(0===n.length)return null;if(n.length>1&&r){ce(!1,`ambiguous event description (i.e. matches ${n.map((e=>JSON.stringify(e.format()))).join(", ")})`,"key",e)}return n[0]}const n=__privateGet(this,W).get(an.from(e).format());return n||null};let Nn=class e{constructor(e){__privateAdd(this,V),__privateAdd(this,K),__publicField(this,"fragments"),__publicField(this,"deploy"),__publicField(this,"fallback"),__publicField(this,"receive"),__privateAdd(this,B,void 0),__privateAdd(this,W,void 0),__privateAdd(this,$,void 0),__privateAdd(this,z,void 0);let t=[];t="string"==typeof e?JSON.parse(e):e,__privateSet(this,$,new Map),__privateSet(this,B,new Map),__privateSet(this,W,new Map);const r=[];for(const o of t)try{r.push(rn.from(o))}catch(i){console.log(`[Warning] Invalid Fragment ${JSON.stringify(o)}:`,i.message)}ne(this,{fragments:Object.freeze(r)});let n=null,s=!1;__privateSet(this,z,this.getAbiCoder()),this.fragments.forEach(((e,t)=>{let r;switch(e.type){case"constructor":return this.deploy?void console.log("duplicate definition - constructor"):void ne(this,{deploy:e});case"fallback":return void(0===e.inputs.length?s=!0:(ce(!n||e.payable!==n.payable,"conflicting fallback fragments",`fragments[${t}]`,e),n=e,s=n.payable));case"function":r=__privateGet(this,$);break;case"event":r=__privateGet(this,W);break;case"error":r=__privateGet(this,B);break;default:return}const i=e.format();r.has(i)||r.set(i,e)})),this.deploy||ne(this,{deploy:ln.from("constructor()")}),ne(this,{fallback:n,receive:s})}format(e){const t=e?"minimal":"full";return this.fragments.map((e=>e.format(t)))}formatJson(){const e=this.fragments.map((e=>e.format("json")));return JSON.stringify(e.map((e=>JSON.parse(e))))}getAbiCoder(){return yn.defaultAbiCoder()}getFunctionName(e){const t=__privateMethod(this,V,H).call(this,e,null,!1);return ce(t,"no matching function","key",e),t.name}hasFunction(e){return!!__privateMethod(this,V,H).call(this,e,null,!1)}getFunction(e,t){return __privateMethod(this,V,H).call(this,e,t||null,!0)}forEachFunction(e){const t=Array.from(__privateGet(this,$).keys());t.sort(((e,t)=>e.localeCompare(t)));for(let r=0;r<t.length;r++){const n=t[r];e(__privateGet(this,$).get(n),r)}}getEventName(e){const t=__privateMethod(this,K,q).call(this,e,null,!1);return ce(t,"no matching event","key",e),t.name}hasEvent(e){return!!__privateMethod(this,K,q).call(this,e,null,!1)}getEvent(e,t){return __privateMethod(this,K,q).call(this,e,t||null,!0)}forEachEvent(e){const t=Array.from(__privateGet(this,W).keys());t.sort(((e,t)=>e.localeCompare(t)));for(let r=0;r<t.length;r++){const n=t[r];e(__privateGet(this,W).get(n),r)}}getError(e,t){if(ge(e)){const t=e.toLowerCase();if(En[t])return on.from(En[t].signature);for(const e of __privateGet(this,B).values())if(t===e.selector)return e;return null}if(-1===e.indexOf("(")){const t=[];for(const[r,n]of __privateGet(this,B))r.split("(")[0]===e&&t.push(n);if(0===t.length)return"Error"===e?on.from("error Error(string)"):"Panic"===e?on.from("error Panic(uint256)"):null;if(t.length>1){ce(!1,`ambiguous error description (i.e. ${t.map((e=>JSON.stringify(e.format()))).join(", ")})`,"name",e)}return t[0]}if("Error(string)"===(e=on.from(e).format()))return on.from("error Error(string)");if("Panic(uint256)"===e)return on.from("error Panic(uint256)");const r=__privateGet(this,B).get(e);return r||null}forEachError(e){const t=Array.from(__privateGet(this,B).keys());t.sort(((e,t)=>e.localeCompare(t)));for(let r=0;r<t.length;r++){const n=t[r];e(__privateGet(this,B).get(n),r)}}_decodeParams(e,t){return __privateGet(this,z).decode(e,t)}_encodeParams(e,t){return __privateGet(this,z).encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){if("string"==typeof e){const t=this.getError(e);ce(t,"unknown error","fragment",e),e=t}return ce(we(t,0,4)===e.selector,`data signature does not match error ${e.name}.`,"data",t),this._decodeParams(e.inputs,we(t,4))}encodeErrorResult(e,t){if("string"==typeof e){const t=this.getError(e);ce(t,"unknown error","fragment",e),e=t}return be([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionData(e,t){if("string"==typeof e){const t=this.getFunction(e);ce(t,"unknown function","fragment",e),e=t}return ce(we(t,0,4)===e.selector,`data signature does not match function ${e.name}.`,"data",t),this._decodeParams(e.inputs,we(t,4))}encodeFunctionData(e,t){if("string"==typeof e){const t=this.getFunction(e);ce(t,"unknown function","fragment",e),e=t}return be([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionResult(e,t){if("string"==typeof e){const t=this.getFunction(e);ce(t,"unknown function","fragment",e),e=t}let r="invalid length for result data";const n=me(t);if(n.length%32==0)try{return __privateGet(this,z).decode(e.outputs,n)}catch(s){r="could not decode result data"}le(!1,r,"BAD_DATA",{value:_e(n),info:{method:e.name,signature:e.format()}})}makeError(e,t){const r=fe(e,"data"),n=yn.getBuiltinCallException("call",t,r);if(n.message.startsWith("execution reverted (unknown custom error)")){const e=_e(r.slice(0,4)),t=this.getError(e);if(t)try{const e=__privateGet(this,z).decode(t.inputs,r.slice(4));n.revert={name:t.name,signature:t.format(),args:e},n.reason=n.revert.signature,n.message=`execution reverted: ${n.reason}`}catch(i){n.message="execution reverted (coult not decode custom error)"}}const s=this.parseTransaction(t);return s&&(n.invocation={method:s.name,signature:s.signature,args:s.args}),n}encodeFunctionResult(e,t){if("string"==typeof e){const t=this.getFunction(e);ce(t,"unknown function","fragment",e),e=t}return _e(__privateGet(this,z).encode(e.outputs,t||[]))}encodeFilterTopics(e,t){if("string"==typeof e){const t=this.getEvent(e);ce(t,"unknown event","eventFragment",e),e=t}le(t.length<=e.inputs.length,`too many arguments for ${e.format()}`,"UNEXPECTED_ARGUMENT",{count:t.length,expectedCount:e.inputs.length});const r=[];e.anonymous||r.push(e.topicHash);const n=(e,t)=>"string"===e.type?_r(t):"bytes"===e.type?Gt(_e(t)):("bool"===e.type&&"boolean"==typeof t?t=t?"0x01":"0x00":e.type.match(/^u?int/)?t=Pe(t):e.type.match(/^bytes/)?t=ve(t,32,!1):"address"===e.type&&__privateGet(this,z).encode(["address"],[t]),function(e,t){return ve(e,t,!0)}(_e(t),32));for(t.forEach(((t,s)=>{const i=e.inputs[s];i.indexed?null==t?r.push(null):"array"===i.baseType||"tuple"===i.baseType?ce(!1,"filtering with tuples or arrays not supported","contract."+i.name,t):Array.isArray(t)?r.push(t.map((e=>n(i,e)))):r.push(n(i,t)):ce(null==t,"cannot filter non-indexed parameters; must be null","contract."+i.name,t)}));r.length&&null===r[r.length-1];)r.pop();return r}encodeEventLog(e,t){if("string"==typeof e){const t=this.getEvent(e);ce(t,"unknown event","eventFragment",e),e=t}const r=[],n=[],s=[];return e.anonymous||r.push(e.topicHash),ce(t.length===e.inputs.length,"event arguments/values mismatch","values",t),e.inputs.forEach(((e,i)=>{const o=t[i];if(e.indexed)if("string"===e.type)r.push(_r(o));else if("bytes"===e.type)r.push(Gt(o));else{if("tuple"===e.baseType||"array"===e.baseType)throw new Error("not implemented");r.push(__privateGet(this,z).encode([e.type],[o]))}else n.push(e),s.push(o)})),{data:__privateGet(this,z).encode(n,s),topics:r}}decodeEventLog(e,t,r){if("string"==typeof e){const t=this.getEvent(e);ce(t,"unknown event","eventFragment",e),e=t}if(null!=r&&!e.anonymous){const t=e.topicHash;ce(ge(r[0],32)&&r[0].toLowerCase()===t,"fragment/topic mismatch","topics[0]",r[0]),r=r.slice(1)}const n=[],s=[],i=[];e.inputs.forEach(((e,t)=>{e.indexed?"string"===e.type||"bytes"===e.type||"tuple"===e.baseType||"array"===e.baseType?(n.push(tn.from({type:"bytes32",name:e.name})),i.push(!0)):(n.push(e),i.push(!1)):(s.push(e),i.push(!1))}));const o=null!=r?__privateGet(this,z).decode(n,be(r)):null,a=__privateGet(this,z).decode(s,t,!0),l=[],c=[];let u=0,d=0;return e.inputs.forEach(((e,t)=>{let r=null;if(e.indexed)if(null==o)r=new vn(null);else if(i[t])r=new vn(o[d++]);else try{r=o[d++]}catch(n){r=n}else try{r=a[u++]}catch(n){r=n}l.push(r),c.push(e.name||null)})),at.fromItems(l,c)}parseTransaction(e){const t=fe(e.data,"tx.data"),r=Te(null!=e.value?e.value:0,"tx.value"),n=this.getFunction(_e(t.slice(0,4)));if(!n)return null;const s=__privateGet(this,z).decode(n.inputs,t.slice(4));return new bn(n,n.selector,s,r)}parseCallResult(e){throw new Error("@TODO")}parseLog(e){const t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new _n(t,t.topicHash,this.decodeEventLog(t,e.data,e.topics))}parseError(e){const t=_e(e),r=this.getError(we(t,0,4));if(!r)return null;const n=__privateGet(this,z).decode(r.inputs,we(t,4));return new wn(r,r.selector,n)}static from(t){return t instanceof e?t:"string"==typeof t?new e(JSON.parse(t)):"function"==typeof t.formatJson?new e(t.formatJson()):"function"==typeof t.format?new e(t.format("json")):new e(t)}};const kn=BigInt(0);function An(e){return null==e?null:e.toString()}function Tn(e){const t={};e.to&&(t.to=e.to),e.from&&(t.from=e.from),e.data&&(t.data=_e(e.data));const r="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const s of r)s in e&&null!=e[s]&&(t[s]=Te(e[s],`request.${s}`));const n="type,nonce".split(/,/);for(const s of n)s in e&&null!=e[s]&&(t[s]=Ce(e[s],`request.${s}`));return e.accessList&&(t.accessList=function(e){if(Array.isArray(e))return e.map(((t,r)=>Array.isArray(t)?(ce(2===t.length,"invalid slot set",`value[${r}]`,t),yr(t[0],t[1])):(ce(null!=t&&"object"==typeof t,"invalid address-slot set","value",e),yr(t.address,t.storageKeys))));ce(null!=e&&"object"==typeof e,"invalid access list","value",e);const t=Object.keys(e).map((t=>{const r=e[t].reduce(((e,t)=>(e[t]=!0,e)),{});return yr(t,Object.keys(r).sort())}));return t.sort(((e,t)=>e.address.localeCompare(t.address))),t}(e.accessList)),e.authorizationList&&(t.authorizationList=e.authorizationList.slice()),"blockTag"in e&&(t.blockTag=e.blockTag),"enableCcipRead"in e&&(t.enableCcipRead=!!e.enableCcipRead),"customData"in e&&(t.customData=e.customData),"blobVersionedHashes"in e&&e.blobVersionedHashes&&(t.blobVersionedHashes=e.blobVersionedHashes.slice()),"kzg"in e&&(t.kzg=e.kzg),"blobs"in e&&e.blobs&&(t.blobs=e.blobs.map((e=>{return ge(t=e,!0)||t instanceof Uint8Array?_e(e):Object.assign({},e);var t}))),t}class Sn{constructor(e,t){__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=t;const r=Object.freeze(e.topics.slice());ne(this,{transactionHash:e.transactionHash,blockHash:e.blockHash,blockNumber:e.blockNumber,removed:e.removed,address:e.address,data:e.data,topics:r,index:e.index,transactionIndex:e.transactionIndex})}toJSON(){const{address:e,blockHash:t,blockNumber:r,data:n,index:s,removed:i,topics:o,transactionHash:a,transactionIndex:l}=this;return{_type:"log",address:e,blockHash:t,blockNumber:r,data:n,index:s,removed:i,topics:o,transactionHash:a,transactionIndex:l}}getBlock(){return __async(this,null,(function*(){const e=yield this.provider.getBlock(this.blockHash);return le(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}))}getTransaction(){return __async(this,null,(function*(){const e=yield this.provider.getTransaction(this.transactionHash);return le(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}))}getTransactionReceipt(){return __async(this,null,(function*(){const e=yield this.provider.getTransactionReceipt(this.transactionHash);return le(!!e,"failed to find transaction receipt","UNKNOWN_ERROR",{}),e}))}removedEvent(){return{orphan:"drop-log",log:{transactionHash:(e=this).transactionHash,blockHash:e.blockHash,blockNumber:e.blockNumber,address:e.address,data:e.data,topics:Object.freeze(e.topics.slice()),index:e.index}};var e}}class Rn{constructor(e,t){__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,J,void 0),__privateSet(this,J,Object.freeze(e.logs.map((e=>new Sn(e,t)))));let r=kn;null!=e.effectiveGasPrice?r=e.effectiveGasPrice:null!=e.gasPrice&&(r=e.gasPrice),ne(this,{provider:t,to:e.to,from:e.from,contractAddress:e.contractAddress,hash:e.hash,index:e.index,blockHash:e.blockHash,blockNumber:e.blockNumber,logsBloom:e.logsBloom,gasUsed:e.gasUsed,cumulativeGasUsed:e.cumulativeGasUsed,blobGasUsed:e.blobGasUsed,gasPrice:r,blobGasPrice:e.blobGasPrice,type:e.type,status:e.status,root:e.root})}get logs(){return __privateGet(this,J)}toJSON(){const{to:e,from:t,contractAddress:r,hash:n,index:s,blockHash:i,blockNumber:o,logsBloom:a,logs:l,status:c,root:u}=this;return{_type:"TransactionReceipt",blockHash:i,blockNumber:o,contractAddress:r,cumulativeGasUsed:An(this.cumulativeGasUsed),from:t,gasPrice:An(this.gasPrice),blobGasUsed:An(this.blobGasUsed),blobGasPrice:An(this.blobGasPrice),gasUsed:An(this.gasUsed),hash:n,index:s,logs:l,logsBloom:a,root:u,status:c,to:e}}get length(){return this.logs.length}[Symbol.iterator](){let e=0;return{next:()=>e<this.length?{value:this.logs[e++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}getBlock(){return __async(this,null,(function*(){const e=yield this.provider.getBlock(this.blockHash);if(null==e)throw new Error("TODO");return e}))}getTransaction(){return __async(this,null,(function*(){const e=yield this.provider.getTransaction(this.hash);if(null==e)throw new Error("TODO");return e}))}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 Pn(this)}reorderedEvent(e){return le(!e||e.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),Cn(this,e)}}J=new WeakMap;Q=new WeakMap;let On=class e{constructor(e,t){__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,Q,void 0),this.provider=t,this.blockNumber=null!=e.blockNumber?e.blockNumber:null,this.blockHash=null!=e.blockHash?e.blockHash:null,this.hash=e.hash,this.index=e.index,this.type=e.type,this.from=e.from,this.to=e.to||null,this.gasLimit=e.gasLimit,this.nonce=e.nonce,this.data=e.data,this.value=e.value,this.gasPrice=e.gasPrice,this.maxPriorityFeePerGas=null!=e.maxPriorityFeePerGas?e.maxPriorityFeePerGas:null,this.maxFeePerGas=null!=e.maxFeePerGas?e.maxFeePerGas:null,this.maxFeePerBlobGas=null!=e.maxFeePerBlobGas?e.maxFeePerBlobGas:null,this.chainId=e.chainId,this.signature=e.signature,this.accessList=null!=e.accessList?e.accessList:null,this.blobVersionedHashes=null!=e.blobVersionedHashes?e.blobVersionedHashes:null,this.authorizationList=null!=e.authorizationList?e.authorizationList:null,__privateSet(this,Q,-1)}toJSON(){const{blockNumber:e,blockHash:t,index:r,hash:n,type:s,to:i,from:o,nonce:a,data:l,signature:c,accessList:u,blobVersionedHashes:d}=this;return{_type:"TransactionResponse",accessList:u,blockNumber:e,blockHash:t,blobVersionedHashes:d,chainId:An(this.chainId),data:l,from:o,gasLimit:An(this.gasLimit),gasPrice:An(this.gasPrice),hash:n,maxFeePerGas:An(this.maxFeePerGas),maxPriorityFeePerGas:An(this.maxPriorityFeePerGas),maxFeePerBlobGas:An(this.maxFeePerBlobGas),nonce:a,signature:c,to:i,index:r,type:s,value:An(this.value)}}getBlock(){return __async(this,null,(function*(){let e=this.blockNumber;if(null==e){const t=yield this.getTransaction();t&&(e=t.blockNumber)}if(null==e)return null;const t=this.provider.getBlock(e);if(null==t)throw new Error("TODO");return t}))}getTransaction(){return __async(this,null,(function*(){return this.provider.getTransaction(this.hash)}))}confirmations(){return __async(this,null,(function*(){if(null==this.blockNumber){const{tx:e,blockNumber:t}=yield re({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return null==e||null==e.blockNumber?0:t-e.blockNumber+1}return(yield this.provider.getBlockNumber())-this.blockNumber+1}))}wait(e,t){return __async(this,null,(function*(){const r=null==e?1:e,n=null==t?0:t;let s=__privateGet(this,Q),i=-1,o=-1===s;const a=()=>__async(this,null,(function*(){if(o)return null;const{blockNumber:e,nonce:t}=yield re({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(t<this.nonce)return void(s=e);if(o)return null;const n=yield this.getTransaction();if(!n||null==n.blockNumber)for(-1===i&&(i=s-3,i<__privateGet(this,Q)&&(i=__privateGet(this,Q)));i<=e;){if(o)return null;const t=yield this.provider.getBlock(i,!0);if(null==t)return;for(const e of t)if(e===this.hash)return;for(let n=0;n<t.length;n++){const i=yield t.getTransaction(n);if(i.from===this.from&&i.nonce===this.nonce){if(o)return null;const t=yield this.provider.getTransactionReceipt(i.hash);if(null==t)return;if(e-t.blockNumber+1<r)return;let n="replaced";i.data===this.data&&i.to===this.to&&i.value===this.value?n="repriced":"0x"===i.data&&i.from===i.to&&i.value===kn&&(n="cancelled"),le(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:"replaced"===n||"cancelled"===n,reason:n,replacement:i.replaceableTransaction(s),hash:i.hash,receipt:t})}}i++}})),l=e=>{if(null==e||0!==e.status)return e;le(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:e.to,from:e.from,data:""},receipt:e})},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 a(),0===r)return null;const u=new Promise(((e,t)=>{const i=[],c=()=>{i.forEach((e=>e()))};if(i.push((()=>{o=!0})),n>0){const e=setTimeout((()=>{c(),t(ae("wait for transaction timeout","TIMEOUT"))}),n);i.push((()=>{clearTimeout(e)}))}const u=n=>__async(this,null,(function*(){if((yield n.confirmations())>=r){c();try{e(l(n))}catch(s){t(s)}}}));if(i.push((()=>{this.provider.off(this.hash,u)})),this.provider.on(this.hash,u),s>=0){const e=()=>__async(this,null,(function*(){try{yield a()}catch(r){if(ie(r,"TRANSACTION_REPLACED"))return c(),void t(r)}o||this.provider.once("block",e)}));i.push((()=>{this.provider.off("block",e)})),this.provider.once("block",e)}}));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 le(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Pn(this)}reorderedEvent(e){return le(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),le(!e||e.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),Cn(this,e)}replaceableTransaction(t){ce(Number.isInteger(t)&&t>=0,"invalid startBlock","startBlock",t);const r=new e(this,this.provider);return __privateSet(r,Q,t),r}};function Cn(e,t){return{orphan:"reorder-transaction",tx:e,other:t}}function Pn(e){return{orphan:"drop-transaction",tx:e}}class Mn extends Sn{constructor(e,t,r){super(e,e.provider),__publicField(this,"interface"),__publicField(this,"fragment"),__publicField(this,"args");ne(this,{args:t.decodeEventLog(r,e.data,e.topics),fragment:r,interface:t})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class Fn extends Sn{constructor(e,t){super(e,e.provider),__publicField(this,"error"),ne(this,{error:t})}}class jn extends Rn{constructor(e,t,r){super(r,t),__privateAdd(this,X,void 0),__privateSet(this,X,e)}get logs(){return super.logs.map((e=>{const t=e.topics.length?__privateGet(this,X).getEvent(e.topics[0]):null;if(t)try{return new Mn(e,__privateGet(this,X),t)}catch(r){return new Fn(e,r)}return e}))}}X=new WeakMap;Y=new WeakMap;let Un=class e extends On{constructor(e,t,r){super(r,t),__privateAdd(this,Y,void 0),__privateSet(this,Y,e)}wait(t,r){return __async(this,null,(function*(){const n=yield __superGet(e.prototype,this,"wait").call(this,t,r);return null==n?null:new jn(__privateGet(this,Y),this.provider,n)}))}};class Ln extends Me{constructor(e,t,r,n){super(e,t,r),__publicField(this,"log"),ne(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 In extends Ln{constructor(e,t,r,n,s){super(e,t,r,new Mn(s,e.interface,n));ne(this,{args:e.interface.decodeEventLog(n,this.log.data,this.log.topics),fragment:n})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const Gn=BigInt(0);function Dn(e){return e&&"function"==typeof e.call}function Bn(e){return e&&"function"==typeof e.estimateGas}function Wn(e){return e&&"function"==typeof e.resolveName}function $n(e){return e&&"function"==typeof e.sendTransaction}function zn(e){if(null!=e){if(Wn(e))return e;if(e.provider)return e.provider}}class Vn{constructor(e,t,r){if(__privateAdd(this,Z,void 0),__publicField(this,"fragment"),ne(this,{fragment:t}),t.inputs.length<r.length)throw new Error("too many arguments");const n=Hn(e.runner,"resolveName"),s=Wn(n)?n:null;__privateSet(this,Z,function(){return __async(this,null,(function*(){const n=yield Promise.all(t.inputs.map(((e,t)=>null==r[t]?null:e.walkAsync(r[t],((e,t)=>"address"===e?Array.isArray(t)?Promise.all(t.map((e=>qt(e,s)))):qt(t,s):t)))));return e.interface.encodeFilterTopics(t,n)}))}())}getTopicFilter(){return __privateGet(this,Z)}}function Hn(e,t){return null==e?null:"function"==typeof e[t]?e:e.provider&&"function"==typeof e.provider[t]?e.provider:null}function Kn(e){return null==e?null:e.provider||null}function qn(e,t){return __async(this,null,(function*(){const r=Zt.dereference(e,"overrides");ce("object"==typeof r,"invalid overrides parameter","overrides",e);const n=Tn(r);return ce(null==n.to||(t||[]).indexOf("to")>=0,"cannot override to","overrides.to",n.to),ce(null==n.data||(t||[]).indexOf("data")>=0,"cannot override data","overrides.data",n.data),n.from&&(n.from=n.from),n}))}function Jn(e){const t=function(t){return __async(this,null,(function*(){const r=yield qn(t,["data"]);r.to=yield e.getAddress(),r.from&&(r.from=yield qt(r.from,zn(e.runner)));const n=e.interface,s=Te(r.value||Gn,"overrides.value")===Gn,i="0x"===(r.data||"0x");!n.fallback||n.fallback.payable||!n.receive||i||s||ce(!1,"cannot send data to receive or send value to non-payable fallback","overrides",t),ce(n.fallback||i,"cannot send data to receive-only contract","overrides.data",r.data);return ce(n.receive||n.fallback&&n.fallback.payable||s,"cannot send value to non-payable fallback","overrides.value",r.value),ce(n.fallback||i,"cannot send data to receive-only contract","overrides.data",r.data),r}))},r=function(r){return __async(this,null,(function*(){const n=e.runner;le($n(n),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const s=yield n.sendTransaction(yield t(r)),i=Kn(e.runner);return new Un(e.interface,i,s)}))},n=e=>__async(this,null,(function*(){return yield r(e)}));return ne(n,{_contract:e,estimateGas:function(r){return __async(this,null,(function*(){const n=Hn(e.runner,"estimateGas");return le(Bn(n),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),yield n.estimateGas(yield t(r))}))},populateTransaction:t,send:r,staticCall:function(r){return __async(this,null,(function*(){const n=Hn(e.runner,"call");le(Dn(n),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const s=yield t(r);try{return yield n.call(s)}catch(i){if(oe(i)&&i.data)throw e.interface.makeError(i.data,s);throw i}}))}}),n}function Qn(e,t){const r=function(...r){const n=e.interface.getFunction(t,r);return le(n,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t,args:r}}),n},n=function(...t){return __async(this,null,(function*(){const n=r(...t);let s={};if(n.inputs.length+1===t.length&&(s=yield qn(t.pop()),s.from&&(s.from=yield qt(s.from,zn(e.runner)))),n.inputs.length!==t.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const i=yield function(e,t,r){return __async(this,null,(function*(){const n=Hn(e,"resolveName"),s=Wn(n)?n:null;return yield Promise.all(t.map(((e,t)=>e.walkAsync(r[t],((e,t)=>(t=Zt.dereference(t,e),"address"===e?qt(t,s):t))))))}))}(e.runner,n.inputs,t);return Object.assign({},s,yield re({to:e.getAddress(),data:e.interface.encodeFunctionData(n,i)}))}))},s=function(...e){return __async(this,null,(function*(){const t=yield o(...e);return 1===t.length?t[0]:t}))},i=function(...t){return __async(this,null,(function*(){const r=e.runner;le($n(r),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const s=yield r.sendTransaction(yield n(...t)),i=Kn(e.runner);return new Un(e.interface,i,s)}))},o=function(...t){return __async(this,null,(function*(){const s=Hn(e.runner,"call");le(Dn(s),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const i=yield n(...t);let o="0x";try{o=yield s.call(i)}catch(l){if(oe(l)&&l.data)throw e.interface.makeError(l.data,i);throw l}const a=r(...t);return e.interface.decodeFunctionResult(a,o)}))},a=(...e)=>__async(this,null,(function*(){return r(...e).constant?yield s(...e):yield i(...e)}));return ne(a,{name:e.interface.getFunctionName(t),_contract:e,_key:t,getFragment:r,estimateGas:function(...t){return __async(this,null,(function*(){const r=Hn(e.runner,"estimateGas");return le(Bn(r),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),yield r.estimateGas(yield n(...t))}))},populateTransaction:n,send:i,staticCall:s,staticCallResult:o}),Object.defineProperty(a,"fragment",{configurable:!1,enumerable:!0,get:()=>{const r=e.interface.getFunction(t);return le(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t}}),r}}),a}Z=new WeakMap;const Xn=Symbol.for("_ethersInternal_contract"),Yn=new WeakMap;function Zn(e){return Yn.get(e[Xn])}function es(e,t){return __async(this,null,(function*(){let r,n=null;if(Array.isArray(t)){const n=function(t){if(ge(t,32))return t;const r=e.interface.getEvent(t);return ce(r,"unknown fragment","name",t),r.topicHash};r=t.map((e=>null==e?null:Array.isArray(e)?e.map(n):n(e)))}else"*"===t?r=[null]:"string"==typeof t?ge(t,32)?r=[t]:(n=e.interface.getEvent(t),ce(n,"unknown fragment","event",t),r=[n.topicHash]):(s=t)&&"object"==typeof s&&"getTopicFilter"in s&&"function"==typeof s.getTopicFilter&&s.fragment?r=yield t.getTopicFilter():"fragment"in t?(n=t.fragment,r=[n.topicHash]):ce(!1,"unknown event name","event",t);var s;r=r.map((e=>{if(null==e)return null;if(Array.isArray(e)){const t=Array.from(new Set(e.map((e=>e.toLowerCase()))).values());return 1===t.length?t[0]:(t.sort(),t)}return e.toLowerCase()}));return{fragment:n,tag:r.map((e=>null==e?"null":Array.isArray(e)?e.join("|"):e)).join("&"),topics:r}}))}function ts(e,t){return __async(this,null,(function*(){const{subs:r}=Zn(e);return r.get((yield es(e,t)).tag)||null}))}function rs(e,t,r){return __async(this,null,(function*(){const n=Kn(e.runner);le(n,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:t});const{fragment:s,tag:i,topics:o}=yield es(e,r),{addr:a,subs:l}=Zn(e);let c=l.get(i);if(!c){const t={address:a||e,topics:o},u=t=>{let n=s;if(null==n)try{n=e.interface.getEvent(t.topics[0])}catch(i){}if(n){const i=n,o=s?e.interface.decodeEventLog(s,t.data,t.topics):[];ss(e,r,o,(n=>new In(e,n,r,i,t)))}else ss(e,r,[],(n=>new Ln(e,n,r,t)))};let d=[];c={tag:i,listeners:[],start:()=>{d.length||d.push(n.on(t,u))},stop:()=>__async(this,null,(function*(){if(0==d.length)return;let e=d;d=[],yield Promise.all(e),n.off(t,u)}))},l.set(i,c)}return c}))}let ns=Promise.resolve();function ss(e,t,r,n){return __async(this,null,(function*(){try{yield ns}catch(i){}const s=function(e,t,r,n){return __async(this,null,(function*(){yield ns;const s=yield ts(e,t);if(!s)return!1;const o=s.listeners.length;return s.listeners=s.listeners.filter((({listener:t,once:s})=>{const o=Array.from(r);n&&o.push(n(s?null:t));try{t.call(e,...o)}catch(i){}return!s})),0===s.listeners.length&&(s.stop(),Zn(e).subs.delete(s.tag)),o>0}))}(e,t,r,n);return ns=s,yield s}))}const is=["then"];ee=Xn;let os=class e{constructor(e,t,r,n){__publicField(this,"target"),__publicField(this,"interface"),__publicField(this,"runner"),__publicField(this,"filters"),__publicField(this,ee),__publicField(this,"fallback"),ce("string"==typeof e||Ht(e),"invalid value for Contract target","target",e),null==r&&(r=null);const s=Nn.from(t);let i;ne(this,{target:e,runner:r,interface:s}),Object.defineProperty(this,Xn,{value:{}});let o=null,a=null;if(n){const e=Kn(r);a=new Un(this.interface,e,n)}let l=new Map;if("string"==typeof e)if(ge(e))o=e,i=Promise.resolve(e);else{const t=Hn(r,"resolveName");if(!Wn(t))throw ae("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});i=t.resolveName(e).then((t=>{if(null==t)throw ae("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:e});return Zn(this).addr=t,t}))}else i=e.getAddress().then((e=>{if(null==e)throw new Error("TODO");return Zn(this).addr=e,e}));var c,u;c=this,u={addrPromise:i,addr:o,deployTx:a,subs:l},Yn.set(c[Xn],u);return ne(this,{filters:new Proxy({},{get:(e,t,r)=>{if("symbol"==typeof t||is.indexOf(t)>=0)return Reflect.get(e,t,r);try{return this.getEvent(t)}catch(n){if(!ie(n,"INVALID_ARGUMENT")||"key"!==n.argument)throw n}},has:(e,t)=>is.indexOf(t)>=0?Reflect.has(e,t):Reflect.has(e,t)||this.interface.hasEvent(String(t))})}),ne(this,{fallback:s.receive||s.fallback?Jn(this):null}),new Proxy(this,{get:(e,t,r)=>{if("symbol"==typeof t||t in e||is.indexOf(t)>=0)return Reflect.get(e,t,r);try{return e.getFunction(t)}catch(n){if(!ie(n,"INVALID_ARGUMENT")||"key"!==n.argument)throw n}},has:(e,t)=>"symbol"==typeof t||t in e||is.indexOf(t)>=0?Reflect.has(e,t):e.interface.hasFunction(t)})}connect(t){return new e(this.target,this.interface,t)}attach(t){return new e(t,this.interface,this.runner)}getAddress(){return __async(this,null,(function*(){return yield Zn(this).addrPromise}))}getDeployedCode(){return __async(this,null,(function*(){const e=Kn(this.runner);le(e,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const t=yield e.getCode(yield this.getAddress());return"0x"===t?null:t}))}waitForDeployment(){return __async(this,null,(function*(){const e=this.deploymentTransaction();if(e)return yield e.wait(),this;if(null!=(yield this.getDeployedCode()))return this;const t=Kn(this.runner);return le(null!=t,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise(((e,r)=>{const n=()=>__async(this,null,(function*(){try{if(null!=(yield this.getDeployedCode()))return e(this);t.once("block",n)}catch(s){r(s)}}));n()}))}))}deploymentTransaction(){return Zn(this).deployTx}getFunction(e){"string"!=typeof e&&(e=e.format());return Qn(this,e)}getEvent(e){return"string"!=typeof e&&(e=e.format()),function(e,t){const r=function(...r){const n=e.interface.getEvent(t,r);return le(n,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t,args:r}}),n},n=function(...t){return new Vn(e,r(...t),t)};return ne(n,{name:e.interface.getEventName(t),_contract:e,_key:t,getFragment:r}),Object.defineProperty(n,"fragment",{configurable:!1,enumerable:!0,get:()=>{const r=e.interface.getEvent(t);return le(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t}}),r}}),n}(this,e)}queryTransaction(e){return __async(this,null,(function*(){throw new Error("@TODO")}))}queryFilter(e,t,r){return __async(this,null,(function*(){null==t&&(t=0),null==r&&(r="latest");const{addr:n,addrPromise:s}=Zn(this),i=n||(yield s),{fragment:o,topics:a}=yield es(this,e),l={address:i,topics:a,fromBlock:t,toBlock:r},c=Kn(this.runner);return le(c,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(yield c.getLogs(l)).map((e=>{let t=o;if(null==t)try{t=this.interface.getEvent(e.topics[0])}catch(r){}if(t)try{return new Mn(e,this.interface,t)}catch(r){return new Fn(e,r)}return new Sn(e,c)}))}))}on(e,t){return __async(this,null,(function*(){const r=yield rs(this,"on",e);return r.listeners.push({listener:t,once:!1}),r.start(),this}))}once(e,t){return __async(this,null,(function*(){const r=yield rs(this,"once",e);return r.listeners.push({listener:t,once:!0}),r.start(),this}))}emit(e,...t){return __async(this,null,(function*(){return yield ss(this,e,t,null)}))}listenerCount(e){return __async(this,null,(function*(){if(e){const t=yield ts(this,e);return t?t.listeners.length:0}const{subs:t}=Zn(this);let r=0;for(const{listeners:e}of t.values())r+=e.length;return r}))}listeners(e){return __async(this,null,(function*(){if(e){const t=yield ts(this,e);return t?t.listeners.map((({listener:e})=>e)):[]}const{subs:t}=Zn(this);let r=[];for(const{listeners:e}of t.values())r=r.concat(e.map((({listener:e})=>e)));return r}))}off(e,t){return __async(this,null,(function*(){const r=yield ts(this,e);if(!r)return this;if(t){const e=r.listeners.map((({listener:e})=>e)).indexOf(t);e>=0&&r.listeners.splice(e,1)}return null!=t&&0!==r.listeners.length||(r.stop(),Zn(this).subs.delete(r.tag)),this}))}removeAllListeners(e){return __async(this,null,(function*(){if(e){const t=yield ts(this,e);if(!t)return this;t.stop(),Zn(this).subs.delete(t.tag)}else{const{subs:e}=Zn(this);for(const{tag:t,stop:r}of e.values())r(),e.delete(t)}return this}))}addListener(e,t){return __async(this,null,(function*(){return yield this.on(e,t)}))}removeListener(e,t){return __async(this,null,(function*(){return yield this.off(e,t)}))}static buildClass(t){return class extends e{constructor(e,r=null){super(e,t,r)}}}static from(e,t,r){null==r&&(r=null);return new this(e,t,r)}};class as extends(function(){return os}()){}const ls={METAMASK:"metamask",TRONLINK:"tronlink",TRUST_WALLET:"trustwallet",LUTE:"lute"},cs={ETHEREUM:"ethereum",BSC:"bsc",TRON:"tron",ALGORAND:"algorand"},us={[cs.ETHEREUM]:{name:"Ethereum Mainnet",chainId:1,symbol:"ETH",decimals:18,rpcUrl:"https://mainnet.infura.io/v3/your-infura-key",blockExplorerUrl:"https://etherscan.io"},[cs.BSC]:{name:"Binance Smart Chain",chainId:56,symbol:"BNB",decimals:18,rpcUrl:"https://bsc-dataseed.binance.org/",blockExplorerUrl:"https://bscscan.com"},[cs.TRON]:{name:"TRON Mainnet",symbol:"TRX",decimals:6,rpcUrl:"https://api.trongrid.io",blockExplorerUrl:"https://tronscan.org"},[cs.ALGORAND]:{name:"Algorand Mainnet",symbol:"ALGO",decimals:6,rpcUrl:"https://mainnet-api.algonode.cloud",blockExplorerUrl:"https://algoexplorer.io"}},ds={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}},DAI:{ethereum:{contractAddress:"0x6B175474E89094C44Da98b954EedeAC495271d0F",decimals:18,symbol:"DAI"}},FRAX:{ethereum:{contractAddress:"0x853d955aCEf822Db058eb8505911ED77F175b99e",decimals:18,symbol:"FRAX"},bsc:{contractAddress:"0x90C97F71E18723b0Cf0dfa30ee176Ab653E89F40",decimals:18,symbol:"FRAX"}},PYUSD:{ethereum:{contractAddress:"0x6c3ea9036406852006290770BEdFcAbA0e23A0e8",decimals:6,symbol:"PYUSD"}},BUSD:{bsc:{contractAddress:"0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56",decimals:18,symbol:"BUSD"}},USDJ:{tron:{contractAddress:"TMwFHYXLJaRUPeW6421aqXL4ZEzPRFGkGT",decimals:18,symbol:"USDJ"}}},hs={[cs.ETHEREUM]:[ls.METAMASK,ls.TRUST_WALLET],[cs.BSC]:[ls.METAMASK,ls.TRUST_WALLET],[cs.TRON]:[ls.TRONLINK],[cs.ALGORAND]:[ls.LUTE]},ps=e=>({[ls.METAMASK]:"https://metamask.io/download/",[ls.TRONLINK]:"https://www.tronlink.org/download/",[ls.TRUST_WALLET]:"https://trustwallet.com/download/",[ls.LUTE]:"https://lute.app/download/"}[e]||""),fs=()=>({[ls.METAMASK]:"undefined"!=typeof window&&void 0!==window.ethereum&&!0===window.ethereum.isMetaMask,[ls.TRONLINK]:"undefined"!=typeof window&&void 0!==window.tronWeb,[ls.TRUST_WALLET]:"undefined"!=typeof window&&void 0!==window.ethereum&&!0===window.ethereum.isTrust,[ls.LUTE]:"undefined"!=typeof window&&void 0!==window.lute}),ms=(e=3,t=500)=>__async(this,null,(function*(){let r=0,n=fs();const s=Object.values(n).some((e=>!0===e));for(;!s&&r<e;)console.log(`No wallets detected, retrying (${r+1}/${e})...`),yield new Promise((e=>setTimeout(e,t))),n=fs(),r++;return n})),gs=()=>{var e;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==(e=window.tronWeb.fullNode)?void 0:e.host,defaultAddress:window.tronWeb.defaultAddress});const t=fs();console.log("Detected wallets:",t)},ys=()=>__async(this,null,(function*(){if(console.log("Connecting to MetaMask wallet..."),!window.ethereum||!window.ethereum.isMetaMask)throw new Error("MetaMask not detected. Please install MetaMask extension.");try{const e=yield window.ethereum.request({method:"eth_requestAccounts"});if(!e||0===e.length)throw new Error("No accounts found. Please unlock MetaMask.");const t=e[0],r=yield window.ethereum.request({method:"eth_chainId"}),n=parseInt(r,16);let s;switch(n){case 1:s=cs.ETHEREUM;break;case 56:s=cs.BSC;break;default:s=`unknown-${n}`}const i={request:e=>window.ethereum.request(e),getSigner:()=>({getAddress:()=>__async(this,null,(function*(){return t})),sendTransaction:e=>__async(this,null,(function*(){return{hash:yield window.ethereum.request({method:"eth_sendTransaction",params:[{from:t,to:e.to,value:e.value?"string"==typeof e.value?e.value:e.value.toString():"0x0",gasLimit:e.gasLimit?"string"==typeof e.gasLimit?e.gasLimit:e.gasLimit.toString():void 0,data:e.data||"0x"}]})}}))}),estimateGas:e=>__async(this,null,(function*(){const r=yield window.ethereum.request({method:"eth_estimateGas",params:[{from:t,to:e.to,value:e.value?"string"==typeof e.value?e.value:e.value.toString():"0x0",data:e.data||"0x"}]}),n=parseInt(r,16);return{toString:()=>n.toString(),mul:e=>({div:t=>({toString:()=>Math.floor(n*e/t).toString()})})}}))};return console.log("MetaMask connected successfully:",{address:t,chainId:n,networkType:s}),{walletType:ls.METAMASK,address:t,provider:i,network:s,isConnected:!0,chainId:n}}catch(e){throw console.error("MetaMask connection error:",e),e}})),_s=()=>__async(this,null,(function*(){if(console.log("Connecting to TronLink wallet..."),!window.tronWeb)throw new Error("TronLink not detected. Please install TronLink extension.");const e=(e=10,t=500)=>__async(this,null,(function*(){for(let r=0;r<e;r++){if(window.tronWeb&&window.tronWeb.ready)return window.tronWeb;console.log(`Waiting for TronWeb to be ready... Attempt ${r+1}/${e}`),yield new Promise((e=>setTimeout(e,t)))}throw new Error("TronWeb took too long to be ready")}));try{const r=yield e();if(!r.defaultAddress||!r.defaultAddress.base58)try{yield window.tronWeb.request({method:"tron_requestAccounts"})}catch(t){throw new Error("Please unlock TronLink and approve connection")}const n=r.defaultAddress.base58;return console.log("TronLink connected successfully:",n),{walletType:ls.TRONLINK,address:n,provider:r,network:cs.TRON,isConnected:!0}}catch(r){throw console.error("TronLink connection error:",r),r}})),bs=()=>__async(this,null,(function*(){if(console.log("Connecting to Trust Wallet..."),!window.ethereum||!window.ethereum.isTrust)throw new Error("Trust Wallet not detected. Please install Trust Wallet.");try{const e=yield window.ethereum.request({method:"eth_requestAccounts"});if(!e||0===e.length)throw new Error("No accounts found. Please unlock Trust Wallet.");const t=e[0],r=yield window.ethereum.request({method:"eth_chainId"}),n=parseInt(r,16);let s;switch(n){case 1:s=cs.ETHEREUM;break;case 56:s=cs.BSC;break;default:s=`unknown-${n}`}return{walletType:ls.TRUST_WALLET,address:t,provider:{request:e=>window.ethereum.request(e),getSigner:()=>({getAddress:()=>__async(this,null,(function*(){return t})),sendTransaction:e=>__async(this,null,(function*(){return{hash:yield window.ethereum.request({method:"eth_sendTransaction",params:[{from:t,to:e.to,value:e.value?"string"==typeof e.value?e.value:e.value.toString():"0x0",gasLimit:e.gasLimit?"string"==typeof e.gasLimit?e.gasLimit:e.gasLimit.toString():void 0,data:e.data||"0x"}]})}}))}),estimateGas:e=>__async(this,null,(function*(){const r=yield window.ethereum.request({method:"eth_estimateGas",params:[{from:t,to:e.to,value:e.value?"string"==typeof e.value?e.value:e.value.toString():"0x0",data:e.data||"0x"}]}),n=parseInt(r,16);return{toString:()=>n.toString(),mul:e=>({div:t=>({toString:()=>Math.floor(n*e/t).toString()})})}}))},network:s,isConnected:!0,chainId:n}}catch(e){throw console.error("Trust Wallet connection error:",e),e}})),ws=()=>__async(this,null,(function*(){if(console.log("Connecting to Lute wallet..."),!window.lute)throw new Error("Lute not detected. Please install Lute extension.");try{const{address:e}=yield window.lute.connect();if(!e)throw new Error("No address returned. Please unlock Lute wallet.");return console.log("Lute wallet connected successfully:",e),{walletType:ls.LUTE,address:e,provider:window.lute,network:cs.ALGORAND,isConnected:!0}}catch(e){throw console.error("Lute wallet connection error:",e),e}})),vs=(e,t,r=1)=>__async(this,null,(function*(){console.log("Connecting to wallet:",{walletType:e,network:t});for(let t=0;t<r;t++)try{switch(e){case ls.METAMASK:return yield ys();case ls.TRONLINK:return yield _s();case ls.TRUST_WALLET:return yield bs();case ls.LUTE:return yield ws();default:throw new Error(`Unsupported wallet type: ${e}`)}}catch(n){if(console.log(`Wallet connection attempt ${t+1} failed:`,n.message),t===r-1)throw n;yield new Promise((e=>setTimeout(e,1e3)))}})),xs=e=>hs[e]||[],Es=(e,t)=>__async(this,null,(function*(){if(console.log("Sending transaction:",{walletConnection:e,transactionParams:t}),!e)throw new Error("Wallet not connected");const{to:r,amount:n,tokenAddress:s,tokenDecimals:i,currency:o,network:a,tokenConfig:l}=t;if(!r)throw new Error("Recipient address not provided");if(!n||isNaN(parseFloat(n))||parseFloat(n)<=0)throw new Error("Invalid amount");return!s||null===s?Ns(e,r,n):ks(e,{contractAddress:s,decimals:i,symbol:o},r,n)})),Ns=(e,t,r)=>__async(this,null,(function*(){if(console.log("Sending native transaction:",{toAddress:t,amount:r}),!e||!e.provider)throw new Error("Wallet not connected");try{let n;switch(e.walletType){case ls.METAMASK:case ls.TRUST_WALLET:const s=e.provider,i=s.getSigner(),o=Xe?Xe(r.toString()):(void 0).parseEther(r.toString()),a=yield s.estimateGas({to:t,value:o}),l="function"==typeof a.mul?a.mul(110).div(100):{toString:()=>Math.floor(1.1*parseInt(a.toString())).toString()};n=yield i.sendTransaction({to:t,value:o,gasLimit:l});break;case ls.TRONLINK:const c=e.provider;if(!c||!c.ready)throw new Error("TronWeb not initialized");const u=c.toSun(r.toString());n=yield c.trx.sendTransaction(t,u);break;case ls.LUTE:const d=e.provider,h=Math.floor(1e6*parseFloat(r));n=yield d.sendPayment({recipient:t,amount:h});break;default:throw new Error(`Unsupported wallet type: ${e.walletType}`)}const s=n.hash||n.txID||n.txId||n;return console.log("Native transaction sent:",s),s}catch(n){throw console.error("Native transaction error:",n),n}})),ks=(e,t,r,n)=>__async(this,null,(function*(){if(console.log("Sending token transaction:",{tokenConfig:t,toAddress:r,amount:n}),!e||!e.provider)throw new Error("Wallet not connected");if(!t||!t.contractAddress)throw new Error("Token configuration missing");switch(e.walletType){case ls.TRONLINK:return Ts(e,t,r,n);case ls.LUTE:return Ss(e,t,r,n);default:return As(e,t,r,n)}})),As=(e,t,r,n)=>__async(this,null,(function*(){console.log("Sending ERC20/BEP20 transaction:",{tokenConfig:t,toAddress:r,amount:n});const s=e.provider.getSigner(),{contractAddress:i,decimals:o,symbol:a}=t,l=parseFloat(n),c=parseInt(o);let u;try{u=Qe?Qe(l.toString(),c):(void 0).parseUnits(l.toString(),c)}catch(d){const e=l*Math.pow(10,c);u={toString:()=>e.toLocaleString("fullwide",{useGrouping:!1})}}console.log(`Sending ${l} ${a} (${u.toString()} base units) to ${r}`);try{const e=new as(i,["function transfer(address to, uint256 amount) returns (bool)"],s),t="USDC"===a?1.5:1.2,n=yield e.transfer(r,u,{gasLimit:Math.floor(2e5*t)});return console.log("ERC20 transaction sent:",n),n.hash}catch(h){throw console.error("ERC20 transaction error:",h),h.message&&h.message.includes("user rejected")?new Error("Transaction rejected by user"):h.message&&h.message.includes("insufficient funds")?new Error("Insufficient funds for transaction"):h}})),Ts=(e,t,r,n)=>__async(this,null,(function*(){console.log("Sending TRC20 transaction:",{tokenConfig:t,toAddress:r,amount:n});const s=e.provider;if(!s||!s.ready)throw new Error("TronWeb not initialized");const{contractAddress:i,decimals:o,symbol:a}=t,l=parseFloat(n),c=parseInt(o),u=Math.floor(l*Math.pow(10,c));console.log(`Sending ${l} ${a} (${u} base units) to ${r}`);try{const e=yield s.contract().at(i);if(!e.transfer)throw new Error("Invalid TRC-20 contract");const t=yield e.transfer(r,u.toString()).send({feeLimit:1e8,callValue:0,shouldPollResponse:!1});return console.log("TRC20 transaction sent:",t),t}catch(d){throw console.error("TRC20 transaction failed:",d),d.message&&d.message.includes("User rejected")?new Error("Transaction rejected by user"):d.message&&d.message.includes("bandwidth")?new Error("Insufficient energy or bandwidth. Make sure you have enough TRX for fees."):new Error(`Transaction failed: ${d.message||"Unknown error"}`)}})),Ss=(e,t,r,n)=>__async(this,null,(function*(){console.log("Sending Algorand asset transaction:",{tokenConfig:t,toAddress:r,amount:n});const s=e.provider,{assetId:i,decimals:o,symbol:a}=t,l=parseFloat(n),c=parseInt(o),u=Math.floor(l*Math.pow(10,c));console.log(`Sending ${l} ${a} (${u} base units) to ${r}`);try{const e=yield s.sendAssetTransfer({recipient:r,assetId:i,amount:u});return console.log("Algorand asset transaction sent:",e),e.txId}catch(d){throw console.error("Algorand asset transaction error:",d),d.message&&d.message.includes("rejected")?new Error("Transaction rejected by user"):d}}));let Rs={apiKey:null,apiSecret:null,apiUrl:"https://coinleyserver-production.up.railway.app",merchantWalletAddresses:{}};const Os=()=>({"Content-Type":"application/json","x-api-key":Rs.apiKey,"x-api-secret":Rs.apiSecret}),Cs=()=>__async(this,null,(function*(){try{const e=yield fetch(`${Rs.apiUrl}/api/merchants/wallets`,{method:"GET",headers:Os()});if(!e.ok)throw new Error(`Failed to fetch wallet addresses: ${e.status}`);const t=yield e.json(),r={};return t.success&&t.wallets&&t.wallets.forEach((e=>{e.walletAddress&&e.networkShortName&&(r[e.networkShortName]=e.walletAddress)})),r}catch(e){throw console.error("Error fetching merchant wallet addresses:",e),e}})),Ps=e=>__async(this,null,(function*(){try{if(console.log("Creating payment with data:",e),!e.amount)throw new Error("Payment amount is required");let n=Rs.merchantWalletAddresses||{};if(0===Object.keys(n).length)try{n=yield Cs(),Rs.merchantWalletAddresses=n}catch(t){console.warn("Could not fetch merchant wallet addresses:",t.message)}const s=__spreadProps(__spreadValues({},e),{merchantWalletAddresses:__spreadValues(__spreadValues({},n),e.merchantWalletAddresses)});console.log("Enhanced payment data:",__spreadProps(__spreadValues({},s),{merchantWalletAddresses:s.merchantWalletAddresses}));const i=yield fetch(`${Rs.apiUrl}/api/payments/create`,{method:"POST",headers:Os(),body:JSON.stringify(s)});if(console.log("Create payment response status:",i.status),!i.ok){let e;try{e=yield i.json()}catch(r){throw new Error(`Failed to create payment: ${i.status} ${i.statusText}`)}throw console.error("Error creating payment:",e),new Error(e.error||`Failed to create payment: ${i.status}`)}const o=yield i.json();return console.log("Create payment response data:",o),o.merchantConfig&&o.merchantConfig.walletAddresses&&(Rs.merchantWalletAddresses=__spreadValues(__spreadValues({},Rs.merchantWalletAddresses),o.merchantConfig.walletAddresses)),o}catch(n){throw console.error("Create payment error:",n),n}})),Ms=e=>__async(this,null,(function*(){try{if(console.log("Processing payment with data:",e),!e.paymentId)throw new Error("Payment ID is required");if(!e.transactionHash)throw new Error("Transaction hash is required");const r=yield fetch(`${Rs.apiUrl}/api/payments/process`,{method:"POST",headers:Os(),body:JSON.stringify(e)});if(console.log("Process payment response status:",r.status),!r.ok){let e;try{e=yield r.json()}catch(t){throw new Error(`Failed to process payment: ${r.status} ${r.statusText}`)}throw console.error("Error processing payment:",e),new Error(e.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 Fs={exports:{}},js={},Us=t,Ls=Symbol.for("react.element"),Is=Symbol.for("react.fragment"),Gs=Object.prototype.hasOwnProperty,Ds=Us.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Bs={key:!0,ref:!0,__self:!0,__source:!0};function Ws(e,t,r){var n,s={},i=null,o=null;for(n in void 0!==r&&(i=""+r),void 0!==t.key&&(i=""+t.key),void 0!==t.ref&&(o=t.ref),t)Gs.call(t,n)&&!Bs.hasOwnProperty(n)&&(s[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===s[n]&&(s[n]=t[n]);return{$$typeof:Ls,type:e,key:i,ref:o,props:s,_owner:Ds.current}}js.Fragment=Is,js.jsx=Ws,js.jsxs=Ws,Fs.exports=js;var $s=Fs.exports;const zs=t.createContext(),Vs=t.createContext(),Hs=()=>t.useContext(Vs);var Ks,qs,Js=Object.defineProperty,Qs=Object.getOwnPropertySymbols,Xs=Object.prototype.hasOwnProperty,Ys=Object.prototype.propertyIsEnumerable,Zs=(e,t,r)=>t in e?Js(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ei=(e,t)=>{for(var r in t||(t={}))Xs.call(t,r)&&Zs(e,r,t[r]);if(Qs)for(var r of Qs(t))Ys.call(t,r)&&Zs(e,r,t[r]);return e},ti=(e,t)=>{var r={};for(var n in e)Xs.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Qs)for(var n of Qs(e))t.indexOf(n)<0&&Ys.call(e,n)&&(r[n]=e[n]);return r};(e=>{const t=class t{constructor(e,r,n,i){if(this.version=e,this.errorCorrectionLevel=r,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw new RangeError("Version value out of range");if(i<-1||i>7)throw new RangeError("Mask value out of range");this.size=4*e+17;let o=[];for(let t=0;t<this.size;t++)o.push(!1);for(let t=0;t<this.size;t++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();const a=this.addEccAndInterleave(n);if(this.drawCodewords(a),-1==i){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);const r=this.getPenaltyScore();r<e&&(i=t,e=r),this.applyMask(t)}}s(0<=i&&i<=7),this.mask=i,this.applyMask(i),this.drawFormatBits(i),this.isFunction=[]}static encodeText(r,n){const s=e.QrSegment.makeSegments(r);return t.encodeSegments(s,n)}static encodeBinary(r,n){const s=e.QrSegment.makeBytes(r);return t.encodeSegments([s],n)}static encodeSegments(e,n,i=1,a=40,l=-1,c=!0){if(!(t.MIN_VERSION<=i&&i<=a&&a<=t.MAX_VERSION)||l<-1||l>7)throw new RangeError("Invalid value");let u,d;for(u=i;;u++){const r=8*t.getNumDataCodewords(u,n),s=o.getTotalBits(e,u);if(s<=r){d=s;break}if(u>=a)throw new RangeError("Data too long")}for(const r of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])c&&d<=8*t.getNumDataCodewords(u,r)&&(n=r);let h=[];for(const t of e){r(t.mode.modeBits,4,h),r(t.numChars,t.mode.numCharCountBits(u),h);for(const e of t.getData())h.push(e)}s(h.length==d);const p=8*t.getNumDataCodewords(u,n);s(h.length<=p),r(0,Math.min(4,p-h.length),h),r(0,(8-h.length%8)%8,h),s(h.length%8==0);for(let t=236;h.length<p;t^=253)r(t,8,h);let f=[];for(;8*f.length<h.length;)f.push(0);return h.forEach(((e,t)=>f[t>>>3]|=e<<7-(7&t))),new t(u,n,f,l)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}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 e=this.getAlignmentPatternPositions(),t=e.length;for(let r=0;r<t;r++)for(let n=0;n<t;n++)0==r&&0==n||0==r&&n==t-1||r==t-1&&0==n||this.drawAlignmentPattern(e[r],e[n]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){const t=this.errorCorrectionLevel.formatBits<<3|e;let r=t;for(let n=0;n<10;n++)r=r<<1^1335*(r>>>9);const i=21522^(t<<10|r);s(i>>>15==0);for(let s=0;s<=5;s++)this.setFunctionModule(8,s,n(i,s));this.setFunctionModule(8,7,n(i,6)),this.setFunctionModule(8,8,n(i,7)),this.setFunctionModule(7,8,n(i,8));for(let s=9;s<15;s++)this.setFunctionModule(14-s,8,n(i,s));for(let s=0;s<8;s++)this.setFunctionModule(this.size-1-s,8,n(i,s));for(let s=8;s<15;s++)this.setFunctionModule(8,this.size-15+s,n(i,s));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let r=0;r<12;r++)e=e<<1^7973*(e>>>11);const t=this.version<<12|e;s(t>>>18==0);for(let r=0;r<18;r++){const e=n(t,r),s=this.size-11+r%3,i=Math.floor(r/3);this.setFunctionModule(s,i,e),this.setFunctionModule(i,s,e)}}drawFinderPattern(e,t){for(let r=-4;r<=4;r++)for(let n=-4;n<=4;n++){const s=Math.max(Math.abs(n),Math.abs(r)),i=e+n,o=t+r;0<=i&&i<this.size&&0<=o&&o<this.size&&this.setFunctionModule(i,o,2!=s&&4!=s)}}drawAlignmentPattern(e,t){for(let r=-2;r<=2;r++)for(let n=-2;n<=2;n++)this.setFunctionModule(e+n,t+r,1!=Math.max(Math.abs(n),Math.abs(r)))}setFunctionModule(e,t,r){this.modules[t][e]=r,this.isFunction[t][e]=!0}addEccAndInterleave(e){const r=this.version,n=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(r,n))throw new RangeError("Invalid argument");const i=t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][r],o=t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][r],a=Math.floor(t.getNumRawDataModules(r)/8),l=i-a%i,c=Math.floor(a/i);let u=[];const d=t.reedSolomonComputeDivisor(o);for(let s=0,p=0;s<i;s++){let r=e.slice(p,p+c-o+(s<l?0:1));p+=r.length;const n=t.reedSolomonComputeRemainder(r,d);s<l&&r.push(0),u.push(r.concat(n))}let h=[];for(let t=0;t<u[0].length;t++)u.forEach(((e,r)=>{(t!=c-o||r>=l)&&h.push(e[t])}));return s(h.length==a),h}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let r=0;for(let t=this.size-1;t>=1;t-=2){6==t&&(t=5);for(let s=0;s<this.size;s++)for(let i=0;i<2;i++){const o=t-i,a=!(t+1&2)?this.size-1-s:s;!this.isFunction[a][o]&&r<8*e.length&&(this.modules[a][o]=n(e[r>>>3],7-(7&r)),r++)}}s(r==8*e.length)}applyMask(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(let t=0;t<this.size;t++)for(let r=0;r<this.size;r++){let n;switch(e){case 0:n=(r+t)%2==0;break;case 1:n=t%2==0;break;case 2:n=r%3==0;break;case 3:n=(r+t)%3==0;break;case 4:n=(Math.floor(r/3)+Math.floor(t/2))%2==0;break;case 5:n=r*t%2+r*t%3==0;break;case 6:n=(r*t%2+r*t%3)%2==0;break;case 7:n=((r+t)%2+r*t%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[t][r]&&n&&(this.modules[t][r]=!this.modules[t][r])}}getPenaltyScore(){let e=0;for(let s=0;s<this.size;s++){let r=!1,n=0,i=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[s][o]==r?(n++,5==n?e+=t.PENALTY_N1:n>5&&e++):(this.finderPenaltyAddHistory(n,i),r||(e+=this.finderPenaltyCountPatterns(i)*t.PENALTY_N3),r=this.modules[s][o],n=1);e+=this.finderPenaltyTerminateAndCount(r,n,i)*t.PENALTY_N3}for(let s=0;s<this.size;s++){let r=!1,n=0,i=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][s]==r?(n++,5==n?e+=t.PENALTY_N1:n>5&&e++):(this.finderPenaltyAddHistory(n,i),r||(e+=this.finderPenaltyCountPatterns(i)*t.PENALTY_N3),r=this.modules[o][s],n=1);e+=this.finderPenaltyTerminateAndCount(r,n,i)*t.PENALTY_N3}for(let s=0;s<this.size-1;s++)for(let r=0;r<this.size-1;r++){const n=this.modules[s][r];n==this.modules[s][r+1]&&n==this.modules[s+1][r]&&n==this.modules[s+1][r+1]&&(e+=t.PENALTY_N2)}let r=0;for(const t of this.modules)r=t.reduce(((e,t)=>e+(t?1:0)),r);const n=this.size*this.size,i=Math.ceil(Math.abs(20*r-10*n)/n)-1;return s(0<=i&&i<=9),e+=i*t.PENALTY_N4,s(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(1==this.version)return[];{const e=Math.floor(this.version/7)+2,t=32==this.version?26:2*Math.ceil((4*this.version+4)/(2*e-2));let r=[6];for(let n=this.size-7;r.length<e;n-=t)r.splice(1,0,n);return r}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw new RangeError("Version number out of range");let r=(16*e+128)*e+64;if(e>=2){const t=Math.floor(e/7)+2;r-=(25*t-10)*t-55,e>=7&&(r-=36)}return s(208<=r&&r<=29648),r}static getNumDataCodewords(e,r){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw new RangeError("Degree out of range");let r=[];for(let t=0;t<e-1;t++)r.push(0);r.push(1);let n=1;for(let s=0;s<e;s++){for(let e=0;e<r.length;e++)r[e]=t.reedSolomonMultiply(r[e],n),e+1<r.length&&(r[e]^=r[e+1]);n=t.reedSolomonMultiply(n,2)}return r}static reedSolomonComputeRemainder(e,r){let n=r.map((e=>0));for(const s of e){const e=s^n.shift();n.push(0),r.forEach(((r,s)=>n[s]^=t.reedSolomonMultiply(r,e)))}return n}static reedSolomonMultiply(e,t){if(e>>>8!=0||t>>>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^=(t>>>n&1)*e;return s(r>>>8==0),r}finderPenaltyCountPatterns(e){const t=e[1];s(t<=3*this.size);const r=t>0&&e[2]==t&&e[3]==3*t&&e[4]==t&&e[5]==t;return(r&&e[0]>=4*t&&e[6]>=t?1:0)+(r&&e[6]>=4*t&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,r){return e&&(this.finderPenaltyAddHistory(t,r),t=0),t+=this.size,this.finderPenaltyAddHistory(t,r),this.finderPenaltyCountPatterns(r)}finderPenaltyAddHistory(e,t){0==t[0]&&(e+=this.size),t.pop(),t.unshift(e)}};function r(e,t,r){if(t<0||t>31||e>>>t!=0)throw new RangeError("Value out of range");for(let n=t-1;n>=0;n--)r.push(e>>>n&1)}function n(e,t){return!!(e>>>t&1)}function s(e){if(!e)throw new Error("Assertion error")}t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.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]],t.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]],e.QrCode=t;const i=class e{constructor(e,t,r){if(this.mode=e,this.numChars=t,this.bitData=r,t<0)throw new RangeError("Invalid argument");this.bitData=r.slice()}static makeBytes(t){let n=[];for(const e of t)r(e,8,n);return new e(e.Mode.BYTE,t.length,n)}static makeNumeric(t){if(!e.isNumeric(t))throw new RangeError("String contains non-numeric characters");let n=[];for(let e=0;e<t.length;){const s=Math.min(t.length-e,3);r(parseInt(t.substring(e,e+s),10),3*s+1,n),e+=s}return new e(e.Mode.NUMERIC,t.length,n)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw new RangeError("String contains unencodable characters in alphanumeric mode");let n,s=[];for(n=0;n+2<=t.length;n+=2){let i=45*e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(n));i+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(n+1)),r(i,11,s)}return n<t.length&&r(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(n)),6,s),new e(e.Mode.ALPHANUMERIC,t.length,s)}static makeSegments(t){return""==t?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let n=[];if(t<0)throw new RangeError("ECI assignment value out of range");if(t<128)r(t,8,n);else if(t<16384)r(2,2,n),r(t,14,n);else{if(!(t<1e6))throw new RangeError("ECI assignment value out of range");r(6,3,n),r(t,21,n)}return new e(e.Mode.ECI,0,n)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let r=0;for(const n of e){const e=n.mode.numCharCountBits(t);if(n.numChars>=1<<e)return 1/0;r+=4+e+n.bitData.length}return r}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let r=0;r<e.length;r++)"%"!=e.charAt(r)?t.push(e.charCodeAt(r)):(t.push(parseInt(e.substring(r+1,r+3),16)),r+=2);return t}};i.NUMERIC_REGEX=/^[0-9]*$/,i.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,i.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let o=i;e.QrSegment=i})(Ks||(Ks={})),(e=>{const t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})((qs=Ks||(Ks={})).QrCode||(qs.QrCode={})),(e=>{(e=>{const t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||(e.QrSegment={}))})(Ks||(Ks={}));var ri=Ks,ni={L:ri.QrCode.Ecc.LOW,M:ri.QrCode.Ecc.MEDIUM,Q:ri.QrCode.Ecc.QUARTILE,H:ri.QrCode.Ecc.HIGH},si=128,ii="L",oi="#FFFFFF",ai="#000000",li=!1,ci=1;
|
12
3
|
/**
|
13
4
|
* @license qrcode.react
|
14
5
|
* Copyright (c) Paul O'Shannessy
|
15
6
|
* 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/kiKV87qm4FFgM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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"})}));
|
7
|
+
*/function ui(e,t=0){const r=[];return e.forEach((function(e,n){let s=null;e.forEach((function(i,o){if(!i&&null!==s)return r.push(`M${s+t} ${n+t}h${o-s}v1H${s+t}z`),void(s=null);if(o!==e.length-1)i&&null===s&&(s=o);else{if(!i)return;null===s?r.push(`M${o+t},${n+t} h1v1H${o+t}z`):r.push(`M${s+t},${n+t} h${o+1-s}v1H${s+t}z`)}}))})),r.join("")}function di(e,t){return e.slice().map(((e,r)=>r<t.y||r>=t.y+t.h?e:e.map(((e,r)=>(r<t.x||r>=t.x+t.w)&&e))))}function hi({value:e,level:r,minVersion:n,includeMargin:s,marginSize:i,imageSettings:o,size:a,boostLevel:l}){let c=t.useMemo((()=>{const t=(Array.isArray(e)?e:[e]).reduce(((e,t)=>(e.push(...ri.QrSegment.makeSegments(t)),e)),[]);return ri.QrCode.encodeSegments(t,ni[r],n,void 0,void 0,l)}),[e,r,n,l]);const{cells:u,margin:d,numCells:h,calculatedImageSettings:p}=t.useMemo((()=>{let e=c.getModules();const t=function(e,t){return null!=t?Math.max(Math.floor(t),0):e?4:0}(s,i),r=e.length+2*t,n=function(e,t,r,n){if(null==n)return null;const s=e.length+2*r,i=Math.floor(.1*t),o=s/t,a=(n.width||i)*o,l=(n.height||i)*o,c=null==n.x?e.length/2-a/2:n.x*o,u=null==n.y?e.length/2-l/2:n.y*o,d=null==n.opacity?1:n.opacity;let h=null;if(n.excavate){let e=Math.floor(c),t=Math.floor(u);h={x:e,y:t,w:Math.ceil(a+c-e),h:Math.ceil(l+u-t)}}return{x:c,y:u,h:l,w:a,excavation:h,opacity:d,crossOrigin:n.crossOrigin}}(e,a,t,o);return{cells:e,margin:t,numCells:r,calculatedImageSettings:n}}),[c,a,o,s,i]);return{qrcode:c,margin:d,cells:u,numCells:h,calculatedImageSettings:p}}var pi=function(){try{(new Path2D).addPath(new Path2D)}catch(e){return!1}return!0}();t.forwardRef((function(e,r){const n=e,{value:s,size:i=si,level:o=ii,bgColor:a=oi,fgColor:l=ai,includeMargin:c=li,minVersion:u=ci,boostLevel:d,marginSize:h,imageSettings:p}=n,f=ti(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:m}=f,g=ti(f,["style"]),y=null==p?void 0:p.src,_=t.useRef(null),b=t.useRef(null),w=t.useCallback((e=>{_.current=e,"function"==typeof r?r(e):r&&(r.current=e)}),[r]),[v,x]=t.useState(!1),{margin:E,cells:N,numCells:k,calculatedImageSettings:A}=hi({value:s,level:o,minVersion:u,boostLevel:d,includeMargin:c,marginSize:h,imageSettings:p,size:i});t.useEffect((()=>{if(null!=_.current){const e=_.current,t=e.getContext("2d");if(!t)return;let r=N;const n=b.current,s=null!=A&&null!==n&&n.complete&&0!==n.naturalHeight&&0!==n.naturalWidth;s&&null!=A.excavation&&(r=di(N,A.excavation));const o=window.devicePixelRatio||1;e.height=e.width=i*o;const c=i/k*o;t.scale(c,c),t.fillStyle=a,t.fillRect(0,0,k,k),t.fillStyle=l,pi?t.fill(new Path2D(ui(r,E))):N.forEach((function(e,r){e.forEach((function(e,n){e&&t.fillRect(n+E,r+E,1,1)}))})),A&&(t.globalAlpha=A.opacity),s&&t.drawImage(n,A.x+E,A.y+E,A.w,A.h)}})),t.useEffect((()=>{x(!1)}),[y]);const T=ei({height:i,width:i},m);let S=null;return null!=y&&(S=t.createElement("img",{src:y,key:y,style:{display:"none"},onLoad:()=>{x(!0)},ref:b,crossOrigin:null==A?void 0:A.crossOrigin})),t.createElement(t.Fragment,null,t.createElement("canvas",ei({style:T,height:i,width:i,ref:w,role:"img"},g)),S)})).displayName="QRCodeCanvas";var fi=t.forwardRef((function(e,r){const n=e,{value:s,size:i=si,level:o=ii,bgColor:a=oi,fgColor:l=ai,includeMargin:c=li,minVersion:u=ci,boostLevel:d,title:h,marginSize:p,imageSettings:f}=n,m=ti(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:g,cells:y,numCells:_,calculatedImageSettings:b}=hi({value:s,level:o,minVersion:u,boostLevel:d,includeMargin:c,marginSize:p,imageSettings:f,size:i});let w=y,v=null;null!=f&&null!=b&&(null!=b.excavation&&(w=di(y,b.excavation)),v=t.createElement("image",{href:f.src,height:b.h,width:b.w,x:b.x+g,y:b.y+g,preserveAspectRatio:"none",opacity:b.opacity,crossOrigin:b.crossOrigin}));const x=ui(w,g);return t.createElement("svg",ei({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:r,role:"img"},m),!!h&&t.createElement("title",null,h),t.createElement("path",{fill:a,d:`M0,0 h${_}v${_}H0z`,shapeRendering:"crispEdges"}),t.createElement("path",{fill:l,d:x,shapeRendering:"crispEdges"}),v)}));fi.displayName="QRCodeSVG";const mi=({walletAddress:e,amount:r,currency:n,network:s,theme:i="light",size:o=200})=>{const[a,l]=t.useState(""),[c,u]=t.useState(null);t.useEffect((()=>{if(e&&"No address configured"!==e)try{let t;switch(s){case"tron":t="TRX"===n?`tronlink://transfer?to=${e}&amount=${r}`:e;break;case"algorand":t=`algorand://${e}?amount=${Math.floor(1e6*parseFloat(r))}`;break;case"bsc":if("BNB"===n)t=`ethereum:${e}@56?value=${p(r)}`;else{const s=d(n,"bsc");t=s?`ethereum:${s}/transfer?address=${e}&uint256=${h(r,n)}@56`:e}break;default:if("ETH"===n)t=`ethereum:${e}@1?value=${p(r)}`;else{const s=d(n,"ethereum");t=s?`ethereum:${s}/transfer?address=${e}&uint256=${h(r,n)}`:e}}l(t),u(null)}catch(t){console.error("Error generating QR code:",t),u("Error generating payment QR code")}else u("No wallet address configured for this network")}),[e,r,n,s]);const d=(e,t)=>{var r;return(null==(r={ethereum:{USDT:"0xdAC17F958D2ee523a2206206994597C13D831ec7",USDC:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},bsc:{USDT:"0x55d398326f99059fF775485246999027B3197955",USDC:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"},tron:{USDT:"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",USDC:"TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8"}}[t])?void 0:r[e])||""},h=(e,t)=>{const r="USDT"===t||"USDC"===t?6:18;return Math.floor(parseFloat(e)*Math.pow(10,r)).toString()},p=e=>Math.floor(1e18*parseFloat(e)).toString(),f=e=>({ethereum:"Ethereum",bsc:"BSC",tron:"Tron",algorand:"Algorand"}[e]||e);return $s.jsxs("div",{className:"flex flex-col items-center",children:[c?$s.jsxs("div",{className:"p-4 rounded-lg bg-red-100 mb-3 text-red-700 text-center",children:[$s.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:$s.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"})}),$s.jsx("p",{className:"font-medium",children:c})]}):$s.jsx("div",{className:"p-4 rounded-lg bg-white mb-3 shadow-sm border",children:a&&$s.jsx(fi,{value:a,size:o,bgColor:"dark"===i?"#374151":"#FFFFFF",fgColor:"dark"===i?"#FFFFFF":"#000000",level:"H",includeMargin:!0})}),$s.jsxs("div",{className:"text-center text-sm text-gray-700 mb-4",children:[$s.jsxs("p",{className:"font-semibold text-gray-800 flex items-center justify-center",children:[$s.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:$s.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]}),$s.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Scan with your ",f(s)," wallet app"]})]}),$s.jsxs("div",{className:"w-full mb-4 p-3 bg-gray-50 rounded-lg",children:[$s.jsxs("div",{className:"flex justify-between items-center",children:[$s.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Amount to Pay:"}),$s.jsxs("span",{className:"text-lg font-bold text-[#7042D2]",children:[r," ",n]})]}),$s.jsxs("div",{className:"flex justify-between items-center mt-1",children:[$s.jsx("span",{className:"text-xs text-gray-500",children:"Network:"}),$s.jsx("span",{className:"text-xs font-medium text-gray-700",children:f(s)})]})]}),!c&&$s.jsxs("div",{className:"w-full mb-4",children:[$s.jsx("p",{className:"text-xs text-gray-500 mb-1 text-center",children:"Or copy wallet address:"}),$s.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 t;return null==(t=navigator.clipboard)?void 0:t.writeText(e)},title:"Click to copy",children:e})]}),$s.jsx("div",{className:"w-full",children:$s.jsxs("div",{className:"p-3 rounded bg-blue-50 border border-blue-200",children:[$s.jsxs("h4",{className:"text-sm font-medium mb-2 text-blue-800 flex items-center",children:[$s.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:$s.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"]}),$s.jsxs("ol",{className:"text-xs space-y-1 text-blue-700",children:[$s.jsxs("li",{children:["1. Open your crypto wallet app (",(m=s,{ethereum:["MetaMask","Trust Wallet","Coinbase Wallet"],bsc:["MetaMask","Trust Wallet","SafePal"],tron:["TronLink","Trust Wallet"],algorand:["Pera Wallet","MyAlgo Wallet"]}[m]||["MetaMask","Trust Wallet"]).join(", "),")"]}),$s.jsx("li",{children:"2. Scan the QR code above or copy the wallet address"}),$s.jsxs("li",{children:["3. Send exactly ",$s.jsxs("strong",{children:[r," ",n]})," on ",f(s)," network"]}),$s.jsx("li",{children:'4. Click "I have sent the payment" button below after sending'})]}),$s.jsx("div",{className:"mt-3 p-2 bg-yellow-50 border border-yellow-200 rounded",children:$s.jsxs("p",{className:"text-xs text-yellow-800",children:[$s.jsx("strong",{children:"Important:"})," Make sure you're sending on the correct network (",f(s),") and using the exact amount shown above."]})})]})})]});var m},gi=({status:e,message:t,theme:r="light"})=>$s.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[$s.jsx("div",{className:"mb-4",children:(()=>{switch(e){case"processing":return $s.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-4 border-t-blue-500 border-blue-500/20"});case"success":return $s.jsx("div",{className:"rounded-full h-12 w-12 bg-green-100 flex items-center justify-center",children:$s.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:$s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})});case"error":return $s.jsx("div",{className:"rounded-full h-12 w-12 bg-red-100 flex items-center justify-center",children:$s.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:$s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})});default:return null}})()}),$s.jsx("h3",{className:"text-xl font-bold mb-2 "+("dark"===r?"text-white":"text-gray-900"),children:(()=>{switch(e){case"processing":return"Processing Payment";case"success":return"Payment Successful";case"error":return"Payment Failed";default:return"Unknown Status"}})()}),$s.jsx("p",{className:`text-center ${(()=>{switch(e){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:t}),"processing"===e&&$s.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"===e&&$s.jsx("div",{className:"mt-4 p-2 rounded "+("dark"===r?"bg-gray-700":"bg-gray-100"),children:$s.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."})})]}),yi=({onSelect:e,selected:r,theme:n="light",supportedNetworks:s=[]})=>{const[i,o]=t.useState(cs.ETHEREUM),[a,l]=t.useState({}),[c,u]=t.useState(!1);t.useEffect((()=>{l(fs())}),[]);const d=[{id:cs.ETHEREUM,name:"Ethereum",description:"ERC-20 tokens"},{id:cs.BSC,name:"BSC (Binance Smart Chain)",description:"BEP-20 tokens"},{id:cs.TRON,name:"Tron",description:"TRC-20 tokens"},{id:cs.ALGORAND,name:"Algorand",description:"ASA tokens"}],h=(e=>{const t=[];switch(e){case cs.ETHEREUM:t.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:cs.ETHEREUM},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:cs.ETHEREUM},{id:"PYUSD",name:"PYUSD",description:"PayPal USD",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/28492.png",network:cs.ETHEREUM},{id:"FRAX",name:"FRAX",description:"Frax",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6952.png",network:cs.ETHEREUM},{id:"USDP",name:"USDP",description:"Pax Dollar",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6662.png",network:cs.ETHEREUM},{id:"DAI",name:"DAI",description:"Dai Stablecoin",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4943.png",network:cs.ETHEREUM},{id:"ETH",name:"ETH",description:"Ethereum",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTcyJyRKN0dRJWVZqoLzYgkRHdJsxKGq8nHUw&s",network:cs.ETHEREUM});break;case cs.BSC:t.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:cs.BSC},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:cs.BSC},{id:"BUSD",name:"BUSD",description:"Binance USD",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4687.png",network:cs.BSC},{id:"FRAX",name:"FRAX",description:"Frax",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/6952.png",network:cs.BSC},{id:"BNB",name:"BNB",description:"Binance Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRHSjyW2sSnBhwztCwVW97i1BtV40g7heMMxg&s",network:cs.BSC});break;case cs.TRON:t.push({id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:cs.TRON},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:cs.TRON},{id:"USDJ",name:"USDJ",description:"JUST Stablecoin",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/5446.png",network:cs.TRON},{id:"TRX",name:"TRX",description:"Tron",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQKLpLNsGRHbZfCUXAjZLPSp_YFZvX5dMnAoA&s",network:cs.TRON});break;case cs.ALGORAND:t.push({id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",network:cs.ALGORAND},{id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",network:cs.ALGORAND},{id:"ALGO",name:"ALGO",description:"Algorand",logo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4030.png",network:cs.ALGORAND})}return t})(i),p=c?h:h.slice(0,4);function f(e){switch(e){case cs.ETHEREUM:case cs.BSC:return ls.METAMASK;case cs.TRON:return ls.TRONLINK;case cs.ALGORAND:return ls.LUTE;default:return ls.METAMASK}}return $s.jsxs("div",{children:[$s.jsx("h3",{className:"text-lg font-medium mb-4 "+("dark"===n?"text-white":"text-gray-800"),children:"Select Payment Method"}),$s.jsxs("div",{className:"mb-6",children:[$s.jsx("label",{className:"block text-sm font-medium mb-2 "+("dark"===n?"text-white":"text-gray-700"),children:"Blockchain Network"}),$s.jsx("select",{value:i,onChange:t=>{return n=t.target.value,o(n),u(!1),void((null==r?void 0:r.network)!==n&&e(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:d.filter((e=>0===s.length||s.includes(e.id))).map((e=>$s.jsxs("option",{value:e.id,children:[e.name," - ",e.description]},e.id)))})]}),$s.jsxs("div",{className:"mb-4",children:[$s.jsx("label",{className:"block text-sm font-medium mb-3 "+("dark"===n?"text-white":"text-gray-700"),children:"Choose Cryptocurrency"}),$s.jsx("div",{className:"grid grid-cols-2 gap-3 mb-4",children:p.map((t=>$s.jsx("button",{onClick:()=>(t=>{var r;e({currency:t.id,network:i,tokenConfig:null==(r=ds[t.id])?void 0:r[i],method:t})})(t),className:"p-4 rounded-lg transition-all duration-200 border-2 "+((null==r?void 0:r.currency)===t.id&&(null==r?void 0:r.network)===i?"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:$s.jsxs("div",{className:"flex flex-col items-center text-center",children:[$s.jsx("div",{className:"flex-shrink-0 h-10 w-10 bg-white rounded-full flex items-center justify-center mb-2 shadow-sm",children:$s.jsx("img",{src:t.logo,alt:t.name,className:"h-6 w-6"})}),$s.jsxs("div",{children:[$s.jsx("h4",{className:"font-medium text-sm "+("dark"===n?"text-white":"text-gray-900"),children:t.name}),$s.jsx("p",{className:"text-xs "+("dark"===n?"text-gray-300":"text-gray-500"),children:t.description})]}),(null==r?void 0:r.currency)===t.id&&(null==r?void 0:r.network)===i&&$s.jsx("div",{className:"mt-2",children:$s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-[#7042D2]",viewBox:"0 0 20 20",fill:"currentColor",children:$s.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"})})})]})},`${t.id}-${t.network}`)))}),h.length>4&&$s.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 (${h.length-4} more)`})]}),$s.jsx("div",{className:"p-3 rounded-lg text-sm "+("dark"===n?"bg-gray-800 text-gray-300":"bg-gray-50 text-gray-600"),children:$s.jsxs("div",{className:"flex items-center",children:[$s.jsx("div",{className:"w-2 h-2 rounded-full mr-2 "+(a[f(i)]?"bg-green-500":"bg-red-500")}),$s.jsx("span",{className:"text-xs",children:function(e){const t=f(e),r=a[t],n={[ls.METAMASK]:"MetaMask",[ls.TRONLINK]:"TronLink",[ls.TRUST_WALLET]:"Trust Wallet",[ls.LUTE]:"Lute Wallet"};return r?`${n[t]} detected - Ready to pay`:`${n[t]} required - Please install to continue`}(i)})]})})]})},_i=({isOpen:e,onClose:r,payment:n,paymentStatus:s,selectedPaymentMethod:i,onPaymentMethodSelect:o,onPayment:a,onBack:l,error:c,theme:u="light",merchantName:d,transactionHash:h,walletConnection:p,onConnectWallet:f,testMode:m=!1,supportedNetworks:g=[],availableWallets:y={},supportedWallets:_=[],step:b="select-currency",merchantWalletAddresses:w={},debug:v=!1})=>{const[x,E]=t.useState("wallet"),N=e=>({ethereum:"Ethereum",bsc:"BSC",tron:"Tron",algorand:"Algorand"}[e]||e),k=e=>({[ls.METAMASK]:"MetaMask",[ls.TRONLINK]:"TronLink",[ls.TRUST_WALLET]:"Trust Wallet",[ls.LUTE]:"Lute Wallet"}[e]||e),A=e=>({[ls.METAMASK]:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT3ymr3UNKopfI0NmUY95Dr-0589vG-91KuAA&s",[ls.TRONLINK]:"https://www.tronlink.org/images/logo.png",[ls.TRUST_WALLET]:"https://trustwallet.com/assets/images/trust_logotype.svg",[ls.LUTE]:"https://lute.app/logo.png"}[e]||"");return e?$s.jsx("div",{className:"fixed inset-0 z-50 overflow-y-auto bg-black/50",children:$s.jsx("div",{className:"flex min-h-screen items-center justify-center p-4",children:$s.jsxs("div",{className:"relative p-6 w-full max-w-md mx-auto rounded-lg shadow-xl bg-white text-gray-800",children:[$s.jsxs("div",{className:"flex justify-between items-center mb-6 bg-[#F1ECFB] p-3 rounded-xl",children:[$s.jsx("div",{className:"flex items-center",children:$s.jsx("h2",{className:"text-xl font-bold text-gray-900",children:$s.jsx("img",{src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJQAAAAkCAYAAABv9hOhAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAmVSURBVHgB7Vzdcdu4Fv5I+X2VCoK83pkb2xVc2ikgTgVWKog8twDJBexYrsBKBXYKWJtbQWRnZl+NrWC172txcQBQBA8B/kiKV87qm4FFgMAhAX48ODg4dISOGB4/XKsfObl9e+Y9n3wViHt3QHY5ud2fYId1caDSJyc/V+kMW4q4S2VFFurcCR0Oj+/H3kq9vSv1VyDDKX5s0Fh8VSlTifrcx/cByR046QRbjE6EQmnQok9aGzlQ+QRZluDHh1BJaWFNKsJApQvs0JlQc+e4jzgelqX1HNUczfHjQqCqkRLsUCWU0jL94buHE659LG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xXCW3gUOmfpBMeTSmiXU6QRwnVtSJzke9q6Lu4oOdMsd6Fbka6G0KkVEgbGQTQdztkxThuG8a6ARhMlG7bZvuctB9+cZHwH5DCaOFEvjJdIQwuAbMMUMgINAfD8UD41yo6dHaRgNb0reSzK+aFvNwYU1QIpWJOliHVGNU96DqkML/Bk3RLf6b6h2hvWf9n8IY9XucPhARDxva+FwIhMtQg0rEJiNLGSZI7lyvDMsXhbG1LKLeMvTBTodH9vN0IhVWnP6mNg1gDOaEnc+N+DxsIwQJQ6qBlcOnAZJDRPyMeiJ9QflhSHbuJyazCVze3JE79ZRzpCj6RY7pBH6NRNe5QfvVqgxcy4uIF5hPzCO/JlG2k44pP36g8Ip+qYyM78yZyxdPr1w3g/5yJoqv9apSGfuTX95uYgoRzrHE6hAbkrNtcG3LOVZzhnLbboqaT8aqU17mnermS+KY6Yzv5QBP7LOoOB64WR2MRxGgWsvhakNed+mkbZCzbSACSVR9Vm3BXQWEz3UNqoSquhCmJtTXbg4vjXDQFDjLtZD+pUjPQtA+F0021eRu/40NKz7ADtuMkB8urWtU/Yzq9u1UaQ+pow0WTzdV77hDlGgZgmuQLdT8HBmi1Hjfl3HnO2wbEhT2qWDniAeNIdD+z6jqQlXcuHL6MMHFYpEuDfYo2sSUtsPzQiDs6CQySTQgRldkWU6UKf+KRROxOaR4h5cF0kzk+pm2qdydUJF2D8yXH3NyPP21tf9dbYdOkDAOU3JFtF6R76EraO9PrfJC39hZv5NidG835b085Eb3qi4G/A2inrQKnVgMFAAAAABJRU5ErkJggg==",className:"w-32",alt:"Coinley Logo"})})}),$s.jsx("button",{onClick:r,className:"text-gray-500 hover:text-gray-700 focus:outline-none",children:$s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:$s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),$s.jsxs("div",{className:"mb-6 bg-[#F1ECFB] p-3 rounded-xl",children:[n&&$s.jsxs("div",{className:"mb-6 p-4 rounded-lg",children:[$s.jsxs("p",{className:"text-lg text-gray-800 font-semibold",children:["PAY: ",d]}),$s.jsxs("div",{className:"flex justify-between items-center mt-2 bg-gray-100 px-3 rounded-lg",children:[$s.jsx("span",{className:"font-medium text-gray-700",children:"Amount:"}),$s.jsxs("span",{className:"font-bold text-xl text-[#7042D2]",children:["$",(S=n.totalAmount||n.amount,parseFloat(S).toFixed(2))]})]}),$s.jsx("div",{className:"text-xs mt-1 text-right",children:$s.jsxs("span",{className:"text-gray-500",children:["Payment ID: ",n.id?n.id.slice(0,8):"","..."]})})]}),v&&$s.jsx("div",{className:"mb-2 text-right",children:$s.jsx("button",{onClick:()=>{console.log("=== DEBUG INFO ==="),console.log("Current step:",b),console.log("Payment method:",i),console.log("Wallet connection:",p),gs()},className:"text-xs bg-gray-200 p-1 rounded",children:"Debug"})}),"select-currency"===b&&$s.jsxs("div",{children:[$s.jsx(yi,{onSelect:o,selected:i,theme:u,supportedNetworks:g}),i&&$s.jsx("div",{className:"mt-6",children:$s.jsxs("button",{onClick:()=>{console.log("Proceed button clicked, calling onPaymentMethodSelect"),o(i)},className:"w-full py-3 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-lg transition-colors",disabled:!i,children:["Proceed with ",i.currency," on ",N(i.network)]})})]}),"confirm"===b&&i&&n&&$s.jsxs("div",{children:[$s.jsxs("div",{className:"p-4 rounded-lg mb-4 bg-gray-100",children:[$s.jsx("h3",{className:"text-lg font-medium mb-2 text-gray-800",children:"Payment Details"}),$s.jsxs("div",{className:"space-y-2",children:[$s.jsxs("div",{className:"flex justify-between",children:[$s.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Currency:"}),$s.jsx("span",{className:"font-medium",children:i.currency})]}),$s.jsxs("div",{className:"flex justify-between",children:[$s.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Network:"}),$s.jsx("span",{className:"font-medium",children:N(i.network)})]}),$s.jsxs("div",{className:"flex justify-between",children:[$s.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Fee:"}),$s.jsx("span",{className:"font-medium",children:"1.75%"})]})]})]}),$s.jsx("div",{className:"mb-4",children:$s.jsxs("div",{className:"flex border-b border-gray-200",children:[$s.jsx("button",{onClick:()=>E("wallet"),className:"py-2 px-4 text-sm font-medium "+("wallet"===x?"border-b-2 border-[#7042D2] text-[#7042D2]":"text-gray-500 hover:text-gray-700"),children:"Connect Wallet"}),$s.jsx("button",{onClick:()=>E("qrcode"),className:"py-2 px-4 text-sm font-medium "+("qrcode"===x?"border-b-2 border-[#7042D2] text-[#7042D2]":"text-gray-500 hover:text-gray-700"),children:"QR Code"})]})}),m?$s.jsx("div",{className:"p-4 rounded-lg mb-4 bg-blue-50",children:$s.jsxs("div",{className:"flex items-center",children:[$s.jsx("div",{className:"bg-[#7042D2] rounded-full p-2 mr-3",children:$s.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:$s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),$s.jsxs("div",{children:[$s.jsx("h3",{className:"font-medium text-gray-800",children:"Test Mode Payment"}),$s.jsx("p",{className:"text-sm text-gray-600",children:'Click "Pay Now" to simulate a successful payment'})]})]})}):"qrcode"===x?$s.jsx("div",{className:"mb-4",children:$s.jsx(mi,{walletAddress:(()=>{if(!i)return"No network selected";const e=w[i.network];return e||((null==n?void 0:n.recipientWallet)?n.recipientWallet:"No wallet address configured for this network")})(),amount:n.totalAmount||n.amount,currency:i.currency,network:i.network,theme:u})}):$s.jsxs("div",{className:"space-y-3 mb-4",children:[0===_.length?$s.jsx("div",{className:"p-4 rounded-lg bg-yellow-50",children:$s.jsxs("div",{className:"flex items-center",children:[$s.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:$s.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"})}),$s.jsxs("div",{children:[$s.jsx("h3",{className:"font-medium text-gray-800",children:"No Compatible Wallets"}),$s.jsxs("p",{className:"text-sm text-gray-600",children:["No wallets detected for ",N(i.network)," network"]})]})]})}):_.map((e=>$s.jsx("div",{className:"p-4 rounded-lg bg-blue-50",children:$s.jsxs("div",{className:"flex items-center justify-between",children:[$s.jsxs("div",{className:"flex items-center",children:[$s.jsx("img",{src:A(e),alt:k(e),className:"w-8 h-8 mr-3",onError:e=>{e.target.style.display="none"}}),$s.jsxs("div",{children:[$s.jsx("h3",{className:"font-medium text-gray-800",children:k(e)}),$s.jsxs("p",{className:"text-sm text-gray-600",children:["Pay with ",k(e)]})]})]}),(null==p?void 0:p.walletType)===e?$s.jsxs("div",{className:"flex items-center space-x-2",children:[$s.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),$s.jsx("span",{className:"text-sm text-green-600",children:"Connected"})]}):$s.jsx("button",{onClick:()=>{console.log("Connect wallet button clicked for:",e),f(e)},className:"py-2 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-md text-sm",children:"Connect"})]})},e))),$s.jsx("div",{className:"space-y-2",children:Object.entries(y).filter((([e,t])=>!t)).map((([e])=>$s.jsx("div",{className:"p-3 rounded-lg bg-gray-50",children:$s.jsxs("div",{className:"flex items-center justify-between",children:[$s.jsxs("span",{className:"text-sm text-gray-600",children:[k(e)," not detected"]}),$s.jsx("a",{href:ps(e),target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#7042D2] hover:underline",children:"Install"})]})},e)))})]}),c&&$s.jsx("div",{className:"p-3 rounded-lg bg-red-50 mb-4 text-red-600 text-sm",children:c}),$s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[$s.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"}),$s.jsx("button",{type:"button",onClick:()=>a("qrcode"===x),className:"w-full py-2 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-md",disabled:!m&&"wallet"===x&&!p,children:"qrcode"===x?"I have sent the payment":"Pay Now"})]})]}),"processing"===b&&$s.jsx(gi,{status:"processing",theme:u,message:"Processing your payment..."}),"success"===b&&$s.jsxs("div",{children:[$s.jsx(gi,{status:"success",theme:u,message:"Payment successful!"}),h&&$s.jsxs("div",{className:"mt-4 p-3 rounded-lg bg-gray-100",children:[$s.jsx("p",{className:"text-xs text-gray-600 mb-1",children:"Transaction Hash:"}),$s.jsx("p",{className:"text-sm font-mono break-all text-gray-800",children:(T=h,T?T.length<=14?T:`${T.slice(0,8)}...${T.slice(-6)}`:"")}),i&&$s.jsx("a",{href:`${bi(i.network)}/${wi(i.network)}/${h}`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#7042D2] mt-2 inline-block",children:"View on Explorer →"})]})]}),"error"===b&&$s.jsxs("div",{children:[$s.jsx(gi,{status:"error",theme:u,message:c||"An error occurred while processing your payment."}),$s.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"})]})]}),$s.jsx("div",{className:"text-center text-xs text-gray-500",children:$s.jsxs("p",{children:["Powered by ",$s.jsx("span",{className:"text-[#7042D2]",children:"Coinley"})," - Secure Cryptocurrency Payments"]})})]})})}):null;var T,S},bi=e=>({ethereum:"https://etherscan.io",bsc:"https://bscscan.com",tron:"https://tronscan.org",algorand:"https://algoexplorer.io"}[e]||"https://etherscan.io"),wi=e=>({ethereum:"tx",bsc:"tx",tron:"transaction",algorand:"tx"}[e]||"tx"),vi=t.forwardRef((({apiKey:e,apiSecret:r,apiUrl:n,customerEmail:s,merchantName:i="Merchant",merchantWalletAddresses:o={},onSuccess:a,onError:l,onClose:c,theme:u,autoOpen:d=!1,debug:h=!1,testMode:p=!1,supportedNetworks:f=[],preferredNetwork:m=cs.ETHEREUM,preferredWallet:g=ls.METAMASK},y)=>{const _=Hs(),{theme:b}=t.useContext(zs),[w,v]=t.useState(d),[x,E]=t.useState(null),[N,k]=t.useState("idle"),[A,T]=t.useState(null),[S,R]=t.useState(null),[O,C]=t.useState(null),[P,M]=t.useState(null),[F,j]=t.useState({}),[U,L]=t.useState("select-currency"),[I,G]=t.useState({}),[D,B]=t.useState(!1),W=e||(null==_?void 0:_.apiKey),$=r||(null==_?void 0:_.apiSecret);n||null==_||_.apiUrl;const z=u||b,V=h||(null==_?void 0:_.debug),H=f.length>0?f:[cs.ETHEREUM,cs.BSC,cs.TRON,cs.ALGORAND];t.useImperativeHandle(y,(()=>({open:e=>{q(e)},close:()=>{J()},getPayment:()=>x,getWalletConnection:()=>P,getMerchantWallets:()=>I,debugWallets:()=>gs()})));const K=(e,t)=>{V&&console.log(`[Coinley SDK] ${e}`,t)};t.useEffect((()=>{if("undefined"!=typeof window){(()=>__async(this,null,(function*(){const e=yield ms(3,1e3);j(e),K("Available wallets detected:",e)})))()}}),[V]),t.useEffect((()=>{(()=>{__async(this,null,(function*(){if(W&&$){B(!0);try{const e=__spreadProps(__spreadValues({},Rs),{merchantWalletAddresses:__spreadValues({},Rs.merchantWalletAddresses)});if(e.merchantWalletAddresses&&Object.keys(e.merchantWalletAddresses).length>0)G(e.merchantWalletAddresses),K("Loaded wallet addresses from API config:",e.merchantWalletAddresses);else{const e=yield Cs();e&&Object.keys(e).length>0?(G(e),K("Fetched wallet addresses from API:",e)):K("No wallet addresses found in API response")}o&&Object.keys(o).length>0&&(G((e=>__spreadValues(__spreadValues({},e),o))),K("Added manual wallet addresses:",o))}catch(e){K("Error loading merchant wallet addresses:",e),console.warn("Could not load merchant wallet addresses:",e.message),o&&Object.keys(o).length>0&&(G(o),K("Using fallback manual wallet addresses:",o))}finally{B(!1)}}else K("No API credentials available for wallet address fetching")}))})()}),[W,$,o,V]);const q=e=>__async(this,null,(function*(){if(!e||!e.amount)return R("Payment amount is required"),void(l&&l(new Error("Payment amount is required")));k("loading"),v(!0),L("select-currency");try{K("Creating payment with details:",e);let r=__spreadValues({},I);if(0===Object.keys(r).length){K("No wallet addresses available, attempting to fetch...");try{const e=yield Cs();e&&(r=e,G(e))}catch(t){K("Failed to fetch wallet addresses:",t)}}e.merchantWalletAddresses&&(r=__spreadValues(__spreadValues({},r),e.merchantWalletAddresses)),o&&(r=__spreadValues(__spreadValues({},r),o)),K("Final wallet addresses for payment:",r);const n=yield Ps({amount:e.amount,currency:e.currency||"USDT",network:e.network||m,customerEmail:e.customerEmail||s,callbackUrl:e.callbackUrl,metadata:__spreadProps(__spreadValues({},e.metadata),{sdkVersion:"1.0.0",merchantWallets:r}),merchantWalletAddresses:r});if(K("Payment created:",n),!n.payment)throw new Error("Invalid payment response structure");E(n.payment),n.merchantConfig&&n.merchantConfig.walletAddresses&&(G((e=>__spreadValues(__spreadValues({},e),n.merchantConfig.walletAddresses))),K("Updated wallet addresses from payment response:",n.merchantConfig.walletAddresses)),k("idle"),R(null),K("Payment created and state updated successfully")}catch(r){K("Error creating payment:",r),R(r.message||"Failed to create payment"),k("error"),l&&l(r)}})),J=()=>{v(!1),C(null),M(null),T(null),L("select-currency"),R(null),c&&c()},Q=()=>{if(!A)return null;const e=A.network;return x&&x.recipientWallet?x.recipientWallet:I[e]?I[e]:o[e]?o[e]:null};return D?$s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:$s.jsx("div",{className:"bg-white p-6 rounded-lg shadow-xl",children:$s.jsxs("div",{className:"flex items-center space-x-3",children:[$s.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-2 border-blue-500 border-t-transparent"}),$s.jsx("span",{className:"text-gray-700",children:"Loading payment gateway..."})]})})}):$s.jsx($s.Fragment,{children:w&&$s.jsx(_i,{isOpen:w,onClose:J,payment:x,paymentStatus:N,selectedPaymentMethod:A,onPaymentMethodSelect:e=>{K("Payment method selected:",e),T(e),L("confirm")},onPayment:()=>__async(this,null,(function*(){if(!x||!A)return void R("Missing payment information");const e=Q();if(e||p)if(P||p){K("Starting payment process..."),k("loading"),C(null),L("processing");try{let t;if(p)K("Test mode: Generating mock transaction..."),t=`test_${Date.now().toString(16)}_${Math.random().toString(16).substring(2,10)}`;else{K("Sending transaction through wallet...",{recipientAddress:e,amount:x.totalAmount||x.amount,network:A.network});const r=x.token||A.tokenConfig;t=yield Es(P,{to:e,amount:x.totalAmount||x.amount,tokenAddress:null==r?void 0:r.contractAddress,tokenDecimals:null==r?void 0:r.decimals,currency:A.currency,network:A.network,tokenConfig:r})}K("Transaction hash:",t),C(t),K("Processing payment with backend...");const r=yield Ms({paymentId:x.id,transactionHash:t,network:A.network,currency:A.currency,senderAddress:null==P?void 0:P.address});K("Payment processed successfully:",r),k("success"),L("success"),a&&(K("Calling onSuccess callback..."),a(x.id,t,{network:A.network,currency:A.currency,amount:x.totalAmount||x.amount,recipientAddress:e}))}catch(t){K("Payment error:",t);let e=t.message||"Failed to process payment";e.includes("User rejected")||e.includes("user rejected")?e="Transaction was rejected by user":e.includes("insufficient funds")?e="Insufficient funds in wallet":e.includes("network")?e="Network error. Please check your connection and try again":(e.includes("recipient")||e.includes("address"))&&(e="Invalid recipient address. Please contact support"),R(e),k("error"),L("error"),l&&l(new Error(e))}}else R("Please connect your wallet first");else R(`No recipient wallet address configured for ${A.network} network`)})),onBack:()=>{"confirm"===U?(L("select-currency"),M(null),R(null)):"error"===U&&(L("confirm"),R(null))},error:S,theme:z,merchantName:i,transactionHash:O,walletConnection:P,onConnectWallet:e=>__async(this,null,(function*(){if(A)try{R(null),K("Connecting wallet:",{walletType:e,network:A.network});const t=yield vs(e,A.network,2);M(t),R(null),K("Wallet connected successfully:",t)}catch(t){K("Wallet connection error:",t),R(t.message||"Failed to connect wallet")}else R("Please select a payment method first")})),testMode:p,supportedNetworks:H,availableWallets:F,supportedWallets:A?xs(A.network):[],step:U,merchantWalletAddresses:I,recipientAddress:Q(),debug:V})})}));vi.displayName="CoinleyCheckout";e.CoinleyCheckout=vi,e.CoinleyModal=_i,e.CoinleyProvider=({apiKey:e,apiSecret:r,apiUrl:n="https://coinleyserver-production.up.railway.app",merchantWalletAddress:s=null,merchantSolWalletAddress:i=null,debug:o=!1,children:a})=>{const[l,c]=t.useState(!1),[u,d]=t.useState(null),[h,p]=t.useState(null);t.useEffect((()=>{var t;if(e&&r)try{t={apiKey:e,apiSecret:r,apiUrl:n,merchantWalletAddress:s,merchantSolWalletAddress:i},Rs=__spreadValues(__spreadValues({},Rs),t),console.log("API initialized with:",{apiUrl:Rs.apiUrl,apiKey:Rs.apiKey?`${Rs.apiKey.substring(0,6)}...`:null,hasWalletAddresses:Object.keys(Rs.merchantWalletAddresses||{}).length>0}),Rs.apiKey&&Rs.apiSecret&&Cs().then((e=>{e&&(Rs.merchantWalletAddresses=__spreadValues(__spreadValues({},Rs.merchantWalletAddresses),e),console.log("Auto-fetched merchant wallet addresses:",e))})).catch((e=>{console.warn("Could not auto-fetch merchant wallet addresses:",e.message)})),c(!0),o&&console.log("Coinley SDK initialized with:",{apiKey:e,apiUrl:n,merchantWalletAddress:s?`${s.substring(0,6)}...${s.substring(s.length-4)}`:"Not provided",merchantSolWalletAddress:i?`${i.substring(0,6)}...${i.substring(i.length-4)}`:"Not provided"})}catch(a){d(a.message),o&&console.error("Coinley SDK initialization error:",a)}else d("API key and secret are required")}),[e,r,n,s,i,o]);const f={apiKey:e,apiSecret:r,apiUrl:n,merchantWalletAddress:s,merchantSolWalletAddress:i,isInitialized:l,error:u,debug:o,paymentData:h,storePaymentData:e=>(p(e),e)};return $s.jsx(Vs.Provider,{value:f,children:a})},e.DEFAULT_CONFIG={apiUrl:"https://coinleyserver-production.up.railway.app",debug:!1,testMode:!1,theme:"light",supportedNetworks:["ethereum","bsc","tron","algorand"]},e.NETWORK_CONFIG=us,e.NETWORK_TYPES=cs,e.PaymentMethods=yi,e.PaymentStatus=gi,e.QRCode=mi,e.TOKEN_CONFIG=ds,e.ThemeProvider=({initialTheme:e="light",children:r})=>{const[n,s]=t.useState(e);return t.useEffect((()=>{document.documentElement.classList.remove("light","dark"),document.documentElement.classList.add(n)}),[n]),$s.jsx(zs.Provider,{value:{theme:n,setTheme:s,toggleTheme:()=>{s((e=>"light"===e?"dark":"light"))}},children:r})},e.WALLET_TYPES=ls,e.connectWallet=vs,e.createPayment=Ps,e.detectWallets=fs,e.generateMockTransactionHash=(e="ethereum")=>`${{ethereum:"0x",bsc:"0x",tron:"",algorand:""}[e]||"0x"}${Array.from({length:64},(()=>Math.floor(16*Math.random()).toString(16))).join("")}`,e.getMerchantProfile=()=>__async(this,null,(function*(){try{const t=yield fetch(`${Rs.apiUrl}/api/merchants/dashboard`,{method:"GET",headers:Os()});if(!t.ok){let r;try{r=yield t.json()}catch(e){throw new Error(`Failed to get merchant profile: ${t.status} ${t.statusText}`)}throw new Error(r.error||`Failed to get merchant profile: ${t.status}`)}const r=yield t.json();if(r.merchant){const e={};r.merchant.walletAddress&&(e.ethereum=r.merchant.walletAddress),r.merchant.solWalletAddress&&(e.solana=r.merchant.solWalletAddress),r.merchant.merchantWallets&&Object.assign(e,r.merchant.merchantWallets),Rs.merchantWalletAddresses=__spreadValues(__spreadValues({},Rs.merchantWalletAddresses),e)}return r}catch(t){throw console.error("Get merchant profile error:",t),t}})),e.getPayment=e=>__async(this,null,(function*(){try{if(console.log("Getting payment:",e),!e)throw new Error("Payment ID is required");const r=yield fetch(`${Rs.apiUrl}/api/payments/${e}`,{method:"GET",headers:Os()});if(!r.ok){let e;try{e=yield r.json()}catch(t){throw new Error(`Failed to get payment: ${r.status} ${r.statusText}`)}throw console.error("Error getting payment:",e),new Error(e.error||`Failed to get payment: ${r.status}`)}const n=yield r.json();return console.log("Get payment response:",n),n.payment&&n.payment.merchantWallets&&(Rs.merchantWalletAddresses=__spreadValues(__spreadValues({},Rs.merchantWalletAddresses),n.payment.merchantWallets)),n}catch(r){throw console.error("Get payment error:",r),r}})),e.getSupportedNetworks=()=>__async(this,null,(function*(){try{const t=yield fetch(`${Rs.apiUrl}/api/networks`,{method:"GET",headers:Os()});if(!t.ok){let r;try{r=yield t.json()}catch(e){throw new Error(`Failed to get networks: ${t.status} ${t.statusText}`)}throw new Error(r.error||`Failed to get networks: ${t.status}`)}return yield t.json()}catch(t){throw console.error("Get supported networks error:",t),t}})),e.getSupportedWalletsForNetwork=xs,e.getWalletInstallUrl=ps,e.processPayment=Ms,e.sendTransaction=Es,e.useCoinley=Hs,e.validateWalletAddress=(e,t)=>__async(this,null,(function*(){try{const n=yield fetch(`${Rs.apiUrl}/api/wallets/validate`,{method:"POST",headers:Os(),body:JSON.stringify({address:e,network:t})});if(!n.ok){let e;try{e=yield n.json()}catch(r){throw new Error(`Failed to validate address: ${n.status} ${n.statusText}`)}throw new Error(e.error||`Failed to validate address: ${n.status}`)}return yield n.json()}catch(n){throw console.error("Validate wallet address error:",n),n}})),Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
|
17
8
|
//# sourceMappingURL=coinley-checkout.umd.js.map
|