UNPKG

coinley-checkout

Version:

A React SDK for Coinley cryptocurrency payment processing with multi-network support

2 lines 380 kB
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,n)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,__spreadValues=(e,t)=>{for(var n in t||(t={}))__hasOwnProp.call(t,n)&&__defNormalProp(e,n,t[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(t))__propIsEnum.call(t,n)&&__defNormalProp(e,n,t[n]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__publicField=(e,t,n)=>(__defNormalProp(e,"symbol"!=typeof t?t+"":t,n),n),__accessCheck=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},__privateGet=(e,t,n)=>(__accessCheck(e,t,"read from private field"),n?n.call(e):t.get(e)),__privateAdd=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},__privateSet=(e,t,n,r)=>(__accessCheck(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),__privateWrapper=(e,t,n,r)=>({set _(r){__privateSet(e,t,r,n)},get _(){return __privateGet(e,t,r)}}),__privateMethod=(e,t,n)=>(__accessCheck(e,t,"access private method"),n),__superGet=(e,t,n)=>__reflectGet(__getProtoOf(e),n,t),__async=(e,t,n)=>new Promise(((r,i)=>{var s=e=>{try{a(n.next(e))}catch(t){i(t)}},o=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=e=>e.done?r(e.value):Promise.resolve(e.value).then(s,o);a((n=n.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 n,r,i,s,o,a,l,c,u,h,d,p,f,g,m,y,_,w,v,b,A,x,E,k,N,S,C,P,T,M,R,B,I,G,O,L,F,U,D,j,H,W,z,Q,V,K,J,q,Z,Y,X,$,ee,te,ne,re,ie,se,oe,ae,le,ce,ue,he,de,pe,fe,ge,me,ye,_e,we,ve,be,Ae,xe,Ee,ke,Ne,Se,Ce,Pe,Te,Me,Re,Be,Ie,Ge,Oe,Le,Fe,Ue,De,je,He,We,ze,Qe,Ve,Ke,Je,qe,Ze,Ye,Xe,$e,et,tt,nt,rt,it,st,ot,at,lt,ct,ut,ht,dt,pt,ft,gt,mt,yt,_t,wt,vt,bt,At,xt,Et,kt,Nt,St,Ct,Pt,Tt,Mt,Rt,Bt,It,Gt,Ot,Lt,Ft,Ut,Dt,jt,Ht,Wt,zt,Qt,Vt,Kt,Jt,qt,Zt,Yt,Xt,$t,en,tn,nn,rn,sn,on,an,ln,cn,un,hn,dn,pn,fn,gn,mn,yn,_n,wn,vn,bn,An,xn,En,kn,Nn,Sn,Cn;function Pn(e,t,n){const r=t.split("|").map((e=>e.trim()));for(let s=0;s<r.length;s++)switch(t){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof e===t)return}const i=new Error(`invalid value for type ${t}`);throw i.code="INVALID_ARGUMENT",i.argument=`value.${n}`,i.value=e,i}function Tn(e){return __async(this,null,(function*(){const t=Object.keys(e);return(yield Promise.all(t.map((t=>Promise.resolve(e[t]))))).reduce(((e,n,r)=>(e[t[r]]=n,e)),{})}))}function Mn(e,t,n){for(let r in t){let i=t[r];const s=n?n[r]:null;s&&Pn(i,s,r),Object.defineProperty(e,r,{enumerable:!0,value:i,writable:!1})}}function Rn(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=>Rn(e,t))).join(", ")+" ]";if(e instanceof Uint8Array){const t="0123456789abcdef";let n="0x";for(let r=0;r<e.length;r++)n+=t[e[r]>>4],n+=t[15&e[r]];return n}if("object"==typeof e&&"function"==typeof e.toJSON)return Rn(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 n=Object.keys(e);return n.sort(),"{ "+n.map((n=>`${Rn(n,t)}: ${Rn(e[n],t)}`)).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function Bn(e,t){return e&&e.code===t}function In(e){return Bn(e,"CALL_EXCEPTION")}function Gn(e,t,n){let r,i=e;{const r=[];if(n){if("message"in n||"code"in n||"name"in n)throw new Error(`value will overwrite populated values: ${Rn(n)}`);for(const e in n){if("shortMessage"===e)continue;const t=n[e];r.push(e+"="+Rn(t))}}r.push(`code=${t}`),r.push("version=6.14.3"),r.length&&(e+=" ("+r.join(", ")+")")}switch(t){case"INVALID_ARGUMENT":r=new TypeError(e);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":r=new RangeError(e);break;default:r=new Error(e)}return Mn(r,{code:t}),n&&Object.assign(r,n),null==r.shortMessage&&Mn(r,{shortMessage:i}),r}function On(e,t,n,r){if(!e)throw Gn(t,n,r)}function Ln(e,t,n,r){On(e,t,"INVALID_ARGUMENT",{argument:n,value:r})}function Fn(e,t,n){null==n&&(n=""),n&&(n=": "+n),On(e>=t,"missing argument"+n,"MISSING_ARGUMENT",{count:e,expectedCount:t}),On(e<=t,"too many arguments"+n,"UNEXPECTED_ARGUMENT",{count:e,expectedCount:t})}const Un=["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(n){}return e}),[]);function Dn(e,t,n){if(null==n&&(n=""),e!==t){let e=n,t="new";n&&(e+=".",t+=" "+n),On(!1,`private constructor; use ${e}from* methods`,"UNSUPPORTED_OPERATION",{operation:t})}}function jn(e,t,n){if(e instanceof Uint8Array)return n?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 n=2;for(let r=0;r<t.length;r++)t[r]=parseInt(e.substring(n,n+2),16),n+=2;return t}Ln(!1,"invalid BytesLike value",t||"value",e)}function Hn(e,t){return jn(e,t,!1)}function Wn(e,t){return jn(e,t,!0)}function zn(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))}function Qn(e){return zn(e,!0)||e instanceof Uint8Array}const Vn="0123456789abcdef";function Kn(e){const t=Hn(e);let n="0x";for(let r=0;r<t.length;r++){const e=t[r];n+=Vn[(240&e)>>4]+Vn[15&e]}return n}function Jn(e){return"0x"+e.map((e=>Kn(e).substring(2))).join("")}function qn(e){return zn(e,!0)?(e.length-2)/2:Hn(e).length}function Zn(e,t,n){const r=Hn(e);return null!=n&&n>r.length&&On(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:n}),Kn(r.slice(null==t?0:t,null==n?r.length:n))}function Yn(e,t,n){const r=Hn(e);On(t>=r.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(r),length:t,offset:t+1});const i=new Uint8Array(t);return i.fill(0),n?i.set(r,t-r.length):i.set(r,0),Kn(i)}function Xn(e,t){return Yn(e,t,!0)}const $n=BigInt(0),er=BigInt(1),tr=9007199254740991;function nr(e,t){const n=or(e,"value"),r=BigInt(cr(t,"width"));if(On(n>>r===$n,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:e}),n>>r-er){return-((~n&(er<<r)-er)+er)}return n}function rr(e,t){let n=sr(e,"value");const r=BigInt(cr(t,"width")),i=er<<r-er;if(n<$n){n=-n,On(n<=i,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:e});return(~n&(er<<r)-er)+er}return On(n<i,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:e}),n}function ir(e,t){const n=or(e,"value"),r=BigInt(cr(t,"bits"));return n&(er<<r)-er}function sr(e,t){switch(typeof e){case"bigint":return e;case"number":return Ln(Number.isInteger(e),"underflow",t||"value",e),Ln(e>=-tr&&e<=tr,"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(n){Ln(!1,`invalid BigNumberish string: ${n.message}`,t||"value",e)}}Ln(!1,"invalid BigNumberish value",t||"value",e)}function or(e,t){const n=sr(e,t);return On(n>=$n,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:e}),n}const ar="0123456789abcdef";function lr(e){if(e instanceof Uint8Array){let t="0x0";for(const n of e)t+=ar[n>>4],t+=ar[15&n];return BigInt(t)}return sr(e)}function cr(e,t){switch(typeof e){case"bigint":return Ln(e>=-tr&&e<=tr,"overflow",t||"value",e),Number(e);case"number":return Ln(Number.isInteger(e),"underflow",t||"value",e),Ln(e>=-tr&&e<=tr,"overflow",t||"value",e),e;case"string":try{if(""===e)throw new Error("empty string");return cr(BigInt(e),t)}catch(n){Ln(!1,`invalid numeric string: ${n.message}`,t||"value",e)}}Ln(!1,"invalid numeric value",t||"value",e)}function ur(e,t){let n=or(e,"value").toString(16);if(null==t)n.length%2&&(n="0"+n);else{const r=cr(t,"width");for(On(2*r>=n.length,`value exceeds width (${r} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:e});n.length<2*r;)n="0"+n}return"0x"+n}function hr(e){const t=or(e,"value");if(t===$n)return new Uint8Array([]);let n=t.toString(16);n.length%2&&(n="0"+n);const r=new Uint8Array(n.length/2);for(let i=0;i<r.length;i++){const e=2*i;r[i]=parseInt(n.substring(e,e+2),16)}return r}function dr(e){let t=Kn(Qn(e)?e:hr(e)).substring(2);for(;t.startsWith("0");)t=t.substring(1);return""===t&&(t="0"),"0x"+t}const pr="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const fr=BigInt(58);class gr{constructor(e,t,r){__publicField(this,"filter"),__publicField(this,"emitter"),__privateAdd(this,n,void 0),__privateSet(this,n,t),Mn(this,{emitter:e,filter:r})}removeListener(){return __async(this,null,(function*(){null!=__privateGet(this,n)&&(yield this.emitter.off(this.filter,__privateGet(this,n)))}))}}function mr(e,t,n,r,i){if("BAD_PREFIX"===e||"UNEXPECTED_CONTINUE"===e){let e=0;for(let r=t+1;r<n.length&&n[r]>>6==2;r++)e++;return e}return"OVERRUN"===e?n.length-t-1:0}n=new WeakMap;const yr=Object.freeze({error:function(e,t,n,r,i){Ln(!1,`invalid codepoint at offset ${t}; ${e}`,"bytes",n)},ignore:mr,replace:function(e,t,n,r,i){return"OVERLONG"===e?(Ln("number"==typeof i,"invalid bad code point for replacement","badCodepoint",i),r.push(i),0):(r.push(65533),mr(e,t,n))}});function _r(e,t){Ln("string"==typeof e,"invalid string value","str",e),null!=t&&(!function(e){On(Un.indexOf(e)>=0,"platform missing String.prototype.normalize","UNSUPPORTED_OPERATION",{operation:"String.prototype.normalize",info:{form:e}})}(t),e=e.normalize(t));let n=[];for(let r=0;r<e.length;r++){const t=e.charCodeAt(r);if(t<128)n.push(t);else if(t<2048)n.push(t>>6|192),n.push(63&t|128);else if(55296==(64512&t)){r++;const i=e.charCodeAt(r);Ln(r<e.length&&56320==(64512&i),"invalid surrogate pair","str",e);const s=65536+((1023&t)<<10)+(1023&i);n.push(s>>18|240),n.push(s>>12&63|128),n.push(s>>6&63|128),n.push(63&s|128)}else n.push(t>>12|224),n.push(t>>6&63|128),n.push(63&t|128)}return new Uint8Array(n)}function wr(e,t){return n=function(e,t){null==t&&(t=yr.error);const n=Hn(e,"bytes"),r=[];let i=0;for(;i<n.length;){const e=n[i++];if(!(e>>7)){r.push(e);continue}let s=null,o=null;if(192==(224&e))s=1,o=127;else if(224==(240&e))s=2,o=2047;else{if(240!=(248&e)){i+=t(128==(192&e)?"UNEXPECTED_CONTINUE":"BAD_PREFIX",i-1,n,r);continue}s=3,o=65535}if(i-1+s>=n.length){i+=t("OVERRUN",i-1,n,r);continue}let a=e&(1<<8-s-1)-1;for(let l=0;l<s;l++){let e=n[i];if(128!=(192&e)){i+=t("MISSING_CONTINUE",i,n,r),a=null;break}a=a<<6|63&e,i++}null!==a&&(a>1114111?i+=t("OUT_OF_RANGE",i-1-s,n,r,a):a>=55296&&a<=57343?i+=t("UTF16_SURROGATE",i-1-s,n,r,a):a<=o?i+=t("OVERLONG",i-1-s,n,r,a):r.push(a))}return r}(e,t),n.map((e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10&1023),56320+(1023&e))))).join("");var n}function vr(e){return function(t,n){return __async(this,null,(function*(){On(null==n||!n.cancelled,"request cancelled before sending","CANCELLED");const r=t.url.split(":")[0].toLowerCase();On("http"===r||"https"===r,`unsupported protocol ${r}`,"UNSUPPORTED_OPERATION",{info:{protocol:r},operation:"request"}),On("https"===r||!t.credentials||t.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"});let i=null;const s=new AbortController,o=setTimeout((()=>{i=Gn("request timeout","TIMEOUT"),s.abort()}),t.timeout);n&&n.addListener((()=>{i=Gn("request cancelled","CANCELLED"),s.abort()}));const a=Object.assign({},e,{method:t.method,headers:new Headers(Array.from(t)),body:t.body||void 0,signal:s.signal});let l;try{l=yield fetch(t.url,a)}catch(d){if(clearTimeout(o),i)throw i;throw d}clearTimeout(o);const c={};l.headers.forEach(((e,t)=>{c[t.toLowerCase()]=e}));const u=yield l.arrayBuffer(),h=null==u?null:new Uint8Array(u);return{statusCode:l.status,statusMessage:l.statusText,headers:c,body:h}}))}}let br=vr();const Ar=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),xr=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let Er=!1;function kr(e,t){return __async(this,null,(function*(){try{const t=e.match(Ar);if(!t)throw new Error("invalid data");return new Ir(200,"OK",{"content-type":t[1]||"text/plain"},t[2]?function(e){e=atob(e);const t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return Hn(t)}(t[3]):_r(t[3].replace(/%([0-9a-f][0-9a-f])/gi,((e,t)=>String.fromCharCode(parseInt(t,16))))))}catch(t){return new Ir(599,"BAD REQUEST (invalid data: URI)",{},null,new Rr(e))}}))}function Nr(e){return function(t,n){return __async(this,null,(function*(){try{const n=t.match(xr);if(!n)throw new Error("invalid link");return new Rr(`${e}${n[2]}`)}catch(n){return new Ir(599,"BAD REQUEST (invalid IPFS URI)",{},null,new Rr(t))}}))}}const Sr={data:kr,ipfs:Nr("https://gateway.ipfs.io/ipfs/")},Cr=new WeakMap;class Pr{constructor(e){__privateAdd(this,r,void 0),__privateAdd(this,i,void 0),__privateSet(this,r,[]),__privateSet(this,i,!1),Cr.set(e,(()=>{if(!__privateGet(this,i)){__privateSet(this,i,!0);for(const e of __privateGet(this,r))setTimeout((()=>{e()}),0);__privateSet(this,r,[])}}))}addListener(e){On(!__privateGet(this,i),"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),__privateGet(this,r).push(e)}get cancelled(){return __privateGet(this,i)}checkSignal(){On(!this.cancelled,"cancelled","CANCELLED",{})}}function Tr(e){if(null==e)throw new Error("missing signal; should not happen");return e.checkSignal(),e}r=new WeakMap,i=new WeakMap;const Mr=class e{constructor(e){__privateAdd(this,v),__privateAdd(this,s,void 0),__privateAdd(this,o,void 0),__privateAdd(this,a,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,y,void 0),__privateAdd(this,_,void 0),__privateAdd(this,w,void 0),__privateSet(this,u,String(e)),__privateSet(this,s,!1),__privateSet(this,o,!0),__privateSet(this,a,{}),__privateSet(this,l,""),__privateSet(this,c,3e5),__privateSet(this,_,{slotInterval:250,maxAttempts:12}),__privateSet(this,w,null)}get url(){return __privateGet(this,u)}set url(e){__privateSet(this,u,String(e))}get body(){return null==__privateGet(this,h)?null:new Uint8Array(__privateGet(this,h))}set body(e){if(null==e)__privateSet(this,h,void 0),__privateSet(this,d,void 0);else if("string"==typeof e)__privateSet(this,h,_r(e)),__privateSet(this,d,"text/plain");else if(e instanceof Uint8Array)__privateSet(this,h,e),__privateSet(this,d,"application/octet-stream");else{if("object"!=typeof e)throw new Error("invalid body");__privateSet(this,h,_r(JSON.stringify(e))),__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(e){null==e&&(e=""),__privateSet(this,l,String(e).toUpperCase())}get headers(){const e=Object.assign({},__privateGet(this,a));return __privateGet(this,p)&&(e.authorization=`Basic ${function(e){const t=Hn(e);let n="";for(let r=0;r<t.length;r++)n+=String.fromCharCode(t[r]);return btoa(n)}(_r(__privateGet(this,p)))}`),this.allowGzip&&(e["accept-encoding"]="gzip"),null==e["content-type"]&&__privateGet(this,d)&&(e["content-type"]=__privateGet(this,d)),this.body&&(e["content-length"]=String(this.body.length)),e}getHeader(e){return this.headers[e.toLowerCase()]}setHeader(e,t){__privateGet(this,a)[String(e).toLowerCase()]=String(t)}clearHeaders(){__privateSet(this,a,{})}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let n=0;return{next:()=>{if(n<t.length){const r=t[n++];return{value:[r,e[r]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return __privateGet(this,p)||null}setCredentials(e,t){Ln(!e.match(/:/),"invalid basic authentication username","username","[REDACTED]"),__privateSet(this,p,`${e}:${t}`)}get allowGzip(){return __privateGet(this,o)}set allowGzip(e){__privateSet(this,o,!!e)}get allowInsecureAuthentication(){return!!__privateGet(this,s)}set allowInsecureAuthentication(e){__privateSet(this,s,!!e)}get timeout(){return __privateGet(this,c)}set timeout(e){Ln(e>=0,"timeout must be non-zero","timeout",e),__privateSet(this,c,e)}get preflightFunc(){return __privateGet(this,f)||null}set preflightFunc(e){__privateSet(this,f,e)}get processFunc(){return __privateGet(this,g)||null}set processFunc(e){__privateSet(this,g,e)}get retryFunc(){return __privateGet(this,m)||null}set retryFunc(e){__privateSet(this,m,e)}get getUrlFunc(){return __privateGet(this,w)||br}set getUrlFunc(e){__privateSet(this,w,e)}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${__privateGet(this,h)?Kn(__privateGet(this,h)):"null"}>`}setThrottleParams(e){null!=e.slotInterval&&(__privateGet(this,_).slotInterval=e.slotInterval),null!=e.maxAttempts&&(__privateGet(this,_).maxAttempts=e.maxAttempts)}send(){return On(null==__privateGet(this,y),"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),__privateSet(this,y,new Pr(this)),__privateMethod(this,v,b).call(this,0,Gr()+this.timeout,0,this,new Ir(0,"",{},null,this))}cancel(){On(null!=__privateGet(this,y),"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const e=Cr.get(this);if(!e)throw new Error("missing signal; should not happen");e()}redirect(t){const n=this.url.split(":")[0].toLowerCase(),r=t.split(":")[0].toLowerCase();On("GET"===this.method&&("https"!==n||"http"!==r)&&t.match(/^https?:/),"unsupported redirect","UNSUPPORTED_OPERATION",{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(t)})`});const i=new e(t);return i.method="GET",i.allowGzip=this.allowGzip,i.timeout=this.timeout,__privateSet(i,a,Object.assign({},__privateGet(this,a))),__privateGet(this,h)&&__privateSet(i,h,new Uint8Array(__privateGet(this,h))),__privateSet(i,d,__privateGet(this,d)),i}clone(){const t=new e(this.url);return __privateSet(t,l,__privateGet(this,l)),__privateGet(this,h)&&__privateSet(t,h,__privateGet(this,h)),__privateSet(t,d,__privateGet(this,d)),__privateSet(t,a,Object.assign({},__privateGet(this,a))),__privateSet(t,p,__privateGet(this,p)),this.allowGzip&&(t.allowGzip=!0),t.timeout=this.timeout,this.allowInsecureAuthentication&&(t.allowInsecureAuthentication=!0),__privateSet(t,f,__privateGet(this,f)),__privateSet(t,g,__privateGet(this,g)),__privateSet(t,m,__privateGet(this,m)),__privateSet(t,_,Object.assign({},__privateGet(this,_))),__privateSet(t,w,__privateGet(this,w)),t}static lockConfig(){Er=!0}static getGateway(e){return Sr[e.toLowerCase()]||null}static registerGateway(e,t){if("http"===(e=e.toLowerCase())||"https"===e)throw new Error(`cannot intercept ${e}; use registerGetUrl`);if(Er)throw new Error("gateways locked");Sr[e]=t}static registerGetUrl(e){if(Er)throw new Error("gateways locked");br=e}static createGetUrlFunc(e){return vr(e)}static createDataGateway(){return kr}static createIpfsGatewayFunc(e){return Nr(e)}};s=new WeakMap,o=new WeakMap,a=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,y=new WeakMap,_=new WeakMap,w=new WeakMap,v=new WeakSet,b=function(e,t,n,r,i){return __async(this,null,(function*(){var s,o,a;if(e>=__privateGet(this,_).maxAttempts)return i.makeServerError("exceeded maximum retry limit");On(Gr()<=t,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:r}),n>0&&(yield function(e){return new Promise((t=>setTimeout(t,e)))}(n));let l=this.clone();const c=(l.url.split(":")[0]||"").toLowerCase();if(c in Sr){const e=yield Sr[c](l.url,Tr(__privateGet(r,y)));if(e instanceof Ir){let t=e;if(this.processFunc){Tr(__privateGet(r,y));try{t=yield this.processFunc(l,t)}catch(d){null!=d.throttle&&"number"==typeof d.stall||t.makeServerError("error in post-processing function",d).assertOk()}}return t}l=e}this.preflightFunc&&(l=yield this.preflightFunc(l));const u=yield this.getUrlFunc(l,Tr(__privateGet(r,y)));let h=new Ir(u.statusCode,u.statusMessage,u.headers,u.body,r);if(301===h.statusCode||302===h.statusCode){try{const n=h.headers.location||"";return __privateMethod(s=l.redirect(n),v,b).call(s,e+1,t,0,r,h)}catch(d){}return h}if(429===h.statusCode&&(null==this.retryFunc||(yield this.retryFunc(l,h,e)))){const n=h.headers["retry-after"];let i=__privateGet(this,_).slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return"string"==typeof n&&n.match(/^[1-9][0-9]*$/)&&(i=parseInt(n)),__privateMethod(o=l.clone(),v,b).call(o,e+1,t,i,r,h)}if(this.processFunc){Tr(__privateGet(r,y));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 n=__privateGet(this,_).slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return d.stall>=0&&(n=d.stall),__privateMethod(a=l.clone(),v,b).call(a,e+1,t,n,r,h)}}return h}))};let Rr=Mr;const Br=class e{constructor(e,t,n,r,i){__privateAdd(this,A,void 0),__privateAdd(this,x,void 0),__privateAdd(this,E,void 0),__privateAdd(this,k,void 0),__privateAdd(this,N,void 0),__privateAdd(this,S,void 0),__privateSet(this,A,e),__privateSet(this,x,t),__privateSet(this,E,Object.keys(n).reduce(((e,t)=>(e[t.toLowerCase()]=String(n[t]),e)),{})),__privateSet(this,k,null==r?null:new Uint8Array(r)),__privateSet(this,N,i||null),__privateSet(this,S,{message:""})}toString(){return`<FetchResponse status=${this.statusCode} body=${__privateGet(this,k)?Kn(__privateGet(this,k)):"null"}>`}get statusCode(){return __privateGet(this,A)}get statusMessage(){return __privateGet(this,x)}get headers(){return Object.assign({},__privateGet(this,E))}get body(){return null==__privateGet(this,k)?null:new Uint8Array(__privateGet(this,k))}get bodyText(){try{return null==__privateGet(this,k)?"":wr(__privateGet(this,k))}catch(e){On(!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(e){On(!1,"response body is not valid JSON","UNSUPPORTED_OPERATION",{operation:"bodyJson",info:{response:this}})}}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let n=0;return{next:()=>{if(n<t.length){const r=t[n++];return{value:[r,e[r]],done:!1}}return{value:void 0,done:!0}}}}makeServerError(t,n){let r;r=t?`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${t})`:`CLIENT ESCALATED SERVER ERROR (${t=`${this.statusCode} ${this.statusMessage}`})`;const i=new e(599,r,this.headers,this.body,__privateGet(this,N)||void 0);return __privateSet(i,S,{message:t,error:n}),i}throwThrottleError(e,t){null==t?t=-1:Ln(Number.isInteger(t)&&t>=0,"invalid stall timeout","stall",t);const n=new Error(e||"throttling requests");throw Mn(n,{stall:t,throttle:!0}),n}getHeader(e){return this.headers[e.toLowerCase()]}hasBody(){return null!=__privateGet(this,k)}get request(){return __privateGet(this,N)}ok(){return""===__privateGet(this,S).message&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:e,error:t}=__privateGet(this,S);""===e&&(e=`server response ${this.statusCode} ${this.statusMessage}`);let n=null;this.request&&(n=this.request.url);let r=null;try{__privateGet(this,k)&&(r=wr(__privateGet(this,k)))}catch(i){}On(!1,e,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:t,info:{requestUrl:n,responseBody:r,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}};A=new WeakMap,x=new WeakMap,E=new WeakMap,k=new WeakMap,N=new WeakMap,S=new WeakMap;let Ir=Br;function Gr(){return(new Date).getTime()}const Or=BigInt(-1),Lr=BigInt(0),Fr=BigInt(1),Ur=BigInt(5),Dr={};let jr="0000";for(;jr.length<80;)jr+=jr;function Hr(e){let t=jr;for(;t.length<e;)t+=t;return BigInt("1"+t.substring(0,e))}function Wr(e,t,n){const r=BigInt(t.width);if(t.signed){const t=Fr<<r-Fr;On(null==n||e>=-t&&e<t,"overflow","NUMERIC_FAULT",{operation:n,fault:"overflow",value:e}),e=e>Lr?nr(ir(e,r),r):-nr(ir(-e,r),r)}else{const t=Fr<<r;On(null==n||e>=0&&e<t,"overflow","NUMERIC_FAULT",{operation:n,fault:"overflow",value:e}),e=(e%t+t)%t&t-Fr}return e}function zr(e){"number"==typeof e&&(e=`fixed128x${e}`);let t=!0,n=128,r=18;if("string"==typeof e)if("fixed"===e);else if("ufixed"===e)t=!1;else{const i=e.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);Ln(i,"invalid fixed format","format",e),t="u"!==i[1],n=parseInt(i[2]),r=parseInt(i[3])}else if(e){const i=e,s=(e,t,n)=>null==i[e]?n:(Ln(typeof i[e]===t,"invalid fixed format ("+e+" not "+t+")","format."+e,i[e]),i[e]);t=s("signed","boolean",t),n=s("width","number",n),r=s("decimals","number",r)}Ln(n%8==0,"invalid FixedNumber width (not byte aligned)","format.width",n),Ln(r<=80,"invalid FixedNumber decimals (too large)","format.decimals",r);return{signed:t,width:n,decimals:r,name:(t?"":"u")+"fixed"+String(n)+"x"+String(r)}}const Qr=class e{constructor(e,t,n){__privateAdd(this,M),__privateAdd(this,B),__privateAdd(this,G),__privateAdd(this,L),__privateAdd(this,U),__privateAdd(this,j),__publicField(this,"format"),__privateAdd(this,C,void 0),__privateAdd(this,P,void 0),__privateAdd(this,T,void 0),__publicField(this,"_value"),Dn(e,Dr,"FixedNumber"),__privateSet(this,P,t),__privateSet(this,C,n);const r=function(e,t){let n="";e<Lr&&(n="-",e*=Or);let r=e.toString();if(0===t)return n+r;for(;r.length<=t;)r=jr+r;const i=r.length-t;for(r=r.substring(0,i)+"."+r.substring(i);"0"===r[0]&&"."!==r[1];)r=r.substring(1);for(;"0"===r[r.length-1]&&"."!==r[r.length-2];)r=r.substring(0,r.length-1);return n+r}(t,n.decimals);Mn(this,{format:n.name,_value:r}),__privateSet(this,T,Hr(n.decimals))}get signed(){return __privateGet(this,C).signed}get width(){return __privateGet(this,C).width}get decimals(){return __privateGet(this,C).decimals}get value(){return __privateGet(this,P)}addUnsafe(e){return __privateMethod(this,G,O).call(this,e)}add(e){return __privateMethod(this,G,O).call(this,e,"add")}subUnsafe(e){return __privateMethod(this,L,F).call(this,e)}sub(e){return __privateMethod(this,L,F).call(this,e,"sub")}mulUnsafe(e){return __privateMethod(this,U,D).call(this,e)}mul(e){return __privateMethod(this,U,D).call(this,e,"mul")}mulSignal(e){__privateMethod(this,M,R).call(this,e);const t=__privateGet(this,P)*__privateGet(e,P);return On(t%__privateGet(this,T)===Lr,"precision lost during signalling mul","NUMERIC_FAULT",{operation:"mulSignal",fault:"underflow",value:this}),__privateMethod(this,B,I).call(this,t/__privateGet(this,T),"mulSignal")}divUnsafe(e){return __privateMethod(this,j,H).call(this,e)}div(e){return __privateMethod(this,j,H).call(this,e,"div")}divSignal(e){On(__privateGet(e,P)!==Lr,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),__privateMethod(this,M,R).call(this,e);const t=__privateGet(this,P)*__privateGet(this,T);return On(t%__privateGet(e,P)===Lr,"precision lost during signalling div","NUMERIC_FAULT",{operation:"divSignal",fault:"underflow",value:this}),__privateMethod(this,B,I).call(this,t/__privateGet(e,P),"divSignal")}cmp(e){let t=this.value,n=e.value;const r=this.decimals-e.decimals;return r>0?n*=Hr(r):r<0&&(t*=Hr(-r)),t<n?-1:t>n?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,P);return __privateGet(this,P)<Lr&&(e-=__privateGet(this,T)-Fr),e=__privateGet(this,P)/__privateGet(this,T)*__privateGet(this,T),__privateMethod(this,B,I).call(this,e,"floor")}ceiling(){let e=__privateGet(this,P);return __privateGet(this,P)>Lr&&(e+=__privateGet(this,T)-Fr),e=__privateGet(this,P)/__privateGet(this,T)*__privateGet(this,T),__privateMethod(this,B,I).call(this,e,"ceiling")}round(t){if(null==t&&(t=0),t>=this.decimals)return this;const n=this.decimals-t,r=Ur*Hr(n-1);let i=this.value+r;const s=Hr(n);return i=i/s*s,Wr(i,__privateGet(this,C),"round"),new e(Dr,i,__privateGet(this,C))}isZero(){return __privateGet(this,P)===Lr}isNegative(){return __privateGet(this,P)<Lr}toString(){return this._value}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(t){return e.fromString(this.toString(),t)}static fromValue(t,n,r){const i=null==n?0:cr(n),s=zr(r);let o=sr(t,"value");const a=i-s.decimals;if(a>0){const e=Hr(a);On(o%e===Lr,"value loses precision for format","NUMERIC_FAULT",{operation:"fromValue",fault:"underflow",value:t}),o/=e}else a<0&&(o*=Hr(-a));return Wr(o,s,"fromValue"),new e(Dr,o,s)}static fromString(t,n){const r=t.match(/^(-?)([0-9]*)\.?([0-9]*)$/);Ln(r&&r[2].length+r[3].length>0,"invalid FixedNumber string value","value",t);const i=zr(n);let s=r[2]||"0",o=r[3]||"";for(;o.length<i.decimals;)o+=jr;On(o.substring(i.decimals).match(/^0*$/),"too many decimals for format","NUMERIC_FAULT",{operation:"fromString",fault:"underflow",value:t}),o=o.substring(0,i.decimals);const a=BigInt(r[1]+s+o);return Wr(a,i,"fromString"),new e(Dr,a,i)}static fromBytes(t,n){let r=lr(Hn(t,"value"));const i=zr(n);return i.signed&&(r=nr(r,i.width)),Wr(r,i,"fromBytes"),new e(Dr,r,i)}};C=new WeakMap,P=new WeakMap,T=new WeakMap,M=new WeakSet,R=function(e){Ln(this.format===e.format,"incompatible format; use fixedNumber.toFormat","other",e)},B=new WeakSet,I=function(e,t){return e=Wr(e,__privateGet(this,C),t),new Qr(Dr,e,__privateGet(this,C))},G=new WeakSet,O=function(e,t){return __privateMethod(this,M,R).call(this,e),__privateMethod(this,B,I).call(this,__privateGet(this,P)+__privateGet(e,P),t)},L=new WeakSet,F=function(e,t){return __privateMethod(this,M,R).call(this,e),__privateMethod(this,B,I).call(this,__privateGet(this,P)-__privateGet(e,P),t)},U=new WeakSet,D=function(e,t){return __privateMethod(this,M,R).call(this,e),__privateMethod(this,B,I).call(this,__privateGet(this,P)*__privateGet(e,P)/__privateGet(this,T),t)},j=new WeakSet,H=function(e,t){return On(__privateGet(e,P)!==Lr,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),__privateMethod(this,M,R).call(this,e),__privateMethod(this,B,I).call(this,__privateGet(this,P)*__privateGet(this,T)/__privateGet(e,P),t)};let Vr=Qr;function Kr(e){let t=e.toString(16);for(;t.length<2;)t="0"+t;return"0x"+t}function Jr(e,t,n){let r=0;for(let i=0;i<n;i++)r=256*r+e[t+i];return r}function qr(e,t,n,r){const i=[];for(;n<t+1+r;){const s=Zr(e,n);i.push(s.result),On((n+=s.consumed)<=t+1+r,"child data too short","BUFFER_OVERRUN",{buffer:e,length:r,offset:t})}return{consumed:1+r,result:i}}function Zr(e,t){On(0!==e.length,"data too short","BUFFER_OVERRUN",{buffer:e,length:0,offset:1});const n=t=>{On(t<=e.length,"data short segment too short","BUFFER_OVERRUN",{buffer:e,length:e.length,offset:t})};if(e[t]>=248){const r=e[t]-247;n(t+1+r);const i=Jr(e,t+1,r);return n(t+1+r+i),qr(e,t,t+1+r,r+i)}if(e[t]>=192){const r=e[t]-192;return n(t+1+r),qr(e,t,t+1,r)}if(e[t]>=184){const r=e[t]-183;n(t+1+r);const i=Jr(e,t+1,r);n(t+1+r+i);return{consumed:1+r+i,result:Kn(e.slice(t+1+r,t+1+r+i))}}if(e[t]>=128){const r=e[t]-128;n(t+1+r);return{consumed:1+r,result:Kn(e.slice(t+1,t+1+r))}}return{consumed:1,result:Kr(e[t])}}function Yr(e){const t=Hn(e,"data"),n=Zr(t,0);return Ln(n.consumed===t.length,"unexpected junk after rlp payload","data",e),n.result}function Xr(e){const t=[];for(;e;)t.unshift(255&e),e>>=8;return t}function $r(e){if(Array.isArray(e)){let t=[];if(e.forEach((function(e){t=t.concat($r(e))})),t.length<=55)return t.unshift(192+t.length),t;const n=Xr(t.length);return n.unshift(247+n.length),n.concat(t)}const t=Array.prototype.slice.call(Hn(e,"object"));if(1===t.length&&t[0]<=127)return t;if(t.length<=55)return t.unshift(128+t.length),t;const n=Xr(t.length);return n.unshift(183+n.length),n.concat(t)}const ei="0123456789abcdef";function ti(e){let t="0x";for(const n of $r(e))t+=ei[n>>4],t+=ei[15&n];return t}const ni=["wei","kwei","mwei","gwei","szabo","finney","ether"];function ri(e,t){let n=18;if("string"==typeof t){const e=ni.indexOf(t);Ln(e>=0,"invalid unit","unit",t),n=3*e}else null!=t&&(n=cr(t,"unit"));return Vr.fromValue(e,n,{decimals:n,width:512}).toString()}function ii(e,t){Ln("string"==typeof e,"value must be a string","value",e);let n=18;if("string"==typeof t){const e=ni.indexOf(t);Ln(e>=0,"invalid unit","unit",t),n=3*e}else null!=t&&(n=cr(t,"unit"));return Vr.fromString(e,{decimals:n,width:512}).value}const si=32,oi=new Uint8Array(si),ai=["then"],li={},ci=new WeakMap;function ui(e){return ci.get(e)}function hi(e,t){ci.set(e,t)}function di(e,t){const n=new Error(`deferred error during ABI decoding triggered accessing ${e}`);throw n.error=t,n}function pi(e,t,n){return e.indexOf(null)>=0?t.map(((e,t)=>e instanceof fi?pi(ui(e),e,n):e)):e.reduce(((e,r,i)=>{let s=t.getValue(r);return r in e||(n&&s instanceof fi&&(s=pi(ui(s),s,n)),e[r]=s),e}),{})}W=new WeakMap;let fi=class e extends Array{constructor(...e){const t=e[0];let n=e[1],r=(e[2]||[]).slice(),i=!0;t!==li&&(n=e,r=[],i=!1),super(n.length),__privateAdd(this,W,void 0),n.forEach(((e,t)=>{this[t]=e}));const s=r.reduce(((e,t)=>("string"==typeof t&&e.set(t,(e.get(t)||0)+1),e)),new Map);if(hi(this,Object.freeze(n.map(((e,t)=>{const n=r[t];return null!=n&&1===s.get(n)?n:null})))),__privateSet(this,W,[]),null==__privateGet(this,W)&&__privateGet(this,W),!i)return;Object.freeze(this);const o=new Proxy(this,{get:(e,t,n)=>{if("string"==typeof t){if(t.match(/^[0-9]+$/)){const n=cr(t,"%index");if(n<0||n>=this.length)throw new RangeError("out of result range");const r=e[n];return r instanceof Error&&di(`index ${n}`,r),r}if(ai.indexOf(t)>=0)return Reflect.get(e,t,n);const r=e[t];if(r instanceof Function)return function(...t){return r.apply(this===n?e:this,t)};if(!(t in e))return e.getValue.apply(this===n?e:this,[t])}return Reflect.get(e,t,n)}});return hi(o,ui(this)),o}toArray(t){const n=[];return this.forEach(((r,i)=>{r instanceof Error&&di(`index ${i}`,r),t&&r instanceof e&&(r=r.toArray(t)),n.push(r)})),n}toObject(e){const t=ui(this);return t.reduce(((n,r,i)=>(On(null!=r,`value at index ${i} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),pi(t,this,e))),{})}slice(t,n){null==t&&(t=0),t<0&&(t+=this.length)<0&&(t=0),null==n&&(n=this.length),n<0&&(n+=this.length)<0&&(n=0),n>this.length&&(n=this.length);const r=ui(this),i=[],s=[];for(let e=t;e<n;e++)i.push(this[e]),s.push(r[e]);return new e(li,i,s)}filter(t,n){const r=ui(this),i=[],s=[];for(let e=0;e<this.length;e++){const o=this[e];o instanceof Error&&di(`index ${e}`,o),t.call(n,o,e,this)&&(i.push(o),s.push(r[e]))}return new e(li,i,s)}map(e,t){const n=[];for(let r=0;r<this.length;r++){const i=this[r];i instanceof Error&&di(`index ${r}`,i),n.push(e.call(t,i,r,this))}return n}getValue(e){const t=ui(this).indexOf(e);if(-1===t)return;const n=this[t];return n instanceof Error&&di(`property ${JSON.stringify(e)}`,n.error),n}static fromItems(t,n){return new e(li,t,n)}};function gi(e){let t=hr(e);return On(t.length<=si,"value out-of-bounds","BUFFER_OVERRUN",{buffer:t,length:si,offset:t.length}),t.length!==si&&(t=Wn(Jn([oi.slice(t.length%si),t]))),t}class mi{constructor(e,t,n,r){__publicField(this,"name"),__publicField(this,"type"),__publicField(this,"localName"),__publicField(this,"dynamic"),Mn(this,{name:e,type:t,localName:n,dynamic:r},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(e,t){Ln(!1,e,this.localName,t)}}class yi{constructor(){__privateAdd(this,V),__privateAdd(this,z,void 0),__privateAdd(this,Q,void 0),__privateSet(this,z,[]),__privateSet(this,Q,0)}get data(){return Jn(__privateGet(this,z))}get length(){return __privateGet(this,Q)}appendWriter(e){return __privateMethod(this,V,K).call(this,Wn(e.data))}writeBytes(e){let t=Wn(e);const n=t.length%si;return n&&(t=Wn(Jn([t,oi.slice(n)]))),__privateMethod(this,V,K).call(this,t)}writeValue(e){return __privateMethod(this,V,K).call(this,gi(e))}writeUpdatableValue(){const e=__privateGet(this,z).length;return __privateGet(this,z).push(oi),__privateSet(this,Q,__privateGet(this,Q)+si),t=>{__privateGet(this,z)[e]=gi(t)}}}z=new WeakMap,Q=new WeakMap,V=new WeakSet,K=function(e){return __privateGet(this,z).push(e),__privateSet(this,Q,__privateGet(this,Q)+e.length),e.length};J=new WeakMap,q=new WeakMap,Z=new WeakMap,Y=new WeakMap,X=new WeakMap,$=new WeakSet,ee=function(e){var t;if(__privateGet(this,Y))return __privateMethod(t=__privateGet(this,Y),$,ee).call(t,e);__privateSet(this,Z,__privateGet(this,Z)+e),On(__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:Wn(__privateGet(this,J)),offset:__privateGet(this,q),length:e,info:{bytesRead:__privateGet(this,Z),dataLength:this.dataLength}})},te=new WeakSet,ne=function(e,t,n){let r=Math.ceil(t/si)*si;return __privateGet(this,q)+r>__privateGet(this,J).length&&(this.allowLoose&&n&&__privateGet(this,q)+t<=__privateGet(this,J).length?r=t:On(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:Wn(__privateGet(this,J)),length:__privateGet(this,J).length,offset:__privateGet(this,q)+r})),__privateGet(this,J).slice(__privateGet(this,q),__privateGet(this,q)+r)};let _i=class e{constructor(e,t,n){__privateAdd(this,$),__privateAdd(this,te),__publicField(this,"allowLoose"),__privateAdd(this,J,void 0),__privateAdd(this,q,void 0),__privateAdd(this,Z,void 0),__privateAdd(this,Y,void 0),__privateAdd(this,X,void 0),Mn(this,{allowLoose:!!t}),__privateSet(this,J,Wn(e)),__privateSet(this,Z,0),__privateSet(this,Y,null),__privateSet(this,X,null!=n?n:1024),__privateSet(this,q,0)}get data(){return Kn(__privateGet(this,J))}get dataLength(){return __privateGet(this,J).length}get consumed(){return __privateGet(this,q)}get bytes(){return new Uint8Array(__privateGet(this,J))}subReader(t){const n=new e(__privateGet(this,J).slice(__privateGet(this,q)+t),this.allowLoose,__privateGet(this,X));return __privateSet(n,Y,this),n}readBytes(e,t){let n=__privateMethod(this,te,ne).call(this,0,e,!!t);return __privateMethod(this,$,ee).call(this,e),__privateSet(this,q,__privateGet(this,q)+n.length),n.slice(0,e)}readValue(){return lr(this.readBytes(si))}readIndex(){return cr(lr(this.readBytes(si)))}};function wi(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function vi(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 bi(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Ai(e,t){vi(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const xi="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,Ei=e=>e instanceof Uint8Array,ki=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Ni=(e,t)=>e<<32-t|e>>>t; /*! 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(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)),!Ei(e))throw new Error("expected Uint8Array, got "+typeof e);return e}class Ci{clone(){return this._cloneInto()}}function Pi(e){const t=t=>e().update(Si(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Ti(e=32){if(xi&&"function"==typeof xi.getRandomValues)return xi.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}class Mi extends Ci{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");wi(e.outputLen),wi(e.blockLen)}(e);const n=Si(t);if(this.iHash=e.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 r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=e.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(e){return bi(this),this.iHash.update(e),this}digestInto(e){bi(this),vi(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:s,outputLen:o}=this;return e.finished=r,e.destroyed=i,e.blockLen=s,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Ri=(e,t,n)=>new Mi(e,t).update(n).digest();Ri.create=(e,t)=>new Mi(e,t);class Bi extends Ci{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=ki(this.buffer)}update(e){bi(this);const{view:t,buffer:n,blockLen:r}=this,i=(e=Si(e)).length;for(let s=0;s<i;){const o=Math.min(r-this.pos,i-s);if(o!==r)n.set(e.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===r&&(this.process(t,0),this.pos=0);else{const t=ki(e);for(;r<=i-s;s+=r)this.process(t,s)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){bi(this),Ai(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:i}=this;let{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>r-s&&(this.process(n,0),s=0);for(let u=s;u<r;u++)t[u]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(n>>i&s),a=Number(n&s),l=r?4:0,c=r?0:4;e.setUint32(t+l,o,r),e.setUint32(t+c,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const o=ki(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,c=this.get();if(l>c.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)o.setUint32(4*u,c[u],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:i,destroyed:s,pos:o}=this;return e.length=r,e.pos=o,e.finished=i,e.destroyed=s,r%t&&e.buffer.set(n),e}}const Ii=(e,t,n)=>e&t^e&n^t&n,Gi=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]),Oi=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Li=new Uint32Array(64);class Fi extends Bi{constructor(){super(64,32,8,!1),this.A=0|Oi[0],this.B=0|Oi[1],this.C=0|Oi[2],this.D=0|Oi[3],this.E=0|Oi[4],this.F=0|Oi[5],this.G=0|Oi[6],this.H=0|Oi[7]}get(){const{A:e,B:t,C:n,D:r,E:i,F:s,G:o,H:a}=this;return[e,t,n,r,i,s,o,a]}set(e,t,n,r,i,s,o,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|s,this.G=0|o,this.H=0|a}process(e,t){for(let h=0;h<16;h++,t+=4)Li[h]=e.getUint32(t,!1);for(let h=16;h<64;h++){const e=Li[h-15],t=Li[h-2],n=Ni(e,7)^Ni(e,18)^e>>>3,r=Ni(t,17)^Ni(t,19)^t>>>10;Li[h]=r+Li[h-7]+n+Li[h-16]|0}let{A:n,B:r,C:i,D:s,E:o,F:a,G:l,H:c}=this;for(let h=0;h<64;h++){const e=c+(Ni(o,6)^Ni(o,11)^Ni(o,25))+((u=o)&a^~u&l)+Gi[h]+Li[h]|0,t=(Ni(n,2)^Ni(n,13)^Ni(n,22))+Ii(n,r,i)|0;c=l,l=a,a=o,o=s+e|0,s=i,i=r,r=n,n=e+t|0}var u;n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,s=s+this.D|0,o=o+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,i,s,o,a,l,c)}roundClean(){Li.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Ui=Pi((()=>new Fi)),Di=BigInt(__pow(2,32)-1),ji=BigInt(32);function Hi(e,t=!1){return t?{h:Number(e&Di),l:Number(e>>ji&Di)}:{h:0|Number(e>>ji&Di),l:0|Number(e&Di)}}function Wi(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:s,l:o}=Hi(e[i],t);[n[i],r[i]]=[s,o]}return[n,r]}const zi=(e,t,n)=>e<<n|t>>>32-n,Qi=(e,t,n)=>t<<n|e>>>32-n,Vi=(e,t,n)=>t<<n-32|e>>>64-n,Ki=(e,t,n)=>e<<n-32|t>>>64-n;const Ji={fromBig:Hi,split:Wi,toBig:(e,t)=>BigInt(e>>>0)<<ji|BigInt(t>>>0),shrSH:(e,t,n)=>e>>>n,shrSL:(e,t,n)=>e<<32-n|t>>>n,rotrSH:(e,t,n)=>e>>>n|t<<32-n,rotrSL:(e,t,n)=>e<<32-n|t>>>n,rotrBH:(e,t,n)=>e<<64-n|t>>>n-32,rotrBL:(e,t,n)=>e>>>n-32|t<<64-n,rotr32H:(e,t)=>t,rotr32L:(e,t)=>e,rotlSH:zi,rotlSL:Qi,rotlBH:Vi,rotlBL:Ki,add:function(e,t,n,r){const i=(t>>>0)+(r>>>0);return{h:e+n+(i/__pow(2,32)|0)|0,l:0|i}},add3L:(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),add3H:(e,t,n,r)=>t+n+r+(e/__pow(2,32)|0)|0,add4L:(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),add4H:(e,t,n,r,i)=>t+n+r+i+(e/__pow(2,32)|0)|0,add5H:(e,t,n,r,i,s)=>t+n+r+i+s+(e/__pow(2,32)|0)|0,add5L:(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0)},[qi,Zi]=(()=>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((e=>BigInt(e)))))(),Yi=new Uint32Array(80),Xi=new Uint32Array(80);class $i extends Bi{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:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:s,Dh:o,Dl:a,Eh:l,El:c,Fh:u,Fl:h,Gh:d,Gl:p,Hh:f,Hl:g}=this;return[e,t,n,r,i,s,o,a,l,c,u,h,d,p,f,g]}set(e,t,n,r,i,s,o,a,l,c,u,h,d,p,f,g){this.Ah=0|e,this.Al=0|t,this.Bh=0|n,this.Bl=0|r,this.Ch=0|i,this.Cl=0|s,this.Dh=0|o,this.Dl=0|a,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(e,t){for(let _=0;_<16;_++,t+=4)Yi[_]=e.getUint32(t),Xi[_]=e.getUint32(t+=4);for(let _=16;_<80;_++){const e=0|Yi[_-15],t=0|Xi[_-15],n=Ji.rotrSH(e,t,1)^Ji.rotrSH(e,t,8)^Ji.shrSH(e,t,7),r=Ji.rotrSL(e,t,1)^Ji.rotrSL(e,t,8)^Ji.shrSL(e,t,7),i=0|Yi[_-2],s=0|Xi[_-2],o=Ji.rotrSH(i,s,19)^Ji.rotrBH(i,s,61)^Ji.shrSH(i,s,6),a=Ji.rotrSL(i,s,19)^Ji.rotrBL(i,s,61)^Ji.shrSL(i,s,6),l=Ji.add4L(r,a,Xi[_-7],Xi[_-16]),c=Ji.add4H(l,n,o,Yi[_-7],Yi[_-16]);Yi[_]=0|c,Xi[_]=0|l}let{Ah:n,Al:r,Bh:i,Bl:s,Ch:o,Cl:a,Dh:l,Dl:c,Eh:u,El:h,Fh:d,Fl:p,Gh:f,Gl:g,Hh:m,Hl:y}=this;for(let _=0;_<80;_++){const e=Ji.rotrSH(u,h,14)^Ji.rotrSH(u,h,18)^Ji.rotrBH(u,h,41),t=Ji.rotrSL(u,h,14)^Ji.rotrSL(u,h,18)^Ji.rotrBL(u,h,41),w=u&d^~u&f,v=h&p^~h&g,b=Ji.add5L(y,t,v,Zi[_],Xi[_]),A=Ji.add5H(b,m,e,w,qi[_],Yi[_]),x=0|b,E=Ji.rotrSH(n,r,28)^Ji.rotrBH(n,r,34)^Ji.rotrBH(n,r,39),k=Ji.rotrSL(n,r,28)^Ji.rotrBL(n,r,34)^Ji.rotrBL(n,r,39),N=n&i^n&o^i&o,S=r&s^r&a^s&a;m=0|f,y=0|g,f=0|d,g=0|p,d=0|u,p=0|h,({h:u,l:h}=Ji.add(0|l,0|c,0|A,0|x)),l=0|o,c=0|a,o=0|i,a=0|s,i=0|n,s=0|r;const C=Ji.add3L(x,k,S);n=Ji.add3H(C,A,E,N),r=0|C}({h:n,l:r}=Ji.add(0|this.Ah,0|this.Al,0|n,0|r)),({h:i,l:s}=Ji.add(0|this.Bh,0|this.Bl,0|i,0|s)),({h:o,l:a}=Ji.add(0|this.Ch,0|this.Cl,0|o