diff --git a/Data/js/jcwallet.js b/Data/js/jcwallet.js index f266c0d..503bfe5 100644 --- a/Data/js/jcwallet.js +++ b/Data/js/jcwallet.js @@ -92,7 +92,7 @@ __p += '`),Lt&&(Pe+=`' + function print() { __p += __j.call(arguments, '') } `:`; `)+Pe+`return __p -}`;var lt=xL(function(){return Vt(D0,ze+"return "+Pe).apply(r,z0)});if(lt.source=Pe,hw(lt))throw lt;return lt}function zP0(M){return Yt(M).toLowerCase()}function qP0(M){return Yt(M).toUpperCase()}function HP0(M,S,K){if(M=Yt(M),M&&(K||S===r))return E$(M);if(!M||!(S=Tn(S)))return M;var a0=Xf(M),s0=Xf(S),D0=A$(a0,s0),z0=S$(a0,s0)+1;return Ko(a0,D0,z0).join("")}function KP0(M,S,K){if(M=Yt(M),M&&(K||S===r))return M.slice(0,T$(M)+1);if(!M||!(S=Tn(S)))return M;var a0=Xf(M),s0=S$(a0,Xf(S))+1;return Ko(a0,0,s0).join("")}function VP0(M,S,K){if(M=Yt(M),M&&(K||S===r))return M.replace(Z,"");if(!M||!(S=Tn(S)))return M;var a0=Xf(M),s0=A$(a0,Xf(S));return Ko(a0,s0).join("")}function WP0(M,S){var K=T,a0=p;if(Br(S)){var s0="separator"in S?S.separator:s0;K="length"in S?ut(S.length):K,a0="omission"in S?Tn(S.omission):a0}M=Yt(M);var D0=M.length;if(l6(M)){var z0=Xf(M);D0=z0.length}if(K>=D0)return M;var H0=K-x6(a0);if(H0<1)return a0;var Y0=z0?Ko(z0,0,H0).join(""):M.slice(0,H0);if(s0===r)return Y0+a0;if(z0&&(H0+=Y0.length-H0),lw(s0)){if(M.slice(H0).search(s0)){var ge,ye=Y0;for(s0.global||(s0=Py(s0.source,Yt(I0.exec(s0))+"g")),s0.lastIndex=0;ge=s0.exec(ye);)var Pe=ge.index;Y0=Y0.slice(0,Pe===r?H0:Pe)}}else if(M.indexOf(Tn(s0),H0)!=H0){var De=Y0.lastIndexOf(s0);De>-1&&(Y0=Y0.slice(0,De))}return Y0+a0}function GP0(M){return M=Yt(M),M&&Ie.test(M)?M.replace(L0,MA0):M}var ZP0=_6(function(M,S,K){return M+(K?" ":"")+S.toUpperCase()}),vw=pU("toUpperCase");function lL(M,S,K){return M=Yt(M),S=K?r:S,S===r?mA0(M)?SA0(M):dA0(M):M.match(S)||[]}var xL=vt(function(M,S){try{return _a(M,r,S)}catch(K){return hw(K)?K:new rt(K)}}),YP0=j1(function(M,S){return lf(S,function(K){K=Xc(K),L1(M,K,uw(M[K],M))}),M});function JP0(M){var S=M==null?0:M.length,K=We();return M=S?Er(M,function(a0){if(typeof a0[1]!="function")throw new xf(l);return[K(a0[0]),a0[1]]}):[],vt(function(a0){for(var s0=-1;++s0x)return[];var K=b,a0=oi(M,b);S=We(S),M-=b;for(var s0=ky(a0,S);++K0||S<0)?new Ct(K):(M<0?K=K.takeRight(-M):M&&(K=K.drop(M)),S!==r&&(S=ut(S),K=S<0?K.dropRight(-S):K.take(S-M)),K)},Ct.prototype.takeRightWhile=function(M){return this.reverse().takeWhile(M).reverse()},Ct.prototype.toArray=function(){return this.take(b)},Yc(Ct.prototype,function(M,S){var K=/^(?:filter|find|map|reject)|While$/.test(S),a0=/^(?:head|last)$/.test(S),s0=w0[a0?"take"+(S=="last"?"Right":""):S],D0=a0||/^find/.test(S);s0&&(w0.prototype[S]=function(){var z0=this.__wrapped__,H0=a0?[1]:arguments,Y0=z0 instanceof Ct,ge=H0[0],ye=Y0||ft(z0),Pe=function(St){var Lt=s0.apply(w0,Lo([St],H0));return a0&&De?Lt[0]:Lt};ye&&K&&typeof ge=="function"&&ge.length!=1&&(Y0=ye=!1);var De=this.__chain__,ze=!!this.__actions__.length,Ye=D0&&!De,lt=Y0&&!ze;if(!D0&&ye){z0=lt?z0:new Ct(this);var Je=M.apply(z0,H0);return Je.__actions__.push({func:_l,args:[Pe],thisArg:r}),new pf(Je,De)}return Ye&<?M.apply(this,H0):(Je=this.thru(Pe),Ye?a0?Je.value()[0]:Je.value():Je)})}),lf(["pop","push","shift","sort","splice","unshift"],function(M){var S=Gh[M],K=/^(?:push|sort|unshift)$/.test(M)?"tap":"thru",a0=/^(?:pop|shift)$/.test(M);w0.prototype[M]=function(){var s0=arguments;if(a0&&!this.__chain__){var D0=this.value();return S.apply(ft(D0)?D0:[],s0)}return this[K](function(z0){return S.apply(ft(z0)?z0:[],s0)})}}),Yc(Ct.prototype,function(M,S){var K=w0[S];if(K){var a0=K.name+"";Qt.call(g6,a0)||(g6[a0]=[]),g6[a0].push({name:S,func:K})}}),g6[xl(r,H).name]=[{name:"wrapper",func:r}],Ct.prototype.clone=GA0,Ct.prototype.reverse=ZA0,Ct.prototype.value=YA0,w0.prototype.at=AT0,w0.prototype.chain=ST0,w0.prototype.commit=kT0,w0.prototype.next=TT0,w0.prototype.plant=PT0,w0.prototype.reverse=CT0,w0.prototype.toJSON=w0.prototype.valueOf=w0.prototype.value=IT0,w0.prototype.first=w0.prototype.head,W8&&(w0.prototype[W8]=BT0),w0},p6=kA0();Yr?((Yr.exports=p6)._=p6,xr._=p6):Ut._=p6}).call(B8)})(zm,zm.exports);var jm0=Object.defineProperty,zm0=Object.defineProperties,qm0=Object.getOwnPropertyDescriptors,eN=Object.getOwnPropertySymbols,Hm0=Object.prototype.hasOwnProperty,Km0=Object.prototype.propertyIsEnumerable,tN=(t,e,r)=>e in t?jm0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,th=(t,e)=>{for(var r in e||(e={}))Hm0.call(e,r)&&tN(t,r,e[r]);if(eN)for(var r of eN(e))Km0.call(e,r)&&tN(t,r,e[r]);return t},Vm0=(t,e)=>zm0(t,qm0(e));function t6(t,e,r){var a;const f=M90(t);return((a=e.rpcMap)==null?void 0:a[f.reference])||`${Fm0}?chainId=${f.namespace}:${f.reference}&projectId=${r}`}function us(t){return t.includes(":")?t.split(":")[1]:t}function rN(t){return t.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function Wm0(t,e){const r=Object.keys(e.namespaces).filter(f=>f.includes(t));if(!r.length)return[];const a=[];return r.forEach(f=>{const n=e.namespaces[f].accounts;a.push(...n)}),a}function Gm0(t={},e={}){const r=aN(t),a=aN(e);return zm.exports.merge(r,a)}function aN(t){var e,r,a,f;const n={};if(!J2(t))return n;for(const[l,m]of Object.entries(t)){const y=mm(l)?[l]:m.chains,_=m.methods||[],E=m.events||[],A=m.rpcMap||{},k=l8(l);n[k]=Vm0(th(th({},n[k]),m),{chains:pm(y,(e=n[k])==null?void 0:e.chains),methods:pm(_,(r=n[k])==null?void 0:r.methods),events:pm(E,(a=n[k])==null?void 0:a.events),rpcMap:th(th({},A),(f=n[k])==null?void 0:f.rpcMap)})}return n}function Zm0(t){return t.includes(":")?t.split(":")[2]:t}function Ym0(t){const e={};for(const[r,a]of Object.entries(t)){const f=a.methods||[],n=a.events||[],l=a.accounts||[],m=mm(r)?[r]:a.chains?a.chains:rN(a.accounts);e[r]={chains:m,methods:f,events:n,accounts:l}}return e}function qm(t){return typeof t=="number"?t:t.includes("0x")?parseInt(t,16):t.includes(":")?Number(t.split(":")[1]):Number(t)}const iN={},Hr=t=>iN[t],Hm=(t,e)=>{iN[t]=e};class Jm0{constructor(e){this.name="polkadot",this.namespace=e.namespace,this.events=Hr("events"),this.client=Hr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Bo.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var a;const f=us(r);e[f]=this.createHttpProvider(f,(a=this.namespace.rpcMap)==null?void 0:a[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const a=this.createHttpProvider(e,r);a&&(this.httpProviders[e]=a)}createHttpProvider(e,r){const a=r||t6(e,this.namespace,this.client.core.projectId);if(!a)throw new Error(`No RPC url provided for chainId: ${e}`);return new ko(new ss(a,Hr("disableProviderPing")))}}class Xm0{constructor(e){this.name="eip155",this.namespace=e.namespace,this.events=Hr("events"),this.client=Hr("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(parseInt(e),r),this.chainId=parseInt(e),this.events.emit(Bo.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,r){const a=r||t6(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!a)throw new Error(`No RPC url provided for chainId: ${e}`);return new ko(new ss(a,Hr("disableProviderPing")))}setHttpProvider(e,r){const a=this.createHttpProvider(e,r);a&&(this.httpProviders[e]=a)}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var a;const f=parseInt(us(r));e[f]=this.createHttpProvider(f,(a=this.namespace.rpcMap)==null?void 0:a[r])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}async handleSwitchChain(e){var r,a;let f=e.request.params?(r=e.request.params[0])==null?void 0:r.chainId:"0x0";f=f.startsWith("0x")?f:`0x${f}`;const n=parseInt(f,16);if(this.isChainApproved(n))this.setDefaultChain(`${n}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:f}]},chainId:(a=this.namespace.chains)==null?void 0:a[0]}),this.setDefaultChain(`${n}`);else throw new Error(`Failed to switch to chain 'eip155:${n}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}}class Qm0{constructor(e){this.name="solana",this.namespace=e.namespace,this.events=Hr("events"),this.client=Hr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Bo.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var a;const f=us(r);e[f]=this.createHttpProvider(f,(a=this.namespace.rpcMap)==null?void 0:a[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const a=this.createHttpProvider(e,r);a&&(this.httpProviders[e]=a)}createHttpProvider(e,r){const a=r||t6(e,this.namespace,this.client.core.projectId);if(!a)throw new Error(`No RPC url provided for chainId: ${e}`);return new ko(new ss(a,Hr("disableProviderPing")))}}class eg0{constructor(e){this.name="cosmos",this.namespace=e.namespace,this.events=Hr("events"),this.client=Hr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Bo.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var a;const f=us(r);e[f]=this.createHttpProvider(f,(a=this.namespace.rpcMap)==null?void 0:a[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const a=this.createHttpProvider(e,r);a&&(this.httpProviders[e]=a)}createHttpProvider(e,r){const a=r||t6(e,this.namespace,this.client.core.projectId);if(!a)throw new Error(`No RPC url provided for chainId: ${e}`);return new ko(new ss(a,Hr("disableProviderPing")))}}class tg0{constructor(e){this.name="cip34",this.namespace=e.namespace,this.events=Hr("events"),this.client=Hr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Bo.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{const a=this.getCardanoRPCUrl(r),f=us(r);e[f]=this.createHttpProvider(f,a)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}getCardanoRPCUrl(e){const r=this.namespace.rpcMap;if(r)return r[e]}setHttpProvider(e,r){const a=this.createHttpProvider(e,r);a&&(this.httpProviders[e]=a)}createHttpProvider(e,r){const a=r||this.getCardanoRPCUrl(e);if(!a)throw new Error(`No RPC url provided for chainId: ${e}`);return new ko(new ss(a,Hr("disableProviderPing")))}}class rg0{constructor(e){this.name="elrond",this.namespace=e.namespace,this.events=Hr("events"),this.client=Hr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Bo.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var a;const f=us(r);e[f]=this.createHttpProvider(f,(a=this.namespace.rpcMap)==null?void 0:a[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const a=this.createHttpProvider(e,r);a&&(this.httpProviders[e]=a)}createHttpProvider(e,r){const a=r||t6(e,this.namespace,this.client.core.projectId);if(!a)throw new Error(`No RPC url provided for chainId: ${e}`);return new ko(new ss(a,Hr("disableProviderPing")))}}class ag0{constructor(e){this.name="multiversx",this.namespace=e.namespace,this.events=Hr("events"),this.client=Hr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Bo.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var a;const f=us(r);e[f]=this.createHttpProvider(f,(a=this.namespace.rpcMap)==null?void 0:a[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const a=this.createHttpProvider(e,r);a&&(this.httpProviders[e]=a)}createHttpProvider(e,r){const a=r||t6(e,this.namespace,this.client.core.projectId);if(!a)throw new Error(`No RPC url provided for chainId: ${e}`);return new ko(new ss(a,Hr("disableProviderPing")))}}var ig0=Object.defineProperty,ng0=Object.defineProperties,fg0=Object.getOwnPropertyDescriptors,nN=Object.getOwnPropertySymbols,cg0=Object.prototype.hasOwnProperty,og0=Object.prototype.propertyIsEnumerable,fN=(t,e,r)=>e in t?ig0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,rh=(t,e)=>{for(var r in e||(e={}))cg0.call(e,r)&&fN(t,r,e[r]);if(nN)for(var r of nN(e))og0.call(e,r)&&fN(t,r,e[r]);return t},Km=(t,e)=>ng0(t,fg0(e));class Vm{constructor(e){this.events=new Ve,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=e,this.logger=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:Dt.pino(Dt.getDefaultLoggerOptions({level:e?.logger||XO})),this.disableProviderPing=e?.disableProviderPing||!1}static async init(e){const r=new Vm(e);return await r.initialize(),r}async request(e,r){const[a,f]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(a).request({request:rh({},e),chainId:`${a}:${f}`,topic:this.session.topic})}sendAsync(e,r,a){this.request(e,a).then(f=>r(null,f)).catch(f=>r(f,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(e=this.session)==null?void 0:e.topic,reason:zr("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}removeListener(e,r){this.events.removeListener(e,r)}off(e,r){this.events.off(e,r)}get isWalletConnect(){return!0}async pair(e){this.shouldAbortPairingAttempt=!1;let r=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(r>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:a,approval:f}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});a&&(this.uri=a,this.events.emit("display_uri",a)),await f().then(n=>{this.session=n,this.namespaces||(this.namespaces=Ym0(n.namespaces),this.persist("namespaces",this.namespaces))}).catch(n=>{if(n.message!==VO)throw n;r++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(e,r){try{if(!this.session)return;const[a,f]=this.validateChain(e);this.getProvider(a).setDefaultChain(f,r)}catch(a){if(!/Please call connect/.test(a.message))throw a}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const r=this.client.pairing.getAll();if(Lc(r)){for(const a of r)e.deletePairings?this.client.core.expirer.set(a.topic,0):await this.client.core.relayer.subscriber.unsubscribe(a.topic);this.logger.info(`Inactive pairings cleared: ${r.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const e=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[e]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await Nm0.init({logger:this.providerOpts.logger||XO,relayUrl:this.providerOpts.relayUrl||$m0,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(r=>l8(r)))];Hm("client",this.client),Hm("events",this.events),Hm("disableProviderPing",this.disableProviderPing),e.forEach(r=>{if(!this.session)return;const a=Wm0(r,this.session),f=rN(a),n=Gm0(this.namespaces,this.optionalNamespaces),l=Km(rh({},n[r]),{accounts:a,chains:f});switch(r){case"eip155":this.rpcProviders[r]=new Xm0({namespace:l});break;case"solana":this.rpcProviders[r]=new Qm0({namespace:l});break;case"cosmos":this.rpcProviders[r]=new eg0({namespace:l});break;case"polkadot":this.rpcProviders[r]=new Jm0({namespace:l});break;case"cip34":this.rpcProviders[r]=new tg0({namespace:l});break;case"elrond":this.rpcProviders[r]=new rg0({namespace:l});break;case"multiversx":this.rpcProviders[r]=new ag0({namespace:l});break}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{const{params:r}=e,{event:a}=r;if(a.name==="accountsChanged"){const f=a.data;f&&Lc(f)&&this.events.emit("accountsChanged",f.map(Zm0))}else if(a.name==="chainChanged"){const f=r.chainId,n=r.event.data,l=l8(f),m=qm(f)!==qm(n)?`${l}:${qm(n)}`:f;this.onChainChanged(m)}else this.events.emit(a.name,a.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:r})=>{var a;const{namespaces:f}=r,n=(a=this.client)==null?void 0:a.session.get(e);this.session=Km(rh({},n),{namespaces:f}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:r})}),this.client.on("session_delete",async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",Km(rh({},zr("USER_DISCONNECTED")),{data:e.topic}))}),this.on(Bo.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){if(!this.rpcProviders[e])throw new Error(`Provider not found: ${e}`);return this.rpcProviders[e]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var r;this.getProvider(e).updateNamespace((r=this.session)==null?void 0:r.namespaces[e])})}setNamespaces(e){const{namespaces:r,optionalNamespaces:a,sessionProperties:f}=e;r&&Object.keys(r).length&&(this.namespaces=r),a&&Object.keys(a).length&&(this.optionalNamespaces=a),this.sessionProperties=f,this.persist("namespaces",r),this.persist("optionalNamespaces",a)}validateChain(e){const[r,a]=e?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[r,a];if(r&&!Object.keys(this.namespaces||{}).map(l=>l8(l)).includes(r))throw new Error(`Namespace '${r}' is not configured. Please call connect() first with namespace config.`);if(r&&a)return[r,a];const f=l8(Object.keys(this.namespaces)[0]),n=this.rpcProviders[f].getDefaultChain();return[f,n]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,r=!1){var a;if(!this.namespaces)return;const[f,n]=this.validateChain(e);r||this.getProvider(f).setDefaultChain(n),((a=this.namespaces[f])!=null?a:this.namespaces[`${f}:${n}`]).defaultChain=n,this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",n)}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(e,r){this.client.core.storage.setItem(`${QO}/${e}`,r)}async getFromStore(e){return await this.client.core.storage.getItem(`${QO}/${e}`)}}const dg0=Vm,sg0="wc",ug0="ethereum_provider",bg0=`${sg0}@2:${ug0}:`,hg0="https://rpc.walletconnect.com/v1/",Wm=["eth_sendTransaction","personal_sign"],lg0=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],Gm=["chainChanged","accountsChanged"],xg0=["chainChanged","accountsChanged","message","disconnect","connect"];var pg0=Object.defineProperty,vg0=Object.defineProperties,mg0=Object.getOwnPropertyDescriptors,cN=Object.getOwnPropertySymbols,gg0=Object.prototype.hasOwnProperty,yg0=Object.prototype.propertyIsEnumerable,oN=(t,e,r)=>e in t?pg0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,P8=(t,e)=>{for(var r in e||(e={}))gg0.call(e,r)&&oN(t,r,e[r]);if(cN)for(var r of cN(e))yg0.call(e,r)&&oN(t,r,e[r]);return t},dN=(t,e)=>vg0(t,mg0(e));function ah(t){return Number(t[0].split(":")[1])}function Zm(t){return`0x${t.toString(16)}`}function wg0(t){const{chains:e,optionalChains:r,methods:a,optionalMethods:f,events:n,optionalEvents:l,rpcMap:m}=t;if(!Lc(e))throw new Error("Invalid chains");const y={chains:e,methods:a||Wm,events:n||Gm,rpcMap:P8({},e.length?{[ah(e)]:m[ah(e)]}:{})},_=n?.filter(P=>!Gm.includes(P)),E=a?.filter(P=>!Wm.includes(P));if(!r&&!l&&!f&&!(_!=null&&_.length)&&!(E!=null&&E.length))return{required:e.length?y:void 0};const A=_?.length&&E?.length||!r,k={chains:[...new Set(A?y.chains.concat(r||[]):r)],methods:[...new Set(y.methods.concat(f!=null&&f.length?f:lg0))],events:[...new Set(y.events.concat(l!=null&&l.length?l:xg0))],rpcMap:m};return{required:e.length?y:void 0,optional:r.length?k:void 0}}class Ym{constructor(){this.events=new Ve,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=bg0,this.on=(e,r)=>(this.events.on(e,r),this),this.once=(e,r)=>(this.events.once(e,r),this),this.removeListener=(e,r)=>(this.events.removeListener(e,r),this),this.off=(e,r)=>(this.events.off(e,r),this),this.parseAccount=e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e,this.signer={},this.rpc={}}static async init(e){const r=new Ym;return await r.initialize(e),r}async request(e){return await this.signer.request(e,this.formatChainId(this.chainId))}sendAsync(e,r){this.signer.sendAsync(e,r,this.formatChainId(this.chainId))}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(e){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(e);const{required:r,optional:a}=wg0(this.rpc);try{const f=await new Promise(async(l,m)=>{var y;this.rpc.showQrModal&&((y=this.modal)==null||y.subscribeModal(_=>{!_.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),m(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(dN(P8({namespaces:P8({},r&&{[this.namespace]:r})},a&&{optionalNamespaces:{[this.namespace]:a}}),{pairingTopic:e?.pairingTopic})).then(_=>{l(_)}).catch(_=>{m(new Error(_.message))})});if(!f)return;const n=E90(f.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:n),this.setAccounts(n),this.events.emit("connect",{chainId:Zm(this.chainId)})}catch(f){throw this.signer.logger.error(f),f}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",e=>{const{params:r}=e,{event:a}=r;a.name==="accountsChanged"?(this.accounts=this.parseAccounts(a.data),this.events.emit("accountsChanged",this.accounts)):a.name==="chainChanged"?this.setChainId(this.formatChainId(a.data)):this.events.emit(a.name,a.data),this.events.emit("session_event",e)}),this.signer.on("chainChanged",e=>{const r=parseInt(e);this.chainId=r,this.events.emit("chainChanged",Zm(this.chainId)),this.persist()}),this.signer.on("session_update",e=>{this.events.emit("session_update",e)}),this.signer.on("session_delete",e=>{this.reset(),this.events.emit("session_delete",e),this.events.emit("disconnect",dN(P8({},zr("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{var r,a;this.rpc.showQrModal&&((r=this.modal)==null||r.closeModal(),(a=this.modal)==null||a.openModal({uri:e})),this.events.emit("display_uri",e)})}switchEthereumChain(e){this.request({method:"wallet_switchEthereumChain",params:[{chainId:e.toString(16)}]})}isCompatibleChainId(e){return typeof e=="string"?e.startsWith(`${this.namespace}:`):!1}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){const r=e.filter(a=>this.isCompatibleChainId(a)).map(a=>this.parseChainId(a));r.length&&(this.chainId=r[0],this.events.emit("chainChanged",Zm(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){const r=this.parseChainId(e);this.chainId=r,this.switchEthereumChain(r)}}parseAccountId(e){const[r,a,f]=e.split(":");return{chainId:`${r}:${a}`,address:f}}setAccounts(e){this.accounts=e.filter(r=>this.parseChainId(this.parseAccountId(r).chainId)===this.chainId).map(r=>this.parseAccountId(r).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var r,a;const f=(r=e?.chains)!=null?r:[],n=(a=e?.optionalChains)!=null?a:[],l=f.concat(n);if(!l.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const m=f.length?e?.methods||Wm:[],y=f.length?e?.events||Gm:[],_=e?.optionalMethods||[],E=e?.optionalEvents||[],A=e?.rpcMap||this.buildRpcMap(l,e.projectId),k=e?.qrModalOptions||void 0;return{chains:f?.map(P=>this.formatChainId(P)),optionalChains:n.map(P=>this.formatChainId(P)),methods:m,events:y,optionalMethods:_,optionalEvents:E,rpcMap:A,showQrModal:!!(e!=null&&e.showQrModal),qrModalOptions:k,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,r){const a={};return e.forEach(f=>{a[f]=this.getRpcUrl(f,r)}),a}async initialize(e){if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?ah(this.rpc.chains):ah(this.rpc.optionalChains),this.signer=await dg0.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:e.disableProviderPing,relayUrl:e.relayUrl,storageOptions:e.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let r;try{const{WalletConnectModal:a}=await import("@walletconnect/modal");r=a}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(r)try{this.modal=new r(P8({walletConnectVersion:2,projectId:this.rpc.projectId,standaloneChains:this.rpc.chains},this.rpc.qrModalOptions))}catch(a){throw this.signer.logger.error(a),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(e){if(!e)return;const{chains:r,optionalChains:a,rpcMap:f}=e;r&&Lc(r)&&(this.rpc.chains=r.map(n=>this.formatChainId(n)),r.forEach(n=>{this.rpc.rpcMap[n]=f?.[n]||this.getRpcUrl(n)})),a&&Lc(a)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=a?.map(n=>this.formatChainId(n)),a.forEach(n=>{this.rpc.rpcMap[n]=f?.[n]||this.getRpcUrl(n)}))}getRpcUrl(e,r){var a;return((a=this.rpc.rpcMap)==null?void 0:a[e])||`${hg0}?chainId=eip155:${e}&projectId=${r||this.rpc.projectId}`}async loadPersistedSession(){if(!this.session)return;const e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),r=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:r?.accounts),this.setAccounts(r?.accounts)}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(e){return typeof e=="string"||e instanceof String?[this.parseAccount(e)]:e.map(r=>this.parseAccount(r))}}const _g0=Ym,Mg0="jc_wallet_data",Eg0="https://oauth-svr.cebggame.com/test",Ag0="https://wallet.cebggame.com",Kr=()=>jc.wallet.env==="dev"||jc.wallet.useWaas?Eg0:Ag0,Sg0="https://pay.cebggame.com/v2",kg0="https://pay.cebggame.com/v0",Tg0="https://www.counterfire.games/okx/okx.html",Bg0="https://www.counterfire.games/okx/okx.html",C8=()=>jc.wallet.env==="release"?Sg0:kg0,Pg0=()=>jc.wallet.env==="dev"?Tg0:Bg0,sN=6,Cg0=10,uN=6,Ig0="0x000000000000000000000000",Jm="0x0000000000000000000000000000000000000000",Rg0=[80001,421613,137,42161,195],Sr=1.2,bN=1,hN="relay_token",ih="initOKXWallet",Xm="relay_aes_key",lN="encrypted",Qm="last_relay_data",xN="jcwallet_params",pN="current_wallet_address";var nh=()=>({events:{},emit(t,...e){for(let r of this.events[t]||[])r(...e)},on(t,e){return(this.events[t]=this.events[t]||[]).push(e),()=>this.events[t]=this.events[t].filter(r=>r!==e)},once(t,e){var r=(...a)=>{this.events[t]=this.events[t].filter(f=>f!==r),e(...a)};(this.events[t]=this.events[t]||[]).push(r)},listen(t,e){return(this.events[t]=this.events[t]||[]).push(e),()=>this.events[t]=this.events[t].filter(r=>r!==e)},remove(t,e){this.events[t]=this.events[t].filter(r=>r!==e)}});const Og0="wallet_chain_change",Ng0="wallet_account_change",Dg0="wallet_token_type_change";function vN(t,e){return{types:{EIP712Domain:[{name:"name",type:"string"},{name:"version",type:"string"}],set:[{name:"tips",type:"string"},{name:"nonce",type:"string"}]},primaryType:"set",domain:{name:"Auth",version:"1"},message:{tips:e,nonce:t}}}function $g0(t,e,r){const a=vN(t,e);return Zo.signTypedData({data:a,privateKey:Buffer.from(r.replace("0x",""),"hex"),version:Zo.SignTypedDataVersion.V4})}function mN(t){if(!t)return{};let e=t.split(".");if(e.length<2)return{};try{return JSON.parse(window.atob(e[1]))}catch{return{}}}function gN(t,e){if(!e)return!0;let r=mN(e);if(!r.exp)return!0;let a=Date.now()/1e3|0;return r.exp{for(var f=a>1?void 0:a?jg0(e,r):e,n=t.length-1,l;n>=0;n--)(l=t[n])&&(f=(a?l(e,r,f):l(f))||f);return a&&f&&Fg0(e,r,f),f};let oa=class{constructor(){this.handler=nh()}get tokenData(){return mN(this.token)}};oa=zg0([$c],oa);function yN(t,e,r){let a={};a["Content-Type"]="application/json";let f=new oa;!r&&f.token?a.Authorization=`Bearer ${f.token}`:r&&(a.Authorization=`Bearer ${r}`),a.api_version=bN+"",a.api_env,jc.wallet.env,a.api_platform,jc.wallet.platform;let n={method:"GET",mode:"cors",cache:"no-cache"};return Object.assign(n,e),n.headers=a,P4(t,n)}function qg0(t,e){return yN(t,{},e)}function fh(t,e){return qg0(t,e).then(r=>r.json())}function Hg0(t,e,r){let a={method:"POST",body:JSON.stringify(e)};return yN(t,a,r)}function Or(t,e,r){return Hg0(t,e,r).then(a=>a.json())}function Kg0(t){const e=`${Kr()}/trans/record`;return Or(e,t)}function wN(t){const e=`${Kr()}/trans/records`;return Or(e,t)}function Vg0(t={dedupeConcurrent:!1}){const{dedupeConcurrent:e}=t;let r=[],a,f=new eg;const n=m=>{let y=new eg;return e&&(r=[],f.started&&(f=new eg),y=f),r.push(()=>(y.started=!0,m().then(y.resolve).catch(y.reject),y.promise)),a||(a=l()),y.promise},l=async()=>{for(;r.length;)await r.shift()().catch(()=>{});a=void 0};return{push:n,flush:()=>a||Promise.resolve(),get size(){return r.length}}}let eg=class{constructor(){this.started=!1,this.resolve=()=>{},this.reject=()=>{},this.promise=new Promise((e,r)=>{this.resolve=e,this.reject=r})}};var Wg0=Object.defineProperty,Gg0=Object.getOwnPropertyDescriptor,Zg0=(t,e,r,a)=>{for(var f=a>1?void 0:a?Gg0(e,r):e,n=t.length-1,l;n>=0;n--)(l=t[n])&&(f=(a?l(e,r,f):l(f))||f);return a&&f&&Wg0(e,r,f),f};let r6=class{constructor(){this.queue=Vg0()}addLog(t){this.queue.push(async()=>{try{await Kg0(t)}catch(e){console.log("error save tx record: "),console.log(e)}})}};r6=Zg0([$c],r6);function _N(t){return"0x"+t.toString(16)}function Ia(t,e){return new Promise((r,a)=>{e.on("presend",function(f){if(jc.wallet.isInternal){console.log("before send tran: ",JSON.stringify(f));let n;!f.gasPrice&&f.maxPriorityFeePerGas&&f.maxFeePerGas?n=Lr.toBN(f.maxFeePerGas).sub(Lr.toBN(f.maxPriorityFeePerGas)).div(Lr.toBN(2)).mul(Lr.toBN(1e9)):f.gasPrice&&(n=Lr.toBN(f.gasPrice)),t.gas=Lr.toBN(f.gas).toString(),t.gasPrice=n.toString(),t.transactionHash=f.transactionHash,t.chain=jc.wallet.currentChain.id,t.startTime=Date.now(),new r6().addLog(t)}}).on("transactionHash",function(f){console.log(`remote transactionHash: ${f}`)}).on("confirmation",function(f,n){console.log(`confirmation:: confirmationNumber: ${f} , receipt: ${JSON.stringify(n)}`),jc.wallet.isInternal&&f>=uN&&(t.status=2,t.confirmTime=Date.now(),new r6().addLog(t))}).on("receipt",function(f){console.log(f),jc.wallet.isInternal&&(t.status=f.status?1:10,t.blockNumber=f.blockNumber,t.blockHash=f.blockHash,t.gas=f.gasUsed,new r6().addLog(t)),r&&r(f)}).on("error",function(f,n){console.log(f),jc.wallet.isInternal&&(t.status=11,new r6().addLog(t)),a&&a(f)})})}class Yg0{constructor(){this.accounts=[],this.socketConnected=!1,console.log("ZWalletConnect constructor")}async connect(e){return console.log("wallet connect begin init"),this.provider=await _g0.init({projectId:"e7743d46923911fa8850619b7a7f6d9d",chains:[e],showQrModal:!1,optionalChains:[e],metadata:{name:"Counter Fire",description:"Counter Fire Game",url:"https://www.counterfire.games",icons:["https://www.counterfire.games/favicon.ico"]}}),this._subscribeToEvents(),console.log("wallet connect begin connect"),this.provider.connect()}async disconnect(){this.provider&&(this.provider.removeListener("accountsChanged"),this.provider.removeListener("chainChanged"),this.provider.removeListener("disconnect"),this.provider.removeListener("display_uri"),await this.provider.disconnect())}_subscribeToEvents(){this.provider.on("accountsChanged",async e=>{console.log("on accountsChanged: ",e),this.accounts=e}),this.provider.on("chainChanged",async e=>{const r=parseInt(e);console.log("on chainChanged",e,r)}),this.provider.on("disconnect",e=>{console.log("on disconnect",e)}),this.provider.on("display_uri",e=>{jumpToWallet(e)})}async addOrChangeChain(e){return new Promise((r,a)=>{const f=l=>{console.log("switchEthereumChain: ",l),this.provider.removeListener("chainChanged",f),r&&r(l)};this.provider.on("chainChanged",f);let n={chainId:_N(e.id),chainName:e.name,nativeCurrency:{name:e.symbol,symbol:e.symbol,decimals:e.decimals||18},rpcUrls:[e.rpc],blockExplorerUrls:[e.explorerurl]};this.provider.request({method:"wallet_addEthereumChain",params:[n]}).then(()=>{console.log("add chain success, wait result")}).catch(l=>{console.error("add chain error: ",JSON.stringify(l)),this.provider.removeListener("chainChanged",f),a&&a(l)})})}async signData(e,r){const a=JSON.stringify(e),f=r||this.accounts[0];if(!f)throw new Error("no account");console.log("sending personal sign req from",f,a);const n=[f,a];return(await this.sendCmd({method:"eth_signTypedData_v4",params:n,from:f})).result}async sendCmd({method:e,params:r,from:a}){return new Promise((f,n)=>{this.provider.sendAsync({method:e,params:r,from:a},async function(l,m){if(l){n&&n(l);return}f&&f(m)})})}}const Jg0=[{name:"Ethereum Mainnet RPC",type:"Mainnet",rpc:"https://rpc.ankr.com/eth",id:1,symbol:"ETH",explorerurl:"https://etherscan.io"},{name:"Ethereum Ropsten Testnet RPC",type:"Testnet",rpc:"https://ropsten.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161",id:3,symbol:"ETH",explorerurl:"https://ropsten.etherscan.io"},{name:"Ethereum Rinkeby Testnet RPC",type:"Testnet",rpc:"https://rinkey.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161",id:4,symbol:"ETH",explorerurl:"https://rinkey.etherscan.io"},{name:"Ethereum Goerli Testnet",type:"Testnet",rpc:"https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161",id:5,symbol:"ETH",explorerurl:"https://goerli.etherscan.io"},{name:"Ethereum Kovan Testnet RPC",type:"Testnet",rpc:"https://kovan.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161",id:6,symbol:"ETH",explorerurl:"https://kovan.etherscan.io"},{name:"Ubiq Mainnet RPC",type:"Mainnet",rpc:"https://rpc.octano.dev/",id:8,symbol:"UBQ",explorerurl:"https://ubiqscan.io/"},{name:"Elastos ETH Mainnet RPC",type:"Mainnet",rpc:"https://api.elastos.io/eth",id:20,symbol:"ELA",explorerurl:"https://explorer.elaeth.io/"},{name:"Cronos Mainnet RPC",type:"Mainnet",rpc:"https://evm-cronos.crypto.org",id:25,symbol:"CRO",explorerurl:"https://cronos.crypto.org/explorer/"},{name:"Telos EVM Mainnet RPC",type:"Mainnet",rpc:"https://mainnet.telos.net/evm",id:40,symbol:"TLOS",explorerurl:"https://telos.net/"},{name:"Binance Smart Chain",type:"Mainnet",rpc:"https://rpc.ankr.com/bsc",id:56,symbol:"BNB",explorerurl:"https://bscscan.com"},{name:"OKExChain Mainnet RPC",type:"Mainnet",rpc:"https://exchainrpc.okex.org",id:66,symbol:"OKT",explorerurl:"https://www.oklink.com/okexchain"},{name:"Hoo Mainnet RPC",type:"Mainnet",rpc:"https://http-mainnet.hoosmartchain.com",id:70,symbol:"HOO",explorerurl:"https://hooscan.com"},{name:"Binance Testnet",type:"Testnet",rpc:"https://data-seed-prebsc-1-s1.binance.org:8545/",id:97,symbol:"BNB",explorerurl:"https://testnet.bscscan.com"},{name:"xDai Mainnet RPC",type:"Mainnet",rpc:"https://rpc.xdaichain.com/",id:100,symbol:"XDAI",explorerurl:"https://blockscout.com/xdai/mainnet/"},{name:"Fuse Mainnet RPC",type:"Mainnet",rpc:"https://rpc.fuse.io",id:122,symbol:"FUSE",explorerurl:"https://explorer.fuse.io/"},{name:"HECO Mainnet RPC",type:"Mainnet",rpc:"https://http-mainnet-node.huobichain.com/",id:128,symbol:"HT",explorerurl:"https://hecoinfo.com/"},{name:"Matic Mainnet RPC",type:"Mainnet",rpc:"https://polygon-rpc.com",network:"POLYGON",id:137,symbol:"MATIC",explorerurl:"https://explorer.matic.network/"},{name:"Fantom Opera Mainnet RPC",type:"Mainnet",rpc:"https://rpc.ftm.tools/",id:250,symbol:"FTM",explorerurl:"https://ftmscan.com"},{name:"HECO Testnet RPC",type:"Testnet",rpc:"https://http-testnet.hecochain.com",id:256,symbol:"HT",explorerurl:"https://testnet.hecoinfo.com/"},{name:"KCC Mainnet",type:"Mainnet",rpc:"https://rpc-mainnet.kcc.network",id:321,symbol:"KCS",explorerurl:"https://scan.kcc.network"},{name:"KCC Testnet",type:"Testnet",rpc:"https://rpc-testnet.kcc.network",id:322,symbol:"tKCS",explorerurl:"https://scan-testnet.kcc.network"},{name:"Moonriver Mainnet RPC",type:"Mainnet",rpc:"https://rpc.moonriver.moonbeam.network",id:1285,symbol:"MOVR",explorerurl:"https://blockscout.moonriver.moonbeam.network/"},{name:"Fantom Testnet RPC",type:"Testnet",rpc:"https://rpc.testnet.fantom.network/",id:4002,symbol:"FTM",explorerurl:"https://testnet.ftmscan.com"},{name:"IoTeX Mainnet RPC",type:"Mainnet",rpc:"https://babel-api.mainnet.iotex.io",id:4689,symbol:"IOTEX",explorerurl:"https://iotexscan.io/"},{name:"Nahmii Mainnet RPC",type:"Mainnet",rpc:"https://l2.nahmii.io/",id:5551,symbol:"ETH",explorerurl:"https://explorer.nahmii.io/"},{name:"Nahmii Testnet RPC",type:"Testnet",rpc:"https://l2.testnet.nahmii.io/",id:5553,symbol:"ETH",explorerurl:"https://explorer.testnet.nahmii.io/"},{name:"Arbitrum One",type:"Mainnet",rpc:"https://arb1.arbitrum.io/rpc",id:42161,network:"ARBITRUM",symbol:"ETH",explorerurl:"https://arbiscan.io/"},{name:"Arbitrum Goerli",type:"Testnet",rpc:"https://goerli-rollup.arbitrum.io/rpc",id:421613,network:"AGOR",symbol:"AGOR",explorerurl:"https://testnet.arbiscan.io"},{name:"X1 testnet",type:"Testnet",rpc:"https://testrpc.x1.tech",id:195,network:"OKB",symbol:"OKB",explorerurl:"https://www.oklink.com/cn/x1-test"},{name:"Celo Mainnet RPC",type:"Mainnet",rpc:"https://rpc.ankr.com/celo",id:42220,symbol:"CELO",explorerurl:"https://celoscan.com"},{name:"Avalanche C Chain Local RPC",type:"Testnet",rpc:"https://localhost:9650/ext/bc/C/rpc",id:43112,symbol:"AVAX",explorerurl:"https://snowtrace.io"},{name:"Avalanche FUJI Testnet RPC",type:"Testnet",rpc:"https://api.avax-test.network/ext/bc/C/rpc",id:43113,symbol:"AVAX",explorerurl:"https://testnet.explorer.avax.network/"},{name:"Avalanche C Chain Mainnet RPC",type:"Mainnet",rpc:"https://rpc.ankr.com/avalanche",id:43114,symbol:"AVAX",explorerurl:"https://snowtrace.io"},{name:"Matic Testnet RPC",type:"Testnet",rpc:"https://rpc-mumbai.maticvigil.com",id:80001,symbol:"MATIC",explorerurl:"https://mumbai.polygonscan.com/"},{name:"Harmony Mainnet RPC",type:"Mainnet",rpc:"https://api.harmony.one/",id:16666e5,symbol:"ONE",explorerurl:"https://explorer.harmony.one"},{name:"Harmony Testnet RPC",type:"Testnet",rpc:"https://api.s0.b.hmny.io/",id:16667e5,symbol:"ONE",explorerurl:"https://explorer.harmony.one"},{name:"zkSync Era Mainnet",type:"Mainnet",rpc:"https://mainnet.era.zksync.io",id:324,symbol:"ETH",explorerurl:"https://explorer.zksync.io"},{name:"zkSync Era Testnet",type:"Testnet",rpc:"https://testnet.era.zksync.dev",id:280,symbol:"ETH",explorerurl:"https://goerli.explorer.zksync.io"},{name:"Local Testnet",type:"Local",rpc:"https://login-test.kingsome.cn/rpc",id:1338,symbol:"ETH",explorerurl:"https://explorer.harmony.one"}],Xg0=/^(.+?):\/\/.+?$/;function Qg0(t){let e=t.match(Xg0);return e?e[1]:""}var tg={},rg={},ag={},Zi={},ig={exports:{}};ig.exports,function(t){(function(e,r){function a(s,i){if(!s)throw new Error(i||"Assertion failed")}function f(s,i){s.super_=i;var o=function(){};o.prototype=i.prototype,s.prototype=new o,s.prototype.constructor=s}function n(s,i,o){if(n.isBN(s))return s;this.negative=0,this.words=null,this.length=0,this.red=null,s!==null&&((i==="le"||i==="be")&&(o=i,i=10),this._init(s||0,i||10,o||"be"))}typeof e=="object"?e.exports=n:r.BN=n,n.BN=n,n.wordSize=26;var l;try{typeof window<"u"&&typeof window.Buffer<"u"?l=window.Buffer:l=It.Buffer}catch{}n.isBN=function(i){return i instanceof n?!0:i!==null&&typeof i=="object"&&i.constructor.wordSize===n.wordSize&&Array.isArray(i.words)},n.max=function(i,o){return i.cmp(o)>0?i:o},n.min=function(i,o){return i.cmp(o)<0?i:o},n.prototype._init=function(i,o,d){if(typeof i=="number")return this._initNumber(i,o,d);if(typeof i=="object")return this._initArray(i,o,d);o==="hex"&&(o=16),a(o===(o|0)&&o>=2&&o<=36),i=i.toString().replace(/\s+/g,"");var h=0;i[0]==="-"&&(h++,this.negative=1),h=0;h-=3)u=i[h]|i[h-1]<<8|i[h-2]<<16,this.words[x]|=u<>>26-g&67108863,g+=24,g>=26&&(g-=26,x++);else if(d==="le")for(h=0,x=0;h>>26-g&67108863,g+=24,g>=26&&(g-=26,x++);return this._strip()};function m(s,i){var o=s.charCodeAt(i);if(o>=48&&o<=57)return o-48;if(o>=65&&o<=70)return o-55;if(o>=97&&o<=102)return o-87;a(!1,"Invalid character in "+s)}function y(s,i,o){var d=m(s,o);return o-1>=i&&(d|=m(s,o-1)<<4),d}n.prototype._parseHex=function(i,o,d){this.length=Math.ceil((i.length-o)/6),this.words=new Array(this.length);for(var h=0;h=o;h-=2)g=y(i,o,h)<=18?(x-=18,u+=1,this.words[u]|=g>>>26):x+=8;else{var b=i.length-o;for(h=b%2===0?o+1:o;h=18?(x-=18,u+=1,this.words[u]|=g>>>26):x+=8}this._strip()};function _(s,i,o,d){for(var h=0,x=0,u=Math.min(s.length,o),g=i;g=49?x=b-49+10:b>=17?x=b-17+10:x=b,a(b>=0&&x1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=A}catch{n.prototype.inspect=A}else n.prototype.inspect=A;function A(){return(this.red?""}var k=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],P=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],B=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(i,o){i=i||10,o=o|0||1;var d;if(i===16||i==="hex"){d="";for(var h=0,x=0,u=0;u>>24-h&16777215,h+=2,h>=26&&(h-=26,u--),x!==0||u!==this.length-1?d=k[6-b.length]+b+d:d=b+d}for(x!==0&&(d=x.toString(16)+d);d.length%o!==0;)d="0"+d;return this.negative!==0&&(d="-"+d),d}if(i===(i|0)&&i>=2&&i<=36){var c=P[i],v=B[i];d="";var F=this.clone();for(F.negative=0;!F.isZero();){var C=F.modrn(v).toString(i);F=F.idivn(v),F.isZero()?d=C+d:d=k[c-C.length]+C+d}for(this.isZero()&&(d="0"+d);d.length%o!==0;)d="0"+d;return this.negative!==0&&(d="-"+d),d}a(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var i=this.words[0];return this.length===2?i+=this.words[1]*67108864:this.length===3&&this.words[2]===1?i+=4503599627370496+this.words[1]*67108864:this.length>2&&a(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-i:i},n.prototype.toJSON=function(){return this.toString(16,2)},l&&(n.prototype.toBuffer=function(i,o){return this.toArrayLike(l,i,o)}),n.prototype.toArray=function(i,o){return this.toArrayLike(Array,i,o)};var I=function(i,o){return i.allocUnsafe?i.allocUnsafe(o):new i(o)};n.prototype.toArrayLike=function(i,o,d){this._strip();var h=this.byteLength(),x=d||Math.max(1,h);a(h<=x,"byte array longer than desired length"),a(x>0,"Requested array length <= 0");var u=I(i,x),g=o==="le"?"LE":"BE";return this["_toArrayLike"+g](u,h),u},n.prototype._toArrayLikeLE=function(i,o){for(var d=0,h=0,x=0,u=0;x>8&255),d>16&255),u===6?(d>24&255),h=0,u=0):(h=g>>>24,u+=2)}if(d=0&&(i[d--]=g>>8&255),d>=0&&(i[d--]=g>>16&255),u===6?(d>=0&&(i[d--]=g>>24&255),h=0,u=0):(h=g>>>24,u+=2)}if(d>=0)for(i[d--]=h;d>=0;)i[d--]=0},Math.clz32?n.prototype._countBits=function(i){return 32-Math.clz32(i)}:n.prototype._countBits=function(i){var o=i,d=0;return o>=4096&&(d+=13,o>>>=13),o>=64&&(d+=7,o>>>=7),o>=8&&(d+=4,o>>>=4),o>=2&&(d+=2,o>>>=2),d+o},n.prototype._zeroBits=function(i){if(i===0)return 26;var o=i,d=0;return o&8191||(d+=13,o>>>=13),o&127||(d+=7,o>>>=7),o&15||(d+=4,o>>>=4),o&3||(d+=2,o>>>=2),o&1||d++,d},n.prototype.bitLength=function(){var i=this.words[this.length-1],o=this._countBits(i);return(this.length-1)*26+o};function O(s){for(var i=new Array(s.bitLength()),o=0;o>>h&1}return i}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var i=0,o=0;oi.length?this.clone().ior(i):i.clone().ior(this)},n.prototype.uor=function(i){return this.length>i.length?this.clone().iuor(i):i.clone().iuor(this)},n.prototype.iuand=function(i){var o;this.length>i.length?o=i:o=this;for(var d=0;di.length?this.clone().iand(i):i.clone().iand(this)},n.prototype.uand=function(i){return this.length>i.length?this.clone().iuand(i):i.clone().iuand(this)},n.prototype.iuxor=function(i){var o,d;this.length>i.length?(o=this,d=i):(o=i,d=this);for(var h=0;hi.length?this.clone().ixor(i):i.clone().ixor(this)},n.prototype.uxor=function(i){return this.length>i.length?this.clone().iuxor(i):i.clone().iuxor(this)},n.prototype.inotn=function(i){a(typeof i=="number"&&i>=0);var o=Math.ceil(i/26)|0,d=i%26;this._expand(o),d>0&&o--;for(var h=0;h0&&(this.words[h]=~this.words[h]&67108863>>26-d),this._strip()},n.prototype.notn=function(i){return this.clone().inotn(i)},n.prototype.setn=function(i,o){a(typeof i=="number"&&i>=0);var d=i/26|0,h=i%26;return this._expand(d+1),o?this.words[d]=this.words[d]|1<i.length?(d=this,h=i):(d=i,h=this);for(var x=0,u=0;u>>26;for(;x!==0&&u>>26;if(this.length=d.length,x!==0)this.words[this.length]=x,this.length++;else if(d!==this)for(;ui.length?this.clone().iadd(i):i.clone().iadd(this)},n.prototype.isub=function(i){if(i.negative!==0){i.negative=0;var o=this.iadd(i);return i.negative=1,o._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(i),this.negative=1,this._normSign();var d=this.cmp(i);if(d===0)return this.negative=0,this.length=1,this.words[0]=0,this;var h,x;d>0?(h=this,x=i):(h=i,x=this);for(var u=0,g=0;g>26,this.words[g]=o&67108863;for(;u!==0&&g>26,this.words[g]=o&67108863;if(u===0&&g>>26,F=b&67108863,C=Math.min(c,i.length-1),L=Math.max(0,c-s.length+1);L<=C;L++){var G=c-L|0;h=s.words[G]|0,x=i.words[L]|0,u=h*x+F,v+=u/67108864|0,F=u&67108863}o.words[c]=F|0,b=v|0}return b!==0?o.words[c]=b|0:o.length--,o._strip()}var N=function(i,o,d){var h=i.words,x=o.words,u=d.words,g=0,b,c,v,F=h[0]|0,C=F&8191,L=F>>>13,G=h[1]|0,V=G&8191,J=G>>>13,Y=h[2]|0,W=Y&8191,X=Y>>>13,O0=h[3]|0,i0=O0&8191,c0=O0>>>13,Z0=h[4]|0,d0=Z0&8191,x0=Z0>>>13,ne=h[5]|0,p0=ne&8191,u0=ne>>>13,J0=h[6]|0,l0=J0&8191,h0=J0>>>13,te=h[7]|0,v0=te&8191,b0=te>>>13,re=h[8]|0,E0=re&8191,m0=re>>>13,he=h[9]|0,A0=he&8191,g0=he>>>13,le=x[0]|0,S0=le&8191,k0=le>>>13,Oe=x[1]|0,U0=Oe&8191,T0=Oe>>>13,Ne=x[2]|0,L0=Ne&8191,R0=Ne>>>13,Ie=x[3]|0,C0=Ie&8191,_0=Ie>>>13,Te=x[4]|0,N0=Te&8191,M0=Te>>>13,Re=x[5]|0,$0=Re&8191,y0=Re>>>13,Me=x[6]|0,Z=Me&8191,e0=Me>>>13,f0=x[7]|0,z=f0&8191,r0=f0>>>13,j0=x[8]|0,n0=j0&8191,o0=j0>>>13,X0=x[9]|0,I0=X0&8191,P0=X0>>>13;d.negative=i.negative^o.negative,d.length=19,b=Math.imul(C,S0),c=Math.imul(C,k0),c=c+Math.imul(L,S0)|0,v=Math.imul(L,k0);var Ce=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,b=Math.imul(V,S0),c=Math.imul(V,k0),c=c+Math.imul(J,S0)|0,v=Math.imul(J,k0),b=b+Math.imul(C,U0)|0,c=c+Math.imul(C,T0)|0,c=c+Math.imul(L,U0)|0,v=v+Math.imul(L,T0)|0;var ie=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(ie>>>26)|0,ie&=67108863,b=Math.imul(W,S0),c=Math.imul(W,k0),c=c+Math.imul(X,S0)|0,v=Math.imul(X,k0),b=b+Math.imul(V,U0)|0,c=c+Math.imul(V,T0)|0,c=c+Math.imul(J,U0)|0,v=v+Math.imul(J,T0)|0,b=b+Math.imul(C,L0)|0,c=c+Math.imul(C,R0)|0,c=c+Math.imul(L,L0)|0,v=v+Math.imul(L,R0)|0;var ve=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(ve>>>26)|0,ve&=67108863,b=Math.imul(i0,S0),c=Math.imul(i0,k0),c=c+Math.imul(c0,S0)|0,v=Math.imul(c0,k0),b=b+Math.imul(W,U0)|0,c=c+Math.imul(W,T0)|0,c=c+Math.imul(X,U0)|0,v=v+Math.imul(X,T0)|0,b=b+Math.imul(V,L0)|0,c=c+Math.imul(V,R0)|0,c=c+Math.imul(J,L0)|0,v=v+Math.imul(J,R0)|0,b=b+Math.imul(C,C0)|0,c=c+Math.imul(C,_0)|0,c=c+Math.imul(L,C0)|0,v=v+Math.imul(L,_0)|0;var me=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(me>>>26)|0,me&=67108863,b=Math.imul(d0,S0),c=Math.imul(d0,k0),c=c+Math.imul(x0,S0)|0,v=Math.imul(x0,k0),b=b+Math.imul(i0,U0)|0,c=c+Math.imul(i0,T0)|0,c=c+Math.imul(c0,U0)|0,v=v+Math.imul(c0,T0)|0,b=b+Math.imul(W,L0)|0,c=c+Math.imul(W,R0)|0,c=c+Math.imul(X,L0)|0,v=v+Math.imul(X,R0)|0,b=b+Math.imul(V,C0)|0,c=c+Math.imul(V,_0)|0,c=c+Math.imul(J,C0)|0,v=v+Math.imul(J,_0)|0,b=b+Math.imul(C,N0)|0,c=c+Math.imul(C,M0)|0,c=c+Math.imul(L,N0)|0,v=v+Math.imul(L,M0)|0;var xe=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(xe>>>26)|0,xe&=67108863,b=Math.imul(p0,S0),c=Math.imul(p0,k0),c=c+Math.imul(u0,S0)|0,v=Math.imul(u0,k0),b=b+Math.imul(d0,U0)|0,c=c+Math.imul(d0,T0)|0,c=c+Math.imul(x0,U0)|0,v=v+Math.imul(x0,T0)|0,b=b+Math.imul(i0,L0)|0,c=c+Math.imul(i0,R0)|0,c=c+Math.imul(c0,L0)|0,v=v+Math.imul(c0,R0)|0,b=b+Math.imul(W,C0)|0,c=c+Math.imul(W,_0)|0,c=c+Math.imul(X,C0)|0,v=v+Math.imul(X,_0)|0,b=b+Math.imul(V,N0)|0,c=c+Math.imul(V,M0)|0,c=c+Math.imul(J,N0)|0,v=v+Math.imul(J,M0)|0,b=b+Math.imul(C,$0)|0,c=c+Math.imul(C,y0)|0,c=c+Math.imul(L,$0)|0,v=v+Math.imul(L,y0)|0;var Ee=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,b=Math.imul(l0,S0),c=Math.imul(l0,k0),c=c+Math.imul(h0,S0)|0,v=Math.imul(h0,k0),b=b+Math.imul(p0,U0)|0,c=c+Math.imul(p0,T0)|0,c=c+Math.imul(u0,U0)|0,v=v+Math.imul(u0,T0)|0,b=b+Math.imul(d0,L0)|0,c=c+Math.imul(d0,R0)|0,c=c+Math.imul(x0,L0)|0,v=v+Math.imul(x0,R0)|0,b=b+Math.imul(i0,C0)|0,c=c+Math.imul(i0,_0)|0,c=c+Math.imul(c0,C0)|0,v=v+Math.imul(c0,_0)|0,b=b+Math.imul(W,N0)|0,c=c+Math.imul(W,M0)|0,c=c+Math.imul(X,N0)|0,v=v+Math.imul(X,M0)|0,b=b+Math.imul(V,$0)|0,c=c+Math.imul(V,y0)|0,c=c+Math.imul(J,$0)|0,v=v+Math.imul(J,y0)|0,b=b+Math.imul(C,Z)|0,c=c+Math.imul(C,e0)|0,c=c+Math.imul(L,Z)|0,v=v+Math.imul(L,e0)|0;var Ae=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,b=Math.imul(v0,S0),c=Math.imul(v0,k0),c=c+Math.imul(b0,S0)|0,v=Math.imul(b0,k0),b=b+Math.imul(l0,U0)|0,c=c+Math.imul(l0,T0)|0,c=c+Math.imul(h0,U0)|0,v=v+Math.imul(h0,T0)|0,b=b+Math.imul(p0,L0)|0,c=c+Math.imul(p0,R0)|0,c=c+Math.imul(u0,L0)|0,v=v+Math.imul(u0,R0)|0,b=b+Math.imul(d0,C0)|0,c=c+Math.imul(d0,_0)|0,c=c+Math.imul(x0,C0)|0,v=v+Math.imul(x0,_0)|0,b=b+Math.imul(i0,N0)|0,c=c+Math.imul(i0,M0)|0,c=c+Math.imul(c0,N0)|0,v=v+Math.imul(c0,M0)|0,b=b+Math.imul(W,$0)|0,c=c+Math.imul(W,y0)|0,c=c+Math.imul(X,$0)|0,v=v+Math.imul(X,y0)|0,b=b+Math.imul(V,Z)|0,c=c+Math.imul(V,e0)|0,c=c+Math.imul(J,Z)|0,v=v+Math.imul(J,e0)|0,b=b+Math.imul(C,z)|0,c=c+Math.imul(C,r0)|0,c=c+Math.imul(L,z)|0,v=v+Math.imul(L,r0)|0;var we=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(we>>>26)|0,we&=67108863,b=Math.imul(E0,S0),c=Math.imul(E0,k0),c=c+Math.imul(m0,S0)|0,v=Math.imul(m0,k0),b=b+Math.imul(v0,U0)|0,c=c+Math.imul(v0,T0)|0,c=c+Math.imul(b0,U0)|0,v=v+Math.imul(b0,T0)|0,b=b+Math.imul(l0,L0)|0,c=c+Math.imul(l0,R0)|0,c=c+Math.imul(h0,L0)|0,v=v+Math.imul(h0,R0)|0,b=b+Math.imul(p0,C0)|0,c=c+Math.imul(p0,_0)|0,c=c+Math.imul(u0,C0)|0,v=v+Math.imul(u0,_0)|0,b=b+Math.imul(d0,N0)|0,c=c+Math.imul(d0,M0)|0,c=c+Math.imul(x0,N0)|0,v=v+Math.imul(x0,M0)|0,b=b+Math.imul(i0,$0)|0,c=c+Math.imul(i0,y0)|0,c=c+Math.imul(c0,$0)|0,v=v+Math.imul(c0,y0)|0,b=b+Math.imul(W,Z)|0,c=c+Math.imul(W,e0)|0,c=c+Math.imul(X,Z)|0,v=v+Math.imul(X,e0)|0,b=b+Math.imul(V,z)|0,c=c+Math.imul(V,r0)|0,c=c+Math.imul(J,z)|0,v=v+Math.imul(J,r0)|0,b=b+Math.imul(C,n0)|0,c=c+Math.imul(C,o0)|0,c=c+Math.imul(L,n0)|0,v=v+Math.imul(L,o0)|0;var Se=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(Se>>>26)|0,Se&=67108863,b=Math.imul(A0,S0),c=Math.imul(A0,k0),c=c+Math.imul(g0,S0)|0,v=Math.imul(g0,k0),b=b+Math.imul(E0,U0)|0,c=c+Math.imul(E0,T0)|0,c=c+Math.imul(m0,U0)|0,v=v+Math.imul(m0,T0)|0,b=b+Math.imul(v0,L0)|0,c=c+Math.imul(v0,R0)|0,c=c+Math.imul(b0,L0)|0,v=v+Math.imul(b0,R0)|0,b=b+Math.imul(l0,C0)|0,c=c+Math.imul(l0,_0)|0,c=c+Math.imul(h0,C0)|0,v=v+Math.imul(h0,_0)|0,b=b+Math.imul(p0,N0)|0,c=c+Math.imul(p0,M0)|0,c=c+Math.imul(u0,N0)|0,v=v+Math.imul(u0,M0)|0,b=b+Math.imul(d0,$0)|0,c=c+Math.imul(d0,y0)|0,c=c+Math.imul(x0,$0)|0,v=v+Math.imul(x0,y0)|0,b=b+Math.imul(i0,Z)|0,c=c+Math.imul(i0,e0)|0,c=c+Math.imul(c0,Z)|0,v=v+Math.imul(c0,e0)|0,b=b+Math.imul(W,z)|0,c=c+Math.imul(W,r0)|0,c=c+Math.imul(X,z)|0,v=v+Math.imul(X,r0)|0,b=b+Math.imul(V,n0)|0,c=c+Math.imul(V,o0)|0,c=c+Math.imul(J,n0)|0,v=v+Math.imul(J,o0)|0,b=b+Math.imul(C,I0)|0,c=c+Math.imul(C,P0)|0,c=c+Math.imul(L,I0)|0,v=v+Math.imul(L,P0)|0;var de=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(de>>>26)|0,de&=67108863,b=Math.imul(A0,U0),c=Math.imul(A0,T0),c=c+Math.imul(g0,U0)|0,v=Math.imul(g0,T0),b=b+Math.imul(E0,L0)|0,c=c+Math.imul(E0,R0)|0,c=c+Math.imul(m0,L0)|0,v=v+Math.imul(m0,R0)|0,b=b+Math.imul(v0,C0)|0,c=c+Math.imul(v0,_0)|0,c=c+Math.imul(b0,C0)|0,v=v+Math.imul(b0,_0)|0,b=b+Math.imul(l0,N0)|0,c=c+Math.imul(l0,M0)|0,c=c+Math.imul(h0,N0)|0,v=v+Math.imul(h0,M0)|0,b=b+Math.imul(p0,$0)|0,c=c+Math.imul(p0,y0)|0,c=c+Math.imul(u0,$0)|0,v=v+Math.imul(u0,y0)|0,b=b+Math.imul(d0,Z)|0,c=c+Math.imul(d0,e0)|0,c=c+Math.imul(x0,Z)|0,v=v+Math.imul(x0,e0)|0,b=b+Math.imul(i0,z)|0,c=c+Math.imul(i0,r0)|0,c=c+Math.imul(c0,z)|0,v=v+Math.imul(c0,r0)|0,b=b+Math.imul(W,n0)|0,c=c+Math.imul(W,o0)|0,c=c+Math.imul(X,n0)|0,v=v+Math.imul(X,o0)|0,b=b+Math.imul(V,I0)|0,c=c+Math.imul(V,P0)|0,c=c+Math.imul(J,I0)|0,v=v+Math.imul(J,P0)|0;var ue=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(ue>>>26)|0,ue&=67108863,b=Math.imul(A0,L0),c=Math.imul(A0,R0),c=c+Math.imul(g0,L0)|0,v=Math.imul(g0,R0),b=b+Math.imul(E0,C0)|0,c=c+Math.imul(E0,_0)|0,c=c+Math.imul(m0,C0)|0,v=v+Math.imul(m0,_0)|0,b=b+Math.imul(v0,N0)|0,c=c+Math.imul(v0,M0)|0,c=c+Math.imul(b0,N0)|0,v=v+Math.imul(b0,M0)|0,b=b+Math.imul(l0,$0)|0,c=c+Math.imul(l0,y0)|0,c=c+Math.imul(h0,$0)|0,v=v+Math.imul(h0,y0)|0,b=b+Math.imul(p0,Z)|0,c=c+Math.imul(p0,e0)|0,c=c+Math.imul(u0,Z)|0,v=v+Math.imul(u0,e0)|0,b=b+Math.imul(d0,z)|0,c=c+Math.imul(d0,r0)|0,c=c+Math.imul(x0,z)|0,v=v+Math.imul(x0,r0)|0,b=b+Math.imul(i0,n0)|0,c=c+Math.imul(i0,o0)|0,c=c+Math.imul(c0,n0)|0,v=v+Math.imul(c0,o0)|0,b=b+Math.imul(W,I0)|0,c=c+Math.imul(W,P0)|0,c=c+Math.imul(X,I0)|0,v=v+Math.imul(X,P0)|0;var fe=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(fe>>>26)|0,fe&=67108863,b=Math.imul(A0,C0),c=Math.imul(A0,_0),c=c+Math.imul(g0,C0)|0,v=Math.imul(g0,_0),b=b+Math.imul(E0,N0)|0,c=c+Math.imul(E0,M0)|0,c=c+Math.imul(m0,N0)|0,v=v+Math.imul(m0,M0)|0,b=b+Math.imul(v0,$0)|0,c=c+Math.imul(v0,y0)|0,c=c+Math.imul(b0,$0)|0,v=v+Math.imul(b0,y0)|0,b=b+Math.imul(l0,Z)|0,c=c+Math.imul(l0,e0)|0,c=c+Math.imul(h0,Z)|0,v=v+Math.imul(h0,e0)|0,b=b+Math.imul(p0,z)|0,c=c+Math.imul(p0,r0)|0,c=c+Math.imul(u0,z)|0,v=v+Math.imul(u0,r0)|0,b=b+Math.imul(d0,n0)|0,c=c+Math.imul(d0,o0)|0,c=c+Math.imul(x0,n0)|0,v=v+Math.imul(x0,o0)|0,b=b+Math.imul(i0,I0)|0,c=c+Math.imul(i0,P0)|0,c=c+Math.imul(c0,I0)|0,v=v+Math.imul(c0,P0)|0;var se=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(se>>>26)|0,se&=67108863,b=Math.imul(A0,N0),c=Math.imul(A0,M0),c=c+Math.imul(g0,N0)|0,v=Math.imul(g0,M0),b=b+Math.imul(E0,$0)|0,c=c+Math.imul(E0,y0)|0,c=c+Math.imul(m0,$0)|0,v=v+Math.imul(m0,y0)|0,b=b+Math.imul(v0,Z)|0,c=c+Math.imul(v0,e0)|0,c=c+Math.imul(b0,Z)|0,v=v+Math.imul(b0,e0)|0,b=b+Math.imul(l0,z)|0,c=c+Math.imul(l0,r0)|0,c=c+Math.imul(h0,z)|0,v=v+Math.imul(h0,r0)|0,b=b+Math.imul(p0,n0)|0,c=c+Math.imul(p0,o0)|0,c=c+Math.imul(u0,n0)|0,v=v+Math.imul(u0,o0)|0,b=b+Math.imul(d0,I0)|0,c=c+Math.imul(d0,P0)|0,c=c+Math.imul(x0,I0)|0,v=v+Math.imul(x0,P0)|0;var ce=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(ce>>>26)|0,ce&=67108863,b=Math.imul(A0,$0),c=Math.imul(A0,y0),c=c+Math.imul(g0,$0)|0,v=Math.imul(g0,y0),b=b+Math.imul(E0,Z)|0,c=c+Math.imul(E0,e0)|0,c=c+Math.imul(m0,Z)|0,v=v+Math.imul(m0,e0)|0,b=b+Math.imul(v0,z)|0,c=c+Math.imul(v0,r0)|0,c=c+Math.imul(b0,z)|0,v=v+Math.imul(b0,r0)|0,b=b+Math.imul(l0,n0)|0,c=c+Math.imul(l0,o0)|0,c=c+Math.imul(h0,n0)|0,v=v+Math.imul(h0,o0)|0,b=b+Math.imul(p0,I0)|0,c=c+Math.imul(p0,P0)|0,c=c+Math.imul(u0,I0)|0,v=v+Math.imul(u0,P0)|0;var oe=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(oe>>>26)|0,oe&=67108863,b=Math.imul(A0,Z),c=Math.imul(A0,e0),c=c+Math.imul(g0,Z)|0,v=Math.imul(g0,e0),b=b+Math.imul(E0,z)|0,c=c+Math.imul(E0,r0)|0,c=c+Math.imul(m0,z)|0,v=v+Math.imul(m0,r0)|0,b=b+Math.imul(v0,n0)|0,c=c+Math.imul(v0,o0)|0,c=c+Math.imul(b0,n0)|0,v=v+Math.imul(b0,o0)|0,b=b+Math.imul(l0,I0)|0,c=c+Math.imul(l0,P0)|0,c=c+Math.imul(h0,I0)|0,v=v+Math.imul(h0,P0)|0;var K0=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(K0>>>26)|0,K0&=67108863,b=Math.imul(A0,z),c=Math.imul(A0,r0),c=c+Math.imul(g0,z)|0,v=Math.imul(g0,r0),b=b+Math.imul(E0,n0)|0,c=c+Math.imul(E0,o0)|0,c=c+Math.imul(m0,n0)|0,v=v+Math.imul(m0,o0)|0,b=b+Math.imul(v0,I0)|0,c=c+Math.imul(v0,P0)|0,c=c+Math.imul(b0,I0)|0,v=v+Math.imul(b0,P0)|0;var V0=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(V0>>>26)|0,V0&=67108863,b=Math.imul(A0,n0),c=Math.imul(A0,o0),c=c+Math.imul(g0,n0)|0,v=Math.imul(g0,o0),b=b+Math.imul(E0,I0)|0,c=c+Math.imul(E0,P0)|0,c=c+Math.imul(m0,I0)|0,v=v+Math.imul(m0,P0)|0;var ee=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(ee>>>26)|0,ee&=67108863,b=Math.imul(A0,I0),c=Math.imul(A0,P0),c=c+Math.imul(g0,I0)|0,v=Math.imul(g0,P0);var Q0=(g+b|0)+((c&8191)<<13)|0;return g=(v+(c>>>13)|0)+(Q0>>>26)|0,Q0&=67108863,u[0]=Ce,u[1]=ie,u[2]=ve,u[3]=me,u[4]=xe,u[5]=Ee,u[6]=Ae,u[7]=we,u[8]=Se,u[9]=de,u[10]=ue,u[11]=fe,u[12]=se,u[13]=ce,u[14]=oe,u[15]=K0,u[16]=V0,u[17]=ee,u[18]=Q0,g!==0&&(u[19]=g,d.length++),d};Math.imul||(N=H);function $(s,i,o){o.negative=i.negative^s.negative,o.length=s.length+i.length;for(var d=0,h=0,x=0;x>>26)|0,h+=u>>>26,u&=67108863}o.words[x]=g,d=u,u=h}return d!==0?o.words[x]=d:o.length--,o._strip()}function R(s,i,o){return $(s,i,o)}n.prototype.mulTo=function(i,o){var d,h=this.length+i.length;return this.length===10&&i.length===10?d=N(this,i,o):h<63?d=H(this,i,o):h<1024?d=$(this,i,o):d=R(this,i,o),d},n.prototype.mul=function(i){var o=new n(null);return o.words=new Array(this.length+i.length),this.mulTo(i,o)},n.prototype.mulf=function(i){var o=new n(null);return o.words=new Array(this.length+i.length),R(this,i,o)},n.prototype.imul=function(i){return this.clone().mulTo(i,this)},n.prototype.imuln=function(i){var o=i<0;o&&(i=-i),a(typeof i=="number"),a(i<67108864);for(var d=0,h=0;h>=26,d+=x/67108864|0,d+=u>>>26,this.words[h]=u&67108863}return d!==0&&(this.words[h]=d,this.length++),o?this.ineg():this},n.prototype.muln=function(i){return this.clone().imuln(i)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(i){var o=O(i);if(o.length===0)return new n(1);for(var d=this,h=0;h=0);var o=i%26,d=(i-o)/26,h=67108863>>>26-o<<26-o,x;if(o!==0){var u=0;for(x=0;x>>26-o}u&&(this.words[x]=u,this.length++)}if(d!==0){for(x=this.length-1;x>=0;x--)this.words[x+d]=this.words[x];for(x=0;x=0);var h;o?h=(o-o%26)/26:h=0;var x=i%26,u=Math.min((i-x)/26,this.length),g=67108863^67108863>>>x<u)for(this.length-=u,c=0;c=0&&(v!==0||c>=h);c--){var F=this.words[c]|0;this.words[c]=v<<26-x|F>>>x,v=F&g}return b&&v!==0&&(b.words[b.length++]=v),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(i,o,d){return a(this.negative===0),this.iushrn(i,o,d)},n.prototype.shln=function(i){return this.clone().ishln(i)},n.prototype.ushln=function(i){return this.clone().iushln(i)},n.prototype.shrn=function(i){return this.clone().ishrn(i)},n.prototype.ushrn=function(i){return this.clone().iushrn(i)},n.prototype.testn=function(i){a(typeof i=="number"&&i>=0);var o=i%26,d=(i-o)/26,h=1<=0);var o=i%26,d=(i-o)/26;if(a(this.negative===0,"imaskn works only with positive numbers"),this.length<=d)return this;if(o!==0&&d++,this.length=Math.min(d,this.length),o!==0){var h=67108863^67108863>>>o<=67108864;o++)this.words[o]-=67108864,o===this.length-1?this.words[o+1]=1:this.words[o+1]++;return this.length=Math.max(this.length,o+1),this},n.prototype.isubn=function(i){if(a(typeof i=="number"),a(i<67108864),i<0)return this.iaddn(-i);if(this.negative!==0)return this.negative=0,this.iaddn(i),this.negative=1,this;if(this.words[0]-=i,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var o=0;o>26)-(b/67108864|0),this.words[x+d]=u&67108863}for(;x>26,this.words[x+d]=u&67108863;if(g===0)return this._strip();for(a(g===-1),g=0,x=0;x>26,this.words[x]=u&67108863;return this.negative=1,this._strip()},n.prototype._wordDiv=function(i,o){var d=this.length-i.length,h=this.clone(),x=i,u=x.words[x.length-1]|0,g=this._countBits(u);d=26-g,d!==0&&(x=x.ushln(d),h.iushln(d),u=x.words[x.length-1]|0);var b=h.length-x.length,c;if(o!=="mod"){c=new n(null),c.length=b+1,c.words=new Array(c.length);for(var v=0;v=0;C--){var L=(h.words[x.length+C]|0)*67108864+(h.words[x.length+C-1]|0);for(L=Math.min(L/u|0,67108863),h._ishlnsubmul(x,L,C);h.negative!==0;)L--,h.negative=0,h._ishlnsubmul(x,1,C),h.isZero()||(h.negative^=1);c&&(c.words[C]=L)}return c&&c._strip(),h._strip(),o!=="div"&&d!==0&&h.iushrn(d),{div:c||null,mod:h}},n.prototype.divmod=function(i,o,d){if(a(!i.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var h,x,u;return this.negative!==0&&i.negative===0?(u=this.neg().divmod(i,o),o!=="mod"&&(h=u.div.neg()),o!=="div"&&(x=u.mod.neg(),d&&x.negative!==0&&x.iadd(i)),{div:h,mod:x}):this.negative===0&&i.negative!==0?(u=this.divmod(i.neg(),o),o!=="mod"&&(h=u.div.neg()),{div:h,mod:u.mod}):this.negative&i.negative?(u=this.neg().divmod(i.neg(),o),o!=="div"&&(x=u.mod.neg(),d&&x.negative!==0&&x.isub(i)),{div:u.div,mod:x}):i.length>this.length||this.cmp(i)<0?{div:new n(0),mod:this}:i.length===1?o==="div"?{div:this.divn(i.words[0]),mod:null}:o==="mod"?{div:null,mod:new n(this.modrn(i.words[0]))}:{div:this.divn(i.words[0]),mod:new n(this.modrn(i.words[0]))}:this._wordDiv(i,o)},n.prototype.div=function(i){return this.divmod(i,"div",!1).div},n.prototype.mod=function(i){return this.divmod(i,"mod",!1).mod},n.prototype.umod=function(i){return this.divmod(i,"mod",!0).mod},n.prototype.divRound=function(i){var o=this.divmod(i);if(o.mod.isZero())return o.div;var d=o.div.negative!==0?o.mod.isub(i):o.mod,h=i.ushrn(1),x=i.andln(1),u=d.cmp(h);return u<0||x===1&&u===0?o.div:o.div.negative!==0?o.div.isubn(1):o.div.iaddn(1)},n.prototype.modrn=function(i){var o=i<0;o&&(i=-i),a(i<=67108863);for(var d=(1<<26)%i,h=0,x=this.length-1;x>=0;x--)h=(d*h+(this.words[x]|0))%i;return o?-h:h},n.prototype.modn=function(i){return this.modrn(i)},n.prototype.idivn=function(i){var o=i<0;o&&(i=-i),a(i<=67108863);for(var d=0,h=this.length-1;h>=0;h--){var x=(this.words[h]|0)+d*67108864;this.words[h]=x/i|0,d=x%i}return this._strip(),o?this.ineg():this},n.prototype.divn=function(i){return this.clone().idivn(i)},n.prototype.egcd=function(i){a(i.negative===0),a(!i.isZero());var o=this,d=i.clone();o.negative!==0?o=o.umod(i):o=o.clone();for(var h=new n(1),x=new n(0),u=new n(0),g=new n(1),b=0;o.isEven()&&d.isEven();)o.iushrn(1),d.iushrn(1),++b;for(var c=d.clone(),v=o.clone();!o.isZero();){for(var F=0,C=1;!(o.words[0]&C)&&F<26;++F,C<<=1);if(F>0)for(o.iushrn(F);F-- >0;)(h.isOdd()||x.isOdd())&&(h.iadd(c),x.isub(v)),h.iushrn(1),x.iushrn(1);for(var L=0,G=1;!(d.words[0]&G)&&L<26;++L,G<<=1);if(L>0)for(d.iushrn(L);L-- >0;)(u.isOdd()||g.isOdd())&&(u.iadd(c),g.isub(v)),u.iushrn(1),g.iushrn(1);o.cmp(d)>=0?(o.isub(d),h.isub(u),x.isub(g)):(d.isub(o),u.isub(h),g.isub(x))}return{a:u,b:g,gcd:d.iushln(b)}},n.prototype._invmp=function(i){a(i.negative===0),a(!i.isZero());var o=this,d=i.clone();o.negative!==0?o=o.umod(i):o=o.clone();for(var h=new n(1),x=new n(0),u=d.clone();o.cmpn(1)>0&&d.cmpn(1)>0;){for(var g=0,b=1;!(o.words[0]&b)&&g<26;++g,b<<=1);if(g>0)for(o.iushrn(g);g-- >0;)h.isOdd()&&h.iadd(u),h.iushrn(1);for(var c=0,v=1;!(d.words[0]&v)&&c<26;++c,v<<=1);if(c>0)for(d.iushrn(c);c-- >0;)x.isOdd()&&x.iadd(u),x.iushrn(1);o.cmp(d)>=0?(o.isub(d),h.isub(x)):(d.isub(o),x.isub(h))}var F;return o.cmpn(1)===0?F=h:F=x,F.cmpn(0)<0&&F.iadd(i),F},n.prototype.gcd=function(i){if(this.isZero())return i.abs();if(i.isZero())return this.abs();var o=this.clone(),d=i.clone();o.negative=0,d.negative=0;for(var h=0;o.isEven()&&d.isEven();h++)o.iushrn(1),d.iushrn(1);do{for(;o.isEven();)o.iushrn(1);for(;d.isEven();)d.iushrn(1);var x=o.cmp(d);if(x<0){var u=o;o=d,d=u}else if(x===0||d.cmpn(1)===0)break;o.isub(d)}while(!0);return d.iushln(h)},n.prototype.invm=function(i){return this.egcd(i).a.umod(i)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(i){return this.words[0]&i},n.prototype.bincn=function(i){a(typeof i=="number");var o=i%26,d=(i-o)/26,h=1<>>26,g&=67108863,this.words[u]=g}return x!==0&&(this.words[u]=x,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(i){var o=i<0;if(this.negative!==0&&!o)return-1;if(this.negative===0&&o)return 1;this._strip();var d;if(this.length>1)d=1;else{o&&(i=-i),a(i<=67108863,"Number is too big");var h=this.words[0]|0;d=h===i?0:hi.length)return 1;if(this.length=0;d--){var h=this.words[d]|0,x=i.words[d]|0;if(h!==x){hx&&(o=1);break}}return o},n.prototype.gtn=function(i){return this.cmpn(i)===1},n.prototype.gt=function(i){return this.cmp(i)===1},n.prototype.gten=function(i){return this.cmpn(i)>=0},n.prototype.gte=function(i){return this.cmp(i)>=0},n.prototype.ltn=function(i){return this.cmpn(i)===-1},n.prototype.lt=function(i){return this.cmp(i)===-1},n.prototype.lten=function(i){return this.cmpn(i)<=0},n.prototype.lte=function(i){return this.cmp(i)<=0},n.prototype.eqn=function(i){return this.cmpn(i)===0},n.prototype.eq=function(i){return this.cmp(i)===0},n.red=function(i){return new p(i)},n.prototype.toRed=function(i){return a(!this.red,"Already a number in reduction context"),a(this.negative===0,"red works only with positives"),i.convertTo(this)._forceRed(i)},n.prototype.fromRed=function(){return a(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(i){return this.red=i,this},n.prototype.forceRed=function(i){return a(!this.red,"Already a number in reduction context"),this._forceRed(i)},n.prototype.redAdd=function(i){return a(this.red,"redAdd works only with red numbers"),this.red.add(this,i)},n.prototype.redIAdd=function(i){return a(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,i)},n.prototype.redSub=function(i){return a(this.red,"redSub works only with red numbers"),this.red.sub(this,i)},n.prototype.redISub=function(i){return a(this.red,"redISub works only with red numbers"),this.red.isub(this,i)},n.prototype.redShl=function(i){return a(this.red,"redShl works only with red numbers"),this.red.shl(this,i)},n.prototype.redMul=function(i){return a(this.red,"redMul works only with red numbers"),this.red._verify2(this,i),this.red.mul(this,i)},n.prototype.redIMul=function(i){return a(this.red,"redMul works only with red numbers"),this.red._verify2(this,i),this.red.imul(this,i)},n.prototype.redSqr=function(){return a(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return a(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return a(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return a(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return a(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(i){return a(this.red&&!i.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,i)};var q={k256:null,p224:null,p192:null,p25519:null};function U(s,i){this.name=s,this.p=new n(i,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}U.prototype._tmp=function(){var i=new n(null);return i.words=new Array(Math.ceil(this.n/13)),i},U.prototype.ireduce=function(i){var o=i,d;do this.split(o,this.tmp),o=this.imulK(o),o=o.iadd(this.tmp),d=o.bitLength();while(d>this.n);var h=d0?o.isub(this.p):o.strip!==void 0?o.strip():o._strip(),o},U.prototype.split=function(i,o){i.iushrn(this.n,0,o)},U.prototype.imulK=function(i){return i.imul(this.k)};function D(){U.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}f(D,U),D.prototype.split=function(i,o){for(var d=4194303,h=Math.min(i.length,9),x=0;x>>22,u=g}u>>>=22,i.words[x-10]=u,u===0&&i.length>10?i.length-=10:i.length-=9},D.prototype.imulK=function(i){i.words[i.length]=0,i.words[i.length+1]=0,i.length+=2;for(var o=0,d=0;d>>=26,i.words[d]=x,o=h}return o!==0&&(i.words[i.length++]=o),i},n._prime=function(i){if(q[i])return q[i];var o;if(i==="k256")o=new D;else if(i==="p224")o=new j;else if(i==="p192")o=new t0;else if(i==="p25519")o=new T;else throw new Error("Unknown prime "+i);return q[i]=o,o};function p(s){if(typeof s=="string"){var i=n._prime(s);this.m=i.p,this.prime=i}else a(s.gtn(1),"modulus must be greater than 1"),this.m=s,this.prime=null}p.prototype._verify1=function(i){a(i.negative===0,"red works only with positives"),a(i.red,"red works only with red numbers")},p.prototype._verify2=function(i,o){a((i.negative|o.negative)===0,"red works only with positives"),a(i.red&&i.red===o.red,"red works only with red numbers")},p.prototype.imod=function(i){return this.prime?this.prime.ireduce(i)._forceRed(this):(E(i,i.umod(this.m)._forceRed(this)),i)},p.prototype.neg=function(i){return i.isZero()?i.clone():this.m.sub(i)._forceRed(this)},p.prototype.add=function(i,o){this._verify2(i,o);var d=i.add(o);return d.cmp(this.m)>=0&&d.isub(this.m),d._forceRed(this)},p.prototype.iadd=function(i,o){this._verify2(i,o);var d=i.iadd(o);return d.cmp(this.m)>=0&&d.isub(this.m),d},p.prototype.sub=function(i,o){this._verify2(i,o);var d=i.sub(o);return d.cmpn(0)<0&&d.iadd(this.m),d._forceRed(this)},p.prototype.isub=function(i,o){this._verify2(i,o);var d=i.isub(o);return d.cmpn(0)<0&&d.iadd(this.m),d},p.prototype.shl=function(i,o){return this._verify1(i),this.imod(i.ushln(o))},p.prototype.imul=function(i,o){return this._verify2(i,o),this.imod(i.imul(o))},p.prototype.mul=function(i,o){return this._verify2(i,o),this.imod(i.mul(o))},p.prototype.isqr=function(i){return this.imul(i,i.clone())},p.prototype.sqr=function(i){return this.mul(i,i)},p.prototype.sqrt=function(i){if(i.isZero())return i.clone();var o=this.m.andln(3);if(a(o%2===1),o===3){var d=this.m.add(new n(1)).iushrn(2);return this.pow(i,d)}for(var h=this.m.subn(1),x=0;!h.isZero()&&h.andln(1)===0;)x++,h.iushrn(1);a(!h.isZero());var u=new n(1).toRed(this),g=u.redNeg(),b=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new n(2*c*c).toRed(this);this.pow(c,b).cmp(g)!==0;)c.redIAdd(g);for(var v=this.pow(c,h),F=this.pow(i,h.addn(1).iushrn(1)),C=this.pow(i,h),L=x;C.cmp(u)!==0;){for(var G=C,V=0;G.cmp(u)!==0;V++)G=G.redSqr();a(V=0;x--){for(var v=o.words[x],F=c-1;F>=0;F--){var C=v>>F&1;if(u!==h[0]&&(u=this.sqr(u)),C===0&&g===0){b=0;continue}g<<=1,g|=C,b++,!(b!==d&&(x!==0||F!==0))&&(u=this.mul(u,h[g]),b=0,g=0)}c=26}return u},p.prototype.convertTo=function(i){var o=i.umod(this.m);return o===i?o.clone():o},p.prototype.convertFrom=function(i){var o=i.clone();return o.red=null,o},n.mont=function(i){return new w(i)};function w(s){p.call(this,s),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}f(w,p),w.prototype.convertTo=function(i){return this.imod(i.ushln(this.shift))},w.prototype.convertFrom=function(i){var o=this.imod(i.mul(this.rinv));return o.red=null,o},w.prototype.imul=function(i,o){if(i.isZero()||o.isZero())return i.words[0]=0,i.length=1,i;var d=i.imul(o),h=d.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),x=d.isub(h).iushrn(this.shift),u=x;return x.cmp(this.m)>=0?u=x.isub(this.m):x.cmpn(0)<0&&(u=x.iadd(this.m)),u._forceRed(this)},w.prototype.mul=function(i,o){if(i.isZero()||o.isZero())return new n(0)._forceRed(this);var d=i.mul(o),h=d.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),x=d.isub(h).iushrn(this.shift),u=x;return x.cmp(this.m)>=0?u=x.isub(this.m):x.cmpn(0)<0&&(u=x.iadd(this.m)),u._forceRed(this)},w.prototype.invm=function(i){var o=this.imod(i._invmp(this.m).mul(this.r2));return o._forceRed(this)}})(t,B0)}(ig);var ey0=ig.exports,ty0=B0&&B0.__createBinding||(Object.create?function(t,e,r,a){a===void 0&&(a=r);var f=Object.getOwnPropertyDescriptor(e,r);(!f||("get"in f?!e.__esModule:f.writable||f.configurable))&&(f={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,a,f)}:function(t,e,r,a){a===void 0&&(a=r),t[a]=e[r]}),ry0=B0&&B0.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),ay0=B0&&B0.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&ty0(e,t,r);return ry0(e,t),e},iy0=B0&&B0.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Zi,"__esModule",{value:!0}),Zi.rlp=Zi.BN=void 0;var ny0=iy0(ey0);Zi.BN=ny0.default;var fy0=ay0(na);Zi.rlp=fy0,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.KECCAK256_RLP=t.KECCAK256_RLP_S=t.KECCAK256_RLP_ARRAY=t.KECCAK256_RLP_ARRAY_S=t.KECCAK256_NULL=t.KECCAK256_NULL_S=t.TWO_POW256=t.MAX_INTEGER=t.MAX_UINT64=void 0;var e=It,r=Zi;t.MAX_UINT64=new r.BN("ffffffffffffffff",16),t.MAX_INTEGER=new r.BN("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16),t.TWO_POW256=new r.BN("10000000000000000000000000000000000000000000000000000000000000000",16),t.KECCAK256_NULL_S="c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",t.KECCAK256_NULL=e.Buffer.from(t.KECCAK256_NULL_S,"hex"),t.KECCAK256_RLP_ARRAY_S="1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",t.KECCAK256_RLP_ARRAY=e.Buffer.from(t.KECCAK256_RLP_ARRAY_S,"hex"),t.KECCAK256_RLP_S="56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",t.KECCAK256_RLP=e.Buffer.from(t.KECCAK256_RLP_S,"hex")}(ag);var ng={},sr={};Object.defineProperty(sr,"__esModule",{value:!0}),sr.isHexString=sr.getKeys=sr.fromAscii=sr.fromUtf8=sr.toAscii=sr.arrayContainsArray=sr.getBinarySize=sr.padToEven=sr.stripHexPrefix=sr.isHexPrefixed=void 0;function MN(t){if(typeof t!="string")throw new Error("[isHexPrefixed] input must be type 'string', received type ".concat(typeof t));return t[0]==="0"&&t[1]==="x"}sr.isHexPrefixed=MN;var cy0=function(t){if(typeof t!="string")throw new Error("[stripHexPrefix] input must be type 'string', received ".concat(typeof t));return MN(t)?t.slice(2):t};sr.stripHexPrefix=cy0;function EN(t){var e=t;if(typeof e!="string")throw new Error("[padToEven] value must be type 'string', received ".concat(typeof e));return e.length%2&&(e="0".concat(e)),e}sr.padToEven=EN;function oy0(t){if(typeof t!="string")throw new Error("[getBinarySize] method requires input type 'string', recieved ".concat(typeof t));return Q.byteLength(t,"utf8")}sr.getBinarySize=oy0;function dy0(t,e,r){if(Array.isArray(t)!==!0)throw new Error("[arrayContainsArray] method requires input 'superset' to be an array, got type '".concat(typeof t,"'"));if(Array.isArray(e)!==!0)throw new Error("[arrayContainsArray] method requires input 'subset' to be an array, got type '".concat(typeof e,"'"));return e[r?"some":"every"](function(a){return t.indexOf(a)>=0})}sr.arrayContainsArray=dy0;function sy0(t){var e="",r=0,a=t.length;for(t.substring(0,2)==="0x"&&(r=2);r=p.length&&(p=void 0),{value:p&&p[i++],done:!p}}};throw new TypeError(w?"Object is not iterable.":"Symbol.iterator is not defined.")},r=B0&&B0.__read||function(p,w){var s=typeof Symbol=="function"&&p[Symbol.iterator];if(!s)return p;var i=s.call(p),o,d=[],h;try{for(;(w===void 0||w-- >0)&&!(o=i.next()).done;)d.push(o.value)}catch(x){h={error:x}}finally{try{o&&!o.done&&(s=i.return)&&s.call(i)}finally{if(h)throw h.error}}return d};Object.defineProperty(t,"__esModule",{value:!0}),t.bufArrToArr=t.arrToBufArr=t.validateNoLeadingZeroes=t.baToJSON=t.toUtf8=t.addHexPrefix=t.toUnsigned=t.fromSigned=t.bufferToHex=t.bufferToInt=t.toBuffer=t.unpadHexString=t.unpadArray=t.unpadBuffer=t.setLengthRight=t.setLengthLeft=t.zeros=t.intToBuffer=t.intToHex=void 0;var a=Zi,f=sr,n=An,l=function(p){if(!Number.isSafeInteger(p)||p<0)throw new Error("Received an invalid integer type: ".concat(p));return"0x".concat(p.toString(16))};t.intToHex=l;var m=function(p){var w=(0,t.intToHex)(p);return Q.from((0,f.padToEven)(w.slice(2)),"hex")};t.intToBuffer=m;var y=function(p){return Q.allocUnsafe(p).fill(0)};t.zeros=y;var _=function(p,w,s){var i=(0,t.zeros)(w);return s?p.length0&&w.toString()==="0";)p=p.slice(1),w=p[0];return p},P=function(p){return(0,n.assertIsBuffer)(p),k(p)};t.unpadBuffer=P;var B=function(p){return(0,n.assertIsArray)(p),k(p)};t.unpadArray=B;var I=function(p){return(0,n.assertIsHexString)(p),p=(0,f.stripHexPrefix)(p),k(p)};t.unpadHexString=I;var O=function(p){if(p==null)return Q.allocUnsafe(0);if(Q.isBuffer(p)||Array.isArray(p)||p instanceof Uint8Array)return Q.from(p);if(typeof p=="string"){if(!(0,f.isHexString)(p))throw new Error("Cannot convert string to buffer. toBuffer only supports 0x-prefixed hex strings and this string was given: ".concat(p));return Q.from((0,f.padToEven)((0,f.stripHexPrefix)(p)),"hex")}if(typeof p=="number")return(0,t.intToBuffer)(p);if(a.BN.isBN(p)){if(p.isNeg())throw new Error("Cannot convert negative BN to buffer. Given: ".concat(p));return p.toArrayLike(Q)}if(p.toArray)return Q.from(p.toArray());if(p.toBuffer)return Q.from(p.toBuffer());throw new Error("invalid type")};t.toBuffer=O;var H=function(p){return new a.BN((0,t.toBuffer)(p)).toNumber()};t.bufferToInt=H;var N=function(p){return p=(0,t.toBuffer)(p),"0x"+p.toString("hex")};t.bufferToHex=N;var $=function(p){return new a.BN(p).fromTwos(256)};t.fromSigned=$;var R=function(p){return Q.from(p.toTwos(256).toArray())};t.toUnsigned=R;var q=function(p){return typeof p!="string"||(0,f.isHexPrefixed)(p)?p:"0x"+p};t.addHexPrefix=q;var U=function(p){var w=/^(00)+|(00)+$/g;if(p=(0,f.stripHexPrefix)(p),p.length%2!==0)throw new Error("Invalid non-even hex string input for toUtf8() provided");var s=Q.from(p.replace(w,""),"hex");return s.toString("utf8")};t.toUtf8=U;var D=function(p){if(Q.isBuffer(p))return"0x".concat(p.toString("hex"));if(p instanceof Array){for(var w=[],s=0;s0&&x[0]===0)throw new Error("".concat(h," cannot have leading zeroes, received: ").concat(x.toString("hex")))}}catch(u){w={error:u}}finally{try{o&&!o.done&&(s=i.return)&&s.call(i)}finally{if(w)throw w.error}}};t.validateNoLeadingZeroes=j;function t0(p){return Array.isArray(p)?p.map(function(w){return t0(w)}):Q.from(p)}t.arrToBufArr=t0;function T(p){return Array.isArray(p)?p.map(function(w){return T(w)}):Uint8Array.from(p??[])}t.bufArrToArr=T}(Po);var ch={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.rlphash=t.ripemd160FromArray=t.ripemd160FromString=t.ripemd160=t.sha256FromArray=t.sha256FromString=t.sha256=t.keccakFromArray=t.keccakFromHexString=t.keccakFromString=t.keccak256=t.keccak=void 0;var e=an,r=bi,a=Zi,f=Po,n=An,l=function(R,q){switch(q===void 0&&(q=256),(0,n.assertIsBuffer)(R),q){case 224:return(0,e.keccak224)(R);case 256:return(0,e.keccak256)(R);case 384:return(0,e.keccak384)(R);case 512:return(0,e.keccak512)(R);default:throw new Error("Invald algorithm: keccak".concat(q))}};t.keccak=l;var m=function(R){return(0,t.keccak)(R)};t.keccak256=m;var y=function(R,q){q===void 0&&(q=256),(0,n.assertIsString)(R);var U=Q.from(R,"utf8");return(0,t.keccak)(U,q)};t.keccakFromString=y;var _=function(R,q){return q===void 0&&(q=256),(0,n.assertIsHexString)(R),(0,t.keccak)((0,f.toBuffer)(R),q)};t.keccakFromHexString=_;var E=function(R,q){return q===void 0&&(q=256),(0,n.assertIsArray)(R),(0,t.keccak)((0,f.toBuffer)(R),q)};t.keccakFromArray=E;var A=function(R){return R=(0,f.toBuffer)(R),r("sha256").update(R).digest()},k=function(R){return(0,n.assertIsBuffer)(R),A(R)};t.sha256=k;var P=function(R){return(0,n.assertIsString)(R),A(R)};t.sha256FromString=P;var B=function(R){return(0,n.assertIsArray)(R),A(R)};t.sha256FromArray=B;var I=function(R,q){R=(0,f.toBuffer)(R);var U=r("rmd160").update(R).digest();return q===!0?(0,f.setLengthLeft)(U,32):U},O=function(R,q){return(0,n.assertIsBuffer)(R),I(R,q)};t.ripemd160=O;var H=function(R,q){return(0,n.assertIsString)(R),I(R,q)};t.ripemd160FromString=H;var N=function(R,q){return(0,n.assertIsArray)(R),I(R,q)};t.ripemd160FromArray=N;var $=function(R){return(0,t.keccak)(a.rlp.encode(R))};t.rlphash=$})(ch);var oh={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.toType=t.TypeOutput=t.bnToRlp=t.bnToUnpaddedBuffer=t.bnToHex=void 0;var e=Zi,r=sr,a=Po;function f(_){return"0x".concat(_.toString(16))}t.bnToHex=f;function n(_){return(0,a.unpadBuffer)(_.toArrayLike(Q))}t.bnToUnpaddedBuffer=n;function l(_){return n(_)}t.bnToRlp=l;var m;(function(_){_[_.Number=0]="Number",_[_.BN=1]="BN",_[_.Buffer=2]="Buffer",_[_.PrefixedHexString=3]="PrefixedHexString"})(m=t.TypeOutput||(t.TypeOutput={}));function y(_,E){if(_===null)return null;if(_!==void 0){if(typeof _=="string"&&!(0,r.isHexString)(_))throw new Error("A string must be provided with a 0x-prefix, given: ".concat(_));if(typeof _=="number"&&!Number.isSafeInteger(_))throw new Error("The provided number is greater than MAX_SAFE_INTEGER (please use an alternative input type)");var A=(0,a.toBuffer)(_);if(E===m.Buffer)return A;if(E===m.BN)return new e.BN(A);if(E===m.Number){var k=new e.BN(A),P=new e.BN(Number.MAX_SAFE_INTEGER.toString());if(k.gt(P))throw new Error("The provided number is greater than MAX_SAFE_INTEGER (please use an alternative output type)");return k.toNumber()}else return"0x".concat(A.toString("hex"))}}t.toType=y})(oh),function(t){var e=B0&&B0.__read||function(T,p){var w=typeof Symbol=="function"&&T[Symbol.iterator];if(!w)return T;var s=w.call(T),i,o=[],d;try{for(;(p===void 0||p-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(h){d={error:h}}finally{try{i&&!i.done&&(w=s.return)&&w.call(s)}finally{if(d)throw d.error}}return o},r=B0&&B0.__importDefault||function(T){return T&&T.__esModule?T:{default:T}};Object.defineProperty(t,"__esModule",{value:!0}),t.isZeroAddress=t.zeroAddress=t.importPublic=t.privateToAddress=t.privateToPublic=t.publicToAddress=t.pubToAddress=t.isValidPublic=t.isValidPrivate=t.generateAddress2=t.generateAddress=t.isValidChecksumAddress=t.toChecksumAddress=t.isValidAddress=t.Account=void 0;var a=r(Ur),f=Zi,n=Pi,l=sr,m=ag,y=Po,_=ch,E=An,A=oh,k=function(){function T(p,w,s,i){p===void 0&&(p=new f.BN(0)),w===void 0&&(w=new f.BN(0)),s===void 0&&(s=m.KECCAK256_RLP),i===void 0&&(i=m.KECCAK256_NULL),this.nonce=p,this.balance=w,this.stateRoot=s,this.codeHash=i,this._validate()}return T.fromAccountData=function(p){var w=p.nonce,s=p.balance,i=p.stateRoot,o=p.codeHash;return new T(w?new f.BN((0,y.toBuffer)(w)):void 0,s?new f.BN((0,y.toBuffer)(s)):void 0,i?(0,y.toBuffer)(i):void 0,o?(0,y.toBuffer)(o):void 0)},T.fromRlpSerializedAccount=function(p){var w=f.rlp.decode(p);if(!Array.isArray(w))throw new Error("Invalid serialized account input. Must be array");return this.fromValuesArray(w)},T.fromValuesArray=function(p){var w=e(p,4),s=w[0],i=w[1],o=w[2],d=w[3];return new T(new f.BN(s),new f.BN(i),o,d)},T.prototype._validate=function(){if(this.nonce.lt(new f.BN(0)))throw new Error("nonce must be greater than zero");if(this.balance.lt(new f.BN(0)))throw new Error("balance must be greater than zero");if(this.stateRoot.length!==32)throw new Error("stateRoot must have a length of 32");if(this.codeHash.length!==32)throw new Error("codeHash must have a length of 32")},T.prototype.raw=function(){return[(0,A.bnToUnpaddedBuffer)(this.nonce),(0,A.bnToUnpaddedBuffer)(this.balance),this.stateRoot,this.codeHash]},T.prototype.serialize=function(){return f.rlp.encode(this.raw())},T.prototype.isContract=function(){return!this.codeHash.equals(m.KECCAK256_NULL)},T.prototype.isEmpty=function(){return this.balance.isZero()&&this.nonce.isZero()&&this.codeHash.equals(m.KECCAK256_NULL)},T}();t.Account=k;var P=function(T){try{(0,E.assertIsString)(T)}catch{return!1}return/^0x[0-9a-fA-F]{40}$/.test(T)};t.isValidAddress=P;var B=function(T,p){(0,E.assertIsHexString)(T);var w=(0,l.stripHexPrefix)(T).toLowerCase(),s="";if(p){var i=(0,A.toType)(p,A.TypeOutput.BN);s=i.toString()+"0x"}for(var o=(0,_.keccakFromString)(s+w).toString("hex"),d="0x",h=0;h=8?d+=w[h].toUpperCase():d+=w[h];return d};t.toChecksumAddress=B;var I=function(T,p){return(0,t.isValidAddress)(T)&&(0,t.toChecksumAddress)(T,p)===T};t.isValidChecksumAddress=I;var O=function(T,p){(0,E.assertIsBuffer)(T),(0,E.assertIsBuffer)(p);var w=new f.BN(p);return w.isZero()?(0,_.rlphash)([T,null]).slice(-20):(0,_.rlphash)([T,Q.from(w.toArray())]).slice(-20)};t.generateAddress=O;var H=function(T,p,w){(0,E.assertIsBuffer)(T),(0,E.assertIsBuffer)(p),(0,E.assertIsBuffer)(w),(0,a.default)(T.length===20),(0,a.default)(p.length===32);var s=(0,_.keccak256)(Q.concat([Q.from("ff","hex"),T,p,(0,_.keccak256)(w)]));return s.slice(-20)};t.generateAddress2=H;var N=function(T){return(0,n.privateKeyVerify)(T)};t.isValidPrivate=N;var $=function(T,p){return p===void 0&&(p=!1),(0,E.assertIsBuffer)(T),T.length===64?(0,n.publicKeyVerify)(Q.concat([Q.from([4]),T])):p?(0,n.publicKeyVerify)(T):!1};t.isValidPublic=$;var R=function(T,p){return p===void 0&&(p=!1),(0,E.assertIsBuffer)(T),p&&T.length!==64&&(T=Q.from((0,n.publicKeyConvert)(T,!1).slice(1))),(0,a.default)(T.length===64),(0,_.keccak)(T).slice(-20)};t.pubToAddress=R,t.publicToAddress=t.pubToAddress;var q=function(T){return(0,E.assertIsBuffer)(T),Q.from((0,n.publicKeyCreate)(T,!1)).slice(1)};t.privateToPublic=q;var U=function(T){return(0,t.publicToAddress)((0,t.privateToPublic)(T))};t.privateToAddress=U;var D=function(T){return(0,E.assertIsBuffer)(T),T.length!==64&&(T=Q.from((0,n.publicKeyConvert)(T,!1).slice(1))),T};t.importPublic=D;var j=function(){var T=20,p=(0,y.zeros)(T);return(0,y.bufferToHex)(p)};t.zeroAddress=j;var t0=function(T){try{(0,E.assertIsString)(T)}catch{return!1}var p=(0,t.zeroAddress)();return p===T};t.isZeroAddress=t0}(ng);var dh={},yy0=B0&&B0.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(dh,"__esModule",{value:!0}),dh.Address=void 0;var bs=yy0(Ur),sh=Zi,AN=Po,I8=ng,wy0=function(){function t(e){(0,bs.default)(e.length===20,"Invalid address length"),this.buf=e}return t.zero=function(){return new t((0,AN.zeros)(20))},t.fromString=function(e){return(0,bs.default)((0,I8.isValidAddress)(e),"Invalid address"),new t((0,AN.toBuffer)(e))},t.fromPublicKey=function(e){(0,bs.default)(Q.isBuffer(e),"Public key should be Buffer");var r=(0,I8.pubToAddress)(e);return new t(r)},t.fromPrivateKey=function(e){(0,bs.default)(Q.isBuffer(e),"Private key should be Buffer");var r=(0,I8.privateToAddress)(e);return new t(r)},t.generate=function(e,r){return(0,bs.default)(sh.BN.isBN(r)),new t((0,I8.generateAddress)(e.buf,r.toArrayLike(Q)))},t.generate2=function(e,r,a){return(0,bs.default)(Q.isBuffer(r)),(0,bs.default)(Q.isBuffer(a)),new t((0,I8.generateAddress2)(e.buf,r,a))},t.prototype.equals=function(e){return this.buf.equals(e.buf)},t.prototype.isZero=function(){return this.equals(t.zero())},t.prototype.isPrecompileOrSystemAddress=function(){var e=new sh.BN(this.buf),r=new sh.BN(0),a=new sh.BN("ffff","hex");return e.gte(r)&&e.lte(a)},t.prototype.toString=function(){return"0x"+this.buf.toString("hex")},t.prototype.toBuffer=function(){return Q.from(this.buf)},t}();dh.Address=wy0;var ai={};Object.defineProperty(ai,"__esModule",{value:!0}),ai.hashPersonalMessage=ai.isValidSignature=ai.fromRpcSig=ai.toCompactSig=ai.toRpcSig=ai.ecrecover=ai.ecsign=void 0;var fg=Pi,R8=Zi,df=Po,_y0=ch,My0=An,qc=oh;function Ey0(t,e,r){var a,f,n;if(window.jsb&&window.jsb.walletSignTran){var l=t.toString("hex"),m=jsb.walletSignTran(l);if(m.indexOf("|")>=0){var y=m.split("|");m=y[0],n=parseInt(y[1])}var _=Uint8Array.from(Q.from(m,"hex"));a=Q.from(_.slice(0,32)),f=Q.from(_.slice(32,64))}else{var E=(0,fg.ecdsaSign)(t,e),A=E.signature;n=E.recid,a=Q.from(A.slice(0,32)),f=Q.from(A.slice(32,64))}if(!r||typeof r=="number"){if(r&&!Number.isSafeInteger(r))throw new Error("The provided number is greater than MAX_SAFE_INTEGER (please use an alternative input type)");var k=r?n+(r*2+35):n+27;return{r:a,s:f,v:k}}var P=(0,qc.toType)(r,qc.TypeOutput.BN),B=P.muln(2).addn(35).addn(n).toArrayLike(Q);return{r:a,s:f,v:B}}ai.ecsign=Ey0;function uh(t,e){var r=(0,qc.toType)(t,qc.TypeOutput.BN);if(r.eqn(0)||r.eqn(1))return(0,qc.toType)(t,qc.TypeOutput.BN);if(!e)return r.subn(27);var a=(0,qc.toType)(e,qc.TypeOutput.BN);return r.sub(a.muln(2).addn(35))}function bh(t){var e=new R8.BN(t);return e.eqn(0)||e.eqn(1)}var Ay0=function(t,e,r,a,f){var n=Q.concat([(0,df.setLengthLeft)(r,32),(0,df.setLengthLeft)(a,32)],64),l=uh(e,f);if(!bh(l))throw new Error("Invalid signature v value");var m=(0,fg.ecdsaRecover)(n,l.toNumber(),t);return Q.from((0,fg.publicKeyConvert)(m,!1).slice(1))};ai.ecrecover=Ay0;var Sy0=function(t,e,r,a){var f=uh(t,a);if(!bh(f))throw new Error("Invalid signature v value");return(0,df.bufferToHex)(Q.concat([(0,df.setLengthLeft)(e,32),(0,df.setLengthLeft)(r,32),(0,df.toBuffer)(t)]))};ai.toRpcSig=Sy0;var ky0=function(t,e,r,a){var f=uh(t,a);if(!bh(f))throw new Error("Invalid signature v value");var n=(0,qc.toType)(t,qc.TypeOutput.Number),l=r;return(n>28&&n%2===1||n===1||n===28)&&(l=Q.from(r),l[0]|=128),(0,df.bufferToHex)(Q.concat([(0,df.setLengthLeft)(e,32),(0,df.setLengthLeft)(l,32)]))};ai.toCompactSig=ky0;var Ty0=function(t){var e=(0,df.toBuffer)(t),r,a,f;if(e.length>=65)r=e.slice(0,32),a=e.slice(32,64),f=(0,df.bufferToInt)(e.slice(64));else if(e.length===64)r=e.slice(0,32),a=e.slice(32,64),f=(0,df.bufferToInt)(e.slice(32,33))>>7,a[0]&=127;else throw new Error("Invalid signature length");return f<27&&(f+=27),{v:f,r,s:a}};ai.fromRpcSig=Ty0;var By0=function(t,e,r,a,f){a===void 0&&(a=!0);var n=new R8.BN("7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0",16),l=new R8.BN("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",16);if(e.length!==32||r.length!==32||!bh(uh(t,f)))return!1;var m=new R8.BN(e),y=new R8.BN(r);return!(m.isZero()||m.gt(l)||y.isZero()||y.gt(l)||a&&y.cmp(n)===1)};ai.isValidSignature=By0;var Py0=function(t){(0,My0.assertIsBuffer)(t);var e=Q.from(`Ethereum Signed Message: +}`;var lt=xL(function(){return Vt(D0,ze+"return "+Pe).apply(r,z0)});if(lt.source=Pe,hw(lt))throw lt;return lt}function zP0(M){return Yt(M).toLowerCase()}function qP0(M){return Yt(M).toUpperCase()}function HP0(M,S,K){if(M=Yt(M),M&&(K||S===r))return E$(M);if(!M||!(S=Tn(S)))return M;var a0=Xf(M),s0=Xf(S),D0=A$(a0,s0),z0=S$(a0,s0)+1;return Ko(a0,D0,z0).join("")}function KP0(M,S,K){if(M=Yt(M),M&&(K||S===r))return M.slice(0,T$(M)+1);if(!M||!(S=Tn(S)))return M;var a0=Xf(M),s0=S$(a0,Xf(S))+1;return Ko(a0,0,s0).join("")}function VP0(M,S,K){if(M=Yt(M),M&&(K||S===r))return M.replace(Z,"");if(!M||!(S=Tn(S)))return M;var a0=Xf(M),s0=A$(a0,Xf(S));return Ko(a0,s0).join("")}function WP0(M,S){var K=T,a0=p;if(Br(S)){var s0="separator"in S?S.separator:s0;K="length"in S?ut(S.length):K,a0="omission"in S?Tn(S.omission):a0}M=Yt(M);var D0=M.length;if(l6(M)){var z0=Xf(M);D0=z0.length}if(K>=D0)return M;var H0=K-x6(a0);if(H0<1)return a0;var Y0=z0?Ko(z0,0,H0).join(""):M.slice(0,H0);if(s0===r)return Y0+a0;if(z0&&(H0+=Y0.length-H0),lw(s0)){if(M.slice(H0).search(s0)){var ge,ye=Y0;for(s0.global||(s0=Py(s0.source,Yt(I0.exec(s0))+"g")),s0.lastIndex=0;ge=s0.exec(ye);)var Pe=ge.index;Y0=Y0.slice(0,Pe===r?H0:Pe)}}else if(M.indexOf(Tn(s0),H0)!=H0){var De=Y0.lastIndexOf(s0);De>-1&&(Y0=Y0.slice(0,De))}return Y0+a0}function GP0(M){return M=Yt(M),M&&Ie.test(M)?M.replace(L0,MA0):M}var ZP0=_6(function(M,S,K){return M+(K?" ":"")+S.toUpperCase()}),vw=pU("toUpperCase");function lL(M,S,K){return M=Yt(M),S=K?r:S,S===r?mA0(M)?SA0(M):dA0(M):M.match(S)||[]}var xL=vt(function(M,S){try{return _a(M,r,S)}catch(K){return hw(K)?K:new rt(K)}}),YP0=j1(function(M,S){return lf(S,function(K){K=Xc(K),L1(M,K,uw(M[K],M))}),M});function JP0(M){var S=M==null?0:M.length,K=We();return M=S?Er(M,function(a0){if(typeof a0[1]!="function")throw new xf(l);return[K(a0[0]),a0[1]]}):[],vt(function(a0){for(var s0=-1;++s0x)return[];var K=b,a0=oi(M,b);S=We(S),M-=b;for(var s0=ky(a0,S);++K0||S<0)?new Ct(K):(M<0?K=K.takeRight(-M):M&&(K=K.drop(M)),S!==r&&(S=ut(S),K=S<0?K.dropRight(-S):K.take(S-M)),K)},Ct.prototype.takeRightWhile=function(M){return this.reverse().takeWhile(M).reverse()},Ct.prototype.toArray=function(){return this.take(b)},Yc(Ct.prototype,function(M,S){var K=/^(?:filter|find|map|reject)|While$/.test(S),a0=/^(?:head|last)$/.test(S),s0=w0[a0?"take"+(S=="last"?"Right":""):S],D0=a0||/^find/.test(S);s0&&(w0.prototype[S]=function(){var z0=this.__wrapped__,H0=a0?[1]:arguments,Y0=z0 instanceof Ct,ge=H0[0],ye=Y0||ft(z0),Pe=function(St){var Lt=s0.apply(w0,Lo([St],H0));return a0&&De?Lt[0]:Lt};ye&&K&&typeof ge=="function"&&ge.length!=1&&(Y0=ye=!1);var De=this.__chain__,ze=!!this.__actions__.length,Ye=D0&&!De,lt=Y0&&!ze;if(!D0&&ye){z0=lt?z0:new Ct(this);var Je=M.apply(z0,H0);return Je.__actions__.push({func:_l,args:[Pe],thisArg:r}),new pf(Je,De)}return Ye&<?M.apply(this,H0):(Je=this.thru(Pe),Ye?a0?Je.value()[0]:Je.value():Je)})}),lf(["pop","push","shift","sort","splice","unshift"],function(M){var S=Gh[M],K=/^(?:push|sort|unshift)$/.test(M)?"tap":"thru",a0=/^(?:pop|shift)$/.test(M);w0.prototype[M]=function(){var s0=arguments;if(a0&&!this.__chain__){var D0=this.value();return S.apply(ft(D0)?D0:[],s0)}return this[K](function(z0){return S.apply(ft(z0)?z0:[],s0)})}}),Yc(Ct.prototype,function(M,S){var K=w0[S];if(K){var a0=K.name+"";Qt.call(g6,a0)||(g6[a0]=[]),g6[a0].push({name:S,func:K})}}),g6[xl(r,H).name]=[{name:"wrapper",func:r}],Ct.prototype.clone=GA0,Ct.prototype.reverse=ZA0,Ct.prototype.value=YA0,w0.prototype.at=AT0,w0.prototype.chain=ST0,w0.prototype.commit=kT0,w0.prototype.next=TT0,w0.prototype.plant=PT0,w0.prototype.reverse=CT0,w0.prototype.toJSON=w0.prototype.valueOf=w0.prototype.value=IT0,w0.prototype.first=w0.prototype.head,W8&&(w0.prototype[W8]=BT0),w0},p6=kA0();Yr?((Yr.exports=p6)._=p6,xr._=p6):Ut._=p6}).call(B8)})(zm,zm.exports);var jm0=Object.defineProperty,zm0=Object.defineProperties,qm0=Object.getOwnPropertyDescriptors,eN=Object.getOwnPropertySymbols,Hm0=Object.prototype.hasOwnProperty,Km0=Object.prototype.propertyIsEnumerable,tN=(t,e,r)=>e in t?jm0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,th=(t,e)=>{for(var r in e||(e={}))Hm0.call(e,r)&&tN(t,r,e[r]);if(eN)for(var r of eN(e))Km0.call(e,r)&&tN(t,r,e[r]);return t},Vm0=(t,e)=>zm0(t,qm0(e));function t6(t,e,r){var a;const f=M90(t);return((a=e.rpcMap)==null?void 0:a[f.reference])||`${Fm0}?chainId=${f.namespace}:${f.reference}&projectId=${r}`}function us(t){return t.includes(":")?t.split(":")[1]:t}function rN(t){return t.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function Wm0(t,e){const r=Object.keys(e.namespaces).filter(f=>f.includes(t));if(!r.length)return[];const a=[];return r.forEach(f=>{const n=e.namespaces[f].accounts;a.push(...n)}),a}function Gm0(t={},e={}){const r=aN(t),a=aN(e);return zm.exports.merge(r,a)}function aN(t){var e,r,a,f;const n={};if(!J2(t))return n;for(const[l,m]of Object.entries(t)){const y=mm(l)?[l]:m.chains,_=m.methods||[],E=m.events||[],A=m.rpcMap||{},k=l8(l);n[k]=Vm0(th(th({},n[k]),m),{chains:pm(y,(e=n[k])==null?void 0:e.chains),methods:pm(_,(r=n[k])==null?void 0:r.methods),events:pm(E,(a=n[k])==null?void 0:a.events),rpcMap:th(th({},A),(f=n[k])==null?void 0:f.rpcMap)})}return n}function Zm0(t){return t.includes(":")?t.split(":")[2]:t}function Ym0(t){const e={};for(const[r,a]of Object.entries(t)){const f=a.methods||[],n=a.events||[],l=a.accounts||[],m=mm(r)?[r]:a.chains?a.chains:rN(a.accounts);e[r]={chains:m,methods:f,events:n,accounts:l}}return e}function qm(t){return typeof t=="number"?t:t.includes("0x")?parseInt(t,16):t.includes(":")?Number(t.split(":")[1]):Number(t)}const iN={},Hr=t=>iN[t],Hm=(t,e)=>{iN[t]=e};class Jm0{constructor(e){this.name="polkadot",this.namespace=e.namespace,this.events=Hr("events"),this.client=Hr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Bo.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var a;const f=us(r);e[f]=this.createHttpProvider(f,(a=this.namespace.rpcMap)==null?void 0:a[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const a=this.createHttpProvider(e,r);a&&(this.httpProviders[e]=a)}createHttpProvider(e,r){const a=r||t6(e,this.namespace,this.client.core.projectId);if(!a)throw new Error(`No RPC url provided for chainId: ${e}`);return new ko(new ss(a,Hr("disableProviderPing")))}}class Xm0{constructor(e){this.name="eip155",this.namespace=e.namespace,this.events=Hr("events"),this.client=Hr("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(parseInt(e),r),this.chainId=parseInt(e),this.events.emit(Bo.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,r){const a=r||t6(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!a)throw new Error(`No RPC url provided for chainId: ${e}`);return new ko(new ss(a,Hr("disableProviderPing")))}setHttpProvider(e,r){const a=this.createHttpProvider(e,r);a&&(this.httpProviders[e]=a)}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var a;const f=parseInt(us(r));e[f]=this.createHttpProvider(f,(a=this.namespace.rpcMap)==null?void 0:a[r])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}async handleSwitchChain(e){var r,a;let f=e.request.params?(r=e.request.params[0])==null?void 0:r.chainId:"0x0";f=f.startsWith("0x")?f:`0x${f}`;const n=parseInt(f,16);if(this.isChainApproved(n))this.setDefaultChain(`${n}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:f}]},chainId:(a=this.namespace.chains)==null?void 0:a[0]}),this.setDefaultChain(`${n}`);else throw new Error(`Failed to switch to chain 'eip155:${n}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}}class Qm0{constructor(e){this.name="solana",this.namespace=e.namespace,this.events=Hr("events"),this.client=Hr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Bo.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var a;const f=us(r);e[f]=this.createHttpProvider(f,(a=this.namespace.rpcMap)==null?void 0:a[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const a=this.createHttpProvider(e,r);a&&(this.httpProviders[e]=a)}createHttpProvider(e,r){const a=r||t6(e,this.namespace,this.client.core.projectId);if(!a)throw new Error(`No RPC url provided for chainId: ${e}`);return new ko(new ss(a,Hr("disableProviderPing")))}}class eg0{constructor(e){this.name="cosmos",this.namespace=e.namespace,this.events=Hr("events"),this.client=Hr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Bo.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var a;const f=us(r);e[f]=this.createHttpProvider(f,(a=this.namespace.rpcMap)==null?void 0:a[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const a=this.createHttpProvider(e,r);a&&(this.httpProviders[e]=a)}createHttpProvider(e,r){const a=r||t6(e,this.namespace,this.client.core.projectId);if(!a)throw new Error(`No RPC url provided for chainId: ${e}`);return new ko(new ss(a,Hr("disableProviderPing")))}}class tg0{constructor(e){this.name="cip34",this.namespace=e.namespace,this.events=Hr("events"),this.client=Hr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Bo.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{const a=this.getCardanoRPCUrl(r),f=us(r);e[f]=this.createHttpProvider(f,a)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}getCardanoRPCUrl(e){const r=this.namespace.rpcMap;if(r)return r[e]}setHttpProvider(e,r){const a=this.createHttpProvider(e,r);a&&(this.httpProviders[e]=a)}createHttpProvider(e,r){const a=r||this.getCardanoRPCUrl(e);if(!a)throw new Error(`No RPC url provided for chainId: ${e}`);return new ko(new ss(a,Hr("disableProviderPing")))}}class rg0{constructor(e){this.name="elrond",this.namespace=e.namespace,this.events=Hr("events"),this.client=Hr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Bo.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var a;const f=us(r);e[f]=this.createHttpProvider(f,(a=this.namespace.rpcMap)==null?void 0:a[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const a=this.createHttpProvider(e,r);a&&(this.httpProviders[e]=a)}createHttpProvider(e,r){const a=r||t6(e,this.namespace,this.client.core.projectId);if(!a)throw new Error(`No RPC url provided for chainId: ${e}`);return new ko(new ss(a,Hr("disableProviderPing")))}}class ag0{constructor(e){this.name="multiversx",this.namespace=e.namespace,this.events=Hr("events"),this.client=Hr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Bo.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var a;const f=us(r);e[f]=this.createHttpProvider(f,(a=this.namespace.rpcMap)==null?void 0:a[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const a=this.createHttpProvider(e,r);a&&(this.httpProviders[e]=a)}createHttpProvider(e,r){const a=r||t6(e,this.namespace,this.client.core.projectId);if(!a)throw new Error(`No RPC url provided for chainId: ${e}`);return new ko(new ss(a,Hr("disableProviderPing")))}}var ig0=Object.defineProperty,ng0=Object.defineProperties,fg0=Object.getOwnPropertyDescriptors,nN=Object.getOwnPropertySymbols,cg0=Object.prototype.hasOwnProperty,og0=Object.prototype.propertyIsEnumerable,fN=(t,e,r)=>e in t?ig0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,rh=(t,e)=>{for(var r in e||(e={}))cg0.call(e,r)&&fN(t,r,e[r]);if(nN)for(var r of nN(e))og0.call(e,r)&&fN(t,r,e[r]);return t},Km=(t,e)=>ng0(t,fg0(e));class Vm{constructor(e){this.events=new Ve,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=e,this.logger=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:Dt.pino(Dt.getDefaultLoggerOptions({level:e?.logger||XO})),this.disableProviderPing=e?.disableProviderPing||!1}static async init(e){const r=new Vm(e);return await r.initialize(),r}async request(e,r){const[a,f]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(a).request({request:rh({},e),chainId:`${a}:${f}`,topic:this.session.topic})}sendAsync(e,r,a){this.request(e,a).then(f=>r(null,f)).catch(f=>r(f,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(e=this.session)==null?void 0:e.topic,reason:zr("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}removeListener(e,r){this.events.removeListener(e,r)}off(e,r){this.events.off(e,r)}get isWalletConnect(){return!0}async pair(e){this.shouldAbortPairingAttempt=!1;let r=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(r>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:a,approval:f}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});a&&(this.uri=a,this.events.emit("display_uri",a)),await f().then(n=>{this.session=n,this.namespaces||(this.namespaces=Ym0(n.namespaces),this.persist("namespaces",this.namespaces))}).catch(n=>{if(n.message!==VO)throw n;r++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(e,r){try{if(!this.session)return;const[a,f]=this.validateChain(e);this.getProvider(a).setDefaultChain(f,r)}catch(a){if(!/Please call connect/.test(a.message))throw a}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const r=this.client.pairing.getAll();if(Lc(r)){for(const a of r)e.deletePairings?this.client.core.expirer.set(a.topic,0):await this.client.core.relayer.subscriber.unsubscribe(a.topic);this.logger.info(`Inactive pairings cleared: ${r.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const e=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[e]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await Nm0.init({logger:this.providerOpts.logger||XO,relayUrl:this.providerOpts.relayUrl||$m0,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(r=>l8(r)))];Hm("client",this.client),Hm("events",this.events),Hm("disableProviderPing",this.disableProviderPing),e.forEach(r=>{if(!this.session)return;const a=Wm0(r,this.session),f=rN(a),n=Gm0(this.namespaces,this.optionalNamespaces),l=Km(rh({},n[r]),{accounts:a,chains:f});switch(r){case"eip155":this.rpcProviders[r]=new Xm0({namespace:l});break;case"solana":this.rpcProviders[r]=new Qm0({namespace:l});break;case"cosmos":this.rpcProviders[r]=new eg0({namespace:l});break;case"polkadot":this.rpcProviders[r]=new Jm0({namespace:l});break;case"cip34":this.rpcProviders[r]=new tg0({namespace:l});break;case"elrond":this.rpcProviders[r]=new rg0({namespace:l});break;case"multiversx":this.rpcProviders[r]=new ag0({namespace:l});break}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{const{params:r}=e,{event:a}=r;if(a.name==="accountsChanged"){const f=a.data;f&&Lc(f)&&this.events.emit("accountsChanged",f.map(Zm0))}else if(a.name==="chainChanged"){const f=r.chainId,n=r.event.data,l=l8(f),m=qm(f)!==qm(n)?`${l}:${qm(n)}`:f;this.onChainChanged(m)}else this.events.emit(a.name,a.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:r})=>{var a;const{namespaces:f}=r,n=(a=this.client)==null?void 0:a.session.get(e);this.session=Km(rh({},n),{namespaces:f}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:r})}),this.client.on("session_delete",async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",Km(rh({},zr("USER_DISCONNECTED")),{data:e.topic}))}),this.on(Bo.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){if(!this.rpcProviders[e])throw new Error(`Provider not found: ${e}`);return this.rpcProviders[e]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var r;this.getProvider(e).updateNamespace((r=this.session)==null?void 0:r.namespaces[e])})}setNamespaces(e){const{namespaces:r,optionalNamespaces:a,sessionProperties:f}=e;r&&Object.keys(r).length&&(this.namespaces=r),a&&Object.keys(a).length&&(this.optionalNamespaces=a),this.sessionProperties=f,this.persist("namespaces",r),this.persist("optionalNamespaces",a)}validateChain(e){const[r,a]=e?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[r,a];if(r&&!Object.keys(this.namespaces||{}).map(l=>l8(l)).includes(r))throw new Error(`Namespace '${r}' is not configured. Please call connect() first with namespace config.`);if(r&&a)return[r,a];const f=l8(Object.keys(this.namespaces)[0]),n=this.rpcProviders[f].getDefaultChain();return[f,n]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,r=!1){var a;if(!this.namespaces)return;const[f,n]=this.validateChain(e);r||this.getProvider(f).setDefaultChain(n),((a=this.namespaces[f])!=null?a:this.namespaces[`${f}:${n}`]).defaultChain=n,this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",n)}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(e,r){this.client.core.storage.setItem(`${QO}/${e}`,r)}async getFromStore(e){return await this.client.core.storage.getItem(`${QO}/${e}`)}}const dg0=Vm,sg0="wc",ug0="ethereum_provider",bg0=`${sg0}@2:${ug0}:`,hg0="https://rpc.walletconnect.com/v1/",Wm=["eth_sendTransaction","personal_sign"],lg0=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],Gm=["chainChanged","accountsChanged"],xg0=["chainChanged","accountsChanged","message","disconnect","connect"];var pg0=Object.defineProperty,vg0=Object.defineProperties,mg0=Object.getOwnPropertyDescriptors,cN=Object.getOwnPropertySymbols,gg0=Object.prototype.hasOwnProperty,yg0=Object.prototype.propertyIsEnumerable,oN=(t,e,r)=>e in t?pg0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,P8=(t,e)=>{for(var r in e||(e={}))gg0.call(e,r)&&oN(t,r,e[r]);if(cN)for(var r of cN(e))yg0.call(e,r)&&oN(t,r,e[r]);return t},dN=(t,e)=>vg0(t,mg0(e));function ah(t){return Number(t[0].split(":")[1])}function Zm(t){return`0x${t.toString(16)}`}function wg0(t){const{chains:e,optionalChains:r,methods:a,optionalMethods:f,events:n,optionalEvents:l,rpcMap:m}=t;if(!Lc(e))throw new Error("Invalid chains");const y={chains:e,methods:a||Wm,events:n||Gm,rpcMap:P8({},e.length?{[ah(e)]:m[ah(e)]}:{})},_=n?.filter(P=>!Gm.includes(P)),E=a?.filter(P=>!Wm.includes(P));if(!r&&!l&&!f&&!(_!=null&&_.length)&&!(E!=null&&E.length))return{required:e.length?y:void 0};const A=_?.length&&E?.length||!r,k={chains:[...new Set(A?y.chains.concat(r||[]):r)],methods:[...new Set(y.methods.concat(f!=null&&f.length?f:lg0))],events:[...new Set(y.events.concat(l!=null&&l.length?l:xg0))],rpcMap:m};return{required:e.length?y:void 0,optional:r.length?k:void 0}}class Ym{constructor(){this.events=new Ve,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=bg0,this.on=(e,r)=>(this.events.on(e,r),this),this.once=(e,r)=>(this.events.once(e,r),this),this.removeListener=(e,r)=>(this.events.removeListener(e,r),this),this.off=(e,r)=>(this.events.off(e,r),this),this.parseAccount=e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e,this.signer={},this.rpc={}}static async init(e){const r=new Ym;return await r.initialize(e),r}async request(e){return await this.signer.request(e,this.formatChainId(this.chainId))}sendAsync(e,r){this.signer.sendAsync(e,r,this.formatChainId(this.chainId))}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(e){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(e);const{required:r,optional:a}=wg0(this.rpc);try{const f=await new Promise(async(l,m)=>{var y;this.rpc.showQrModal&&((y=this.modal)==null||y.subscribeModal(_=>{!_.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),m(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(dN(P8({namespaces:P8({},r&&{[this.namespace]:r})},a&&{optionalNamespaces:{[this.namespace]:a}}),{pairingTopic:e?.pairingTopic})).then(_=>{l(_)}).catch(_=>{m(new Error(_.message))})});if(!f)return;const n=E90(f.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:n),this.setAccounts(n),this.events.emit("connect",{chainId:Zm(this.chainId)})}catch(f){throw this.signer.logger.error(f),f}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",e=>{const{params:r}=e,{event:a}=r;a.name==="accountsChanged"?(this.accounts=this.parseAccounts(a.data),this.events.emit("accountsChanged",this.accounts)):a.name==="chainChanged"?this.setChainId(this.formatChainId(a.data)):this.events.emit(a.name,a.data),this.events.emit("session_event",e)}),this.signer.on("chainChanged",e=>{const r=parseInt(e);this.chainId=r,this.events.emit("chainChanged",Zm(this.chainId)),this.persist()}),this.signer.on("session_update",e=>{this.events.emit("session_update",e)}),this.signer.on("session_delete",e=>{this.reset(),this.events.emit("session_delete",e),this.events.emit("disconnect",dN(P8({},zr("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{var r,a;this.rpc.showQrModal&&((r=this.modal)==null||r.closeModal(),(a=this.modal)==null||a.openModal({uri:e})),this.events.emit("display_uri",e)})}switchEthereumChain(e){this.request({method:"wallet_switchEthereumChain",params:[{chainId:e.toString(16)}]})}isCompatibleChainId(e){return typeof e=="string"?e.startsWith(`${this.namespace}:`):!1}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){const r=e.filter(a=>this.isCompatibleChainId(a)).map(a=>this.parseChainId(a));r.length&&(this.chainId=r[0],this.events.emit("chainChanged",Zm(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){const r=this.parseChainId(e);this.chainId=r,this.switchEthereumChain(r)}}parseAccountId(e){const[r,a,f]=e.split(":");return{chainId:`${r}:${a}`,address:f}}setAccounts(e){this.accounts=e.filter(r=>this.parseChainId(this.parseAccountId(r).chainId)===this.chainId).map(r=>this.parseAccountId(r).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var r,a;const f=(r=e?.chains)!=null?r:[],n=(a=e?.optionalChains)!=null?a:[],l=f.concat(n);if(!l.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const m=f.length?e?.methods||Wm:[],y=f.length?e?.events||Gm:[],_=e?.optionalMethods||[],E=e?.optionalEvents||[],A=e?.rpcMap||this.buildRpcMap(l,e.projectId),k=e?.qrModalOptions||void 0;return{chains:f?.map(P=>this.formatChainId(P)),optionalChains:n.map(P=>this.formatChainId(P)),methods:m,events:y,optionalMethods:_,optionalEvents:E,rpcMap:A,showQrModal:!!(e!=null&&e.showQrModal),qrModalOptions:k,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,r){const a={};return e.forEach(f=>{a[f]=this.getRpcUrl(f,r)}),a}async initialize(e){if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?ah(this.rpc.chains):ah(this.rpc.optionalChains),this.signer=await dg0.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:e.disableProviderPing,relayUrl:e.relayUrl,storageOptions:e.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let r;try{const{WalletConnectModal:a}=await import("@walletconnect/modal");r=a}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(r)try{this.modal=new r(P8({walletConnectVersion:2,projectId:this.rpc.projectId,standaloneChains:this.rpc.chains},this.rpc.qrModalOptions))}catch(a){throw this.signer.logger.error(a),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(e){if(!e)return;const{chains:r,optionalChains:a,rpcMap:f}=e;r&&Lc(r)&&(this.rpc.chains=r.map(n=>this.formatChainId(n)),r.forEach(n=>{this.rpc.rpcMap[n]=f?.[n]||this.getRpcUrl(n)})),a&&Lc(a)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=a?.map(n=>this.formatChainId(n)),a.forEach(n=>{this.rpc.rpcMap[n]=f?.[n]||this.getRpcUrl(n)}))}getRpcUrl(e,r){var a;return((a=this.rpc.rpcMap)==null?void 0:a[e])||`${hg0}?chainId=eip155:${e}&projectId=${r||this.rpc.projectId}`}async loadPersistedSession(){if(!this.session)return;const e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),r=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:r?.accounts),this.setAccounts(r?.accounts)}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(e){return typeof e=="string"||e instanceof String?[this.parseAccount(e)]:e.map(r=>this.parseAccount(r))}}const _g0=Ym,Mg0="jc_wallet_data",Eg0="https://oauth-svr.cebggame.com/test",Ag0="https://wallet.cebggame.com",Kr=()=>jc.wallet.env==="dev"||jc.wallet.useWaas?Eg0:Ag0,Sg0="https://pay.cebggame.com/v2",kg0="https://pay.cebggame.com/v0",Tg0="https://www.counterfire.games/okx/okx.html",Bg0="https://www.counterfire.games/okx/okx.html",C8=()=>jc.wallet.env==="release"?Sg0:kg0,Pg0=()=>jc.wallet.env==="dev"?Tg0:Bg0,sN=6,Cg0=10,uN=6,Ig0="0x000000000000000000000000",Jm="0x0000000000000000000000000000000000000000",Rg0=[80001,421613,421614,137,42161,195],Sr=1.2,bN=1,hN="relay_token",ih="initOKXWallet",Xm="relay_aes_key",lN="encrypted",Qm="last_relay_data",xN="jcwallet_params",pN="current_wallet_address";var nh=()=>({events:{},emit(t,...e){for(let r of this.events[t]||[])r(...e)},on(t,e){return(this.events[t]=this.events[t]||[]).push(e),()=>this.events[t]=this.events[t].filter(r=>r!==e)},once(t,e){var r=(...a)=>{this.events[t]=this.events[t].filter(f=>f!==r),e(...a)};(this.events[t]=this.events[t]||[]).push(r)},listen(t,e){return(this.events[t]=this.events[t]||[]).push(e),()=>this.events[t]=this.events[t].filter(r=>r!==e)},remove(t,e){this.events[t]=this.events[t].filter(r=>r!==e)}});const Og0="wallet_chain_change",Ng0="wallet_account_change",Dg0="wallet_token_type_change";function vN(t,e){return{types:{EIP712Domain:[{name:"name",type:"string"},{name:"version",type:"string"}],set:[{name:"tips",type:"string"},{name:"nonce",type:"string"}]},primaryType:"set",domain:{name:"Auth",version:"1"},message:{tips:e,nonce:t}}}function $g0(t,e,r){const a=vN(t,e);return Zo.signTypedData({data:a,privateKey:Buffer.from(r.replace("0x",""),"hex"),version:Zo.SignTypedDataVersion.V4})}function mN(t){if(!t)return{};let e=t.split(".");if(e.length<2)return{};try{return JSON.parse(window.atob(e[1]))}catch{return{}}}function gN(t,e){if(!e)return!0;let r=mN(e);if(!r.exp)return!0;let a=Date.now()/1e3|0;return r.exp{for(var f=a>1?void 0:a?jg0(e,r):e,n=t.length-1,l;n>=0;n--)(l=t[n])&&(f=(a?l(e,r,f):l(f))||f);return a&&f&&Fg0(e,r,f),f};let oa=class{constructor(){this.handler=nh()}get tokenData(){return mN(this.token)}};oa=zg0([$c],oa);function yN(t,e,r){let a={};a["Content-Type"]="application/json";let f=new oa;!r&&f.token?a.Authorization=`Bearer ${f.token}`:r&&(a.Authorization=`Bearer ${r}`),a.api_version=bN+"",a.api_env,jc.wallet.env,a.api_platform,jc.wallet.platform;let n={method:"GET",mode:"cors",cache:"no-cache"};return Object.assign(n,e),n.headers=a,P4(t,n)}function qg0(t,e){return yN(t,{},e)}function fh(t,e){return qg0(t,e).then(r=>r.json())}function Hg0(t,e,r){let a={method:"POST",body:JSON.stringify(e)};return yN(t,a,r)}function Or(t,e,r){return Hg0(t,e,r).then(a=>a.json())}function Kg0(t){const e=`${Kr()}/trans/record`;return Or(e,t)}function wN(t){const e=`${Kr()}/trans/records`;return Or(e,t)}function Vg0(t={dedupeConcurrent:!1}){const{dedupeConcurrent:e}=t;let r=[],a,f=new eg;const n=m=>{let y=new eg;return e&&(r=[],f.started&&(f=new eg),y=f),r.push(()=>(y.started=!0,m().then(y.resolve).catch(y.reject),y.promise)),a||(a=l()),y.promise},l=async()=>{for(;r.length;)await r.shift()().catch(()=>{});a=void 0};return{push:n,flush:()=>a||Promise.resolve(),get size(){return r.length}}}let eg=class{constructor(){this.started=!1,this.resolve=()=>{},this.reject=()=>{},this.promise=new Promise((e,r)=>{this.resolve=e,this.reject=r})}};var Wg0=Object.defineProperty,Gg0=Object.getOwnPropertyDescriptor,Zg0=(t,e,r,a)=>{for(var f=a>1?void 0:a?Gg0(e,r):e,n=t.length-1,l;n>=0;n--)(l=t[n])&&(f=(a?l(e,r,f):l(f))||f);return a&&f&&Wg0(e,r,f),f};let r6=class{constructor(){this.queue=Vg0()}addLog(t){this.queue.push(async()=>{try{await Kg0(t)}catch(e){console.log("error save tx record: "),console.log(e)}})}};r6=Zg0([$c],r6);function _N(t){return"0x"+t.toString(16)}function Ia(t,e){return new Promise((r,a)=>{e.on("presend",function(f){if(jc.wallet.isInternal){console.log("before send tran: ",JSON.stringify(f));let n;!f.gasPrice&&f.maxPriorityFeePerGas&&f.maxFeePerGas?n=Lr.toBN(f.maxFeePerGas).sub(Lr.toBN(f.maxPriorityFeePerGas)).div(Lr.toBN(2)).mul(Lr.toBN(1e9)):f.gasPrice&&(n=Lr.toBN(f.gasPrice)),t.gas=Lr.toBN(f.gas).toString(),t.gasPrice=n.toString(),t.transactionHash=f.transactionHash,t.chain=jc.wallet.currentChain.id,t.startTime=Date.now(),new r6().addLog(t)}}).on("transactionHash",function(f){console.log(`remote transactionHash: ${f}`)}).on("confirmation",function(f,n){console.log(`confirmation:: confirmationNumber: ${f} , receipt: ${JSON.stringify(n)}`),jc.wallet.isInternal&&f>=uN&&(t.status=2,t.confirmTime=Date.now(),new r6().addLog(t))}).on("receipt",function(f){console.log(f),jc.wallet.isInternal&&(t.status=f.status?1:10,t.blockNumber=f.blockNumber,t.blockHash=f.blockHash,t.gas=f.gasUsed,new r6().addLog(t)),r&&r(f)}).on("error",function(f,n){console.log(f),jc.wallet.isInternal&&(t.status=11,new r6().addLog(t)),a&&a(f)})})}class Yg0{constructor(){this.accounts=[],this.socketConnected=!1,console.log("ZWalletConnect constructor")}async connect(e){return console.log("wallet connect begin init"),this.provider=await _g0.init({projectId:"e7743d46923911fa8850619b7a7f6d9d",chains:[e],showQrModal:!1,optionalChains:[e],metadata:{name:"Counter Fire",description:"Counter Fire Game",url:"https://www.counterfire.games",icons:["https://www.counterfire.games/favicon.ico"]}}),this._subscribeToEvents(),console.log("wallet connect begin connect"),this.provider.connect()}async disconnect(){this.provider&&(this.provider.removeListener("accountsChanged"),this.provider.removeListener("chainChanged"),this.provider.removeListener("disconnect"),this.provider.removeListener("display_uri"),await this.provider.disconnect())}_subscribeToEvents(){this.provider.on("accountsChanged",async e=>{console.log("on accountsChanged: ",e),this.accounts=e}),this.provider.on("chainChanged",async e=>{const r=parseInt(e);console.log("on chainChanged",e,r)}),this.provider.on("disconnect",e=>{console.log("on disconnect",e)}),this.provider.on("display_uri",e=>{jumpToWallet(e)})}async addOrChangeChain(e){return new Promise((r,a)=>{const f=l=>{console.log("switchEthereumChain: ",l),this.provider.removeListener("chainChanged",f),r&&r(l)};this.provider.on("chainChanged",f);let n={chainId:_N(e.id),chainName:e.name,nativeCurrency:{name:e.symbol,symbol:e.symbol,decimals:e.decimals||18},rpcUrls:[e.rpc],blockExplorerUrls:[e.explorerurl]};this.provider.request({method:"wallet_addEthereumChain",params:[n]}).then(()=>{console.log("add chain success, wait result")}).catch(l=>{console.error("add chain error: ",JSON.stringify(l)),this.provider.removeListener("chainChanged",f),a&&a(l)})})}async signData(e,r){const a=JSON.stringify(e),f=r||this.accounts[0];if(!f)throw new Error("no account");console.log("sending personal sign req from",f,a);const n=[f,a];return(await this.sendCmd({method:"eth_signTypedData_v4",params:n,from:f})).result}async sendCmd({method:e,params:r,from:a}){return new Promise((f,n)=>{this.provider.sendAsync({method:e,params:r,from:a},async function(l,m){if(l){n&&n(l);return}f&&f(m)})})}}const Jg0=[{name:"Ethereum Mainnet RPC",type:"Mainnet",rpc:"https://rpc.ankr.com/eth",id:1,symbol:"ETH",explorerurl:"https://etherscan.io"},{name:"Ethereum Ropsten Testnet RPC",type:"Testnet",rpc:"https://ropsten.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161",id:3,symbol:"ETH",explorerurl:"https://ropsten.etherscan.io"},{name:"Ethereum Rinkeby Testnet RPC",type:"Testnet",rpc:"https://rinkey.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161",id:4,symbol:"ETH",explorerurl:"https://rinkey.etherscan.io"},{name:"Ethereum Goerli Testnet",type:"Testnet",rpc:"https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161",id:5,symbol:"ETH",explorerurl:"https://goerli.etherscan.io"},{name:"Ethereum Kovan Testnet RPC",type:"Testnet",rpc:"https://kovan.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161",id:6,symbol:"ETH",explorerurl:"https://kovan.etherscan.io"},{name:"Ubiq Mainnet RPC",type:"Mainnet",rpc:"https://rpc.octano.dev/",id:8,symbol:"UBQ",explorerurl:"https://ubiqscan.io/"},{name:"Elastos ETH Mainnet RPC",type:"Mainnet",rpc:"https://api.elastos.io/eth",id:20,symbol:"ELA",explorerurl:"https://explorer.elaeth.io/"},{name:"Cronos Mainnet RPC",type:"Mainnet",rpc:"https://evm-cronos.crypto.org",id:25,symbol:"CRO",explorerurl:"https://cronos.crypto.org/explorer/"},{name:"Telos EVM Mainnet RPC",type:"Mainnet",rpc:"https://mainnet.telos.net/evm",id:40,symbol:"TLOS",explorerurl:"https://telos.net/"},{name:"Binance Smart Chain",type:"Mainnet",rpc:"https://rpc.ankr.com/bsc",id:56,symbol:"BNB",explorerurl:"https://bscscan.com"},{name:"OKExChain Mainnet RPC",type:"Mainnet",rpc:"https://exchainrpc.okex.org",id:66,symbol:"OKT",explorerurl:"https://www.oklink.com/okexchain"},{name:"Hoo Mainnet RPC",type:"Mainnet",rpc:"https://http-mainnet.hoosmartchain.com",id:70,symbol:"HOO",explorerurl:"https://hooscan.com"},{name:"Binance Testnet",type:"Testnet",rpc:"https://data-seed-prebsc-1-s1.binance.org:8545/",id:97,symbol:"BNB",explorerurl:"https://testnet.bscscan.com"},{name:"xDai Mainnet RPC",type:"Mainnet",rpc:"https://rpc.xdaichain.com/",id:100,symbol:"XDAI",explorerurl:"https://blockscout.com/xdai/mainnet/"},{name:"Fuse Mainnet RPC",type:"Mainnet",rpc:"https://rpc.fuse.io",id:122,symbol:"FUSE",explorerurl:"https://explorer.fuse.io/"},{name:"HECO Mainnet RPC",type:"Mainnet",rpc:"https://http-mainnet-node.huobichain.com/",id:128,symbol:"HT",explorerurl:"https://hecoinfo.com/"},{name:"Matic Mainnet RPC",type:"Mainnet",rpc:"https://polygon-rpc.com",network:"POLYGON",id:137,symbol:"MATIC",explorerurl:"https://explorer.matic.network/"},{name:"Fantom Opera Mainnet RPC",type:"Mainnet",rpc:"https://rpc.ftm.tools/",id:250,symbol:"FTM",explorerurl:"https://ftmscan.com"},{name:"HECO Testnet RPC",type:"Testnet",rpc:"https://http-testnet.hecochain.com",id:256,symbol:"HT",explorerurl:"https://testnet.hecoinfo.com/"},{name:"KCC Mainnet",type:"Mainnet",rpc:"https://rpc-mainnet.kcc.network",id:321,symbol:"KCS",explorerurl:"https://scan.kcc.network"},{name:"KCC Testnet",type:"Testnet",rpc:"https://rpc-testnet.kcc.network",id:322,symbol:"tKCS",explorerurl:"https://scan-testnet.kcc.network"},{name:"Moonriver Mainnet RPC",type:"Mainnet",rpc:"https://rpc.moonriver.moonbeam.network",id:1285,symbol:"MOVR",explorerurl:"https://blockscout.moonriver.moonbeam.network/"},{name:"Fantom Testnet RPC",type:"Testnet",rpc:"https://rpc.testnet.fantom.network/",id:4002,symbol:"FTM",explorerurl:"https://testnet.ftmscan.com"},{name:"IoTeX Mainnet RPC",type:"Mainnet",rpc:"https://babel-api.mainnet.iotex.io",id:4689,symbol:"IOTEX",explorerurl:"https://iotexscan.io/"},{name:"Nahmii Mainnet RPC",type:"Mainnet",rpc:"https://l2.nahmii.io/",id:5551,symbol:"ETH",explorerurl:"https://explorer.nahmii.io/"},{name:"Nahmii Testnet RPC",type:"Testnet",rpc:"https://l2.testnet.nahmii.io/",id:5553,symbol:"ETH",explorerurl:"https://explorer.testnet.nahmii.io/"},{name:"Arbitrum One",type:"Mainnet",rpc:"https://arb1.arbitrum.io/rpc",id:42161,network:"ARBITRUM",symbol:"ETH",explorerurl:"https://arbiscan.io/"},{name:"Arbitrum Goerli",type:"Testnet",rpc:"https://goerli-rollup.arbitrum.io/rpc",id:421613,network:"AGOR",symbol:"AGOR",explorerurl:"https://testnet.arbiscan.io"},{name:"Arbitrum Sepolia",type:"Testnet",rpc:"https://sepolia-rollup.arbitrum.io/rpc",id:421614,network:"ARBITRUM_SEPOLIA",symbol:"ETH",explorerurl:"https://sepolia.arbiscan.io"},{name:"X1 testnet",type:"Testnet",rpc:"https://testrpc.x1.tech",id:195,network:"OKB",symbol:"OKB",explorerurl:"https://www.oklink.com/cn/x1-test"},{name:"Celo Mainnet RPC",type:"Mainnet",rpc:"https://rpc.ankr.com/celo",id:42220,symbol:"CELO",explorerurl:"https://celoscan.com"},{name:"Avalanche C Chain Local RPC",type:"Testnet",rpc:"https://localhost:9650/ext/bc/C/rpc",id:43112,symbol:"AVAX",explorerurl:"https://snowtrace.io"},{name:"Avalanche FUJI Testnet RPC",type:"Testnet",rpc:"https://api.avax-test.network/ext/bc/C/rpc",id:43113,symbol:"AVAX",explorerurl:"https://testnet.explorer.avax.network/"},{name:"Avalanche C Chain Mainnet RPC",type:"Mainnet",rpc:"https://rpc.ankr.com/avalanche",id:43114,symbol:"AVAX",explorerurl:"https://snowtrace.io"},{name:"Matic Testnet RPC",type:"Testnet",rpc:"https://rpc-mumbai.maticvigil.com",id:80001,symbol:"MATIC",explorerurl:"https://mumbai.polygonscan.com/"},{name:"Harmony Mainnet RPC",type:"Mainnet",rpc:"https://api.harmony.one/",id:16666e5,symbol:"ONE",explorerurl:"https://explorer.harmony.one"},{name:"Harmony Testnet RPC",type:"Testnet",rpc:"https://api.s0.b.hmny.io/",id:16667e5,symbol:"ONE",explorerurl:"https://explorer.harmony.one"},{name:"zkSync Era Mainnet",type:"Mainnet",rpc:"https://mainnet.era.zksync.io",id:324,symbol:"ETH",explorerurl:"https://explorer.zksync.io"},{name:"zkSync Era Testnet",type:"Testnet",rpc:"https://testnet.era.zksync.dev",id:280,symbol:"ETH",explorerurl:"https://goerli.explorer.zksync.io"},{name:"Local Testnet",type:"Local",rpc:"https://login-test.kingsome.cn/rpc",id:1338,symbol:"ETH",explorerurl:"https://explorer.harmony.one"}],Xg0=/^(.+?):\/\/.+?$/;function Qg0(t){let e=t.match(Xg0);return e?e[1]:""}var tg={},rg={},ag={},Zi={},ig={exports:{}};ig.exports,function(t){(function(e,r){function a(s,i){if(!s)throw new Error(i||"Assertion failed")}function f(s,i){s.super_=i;var o=function(){};o.prototype=i.prototype,s.prototype=new o,s.prototype.constructor=s}function n(s,i,o){if(n.isBN(s))return s;this.negative=0,this.words=null,this.length=0,this.red=null,s!==null&&((i==="le"||i==="be")&&(o=i,i=10),this._init(s||0,i||10,o||"be"))}typeof e=="object"?e.exports=n:r.BN=n,n.BN=n,n.wordSize=26;var l;try{typeof window<"u"&&typeof window.Buffer<"u"?l=window.Buffer:l=It.Buffer}catch{}n.isBN=function(i){return i instanceof n?!0:i!==null&&typeof i=="object"&&i.constructor.wordSize===n.wordSize&&Array.isArray(i.words)},n.max=function(i,o){return i.cmp(o)>0?i:o},n.min=function(i,o){return i.cmp(o)<0?i:o},n.prototype._init=function(i,o,d){if(typeof i=="number")return this._initNumber(i,o,d);if(typeof i=="object")return this._initArray(i,o,d);o==="hex"&&(o=16),a(o===(o|0)&&o>=2&&o<=36),i=i.toString().replace(/\s+/g,"");var h=0;i[0]==="-"&&(h++,this.negative=1),h=0;h-=3)u=i[h]|i[h-1]<<8|i[h-2]<<16,this.words[x]|=u<>>26-g&67108863,g+=24,g>=26&&(g-=26,x++);else if(d==="le")for(h=0,x=0;h>>26-g&67108863,g+=24,g>=26&&(g-=26,x++);return this._strip()};function m(s,i){var o=s.charCodeAt(i);if(o>=48&&o<=57)return o-48;if(o>=65&&o<=70)return o-55;if(o>=97&&o<=102)return o-87;a(!1,"Invalid character in "+s)}function y(s,i,o){var d=m(s,o);return o-1>=i&&(d|=m(s,o-1)<<4),d}n.prototype._parseHex=function(i,o,d){this.length=Math.ceil((i.length-o)/6),this.words=new Array(this.length);for(var h=0;h=o;h-=2)g=y(i,o,h)<=18?(x-=18,u+=1,this.words[u]|=g>>>26):x+=8;else{var b=i.length-o;for(h=b%2===0?o+1:o;h=18?(x-=18,u+=1,this.words[u]|=g>>>26):x+=8}this._strip()};function _(s,i,o,d){for(var h=0,x=0,u=Math.min(s.length,o),g=i;g=49?x=b-49+10:b>=17?x=b-17+10:x=b,a(b>=0&&x1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=A}catch{n.prototype.inspect=A}else n.prototype.inspect=A;function A(){return(this.red?""}var k=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],P=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],B=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(i,o){i=i||10,o=o|0||1;var d;if(i===16||i==="hex"){d="";for(var h=0,x=0,u=0;u>>24-h&16777215,h+=2,h>=26&&(h-=26,u--),x!==0||u!==this.length-1?d=k[6-b.length]+b+d:d=b+d}for(x!==0&&(d=x.toString(16)+d);d.length%o!==0;)d="0"+d;return this.negative!==0&&(d="-"+d),d}if(i===(i|0)&&i>=2&&i<=36){var c=P[i],v=B[i];d="";var F=this.clone();for(F.negative=0;!F.isZero();){var C=F.modrn(v).toString(i);F=F.idivn(v),F.isZero()?d=C+d:d=k[c-C.length]+C+d}for(this.isZero()&&(d="0"+d);d.length%o!==0;)d="0"+d;return this.negative!==0&&(d="-"+d),d}a(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var i=this.words[0];return this.length===2?i+=this.words[1]*67108864:this.length===3&&this.words[2]===1?i+=4503599627370496+this.words[1]*67108864:this.length>2&&a(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-i:i},n.prototype.toJSON=function(){return this.toString(16,2)},l&&(n.prototype.toBuffer=function(i,o){return this.toArrayLike(l,i,o)}),n.prototype.toArray=function(i,o){return this.toArrayLike(Array,i,o)};var I=function(i,o){return i.allocUnsafe?i.allocUnsafe(o):new i(o)};n.prototype.toArrayLike=function(i,o,d){this._strip();var h=this.byteLength(),x=d||Math.max(1,h);a(h<=x,"byte array longer than desired length"),a(x>0,"Requested array length <= 0");var u=I(i,x),g=o==="le"?"LE":"BE";return this["_toArrayLike"+g](u,h),u},n.prototype._toArrayLikeLE=function(i,o){for(var d=0,h=0,x=0,u=0;x>8&255),d>16&255),u===6?(d>24&255),h=0,u=0):(h=g>>>24,u+=2)}if(d=0&&(i[d--]=g>>8&255),d>=0&&(i[d--]=g>>16&255),u===6?(d>=0&&(i[d--]=g>>24&255),h=0,u=0):(h=g>>>24,u+=2)}if(d>=0)for(i[d--]=h;d>=0;)i[d--]=0},Math.clz32?n.prototype._countBits=function(i){return 32-Math.clz32(i)}:n.prototype._countBits=function(i){var o=i,d=0;return o>=4096&&(d+=13,o>>>=13),o>=64&&(d+=7,o>>>=7),o>=8&&(d+=4,o>>>=4),o>=2&&(d+=2,o>>>=2),d+o},n.prototype._zeroBits=function(i){if(i===0)return 26;var o=i,d=0;return o&8191||(d+=13,o>>>=13),o&127||(d+=7,o>>>=7),o&15||(d+=4,o>>>=4),o&3||(d+=2,o>>>=2),o&1||d++,d},n.prototype.bitLength=function(){var i=this.words[this.length-1],o=this._countBits(i);return(this.length-1)*26+o};function O(s){for(var i=new Array(s.bitLength()),o=0;o>>h&1}return i}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var i=0,o=0;oi.length?this.clone().ior(i):i.clone().ior(this)},n.prototype.uor=function(i){return this.length>i.length?this.clone().iuor(i):i.clone().iuor(this)},n.prototype.iuand=function(i){var o;this.length>i.length?o=i:o=this;for(var d=0;di.length?this.clone().iand(i):i.clone().iand(this)},n.prototype.uand=function(i){return this.length>i.length?this.clone().iuand(i):i.clone().iuand(this)},n.prototype.iuxor=function(i){var o,d;this.length>i.length?(o=this,d=i):(o=i,d=this);for(var h=0;hi.length?this.clone().ixor(i):i.clone().ixor(this)},n.prototype.uxor=function(i){return this.length>i.length?this.clone().iuxor(i):i.clone().iuxor(this)},n.prototype.inotn=function(i){a(typeof i=="number"&&i>=0);var o=Math.ceil(i/26)|0,d=i%26;this._expand(o),d>0&&o--;for(var h=0;h0&&(this.words[h]=~this.words[h]&67108863>>26-d),this._strip()},n.prototype.notn=function(i){return this.clone().inotn(i)},n.prototype.setn=function(i,o){a(typeof i=="number"&&i>=0);var d=i/26|0,h=i%26;return this._expand(d+1),o?this.words[d]=this.words[d]|1<i.length?(d=this,h=i):(d=i,h=this);for(var x=0,u=0;u>>26;for(;x!==0&&u>>26;if(this.length=d.length,x!==0)this.words[this.length]=x,this.length++;else if(d!==this)for(;ui.length?this.clone().iadd(i):i.clone().iadd(this)},n.prototype.isub=function(i){if(i.negative!==0){i.negative=0;var o=this.iadd(i);return i.negative=1,o._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(i),this.negative=1,this._normSign();var d=this.cmp(i);if(d===0)return this.negative=0,this.length=1,this.words[0]=0,this;var h,x;d>0?(h=this,x=i):(h=i,x=this);for(var u=0,g=0;g>26,this.words[g]=o&67108863;for(;u!==0&&g>26,this.words[g]=o&67108863;if(u===0&&g>>26,F=b&67108863,C=Math.min(c,i.length-1),L=Math.max(0,c-s.length+1);L<=C;L++){var G=c-L|0;h=s.words[G]|0,x=i.words[L]|0,u=h*x+F,v+=u/67108864|0,F=u&67108863}o.words[c]=F|0,b=v|0}return b!==0?o.words[c]=b|0:o.length--,o._strip()}var N=function(i,o,d){var h=i.words,x=o.words,u=d.words,g=0,b,c,v,F=h[0]|0,C=F&8191,L=F>>>13,G=h[1]|0,V=G&8191,J=G>>>13,Y=h[2]|0,W=Y&8191,X=Y>>>13,O0=h[3]|0,i0=O0&8191,c0=O0>>>13,Z0=h[4]|0,d0=Z0&8191,x0=Z0>>>13,ne=h[5]|0,p0=ne&8191,u0=ne>>>13,J0=h[6]|0,l0=J0&8191,h0=J0>>>13,te=h[7]|0,v0=te&8191,b0=te>>>13,re=h[8]|0,E0=re&8191,m0=re>>>13,he=h[9]|0,A0=he&8191,g0=he>>>13,le=x[0]|0,S0=le&8191,k0=le>>>13,Oe=x[1]|0,U0=Oe&8191,T0=Oe>>>13,Ne=x[2]|0,L0=Ne&8191,R0=Ne>>>13,Ie=x[3]|0,C0=Ie&8191,_0=Ie>>>13,Te=x[4]|0,N0=Te&8191,M0=Te>>>13,Re=x[5]|0,$0=Re&8191,y0=Re>>>13,Me=x[6]|0,Z=Me&8191,e0=Me>>>13,f0=x[7]|0,z=f0&8191,r0=f0>>>13,j0=x[8]|0,n0=j0&8191,o0=j0>>>13,X0=x[9]|0,I0=X0&8191,P0=X0>>>13;d.negative=i.negative^o.negative,d.length=19,b=Math.imul(C,S0),c=Math.imul(C,k0),c=c+Math.imul(L,S0)|0,v=Math.imul(L,k0);var Ce=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,b=Math.imul(V,S0),c=Math.imul(V,k0),c=c+Math.imul(J,S0)|0,v=Math.imul(J,k0),b=b+Math.imul(C,U0)|0,c=c+Math.imul(C,T0)|0,c=c+Math.imul(L,U0)|0,v=v+Math.imul(L,T0)|0;var ie=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(ie>>>26)|0,ie&=67108863,b=Math.imul(W,S0),c=Math.imul(W,k0),c=c+Math.imul(X,S0)|0,v=Math.imul(X,k0),b=b+Math.imul(V,U0)|0,c=c+Math.imul(V,T0)|0,c=c+Math.imul(J,U0)|0,v=v+Math.imul(J,T0)|0,b=b+Math.imul(C,L0)|0,c=c+Math.imul(C,R0)|0,c=c+Math.imul(L,L0)|0,v=v+Math.imul(L,R0)|0;var ve=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(ve>>>26)|0,ve&=67108863,b=Math.imul(i0,S0),c=Math.imul(i0,k0),c=c+Math.imul(c0,S0)|0,v=Math.imul(c0,k0),b=b+Math.imul(W,U0)|0,c=c+Math.imul(W,T0)|0,c=c+Math.imul(X,U0)|0,v=v+Math.imul(X,T0)|0,b=b+Math.imul(V,L0)|0,c=c+Math.imul(V,R0)|0,c=c+Math.imul(J,L0)|0,v=v+Math.imul(J,R0)|0,b=b+Math.imul(C,C0)|0,c=c+Math.imul(C,_0)|0,c=c+Math.imul(L,C0)|0,v=v+Math.imul(L,_0)|0;var me=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(me>>>26)|0,me&=67108863,b=Math.imul(d0,S0),c=Math.imul(d0,k0),c=c+Math.imul(x0,S0)|0,v=Math.imul(x0,k0),b=b+Math.imul(i0,U0)|0,c=c+Math.imul(i0,T0)|0,c=c+Math.imul(c0,U0)|0,v=v+Math.imul(c0,T0)|0,b=b+Math.imul(W,L0)|0,c=c+Math.imul(W,R0)|0,c=c+Math.imul(X,L0)|0,v=v+Math.imul(X,R0)|0,b=b+Math.imul(V,C0)|0,c=c+Math.imul(V,_0)|0,c=c+Math.imul(J,C0)|0,v=v+Math.imul(J,_0)|0,b=b+Math.imul(C,N0)|0,c=c+Math.imul(C,M0)|0,c=c+Math.imul(L,N0)|0,v=v+Math.imul(L,M0)|0;var xe=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(xe>>>26)|0,xe&=67108863,b=Math.imul(p0,S0),c=Math.imul(p0,k0),c=c+Math.imul(u0,S0)|0,v=Math.imul(u0,k0),b=b+Math.imul(d0,U0)|0,c=c+Math.imul(d0,T0)|0,c=c+Math.imul(x0,U0)|0,v=v+Math.imul(x0,T0)|0,b=b+Math.imul(i0,L0)|0,c=c+Math.imul(i0,R0)|0,c=c+Math.imul(c0,L0)|0,v=v+Math.imul(c0,R0)|0,b=b+Math.imul(W,C0)|0,c=c+Math.imul(W,_0)|0,c=c+Math.imul(X,C0)|0,v=v+Math.imul(X,_0)|0,b=b+Math.imul(V,N0)|0,c=c+Math.imul(V,M0)|0,c=c+Math.imul(J,N0)|0,v=v+Math.imul(J,M0)|0,b=b+Math.imul(C,$0)|0,c=c+Math.imul(C,y0)|0,c=c+Math.imul(L,$0)|0,v=v+Math.imul(L,y0)|0;var Ee=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,b=Math.imul(l0,S0),c=Math.imul(l0,k0),c=c+Math.imul(h0,S0)|0,v=Math.imul(h0,k0),b=b+Math.imul(p0,U0)|0,c=c+Math.imul(p0,T0)|0,c=c+Math.imul(u0,U0)|0,v=v+Math.imul(u0,T0)|0,b=b+Math.imul(d0,L0)|0,c=c+Math.imul(d0,R0)|0,c=c+Math.imul(x0,L0)|0,v=v+Math.imul(x0,R0)|0,b=b+Math.imul(i0,C0)|0,c=c+Math.imul(i0,_0)|0,c=c+Math.imul(c0,C0)|0,v=v+Math.imul(c0,_0)|0,b=b+Math.imul(W,N0)|0,c=c+Math.imul(W,M0)|0,c=c+Math.imul(X,N0)|0,v=v+Math.imul(X,M0)|0,b=b+Math.imul(V,$0)|0,c=c+Math.imul(V,y0)|0,c=c+Math.imul(J,$0)|0,v=v+Math.imul(J,y0)|0,b=b+Math.imul(C,Z)|0,c=c+Math.imul(C,e0)|0,c=c+Math.imul(L,Z)|0,v=v+Math.imul(L,e0)|0;var Ae=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,b=Math.imul(v0,S0),c=Math.imul(v0,k0),c=c+Math.imul(b0,S0)|0,v=Math.imul(b0,k0),b=b+Math.imul(l0,U0)|0,c=c+Math.imul(l0,T0)|0,c=c+Math.imul(h0,U0)|0,v=v+Math.imul(h0,T0)|0,b=b+Math.imul(p0,L0)|0,c=c+Math.imul(p0,R0)|0,c=c+Math.imul(u0,L0)|0,v=v+Math.imul(u0,R0)|0,b=b+Math.imul(d0,C0)|0,c=c+Math.imul(d0,_0)|0,c=c+Math.imul(x0,C0)|0,v=v+Math.imul(x0,_0)|0,b=b+Math.imul(i0,N0)|0,c=c+Math.imul(i0,M0)|0,c=c+Math.imul(c0,N0)|0,v=v+Math.imul(c0,M0)|0,b=b+Math.imul(W,$0)|0,c=c+Math.imul(W,y0)|0,c=c+Math.imul(X,$0)|0,v=v+Math.imul(X,y0)|0,b=b+Math.imul(V,Z)|0,c=c+Math.imul(V,e0)|0,c=c+Math.imul(J,Z)|0,v=v+Math.imul(J,e0)|0,b=b+Math.imul(C,z)|0,c=c+Math.imul(C,r0)|0,c=c+Math.imul(L,z)|0,v=v+Math.imul(L,r0)|0;var we=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(we>>>26)|0,we&=67108863,b=Math.imul(E0,S0),c=Math.imul(E0,k0),c=c+Math.imul(m0,S0)|0,v=Math.imul(m0,k0),b=b+Math.imul(v0,U0)|0,c=c+Math.imul(v0,T0)|0,c=c+Math.imul(b0,U0)|0,v=v+Math.imul(b0,T0)|0,b=b+Math.imul(l0,L0)|0,c=c+Math.imul(l0,R0)|0,c=c+Math.imul(h0,L0)|0,v=v+Math.imul(h0,R0)|0,b=b+Math.imul(p0,C0)|0,c=c+Math.imul(p0,_0)|0,c=c+Math.imul(u0,C0)|0,v=v+Math.imul(u0,_0)|0,b=b+Math.imul(d0,N0)|0,c=c+Math.imul(d0,M0)|0,c=c+Math.imul(x0,N0)|0,v=v+Math.imul(x0,M0)|0,b=b+Math.imul(i0,$0)|0,c=c+Math.imul(i0,y0)|0,c=c+Math.imul(c0,$0)|0,v=v+Math.imul(c0,y0)|0,b=b+Math.imul(W,Z)|0,c=c+Math.imul(W,e0)|0,c=c+Math.imul(X,Z)|0,v=v+Math.imul(X,e0)|0,b=b+Math.imul(V,z)|0,c=c+Math.imul(V,r0)|0,c=c+Math.imul(J,z)|0,v=v+Math.imul(J,r0)|0,b=b+Math.imul(C,n0)|0,c=c+Math.imul(C,o0)|0,c=c+Math.imul(L,n0)|0,v=v+Math.imul(L,o0)|0;var Se=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(Se>>>26)|0,Se&=67108863,b=Math.imul(A0,S0),c=Math.imul(A0,k0),c=c+Math.imul(g0,S0)|0,v=Math.imul(g0,k0),b=b+Math.imul(E0,U0)|0,c=c+Math.imul(E0,T0)|0,c=c+Math.imul(m0,U0)|0,v=v+Math.imul(m0,T0)|0,b=b+Math.imul(v0,L0)|0,c=c+Math.imul(v0,R0)|0,c=c+Math.imul(b0,L0)|0,v=v+Math.imul(b0,R0)|0,b=b+Math.imul(l0,C0)|0,c=c+Math.imul(l0,_0)|0,c=c+Math.imul(h0,C0)|0,v=v+Math.imul(h0,_0)|0,b=b+Math.imul(p0,N0)|0,c=c+Math.imul(p0,M0)|0,c=c+Math.imul(u0,N0)|0,v=v+Math.imul(u0,M0)|0,b=b+Math.imul(d0,$0)|0,c=c+Math.imul(d0,y0)|0,c=c+Math.imul(x0,$0)|0,v=v+Math.imul(x0,y0)|0,b=b+Math.imul(i0,Z)|0,c=c+Math.imul(i0,e0)|0,c=c+Math.imul(c0,Z)|0,v=v+Math.imul(c0,e0)|0,b=b+Math.imul(W,z)|0,c=c+Math.imul(W,r0)|0,c=c+Math.imul(X,z)|0,v=v+Math.imul(X,r0)|0,b=b+Math.imul(V,n0)|0,c=c+Math.imul(V,o0)|0,c=c+Math.imul(J,n0)|0,v=v+Math.imul(J,o0)|0,b=b+Math.imul(C,I0)|0,c=c+Math.imul(C,P0)|0,c=c+Math.imul(L,I0)|0,v=v+Math.imul(L,P0)|0;var de=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(de>>>26)|0,de&=67108863,b=Math.imul(A0,U0),c=Math.imul(A0,T0),c=c+Math.imul(g0,U0)|0,v=Math.imul(g0,T0),b=b+Math.imul(E0,L0)|0,c=c+Math.imul(E0,R0)|0,c=c+Math.imul(m0,L0)|0,v=v+Math.imul(m0,R0)|0,b=b+Math.imul(v0,C0)|0,c=c+Math.imul(v0,_0)|0,c=c+Math.imul(b0,C0)|0,v=v+Math.imul(b0,_0)|0,b=b+Math.imul(l0,N0)|0,c=c+Math.imul(l0,M0)|0,c=c+Math.imul(h0,N0)|0,v=v+Math.imul(h0,M0)|0,b=b+Math.imul(p0,$0)|0,c=c+Math.imul(p0,y0)|0,c=c+Math.imul(u0,$0)|0,v=v+Math.imul(u0,y0)|0,b=b+Math.imul(d0,Z)|0,c=c+Math.imul(d0,e0)|0,c=c+Math.imul(x0,Z)|0,v=v+Math.imul(x0,e0)|0,b=b+Math.imul(i0,z)|0,c=c+Math.imul(i0,r0)|0,c=c+Math.imul(c0,z)|0,v=v+Math.imul(c0,r0)|0,b=b+Math.imul(W,n0)|0,c=c+Math.imul(W,o0)|0,c=c+Math.imul(X,n0)|0,v=v+Math.imul(X,o0)|0,b=b+Math.imul(V,I0)|0,c=c+Math.imul(V,P0)|0,c=c+Math.imul(J,I0)|0,v=v+Math.imul(J,P0)|0;var ue=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(ue>>>26)|0,ue&=67108863,b=Math.imul(A0,L0),c=Math.imul(A0,R0),c=c+Math.imul(g0,L0)|0,v=Math.imul(g0,R0),b=b+Math.imul(E0,C0)|0,c=c+Math.imul(E0,_0)|0,c=c+Math.imul(m0,C0)|0,v=v+Math.imul(m0,_0)|0,b=b+Math.imul(v0,N0)|0,c=c+Math.imul(v0,M0)|0,c=c+Math.imul(b0,N0)|0,v=v+Math.imul(b0,M0)|0,b=b+Math.imul(l0,$0)|0,c=c+Math.imul(l0,y0)|0,c=c+Math.imul(h0,$0)|0,v=v+Math.imul(h0,y0)|0,b=b+Math.imul(p0,Z)|0,c=c+Math.imul(p0,e0)|0,c=c+Math.imul(u0,Z)|0,v=v+Math.imul(u0,e0)|0,b=b+Math.imul(d0,z)|0,c=c+Math.imul(d0,r0)|0,c=c+Math.imul(x0,z)|0,v=v+Math.imul(x0,r0)|0,b=b+Math.imul(i0,n0)|0,c=c+Math.imul(i0,o0)|0,c=c+Math.imul(c0,n0)|0,v=v+Math.imul(c0,o0)|0,b=b+Math.imul(W,I0)|0,c=c+Math.imul(W,P0)|0,c=c+Math.imul(X,I0)|0,v=v+Math.imul(X,P0)|0;var fe=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(fe>>>26)|0,fe&=67108863,b=Math.imul(A0,C0),c=Math.imul(A0,_0),c=c+Math.imul(g0,C0)|0,v=Math.imul(g0,_0),b=b+Math.imul(E0,N0)|0,c=c+Math.imul(E0,M0)|0,c=c+Math.imul(m0,N0)|0,v=v+Math.imul(m0,M0)|0,b=b+Math.imul(v0,$0)|0,c=c+Math.imul(v0,y0)|0,c=c+Math.imul(b0,$0)|0,v=v+Math.imul(b0,y0)|0,b=b+Math.imul(l0,Z)|0,c=c+Math.imul(l0,e0)|0,c=c+Math.imul(h0,Z)|0,v=v+Math.imul(h0,e0)|0,b=b+Math.imul(p0,z)|0,c=c+Math.imul(p0,r0)|0,c=c+Math.imul(u0,z)|0,v=v+Math.imul(u0,r0)|0,b=b+Math.imul(d0,n0)|0,c=c+Math.imul(d0,o0)|0,c=c+Math.imul(x0,n0)|0,v=v+Math.imul(x0,o0)|0,b=b+Math.imul(i0,I0)|0,c=c+Math.imul(i0,P0)|0,c=c+Math.imul(c0,I0)|0,v=v+Math.imul(c0,P0)|0;var se=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(se>>>26)|0,se&=67108863,b=Math.imul(A0,N0),c=Math.imul(A0,M0),c=c+Math.imul(g0,N0)|0,v=Math.imul(g0,M0),b=b+Math.imul(E0,$0)|0,c=c+Math.imul(E0,y0)|0,c=c+Math.imul(m0,$0)|0,v=v+Math.imul(m0,y0)|0,b=b+Math.imul(v0,Z)|0,c=c+Math.imul(v0,e0)|0,c=c+Math.imul(b0,Z)|0,v=v+Math.imul(b0,e0)|0,b=b+Math.imul(l0,z)|0,c=c+Math.imul(l0,r0)|0,c=c+Math.imul(h0,z)|0,v=v+Math.imul(h0,r0)|0,b=b+Math.imul(p0,n0)|0,c=c+Math.imul(p0,o0)|0,c=c+Math.imul(u0,n0)|0,v=v+Math.imul(u0,o0)|0,b=b+Math.imul(d0,I0)|0,c=c+Math.imul(d0,P0)|0,c=c+Math.imul(x0,I0)|0,v=v+Math.imul(x0,P0)|0;var ce=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(ce>>>26)|0,ce&=67108863,b=Math.imul(A0,$0),c=Math.imul(A0,y0),c=c+Math.imul(g0,$0)|0,v=Math.imul(g0,y0),b=b+Math.imul(E0,Z)|0,c=c+Math.imul(E0,e0)|0,c=c+Math.imul(m0,Z)|0,v=v+Math.imul(m0,e0)|0,b=b+Math.imul(v0,z)|0,c=c+Math.imul(v0,r0)|0,c=c+Math.imul(b0,z)|0,v=v+Math.imul(b0,r0)|0,b=b+Math.imul(l0,n0)|0,c=c+Math.imul(l0,o0)|0,c=c+Math.imul(h0,n0)|0,v=v+Math.imul(h0,o0)|0,b=b+Math.imul(p0,I0)|0,c=c+Math.imul(p0,P0)|0,c=c+Math.imul(u0,I0)|0,v=v+Math.imul(u0,P0)|0;var oe=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(oe>>>26)|0,oe&=67108863,b=Math.imul(A0,Z),c=Math.imul(A0,e0),c=c+Math.imul(g0,Z)|0,v=Math.imul(g0,e0),b=b+Math.imul(E0,z)|0,c=c+Math.imul(E0,r0)|0,c=c+Math.imul(m0,z)|0,v=v+Math.imul(m0,r0)|0,b=b+Math.imul(v0,n0)|0,c=c+Math.imul(v0,o0)|0,c=c+Math.imul(b0,n0)|0,v=v+Math.imul(b0,o0)|0,b=b+Math.imul(l0,I0)|0,c=c+Math.imul(l0,P0)|0,c=c+Math.imul(h0,I0)|0,v=v+Math.imul(h0,P0)|0;var K0=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(K0>>>26)|0,K0&=67108863,b=Math.imul(A0,z),c=Math.imul(A0,r0),c=c+Math.imul(g0,z)|0,v=Math.imul(g0,r0),b=b+Math.imul(E0,n0)|0,c=c+Math.imul(E0,o0)|0,c=c+Math.imul(m0,n0)|0,v=v+Math.imul(m0,o0)|0,b=b+Math.imul(v0,I0)|0,c=c+Math.imul(v0,P0)|0,c=c+Math.imul(b0,I0)|0,v=v+Math.imul(b0,P0)|0;var V0=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(V0>>>26)|0,V0&=67108863,b=Math.imul(A0,n0),c=Math.imul(A0,o0),c=c+Math.imul(g0,n0)|0,v=Math.imul(g0,o0),b=b+Math.imul(E0,I0)|0,c=c+Math.imul(E0,P0)|0,c=c+Math.imul(m0,I0)|0,v=v+Math.imul(m0,P0)|0;var ee=(g+b|0)+((c&8191)<<13)|0;g=(v+(c>>>13)|0)+(ee>>>26)|0,ee&=67108863,b=Math.imul(A0,I0),c=Math.imul(A0,P0),c=c+Math.imul(g0,I0)|0,v=Math.imul(g0,P0);var Q0=(g+b|0)+((c&8191)<<13)|0;return g=(v+(c>>>13)|0)+(Q0>>>26)|0,Q0&=67108863,u[0]=Ce,u[1]=ie,u[2]=ve,u[3]=me,u[4]=xe,u[5]=Ee,u[6]=Ae,u[7]=we,u[8]=Se,u[9]=de,u[10]=ue,u[11]=fe,u[12]=se,u[13]=ce,u[14]=oe,u[15]=K0,u[16]=V0,u[17]=ee,u[18]=Q0,g!==0&&(u[19]=g,d.length++),d};Math.imul||(N=H);function $(s,i,o){o.negative=i.negative^s.negative,o.length=s.length+i.length;for(var d=0,h=0,x=0;x>>26)|0,h+=u>>>26,u&=67108863}o.words[x]=g,d=u,u=h}return d!==0?o.words[x]=d:o.length--,o._strip()}function R(s,i,o){return $(s,i,o)}n.prototype.mulTo=function(i,o){var d,h=this.length+i.length;return this.length===10&&i.length===10?d=N(this,i,o):h<63?d=H(this,i,o):h<1024?d=$(this,i,o):d=R(this,i,o),d},n.prototype.mul=function(i){var o=new n(null);return o.words=new Array(this.length+i.length),this.mulTo(i,o)},n.prototype.mulf=function(i){var o=new n(null);return o.words=new Array(this.length+i.length),R(this,i,o)},n.prototype.imul=function(i){return this.clone().mulTo(i,this)},n.prototype.imuln=function(i){var o=i<0;o&&(i=-i),a(typeof i=="number"),a(i<67108864);for(var d=0,h=0;h>=26,d+=x/67108864|0,d+=u>>>26,this.words[h]=u&67108863}return d!==0&&(this.words[h]=d,this.length++),o?this.ineg():this},n.prototype.muln=function(i){return this.clone().imuln(i)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(i){var o=O(i);if(o.length===0)return new n(1);for(var d=this,h=0;h=0);var o=i%26,d=(i-o)/26,h=67108863>>>26-o<<26-o,x;if(o!==0){var u=0;for(x=0;x>>26-o}u&&(this.words[x]=u,this.length++)}if(d!==0){for(x=this.length-1;x>=0;x--)this.words[x+d]=this.words[x];for(x=0;x=0);var h;o?h=(o-o%26)/26:h=0;var x=i%26,u=Math.min((i-x)/26,this.length),g=67108863^67108863>>>x<u)for(this.length-=u,c=0;c=0&&(v!==0||c>=h);c--){var F=this.words[c]|0;this.words[c]=v<<26-x|F>>>x,v=F&g}return b&&v!==0&&(b.words[b.length++]=v),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(i,o,d){return a(this.negative===0),this.iushrn(i,o,d)},n.prototype.shln=function(i){return this.clone().ishln(i)},n.prototype.ushln=function(i){return this.clone().iushln(i)},n.prototype.shrn=function(i){return this.clone().ishrn(i)},n.prototype.ushrn=function(i){return this.clone().iushrn(i)},n.prototype.testn=function(i){a(typeof i=="number"&&i>=0);var o=i%26,d=(i-o)/26,h=1<=0);var o=i%26,d=(i-o)/26;if(a(this.negative===0,"imaskn works only with positive numbers"),this.length<=d)return this;if(o!==0&&d++,this.length=Math.min(d,this.length),o!==0){var h=67108863^67108863>>>o<=67108864;o++)this.words[o]-=67108864,o===this.length-1?this.words[o+1]=1:this.words[o+1]++;return this.length=Math.max(this.length,o+1),this},n.prototype.isubn=function(i){if(a(typeof i=="number"),a(i<67108864),i<0)return this.iaddn(-i);if(this.negative!==0)return this.negative=0,this.iaddn(i),this.negative=1,this;if(this.words[0]-=i,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var o=0;o>26)-(b/67108864|0),this.words[x+d]=u&67108863}for(;x>26,this.words[x+d]=u&67108863;if(g===0)return this._strip();for(a(g===-1),g=0,x=0;x>26,this.words[x]=u&67108863;return this.negative=1,this._strip()},n.prototype._wordDiv=function(i,o){var d=this.length-i.length,h=this.clone(),x=i,u=x.words[x.length-1]|0,g=this._countBits(u);d=26-g,d!==0&&(x=x.ushln(d),h.iushln(d),u=x.words[x.length-1]|0);var b=h.length-x.length,c;if(o!=="mod"){c=new n(null),c.length=b+1,c.words=new Array(c.length);for(var v=0;v=0;C--){var L=(h.words[x.length+C]|0)*67108864+(h.words[x.length+C-1]|0);for(L=Math.min(L/u|0,67108863),h._ishlnsubmul(x,L,C);h.negative!==0;)L--,h.negative=0,h._ishlnsubmul(x,1,C),h.isZero()||(h.negative^=1);c&&(c.words[C]=L)}return c&&c._strip(),h._strip(),o!=="div"&&d!==0&&h.iushrn(d),{div:c||null,mod:h}},n.prototype.divmod=function(i,o,d){if(a(!i.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var h,x,u;return this.negative!==0&&i.negative===0?(u=this.neg().divmod(i,o),o!=="mod"&&(h=u.div.neg()),o!=="div"&&(x=u.mod.neg(),d&&x.negative!==0&&x.iadd(i)),{div:h,mod:x}):this.negative===0&&i.negative!==0?(u=this.divmod(i.neg(),o),o!=="mod"&&(h=u.div.neg()),{div:h,mod:u.mod}):this.negative&i.negative?(u=this.neg().divmod(i.neg(),o),o!=="div"&&(x=u.mod.neg(),d&&x.negative!==0&&x.isub(i)),{div:u.div,mod:x}):i.length>this.length||this.cmp(i)<0?{div:new n(0),mod:this}:i.length===1?o==="div"?{div:this.divn(i.words[0]),mod:null}:o==="mod"?{div:null,mod:new n(this.modrn(i.words[0]))}:{div:this.divn(i.words[0]),mod:new n(this.modrn(i.words[0]))}:this._wordDiv(i,o)},n.prototype.div=function(i){return this.divmod(i,"div",!1).div},n.prototype.mod=function(i){return this.divmod(i,"mod",!1).mod},n.prototype.umod=function(i){return this.divmod(i,"mod",!0).mod},n.prototype.divRound=function(i){var o=this.divmod(i);if(o.mod.isZero())return o.div;var d=o.div.negative!==0?o.mod.isub(i):o.mod,h=i.ushrn(1),x=i.andln(1),u=d.cmp(h);return u<0||x===1&&u===0?o.div:o.div.negative!==0?o.div.isubn(1):o.div.iaddn(1)},n.prototype.modrn=function(i){var o=i<0;o&&(i=-i),a(i<=67108863);for(var d=(1<<26)%i,h=0,x=this.length-1;x>=0;x--)h=(d*h+(this.words[x]|0))%i;return o?-h:h},n.prototype.modn=function(i){return this.modrn(i)},n.prototype.idivn=function(i){var o=i<0;o&&(i=-i),a(i<=67108863);for(var d=0,h=this.length-1;h>=0;h--){var x=(this.words[h]|0)+d*67108864;this.words[h]=x/i|0,d=x%i}return this._strip(),o?this.ineg():this},n.prototype.divn=function(i){return this.clone().idivn(i)},n.prototype.egcd=function(i){a(i.negative===0),a(!i.isZero());var o=this,d=i.clone();o.negative!==0?o=o.umod(i):o=o.clone();for(var h=new n(1),x=new n(0),u=new n(0),g=new n(1),b=0;o.isEven()&&d.isEven();)o.iushrn(1),d.iushrn(1),++b;for(var c=d.clone(),v=o.clone();!o.isZero();){for(var F=0,C=1;!(o.words[0]&C)&&F<26;++F,C<<=1);if(F>0)for(o.iushrn(F);F-- >0;)(h.isOdd()||x.isOdd())&&(h.iadd(c),x.isub(v)),h.iushrn(1),x.iushrn(1);for(var L=0,G=1;!(d.words[0]&G)&&L<26;++L,G<<=1);if(L>0)for(d.iushrn(L);L-- >0;)(u.isOdd()||g.isOdd())&&(u.iadd(c),g.isub(v)),u.iushrn(1),g.iushrn(1);o.cmp(d)>=0?(o.isub(d),h.isub(u),x.isub(g)):(d.isub(o),u.isub(h),g.isub(x))}return{a:u,b:g,gcd:d.iushln(b)}},n.prototype._invmp=function(i){a(i.negative===0),a(!i.isZero());var o=this,d=i.clone();o.negative!==0?o=o.umod(i):o=o.clone();for(var h=new n(1),x=new n(0),u=d.clone();o.cmpn(1)>0&&d.cmpn(1)>0;){for(var g=0,b=1;!(o.words[0]&b)&&g<26;++g,b<<=1);if(g>0)for(o.iushrn(g);g-- >0;)h.isOdd()&&h.iadd(u),h.iushrn(1);for(var c=0,v=1;!(d.words[0]&v)&&c<26;++c,v<<=1);if(c>0)for(d.iushrn(c);c-- >0;)x.isOdd()&&x.iadd(u),x.iushrn(1);o.cmp(d)>=0?(o.isub(d),h.isub(x)):(d.isub(o),x.isub(h))}var F;return o.cmpn(1)===0?F=h:F=x,F.cmpn(0)<0&&F.iadd(i),F},n.prototype.gcd=function(i){if(this.isZero())return i.abs();if(i.isZero())return this.abs();var o=this.clone(),d=i.clone();o.negative=0,d.negative=0;for(var h=0;o.isEven()&&d.isEven();h++)o.iushrn(1),d.iushrn(1);do{for(;o.isEven();)o.iushrn(1);for(;d.isEven();)d.iushrn(1);var x=o.cmp(d);if(x<0){var u=o;o=d,d=u}else if(x===0||d.cmpn(1)===0)break;o.isub(d)}while(!0);return d.iushln(h)},n.prototype.invm=function(i){return this.egcd(i).a.umod(i)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(i){return this.words[0]&i},n.prototype.bincn=function(i){a(typeof i=="number");var o=i%26,d=(i-o)/26,h=1<>>26,g&=67108863,this.words[u]=g}return x!==0&&(this.words[u]=x,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(i){var o=i<0;if(this.negative!==0&&!o)return-1;if(this.negative===0&&o)return 1;this._strip();var d;if(this.length>1)d=1;else{o&&(i=-i),a(i<=67108863,"Number is too big");var h=this.words[0]|0;d=h===i?0:hi.length)return 1;if(this.length=0;d--){var h=this.words[d]|0,x=i.words[d]|0;if(h!==x){hx&&(o=1);break}}return o},n.prototype.gtn=function(i){return this.cmpn(i)===1},n.prototype.gt=function(i){return this.cmp(i)===1},n.prototype.gten=function(i){return this.cmpn(i)>=0},n.prototype.gte=function(i){return this.cmp(i)>=0},n.prototype.ltn=function(i){return this.cmpn(i)===-1},n.prototype.lt=function(i){return this.cmp(i)===-1},n.prototype.lten=function(i){return this.cmpn(i)<=0},n.prototype.lte=function(i){return this.cmp(i)<=0},n.prototype.eqn=function(i){return this.cmpn(i)===0},n.prototype.eq=function(i){return this.cmp(i)===0},n.red=function(i){return new p(i)},n.prototype.toRed=function(i){return a(!this.red,"Already a number in reduction context"),a(this.negative===0,"red works only with positives"),i.convertTo(this)._forceRed(i)},n.prototype.fromRed=function(){return a(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(i){return this.red=i,this},n.prototype.forceRed=function(i){return a(!this.red,"Already a number in reduction context"),this._forceRed(i)},n.prototype.redAdd=function(i){return a(this.red,"redAdd works only with red numbers"),this.red.add(this,i)},n.prototype.redIAdd=function(i){return a(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,i)},n.prototype.redSub=function(i){return a(this.red,"redSub works only with red numbers"),this.red.sub(this,i)},n.prototype.redISub=function(i){return a(this.red,"redISub works only with red numbers"),this.red.isub(this,i)},n.prototype.redShl=function(i){return a(this.red,"redShl works only with red numbers"),this.red.shl(this,i)},n.prototype.redMul=function(i){return a(this.red,"redMul works only with red numbers"),this.red._verify2(this,i),this.red.mul(this,i)},n.prototype.redIMul=function(i){return a(this.red,"redMul works only with red numbers"),this.red._verify2(this,i),this.red.imul(this,i)},n.prototype.redSqr=function(){return a(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return a(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return a(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return a(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return a(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(i){return a(this.red&&!i.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,i)};var q={k256:null,p224:null,p192:null,p25519:null};function U(s,i){this.name=s,this.p=new n(i,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}U.prototype._tmp=function(){var i=new n(null);return i.words=new Array(Math.ceil(this.n/13)),i},U.prototype.ireduce=function(i){var o=i,d;do this.split(o,this.tmp),o=this.imulK(o),o=o.iadd(this.tmp),d=o.bitLength();while(d>this.n);var h=d0?o.isub(this.p):o.strip!==void 0?o.strip():o._strip(),o},U.prototype.split=function(i,o){i.iushrn(this.n,0,o)},U.prototype.imulK=function(i){return i.imul(this.k)};function D(){U.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}f(D,U),D.prototype.split=function(i,o){for(var d=4194303,h=Math.min(i.length,9),x=0;x>>22,u=g}u>>>=22,i.words[x-10]=u,u===0&&i.length>10?i.length-=10:i.length-=9},D.prototype.imulK=function(i){i.words[i.length]=0,i.words[i.length+1]=0,i.length+=2;for(var o=0,d=0;d>>=26,i.words[d]=x,o=h}return o!==0&&(i.words[i.length++]=o),i},n._prime=function(i){if(q[i])return q[i];var o;if(i==="k256")o=new D;else if(i==="p224")o=new j;else if(i==="p192")o=new t0;else if(i==="p25519")o=new T;else throw new Error("Unknown prime "+i);return q[i]=o,o};function p(s){if(typeof s=="string"){var i=n._prime(s);this.m=i.p,this.prime=i}else a(s.gtn(1),"modulus must be greater than 1"),this.m=s,this.prime=null}p.prototype._verify1=function(i){a(i.negative===0,"red works only with positives"),a(i.red,"red works only with red numbers")},p.prototype._verify2=function(i,o){a((i.negative|o.negative)===0,"red works only with positives"),a(i.red&&i.red===o.red,"red works only with red numbers")},p.prototype.imod=function(i){return this.prime?this.prime.ireduce(i)._forceRed(this):(E(i,i.umod(this.m)._forceRed(this)),i)},p.prototype.neg=function(i){return i.isZero()?i.clone():this.m.sub(i)._forceRed(this)},p.prototype.add=function(i,o){this._verify2(i,o);var d=i.add(o);return d.cmp(this.m)>=0&&d.isub(this.m),d._forceRed(this)},p.prototype.iadd=function(i,o){this._verify2(i,o);var d=i.iadd(o);return d.cmp(this.m)>=0&&d.isub(this.m),d},p.prototype.sub=function(i,o){this._verify2(i,o);var d=i.sub(o);return d.cmpn(0)<0&&d.iadd(this.m),d._forceRed(this)},p.prototype.isub=function(i,o){this._verify2(i,o);var d=i.isub(o);return d.cmpn(0)<0&&d.iadd(this.m),d},p.prototype.shl=function(i,o){return this._verify1(i),this.imod(i.ushln(o))},p.prototype.imul=function(i,o){return this._verify2(i,o),this.imod(i.imul(o))},p.prototype.mul=function(i,o){return this._verify2(i,o),this.imod(i.mul(o))},p.prototype.isqr=function(i){return this.imul(i,i.clone())},p.prototype.sqr=function(i){return this.mul(i,i)},p.prototype.sqrt=function(i){if(i.isZero())return i.clone();var o=this.m.andln(3);if(a(o%2===1),o===3){var d=this.m.add(new n(1)).iushrn(2);return this.pow(i,d)}for(var h=this.m.subn(1),x=0;!h.isZero()&&h.andln(1)===0;)x++,h.iushrn(1);a(!h.isZero());var u=new n(1).toRed(this),g=u.redNeg(),b=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new n(2*c*c).toRed(this);this.pow(c,b).cmp(g)!==0;)c.redIAdd(g);for(var v=this.pow(c,h),F=this.pow(i,h.addn(1).iushrn(1)),C=this.pow(i,h),L=x;C.cmp(u)!==0;){for(var G=C,V=0;G.cmp(u)!==0;V++)G=G.redSqr();a(V=0;x--){for(var v=o.words[x],F=c-1;F>=0;F--){var C=v>>F&1;if(u!==h[0]&&(u=this.sqr(u)),C===0&&g===0){b=0;continue}g<<=1,g|=C,b++,!(b!==d&&(x!==0||F!==0))&&(u=this.mul(u,h[g]),b=0,g=0)}c=26}return u},p.prototype.convertTo=function(i){var o=i.umod(this.m);return o===i?o.clone():o},p.prototype.convertFrom=function(i){var o=i.clone();return o.red=null,o},n.mont=function(i){return new w(i)};function w(s){p.call(this,s),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}f(w,p),w.prototype.convertTo=function(i){return this.imod(i.ushln(this.shift))},w.prototype.convertFrom=function(i){var o=this.imod(i.mul(this.rinv));return o.red=null,o},w.prototype.imul=function(i,o){if(i.isZero()||o.isZero())return i.words[0]=0,i.length=1,i;var d=i.imul(o),h=d.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),x=d.isub(h).iushrn(this.shift),u=x;return x.cmp(this.m)>=0?u=x.isub(this.m):x.cmpn(0)<0&&(u=x.iadd(this.m)),u._forceRed(this)},w.prototype.mul=function(i,o){if(i.isZero()||o.isZero())return new n(0)._forceRed(this);var d=i.mul(o),h=d.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),x=d.isub(h).iushrn(this.shift),u=x;return x.cmp(this.m)>=0?u=x.isub(this.m):x.cmpn(0)<0&&(u=x.iadd(this.m)),u._forceRed(this)},w.prototype.invm=function(i){var o=this.imod(i._invmp(this.m).mul(this.r2));return o._forceRed(this)}})(t,B0)}(ig);var ey0=ig.exports,ty0=B0&&B0.__createBinding||(Object.create?function(t,e,r,a){a===void 0&&(a=r);var f=Object.getOwnPropertyDescriptor(e,r);(!f||("get"in f?!e.__esModule:f.writable||f.configurable))&&(f={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,a,f)}:function(t,e,r,a){a===void 0&&(a=r),t[a]=e[r]}),ry0=B0&&B0.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),ay0=B0&&B0.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&ty0(e,t,r);return ry0(e,t),e},iy0=B0&&B0.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Zi,"__esModule",{value:!0}),Zi.rlp=Zi.BN=void 0;var ny0=iy0(ey0);Zi.BN=ny0.default;var fy0=ay0(na);Zi.rlp=fy0,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.KECCAK256_RLP=t.KECCAK256_RLP_S=t.KECCAK256_RLP_ARRAY=t.KECCAK256_RLP_ARRAY_S=t.KECCAK256_NULL=t.KECCAK256_NULL_S=t.TWO_POW256=t.MAX_INTEGER=t.MAX_UINT64=void 0;var e=It,r=Zi;t.MAX_UINT64=new r.BN("ffffffffffffffff",16),t.MAX_INTEGER=new r.BN("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16),t.TWO_POW256=new r.BN("10000000000000000000000000000000000000000000000000000000000000000",16),t.KECCAK256_NULL_S="c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",t.KECCAK256_NULL=e.Buffer.from(t.KECCAK256_NULL_S,"hex"),t.KECCAK256_RLP_ARRAY_S="1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",t.KECCAK256_RLP_ARRAY=e.Buffer.from(t.KECCAK256_RLP_ARRAY_S,"hex"),t.KECCAK256_RLP_S="56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",t.KECCAK256_RLP=e.Buffer.from(t.KECCAK256_RLP_S,"hex")}(ag);var ng={},sr={};Object.defineProperty(sr,"__esModule",{value:!0}),sr.isHexString=sr.getKeys=sr.fromAscii=sr.fromUtf8=sr.toAscii=sr.arrayContainsArray=sr.getBinarySize=sr.padToEven=sr.stripHexPrefix=sr.isHexPrefixed=void 0;function MN(t){if(typeof t!="string")throw new Error("[isHexPrefixed] input must be type 'string', received type ".concat(typeof t));return t[0]==="0"&&t[1]==="x"}sr.isHexPrefixed=MN;var cy0=function(t){if(typeof t!="string")throw new Error("[stripHexPrefix] input must be type 'string', received ".concat(typeof t));return MN(t)?t.slice(2):t};sr.stripHexPrefix=cy0;function EN(t){var e=t;if(typeof e!="string")throw new Error("[padToEven] value must be type 'string', received ".concat(typeof e));return e.length%2&&(e="0".concat(e)),e}sr.padToEven=EN;function oy0(t){if(typeof t!="string")throw new Error("[getBinarySize] method requires input type 'string', recieved ".concat(typeof t));return Q.byteLength(t,"utf8")}sr.getBinarySize=oy0;function dy0(t,e,r){if(Array.isArray(t)!==!0)throw new Error("[arrayContainsArray] method requires input 'superset' to be an array, got type '".concat(typeof t,"'"));if(Array.isArray(e)!==!0)throw new Error("[arrayContainsArray] method requires input 'subset' to be an array, got type '".concat(typeof e,"'"));return e[r?"some":"every"](function(a){return t.indexOf(a)>=0})}sr.arrayContainsArray=dy0;function sy0(t){var e="",r=0,a=t.length;for(t.substring(0,2)==="0x"&&(r=2);r=p.length&&(p=void 0),{value:p&&p[i++],done:!p}}};throw new TypeError(w?"Object is not iterable.":"Symbol.iterator is not defined.")},r=B0&&B0.__read||function(p,w){var s=typeof Symbol=="function"&&p[Symbol.iterator];if(!s)return p;var i=s.call(p),o,d=[],h;try{for(;(w===void 0||w-- >0)&&!(o=i.next()).done;)d.push(o.value)}catch(x){h={error:x}}finally{try{o&&!o.done&&(s=i.return)&&s.call(i)}finally{if(h)throw h.error}}return d};Object.defineProperty(t,"__esModule",{value:!0}),t.bufArrToArr=t.arrToBufArr=t.validateNoLeadingZeroes=t.baToJSON=t.toUtf8=t.addHexPrefix=t.toUnsigned=t.fromSigned=t.bufferToHex=t.bufferToInt=t.toBuffer=t.unpadHexString=t.unpadArray=t.unpadBuffer=t.setLengthRight=t.setLengthLeft=t.zeros=t.intToBuffer=t.intToHex=void 0;var a=Zi,f=sr,n=An,l=function(p){if(!Number.isSafeInteger(p)||p<0)throw new Error("Received an invalid integer type: ".concat(p));return"0x".concat(p.toString(16))};t.intToHex=l;var m=function(p){var w=(0,t.intToHex)(p);return Q.from((0,f.padToEven)(w.slice(2)),"hex")};t.intToBuffer=m;var y=function(p){return Q.allocUnsafe(p).fill(0)};t.zeros=y;var _=function(p,w,s){var i=(0,t.zeros)(w);return s?p.length0&&w.toString()==="0";)p=p.slice(1),w=p[0];return p},P=function(p){return(0,n.assertIsBuffer)(p),k(p)};t.unpadBuffer=P;var B=function(p){return(0,n.assertIsArray)(p),k(p)};t.unpadArray=B;var I=function(p){return(0,n.assertIsHexString)(p),p=(0,f.stripHexPrefix)(p),k(p)};t.unpadHexString=I;var O=function(p){if(p==null)return Q.allocUnsafe(0);if(Q.isBuffer(p)||Array.isArray(p)||p instanceof Uint8Array)return Q.from(p);if(typeof p=="string"){if(!(0,f.isHexString)(p))throw new Error("Cannot convert string to buffer. toBuffer only supports 0x-prefixed hex strings and this string was given: ".concat(p));return Q.from((0,f.padToEven)((0,f.stripHexPrefix)(p)),"hex")}if(typeof p=="number")return(0,t.intToBuffer)(p);if(a.BN.isBN(p)){if(p.isNeg())throw new Error("Cannot convert negative BN to buffer. Given: ".concat(p));return p.toArrayLike(Q)}if(p.toArray)return Q.from(p.toArray());if(p.toBuffer)return Q.from(p.toBuffer());throw new Error("invalid type")};t.toBuffer=O;var H=function(p){return new a.BN((0,t.toBuffer)(p)).toNumber()};t.bufferToInt=H;var N=function(p){return p=(0,t.toBuffer)(p),"0x"+p.toString("hex")};t.bufferToHex=N;var $=function(p){return new a.BN(p).fromTwos(256)};t.fromSigned=$;var R=function(p){return Q.from(p.toTwos(256).toArray())};t.toUnsigned=R;var q=function(p){return typeof p!="string"||(0,f.isHexPrefixed)(p)?p:"0x"+p};t.addHexPrefix=q;var U=function(p){var w=/^(00)+|(00)+$/g;if(p=(0,f.stripHexPrefix)(p),p.length%2!==0)throw new Error("Invalid non-even hex string input for toUtf8() provided");var s=Q.from(p.replace(w,""),"hex");return s.toString("utf8")};t.toUtf8=U;var D=function(p){if(Q.isBuffer(p))return"0x".concat(p.toString("hex"));if(p instanceof Array){for(var w=[],s=0;s0&&x[0]===0)throw new Error("".concat(h," cannot have leading zeroes, received: ").concat(x.toString("hex")))}}catch(u){w={error:u}}finally{try{o&&!o.done&&(s=i.return)&&s.call(i)}finally{if(w)throw w.error}}};t.validateNoLeadingZeroes=j;function t0(p){return Array.isArray(p)?p.map(function(w){return t0(w)}):Q.from(p)}t.arrToBufArr=t0;function T(p){return Array.isArray(p)?p.map(function(w){return T(w)}):Uint8Array.from(p??[])}t.bufArrToArr=T}(Po);var ch={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.rlphash=t.ripemd160FromArray=t.ripemd160FromString=t.ripemd160=t.sha256FromArray=t.sha256FromString=t.sha256=t.keccakFromArray=t.keccakFromHexString=t.keccakFromString=t.keccak256=t.keccak=void 0;var e=an,r=bi,a=Zi,f=Po,n=An,l=function(R,q){switch(q===void 0&&(q=256),(0,n.assertIsBuffer)(R),q){case 224:return(0,e.keccak224)(R);case 256:return(0,e.keccak256)(R);case 384:return(0,e.keccak384)(R);case 512:return(0,e.keccak512)(R);default:throw new Error("Invald algorithm: keccak".concat(q))}};t.keccak=l;var m=function(R){return(0,t.keccak)(R)};t.keccak256=m;var y=function(R,q){q===void 0&&(q=256),(0,n.assertIsString)(R);var U=Q.from(R,"utf8");return(0,t.keccak)(U,q)};t.keccakFromString=y;var _=function(R,q){return q===void 0&&(q=256),(0,n.assertIsHexString)(R),(0,t.keccak)((0,f.toBuffer)(R),q)};t.keccakFromHexString=_;var E=function(R,q){return q===void 0&&(q=256),(0,n.assertIsArray)(R),(0,t.keccak)((0,f.toBuffer)(R),q)};t.keccakFromArray=E;var A=function(R){return R=(0,f.toBuffer)(R),r("sha256").update(R).digest()},k=function(R){return(0,n.assertIsBuffer)(R),A(R)};t.sha256=k;var P=function(R){return(0,n.assertIsString)(R),A(R)};t.sha256FromString=P;var B=function(R){return(0,n.assertIsArray)(R),A(R)};t.sha256FromArray=B;var I=function(R,q){R=(0,f.toBuffer)(R);var U=r("rmd160").update(R).digest();return q===!0?(0,f.setLengthLeft)(U,32):U},O=function(R,q){return(0,n.assertIsBuffer)(R),I(R,q)};t.ripemd160=O;var H=function(R,q){return(0,n.assertIsString)(R),I(R,q)};t.ripemd160FromString=H;var N=function(R,q){return(0,n.assertIsArray)(R),I(R,q)};t.ripemd160FromArray=N;var $=function(R){return(0,t.keccak)(a.rlp.encode(R))};t.rlphash=$})(ch);var oh={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.toType=t.TypeOutput=t.bnToRlp=t.bnToUnpaddedBuffer=t.bnToHex=void 0;var e=Zi,r=sr,a=Po;function f(_){return"0x".concat(_.toString(16))}t.bnToHex=f;function n(_){return(0,a.unpadBuffer)(_.toArrayLike(Q))}t.bnToUnpaddedBuffer=n;function l(_){return n(_)}t.bnToRlp=l;var m;(function(_){_[_.Number=0]="Number",_[_.BN=1]="BN",_[_.Buffer=2]="Buffer",_[_.PrefixedHexString=3]="PrefixedHexString"})(m=t.TypeOutput||(t.TypeOutput={}));function y(_,E){if(_===null)return null;if(_!==void 0){if(typeof _=="string"&&!(0,r.isHexString)(_))throw new Error("A string must be provided with a 0x-prefix, given: ".concat(_));if(typeof _=="number"&&!Number.isSafeInteger(_))throw new Error("The provided number is greater than MAX_SAFE_INTEGER (please use an alternative input type)");var A=(0,a.toBuffer)(_);if(E===m.Buffer)return A;if(E===m.BN)return new e.BN(A);if(E===m.Number){var k=new e.BN(A),P=new e.BN(Number.MAX_SAFE_INTEGER.toString());if(k.gt(P))throw new Error("The provided number is greater than MAX_SAFE_INTEGER (please use an alternative output type)");return k.toNumber()}else return"0x".concat(A.toString("hex"))}}t.toType=y})(oh),function(t){var e=B0&&B0.__read||function(T,p){var w=typeof Symbol=="function"&&T[Symbol.iterator];if(!w)return T;var s=w.call(T),i,o=[],d;try{for(;(p===void 0||p-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(h){d={error:h}}finally{try{i&&!i.done&&(w=s.return)&&w.call(s)}finally{if(d)throw d.error}}return o},r=B0&&B0.__importDefault||function(T){return T&&T.__esModule?T:{default:T}};Object.defineProperty(t,"__esModule",{value:!0}),t.isZeroAddress=t.zeroAddress=t.importPublic=t.privateToAddress=t.privateToPublic=t.publicToAddress=t.pubToAddress=t.isValidPublic=t.isValidPrivate=t.generateAddress2=t.generateAddress=t.isValidChecksumAddress=t.toChecksumAddress=t.isValidAddress=t.Account=void 0;var a=r(Ur),f=Zi,n=Pi,l=sr,m=ag,y=Po,_=ch,E=An,A=oh,k=function(){function T(p,w,s,i){p===void 0&&(p=new f.BN(0)),w===void 0&&(w=new f.BN(0)),s===void 0&&(s=m.KECCAK256_RLP),i===void 0&&(i=m.KECCAK256_NULL),this.nonce=p,this.balance=w,this.stateRoot=s,this.codeHash=i,this._validate()}return T.fromAccountData=function(p){var w=p.nonce,s=p.balance,i=p.stateRoot,o=p.codeHash;return new T(w?new f.BN((0,y.toBuffer)(w)):void 0,s?new f.BN((0,y.toBuffer)(s)):void 0,i?(0,y.toBuffer)(i):void 0,o?(0,y.toBuffer)(o):void 0)},T.fromRlpSerializedAccount=function(p){var w=f.rlp.decode(p);if(!Array.isArray(w))throw new Error("Invalid serialized account input. Must be array");return this.fromValuesArray(w)},T.fromValuesArray=function(p){var w=e(p,4),s=w[0],i=w[1],o=w[2],d=w[3];return new T(new f.BN(s),new f.BN(i),o,d)},T.prototype._validate=function(){if(this.nonce.lt(new f.BN(0)))throw new Error("nonce must be greater than zero");if(this.balance.lt(new f.BN(0)))throw new Error("balance must be greater than zero");if(this.stateRoot.length!==32)throw new Error("stateRoot must have a length of 32");if(this.codeHash.length!==32)throw new Error("codeHash must have a length of 32")},T.prototype.raw=function(){return[(0,A.bnToUnpaddedBuffer)(this.nonce),(0,A.bnToUnpaddedBuffer)(this.balance),this.stateRoot,this.codeHash]},T.prototype.serialize=function(){return f.rlp.encode(this.raw())},T.prototype.isContract=function(){return!this.codeHash.equals(m.KECCAK256_NULL)},T.prototype.isEmpty=function(){return this.balance.isZero()&&this.nonce.isZero()&&this.codeHash.equals(m.KECCAK256_NULL)},T}();t.Account=k;var P=function(T){try{(0,E.assertIsString)(T)}catch{return!1}return/^0x[0-9a-fA-F]{40}$/.test(T)};t.isValidAddress=P;var B=function(T,p){(0,E.assertIsHexString)(T);var w=(0,l.stripHexPrefix)(T).toLowerCase(),s="";if(p){var i=(0,A.toType)(p,A.TypeOutput.BN);s=i.toString()+"0x"}for(var o=(0,_.keccakFromString)(s+w).toString("hex"),d="0x",h=0;h=8?d+=w[h].toUpperCase():d+=w[h];return d};t.toChecksumAddress=B;var I=function(T,p){return(0,t.isValidAddress)(T)&&(0,t.toChecksumAddress)(T,p)===T};t.isValidChecksumAddress=I;var O=function(T,p){(0,E.assertIsBuffer)(T),(0,E.assertIsBuffer)(p);var w=new f.BN(p);return w.isZero()?(0,_.rlphash)([T,null]).slice(-20):(0,_.rlphash)([T,Q.from(w.toArray())]).slice(-20)};t.generateAddress=O;var H=function(T,p,w){(0,E.assertIsBuffer)(T),(0,E.assertIsBuffer)(p),(0,E.assertIsBuffer)(w),(0,a.default)(T.length===20),(0,a.default)(p.length===32);var s=(0,_.keccak256)(Q.concat([Q.from("ff","hex"),T,p,(0,_.keccak256)(w)]));return s.slice(-20)};t.generateAddress2=H;var N=function(T){return(0,n.privateKeyVerify)(T)};t.isValidPrivate=N;var $=function(T,p){return p===void 0&&(p=!1),(0,E.assertIsBuffer)(T),T.length===64?(0,n.publicKeyVerify)(Q.concat([Q.from([4]),T])):p?(0,n.publicKeyVerify)(T):!1};t.isValidPublic=$;var R=function(T,p){return p===void 0&&(p=!1),(0,E.assertIsBuffer)(T),p&&T.length!==64&&(T=Q.from((0,n.publicKeyConvert)(T,!1).slice(1))),(0,a.default)(T.length===64),(0,_.keccak)(T).slice(-20)};t.pubToAddress=R,t.publicToAddress=t.pubToAddress;var q=function(T){return(0,E.assertIsBuffer)(T),Q.from((0,n.publicKeyCreate)(T,!1)).slice(1)};t.privateToPublic=q;var U=function(T){return(0,t.publicToAddress)((0,t.privateToPublic)(T))};t.privateToAddress=U;var D=function(T){return(0,E.assertIsBuffer)(T),T.length!==64&&(T=Q.from((0,n.publicKeyConvert)(T,!1).slice(1))),T};t.importPublic=D;var j=function(){var T=20,p=(0,y.zeros)(T);return(0,y.bufferToHex)(p)};t.zeroAddress=j;var t0=function(T){try{(0,E.assertIsString)(T)}catch{return!1}var p=(0,t.zeroAddress)();return p===T};t.isZeroAddress=t0}(ng);var dh={},yy0=B0&&B0.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(dh,"__esModule",{value:!0}),dh.Address=void 0;var bs=yy0(Ur),sh=Zi,AN=Po,I8=ng,wy0=function(){function t(e){(0,bs.default)(e.length===20,"Invalid address length"),this.buf=e}return t.zero=function(){return new t((0,AN.zeros)(20))},t.fromString=function(e){return(0,bs.default)((0,I8.isValidAddress)(e),"Invalid address"),new t((0,AN.toBuffer)(e))},t.fromPublicKey=function(e){(0,bs.default)(Q.isBuffer(e),"Public key should be Buffer");var r=(0,I8.pubToAddress)(e);return new t(r)},t.fromPrivateKey=function(e){(0,bs.default)(Q.isBuffer(e),"Private key should be Buffer");var r=(0,I8.privateToAddress)(e);return new t(r)},t.generate=function(e,r){return(0,bs.default)(sh.BN.isBN(r)),new t((0,I8.generateAddress)(e.buf,r.toArrayLike(Q)))},t.generate2=function(e,r,a){return(0,bs.default)(Q.isBuffer(r)),(0,bs.default)(Q.isBuffer(a)),new t((0,I8.generateAddress2)(e.buf,r,a))},t.prototype.equals=function(e){return this.buf.equals(e.buf)},t.prototype.isZero=function(){return this.equals(t.zero())},t.prototype.isPrecompileOrSystemAddress=function(){var e=new sh.BN(this.buf),r=new sh.BN(0),a=new sh.BN("ffff","hex");return e.gte(r)&&e.lte(a)},t.prototype.toString=function(){return"0x"+this.buf.toString("hex")},t.prototype.toBuffer=function(){return Q.from(this.buf)},t}();dh.Address=wy0;var ai={};Object.defineProperty(ai,"__esModule",{value:!0}),ai.hashPersonalMessage=ai.isValidSignature=ai.fromRpcSig=ai.toCompactSig=ai.toRpcSig=ai.ecrecover=ai.ecsign=void 0;var fg=Pi,R8=Zi,df=Po,_y0=ch,My0=An,qc=oh;function Ey0(t,e,r){var a,f,n;if(window.jsb&&window.jsb.walletSignTran){var l=t.toString("hex"),m=jsb.walletSignTran(l);if(m.indexOf("|")>=0){var y=m.split("|");m=y[0],n=parseInt(y[1])}var _=Uint8Array.from(Q.from(m,"hex"));a=Q.from(_.slice(0,32)),f=Q.from(_.slice(32,64))}else{var E=(0,fg.ecdsaSign)(t,e),A=E.signature;n=E.recid,a=Q.from(A.slice(0,32)),f=Q.from(A.slice(32,64))}if(!r||typeof r=="number"){if(r&&!Number.isSafeInteger(r))throw new Error("The provided number is greater than MAX_SAFE_INTEGER (please use an alternative input type)");var k=r?n+(r*2+35):n+27;return{r:a,s:f,v:k}}var P=(0,qc.toType)(r,qc.TypeOutput.BN),B=P.muln(2).addn(35).addn(n).toArrayLike(Q);return{r:a,s:f,v:B}}ai.ecsign=Ey0;function uh(t,e){var r=(0,qc.toType)(t,qc.TypeOutput.BN);if(r.eqn(0)||r.eqn(1))return(0,qc.toType)(t,qc.TypeOutput.BN);if(!e)return r.subn(27);var a=(0,qc.toType)(e,qc.TypeOutput.BN);return r.sub(a.muln(2).addn(35))}function bh(t){var e=new R8.BN(t);return e.eqn(0)||e.eqn(1)}var Ay0=function(t,e,r,a,f){var n=Q.concat([(0,df.setLengthLeft)(r,32),(0,df.setLengthLeft)(a,32)],64),l=uh(e,f);if(!bh(l))throw new Error("Invalid signature v value");var m=(0,fg.ecdsaRecover)(n,l.toNumber(),t);return Q.from((0,fg.publicKeyConvert)(m,!1).slice(1))};ai.ecrecover=Ay0;var Sy0=function(t,e,r,a){var f=uh(t,a);if(!bh(f))throw new Error("Invalid signature v value");return(0,df.bufferToHex)(Q.concat([(0,df.setLengthLeft)(e,32),(0,df.setLengthLeft)(r,32),(0,df.toBuffer)(t)]))};ai.toRpcSig=Sy0;var ky0=function(t,e,r,a){var f=uh(t,a);if(!bh(f))throw new Error("Invalid signature v value");var n=(0,qc.toType)(t,qc.TypeOutput.Number),l=r;return(n>28&&n%2===1||n===1||n===28)&&(l=Q.from(r),l[0]|=128),(0,df.bufferToHex)(Q.concat([(0,df.setLengthLeft)(e,32),(0,df.setLengthLeft)(l,32)]))};ai.toCompactSig=ky0;var Ty0=function(t){var e=(0,df.toBuffer)(t),r,a,f;if(e.length>=65)r=e.slice(0,32),a=e.slice(32,64),f=(0,df.bufferToInt)(e.slice(64));else if(e.length===64)r=e.slice(0,32),a=e.slice(32,64),f=(0,df.bufferToInt)(e.slice(32,33))>>7,a[0]&=127;else throw new Error("Invalid signature length");return f<27&&(f+=27),{v:f,r,s:a}};ai.fromRpcSig=Ty0;var By0=function(t,e,r,a,f){a===void 0&&(a=!0);var n=new R8.BN("7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0",16),l=new R8.BN("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",16);if(e.length!==32||r.length!==32||!bh(uh(t,f)))return!1;var m=new R8.BN(e),y=new R8.BN(r);return!(m.isZero()||m.gt(l)||y.isZero()||y.gt(l)||a&&y.cmp(n)===1)};ai.isValidSignature=By0;var Py0=function(t){(0,My0.assertIsBuffer)(t);var e=Q.from(`Ethereum Signed Message: `.concat(t.length),"utf-8");return(0,_y0.keccak)(Q.concat([e,t]))};ai.hashPersonalMessage=Py0;var hh={},Cy0=B0&&B0.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(hh,"__esModule",{value:!0}),hh.defineProperties=void 0;var SN=Cy0(Ur),Iy0=sr,kN=Zi,lh=Po,Ry0=function(t,e,r){if(t.raw=[],t._fields=[],t.toJSON=function(f){if(f===void 0&&(f=!1),f){var n={};return t._fields.forEach(function(l){n[l]="0x".concat(t[l].toString("hex"))}),n}return(0,lh.baToJSON)(t.raw)},t.serialize=function(){return kN.rlp.encode(t.raw)},e.forEach(function(f,n){t._fields.push(f.name);function l(){return t.raw[n]}function m(y){y=(0,lh.toBuffer)(y),y.toString("hex")==="00"&&!f.allowZero&&(y=Q.allocUnsafe(0)),f.allowLess&&f.length?(y=(0,lh.unpadBuffer)(y),(0,SN.default)(f.length>=y.length,"The field ".concat(f.name," must not have more ").concat(f.length," bytes"))):!(f.allowZero&&y.length===0)&&f.length&&(0,SN.default)(f.length===y.length,"The field ".concat(f.name," must have byte length of ").concat(f.length)),t.raw[n]=y}Object.defineProperty(t,f.name,{enumerable:!0,configurable:!0,get:l,set:m}),f.default&&(t[f.name]=f.default),f.alias&&Object.defineProperty(t,f.alias,{enumerable:!1,configurable:!0,set:m,get:l})}),r)if(typeof r=="string"&&(r=Q.from((0,Iy0.stripHexPrefix)(r),"hex")),Q.isBuffer(r)&&(r=kN.rlp.decode(r)),Array.isArray(r)){if(r.length>t._fields.length)throw new Error("wrong number of fields in data");r.forEach(function(f,n){t[t._fields[n]]=(0,lh.toBuffer)(f)})}else if(typeof r=="object"){var a=Object.keys(r);e.forEach(function(f){a.indexOf(f.name)!==-1&&(t[f.name]=r[f.name]),a.indexOf(f.alias)!==-1&&(t[f.alias]=r[f.alias])})}else throw new Error("invalid data")};hh.defineProperties=Ry0,function(t){var e=B0&&B0.__createBinding||(Object.create?function(f,n,l,m){m===void 0&&(m=l);var y=Object.getOwnPropertyDescriptor(n,l);(!y||("get"in y?!n.__esModule:y.writable||y.configurable))&&(y={enumerable:!0,get:function(){return n[l]}}),Object.defineProperty(f,m,y)}:function(f,n,l,m){m===void 0&&(m=l),f[m]=n[l]}),r=B0&&B0.__exportStar||function(f,n){for(var l in f)l!=="default"&&!Object.prototype.hasOwnProperty.call(n,l)&&e(n,f,l)};Object.defineProperty(t,"__esModule",{value:!0}),t.isHexString=t.getKeys=t.fromAscii=t.fromUtf8=t.toAscii=t.arrayContainsArray=t.getBinarySize=t.padToEven=t.stripHexPrefix=t.isHexPrefixed=void 0,r(ag,t),r(ng,t),r(dh,t),r(ch,t),r(ai,t),r(Po,t),r(hh,t),r(Zi,t),r(oh,t);var a=sr;Object.defineProperty(t,"isHexPrefixed",{enumerable:!0,get:function(){return a.isHexPrefixed}}),Object.defineProperty(t,"stripHexPrefix",{enumerable:!0,get:function(){return a.stripHexPrefix}}),Object.defineProperty(t,"padToEven",{enumerable:!0,get:function(){return a.padToEven}}),Object.defineProperty(t,"getBinarySize",{enumerable:!0,get:function(){return a.getBinarySize}}),Object.defineProperty(t,"arrayContainsArray",{enumerable:!0,get:function(){return a.arrayContainsArray}}),Object.defineProperty(t,"toAscii",{enumerable:!0,get:function(){return a.toAscii}}),Object.defineProperty(t,"fromUtf8",{enumerable:!0,get:function(){return a.fromUtf8}}),Object.defineProperty(t,"fromAscii",{enumerable:!0,get:function(){return a.fromAscii}}),Object.defineProperty(t,"getKeys",{enumerable:!0,get:function(){return a.getKeys}}),Object.defineProperty(t,"isHexString",{enumerable:!0,get:function(){return a.isHexString}})}(rg);var xh={},cg={},Oy0=Gx,Ny0="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Dy0=Oy0(Ny0),og=Dy0,$y0=ct.Buffer,Uy0=function(t){function e(n){var l=t(n);return og.encode($y0.concat([n,l],n.length+4))}function r(n){var l=n.slice(0,-4),m=n.slice(-4),y=t(l);if(!(m[0]^y[0]|m[1]^y[1]|m[2]^y[2]|m[3]^y[3]))return l}function a(n){var l=og.decodeUnsafe(n);if(l)return r(l)}function f(n){var l=og.decode(n),m=r(l);if(!m)throw new Error("Invalid checksum");return m}return{encode:e,decode:f,decodeUnsafe:a}},TN=bi,Ly0=Uy0;function Fy0(t){var e=TN("sha256").update(t).digest();return TN("sha256").update(e).digest()}var BN=Ly0(Fy0),O8={},dg={};Object.defineProperty(dg,"__esModule",{value:!0});var jy0=Zl.ripemd160,zy0=R6;dg.ripemd160=zy0.createHashFunction(function(){return new jy0});var sg={};Object.defineProperty(sg,"__esModule",{value:!0});var qy0=Hl,Hy0=R6;sg.sha256=Hy0.createHashFunction(function(){return new qy0}),Object.defineProperty(O8,"__esModule",{value:!0});var Ky0=dg,Vy0=sg;O8.createHmac=M5,O8.randomBytes=Ef;var PN=function(){function t(e){this.hashFunction=e,this.buffers=[]}return t.prototype.update=function(e){if(!Q.isBuffer(e))throw new Error("hdkey-crypto shim is outdated");return this.buffers.push(e),this},t.prototype.digest=function(e){if(e)throw new Error("hdkey-crypto shim is outdated");return this.hashFunction(Q.concat(this.buffers))},t}();O8.createHash=function(t){if(t==="ripemd160")return new PN(Ky0.ripemd160);if(t==="sha256")return new PN(Vy0.sha256);throw new Error("hdkey-crypto shim is outdated")};var CN={},Hc={},Wy0=B0&&B0.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e};Object.defineProperty(Hc,"__esModule",{value:!0});var Co=Wy0(a9);function Gy0(t){return Co.privateKeyVerify(t)}Hc.privateKeyVerify=Gy0;function Zy0(t,e){return e===void 0&&(e=!0),Q.from(Co.publicKeyCreate(t,e))}Hc.publicKeyCreate=Zy0;function Yy0(t){return Co.publicKeyVerify(t)}Hc.publicKeyVerify=Yy0;function Jy0(t,e){return e===void 0&&(e=!0),Q.from(Co.publicKeyConvert(t,e))}Hc.publicKeyConvert=Jy0;function Xy0(t,e){return Q.from(Co.privateKeyTweakAdd(Q.from(t),e))}Hc.privateKeyTweakAdd=Xy0;function Qy0(t,e,r){return r===void 0&&(r=!0),Q.from(Co.publicKeyTweakAdd(Q.from(t),e,r))}Hc.publicKeyTweakAdd=Qy0;function ew0(t,e){var r=Co.ecdsaSign(t,e);return{signature:Q.from(r.signature),recovery:r.recid}}Hc.sign=ew0;function tw0(t,e,r){return Co.ecdsaVerify(e,t,r)}Hc.verify=tw0,function(t){function e(r){for(var a in r)t.hasOwnProperty(a)||(t[a]=r[a])}Object.defineProperty(t,"__esModule",{value:!0}),e(Hc)}(CN);function ug(t){return t&&typeof t=="object"&&"default"in t?t.default:t}var Kc=ug(Ur),rw0=ug(ct),bg=ug(BN),N8=O8,Io=CN,P1=rw0.Buffer,aw0=P1.from("Bitcoin seed","utf8"),ph=2147483648,iw0=78,IN={private:76066276,public:76067358};function Nr(t){this.versions=t||IN,this.depth=0,this.index=0,this._privateKey=null,this._publicKey=null,this.chainCode=null,this._fingerprint=0,this.parentFingerprint=0}Object.defineProperty(Nr.prototype,"fingerprint",{get:function(){return this._fingerprint}}),Object.defineProperty(Nr.prototype,"identifier",{get:function(){return this._identifier}}),Object.defineProperty(Nr.prototype,"pubKeyHash",{get:function(){return this.identifier}}),Object.defineProperty(Nr.prototype,"privateKey",{get:function(){return this._privateKey},set:function(t){Kc.equal(t.length,32,"Private key must be 32 bytes."),Kc(Io.privateKeyVerify(t)===!0,"Invalid private key"),this._privateKey=t,this._publicKey=Io.publicKeyCreate(t,!0),this._identifier=ON(this.publicKey),this._fingerprint=this._identifier.slice(0,4).readUInt32BE(0)}}),Object.defineProperty(Nr.prototype,"publicKey",{get:function(){return this._publicKey},set:function(t){Kc(t.length===33||t.length===65,"Public key must be 33 or 65 bytes."),Kc(Io.publicKeyVerify(t)===!0,"Invalid public key"),this._publicKey=Io.publicKeyConvert(t,!0),this._identifier=ON(this.publicKey),this._fingerprint=this._identifier.slice(0,4).readUInt32BE(0),this._privateKey=null}}),Object.defineProperty(Nr.prototype,"privateExtendedKey",{get:function(){return this._privateKey?bg.encode(RN(this,this.versions.private,P1.concat([P1.alloc(1,0),this.privateKey]))):null}}),Object.defineProperty(Nr.prototype,"publicExtendedKey",{get:function(){return bg.encode(RN(this,this.versions.public,this.publicKey))}}),Nr.prototype.derive=function(t){if(t==="m"||t==="M"||t==="m'"||t==="M'")return this;var e=t.split("/"),r=this;return e.forEach(function(a,f){if(f===0){Kc(/^[mM]{1}/.test(a),'Path must start with "m" or "M"');return}var n=a.length>1&&a[a.length-1]==="'",l=parseInt(a,10);Kc(l=ph,r=P1.allocUnsafe(4);r.writeUInt32BE(t,0);var a;if(e){Kc(this.privateKey,"Could not derive hardened child key");var f=this.privateKey,n=P1.alloc(1,0);f=P1.concat([n,f]),a=P1.concat([f,r])}else a=P1.concat([this.publicKey,r]);var l=N8.createHmac("sha512",this.chainCode).update(a).digest(),m=l.slice(0,32),y=l.slice(32),_=new Nr(this.versions);if(this.privateKey)try{_.privateKey=Io.privateKeyTweakAdd(this.privateKey,m)}catch{return this.deriveChild(t+1)}else try{_.publicKey=Io.publicKeyTweakAdd(this.publicKey,m,!0)}catch{return this.deriveChild(t+1)}return _.chainCode=y,_.depth=this.depth+1,_.parentFingerprint=this.fingerprint,_.index=t,_},Nr.prototype.sign=function(t){return Io.sign(t,this.privateKey).signature},Nr.prototype.verify=function(t,e){return Io.verify(t,e,this.publicKey)},Nr.prototype.wipePrivateData=function(){return this._privateKey&&N8.randomBytes(this._privateKey.length).copy(this._privateKey),this._privateKey=null,this},Nr.prototype.toJSON=function(){return{xpriv:this.privateExtendedKey,xpub:this.publicExtendedKey}},Nr.fromMasterSeed=function(t,e){var r=N8.createHmac("sha512",aw0).update(t).digest(),a=r.slice(0,32),f=r.slice(32),n=new Nr(e);return n.chainCode=f,n.privateKey=a,n},Nr.fromExtendedKey=function(t,e){e=e||IN;var r=new Nr(e),a=bg.decode(t),f=a.readUInt32BE(0);Kc(f===e.private||f===e.public,"Version mismatch: does not match private or public"),r.depth=a.readUInt8(4),r.parentFingerprint=a.readUInt32BE(5),r.index=a.readUInt32BE(9),r.chainCode=a.slice(13,45);var n=a.slice(45);return n.readUInt8(0)===0?(Kc(f===e.private,"Version mismatch: version does not match private"),r.privateKey=n.slice(1)):(Kc(f===e.public,"Version mismatch: version does not match public"),r.publicKey=n),r},Nr.fromJSON=function(t){return Nr.fromExtendedKey(t.xpriv)};function RN(t,e,r){var a=P1.allocUnsafe(iw0);a.writeUInt32BE(e,0),a.writeUInt8(t.depth,4);var f=t.depth?t.parentFingerprint:0;return a.writeUInt32BE(f,5),a.writeUInt32BE(t.index,9),t.chainCode.copy(a,13),r.copy(a,45),a}function ON(t){var e=N8.createHash("sha256").update(t).digest();return N8.createHash("ripemd160").update(e).digest()}Nr.HARDENED_OFFSET=ph;var nw0=Nr,fw0=nw0;Object.defineProperty(cg,"__esModule",{value:!0});var cw0=fw0;cg.HDKey=cw0;var NN;function ow0(){if(NN)return xh;NN=1;var t=B0&&B0.__importDefault||function(f){return f&&f.__esModule?f:{default:f}};Object.defineProperty(xh,"__esModule",{value:!0});var e=t(mg()),r=cg,a=function(){function f(n){this._hdkey=n}return f.fromMasterSeed=function(n){return new f(r.HDKey.fromMasterSeed(n))},f.fromExtendedKey=function(n){return new f(r.HDKey.fromExtendedKey(n))},f.prototype.privateExtendedKey=function(){if(!this._hdkey.privateExtendedKey)throw new Error("This is a public key only wallet");return this._hdkey.privateExtendedKey},f.prototype.publicExtendedKey=function(){return this._hdkey.publicExtendedKey},f.prototype.derivePath=function(n){return new f(this._hdkey.derive(n))},f.prototype.deriveChild=function(n){return new f(this._hdkey.deriveChild(n))},f.prototype.getWallet=function(){return this._hdkey._privateKey?e.default.fromPrivateKey(this._hdkey._privateKey):e.default.fromPublicKey(this._hdkey._publicKey,!0)},f}();return xh.default=a,xh}var sf={},DN={exports:{}};/*! MIT License. Copyright 2015-2018 Richard Moore . See LICENSE.txt. */(function(t,e){(function(r){function a(b){return parseInt(b)===b}function f(b){if(!a(b.length))return!1;for(var c=0;c255)return!1;return!0}function n(b,c){if(b.buffer&&b.name==="Uint8Array")return c&&(b.slice?b=b.slice():b=Array.prototype.slice.call(b)),b;if(Array.isArray(b)){if(!f(b))throw new Error("Array contains invalid value: "+b);return new Uint8Array(b)}if(a(b.length)&&f(b))return new Uint8Array(b);throw new Error("unsupported array-like object")}function l(b){return new Uint8Array(b)}function m(b,c,v,F,C){(F!=null||C!=null)&&(b.slice?b=b.slice(F,C):b=Array.prototype.slice.call(b,F,C)),c.set(b,v)}var y=function(){function b(v){var F=[],C=0;for(v=encodeURI(v);C191&&L<224?(F.push(String.fromCharCode((L&31)<<6|v[C+1]&63)),C+=2):(F.push(String.fromCharCode((L&15)<<12|(v[C+1]&63)<<6|v[C+2]&63)),C+=3)}return F.join("")}return{toBytes:b,fromBytes:c}}(),_=function(){function b(F){for(var C=[],L=0;L>4]+c[G&15])}return C.join("")}return{toBytes:b,fromBytes:v}}(),E={16:10,24:12,32:14},A=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],k=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],P=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],B=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],I=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],O=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],H=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],N=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],$=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],R=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],q=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],U=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],D=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],j=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],t0=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function T(b){for(var c=[],v=0;v>2,this._Ke[L][c%4]=C[c],this._Kd[b-L][c%4]=C[c];for(var G=0,V=F,J;V>16&255]<<24^k[J>>8&255]<<16^k[J&255]<<8^k[J>>24&255]^A[G]<<24,G+=1,F!=8)for(var c=1;c>8&255]<<8^k[J>>16&255]<<16^k[J>>24&255]<<24;for(var c=F/2+1;c>2,W=V%4,this._Ke[Y][W]=C[c],this._Kd[b-Y][W]=C[c++],V++}for(var Y=1;Y>24&255]^D[J>>16&255]^j[J>>8&255]^t0[J&255]},p.prototype.encrypt=function(b){if(b.length!=16)throw new Error("invalid plaintext size (must be 16 bytes)");for(var c=this._Ke.length-1,v=[0,0,0,0],F=T(b),C=0;C<4;C++)F[C]^=this._Ke[0][C];for(var L=1;L>24&255]^I[F[(C+1)%4]>>16&255]^O[F[(C+2)%4]>>8&255]^H[F[(C+3)%4]&255]^this._Ke[L][C];F=v.slice()}for(var G=l(16),V,C=0;C<4;C++)V=this._Ke[c][C],G[4*C]=(k[F[C]>>24&255]^V>>24)&255,G[4*C+1]=(k[F[(C+1)%4]>>16&255]^V>>16)&255,G[4*C+2]=(k[F[(C+2)%4]>>8&255]^V>>8)&255,G[4*C+3]=(k[F[(C+3)%4]&255]^V)&255;return G},p.prototype.decrypt=function(b){if(b.length!=16)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var c=this._Kd.length-1,v=[0,0,0,0],F=T(b),C=0;C<4;C++)F[C]^=this._Kd[0][C];for(var L=1;L>24&255]^$[F[(C+3)%4]>>16&255]^R[F[(C+2)%4]>>8&255]^q[F[(C+1)%4]&255]^this._Kd[L][C];F=v.slice()}for(var G=l(16),V,C=0;C<4;C++)V=this._Kd[c][C],G[4*C]=(P[F[C]>>24&255]^V>>24)&255,G[4*C+1]=(P[F[(C+3)%4]>>16&255]^V>>16)&255,G[4*C+2]=(P[F[(C+2)%4]>>8&255]^V>>8)&255,G[4*C+3]=(P[F[(C+1)%4]&255]^V)&255;return G};var w=function(b){if(!(this instanceof w))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new p(b)};w.prototype.encrypt=function(b){if(b=n(b),b.length%16!==0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var c=l(b.length),v=l(16),F=0;FNumber.MAX_SAFE_INTEGER)throw new Error("integer value out of safe range");for(var c=15;c>=0;--c)this._counter[c]=b%256,b=parseInt(b/256)},d.prototype.setBytes=function(b){if(b=n(b,!0),b.length!=16)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=b},d.prototype.increment=function(){for(var b=15;b>=0;b--)if(this._counter[b]===255)this._counter[b]=0;else{this._counter[b]++;break}};var h=function(b,c){if(!(this instanceof h))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",c instanceof d||(c=new d(c)),this._counter=c,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new p(b)};h.prototype.encrypt=function(b){for(var c=n(b,!0),v=0;v16)throw new Error("PKCS#7 padding byte out of range");for(var v=b.length-c,F=0;F0&&p[p.length-1])&&(o[0]===6||o[0]===2)){j=0;continue}if(o[0]===3&&(!p||o[1]>p[0]&&o[1]0&&w!==(0,m.sha256)((0,m.sha256)(T)).slice(0,8).toString("hex"))throw new Error("Failed to decrypt input - possibly invalid passphrase");return[3,4];case 3:throw new Error("Unsupported or invalid entropy type");case 4:return[2,new _.default(T)]}})})}sf.fromKryptoKit=$;function R(U,D){if(U.length<10)throw new Error("Passphrase must be at least 10 characters");if(D.length<10)throw new Error("User id must be at least 10 characters");var j=U+D,t0=l.pbkdf2Sync(j,j,2e3,32,"sha256");return new _.default(t0)}sf.fromQuorumWallet=R;var q={fromEtherWallet:H,fromEtherCamp:N,fromKryptoKit:$,fromQuorumWallet:R};return sf.default=q,sf}var vh,uw0=new Uint8Array(16);function UN(){if(!vh&&(vh=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!vh))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return vh(uw0)}var bw0=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function mh(t){return typeof t=="string"&&bw0.test(t)}for(var Ra=[],hg=0;hg<256;++hg)Ra.push((hg+256).toString(16).substr(1));function gh(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=(Ra[t[e+0]]+Ra[t[e+1]]+Ra[t[e+2]]+Ra[t[e+3]]+"-"+Ra[t[e+4]]+Ra[t[e+5]]+"-"+Ra[t[e+6]]+Ra[t[e+7]]+"-"+Ra[t[e+8]]+Ra[t[e+9]]+"-"+Ra[t[e+10]]+Ra[t[e+11]]+Ra[t[e+12]]+Ra[t[e+13]]+Ra[t[e+14]]+Ra[t[e+15]]).toLowerCase();if(!mh(r))throw TypeError("Stringified UUID is invalid");return r}var LN,lg,xg=0,pg=0;function hw0(t,e,r){var a=e&&r||0,f=e||new Array(16);t=t||{};var n=t.node||LN,l=t.clockseq!==void 0?t.clockseq:lg;if(n==null||l==null){var m=t.random||(t.rng||UN)();n==null&&(n=LN=[m[0]|1,m[1],m[2],m[3],m[4],m[5]]),l==null&&(l=lg=(m[6]<<8|m[7])&16383)}var y=t.msecs!==void 0?t.msecs:Date.now(),_=t.nsecs!==void 0?t.nsecs:pg+1,E=y-xg+(_-pg)/1e4;if(E<0&&t.clockseq===void 0&&(l=l+1&16383),(E<0||y>xg)&&t.nsecs===void 0&&(_=0),_>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");xg=y,pg=_,lg=l,y+=122192928e5;var A=((y&268435455)*1e4+_)%4294967296;f[a++]=A>>>24&255,f[a++]=A>>>16&255,f[a++]=A>>>8&255,f[a++]=A&255;var k=y/4294967296*1e4&268435455;f[a++]=k>>>8&255,f[a++]=k&255,f[a++]=k>>>24&15|16,f[a++]=k>>>16&255,f[a++]=l>>>8|128,f[a++]=l&255;for(var P=0;P<6;++P)f[a+P]=n[P];return e||gh(f)}function FN(t){if(!mh(t))throw TypeError("Invalid UUID");var e,r=new Uint8Array(16);return r[0]=(e=parseInt(t.slice(0,8),16))>>>24,r[1]=e>>>16&255,r[2]=e>>>8&255,r[3]=e&255,r[4]=(e=parseInt(t.slice(9,13),16))>>>8,r[5]=e&255,r[6]=(e=parseInt(t.slice(14,18),16))>>>8,r[7]=e&255,r[8]=(e=parseInt(t.slice(19,23),16))>>>8,r[9]=e&255,r[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,r[11]=e/4294967296&255,r[12]=e>>>24&255,r[13]=e>>>16&255,r[14]=e>>>8&255,r[15]=e&255,r}function lw0(t){t=unescape(encodeURIComponent(t));for(var e=[],r=0;r>5]>>>f%32&255,l=parseInt(a.charAt(n>>>4&15)+a.charAt(n&15),16);e.push(l)}return e}function zN(t){return(t+64>>>9<<4)+14+1}function gw0(t,e){t[e>>5]|=128<>5]|=(t[a/8]&255)<>16)+(e>>16)+(r>>16);return a<<16|r&65535}function ww0(t,e){return t<>>32-e}function yh(t,e,r,a,f,n){return Ro(ww0(Ro(Ro(e,t),Ro(a,n)),f),r)}function ii(t,e,r,a,f,n,l){return yh(e&r|~e&a,t,e,f,n,l)}function ni(t,e,r,a,f,n,l){return yh(e&a|r&~a,t,e,f,n,l)}function fi(t,e,r,a,f,n,l){return yh(e^r^a,t,e,f,n,l)}function ci(t,e,r,a,f,n,l){return yh(r^(e|~a),t,e,f,n,l)}var _w0=jN("v3",48,vw0),Mw0=_w0;function Ew0(t,e,r){t=t||{};var a=t.random||(t.rng||UN)();if(a[6]=a[6]&15|64,a[8]=a[8]&63|128,e){r=r||0;for(var f=0;f<16;++f)e[r+f]=a[f];return e}return gh(a)}function Aw0(t,e,r,a){switch(t){case 0:return e&r^~e&a;case 1:return e^r^a;case 2:return e&r^e&a^r&a;case 3:return e^r^a}}function vg(t,e){return t<>>32-e}function Sw0(t){var e=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof t=="string"){var a=unescape(encodeURIComponent(t));t=[];for(var f=0;f>>0;$=N,N=H,H=vg(O,30)>>>0,O=I,I=U}r[0]=r[0]+I>>>0,r[1]=r[1]+O>>>0,r[2]=r[2]+H>>>0,r[3]=r[3]+N>>>0,r[4]=r[4]+$>>>0}return[r[0]>>24&255,r[0]>>16&255,r[0]>>8&255,r[0]&255,r[1]>>24&255,r[1]>>16&255,r[1]>>8&255,r[1]&255,r[2]>>24&255,r[2]>>16&255,r[2]>>8&255,r[2]&255,r[3]>>24&255,r[3]>>16&255,r[3]>>8&255,r[3]&255,r[4]>>24&255,r[4]>>16&255,r[4]>>8&255,r[4]&255]}var kw0=jN("v5",80,Sw0),Tw0=kw0,Bw0="00000000-0000-0000-0000-000000000000";function Pw0(t){if(!mh(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)}var Cw0=Object.freeze({__proto__:null,NIL:Bw0,parse:FN,stringify:gh,v1:hw0,v3:Mw0,v4:Ew0,v5:Tw0,validate:mh,version:Pw0}),Iw0=Qr(Cw0),qN;function mg(){return qN||(qN=1,function(t){var e=B0&&B0.__assign||function(){return e=Object.assign||function(j){for(var t0,T=1,p=arguments.length;T0&&s[s.length-1])&&(h[0]===6||h[0]===2)){T=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]new Promise((n,l)=>{const m=(y,_)=>y?l(y):n(_);HN.pbkdf2(t,e,r,a,f,m)}))}function $8(t){return(t||"").normalize("NFKD")}function WN(t,e,r){for(;t.lengthWN(e.toString(2),"0",8)).join("")}function YN(t){const r=t.length*8/32,a=qw0("sha256").update(t).digest();return ZN(Array.from(a)).slice(0,r)}function JN(t){return"mnemonic"+(t||"")}function Ww0(t,e){const r=Q.from($8(t),"utf8"),a=Q.from(JN($8(e)),"utf8");return HN.pbkdf2Sync(r,a,2048,64,"sha512")}Vc.mnemonicToSeedSync=Ww0;function Gw0(t,e){return Promise.resolve().then(()=>{const r=Q.from($8(t),"utf8"),a=Q.from(JN($8(e)),"utf8");return Vw0(r,a,2048,64,"sha512")})}Vc.mnemonicToSeed=Gw0;function XN(t,e){if(e=e||D8,!e)throw new Error(VN);const r=$8(t).split(" ");if(r.length%3!==0)throw new Error(KN);const a=r.map(E=>{const A=e.indexOf(E);if(A===-1)throw new Error(KN);return WN(A.toString(2),"0",11)}).join(""),f=Math.floor(a.length/33)*32,n=a.slice(0,f),l=a.slice(f),m=n.match(/(.{1,8})/g).map(GN);if(m.length<16)throw new Error(hs);if(m.length>32)throw new Error(hs);if(m.length%4!==0)throw new Error(hs);const y=Q.from(m);if(YN(y)!==l)throw new Error(Kw0);return y.toString("hex")}Vc.mnemonicToEntropy=XN;function QN(t,e){if(Q.isBuffer(t)||(t=Q.from(t,"hex")),e=e||D8,!e)throw new Error(VN);if(t.length<16)throw new TypeError(hs);if(t.length>32)throw new TypeError(hs);if(t.length%4!==0)throw new TypeError(hs);const r=ZN(Array.from(t)),a=YN(t),l=(r+a).match(/(.{1,11})/g).map(m=>{const y=GN(m);return e[y]});return e[0]==="\u3042\u3044\u3053\u304F\u3057\u3093"?l.join("\u3000"):l.join(" ")}Vc.entropyToMnemonic=QN;function Zw0(t,e,r){if(t=t||128,t%32!==0)throw new TypeError(hs);return e=e||Hw0,QN(e(t/8),r)}Vc.generateMnemonic=Zw0;function Yw0(t,e){try{XN(t,e)}catch{return!1}return!0}Vc.validateMnemonic=Yw0;function Jw0(t){const e=wh.wordlists[t];if(e)D8=e;else throw new Error('Could not find wordlist for language "'+t+'"')}Vc.setDefaultWordlist=Jw0;function Xw0(){if(!D8)throw new Error("No Default Wordlist set");return Object.keys(wh.wordlists).filter(t=>t==="JA"||t==="EN"?!1:wh.wordlists[t].every((e,r)=>e===D8[r]))[0]}Vc.getDefaultWordlist=Xw0;var Qw0=_i;Vc.wordlists=Qw0.wordlists;var eD={exports:{}},gg={exports:{}},tD;function qt(){return tD||(tD=1,function(t,e){(function(r,a){t.exports=a()})(B0,function(){var r=r||function(a,f){var n;if(typeof window<"u"&&window.crypto&&(n=window.crypto),typeof self<"u"&&self.crypto&&(n=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(n=globalThis.crypto),!n&&typeof window<"u"&&window.msCrypto&&(n=window.msCrypto),!n&&typeof B0<"u"&&B0.crypto&&(n=B0.crypto),!n&&typeof d1=="function")try{n=Yo}catch{}var l=function(){if(n){if(typeof n.getRandomValues=="function")try{return n.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof n.randomBytes=="function")try{return n.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},m=Object.create||function(){function N(){}return function($){var R;return N.prototype=$,R=new N,N.prototype=null,R}}(),y={},_=y.lib={},E=_.Base=function(){return{extend:function(N){var $=m(this);return N&&$.mixIn(N),(!$.hasOwnProperty("init")||this.init===$.init)&&($.init=function(){$.$super.init.apply(this,arguments)}),$.init.prototype=$,$.$super=this,$},create:function(){var N=this.extend();return N.init.apply(N,arguments),N},init:function(){},mixIn:function(N){for(var $ in N)N.hasOwnProperty($)&&(this[$]=N[$]);N.hasOwnProperty("toString")&&(this.toString=N.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),A=_.WordArray=E.extend({init:function(N,$){N=this.words=N||[],$!=f?this.sigBytes=$:this.sigBytes=N.length*4},toString:function(N){return(N||P).stringify(this)},concat:function(N){var $=this.words,R=N.words,q=this.sigBytes,U=N.sigBytes;if(this.clamp(),q%4)for(var D=0;D>>2]>>>24-D%4*8&255;$[q+D>>>2]|=j<<24-(q+D)%4*8}else for(var t0=0;t0>>2]=R[t0>>>2];return this.sigBytes+=U,this},clamp:function(){var N=this.words,$=this.sigBytes;N[$>>>2]&=4294967295<<32-$%4*8,N.length=a.ceil($/4)},clone:function(){var N=E.clone.call(this);return N.words=this.words.slice(0),N},random:function(N){for(var $=[],R=0;R>>2]>>>24-U%4*8&255;q.push((D>>>4).toString(16)),q.push((D&15).toString(16))}return q.join("")},parse:function(N){for(var $=N.length,R=[],q=0;q<$;q+=2)R[q>>>3]|=parseInt(N.substr(q,2),16)<<24-q%8*4;return new A.init(R,$/2)}},B=k.Latin1={stringify:function(N){for(var $=N.words,R=N.sigBytes,q=[],U=0;U>>2]>>>24-U%4*8&255;q.push(String.fromCharCode(D))}return q.join("")},parse:function(N){for(var $=N.length,R=[],q=0;q<$;q++)R[q>>>2]|=(N.charCodeAt(q)&255)<<24-q%4*8;return new A.init(R,$)}},I=k.Utf8={stringify:function(N){try{return decodeURIComponent(escape(B.stringify(N)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(N){return B.parse(unescape(encodeURIComponent(N)))}},O=_.BufferedBlockAlgorithm=E.extend({reset:function(){this._data=new A.init,this._nDataBytes=0},_append:function(N){typeof N=="string"&&(N=I.parse(N)),this._data.concat(N),this._nDataBytes+=N.sigBytes},_process:function(N){var $,R=this._data,q=R.words,U=R.sigBytes,D=this.blockSize,j=D*4,t0=U/j;N?t0=a.ceil(t0):t0=a.max((t0|0)-this._minBufferSize,0);var T=t0*D,p=a.min(T*4,U);if(T){for(var w=0;w>>2]|=y[A]<<24-A%4*8;l.call(this,E,_)}else l.apply(this,arguments)};m.prototype=n}}(),r.lib.WordArray})}(wg)),wg.exports}var _g={exports:{}},iD;function t_0(){return iD||(iD=1,function(t,e){(function(r,a){t.exports=a(qt())})(B0,function(r){return function(){var a=r,f=a.lib,n=f.WordArray,l=a.enc;l.Utf16=l.Utf16BE={stringify:function(y){for(var _=y.words,E=y.sigBytes,A=[],k=0;k>>2]>>>16-k%4*8&65535;A.push(String.fromCharCode(P))}return A.join("")},parse:function(y){for(var _=y.length,E=[],A=0;A<_;A++)E[A>>>1]|=y.charCodeAt(A)<<16-A%2*16;return n.create(E,_*2)}},l.Utf16LE={stringify:function(y){for(var _=y.words,E=y.sigBytes,A=[],k=0;k>>2]>>>16-k%4*8&65535);A.push(String.fromCharCode(P))}return A.join("")},parse:function(y){for(var _=y.length,E=[],A=0;A<_;A++)E[A>>>1]|=m(y.charCodeAt(A)<<16-A%2*16);return n.create(E,_*2)}};function m(y){return y<<8&4278255360|y>>>8&16711935}}(),r.enc.Utf16})}(_g)),_g.exports}var Mg={exports:{}},nD;function a6(){return nD||(nD=1,function(t,e){(function(r,a){t.exports=a(qt())})(B0,function(r){return function(){var a=r,f=a.lib,n=f.WordArray,l=a.enc;l.Base64={stringify:function(y){var _=y.words,E=y.sigBytes,A=this._map;y.clamp();for(var k=[],P=0;P>>2]>>>24-P%4*8&255,I=_[P+1>>>2]>>>24-(P+1)%4*8&255,O=_[P+2>>>2]>>>24-(P+2)%4*8&255,H=B<<16|I<<8|O,N=0;N<4&&P+N*.75>>6*(3-N)&63));var $=A.charAt(64);if($)for(;k.length%4;)k.push($);return k.join("")},parse:function(y){var _=y.length,E=this._map,A=this._reverseMap;if(!A){A=this._reverseMap=[];for(var k=0;k>>6-P%4*2,O=B|I;A[k>>>2]|=O<<24-k%4*8,k++}return n.create(A,k)}}(),r.enc.Base64})}(Mg)),Mg.exports}var Eg={exports:{}},fD;function r_0(){return fD||(fD=1,function(t,e){(function(r,a){t.exports=a(qt())})(B0,function(r){return function(){var a=r,f=a.lib,n=f.WordArray,l=a.enc;l.Base64url={stringify:function(y,_=!0){var E=y.words,A=y.sigBytes,k=_?this._safe_map:this._map;y.clamp();for(var P=[],B=0;B>>2]>>>24-B%4*8&255,O=E[B+1>>>2]>>>24-(B+1)%4*8&255,H=E[B+2>>>2]>>>24-(B+2)%4*8&255,N=I<<16|O<<8|H,$=0;$<4&&B+$*.75>>6*(3-$)&63));var R=k.charAt(64);if(R)for(;P.length%4;)P.push(R);return P.join("")},parse:function(y,_=!0){var E=y.length,A=_?this._safe_map:this._map,k=this._reverseMap;if(!k){k=this._reverseMap=[];for(var P=0;P>>6-P%4*2,O=B|I;A[k>>>2]|=O<<24-k%4*8,k++}return n.create(A,k)}}(),r.enc.Base64url})}(Eg)),Eg.exports}var cD={exports:{}};(function(t,e){(function(r,a){t.exports=a(qt())})(B0,function(r){return function(a){var f=r,n=f.lib,l=n.WordArray,m=n.Hasher,y=f.algo,_=[];(function(){for(var I=0;I<64;I++)_[I]=a.abs(a.sin(I+1))*4294967296|0})();var E=y.MD5=m.extend({_doReset:function(){this._hash=new l.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(I,O){for(var H=0;H<16;H++){var N=O+H,$=I[N];I[N]=($<<8|$>>>24)&16711935|($<<24|$>>>8)&4278255360}var R=this._hash.words,q=I[O+0],U=I[O+1],D=I[O+2],j=I[O+3],t0=I[O+4],T=I[O+5],p=I[O+6],w=I[O+7],s=I[O+8],i=I[O+9],o=I[O+10],d=I[O+11],h=I[O+12],x=I[O+13],u=I[O+14],g=I[O+15],b=R[0],c=R[1],v=R[2],F=R[3];b=A(b,c,v,F,q,7,_[0]),F=A(F,b,c,v,U,12,_[1]),v=A(v,F,b,c,D,17,_[2]),c=A(c,v,F,b,j,22,_[3]),b=A(b,c,v,F,t0,7,_[4]),F=A(F,b,c,v,T,12,_[5]),v=A(v,F,b,c,p,17,_[6]),c=A(c,v,F,b,w,22,_[7]),b=A(b,c,v,F,s,7,_[8]),F=A(F,b,c,v,i,12,_[9]),v=A(v,F,b,c,o,17,_[10]),c=A(c,v,F,b,d,22,_[11]),b=A(b,c,v,F,h,7,_[12]),F=A(F,b,c,v,x,12,_[13]),v=A(v,F,b,c,u,17,_[14]),c=A(c,v,F,b,g,22,_[15]),b=k(b,c,v,F,U,5,_[16]),F=k(F,b,c,v,p,9,_[17]),v=k(v,F,b,c,d,14,_[18]),c=k(c,v,F,b,q,20,_[19]),b=k(b,c,v,F,T,5,_[20]),F=k(F,b,c,v,o,9,_[21]),v=k(v,F,b,c,g,14,_[22]),c=k(c,v,F,b,t0,20,_[23]),b=k(b,c,v,F,i,5,_[24]),F=k(F,b,c,v,u,9,_[25]),v=k(v,F,b,c,j,14,_[26]),c=k(c,v,F,b,s,20,_[27]),b=k(b,c,v,F,x,5,_[28]),F=k(F,b,c,v,D,9,_[29]),v=k(v,F,b,c,w,14,_[30]),c=k(c,v,F,b,h,20,_[31]),b=P(b,c,v,F,T,4,_[32]),F=P(F,b,c,v,s,11,_[33]),v=P(v,F,b,c,d,16,_[34]),c=P(c,v,F,b,u,23,_[35]),b=P(b,c,v,F,U,4,_[36]),F=P(F,b,c,v,t0,11,_[37]),v=P(v,F,b,c,w,16,_[38]),c=P(c,v,F,b,o,23,_[39]),b=P(b,c,v,F,x,4,_[40]),F=P(F,b,c,v,q,11,_[41]),v=P(v,F,b,c,j,16,_[42]),c=P(c,v,F,b,p,23,_[43]),b=P(b,c,v,F,i,4,_[44]),F=P(F,b,c,v,h,11,_[45]),v=P(v,F,b,c,g,16,_[46]),c=P(c,v,F,b,D,23,_[47]),b=B(b,c,v,F,q,6,_[48]),F=B(F,b,c,v,w,10,_[49]),v=B(v,F,b,c,u,15,_[50]),c=B(c,v,F,b,T,21,_[51]),b=B(b,c,v,F,h,6,_[52]),F=B(F,b,c,v,j,10,_[53]),v=B(v,F,b,c,o,15,_[54]),c=B(c,v,F,b,U,21,_[55]),b=B(b,c,v,F,s,6,_[56]),F=B(F,b,c,v,g,10,_[57]),v=B(v,F,b,c,p,15,_[58]),c=B(c,v,F,b,x,21,_[59]),b=B(b,c,v,F,t0,6,_[60]),F=B(F,b,c,v,d,10,_[61]),v=B(v,F,b,c,D,15,_[62]),c=B(c,v,F,b,i,21,_[63]),R[0]=R[0]+b|0,R[1]=R[1]+c|0,R[2]=R[2]+v|0,R[3]=R[3]+F|0},_doFinalize:function(){var I=this._data,O=I.words,H=this._nDataBytes*8,N=I.sigBytes*8;O[N>>>5]|=128<<24-N%32;var $=a.floor(H/4294967296),R=H;O[(N+64>>>9<<4)+15]=($<<8|$>>>24)&16711935|($<<24|$>>>8)&4278255360,O[(N+64>>>9<<4)+14]=(R<<8|R>>>24)&16711935|(R<<24|R>>>8)&4278255360,I.sigBytes=(O.length+1)*4,this._process();for(var q=this._hash,U=q.words,D=0;D<4;D++){var j=U[D];U[D]=(j<<8|j>>>24)&16711935|(j<<24|j>>>8)&4278255360}return q},clone:function(){var I=m.clone.call(this);return I._hash=this._hash.clone(),I}});function A(I,O,H,N,$,R,q){var U=I+(O&H|~O&N)+$+q;return(U<>>32-R)+O}function k(I,O,H,N,$,R,q){var U=I+(O&N|H&~N)+$+q;return(U<>>32-R)+O}function P(I,O,H,N,$,R,q){var U=I+(O^H^N)+$+q;return(U<>>32-R)+O}function B(I,O,H,N,$,R,q){var U=I+(H^(O|~N))+$+q;return(U<>>32-R)+O}f.MD5=m._createHelper(E),f.HmacMD5=m._createHmacHelper(E)}(Math),r.MD5})})(cD);var ls=cD.exports,a_0=ac(ls),oD={exports:{}};(function(t,e){(function(r,a){t.exports=a(qt())})(B0,function(r){return function(){var a=r,f=a.lib,n=f.WordArray,l=f.Hasher,m=a.algo,y=[],_=m.SHA1=l.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(E,A){for(var k=this._hash.words,P=k[0],B=k[1],I=k[2],O=k[3],H=k[4],N=0;N<80;N++){if(N<16)y[N]=E[A+N]|0;else{var $=y[N-3]^y[N-8]^y[N-14]^y[N-16];y[N]=$<<1|$>>>31}var R=(P<<5|P>>>27)+H+y[N];N<20?R+=(B&I|~B&O)+1518500249:N<40?R+=(B^I^O)+1859775393:N<60?R+=(B&I|B&O|I&O)-1894007588:R+=(B^I^O)-899497514,H=O,O=I,I=B<<30|B>>>2,B=P,P=R}k[0]=k[0]+P|0,k[1]=k[1]+B|0,k[2]=k[2]+I|0,k[3]=k[3]+O|0,k[4]=k[4]+H|0},_doFinalize:function(){var E=this._data,A=E.words,k=this._nDataBytes*8,P=E.sigBytes*8;return A[P>>>5]|=128<<24-P%32,A[(P+64>>>9<<4)+14]=Math.floor(k/4294967296),A[(P+64>>>9<<4)+15]=k,E.sigBytes=A.length*4,this._process(),this._hash},clone:function(){var E=l.clone.call(this);return E._hash=this._hash.clone(),E}});a.SHA1=l._createHelper(_),a.HmacSHA1=l._createHmacHelper(_)}(),r.SHA1})})(oD);var Mh=oD.exports,i_0=ac(Mh),dD={exports:{}};(function(t,e){(function(r,a){t.exports=a(qt())})(B0,function(r){return function(a){var f=r,n=f.lib,l=n.WordArray,m=n.Hasher,y=f.algo,_=[],E=[];(function(){function P(H){for(var N=a.sqrt(H),$=2;$<=N;$++)if(!(H%$))return!1;return!0}function B(H){return(H-(H|0))*4294967296|0}for(var I=2,O=0;O<64;)P(I)&&(O<8&&(_[O]=B(a.pow(I,1/2))),E[O]=B(a.pow(I,1/3)),O++),I++})();var A=[],k=y.SHA256=m.extend({_doReset:function(){this._hash=new l.init(_.slice(0))},_doProcessBlock:function(P,B){for(var I=this._hash.words,O=I[0],H=I[1],N=I[2],$=I[3],R=I[4],q=I[5],U=I[6],D=I[7],j=0;j<64;j++){if(j<16)A[j]=P[B+j]|0;else{var t0=A[j-15],T=(t0<<25|t0>>>7)^(t0<<14|t0>>>18)^t0>>>3,p=A[j-2],w=(p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10;A[j]=T+A[j-7]+w+A[j-16]}var s=R&q^~R&U,i=O&H^O&N^H&N,o=(O<<30|O>>>2)^(O<<19|O>>>13)^(O<<10|O>>>22),d=(R<<26|R>>>6)^(R<<21|R>>>11)^(R<<7|R>>>25),h=D+d+s+E[j]+A[j],x=o+i;D=U,U=q,q=R,R=$+h|0,$=N,N=H,H=O,O=h+x|0}I[0]=I[0]+O|0,I[1]=I[1]+H|0,I[2]=I[2]+N|0,I[3]=I[3]+$|0,I[4]=I[4]+R|0,I[5]=I[5]+q|0,I[6]=I[6]+U|0,I[7]=I[7]+D|0},_doFinalize:function(){var P=this._data,B=P.words,I=this._nDataBytes*8,O=P.sigBytes*8;return B[O>>>5]|=128<<24-O%32,B[(O+64>>>9<<4)+14]=a.floor(I/4294967296),B[(O+64>>>9<<4)+15]=I,P.sigBytes=B.length*4,this._process(),this._hash},clone:function(){var P=m.clone.call(this);return P._hash=this._hash.clone(),P}});f.SHA256=m._createHelper(k),f.HmacSHA256=m._createHmacHelper(k)}(Math),r.SHA256})})(dD);var Ag=dD.exports,n_0=ac(Ag),Sg={exports:{}},sD;function f_0(){return sD||(sD=1,function(t,e){(function(r,a,f){t.exports=a(qt(),Ag)})(B0,function(r){return function(){var a=r,f=a.lib,n=f.WordArray,l=a.algo,m=l.SHA256,y=l.SHA224=m.extend({_doReset:function(){this._hash=new n.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var _=m._doFinalize.call(this);return _.sigBytes-=4,_}});a.SHA224=m._createHelper(y),a.HmacSHA224=m._createHmacHelper(y)}(),r.SHA224})}(Sg)),Sg.exports}var kg={exports:{}},uD;function bD(){return uD||(uD=1,function(t,e){(function(r,a,f){t.exports=a(qt(),_h())})(B0,function(r){return function(){var a=r,f=a.lib,n=f.Hasher,l=a.x64,m=l.Word,y=l.WordArray,_=a.algo;function E(){return m.create.apply(m,arguments)}var A=[E(1116352408,3609767458),E(1899447441,602891725),E(3049323471,3964484399),E(3921009573,2173295548),E(961987163,4081628472),E(1508970993,3053834265),E(2453635748,2937671579),E(2870763221,3664609560),E(3624381080,2734883394),E(310598401,1164996542),E(607225278,1323610764),E(1426881987,3590304994),E(1925078388,4068182383),E(2162078206,991336113),E(2614888103,633803317),E(3248222580,3479774868),E(3835390401,2666613458),E(4022224774,944711139),E(264347078,2341262773),E(604807628,2007800933),E(770255983,1495990901),E(1249150122,1856431235),E(1555081692,3175218132),E(1996064986,2198950837),E(2554220882,3999719339),E(2821834349,766784016),E(2952996808,2566594879),E(3210313671,3203337956),E(3336571891,1034457026),E(3584528711,2466948901),E(113926993,3758326383),E(338241895,168717936),E(666307205,1188179964),E(773529912,1546045734),E(1294757372,1522805485),E(1396182291,2643833823),E(1695183700,2343527390),E(1986661051,1014477480),E(2177026350,1206759142),E(2456956037,344077627),E(2730485921,1290863460),E(2820302411,3158454273),E(3259730800,3505952657),E(3345764771,106217008),E(3516065817,3606008344),E(3600352804,1432725776),E(4094571909,1467031594),E(275423344,851169720),E(430227734,3100823752),E(506948616,1363258195),E(659060556,3750685593),E(883997877,3785050280),E(958139571,3318307427),E(1322822218,3812723403),E(1537002063,2003034995),E(1747873779,3602036899),E(1955562222,1575990012),E(2024104815,1125592928),E(2227730452,2716904306),E(2361852424,442776044),E(2428436474,593698344),E(2756734187,3733110249),E(3204031479,2999351573),E(3329325298,3815920427),E(3391569614,3928383900),E(3515267271,566280711),E(3940187606,3454069534),E(4118630271,4000239992),E(116418474,1914138554),E(174292421,2731055270),E(289380356,3203993006),E(460393269,320620315),E(685471733,587496836),E(852142971,1086792851),E(1017036298,365543100),E(1126000580,2618297676),E(1288033470,3409855158),E(1501505948,4234509866),E(1607167915,987167468),E(1816402316,1246189591)],k=[];(function(){for(var B=0;B<80;B++)k[B]=E()})();var P=_.SHA512=n.extend({_doReset:function(){this._hash=new y.init([new m.init(1779033703,4089235720),new m.init(3144134277,2227873595),new m.init(1013904242,4271175723),new m.init(2773480762,1595750129),new m.init(1359893119,2917565137),new m.init(2600822924,725511199),new m.init(528734635,4215389547),new m.init(1541459225,327033209)])},_doProcessBlock:function(B,I){for(var O=this._hash.words,H=O[0],N=O[1],$=O[2],R=O[3],q=O[4],U=O[5],D=O[6],j=O[7],t0=H.high,T=H.low,p=N.high,w=N.low,s=$.high,i=$.low,o=R.high,d=R.low,h=q.high,x=q.low,u=U.high,g=U.low,b=D.high,c=D.low,v=j.high,F=j.low,C=t0,L=T,G=p,V=w,J=s,Y=i,W=o,X=d,O0=h,i0=x,c0=u,Z0=g,d0=b,x0=c,ne=v,p0=F,u0=0;u0<80;u0++){var J0,l0,h0=k[u0];if(u0<16)l0=h0.high=B[I+u0*2]|0,J0=h0.low=B[I+u0*2+1]|0;else{var te=k[u0-15],v0=te.high,b0=te.low,re=(v0>>>1|b0<<31)^(v0>>>8|b0<<24)^v0>>>7,E0=(b0>>>1|v0<<31)^(b0>>>8|v0<<24)^(b0>>>7|v0<<25),m0=k[u0-2],he=m0.high,A0=m0.low,g0=(he>>>19|A0<<13)^(he<<3|A0>>>29)^he>>>6,le=(A0>>>19|he<<13)^(A0<<3|he>>>29)^(A0>>>6|he<<26),S0=k[u0-7],k0=S0.high,Oe=S0.low,U0=k[u0-16],T0=U0.high,Ne=U0.low;J0=E0+Oe,l0=re+k0+(J0>>>0>>0?1:0),J0=J0+le,l0=l0+g0+(J0>>>0>>0?1:0),J0=J0+Ne,l0=l0+T0+(J0>>>0>>0?1:0),h0.high=l0,h0.low=J0}var L0=O0&c0^~O0&d0,R0=i0&Z0^~i0&x0,Ie=C&G^C&J^G&J,C0=L&V^L&Y^V&Y,_0=(C>>>28|L<<4)^(C<<30|L>>>2)^(C<<25|L>>>7),Te=(L>>>28|C<<4)^(L<<30|C>>>2)^(L<<25|C>>>7),N0=(O0>>>14|i0<<18)^(O0>>>18|i0<<14)^(O0<<23|i0>>>9),M0=(i0>>>14|O0<<18)^(i0>>>18|O0<<14)^(i0<<23|O0>>>9),Re=A[u0],$0=Re.high,y0=Re.low,Me=p0+M0,Z=ne+N0+(Me>>>0>>0?1:0),Me=Me+R0,Z=Z+L0+(Me>>>0>>0?1:0),Me=Me+y0,Z=Z+$0+(Me>>>0>>0?1:0),Me=Me+J0,Z=Z+l0+(Me>>>0>>0?1:0),e0=Te+C0,f0=_0+Ie+(e0>>>0>>0?1:0);ne=d0,p0=x0,d0=c0,x0=Z0,c0=O0,Z0=i0,i0=X+Me|0,O0=W+Z+(i0>>>0>>0?1:0)|0,W=J,X=Y,J=G,Y=V,G=C,V=L,L=Me+e0|0,C=Z+f0+(L>>>0>>0?1:0)|0}T=H.low=T+L,H.high=t0+C+(T>>>0>>0?1:0),w=N.low=w+V,N.high=p+G+(w>>>0>>0?1:0),i=$.low=i+Y,$.high=s+J+(i>>>0>>0?1:0),d=R.low=d+X,R.high=o+W+(d>>>0>>0?1:0),x=q.low=x+i0,q.high=h+O0+(x>>>0>>0?1:0),g=U.low=g+Z0,U.high=u+c0+(g>>>0>>0?1:0),c=D.low=c+x0,D.high=b+d0+(c>>>0>>0?1:0),F=j.low=F+p0,j.high=v+ne+(F>>>0>>0?1:0)},_doFinalize:function(){var B=this._data,I=B.words,O=this._nDataBytes*8,H=B.sigBytes*8;I[H>>>5]|=128<<24-H%32,I[(H+128>>>10<<5)+30]=Math.floor(O/4294967296),I[(H+128>>>10<<5)+31]=O,B.sigBytes=I.length*4,this._process();var N=this._hash.toX32();return N},clone:function(){var B=n.clone.call(this);return B._hash=this._hash.clone(),B},blockSize:1024/32});a.SHA512=n._createHelper(P),a.HmacSHA512=n._createHmacHelper(P)}(),r.SHA512})}(kg)),kg.exports}var Tg={exports:{}},hD;function c_0(){return hD||(hD=1,function(t,e){(function(r,a,f){t.exports=a(qt(),_h(),bD())})(B0,function(r){return function(){var a=r,f=a.x64,n=f.Word,l=f.WordArray,m=a.algo,y=m.SHA512,_=m.SHA384=y.extend({_doReset:function(){this._hash=new l.init([new n.init(3418070365,3238371032),new n.init(1654270250,914150663),new n.init(2438529370,812702999),new n.init(355462360,4144912697),new n.init(1731405415,4290775857),new n.init(2394180231,1750603025),new n.init(3675008525,1694076839),new n.init(1203062813,3204075428)])},_doFinalize:function(){var E=y._doFinalize.call(this);return E.sigBytes-=16,E}});a.SHA384=y._createHelper(_),a.HmacSHA384=y._createHmacHelper(_)}(),r.SHA384})}(Tg)),Tg.exports}var Bg={exports:{}},lD;function o_0(){return lD||(lD=1,function(t,e){(function(r,a,f){t.exports=a(qt(),_h())})(B0,function(r){return function(a){var f=r,n=f.lib,l=n.WordArray,m=n.Hasher,y=f.x64,_=y.Word,E=f.algo,A=[],k=[],P=[];(function(){for(var O=1,H=0,N=0;N<24;N++){A[O+5*H]=(N+1)*(N+2)/2%64;var $=H%5,R=(2*O+3*H)%5;O=$,H=R}for(var O=0;O<5;O++)for(var H=0;H<5;H++)k[O+5*H]=H+(2*O+3*H)%5*5;for(var q=1,U=0;U<24;U++){for(var D=0,j=0,t0=0;t0<7;t0++){if(q&1){var T=(1<>>24)&16711935|(q<<24|q>>>8)&4278255360,U=(U<<8|U>>>24)&16711935|(U<<24|U>>>8)&4278255360;var D=N[R];D.high^=U,D.low^=q}for(var j=0;j<24;j++){for(var t0=0;t0<5;t0++){for(var T=0,p=0,w=0;w<5;w++){var D=N[t0+5*w];T^=D.high,p^=D.low}var s=B[t0];s.high=T,s.low=p}for(var t0=0;t0<5;t0++)for(var i=B[(t0+4)%5],o=B[(t0+1)%5],d=o.high,h=o.low,T=i.high^(d<<1|h>>>31),p=i.low^(h<<1|d>>>31),w=0;w<5;w++){var D=N[t0+5*w];D.high^=T,D.low^=p}for(var x=1;x<25;x++){var T,p,D=N[x],u=D.high,g=D.low,b=A[x];b<32?(T=u<>>32-b,p=g<>>32-b):(T=g<>>64-b,p=u<>>64-b);var c=B[k[x]];c.high=T,c.low=p}var v=B[0],F=N[0];v.high=F.high,v.low=F.low;for(var t0=0;t0<5;t0++)for(var w=0;w<5;w++){var x=t0+5*w,D=N[x],C=B[x],L=B[(t0+1)%5+5*w],G=B[(t0+2)%5+5*w];D.high=C.high^~L.high&G.high,D.low=C.low^~L.low&G.low}var D=N[0],V=P[j];D.high^=V.high,D.low^=V.low}},_doFinalize:function(){var O=this._data,H=O.words;this._nDataBytes*8;var N=O.sigBytes*8,$=this.blockSize*32;H[N>>>5]|=1<<24-N%32,H[(a.ceil((N+1)/$)*$>>>5)-1]|=128,O.sigBytes=H.length*4,this._process();for(var R=this._state,q=this.cfg.outputLength/8,U=q/8,D=[],j=0;j>>24)&16711935|(T<<24|T>>>8)&4278255360,p=(p<<8|p>>>24)&16711935|(p<<24|p>>>8)&4278255360,D.push(p),D.push(T)}return new l.init(D,q)},clone:function(){for(var O=m.clone.call(this),H=O._state=this._state.slice(0),N=0;N<25;N++)H[N]=H[N].clone();return O}});f.SHA3=m._createHelper(I),f.HmacSHA3=m._createHmacHelper(I)}(Math),r.SHA3})}(Bg)),Bg.exports}var Pg={exports:{}},xD;function d_0(){return xD||(xD=1,function(t,e){(function(r,a){t.exports=a(qt())})(B0,function(r){/** @preserve (c) 2012 by Cédric Mesnil. All rights reserved. @@ -140,5 +140,5 @@ version: 2.9.0 `),this.statement&&(a+=` `),[a,y].join(` -`)}}class NE0{constructor(){this.accounts=[],this.onAccountsChanged=e=>{console.log("on accountsChanged: ",e),this.accounts=e},this.onChainChanged=e=>{const r=parseInt(e);console.log("on chainChanged",e,r)},this.onDisconnect=e=>{console.log("on disconnect",e)}}async connect(e,r=window.okxwallet||window.ethereum){this.provider=r,this.chainId=e,this._subscribeToEvents()}async disconnect(){this.provider&&(this.provider.removeListener("accountsChanged",this.onAccountsChanged),this.provider.removeListener("chainChanged",this.onChainChanged),this.provider.removeListener("disconnect",this.onDisconnect))}_subscribeToEvents(){this.provider.on("accountsChanged",this.onAccountsChanged),this.provider.on("chainChanged",this.onChainChanged),this.provider.on("disconnect",this.onDisconnect)}async addOrChangeChain(e){return new Promise((r,a)=>{const f=l=>{console.log("switchEthereumChain: ",l),this.provider.removeListener("chainChanged",f),r&&r(l)};this.provider.on("chainChanged",f);let n={chainId:_N(e.id),chainName:e.name,nativeCurrency:{name:e.symbol,symbol:e.symbol,decimals:e.decimals||18},rpcUrls:[e.rpc],blockExplorerUrls:[e.explorerurl]};this.provider.request({method:"wallet_addEthereumChain",params:[n]}).then(()=>{console.log("add chain success, wait result")}).catch(l=>{console.error("add chain error: ",JSON.stringify(l)),this.provider.removeListener("chainChanged",f),a&&a(l)})})}async signWithSiwe(){let e=await Rh(()=>oM0(),sN);if(e.errcode)throw new Xt(e.errcode,e.errmsg);let r=e.data.nonce;return this.signData({chainId:this.chainId,nonce:r},this.accounts[0])}async signData(e,r){const a=Lr.toChecksumAddress(r),{chainId:f,nonce:n}=e;let l=new OE0({domain:document.location.host,address:a,chainId:f,uri:document.location.origin,version:"1",statement:"Counter Fire Wallet Relay",nonce:n}),m=l.toMessage();return{signature:await this.provider.request({method:"personal_sign",params:[Lr.utf8ToHex(m),a]}),message:l}}async sendCmd({method:e,params:r,from:a}){}}function DE0(t){const e=`${Kr()}/wallet/relay/prepare`;return Or(e,t)}function u$(t){const e=`${Kr()}/wallet/relay/getlast`;return Or(e,{type:t},new oa().relayToken)}function $E0(t){const e=`${Kr()}/wallet/relay/getdata`;return Or(e,{id:t},new oa().relayToken)}function b$(t,e){const r=`${Kr()}/wallet/relay/putdata`;return Or(r,{type:t,data:e},new oa().relayToken)}function h$(t,e){const r=`${Kr()}/wallet/relay/updata`;return Or(r,{id:t,data:e},new oa().relayToken)}var q8=(t=>(t[t.TO_WALLET=0]="TO_WALLET",t[t.FROM_WALLET=1]="FROM_WALLET",t))(q8||{});async function UE0(t,e="dev"){let r=qr()+"",a=localStorage.getItem(hN);if(gN(60,a)){let _=jsb.preRegistClient(r),[E,A]=_.split("|"),k=await DE0({msg:r,address:E,signature:A});if(k.errorcode)throw new Error(k.errmsg);a=k.data.token,localStorage.setItem(hN,a)}console.log(`relay token: ${a}`),LE0(a);let f=await jc.wallet.relaySvr.beginReq("",ih,t,e),{address:n,signature:l,message:m,key:y}=f;return console.log(`initRelayWallet::from relay: address: ${n}, signature: ${l}, encrypt: ${!!y}`),y&&jsb.parseRelayAESKey(y),{token:await fy({channel:R1.RELAY_WALLET,code:l,message:m}),address:n}}async function LE0(t){new oa().relayToken=t}async function FE0(t){return b$(q8.TO_WALLET,t)}var jE0=Object.defineProperty,zE0=Object.getOwnPropertyDescriptor,qE0=(t,e,r,a)=>{for(var f=a>1?void 0:a?zE0(e,r):e,n=t.length-1,l;n>=0;n--)(l=t[n])&&(f=(a?l(e,r,f):l(f))||f);return a&&f&&jE0(e,r,f),f};let py=class{constructor(){this._event=nh()}_subscribeToResponse(t,e){this._event.on(`response:${t}`,e)}_subscribeToCallResponse(t){return new Promise((e,r)=>{this._subscribeToResponse(t,a=>{if(a.errcode){r(a.errmsg||a.data||a.errcode);return}e(a.data)})})}handleNativeCallback(...t){let e=t[0],r=JSON.parse(t[1]);this._event.emit(`response:${e}`,r)}async checkResult(){if(console.log("relay check result: "+window.currentRelayId),!window.currentRelayId)return;let{errcode:t,errmsg:e,data:r}=await $E0(window.currentRelayId),a=r.resp;if(typeof a=="object"&&a.encrypt){let f=jsb.loadRelayAESKey();a=JSON.parse(ny(a.values,f)),console.log("decrypt result: "+JSON.stringify(a))}this._event.emit(`response:${window.currentRelayId}`,a),window.currentRelayId=void 0}async beginReq(...t){let e=t[1],r={method:e,params:t};e===ih?r.pk=jsb.prepareRelayRSAKey():r={method:lN,values:iy(JSON.stringify(r),jsb.loadRelayAESKey())};let{errcode:a,data:f,errmsg:n}=await FE0(r);console.log("uploadRelayData result: "+JSON.stringify({errcode:a,data:f,errmsg:n}));let{id:l}=f;console.log("relay id: "+l);let m=Ug0(new oa().relayToken);return window.toRelayPage(`${Pg0()}?token=${m}`),window.currentRelayId=l+"",this._subscribeToCallResponse(l)}};py=qE0([$c],py);const HE0={"42161_release":{tokens:[{type:"eth",address:"eth",symbol:"ETH",decimal:18},{type:"erc20",address:"0x741482aE1480E552735E44Ff3A733448AcBbeD8d",symbol:"CEG",decimal:18},{address:"0x79fc2a4216A1e595DBD09D13c4B4bD3B095d5bb2",name:"hero",type:"erc721"},{address:"0x551838d7754157D13e7D945b8a37bBD6Ad50dDC7",name:"chip",type:"erc721"},{address:"0xD728de3d9ebeD90E84aBe84539280cbC5b18E304",name:"genesis",type:"erc721"},{address:"0x3F13F83E6363D97d0353cAAfACA08B05D9BF3637",name:"gacha",type:"erc721"},{type:"erc20",address:"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",symbol:"USDT",decimal:6,thirdparty:1},{type:"erc20",address:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",symbol:"USDC",decimal:6,thirdparty:1},{address:"0x66944F7AEB68779DE2B4f68Fde5d704fff723134",name:"planet",type:"erc721"}],contracts:{minterFactory:"0x24499444b2BE6A8E3F800D47E4Ed0c36B5c0747e",nftmarket:"0xA683c7BC5f3c73782fce9fc614Fda7C999934db8",nftmall:"0xb5EF2FAC11c385041f847E34E0b1B4740436f769",gamemarket:"0x6232d2B720C22D6BCB633560b05002C472a64f18",gamemall:"0x1Ee01D949C848aF1ceDb80165b290554937819d9",tokenmall:"0x2Da675caB260c6aDC6A59802Df028B3057EeE848",nftStaking:"0x2d8D530941d6Cbe92Cf0654671522e425b9882A2",brickFactory:"0x0"},gasInfo:{nftApprove:49340,cecApprove:46962,marketSellNFT:270740,marketCancelOrder:119027,marketUpdatePrice:41272,marketBuy:207735,gameMallBuy:119416,gameMarketBuy:133251}},"421613_release":{tokens:[{type:"eth",address:"eth",symbol:"AGOR",decimal:18},{type:"erc20",address:"0x8dd1439E0C3254b4543d6D68b3C0C891E5Bd2eCE",symbol:"CEC",decimal:18},{type:"erc20",address:"0x2C7221588D4FBac2585D71618CD540e74c7413B8",symbol:"CEG",decimal:18},{address:"0xE6A69474E04B93De50dd07F239d62879dB9bF716",name:"hero",type:"erc721"},{address:"0x8Ce844402bE22fA1276a375Ff2354DD27aDEF285",name:"weapon",type:"erc721"},{address:"0x4678fE0177B15538F441264cB851364d9F3872AA",name:"chip",type:"erc721"}],contracts:{minterFactory:"0x1A27515c35a92Fb276c2670fa27C85ffAd75D094",market:"0xb80E19c50747972E735c68C0BA5651AD952d70BC"}},"421613_dev":{tokens:[{type:"eth",address:"eth",symbol:"AGOR",decimal:18},{type:"erc20",address:"0x8dd1439E0C3254b4543d6D68b3C0C891E5Bd2eCE",symbol:"CEC",decimal:18},{type:"erc20",address:"0x2C7221588D4FBac2585D71618CD540e74c7413B8",symbol:"CEG",decimal:18},{address:"0xE6A69474E04B93De50dd07F239d62879dB9bF716",name:"hero",type:"erc721"},{address:"0x8Ce844402bE22fA1276a375Ff2354DD27aDEF285",name:"weapon",type:"erc721"},{address:"0x4678fE0177B15538F441264cB851364d9F3872AA",name:"chip",type:"erc721"},{type:"erc20",address:"0xaa34B79A0Ab433eaC900fB3CB9f191F5Cd27501D",symbol:"USDT",decimal:18,thirdparty:1},{type:"erc20",address:"0x944D0A8463B2c955F90F7252bBb99A3395087155",symbol:"USDC",decimal:6,thirdparty:1},{address:"0xEbC170185ad614C05Af38C820020b70E458717F5",name:"gacha",type:"erc721"},{address:"0xae37bb7BcA26Bab9a11D8BaE8fdB97f63b82c189",name:"TestHero",type:"erc721"},{address:"0x6f9c3F80C7F92064560eC09ab66dc132928Ff2dF",name:"planet",type:"erc721"},{address:"0x0bC735C26040a56352271C32A9bAf9cc47f2F264",name:"goldbrick",type:"erc721"}],contracts:{minterFactory:"0x1A27515c35a92Fb276c2670fa27C85ffAd75D094",nftmarket:"0xB9720d2c9D01FE36a1aA1224cbB06BF8e436812E",nftmall:"0x4d71dE0428328112A78D402A6fdd7ceD1C96B71e",gamemarket:"0x46e2C612756b702b3d68d89F97c88FFa725F6fab",gamemall:"0x1D058c7c7451c34BbfF9c0dF1C16b95C5d171d64",tokenmall:"0x22557f3fe7fbA53C66a35a3D70527D014704fd4D",nftStaking:"0xB18Ba312f939E58b959F30c747c198BDc205482E",brickFactory:"0x40295E4879926D04E04cE59F0293b5b5FDe6267c"},gasInfo:{nftApprove:49340,cecApprove:46962,marketSellNFT:270740,marketCancelOrder:119027,marketUpdatePrice:41272,marketBuy:207735,gameMallBuy:119416,gameMarketBuy:133251}},"195_dev":{tokens:[{type:"eth",address:"eth",symbol:"OKB",decimal:18},{type:"erc20",address:"0xB469331cEC98E52b7Eab07dFB586253bE232BBF7",symbol:"CEC",decimal:18},{type:"erc20",address:"0x0Ddb3c60DEab2d55bb757772A89680A0533f6B41",symbol:"CEG",decimal:18},{address:"0xE68F149daF2F314d9960c08496D8701BC7671850",name:"hero",type:"erc721"},{address:"0xD80a641a28702064e3f5EF383bd2640d4ff795c8",name:"planet",type:"erc721"},{address:"0x1991ee2f224ae5500fb15E90f9967Fb70F4ca27f",name:"gacha",type:"erc721"},{address:"0xC35Dcdb3672f1CFC5fe0B0Ec6861a5e9777757CD",name:"TestHero",type:"erc721"},{type:"erc20",address:"0x0Fd13D2CD0B6c679B6f92590E0b91C18DDe7BD3A",symbol:"USDT",decimal:18,thirdparty:1},{type:"erc20",address:"0x23e7Ef7D6F9bc3305E8EF0Fa1e5e12C1D5a4b06B",symbol:"USDC",decimal:6,thirdparty:1}],contracts:{minterFactory:"0xf45702180314187a3549FEDac3B78349b47ca6A0",nftmarket:"0xD7Fc45b5E6C7A7ad299b45E6D34B59b9c3B5e7e1",nftmall:"0x2036A0708AC2F17F67b08357d8b4A7d47cF49c29",gamemarket:"0x61E1B8A2937Fa966a6D50D294B66948Ee20f328a",gamemall:"0x31F29C9A3D0c1c13C825475aebF0d964b5B47c45",tokenmall:"0x20e2677F32dC0CB5D0bB0DEf9df84369AD5a7EC2",nftStaking:"0x07564E0C9dAC31F1640b34070C09aF3C820CD9E7",brickFactory:"0x0"},gasInfo:{nftApprove:49340,cecApprove:46962,marketSellNFT:270740,marketCancelOrder:119027,marketUpdatePrice:41272,marketBuy:207735,gameMallBuy:119416,gameMarketBuy:133251}}};function KE0(t){const e=`${Kr()}/wallet/okx/sendtran`;return Or(e,t)}function VE0(t){const e=`${Kr()}/wallet/okx/gasprice`;return Or(e,t)}const l$=new Map([["eth_requestAccounts","requestAccounts"],["eth_gasPrice","gasPrice"],["eth_sendRawTransaction","sendTransaction"]]),WE0="0xa9059cbb",GE0="0x23b872dd";class ZE0{constructor(e,r){this.address=e,this.rpc=r}async sendAsync(e,r){window.debug&&console.log("payload: "+JSON.stringify(e)),l$.has(e.method)?await this[l$.get(e.method)].call(this,e,r):await this.normalSend(e,r)}async send(e,r){this.sendAsync(e,r)}async normalSend(e,r){try{let a={};a["Content-Type"]="application/json";let f=await P4(this.rpc,{method:"POST",body:JSON.stringify(e),headers:a});f=await f.json(),r(null,f)}catch(a){r(a)}}requestAccounts(e,r){r(null,{id:e.id,jsonrpc:e.jsonrpc,result:this.address})}async gasPrice(e,r){let a=jc.wallet.currentChain.id;try{let f=await VE0({chain:a});if(f.errcode)r(new Error(f.errmsg));else{let n=f.data.min;n=by(Number(n).toString(16)),r(null,{id:e.id,jsonrpc:e.jsonrpc,result:n})}}catch(f){r(f)}}async sendTransaction(e,r){let a=e.paramsOrig,f=jc.wallet.currentChain.id,n=Tr(a.gas),l=Tr(a.maxFeePerGas||a.gasPrice),m=n.mul(l),y={signedTx:e.params[0],addrFrom:a.from,addrTo:a.to,txHash:a.transactionHash,txAmount:Tr(a.value||0).toString(),chainId:f,serviceCharge:m.toString(),extJson:{gasPrice:l.toString(),gasLimit:n.toString(),nonce:Tr(a.nonce).toString()}};a.data?(y.txType="contractCall",(a.data.startsWith(WE0)||a.data.startsWith(GE0))&&(y.tokenAddress=a.to)):y.txType="transfer";try{let _=await KE0({data:y});console.log("sendTransaction result: ",JSON.stringify(_));let E={id:e.id,jsonrpc:e.jsonrpc};_.errcode?E.error={code:_.errcode,message:_.errmsg}:E.result=_.data.txHash,r(null,E)}catch(_){r(_)}}}var $o=(t=>(t.DEV="dev",t.RELEASE="release",t))($o||{});function YE0(t){let e=JD();return localStorage.setItem(Xm,e+""),YD(e+"",t)}async function x$(...t){let e=t.pop(),r=t.pop(),a=!1;e&&(a=YE0(e)),t.shift(),t.shift();let f;try{let n=await jc.wallet.initOKXWallet(...t);localStorage.setItem(xN,JSON.stringify(t)),localStorage.setItem(pN,n.address),Object.assign(n,{key:a}),n={errcode:0,data:n},r&&await h$(r,n)}catch(n){f=n}return{error:f}}async function JE0(){if(!jc||!jc.wallet||!jc.wallet.web3){window.showLoading({title:"prepare wallet"});let t=localStorage.getItem(xN);t||(t=JSON.stringify([421613,"dev"]));let e=JSON.parse(t);e.push(!1);let r=await jc.wallet.initOKXWallet(...e),a=localStorage.getItem(pN);if(a&&a!==r.address)throw new Error("Current address is inconsistent with the address bound to the game, Change current account then retry.")}}async function p$(...t){let e=t.shift(),r=t.shift();console.log(`relay method: ${e}.${r}`),r!==ih&&(await JE0(),window.showLoading({title:"parse chain request"}));let a,f;try{e?a=await jc.wallet[e][r](...t):a=await jc.wallet[r](...t)}catch(n){a=n.message||n,f=n}return{value:a,error:f}}var XE0=Object.defineProperty,QE0=Object.getOwnPropertyDescriptor,eA0=(t,e,r,a)=>{for(var f=a>1?void 0:a?QE0(e,r):e,n=t.length-1,l;n>=0;n--)(l=t[n])&&(f=(a?l(e,r,f):l(f))||f);return a&&f&&XE0(e,r,f),f};const v$=[{path:"",method:"initOKXWallet"},{path:"erc20Standard",method:"transfer"},{path:"erc721Standard",method:"transfer"},{path:"erc1155Standard",method:"transferBatch"},{path:"chainCommon",method:"sendEth"},{path:"jcStandard",method:"mintNFT"},{path:"jcStandard",method:"marketSellNFT"},{path:"jcStandard",method:"marketUpdatePrice"},{path:"jcStandard",method:"marketBuy"},{path:"jcStandard",method:"gameMallBuy"},{path:"jcStandard",method:"gameMarketBuy"},{path:"jcStandard",method:"buyTokenWithErc20"},{path:"jcStandard",method:"mallBuy"},{path:"jcStandard",method:"stakeNfts"},{path:"jcStandard",method:"redeemNfts"}],m$=1201;mt.RelayWallet=class{async startRelay(e){e=Lg0(e),new oa().relayToken=e,window.showLoading({title:"init wallet"});try{let{errcode:r,errmsg:a,data:f}=await u$(q8.TO_WALLET);if(r)throw new Error(a);if(f.status!==0)throw new Error("no task to do, back to game and try again.");await this.parseLastRelayCmd(f),window.showResult({title:"finished parse task, back to game manually."})}catch(r){if(r instanceof Xt&&r.statusCode===m$){let a=r.message||r||"";window.showResult({error:1,title:`parse task with error: ${a}, try again?`})}else{let a=r.message||r||"error parse task, please try again later.";window.showResult({title:a,error:1})}}return!0}async uploadRelayData(e){return b$(q8.FROM_WALLET,e)}async fetchRelayData(){return u$(q8.TO_WALLET)}async retryLastRelayCmd(){let e=localStorage.getItem(Qm);if(e)try{let r=JSON.parse(e);await this.parseLastRelayCmd(r),window.showResult({title:"finished parse task, back to game manually."}),localStorage.removeItem(Qm)}catch(r){let a=r.message||r||"";window.showResult({error:1,title:`parse task with error: ${a}, try again?`})}else console.log("no local tmp data")}async parseLastRelayCmd(e){window.hideRetry();let r=e.data,a;if(r.method===ih){let f=[...r.params,e.id,r.pk];a=(await x$.apply(this,f)).error}else{let f=r.method===lN;if(f){let m=localStorage.getItem(Xm);if(!m)throw new Error("relay msg key not found");r=JSON.parse(ny(r.values,m))}if(v$.findIndex(m=>m.method==r.method)<0)throw new Error(`method ${r.method} not found`);let{value:n,error:l}=await p$.apply(this,r.params);a=l,f&&(n={encrypt:1,values:iy(JSON.stringify({errcode:l?1:0,data:n}),localStorage.getItem(Xm))}),window.showLoading({title:"upload task result"}),await h$(e.id,n)}if(window.showBack(),a)throw e.retry+=1,window.showRetry(),localStorage.setItem(Qm,JSON.stringify(e)),new Xt(m$,a);window.backToGame&&window.backToGame()}async testInitWallet(){await x$("","",421613,"dev",0,"","")}async testSendEth(){await p$("chainCommon","sendEth","0x50A8e60041A206AcaA5F844a1104896224be6F39","0.01",0)}},mt.RelayWallet=eA0([$c],mt.RelayWallet);var tA0=Object.defineProperty,rA0=Object.getOwnPropertyDescriptor,aA0=(t,e,r,a)=>{for(var f=a>1?void 0:a?rA0(e,r):e,n=t.length-1,l;n>=0;n--)(l=t[n])&&(f=(a?l(e,r,f):l(f))||f);return a&&f&&tA0(e,r,f),f};window.Buffer=Q,global.AbortController=global.AbortController||window.AbortController,mt.default=class{constructor(){this.web3=null,this.wallet=null,this.password="111111",this.chainSet=new Set,this.chainMap=new Map,this.walletType=$t.INTERNAL,this.rpcUrl="",this.rpc={},this.nativeAccount="",this.env=$o.DEV,this.web3Map=new Map,this.gameAccount="",this.useWaas=!1,this.nativeSvr=new bf,this.relaySvr=new py,this.historySvr=new oy,this.emailVerifySvr=new cy,this.paySvr=new d6,window.jc={wallet:this},this.init()}updateChain(e){e=e||421613;let r=this.chainMap.get(e);if(!r)throw new Error("no current chain data");this._currentChain=r,this.rpcUrl=r.rpc,console.log(`rpc url: ${this.rpcUrl}`)}get isInternal(){return this.walletType===$t.INTERNAL}get platform(){return window.JavascriptJavaBridge?(console.log("regist android jsb.reflection"),"game_android"):window.JavaScriptObjCBridge?"game_ios":window.platform||"web"}preLogin(e,r=$o.DEV,a){return this.env=r,XD(e,a)}logout(e){return new Promise((r,a)=>{if(e===0){let f=Math.random()*1e6|0;jsb.signOutGoogle(f)}setTimeout(()=>{r&&r("")},1)})}bindPlatform(e,r){return XD(r,e)}verifyLocalPass(e){return yM0(e)}exportPrivateKey(e){return wM0(e)}emailLogin(e,r){return mM0(e,r)}configWeb3Env(){this.web3.eth.handleRevert=!0,this.web3.eth.transactionConfirmationBlocks=uN,this.erc20Standard=new _E0(this.web3),this.erc721Standard=new kE0(this.web3),this.erc1155Standard=new wE0(this.web3),this.jcStandard=new RE0(this.web3),this.chainCommon=new cE0(this.web3)}async initInternalWallet(e,r,a=$o.DEV,f=!1){this.env=a,this.useWaas=f,this.walletType=$t.INTERNAL,this.updateChain(e);let n=await gM0(r);this.nativeAccount=n,console.log("native wallet address: "+n);var l=Date.now();this.web3=this.generateWeb3(e),console.log(`init web3 cost: ${(Date.now()-l)/1e3}s`),this.configWeb3Env(),console.log("this.web3.eth.defaultAccount: "+JSON.stringify(this.web3.eth.defaultAccount));let m=await this.web3.eth.getGasPrice();console.log("gas price: "+m)}async initThirdPartyWallet(e,r=$o.DEV,a=$t.THIRD_PARTY,f){if(a===$t.INJECTED){let l=await this.initOKXWallet(e,r,!0,f),{address:m,signature:y,message:_}=l,E=await fy({channel:R1.RELAY_WALLET,code:y,message:_});return{address:m,token:E}}this.env=r,this.walletType=$t.THIRD_PARTY,this.updateChain(e),this.wConnect&&this.wConnect.disconnect(),this.wConnect=new Yg0,await this.wConnect.connect(e),this.web3=new ya(this.wConnect.provider),this.configWeb3Env();let n=await this.web3.eth.getChainId();console.log(`current chain: ${n}, this._currentchain: ${this._currentChain.id}`),n!==this._currentChain.id&&await this.updateCurrentChain(this.currentChain.id)}async initRelayWallet(e,r=$o.DEV){this.env=r,this.walletType=$t.RELAY,this.updateChain(e);let{token:a,address:f}=await UE0(e,r);return this.nativeAccount=f,this.web3=this.generateWeb3(e),this.configWeb3Env(),{address:f,token:a}}async initOKXWallet(e,r=$o.DEV,a=!0,f){console.log(`initOKXWallet with chain: ${e}, env: ${r}`),this.env=r,this.walletType=$t.INJECTED,this.updateChain(e),this.injectedConnect&&this.injectedConnect.disconnect(),this.injectedConnect=new NE0,await this.injectedConnect.connect(e,f),this.web3=new ya(this.injectedConnect.provider);const n=await this.web3.eth.requestAccounts();this.injectedConnect.accounts=n;let l,m;if(a){let y=await this.injectedConnect.signWithSiwe();l=y.signature,m=y.message}return this.configWeb3Env(),await this.web3.eth.getChainId()!==this._currentChain.id&&await this.updateCurrentChain(this.currentChain.id),{address:n[0],signature:l,message:m}}init(){for(let e of Rg0)if(this.chainSet.add(e),!this.chainMap.has(e)){let r=Jg0.find(a=>a.id===e);r&&this.chainMap.set(e,r)}}get currentChain(){return this._currentChain}get currentChainCfg(){return HE0[`${this.currentChain.id}_${this.env}`]}updateCurrentChain(e){return new Promise((r,a)=>{if(this.walletType===$t.INTERNAL){const f=this.chainMap.get(e);if(!f){a&&a("chain data not found");return}this._currentChain=f,this.web3.eth.setProvider(f.rpc),r&&r(this.currentChain)}else if(this.walletType===$t.INJECTED){const f=this.chainMap.get(e);this.injectedConnect.addOrChangeChain(f).then(()=>{r&&r(f)}).catch(n=>{a&&a(n)})}else{console.log("third party wallet change chain: "+e);const f=this.chainMap.get(e);this.wConnect.addOrChangeChain(f).then(()=>{r&&r(f)}).catch(n=>{a&&a(n)}),setTimeout(()=>{jumpToWallet()},500)}})}get chainList(){return[...this.chainMap.values()]}currentAccount(){return this.walletType===$t.INTERNAL||this.walletType===$t.RELAY?this.wallet[0]:this.walletType===$t.INJECTED?this.injectedConnect.accounts[0]:this.wConnect.accounts[0]}get currentAccAddr(){return this.walletType===$t.INTERNAL||this.walletType===$t.RELAY?this.nativeAccount:this.walletType===$t.INJECTED?this.injectedConnect.accounts[0]:this.wConnect.accounts[0]}generateWeb3(e,r=!0){if(this.web3Map.has(e))return this.web3Map.get(e);const a=this.chainMap.get(e);if(!a)return null;let f;return this.useWaas&&this.env===$o.RELEASE?f=new ya(new ZE0(this.nativeAccount,a.rpc)):f=new ya(a.rpc),this.injectAccount(f,r),this.web3Map.set(e,f),f}injectAccount(e,r=!0){const a=`${Ig0}${this.currentAccAddr.slice(2)}`,f=e.eth.accounts.privateKeyToAccount(a),n=e.eth.accounts.wallet.add(f);return e.eth.defaultAccount=n.address,console.log("web3 account: "+JSON.stringify(e.eth.accounts.wallet[0])),r&&(this.wallet=e.eth.accounts.wallet,e.eth.accounts.wallet.save(this.password,Mg0)),n.address}async generateGasShow(e){let r=this.currentChain,a=await new d6().getGasPrice(r.id),f=F8(a).mul(F8(e)),n=r.type!=="Testnet"?r.symbol:"ETH",l=r.type!=="Testnet"?r.network||r.symbol:"ETH",m=await new d6().queryTokenPrice(l,n),y=parseFloat(m)*100,_=F8(y),E=Uh(f.mul(_),20),A=Uh(f,18);return{gas:e,price:a,eth:A,usd:E}}async fetchGasPrice(){let e=await this.web3.eth.getGasPrice();return console.log("fetchGasPrice::"+e),(parseInt(e)*1.3|0)+""}async calcTokenPrice(e,r){let a=this.currentChain,f=a.type!=="Testnet"?a.network||a.symbol:"ETH",n=this.env,l=await new d6().queryTokenPrice(f,e,n);return parseFloat(l)*parseFloat(r)}signTypedDataV4(e){const r=this.currentAccount();return Zo.signTypedData({data:e,privateKey:Q.from(r.privateKey.replace("0x",""),"hex"),version:Zo.SignTypedDataVersion.V4})}loginSign(e,r,a){return new Promise((f,n)=>{const l=this.currentAccount();if(this.walletType===$t.INTERNAL){const m=$g0(e,r,l.privateKey);f&&f(m)}else if(this.walletType===$t.INJECTED)this.injectedConnect.signData({nonce:e,tips:r,chainId:this.currentChain.id},a||l).then(m=>{f&&f(m)});else{const m=vN(e,r);this.wConnect.signData(m,a||l).then(y=>{f&&f(y)}).catch(y=>{n&&n(y)}),setTimeout(()=>{jumpToWallet()},500)}})}recoverTypedSignatureV4(e,r){return Zo.recoverTypedSignature({data:e,signature:r,version:Zo.SignTypedDataVersion.V4})}generateIconData(e,r){return new R40().init(e,r)}formatPrice(e,r,a){return uy(e,r,a)}async erc20Info(e){let r=await this.erc20Standard.getTokenSymbol(e),a=await this.erc20Standard.getTokenDecimals(e);return{symbol:r,decimal:a}}async scanQr(e){let r=await this.nativeSvr.scanQRCode(e)+"";return console.log("scan qr code: "+r),r&&r.indexOf("://")>=0&&MM0(r),r}async deleteAccount(){return await cM0(),{}}async resetWalletAddress(){return await fM0(),await Oh(),{}}saveLocalItem(e,r){jsb.saveLocalStorage(e,r)}loadLocalItem(e){let r=jsb.loadLocalStorage(e);return console.log("loadLocalItem:: "+r),r}},mt.default=aA0([$c],mt.default),mt.BN_ZERO=sE0,mt.RELAYED_METHODS=v$,mt.WALLET_ACCOUNT_CHANGE=Ng0,mt.WALLET_CHAIN_CHANGE=Og0,mt.WALLET_TOKEN_TYPE_CHANGE=Dg0,mt.ZError=Xt,mt.addHexPrefix=by,mt.addUrlProtocolPrefix=d$,mt.calcTokenValueToSend=bE0,mt.createWalletEvents=nh,mt.cryptoUtil=Q_0,mt.fastSplit=n$,mt.formatAddress=xE0,mt.formatMoney=pE0,mt.fromTokenMinimalUnit=Uh,mt.getFormattedIpfsUrl=j8,mt.getIpfsCIDv1AndPath=o$,mt.isDecimal=hE0,mt.isSmartContractCode=lE0,mt.numberToBN=c$,mt.removeIpfsProtocolPrefix=ly,mt.renderFromTokenMinimalUnit=uy,mt.renderFromWei=uE0,mt.safeNumberToBN=F8,mt.stripHexPrefix=hy,mt.toBN=Tr,mt.toWeiBn=f$,Object.defineProperty(mt,"__esModule",{value:!0})}); +`)}}class NE0{constructor(){this.accounts=[],this.onAccountsChanged=e=>{console.log("on accountsChanged: ",e),this.accounts=e},this.onChainChanged=e=>{const r=parseInt(e);console.log("on chainChanged",e,r)},this.onDisconnect=e=>{console.log("on disconnect",e)}}async connect(e,r=window.okxwallet||window.ethereum){this.provider=r,this.chainId=e,this._subscribeToEvents()}async disconnect(){this.provider&&(this.provider.removeListener("accountsChanged",this.onAccountsChanged),this.provider.removeListener("chainChanged",this.onChainChanged),this.provider.removeListener("disconnect",this.onDisconnect))}_subscribeToEvents(){this.provider.on("accountsChanged",this.onAccountsChanged),this.provider.on("chainChanged",this.onChainChanged),this.provider.on("disconnect",this.onDisconnect)}async addOrChangeChain(e){return new Promise((r,a)=>{const f=l=>{console.log("switchEthereumChain: ",l),this.provider.removeListener("chainChanged",f),r&&r(l)};this.provider.on("chainChanged",f);let n={chainId:_N(e.id),chainName:e.name,nativeCurrency:{name:e.symbol,symbol:e.symbol,decimals:e.decimals||18},rpcUrls:[e.rpc],blockExplorerUrls:[e.explorerurl]};this.provider.request({method:"wallet_addEthereumChain",params:[n]}).then(()=>{console.log("add chain success, wait result")}).catch(l=>{console.error("add chain error: ",JSON.stringify(l)),this.provider.removeListener("chainChanged",f),a&&a(l)})})}async signWithSiwe(){let e=await Rh(()=>oM0(),sN);if(e.errcode)throw new Xt(e.errcode,e.errmsg);let r=e.data.nonce;return this.signData({chainId:this.chainId,nonce:r},this.accounts[0])}async signData(e,r){const a=Lr.toChecksumAddress(r),{chainId:f,nonce:n}=e;let l=new OE0({domain:document.location.host,address:a,chainId:f,uri:document.location.origin,version:"1",statement:"Counter Fire Wallet Relay",nonce:n}),m=l.toMessage();return{signature:await this.provider.request({method:"personal_sign",params:[Lr.utf8ToHex(m),a]}),message:l}}async sendCmd({method:e,params:r,from:a}){}}function DE0(t){const e=`${Kr()}/wallet/relay/prepare`;return Or(e,t)}function u$(t){const e=`${Kr()}/wallet/relay/getlast`;return Or(e,{type:t},new oa().relayToken)}function $E0(t){const e=`${Kr()}/wallet/relay/getdata`;return Or(e,{id:t},new oa().relayToken)}function b$(t,e){const r=`${Kr()}/wallet/relay/putdata`;return Or(r,{type:t,data:e},new oa().relayToken)}function h$(t,e){const r=`${Kr()}/wallet/relay/updata`;return Or(r,{id:t,data:e},new oa().relayToken)}var q8=(t=>(t[t.TO_WALLET=0]="TO_WALLET",t[t.FROM_WALLET=1]="FROM_WALLET",t))(q8||{});async function UE0(t,e="dev"){let r=qr()+"",a=localStorage.getItem(hN);if(gN(60,a)){let _=jsb.preRegistClient(r),[E,A]=_.split("|"),k=await DE0({msg:r,address:E,signature:A});if(k.errorcode)throw new Error(k.errmsg);a=k.data.token,localStorage.setItem(hN,a)}console.log(`relay token: ${a}`),LE0(a);let f=await jc.wallet.relaySvr.beginReq("",ih,t,e),{address:n,signature:l,message:m,key:y}=f;return console.log(`initRelayWallet::from relay: address: ${n}, signature: ${l}, encrypt: ${!!y}`),y&&jsb.parseRelayAESKey(y),{token:await fy({channel:R1.RELAY_WALLET,code:l,message:m}),address:n}}async function LE0(t){new oa().relayToken=t}async function FE0(t){return b$(q8.TO_WALLET,t)}var jE0=Object.defineProperty,zE0=Object.getOwnPropertyDescriptor,qE0=(t,e,r,a)=>{for(var f=a>1?void 0:a?zE0(e,r):e,n=t.length-1,l;n>=0;n--)(l=t[n])&&(f=(a?l(e,r,f):l(f))||f);return a&&f&&jE0(e,r,f),f};let py=class{constructor(){this._event=nh()}_subscribeToResponse(t,e){this._event.on(`response:${t}`,e)}_subscribeToCallResponse(t){return new Promise((e,r)=>{this._subscribeToResponse(t,a=>{if(a.errcode){r(a.errmsg||a.data||a.errcode);return}e(a.data)})})}handleNativeCallback(...t){let e=t[0],r=JSON.parse(t[1]);this._event.emit(`response:${e}`,r)}async checkResult(){if(console.log("relay check result: "+window.currentRelayId),!window.currentRelayId)return;let{errcode:t,errmsg:e,data:r}=await $E0(window.currentRelayId),a=r.resp;if(typeof a=="object"&&a.encrypt){let f=jsb.loadRelayAESKey();a=JSON.parse(ny(a.values,f)),console.log("decrypt result: "+JSON.stringify(a))}this._event.emit(`response:${window.currentRelayId}`,a),window.currentRelayId=void 0}async beginReq(...t){let e=t[1],r={method:e,params:t};e===ih?r.pk=jsb.prepareRelayRSAKey():r={method:lN,values:iy(JSON.stringify(r),jsb.loadRelayAESKey())};let{errcode:a,data:f,errmsg:n}=await FE0(r);console.log("uploadRelayData result: "+JSON.stringify({errcode:a,data:f,errmsg:n}));let{id:l}=f;console.log("relay id: "+l);let m=Ug0(new oa().relayToken);return window.toRelayPage(`${Pg0()}?token=${m}`),window.currentRelayId=l+"",this._subscribeToCallResponse(l)}};py=qE0([$c],py);const HE0={"42161_release":{tokens:[{type:"eth",address:"eth",symbol:"ETH",decimal:18},{type:"erc20",address:"0x741482aE1480E552735E44Ff3A733448AcBbeD8d",symbol:"CEG",decimal:18},{address:"0x79fc2a4216A1e595DBD09D13c4B4bD3B095d5bb2",name:"hero",type:"erc721"},{address:"0x551838d7754157D13e7D945b8a37bBD6Ad50dDC7",name:"chip",type:"erc721"},{address:"0xD728de3d9ebeD90E84aBe84539280cbC5b18E304",name:"genesis",type:"erc721"},{address:"0x3F13F83E6363D97d0353cAAfACA08B05D9BF3637",name:"gacha",type:"erc721"},{type:"erc20",address:"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",symbol:"USDT",decimal:6,thirdparty:1},{type:"erc20",address:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",symbol:"USDC",decimal:6,thirdparty:1},{address:"0x66944F7AEB68779DE2B4f68Fde5d704fff723134",name:"planet",type:"erc721"}],contracts:{minterFactory:"0x24499444b2BE6A8E3F800D47E4Ed0c36B5c0747e",nftmarket:"0xA683c7BC5f3c73782fce9fc614Fda7C999934db8",nftmall:"0xb5EF2FAC11c385041f847E34E0b1B4740436f769",gamemarket:"0x6232d2B720C22D6BCB633560b05002C472a64f18",gamemall:"0x1Ee01D949C848aF1ceDb80165b290554937819d9",tokenmall:"0x2Da675caB260c6aDC6A59802Df028B3057EeE848",nftStaking:"0x2d8D530941d6Cbe92Cf0654671522e425b9882A2",brickFactory:"0x0"},gasInfo:{nftApprove:49340,cecApprove:46962,marketSellNFT:270740,marketCancelOrder:119027,marketUpdatePrice:41272,marketBuy:207735,gameMallBuy:119416,gameMarketBuy:133251}},"421613_release":{tokens:[{type:"eth",address:"eth",symbol:"AGOR",decimal:18},{type:"erc20",address:"0x8dd1439E0C3254b4543d6D68b3C0C891E5Bd2eCE",symbol:"CEC",decimal:18},{type:"erc20",address:"0x2C7221588D4FBac2585D71618CD540e74c7413B8",symbol:"CEG",decimal:18},{address:"0xE6A69474E04B93De50dd07F239d62879dB9bF716",name:"hero",type:"erc721"},{address:"0x8Ce844402bE22fA1276a375Ff2354DD27aDEF285",name:"weapon",type:"erc721"},{address:"0x4678fE0177B15538F441264cB851364d9F3872AA",name:"chip",type:"erc721"}],contracts:{minterFactory:"0x1A27515c35a92Fb276c2670fa27C85ffAd75D094",market:"0xb80E19c50747972E735c68C0BA5651AD952d70BC"}},"421613_dev":{tokens:[{type:"eth",address:"eth",symbol:"AGOR",decimal:18},{type:"erc20",address:"0x8dd1439E0C3254b4543d6D68b3C0C891E5Bd2eCE",symbol:"CEC",decimal:18},{type:"erc20",address:"0x2C7221588D4FBac2585D71618CD540e74c7413B8",symbol:"CEG",decimal:18},{address:"0xE6A69474E04B93De50dd07F239d62879dB9bF716",name:"hero",type:"erc721"},{address:"0x8Ce844402bE22fA1276a375Ff2354DD27aDEF285",name:"weapon",type:"erc721"},{address:"0x4678fE0177B15538F441264cB851364d9F3872AA",name:"chip",type:"erc721"},{type:"erc20",address:"0xaa34B79A0Ab433eaC900fB3CB9f191F5Cd27501D",symbol:"USDT",decimal:18,thirdparty:1},{type:"erc20",address:"0x944D0A8463B2c955F90F7252bBb99A3395087155",symbol:"USDC",decimal:6,thirdparty:1},{address:"0xEbC170185ad614C05Af38C820020b70E458717F5",name:"gacha",type:"erc721"},{address:"0xae37bb7BcA26Bab9a11D8BaE8fdB97f63b82c189",name:"TestHero",type:"erc721"},{address:"0x6f9c3F80C7F92064560eC09ab66dc132928Ff2dF",name:"planet",type:"erc721"},{address:"0x0bC735C26040a56352271C32A9bAf9cc47f2F264",name:"goldbrick",type:"erc721"}],contracts:{minterFactory:"0x1A27515c35a92Fb276c2670fa27C85ffAd75D094",nftmarket:"0xB9720d2c9D01FE36a1aA1224cbB06BF8e436812E",nftmall:"0x4d71dE0428328112A78D402A6fdd7ceD1C96B71e",gamemarket:"0x46e2C612756b702b3d68d89F97c88FFa725F6fab",gamemall:"0x1D058c7c7451c34BbfF9c0dF1C16b95C5d171d64",tokenmall:"0x22557f3fe7fbA53C66a35a3D70527D014704fd4D",nftStaking:"0xB18Ba312f939E58b959F30c747c198BDc205482E",brickFactory:"0x40295E4879926D04E04cE59F0293b5b5FDe6267c"},gasInfo:{nftApprove:49340,cecApprove:46962,marketSellNFT:270740,marketCancelOrder:119027,marketUpdatePrice:41272,marketBuy:207735,gameMallBuy:119416,gameMarketBuy:133251}},"421614_dev":{tokens:[{type:"eth",address:"eth",symbol:"ETH",decimal:18},{type:"erc20",address:"0x4A490306E1644Ce1AA755c90A2F3728A1E925e11",symbol:"CEC",decimal:18},{type:"erc20",address:"0xa12cdbC6BAcDDE9BbC03F9a7ea1240c7D48009E5",symbol:"CEG",decimal:18},{address:"0x59e751c2037B710090035B6ea928e0cce80aC03f",name:"hero",type:"erc721"},{type:"erc20",address:"0x1304E6AA241eE3C9ea44Db9e593e85Ae76eC41F1",symbol:"USDT",decimal:18,thirdparty:1},{type:"erc20",address:"0x705FA0719764E184458b407dfeFD54958b52070a",symbol:"USDC",decimal:6,thirdparty:1},{address:"0xe2E4D5a4045fBFcbCBECAf5b8A94303712d2FA97",name:"gacha",type:"erc721"},{address:"0xCD4bb3402f1a444a1AF10F31946Ed37DaC0eaC4d",name:"TestHero",type:"erc721"},{address:"0x8ee0a9D6025A46f21c9b0b75a8472D001d94e8A7",name:"planet",type:"erc721"},{address:"0x22Ac497e7FbdaDDB6945354F8080998f4Abbdc4b",name:"goldbrick",type:"erc721"}],contracts:{minterFactory:"0x57cCdaF10dBDb0171207ec6Ccb6669D4a09257F8",nftmarket:"0x914F7646F30A18d84C21b0255b84896Ef7e5a05a",nftmall:"0x3c5991E9A0e6c713163cD0a91f246dc61f18d918",gamemarket:"0x2036A0708AC2F17F67b08357d8b4A7d47cF49c29",gamemall:"0x20e2677F32dC0CB5D0bB0DEf9df84369AD5a7EC2",tokenmall:"0x23e7Ef7D6F9bc3305E8EF0Fa1e5e12C1D5a4b06B",nftStaking:"0xd46fA2E72BA0F54092D0eF6a6e0D1d5660259C7a",brickFactory:"0x45E2Eae3634a69Fb9242397A75dd5751aEa8041e"},gasInfo:{nftApprove:49340,cecApprove:46962,marketSellNFT:270740,marketCancelOrder:119027,marketUpdatePrice:41272,marketBuy:207735,gameMallBuy:119416,gameMarketBuy:133251}},"195_dev":{tokens:[{type:"eth",address:"eth",symbol:"OKB",decimal:18},{type:"erc20",address:"0xB469331cEC98E52b7Eab07dFB586253bE232BBF7",symbol:"CEC",decimal:18},{type:"erc20",address:"0x0Ddb3c60DEab2d55bb757772A89680A0533f6B41",symbol:"CEG",decimal:18},{address:"0xE68F149daF2F314d9960c08496D8701BC7671850",name:"hero",type:"erc721"},{address:"0xD80a641a28702064e3f5EF383bd2640d4ff795c8",name:"planet",type:"erc721"},{address:"0x1991ee2f224ae5500fb15E90f9967Fb70F4ca27f",name:"gacha",type:"erc721"},{address:"0xC35Dcdb3672f1CFC5fe0B0Ec6861a5e9777757CD",name:"TestHero",type:"erc721"},{type:"erc20",address:"0x0Fd13D2CD0B6c679B6f92590E0b91C18DDe7BD3A",symbol:"USDT",decimal:18,thirdparty:1},{type:"erc20",address:"0x23e7Ef7D6F9bc3305E8EF0Fa1e5e12C1D5a4b06B",symbol:"USDC",decimal:6,thirdparty:1}],contracts:{minterFactory:"0xf45702180314187a3549FEDac3B78349b47ca6A0",nftmarket:"0xD7Fc45b5E6C7A7ad299b45E6D34B59b9c3B5e7e1",nftmall:"0x2036A0708AC2F17F67b08357d8b4A7d47cF49c29",gamemarket:"0x61E1B8A2937Fa966a6D50D294B66948Ee20f328a",gamemall:"0x31F29C9A3D0c1c13C825475aebF0d964b5B47c45",tokenmall:"0x20e2677F32dC0CB5D0bB0DEf9df84369AD5a7EC2",nftStaking:"0x07564E0C9dAC31F1640b34070C09aF3C820CD9E7",brickFactory:"0x0"},gasInfo:{nftApprove:49340,cecApprove:46962,marketSellNFT:270740,marketCancelOrder:119027,marketUpdatePrice:41272,marketBuy:207735,gameMallBuy:119416,gameMarketBuy:133251}}};function KE0(t){const e=`${Kr()}/wallet/okx/sendtran`;return Or(e,t)}function VE0(t){const e=`${Kr()}/wallet/okx/gasprice`;return Or(e,t)}const l$=new Map([["eth_requestAccounts","requestAccounts"],["eth_gasPrice","gasPrice"],["eth_sendRawTransaction","sendTransaction"]]),WE0="0xa9059cbb",GE0="0x23b872dd";class ZE0{constructor(e,r){this.address=e,this.rpc=r}async sendAsync(e,r){window.debug&&console.log("payload: "+JSON.stringify(e)),l$.has(e.method)?await this[l$.get(e.method)].call(this,e,r):await this.normalSend(e,r)}async send(e,r){this.sendAsync(e,r)}async normalSend(e,r){try{let a={};a["Content-Type"]="application/json";let f=await P4(this.rpc,{method:"POST",body:JSON.stringify(e),headers:a});f=await f.json(),r(null,f)}catch(a){r(a)}}requestAccounts(e,r){r(null,{id:e.id,jsonrpc:e.jsonrpc,result:this.address})}async gasPrice(e,r){let a=jc.wallet.currentChain.id;try{let f=await VE0({chain:a});if(f.errcode)r(new Error(f.errmsg));else{let n=f.data.min;n=by(Number(n).toString(16)),r(null,{id:e.id,jsonrpc:e.jsonrpc,result:n})}}catch(f){r(f)}}async sendTransaction(e,r){let a=e.paramsOrig,f=jc.wallet.currentChain.id,n=Tr(a.gas),l=Tr(a.maxFeePerGas||a.gasPrice),m=n.mul(l),y={signedTx:e.params[0],addrFrom:a.from,addrTo:a.to,txHash:a.transactionHash,txAmount:Tr(a.value||0).toString(),chainId:f,serviceCharge:m.toString(),extJson:{gasPrice:l.toString(),gasLimit:n.toString(),nonce:Tr(a.nonce).toString()}};a.data?(y.txType="contractCall",(a.data.startsWith(WE0)||a.data.startsWith(GE0))&&(y.tokenAddress=a.to)):y.txType="transfer";try{let _=await KE0({data:y});console.log("sendTransaction result: ",JSON.stringify(_));let E={id:e.id,jsonrpc:e.jsonrpc};_.errcode?E.error={code:_.errcode,message:_.errmsg}:E.result=_.data.txHash,r(null,E)}catch(_){r(_)}}}var $o=(t=>(t.DEV="dev",t.RELEASE="release",t))($o||{});function YE0(t){let e=JD();return localStorage.setItem(Xm,e+""),YD(e+"",t)}async function x$(...t){let e=t.pop(),r=t.pop(),a=!1;e&&(a=YE0(e)),t.shift(),t.shift();let f;try{let n=await jc.wallet.initOKXWallet(...t);localStorage.setItem(xN,JSON.stringify(t)),localStorage.setItem(pN,n.address),Object.assign(n,{key:a}),n={errcode:0,data:n},r&&await h$(r,n)}catch(n){f=n}return{error:f}}async function JE0(){if(!jc||!jc.wallet||!jc.wallet.web3){window.showLoading({title:"prepare wallet"});let t=localStorage.getItem(xN);t||(t=JSON.stringify([421613,"dev"]));let e=JSON.parse(t);e.push(!1);let r=await jc.wallet.initOKXWallet(...e),a=localStorage.getItem(pN);if(a&&a!==r.address)throw new Error("Current address is inconsistent with the address bound to the game, Change current account then retry.")}}async function p$(...t){let e=t.shift(),r=t.shift();console.log(`relay method: ${e}.${r}`),r!==ih&&(await JE0(),window.showLoading({title:"parse chain request"}));let a,f;try{e?a=await jc.wallet[e][r](...t):a=await jc.wallet[r](...t)}catch(n){a=n.message||n,f=n}return{value:a,error:f}}var XE0=Object.defineProperty,QE0=Object.getOwnPropertyDescriptor,eA0=(t,e,r,a)=>{for(var f=a>1?void 0:a?QE0(e,r):e,n=t.length-1,l;n>=0;n--)(l=t[n])&&(f=(a?l(e,r,f):l(f))||f);return a&&f&&XE0(e,r,f),f};const v$=[{path:"",method:"initOKXWallet"},{path:"erc20Standard",method:"transfer"},{path:"erc721Standard",method:"transfer"},{path:"erc1155Standard",method:"transferBatch"},{path:"chainCommon",method:"sendEth"},{path:"jcStandard",method:"mintNFT"},{path:"jcStandard",method:"marketSellNFT"},{path:"jcStandard",method:"marketUpdatePrice"},{path:"jcStandard",method:"marketBuy"},{path:"jcStandard",method:"gameMallBuy"},{path:"jcStandard",method:"gameMarketBuy"},{path:"jcStandard",method:"buyTokenWithErc20"},{path:"jcStandard",method:"mallBuy"},{path:"jcStandard",method:"stakeNfts"},{path:"jcStandard",method:"redeemNfts"}],m$=1201;mt.RelayWallet=class{async startRelay(e){e=Lg0(e),new oa().relayToken=e,window.showLoading({title:"init wallet"});try{let{errcode:r,errmsg:a,data:f}=await u$(q8.TO_WALLET);if(r)throw new Error(a);if(f.status!==0)throw new Error("no task to do, back to game and try again.");await this.parseLastRelayCmd(f),window.showResult({title:"finished parse task, back to game manually."})}catch(r){if(r instanceof Xt&&r.statusCode===m$){let a=r.message||r||"";window.showResult({error:1,title:`parse task with error: ${a}, try again?`})}else{let a=r.message||r||"error parse task, please try again later.";window.showResult({title:a,error:1})}}return!0}async uploadRelayData(e){return b$(q8.FROM_WALLET,e)}async fetchRelayData(){return u$(q8.TO_WALLET)}async retryLastRelayCmd(){let e=localStorage.getItem(Qm);if(e)try{let r=JSON.parse(e);await this.parseLastRelayCmd(r),window.showResult({title:"finished parse task, back to game manually."}),localStorage.removeItem(Qm)}catch(r){let a=r.message||r||"";window.showResult({error:1,title:`parse task with error: ${a}, try again?`})}else console.log("no local tmp data")}async parseLastRelayCmd(e){window.hideRetry();let r=e.data,a;if(r.method===ih){let f=[...r.params,e.id,r.pk];a=(await x$.apply(this,f)).error}else{let f=r.method===lN;if(f){let m=localStorage.getItem(Xm);if(!m)throw new Error("relay msg key not found");r=JSON.parse(ny(r.values,m))}if(v$.findIndex(m=>m.method==r.method)<0)throw new Error(`method ${r.method} not found`);let{value:n,error:l}=await p$.apply(this,r.params);a=l,f&&(n={encrypt:1,values:iy(JSON.stringify({errcode:l?1:0,data:n}),localStorage.getItem(Xm))}),window.showLoading({title:"upload task result"}),await h$(e.id,n)}if(window.showBack(),a)throw e.retry+=1,window.showRetry(),localStorage.setItem(Qm,JSON.stringify(e)),new Xt(m$,a);window.backToGame&&window.backToGame()}async testInitWallet(){await x$("","",421613,"dev",0,"","")}async testSendEth(){await p$("chainCommon","sendEth","0x50A8e60041A206AcaA5F844a1104896224be6F39","0.01",0)}},mt.RelayWallet=eA0([$c],mt.RelayWallet);var tA0=Object.defineProperty,rA0=Object.getOwnPropertyDescriptor,aA0=(t,e,r,a)=>{for(var f=a>1?void 0:a?rA0(e,r):e,n=t.length-1,l;n>=0;n--)(l=t[n])&&(f=(a?l(e,r,f):l(f))||f);return a&&f&&tA0(e,r,f),f};window.Buffer=Q,global.AbortController=global.AbortController||window.AbortController,mt.default=class{constructor(){this.web3=null,this.wallet=null,this.password="111111",this.chainSet=new Set,this.chainMap=new Map,this.walletType=$t.INTERNAL,this.rpcUrl="",this.rpc={},this.nativeAccount="",this.env=$o.DEV,this.web3Map=new Map,this.gameAccount="",this.useWaas=!1,this.nativeSvr=new bf,this.relaySvr=new py,this.historySvr=new oy,this.emailVerifySvr=new cy,this.paySvr=new d6,window.jc={wallet:this},this.init()}updateChain(e){e=e||421613;let r=this.chainMap.get(e);if(!r)throw new Error("no current chain data");this._currentChain=r,this.rpcUrl=r.rpc,console.log(`rpc url: ${this.rpcUrl}`)}get isInternal(){return this.walletType===$t.INTERNAL}get platform(){return window.JavascriptJavaBridge?(console.log("regist android jsb.reflection"),"game_android"):window.JavaScriptObjCBridge?"game_ios":window.platform||"web"}preLogin(e,r=$o.DEV,a){return this.env=r,XD(e,a)}logout(e){return new Promise((r,a)=>{if(e===0){let f=Math.random()*1e6|0;jsb.signOutGoogle(f)}setTimeout(()=>{r&&r("")},1)})}bindPlatform(e,r){return XD(r,e)}verifyLocalPass(e){return yM0(e)}exportPrivateKey(e){return wM0(e)}emailLogin(e,r){return mM0(e,r)}configWeb3Env(){this.web3.eth.handleRevert=!0,this.web3.eth.transactionConfirmationBlocks=uN,this.erc20Standard=new _E0(this.web3),this.erc721Standard=new kE0(this.web3),this.erc1155Standard=new wE0(this.web3),this.jcStandard=new RE0(this.web3),this.chainCommon=new cE0(this.web3)}async initInternalWallet(e,r,a=$o.DEV,f=!1){this.env=a,this.useWaas=f,this.walletType=$t.INTERNAL,this.updateChain(e);let n=await gM0(r);this.nativeAccount=n,console.log("native wallet address: "+n);var l=Date.now();this.web3=this.generateWeb3(e),console.log(`init web3 cost: ${(Date.now()-l)/1e3}s`),this.configWeb3Env(),console.log("this.web3.eth.defaultAccount: "+JSON.stringify(this.web3.eth.defaultAccount));let m=await this.web3.eth.getGasPrice();console.log("gas price: "+m)}async initThirdPartyWallet(e,r=$o.DEV,a=$t.THIRD_PARTY,f){if(a===$t.INJECTED){let l=await this.initOKXWallet(e,r,!0,f),{address:m,signature:y,message:_}=l,E=await fy({channel:R1.RELAY_WALLET,code:y,message:_});return{address:m,token:E}}this.env=r,this.walletType=$t.THIRD_PARTY,this.updateChain(e),this.wConnect&&this.wConnect.disconnect(),this.wConnect=new Yg0,await this.wConnect.connect(e),this.web3=new ya(this.wConnect.provider),this.configWeb3Env();let n=await this.web3.eth.getChainId();console.log(`current chain: ${n}, this._currentchain: ${this._currentChain.id}`),n!==this._currentChain.id&&await this.updateCurrentChain(this.currentChain.id)}async initRelayWallet(e,r=$o.DEV){this.env=r,this.walletType=$t.RELAY,this.updateChain(e);let{token:a,address:f}=await UE0(e,r);return this.nativeAccount=f,this.web3=this.generateWeb3(e),this.configWeb3Env(),{address:f,token:a}}async initOKXWallet(e,r=$o.DEV,a=!0,f){console.log(`initOKXWallet with chain: ${e}, env: ${r}`),this.env=r,this.walletType=$t.INJECTED,this.updateChain(e),this.injectedConnect&&this.injectedConnect.disconnect(),this.injectedConnect=new NE0,await this.injectedConnect.connect(e,f),this.web3=new ya(this.injectedConnect.provider);const n=await this.web3.eth.requestAccounts();this.injectedConnect.accounts=n;let l,m;if(a){let y=await this.injectedConnect.signWithSiwe();l=y.signature,m=y.message}return this.configWeb3Env(),await this.web3.eth.getChainId()!==this._currentChain.id&&await this.updateCurrentChain(this.currentChain.id),{address:n[0],signature:l,message:m}}init(){for(let e of Rg0)if(this.chainSet.add(e),!this.chainMap.has(e)){let r=Jg0.find(a=>a.id===e);r&&this.chainMap.set(e,r)}}get currentChain(){return this._currentChain}get currentChainCfg(){return HE0[`${this.currentChain.id}_${this.env}`]}updateCurrentChain(e){return new Promise((r,a)=>{if(this.walletType===$t.INTERNAL){const f=this.chainMap.get(e);if(!f){a&&a("chain data not found");return}this._currentChain=f,this.web3.eth.setProvider(f.rpc),r&&r(this.currentChain)}else if(this.walletType===$t.INJECTED){const f=this.chainMap.get(e);this.injectedConnect.addOrChangeChain(f).then(()=>{r&&r(f)}).catch(n=>{a&&a(n)})}else{console.log("third party wallet change chain: "+e);const f=this.chainMap.get(e);this.wConnect.addOrChangeChain(f).then(()=>{r&&r(f)}).catch(n=>{a&&a(n)}),setTimeout(()=>{jumpToWallet()},500)}})}get chainList(){return[...this.chainMap.values()]}currentAccount(){return this.walletType===$t.INTERNAL||this.walletType===$t.RELAY?this.wallet[0]:this.walletType===$t.INJECTED?this.injectedConnect.accounts[0]:this.wConnect.accounts[0]}get currentAccAddr(){return this.walletType===$t.INTERNAL||this.walletType===$t.RELAY?this.nativeAccount:this.walletType===$t.INJECTED?this.injectedConnect.accounts[0]:this.wConnect.accounts[0]}generateWeb3(e,r=!0){if(this.web3Map.has(e))return this.web3Map.get(e);const a=this.chainMap.get(e);if(!a)return null;let f;return this.useWaas&&this.env===$o.RELEASE?f=new ya(new ZE0(this.nativeAccount,a.rpc)):f=new ya(a.rpc),this.injectAccount(f,r),this.web3Map.set(e,f),f}injectAccount(e,r=!0){const a=`${Ig0}${this.currentAccAddr.slice(2)}`,f=e.eth.accounts.privateKeyToAccount(a),n=e.eth.accounts.wallet.add(f);return e.eth.defaultAccount=n.address,console.log("web3 account: "+JSON.stringify(e.eth.accounts.wallet[0])),r&&(this.wallet=e.eth.accounts.wallet,e.eth.accounts.wallet.save(this.password,Mg0)),n.address}async generateGasShow(e){let r=this.currentChain,a=await new d6().getGasPrice(r.id),f=F8(a).mul(F8(e)),n=r.type!=="Testnet"?r.symbol:"ETH",l=r.type!=="Testnet"?r.network||r.symbol:"ETH",m=await new d6().queryTokenPrice(l,n),y=parseFloat(m)*100,_=F8(y),E=Uh(f.mul(_),20),A=Uh(f,18);return{gas:e,price:a,eth:A,usd:E}}async fetchGasPrice(){let e=await this.web3.eth.getGasPrice();return console.log("fetchGasPrice::"+e),(parseInt(e)*1.3|0)+""}async calcTokenPrice(e,r){let a=this.currentChain,f=a.type!=="Testnet"?a.network||a.symbol:"ETH",n=this.env,l=await new d6().queryTokenPrice(f,e,n);return parseFloat(l)*parseFloat(r)}signTypedDataV4(e){const r=this.currentAccount();return Zo.signTypedData({data:e,privateKey:Q.from(r.privateKey.replace("0x",""),"hex"),version:Zo.SignTypedDataVersion.V4})}loginSign(e,r,a){return new Promise((f,n)=>{const l=this.currentAccount();if(this.walletType===$t.INTERNAL){const m=$g0(e,r,l.privateKey);f&&f(m)}else if(this.walletType===$t.INJECTED)this.injectedConnect.signData({nonce:e,tips:r,chainId:this.currentChain.id},a||l).then(m=>{f&&f(m)});else{const m=vN(e,r);this.wConnect.signData(m,a||l).then(y=>{f&&f(y)}).catch(y=>{n&&n(y)}),setTimeout(()=>{jumpToWallet()},500)}})}recoverTypedSignatureV4(e,r){return Zo.recoverTypedSignature({data:e,signature:r,version:Zo.SignTypedDataVersion.V4})}generateIconData(e,r){return new R40().init(e,r)}formatPrice(e,r,a){return uy(e,r,a)}async erc20Info(e){let r=await this.erc20Standard.getTokenSymbol(e),a=await this.erc20Standard.getTokenDecimals(e);return{symbol:r,decimal:a}}async scanQr(e){let r=await this.nativeSvr.scanQRCode(e)+"";return console.log("scan qr code: "+r),r&&r.indexOf("://")>=0&&MM0(r),r}async deleteAccount(){return await cM0(),{}}async resetWalletAddress(){return await fM0(),await Oh(),{}}saveLocalItem(e,r){jsb.saveLocalStorage(e,r)}loadLocalItem(e){let r=jsb.loadLocalStorage(e);return console.log("loadLocalItem:: "+r),r}},mt.default=aA0([$c],mt.default),mt.BN_ZERO=sE0,mt.RELAYED_METHODS=v$,mt.WALLET_ACCOUNT_CHANGE=Ng0,mt.WALLET_CHAIN_CHANGE=Og0,mt.WALLET_TOKEN_TYPE_CHANGE=Dg0,mt.ZError=Xt,mt.addHexPrefix=by,mt.addUrlProtocolPrefix=d$,mt.calcTokenValueToSend=bE0,mt.createWalletEvents=nh,mt.cryptoUtil=Q_0,mt.fastSplit=n$,mt.formatAddress=xE0,mt.formatMoney=pE0,mt.fromTokenMinimalUnit=Uh,mt.getFormattedIpfsUrl=j8,mt.getIpfsCIDv1AndPath=o$,mt.isDecimal=hE0,mt.isSmartContractCode=lE0,mt.numberToBN=c$,mt.removeIpfsProtocolPrefix=ly,mt.renderFromTokenMinimalUnit=uy,mt.renderFromWei=uE0,mt.safeNumberToBN=F8,mt.stripHexPrefix=hy,mt.toBN=Tr,mt.toWeiBn=f$,Object.defineProperty(mt,"__esModule",{value:!0})}); //# sourceMappingURL=index.umd.js.map