@coinmeca/wallet-sdk
Version:
1 lines • 67.3 kB
JavaScript
import{Common as t}from"@ethereumjs/common";import{hdkey as e}from"@ethereumjs/wallet";import{bytesToHex as s,privateToAddress as i,fetchFromProvider as r,ecsign as n,toRpcSig as o}from"@ethereumjs/util";import{TransactionFactory as a}from"@ethereumjs/tx";import{keccak256 as h}from"ethereum-cryptography/keccak";import{signTypedData as c,signTypedData_v4 as d}from"eth-sig-util";import{m as u,t as f,l as p,p as l,d as y,a as w,i as m,c as v,u as g,f as b,b as A,n as E,j as S,s as I,e as k,q as D,k as C,g as x,h as _}from"./constants-BBbo8WQE.js";import{C as B}from"./core-ByiNW7VX.js";import{selectors as U}from"./selectors.js";import{random as K,hash as N,parseChainId as T,valid as F,deviceBinding as P,sealWith as R,deviceAttest as W,deviceBindingCandidates as j,deviceAttestationMatches as L,derive as M,openWith as q,parse as O,formatChainId as z,seal as V,format as G,open as $,personalSignRequest as J,typedDataRequest as Y}from"./utils.js";import{getSecureStorage as H}from"./storage.js";import"eventemitter3";import"ethereum-cryptography/utils";function Q(){const t=["m/44'/60'/0'/0/","isArray","Vault integrity check failed.","symbol","Invalid typed data.","Account ","Invalid asset data.","check","evm","The given address(","lock.count","remove","recent","http:","updateContacts","Vault state is invalid.","key",":address","svm","updateReceipt","explorer","name","string","info","cumulativeGasUsed","Invalid account address.","public:","ws:","rpc","Backup secret is required.","size","Telegram","isInitialized","fill","pending","Secure device binding is unavailable in this context.","chainId","get","https://","receipt","timeout","remain","addNonFungibleAsset","salt","nativeCurrency","number","The account information for adding the asset could not be found.","catch",") is something wrong","undefined","Chain not registered yet.","master","addFungibleAsset","public","changeAccount","Invalid signing signer.","slice","mainnet-beta","24152DPkUby","tokens","base","max","peek","tokenUpdated","Wallet already initialized.","exportState","getTime","Invalid key entered.","Invalid signing message.","index","getPrivateKey","AES-GCM","utf-8","toLowerCase","imported","Given account data is something wrong.","updateChain","The given tokenId(","failure","939654AMipJG","Locked out. Try again after ","padStart","Secure platform binding is unavailable in this context.",":state","version","assertAllowance","Invalid transaction chain id.","Requested chain RPC URL was not setup yet.","getAddressString","chainChanged","Backup bundle is required.","host","success","set","unlock","ready","push","value","url","Invalid chain id.","Secure device binding is required.","min","freeze"," second(s).","create","sign","fungibles","signTypedData_v4","contactUpdated","getSenderAddress","disable","Invalid chain parameters. `chainId`, valid `rpcUrls`, and valid native currency are required.","kdf","chainName","1237314KPXxqb","payload","backup","://","icon","balance","storageCleared","The account data wasn't provided.","Invalid account information.","device","then","updateApp","Wallet is locked.","parallelism","28CDykxh","consumeSource","Requested chain is not registered.","https:","prepend","effectiveGasPrice","135704WcpGaL","createdAt","Invalid app information.","Invalid private key.","test","resolve","startsWith","accountUpdated","Invalid transaction sender.","from","boolean","memorySize","selection","isLocked","change","CloudStorage","type","getReceipts","coinmeca:wallet","signTypedData","Invalid app accounts.","schema","nftUpdated","clear","isContract","eth_getTransactionReceipt","switchEthereumChain","data","Contract Interaction","Wallet is not setup yet.","getReceipt","keys","watchAsset","send","floor","396dzyYjY","addEthereumChain","lockTimeUpdated","Wallet reset is only available while locked out.","filter","deploy","common","storageUpdated","status","emit","logo","vault","hashLength","latest","nonFungibles","The requested account approval did not persist.","Not found account info","reset","There is no any chain registered.","path","chainUpdated","eth_getCode","coinmeca.wallet.backup","slot","length","Invalid typed data signer.","address","WebApp","signer","Couldn't found a current account information.","ethereum","credential","Backup bundle is invalid.","import","changeChain","devnet","decimals","appUpdated","fromTxData",":lock.count","interval","lock","category","call","init","defineProperty","importState","rpcUrls","fromMasterSeed","has","derivePath","Transaction sender does not match signer.","revokeAccount","There is no signer information.","export","generated","contact","next","secret:","pop","data:image/","contractAddress","3082625LgFPwz","map","exist","No active chain.","getWallet","Invalid transaction hash.","secure","There is no accounts that setup yet.","locked","NaN","Timed out while waiting for transaction ","binding","ceil","protocol","Wallet passcode is required.","EthereumHDKey","join","box","time","accounts","2OcyYwE","now","delete","removeNonFungibleAsset","blockExplorerUrls","chains","2073280krRmQJ","iterations","updateAccount","includes","signMessage","some","meta","concat","The requested account and/or method has not been authorized by the user.","apps","Typed data signer does not match requested signer.","updateReceipts","kind","wait","gasUsed","add","toUpperCase","10299050ZApCdz","Invalid chain parameters. `chainId` and at least one `rpcUrls` are required.","blockNumber","message","argon2id","Invalid transaction recipient.","isFinite","Invalid transaction receipts.","account","isSafeInteger","toString","stringify","options","Vault attestation failed.","trim","count","Invalid account index.","accountChanged","domain","isInteger","The account information for removing the asset could not be found.","substring","allowance","chain","custom","vault.attestation","hash","hasOwnProperty","removeFungibleAsset","cipher","txUpdated","platform","object","prototype","forEach","iconUrls","Locked out. Please try again later ","isCoinmecaWallet","lock.time","hex","multiTokens","Too many failed attempts. Reset the wallet if you no longer remember the passcode."];return(Q=function(){return t})()}const X=Z;function Z(t,e){const s=Q();return(Z=function(t,e){return s[t-=209]})(t,e)}!function(){const t=Z,e=Q();for(;;)try{if(375174===parseInt(t(497))/1*(-parseInt(t(374))/2)+-parseInt(t(237))/3+parseInt(t(380))/4+-parseInt(t(354))/5+parseInt(t(518))/6*(parseInt(t(251))/7)+parseInt(t(257))/8*(-parseInt(t(292))/9)+parseInt(t(397))/10)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class tt extends B{#t=X(275);#e;#s;#i;#r;#n=0;#o=[];#a=[];#h;#c=new Map;constructor(t){const e=X;super();const s=this.#d?this.#u?.[e(272)]:localStorage;this.#h=H(s,this.#t+e(522),{codename:this.#t,emit:(t,s)=>{const i=e;if(t===i(243)){const e=!this[i(270)];return this.#f(),this[i(301)](t),void(e&&this[i(301)](i(333)))}const r=s?.key,n=!!s?.[i(513)],o=r===this.#t+":lock.time"||r===this.#t+i(331),a=this[i(362)].remain,h=!this[i(270)];switch((n||o)&&a>0?(h&&(this.#f(),this[i(301)]("lock")),this[i(301)](i(294),Math.max(0,this[i(362)][i(372)]-Date[i(375)]()))):o&&this[i(301)]("lockTimeUpdated",0),s?.[i(220)],this[i(301)](t),r){case this.#t+i(456):return void this[i(301)]("accountChanged",this[i(318)]||void 0);case this.#t+":chain":case this.#t+":chainId":const t=this[i(475)],e=typeof window!==i(488)?window[i(322)]:void 0;return e?.[i(434)]&&(e.chainId=t),void this[i(301)](i(212),t);default:return}}});const{chainId:i}=t||{},r=this.#p();if("undefined"!=typeof window&&!window[e(322)]){const t={chainId:this[e(475)],isCoinmecaWallet:!0};Object[e(337)](window,"ethereum",{value:t,writable:!0,configurable:!0,enumerable:!1})}if(i&&this.#l(r,i))this[e(326)](i);else{const t=this.#y();t&&this.#l(r,t)&&this[e(326)](t)}this.#w(),Object[e(225)](this)}#m(t){const e=X;if(this.#v)return t(this.#v);if(!this[e(471)])throw new Error("Cannot access to the information of accounts.");throw new Error(e(249))}#g(t,e){const s=X;if(t===e)return!0;if(typeof t!=typeof e)return!1;if(!t||!e)return t===e;if(Array[s(440)](t)){if(!Array.isArray(e)||t.length!==e[s(316)])return!1;for(let i=0;i<t[s(316)];i+=1)if(!this.#g(t[i],e[i]))return!1;return!0}if("object"==typeof t){if(Array[s(440)](e))return!1;let i=0;for(const r in t)if(Object[s(430)][s(424)].call(t,r)){if(i+=1,!Object.prototype[s(424)][s(335)](e,r))return!1;if(!this.#g(t[r],e[r]))return!1}let r=0;for(const t in e)if(Object.prototype[s(424)].call(e,t)&&(r+=1,r>i))return!1;return i===r}return!1}#f(){this.#b(this.#s),this.#o.forEach(t=>this.#b(t)),this.#e=void 0,this.#s=void 0,this.#i=void 0,this.#r=void 0,this.#n=0,this.#o=[],this.#a=[]}#b(t){const e=X;t?.[e(472)](0)}#A(t){const e=X;if(Array.isArray(t)){for(let s=0;s<t[e(316)];s+=1)t[s]="";t.length=0}}#E(t){const e=X;return this.#h?.[e(360)](t)}#S(t){const e=X;return this.#E(t?e(465)+t:e(492))}#I(t,e,s){const i=X,r=this.#S(e)?.[i(501)]?.(t);if(typeof r!==i(488)){const t=s?s(r):r;if(typeof t!==i(488))return t}const n=this.#E()?.[i(501)]?.(t);if(typeof n!==i(488)){const t=s?s(n):n;if(typeof t!==i(488))return t}}#k(t,e,s){const i=X;if(typeof e===i(488))return void this.#D(t,s);const r=this.#S(s),n=r?.peek?.(t);if(this.#g(n,e))return void(typeof this.#E()?.[i(501)]?.(t)!==i(488)&&this.#E()?.[i(450)](t));r?.[i(216)](t,e);const o=r?.[i(501)]?.(t);this.#g(o,e)&&this.#E()?.[i(450)](t)}#D(t,e,s=!0,i=!0){const r=X,n=this.#S(e),o=void 0!==n?.get(t),a=!(o||!s||"selection"!==e)&&typeof this.#E()?.[r(476)](t)!==r(488);n?.remove(t);const h=typeof n?.[r(476)](t)===r(488);if(h&&s&&this.#E()?.remove(t),i&&e===r(269)&&h&&(o||a))switch(this.emit(r(299)),t){case r(318):return void this[r(301)](r(414),this[r(318)]||void 0);case r(420):case r(475):const t=this[r(475)],e="undefined"!=typeof window?window[r(322)]:void 0;return e?.[r(434)]&&(e[r(475)]=t),void this[r(301)](r(212),t);default:return}}#C(t){const e=X;return this.#m(s=>this.#E(e(350)+t+":"+s))}#x(t,e,s){const i=X,r=this.#C(e)?.[i(501)]?.(t);if(typeof r!==i(488)){const t=s?s(r):r;if(typeof t!==i(488))return t}const n=this.#_?.[i(501)]?.(t);if(typeof n!==i(488)){const t=s?s(n):n;if(void 0!==t)return t}}#B(t,e,s){const i=X;if(typeof e===i(488))return void this.#U(t,s);const r=this.#C(s),n=r?.[i(501)]?.(t);if(this.#g(n,e))return void(typeof this.#_?.[i(501)]?.(t)!==i(488)&&this.#_?.remove(t));r?.[i(216)](t,e);const o=r?.peek?.(t);this.#g(o,e)&&this.#_?.[i(450)](t)}#U(t,e,s=!0){const i=X,r=this.#C(e);r?.remove(t),s&&typeof r?.get(t)===i(488)&&this.#_?.[i(450)](t)}#K(t,e){const s=X;if(typeof t!==s(461))return;const i=t[s(411)]()[s(512)](),r=i[s(263)]("0x")?i.slice(2):i;return!/^[0-9a-f]+$/[s(261)](r)||e&&r.length!==e?void 0:r}#N(t){return this.#K(t,64)}#T(t){const e=X;let s=this.#N(t);t="";try{return s?Buffer[e(266)](s,"hex"):void 0}finally{s=""}}#F(t){const e=X;if(!Array[e(440)](t))return[];const s=[];for(let i=0;i<t[e(316)];i+=1){let r=typeof t[i]===e(461)?t[i]:void 0;const n=s.length<u?this.#T(r):void 0;r="",typeof t[i]===e(461)&&(t[i]=""),n&&s.push(n)}return s}#P(t=this.#o){const e=X;return t[e(355)](t=>{const s=Buffer[e(266)](t);try{return s.toString("hex")}finally{s.fill(0)}})}#R(t){const e=X;if(!t?.length)throw new Error(e(260));let r;try{return r=i(t),s(r)}finally{r?.fill(0)}}#W(t){const e=X;let s=this.#N(t);if(t="",!s)throw new Error(e(260));const i=Buffer.from(s,"hex");s="";try{return this.#R(i)}finally{i[e(472)](0),s=""}}#j(t=32){const e=X;return Array[e(266)](K(t)).map(t=>t[e(407)](16)[e(520)](2,"0"))[e(370)]("")}#L(t,e=f){const s=X;if(typeof t!==s(461))return;const i=t[s(411)]();return""!==i?i.slice(0,Math[s(500)](1,e)):void 0}async#M(t){const e=X,s=this.#L(t,1024);if(!s)return[];const i=/^[0-9a-f]{64}$/i.test(s)?s[e(512)]():await N(s);return i===s?[i]:[i,s]}#q(){this.#h.ready()}#O(t){const e=X,s=Math[e(224)](this[e(362)][e(412)]+1,p[e(316)]+3);if(this.#k(e(449),s,e(333)),this.#q(),s>3){const t=s-4;if(t>=p.length){const t=60*p[p[e(316)]-1]*1e3;throw this.#k("lock.time",Date.now()+t,e(333)),this.#q(),this[e(301)](e(294),t),new Error(e(438))}const i=60*p[t]*1e3;throw this.#k("lock.time",Date[e(375)]()+i,"lock"),this.#q(),this.emit("lockTimeUpdated",i),new Error(e(433)+Math[e(500)](1,Math[e(366)](i/1e3))+e(226))}throw new Error(t)}#z(t){const e=X;if(!t||typeof t!==e(429)||1!==t?.[e(523)]||t?.[e(426)]?.[e(460)]!==e(510))return;if("string"!=typeof t?.[e(284)]||typeof t?.[e(426)]?.iv!==e(461)||!t.cipher.iv[e(411)]())return;const s=t?.[e(235)];if(!s||"object"!=typeof s||s?.[e(460)]!==e(401)||typeof s?.[e(482)]!==e(461)||!s.salt.trim())return;const i=Number[e(416)](s?.iterations)&&s[e(381)]>0?s[e(381)]:void 0,r=Number.isInteger(s?.[e(250)])&&s[e(250)]>0?s.parallelism:void 0,n=Number.isInteger(s?.[e(268)])&&s[e(268)]>0?s[e(268)]:void 0,o=Number.isInteger(s?.[e(304)])&&s[e(304)]>0?s.hashLength:void 0;return"number"==typeof i&&typeof r===e(484)&&typeof n===e(484)&&typeof o===e(484)?{version:1,binding:t?.[e(365)]===e(246)||t?.[e(365)]===e(428)?t[e(365)]:void 0,kdf:{name:e(401),iterations:i,parallelism:r,memorySize:n,hashLength:o,salt:s.salt[e(411)]()},cipher:{name:"AES-GCM",iv:t[e(426)].iv.trim()},data:t[e(284)]}:void 0}#V(){const t=X;return this.#I(t(303),t(303),t=>this.#z(t))}#G(){const t=X;return this.#I("vault.attestation","vault",e=>typeof e===t(461)&&""!==e[t(411)]()?e[t(411)]():void 0)}#$(){return this.#t+":vault"}#J(t){const e=X;if(t)return JSON[e(408)]({version:1,binding:t[e(365)]===e(246)||t[e(365)]===e(428)?t[e(365)]:void 0,kdf:{name:e(401),iterations:t[e(235)].iterations,parallelism:t.kdf.parallelism,memorySize:t[e(235)][e(268)],hashLength:t[e(235)][e(304)],salt:t[e(235)][e(482)]},cipher:{name:e(510),iv:t[e(426)].iv},data:t.data})}#Y(){const t=X;return typeof window!==t(488)&&!this.#d&&typeof indexedDB!==t(488)}#H(t,e=u){return Number.isInteger(t)&&t>=0&&t<=e?t:void 0}#Q(t,e=u-1){return this.#H(t,e)}#X(t){const e=X;if(!t||"object"!=typeof t)return;const s="generated"===t?.[e(392)]||"imported"===t?.[e(392)]?t[e(392)]:void 0,i=this.#Q(t?.[e(315)]);return s&&typeof i===e(484)?{kind:s,slot:i}:void 0}#Z(t){const e=X;if(!Array[e(440)](t))return[];const s=[],i=new Set;return t[e(431)](t=>{const r=e;if(s[r(316)]>=u)return;const n=this.#X(t);if(!n)return;const o=n[r(392)]+":"+n[r(315)];i.has(o)||(i[r(395)](o),s[r(219)](n))}),s}#tt(t,e){const s=X;if(!e?.[s(455)]||!e?.[s(490)]||!t||typeof t!==s(429)||Array[s(440)](t))return!1;if(1!==t?.[s(278)]||t?.[s(455)]!==e[s(455)]||t?.[s(490)]!==e[s(490)])return!1;if((this.#H(t?.[s(347)])||0)!==(this.#H(e[s(347)])||0))return!1;const i=e[s(513)];if(!Array[s(440)](t?.[s(513)])||t[s(513)][s(316)]!==i[s(316)])return!1;for(let e=0;e<i.length;e+=1)if(t[s(513)][e]!==i[e])return!1;const r=e[s(373)];if(!Array[s(440)](t?.[s(373)])||t[s(373)].length!==r[s(316)])return!1;for(let e=0;e<r.length;e+=1){const i=this.#X(t[s(373)][e]),n=r[e];if(!i||!n||i[s(392)]!==n[s(392)]||i.slot!==n.slot)return!1}let n=0;for(const e in t)if(Object[s(430)][s(424)].call(t,e)&&(n+=1,e!==s(278)&&e!==s(455)&&"master"!==e&&e!==s(347)&&e!==s(513)&&e!==s(373)))return!1;return 6===n}#et(t=[]){return{schema:1,apps:this.#st(t)}}#it(t){const e=X;if(Array[e(440)](t)){const s=this.#rt(this.#nt(t));if(t[e(316)]&&!s.length)return;return this.#et(s)}if(!t||"object"!=typeof t)return;if("number"==typeof t?.[e(278)]&&1!==t[e(278)])return;if(!Array[e(440)](t?.[e(389)]))return;const s=this.#rt(this.#nt(t));return!t.apps[e(316)]||s[e(316)]?this.#et(s):void 0}#ot(t=[]){return{schema:1,chains:this.#at(t)}}#ht(){const t=X;if(!this.#r)return;const e=this.#a[t(355)](t=>({...t})),s=this.#P(),i=this.#p(),r=this.#ct(),n=this[t(475)],o=n?T(n):void 0,a=[];this.#m(()=>{const e=t;for(let t=0;t<this.#a.length&&a.length<u;t+=1){const s=this.#dt(t)[e(349)];a[e(219)]({address:s[e(318)],name:s.name,disable:s[e(233)],kind:s.kind,slot:s[e(315)],path:s[e(311)],tokens:s[e(498)],tx:s.tx})}});const h={schema:1,createdAt:Date[t(375)](),master:this.#r,generated:this.#n,imported:s,accounts:e,meta:a,address:this[t(318)],chainId:o,chains:i,contact:r},c=h[t(258)],d={accounts:Math[t(500)](0,h.accounts[t(316)]),generated:Math.max(0,h[t(347)]),imported:Math[t(500)](0,h[t(513)][t(316)])};let f="";try{f=JSON[t(408)](h)}finally{this.#ut(h),e[t(316)]=0,a.length=0,i.length=0,this.#ft(r)}return{payload:f,createdAt:c,info:d}}#pt(t,e,s=!1){this.#s&&this.#s!==t&&this.#b(this.#s),this.#s=t?s?t:new Uint8Array(t):void 0,this.#i=e?{...e}:void 0}#lt(t){const e=X;t&&(t[e(455)]="",t[e(490)]="",t[e(347)]=0,this.#A(t[e(513)]),t[e(513)]=[],t[e(373)].forEach(t=>{const s=e;t[s(392)]=s(513),t[s(315)]=0}),t[e(373)]=[])}#ut(t){const e=X;t&&(t[e(258)]=0,t[e(490)]="",t[e(347)]=0,this.#A(t.imported),t[e(513)]=[],t[e(373)][e(431)](t=>{const s=e;t[s(392)]=s(513),t.slot=0}),t[e(373)]=[],t.meta.forEach(t=>{const s=e;t[s(318)]="",t.name=void 0,t.disable=void 0,t.kind=void 0,t[s(315)]=void 0,t[s(311)]=void 0,t.tokens=void 0,t.tx=void 0}),t[e(386)]=[],t[e(318)]=void 0,t[e(475)]=void 0,t.chains=[],t[e(348)]=void 0)}#yt(t){const e=X;t&&(t[e(318)]="",t[e(460)]=void 0,t.disable=void 0,t[e(392)]=void 0,t[e(315)]=void 0,t[e(311)]=void 0,t[e(498)]=void 0,t.tx=void 0)}#wt(t){const e=X;t&&(t[e(284)]="",t[e(426)].iv="",t[e(235)][e(482)]="",t.binding=void 0)}#ft(t,e=6){const s=X;if(t&&!(e<0)&&typeof t===s(429)){if(Array[s(440)](t))return t[s(431)](t=>this.#ft(t,e-1)),void(t[s(316)]=0);for(const i in t)Object[s(430)][s(424)][s(335)](t,i)&&(this.#ft(t[i],e-1),t[i]=void 0,delete t[i])}}#mt(t){const e=this.#vt(t);if(e)return{schema:1,account:e}}#gt(t){const e=X;t&&typeof t===e(429)&&!Array[e(440)](t)&&(t=t[e(318)]);const s="string"==typeof t?t[e(411)]():void 0;return s&&F.address(s)?s:void 0}#bt(){const t=X;return this.#I(t(318),t(269),t=>this.#gt(t))}#vt(t){const e=X;if(!t||"object"!=typeof t)return;if(typeof t?.[e(278)]===e(484)){if(1!==t.schema)return;t=t.account}const s=this.#gt(t?.[e(318)]),i=this.#Q(t?.[e(508)]);if(!t||"object"!=typeof t||!s||typeof i!==e(484))return;const r=t?.[e(392)]===e(347)||t?.kind===e(513)?t.kind:void 0,n=r?this.#Q(t?.slot):void 0;return{address:s,index:i,name:this.#At(t?.[e(460)])||"Account "+(i+1),disable:!!t?.[e(233)],kind:r,slot:n,path:this.#L(t?.[e(311)],l),balance:typeof t?.[e(242)]===e(484)&&Number.isFinite(t[e(242)])?t[e(242)]:void 0,tokens:this.#Et(t?.tokens),tx:this.#St(t?.tx)}}#It(t){const e=X;if(!t||""===t)return;const s=t[e(512)](),i=this.#C(e(405)),r=i?.get(s);if(void 0!==r){const t=this.#mt(this.#vt(r));if(t){this.#g(r,t)?this.#_?.[e(450)](s):this.#B(s,t,e(405));const i=this.#mt(this.#vt(this.#C("account")?.[e(476)](s)));if(i)return i[e(405)];const n=this.#mt(this.#vt(this.#_?.get(s)));if(n)return n[e(405)]}this.#U(s,e(405),!1);const i=this.#mt(this.#vt(this.#C("account")?.[e(476)](s)));if(i)return i[e(405)]}const n=this.#_?.get(s);if(typeof n===e(488))return;const o=this.#mt(this.#vt(n));if(!o)return void this.#_?.[e(450)](s);this.#B(s,o,"account");const a=this.#mt(this.#vt(this.#C("account")?.[e(476)](s)));if(a)return a[e(405)];const h=this.#mt(this.#vt(this.#_?.[e(476)](s)));return h?.[e(405)]}#kt(t){const e=X;if(!t||""===t)return;const s=t.toLowerCase(),i=this.#mt(this.#vt(this.#C("account")?.[e(501)]?.(s)));if(i)return i[e(405)];const r=this.#mt(this.#vt(this.#_?.[e(501)]?.(s)));return r?.[e(405)]}#Dt(t){const e=X;if(!t?.address)return;const s=this.#It(t[e(318)]),i=this.#mt(t);return i?(this.#B(i[e(405)][e(318)].toLowerCase(),i,"account"),this.#It(i.account[e(318)])||s):s}#Ct(t,e){const s=X,i=!1!==e?.[s(252)],r=this.#K(t?.key,64);if(!r)return;if(typeof t?.[s(278)]===s(484)&&1!==t.schema)return;if(typeof t?.[s(490)]===s(461)&&Array[s(440)](t?.[s(513)])&&Array[s(440)](t?.[s(373)])){const e=this.#K(t.master,128);if(!e)return;const n=this.#Z(t[s(373)]),o=[];for(let e=0;e<t[s(513)][s(316)];e+=1){let r="string"==typeof t[s(513)][e]?t[s(513)][e]:void 0;const n=o.length<u?this.#N(r):void 0;r="",i&&"string"==typeof t[s(513)][e]&&(t[s(513)][e]=""),n&&o.push(n)}const a=Math[s(500)](this.#H(t?.[s(347)])||0,...n.filter(t=>t.kind===s(347))[s(355)](t=>t[s(315)]+1),0);return{key:r,master:e,generated:a,imported:o,accounts:n[s(296)](t=>t[s(392)]===s(513)?t[s(315)]<o[s(316)]:t[s(315)]<a)}}const n=[];if(Array[s(440)](t?.[s(288)]))for(let e=0;e<t[s(288)][s(316)];e+=1){let r=typeof t.keys[e]===s(461)?t[s(288)][e]:void 0;const o=n[s(316)]<u?this.#N(r):void 0;r="",i&&typeof t[s(288)][e]===s(461)&&(t.keys[e]=""),o&&n[s(219)](o)}return{key:r,master:this.#j(64),generated:0,imported:n,accounts:n.map((t,e)=>({kind:s(513),slot:e}))}}#xt(t,e,s){const i=X;if(!t||!e||!s)return;const r=this.#F(t.imported),n=t[i(373)];return this.#e=t[i(455)],this.#pt(e,s,!0),this.#r=t[i(490)],this.#n=t.generated,this.#o=r,this.#a=n,t[i(455)]="",t[i(490)]="",t[i(347)]=0,this.#A(t.imported),t[i(513)]=[],t[i(373)]=[],t}async#_t(t,e=this.#s,s=this.#i){const i=X;if(!e||!s)throw new Error("Wallet is locked.");let r,n,o,a,h=typeof t===i(461)?t:t&&typeof t===i(429)&&(typeof t?.schema!==i(484)||1===t[i(278)])&&"string"==typeof t?.[i(455)]&&"string"==typeof t?.[i(490)]&&Array[i(440)](t?.[i(513)])&&Array.isArray(t?.[i(373)])?JSON[i(408)]({schema:1,key:t[i(455)],master:t[i(490)],generated:this.#H(t?.[i(347)])||0,imported:t[i(513)],accounts:t[i(373)]}):void 0;if(!h)throw new Error("Wallet is locked.");try{a=this.#V(),n=await P(this.#$(),a?.[i(365)]?[a[i(365)]]:[i(246)]).catch(()=>{});const t=this.#Y()||!!a?.[i(365)];if("platform"===a?.[i(365)]&&n?.[i(392)]!==i(428))throw new Error("Secure platform binding is required.");if(t&&!n)throw new Error(i(223));o=n?.[i(284)]?new Uint8Array(n.data):void 0,r=await R(h,e,s,n?{binding:n[i(284)],bindingKind:n[i(392)]}:void 0)}finally{this.#b(n?.[i(284)]),n=void 0,this.#wt(a),h=""}let c="";try{const t=this.#J(r);if(!t)throw new Error(i(454));if(c=await W(this.#$(),t,{binding:o,kinds:r[i(365)]?[r.binding]:void 0}).catch(()=>{})||"",r[i(365)]&&!c)throw new Error(i(410));this.#k(i(303),r,i(303)),c?this.#k("vault.attestation",c,i(303)):this.#D(i(422),"vault"),this.#h[i(218)]()}finally{c="",this.#b(o),o=void 0,this.#wt(r)}}async#Bt(t=this.#s,e=this.#i){const s=X;if(!this.#e||!this.#r)throw new Error("Wallet is locked.");const i=this.#P();let r="";try{r=JSON[s(408)]({schema:1,key:this.#e,master:this.#r,generated:this.#n,imported:i,accounts:this.#a})}finally{this.#A(i)}if(!r)throw new Error(s(249));try{await this.#_t(r,t,e)}finally{r=""}}#Ut(t,s=this.#r){const i=X;if(!s)throw new Error(i(286));const r=Buffer[i(266)](s,i(436));let n;try{return n=e[i(369)][i(340)](r).derivePath(i(439)+t)[i(358)]()[i(509)](),Buffer[i(266)](n)}finally{n?.[i(472)](0),r[i(472)](0)}}#Kt(t){const s=X;if(typeof t===s(461)){const e=this.#Nt(t)?.index;if(typeof e!==s(484))throw new Error("Not found account info");t=e}if(typeof t!==s(484))throw new Error(s(308));return this.#m(()=>{const i=s,r=this.#a[t];if(!r)throw new Error("Not found account info");if(r[i(392)]===i(347)){if(!this.#r)throw new Error("Wallet is not setup yet.");const s=i(439)+r[i(315)],n=Buffer.from(this.#r,i(436));try{const o=e[i(369)].fromMasterSeed(n)[i(342)](s)[i(358)]();return{index:t,...r,path:s,address:o[i(211)]()}}finally{n[i(472)](0)}}const n=this.#o[r[i(315)]];if(!n)throw new Error(i(308));const o=this.#R(n);return{index:t,...r,address:o}})}#dt(t){const e=X,s=this.#Kt(t),i=this.#kt(s[e(318)])||{};return{current:i,next:{...i,address:s[e(318)],index:t,name:i?.[e(460)]||e(444)+(t+1),disable:!!i?.disable,kind:s[e(392)],slot:s[e(315)],path:s[e(311)]}}}#Tt(t){const e=X,{current:s,next:i}=this.#dt(t);return this.#g(s,i)?s?.[e(318)]?s:void 0:this.#Dt(i)||this.#It(i[e(318)])}#Ft(){const t=X;return this.#m(()=>this.#a[t(355)]((t,e)=>this.#dt(e).next))}#Pt(t){const e=X;return this.#gt(t)?.[e(512)]()}#Rt(t,e){const s=X,i=this.#Pt(e);if(i&&Array.isArray(t))for(const e of t)if(this.#Pt(e?.[s(318)])===i)return e}#Nt(t,e){const s=X;if(this.isLocked)return;const i=void 0===e?this.#Ft():e;if(!i.length)return;if(typeof t===s(484))return i[t];if(t&&"object"==typeof t&&!Array[s(440)](t))return this.#Rt(i,t?.[s(318)])||(typeof t?.[s(508)]===s(484)?i[t[s(508)]]:void 0);const r=this.#Pt(typeof t===s(461)?t:this.#bt());return r?this.#Rt(i,r):void 0}#Wt(t,e){const s=X,i=this.#Pt(e);if(!i||!Array[s(440)](t))return!1;for(const e of t){if((typeof e===s(461)?this.#Pt(e):this.#Pt(e?.address))===i)return!0}return!1}#l(t,e){const s=X,i=this.#jt(e);if(typeof i===s(484)&&Array[s(440)](t))for(const e of t)if(T(e?.[s(475)])===i)return e}#Lt(t,e){const s=X,i=this.#jt(e);return Array[s(440)](t)?typeof i!==s(484)?[...t]:t[s(296)](t=>T(t?.[s(475)])!==i):[]}#Mt(t,e,s=X(467)){const i=X;return this.#qt([...Array.isArray(e)?e:[],...Array[i(440)](t)?t:[]],s)}#Ot(t,e){const s=X;if(!t)return e;if(!e)return t;const i=t?.nativeCurrency||e?.[s(483)]?{...t?.[s(483)]||{},...e?.nativeCurrency||{}}:void 0;return{base:typeof e?.base!==s(488)?e[s(499)]:t[s(499)],type:typeof e?.[s(273)]!==s(488)?e[s(273)]:t[s(273)],logo:typeof e?.[s(302)]!==s(488)?e.logo:t[s(302)],chainId:void 0!==e?.[s(475)]?e[s(475)]:t.chainId,chainName:typeof e?.[s(236)]!==s(488)?e[s(236)]:t[s(236)],nativeCurrency:i,rpcUrls:this.#Mt(t?.[s(339)],e?.[s(339)],"rpc"),blockExplorerUrls:this.#Mt(t?.[s(378)],e?.blockExplorerUrls,s(459)),iconUrls:this.#Mt(t?.[s(432)],e?.[s(432)],s(241))}}#zt(t){const e=X;if(!Array.isArray(t)||!t[e(316)])return;let s;for(const i of t)if(!s&&i&&(s=i),1===T(i?.[e(475)]))return i;return s}#Vt(t){const e=X;if(!t||""===t)return;const s=(""+t).trim();if(""!==s){try{if(s[e(383)]("://")){const t=new URL(s),i=t[e(367)][e(512)]();if(i!==e(452)&&"https:"!==i)return;return t.origin[e(512)]()}}catch{return}try{return new URL(e(477)+s).host[e(512)]()}catch{return}}}#Gt(t){const e=X,s=this.#Vt(t);if(!s)return[];const i=new Set([s]);try{const t=s.includes(e(240))?new URL(s):new URL("https://"+s);i[e(395)](t.origin[e(512)]()),i[e(395)](t[e(214)][e(512)]())}catch{}return[...i]}#$t(t,e){const s=X,i=this.#Gt(t),r=this.#Gt(e);if(!i[s(316)]||!r.length)return!1;const n=new Set(r);return i[s(385)](t=>n[s(341)](t))}#Jt(t=[],e=[]){const s=[],i=new Set;return[...t,...e].forEach(t=>{const e=Z;if(s[e(316)]>=y)return;const r="string"==typeof t?t[e(411)]():void 0,n=r&&F[e(318)](r)?r:void 0,o=n?.toLowerCase();n&&o&&!i.has(o)&&(i[e(395)](o),s[e(219)](n))}),s}#Yt(t=[],e){const s=X,i=this.#Pt(e);return i?this.#Jt(t)[s(296)](t=>t[s(512)]()!==i):this.#Jt(t)}#Ht(t=[],e){const s=X,i=typeof e===s(461)?e[s(411)]():void 0,r=i&&F[s(318)](i)?i:void 0;return r?[r,...this.#Yt(t,r)]:this.#Jt(t)}#Qt(t=[],e){const s=X;return t[s(296)](t=>!this.#$t(t?.[s(221)],e))}#Xt(t=[],e){const s=X;for(const i of t)if(this.#$t(i?.[s(221)],e))return i}#Zt(t,e){const s=X,i=this.#Jt(t?.accounts||[]);return i[s(316)]?this.#Wt(i,e)?this.#Ht(i,e):i:[]}#At(t){return this.#L(t,f)}#te(t){const e=X;if(typeof t!==e(461))return;const s=t[e(411)]();return s[e(512)]().startsWith(e(352))&&s[e(316)]<=w?s:void 0}#ee(t){const e=X;if(!Array[e(440)](t))return[];const s=[],i=new Set;return t[e(431)](t=>{const r=e;if(s[r(316)]>=m)return;const n=this.#se(typeof t===r(461)?t:void 0);n&&!i.has(n)&&(i[r(395)](n),s.push(n))}),s}#st(t=[]){const e=X,s=[],i=new Map;return t[e(431)](t=>{const r=e,n=this.#Vt(t?.url);if(!n)return;const o={url:n,name:this.#At(t?.[r(460)]),logo:this.#te(t?.logo),accounts:this.#Jt(t?.[r(373)])},a=this.#Gt(n);let h;if(a[r(385)](t=>{const e=i[r(476)](t);return"number"==typeof e&&(h=e,!0)}),typeof h===r(488)){if(s[r(316)]>=v)return;h=s.length,s[r(219)](o)}else{const t=s[h];t.accounts=this.#Jt(t?.[r(373)],o?.[r(373)]),!t?.name&&o?.[r(460)]&&(t[r(460)]=o[r(460)]),!t?.[r(302)]&&o?.[r(302)]&&(t[r(302)]=o.logo),!t?.url?.[r(383)](r(240))&&n[r(383)](r(240))&&(t[r(221)]=n)}this.#Gt(s[h].url).forEach(t=>i[r(216)](t,h)),a[r(431)](t=>i[r(216)](t,h))}),s}#ie(t=[]){const e=X,s=this.#st(t),i=this.isLocked?void 0:new Set(this.#Ft()[e(355)](t=>t[e(318)][e(512)]()));return i?.size?s[e(355)](t=>({...t,accounts:(t?.accounts||[]).filter(t=>i[e(341)](t[e(512)]()))})):s}#nt(t){const e=X;return Array.isArray(t)?this.#st(t):t&&typeof t===e(429)?typeof t?.[e(278)]===e(484)&&1!==t[e(278)]?[]:Array[e(440)](t?.[e(389)])?this.#st(t[e(389)]):[]:[]}#rt(t=[]){const e=X;return this.#st(t).map(t=>({url:t[e(221)],accounts:[...t?.[e(373)]||[]]}))}#re(t=[]){const e=X;return this.#st(t)[e(355)](t=>({url:t[e(221)],name:this.#At(t?.name),logo:this.#te(t?.logo)}))[e(296)](t=>!(!t?.[e(221)]||!t?.[e(460)]&&!t?.[e(302)]))}#ne(t){const e=X;if(typeof t!==e(461))return;const s=t[e(411)]()[e(512)]();return/^[a-z0-9._-]{1,32}$/[e(261)](s)?s:void 0}#oe(t){const e=X,s=typeof t?.[e(318)]===e(461)?t[e(318)][e(411)]():void 0;if(s&&F[e(318)](s))return{name:this.#At(t?.[e(460)]),address:s}}#ae(t,e=X(467)){const s=X;if(typeof t!==s(461)||""===t.trim())return;const i=t[s(411)]();if(e===s(241)&&i[s(512)]().startsWith("data:image/"))return i.length<=w?i:void 0;if(!(i[s(316)]>g))try{const t=new URL(i)[s(367)][s(512)]();return"icon"===e?"http:"===t||t===s(254)?i:void 0:[s(452),s(254),s(466),"wss:"][s(383)](t)?i:void 0}catch{return}}#qt(t,e=X(467)){const s=X;if(!Array[s(440)](t)||!t[s(316)])return;const i=[],r=new Set;return t[s(431)](t=>{const n=s;if(i[n(316)]>=b||typeof t!==n(461)||""===t[n(411)]())return;const o=this.#ae(t,e);o&&!r.has(o)&&(r[n(395)](o),i[n(219)](o))}),i[s(316)]?i:void 0}#se(t){const e=X;if(typeof t!==e(461))return;const s=t[e(411)]().toLowerCase();return F.address(s)?s:void 0}#he(t){return this.#L(t,A)}#ce(t){const e=X;if(!Array[e(440)](t))return[];const s=[];return t.forEach(t=>{const i=e;if(s[i(316)]>=E||!t||typeof t!==i(429))return;const r={};let n=0;for(const e in t){if(!Object[i(430)][i(424)][i(335)](t,e)||n>=E)continue;const s=this.#se(e);if(!s)continue;const o=[],a=new Set,h=t[e];Array[i(440)](h)&&h.forEach(t=>{const e=i;if(o[e(316)]>=S)return;const s=this.#he(typeof t===e(461)?t:void 0);s&&!a[e(341)](s)&&(a[e(395)](s),o.push(s))}),r[s]=o,n+=1}n&&s[i(219)](r)}),s}#de(t,e){const s=X,i=[];return this.#ce(t)[s(431)](t=>{const r=s;if(!(i[r(316)]>=E))for(const s in t)if(Object.prototype[r(424)][r(335)](t,s)&&(!e||s!==e)){i.push({[s]:[...t[s]]});break}}),i}#ue(t,e){const s=X;if(!e)return[];const i=[],r=new Set;return this.#ce(t)[s(431)](t=>{const n=s,o=t?.[e];Array[n(440)](o)&&o[n(431)](t=>{const e=n;i[e(316)]>=S||r.has(t)||(r.add(t),i[e(219)](t))})}),i}#Et(t){const e=X;if(!t||"object"!=typeof t)return;const s=t?.fungibles&&typeof t[e(229)]===e(429)?(()=>{const s=e,i={};let r=0;for(const e in t[s(229)]){if(!Object[s(430)][s(424)][s(335)](t.fungibles,e))continue;const n=this.#jt(e);typeof n===s(484)&&(i[n]=this.#ee(t[s(229)][e]),r+=1)}return r?i:void 0})():void 0,i=t?.[e(306)]&&typeof t[e(306)]===e(429)?(()=>{const s=e,i={};let r=0;for(const e in t.nonFungibles){if(!Object[s(430)][s(424)][s(335)](t.nonFungibles,e))continue;const n=this.#jt(e);typeof n===s(484)&&(i[n]=this.#ce(t[s(306)][e]),r+=1)}return r?i:void 0})():void 0,r=t?.[e(437)]&&typeof t[e(437)]===e(429)?(()=>{const s=e,i={};let r=0;for(const e in t[s(437)]){if(!Object[s(430)].hasOwnProperty[s(335)](t[s(437)],e))continue;const n=this.#jt(e);"number"==typeof n&&(i[n]=this.#ee(t.multiTokens[e]),r+=1)}return r?i:void 0})():void 0;return s||i||r?{fungibles:s,nonFungibles:i,multiTokens:r}:void 0}#at(t){const e=X;if(t&&typeof t===e(429)&&!Array.isArray(t)){if(typeof t?.schema===e(484)&&1!==t[e(278)])return[];t=t.chains}return Array[e(440)](t)?t.map(t=>{const s=e,i=this.#jt(t?.[s(475)]),r=this.#qt(t?.rpcUrls,s(467)),n=typeof t?.nativeCurrency?.decimals===s(484)&&Number.isFinite(t[s(483)][s(328)])?Math.trunc(t[s(483)][s(328)]):void 0,o=t?.[s(483)]&&"object"==typeof t[s(483)]&&this.#L(t[s(483)]?.[s(460)],f)&&this.#L(t[s(483)]?.[s(442)],I)&&typeof n===s(484)&&n>=0?{name:this.#L(t[s(483)][s(460)],f),symbol:this.#L(t[s(483)][s(442)],I),decimals:n}:void 0;if(i&&r&&o)return{base:t?.[s(499)]===s(447)||t?.[s(499)]===s(457)?t.base:void 0,type:"mainnet"===t?.[s(273)]||t?.type===s(496)||"testnet"===t?.type||t?.type===s(327)?t[s(273)]:void 0,logo:this.#ae(t?.logo,"icon"),chainId:i,chainName:this.#L(t?.[s(236)],f),nativeCurrency:o,rpcUrls:r,blockExplorerUrls:this.#qt(t?.blockExplorerUrls,s(459)),iconUrls:this.#qt(t?.[s(432)],s(241))}}).filter(t=>!!t)[e(495)](0,k):[]}#jt(t){const e=X;if(t&&"object"==typeof t&&!Array[e(440)](t)&&(t=t.chainId),typeof t===e(461)||typeof t===e(484))return T(t)}#fe(t){const e=X;if(typeof t!==e(461))return;const s=t[e(411)]()[e(512)]();return/^0x[0-9a-f]{64}$/i[e(261)](s)?s:void 0}#pe(t){const e=X;if("number"==typeof t)return Number[e(406)](t)&&t>=0?t:void 0;if(typeof t!==e(461))return;const s=t[e(411)]();if(""===s||s.length>D)return;if(/^[0-9]+$/.test(s))return s;const i=s[e(512)]();return/^0x[0-9a-f]+$/i[e(261)](i)?i:void 0}#y(){const t=X;return this.#I(t(475),t(269),t=>this.#jt(t))}#le(){const t=X,e=this.#p(),s=this.#y();if(s&&this.#l(e,s))return s;const i=this.#zt(e);return i?.[t(475)]?T(i[t(475)]):1}#ye(t){const e=X;if(!t||typeof t!==e(429))return;const s=this.#fe(t?.[e(423)]);return s&&["pending",e(215),e(517)].includes(t?.status)?{hash:s,status:t[e(300)],chainId:this.#jt(t?.chainId),time:this.#pe(t?.[e(372)]),to:this.#gt(t?.to),from:this.#gt(t?.from),category:this.#At(t?.[e(334)]),isContract:typeof t?.[e(281)]===e(267)?t.isContract:void 0,blockNumber:this.#pe(t?.[e(399)]),gasUsed:this.#pe(t?.[e(394)]),cumulativeGasUsed:this.#pe(t?.[e(463)]),effectiveGasPrice:this.#pe(t?.effectiveGasPrice),contractAddress:this.#gt(t?.[e(353)]),no:Number[e(416)](t?.no)&&t.no>=0?t.no:void 0}:void 0}#we(t,e,s){const i=X,r=this.#ye(e);if(!r)return this.#me(t);const n=r.hash[i(512)](),o=s?.[i(255)]?[r]:[],a=new Set(s?.prepend?[n]:[]);let h=!!s?.[i(255)];return Array.isArray(t)&&t[i(431)](t=>{const e=i,s=this.#ye(t),c=s?.hash?.toLowerCase();s&&c&&(c!==n?a[e(341)](c)||(a[e(395)](c),o.push(s)):!h&&(o[e(219)]({...s,...r}),h=!0,a[e(395)](c)))}),h||o[i(219)](r),o[i(495)](0,C)}#St(t){const e=X;if(!t||typeof t!==e(429))return;const s={};let i=0;for(const r in t){if(!Object[e(430)][e(424)][e(335)](t,r))continue;const n=this.#jt(r);if(typeof n!==e(484))continue;const o=[],a=new Set,h=t[r];Array[e(440)](h)&&h[e(431)](t=>{const s=e;if(o[s(316)]>=C)return;const i=this.#ye(t),r=i?.[s(423)]?.[s(512)]();i&&r&&!a[s(341)](r)&&(a.add(r),o.push(i))}),s[n]=o,i+=1}return i?s:void 0}#ve(t){const e=X;if(t&&typeof t===e(429)&&!Array[e(440)](t)){if(typeof t?.schema===e(484)&&1!==t[e(278)])return;t=t[e(348)]}if(!t||typeof t!==e(429))return;const s={};let i=0;for(const r in t){if(!Object[e(430)][e(424)].call(t,r)||i>=x)continue;const n=this.#ne(r);if(!n)continue;const o=[],a=new Set,h=t[r];Array[e(440)](h)&&h[e(431)](t=>{const s=e;if(o.length>=_)return;const i=this.#oe(t),r=i?.[s(318)]?.[s(512)]();i&&r&&!a[s(341)](r)&&(a[s(395)](r),o[s(219)](i))}),s[n]=o,i+=1}return i?s:void 0}#me(t){const e=X;return Array[e(440)](t)?t.map(t=>this.#ye(t))[e(296)](t=>!!t):[]}#ge(t){return this.#Et({fungibles:t})?.fungibles}#be(t){const e=X;return this.#Et({nonFungibles:t})?.[e(306)]}#Ae(t){const e=X,s=this.#K(t?.master,128);if(!t||typeof t!==e(429)||1!==t?.[e(278)]||!s)return;const i=this.#Z(t?.[e(373)]),r=[];if(Array[e(440)](t?.[e(513)]))for(let s=0;s<t[e(513)][e(316)];s+=1){let i="string"==typeof t[e(513)][s]?t[e(513)][s]:void 0;const n=r[e(316)]<u?this.#N(i):void 0;i="",typeof t[e(513)][s]===e(461)&&(t[e(513)][s]=""),n&&r.push(n)}const n=Math[e(500)](this.#H(t?.[e(347)])||0,...i.filter(t=>t[e(392)]===e(347)).map(t=>t[e(315)]+1),0),o=[];if(Array[e(440)](t?.[e(386)])){const s=new Set;t.meta[e(431)](t=>{const i=e;if(o.length>=u)return;if(!t||typeof t!==i(429)||!F[i(318)](t?.[i(318)]))return;const r=t?.[i(392)]===i(347)||"imported"===t?.[i(392)]?t[i(392)]:void 0,n=this.#Q(t?.[i(315)]),a=r&&"number"==typeof n,h={address:t[i(318)].trim(),name:this.#At(t?.[i(460)]),disable:"boolean"==typeof t?.[i(233)]?t[i(233)]:void 0,kind:a?r:void 0,slot:a?n:void 0,path:this.#L(t?.[i(311)],l),tokens:this.#Et(t?.[i(498)]),tx:this.#St(t?.tx)},c=h.address.toLowerCase();s.has(c)||(s.add(c),o[i(219)](h))})}const a=this.#at(t?.[e(379)]),h=this.#ve(t?.[e(348)]),c=this.#gt(t?.[e(318)]),d=this.#jt(t?.[e(475)]);return{schema:1,createdAt:typeof t?.[e(258)]===e(484)&&Number[e(403)](t[e(258)])?t[e(258)]:Date[e(375)](),master:s,generated:n,imported:r,accounts:i.filter(t=>t[e(392)]===e(513)?t[e(315)]<r.length:t[e(315)]<n),meta:o,address:c,chainId:d,chains:a,contact:h}}#w(){const t=X,e=this.#I(t(389),t(389),t=>{const e=this.#it(t);return e?this.#nt(e):void 0})||[];if(this[t(270)])return this.#rt(e);const s=this.#x(t(389),t(389),e=>{const s=t,i=this.#re(this.#nt(e));return i[s(316)]?i:void 0})||[];return this.#ie([...e,...s])}#Ee(t=[],e){const s=X,i=this.#w(),r=this.#nt(t);if(this[s(270)]){this.#g(i,r)||this.#k("apps",this.#et(r),s(389));const t=this.#w();return e&&!this.#g(i,t)&&this[s(301)](s(329)),t}const n=this.#ie(r),o=this.#rt(n),a=this.#re(n),h=this.#I(s(389),"apps",t=>{const e=this.#it(t);return e?e.apps:void 0})||[],c=this.#x("apps",s(389),t=>{const e=s,i=this.#re(this.#nt(t));return i[e(316)]?i:void 0})||[];this.#g(h,o)?typeof this.#E()?.[s(501)]?.(s(389))!==s(488)&&this.#E()?.[s(450)](s(389)):this.#k("apps",this.#et(o),s(389)),a.length?this.#g(c,a)?typeof this.#_?.[s(501)]?.(s(389))!==s(488)&&this.#_?.[s(450)](s(389)):this.#B(s(389),this.#et(a),"apps"):void 0===this.#C(s(389))?.[s(501)]?.(s(389))&&typeof this.#_?.[s(501)]?.(s(389))===s(488)||this.#U("apps","apps");const d=this.#w();return e&&!this.#g(i,d)&&this[s(301)](s(329)),d}#p(){return this.#I("chains","chains",t=>{const e=Z;if(Array[e(440)](t)){const s=this.#at(t);if(t[e(316)]&&!s[e(316)])return;return s}if(!t||typeof t!==e(429))return;if("number"==typeof t?.[e(278)]&&1!==t[e(278)])return;if(!Array.isArray(t?.[e(379)]))return;const s=this.#at(t);return!t[e(379)][e(316)]||s.length?s:void 0})||[]}#ct(){const t=X;return this[t(270)]?{}:this.#x("contact",t(348),t=>this.#ve(t)||void 0)||{}}async#Se(t,e){const s=X,i=!1!==e?.persistCanonical,r=!!e?.includeKdf,n=this.#V(),o=this.#G(),a=await this.#M(t);if(t="",n){const t=n.binding?[n[s(365)]]:void 0,e=n.binding?await j(this.#$(),t)[s(486)](()=>[]):[];if(n[s(365)]&&!e[s(316)])throw this.#wt(n),new Error(n[s(365)]===s(428)?s(521):s(474));const h=this.#J(n);if(h&&o){if(!await L(this.#$(),h,o,t,e)[s(486)](()=>!1))throw e[s(431)](t=>this.#b(t)),e[s(316)]=0,this.#wt(n),new Error(s(441))}for(const t of a){const o=i||r?{...n.kdf}:void 0,{data:a}=await M(t,n[s(235)][s(482)],{iterations:n[s(235)][s(381)],parallelism:n.kdf[s(250)],memorySize:n[s(235)].memorySize,hashLength:n[s(235)][s(304)]})[s(486)](()=>({data:void 0}));let h;const c=e[s(316)]?e[s(355)](t=>t[s(495)]()):[void 0];try{for(const t of c)if(h=await q(n,a,t).catch(()=>{}),h)break}finally{c.forEach(t=>this.#b(t)),c[s(316)]=0}if(!h){this.#b(a);continue}let d=O(h);h="";const u=this.#Ct(d,{consumeSource:!i});if(!u){this.#ft(d),d=void 0,this.#b(a);continue}const f=!!i&&this.#tt(d,u);this.#ft(d),d=void 0;const p=n[s(365)];return i&&!f&&await this.#_t(u,a,o),e[s(431)](t=>this.#b(t)),e[s(316)]=0,this.#wt(n),{vault:u,credential:a,kdf:r?o:void 0,binding:p}}e[s(431)](t=>this.#b(t)),e[s(316)]=0,this.#wt(n)}}#Ie(t){const e=X;if(typeof t===e(461)){const s=this.#Nt(t)?.[e(508)];if("number"!=typeof s)throw new Error(e(308));t=s}if(typeof t!==e(484))throw new Error(e(308));return this.#m(()=>{const s=e,i=this.#a[t];if(!i)throw new Error(s(308));if(i[s(392)]===s(347))return this.#Ut(i[s(315)]);const r=this.#o[i[s(315)]];if(!r)throw new Error(s(308));return Buffer.from(r)})}async[X(509)](t){const e=X;if(!t)throw new Error("The account data wasn't provided.");if(this[e(362)].remain)throw new Error("Locked out. Try again after "+this[e(362)][e(480)]+e(226));let r=t?.code;const n=t?.[e(508)];let o=t?.address;if(!r||typeof n===e(488)||!o)throw new Error(e(244));const a=typeof n===e(461)?/^[0-9]+$/[e(261)](n.trim())?parseInt(n[e(411)](),10):Number[e(363)]:n;if(typeof a!==e(484)||!Number[e(416)](a)||a<0)throw new Error(e(413));const h=this.#gt(o);if(o="",!h)throw new Error(e(464));let c=await this.#Se(r,{persistCanonical:!1});r="";let d=c?.vault,u=c?.credential;c=void 0;try{if(!d?.[e(455)])throw new Error(e(514));const t=d[e(373)][a];if(!t)throw new Error(e(308));const r=this.#Pt(h);if(t[e(392)]===e(347)){const n=this.#Ut(t[e(315)],d[e(490)]);let o,a="";try{if(o=i(n),a=s(o),r&&this.#Pt(a)!==r)return;return s(n)}finally{a="",d[e(490)]="",o?.[e(472)](0),n[e(472)](0)}}let n=d.imported[t[e(315)]];if(!n)throw new Error("Not found account info");let o,c="";try{if(r&&(o=this.#T(n),c=this.#R(o),this.#Pt(c)!==r))return;return n}finally{c="",n="",d[e(513)][t.slot]="",o?.[e(472)](0)}this.#O("Given account data is something wrong.")}finally{this.#b(u),u=void 0,this.#lt(d),d=void 0}}get#v(){return this.#e}get#_(){return this.#m(t=>this.#E(t))}get#u(){const t=X;return typeof window!==t(488)?window[t(470)]?.[t(319)]:void 0}get#d(){return!!this.#u?.initDataUnsafe?.user?.id}#ke(t,e=this.#p()){const s=X;return typeof t===s(488)?this.#l(e,this.#le()):t&&typeof t===s(429)&&!Array[s(440)](t)?this.#l(e,t?.[s(475)])||this.#at([t])[0]:this.#l(e,t)}async#De(t,e,s){const i=X,n=this.#ke(s)?.[i(339)]?.[0];if(!n)throw new Error(i(void 0===s?357:210));return await r(n,{method:t,params:e})}get[X(471)](){return!!this.#V()}[X(504)](){const t=X;return this.#h[t(346)]()}[X(338)](t){const e=X;return!!t&&(this.#h[e(325)](t),!0)}get[X(270)](){return!this.#v}get[X(318)](){const t=X,e=this.#bt();if(this[t(270)])return e;const s=this.#Ft();return this.#Nt(e,s)?.[t(318)]||s?.[0]?.[t(318)]}account(t){if(this[X(270)])return;const e=this.#Ft();return e.length?this.#Nt(t,e)||e[0]:void 0}[X(373)](t){const e=X;if(this[e(270)])return[];if(t&&""!==t){const s=this.#Xt(this.#w(),t);return s?this.#Zt(s,this[e(318)]):[]}return this.#Ft()}[X(419)](t,e){const s=X;if(e=void 0!==e?this.#gt(e):this[s(318)],!t||""===t||!e||""===e)return!1;const i=this.#Xt(this.#w(),t);return!!i&&this.#Wt(this.#Zt(i,e),e)}[X(524)](t,e){const s=X,i=this.#Vt("string"==typeof t?t:t?.url)||"";if(e=void 0!==e?this.#gt(e):this.address,!i)throw new Error(s(259));if(typeof e===s(488)||""===e||!this.#Nt(e))throw new Error(s(321));if(!this.allowance(i,e))throw new Error(s(388));return{url:i,address:e,account:this.#Nt(e)}}#Ce(t,e){const s=X;typeof t!==s(488)&&null!==t&&this[s(524)](t,e)}get[X(475)](){const t=X,e=this.#ke(void 0,this.#p());return void 0!==e?.[t(475)]?z(e[t(475)]):void 0}get[X(420)](){const t=this.#p(),e=this.#le();return this.#l(t,e)}get[X(379)](){return this.#p()}get[X(389)](){return this.#w()}get[X(348)](){return this.#ct()}async[X(336)](t){const e=X;if(this[e(471)])throw new Error(e(503));let s;try{this.#e=this.#j(32),this.#r=this.#j(64),this.#n=0,this.#o=[],this.#a=[];const i=(await this.#M(t))[0];if(t="",!i)throw new Error(e(368));const r=await M(i);s=r[e(284)],this.#pt(s,r[e(235)],!0),s=void 0,await this.#Bt();const n=this.#p(),o=this.#zt(n);o?.[e(475)]&&this[e(326)](o.chainId)}catch(t){throw this.#f(),this.#E()?.clear(),t}finally{this.#b(s)}}#xe(){const t=X;this.#f(),this.#E()?.[t(280)]()}[X(309)](){const t=X;if(!this[t(362)].remain)throw new Error(t(295));this.#xe()}get[X(362)](){const t=X,e=this.#I(t(435),t(333),t=>Number.isInteger(t)&&t>=0?t:void 0),s=this.#I(t(449),t(333),e=>Number[t(416)](e)&&e>=0?e:void 0),i=Number[t(416)](e)&&e>=0?e:0,r=Number[t(416)](s)&&s>=0?s:0,n=Math[t(291)]((i-Date[t(375)]())/1e3);return{count:r,time:i,remain:n>0?n:0}}[X(333)](){const t=X;this.#k("address",this.#Nt()?.[t(318)],t(269)),this.#f(),this[t(301)](t(333))}async[X(446)](t){const e=X;let s=await this.#Se(t,{persistCanonical:!1});t="";let i=s?.vault,r=s?.[e(323)];s=void 0;try{return!!i?.key}finally{this.#b(r),r=void 0,this.#lt(i),i=void 0}}async[X(217)](t){const e=X;if(this[e(362)][e(480)])throw new Error(e(519)+this.locked[e(480)]+e(226));let s=await this.#Se(t,{persistCanonical:!1,includeKdf:!0});t="";let i=s?.vault,r=s?.[e(323)],n=s?.[e(235)];const o=s?.binding;s=void 0;let a,h=[];try{if(i?.[e(455)]){if(this.#xt(i,r,n),r=void 0,h=this.#Ft(),h[e(316)]){const t=(this.#bt()||h[0]?.address)?.[e(512)]();a=t?this.#Rt(h,t):void 0,a?this.changeAccount(a?.[e(508)]):this.#D(e(318),e(269))}else this.#D(e(318),e(269));this.#k("lock.time",0,e(333)),this.#k(e(449),0,e(333)),this.#q();const t=this.#Nt();return this[e(301)]("unlock",t||!0),!this.#G()&&P(this.#$(),o?[o]:["device"])[e(247)](t=>{const s=e;if(!t)return;const i=!!t?.[s(284)]?.[s(316)];return this.#b(t[s(284)]),i?this.#Bt():void 0}).catch(()=>{}),!0}this.#O("Invalid key entered.")}finally{h[e(316)]=0,a=void 0,this.#b(r),r=void 0,n=void 0,this.#lt(i),i=void 0}}[X(356)](t){return this.#m(()=>{const e=Z;if(!t||""===t)return!1;const s=this.#Ft();switch(t[e(316)]){case 42:const e=this.#gt(t);return!!e&&this.#Wt(s,e);case 64:case 66:let i=this.#N(t);if(t="",!i)return!1;const r=this.#W(i);return i="",this.#Wt(s,r);default:return!1}})}async[X(227)](){return await this.#m(async()=>{const t=Z,e=this.#n,s=this.#a[t(316)],i=this.#n,r={kind:t(347),slot:i},n=[...this.#a,r];try{this.#n=i+1,this.#a=n,await this.#Bt()}catch(i){for(this.#n=e;this.#a.length>s;){const e=this.#a[t(351)]();e&&(e.kind=t(513),e[t(315)]=0)}throw i}const o=n.length-1,a=this.#Tt(o),h=a?.[t(318)]?this.changeAccount(o):void 0,c=a?.[t(318)]||this.#Kt(o)?.[t(318)];return!!c&&!!this.#Nt(c)&&this.#Pt(h)===this.#Pt(c)})}import(t){return this.#m(async()=>{const e=Z,s=this.#o[e(316)],i=this.#a[e(316)];let r=this.#N(t);if(t="",!r)throw new Error("Invalid private key.");const n=this.#W(r),o=this.#Nt(n);if(o)return r="",this[e(493)](o[e(508)]),!1;const a=this.#o[e(316)],h={kind:e(513),slot:a},c=[...this.#a,h];try{const t=this.#T(r);if(r="",!t)throw new Error(e(260));this.#o=[...this.#o,t],this.#a=c,await this.#Bt()}catch(t){for(r="";this.#o[e(316)]>s;){const t=this.#o[e(351)]();this.#b(t)}for(;this.#a[e(316)]>i;){const t=this.#a[e(351)]();t&&(t[e(392)]=e(513),t[e(315)]=0)}throw t}const d=c.length-1,u=this.#Tt(d),f=u?.[e(318)]?this.changeAccount(d):void 0,p=u?.[e(318)]||this.#Kt(d)?.[e(318)];return!!p&&!!this.#Nt(p)&&this.#Pt(f)===this.#Pt(p)})}async[X(271)](t,e){const s=X;try{let i=await this.#Se(t,{persistCanonical:!1});t="";let r,n,o=i?.[s(303)],a=i?.[s(323)];if(i=void 0,!o?.[s(455)])throw new Error(s(506));try{let t;try{const i=(await this.#M(e))[0];if(!i)throw new Error(s(368));t=await M(i)}finally{e=""}r=t[s(284)],n=t[s(235)],t=void 0,await this.#_t(o,r,n),this.#pt(r,n,!0),n=void 0,r=void 0}finally{this.#b(a),a=void 0,this.#b(r),n=void 0,this.#lt(o),o=void 0}}finally{t="",e=""}}async[X(239)](t){return await this.#m(async()=>{const e=Z;let s;try{if(!t||""===t)throw new Error(e(468));let i="",r=this.#ht();if(!r)throw new Error(e(249));i=r[e(238)],r[e(238)]="";try{s=await V(i,t)}finally{i=""}try{return G({schema:1,kind:e(314),createdAt:r[e(258)],box:s,info:r.info})}finally{r&&(r.createdAt=0,r[e(462)][e(373)]=0,r[e(462)].generated=0,r.info.imported=0,r=void 0)}}finally{t="",this.#wt(s)}})}async recover(t,e,s){const i=X;try{if(this[i(471)])throw new Error(i(503));if(!t||""===t)throw new Error(i(368));if(!e||""===e)throw new Error(i(213));if(!s||""===s)throw new Error(i(468));let r=O(e);e="";const n=r&&typeof r===i(429)&&1===r?.[i(278)]&&r?.[i(392)]===i(314)?this.#z(r?.[i(371)]):this.#z(r);if(this.#ft(r),r=void 0,!n)throw new Error(i(324));let o;try{o=await $(n,s)}finally{s="",this.#wt(n)}if(!o)throw new Error(i(324));let a=O(o),h=this.#Ae(a);if(this.#ft(a),a=void 0,o="",!h)throw new Error("Backup bundle is invalid.");let c,d,u,f,p,l=[],y=[];try{let e;this.#e=this.#j(32),this.#r=h[i(490)],this.#n=h[i(347)],h[i(490)]="",h[i(347)]=0,this.#o=this.#F(h[i(513)]),this.#A(h.imported),this.#a=h.accounts,h[i(513)]=[],h[i(373)]=[],l=h[i(386)],h[i(386)]=[],y=h.chains??[],h.chains=[],d=h.contact,h[i(348)]=void 0,u=h[i(475)],h[i(475)]=void 0,f=h.address,h[i(318)]=void 0,this.#ut(h),h=void 0;try{const s=(await this.#M(t))[0];if(!s)throw new Error(i(368));e=await M(s)}finally{t=""}for(c=e.data,p=e[i(235)],e=void 0,this.#pt(c,p,!0),p=void 0,c=void 0,await this.#Bt();l.length;){const t=l[i(351)]();if(!t)continue;const e=this.#Nt(t[i(318)]);e?(this.#Dt({...e,name:t[i(460)]||e[i(460)],disable:"boolean"==typeof t[i(233)]?t[i(233)]:e[i(233)],tokens:this.#Et(t[i(498)])||e.tokens,tx:this.#St(t.tx)||e.tx}),this.#yt(t)):this.#yt(t)}y[i(316)]&&this.#k(i(379),this.#ot(y),i(379)),y[i(316)]=0;const s=d;d=void 0,s&&this.#B(i(348),{schema:1,contact:s},"contact"),this.#ft(s);const r=u;if(u=void 0,r)try{this[i(326)](r)}catch{}const n=f;f=void 0;const o=n&&this.#Nt(n)?n:void 0;return o?this.changeAccount(o):this.#a.length&&this[i(493)](0),this.#k(i(435),0,i(333)),this.#k(i(449),0,i(333)),this.#q(),this[i(301)](i(217),this.#Nt()||!0),!0}catch(t){throw this.#f(),this.#E()?.[i(280)](),t}finally{for(this.#b(c);l.length;)this.#yt(l[i(351)]());y[i(316)]=0,this.#ft(d),d=void 0,u=void 0,f=void 0,p=void 0,this.#ut(h)}}finally{t="",e="",s=""}}[X(493)](t){const e=X;if(typeof t===e(488))throw new Error(e(413));const s=this.#Ft(),i=typeof t===e(461)?/^[0-9]+$/[e(261)](t[e(411)]())?parseInt(t[e(411)](),10):this.#Nt(t,s)?.index:t;if(typeof i!==e(484)||!Number.isInteger(i)||i<0)throw new Error(e(413));const r=i;if(!s[e(316)])throw new Error(e(361));const n=s[r];if(!n)throw new Error(e(321));const o=n[e(318)].toLowerCase();if(this.#Pt(this.#bt())===o)return n[e(318)];this.#k(e(318),n[e(318)],e(269));return this.#Pt(this.#bt())===o?n.address:void 0}[X(326)](t){const e=X;if(void 0===t)throw new Error(e(222));if("number"!=typeof(t=this.#jt(t)))throw new Error(e(222));const s=T(t),i=this[e(475)]?T(this[e(475)]):void 0,r=this.#y(),n=this.#p();if(!n.length)throw new Error("There is no any chain registered.");if(this.#l(n,t)){if(i===s&&typeof r===e(484)&&T(r)===s)return s;this.#k(e(475),t,e(269));const n=this.#y();return typeof n===e(484)&&T(n)===s?s:void 0}throw new Error(e(489))}[X(382)](t){const e=X;if(!t||"object"!=typeof t)throw new Error(e(245));const s=this.#gt(t[e(318)]);if(!s)throw new Error(e(464));const i=this.#It(s);if(!i)throw new Error("Couldn't found a current account information.");const r=this.#Dt({...i,name:t?.name,disable:t?.[e(233)]});this.#g(i,r)||this[e(301)](e(264),r||!0)}[X(515)](t){const e=X;if(!t||"object"!=typeof t||Array[e(440)](t))throw new Error(e(234));const s=this.#at([t])[0];if(!s)throw new Error(e(234));return this.updateChains([s,...this.#Lt(this.#p(),s.chainId)])}updateChains(t=[]){const e=X;if(typ