@wormhole-foundation/wormhole-connect 2.1.0-beta.1-development → 2.1.0-beta.3-development
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/assets/{ccip-j5QHovIT.js → ccip-DfI9A4kL.js} +1 -1
- package/dist/assets/{evm-B5I5ieRn.js → evm-CYICYl2d.js} +3 -3
- package/dist/assets/index-26ve8f2n.js +531 -0
- package/dist/assets/index-NqsKKz5-.js +14 -0
- package/dist/assets/index.es-CephYdxr.js +47 -0
- package/dist/assets/{solana-c_vE3Ye5.js → solana-DXbD7wpn.js} +2 -2
- package/dist/assets/{solanaEmbed.esm-Bx0ME0S1.js → solanaEmbed.esm-CcwIvLto.js} +10 -10
- package/dist/main.js +106 -106
- package/dist/src/config/constants.d.ts.map +1 -1
- package/dist/src/config/mainnet/chains.d.ts.map +1 -1
- package/dist/src/config/mainnet/rpcs.d.ts.map +1 -1
- package/dist/src/config/mainnet/tokens.d.ts.map +1 -1
- package/dist/src/config/tokens.d.ts +1 -1
- package/dist/src/config/tokens.d.ts.map +1 -1
- package/dist/src/config/types.d.ts +1 -1
- package/dist/src/config/types.d.ts.map +1 -1
- package/dist/src/hooks/useTransactionHistoryMayan.d.ts.map +1 -1
- package/dist/src/hooks/useTransactionHistoryWHScan.d.ts.map +1 -1
- package/dist/src/icons/ChainIcons.d.ts.map +1 -1
- package/dist/src/icons/Chains/BERA.d.ts +4 -0
- package/dist/src/icons/Chains/BERA.d.ts.map +1 -0
- package/dist/src/icons/Tokens/BERA.d.ts +4 -0
- package/dist/src/icons/Tokens/BERA.d.ts.map +1 -0
- package/dist/src/sdklegacy/config/MAINNET.d.ts.map +1 -1
- package/dist/src/store/transferInput.d.ts +1 -1
- package/dist/src/store/transferInput.d.ts.map +1 -1
- package/dist/src/utils/coingecko.d.ts.map +1 -1
- package/dist/src/views/v2/Bridge/ReviewTransaction/index.d.ts.map +1 -1
- package/dist/src/views/v2/Bridge/Routes/SingleRoute.d.ts +1 -2
- package/dist/src/views/v2/Bridge/Routes/SingleRoute.d.ts.map +1 -1
- package/dist/src/views/v2/Bridge/Routes/index.d.ts.map +1 -1
- package/lib/{aptos-DxhN-FI3.mjs → aptos-BzWhIYlr.mjs} +5 -5
- package/lib/{aptos-CqfHXKy7.js → aptos-BzXZvGaH.js} +1 -1
- package/lib/{aptos-CzT6f7Ba.js → aptos-D3_AGWR7.js} +2 -2
- package/lib/{aptos-wFa1-xae.mjs → aptos-UPRxA7V-.mjs} +2 -2
- package/lib/{base64-C_XWimVd.js → base64-DRH1vfG7.js} +1 -1
- package/lib/{base64-L1vzz0KI.mjs → base64-DVjW5Kcf.mjs} +1 -1
- package/lib/{ccip-D6aPw5Ue.js → ccip-BB23_sIM.js} +1 -1
- package/lib/{ccip-z81HbzxN.mjs → ccip-wLlfyIvk.mjs} +1 -1
- package/lib/{chunk-IMTC3J2M-WMj1Jt5m.js → chunk-IMTC3J2M-CBauIJwr.js} +1 -1
- package/lib/{chunk-IMTC3J2M-CazR2ogu.mjs → chunk-IMTC3J2M-DNVBjBib.mjs} +3 -3
- package/lib/{events-D4Mv_WYU.js → events-CKwRCNdA.js} +1 -1
- package/lib/{events-BrdIAbQL.mjs → events-IHlp1dj4.mjs} +1 -1
- package/lib/{evm-CB6zu7io.mjs → evm-BabY832Q.mjs} +5 -5
- package/lib/{evm-BJL8RjTB.js → evm-C2f5n9qH.js} +3 -3
- package/lib/{evm-CULALpUt.mjs → evm-CogaB9FQ.mjs} +10 -6
- package/lib/{evm-Fk4wBAda.js → evm-CyaMnZnL.js} +1 -1
- package/lib/{index-DUGwXho3.js → index-5VUxPYxW.js} +115 -115
- package/lib/{index-DsYAlD9Y.mjs → index-B2wyWEm0.mjs} +2 -2
- package/lib/{index-BqaYMlOq.mjs → index-B5jfHVNH.mjs} +3 -3
- package/lib/{index-D2y7My6x.mjs → index-B60oaJsI.mjs} +2 -2
- package/lib/{index-Cf2BEUjb.mjs → index-B9LgOPw7.mjs} +1 -1
- package/lib/{index-jC1hUxPJ.mjs → index-BG8PXjVw.mjs} +1 -1
- package/lib/{index-ChzkRsG0.js → index-BM78yUJC.js} +1 -1
- package/lib/{index-HeldZ3mJ.mjs → index-BQ9dR-yJ.mjs} +2 -2
- package/lib/{index-BsYhqVq_.js → index-BZETHtjN.js} +1 -1
- package/lib/index-BhivGLAi.mjs +3236 -0
- package/lib/{index-B5TOuhBB.js → index-Bk1zihOK.js} +1 -1
- package/lib/{index-CtpCK8QC.js → index-Bket7LZZ.js} +1 -1
- package/lib/{index-BqCducVx.mjs → index-Bn72ykZ2.mjs} +3 -3
- package/lib/{index-BnVRRJvv.js → index-BtaC2yLu.js} +1 -1
- package/lib/{index-Dtg6idl8.js → index-BvuTcXfv.js} +1 -1
- package/lib/{index-DdRe9fUB.mjs → index-BxevXfo4.mjs} +1 -1
- package/lib/{index-DEpSdwA-.mjs → index-C1sV2FAp.mjs} +2 -2
- package/lib/{index-B9FwYN90.js → index-C407bW0H.js} +1 -1
- package/lib/{index-BT_eiQVC.js → index-CBlNoKKQ.js} +1 -1
- package/lib/{index-wAClTIQn.mjs → index-CNvVpBBa.mjs} +2 -2
- package/lib/{index-BsmdxKnE.mjs → index-CTm08KJA.mjs} +3008 -3525
- package/lib/{index-GM4m48QO.js → index-CV8YMcz4.js} +1 -1
- package/lib/{index-BTmEJpYG.mjs → index-Cs0blatJ.mjs} +1 -1
- package/lib/{index-CS3t6bxx.mjs → index-CzwViHJ0.mjs} +1 -1
- package/lib/{index-CGdGYg5B.mjs → index-D19sSkOu.mjs} +2 -2
- package/lib/{index-Xy8XaqU-.js → index-D6VdydhT.js} +1 -1
- package/lib/{index-C0MgLwy8.js → index-DIVxdT0X.js} +1 -1
- package/lib/index-DT-Qo8X9.js +14 -0
- package/lib/{index-DJJ3umH8.mjs → index-DUGSEVtX.mjs} +2 -2
- package/lib/{index-BGZONAdj.js → index-Dfo6fMQc.js} +1 -1
- package/lib/{index-CkUMgihl.js → index-DhpLGCAx.js} +1 -1
- package/lib/{index-Cuov-W4s.js → index-DiEuvJoC.js} +1 -1
- package/lib/{index-CAqS4koK.js → index-DqlsWTi0.js} +1 -1
- package/lib/{index-DXIpHh2N.mjs → index-DrO4MMc6.mjs} +4 -4
- package/lib/{index-C_2eG0Va.mjs → index-FVwpVvZ7.mjs} +1 -1
- package/lib/{index-CuPOodtE.js → index-ImA899Nn.js} +1 -1
- package/lib/{index-CuWt4RaJ.js → index-ItME4Ygf.js} +1 -1
- package/lib/index-M6UZ-4MJ.js +531 -0
- package/lib/{index-DtqIOAjg.mjs → index-or7CYt4J.mjs} +1 -1
- package/lib/{index-DGcrnWdu.mjs → index-qAojYF7t.mjs} +15207 -14384
- package/lib/{index-DpfI-2hT.mjs → index-y5-IYFyD.mjs} +2 -2
- package/lib/{index-CayMgbM_.js → index-zfWv19dx.js} +1 -1
- package/lib/index.es-C3FF2T3n.js +46 -0
- package/lib/index.es-dld457ym.mjs +7725 -0
- package/lib/index.js +1 -1
- package/lib/index.mjs +1 -1
- package/lib/{signer-BBJR-S7u.mjs → signer-BBccJJ2M.mjs} +1 -1
- package/lib/{signer-D8m72nd4.js → signer-BpeTLqjx.js} +1 -1
- package/lib/solana-4RJ4XeTx.js +1 -0
- package/lib/{solana-tZZpsxE8.js → solana-BIaWIfzq.js} +1 -1
- package/lib/{solana-DdLCPKF2.mjs → solana-Ds-NCQtw.mjs} +5 -5
- package/lib/{solana-DB5vwgKO.mjs → solana-zqUypMcM.mjs} +4 -4
- package/lib/{solanaEmbed.esm-TpsYEDsw.js → solanaEmbed.esm-BxikN_Mz.js} +10 -10
- package/lib/{solanaEmbed.esm-ANGjgiaN.mjs → solanaEmbed.esm-DRkknJ2o.mjs} +1559 -1560
- package/lib/src/config/constants.d.ts.map +1 -1
- package/lib/src/config/mainnet/chains.d.ts.map +1 -1
- package/lib/src/config/mainnet/rpcs.d.ts.map +1 -1
- package/lib/src/config/mainnet/tokens.d.ts.map +1 -1
- package/lib/src/config/tokens.d.ts +1 -1
- package/lib/src/config/tokens.d.ts.map +1 -1
- package/lib/src/config/types.d.ts +1 -1
- package/lib/src/config/types.d.ts.map +1 -1
- package/lib/src/hooks/useTransactionHistoryMayan.d.ts.map +1 -1
- package/lib/src/hooks/useTransactionHistoryWHScan.d.ts.map +1 -1
- package/lib/src/icons/ChainIcons.d.ts.map +1 -1
- package/lib/src/icons/Chains/BERA.d.ts +4 -0
- package/lib/src/icons/Chains/BERA.d.ts.map +1 -0
- package/lib/src/icons/Tokens/BERA.d.ts +4 -0
- package/lib/src/icons/Tokens/BERA.d.ts.map +1 -0
- package/lib/src/sdklegacy/config/MAINNET.d.ts.map +1 -1
- package/lib/src/store/transferInput.d.ts +1 -1
- package/lib/src/store/transferInput.d.ts.map +1 -1
- package/lib/src/utils/coingecko.d.ts.map +1 -1
- package/lib/src/views/v2/Bridge/ReviewTransaction/index.d.ts.map +1 -1
- package/lib/src/views/v2/Bridge/Routes/SingleRoute.d.ts +1 -2
- package/lib/src/views/v2/Bridge/Routes/SingleRoute.d.ts.map +1 -1
- package/lib/src/views/v2/Bridge/Routes/index.d.ts.map +1 -1
- package/lib/{sui-DKw9LmTC.mjs → sui-5OP1jpsj.mjs} +1 -1
- package/lib/{sui-UELhAZj0.js → sui-710wCQpP.js} +1 -1
- package/lib/{sui-D9F11hKw.js → sui-8bnax2uU.js} +2 -2
- package/lib/{sui-BFNsLy1t.mjs → sui-n-MTTZiA.mjs} +5 -5
- package/package.json +22 -18
- package/dist/assets/index-BUd_4Lqz.js +0 -14
- package/dist/assets/index-Db_i6Hbk.js +0 -531
- package/dist/assets/index.es-BYwyqXqm.js +0 -47
- package/dist/src/config/routes.d.ts +0 -10
- package/dist/src/config/routes.d.ts.map +0 -1
- package/lib/index-5EBn2EJL.mjs +0 -2709
- package/lib/index-CYpOkqEl.js +0 -14
- package/lib/index-Cst2493l.js +0 -531
- package/lib/index.es-DG7BWZ8R.js +0 -46
- package/lib/index.es-IbuqEs8_.mjs +0 -8242
- package/lib/solana-521ACL4P.js +0 -1
- package/lib/src/config/routes.d.ts +0 -10
- package/lib/src/config/routes.d.ts.map +0 -1
|
@@ -0,0 +1,531 @@
|
|
|
1
|
+
import{bg as Wl,i as R,be as sa,S as Hl,j as oa,bh as L,P as Jl,T as Gl}from"../main.js";import{d as Yl}from"./dijkstra-D_NXgYpA.js";import{e as He,s as aa}from"./events-CWXiu-8K.js";import{c as I,a as Ye}from"./index-DDKl8WTX.js";import{r as Ql,a as It,g as xt,i as qe,b as ni,I as Rt,f as Ce,t as fe,w as Hi,c as Si,C as Xl,d as Zl,e as ns,h as eu,j as tu,k as vn,p as ru,l as wn,A as iu,E as pe,m as nu,y as be,P as ss,Q as su,n as ou,T as ca,o as _n,q as bn,s as Qe,_ as au,u as vt}from"./index-NqsKKz5-.js";import{s as la,a as Re,h as ua,L as cu,d as nr,l as lu,e as Ii,g as uu,i as os,k as hu}from"./index-Dv9aAcjK.js";let du=class extends Ql{constructor(e){super(e),this.events=new He.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict(It(e.method,e.params||[],e.id||xt().toString()),t)}async requestStrict(e,t){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(s){n(s)}this.events.on(`${e.id}`,s=>{qe(s)?n(s.error):i(s.result)});try{await this.connection.send(e,t)}catch(s){n(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),ni(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}};var fu=function(){var r=document.getSelection();if(!r.rangeCount)return function(){};for(var e=document.activeElement,t=[],i=0;i<r.rangeCount;i++)t.push(r.getRangeAt(i));switch(e.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":e.blur();break;default:e=null;break}return r.removeAllRanges(),function(){r.type==="Caret"&&r.removeAllRanges(),r.rangeCount||t.forEach(function(n){r.addRange(n)}),e&&e.focus()}},pu=fu,as={"text/plain":"Text","text/html":"Url",default:"Text"},gu="Copy to clipboard: #{key}, Enter";function yu(r){var e=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return r.replace(/#{\s*key\s*}/g,e)}function mu(r,e){var t,i,n,s,o,a,c=!1;e||(e={}),t=e.debug||!1;try{n=pu(),s=document.createRange(),o=document.getSelection(),a=document.createElement("span"),a.textContent=r,a.ariaHidden="true",a.style.all="unset",a.style.position="fixed",a.style.top=0,a.style.clip="rect(0, 0, 0, 0)",a.style.whiteSpace="pre",a.style.webkitUserSelect="text",a.style.MozUserSelect="text",a.style.msUserSelect="text",a.style.userSelect="text",a.addEventListener("copy",function(u){if(u.stopPropagation(),e.format)if(u.preventDefault(),typeof u.clipboardData>"u"){t&&console.warn("unable to use e.clipboardData"),t&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var h=as[e.format]||as.default;window.clipboardData.setData(h,r)}else u.clipboardData.clearData(),u.clipboardData.setData(e.format,r);e.onCopy&&(u.preventDefault(),e.onCopy(u.clipboardData))}),document.body.appendChild(a),s.selectNodeContents(a),o.addRange(s);var l=document.execCommand("copy");if(!l)throw new Error("copy command was unsuccessful");c=!0}catch(u){t&&console.error("unable to copy using execCommand: ",u),t&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(e.format||"text",r),e.onCopy&&e.onCopy(window.clipboardData),c=!0}catch(h){t&&console.error("unable to copy using clipboardData: ",h),t&&console.error("falling back to prompt"),i=yu("message"in e?e.message:gu),window.prompt(i,r)}}finally{o&&(typeof o.removeRange=="function"?o.removeRange(s):o.removeAllRanges()),a&&document.body.removeChild(a),n()}return c}var vu=mu,wu={}.toString,En=Array.isArray||function(r){return wu.call(r)=="[object Array]"},_u=Wl(),Sn={},Y={};Object.defineProperty(Y,"__esModule",{value:!0});var ha=Y.getLocalStorage=Ea=Y.getLocalStorageOrThrow=ba=Y.getCrypto=_a=Y.getCryptoOrThrow=wa=Y.getLocation=va=Y.getLocationOrThrow=ma=Y.getNavigator=ya=Y.getNavigatorOrThrow=ga=Y.getDocument=pa=Y.getDocumentOrThrow=fa=Y.getFromWindowOrThrow=da=Y.getFromWindow=void 0;function Ct(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}var da=Y.getFromWindow=Ct;function Qt(r){const e=Ct(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}var fa=Y.getFromWindowOrThrow=Qt;function bu(){return Qt("document")}var pa=Y.getDocumentOrThrow=bu;function Eu(){return Ct("document")}var ga=Y.getDocument=Eu;function Su(){return Qt("navigator")}var ya=Y.getNavigatorOrThrow=Su;function Iu(){return Ct("navigator")}var ma=Y.getNavigator=Iu;function xu(){return Qt("location")}var va=Y.getLocationOrThrow=xu;function Pu(){return Ct("location")}var wa=Y.getLocation=Pu;function Au(){return Qt("crypto")}var _a=Y.getCryptoOrThrow=Au;function Tu(){return Ct("crypto")}var ba=Y.getCrypto=Tu;function Ru(){return Qt("localStorage")}var Ea=Y.getLocalStorageOrThrow=Ru;function Cu(){return Ct("localStorage")}ha=Y.getLocalStorage=Cu;Object.defineProperty(Sn,"__esModule",{value:!0});var Sa=Sn.getWindowMetadata=void 0;const cs=Y;function Nu(){let r,e;try{r=cs.getDocumentOrThrow(),e=cs.getLocationOrThrow()}catch{return null}function t(){const h=r.getElementsByTagName("link"),p=[];for(let d=0;d<h.length;d++){const f=h[d],g=f.getAttribute("rel");if(g&&g.toLowerCase().indexOf("icon")>-1){const y=f.getAttribute("href");if(y)if(y.toLowerCase().indexOf("https:")===-1&&y.toLowerCase().indexOf("http:")===-1&&y.indexOf("//")!==0){let m=e.protocol+"//"+e.host;if(y.indexOf("/")===0)m+=y;else{const v=e.pathname.split("/");v.pop();const _=v.join("/");m+=_+"/"+y}p.push(m)}else if(y.indexOf("//")===0){const m=e.protocol+y;p.push(m)}else p.push(y)}}return p}function i(...h){const p=r.getElementsByTagName("meta");for(let d=0;d<p.length;d++){const f=p[d],g=["itemprop","property","name"].map(y=>f.getAttribute(y)).filter(y=>y?h.includes(y):!1);if(g.length&&g){const y=f.getAttribute("content");if(y)return y}}return""}function n(){let h=i("name","og:site_name","og:title","twitter:title");return h||(h=r.title),h}function s(){return i("description","og:description","twitter:description","keywords")}const o=n(),a=s(),c=e.origin,l=t();return{description:a,url:c,icons:l,name:o}}Sa=Sn.getWindowMetadata=Nu;var Ou=function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var i=Array(r),n=0,e=0;e<t;e++)for(var s=arguments[e],o=0,a=s.length;o<a;o++,n++)i[n]=s[o];return i},$u=function(){function r(e,t,i){this.name=e,this.version=t,this.os=i,this.type="browser"}return r}(),ku=function(){function r(e){this.version=e,this.type="node",this.name="node",this.os=R.process.platform}return r}(),Mu=function(){function r(e,t,i,n){this.name=e,this.version=t,this.os=i,this.bot=n,this.type="bot-device"}return r}(),Lu=function(){function r(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return r}(),Du=function(){function r(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return r}(),Fu=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,qu=/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,ls=3,Uu=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FBAV\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["searchbot",Fu]],us=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function Bu(r){return r?hs(r):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Du:typeof navigator<"u"?hs(navigator.userAgent):ju()}function zu(r){return r!==""&&Uu.reduce(function(e,t){var i=t[0],n=t[1];if(e)return e;var s=n.exec(r);return!!s&&[i,s]},!1)}function hs(r){var e=zu(r);if(!e)return null;var t=e[0],i=e[1];if(t==="searchbot")return new Lu;var n=i[1]&&i[1].split(/[._]/).slice(0,3);n?n.length<ls&&(n=Ou(n,Vu(ls-n.length))):n=[];var s=n.join("."),o=Ku(r),a=qu.exec(r);return a&&a[1]?new Mu(t,s,o,a[1]):new $u(t,s,o)}function Ku(r){for(var e=0,t=us.length;e<t;e++){var i=us[e],n=i[0],s=i[1],o=s.exec(r);if(o)return n}return null}function ju(){var r=typeof R.process<"u"&&R.process.version;return r?new ku(R.process.version.slice(1)):null}function Vu(r){for(var e=[],t=0;t<r;t++)e.push("0");return e}function In(r){return Bu(r)}function si(){const r=In();return r&&r.os?r.os:void 0}function Ia(){const r=si();return r?r.toLowerCase().includes("android"):!1}function xa(){const r=si();return r?r.toLowerCase().includes("ios")||r.toLowerCase().includes("mac")&&navigator.maxTouchPoints>1:!1}function Wu(){return si()?Ia()||xa():!1}function Pa(){const r=In();return r&&r.name?r.name.toLowerCase()==="node":!1}function Hu(){return!Pa()&&!!Aa()}const Ju=da,Gu=fa,Yu=pa,Qu=ga,Xu=ya,Aa=ma,Zu=va,eh=wa,th=_a,rh=ba,ih=Ea,oi=ha;function nh(){return Sa()}function sh(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return JSON.parse(r)}catch{return r}}function oh(r){return typeof r=="string"?r:JSON.stringify(r)}const Ta=sh,Ra=oh;function Ca(r,e){const t=Ra(e),i=oi();i&&i.setItem(r,t)}function ah(r){let e=null,t=null;const i=oi();return i&&(t=i.getItem(r)),e=t&&Ta(t),e}function ch(r){const e=oi();e&&e.removeItem(r)}const Na="WALLETCONNECT_DEEPLINK_CHOICE";function lh(r,e){const t=encodeURIComponent(r);return e.universalLink?`${e.universalLink}/wc?uri=${t}`:e.deepLink?`${e.deepLink}${e.deepLink.endsWith(":")?"//":"/"}wc?uri=${t}`:""}function uh(r){const e=r.href.split("?")[0];Ca(Na,Object.assign(Object.assign({},r),{href:e}))}function Oa(r,e){return r.filter(t=>t.name.toLowerCase().includes(e.toLowerCase()))[0]}function hh(r,e){let t=r;return e&&(t=e.map(i=>Oa(r,i)).filter(Boolean)),t}const $a="https://registry.walletconnect.com";function dh(){return $a+"/api/v2/wallets"}function fh(){return $a+"/api/v2/dapps"}function ka(r,e="mobile"){var t;return{name:r.name||"",shortName:r.metadata.shortName||"",color:r.metadata.colors.primary||"",logo:(t=r.image_url.sm)!==null&&t!==void 0?t:"",universalLink:r[e].universal||"",deepLink:r[e].native||""}}function ph(r,e="mobile"){return Object.values(r).filter(t=>!!t[e].universal||!!t[e].native).map(t=>ka(t,e))}const gh=Object.freeze(Object.defineProperty({__proto__:null,detectEnv:In,detectOS:si,formatIOSMobile:lh,formatMobileRegistry:ph,formatMobileRegistryEntry:ka,getClientMeta:nh,getCrypto:rh,getCryptoOrThrow:th,getDappRegistryUrl:fh,getDocument:Qu,getDocumentOrThrow:Yu,getFromWindow:Ju,getFromWindowOrThrow:Gu,getLocal:ah,getLocalStorage:oi,getLocalStorageOrThrow:ih,getLocation:eh,getLocationOrThrow:Zu,getMobileLinkRegistry:hh,getMobileRegistryEntry:Oa,getNavigator:Aa,getNavigatorOrThrow:Xu,getWalletRegistryUrl:dh,isAndroid:Ia,isBrowser:Hu,isIOS:xa,isMobile:Wu,isNode:Pa,mobileLinkChoiceKey:Na,removeLocal:ch,safeJsonParse:Ta,safeJsonStringify:Ra,saveMobileLinkInfo:uh,setLocal:Ca},Symbol.toStringTag,{value:"Module"})),yh=sa(gh);var Ir={},mh=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},Ma={},pt={},vh=En;function wh(){try{var r=new Uint8Array(1);return r.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},r.foo()===42}catch{return!1}}z.TYPED_ARRAY_SUPPORT=wh();var ds=z.TYPED_ARRAY_SUPPORT?2147483647:1073741823;function z(r,e,t){return!z.TYPED_ARRAY_SUPPORT&&!(this instanceof z)?new z(r,e,t):typeof r=="number"?La(this,r):Ph(this,r,e,t)}z.TYPED_ARRAY_SUPPORT&&(z.prototype.__proto__=Uint8Array.prototype,z.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&z[Symbol.species]===z&&Object.defineProperty(z,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}));function xn(r){if(r>=ds)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ds.toString(16)+" bytes");return r|0}function _h(r){return r!==r}function Bt(r,e){var t;return z.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=z.prototype):(t=r,t===null&&(t=new z(e)),t.length=e),t}function La(r,e){var t=Bt(r,e<0?0:xn(e)|0);if(!z.TYPED_ARRAY_SUPPORT)for(var i=0;i<e;++i)t[i]=0;return t}function bh(r,e){var t=Fa(e)|0,i=Bt(r,t),n=i.write(e);return n!==t&&(i=i.slice(0,n)),i}function Ji(r,e){for(var t=e.length<0?0:xn(e.length)|0,i=Bt(r,t),n=0;n<t;n+=1)i[n]=e[n]&255;return i}function Eh(r,e,t,i){if(t<0||e.byteLength<t)throw new RangeError("'offset' is out of bounds");if(e.byteLength<t+(i||0))throw new RangeError("'length' is out of bounds");var n;return t===void 0&&i===void 0?n=new Uint8Array(e):i===void 0?n=new Uint8Array(e,t):n=new Uint8Array(e,t,i),z.TYPED_ARRAY_SUPPORT?n.__proto__=z.prototype:n=Ji(r,n),n}function Sh(r,e){if(z.isBuffer(e)){var t=xn(e.length)|0,i=Bt(r,t);return i.length===0||e.copy(i,0,0,t),i}if(e){if(typeof ArrayBuffer<"u"&&e.buffer instanceof ArrayBuffer||"length"in e)return typeof e.length!="number"||_h(e.length)?Bt(r,0):Ji(r,e);if(e.type==="Buffer"&&Array.isArray(e.data))return Ji(r,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function Da(r,e){e=e||1/0;for(var t,i=r.length,n=null,s=[],o=0;o<i;++o){if(t=r.charCodeAt(o),t>55295&&t<57344){if(!n){if(t>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===i){(e-=3)>-1&&s.push(239,191,189);continue}n=t;continue}if(t<56320){(e-=3)>-1&&s.push(239,191,189),n=t;continue}t=(n-55296<<10|t-56320)+65536}else n&&(e-=3)>-1&&s.push(239,191,189);if(n=null,t<128){if((e-=1)<0)break;s.push(t)}else if(t<2048){if((e-=2)<0)break;s.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;s.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;s.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return s}function Fa(r){if(z.isBuffer(r))return r.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(r)||r instanceof ArrayBuffer))return r.byteLength;typeof r!="string"&&(r=""+r);var e=r.length;return e===0?0:Da(r).length}function Ih(r,e,t,i){for(var n=0;n<i&&!(n+t>=e.length||n>=r.length);++n)e[n+t]=r[n];return n}function xh(r,e,t,i){return Ih(Da(e,r.length-t),r,t,i)}function Ph(r,e,t,i){if(typeof e=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer?Eh(r,e,t,i):typeof e=="string"?bh(r,e):Sh(r,e)}z.prototype.write=function(e,t,i){t===void 0?(i=this.length,t=0):i===void 0&&typeof t=="string"?(i=this.length,t=0):isFinite(t)&&(t=t|0,isFinite(i)?i=i|0:i=void 0);var n=this.length-t;if((i===void 0||i>n)&&(i=n),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");return xh(this,e,t,i)};z.prototype.slice=function(e,t){var i=this.length;e=~~e,t=t===void 0?i:~~t,e<0?(e+=i,e<0&&(e=0)):e>i&&(e=i),t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),t<e&&(t=e);var n;if(z.TYPED_ARRAY_SUPPORT)n=this.subarray(e,t),n.__proto__=z.prototype;else{var s=t-e;n=new z(s,void 0);for(var o=0;o<s;++o)n[o]=this[o+e]}return n};z.prototype.copy=function(e,t,i,n){if(i||(i=0),!n&&n!==0&&(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<i&&(n=i),n===i||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-i&&(n=e.length-t+i);var s=n-i,o;if(this===e&&i<t&&t<n)for(o=s-1;o>=0;--o)e[o+t]=this[o+i];else if(s<1e3||!z.TYPED_ARRAY_SUPPORT)for(o=0;o<s;++o)e[o+t]=this[o+i];else Uint8Array.prototype.set.call(e,this.subarray(i,i+s),t);return s};z.prototype.fill=function(e,t,i){if(typeof e=="string"){if(typeof t=="string"?(t=0,i=this.length):typeof i=="string"&&(i=this.length),e.length===1){var n=e.charCodeAt(0);n<256&&(e=n)}}else typeof e=="number"&&(e=e&255);if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;t=t>>>0,i=i===void 0?this.length:i>>>0,e||(e=0);var s;if(typeof e=="number")for(s=t;s<i;++s)this[s]=e;else{var o=z.isBuffer(e)?e:new z(e),a=o.length;for(s=0;s<i-t;++s)this[s+t]=o[s%a]}return this};z.concat=function(e,t){if(!vh(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return Bt(null,0);var i;if(t===void 0)for(t=0,i=0;i<e.length;++i)t+=e[i].length;var n=La(null,t),s=0;for(i=0;i<e.length;++i){var o=e[i];if(!z.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,s),s+=o.length}return n};z.byteLength=Fa;z.prototype._isBuffer=!0;z.isBuffer=function(e){return!!(e!=null&&e._isBuffer)};pt.alloc=function(r){var e=new z(r);return e.fill(0),e};pt.from=function(r){return new z(r)};var Ee={},Pn,Ah=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];Ee.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return e*4+17};Ee.getSymbolTotalCodewords=function(e){return Ah[e]};Ee.getBCHDigit=function(r){for(var e=0;r!==0;)e++,r>>>=1;return e};Ee.setToSJISFunction=function(e){if(typeof e!="function")throw new Error('"toSJISFunc" is not a valid function.');Pn=e};Ee.isKanjiModeEnabled=function(){return typeof Pn<"u"};Ee.toSJIS=function(e){return Pn(e)};var ai={};(function(r){r.L={bit:1},r.M={bit:0},r.Q={bit:3},r.H={bit:2};function e(t){if(typeof t!="string")throw new Error("Param is not a string");var i=t.toLowerCase();switch(i){case"l":case"low":return r.L;case"m":case"medium":return r.M;case"q":case"quartile":return r.Q;case"h":case"high":return r.H;default:throw new Error("Unknown EC Level: "+t)}}r.isValid=function(i){return i&&typeof i.bit<"u"&&i.bit>=0&&i.bit<4},r.from=function(i,n){if(r.isValid(i))return i;try{return e(i)}catch{return n}}})(ai);function qa(){this.buffer=[],this.length=0}qa.prototype={get:function(r){var e=Math.floor(r/8);return(this.buffer[e]>>>7-r%8&1)===1},put:function(r,e){for(var t=0;t<e;t++)this.putBit((r>>>e-t-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(r){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),r&&(this.buffer[e]|=128>>>this.length%8),this.length++}};var Th=qa,fs=pt;function xr(r){if(!r||r<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=r,this.data=fs.alloc(r*r),this.reservedBit=fs.alloc(r*r)}xr.prototype.set=function(r,e,t,i){var n=r*this.size+e;this.data[n]=t,i&&(this.reservedBit[n]=!0)};xr.prototype.get=function(r,e){return this.data[r*this.size+e]};xr.prototype.xor=function(r,e,t){this.data[r*this.size+e]^=t};xr.prototype.isReserved=function(r,e){return this.reservedBit[r*this.size+e]};var Rh=xr,Ua={};(function(r){var e=Ee.getSymbolSize;r.getRowColCoords=function(i){if(i===1)return[];for(var n=Math.floor(i/7)+2,s=e(i),o=s===145?26:Math.ceil((s-13)/(2*n-2))*2,a=[s-7],c=1;c<n-1;c++)a[c]=a[c-1]-o;return a.push(6),a.reverse()},r.getPositions=function(i){for(var n=[],s=r.getRowColCoords(i),o=s.length,a=0;a<o;a++)for(var c=0;c<o;c++)a===0&&c===0||a===0&&c===o-1||a===o-1&&c===0||n.push([s[a],s[c]]);return n}})(Ua);var Ba={},Ch=Ee.getSymbolSize,ps=7;Ba.getPositions=function(e){var t=Ch(e);return[[0,0],[t-ps,0],[0,t-ps]]};var za={};(function(r){r.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var e={N1:3,N2:3,N3:40,N4:10};r.isValid=function(n){return n!=null&&n!==""&&!isNaN(n)&&n>=0&&n<=7},r.from=function(n){return r.isValid(n)?parseInt(n,10):void 0},r.getPenaltyN1=function(n){for(var s=n.size,o=0,a=0,c=0,l=null,u=null,h=0;h<s;h++){a=c=0,l=u=null;for(var p=0;p<s;p++){var d=n.get(h,p);d===l?a++:(a>=5&&(o+=e.N1+(a-5)),l=d,a=1),d=n.get(p,h),d===u?c++:(c>=5&&(o+=e.N1+(c-5)),u=d,c=1)}a>=5&&(o+=e.N1+(a-5)),c>=5&&(o+=e.N1+(c-5))}return o},r.getPenaltyN2=function(n){for(var s=n.size,o=0,a=0;a<s-1;a++)for(var c=0;c<s-1;c++){var l=n.get(a,c)+n.get(a,c+1)+n.get(a+1,c)+n.get(a+1,c+1);(l===4||l===0)&&o++}return o*e.N2},r.getPenaltyN3=function(n){for(var s=n.size,o=0,a=0,c=0,l=0;l<s;l++){a=c=0;for(var u=0;u<s;u++)a=a<<1&2047|n.get(l,u),u>=10&&(a===1488||a===93)&&o++,c=c<<1&2047|n.get(u,l),u>=10&&(c===1488||c===93)&&o++}return o*e.N3},r.getPenaltyN4=function(n){for(var s=0,o=n.data.length,a=0;a<o;a++)s+=n.data[a];var c=Math.abs(Math.ceil(s*100/o/5)-10);return c*e.N4};function t(i,n,s){switch(i){case r.Patterns.PATTERN000:return(n+s)%2===0;case r.Patterns.PATTERN001:return n%2===0;case r.Patterns.PATTERN010:return s%3===0;case r.Patterns.PATTERN011:return(n+s)%3===0;case r.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(s/3))%2===0;case r.Patterns.PATTERN101:return n*s%2+n*s%3===0;case r.Patterns.PATTERN110:return(n*s%2+n*s%3)%2===0;case r.Patterns.PATTERN111:return(n*s%3+(n+s)%2)%2===0;default:throw new Error("bad maskPattern:"+i)}}r.applyMask=function(n,s){for(var o=s.size,a=0;a<o;a++)for(var c=0;c<o;c++)s.isReserved(c,a)||s.xor(c,a,t(n,c,a))},r.getBestMask=function(n,s){for(var o=Object.keys(r.Patterns).length,a=0,c=1/0,l=0;l<o;l++){s(l),r.applyMask(l,n);var u=r.getPenaltyN1(n)+r.getPenaltyN2(n)+r.getPenaltyN3(n)+r.getPenaltyN4(n);r.applyMask(l,n),u<c&&(c=u,a=l)}return a}})(za);var ci={},ct=ai,$r=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],kr=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];ci.getBlocksCount=function(e,t){switch(t){case ct.L:return $r[(e-1)*4+0];case ct.M:return $r[(e-1)*4+1];case ct.Q:return $r[(e-1)*4+2];case ct.H:return $r[(e-1)*4+3];default:return}};ci.getTotalCodewordsCount=function(e,t){switch(t){case ct.L:return kr[(e-1)*4+0];case ct.M:return kr[(e-1)*4+1];case ct.Q:return kr[(e-1)*4+2];case ct.H:return kr[(e-1)*4+3];default:return}};var Ka={},li={},ja=pt,fr=ja.alloc(512),Wr=ja.alloc(256);(function(){for(var e=1,t=0;t<255;t++)fr[t]=e,Wr[e]=t,e<<=1,e&256&&(e^=285);for(t=255;t<512;t++)fr[t]=fr[t-255]})();li.log=function(e){if(e<1)throw new Error("log("+e+")");return Wr[e]};li.exp=function(e){return fr[e]};li.mul=function(e,t){return e===0||t===0?0:fr[Wr[e]+Wr[t]]};(function(r){var e=pt,t=li;r.mul=function(n,s){for(var o=e.alloc(n.length+s.length-1),a=0;a<n.length;a++)for(var c=0;c<s.length;c++)o[a+c]^=t.mul(n[a],s[c]);return o},r.mod=function(n,s){for(var o=e.from(n);o.length-s.length>=0;){for(var a=o[0],c=0;c<s.length;c++)o[c]^=t.mul(s[c],a);for(var l=0;l<o.length&&o[l]===0;)l++;o=o.slice(l)}return o},r.generateECPolynomial=function(n){for(var s=e.from([1]),o=0;o<n;o++)s=r.mul(s,[1,t.exp(o)]);return s}})(Ka);var gs=pt,Va=Ka,Nh=Hl.Buffer;function An(r){this.genPoly=void 0,this.degree=r,this.degree&&this.initialize(this.degree)}An.prototype.initialize=function(e){this.degree=e,this.genPoly=Va.generateECPolynomial(this.degree)};An.prototype.encode=function(e){if(!this.genPoly)throw new Error("Encoder not initialized");var t=gs.alloc(this.degree),i=Nh.concat([e,t],e.length+this.degree),n=Va.mod(i,this.genPoly),s=this.degree-n.length;if(s>0){var o=gs.alloc(this.degree);return n.copy(o,s),o}return n};var Oh=An,Wa={},gt={},Tn={};Tn.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40};var Je={},Ha="[0-9]+",$h="[A-Z $%*+\\-./:]+",vr="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";vr=vr.replace(/u/g,"\\u");var kh="(?:(?![A-Z0-9 $%*+\\-./:]|"+vr+`)(?:.|[\r
|
|
2
|
+
]))+`;Je.KANJI=new RegExp(vr,"g");Je.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");Je.BYTE=new RegExp(kh,"g");Je.NUMERIC=new RegExp(Ha,"g");Je.ALPHANUMERIC=new RegExp($h,"g");var Mh=new RegExp("^"+vr+"$"),Lh=new RegExp("^"+Ha+"$"),Dh=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");Je.testKanji=function(e){return Mh.test(e)};Je.testNumeric=function(e){return Lh.test(e)};Je.testAlphanumeric=function(e){return Dh.test(e)};(function(r){var e=Tn,t=Je;r.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},r.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},r.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},r.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},r.MIXED={bit:-1},r.getCharCountIndicator=function(s,o){if(!s.ccBits)throw new Error("Invalid mode: "+s);if(!e.isValid(o))throw new Error("Invalid version: "+o);return o>=1&&o<10?s.ccBits[0]:o<27?s.ccBits[1]:s.ccBits[2]},r.getBestModeForData=function(s){return t.testNumeric(s)?r.NUMERIC:t.testAlphanumeric(s)?r.ALPHANUMERIC:t.testKanji(s)?r.KANJI:r.BYTE},r.toString=function(s){if(s&&s.id)return s.id;throw new Error("Invalid mode")},r.isValid=function(s){return s&&s.bit&&s.ccBits};function i(n){if(typeof n!="string")throw new Error("Param is not a string");var s=n.toLowerCase();switch(s){case"numeric":return r.NUMERIC;case"alphanumeric":return r.ALPHANUMERIC;case"kanji":return r.KANJI;case"byte":return r.BYTE;default:throw new Error("Unknown mode: "+n)}}r.from=function(s,o){if(r.isValid(s))return s;try{return i(s)}catch{return o}}})(gt);(function(r){var e=Ee,t=ci,i=ai,n=gt,s=Tn,o=En,a=7973,c=e.getBCHDigit(a);function l(d,f,g){for(var y=1;y<=40;y++)if(f<=r.getCapacity(y,g,d))return y}function u(d,f){return n.getCharCountIndicator(d,f)+4}function h(d,f){var g=0;return d.forEach(function(y){var m=u(y.mode,f);g+=m+y.getBitsLength()}),g}function p(d,f){for(var g=1;g<=40;g++){var y=h(d,g);if(y<=r.getCapacity(g,f,n.MIXED))return g}}r.from=function(f,g){return s.isValid(f)?parseInt(f,10):g},r.getCapacity=function(f,g,y){if(!s.isValid(f))throw new Error("Invalid QR Code version");typeof y>"u"&&(y=n.BYTE);var m=e.getSymbolTotalCodewords(f),v=t.getTotalCodewordsCount(f,g),_=(m-v)*8;if(y===n.MIXED)return _;var w=_-u(y,f);switch(y){case n.NUMERIC:return Math.floor(w/10*3);case n.ALPHANUMERIC:return Math.floor(w/11*2);case n.KANJI:return Math.floor(w/13);case n.BYTE:default:return Math.floor(w/8)}},r.getBestVersionForData=function(f,g){var y,m=i.from(g,i.M);if(o(f)){if(f.length>1)return p(f,m);if(f.length===0)return 1;y=f[0]}else y=f;return l(y.mode,y.getLength(),m)},r.getEncodedBits=function(f){if(!s.isValid(f)||f<7)throw new Error("Invalid QR Code version");for(var g=f<<12;e.getBCHDigit(g)-c>=0;)g^=a<<e.getBCHDigit(g)-c;return f<<12|g}})(Wa);var Ja={},Gi=Ee,Ga=1335,Fh=21522,ys=Gi.getBCHDigit(Ga);Ja.getEncodedBits=function(e,t){for(var i=e.bit<<3|t,n=i<<10;Gi.getBCHDigit(n)-ys>=0;)n^=Ga<<Gi.getBCHDigit(n)-ys;return(i<<10|n)^Fh};var Ya={},qh=gt;function zt(r){this.mode=qh.NUMERIC,this.data=r.toString()}zt.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)};zt.prototype.getLength=function(){return this.data.length};zt.prototype.getBitsLength=function(){return zt.getBitsLength(this.data.length)};zt.prototype.write=function(e){var t,i,n;for(t=0;t+3<=this.data.length;t+=3)i=this.data.substr(t,3),n=parseInt(i,10),e.put(n,10);var s=this.data.length-t;s>0&&(i=this.data.substr(t),n=parseInt(i,10),e.put(n,s*3+1))};var Uh=zt,Bh=gt,xi=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function Kt(r){this.mode=Bh.ALPHANUMERIC,this.data=r}Kt.getBitsLength=function(e){return 11*Math.floor(e/2)+6*(e%2)};Kt.prototype.getLength=function(){return this.data.length};Kt.prototype.getBitsLength=function(){return Kt.getBitsLength(this.data.length)};Kt.prototype.write=function(e){var t;for(t=0;t+2<=this.data.length;t+=2){var i=xi.indexOf(this.data[t])*45;i+=xi.indexOf(this.data[t+1]),e.put(i,11)}this.data.length%2&&e.put(xi.indexOf(this.data[t]),6)};var zh=Kt,Kh=pt,jh=gt;function jt(r){this.mode=jh.BYTE,this.data=Kh.from(r)}jt.getBitsLength=function(e){return e*8};jt.prototype.getLength=function(){return this.data.length};jt.prototype.getBitsLength=function(){return jt.getBitsLength(this.data.length)};jt.prototype.write=function(r){for(var e=0,t=this.data.length;e<t;e++)r.put(this.data[e],8)};var Vh=jt,Wh=gt,Hh=Ee;function Vt(r){this.mode=Wh.KANJI,this.data=r}Vt.getBitsLength=function(e){return e*13};Vt.prototype.getLength=function(){return this.data.length};Vt.prototype.getBitsLength=function(){return Vt.getBitsLength(this.data.length)};Vt.prototype.write=function(r){var e;for(e=0;e<this.data.length;e++){var t=Hh.toSJIS(this.data[e]);if(t>=33088&&t<=40956)t-=33088;else if(t>=57408&&t<=60351)t-=49472;else throw new Error("Invalid SJIS character: "+this.data[e]+`
|
|
3
|
+
Make sure your charset is UTF-8`);t=(t>>>8&255)*192+(t&255),r.put(t,13)}};var Jh=Vt;(function(r){var e=gt,t=Uh,i=zh,n=Vh,s=Jh,o=Je,a=Ee,c=Yl;function l(m){return unescape(encodeURIComponent(m)).length}function u(m,v,_){for(var w=[],b;(b=m.exec(_))!==null;)w.push({data:b[0],index:b.index,mode:v,length:b[0].length});return w}function h(m){var v=u(o.NUMERIC,e.NUMERIC,m),_=u(o.ALPHANUMERIC,e.ALPHANUMERIC,m),w,b;a.isKanjiModeEnabled()?(w=u(o.BYTE,e.BYTE,m),b=u(o.KANJI,e.KANJI,m)):(w=u(o.BYTE_KANJI,e.BYTE,m),b=[]);var E=v.concat(_,w,b);return E.sort(function(S,x){return S.index-x.index}).map(function(S){return{data:S.data,mode:S.mode,length:S.length}})}function p(m,v){switch(v){case e.NUMERIC:return t.getBitsLength(m);case e.ALPHANUMERIC:return i.getBitsLength(m);case e.KANJI:return s.getBitsLength(m);case e.BYTE:return n.getBitsLength(m)}}function d(m){return m.reduce(function(v,_){var w=v.length-1>=0?v[v.length-1]:null;return w&&w.mode===_.mode?(v[v.length-1].data+=_.data,v):(v.push(_),v)},[])}function f(m){for(var v=[],_=0;_<m.length;_++){var w=m[_];switch(w.mode){case e.NUMERIC:v.push([w,{data:w.data,mode:e.ALPHANUMERIC,length:w.length},{data:w.data,mode:e.BYTE,length:w.length}]);break;case e.ALPHANUMERIC:v.push([w,{data:w.data,mode:e.BYTE,length:w.length}]);break;case e.KANJI:v.push([w,{data:w.data,mode:e.BYTE,length:l(w.data)}]);break;case e.BYTE:v.push([{data:w.data,mode:e.BYTE,length:l(w.data)}])}}return v}function g(m,v){for(var _={},w={start:{}},b=["start"],E=0;E<m.length;E++){for(var S=m[E],x=[],C=0;C<S.length;C++){var N=S[C],O=""+E+C;x.push(O),_[O]={node:N,lastCount:0},w[O]={};for(var D=0;D<b.length;D++){var $=b[D];_[$]&&_[$].node.mode===N.mode?(w[$][O]=p(_[$].lastCount+N.length,N.mode)-p(_[$].lastCount,N.mode),_[$].lastCount+=N.length):(_[$]&&(_[$].lastCount=N.length),w[$][O]=p(N.length,N.mode)+4+e.getCharCountIndicator(N.mode,v))}}b=x}for(D=0;D<b.length;D++)w[b[D]].end=0;return{map:w,table:_}}function y(m,v){var _,w=e.getBestModeForData(m);if(_=e.from(v,w),_!==e.BYTE&&_.bit<w.bit)throw new Error('"'+m+'" cannot be encoded with mode '+e.toString(_)+`.
|
|
4
|
+
Suggested mode is: `+e.toString(w));switch(_===e.KANJI&&!a.isKanjiModeEnabled()&&(_=e.BYTE),_){case e.NUMERIC:return new t(m);case e.ALPHANUMERIC:return new i(m);case e.KANJI:return new s(m);case e.BYTE:return new n(m)}}r.fromArray=function(v){return v.reduce(function(_,w){return typeof w=="string"?_.push(y(w,null)):w.data&&_.push(y(w.data,w.mode)),_},[])},r.fromString=function(v,_){for(var w=h(v,a.isKanjiModeEnabled()),b=f(w),E=g(b,_),S=c.find_path(E.map,"start","end"),x=[],C=1;C<S.length-1;C++)x.push(E.table[S[C]].node);return r.fromArray(d(x))},r.rawSplit=function(v){return r.fromArray(h(v,a.isKanjiModeEnabled()))}})(Ya);var ms=pt,ui=Ee,Pi=ai,Gh=Th,Yh=Rh,Qh=Ua,Xh=Ba,Yi=za,Qi=ci,Zh=Oh,Hr=Wa,ed=Ja,td=gt,Ai=Ya,rd=En;function id(r,e){for(var t=r.size,i=Xh.getPositions(e),n=0;n<i.length;n++)for(var s=i[n][0],o=i[n][1],a=-1;a<=7;a++)if(!(s+a<=-1||t<=s+a))for(var c=-1;c<=7;c++)o+c<=-1||t<=o+c||(a>=0&&a<=6&&(c===0||c===6)||c>=0&&c<=6&&(a===0||a===6)||a>=2&&a<=4&&c>=2&&c<=4?r.set(s+a,o+c,!0,!0):r.set(s+a,o+c,!1,!0))}function nd(r){for(var e=r.size,t=8;t<e-8;t++){var i=t%2===0;r.set(t,6,i,!0),r.set(6,t,i,!0)}}function sd(r,e){for(var t=Qh.getPositions(e),i=0;i<t.length;i++)for(var n=t[i][0],s=t[i][1],o=-2;o<=2;o++)for(var a=-2;a<=2;a++)o===-2||o===2||a===-2||a===2||o===0&&a===0?r.set(n+o,s+a,!0,!0):r.set(n+o,s+a,!1,!0)}function od(r,e){for(var t=r.size,i=Hr.getEncodedBits(e),n,s,o,a=0;a<18;a++)n=Math.floor(a/3),s=a%3+t-8-3,o=(i>>a&1)===1,r.set(n,s,o,!0),r.set(s,n,o,!0)}function Ti(r,e,t){var i=r.size,n=ed.getEncodedBits(e,t),s,o;for(s=0;s<15;s++)o=(n>>s&1)===1,s<6?r.set(s,8,o,!0):s<8?r.set(s+1,8,o,!0):r.set(i-15+s,8,o,!0),s<8?r.set(8,i-s-1,o,!0):s<9?r.set(8,15-s-1+1,o,!0):r.set(8,15-s-1,o,!0);r.set(i-8,8,1,!0)}function ad(r,e){for(var t=r.size,i=-1,n=t-1,s=7,o=0,a=t-1;a>0;a-=2)for(a===6&&a--;;){for(var c=0;c<2;c++)if(!r.isReserved(n,a-c)){var l=!1;o<e.length&&(l=(e[o]>>>s&1)===1),r.set(n,a-c,l),s--,s===-1&&(o++,s=7)}if(n+=i,n<0||t<=n){n-=i,i=-i;break}}}function cd(r,e,t){var i=new Gh;t.forEach(function(l){i.put(l.mode.bit,4),i.put(l.getLength(),td.getCharCountIndicator(l.mode,r)),l.write(i)});var n=ui.getSymbolTotalCodewords(r),s=Qi.getTotalCodewordsCount(r,e),o=(n-s)*8;for(i.getLengthInBits()+4<=o&&i.put(0,4);i.getLengthInBits()%8!==0;)i.putBit(0);for(var a=(o-i.getLengthInBits())/8,c=0;c<a;c++)i.put(c%2?17:236,8);return ld(i,r,e)}function ld(r,e,t){for(var i=ui.getSymbolTotalCodewords(e),n=Qi.getTotalCodewordsCount(e,t),s=i-n,o=Qi.getBlocksCount(e,t),a=i%o,c=o-a,l=Math.floor(i/o),u=Math.floor(s/o),h=u+1,p=l-u,d=new Zh(p),f=0,g=new Array(o),y=new Array(o),m=0,v=ms.from(r.buffer),_=0;_<o;_++){var w=_<c?u:h;g[_]=v.slice(f,f+w),y[_]=d.encode(g[_]),f+=w,m=Math.max(m,w)}var b=ms.alloc(i),E=0,S,x;for(S=0;S<m;S++)for(x=0;x<o;x++)S<g[x].length&&(b[E++]=g[x][S]);for(S=0;S<p;S++)for(x=0;x<o;x++)b[E++]=y[x][S];return b}function ud(r,e,t,i){var n;if(rd(r))n=Ai.fromArray(r);else if(typeof r=="string"){var s=e;if(!s){var o=Ai.rawSplit(r);s=Hr.getBestVersionForData(o,t)}n=Ai.fromString(r,s||40)}else throw new Error("Invalid data");var a=Hr.getBestVersionForData(n,t);if(!a)throw new Error("The amount of data is too big to be stored in a QR Code");if(!e)e=a;else if(e<a)throw new Error(`
|
|
5
|
+
The chosen QR Code version cannot contain this amount of data.
|
|
6
|
+
Minimum version required to store current data is: `+a+`.
|
|
7
|
+
`);var c=cd(e,t,n),l=ui.getSymbolSize(e),u=new Yh(l);return id(u,e),nd(u),sd(u,e),Ti(u,t,0),e>=7&&od(u,e),ad(u,c),isNaN(i)&&(i=Yi.getBestMask(u,Ti.bind(null,u,t))),Yi.applyMask(i,u),Ti(u,t,i),{modules:u,version:e,errorCorrectionLevel:t,maskPattern:i,segments:n}}Ma.create=function(e,t){if(typeof e>"u"||e==="")throw new Error("No input text");var i=Pi.M,n,s;return typeof t<"u"&&(i=Pi.from(t.errorCorrectionLevel,Pi.M),n=Hr.from(t.version),s=Yi.from(t.maskPattern),t.toSJISFunc&&ui.setToSJISFunction(t.toSJISFunc)),ud(e,n,i,s)};var Qa={},Rn={};(function(r){function e(t){if(typeof t=="number"&&(t=t.toString()),typeof t!="string")throw new Error("Color should be defined as hex string");var i=t.slice().replace("#","").split("");if(i.length<3||i.length===5||i.length>8)throw new Error("Invalid hex color: "+t);(i.length===3||i.length===4)&&(i=Array.prototype.concat.apply([],i.map(function(s){return[s,s]}))),i.length===6&&i.push("F","F");var n=parseInt(i.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:"#"+i.slice(0,6).join("")}}r.getOptions=function(i){i||(i={}),i.color||(i.color={});var n=typeof i.margin>"u"||i.margin===null||i.margin<0?4:i.margin,s=i.width&&i.width>=21?i.width:void 0,o=i.scale||4;return{width:s,scale:s?4:o,margin:n,color:{dark:e(i.color.dark||"#000000ff"),light:e(i.color.light||"#ffffffff")},type:i.type,rendererOpts:i.rendererOpts||{}}},r.getScale=function(i,n){return n.width&&n.width>=i+n.margin*2?n.width/(i+n.margin*2):n.scale},r.getImageWidth=function(i,n){var s=r.getScale(i,n);return Math.floor((i+n.margin*2)*s)},r.qrToImageData=function(i,n,s){for(var o=n.modules.size,a=n.modules.data,c=r.getScale(o,s),l=Math.floor((o+s.margin*2)*c),u=s.margin*c,h=[s.color.light,s.color.dark],p=0;p<l;p++)for(var d=0;d<l;d++){var f=(p*l+d)*4,g=s.color.light;if(p>=u&&d>=u&&p<l-u&&d<l-u){var y=Math.floor((p-u)/c),m=Math.floor((d-u)/c);g=h[a[y*o+m]?1:0]}i[f++]=g.r,i[f++]=g.g,i[f++]=g.b,i[f]=g.a}}})(Rn);(function(r){var e=Rn;function t(n,s,o){n.clearRect(0,0,s.width,s.height),s.style||(s.style={}),s.height=o,s.width=o,s.style.height=o+"px",s.style.width=o+"px"}function i(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}r.render=function(s,o,a){var c=a,l=o;typeof c>"u"&&(!o||!o.getContext)&&(c=o,o=void 0),o||(l=i()),c=e.getOptions(c);var u=e.getImageWidth(s.modules.size,c),h=l.getContext("2d"),p=h.createImageData(u,u);return e.qrToImageData(p.data,s,c),t(h,l,u),h.putImageData(p,0,0),l},r.renderToDataURL=function(s,o,a){var c=a;typeof c>"u"&&(!o||!o.getContext)&&(c=o,o=void 0),c||(c={});var l=r.render(s,o,c),u=c.type||"image/png",h=c.rendererOpts||{};return l.toDataURL(u,h.quality)}})(Qa);var Xa={},hd=Rn;function vs(r,e){var t=r.a/255,i=e+'="'+r.hex+'"';return t<1?i+" "+e+'-opacity="'+t.toFixed(2).slice(1)+'"':i}function Ri(r,e,t){var i=r+e;return typeof t<"u"&&(i+=" "+t),i}function dd(r,e,t){for(var i="",n=0,s=!1,o=0,a=0;a<r.length;a++){var c=Math.floor(a%e),l=Math.floor(a/e);!c&&!s&&(s=!0),r[a]?(o++,a>0&&c>0&&r[a-1]||(i+=s?Ri("M",c+t,.5+l+t):Ri("m",n,0),n=0,s=!1),c+1<e&&r[a+1]||(i+=Ri("h",o),o=0)):n++}return i}Xa.render=function(e,t,i){var n=hd.getOptions(t),s=e.modules.size,o=e.modules.data,a=s+n.margin*2,c=n.color.light.a?"<path "+vs(n.color.light,"fill")+' d="M0 0h'+a+"v"+a+'H0z"/>':"",l="<path "+vs(n.color.dark,"stroke")+' d="'+dd(o,s,n.margin)+'"/>',u='viewBox="0 0 '+a+" "+a+'"',h=n.width?'width="'+n.width+'" height="'+n.width+'" ':"",p='<svg xmlns="http://www.w3.org/2000/svg" '+h+u+' shape-rendering="crispEdges">'+c+l+`</svg>
|
|
8
|
+
`;return typeof i=="function"&&i(null,p),p};var fd=mh,Xi=Ma,Za=Qa,pd=Xa;function Cn(r,e,t,i,n){var s=[].slice.call(arguments,1),o=s.length,a=typeof s[o-1]=="function";if(!a&&!fd())throw new Error("Callback required as last argument");if(a){if(o<2)throw new Error("Too few arguments provided");o===2?(n=t,t=e,e=i=void 0):o===3&&(e.getContext&&typeof n>"u"?(n=i,i=void 0):(n=i,i=t,t=e,e=void 0))}else{if(o<1)throw new Error("Too few arguments provided");return o===1?(t=e,e=i=void 0):o===2&&!e.getContext&&(i=t,t=e,e=void 0),new Promise(function(l,u){try{var h=Xi.create(t,i);l(r(h,e,i))}catch(p){u(p)}})}try{var c=Xi.create(t,i);n(null,r(c,e,i))}catch(l){n(l)}}Ir.create=Xi.create;Ir.toCanvas=Cn.bind(null,Za.render);Ir.toDataURL=Cn.bind(null,Za.renderToDataURL);Ir.toString=Cn.bind(null,function(r,e,t){return pd.render(r,t)});var k,pr,Nn,ec,ws,On,tc,tt={},hi=[],gd=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord/i;function et(r,e){for(var t in e)r[t]=e[t];return r}function rc(r){var e=r.parentNode;e&&e.removeChild(r)}function it(r,e,t){var i,n=arguments,s={};for(i in e)i!=="key"&&i!=="ref"&&(s[i]=e[i]);if(arguments.length>3)for(t=[t],i=3;i<arguments.length;i++)t.push(n[i]);if(t!=null&&(s.children=t),typeof r=="function"&&r.defaultProps!=null)for(i in r.defaultProps)s[i]===void 0&&(s[i]=r.defaultProps[i]);return Jr(r,s,e&&e.key,e&&e.ref,null)}function Jr(r,e,t,i,n){var s={type:r,props:e,key:t,ref:i,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:n};return n==null&&(s.__v=s),k.vnode&&k.vnode(s),s}function ic(){return{}}function Pr(r){return r.children}function Be(r,e){this.props=r,this.context=e}function wr(r,e){if(e==null)return r.__?wr(r.__,r.__.__k.indexOf(r)+1):null;for(var t;e<r.__k.length;e++)if((t=r.__k[e])!=null&&t.__e!=null)return t.__e;return typeof r.type=="function"?wr(r):null}function nc(r){var e,t;if((r=r.__)!=null&&r.__c!=null){for(r.__e=r.__c.base=null,e=0;e<r.__k.length;e++)if((t=r.__k[e])!=null&&t.__e!=null){r.__e=r.__c.base=t.__e;break}return nc(r)}}function qr(r){(!r.__d&&(r.__d=!0)&&pr.push(r)&&!Nn++||ws!==k.debounceRendering)&&((ws=k.debounceRendering)||ec)(yd)}function yd(){for(var r;Nn=pr.length;)r=pr.sort(function(e,t){return e.__v.__b-t.__v.__b}),pr=[],r.some(function(e){var t,i,n,s,o,a,c;e.__d&&(a=(o=(t=e).__v).__e,(c=t.__P)&&(i=[],(n=et({},o)).__v=n,s=$n(c,o,n,t.__n,c.ownerSVGElement!==void 0,null,i,a??wr(o)),oc(i,o),s!=a&&nc(o)))})}function sc(r,e,t,i,n,s,o,a,c){var l,u,h,p,d,f,g,y=t&&t.__k||hi,m=y.length;if(a==tt&&(a=s!=null?s[0]:m?wr(t,0):null),l=0,e.__k=ht(e.__k,function(v){if(v!=null){if(v.__=e,v.__b=e.__b+1,(h=y[l])===null||h&&v.key==h.key&&v.type===h.type)y[l]=void 0;else for(u=0;u<m;u++){if((h=y[u])&&v.key==h.key&&v.type===h.type){y[u]=void 0;break}h=null}if(p=$n(r,v,h=h||tt,i,n,s,o,a,c),(u=v.ref)&&h.ref!=u&&(g||(g=[]),h.ref&&g.push(h.ref,null,v),g.push(u,v.__c||p,v)),p!=null){var _;if(f==null&&(f=p),v.__d!==void 0)_=v.__d,v.__d=void 0;else if(s==h||p!=a||p.parentNode==null){e:if(a==null||a.parentNode!==r)r.appendChild(p),_=null;else{for(d=a,u=0;(d=d.nextSibling)&&u<m;u+=2)if(d==p)break e;r.insertBefore(p,a),_=a}e.type=="option"&&(r.value="")}a=_!==void 0?_:p.nextSibling,typeof e.type=="function"&&(e.__d=a)}else a&&h.__e==a&&a.parentNode!=r&&(a=wr(h))}return l++,v}),e.__e=f,s!=null&&typeof e.type!="function")for(l=s.length;l--;)s[l]!=null&&rc(s[l]);for(l=m;l--;)y[l]!=null&&gr(y[l],y[l]);if(g)for(l=0;l<g.length;l++)ac(g[l],g[++l],g[++l])}function ht(r,e,t){if(t==null&&(t=[]),r==null||typeof r=="boolean")e&&t.push(e(null));else if(Array.isArray(r))for(var i=0;i<r.length;i++)ht(r[i],e,t);else t.push(e?e(typeof r=="string"||typeof r=="number"?Jr(null,r,null,null,r):r.__e!=null||r.__c!=null?Jr(r.type,r.props,r.key,null,r.__v):r):r);return t}function md(r,e,t,i,n){var s;for(s in t)s==="children"||s==="key"||s in e||Gr(r,s,null,t[s],i);for(s in e)n&&typeof e[s]!="function"||s==="children"||s==="key"||s==="value"||s==="checked"||t[s]===e[s]||Gr(r,s,e[s],t[s],i)}function _s(r,e,t){e[0]==="-"?r.setProperty(e,t):r[e]=typeof t=="number"&&gd.test(e)===!1?t+"px":t??""}function Gr(r,e,t,i,n){var s,o,a,c,l;if(n?e==="className"&&(e="class"):e==="class"&&(e="className"),e==="style")if(s=r.style,typeof t=="string")s.cssText=t;else{if(typeof i=="string"&&(s.cssText="",i=null),i)for(c in i)t&&c in t||_s(s,c,"");if(t)for(l in t)i&&t[l]===i[l]||_s(s,l,t[l])}else e[0]==="o"&&e[1]==="n"?(o=e!==(e=e.replace(/Capture$/,"")),a=e.toLowerCase(),e=(a in r?a:e).slice(2),t?(i||r.addEventListener(e,bs,o),(r.l||(r.l={}))[e]=t):r.removeEventListener(e,bs,o)):e!=="list"&&e!=="tagName"&&e!=="form"&&e!=="type"&&e!=="size"&&!n&&e in r?r[e]=t??"":typeof t!="function"&&e!=="dangerouslySetInnerHTML"&&(e!==(e=e.replace(/^xlink:?/,""))?t==null||t===!1?r.removeAttributeNS("http://www.w3.org/1999/xlink",e.toLowerCase()):r.setAttributeNS("http://www.w3.org/1999/xlink",e.toLowerCase(),t):t==null||t===!1&&!/^ar/.test(e)?r.removeAttribute(e):r.setAttribute(e,t))}function bs(r){this.l[r.type](k.event?k.event(r):r)}function $n(r,e,t,i,n,s,o,a,c){var l,u,h,p,d,f,g,y,m,v,_=e.type;if(e.constructor!==void 0)return null;(l=k.__b)&&l(e);try{e:if(typeof _=="function"){if(y=e.props,m=(l=_.contextType)&&i[l.__c],v=l?m?m.props.value:l.__:i,t.__c?g=(u=e.__c=t.__c).__=u.__E:("prototype"in _&&_.prototype.render?e.__c=u=new _(y,v):(e.__c=u=new Be(y,v),u.constructor=_,u.render=wd),m&&m.sub(u),u.props=y,u.state||(u.state={}),u.context=v,u.__n=i,h=u.__d=!0,u.__h=[]),u.__s==null&&(u.__s=u.state),_.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=et({},u.__s)),et(u.__s,_.getDerivedStateFromProps(y,u.__s))),p=u.props,d=u.state,h)_.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(_.getDerivedStateFromProps==null&&y!==p&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(y,v),!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(y,u.__s,v)===!1||e.__v===t.__v&&!u.__){for(u.props=y,u.state=u.__s,e.__v!==t.__v&&(u.__d=!1),u.__v=e,e.__e=t.__e,e.__k=t.__k,u.__h.length&&o.push(u),l=0;l<e.__k.length;l++)e.__k[l]&&(e.__k[l].__=e);break e}u.componentWillUpdate!=null&&u.componentWillUpdate(y,u.__s,v),u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(p,d,f)})}u.context=v,u.props=y,u.state=u.__s,(l=k.__r)&&l(e),u.__d=!1,u.__v=e,u.__P=r,l=u.render(u.props,u.state,u.context),e.__k=l!=null&&l.type==Pr&&l.key==null?l.props.children:Array.isArray(l)?l:[l],u.getChildContext!=null&&(i=et(et({},i),u.getChildContext())),h||u.getSnapshotBeforeUpdate==null||(f=u.getSnapshotBeforeUpdate(p,d)),sc(r,e,t,i,n,s,o,a,c),u.base=e.__e,u.__h.length&&o.push(u),g&&(u.__E=u.__=null),u.__e=!1}else s==null&&e.__v===t.__v?(e.__k=t.__k,e.__e=t.__e):e.__e=vd(t.__e,e,t,i,n,s,o,c);(l=k.diffed)&&l(e)}catch(w){e.__v=null,k.__e(w,e,t)}return e.__e}function oc(r,e){k.__c&&k.__c(e,r),r.some(function(t){try{r=t.__h,t.__h=[],r.some(function(i){i.call(t)})}catch(i){k.__e(i,t.__v)}})}function vd(r,e,t,i,n,s,o,a){var c,l,u,h,p,d=t.props,f=e.props;if(n=e.type==="svg"||n,s!=null){for(c=0;c<s.length;c++)if((l=s[c])!=null&&((e.type===null?l.nodeType===3:l.localName===e.type)||r==l)){r=l,s[c]=null;break}}if(r==null){if(e.type===null)return document.createTextNode(f);r=n?document.createElementNS("http://www.w3.org/2000/svg",e.type):document.createElement(e.type,f.is&&{is:f.is}),s=null,a=!1}if(e.type===null)d!==f&&r.data!=f&&(r.data=f);else{if(s!=null&&(s=hi.slice.call(r.childNodes)),u=(d=t.props||tt).dangerouslySetInnerHTML,h=f.dangerouslySetInnerHTML,!a){if(d===tt)for(d={},p=0;p<r.attributes.length;p++)d[r.attributes[p].name]=r.attributes[p].value;(h||u)&&(h&&u&&h.__html==u.__html||(r.innerHTML=h&&h.__html||""))}md(r,f,d,n,a),h?e.__k=[]:(e.__k=e.props.children,sc(r,e,t,i,e.type!=="foreignObject"&&n,s,o,tt,a)),a||("value"in f&&(c=f.value)!==void 0&&c!==r.value&&Gr(r,"value",c,d.value,!1),"checked"in f&&(c=f.checked)!==void 0&&c!==r.checked&&Gr(r,"checked",c,d.checked,!1))}return r}function ac(r,e,t){try{typeof r=="function"?r(e):r.current=e}catch(i){k.__e(i,t)}}function gr(r,e,t){var i,n,s;if(k.unmount&&k.unmount(r),(i=r.ref)&&(i.current&&i.current!==r.__e||ac(i,null,e)),t||typeof r.type=="function"||(t=(n=r.__e)!=null),r.__e=r.__d=void 0,(i=r.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(o){k.__e(o,e)}i.base=i.__P=null}if(i=r.__k)for(s=0;s<i.length;s++)i[s]&&gr(i[s],e,t);n!=null&&rc(n)}function wd(r,e,t){return this.constructor(r,t)}function _r(r,e,t){var i,n,s;k.__&&k.__(r,e),n=(i=t===On)?null:t&&t.__k||e.__k,r=it(Pr,null,[r]),s=[],$n(e,(i?e:t||e).__k=r,n||tt,tt,e.ownerSVGElement!==void 0,t&&!i?[t]:n?null:hi.slice.call(e.childNodes),s,t||tt,i),oc(s,r)}function cc(r,e){_r(r,e,On)}function _d(r,e){var t,i;for(i in e=et(et({},r.props),e),arguments.length>2&&(e.children=hi.slice.call(arguments,2)),t={},e)i!=="key"&&i!=="ref"&&(t[i]=e[i]);return Jr(r.type,t,e.key||r.key,e.ref||r.ref,null)}function lc(r){var e={},t={__c:"__cC"+tc++,__:r,Consumer:function(i,n){return i.children(n)},Provider:function(i){var n,s=this;return this.getChildContext||(n=[],this.getChildContext=function(){return e[t.__c]=s,e},this.shouldComponentUpdate=function(o){s.props.value!==o.value&&n.some(function(a){a.context=o.value,qr(a)})},this.sub=function(o){n.push(o);var a=o.componentWillUnmount;o.componentWillUnmount=function(){n.splice(n.indexOf(o),1),a&&a.call(o)}}),i.children}};return t.Consumer.contextType=t,t.Provider.__=t,t}k={__e:function(r,e){for(var t,i;e=e.__;)if((t=e.__c)&&!t.__)try{if(t.constructor&&t.constructor.getDerivedStateFromError!=null&&(i=!0,t.setState(t.constructor.getDerivedStateFromError(r))),t.componentDidCatch!=null&&(i=!0,t.componentDidCatch(r)),i)return qr(t.__E=t)}catch(n){r=n}throw r}},Be.prototype.setState=function(r,e){var t;t=this.__s!==this.state?this.__s:this.__s=et({},this.state),typeof r=="function"&&(r=r(t,this.props)),r&&et(t,r),r!=null&&this.__v&&(e&&this.__h.push(e),qr(this))},Be.prototype.forceUpdate=function(r){this.__v&&(this.__e=!0,r&&this.__h.push(r),qr(this))},Be.prototype.render=Pr,pr=[],Nn=0,ec=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,On=tt,tc=0;var Nt,ye,Es,Wt=0,Zi=[],Ss=k.__r,Is=k.diffed,xs=k.__c,Ps=k.unmount;function Xt(r,e){k.__h&&k.__h(ye,r,Wt||e),Wt=0;var t=ye.__H||(ye.__H={__:[],__h:[]});return r>=t.__.length&&t.__.push({}),t.__[r]}function kn(r){return Wt=1,Mn(yc,r)}function Mn(r,e,t){var i=Xt(Nt++,2);return i.__c||(i.__c=ye,i.__=[t?t(e):yc(void 0,e),function(n){var s=r(i.__[0],n);i.__[0]!==s&&(i.__[0]=s,i.__c.setState({}))}]),i.__}function uc(r,e){var t=Xt(Nt++,3);!k.__s&&Dn(t.__H,e)&&(t.__=r,t.__H=e,ye.__H.__h.push(t))}function Ln(r,e){var t=Xt(Nt++,4);!k.__s&&Dn(t.__H,e)&&(t.__=r,t.__H=e,ye.__h.push(t))}function hc(r){return Wt=5,di(function(){return{current:r}},[])}function dc(r,e,t){Wt=6,Ln(function(){typeof r=="function"?r(e()):r&&(r.current=e())},t==null?t:t.concat(r))}function di(r,e){var t=Xt(Nt++,7);return Dn(t.__H,e)?(t.__H=e,t.__h=r,t.__=r()):t.__}function fc(r,e){return Wt=8,di(function(){return r},e)}function pc(r){var e=ye.context[r.__c],t=Xt(Nt++,9);return t.__c=r,e?(t.__==null&&(t.__=!0,e.sub(ye)),e.props.value):r.__}function gc(r,e){k.useDebugValue&&k.useDebugValue(e?e(r):r)}function bd(r){var e=Xt(Nt++,10),t=kn();return e.__=r,ye.componentDidCatch||(ye.componentDidCatch=function(i){e.__&&e.__(i),t[1](i)}),[t[0],function(){t[1](void 0)}]}function Ed(){Zi.some(function(r){if(r.__P)try{r.__H.__h.forEach(en),r.__H.__h.forEach(tn),r.__H.__h=[]}catch(e){return r.__H.__h=[],k.__e(e,r.__v),!0}}),Zi=[]}function en(r){r.t&&r.t()}function tn(r){var e=r.__();typeof e=="function"&&(r.t=e)}function Dn(r,e){return!r||e.some(function(t,i){return t!==r[i]})}function yc(r,e){return typeof e=="function"?e(r):e}k.__r=function(r){Ss&&Ss(r),Nt=0,(ye=r.__c).__H&&(ye.__H.__h.forEach(en),ye.__H.__h.forEach(tn),ye.__H.__h=[])},k.diffed=function(r){Is&&Is(r);var e=r.__c;if(e){var t=e.__H;t&&t.__h.length&&(Zi.push(e)!==1&&Es===k.requestAnimationFrame||((Es=k.requestAnimationFrame)||function(i){var n,s=function(){clearTimeout(o),cancelAnimationFrame(n),setTimeout(i)},o=setTimeout(s,100);typeof window<"u"&&(n=requestAnimationFrame(s))})(Ed))}},k.__c=function(r,e){e.some(function(t){try{t.__h.forEach(en),t.__h=t.__h.filter(function(i){return!i.__||tn(i)})}catch(i){e.some(function(n){n.__h&&(n.__h=[])}),e=[],k.__e(i,t.__v)}}),xs&&xs(r,e)},k.unmount=function(r){Ps&&Ps(r);var e=r.__c;if(e){var t=e.__H;if(t)try{t.__.forEach(function(i){return i.t&&i.t()})}catch(i){k.__e(i,e.__v)}}};function Fn(r,e){for(var t in e)r[t]=e[t];return r}function rn(r,e){for(var t in r)if(t!=="__source"&&!(t in e))return!0;for(var i in e)if(i!=="__source"&&r[i]!==e[i])return!0;return!1}var mc=function(r){var e,t;function i(n){var s;return(s=r.call(this,n)||this).isPureReactComponent=!0,s}return t=r,(e=i).prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t,i.prototype.shouldComponentUpdate=function(n,s){return rn(this.props,n)||rn(this.state,s)},i}(Be);function vc(r,e){function t(n){var s=this.props.ref,o=s==n.ref;return!o&&s&&(s.call?s(null):s.current=null),e?!e(this.props,n)||!o:rn(this.props,n)}function i(n){return this.shouldComponentUpdate=t,it(r,Fn({},n))}return i.prototype.isReactComponent=!0,i.displayName="Memo("+(r.displayName||r.name)+")",i.t=!0,i}var As=k.__b;function wc(r){function e(t){var i=Fn({},t);return delete i.ref,r(i,t.ref)}return e.prototype.isReactComponent=e.t=!0,e.displayName="ForwardRef("+(r.displayName||r.name)+")",e}k.__b=function(r){r.type&&r.type.t&&r.ref&&(r.props.ref=r.ref,r.ref=null),As&&As(r)};var Ts=function(r,e){return r?ht(r).reduce(function(t,i,n){return t.concat(e(i,n))},[]):null},_c={map:Ts,forEach:Ts,count:function(r){return r?ht(r).length:0},only:function(r){if((r=ht(r)).length!==1)throw new Error("Children.only() expects only one child.");return r[0]},toArray:ht},Sd=k.__e;function bc(r){return r&&((r=Fn({},r)).__c=null,r.__k=r.__k&&r.__k.map(bc)),r}function Yr(){this.__u=0,this.o=null,this.__b=null}function Ec(r){var e=r.__.__c;return e&&e.u&&e.u(r)}function Sc(r){var e,t,i;function n(s){if(e||(e=r()).then(function(o){t=o.default||o},function(o){i=o}),i)throw i;if(!t)throw e;return it(t,s)}return n.displayName="Lazy",n.t=!0,n}function qt(){this.i=null,this.l=null}k.__e=function(r,e,t){if(r.then){for(var i,n=e;n=n.__;)if((i=n.__c)&&i.__c)return i.__c(r,e.__c)}Sd(r,e,t)},(Yr.prototype=new Be).__c=function(r,e){var t=this;t.o==null&&(t.o=[]),t.o.push(e);var i=Ec(t.__v),n=!1,s=function(){n||(n=!0,i?i(o):o())};e.__c=e.componentWillUnmount,e.componentWillUnmount=function(){s(),e.__c&&e.__c()};var o=function(){var a;if(!--t.__u)for(t.__v.__k[0]=t.state.u,t.setState({u:t.__b=null});a=t.o.pop();)a.forceUpdate()};t.__u++||t.setState({u:t.__b=t.__v.__k[0]}),r.then(s,s)},Yr.prototype.render=function(r,e){return this.__b&&(this.__v.__k[0]=bc(this.__b),this.__b=null),[it(Be,null,e.u?null:r.children),e.u&&r.fallback]};var Rs=function(r,e,t){if(++t[1]===t[0]&&r.l.delete(e),r.props.revealOrder&&(r.props.revealOrder[0]!=="t"||!r.l.size))for(t=r.i;t;){for(;t.length>3;)t.pop()();if(t[1]<t[0])break;r.i=t=t[2]}};(qt.prototype=new Be).u=function(r){var e=this,t=Ec(e.__v),i=e.l.get(r);return i[0]++,function(n){var s=function(){e.props.revealOrder?(i.push(n),Rs(e,r,i)):n()};t?t(s):s()}},qt.prototype.render=function(r){this.i=null,this.l=new Map;var e=ht(r.children);r.revealOrder&&r.revealOrder[0]==="b"&&e.reverse();for(var t=e.length;t--;)this.l.set(e[t],this.i=[1,0,this.i]);return r.children},qt.prototype.componentDidUpdate=qt.prototype.componentDidMount=function(){var r=this;r.l.forEach(function(e,t){Rs(r,t,e)})};var Id=function(){function r(){}var e=r.prototype;return e.getChildContext=function(){return this.props.context},e.render=function(t){return t.children},r}();function xd(r){var e=this,t=r.container,i=it(Id,{context:e.context},r.vnode);return e.s&&e.s!==t&&(e.v.parentNode&&e.s.removeChild(e.v),gr(e.h),e.p=!1),r.vnode?e.p?(t.__k=e.__k,_r(i,t),e.__k=t.__k):(e.v=document.createTextNode(""),cc("",t),t.appendChild(e.v),e.p=!0,e.s=t,_r(i,t,e.v),e.__k=e.v.__k):e.p&&(e.v.parentNode&&e.s.removeChild(e.v),gr(e.h)),e.h=i,e.componentWillUnmount=function(){e.v.parentNode&&e.s.removeChild(e.v),gr(e.h)},null}function Ic(r,e){return it(xd,{vnode:r,container:e})}var Cs=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|fill|flood|font|glyph(?!R)|horiz|marker(?!H|W|U)|overline|paint|stop|strikethrough|stroke|text(?!L)|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/;Be.prototype.isReactComponent={};var xc=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103;function nn(r,e,t){if(e.__k==null)for(;e.firstChild;)e.removeChild(e.firstChild);return _r(r,e),typeof t=="function"&&t(),r?r.__c:null}function Pd(r,e,t){return cc(r,e),typeof t=="function"&&t(),r?r.__c:null}var Ns=k.event;function Ci(r,e){r["UNSAFE_"+e]&&!r[e]&&Object.defineProperty(r,e,{configurable:!1,get:function(){return this["UNSAFE_"+e]},set:function(t){this["UNSAFE_"+e]=t}})}k.event=function(r){Ns&&(r=Ns(r)),r.persist=function(){};var e=!1,t=!1,i=r.stopPropagation;r.stopPropagation=function(){i.call(r),e=!0};var n=r.preventDefault;return r.preventDefault=function(){n.call(r),t=!0},r.isPropagationStopped=function(){return e},r.isDefaultPrevented=function(){return t},r.nativeEvent=r};var Os={configurable:!0,get:function(){return this.class}},$s=k.vnode;k.vnode=function(r){r.$$typeof=xc;var e=r.type,t=r.props;if(e){if(t.class!=t.className&&(Os.enumerable="className"in t,t.className!=null&&(t.class=t.className),Object.defineProperty(t,"className",Os)),typeof e!="function"){var i,n,s;for(s in t.defaultValue&&t.value!==void 0&&(t.value||t.value===0||(t.value=t.defaultValue),delete t.defaultValue),Array.isArray(t.value)&&t.multiple&&e==="select"&&(ht(t.children).forEach(function(o){t.value.indexOf(o.props.value)!=-1&&(o.props.selected=!0)}),delete t.value),t)if(i=Cs.test(s))break;if(i)for(s in n=r.props={},t)n[Cs.test(s)?s.replace(/[A-Z0-9]/,"-$&").toLowerCase():s]=t[s]}(function(o){var a=r.type,c=r.props;if(c&&typeof a=="string"){var l={};for(var u in c)/^on(Ani|Tra|Tou)/.test(u)&&(c[u.toLowerCase()]=c[u],delete c[u]),l[u.toLowerCase()]=u;if(l.ondoubleclick&&(c.ondblclick=c[l.ondoubleclick],delete c[l.ondoubleclick]),l.onbeforeinput&&(c.onbeforeinput=c[l.onbeforeinput],delete c[l.onbeforeinput]),l.onchange&&(a==="textarea"||a.toLowerCase()==="input"&&!/^fil|che|ra/i.test(c.type))){var h=l.oninput||"oninput";c[h]||(c[h]=c[l.onchange],delete c[l.onchange])}}})(),typeof e=="function"&&!e.m&&e.prototype&&(Ci(e.prototype,"componentWillMount"),Ci(e.prototype,"componentWillReceiveProps"),Ci(e.prototype,"componentWillUpdate"),e.m=!0)}$s&&$s(r)};var Ad="16.8.0";function Pc(r){return it.bind(null,r)}function qn(r){return!!r&&r.$$typeof===xc}function Ac(r){return qn(r)?_d.apply(null,arguments):r}function Tc(r){return!!r.__k&&(_r(null,r),!0)}function Rc(r){return r&&(r.base||r.nodeType===1&&r)||null}var Cc=function(r,e){return r(e)};const Td={useState:kn,useReducer:Mn,useEffect:uc,useLayoutEffect:Ln,useRef:hc,useImperativeHandle:dc,useMemo:di,useCallback:fc,useContext:pc,useDebugValue:gc,version:"16.8.0",Children:_c,render:nn,hydrate:nn,unmountComponentAtNode:Tc,createPortal:Ic,createElement:it,createContext:lc,createFactory:Pc,cloneElement:Ac,createRef:ic,Fragment:Pr,isValidElement:qn,findDOMNode:Rc,Component:Be,PureComponent:mc,memo:vc,forwardRef:wc,unstable_batchedUpdates:Cc,Suspense:Yr,SuspenseList:qt,lazy:Sc},Rd=Object.freeze(Object.defineProperty({__proto__:null,Children:_c,Component:Be,Fragment:Pr,PureComponent:mc,Suspense:Yr,SuspenseList:qt,cloneElement:Ac,createContext:lc,createElement:it,createFactory:Pc,createPortal:Ic,createRef:ic,default:Td,findDOMNode:Rc,forwardRef:wc,hydrate:Pd,isValidElement:qn,lazy:Sc,memo:vc,render:nn,unmountComponentAtNode:Tc,unstable_batchedUpdates:Cc,useCallback:fc,useContext:pc,useDebugValue:gc,useEffect:uc,useErrorBoundary:bd,useImperativeHandle:dc,useLayoutEffect:Ln,useMemo:di,useReducer:Mn,useRef:hc,useState:kn,version:Ad},Symbol.toStringTag,{value:"Module"})),Cd=sa(Rd);function Nc(r){return r&&typeof r=="object"&&"default"in r?r.default:r}var he=yh,Oc=Nc(Ir),Nd=Nc(vu),T=Cd;function Od(r){Oc.toString(r,{type:"terminal"}).then(console.log)}var $d=`:root {
|
|
9
|
+
--animation-duration: 300ms;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@keyframes fadeIn {
|
|
13
|
+
from {
|
|
14
|
+
opacity: 0;
|
|
15
|
+
}
|
|
16
|
+
to {
|
|
17
|
+
opacity: 1;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@keyframes fadeOut {
|
|
22
|
+
from {
|
|
23
|
+
opacity: 1;
|
|
24
|
+
}
|
|
25
|
+
to {
|
|
26
|
+
opacity: 0;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.animated {
|
|
31
|
+
animation-duration: var(--animation-duration);
|
|
32
|
+
animation-fill-mode: both;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.fadeIn {
|
|
36
|
+
animation-name: fadeIn;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.fadeOut {
|
|
40
|
+
animation-name: fadeOut;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
#walletconnect-wrapper {
|
|
44
|
+
-webkit-user-select: none;
|
|
45
|
+
align-items: center;
|
|
46
|
+
display: flex;
|
|
47
|
+
height: 100%;
|
|
48
|
+
justify-content: center;
|
|
49
|
+
left: 0;
|
|
50
|
+
pointer-events: none;
|
|
51
|
+
position: fixed;
|
|
52
|
+
top: 0;
|
|
53
|
+
user-select: none;
|
|
54
|
+
width: 100%;
|
|
55
|
+
z-index: 99999999999999;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.walletconnect-modal__headerLogo {
|
|
59
|
+
height: 21px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.walletconnect-modal__header p {
|
|
63
|
+
color: #ffffff;
|
|
64
|
+
font-size: 20px;
|
|
65
|
+
font-weight: 600;
|
|
66
|
+
margin: 0;
|
|
67
|
+
align-items: flex-start;
|
|
68
|
+
display: flex;
|
|
69
|
+
flex: 1;
|
|
70
|
+
margin-left: 5px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.walletconnect-modal__close__wrapper {
|
|
74
|
+
position: absolute;
|
|
75
|
+
top: 0px;
|
|
76
|
+
right: 0px;
|
|
77
|
+
z-index: 10000;
|
|
78
|
+
background: white;
|
|
79
|
+
border-radius: 26px;
|
|
80
|
+
padding: 6px;
|
|
81
|
+
box-sizing: border-box;
|
|
82
|
+
width: 26px;
|
|
83
|
+
height: 26px;
|
|
84
|
+
cursor: pointer;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.walletconnect-modal__close__icon {
|
|
88
|
+
position: relative;
|
|
89
|
+
top: 7px;
|
|
90
|
+
right: 0;
|
|
91
|
+
display: flex;
|
|
92
|
+
align-items: center;
|
|
93
|
+
justify-content: center;
|
|
94
|
+
transform: rotate(45deg);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.walletconnect-modal__close__line1 {
|
|
98
|
+
position: absolute;
|
|
99
|
+
width: 100%;
|
|
100
|
+
border: 1px solid rgb(48, 52, 59);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.walletconnect-modal__close__line2 {
|
|
104
|
+
position: absolute;
|
|
105
|
+
width: 100%;
|
|
106
|
+
border: 1px solid rgb(48, 52, 59);
|
|
107
|
+
transform: rotate(90deg);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.walletconnect-qrcode__base {
|
|
111
|
+
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
112
|
+
background: rgba(37, 41, 46, 0.95);
|
|
113
|
+
height: 100%;
|
|
114
|
+
left: 0;
|
|
115
|
+
pointer-events: auto;
|
|
116
|
+
position: fixed;
|
|
117
|
+
top: 0;
|
|
118
|
+
transition: 0.4s cubic-bezier(0.19, 1, 0.22, 1);
|
|
119
|
+
width: 100%;
|
|
120
|
+
will-change: opacity;
|
|
121
|
+
padding: 40px;
|
|
122
|
+
box-sizing: border-box;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.walletconnect-qrcode__text {
|
|
126
|
+
color: rgba(60, 66, 82, 0.6);
|
|
127
|
+
font-size: 16px;
|
|
128
|
+
font-weight: 600;
|
|
129
|
+
letter-spacing: 0;
|
|
130
|
+
line-height: 1.1875em;
|
|
131
|
+
margin: 10px 0 20px 0;
|
|
132
|
+
text-align: center;
|
|
133
|
+
width: 100%;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@media only screen and (max-width: 768px) {
|
|
137
|
+
.walletconnect-qrcode__text {
|
|
138
|
+
font-size: 4vw;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
@media only screen and (max-width: 320px) {
|
|
143
|
+
.walletconnect-qrcode__text {
|
|
144
|
+
font-size: 14px;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.walletconnect-qrcode__image {
|
|
149
|
+
width: calc(100% - 30px);
|
|
150
|
+
box-sizing: border-box;
|
|
151
|
+
cursor: none;
|
|
152
|
+
margin: 0 auto;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.walletconnect-qrcode__notification {
|
|
156
|
+
position: absolute;
|
|
157
|
+
bottom: 0;
|
|
158
|
+
left: 0;
|
|
159
|
+
right: 0;
|
|
160
|
+
font-size: 16px;
|
|
161
|
+
padding: 16px 20px;
|
|
162
|
+
border-radius: 16px;
|
|
163
|
+
text-align: center;
|
|
164
|
+
transition: all 0.1s ease-in-out;
|
|
165
|
+
background: white;
|
|
166
|
+
color: black;
|
|
167
|
+
margin-bottom: -60px;
|
|
168
|
+
opacity: 0;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.walletconnect-qrcode__notification.notification__show {
|
|
172
|
+
opacity: 1;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
@media only screen and (max-width: 768px) {
|
|
176
|
+
.walletconnect-modal__header {
|
|
177
|
+
height: 130px;
|
|
178
|
+
}
|
|
179
|
+
.walletconnect-modal__base {
|
|
180
|
+
overflow: auto;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
@media only screen and (min-device-width: 415px) and (max-width: 768px) {
|
|
185
|
+
#content {
|
|
186
|
+
max-width: 768px;
|
|
187
|
+
box-sizing: border-box;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
@media only screen and (min-width: 375px) and (max-width: 415px) {
|
|
192
|
+
#content {
|
|
193
|
+
max-width: 414px;
|
|
194
|
+
box-sizing: border-box;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
@media only screen and (min-width: 320px) and (max-width: 375px) {
|
|
199
|
+
#content {
|
|
200
|
+
max-width: 375px;
|
|
201
|
+
box-sizing: border-box;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
@media only screen and (max-width: 320px) {
|
|
206
|
+
#content {
|
|
207
|
+
max-width: 320px;
|
|
208
|
+
box-sizing: border-box;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.walletconnect-modal__base {
|
|
213
|
+
-webkit-font-smoothing: antialiased;
|
|
214
|
+
background: #ffffff;
|
|
215
|
+
border-radius: 24px;
|
|
216
|
+
box-shadow: 0 10px 50px 5px rgba(0, 0, 0, 0.4);
|
|
217
|
+
font-family: ui-rounded, "SF Pro Rounded", "SF Pro Text", medium-content-sans-serif-font,
|
|
218
|
+
-apple-system, BlinkMacSystemFont, ui-sans-serif, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell,
|
|
219
|
+
"Open Sans", "Helvetica Neue", sans-serif;
|
|
220
|
+
margin-top: 41px;
|
|
221
|
+
padding: 24px 24px 22px;
|
|
222
|
+
pointer-events: auto;
|
|
223
|
+
position: relative;
|
|
224
|
+
text-align: center;
|
|
225
|
+
transition: 0.4s cubic-bezier(0.19, 1, 0.22, 1);
|
|
226
|
+
will-change: transform;
|
|
227
|
+
overflow: visible;
|
|
228
|
+
transform: translateY(-50%);
|
|
229
|
+
top: 50%;
|
|
230
|
+
max-width: 500px;
|
|
231
|
+
margin: auto;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
@media only screen and (max-width: 320px) {
|
|
235
|
+
.walletconnect-modal__base {
|
|
236
|
+
padding: 24px 12px;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.walletconnect-modal__base .hidden {
|
|
241
|
+
transform: translateY(150%);
|
|
242
|
+
transition: 0.125s cubic-bezier(0.4, 0, 1, 1);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.walletconnect-modal__header {
|
|
246
|
+
align-items: center;
|
|
247
|
+
display: flex;
|
|
248
|
+
height: 26px;
|
|
249
|
+
left: 0;
|
|
250
|
+
justify-content: space-between;
|
|
251
|
+
position: absolute;
|
|
252
|
+
top: -42px;
|
|
253
|
+
width: 100%;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.walletconnect-modal__base .wc-logo {
|
|
257
|
+
align-items: center;
|
|
258
|
+
display: flex;
|
|
259
|
+
height: 26px;
|
|
260
|
+
margin-top: 15px;
|
|
261
|
+
padding-bottom: 15px;
|
|
262
|
+
pointer-events: auto;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.walletconnect-modal__base .wc-logo div {
|
|
266
|
+
background-color: #3399ff;
|
|
267
|
+
height: 21px;
|
|
268
|
+
margin-right: 5px;
|
|
269
|
+
mask-image: url("images/wc-logo.svg") center no-repeat;
|
|
270
|
+
width: 32px;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.walletconnect-modal__base .wc-logo p {
|
|
274
|
+
color: #ffffff;
|
|
275
|
+
font-size: 20px;
|
|
276
|
+
font-weight: 600;
|
|
277
|
+
margin: 0;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.walletconnect-modal__base h2 {
|
|
281
|
+
color: rgba(60, 66, 82, 0.6);
|
|
282
|
+
font-size: 16px;
|
|
283
|
+
font-weight: 600;
|
|
284
|
+
letter-spacing: 0;
|
|
285
|
+
line-height: 1.1875em;
|
|
286
|
+
margin: 0 0 19px 0;
|
|
287
|
+
text-align: center;
|
|
288
|
+
width: 100%;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.walletconnect-modal__base__row {
|
|
292
|
+
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
293
|
+
align-items: center;
|
|
294
|
+
border-radius: 20px;
|
|
295
|
+
cursor: pointer;
|
|
296
|
+
display: flex;
|
|
297
|
+
height: 56px;
|
|
298
|
+
justify-content: space-between;
|
|
299
|
+
padding: 0 15px;
|
|
300
|
+
position: relative;
|
|
301
|
+
margin: 0px 0px 8px;
|
|
302
|
+
text-align: left;
|
|
303
|
+
transition: 0.15s cubic-bezier(0.25, 0.46, 0.45, 0.94);
|
|
304
|
+
will-change: transform;
|
|
305
|
+
text-decoration: none;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.walletconnect-modal__base__row:hover {
|
|
309
|
+
background: rgba(60, 66, 82, 0.06);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.walletconnect-modal__base__row:active {
|
|
313
|
+
background: rgba(60, 66, 82, 0.06);
|
|
314
|
+
transform: scale(0.975);
|
|
315
|
+
transition: 0.1s cubic-bezier(0.25, 0.46, 0.45, 0.94);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.walletconnect-modal__base__row__h3 {
|
|
319
|
+
color: #25292e;
|
|
320
|
+
font-size: 20px;
|
|
321
|
+
font-weight: 700;
|
|
322
|
+
margin: 0;
|
|
323
|
+
padding-bottom: 3px;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.walletconnect-modal__base__row__right {
|
|
327
|
+
align-items: center;
|
|
328
|
+
display: flex;
|
|
329
|
+
justify-content: center;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
.walletconnect-modal__base__row__right__app-icon {
|
|
333
|
+
border-radius: 8px;
|
|
334
|
+
height: 34px;
|
|
335
|
+
margin: 0 11px 2px 0;
|
|
336
|
+
width: 34px;
|
|
337
|
+
background-size: 100%;
|
|
338
|
+
box-shadow: 0 4px 12px 0 rgba(37, 41, 46, 0.25);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
.walletconnect-modal__base__row__right__caret {
|
|
342
|
+
height: 18px;
|
|
343
|
+
opacity: 0.3;
|
|
344
|
+
transition: 0.1s cubic-bezier(0.25, 0.46, 0.45, 0.94);
|
|
345
|
+
width: 8px;
|
|
346
|
+
will-change: opacity;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.walletconnect-modal__base__row:hover .caret,
|
|
350
|
+
.walletconnect-modal__base__row:active .caret {
|
|
351
|
+
opacity: 0.6;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
.walletconnect-modal__mobile__toggle {
|
|
355
|
+
width: 80%;
|
|
356
|
+
display: flex;
|
|
357
|
+
margin: 0 auto;
|
|
358
|
+
position: relative;
|
|
359
|
+
overflow: hidden;
|
|
360
|
+
border-radius: 8px;
|
|
361
|
+
margin-bottom: 18px;
|
|
362
|
+
background: #d4d5d9;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
.walletconnect-modal__single_wallet {
|
|
366
|
+
display: flex;
|
|
367
|
+
justify-content: center;
|
|
368
|
+
margin-top: 7px;
|
|
369
|
+
margin-bottom: 18px;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
.walletconnect-modal__single_wallet a {
|
|
373
|
+
cursor: pointer;
|
|
374
|
+
color: rgb(64, 153, 255);
|
|
375
|
+
font-size: 21px;
|
|
376
|
+
font-weight: 800;
|
|
377
|
+
text-decoration: none !important;
|
|
378
|
+
margin: 0 auto;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
.walletconnect-modal__mobile__toggle_selector {
|
|
382
|
+
width: calc(50% - 8px);
|
|
383
|
+
background: white;
|
|
384
|
+
position: absolute;
|
|
385
|
+
border-radius: 5px;
|
|
386
|
+
height: calc(100% - 8px);
|
|
387
|
+
top: 4px;
|
|
388
|
+
transition: all 0.2s ease-in-out;
|
|
389
|
+
transform: translate3d(4px, 0, 0);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
.walletconnect-modal__mobile__toggle.right__selected .walletconnect-modal__mobile__toggle_selector {
|
|
393
|
+
transform: translate3d(calc(100% + 12px), 0, 0);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
.walletconnect-modal__mobile__toggle a {
|
|
397
|
+
font-size: 12px;
|
|
398
|
+
width: 50%;
|
|
399
|
+
text-align: center;
|
|
400
|
+
padding: 8px;
|
|
401
|
+
margin: 0;
|
|
402
|
+
font-weight: 600;
|
|
403
|
+
z-index: 1;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
.walletconnect-modal__footer {
|
|
407
|
+
display: flex;
|
|
408
|
+
justify-content: center;
|
|
409
|
+
margin-top: 20px;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
@media only screen and (max-width: 768px) {
|
|
413
|
+
.walletconnect-modal__footer {
|
|
414
|
+
margin-top: 5vw;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
.walletconnect-modal__footer a {
|
|
419
|
+
cursor: pointer;
|
|
420
|
+
color: #898d97;
|
|
421
|
+
font-size: 15px;
|
|
422
|
+
margin: 0 auto;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
@media only screen and (max-width: 320px) {
|
|
426
|
+
.walletconnect-modal__footer a {
|
|
427
|
+
font-size: 14px;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
.walletconnect-connect__buttons__wrapper {
|
|
432
|
+
max-height: 44vh;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
.walletconnect-connect__buttons__wrapper__android {
|
|
436
|
+
margin: 50% 0;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
.walletconnect-connect__buttons__wrapper__wrap {
|
|
440
|
+
display: grid;
|
|
441
|
+
grid-template-columns: repeat(4, 1fr);
|
|
442
|
+
margin: 10px 0;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
@media only screen and (min-width: 768px) {
|
|
446
|
+
.walletconnect-connect__buttons__wrapper__wrap {
|
|
447
|
+
margin-top: 40px;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
.walletconnect-connect__button {
|
|
452
|
+
background-color: rgb(64, 153, 255);
|
|
453
|
+
padding: 12px;
|
|
454
|
+
border-radius: 8px;
|
|
455
|
+
text-decoration: none;
|
|
456
|
+
color: rgb(255, 255, 255);
|
|
457
|
+
font-weight: 500;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
.walletconnect-connect__button__icon_anchor {
|
|
461
|
+
cursor: pointer;
|
|
462
|
+
display: flex;
|
|
463
|
+
justify-content: flex-start;
|
|
464
|
+
align-items: center;
|
|
465
|
+
margin: 8px;
|
|
466
|
+
width: 42px;
|
|
467
|
+
justify-self: center;
|
|
468
|
+
flex-direction: column;
|
|
469
|
+
text-decoration: none !important;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
@media only screen and (max-width: 320px) {
|
|
473
|
+
.walletconnect-connect__button__icon_anchor {
|
|
474
|
+
margin: 4px;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
.walletconnect-connect__button__icon {
|
|
479
|
+
border-radius: 10px;
|
|
480
|
+
height: 42px;
|
|
481
|
+
margin: 0;
|
|
482
|
+
width: 42px;
|
|
483
|
+
background-size: cover !important;
|
|
484
|
+
box-shadow: 0 4px 12px 0 rgba(37, 41, 46, 0.25);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
.walletconnect-connect__button__text {
|
|
488
|
+
color: #424952;
|
|
489
|
+
font-size: 2.7vw;
|
|
490
|
+
text-decoration: none !important;
|
|
491
|
+
padding: 0;
|
|
492
|
+
margin-top: 1.8vw;
|
|
493
|
+
font-weight: 600;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
@media only screen and (min-width: 768px) {
|
|
497
|
+
.walletconnect-connect__button__text {
|
|
498
|
+
font-size: 16px;
|
|
499
|
+
margin-top: 12px;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
.walletconnect-search__input {
|
|
504
|
+
border: none;
|
|
505
|
+
background: #d4d5d9;
|
|
506
|
+
border-style: none;
|
|
507
|
+
padding: 8px 16px;
|
|
508
|
+
outline: none;
|
|
509
|
+
font-style: normal;
|
|
510
|
+
font-stretch: normal;
|
|
511
|
+
font-size: 16px;
|
|
512
|
+
font-style: normal;
|
|
513
|
+
font-stretch: normal;
|
|
514
|
+
line-height: normal;
|
|
515
|
+
letter-spacing: normal;
|
|
516
|
+
text-align: left;
|
|
517
|
+
border-radius: 8px;
|
|
518
|
+
width: calc(100% - 16px);
|
|
519
|
+
margin: 0;
|
|
520
|
+
margin-bottom: 8px;
|
|
521
|
+
}
|
|
522
|
+
`;typeof Symbol<"u"&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")));typeof Symbol<"u"&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));function kd(r,e){try{var t=r()}catch(i){return e(i)}return t&&t.then?t.then(void 0,e):t}var Md="data:image/svg+xml,%3Csvg height='185' viewBox='0 0 300 185' width='300' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m61.4385429 36.2562612c48.9112241-47.8881663 128.2119871-47.8881663 177.1232091 0l5.886545 5.7634174c2.445561 2.3944081 2.445561 6.2765112 0 8.6709204l-20.136695 19.715503c-1.222781 1.1972051-3.2053 1.1972051-4.428081 0l-8.100584-7.9311479c-34.121692-33.4079817-89.443886-33.4079817-123.5655788 0l-8.6750562 8.4936051c-1.2227816 1.1972041-3.205301 1.1972041-4.4280806 0l-20.1366949-19.7155031c-2.4455612-2.3944092-2.4455612-6.2765122 0-8.6709204zm218.7677961 40.7737449 17.921697 17.546897c2.445549 2.3943969 2.445563 6.2764769.000031 8.6708899l-80.810171 79.121134c-2.445544 2.394426-6.410582 2.394453-8.85616.000062-.00001-.00001-.000022-.000022-.000032-.000032l-57.354143-56.154572c-.61139-.598602-1.60265-.598602-2.21404 0-.000004.000004-.000007.000008-.000011.000011l-57.3529212 56.154531c-2.4455368 2.394432-6.4105755 2.394472-8.8561612.000087-.0000143-.000014-.0000296-.000028-.0000449-.000044l-80.81241943-79.122185c-2.44556021-2.394408-2.44556021-6.2765115 0-8.6709197l17.92172963-17.5468673c2.4455602-2.3944082 6.4105989-2.3944082 8.8561602 0l57.3549775 56.155357c.6113908.598602 1.602649.598602 2.2140398 0 .0000092-.000009.0000174-.000017.0000265-.000024l57.3521031-56.155333c2.445505-2.3944633 6.410544-2.3945531 8.856161-.0002.000034.0000336.000068.0000673.000101.000101l57.354902 56.155432c.61139.598601 1.60265.598601 2.21404 0l57.353975-56.1543249c2.445561-2.3944092 6.410599-2.3944092 8.85616 0z' fill='%233b99fc'/%3E%3C/svg%3E",Ld="WalletConnect",Dd=300,Fd="rgb(64, 153, 255)",$c="walletconnect-wrapper",ks="walletconnect-style-sheet",kc="walletconnect-qrcode-modal",qd="walletconnect-qrcode-close",Mc="walletconnect-qrcode-text",Ud="walletconnect-connect-button";function Bd(r){return T.createElement("div",{className:"walletconnect-modal__header"},T.createElement("img",{src:Md,className:"walletconnect-modal__headerLogo"}),T.createElement("p",null,Ld),T.createElement("div",{className:"walletconnect-modal__close__wrapper",onClick:r.onClose},T.createElement("div",{id:qd,className:"walletconnect-modal__close__icon"},T.createElement("div",{className:"walletconnect-modal__close__line1"}),T.createElement("div",{className:"walletconnect-modal__close__line2"}))))}function zd(r){return T.createElement("a",{className:"walletconnect-connect__button",href:r.href,id:Ud+"-"+r.name,onClick:r.onClick,rel:"noopener noreferrer",style:{backgroundColor:r.color},target:"_blank"},r.name)}var Kd="data:image/svg+xml,%3Csvg fill='none' height='18' viewBox='0 0 8 18' width='8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath clip-rule='evenodd' d='m.586301.213898c-.435947.33907-.5144813.967342-.175411 1.403292l4.87831 6.27212c.28087.36111.28087.86677 0 1.22788l-4.878311 6.27211c-.33907.436-.260536 1.0642.175412 1.4033.435949.3391 1.064219.2605 1.403289-.1754l4.87832-6.2721c.84259-1.08336.84259-2.60034 0-3.68367l-4.87832-6.27212c-.33907-.4359474-.96734-.514482-1.403289-.175412z' fill='%233c4252' fill-rule='evenodd'/%3E%3C/svg%3E";function jd(r){var e=r.color,t=r.href,i=r.name,n=r.logo,s=r.onClick;return T.createElement("a",{className:"walletconnect-modal__base__row",href:t,onClick:s,rel:"noopener noreferrer",target:"_blank"},T.createElement("h3",{className:"walletconnect-modal__base__row__h3"},i),T.createElement("div",{className:"walletconnect-modal__base__row__right"},T.createElement("div",{className:"walletconnect-modal__base__row__right__app-icon",style:{background:"url('"+n+"') "+e,backgroundSize:"100%"}}),T.createElement("img",{src:Kd,className:"walletconnect-modal__base__row__right__caret"})))}function Vd(r){var e=r.color,t=r.href,i=r.name,n=r.logo,s=r.onClick,o=window.innerWidth<768?(i.length>8?2.5:2.7)+"vw":"inherit";return T.createElement("a",{className:"walletconnect-connect__button__icon_anchor",href:t,onClick:s,rel:"noopener noreferrer",target:"_blank"},T.createElement("div",{className:"walletconnect-connect__button__icon",style:{background:"url('"+n+"') "+e,backgroundSize:"100%"}}),T.createElement("div",{style:{fontSize:o},className:"walletconnect-connect__button__text"},i))}var Wd=5,Ni=12;function Hd(r){var e=he.isAndroid(),t=T.useState(""),i=t[0],n=t[1],s=T.useState(""),o=s[0],a=s[1],c=T.useState(1),l=c[0],u=c[1],h=o?r.links.filter(function(w){return w.name.toLowerCase().includes(o.toLowerCase())}):r.links,p=r.errorMessage,d=o||h.length>Wd,f=Math.ceil(h.length/Ni),g=[(l-1)*Ni+1,l*Ni],y=h.length?h.filter(function(w,b){return b+1>=g[0]&&b+1<=g[1]}):[],m=!e&&f>1,v=void 0;function _(w){n(w.target.value),clearTimeout(v),w.target.value?v=setTimeout(function(){a(w.target.value),u(1)},1e3):(n(""),a(""),u(1))}return T.createElement("div",null,T.createElement("p",{id:Mc,className:"walletconnect-qrcode__text"},e?r.text.connect_mobile_wallet:r.text.choose_preferred_wallet),!e&&T.createElement("input",{className:"walletconnect-search__input",placeholder:"Search",value:i,onChange:_}),T.createElement("div",{className:"walletconnect-connect__buttons__wrapper"+(e?"__android":d&&h.length?"__wrap":"")},e?T.createElement(zd,{name:r.text.connect,color:Fd,href:r.uri,onClick:T.useCallback(function(){he.saveMobileLinkInfo({name:"Unknown",href:r.uri})},[])}):y.length?y.map(function(w){var b=w.color,E=w.name,S=w.shortName,x=w.logo,C=he.formatIOSMobile(r.uri,w),N=T.useCallback(function(){he.saveMobileLinkInfo({name:E,href:C})},[y]);return d?T.createElement(Vd,{color:b,href:C,name:S||E,logo:x,onClick:N}):T.createElement(jd,{color:b,href:C,name:E,logo:x,onClick:N})}):T.createElement(T.Fragment,null,T.createElement("p",null,p.length?r.errorMessage:r.links.length&&!h.length?r.text.no_wallets_found:r.text.loading))),m&&T.createElement("div",{className:"walletconnect-modal__footer"},Array(f).fill(0).map(function(w,b){var E=b+1,S=l===E;return T.createElement("a",{style:{margin:"auto 10px",fontWeight:S?"bold":"normal"},onClick:function(){return u(E)}},E)})))}function Jd(r){var e=!!r.message.trim();return T.createElement("div",{className:"walletconnect-qrcode__notification"+(e?" notification__show":"")},r.message)}var Gd=function(r){try{var e="";return Promise.resolve(Oc.toString(r,{margin:0,type:"svg"})).then(function(t){return typeof t=="string"&&(e=t.replace("<svg",'<svg class="walletconnect-qrcode__image"')),e})}catch(t){return Promise.reject(t)}};function Yd(r){var e=T.useState(""),t=e[0],i=e[1],n=T.useState(""),s=n[0],o=n[1];T.useEffect(function(){try{return Promise.resolve(Gd(r.uri)).then(function(c){o(c)})}catch(c){Promise.reject(c)}},[]);var a=function(){var c=Nd(r.uri);c?(i(r.text.copied_to_clipboard),setInterval(function(){return i("")},1200)):(i("Error"),setInterval(function(){return i("")},1200))};return T.createElement("div",null,T.createElement("p",{id:Mc,className:"walletconnect-qrcode__text"},r.text.scan_qrcode_with_wallet),T.createElement("div",{dangerouslySetInnerHTML:{__html:s}}),T.createElement("div",{className:"walletconnect-modal__footer"},T.createElement("a",{onClick:a},r.text.copy_to_clipboard)),T.createElement(Jd,{message:t}))}function Qd(r){var e=he.isAndroid(),t=he.isMobile(),i=t?r.qrcodeModalOptions&&r.qrcodeModalOptions.mobileLinks?r.qrcodeModalOptions.mobileLinks:void 0:r.qrcodeModalOptions&&r.qrcodeModalOptions.desktopLinks?r.qrcodeModalOptions.desktopLinks:void 0,n=T.useState(!1),s=n[0],o=n[1],a=T.useState(!1),c=a[0],l=a[1],u=T.useState(!t),h=u[0],p=u[1],d={mobile:t,text:r.text,uri:r.uri,qrcodeModalOptions:r.qrcodeModalOptions},f=T.useState(""),g=f[0],y=f[1],m=T.useState(!1),v=m[0],_=m[1],w=T.useState([]),b=w[0],E=w[1],S=T.useState(""),x=S[0],C=S[1],N=function(){c||s||i&&!i.length||b.length>0||T.useEffect(function(){var D=function(){try{if(e)return Promise.resolve();o(!0);var $=kd(function(){var q=r.qrcodeModalOptions&&r.qrcodeModalOptions.registryUrl?r.qrcodeModalOptions.registryUrl:he.getWalletRegistryUrl();return Promise.resolve(fetch(q)).then(function(F){return Promise.resolve(F.json()).then(function(B){var K=B.listings,M=t?"mobile":"desktop",A=he.getMobileLinkRegistry(he.formatMobileRegistry(K,M),i);o(!1),l(!0),C(A.length?"":r.text.no_supported_wallets),E(A);var j=A.length===1;j&&(y(he.formatIOSMobile(r.uri,A[0])),p(!0)),_(j)})})},function(q){o(!1),l(!0),C(r.text.something_went_wrong),console.error(q)});return Promise.resolve($&&$.then?$.then(function(){}):void 0)}catch(q){return Promise.reject(q)}};D()})};N();var O=t?h:!h;return T.createElement("div",{id:kc,className:"walletconnect-qrcode__base animated fadeIn"},T.createElement("div",{className:"walletconnect-modal__base"},T.createElement(Bd,{onClose:r.onClose}),v&&h?T.createElement("div",{className:"walletconnect-modal__single_wallet"},T.createElement("a",{onClick:function(){return he.saveMobileLinkInfo({name:b[0].name,href:g})},href:g,rel:"noopener noreferrer",target:"_blank"},r.text.connect_with+" "+(v?b[0].name:"")+" ›")):e||s||!s&&b.length?T.createElement("div",{className:"walletconnect-modal__mobile__toggle"+(O?" right__selected":"")},T.createElement("div",{className:"walletconnect-modal__mobile__toggle_selector"}),t?T.createElement(T.Fragment,null,T.createElement("a",{onClick:function(){return p(!1),N()}},r.text.mobile),T.createElement("a",{onClick:function(){return p(!0)}},r.text.qrcode)):T.createElement(T.Fragment,null,T.createElement("a",{onClick:function(){return p(!0)}},r.text.qrcode),T.createElement("a",{onClick:function(){return p(!1),N()}},r.text.desktop))):null,T.createElement("div",null,h||!e&&!s&&!b.length?T.createElement(Yd,Object.assign({},d)):T.createElement(Hd,Object.assign({},d,{links:b,errorMessage:x})))))}var Xd={choose_preferred_wallet:"Wähle bevorzugte Wallet",connect_mobile_wallet:"Verbinde mit Mobile Wallet",scan_qrcode_with_wallet:"Scanne den QR-code mit einer WalletConnect kompatiblen Wallet",connect:"Verbinden",qrcode:"QR-Code",mobile:"Mobile",desktop:"Desktop",copy_to_clipboard:"In die Zwischenablage kopieren",copied_to_clipboard:"In die Zwischenablage kopiert!",connect_with:"Verbinden mit Hilfe von",loading:"Laden...",something_went_wrong:"Etwas ist schief gelaufen",no_supported_wallets:"Es gibt noch keine unterstützten Wallet",no_wallets_found:"keine Wallet gefunden"},Zd={choose_preferred_wallet:"Choose your preferred wallet",connect_mobile_wallet:"Connect to Mobile Wallet",scan_qrcode_with_wallet:"Scan QR code with a WalletConnect-compatible wallet",connect:"Connect",qrcode:"QR Code",mobile:"Mobile",desktop:"Desktop",copy_to_clipboard:"Copy to clipboard",copied_to_clipboard:"Copied to clipboard!",connect_with:"Connect with",loading:"Loading...",something_went_wrong:"Something went wrong",no_supported_wallets:"There are no supported wallets yet",no_wallets_found:"No wallets found"},ef={choose_preferred_wallet:"Elige tu billetera preferida",connect_mobile_wallet:"Conectar a billetera móvil",scan_qrcode_with_wallet:"Escanea el código QR con una billetera compatible con WalletConnect",connect:"Conectar",qrcode:"Código QR",mobile:"Móvil",desktop:"Desktop",copy_to_clipboard:"Copiar",copied_to_clipboard:"Copiado!",connect_with:"Conectar mediante",loading:"Cargando...",something_went_wrong:"Algo salió mal",no_supported_wallets:"Todavía no hay billeteras compatibles",no_wallets_found:"No se encontraron billeteras"},tf={choose_preferred_wallet:"Choisissez votre portefeuille préféré",connect_mobile_wallet:"Se connecter au portefeuille mobile",scan_qrcode_with_wallet:"Scannez le QR code avec un portefeuille compatible WalletConnect",connect:"Se connecter",qrcode:"QR Code",mobile:"Mobile",desktop:"Desktop",copy_to_clipboard:"Copier",copied_to_clipboard:"Copié!",connect_with:"Connectez-vous à l'aide de",loading:"Chargement...",something_went_wrong:"Quelque chose a mal tourné",no_supported_wallets:"Il n'y a pas encore de portefeuilles pris en charge",no_wallets_found:"Aucun portefeuille trouvé"},rf={choose_preferred_wallet:"원하는 지갑을 선택하세요",connect_mobile_wallet:"모바일 지갑과 연결",scan_qrcode_with_wallet:"WalletConnect 지원 지갑에서 QR코드를 스캔하세요",connect:"연결",qrcode:"QR 코드",mobile:"모바일",desktop:"데스크탑",copy_to_clipboard:"클립보드에 복사",copied_to_clipboard:"클립보드에 복사되었습니다!",connect_with:"와 연결하다",loading:"로드 중...",something_went_wrong:"문제가 발생했습니다.",no_supported_wallets:"아직 지원되는 지갑이 없습니다",no_wallets_found:"지갑을 찾을 수 없습니다"},nf={choose_preferred_wallet:"Escolha sua carteira preferida",connect_mobile_wallet:"Conectar-se à carteira móvel",scan_qrcode_with_wallet:"Ler o código QR com uma carteira compatível com WalletConnect",connect:"Conectar",qrcode:"Código QR",mobile:"Móvel",desktop:"Desktop",copy_to_clipboard:"Copiar",copied_to_clipboard:"Copiado!",connect_with:"Ligar por meio de",loading:"Carregamento...",something_went_wrong:"Algo correu mal",no_supported_wallets:"Ainda não há carteiras suportadas",no_wallets_found:"Nenhuma carteira encontrada"},sf={choose_preferred_wallet:"选择你的钱包",connect_mobile_wallet:"连接至移动端钱包",scan_qrcode_with_wallet:"使用兼容 WalletConnect 的钱包扫描二维码",connect:"连接",qrcode:"二维码",mobile:"移动",desktop:"桌面",copy_to_clipboard:"复制到剪贴板",copied_to_clipboard:"复制到剪贴板成功!",connect_with:"通过以下方式连接",loading:"正在加载...",something_went_wrong:"出了问题",no_supported_wallets:"目前还没有支持的钱包",no_wallets_found:"没有找到钱包"},of={choose_preferred_wallet:"کیف پول مورد نظر خود را انتخاب کنید",connect_mobile_wallet:"به کیف پول موبایل وصل شوید",scan_qrcode_with_wallet:"کد QR را با یک کیف پول سازگار با WalletConnect اسکن کنید",connect:"اتصال",qrcode:"کد QR",mobile:"سیار",desktop:"دسکتاپ",copy_to_clipboard:"کپی به کلیپ بورد",copied_to_clipboard:"در کلیپ بورد کپی شد!",connect_with:"ارتباط با",loading:"...بارگذاری",something_went_wrong:"مشکلی پیش آمد",no_supported_wallets:"هنوز هیچ کیف پول پشتیبانی شده ای وجود ندارد",no_wallets_found:"هیچ کیف پولی پیدا نشد"},Ms={de:Xd,en:Zd,es:ef,fr:tf,ko:rf,pt:nf,zh:sf,fa:of};function af(){var r=he.getDocumentOrThrow(),e=r.getElementById(ks);e&&r.head.removeChild(e);var t=r.createElement("style");t.setAttribute("id",ks),t.innerText=$d,r.head.appendChild(t)}function cf(){var r=he.getDocumentOrThrow(),e=r.createElement("div");return e.setAttribute("id",$c),r.body.appendChild(e),e}function Lc(){var r=he.getDocumentOrThrow(),e=r.getElementById(kc);e&&(e.className=e.className.replace("fadeIn","fadeOut"),setTimeout(function(){var t=r.getElementById($c);t&&r.body.removeChild(t)},Dd))}function lf(r){return function(){Lc(),r&&r()}}function uf(){var r=he.getNavigatorOrThrow().language.split("-")[0]||"en";return Ms[r]||Ms.en}function hf(r,e,t){af();var i=cf();T.render(T.createElement(Qd,{text:uf(),uri:r,onClose:lf(e),qrcodeModalOptions:t}),i)}function df(){Lc()}var Dc=function(){return typeof R.process<"u"&&typeof R.process.versions<"u"&&typeof R.process.versions.node<"u"};function ff(r,e,t){console.log(r),Dc()?Od(r):hf(r,e,t)}function pf(){Dc()||df()}var gf={open:ff,close:pf},yf=gf;const Ls=oa(yf);let mf=class extends Rt{constructor(e){super()}};const Ds=I.FIVE_SECONDS,Zt={pulse:"heartbeat_pulse"};class Un extends mf{constructor(e){super(e),this.events=new He.EventEmitter,this.interval=Ds,this.interval=(e==null?void 0:e.interval)||Ds}static async init(e){const t=new Un(e);return await t.init(),t}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),I.toMiliseconds(this.interval))}pulse(){this.events.emit(Zt.pulse)}}class vf extends Rt{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}let wf=class extends Rt{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}};class _f{constructor(e,t){this.logger=e,this.core=t}}class bf extends Rt{constructor(e,t){super(),this.relayer=e,this.logger=t}}class Ef extends Rt{constructor(e){super()}}class Sf{constructor(e,t,i,n){this.core=e,this.logger=t,this.name=i}}let If=class extends Rt{constructor(e,t){super(),this.relayer=e,this.logger=t}},xf=class extends Rt{constructor(e,t){super(),this.core=e,this.logger=t}};class Pf{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}}let Af=class{constructor(e,t){this.projectId=e,this.logger=t}},Tf=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}};const Rf=r=>JSON.stringify(r,(e,t)=>typeof t=="bigint"?t.toString()+"n":t),Cf=r=>{const e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,t=r.replace(e,'$1"$2n"$3');return JSON.parse(t,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function Fs(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return Cf(r)}catch{return r}}function Nf(r){return typeof r=="string"?r:Rf(r)||""}var Q={};Object.defineProperty(Q,"__esModule",{value:!0});Q.getLocalStorage=Q.getLocalStorageOrThrow=Q.getCrypto=Q.getCryptoOrThrow=Fc=Q.getLocation=Q.getLocationOrThrow=Bn=Q.getNavigator=Q.getNavigatorOrThrow=fi=Q.getDocument=Q.getDocumentOrThrow=Q.getFromWindowOrThrow=Q.getFromWindow=void 0;function Ot(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}Q.getFromWindow=Ot;function er(r){const e=Ot(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}Q.getFromWindowOrThrow=er;function Of(){return er("document")}Q.getDocumentOrThrow=Of;function $f(){return Ot("document")}var fi=Q.getDocument=$f;function kf(){return er("navigator")}Q.getNavigatorOrThrow=kf;function Mf(){return Ot("navigator")}var Bn=Q.getNavigator=Mf;function Lf(){return er("location")}Q.getLocationOrThrow=Lf;function Df(){return Ot("location")}var Fc=Q.getLocation=Df;function Ff(){return er("crypto")}Q.getCryptoOrThrow=Ff;function qf(){return Ot("crypto")}Q.getCrypto=qf;function Uf(){return er("localStorage")}Q.getLocalStorageOrThrow=Uf;function Bf(){return Ot("localStorage")}Q.getLocalStorage=Bf;var zn={};Object.defineProperty(zn,"__esModule",{value:!0});var qc=zn.getWindowMetadata=void 0;const qs=Q;function zf(){let r,e;try{r=qs.getDocumentOrThrow(),e=qs.getLocationOrThrow()}catch{return null}function t(){const h=r.getElementsByTagName("link"),p=[];for(let d=0;d<h.length;d++){const f=h[d],g=f.getAttribute("rel");if(g&&g.toLowerCase().indexOf("icon")>-1){const y=f.getAttribute("href");if(y)if(y.toLowerCase().indexOf("https:")===-1&&y.toLowerCase().indexOf("http:")===-1&&y.indexOf("//")!==0){let m=e.protocol+"//"+e.host;if(y.indexOf("/")===0)m+=y;else{const v=e.pathname.split("/");v.pop();const _=v.join("/");m+=_+"/"+y}p.push(m)}else if(y.indexOf("//")===0){const m=e.protocol+y;p.push(m)}else p.push(y)}}return p}function i(...h){const p=r.getElementsByTagName("meta");for(let d=0;d<p.length;d++){const f=p[d],g=["itemprop","property","name"].map(y=>f.getAttribute(y)).filter(y=>y?h.includes(y):!1);if(g.length&&g){const y=f.getAttribute("content");if(y)return y}}return""}function n(){let h=i("name","og:site_name","og:title","twitter:title");return h||(h=r.title),h}function s(){return i("description","og:description","twitter:description","keywords")}const o=n(),a=s(),c=e.origin,l=t();return{description:a,url:c,icons:l,name:o}}qc=zn.getWindowMetadata=zf;function tr(r,e,t){return t={path:e,exports:{},require:function(i,n){return Kf(i,n??t.path)}},r(t,t.exports),t.exports}function Kf(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Kn=Uc;function Uc(r,e){if(!r)throw new Error(e||"Assertion failed")}Uc.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)};var Ue=tr(function(r,e){var t=e;function i(o,a){if(Array.isArray(o))return o.slice();if(!o)return[];var c=[];if(typeof o!="string"){for(var l=0;l<o.length;l++)c[l]=o[l]|0;return c}if(a==="hex"){o=o.replace(/[^a-z0-9]+/ig,""),o.length%2!==0&&(o="0"+o);for(var l=0;l<o.length;l+=2)c.push(parseInt(o[l]+o[l+1],16))}else for(var l=0;l<o.length;l++){var u=o.charCodeAt(l),h=u>>8,p=u&255;h?c.push(h,p):c.push(p)}return c}t.toArray=i;function n(o){return o.length===1?"0"+o:o}t.zero2=n;function s(o){for(var a="",c=0;c<o.length;c++)a+=n(o[c].toString(16));return a}t.toHex=s,t.encode=function(a,c){return c==="hex"?s(a):a}}),Se=tr(function(r,e){var t=e;t.assert=Kn,t.toArray=Ue.toArray,t.zero2=Ue.zero2,t.toHex=Ue.toHex,t.encode=Ue.encode;function i(c,l,u){var h=new Array(Math.max(c.bitLength(),u)+1);h.fill(0);for(var p=1<<l+1,d=c.clone(),f=0;f<h.length;f++){var g,y=d.andln(p-1);d.isOdd()?(y>(p>>1)-1?g=(p>>1)-y:g=y,d.isubn(g)):g=0,h[f]=g,d.iushrn(1)}return h}t.getNAF=i;function n(c,l){var u=[[],[]];c=c.clone(),l=l.clone();for(var h=0,p=0,d;c.cmpn(-h)>0||l.cmpn(-p)>0;){var f=c.andln(3)+h&3,g=l.andln(3)+p&3;f===3&&(f=-1),g===3&&(g=-1);var y;f&1?(d=c.andln(7)+h&7,(d===3||d===5)&&g===2?y=-f:y=f):y=0,u[0].push(y);var m;g&1?(d=l.andln(7)+p&7,(d===3||d===5)&&f===2?m=-g:m=g):m=0,u[1].push(m),2*h===y+1&&(h=1-h),2*p===m+1&&(p=1-p),c.iushrn(1),l.iushrn(1)}return u}t.getJSF=n;function s(c,l,u){var h="_"+l;c.prototype[l]=function(){return this[h]!==void 0?this[h]:this[h]=u.call(this)}}t.cachedProperty=s;function o(c){return typeof c=="string"?t.toArray(c,"hex"):c}t.parseBytes=o;function a(c){return new L(c,"hex","le")}t.intFromLE=a}),Qr=Se.getNAF,jf=Se.getJSF,Xr=Se.assert;function yt(r,e){this.type=r,this.p=new L(e.p,16),this.red=e.prime?L.red(e.prime):L.mont(this.p),this.zero=new L(0).toRed(this.red),this.one=new L(1).toRed(this.red),this.two=new L(2).toRed(this.red),this.n=e.n&&new L(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var $t=yt;yt.prototype.point=function(){throw new Error("Not implemented")};yt.prototype.validate=function(){throw new Error("Not implemented")};yt.prototype._fixedNafMul=function(e,t){Xr(e.precomputed);var i=e._getDoubles(),n=Qr(t,1,this._bitLength),s=(1<<i.step+1)-(i.step%2===0?2:1);s/=3;var o=[],a,c;for(a=0;a<n.length;a+=i.step){c=0;for(var l=a+i.step-1;l>=a;l--)c=(c<<1)+n[l];o.push(c)}for(var u=this.jpoint(null,null,null),h=this.jpoint(null,null,null),p=s;p>0;p--){for(a=0;a<o.length;a++)c=o[a],c===p?h=h.mixedAdd(i.points[a]):c===-p&&(h=h.mixedAdd(i.points[a].neg()));u=u.add(h)}return u.toP()};yt.prototype._wnafMul=function(e,t){var i=4,n=e._getNAFPoints(i);i=n.wnd;for(var s=n.points,o=Qr(t,i,this._bitLength),a=this.jpoint(null,null,null),c=o.length-1;c>=0;c--){for(var l=0;c>=0&&o[c]===0;c--)l++;if(c>=0&&l++,a=a.dblp(l),c<0)break;var u=o[c];Xr(u!==0),e.type==="affine"?u>0?a=a.mixedAdd(s[u-1>>1]):a=a.mixedAdd(s[-u-1>>1].neg()):u>0?a=a.add(s[u-1>>1]):a=a.add(s[-u-1>>1].neg())}return e.type==="affine"?a.toP():a};yt.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,a=this._wnafT2,c=this._wnafT3,l=0,u,h,p;for(u=0;u<n;u++){p=t[u];var d=p._getNAFPoints(e);o[u]=d.wnd,a[u]=d.points}for(u=n-1;u>=1;u-=2){var f=u-1,g=u;if(o[f]!==1||o[g]!==1){c[f]=Qr(i[f],o[f],this._bitLength),c[g]=Qr(i[g],o[g],this._bitLength),l=Math.max(c[f].length,l),l=Math.max(c[g].length,l);continue}var y=[t[f],null,null,t[g]];t[f].y.cmp(t[g].y)===0?(y[1]=t[f].add(t[g]),y[2]=t[f].toJ().mixedAdd(t[g].neg())):t[f].y.cmp(t[g].y.redNeg())===0?(y[1]=t[f].toJ().mixedAdd(t[g]),y[2]=t[f].add(t[g].neg())):(y[1]=t[f].toJ().mixedAdd(t[g]),y[2]=t[f].toJ().mixedAdd(t[g].neg()));var m=[-3,-1,-5,-7,0,7,5,1,3],v=jf(i[f],i[g]);for(l=Math.max(v[0].length,l),c[f]=new Array(l),c[g]=new Array(l),h=0;h<l;h++){var _=v[0][h]|0,w=v[1][h]|0;c[f][h]=m[(_+1)*3+(w+1)],c[g][h]=0,a[f]=y}}var b=this.jpoint(null,null,null),E=this._wnafT4;for(u=l;u>=0;u--){for(var S=0;u>=0;){var x=!0;for(h=0;h<n;h++)E[h]=c[h][u]|0,E[h]!==0&&(x=!1);if(!x)break;S++,u--}if(u>=0&&S++,b=b.dblp(S),u<0)break;for(h=0;h<n;h++){var C=E[h];C!==0&&(C>0?p=a[h][C-1>>1]:C<0&&(p=a[h][-C-1>>1].neg()),p.type==="affine"?b=b.mixedAdd(p):b=b.add(p))}}for(u=0;u<n;u++)a[u]=null;return s?b:b.toP()};function Oe(r,e){this.curve=r,this.type=e,this.precomputed=null}yt.BasePoint=Oe;Oe.prototype.eq=function(){throw new Error("Not implemented")};Oe.prototype.validate=function(){return this.curve.validate(this)};yt.prototype.decodePoint=function(e,t){e=Se.toArray(e,t);var i=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*i){e[0]===6?Xr(e[e.length-1]%2===0):e[0]===7&&Xr(e[e.length-1]%2===1);var n=this.point(e.slice(1,1+i),e.slice(1+i,1+2*i));return n}else if((e[0]===2||e[0]===3)&&e.length-1===i)return this.pointFromX(e.slice(1,1+i),e[0]===3);throw new Error("Unknown point format")};Oe.prototype.encodeCompressed=function(e){return this.encode(e,!0)};Oe.prototype._encode=function(e){var t=this.curve.p.byteLength(),i=this.getX().toArray("be",t);return e?[this.getY().isEven()?2:3].concat(i):[4].concat(i,this.getY().toArray("be",t))};Oe.prototype.encode=function(e,t){return Se.encode(this._encode(t),e)};Oe.prototype.precompute=function(e){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,e),t.beta=this._getBeta(),this.precomputed=t,this};Oe.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return t?t.points.length>=Math.ceil((e.bitLength()+1)/t.step):!1};Oe.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s<t;s+=e){for(var o=0;o<e;o++)n=n.dbl();i.push(n)}return{step:e,points:i}};Oe.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],i=(1<<e)-1,n=i===1?null:this.dbl(),s=1;s<i;s++)t[s]=t[s-1].add(n);return{wnd:e,points:t}};Oe.prototype._getBeta=function(){return null};Oe.prototype.dblp=function(e){for(var t=this,i=0;i<e;i++)t=t.dbl();return t};var jn=tr(function(r){typeof Object.create=="function"?r.exports=function(t,i){i&&(t.super_=i,t.prototype=Object.create(i.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:r.exports=function(t,i){if(i){t.super_=i;var n=function(){};n.prototype=i.prototype,t.prototype=new n,t.prototype.constructor=t}}}),Vf=Se.assert;function $e(r){$t.call(this,"short",r),this.a=new L(r.a,16).toRed(this.red),this.b=new L(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}jn($e,$t);var Wf=$e;$e.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,i;if(e.beta)t=new L(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=n[0].cmp(n[1])<0?n[0]:n[1],t=t.toRed(this.red)}if(e.lambda)i=new L(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))===0?i=s[0]:(i=s[1],Vf(this.g.mul(i).x.cmp(this.g.x.redMul(t))===0))}var o;return e.basis?o=e.basis.map(function(a){return{a:new L(a.a,16),b:new L(a.b,16)}}):o=this._getEndoBasis(i),{beta:t,lambda:i,basis:o}}};$e.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:L.mont(e),i=new L(2).toRed(t).redInvm(),n=i.redNeg(),s=new L(3).toRed(t).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),a=n.redSub(s).fromRed();return[o,a]};$e.prototype._getEndoBasis=function(e){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new L(1),o=new L(0),a=new L(0),c=new L(1),l,u,h,p,d,f,g,y=0,m,v;i.cmpn(0)!==0;){var _=n.div(i);m=n.sub(_.mul(i)),v=a.sub(_.mul(s));var w=c.sub(_.mul(o));if(!h&&m.cmp(t)<0)l=g.neg(),u=s,h=m.neg(),p=v;else if(h&&++y===2)break;g=m,n=i,i=m,a=s,s=v,c=o,o=w}d=m.neg(),f=v;var b=h.sqr().add(p.sqr()),E=d.sqr().add(f.sqr());return E.cmp(b)>=0&&(d=l,f=u),h.negative&&(h=h.neg(),p=p.neg()),d.negative&&(d=d.neg(),f=f.neg()),[{a:h,b:p},{a:d,b:f}]};$e.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),a=s.mul(i.a),c=o.mul(n.a),l=s.mul(i.b),u=o.mul(n.b),h=e.sub(a).sub(c),p=l.add(u).neg();return{k1:h,k2:p}};$e.prototype.pointFromX=function(e,t){e=new L(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)};$e.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0};$e.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o<e.length;o++){var a=this._endoSplit(t[o]),c=e[o],l=c._getBeta();a.k1.negative&&(a.k1.ineg(),c=c.neg(!0)),a.k2.negative&&(a.k2.ineg(),l=l.neg(!0)),n[o*2]=c,n[o*2+1]=l,s[o*2]=a.k1,s[o*2+1]=a.k2}for(var u=this._wnafMulAdd(1,n,s,o*2,i),h=0;h<o*2;h++)n[h]=null,s[h]=null;return u};function se(r,e,t,i){$t.BasePoint.call(this,r,"affine"),e===null&&t===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new L(e,16),this.y=new L(t,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}jn(se,$t.BasePoint);$e.prototype.point=function(e,t,i){return new se(this,e,t,i)};$e.prototype.pointFromJSON=function(e,t){return se.fromJSON(this,e,t)};se.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var i=this.curve,n=function(s){return i.point(s.x.redMul(i.endo.beta),s.y)};e.beta=t,t.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(n)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(n)}}}return t}};se.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]};se.fromJSON=function(e,t,i){typeof t=="string"&&(t=JSON.parse(t));var n=e.point(t[0],t[1],i);if(!t[2])return n;function s(a){return e.point(a[0],a[1],i)}var o=t[2];return n.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[n].concat(o.doubles.points.map(s))},naf:o.naf&&{wnd:o.naf.wnd,points:[n].concat(o.naf.points.map(s))}},n};se.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"};se.prototype.isInfinity=function(){return this.inf};se.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};se.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),a=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)};se.prototype.getX=function(){return this.x.fromRed()};se.prototype.getY=function(){return this.y.fromRed()};se.prototype.mul=function(e){return e=new L(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};se.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)};se.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)};se.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};se.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};se.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function ae(r,e,t,i){$t.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new L(0)):(this.x=new L(e,16),this.y=new L(t,16),this.z=new L(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}jn(ae,$t.BasePoint);$e.prototype.jpoint=function(e,t,i){return new ae(this,e,t,i)};ae.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};ae.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};ae.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(i.redMul(this.z)),c=n.redSub(s),l=o.redSub(a);if(c.cmpn(0)===0)return l.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=c.redSqr(),h=u.redMul(c),p=n.redMul(u),d=l.redSqr().redIAdd(h).redISub(p).redISub(p),f=l.redMul(p.redISub(d)).redISub(o.redMul(h)),g=this.z.redMul(e.z).redMul(c);return this.curve.jpoint(d,f,g)};ae.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),a=i.redSub(n),c=s.redSub(o);if(a.cmpn(0)===0)return c.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var l=a.redSqr(),u=l.redMul(a),h=i.redMul(l),p=c.redSqr().redIAdd(u).redISub(h).redISub(h),d=c.redMul(h.redISub(p)).redISub(s.redMul(u)),f=this.z.redMul(a);return this.curve.jpoint(p,d,f)};ae.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t<e;t++)i=i.dbl();return i}var n=this.curve.a,s=this.curve.tinv,o=this.x,a=this.y,c=this.z,l=c.redSqr().redSqr(),u=a.redAdd(a);for(t=0;t<e;t++){var h=o.redSqr(),p=u.redSqr(),d=p.redSqr(),f=h.redAdd(h).redIAdd(h).redIAdd(n.redMul(l)),g=o.redMul(p),y=f.redSqr().redISub(g.redAdd(g)),m=g.redISub(y),v=f.redMul(m);v=v.redIAdd(v).redISub(d);var _=u.redMul(c);t+1<e&&(l=l.redMul(d)),o=y,c=_,u=v}return this.curve.jpoint(o,u.redMul(s),c)};ae.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()};ae.prototype._zeroDbl=function(){var e,t,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),a=this.x.redAdd(s).redSqr().redISub(n).redISub(o);a=a.redIAdd(a);var c=n.redAdd(n).redIAdd(n),l=c.redSqr().redISub(a).redISub(a),u=o.redIAdd(o);u=u.redIAdd(u),u=u.redIAdd(u),e=l,t=c.redMul(a.redISub(l)).redISub(u),i=this.y.redAdd(this.y)}else{var h=this.x.redSqr(),p=this.y.redSqr(),d=p.redSqr(),f=this.x.redAdd(p).redSqr().redISub(h).redISub(d);f=f.redIAdd(f);var g=h.redAdd(h).redIAdd(h),y=g.redSqr(),m=d.redIAdd(d);m=m.redIAdd(m),m=m.redIAdd(m),e=y.redISub(f).redISub(f),t=g.redMul(f.redISub(e)).redISub(m),i=this.y.redMul(this.z),i=i.redIAdd(i)}return this.curve.jpoint(e,t,i)};ae.prototype._threeDbl=function(){var e,t,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),a=this.x.redAdd(s).redSqr().redISub(n).redISub(o);a=a.redIAdd(a);var c=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),l=c.redSqr().redISub(a).redISub(a);e=l;var u=o.redIAdd(o);u=u.redIAdd(u),u=u.redIAdd(u),t=c.redMul(a.redISub(l)).redISub(u),i=this.y.redAdd(this.y)}else{var h=this.z.redSqr(),p=this.y.redSqr(),d=this.x.redMul(p),f=this.x.redSub(h).redMul(this.x.redAdd(h));f=f.redAdd(f).redIAdd(f);var g=d.redIAdd(d);g=g.redIAdd(g);var y=g.redAdd(g);e=f.redSqr().redISub(y),i=this.y.redAdd(this.z).redSqr().redISub(p).redISub(h);var m=p.redSqr();m=m.redIAdd(m),m=m.redIAdd(m),m=m.redIAdd(m),t=f.redMul(g.redISub(e)).redISub(m)}return this.curve.jpoint(e,t,i)};ae.prototype._dbl=function(){var e=this.curve.a,t=this.x,i=this.y,n=this.z,s=n.redSqr().redSqr(),o=t.redSqr(),a=i.redSqr(),c=o.redAdd(o).redIAdd(o).redIAdd(e.redMul(s)),l=t.redAdd(t);l=l.redIAdd(l);var u=l.redMul(a),h=c.redSqr().redISub(u.redAdd(u)),p=u.redISub(h),d=a.redSqr();d=d.redIAdd(d),d=d.redIAdd(d),d=d.redIAdd(d);var f=c.redMul(p).redISub(d),g=i.redAdd(i).redMul(n);return this.curve.jpoint(h,f,g)};ae.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr(),n=t.redSqr(),s=e.redAdd(e).redIAdd(e),o=s.redSqr(),a=this.x.redAdd(t).redSqr().redISub(e).redISub(n);a=a.redIAdd(a),a=a.redAdd(a).redIAdd(a),a=a.redISub(o);var c=a.redSqr(),l=n.redIAdd(n);l=l.redIAdd(l),l=l.redIAdd(l),l=l.redIAdd(l);var u=s.redIAdd(a).redSqr().redISub(o).redISub(c).redISub(l),h=t.redMul(u);h=h.redIAdd(h),h=h.redIAdd(h);var p=this.x.redMul(c).redISub(h);p=p.redIAdd(p),p=p.redIAdd(p);var d=this.y.redMul(u.redMul(l.redISub(u)).redISub(a.redMul(c)));d=d.redIAdd(d),d=d.redIAdd(d),d=d.redIAdd(d);var f=this.z.redAdd(a).redSqr().redISub(i).redISub(c);return this.curve.jpoint(p,d,f)};ae.prototype.mul=function(e,t){return e=new L(e,t),this.curve._wnafMul(this,e)};ae.prototype.eq=function(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var t=this.z.redSqr(),i=e.z.redSqr();if(this.x.redMul(i).redISub(e.x.redMul(t)).cmpn(0)!==0)return!1;var n=t.redMul(this.z),s=i.redMul(e.z);return this.y.redMul(s).redISub(e.y.redMul(n)).cmpn(0)===0};ae.prototype.eqXToP=function(e){var t=this.z.redSqr(),i=e.toRed(this.curve.red).redMul(t);if(this.x.cmp(i)===0)return!0;for(var n=e.clone(),s=this.curve.redN.redMul(t);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}};ae.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"};ae.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Ur=tr(function(r,e){var t=e;t.base=$t,t.short=Wf,t.mont=null,t.edwards=null}),Br=tr(function(r,e){var t=e,i=Se.assert;function n(a){a.type==="short"?this.curve=new Ur.short(a):a.type==="edwards"?this.curve=new Ur.edwards(a):this.curve=new Ur.mont(a),this.g=this.curve.g,this.n=this.curve.n,this.hash=a.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}t.PresetCurve=n;function s(a,c){Object.defineProperty(t,a,{configurable:!0,enumerable:!0,get:function(){var l=new n(c);return Object.defineProperty(t,a,{configurable:!0,enumerable:!0,value:l}),l}})}s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Ye.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Ye.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Ye.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Ye.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Ye.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Ye.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Ye.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var o;try{o=null.crash()}catch{o=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Ye.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function ft(r){if(!(this instanceof ft))return new ft(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Ue.toArray(r.entropy,r.entropyEnc||"hex"),t=Ue.toArray(r.nonce,r.nonceEnc||"hex"),i=Ue.toArray(r.pers,r.persEnc||"hex");Kn(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}var Bc=ft;ft.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s<this.V.length;s++)this.K[s]=0,this.V[s]=1;this._update(n),this._reseed=1,this.reseedInterval=281474976710656};ft.prototype._hmac=function(){return new Ye.hmac(this.hash,this.K)};ft.prototype._update=function(e){var t=this._hmac().update(this.V).update([0]);e&&(t=t.update(e)),this.K=t.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())};ft.prototype.reseed=function(e,t,i,n){typeof t!="string"&&(n=i,i=t,t=null),e=Ue.toArray(e,t),i=Ue.toArray(i,n),Kn(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1};ft.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=Ue.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length<e;)this.V=this._hmac().update(this.V).digest(),s=s.concat(this.V);var o=s.slice(0,e);return this._update(i),this._reseed++,Ue.encode(o,t)};var sn=Se.assert;function le(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var Vn=le;le.fromPublic=function(e,t,i){return t instanceof le?t:new le(e,{pub:t,pubEnc:i})};le.fromPrivate=function(e,t,i){return t instanceof le?t:new le(e,{priv:t,privEnc:i})};le.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}};le.prototype.getPublic=function(e,t){return typeof e=="string"&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub};le.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv};le.prototype._importPrivate=function(e,t){this.priv=new L(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)};le.prototype._importPublic=function(e,t){if(e.x||e.y){this.ec.curve.type==="mont"?sn(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&sn(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,t)};le.prototype.derive=function(e){return e.validate()||sn(e.validate(),"public point not validated"),e.mul(this.priv).getX()};le.prototype.sign=function(e,t,i){return this.ec.sign(e,this,t,i)};le.prototype.verify=function(e,t){return this.ec.verify(e,t,this)};le.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var Hf=Se.assert;function pi(r,e){if(r instanceof pi)return r;this._importDER(r,e)||(Hf(r.r&&r.s,"Signature without r or s"),this.r=new L(r.r,16),this.s=new L(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var gi=pi;function Jf(){this.place=0}function Oi(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4)return!1;for(var n=0,s=0,o=e.place;s<i;s++,o++)n<<=8,n|=r[o],n>>>=0;return n<=127?!1:(e.place=o,n)}function Us(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e<t;)e++;return e===0?r:r.slice(e)}pi.prototype._importDER=function(e,t){e=Se.toArray(e,t);var i=new Jf;if(e[i.place++]!==48)return!1;var n=Oi(e,i);if(n===!1||n+i.place!==e.length||e[i.place++]!==2)return!1;var s=Oi(e,i);if(s===!1)return!1;var o=e.slice(i.place,s+i.place);if(i.place+=s,e[i.place++]!==2)return!1;var a=Oi(e,i);if(a===!1||e.length!==a+i.place)return!1;var c=e.slice(i.place,a+i.place);if(o[0]===0)if(o[1]&128)o=o.slice(1);else return!1;if(c[0]===0)if(c[1]&128)c=c.slice(1);else return!1;return this.r=new L(o),this.s=new L(c),this.recoveryParam=null,!0};function $i(r,e){if(e<128){r.push(e);return}var t=1+(Math.log(e)/Math.LN2>>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}pi.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=Us(t),i=Us(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];$i(n,t.length),n=n.concat(t),n.push(2),$i(n,i.length);var s=n.concat(i),o=[48];return $i(o,s.length),o=o.concat(s),Se.encode(o,e)};var Gf=function(){throw new Error("unsupported")},zc=Se.assert;function Ne(r){if(!(this instanceof Ne))return new Ne(r);typeof r=="string"&&(zc(Object.prototype.hasOwnProperty.call(Br,r),"Unknown curve "+r),r=Br[r]),r instanceof Br.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var Yf=Ne;Ne.prototype.keyPair=function(e){return new Vn(this,e)};Ne.prototype.keyFromPrivate=function(e,t){return Vn.fromPrivate(this,e,t)};Ne.prototype.keyFromPublic=function(e,t){return Vn.fromPublic(this,e,t)};Ne.prototype.genKeyPair=function(e){e||(e={});for(var t=new Bc({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||Gf(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new L(2));;){var s=new L(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}};Ne.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};Ne.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new L(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),a=e.toArray("be",s),c=new Bc({hash:this.hash,entropy:o,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),l=this.n.sub(new L(1)),u=0;;u++){var h=n.k?n.k(u):new L(c.generate(this.n.byteLength()));if(h=this._truncateToN(h,!0),!(h.cmpn(1)<=0||h.cmp(l)>=0)){var p=this.g.mul(h);if(!p.isInfinity()){var d=p.getX(),f=d.umod(this.n);if(f.cmpn(0)!==0){var g=h.invm(this.n).mul(f.mul(t.getPrivate()).iadd(e));if(g=g.umod(this.n),g.cmpn(0)!==0){var y=(p.getY().isOdd()?1:0)|(d.cmp(f)!==0?2:0);return n.canonical&&g.cmp(this.nh)>0&&(g=this.n.sub(g),y^=1),new gi({r:f,s:g,recoveryParam:y})}}}}}};Ne.prototype.verify=function(e,t,i,n){e=this._truncateToN(new L(e,16)),i=this.keyFromPublic(i,n),t=new gi(t,"hex");var s=t.r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a=o.invm(this.n),c=a.mul(e).umod(this.n),l=a.mul(s).umod(this.n),u;return this.curve._maxwellTrick?(u=this.g.jmulAdd(c,i.getPublic(),l),u.isInfinity()?!1:u.eqXToP(s)):(u=this.g.mulAdd(c,i.getPublic(),l),u.isInfinity()?!1:u.getX().umod(this.n).cmp(s)===0)};Ne.prototype.recoverPubKey=function(r,e,t,i){zc((3&t)===t,"The recovery param is more than two bits"),e=new gi(e,i);var n=this.n,s=new L(r),o=e.r,a=e.s,c=t&1,l=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");l?o=this.curve.pointFromX(o.add(this.curve.n),c):o=this.curve.pointFromX(o,c);var u=e.r.invm(n),h=n.sub(s).mul(u).umod(n),p=a.mul(u).umod(n);return this.g.mulAdd(h,o,p)};Ne.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new gi(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")};var Qf=tr(function(r,e){var t=e;t.version="6.5.4",t.utils=Se,t.rand=function(){throw new Error("unsupported")},t.curve=Ur,t.curves=Br,t.ec=Yf,t.eddsa=null}),Xf=Qf.ec;const Zf="signing-key/5.7.0",on=new cu(Zf);let ki=null;function ot(){return ki||(ki=new Xf("secp256k1")),ki}class ep{constructor(e){nr(this,"curve","secp256k1"),nr(this,"privateKey",ua(e)),lu(this.privateKey)!==32&&on.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const t=ot().keyFromPrivate(Re(this.privateKey));nr(this,"publicKey","0x"+t.getPublic(!1,"hex")),nr(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),nr(this,"_isSigningKey",!0)}_addPoint(e){const t=ot().keyFromPublic(Re(this.publicKey)),i=ot().keyFromPublic(Re(e));return"0x"+t.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){const t=ot().keyFromPrivate(Re(this.privateKey)),i=Re(e);i.length!==32&&on.throwArgumentError("bad digest length","digest",e);const n=t.sign(i,{canonical:!0});return la({recoveryParam:n.recoveryParam,r:Ii("0x"+n.r.toString(16),32),s:Ii("0x"+n.s.toString(16),32)})}computeSharedSecret(e){const t=ot().keyFromPrivate(Re(this.privateKey)),i=ot().keyFromPublic(Re(Kc(e)));return Ii("0x"+t.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}}function tp(r,e){const t=la(e),i={r:Re(t.r),s:Re(t.s)};return"0x"+ot().recoverPubKey(Re(r),i,t.recoveryParam).encode("hex",!1)}function Kc(r,e){const t=Re(r);return t.length===32?new ep(t).publicKey:t.length===33?"0x"+ot().keyFromPublic(t).getPublic(!1,"hex"):t.length===65?ua(t):on.throwArgumentError("invalid public or private key","key","[REDACTED]")}var Bs;(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(Bs||(Bs={}));function rp(r){const e=Kc(r);return uu(os(hu(os(e,1)),12))}function ip(r,e){return rp(tp(Re(r),e))}var np={};const jc=":";function zr(r){const[e,t]=r.split(jc);return{namespace:e,reference:t}}function sp(r){const[e,t,i]=r.split(jc);return{namespace:e,reference:t,address:i}}function Vc(r,e){return r.includes(":")?[r]:e.chains||[]}const op="ReactNative",_e={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},ap="js";function Zr(){return typeof R.process<"u"&&typeof R.process.versions<"u"&&typeof R.process.versions.node<"u"}function mt(){return!fi()&&!!Bn()&&navigator.product===op}function cp(){return mt()&&typeof R.global<"u"&&typeof(R.global==null?void 0:R.global.Platform)<"u"&&(R.global==null?void 0:R.global.Platform.OS)==="android"}function lp(){return mt()&&typeof R.global<"u"&&typeof(R.global==null?void 0:R.global.Platform)<"u"&&(R.global==null?void 0:R.global.Platform.OS)==="ios"}function Ar(){return!Zr()&&!!Bn()&&!!fi()}function Tr(){return mt()?_e.reactNative:Zr()?_e.node:Ar()?_e.browser:_e.unknown}function zs(){var r;try{return mt()&&typeof R.global<"u"&&typeof(R.global==null?void 0:R.global.Application)<"u"?(r=R.global.Application)==null?void 0:r.applicationId:void 0}catch{return}}function up(r,e){const t=new URLSearchParams(r);for(const i of Object.keys(e).sort())if(e.hasOwnProperty(i)){const n=e[i];n!==void 0&&t.set(i,n)}return t.toString()}function Wc(){return qc()||{name:"",description:"",url:"",icons:[""]}}function hp(){if(Tr()===_e.reactNative&&typeof R.global<"u"&&typeof(R.global==null?void 0:R.global.Platform)<"u"){const{OS:t,Version:i}=R.global.Platform;return[t,i].join("-")}const r=Zl();if(r===null)return"unknown";const e=r.os?r.os.replace(" ","").toLowerCase():"unknown";return r.type==="browser"?[e,r.name,r.version].join("-"):[e,r.version].join("-")}function dp(){var r;const e=Tr();return e===_e.browser?[e,((r=Fc())==null?void 0:r.host)||"unknown"].join(":"):e}function Hc(r,e,t){const i=hp(),n=dp();return[[r,e].join("-"),[ap,t].join("-"),i,n].join("/")}function fp({protocol:r,version:e,relayUrl:t,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:a,packageName:c}){const l=t.split("?"),u=Hc(r,e,i),h={auth:n,ua:u,projectId:s,useOnCloseEvent:o,packageName:c||void 0,bundleId:a||void 0},p=up(l[1]||"",h);return l[0]+"?"+p}function Pt(r,e){return r.filter(t=>e.includes(t)).length===r.length}function Jc(r){return Object.fromEntries(r.entries())}function Gc(r){return new Map(Object.entries(r))}function bt(r=I.FIVE_MINUTES,e){const t=I.toMiliseconds(r||I.FIVE_MINUTES);let i,n,s,o;return{resolve:a=>{s&&i&&(clearTimeout(s),i(a),o=Promise.resolve(a))},reject:a=>{s&&n&&(clearTimeout(s),n(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);s=setTimeout(()=>{const l=new Error(e);o=Promise.reject(l),c(l)},t),i=a,n=c})}}function lt(r,e,t){return new Promise(async(i,n)=>{const s=setTimeout(()=>n(new Error(t)),e);try{const o=await r;i(o)}catch(o){n(o)}clearTimeout(s)})}function Yc(r,e){if(typeof e=="string"&&e.startsWith(`${r}:`))return e;if(r.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(r.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${r}`)}function pp(r){return Yc("topic",r)}function gp(r){return Yc("id",r)}function Qc(r){const[e,t]=r.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function re(r,e){return I.fromMiliseconds(Date.now()+I.toMiliseconds(r))}function at(r){return Date.now()>=I.toMiliseconds(r)}function U(r,e){return`${r}${e?`:${e}`:""}`}function yp(r=[],e=[]){return[...new Set([...r,...e])]}async function mp({id:r,topic:e,wcDeepLink:t}){var i;try{if(!t)return;const n=typeof t=="string"?JSON.parse(t):t,s=n==null?void 0:n.href;if(typeof s!="string")return;const o=vp(s,r,e),a=Tr();if(a===_e.browser){if(!((i=fi())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}wp(o)}else a===_e.reactNative&&typeof(R.global==null?void 0:R.global.Linking)<"u"&&await R.global.Linking.openURL(o)}catch(n){console.error(n)}}function vp(r,e,t){const i=`requestId=${e}&sessionTopic=${t}`;r.endsWith("/")&&(r=r.slice(0,-1));let n=`${r}`;if(r.startsWith("https://t.me")){const s=r.includes("?")?"&startapp=":"?startapp=";n=`${n}${s}${Sp(i,!0)}`}else n=`${n}/wc?${i}`;return n}function wp(r){let e="_self";Ep()?e="_top":(bp()||r.startsWith("https://")||r.startsWith("http://"))&&(e="_blank"),window.open(r,e,"noreferrer noopener")}async function _p(r,e){let t="";try{if(Ar()&&(t=localStorage.getItem(e),t))return t;t=await r.getItem(e)}catch(i){console.error(i)}return t}function Ks(r,e){if(!r.includes(e))return null;const t=r.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function js(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,r=>{const e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function Wn(){return typeof R.process<"u"&&np.IS_VITEST==="true"}function bp(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function Ep(){try{return window.self!==window.top}catch{return!1}}function Sp(r,e=!1){const t=R.Buffer.from(r).toString("base64");return e?t.replace(/[=]/g,""):t}function Xc(r){return R.Buffer.from(r,"base64").toString("utf-8")}function Ip(r){return new Promise(e=>setTimeout(e,r))}function br(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function xp(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function yi(r,...e){if(!xp(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error("Uint8Array expected of length "+e+", got length="+r.length)}function Hn(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");br(r.outputLen),br(r.blockLen)}function Ht(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function Zc(r,e){yi(r);const t=e.outputLen;if(r.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const Mr=BigInt(2**32-1),Vs=BigInt(32);function Pp(r,e=!1){return e?{h:Number(r&Mr),l:Number(r>>Vs&Mr)}:{h:Number(r>>Vs&Mr)|0,l:Number(r&Mr)|0}}function Ap(r,e=!1){let t=new Uint32Array(r.length),i=new Uint32Array(r.length);for(let n=0;n<r.length;n++){const{h:s,l:o}=Pp(r[n],e);[t[n],i[n]]=[s,o]}return[t,i]}const Tp=(r,e,t)=>r<<t|e>>>32-t,Rp=(r,e,t)=>e<<t|r>>>32-t,Cp=(r,e,t)=>e<<t-32|r>>>64-t,Np=(r,e,t)=>r<<t-32|e>>>64-t,Lt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Op(r){return new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4))}function Mi(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Ke(r,e){return r<<32-e|r>>>e}const Ws=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function $p(r){return r<<24&4278190080|r<<8&16711680|r>>>8&65280|r>>>24&255}function Hs(r){for(let e=0;e<r.length;e++)r[e]=$p(r[e])}function kp(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function Jt(r){return typeof r=="string"&&(r=kp(r)),yi(r),r}let Jn=class{clone(){return this._cloneInto()}};function el(r){const e=i=>r().update(Jt(i)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Rr(r=32){if(Lt&&typeof Lt.getRandomValues=="function")return Lt.getRandomValues(new Uint8Array(r));if(Lt&&typeof Lt.randomBytes=="function")return Lt.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}const tl=[],rl=[],il=[],Mp=BigInt(0),sr=BigInt(1),Lp=BigInt(2),Dp=BigInt(7),Fp=BigInt(256),qp=BigInt(113);for(let r=0,e=sr,t=1,i=0;r<24;r++){[t,i]=[i,(2*t+3*i)%5],tl.push(2*(5*i+t)),rl.push((r+1)*(r+2)/2%64);let n=Mp;for(let s=0;s<7;s++)e=(e<<sr^(e>>Dp)*qp)%Fp,e&Lp&&(n^=sr<<(sr<<BigInt(s))-sr);il.push(n)}const[Up,Bp]=Ap(il,!0),Js=(r,e,t)=>t>32?Cp(r,e,t):Tp(r,e,t),Gs=(r,e,t)=>t>32?Np(r,e,t):Rp(r,e,t);function zp(r,e=24){const t=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)t[o]=r[o]^r[o+10]^r[o+20]^r[o+30]^r[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=t[c],u=t[c+1],h=Js(l,u,1)^t[a],p=Gs(l,u,1)^t[a+1];for(let d=0;d<50;d+=10)r[o+d]^=h,r[o+d+1]^=p}let n=r[2],s=r[3];for(let o=0;o<24;o++){const a=rl[o],c=Js(n,s,a),l=Gs(n,s,a),u=tl[o];n=r[u],s=r[u+1],r[u]=c,r[u+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=r[o+a];for(let a=0;a<10;a++)r[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}r[0]^=Up[i],r[1]^=Bp[i]}t.fill(0)}let Kp=class nl extends Jn{constructor(e,t,i,n=!1,s=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=n,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,br(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Op(this.state)}keccak(){Ws||Hs(this.state32),zp(this.state32,this.rounds),Ws||Hs(this.state32),this.posOut=0,this.pos=0}update(e){Ht(this);const{blockLen:t,state:i}=this;e=Jt(e);const n=e.length;for(let s=0;s<n;){const o=Math.min(t-this.pos,n-s);for(let a=0;a<o;a++)i[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:i,blockLen:n}=this;e[i]^=t,t&128&&i===n-1&&this.keccak(),e[n-1]^=128,this.keccak()}writeInto(e){Ht(this,!1),yi(e),this.finish();const t=this.state,{blockLen:i}=this;for(let n=0,s=e.length;n<s;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,s-n);e.set(t.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return br(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Zc(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:i,outputLen:n,rounds:s,enableXOF:o}=this;return e||(e=new nl(t,i,n,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=i,e.outputLen=n,e.enableXOF=o,e.destroyed=this.destroyed,e}};const jp=(r,e,t)=>el(()=>new Kp(e,r,t)),Vp=jp(1,136,256/8),Wp="https://rpc.walletconnect.org/v1";function sl(r){const e=`Ethereum Signed Message:
|
|
523
|
+
${r.length}`,t=new TextEncoder().encode(e+r);return"0x"+R.Buffer.from(Vp(t)).toString("hex")}async function Hp(r,e,t,i,n,s){switch(t.t){case"eip191":return Jp(r,e,t.s);case"eip1271":return await Gp(r,e,t.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}function Jp(r,e,t){return ip(sl(e),t).toLowerCase()===r.toLowerCase()}async function Gp(r,e,t,i,n,s){const o=zr(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{const a="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",l="0000000000000000000000000000000000000000000000000000000000000041",u=t.substring(2),h=sl(e).substring(2),p=a+h+c+l+u,d=await fetch(`${s||Wp}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:Yp(),jsonrpc:"2.0",method:"eth_call",params:[{to:r,data:p},"latest"]})}),{result:f}=await d.json();return f?f.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function Yp(){return Date.now()+Math.floor(Math.random()*1e3)}var Qp=Object.defineProperty,Xp=Object.defineProperties,Zp=Object.getOwnPropertyDescriptors,Ys=Object.getOwnPropertySymbols,eg=Object.prototype.hasOwnProperty,tg=Object.prototype.propertyIsEnumerable,Qs=(r,e,t)=>e in r?Qp(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,rg=(r,e)=>{for(var t in e||(e={}))eg.call(e,t)&&Qs(r,t,e[t]);if(Ys)for(var t of Ys(e))tg.call(e,t)&&Qs(r,t,e[t]);return r},ig=(r,e)=>Xp(r,Zp(e));const ng="did:pkh:",Gn=r=>r==null?void 0:r.split(":"),sg=r=>{const e=r&&Gn(r);if(e)return r.includes(ng)?e[3]:e[1]},an=r=>{const e=r&&Gn(r);if(e)return e[2]+":"+e[3]},ei=r=>{const e=r&&Gn(r);if(e)return e.pop()};async function Xs(r){const{cacao:e,projectId:t}=r,{s:i,p:n}=e,s=ol(n,n.iss),o=ei(n.iss);return await Hp(o,s,i,an(n.iss),t)}const ol=(r,e)=>{const t=`${r.domain} wants you to sign in with your Ethereum account:`,i=ei(e);if(!r.aud&&!r.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=r.statement||void 0;const s=`URI: ${r.aud||r.uri}`,o=`Version: ${r.version}`,a=`Chain ID: ${sg(e)}`,c=`Nonce: ${r.nonce}`,l=`Issued At: ${r.iat}`,u=r.exp?`Expiration Time: ${r.exp}`:void 0,h=r.nbf?`Not Before: ${r.nbf}`:void 0,p=r.requestId?`Request ID: ${r.requestId}`:void 0,d=r.resources?`Resources:${r.resources.map(g=>`
|
|
524
|
+
- ${g}`).join("")}`:void 0,f=Kr(r.resources);if(f){const g=Er(f);n=pg(n,g)}return[t,i,"",n,"",s,o,a,c,l,u,h,p,d].filter(g=>g!=null).join(`
|
|
525
|
+
`)};function og(r){return R.Buffer.from(JSON.stringify(r)).toString("base64")}function ag(r){return JSON.parse(R.Buffer.from(r,"base64").toString("utf-8"))}function At(r){if(!r)throw new Error("No recap provided, value is undefined");if(!r.att)throw new Error("No `att` property found");const e=Object.keys(r.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(t=>{const i=r.att[t];if(Array.isArray(i))throw new Error(`Resource must be an object: ${t}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(i).forEach(n=>{const s=i[n];if(!Array.isArray(s))throw new Error(`Ability limits ${n} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${n} is empty array, must be an array with objects`);s.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${n}) must be an array of objects, found: ${o}`)})})})}function cg(r,e,t,i={}){return t==null||t.sort((n,s)=>n.localeCompare(s)),{att:{[r]:lg(e,t,i)}}}function lg(r,e,t={}){e=e==null?void 0:e.sort((n,s)=>n.localeCompare(s));const i=e.map(n=>({[`${r}/${n}`]:[t]}));return Object.assign({},...i)}function al(r){return At(r),`urn:recap:${og(r).replace(/=/g,"")}`}function Er(r){const e=ag(r.replace("urn:recap:",""));return At(e),e}function ug(r,e,t){const i=cg(r,e,t);return al(i)}function hg(r){return r&&r.includes("urn:recap:")}function dg(r,e){const t=Er(r),i=Er(e),n=fg(t,i);return al(n)}function fg(r,e){At(r),At(e);const t=Object.keys(r.att).concat(Object.keys(e.att)).sort((n,s)=>n.localeCompare(s)),i={att:{}};return t.forEach(n=>{var s,o;Object.keys(((s=r.att)==null?void 0:s[n])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[n])||{})).sort((a,c)=>a.localeCompare(c)).forEach(a=>{var c,l;i.att[n]=ig(rg({},i.att[n]),{[a]:((c=r.att[n])==null?void 0:c[a])||((l=e.att[n])==null?void 0:l[a])})})}),i}function pg(r="",e){At(e);const t="I further authorize the stated URI to perform the following actions on my behalf: ";if(r.includes(t))return r;const i=[];let n=0;Object.keys(e.att).forEach(a=>{const c=Object.keys(e.att[a]).map(h=>({ability:h.split("/")[0],action:h.split("/")[1]}));c.sort((h,p)=>h.action.localeCompare(p.action));const l={};c.forEach(h=>{l[h.ability]||(l[h.ability]=[]),l[h.ability].push(h.action)});const u=Object.keys(l).map(h=>(n++,`(${n}) '${h}': '${l[h].join("', '")}' for '${a}'.`));i.push(u.join(", ").replace(".,","."))});const s=i.join(" "),o=`${t}${s}`;return`${r?r+" ":""}${o}`}function Zs(r){var e;const t=Er(r);At(t);const i=(e=t.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function eo(r){const e=Er(r);At(e);const t=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(n=>{var s;(s=n==null?void 0:n[0])!=null&&s.chains&&t.push(n[0].chains)})}),[...new Set(t.flat())]}function Kr(r){if(!r)return;const e=r==null?void 0:r[r.length-1];return hg(e)?e:void 0}function Li(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function cl(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function we(r,...e){if(!cl(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error("Uint8Array expected of length "+e+", got length="+r.length)}function to(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function gg(r,e){we(r);const t=e.outputLen;if(r.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}function ro(r){if(typeof r!="boolean")throw new Error(`boolean expected, not ${r}`)}const dt=r=>new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4)),yg=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),mg=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!mg)throw new Error("Non little-endian hardware is not supported");function vg(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function cn(r){if(typeof r=="string")r=vg(r);else if(cl(r))r=ln(r);else throw new Error("Uint8Array expected, got "+typeof r);return r}function wg(r,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(r,e)}function _g(r,e){if(r.length!==e.length)return!1;let t=0;for(let i=0;i<r.length;i++)t|=r[i]^e[i];return t===0}const bg=(r,e)=>{function t(i,...n){if(we(i),r.nonceLength!==void 0){const l=n[0];if(!l)throw new Error("nonce / iv required");r.varSizeNonce?we(l):we(l,r.nonceLength)}const s=r.tagLength;s&&n[1]!==void 0&&we(n[1]);const o=e(i,...n),a=(l,u)=>{if(u!==void 0){if(l!==2)throw new Error("cipher output not supported");we(u)}};let c=!1;return{encrypt(l,u){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,we(l),a(o.encrypt.length,u),o.encrypt(l,u)},decrypt(l,u){if(we(l),s&&l.length<s)throw new Error("invalid ciphertext length: smaller than tagLength="+s);return a(o.decrypt.length,u),o.decrypt(l,u)}}}return Object.assign(t,r),t};function io(r,e,t=!0){if(e===void 0)return new Uint8Array(r);if(e.length!==r)throw new Error("invalid output length, expected "+r+", got: "+e.length);if(t&&!Eg(e))throw new Error("invalid output, must be aligned");return e}function no(r,e,t,i){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,i);const n=BigInt(32),s=BigInt(4294967295),o=Number(t>>n&s),a=Number(t&s);r.setUint32(e+4,o,i),r.setUint32(e+0,a,i)}function Eg(r){return r.byteOffset%4===0}function ln(r){return Uint8Array.from(r)}function Gt(...r){for(let e=0;e<r.length;e++)r[e].fill(0)}const ll=r=>Uint8Array.from(r.split("").map(e=>e.charCodeAt(0))),Sg=ll("expand 16-byte k"),Ig=ll("expand 32-byte k"),xg=dt(Sg),Pg=dt(Ig);function V(r,e){return r<<e|r>>>32-e}function un(r){return r.byteOffset%4===0}const Lr=64,Ag=16,ul=2**32-1,so=new Uint32Array;function Tg(r,e,t,i,n,s,o,a){const c=n.length,l=new Uint8Array(Lr),u=dt(l),h=un(n)&&un(s),p=h?dt(n):so,d=h?dt(s):so;for(let f=0;f<c;o++){if(r(e,t,i,u,o,a),o>=ul)throw new Error("arx: counter overflow");const g=Math.min(Lr,c-f);if(h&&g===Lr){const y=f/4;if(f%4!==0)throw new Error("arx: invalid block position");for(let m=0,v;m<Ag;m++)v=y+m,d[v]=p[v]^u[m];f+=Lr;continue}for(let y=0,m;y<g;y++)m=f+y,s[m]=n[m]^l[y];f+=g}}function Rg(r,e){const{allowShortKeys:t,extendNonceFn:i,counterLength:n,counterRight:s,rounds:o}=wg({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof r!="function")throw new Error("core must be a function");return Li(n),Li(o),ro(s),ro(t),(a,c,l,u,h=0)=>{we(a),we(c),we(l);const p=l.length;if(u===void 0&&(u=new Uint8Array(p)),we(u),Li(h),h<0||h>=ul)throw new Error("arx: counter overflow");if(u.length<p)throw new Error(`arx: output (${u.length}) is shorter than data (${p})`);const d=[];let f=a.length,g,y;if(f===32)d.push(g=ln(a)),y=Pg;else if(f===16&&t)g=new Uint8Array(32),g.set(a),g.set(a,16),y=xg,d.push(g);else throw new Error(`arx: invalid 32-byte key, got length=${f}`);un(c)||d.push(c=ln(c));const m=dt(g);if(i){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");i(y,m,dt(c.subarray(0,16)),m),c=c.subarray(16)}const v=16-n;if(v!==c.length)throw new Error(`arx: nonce must be ${v} or 16 bytes`);if(v!==12){const w=new Uint8Array(12);w.set(c,s?0:12-c.length),c=w,d.push(c)}const _=dt(c);return Tg(r,y,m,_,l,u,h,o),Gt(...d),u}}const oe=(r,e)=>r[e++]&255|(r[e++]&255)<<8;let Cg=class{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=cn(e),we(e,32);const t=oe(e,0),i=oe(e,2),n=oe(e,4),s=oe(e,6),o=oe(e,8),a=oe(e,10),c=oe(e,12),l=oe(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|i<<3)&8191,this.r[2]=(i>>>10|n<<6)&7939,this.r[3]=(n>>>7|s<<9)&8191,this.r[4]=(s>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>14|a<<2)&8191,this.r[7]=(a>>>11|c<<5)&8065,this.r[8]=(c>>>8|l<<8)&8191,this.r[9]=l>>>5&127;for(let u=0;u<8;u++)this.pad[u]=oe(e,16+2*u)}process(e,t,i=!1){const n=i?0:2048,{h:s,r:o}=this,a=o[0],c=o[1],l=o[2],u=o[3],h=o[4],p=o[5],d=o[6],f=o[7],g=o[8],y=o[9],m=oe(e,t+0),v=oe(e,t+2),_=oe(e,t+4),w=oe(e,t+6),b=oe(e,t+8),E=oe(e,t+10),S=oe(e,t+12),x=oe(e,t+14);let C=s[0]+(m&8191),N=s[1]+((m>>>13|v<<3)&8191),O=s[2]+((v>>>10|_<<6)&8191),D=s[3]+((_>>>7|w<<9)&8191),$=s[4]+((w>>>4|b<<12)&8191),q=s[5]+(b>>>1&8191),F=s[6]+((b>>>14|E<<2)&8191),B=s[7]+((E>>>11|S<<5)&8191),K=s[8]+((S>>>8|x<<8)&8191),M=s[9]+(x>>>5|n),A=0,j=A+C*a+N*(5*y)+O*(5*g)+D*(5*f)+$*(5*d);A=j>>>13,j&=8191,j+=q*(5*p)+F*(5*h)+B*(5*u)+K*(5*l)+M*(5*c),A+=j>>>13,j&=8191;let J=A+C*c+N*a+O*(5*y)+D*(5*g)+$*(5*f);A=J>>>13,J&=8191,J+=q*(5*d)+F*(5*p)+B*(5*h)+K*(5*u)+M*(5*l),A+=J>>>13,J&=8191;let W=A+C*l+N*c+O*a+D*(5*y)+$*(5*g);A=W>>>13,W&=8191,W+=q*(5*f)+F*(5*d)+B*(5*p)+K*(5*h)+M*(5*u),A+=W>>>13,W&=8191;let te=A+C*u+N*l+O*c+D*a+$*(5*y);A=te>>>13,te&=8191,te+=q*(5*g)+F*(5*f)+B*(5*d)+K*(5*p)+M*(5*h),A+=te>>>13,te&=8191;let me=A+C*h+N*u+O*l+D*c+$*a;A=me>>>13,me&=8191,me+=q*(5*y)+F*(5*g)+B*(5*f)+K*(5*d)+M*(5*p),A+=me>>>13,me&=8191;let Ie=A+C*p+N*h+O*u+D*l+$*c;A=Ie>>>13,Ie&=8191,Ie+=q*a+F*(5*y)+B*(5*g)+K*(5*f)+M*(5*d),A+=Ie>>>13,Ie&=8191;let xe=A+C*d+N*p+O*h+D*u+$*l;A=xe>>>13,xe&=8191,xe+=q*c+F*a+B*(5*y)+K*(5*g)+M*(5*f),A+=xe>>>13,xe&=8191;let ke=A+C*f+N*d+O*p+D*h+$*u;A=ke>>>13,ke&=8191,ke+=q*l+F*c+B*a+K*(5*y)+M*(5*g),A+=ke>>>13,ke&=8191;let Pe=A+C*g+N*f+O*d+D*p+$*h;A=Pe>>>13,Pe&=8191,Pe+=q*u+F*l+B*c+K*a+M*(5*y),A+=Pe>>>13,Pe&=8191;let ze=A+C*y+N*g+O*f+D*d+$*p;A=ze>>>13,ze&=8191,ze+=q*h+F*u+B*l+K*c+M*a,A+=ze>>>13,ze&=8191,A=(A<<2)+A|0,A=A+j|0,j=A&8191,A=A>>>13,J+=A,s[0]=j,s[1]=J,s[2]=W,s[3]=te,s[4]=me,s[5]=Ie,s[6]=xe,s[7]=ke,s[8]=Pe,s[9]=ze}finalize(){const{h:e,pad:t}=this,i=new Uint16Array(10);let n=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=n,n=e[a]>>>13,e[a]&=8191;e[0]+=n*5,n=e[0]>>>13,e[0]&=8191,e[1]+=n,n=e[1]>>>13,e[1]&=8191,e[2]+=n,i[0]=e[0]+5,n=i[0]>>>13,i[0]&=8191;for(let a=1;a<10;a++)i[a]=e[a]+n,n=i[a]>>>13,i[a]&=8191;i[9]-=8192;let s=(n^1)-1;for(let a=0;a<10;a++)i[a]&=s;s=~s;for(let a=0;a<10;a++)e[a]=e[a]&s|i[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let o=e[0]+t[0];e[0]=o&65535;for(let a=1;a<8;a++)o=(e[a]+t[a]|0)+(o>>>16)|0,e[a]=o&65535;Gt(i)}update(e){to(this);const{buffer:t,blockLen:i}=this;e=cn(e);const n=e.length;for(let s=0;s<n;){const o=Math.min(i-this.pos,n-s);if(o===i){for(;i<=n-s;s+=i)this.process(e,s);continue}t.set(e.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===i&&(this.process(t,0,!1),this.pos=0)}return this}destroy(){Gt(this.h,this.r,this.buffer,this.pad)}digestInto(e){to(this),gg(e,this),this.finished=!0;const{buffer:t,h:i}=this;let{pos:n}=this;if(n){for(t[n++]=1;n<16;n++)t[n]=0;this.process(t,0,!0)}this.finalize();let s=0;for(let o=0;o<8;o++)e[s++]=i[o]>>>0,e[s++]=i[o]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}};function Ng(r){const e=(i,n)=>r(n).update(cn(i)).digest(),t=r(new Uint8Array(32));return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=i=>r(i),e}const Og=Ng(r=>new Cg(r));function $g(r,e,t,i,n,s=20){let o=r[0],a=r[1],c=r[2],l=r[3],u=e[0],h=e[1],p=e[2],d=e[3],f=e[4],g=e[5],y=e[6],m=e[7],v=n,_=t[0],w=t[1],b=t[2],E=o,S=a,x=c,C=l,N=u,O=h,D=p,$=d,q=f,F=g,B=y,K=m,M=v,A=_,j=w,J=b;for(let te=0;te<s;te+=2)E=E+N|0,M=V(M^E,16),q=q+M|0,N=V(N^q,12),E=E+N|0,M=V(M^E,8),q=q+M|0,N=V(N^q,7),S=S+O|0,A=V(A^S,16),F=F+A|0,O=V(O^F,12),S=S+O|0,A=V(A^S,8),F=F+A|0,O=V(O^F,7),x=x+D|0,j=V(j^x,16),B=B+j|0,D=V(D^B,12),x=x+D|0,j=V(j^x,8),B=B+j|0,D=V(D^B,7),C=C+$|0,J=V(J^C,16),K=K+J|0,$=V($^K,12),C=C+$|0,J=V(J^C,8),K=K+J|0,$=V($^K,7),E=E+O|0,J=V(J^E,16),B=B+J|0,O=V(O^B,12),E=E+O|0,J=V(J^E,8),B=B+J|0,O=V(O^B,7),S=S+D|0,M=V(M^S,16),K=K+M|0,D=V(D^K,12),S=S+D|0,M=V(M^S,8),K=K+M|0,D=V(D^K,7),x=x+$|0,A=V(A^x,16),q=q+A|0,$=V($^q,12),x=x+$|0,A=V(A^x,8),q=q+A|0,$=V($^q,7),C=C+N|0,j=V(j^C,16),F=F+j|0,N=V(N^F,12),C=C+N|0,j=V(j^C,8),F=F+j|0,N=V(N^F,7);let W=0;i[W++]=o+E|0,i[W++]=a+S|0,i[W++]=c+x|0,i[W++]=l+C|0,i[W++]=u+N|0,i[W++]=h+O|0,i[W++]=p+D|0,i[W++]=d+$|0,i[W++]=f+q|0,i[W++]=g+F|0,i[W++]=y+B|0,i[W++]=m+K|0,i[W++]=v+M|0,i[W++]=_+A|0,i[W++]=w+j|0,i[W++]=b+J|0}const kg=Rg($g,{counterRight:!1,counterLength:4,allowShortKeys:!1}),Mg=new Uint8Array(16),oo=(r,e)=>{r.update(e);const t=e.length%16;t&&r.update(Mg.subarray(t))},Lg=new Uint8Array(32);function ao(r,e,t,i,n){const s=r(e,t,Lg),o=Og.create(s);n&&oo(o,n),oo(o,i);const a=new Uint8Array(16),c=yg(a);no(c,0,BigInt(n?n.length:0),!0),no(c,8,BigInt(i.length),!0),o.update(a);const l=o.digest();return Gt(s,a),l}const Dg=r=>(e,t,i)=>({encrypt(n,s){const o=n.length;s=io(o+16,s,!1),s.set(n);const a=s.subarray(0,-16);r(e,t,a,a,1);const c=ao(r,e,t,a,i);return s.set(c,o),Gt(c),s},decrypt(n,s){s=io(n.length-16,s,!1);const o=n.subarray(0,-16),a=n.subarray(-16),c=ao(r,e,t,o,i);if(!_g(a,c))throw new Error("invalid tag");return s.set(n.subarray(0,-16)),r(e,t,s,s,1),Gt(c),s}}),hl=bg({blockSize:64,nonceLength:12,tagLength:16},Dg(kg));class dl extends Jn{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Hn(e);const i=Jt(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,s=new Uint8Array(n);s.set(i.length>n?e.create().update(i).digest():i);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=e.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(e){return Ht(this),this.iHash.update(e),this}digestInto(e){Ht(this),yi(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:i,finished:n,destroyed:s,blockLen:o,outputLen:a}=this;return e=e,e.finished=n,e.destroyed=s,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=i._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Yn=(r,e,t)=>new dl(r,e).update(t).digest();Yn.create=(r,e)=>new dl(r,e);function Fg(r,e,t){return Hn(r),t===void 0&&(t=new Uint8Array(r.outputLen)),Yn(r,Jt(t),Jt(e))}const Di=new Uint8Array([0]),co=new Uint8Array;function qg(r,e,t,i=32){if(Hn(r),br(i),i>255*r.outputLen)throw new Error("Length should be <= 255*HashLen");const n=Math.ceil(i/r.outputLen);t===void 0&&(t=co);const s=new Uint8Array(n*r.outputLen),o=Yn.create(r,e),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let l=0;l<n;l++)Di[0]=l+1,a.update(l===0?co:c).update(t).update(Di).digestInto(c),s.set(c,r.outputLen*l),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),Di.fill(0),s.slice(0,i)}const Ug=(r,e,t,i,n)=>qg(r,Fg(r,e,t),i,n);function Bg(r,e,t,i){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,i);const n=BigInt(32),s=BigInt(4294967295),o=Number(t>>n&s),a=Number(t&s),c=i?4:0,l=i?0:4;r.setUint32(e+c,o,i),r.setUint32(e+l,a,i)}function zg(r,e,t){return r&e^~r&t}function Kg(r,e,t){return r&e^r&t^e&t}let jg=class extends Jn{constructor(e,t,i,n){super(),this.blockLen=e,this.outputLen=t,this.padOffset=i,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Mi(this.buffer)}update(e){Ht(this);const{view:t,buffer:i,blockLen:n}=this;e=Jt(e);const s=e.length;for(let o=0;o<s;){const a=Math.min(n-this.pos,s-o);if(a===n){const c=Mi(e);for(;n<=s-o;o+=n)this.process(c,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ht(this),Zc(e,this),this.finished=!0;const{buffer:t,view:i,blockLen:n,isLE:s}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(i,0),o=0);for(let h=o;h<n;h++)t[h]=0;Bg(i,n-8,BigInt(this.length*8),s),this.process(i,0);const a=Mi(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<l;h++)a.setUint32(4*h,u[h],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:i,length:n,finished:s,destroyed:o,pos:a}=this;return e.length=n,e.pos=a,e.finished=s,e.destroyed=o,n%t&&e.buffer.set(i),e}};const Vg=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),nt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),st=new Uint32Array(64);let Wg=class extends jg{constructor(){super(64,32,8,!1),this.A=nt[0]|0,this.B=nt[1]|0,this.C=nt[2]|0,this.D=nt[3]|0,this.E=nt[4]|0,this.F=nt[5]|0,this.G=nt[6]|0,this.H=nt[7]|0}get(){const{A:e,B:t,C:i,D:n,E:s,F:o,G:a,H:c}=this;return[e,t,i,n,s,o,a,c]}set(e,t,i,n,s,o,a,c){this.A=e|0,this.B=t|0,this.C=i|0,this.D=n|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,t){for(let h=0;h<16;h++,t+=4)st[h]=e.getUint32(t,!1);for(let h=16;h<64;h++){const p=st[h-15],d=st[h-2],f=Ke(p,7)^Ke(p,18)^p>>>3,g=Ke(d,17)^Ke(d,19)^d>>>10;st[h]=g+st[h-7]+f+st[h-16]|0}let{A:i,B:n,C:s,D:o,E:a,F:c,G:l,H:u}=this;for(let h=0;h<64;h++){const p=Ke(a,6)^Ke(a,11)^Ke(a,25),d=u+p+zg(a,c,l)+Vg[h]+st[h]|0,f=(Ke(i,2)^Ke(i,13)^Ke(i,22))+Kg(i,n,s)|0;u=l,l=c,c=a,a=o+d|0,o=s,s=n,n=i,i=d+f|0}i=i+this.A|0,n=n+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(i,n,s,o,a,c,l,u)}roundClean(){st.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const mi=el(()=>new Wg);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const fl=BigInt(0);function Qn(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function pl(r){if(!Qn(r))throw new Error("Uint8Array expected")}const Hg=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Jg(r){pl(r);let e="";for(let t=0;t<r.length;t++)e+=Hg[r[t]];return e}function Gg(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?fl:BigInt("0x"+r)}const Ge={_0:48,_9:57,A:65,F:70,a:97,f:102};function lo(r){if(r>=Ge._0&&r<=Ge._9)return r-Ge._0;if(r>=Ge.A&&r<=Ge.F)return r-(Ge.A-10);if(r>=Ge.a&&r<=Ge.f)return r-(Ge.a-10)}function gl(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);const e=r.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(t);for(let n=0,s=0;n<t;n++,s+=2){const o=lo(r.charCodeAt(s)),a=lo(r.charCodeAt(s+1));if(o===void 0||a===void 0){const c=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}i[n]=o*16+a}return i}function uo(r){return pl(r),Gg(Jg(Uint8Array.from(r).reverse()))}function Yg(r,e){return gl(r.toString(16).padStart(e*2,"0"))}function Qg(r,e){return Yg(r,e).reverse()}function ho(r,e,t){let i;if(typeof e=="string")try{i=gl(e)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(Qn(e))i=Uint8Array.from(e);else throw new Error(r+" must be hex string or Uint8Array");const n=i.length;if(typeof t=="number"&&n!==t)throw new Error(r+" of length "+t+" expected, got "+n);return i}const Fi=r=>typeof r=="bigint"&&fl<=r;function Xg(r,e,t){return Fi(r)&&Fi(e)&&Fi(t)&&e<=r&&r<t}function fo(r,e,t,i){if(!Xg(e,t,i))throw new Error("expected valid "+r+": "+t+" <= n < "+i+", got "+e)}const Zg={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||Qn(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function ey(r,e,t={}){const i=(n,s,o)=>{const a=Zg[s];if(typeof a!="function")throw new Error("invalid validator function");const c=r[n];if(!(o&&c===void 0)&&!a(c,r))throw new Error("param "+String(n)+" is invalid. Expected "+s+", got "+c)};for(const[n,s]of Object.entries(e))i(n,s,!1);for(const[n,s]of Object.entries(t))i(n,s,!0);return r}const Ut=BigInt(0),Dr=BigInt(1);function yl(r,e){const t=r%e;return t>=Ut?t:e+t}function ty(r,e,t){if(e<Ut)throw new Error("invalid exponent, negatives unsupported");if(t<=Ut)throw new Error("invalid modulus");if(t===Dr)return Ut;let i=Dr;for(;e>Ut;)e&Dr&&(i=i*r%t),r=r*r%t,e>>=Dr;return i}function Fe(r,e,t){let i=r;for(;e-- >Ut;)i*=i,i%=t;return i}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);const Dt=BigInt(0),qi=BigInt(1);function ry(r){return ey(r,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...r})}function iy(r){const e=ry(r),{P:t}=e,i=v=>yl(v,t),n=e.montgomeryBits,s=Math.ceil(n/8),o=e.nByteLength,a=e.adjustScalarBytes||(v=>v),c=e.powPminus2||(v=>ty(v,t-BigInt(2),t));function l(v,_,w){const b=i(v*(_-w));return _=i(_-b),w=i(w+b),[_,w]}const u=(e.a-BigInt(2))/BigInt(4);function h(v,_){fo("u",v,Dt,t),fo("scalar",_,Dt,t);const w=_,b=v;let E=qi,S=Dt,x=v,C=qi,N=Dt,O;for(let $=BigInt(n-1);$>=Dt;$--){const q=w>>$&qi;N^=q,O=l(N,E,x),E=O[0],x=O[1],O=l(N,S,C),S=O[0],C=O[1],N=q;const F=E+S,B=i(F*F),K=E-S,M=i(K*K),A=B-M,j=x+C,J=x-C,W=i(J*F),te=i(j*K),me=W+te,Ie=W-te;x=i(me*me),C=i(b*i(Ie*Ie)),E=i(B*M),S=i(A*(B+i(u*A)))}O=l(N,E,x),E=O[0],x=O[1],O=l(N,S,C),S=O[0],C=O[1];const D=c(S);return i(E*D)}function p(v){return Qg(i(v),s)}function d(v){const _=ho("u coordinate",v,s);return o===32&&(_[31]&=127),uo(_)}function f(v){const _=ho("scalar",v),w=_.length;if(w!==s&&w!==o){let b=""+s+" or "+o;throw new Error("invalid scalar, expected "+b+" bytes, got "+w)}return uo(a(_))}function g(v,_){const w=d(_),b=f(v),E=h(w,b);if(E===Dt)throw new Error("invalid private or public key received");return p(E)}const y=p(e.Gu);function m(v){return g(v,y)}return{scalarMult:g,scalarMultBase:m,getSharedSecret:(v,_)=>g(v,_),getPublicKey:v=>m(v),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:y}}const hn=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const ny=BigInt(1),po=BigInt(2),sy=BigInt(3),oy=BigInt(5);BigInt(8);function ay(r){const e=BigInt(10),t=BigInt(20),i=BigInt(40),n=BigInt(80),s=hn,o=r*r%s*r%s,a=Fe(o,po,s)*o%s,c=Fe(a,ny,s)*r%s,l=Fe(c,oy,s)*c%s,u=Fe(l,e,s)*l%s,h=Fe(u,t,s)*u%s,p=Fe(h,i,s)*h%s,d=Fe(p,n,s)*p%s,f=Fe(d,n,s)*p%s,g=Fe(f,e,s)*l%s;return{pow_p_5_8:Fe(g,po,s)*r%s,b2:o}}function cy(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}const dn=iy({P:hn,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:r=>{const e=hn,{pow_p_5_8:t,b2:i}=ay(r);return yl(Fe(t,sy,e)*i,e)},adjustScalarBytes:cy,randomBytes:Rr}),ml="base10",ue="base16",ut="base64pad",or="base64url",Cr="utf8",vl=0,rt=1,Nr=2,ly=0,go=1,yr=12,Xn=32;function uy(){const r=dn.utils.randomPrivateKey(),e=dn.getPublicKey(r);return{privateKey:fe(r,ue),publicKey:fe(e,ue)}}function fn(){const r=Rr(Xn);return fe(r,ue)}function hy(r,e){const t=dn.getSharedSecret(Ce(r,ue),Ce(e,ue)),i=Ug(mi,t,void 0,void 0,Xn);return fe(i,ue)}function jr(r){const e=mi(Ce(r,ue));return fe(e,ue)}function Ze(r){const e=mi(Ce(r,Cr));return fe(e,ue)}function wl(r){return Ce(`${r}`,ml)}function Tt(r){return Number(fe(r,ml))}function dy(r){const e=wl(typeof r.type<"u"?r.type:vl);if(Tt(e)===rt&&typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const t=typeof r.senderPublicKey<"u"?Ce(r.senderPublicKey,ue):void 0,i=typeof r.iv<"u"?Ce(r.iv,ue):Rr(yr),n=Ce(r.symKey,ue),s=hl(n,i).encrypt(Ce(r.message,Cr));return _l({type:e,sealed:s,iv:i,senderPublicKey:t,encoding:r.encoding})}function fy(r){const e=Ce(r.symKey,ue),{sealed:t,iv:i}=Sr(r),n=hl(e,i).decrypt(t);if(n===null)throw new Error("Failed to decrypt");return fe(n,Cr)}function py(r,e){const t=wl(Nr),i=Rr(yr),n=Ce(r,Cr);return _l({type:t,sealed:n,iv:i,encoding:e})}function gy(r,e){const{sealed:t}=Sr({encoded:r,encoding:e});return fe(t,Cr)}function _l(r){const{encoding:e=ut}=r;if(Tt(r.type)===Nr)return fe(Si([r.type,r.sealed]),e);if(Tt(r.type)===rt){if(typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return fe(Si([r.type,r.senderPublicKey,r.iv,r.sealed]),e)}return fe(Si([r.type,r.iv,r.sealed]),e)}function Sr(r){const{encoded:e,encoding:t=ut}=r,i=Ce(e,t),n=i.slice(ly,go),s=go;if(Tt(n)===rt){const l=s+Xn,u=l+yr,h=i.slice(s,l),p=i.slice(l,u),d=i.slice(u);return{type:n,sealed:d,iv:p,senderPublicKey:h}}if(Tt(n)===Nr){const l=i.slice(s),u=Rr(yr);return{type:n,sealed:l,iv:u}}const o=s+yr,a=i.slice(s,o),c=i.slice(o);return{type:n,sealed:c,iv:a}}function yy(r,e){const t=Sr({encoded:r,encoding:e==null?void 0:e.encoding});return bl({type:Tt(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?fe(t.senderPublicKey,ue):void 0,receiverPublicKey:e==null?void 0:e.receiverPublicKey})}function bl(r){const e=(r==null?void 0:r.type)||vl;if(e===rt){if(typeof(r==null?void 0:r.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(r==null?void 0:r.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:r==null?void 0:r.senderPublicKey,receiverPublicKey:r==null?void 0:r.receiverPublicKey}}function yo(r){return r.type===rt&&typeof r.senderPublicKey=="string"&&typeof r.receiverPublicKey=="string"}function mo(r){return r.type===Nr}function my(r){return new _u.ec("p256").keyFromPublic({x:R.Buffer.from(r.x,"base64").toString("hex"),y:R.Buffer.from(r.y,"base64").toString("hex")},"hex")}function vy(r){let e=r.replace(/-/g,"+").replace(/_/g,"/");const t=e.length%4;return t>0&&(e+="=".repeat(4-t)),e}function wy(r){return R.Buffer.from(vy(r),"base64")}function _y(r,e){const[t,i,n]=r.split("."),s=wy(n);if(s.length!==64)throw new Error("Invalid signature length");const o=s.slice(0,32).toString("hex"),a=s.slice(32,64).toString("hex"),c=`${t}.${i}`,l=mi(c),u=my(e),h=fe(l,ue);if(!u.verify(h,{r:o,s:a}))throw new Error("Invalid signature");return Hi(r).payload}const by="irn";function ti(r){return(r==null?void 0:r.relay)||{protocol:by}}function dr(r){const e=Xl[r];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${r}`);return e}function Ey(r,e="-"){const t={},i="relay"+e;return Object.keys(r).forEach(n=>{if(n.startsWith(i)){const s=n.replace(i,""),o=r[n];t[s]=o}}),t}function vo(r){if(!r.includes("wc:")){const l=Xc(r);l!=null&&l.includes("wc:")&&(r=l)}r=r.includes("wc://")?r.replace("wc://",""):r,r=r.includes("wc:")?r.replace("wc:",""):r;const e=r.indexOf(":"),t=r.indexOf("?")!==-1?r.indexOf("?"):void 0,i=r.substring(0,e),n=r.substring(e+1,t).split("@"),s=typeof t<"u"?r.substring(t):"",o=new URLSearchParams(s),a={};o.forEach((l,u)=>{a[u]=l});const c=typeof a.methods=="string"?a.methods.split(","):void 0;return{protocol:i,topic:Sy(n[0]),version:parseInt(n[1],10),symKey:a.symKey,relay:Ey(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function Sy(r){return r.startsWith("//")?r.substring(2):r}function Iy(r,e="-"){const t="relay",i={};return Object.keys(r).forEach(n=>{const s=t+e+n;r[n]&&(i[s]=r[n])}),i}function wo(r){const e=new URLSearchParams,t=Iy(r.relay);Object.keys(t).sort().forEach(n=>{e.set(n,t[n])}),e.set("symKey",r.symKey),r.expiryTimestamp&&e.set("expiryTimestamp",r.expiryTimestamp.toString()),r.methods&&e.set("methods",r.methods.join(","));const i=e.toString();return`${r.protocol}:${r.topic}@${r.version}?${i}`}function Fr(r,e,t){return`${r}?wc_ev=${t}&topic=${e}`}function rr(r){const e=[];return r.forEach(t=>{const[i,n]=t.split(":");e.push(`${i}:${n}`)}),e}function xy(r){const e=[];return Object.values(r).forEach(t=>{e.push(...rr(t.accounts))}),e}function Py(r,e){const t=[];return Object.values(r).forEach(i=>{rr(i.accounts).includes(e)&&t.push(...i.methods)}),t}function Ay(r,e){const t=[];return Object.values(r).forEach(i=>{rr(i.accounts).includes(e)&&t.push(...i.events)}),t}function Ty(r){const e={};return r==null||r.forEach(t=>{const[i,n]=t.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[]}),e[i].accounts.push(t),e[i].chains.push(`${i}:${n}`)}),e}function _o(r,e){e=e.map(i=>i.replace("did:pkh:",""));const t=Ty(e);for(const[i,n]of Object.entries(t))n.methods?n.methods=yp(n.methods,r):n.methods=r,n.events=["chainChanged","accountsChanged"];return t}const Ry={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},Cy={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function P(r,e){const{message:t,code:i}=Cy[r];return{message:e?`${t} ${e}`:t,code:i}}function H(r,e){const{message:t,code:i}=Ry[r];return{message:e?`${t} ${e}`:t,code:i}}function vi(r,e){return!!Array.isArray(r)}function ri(r){return Object.getPrototypeOf(r)===Object.prototype&&Object.keys(r).length}function de(r){return typeof r>"u"}function ee(r,e){return e&&de(r)?!0:typeof r=="string"&&!!r.trim().length}function Zn(r,e){return e&&de(r)?!0:typeof r=="number"&&!isNaN(r)}function Ny(r,e){const{requiredNamespaces:t}=e,i=Object.keys(r.namespaces),n=Object.keys(t);let s=!0;return Pt(n,i)?(i.forEach(o=>{const{accounts:a,methods:c,events:l}=r.namespaces[o],u=rr(a),h=t[o];(!Pt(Vc(o,h),u)||!Pt(h.methods,c)||!Pt(h.events,l))&&(s=!1)}),s):!1}function ii(r){return ee(r,!1)&&r.includes(":")?r.split(":").length===2:!1}function Oy(r){if(ee(r,!1)&&r.includes(":")){const e=r.split(":");if(e.length===3){const t=e[0]+":"+e[1];return!!e[2]&&ii(t)}}return!1}function $y(r){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(ee(r,!1)){if(e(r))return!0;const t=Xc(r);return e(t)}}catch{}return!1}function ky(r){var e;return(e=r==null?void 0:r.proposer)==null?void 0:e.publicKey}function My(r){return r==null?void 0:r.topic}function Ly(r,e){let t=null;return ee(r==null?void 0:r.publicKey,!1)||(t=P("MISSING_OR_INVALID",`${e} controller public key should be a string`)),t}function bo(r){let e=!0;return vi(r)?r.length&&(e=r.every(t=>ee(t,!1))):e=!1,e}function Dy(r,e,t){let i=null;return vi(e)&&e.length?e.forEach(n=>{i||ii(n)||(i=H("UNSUPPORTED_CHAINS",`${t}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):ii(r)||(i=H("UNSUPPORTED_CHAINS",`${t}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function Fy(r,e,t){let i=null;return Object.entries(r).forEach(([n,s])=>{if(i)return;const o=Dy(n,Vc(n,s),`${e} ${t}`);o&&(i=o)}),i}function qy(r,e){let t=null;return vi(r)?r.forEach(i=>{t||Oy(i)||(t=H("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):t=H("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}function Uy(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;const n=qy(i==null?void 0:i.accounts,`${e} namespace`);n&&(t=n)}),t}function By(r,e){let t=null;return bo(r==null?void 0:r.methods)?bo(r==null?void 0:r.events)||(t=H("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=H("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}function El(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;const n=By(i,`${e}, namespace`);n&&(t=n)}),t}function zy(r,e,t){let i=null;if(r&&ri(r)){const n=El(r,e);n&&(i=n);const s=Fy(r,e,t);s&&(i=s)}else i=P("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return i}function Ui(r,e){let t=null;if(r&&ri(r)){const i=El(r,e);i&&(t=i);const n=Uy(r,e);n&&(t=n)}else t=P("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function Sl(r){return ee(r.protocol,!0)}function Ky(r,e){let t=!1;return r?r&&vi(r)&&r.length&&r.forEach(i=>{t=Sl(i)}):t=!0,t}function jy(r){return typeof r=="number"}function ge(r){return typeof r<"u"&&typeof r!==null}function Vy(r){return!(!r||typeof r!="object"||!r.code||!Zn(r.code,!1)||!r.message||!ee(r.message,!1))}function Wy(r){return!(de(r)||!ee(r.method,!1))}function Hy(r){return!(de(r)||de(r.result)&&de(r.error)||!Zn(r.id,!1)||!ee(r.jsonrpc,!1))}function Jy(r){return!(de(r)||!ee(r.name,!1))}function Eo(r,e){return!(!ii(e)||!xy(r).includes(e))}function Gy(r,e,t){return ee(t,!1)?Py(r,e).includes(t):!1}function Yy(r,e,t){return ee(t,!1)?Ay(r,e).includes(t):!1}function So(r,e,t){let i=null;const n=Qy(r),s=Xy(e),o=Object.keys(n),a=Object.keys(s),c=Io(Object.keys(r)),l=Io(Object.keys(e)),u=c.filter(h=>!l.includes(h));return u.length&&(i=P("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces.
|
|
526
|
+
Required: ${u.toString()}
|
|
527
|
+
Received: ${Object.keys(e).toString()}`)),Pt(o,a)||(i=P("NON_CONFORMING_NAMESPACES",`${t} namespaces chains don't satisfy required namespaces.
|
|
528
|
+
Required: ${o.toString()}
|
|
529
|
+
Approved: ${a.toString()}`)),Object.keys(e).forEach(h=>{if(!h.includes(":")||i)return;const p=rr(e[h].accounts);p.includes(h)||(i=P("NON_CONFORMING_NAMESPACES",`${t} namespaces accounts don't satisfy namespace accounts for ${h}
|
|
530
|
+
Required: ${h}
|
|
531
|
+
Approved: ${p.toString()}`))}),o.forEach(h=>{i||(Pt(n[h].methods,s[h].methods)?Pt(n[h].events,s[h].events)||(i=P("NON_CONFORMING_NAMESPACES",`${t} namespaces events don't satisfy namespace events for ${h}`)):i=P("NON_CONFORMING_NAMESPACES",`${t} namespaces methods don't satisfy namespace methods for ${h}`))}),i}function Qy(r){const e={};return Object.keys(r).forEach(t=>{var i;t.includes(":")?e[t]=r[t]:(i=r[t].chains)==null||i.forEach(n=>{e[n]={methods:r[t].methods,events:r[t].events}})}),e}function Io(r){return[...new Set(r.map(e=>e.includes(":")?e.split(":")[0]:e))]}function Xy(r){const e={};return Object.keys(r).forEach(t=>{if(t.includes(":"))e[t]=r[t];else{const i=rr(r[t].accounts);i==null||i.forEach(n=>{e[n]={accounts:r[t].accounts.filter(s=>s.includes(`${n}:`)),methods:r[t].methods,events:r[t].events}})}}),e}function Zy(r,e){return Zn(r,!1)&&r<=e.max&&r>=e.min}function xo(){const r=Tr();return new Promise(e=>{switch(r){case _e.browser:e(em());break;case _e.reactNative:e(tm());break;case _e.node:e(rm());break;default:e(!0)}})}function em(){return Ar()&&(navigator==null?void 0:navigator.onLine)}async function tm(){if(mt()&&typeof R.global<"u"&&R.global!=null&&R.global.NetInfo){const r=await(R.global==null?void 0:R.global.NetInfo.fetch());return r==null?void 0:r.isConnected}return!0}function rm(){return!0}function im(r){switch(Tr()){case _e.browser:nm(r);break;case _e.reactNative:sm(r);break}}function nm(r){!mt()&&Ar()&&(window.addEventListener("online",()=>r(!0)),window.addEventListener("offline",()=>r(!1)))}function sm(r){var e;mt()&&typeof R.global<"u"&&R.global!=null&&R.global.NetInfo&&((e=R.global)==null||e.NetInfo.addEventListener(t=>r(t==null?void 0:t.isConnected)))}const Bi={};class ar{static get(e){return Bi[e]}static set(e,t){Bi[e]=t}static delete(e){delete Bi[e]}}const om=r=>JSON.stringify(r,(e,t)=>typeof t=="bigint"?t.toString()+"n":t),am=r=>{const e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,t=r.replace(e,'$1"$2n"$3');return JSON.parse(t,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function cm(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return am(r)}catch{return r}}function lm(r){return typeof r=="string"?r:om(r)||""}const um=()=>typeof WebSocket<"u"?WebSocket:typeof R.global<"u"&&typeof R.global.WebSocket<"u"?R.global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),hm=()=>typeof WebSocket<"u"||typeof R.global<"u"&&typeof R.global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",Po=r=>r.split("?")[0],Ao=10,dm=um();class fm{constructor(e){if(this.url=e,this.events=new He.EventEmitter,this.registering=!1,!ns(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,t)=>{if(typeof this.socket>"u"){t(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(lm(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!ns(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return n(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((t,i)=>{const n=eu.isReactNative()?void 0:{rejectUnauthorized:!tu(e)},s=new dm(e,[],n);hm()?s.onerror=o=>{const a=o;i(this.emitError(a.error))}:s.on("error",o=>{i(this.emitError(o))}),s.onopen=()=>{this.onOpen(s),t(s)}})}onOpen(e){e.onmessage=t=>this.onPayload(t),e.onclose=t=>this.onClose(t),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;const t=typeof e.data=="string"?cm(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const i=this.parseError(t),n=i.message||i.toString(),s=vn(e,n);this.events.emit("payload",s)}parseError(e,t=this.url){return ru(e,Po(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>Ao&&this.events.setMaxListeners(Ao)}emitError(e){const t=this.parseError(new Error((e==null?void 0:e.message)||`WebSocket connection failed for host: ${Po(this.url)}`));return this.events.emit("register_error",t),t}}var X={};Object.defineProperty(X,"__esModule",{value:!0});X.getLocalStorage=X.getLocalStorageOrThrow=X.getCrypto=X.getCryptoOrThrow=X.getLocation=X.getLocationOrThrow=X.getNavigator=X.getNavigatorOrThrow=Il=X.getDocument=X.getDocumentOrThrow=X.getFromWindowOrThrow=X.getFromWindow=void 0;function kt(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}X.getFromWindow=kt;function ir(r){const e=kt(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}X.getFromWindowOrThrow=ir;function pm(){return ir("document")}X.getDocumentOrThrow=pm;function gm(){return kt("document")}var Il=X.getDocument=gm;function ym(){return ir("navigator")}X.getNavigatorOrThrow=ym;function mm(){return kt("navigator")}X.getNavigator=mm;function vm(){return ir("location")}X.getLocationOrThrow=vm;function wm(){return kt("location")}X.getLocation=wm;function _m(){return ir("crypto")}X.getCryptoOrThrow=_m;function bm(){return kt("crypto")}X.getCrypto=bm;function Em(){return ir("localStorage")}X.getLocalStorageOrThrow=Em;function Sm(){return kt("localStorage")}X.getLocalStorage=Sm;const xl="wc",Pl=2,pn="core",We=`${xl}@2:${pn}:`,Im={logger:"error"},xm={database:":memory:"},Pm="crypto",To="client_ed25519_seed",Am=I.ONE_DAY,Tm="keychain",Rm="0.3",Cm="messages",Nm="0.3",Ro=I.SIX_HOURS,Om="publisher",Al="irn",$m="error",Tl="wss://relay.walletconnect.org",km="relayer",ne={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},Mm="_subscription",Ae={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},Lm=.1,gn="2.18.0",G={link_mode:"link_mode",relay:"relay"},Dm="0.3",Fm="WALLETCONNECT_CLIENT_ID",Co="WALLETCONNECT_LINK_MODE_APPS",ve={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},qm="subscription",Um="0.3",Bm=I.FIVE_SECONDS*1e3,zm="pairing",Km="0.3",cr={wc_pairingDelete:{req:{ttl:I.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:I.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:I.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:I.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:I.ONE_DAY,prompt:!1,tag:0},res:{ttl:I.ONE_DAY,prompt:!1,tag:0}}},Et={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Me={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},jm="history",Vm="0.3",Wm="expirer",Te={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},Hm="0.3",Jm="verify-api",Gm="https://verify.walletconnect.com",Rl="https://verify.walletconnect.org",mr=Rl,Ym=`${mr}/v3`,Qm=[Gm,Rl],Xm="echo",Zm="https://echo.walletconnect.com",Ve={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},Xe={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},Le={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},wt={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},_t={authenticated_session_approve_started:"authenticated_session_approve_started",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve"},lr={no_internet_connection:"no_internet_connection",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},e0=.1,t0="event-client",r0=86400,i0="https://pulse.walletconnect.org/batch";function n0(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i<t.length;i++)t[i]=255;for(var n=0;n<r.length;n++){var s=r.charAt(n),o=s.charCodeAt(0);if(t[o]!==255)throw new TypeError(s+" is ambiguous");t[o]=n}var a=r.length,c=r.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function h(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";for(var g=0,y=0,m=0,v=f.length;m!==v&&f[m]===0;)m++,g++;for(var _=(v-m)*u+1>>>0,w=new Uint8Array(_);m!==v;){for(var b=f[m],E=0,S=_-1;(b!==0||E<y)&&S!==-1;S--,E++)b+=256*w[S]>>>0,w[S]=b%a>>>0,b=b/a>>>0;if(b!==0)throw new Error("Non-zero carry");y=E,m++}for(var x=_-y;x!==_&&w[x]===0;)x++;for(var C=c.repeat(g);x<_;++x)C+=r.charAt(w[x]);return C}function p(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var g=0;if(f[g]!==" "){for(var y=0,m=0;f[g]===c;)y++,g++;for(var v=(f.length-g)*l+1>>>0,_=new Uint8Array(v);f[g];){var w=t[f.charCodeAt(g)];if(w===255)return;for(var b=0,E=v-1;(w!==0||b<m)&&E!==-1;E--,b++)w+=a*_[E]>>>0,_[E]=w%256>>>0,w=w/256>>>0;if(w!==0)throw new Error("Non-zero carry");m=b,g++}if(f[g]!==" "){for(var S=v-m;S!==v&&_[S]===0;)S++;for(var x=new Uint8Array(y+(v-S)),C=y;S!==v;)x[C++]=_[S++];return x}}}function d(f){var g=p(f);if(g)return g;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:p,decode:d}}var s0=n0,o0=s0;const Cl=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},a0=r=>new TextEncoder().encode(r),c0=r=>new TextDecoder().decode(r);class l0{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class u0{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Nl(this,e)}}class h0{constructor(e){this.decoders=e}or(e){return Nl(this,e)}decode(e){const t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Nl=(r,e)=>new h0({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}});class d0{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new l0(e,t,i),this.decoder=new u0(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const wi=({name:r,prefix:e,encode:t,decode:i})=>new d0(r,e,t,i),Or=({prefix:r,name:e,alphabet:t})=>{const{encode:i,decode:n}=o0(t,e);return wi({prefix:r,name:e,encode:i,decode:s=>Cl(n(s))})},f0=(r,e,t,i)=>{const n={};for(let u=0;u<e.length;++u)n[e[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;const o=new Uint8Array(s*t/8|0);let a=0,c=0,l=0;for(let u=0;u<s;++u){const h=n[r[u]];if(h===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<t|h,a+=t,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},p0=(r,e,t)=>{const i=e[e.length-1]==="=",n=(1<<t)-1;let s="",o=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],o+=8;o>t;)o-=t,s+=e[n&a>>o];if(o&&(s+=e[n&a<<t-o]),i)for(;s.length*t&7;)s+="=";return s},ce=({name:r,prefix:e,bitsPerChar:t,alphabet:i})=>wi({prefix:e,name:r,encode(n){return p0(n,i,t)},decode(n){return f0(n,i,t,r)}}),g0=wi({prefix:"\0",name:"identity",encode:r=>c0(r),decode:r=>a0(r)});var y0=Object.freeze({__proto__:null,identity:g0});const m0=ce({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var v0=Object.freeze({__proto__:null,base2:m0});const w0=ce({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var _0=Object.freeze({__proto__:null,base8:w0});const b0=Or({prefix:"9",name:"base10",alphabet:"0123456789"});var E0=Object.freeze({__proto__:null,base10:b0});const S0=ce({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),I0=ce({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var x0=Object.freeze({__proto__:null,base16:S0,base16upper:I0});const P0=ce({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),A0=ce({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),T0=ce({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),R0=ce({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),C0=ce({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),N0=ce({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),O0=ce({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),$0=ce({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),k0=ce({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var M0=Object.freeze({__proto__:null,base32:P0,base32upper:A0,base32pad:T0,base32padupper:R0,base32hex:C0,base32hexupper:N0,base32hexpad:O0,base32hexpadupper:$0,base32z:k0});const L0=Or({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),D0=Or({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var F0=Object.freeze({__proto__:null,base36:L0,base36upper:D0});const q0=Or({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),U0=Or({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var B0=Object.freeze({__proto__:null,base58btc:q0,base58flickr:U0});const z0=ce({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),K0=ce({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),j0=ce({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),V0=ce({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var W0=Object.freeze({__proto__:null,base64:z0,base64pad:K0,base64url:j0,base64urlpad:V0});const Ol=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),H0=Ol.reduce((r,e,t)=>(r[t]=e,r),[]),J0=Ol.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function G0(r){return r.reduce((e,t)=>(e+=H0[t],e),"")}function Y0(r){const e=[];for(const t of r){const i=J0[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}const Q0=wi({prefix:"🚀",name:"base256emoji",encode:G0,decode:Y0});var X0=Object.freeze({__proto__:null,base256emoji:Q0}),Z0=$l,No=128,ev=-128,tv=Math.pow(2,31);function $l(r,e,t){e=e||[],t=t||0;for(var i=t;r>=tv;)e[t++]=r&255|No,r/=128;for(;r&ev;)e[t++]=r&255|No,r>>>=7;return e[t]=r|0,$l.bytes=t-i+1,e}var rv=yn,iv=128,Oo=127;function yn(r,i){var t=0,i=i||0,n=0,s=i,o,a=r.length;do{if(s>=a)throw yn.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&Oo)<<n:(o&Oo)*Math.pow(2,n),n+=7}while(o>=iv);return yn.bytes=s-i,t}var nv=Math.pow(2,7),sv=Math.pow(2,14),ov=Math.pow(2,21),av=Math.pow(2,28),cv=Math.pow(2,35),lv=Math.pow(2,42),uv=Math.pow(2,49),hv=Math.pow(2,56),dv=Math.pow(2,63),fv=function(r){return r<nv?1:r<sv?2:r<ov?3:r<av?4:r<cv?5:r<lv?6:r<uv?7:r<hv?8:r<dv?9:10},pv={encode:Z0,decode:rv,encodingLength:fv},kl=pv;const $o=(r,e,t=0)=>(kl.encode(r,e,t),e),ko=r=>kl.encodingLength(r),mn=(r,e)=>{const t=e.byteLength,i=ko(r),n=i+ko(t),s=new Uint8Array(n+t);return $o(r,s,0),$o(t,s,i),s.set(e,n),new gv(r,t,e,s)};class gv{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}}const Ml=({name:r,code:e,encode:t})=>new yv(r,e,t);class yv{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?mn(this.code,t):t.then(i=>mn(this.code,i))}else throw Error("Unknown type, must be binary type")}}const Ll=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),mv=Ml({name:"sha2-256",code:18,encode:Ll("SHA-256")}),vv=Ml({name:"sha2-512",code:19,encode:Ll("SHA-512")});var wv=Object.freeze({__proto__:null,sha256:mv,sha512:vv});const Dl=0,_v="identity",Fl=Cl,bv=r=>mn(Dl,Fl(r)),Ev={code:Dl,name:_v,encode:Fl,digest:bv};var Sv=Object.freeze({__proto__:null,identity:Ev});new TextEncoder,new TextDecoder;const Mo={...y0,...v0,..._0,...E0,...x0,...M0,...F0,...B0,...W0,...X0};({...wv,...Sv});function Iv(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function ql(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}const Lo=ql("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),zi=ql("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);const e=Iv(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),xv={utf8:Lo,"utf-8":Lo,hex:Mo.base16,latin1:zi,ascii:zi,binary:zi,...Mo};function Pv(r,e="utf8"){const t=xv[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r,"utf8"):t.decoder.decode(`${t.prefix}${r}`)}class Av{constructor(e,t){this.core=e,this.logger=t,this.keychain=new Map,this.name=Tm,this.version=Rm,this.initialized=!1,this.storagePrefix=We,this.init=async()=>{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}},this.has=i=>(this.isInitialized(),this.keychain.has(i)),this.set=async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()},this.get=i=>{this.isInitialized();const n=this.keychain.get(i);if(typeof n>"u"){const{message:s}=P("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(s)}return n},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()},this.core=e,this.logger=pe(t,this.name)}get context(){return be(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Jc(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Gc(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Tv{constructor(e,t,i){this.core=e,this.logger=t,this.name=Pm,this.randomSessionIdentifier=fn(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=n=>(this.isInitialized(),this.keychain.has(n)),this.getClientId=async()=>{this.isInitialized();const n=await this.getClientSeed(),s=ss(n);return su(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const n=uy();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();const s=await this.getClientSeed(),o=ss(s),a=this.randomSessionIdentifier;return await ou(a,n,Am,o)},this.generateSharedKey=(n,s,o)=>{this.isInitialized();const a=this.getPrivateKey(n),c=hy(a,s);return this.setSymKey(c,o)},this.setSymKey=async(n,s)=>{this.isInitialized();const o=s||jr(n);return await this.keychain.set(o,n),o},this.deleteKeyPair=async n=>{this.isInitialized(),await this.keychain.del(n)},this.deleteSymKey=async n=>{this.isInitialized(),await this.keychain.del(n)},this.encode=async(n,s,o)=>{this.isInitialized();const a=bl(o),c=Nf(s);if(mo(a))return py(c,o==null?void 0:o.encoding);if(yo(a)){const p=a.senderPublicKey,d=a.receiverPublicKey;n=await this.generateSharedKey(p,d)}const l=this.getSymKey(n),{type:u,senderPublicKey:h}=a;return dy({type:u,symKey:l,message:c,senderPublicKey:h,encoding:o==null?void 0:o.encoding})},this.decode=async(n,s,o)=>{this.isInitialized();const a=yy(s,o);if(mo(a)){const c=gy(s,o==null?void 0:o.encoding);return Fs(c)}if(yo(a)){const c=a.receiverPublicKey,l=a.senderPublicKey;n=await this.generateSharedKey(c,l)}try{const c=this.getSymKey(n),l=fy({symKey:c,encoded:s,encoding:o==null?void 0:o.encoding});return Fs(l)}catch(c){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(c)}},this.getPayloadType=(n,s=ut)=>{const o=Sr({encoded:n,encoding:s});return Tt(o.type)},this.getPayloadSenderPublicKey=(n,s=ut)=>{const o=Sr({encoded:n,encoding:s});return o.senderPublicKey?fe(o.senderPublicKey,ue):void 0},this.core=e,this.logger=pe(t,this.name),this.keychain=i||new Av(this.core,this.logger)}get context(){return be(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(To)}catch{e=fn(),await this.keychain.set(To,e)}return Pv(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Rv extends _f{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name=Cm,this.version=Nm,this.initialized=!1,this.storagePrefix=We,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}},this.set=async(i,n)=>{this.isInitialized();const s=Ze(n);let o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=n,this.messages.set(i,o),await this.persist()),s},this.get=i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n},this.has=(i,n)=>{this.isInitialized();const s=this.get(i),o=Ze(n);return typeof s[o]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=pe(e,this.name),this.core=t}get context(){return be(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Jc(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Gc(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Cv=Object.defineProperty,Nv=Object.defineProperties,Ov=Object.getOwnPropertyDescriptors,Do=Object.getOwnPropertySymbols,$v=Object.prototype.hasOwnProperty,kv=Object.prototype.propertyIsEnumerable,Fo=(r,e,t)=>e in r?Cv(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,qo=(r,e)=>{for(var t in e||(e={}))$v.call(e,t)&&Fo(r,t,e[t]);if(Do)for(var t of Do(e))kv.call(e,t)&&Fo(r,t,e[t]);return r},Uo=(r,e)=>Nv(r,Ov(e));class Mv extends bf{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new He.EventEmitter,this.name=Om,this.queue=new Map,this.publishTimeout=I.toMiliseconds(I.ONE_MINUTE),this.initialPublishTimeout=I.toMiliseconds(I.ONE_SECOND*15),this.needsTransportRestart=!1,this.publish=async(i,n,s)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:s}});const a=(s==null?void 0:s.ttl)||Ro,c=ti(s),l=(s==null?void 0:s.prompt)||!1,u=(s==null?void 0:s.tag)||0,h=(s==null?void 0:s.id)||xt().toString(),p={topic:i,message:n,opts:{ttl:a,relay:c,prompt:l,tag:u,id:h,attestation:s==null?void 0:s.attestation}},d=`Failed to publish payload, please try again. id:${h} tag:${u}`;try{const f=new Promise(async g=>{const y=({id:v})=>{p.opts.id===v&&(this.removeRequestFromQueue(v),this.relayer.events.removeListener(ne.publish,y),g(p))};this.relayer.events.on(ne.publish,y);const m=lt(new Promise((v,_)=>{this.rpcPublish({topic:i,message:n,ttl:a,prompt:l,tag:u,id:h,attestation:s==null?void 0:s.attestation}).then(v).catch(w=>{this.logger.warn(w,w==null?void 0:w.message),_(w)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${h} tag:${u}`);try{await m,this.events.removeListener(ne.publish,y)}catch(v){this.queue.set(h,Uo(qo({},p),{attempt:1})),this.logger.warn(v,v==null?void 0:v.message)}});this.logger.trace({type:"method",method:"publish",params:{id:h,topic:i,message:n,opts:s}}),await lt(f,this.publishTimeout,d)}catch(f){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(f),(o=s==null?void 0:s.internal)!=null&&o.throwOnFailedPublish)throw f}finally{this.queue.delete(h)}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.relayer=e,this.logger=pe(t,this.name),this.registerEventListeners()}get context(){return be(this.logger)}async rpcPublish(e){var t,i,n,s;const{topic:o,message:a,ttl:c=Ro,prompt:l,tag:u,id:h,attestation:p}=e,d={method:dr(ti().protocol).publish,params:{topic:o,message:a,ttl:c,prompt:l,tag:u,attestation:p},id:h};de((t=d.params)==null?void 0:t.prompt)&&((i=d.params)==null||delete i.prompt),de((n=d.params)==null?void 0:n.tag)&&((s=d.params)==null||delete s.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:d});const f=await this.relayer.request(d);return this.relayer.events.emit(ne.publish,e),this.logger.debug("Successfully Published Payload"),f}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,t)=>{const i=e.attempt+1;this.queue.set(t,Uo(qo({},e),{attempt:i}));const{topic:n,message:s,opts:o,attestation:a}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${i}`),await this.rpcPublish({topic:n,message:s,ttl:o.ttl,prompt:o.prompt,tag:o.tag,id:o.id,attestation:a}),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(Zt.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(ne.connection_stalled);return}this.checkQueue()}),this.relayer.on(ne.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}class Lv{constructor(){this.map=new Map,this.set=(e,t)=>{const i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,t))return;const n=i.filter(s=>s!==t);if(!n.length){this.map.delete(e);return}this.map.set(e,n)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var Dv=Object.defineProperty,Fv=Object.defineProperties,qv=Object.getOwnPropertyDescriptors,Bo=Object.getOwnPropertySymbols,Uv=Object.prototype.hasOwnProperty,Bv=Object.prototype.propertyIsEnumerable,zo=(r,e,t)=>e in r?Dv(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ur=(r,e)=>{for(var t in e||(e={}))Uv.call(e,t)&&zo(r,t,e[t]);if(Bo)for(var t of Bo(e))Bv.call(e,t)&&zo(r,t,e[t]);return r},Ki=(r,e)=>Fv(r,qv(e));class zv extends If{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new Lv,this.events=new He.EventEmitter,this.name=qm,this.version=Um,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=We,this.subscribeTimeout=I.toMiliseconds(I.ONE_MINUTE),this.initialSubscribeTimeout=I.toMiliseconds(I.ONE_SECOND*15),this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId(),await this.restore()),this.initialized=!0},this.subscribe=async(i,n)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}});try{const s=ti(n),o={topic:i,relay:s,transportType:n==null?void 0:n.transportType};this.pending.set(i,o);const a=await this.rpcSubscribe(i,s,n);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),a}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(i,n)=>{await this.restartToComplete(),this.isInitialized(),typeof(n==null?void 0:n.id)<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)},this.isSubscribed=async i=>{if(this.topics.includes(i))return!0;const n=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((s,o)=>{const a=new I.Watch;a.start(n);const c=setInterval(()=>{(!this.pending.has(i)&&this.topics.includes(i)||this.cached.some(l=>l.topic===i))&&(clearInterval(c),a.stop(n),s(!0)),a.elapsed(n)>=Bm&&(clearInterval(c),a.stop(n),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{await this.restore(),await this.onRestart()},this.checkPending=async()=>{if(this.pending.size===0&&(!this.initialized||!this.relayer.connected))return;const i=[];this.pending.forEach(n=>{i.push(n)}),await this.batchSubscribe(i)},this.registerEventListeners=()=>{this.relayer.core.heartbeat.on(Zt.pulse,async()=>{await this.checkPending()}),this.events.on(ve.created,async i=>{const n=ve.created;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()}),this.events.on(ve.deleted,async i=>{const n=ve.deleted;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()})},this.relayer=e,this.logger=pe(t,this.name),this.clientId=""}get context(){return be(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,t){let i=!1;try{i=this.getSubscription(e).topic===t}catch{}return i}reset(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){const i=this.topicMap.get(e);await Promise.all(i.map(async n=>await this.unsubscribeById(e,n,t)))}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{const n=ti(i);await this.rpcUnsubscribe(e,t,n);const s=H("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(e,t,i){var n;(i==null?void 0:i.transportType)===G.relay&&await this.restartToComplete();const s={method:dr(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});const o=(n=i==null?void 0:i.internal)==null?void 0:n.throwOnFailedPublish;try{const a=this.getSubscriptionId(e);if((i==null?void 0:i.transportType)===G.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(u=>this.logger.warn(u))},I.toMiliseconds(I.ONE_SECOND)),a;const c=new Promise(async u=>{const h=p=>{p.topic===e&&(this.events.removeListener(ve.created,h),u(p.id))};this.events.on(ve.created,h);try{const p=await lt(new Promise((d,f)=>{this.relayer.request(s).catch(g=>{this.logger.warn(g,g==null?void 0:g.message),f(g)}).then(d)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(ve.created,h),u(p)}catch{}}),l=await lt(c,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!l&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return l?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(ne.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;const t=e[0].relay,i={method:dr(t.protocol).batchSubscribe,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{await await lt(new Promise(n=>{this.relayer.request(i).catch(s=>this.logger.warn(s)).then(n)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(ne.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const t=e[0].relay,i={method:dr(t.protocol).batchFetchMessages,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let n;try{n=await await lt(new Promise((s,o)=>{this.relayer.request(i).catch(a=>{this.logger.warn(a),o(a)}).then(s)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(ne.connection_stalled)}return n}rpcUnsubscribe(e,t,i){const n={method:dr(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,t){this.setSubscription(e,Ki(ur({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,ur({},t)),this.pending.delete(t.topic)})}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,ur({},t)),this.topicMap.set(t.topic,e),this.events.emit(ve.created,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:i}=P("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(ve.deleted,Ki(ur({},i),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(ve.sync)}async onRestart(){if(this.cached.length){const e=[...this.cached],t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let i=0;i<t;i++){const n=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(n)}}this.events.emit(ve.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:t}=P("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(e.map(t=>Ki(ur({},t),{id:this.getSubscriptionId(t.topic)}))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(await Ip(I.toMiliseconds(I.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(t.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen()}getSubscriptionId(e){return Ze(e+this.clientId)}}var Kv=Object.defineProperty,Ko=Object.getOwnPropertySymbols,jv=Object.prototype.hasOwnProperty,Vv=Object.prototype.propertyIsEnumerable,jo=(r,e,t)=>e in r?Kv(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Vo=(r,e)=>{for(var t in e||(e={}))jv.call(e,t)&&jo(r,t,e[t]);if(Ko)for(var t of Ko(e))Vv.call(e,t)&&jo(r,t,e[t]);return r};class Wv extends Ef{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new He.EventEmitter,this.name=km,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.hasExperiencedNetworkDisruption=!1,this.heartBeatTimeout=I.toMiliseconds(I.THIRTY_SECONDS+I.FIVE_SECONDS),this.requestsInFlight=[],this.connectTimeout=I.toMiliseconds(I.ONE_SECOND*15),this.request=async t=>{var i,n;this.logger.debug("Publishing Request Payload");const s=t.id||xt().toString();await this.toEstablishConnection();try{this.logger.trace({id:s,method:t.method,topic:(i=t.params)==null?void 0:i.topic},"relayer.request - publishing...");const o=`${s}:${((n=t.params)==null?void 0:n.tag)||""}`;this.requestsInFlight.push(o);const a=await this.provider.request(t);return this.requestsInFlight=this.requestsInFlight.filter(c=>c!==o),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${s}`),o}},this.resetPingTimeout=()=>{if(Zr())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var t,i,n;this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(n=(i=(t=this.provider)==null?void 0:t.connection)==null?void 0:i.socket)==null||n.terminate()},this.heartBeatTimeout)}catch(t){this.logger.warn(t,t==null?void 0:t.message)}},this.onPayloadHandler=t=>{this.onProviderPayload(t),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.warn({},"Relayer connected 🛜"),this.startPingTimeout(),this.events.emit(ne.connect)},this.onDisconnectHandler=()=>{this.logger.warn({},"Relayer disconnected 🛑"),this.requestsInFlight=[],this.onProviderDisconnect()},this.onProviderErrorHandler=t=>{this.logger.fatal(t,`Fatal socket error: ${t==null?void 0:t.message}`),this.events.emit(ne.error,t),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(Ae.payload,this.onPayloadHandler),this.provider.on(Ae.connect,this.onConnectHandler),this.provider.on(Ae.disconnect,this.onDisconnectHandler),this.provider.on(Ae.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?pe(e.logger,this.name):ca(wn({level:e.logger||$m})),this.messages=new Rv(this.logger,e.core),this.subscriber=new zv(this,this.logger),this.publisher=new Mv(this,this.logger),this.relayUrl=(e==null?void 0:e.relayUrl)||Tl,this.projectId=e.projectId,cp()?this.packageName=zs():lp()&&(this.bundleId=zs()),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.cached.length>0)try{await this.transportOpen()}catch(e){this.logger.warn(e,e==null?void 0:e.message)}}get context(){return be(this.logger)}get connected(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===1}get connecting(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===0}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:G.relay})}async subscribe(e,t){var i,n,s;this.isInitialized(),(!(t!=null&&t.transportType)||(t==null?void 0:t.transportType)==="relay")&&await this.toEstablishConnection();const o=typeof((i=t==null?void 0:t.internal)==null?void 0:i.throwOnFailedPublish)>"u"?!0:(n=t==null?void 0:t.internal)==null?void 0:n.throwOnFailedPublish;let a=((s=this.subscriber.topicMap.get(e))==null?void 0:s[0])||"",c;const l=u=>{u.topic===e&&(this.subscriber.off(ve.created,l),c())};return await Promise.all([new Promise(u=>{c=u,this.subscriber.on(ve.created,l)}),new Promise(async(u,h)=>{a=await this.subscriber.subscribe(e,Vo({internal:{throwOnFailedPublish:o}},t)).catch(p=>{o&&h(p)})||a,u()})]),a}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await lt(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise(async(t,i)=>{await this.connect(e).then(t).catch(i).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}async restartTransport(e){this.logger.debug({},"Restarting transport..."),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await xo())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if((e==null?void 0:e.length)===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const t=e.sort((i,n)=>i.publishedAt-n.publishedAt);this.logger.debug(`Batch of ${t.length} message events sorted`);for(const i of t)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n,"Error while processing batch message event: "+(n==null?void 0:n.message))}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){const{topic:i}=e;if(!t.sessionExists){const n=re(I.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(ne.message,e),await this.recordMessageEvent(e)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let t=1;for(;t<6;){try{this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${t}...`),await this.createProvider(),await new Promise(async(i,n)=>{const s=()=>{n(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(Ae.disconnect,s),await lt(new Promise((o,a)=>{this.provider.connect().then(o).catch(a)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(o=>{n(o)}).finally(()=>{this.provider.off(Ae.disconnect,s),clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),await new Promise(async(o,a)=>{const c=()=>{a(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(Ae.disconnect,c),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(Ae.disconnect,c)})}),this.hasExperiencedNetworkDisruption=!1,i()})}catch(i){await this.subscriber.stop();const n=i;this.logger.warn({},n.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${t}`);break}await new Promise(i=>setTimeout(i,I.toMiliseconds(t*1))),t++}}startPingTimeout(){var e,t,i,n,s;if(Zr())try{(t=(e=this.provider)==null?void 0:e.connection)!=null&&t.socket&&((s=(n=(i=this.provider)==null?void 0:i.connection)==null?void 0:n.socket)==null||s.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o,o==null?void 0:o.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new du(new fm(fp({sdkVersion:gn,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:t,message:i}=e;await this.messages.set(t,i)}async shouldIgnoreMessageEvent(e){const{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.warn(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.warn(`Ignoring message for non-subscribed topic ${t}`),!0;const n=this.messages.has(t,i);return n&&this.logger.warn(`Ignoring duplicate message: ${i}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),_n(e)){if(!e.method.endsWith(Mm))return;const t=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=t.data,a={topic:i,message:n,publishedAt:s,transportType:G.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Vo({type:"event",event:t.id},a)),this.events.emit(t.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else ni(e)&&this.events.emit(ne.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(ne.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const t=bn(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(Ae.payload,this.onPayloadHandler),this.provider.off(Ae.connect,this.onConnectHandler),this.provider.off(Ae.disconnect,this.onDisconnectHandler),this.provider.off(Ae.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await xo();im(async t=>{e!==t&&(e=t,t?await this.transportOpen().catch(i=>this.logger.error(i,i==null?void 0:i.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),clearTimeout(this.pingTimeout),this.events.emit(ne.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||this.connectPromise||(this.reconnectTimeout=setTimeout(async()=>{clearTimeout(this.reconnectTimeout),await this.transportOpen().catch(e=>this.logger.error(e,e==null?void 0:e.message))},I.toMiliseconds(Lm))))}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&await this.transportOpen()}}var Hv=Object.defineProperty,Wo=Object.getOwnPropertySymbols,Jv=Object.prototype.hasOwnProperty,Gv=Object.prototype.propertyIsEnumerable,Ho=(r,e,t)=>e in r?Hv(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Jo=(r,e)=>{for(var t in e||(e={}))Jv.call(e,t)&&Ho(r,t,e[t]);if(Wo)for(var t of Wo(e))Gv.call(e,t)&&Ho(r,t,e[t]);return r};class Mt extends Sf{constructor(e,t,i,n=We,s=void 0){super(e,t,i,n),this.core=e,this.logger=t,this.name=i,this.map=new Map,this.version=Dm,this.cached=[],this.initialized=!1,this.storagePrefix=We,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!de(o)?this.map.set(this.getKey(o),o):ky(o)?this.map.set(o.id,o):My(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)},this.set=async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist())},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>au(a[c],o[c]))):this.values),this.update=async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const c=Jo(Jo({},this.getData(o)),a);this.map.set(o,c),await this.persist()},this.delete=async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())},this.logger=pe(t,this.name),this.storagePrefix=n,this.getKey=s}get context(){return be(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){const{message:n}=P("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}const{message:i}=P("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:t}=P("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Yv{constructor(e,t){this.core=e,this.logger=t,this.name=zm,this.version=Km,this.events=new aa,this.initialized=!1,this.storagePrefix=We,this.ignoredPayloadTypes=[rt],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]},this.create=async i=>{this.isInitialized();const n=fn(),s=await this.core.crypto.setSymKey(n),o=re(I.FIVE_MINUTES),a={protocol:Al},c={topic:s,expiry:o,relay:a,active:!1,methods:i==null?void 0:i.methods},l=wo({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:a,expiryTimestamp:o,methods:i==null?void 0:i.methods});return this.events.emit(Et.create,c),this.core.expirer.set(s,o),await this.pairings.set(s,c),await this.core.relayer.subscribe(s,{transportType:i==null?void 0:i.transportType}),{topic:s,uri:l}},this.pair=async i=>{this.isInitialized();const n=this.core.eventClient.createEvent({properties:{topic:i==null?void 0:i.uri,trace:[Ve.pairing_started]}});this.isValidPair(i,n);const{topic:s,symKey:o,relay:a,expiryTimestamp:c,methods:l}=vo(i.uri);n.props.properties.topic=s,n.addTrace(Ve.pairing_uri_validation_success),n.addTrace(Ve.pairing_uri_not_expired);let u;if(this.pairings.keys.includes(s)){if(u=this.pairings.get(s),n.addTrace(Ve.existing_pairing),u.active)throw n.setError(Xe.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);n.addTrace(Ve.pairing_not_expired)}const h=c||re(I.FIVE_MINUTES),p={topic:s,relay:a,expiry:h,active:!1,methods:l};this.core.expirer.set(s,h),await this.pairings.set(s,p),n.addTrace(Ve.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(Et.create,p),n.addTrace(Ve.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(Ve.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(Xe.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:a})}catch(d){throw n.setError(Xe.subscribe_pairing_topic_failure),d}return n.addTrace(Ve.subscribe_pairing_topic_success),p},this.activate=async({topic:i})=>{this.isInitialized();const n=re(I.FIVE_MINUTES);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:n}=i;if(this.pairings.keys.includes(n)){const s=await this.sendRequest(n,"wc_pairingPing",{}),{done:o,resolve:a,reject:c}=bt();this.events.once(U("pairing_ping",s),({error:l})=>{l?c(l):a()}),await o()}},this.updateExpiry=async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})},this.updateMetadata=async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:n}=i;this.pairings.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",H("USER_DISCONNECTED")),await this.deletePairing(n))},this.formatUriFromPairing=i=>{this.isInitialized();const{topic:n,relay:s,expiry:o,methods:a}=i,c=this.core.crypto.keychain.get(n);return wo({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:c,relay:s,expiryTimestamp:o,methods:a})},this.sendRequest=async(i,n,s)=>{const o=It(n,s),a=await this.core.crypto.encode(i,o),c=cr[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,a,c),o.id},this.sendResult=async(i,n,s)=>{const o=bn(i,s),a=await this.core.crypto.encode(n,o),c=await this.core.history.get(n,i),l=cr[c.request.method].res;await this.core.relayer.publish(n,a,l),await this.core.history.resolve(o)},this.sendError=async(i,n,s)=>{const o=vn(i,s),a=await this.core.crypto.encode(n,o),c=await this.core.history.get(n,i),l=cr[c.request.method]?cr[c.request.method].res:cr.unregistered_method.res;await this.core.relayer.publish(n,a,l),await this.core.history.resolve(o)},this.deletePairing=async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,H("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])},this.cleanup=async()=>{const i=this.pairings.getAll().filter(n=>at(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))},this.onRelayEventRequest=i=>{const{topic:n,payload:s}=i;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(n,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,s);default:return this.onUnknownRpcMethodRequest(n,s)}},this.onRelayEventResponse=async i=>{const{topic:n,payload:s}=i,o=(await this.core.history.get(n,s.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(n,s);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(i,n)=>{const{id:s}=n;try{this.isValidPing({topic:i}),await this.sendResult(s,i,!0),this.events.emit(Et.ping,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onPairingPingResponse=(i,n)=>{const{id:s}=n;setTimeout(()=>{Qe(n)?this.events.emit(U("pairing_ping",s),{}):qe(n)&&this.events.emit(U("pairing_ping",s),{error:n.error})},500)},this.onPairingDeleteRequest=async(i,n)=>{const{id:s}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(Et.delete,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(i,n)=>{const{id:s,method:o}=n;try{if(this.registeredMethods.includes(o))return;const a=H("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,i,a),this.logger.error(a)}catch(a){await this.sendError(s,i,a),this.logger.error(a)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(H("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=(i,n)=>{var s;if(!ge(i)){const{message:a}=P("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(Xe.malformed_pairing_uri),new Error(a)}if(!$y(i.uri)){const{message:a}=P("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(Xe.malformed_pairing_uri),new Error(a)}const o=vo(i==null?void 0:i.uri);if(!((s=o==null?void 0:o.relay)!=null&&s.protocol)){const{message:a}=P("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(Xe.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=P("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(Xe.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&I.toMiliseconds(o==null?void 0:o.expiryTimestamp)<Date.now()){n.setError(Xe.pairing_expired);const{message:a}=P("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}},this.isValidPing=async i=>{if(!ge(i)){const{message:s}=P("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidDisconnect=async i=>{if(!ge(i)){const{message:s}=P("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidPairingTopic=async i=>{if(!ee(i,!1)){const{message:n}=P("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){const{message:n}=P("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(at(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:n}=P("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}},this.core=e,this.logger=pe(t,this.name),this.pairings=new Mt(this.core,this.logger,this.name,this.storagePrefix)}get context(){return be(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(ne.message,async e=>{const{topic:t,message:i,transportType:n}=e;if(!this.pairings.keys.includes(t)||n===G.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const s=await this.core.crypto.decode(t,i);try{_n(s)?(this.core.history.set(t,s),this.onRelayEventRequest({topic:t,payload:s})):ni(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:t,payload:s}),this.core.history.delete(t,s.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(Te.expired,async e=>{const{topic:t}=Qc(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(Et.expire,{topic:t}))})}}class Qv extends wf{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new He.EventEmitter,this.name=jm,this.version=Vm,this.cached=[],this.initialized=!1,this.storagePrefix=We,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(i,n,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:n,chainId:s}),this.records.has(n.id))return;const o={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:s,expiry:re(I.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Me.created,o)},this.resolve=async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;const n=await this.getRecord(i.id);typeof n.response>"u"&&(n.response=qe(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(Me.updated,n))},this.get=async(i,n)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:n}),await this.getRecord(n)),this.delete=(i,n)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:n}),this.values.forEach(s=>{if(s.topic===i){if(typeof n<"u"&&s.id!==n)return;this.records.delete(s.id),this.events.emit(Me.deleted,s)}}),this.persist()},this.exists=async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1),this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=pe(t,this.name)}get context(){return be(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;const i={topic:t.topic,request:It(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:i}=P("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Me.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:t}=P("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(Me.created,e=>{const t=Me.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(Me.updated,e=>{const t=Me.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(Me.deleted,e=>{const t=Me.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(Zt.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{I.toMiliseconds(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(Me.deleted,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Xv extends xf{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new He.EventEmitter,this.name=Wm,this.version=Hm,this.cached=[],this.initialized=!1,this.storagePrefix=We,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=i=>{try{const n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}},this.set=(i,n)=>{this.isInitialized();const s=this.formatTarget(i),o={target:s,expiry:n};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(Te.created,{target:s,expiration:o})},this.get=i=>{this.isInitialized();const n=this.formatTarget(i);return this.getExpiration(n)},this.del=i=>{if(this.isInitialized(),this.has(i)){const n=this.formatTarget(i),s=this.getExpiration(n);this.expirations.delete(n),this.events.emit(Te.deleted,{target:n,expiration:s})}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=pe(t,this.name)}get context(){return be(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return pp(e);if(typeof e=="number")return gp(e);const{message:t}=P("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Te.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:t}=P("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:i}=P("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return t}checkExpiry(e,t){const{expiry:i}=t;I.toMiliseconds(i)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(Te.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(Zt.pulse,()=>this.checkExpirations()),this.events.on(Te.created,e=>{const t=Te.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Te.expired,e=>{const t=Te.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Te.deleted,e=>{const t=Te.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Zv extends Pf{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,this.name=Jm,this.verifyUrlV3=Ym,this.storagePrefix=We,this.version=Pl,this.init=async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&I.toMiliseconds((n=this.publicKey)==null?void 0:n.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))},this.register=async n=>{if(!Ar()||this.isDevEnv)return;const s=window.location.origin,{id:o,decryptedId:a}=n,c=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${a}`;try{const l=Il(),u=this.startAbortTimer(I.ONE_SECOND*5),h=await new Promise((p,d)=>{const f=()=>{window.removeEventListener("message",y),l.body.removeChild(g),d("attestation aborted")};this.abortController.signal.addEventListener("abort",f);const g=l.createElement("iframe");g.src=c,g.style.display="none",g.addEventListener("error",f,{signal:this.abortController.signal});const y=m=>{if(m.data&&typeof m.data=="string")try{const v=JSON.parse(m.data);if(v.type==="verify_attestation"){if(Hi(v.attestation).payload.id!==o)return;clearInterval(u),l.body.removeChild(g),this.abortController.signal.removeEventListener("abort",f),window.removeEventListener("message",y),p(v.attestation===null?"":v.attestation)}}catch(v){this.logger.warn(v)}};l.body.appendChild(g),window.addEventListener("message",y,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",h),h}catch(l){this.logger.warn(l)}return""},this.resolve=async n=>{if(this.isDevEnv)return"";const{attestationId:s,hash:o,encryptedId:a}=n;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(Hi(s).payload.id!==a)return;const l=await this.isValidJwtAttestation(s);if(l){if(!l.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return l}}if(!o)return;const c=this.getVerifyUrl(n==null?void 0:n.verifyUrl);return this.fetchAttestation(o,c)},this.fetchAttestation=async(n,s)=>{this.logger.debug(`resolving attestation: ${n} from url: ${s}`);const o=this.startAbortTimer(I.ONE_SECOND*5),a=await fetch(`${s}/attestation/${n}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0},this.getVerifyUrl=n=>{let s=n||mr;return Qm.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${mr}`),s=mr),s},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const n=this.startAbortTimer(I.FIVE_SECONDS),s=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(n),await s.json()}catch(n){this.logger.warn(n)}},this.persistPublicKey=async n=>{this.logger.debug("persisting public key to local storage",n),await this.store.setItem(this.storeKey,n),this.publicKey=n},this.removePublicKey=async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0},this.isValidJwtAttestation=async n=>{const s=await this.getPublicKey();try{if(s)return this.validateAttestation(n,s)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(n,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}},this.getPublicKey=async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey(),this.fetchAndPersistPublicKey=async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async s=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),s(o))});const n=await this.fetchPromise;return this.fetchPromise=void 0,n},this.validateAttestation=(n,s)=>{const o=_y(n,s.publicKey),a={hasExpired:I.toMiliseconds(o.exp)<Date.now(),payload:o};if(a.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:a.payload.origin,isScam:a.payload.isScam,isVerified:a.payload.isVerified}},this.logger=pe(t,this.name),this.abortController=new AbortController,this.isDevEnv=Wn(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return be(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),I.toMiliseconds(e))}}class ew extends Af{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.context=Xm,this.registerDeviceToken=async i=>{const{clientId:n,token:s,notificationType:o,enableEncrypted:a=!1}=i,c=`${Zm}/${this.projectId}/clients`;await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:o,token:s,always_raw:a})})},this.logger=pe(t,this.context)}}var tw=Object.defineProperty,Go=Object.getOwnPropertySymbols,rw=Object.prototype.hasOwnProperty,iw=Object.prototype.propertyIsEnumerable,Yo=(r,e,t)=>e in r?tw(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,hr=(r,e)=>{for(var t in e||(e={}))rw.call(e,t)&&Yo(r,t,e[t]);if(Go)for(var t of Go(e))iw.call(e,t)&&Yo(r,t,e[t]);return r};class nw extends Tf{constructor(e,t,i=!0){super(e,t,i),this.core=e,this.logger=t,this.context=t0,this.storagePrefix=We,this.storageVersion=e0,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!Wn())try{const n={eventId:js(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:Hc(this.core.relayer.protocol,this.core.relayer.version,gn)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}},this.createEvent=n=>{const{event:s="ERROR",type:o="",properties:{topic:a,trace:c}}=n,l=js(),u=this.core.projectId||"",h=Date.now(),p=hr({eventId:l,timestamp:h,props:{event:s,type:o,properties:{topic:a,trace:c}},bundleId:u,domain:this.getAppDomain()},this.setMethods(l));return this.telemetryEnabled&&(this.events.set(l,p),this.shouldPersist=!0),p},this.getEvent=n=>{const{eventId:s,topic:o}=n;if(s)return this.events.get(s);const a=Array.from(this.events.values()).find(c=>c.props.properties.topic===o);if(a)return hr(hr({},a),this.setMethods(a.eventId))},this.deleteEvent=n=>{const{eventId:s}=n;this.events.delete(s),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(Zt.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{I.fromMiliseconds(Date.now())-I.fromMiliseconds(n.timestamp)>r0&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})},this.setMethods=n=>({addTrace:s=>this.addTrace(n,s),setError:s=>this.setError(n,s)}),this.addTrace=(n,s)=>{const o=this.events.get(n);o&&(o.props.properties.trace.push(s),this.events.set(n,o),this.shouldPersist=!0)},this.setError=(n,s)=>{const o=this.events.get(n);o&&(o.props.type=s,o.timestamp=Date.now(),this.events.set(n,o),this.shouldPersist=!0)},this.persist=async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1},this.restore=async()=>{try{const n=await this.core.storage.getItem(this.storageKey)||[];if(!n.length)return;n.forEach(s=>{this.events.set(s.eventId,hr(hr({},s),this.setMethods(s.eventId)))})}catch(n){this.logger.warn(n)}},this.submit=async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const n=[];for(const[s,o]of this.events)o.props.type&&n.push(o);if(n.length!==0)try{if((await this.sendEvent(n)).ok)for(const s of n)this.events.delete(s.eventId),this.shouldPersist=!0}catch(s){this.logger.warn(s)}},this.sendEvent=async n=>{const s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${i0}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${gn}${s}`,{method:"POST",body:JSON.stringify(n)})},this.getAppDomain=()=>Wc().url,this.logger=pe(t,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var sw=Object.defineProperty,Qo=Object.getOwnPropertySymbols,ow=Object.prototype.hasOwnProperty,aw=Object.prototype.propertyIsEnumerable,Xo=(r,e,t)=>e in r?sw(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Zo=(r,e)=>{for(var t in e||(e={}))ow.call(e,t)&&Xo(r,t,e[t]);if(Qo)for(var t of Qo(e))aw.call(e,t)&&Xo(r,t,e[t]);return r};let cw=class Ul extends vf{constructor(e){var t;super(e),this.protocol=xl,this.version=Pl,this.name=pn,this.events=new He.EventEmitter,this.initialized=!1,this.on=(o,a)=>this.events.on(o,a),this.once=(o,a)=>this.events.once(o,a),this.off=(o,a)=>this.events.off(o,a),this.removeListener=(o,a)=>this.events.removeListener(o,a),this.dispatchEnvelope=({topic:o,message:a,sessionExists:c})=>{if(!o||!a)return;const l={topic:o,message:a,publishedAt:Date.now(),transportType:G.link_mode};this.relayer.onLinkMessageEvent(l,{sessionExists:c})},this.projectId=e==null?void 0:e.projectId,this.relayUrl=(e==null?void 0:e.relayUrl)||Tl,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=wn({level:typeof(e==null?void 0:e.logger)=="string"&&e.logger?e.logger:Im.logger,name:pn}),{logger:n,chunkLoggerController:s}=iu({opts:i,maxSizeInBytes:e==null?void 0:e.maxLogBlobSizeInBytes,loggerOverride:e==null?void 0:e.logger});this.logChunkController=s,(t=this.logChunkController)!=null&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,a;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((a=this.logChunkController)==null||a.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=pe(n,this.name),this.heartbeat=new Un,this.crypto=new Tv(this,this.logger,e==null?void 0:e.keychain),this.history=new Qv(this,this.logger),this.expirer=new Xv(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new nu(Zo(Zo({},xm),e==null?void 0:e.storageOptions)),this.relayer=new Wv({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Yv(this,this.logger),this.verify=new Zv(this,this.logger,this.storage),this.echoClient=new ew(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new nw(this,this.logger,e==null?void 0:e.telemetryEnabled)}static async init(e){const t=new Ul(e);await t.initialize();const i=await t.crypto.getClientId();return await t.storage.setItem(Fm,i),t}get context(){return be(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(Co,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(Co)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}};const lw=cw;class uw{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class hw{constructor(e){this.client=e}}const Bl="wc",zl=2,Kl="client",es=`${Bl}@${zl}:${Kl}:`,ji={name:Kl,logger:"error"},ea="WALLETCONNECT_DEEPLINK_CHOICE",dw="proposal",fw="Proposal expired",pw="session",Ft=I.SEVEN_DAYS,gw="engine",ie={wc_sessionPropose:{req:{ttl:I.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:I.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:I.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:I.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:I.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:I.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:I.ONE_DAY,prompt:!1,tag:1104},res:{ttl:I.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:I.ONE_DAY,prompt:!1,tag:1106},res:{ttl:I.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:I.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:I.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:I.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:I.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:I.ONE_DAY,prompt:!1,tag:1112},res:{ttl:I.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:I.ONE_DAY,prompt:!1,tag:1114},res:{ttl:I.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:I.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:I.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:I.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:I.FIVE_MINUTES,prompt:!1,tag:1119}}},Vi={min:I.FIVE_MINUTES,max:I.SEVEN_DAYS},je={idle:"IDLE",active:"ACTIVE"},yw="request",mw=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],vw="wc",ww="auth",_w="authKeys",bw="pairingTopics",Ew="requests",_i=`${vw}@${1.5}:${ww}:`,Vr=`${_i}:PUB_KEY`;var Sw=Object.defineProperty,Iw=Object.defineProperties,xw=Object.getOwnPropertyDescriptors,ta=Object.getOwnPropertySymbols,Pw=Object.prototype.hasOwnProperty,Aw=Object.prototype.propertyIsEnumerable,ra=(r,e,t)=>e in r?Sw(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Z=(r,e)=>{for(var t in e||(e={}))Pw.call(e,t)&&ra(r,t,e[t]);if(ta)for(var t of ta(e))Aw.call(e,t)&&ra(r,t,e[t]);return r},De=(r,e)=>Iw(r,xw(e));class Tw extends hw{constructor(e){super(e),this.name=gw,this.events=new aa,this.initialized=!1,this.requestQueue={state:je.idle,queue:[]},this.sessionRequestQueue={state:je.idle,queue:[]},this.requestQueueDelay=I.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(ie)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},I.toMiliseconds(this.requestQueueDelay)))},this.connect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const i=De(Z({},t),{requiredNamespaces:t.requiredNamespaces||{},optionalNamespaces:t.optionalNamespaces||{}});await this.isValidConnect(i);const{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:a,relays:c}=i;let l=n,u,h=!1;try{if(l){const w=this.client.core.pairing.pairings.get(l);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),h=w.active}}catch(w){throw this.client.logger.error(`connect() -> pairing.get(${l}) failed`),w}if(!l||!h){const{topic:w,uri:b}=await this.client.core.pairing.create();l=w,u=b}if(!l){const{message:w}=P("NO_MATCHING_KEY",`connect() pairing topic: ${l}`);throw new Error(w)}const p=await this.client.core.crypto.generateKeyPair(),d=ie.wc_sessionPropose.req.ttl||I.FIVE_MINUTES,f=re(d),g=Z({requiredNamespaces:s,optionalNamespaces:o,relays:c??[{protocol:Al}],proposer:{publicKey:p,metadata:this.client.metadata},expiryTimestamp:f,pairingTopic:l},a&&{sessionProperties:a}),{reject:y,resolve:m,done:v}=bt(d,fw);this.events.once(U("session_connect"),async({error:w,session:b})=>{if(w)y(w);else if(b){b.self.publicKey=p;const E=De(Z({},b),{pairingTopic:g.pairingTopic,requiredNamespaces:g.requiredNamespaces,optionalNamespaces:g.optionalNamespaces,transportType:G.relay});await this.client.session.set(b.topic,E),await this.setExpiry(b.topic,b.expiry),l&&await this.client.core.pairing.updateMetadata({topic:l,metadata:b.peer.metadata}),this.cleanupDuplicatePairings(E),m(E)}});const _=await this.sendRequest({topic:l,method:"wc_sessionPropose",params:g,throwOnFailedPublish:!0});return await this.setProposal(_,Z({id:_},g)),{uri:u,approval:v}},this.pair=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(t)}catch(i){throw this.client.logger.error("pair() failed"),i}},this.approve=async t=>{var i,n,s;const o=this.client.core.eventClient.createEvent({properties:{topic:(i=t==null?void 0:t.id)==null?void 0:i.toString(),trace:[Le.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(x){throw o.setError(wt.no_internet_connection),x}try{await this.isValidProposalId(t==null?void 0:t.id)}catch(x){throw this.client.logger.error(`approve() -> proposal.get(${t==null?void 0:t.id}) failed`),o.setError(wt.proposal_not_found),x}try{await this.isValidApprove(t)}catch(x){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(wt.session_approve_namespace_validation_failure),x}const{id:a,relayProtocol:c,namespaces:l,sessionProperties:u,sessionConfig:h}=t,p=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:d,proposer:f,requiredNamespaces:g,optionalNamespaces:y}=p;let m=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:d});m||(m=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:Le.session_approve_started,properties:{topic:d,trace:[Le.session_approve_started,Le.session_namespaces_validation_success]}}));const v=await this.client.core.crypto.generateKeyPair(),_=f.publicKey,w=await this.client.core.crypto.generateSharedKey(v,_),b=Z(Z({relay:{protocol:c??"irn"},namespaces:l,controller:{publicKey:v,metadata:this.client.metadata},expiry:re(Ft)},u&&{sessionProperties:u}),h&&{sessionConfig:h}),E=G.relay;m.addTrace(Le.subscribing_session_topic);try{await this.client.core.relayer.subscribe(w,{transportType:E})}catch(x){throw m.setError(wt.subscribe_session_topic_failure),x}m.addTrace(Le.subscribe_session_topic_success);const S=De(Z({},b),{topic:w,requiredNamespaces:g,optionalNamespaces:y,pairingTopic:d,acknowledged:!1,self:b.controller,peer:{publicKey:f.publicKey,metadata:f.metadata},controller:v,transportType:G.relay});await this.client.session.set(w,S),m.addTrace(Le.store_session);try{m.addTrace(Le.publishing_session_settle),await this.sendRequest({topic:w,method:"wc_sessionSettle",params:b,throwOnFailedPublish:!0}).catch(x=>{throw m==null||m.setError(wt.session_settle_publish_failure),x}),m.addTrace(Le.session_settle_publish_success),m.addTrace(Le.publishing_session_approve),await this.sendResult({id:a,topic:d,result:{relay:{protocol:c??"irn"},responderPublicKey:v},throwOnFailedPublish:!0}).catch(x=>{throw m==null||m.setError(wt.session_approve_publish_failure),x}),m.addTrace(Le.session_approve_publish_success)}catch(x){throw this.client.logger.error(x),this.client.session.delete(w,H("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(w),x}return this.client.core.eventClient.deleteEvent({eventId:m.eventId}),await this.client.core.pairing.updateMetadata({topic:d,metadata:f.metadata}),await this.client.proposal.delete(a,H("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:d}),await this.setExpiry(w,re(Ft)),{topic:w,acknowledged:()=>Promise.resolve(this.client.session.get(w))}},this.reject=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(t)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}const{id:i,reason:n}=t;let s;try{s=this.client.proposal.get(i).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),o}s&&(await this.sendError({id:i,topic:s,error:n,rpcOpts:ie.wc_sessionPropose.reject}),await this.client.proposal.delete(i,H("USER_DISCONNECTED")))},this.update=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(t)}catch(h){throw this.client.logger.error("update() -> isValidUpdate() failed"),h}const{topic:i,namespaces:n}=t,{done:s,resolve:o,reject:a}=bt(),c=vt(),l=xt().toString(),u=this.client.session.get(i).namespaces;return this.events.once(U("session_update",c),({error:h})=>{h?a(h):o()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:c,relayRpcId:l}).catch(h=>{this.client.logger.error(h),this.client.session.update(i,{namespaces:u}),a(h)}),{acknowledged:s}},this.extend=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(t)}catch(c){throw this.client.logger.error("extend() -> isValidExtend() failed"),c}const{topic:i}=t,n=vt(),{done:s,resolve:o,reject:a}=bt();return this.events.once(U("session_extend",n),({error:c})=>{c?a(c):o()}),await this.setExpiry(i,re(Ft)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(c=>{a(c)}),{acknowledged:s}},this.request=async t=>{this.isInitialized();try{await this.isValidRequest(t)}catch(f){throw this.client.logger.error("request() -> isValidRequest() failed"),f}const{chainId:i,request:n,topic:s,expiry:o=ie.wc_sessionRequest.req.ttl}=t,a=this.client.session.get(s);(a==null?void 0:a.transportType)===G.relay&&await this.confirmOnlineStateOrThrow();const c=vt(),l=xt().toString(),{done:u,resolve:h,reject:p}=bt(o,"Request expired. Please try again.");this.events.once(U("session_request",c),({error:f,result:g})=>{f?p(f):h(g)});const d=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);return d?(await this.sendRequest({clientRpcId:c,relayRpcId:l,topic:s,method:"wc_sessionRequest",params:{request:De(Z({},n),{expiryTimestamp:re(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:d}).catch(f=>p(f)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:c}),await u()):await Promise.all([new Promise(async f=>{await this.sendRequest({clientRpcId:c,relayRpcId:l,topic:s,method:"wc_sessionRequest",params:{request:De(Z({},n),{expiryTimestamp:re(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0}).catch(g=>p(g)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:c}),f()}),new Promise(async f=>{var g;if(!((g=a.sessionConfig)!=null&&g.disableDeepLink)){const y=await _p(this.client.core.storage,ea);await mp({id:c,topic:s,wcDeepLink:y})}f()}),u()]).then(f=>f[2])},this.respond=async t=>{this.isInitialized(),await this.isValidRespond(t);const{topic:i,response:n}=t,{id:s}=n,o=this.client.session.get(i);o.transportType===G.relay&&await this.confirmOnlineStateOrThrow();const a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);Qe(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:a}):qe(n)&&await this.sendError({id:s,topic:i,error:n.error,appLink:a}),this.cleanupAfterResponse(t)},this.ping=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(t)}catch(n){throw this.client.logger.error("ping() -> isValidPing() failed"),n}const{topic:i}=t;if(this.client.session.keys.includes(i)){const n=vt(),s=xt().toString(),{done:o,resolve:a,reject:c}=bt();this.events.once(U("session_ping",n),({error:l})=>{l?c(l):a()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:n,relayRpcId:s}),o()])}else this.client.core.pairing.pairings.keys.includes(i)&&(this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."),await this.client.core.pairing.ping({topic:i}))},this.emit=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(t);const{topic:i,event:n,chainId:s}=t,o=xt().toString(),a=vt();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o,clientRpcId:a})},this.disconnect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(t);const{topic:i}=t;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:H("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:i,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(i))await this.client.core.pairing.disconnect({topic:i});else{const{message:n}=P("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}},this.find=t=>(this.isInitialized(),this.client.session.getAll().filter(i=>Ny(i,t))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(t,i)=>{var n;this.isInitialized(),this.isValidAuthenticate(t);const s=i&&this.client.core.linkModeSupportedApps.includes(i)&&((n=this.client.metadata.redirect)==null?void 0:n.linkMode),o=s?G.link_mode:G.relay;o===G.relay&&await this.confirmOnlineStateOrThrow();const{chains:a,statement:c="",uri:l,domain:u,nonce:h,type:p,exp:d,nbf:f,methods:g=[],expiry:y}=t,m=[...t.resources||[]],{topic:v,uri:_}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:v,uri:_}});const w=await this.client.core.crypto.generateKeyPair(),b=jr(w);if(await Promise.all([this.client.auth.authKeys.set(Vr,{responseTopic:b,publicKey:w}),this.client.auth.pairingTopics.set(b,{topic:b,pairingTopic:v})]),await this.client.core.relayer.subscribe(b,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${v}`),g.length>0){const{namespace:M}=zr(a[0]);let A=ug(M,"request",g);Kr(m)&&(A=dg(A,m.pop())),m.push(A)}const E=y&&y>ie.wc_sessionAuthenticate.req.ttl?y:ie.wc_sessionAuthenticate.req.ttl,S={authPayload:{type:p??"caip122",chains:a,statement:c,aud:l,domain:u,version:"1",nonce:h,iat:new Date().toISOString(),exp:d,nbf:f,resources:m},requester:{publicKey:w,metadata:this.client.metadata},expiryTimestamp:re(E)},x={eip155:{chains:a,methods:[...new Set(["personal_sign",...g])],events:["chainChanged","accountsChanged"]}},C={requiredNamespaces:{},optionalNamespaces:x,relays:[{protocol:"irn"}],pairingTopic:v,proposer:{publicKey:w,metadata:this.client.metadata},expiryTimestamp:re(ie.wc_sessionPropose.req.ttl)},{done:N,resolve:O,reject:D}=bt(E,"Request expired"),$=async({error:M,session:A})=>{if(this.events.off(U("session_request",F),q),M)D(M);else if(A){A.self.publicKey=w,await this.client.session.set(A.topic,A),await this.setExpiry(A.topic,A.expiry),v&&await this.client.core.pairing.updateMetadata({topic:v,metadata:A.peer.metadata});const j=this.client.session.get(A.topic);await this.deleteProposal(B),O({session:j})}},q=async M=>{var A,j,J;if(await this.deletePendingAuthRequest(F,{message:"fulfilled",code:0}),M.error){const Pe=H("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return M.error.code===Pe.code?void 0:(this.events.off(U("session_connect"),$),D(M.error.message))}await this.deleteProposal(B),this.events.off(U("session_connect"),$);const{cacaos:W,responder:te}=M.result,me=[],Ie=[];for(const Pe of W){await Xs({cacao:Pe,projectId:this.client.core.projectId})||(this.client.logger.error(Pe,"Signature verification failed"),D(H("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:ze}=Pe,bi=Kr(ze.resources),is=[an(ze.iss)],jl=ei(ze.iss);if(bi){const Ei=Zs(bi),Vl=eo(bi);me.push(...Ei),is.push(...Vl)}for(const Ei of is)Ie.push(`${Ei}:${jl}`)}const xe=await this.client.core.crypto.generateSharedKey(w,te.publicKey);let ke;me.length>0&&(ke={topic:xe,acknowledged:!0,self:{publicKey:w,metadata:this.client.metadata},peer:te,controller:te.publicKey,expiry:re(Ft),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:v,namespaces:_o([...new Set(me)],[...new Set(Ie)]),transportType:o},await this.client.core.relayer.subscribe(xe,{transportType:o}),await this.client.session.set(xe,ke),v&&await this.client.core.pairing.updateMetadata({topic:v,metadata:te.metadata}),ke=this.client.session.get(xe)),(A=this.client.metadata.redirect)!=null&&A.linkMode&&(j=te.metadata.redirect)!=null&&j.linkMode&&(J=te.metadata.redirect)!=null&&J.universal&&i&&(this.client.core.addLinkModeSupportedApp(te.metadata.redirect.universal),this.client.session.update(xe,{transportType:G.link_mode})),O({auths:W,session:ke})},F=vt(),B=vt();this.events.once(U("session_connect"),$),this.events.once(U("session_request",F),q);let K;try{if(s){const M=It("wc_sessionAuthenticate",S,F);this.client.core.history.set(v,M);const A=await this.client.core.crypto.encode("",M,{type:Nr,encoding:or});K=Fr(i,v,A)}else await Promise.all([this.sendRequest({topic:v,method:"wc_sessionAuthenticate",params:S,expiry:t.expiry,throwOnFailedPublish:!0,clientRpcId:F}),this.sendRequest({topic:v,method:"wc_sessionPropose",params:C,expiry:ie.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:B})])}catch(M){throw this.events.off(U("session_connect"),$),this.events.off(U("session_request",F),q),M}return await this.setProposal(B,Z({id:B},C)),await this.setAuthRequest(F,{request:De(Z({},S),{verifyContext:{}}),pairingTopic:v,transportType:o}),{uri:K??_,response:N}},this.approveSessionAuthenticate=async t=>{const{id:i,auths:n}=t,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[_t.authenticated_session_approve_started]}});try{this.isInitialized()}catch(y){throw s.setError(lr.no_internet_connection),y}const o=this.getPendingAuthRequest(i);if(!o)throw s.setError(lr.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);const a=o.transportType||G.relay;a===G.relay&&await this.confirmOnlineStateOrThrow();const c=o.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),u=jr(c),h={type:rt,receiverPublicKey:c,senderPublicKey:l},p=[],d=[];for(const y of n){if(!await Xs({cacao:y,projectId:this.client.core.projectId})){s.setError(lr.invalid_cacao);const b=H("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:u,error:b,encodeOpts:h}),new Error(b.message)}s.addTrace(_t.cacaos_verified);const{p:m}=y,v=Kr(m.resources),_=[an(m.iss)],w=ei(m.iss);if(v){const b=Zs(v),E=eo(v);p.push(...b),_.push(...E)}for(const b of _)d.push(`${b}:${w}`)}const f=await this.client.core.crypto.generateSharedKey(l,c);s.addTrace(_t.create_authenticated_session_topic);let g;if((p==null?void 0:p.length)>0){g={topic:f,acknowledged:!0,self:{publicKey:l,metadata:this.client.metadata},peer:{publicKey:c,metadata:o.requester.metadata},controller:c,expiry:re(Ft),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:_o([...new Set(p)],[...new Set(d)]),transportType:a},s.addTrace(_t.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(f,{transportType:a})}catch(y){throw s.setError(lr.subscribe_authenticated_session_topic_failure),y}s.addTrace(_t.subscribe_authenticated_session_topic_success),await this.client.session.set(f,g),s.addTrace(_t.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(_t.publishing_authenticated_session_approve);try{await this.sendResult({topic:u,id:i,result:{cacaos:n,responder:{publicKey:l,metadata:this.client.metadata}},encodeOpts:h,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(y){throw s.setError(lr.authenticated_session_approve_publish_failure),y}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:s.eventId}),{session:g}},this.rejectSessionAuthenticate=async t=>{this.isInitialized();const{id:i,reason:n}=t,s=this.getPendingAuthRequest(i);if(!s)throw new Error(`Could not find pending auth request with id ${i}`);s.transportType===G.relay&&await this.confirmOnlineStateOrThrow();const o=s.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),c=jr(o),l={type:rt,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:i,topic:c,error:n,encodeOpts:l,rpcOpts:ie.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(s.requester.metadata,s.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,H("USER_DISCONNECTED"))},this.formatAuthMessage=t=>{this.isInitialized();const{request:i,iss:n}=t;return ol(i,n)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const t=this.relayMessageCache.shift();t&&await this.onRelayMessage(t)}catch(t){this.client.logger.error(t)}},50)},this.cleanupDuplicatePairings=async t=>{if(t.pairingTopic)try{const i=this.client.core.pairing.pairings.get(t.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(s=>{var o,a;return((o=s.peerMetadata)==null?void 0:o.url)&&((a=s.peerMetadata)==null?void 0:a.url)===t.peer.metadata.url&&s.topic&&s.topic!==i.topic});if(n.length===0)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map(s=>this.client.core.pairing.disconnect({topic:s.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}},this.deleteSession=async t=>{var i;const{topic:n,expirerHasDeleted:s=!1,emitEvent:o=!0,id:a=0}=t,{self:c}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,H("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(c.publicKey)&&await this.client.core.crypto.deleteKeyPair(c.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),s||this.client.core.expirer.del(n),this.client.core.storage.removeItem(ea).catch(l=>this.client.logger.warn(l)),this.getPendingSessionRequests().forEach(l=>{l.topic===n&&this.deletePendingSessionRequest(l.id,H("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=je.idle),o&&this.client.events.emit("session_delete",{id:a,topic:n})},this.deleteProposal=async(t,i)=>{if(i)try{const n=this.client.proposal.get(t),s=this.client.core.eventClient.getEvent({topic:n.pairingTopic});s==null||s.setError(wt.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(t,H("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"proposal")},this.deletePendingSessionRequest=async(t,i,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(s=>s.id!==t),n&&(this.sessionRequestQueue.state=je.idle,this.client.events.emit("session_request_expire",{id:t}))},this.deletePendingAuthRequest=async(t,i,n=!1)=>{await Promise.all([this.client.auth.requests.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)])},this.setExpiry=async(t,i)=>{this.client.session.keys.includes(t)&&(this.client.core.expirer.set(t,i),await this.client.session.update(t,{expiry:i}))},this.setProposal=async(t,i)=>{this.client.core.expirer.set(t,re(ie.wc_sessionPropose.req.ttl)),await this.client.proposal.set(t,i)},this.setAuthRequest=async(t,i)=>{const{request:n,pairingTopic:s,transportType:o=G.relay}=i;this.client.core.expirer.set(t,n.expiryTimestamp),await this.client.auth.requests.set(t,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:t,pairingTopic:s,verifyContext:n.verifyContext,transportType:o})},this.setPendingSessionRequest=async t=>{const{id:i,topic:n,params:s,verifyContext:o}=t,a=s.request.expiryTimestamp||re(ie.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,a),await this.client.pendingRequest.set(i,{id:i,topic:n,params:s,verifyContext:o})},this.sendRequest=async t=>{const{topic:i,method:n,params:s,expiry:o,relayRpcId:a,clientRpcId:c,throwOnFailedPublish:l,appLink:u}=t,h=It(n,s,c);let p;const d=!!u;try{const y=d?or:ut;p=await this.client.core.crypto.encode(i,h,{encoding:y})}catch(y){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),y}let f;if(mw.includes(n)){const y=Ze(JSON.stringify(h)),m=Ze(p);f=await this.client.core.verify.register({id:m,decryptedId:y})}const g=ie[n].req;if(g.attestation=f,o&&(g.ttl=o),a&&(g.id=a),this.client.core.history.set(i,h),d){const y=Fr(u,i,p);await R.global.Linking.openURL(y,this.client.name)}else{const y=ie[n].req;o&&(y.ttl=o),a&&(y.id=a),l?(y.internal=De(Z({},y.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,p,y)):this.client.core.relayer.publish(i,p,y).catch(m=>this.client.logger.error(m))}return h.id},this.sendResult=async t=>{const{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:a,appLink:c}=t,l=bn(i,s);let u;const h=c&&typeof(R.global==null?void 0:R.global.Linking)<"u";try{const d=h?or:ut;u=await this.client.core.crypto.encode(n,l,De(Z({},a||{}),{encoding:d}))}catch(d){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),d}let p;try{p=await this.client.core.history.get(n,i)}catch(d){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),d}if(h){const d=Fr(c,n,u);await R.global.Linking.openURL(d,this.client.name)}else{const d=ie[p.request.method].res;o?(d.internal=De(Z({},d.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,u,d)):this.client.core.relayer.publish(n,u,d).catch(f=>this.client.logger.error(f))}await this.client.core.history.resolve(l)},this.sendError=async t=>{const{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:a,appLink:c}=t,l=vn(i,s);let u;const h=c&&typeof(R.global==null?void 0:R.global.Linking)<"u";try{const d=h?or:ut;u=await this.client.core.crypto.encode(n,l,De(Z({},o||{}),{encoding:d}))}catch(d){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),d}let p;try{p=await this.client.core.history.get(n,i)}catch(d){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),d}if(h){const d=Fr(c,n,u);await R.global.Linking.openURL(d,this.client.name)}else{const d=a||ie[p.request.method].res;this.client.core.relayer.publish(n,u,d)}await this.client.core.history.resolve(l)},this.cleanup=async()=>{const t=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;at(n.expiry)&&(s=!0),this.client.core.crypto.keychain.has(n.topic)||(s=!0),s&&t.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{at(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...t.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])},this.onRelayEventRequest=async t=>{this.requestQueue.queue.push(t),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===je.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=je.active;const t=this.requestQueue.queue.shift();if(t)try{await this.processRequest(t)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=je.idle},this.processRequest=async t=>{const{topic:i,payload:n,attestation:s,transportType:o,encryptedId:a}=t,c=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:c}))switch(c){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:n,attestation:s,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,n);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,n);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,n);case"wc_sessionPing":return await this.onSessionPingRequest(i,n);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,n);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:n,attestation:s,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(i,n);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:n,attestation:s,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${c}`)}},this.onRelayEventResponse=async t=>{const{topic:i,payload:n,transportType:s}=t,o=(await this.client.core.history.get(i,n.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(i,n,s);case"wc_sessionSettle":return this.onSessionSettleResponse(i,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,n);case"wc_sessionExtend":return this.onSessionExtendResponse(i,n);case"wc_sessionPing":return this.onSessionPingResponse(i,n);case"wc_sessionRequest":return this.onSessionRequestResponse(i,n);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,n);default:return this.client.logger.info(`Unsupported response method ${o}`)}},this.onRelayEventUnknownPayload=t=>{const{topic:i}=t,{message:n}=P("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)},this.shouldIgnorePairingRequest=t=>{const{topic:i,requestMethod:n}=t,s=this.expectedPairingMethodMap.get(i);return!s||s.includes(n)?!1:!!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async t=>{const{topic:i,payload:n,attestation:s,encryptedId:o}=t,{params:a,id:c}=n;try{const l=this.client.core.eventClient.getEvent({topic:i});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),l==null||l.setError(Xe.proposal_listener_not_found)),this.isValidConnect(Z({},n.params));const u=a.expiryTimestamp||re(ie.wc_sessionPropose.req.ttl),h=Z({id:c,pairingTopic:i,expiryTimestamp:u},a);await this.setProposal(c,h);const p=await this.getVerifyContext({attestationId:s,hash:Ze(JSON.stringify(n)),encryptedId:o,metadata:h.proposer.metadata});l==null||l.addTrace(Ve.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:h,verifyContext:p})}catch(l){await this.sendError({id:c,topic:i,error:l,rpcOpts:ie.wc_sessionPropose.autoReject}),this.client.logger.error(l)}},this.onSessionProposeResponse=async(t,i,n)=>{const{id:s}=i;if(Qe(i)){const{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const a=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});const c=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:c});const l=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:l});const u=await this.client.core.crypto.generateSharedKey(c,l);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:u});const h=await this.client.core.relayer.subscribe(u,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:h}),await this.client.core.pairing.activate({topic:t})}else if(qe(i)){await this.client.proposal.delete(s,H("USER_DISCONNECTED"));const o=U("session_connect");if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(U("session_connect"),{error:i.error})}},this.onSessionSettleRequest=async(t,i)=>{const{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);const{relay:o,controller:a,expiry:c,namespaces:l,sessionProperties:u,sessionConfig:h}=i.params,p=De(Z(Z({topic:t,relay:o,expiry:c,namespaces:l,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:a.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},u&&{sessionProperties:u}),h&&{sessionConfig:h}),{transportType:G.relay}),d=U("session_connect");if(this.events.listenerCount(d)===0)throw new Error(`emitting ${d} without any listeners 997`);this.events.emit(U("session_connect"),{session:p}),await this.sendResult({id:i.id,topic:t,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionSettleResponse=async(t,i)=>{const{id:n}=i;Qe(i)?(await this.client.session.update(t,{acknowledged:!0}),this.events.emit(U("session_approve",n),{})):qe(i)&&(await this.client.session.delete(t,H("USER_DISCONNECTED")),this.events.emit(U("session_approve",n),{error:i.error}))},this.onSessionUpdateRequest=async(t,i)=>{const{params:n,id:s}=i;try{const o=`${t}_session_update`,a=ar.get(o);if(a&&this.isRequestOutOfSync(a,s)){this.client.logger.warn(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:t,error:H("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(Z({topic:t},n));try{ar.set(o,s),await this.client.session.update(t,{namespaces:n.namespaces}),await this.sendResult({id:s,topic:t,result:!0,throwOnFailedPublish:!0})}catch(c){throw ar.delete(o),c}this.client.events.emit("session_update",{id:s,topic:t,params:n})}catch(o){await this.sendError({id:s,topic:t,error:o}),this.client.logger.error(o)}},this.isRequestOutOfSync=(t,i)=>i.toString().slice(0,-3)<t.toString().slice(0,-3),this.onSessionUpdateResponse=(t,i)=>{const{id:n}=i,s=U("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Qe(i)?this.events.emit(U("session_update",n),{}):qe(i)&&this.events.emit(U("session_update",n),{error:i.error})},this.onSessionExtendRequest=async(t,i)=>{const{id:n}=i;try{this.isValidExtend({topic:t}),await this.setExpiry(t,re(Ft)),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionExtendResponse=(t,i)=>{const{id:n}=i,s=U("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Qe(i)?this.events.emit(U("session_extend",n),{}):qe(i)&&this.events.emit(U("session_extend",n),{error:i.error})},this.onSessionPingRequest=async(t,i)=>{const{id:n}=i;try{this.isValidPing({topic:t}),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionPingResponse=(t,i)=>{const{id:n}=i,s=U("session_ping",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{Qe(i)?this.events.emit(U("session_ping",n),{}):qe(i)&&this.events.emit(U("session_ping",n),{error:i.error})},500)},this.onSessionDeleteRequest=async(t,i)=>{const{id:n}=i;try{this.isValidDisconnect({topic:t,reason:i.params}),Promise.all([new Promise(s=>{this.client.core.relayer.once(ne.publish,async()=>{s(await this.deleteSession({topic:t,id:n}))})}),this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:t,error:H("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}},this.onSessionRequest=async t=>{var i,n,s;const{topic:o,payload:a,attestation:c,encryptedId:l,transportType:u}=t,{id:h,params:p}=a;try{await this.isValidRequest(Z({topic:o},p));const d=this.client.session.get(o),f=await this.getVerifyContext({attestationId:c,hash:Ze(JSON.stringify(It("wc_sessionRequest",p,h))),encryptedId:l,metadata:d.peer.metadata,transportType:u}),g={id:h,topic:o,params:p,verifyContext:f};await this.setPendingSessionRequest(g),u===G.link_mode&&(i=d.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=d.peer.metadata.redirect)==null?void 0:n.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(g):(this.addSessionRequestToSessionRequestQueue(g),this.processSessionRequestQueue())}catch(d){await this.sendError({id:h,topic:o,error:d}),this.client.logger.error(d)}},this.onSessionRequestResponse=(t,i)=>{const{id:n}=i,s=U("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Qe(i)?this.events.emit(U("session_request",n),{result:i.result}):qe(i)&&this.events.emit(U("session_request",n),{error:i.error})},this.onSessionEventRequest=async(t,i)=>{const{id:n,params:s}=i;try{const o=`${t}_session_event_${s.event.name}`,a=ar.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(Z({topic:t},s)),this.client.events.emit("session_event",{id:n,topic:t,params:s}),ar.set(o,n)}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionAuthenticateResponse=(t,i)=>{const{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:t,payload:i}),Qe(i)?this.events.emit(U("session_request",n),{result:i.result}):qe(i)&&this.events.emit(U("session_request",n),{error:i.error})},this.onSessionAuthenticateRequest=async t=>{var i;const{topic:n,payload:s,attestation:o,encryptedId:a,transportType:c}=t;try{const{requester:l,authPayload:u,expiryTimestamp:h}=s.params,p=await this.getVerifyContext({attestationId:o,hash:Ze(JSON.stringify(s)),encryptedId:a,metadata:l.metadata,transportType:c}),d={requester:l,pairingTopic:n,id:s.id,authPayload:u,verifyContext:p,expiryTimestamp:h};await this.setAuthRequest(s.id,{request:d,pairingTopic:n,transportType:c}),c===G.link_mode&&(i=l.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(l.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:s.params,id:s.id,verifyContext:p})}catch(l){this.client.logger.error(l);const u=s.params.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),p=this.getAppLinkIfEnabled(s.params.requester.metadata,c),d={type:rt,receiverPublicKey:u,senderPublicKey:h};await this.sendError({id:s.id,topic:n,error:l,encodeOpts:d,rpcOpts:ie.wc_sessionAuthenticate.autoReject,appLink:p})}},this.addSessionRequestToSessionRequestQueue=t=>{this.sessionRequestQueue.queue.push(t)},this.cleanupAfterResponse=t=>{this.deletePendingSessionRequest(t.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=je.idle,this.processSessionRequestQueue()},I.toMiliseconds(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:t,error:i})=>{const n=this.client.core.history.pending;n.length>0&&n.filter(s=>s.topic===t&&s.request.method==="wc_sessionRequest").forEach(s=>{const o=s.request.id,a=U("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(U("session_request",s.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===je.active){this.client.logger.info("session request queue is already active.");return}const t=this.sessionRequestQueue.queue[0];if(!t){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=je.active,this.emitSessionRequest(t)}catch(i){this.client.logger.error(i)}},this.emitSessionRequest=t=>{this.client.events.emit("session_request",t)},this.onPairingCreated=t=>{if(t.methods&&this.expectedPairingMethodMap.set(t.topic,t.methods),t.active)return;const i=this.client.proposal.getAll().find(n=>n.pairingTopic===t.topic);i&&this.onSessionProposeRequest({topic:t.topic,payload:It("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})},this.isValidConnect=async t=>{if(!ge(t)){const{message:c}=P("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(t)}`);throw new Error(c)}const{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:s,sessionProperties:o,relays:a}=t;if(de(i)||await this.isValidPairingTopic(i),!Ky(a)){const{message:c}=P("MISSING_OR_INVALID",`connect() relays: ${a}`);throw new Error(c)}!de(n)&&ri(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!de(s)&&ri(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),de(o)||this.validateSessionProps(o,"sessionProperties")},this.validateNamespaces=(t,i)=>{const n=zy(t,"connect()",i);if(n)throw new Error(n.message)},this.isValidApprove=async t=>{if(!ge(t))throw new Error(P("MISSING_OR_INVALID",`approve() params: ${t}`).message);const{id:i,namespaces:n,relayProtocol:s,sessionProperties:o}=t;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);const a=this.client.proposal.get(i),c=Ui(n,"approve()");if(c)throw new Error(c.message);const l=So(a.requiredNamespaces,n,"approve()");if(l)throw new Error(l.message);if(!ee(s,!0)){const{message:u}=P("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(u)}de(o)||this.validateSessionProps(o,"sessionProperties")},this.isValidReject=async t=>{if(!ge(t)){const{message:s}=P("MISSING_OR_INVALID",`reject() params: ${t}`);throw new Error(s)}const{id:i,reason:n}=t;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!Vy(n)){const{message:s}=P("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidSessionSettleRequest=t=>{if(!ge(t)){const{message:l}=P("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${t}`);throw new Error(l)}const{relay:i,controller:n,namespaces:s,expiry:o}=t;if(!Sl(i)){const{message:l}=P("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(l)}const a=Ly(n,"onSessionSettleRequest()");if(a)throw new Error(a.message);const c=Ui(s,"onSessionSettleRequest()");if(c)throw new Error(c.message);if(at(o)){const{message:l}=P("EXPIRED","onSessionSettleRequest()");throw new Error(l)}},this.isValidUpdate=async t=>{if(!ge(t)){const{message:c}=P("MISSING_OR_INVALID",`update() params: ${t}`);throw new Error(c)}const{topic:i,namespaces:n}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const s=this.client.session.get(i),o=Ui(n,"update()");if(o)throw new Error(o.message);const a=So(s.requiredNamespaces,n,"update()");if(a)throw new Error(a.message)},this.isValidExtend=async t=>{if(!ge(t)){const{message:n}=P("MISSING_OR_INVALID",`extend() params: ${t}`);throw new Error(n)}const{topic:i}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)},this.isValidRequest=async t=>{if(!ge(t)){const{message:c}=P("MISSING_OR_INVALID",`request() params: ${t}`);throw new Error(c)}const{topic:i,request:n,chainId:s,expiry:o}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const{namespaces:a}=this.client.session.get(i);if(!Eo(a,s)){const{message:c}=P("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(c)}if(!Wy(n)){const{message:c}=P("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(c)}if(!Gy(a,s,n.method)){const{message:c}=P("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(c)}if(o&&!Zy(o,Vi)){const{message:c}=P("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${Vi.min} and ${Vi.max}`);throw new Error(c)}},this.isValidRespond=async t=>{var i;if(!ge(t)){const{message:o}=P("MISSING_OR_INVALID",`respond() params: ${t}`);throw new Error(o)}const{topic:n,response:s}=t;try{await this.isValidSessionTopic(n)}catch(o){throw(i=t==null?void 0:t.response)!=null&&i.id&&this.cleanupAfterResponse(t),o}if(!Hy(s)){const{message:o}=P("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}},this.isValidPing=async t=>{if(!ge(t)){const{message:n}=P("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(n)}const{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async t=>{if(!ge(t)){const{message:a}=P("MISSING_OR_INVALID",`emit() params: ${t}`);throw new Error(a)}const{topic:i,event:n,chainId:s}=t;await this.isValidSessionTopic(i);const{namespaces:o}=this.client.session.get(i);if(!Eo(o,s)){const{message:a}=P("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(a)}if(!Jy(n)){const{message:a}=P("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}if(!Yy(o,s,n.name)){const{message:a}=P("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}},this.isValidDisconnect=async t=>{if(!ge(t)){const{message:n}=P("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(n)}const{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidAuthenticate=t=>{const{chains:i,uri:n,domain:s,nonce:o}=t;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!ee(n,!1))throw new Error("uri is required parameter");if(!ee(s,!1))throw new Error("domain is required parameter");if(!ee(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(c=>zr(c).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=zr(i[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async t=>{const{attestationId:i,hash:n,encryptedId:s,metadata:o,transportType:a}=t,c={verified:{verifyUrl:o.verifyUrl||mr,validation:"UNKNOWN",origin:o.url||""}};try{if(a===G.link_mode){const u=this.getAppLinkIfEnabled(o,a);return c.verified.validation=u&&new URL(u).origin===new URL(o.url).origin?"VALID":"INVALID",c}const l=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:s,verifyUrl:o.verifyUrl});l&&(c.verified.origin=l.origin,c.verified.isScam=l.isScam,c.verified.validation=l.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(l){this.client.logger.warn(l)}return this.client.logger.debug(`Verify context: ${JSON.stringify(c)}`),c},this.validateSessionProps=(t,i)=>{Object.values(t).forEach(n=>{if(!ee(n,!1)){const{message:s}=P("MISSING_OR_INVALID",`${i} must be in Record<string, string> format. Received: ${JSON.stringify(n)}`);throw new Error(s)}})},this.getPendingAuthRequest=t=>{const i=this.client.auth.requests.get(t);return typeof i=="object"?i:void 0},this.addToRecentlyDeleted=(t,i)=>{if(this.recentlyDeletedMap.set(t,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let n=0;const s=this.recentlyDeletedLimit/2;for(const o of this.recentlyDeletedMap.keys()){if(n++>=s)break;this.recentlyDeletedMap.delete(o)}}},this.checkRecentlyDeleted=t=>{const i=this.recentlyDeletedMap.get(t);if(i){const{message:n}=P("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${t}`);throw new Error(n)}},this.isLinkModeEnabled=(t,i)=>{var n,s,o,a,c,l,u,h,p;return!t||i!==G.link_mode?!1:((s=(n=this.client.metadata)==null?void 0:n.redirect)==null?void 0:s.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((l=(c=this.client.metadata)==null?void 0:c.redirect)==null?void 0:l.universal)!==""&&((u=t==null?void 0:t.redirect)==null?void 0:u.universal)!==void 0&&((h=t==null?void 0:t.redirect)==null?void 0:h.universal)!==""&&((p=t==null?void 0:t.redirect)==null?void 0:p.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(t.redirect.universal)&&typeof(R.global==null?void 0:R.global.Linking)<"u"},this.getAppLinkIfEnabled=(t,i)=>{var n;return this.isLinkModeEnabled(t,i)?(n=t==null?void 0:t.redirect)==null?void 0:n.universal:void 0},this.handleLinkModeMessage=({url:t})=>{if(!t||!t.includes("wc_ev")||!t.includes("topic"))return;const i=Ks(t,"topic")||"",n=decodeURIComponent(Ks(t,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:G.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})},this.registerLinkModeListeners=async()=>{var t;if(Wn()||mt()&&(t=this.client.metadata.redirect)!=null&&t.linkMode){const i=R.global==null?void 0:R.global.Linking;if(typeof i<"u"){i.addEventListener("url",this.handleLinkModeMessage,this.client.name);const n=await i.getInitialURL();n&&setTimeout(()=>{this.handleLinkModeMessage({url:n})},50)}}}}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(ne.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){const{topic:t,message:i,attestation:n,transportType:s}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(Vr)?this.client.auth.authKeys.get(Vr):{publicKey:void 0},a=await this.client.core.crypto.decode(t,i,{receiverPublicKey:o,encoding:s===G.link_mode?or:ut});try{_n(a)?(this.client.core.history.set(t,a),this.onRelayEventRequest({topic:t,payload:a,attestation:n,transportType:s,encryptedId:Ze(i)})):ni(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:t,payload:a,transportType:s}),this.client.core.history.delete(t,a.id)):this.onRelayEventUnknownPayload({topic:t,payload:a,transportType:s})}catch(c){this.client.logger.error(c)}}registerExpirerEvents(){this.client.core.expirer.on(Te.expired,async e=>{const{topic:t,id:i}=Qc(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,P("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,P("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(Et.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(Et.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!ee(e,!1)){const{message:t}=P("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=P("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(at(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=P("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!ee(e,!1)){const{message:t}=P("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:t}=P("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(at(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:t}=P("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){const{message:t}=P("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(ee(e,!1)){const{message:t}=P("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}else{const{message:t}=P("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}async isValidProposalId(e){if(!jy(e)){const{message:t}=P("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=P("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(at(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:t}=P("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class Rw extends Mt{constructor(e,t){super(e,t,dw,es),this.core=e,this.logger=t}}class Cw extends Mt{constructor(e,t){super(e,t,pw,es),this.core=e,this.logger=t}}class Nw extends Mt{constructor(e,t){super(e,t,yw,es,i=>i.id),this.core=e,this.logger=t}}class Ow extends Mt{constructor(e,t){super(e,t,_w,_i,()=>Vr),this.core=e,this.logger=t}}class $w extends Mt{constructor(e,t){super(e,t,bw,_i),this.core=e,this.logger=t}}class kw extends Mt{constructor(e,t){super(e,t,Ew,_i,i=>i.id),this.core=e,this.logger=t}}class Mw{constructor(e,t){this.core=e,this.logger=t,this.authKeys=new Ow(this.core,this.logger),this.pairingTopics=new $w(this.core,this.logger),this.requests=new kw(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}class ts extends uw{constructor(e){super(e),this.protocol=Bl,this.version=zl,this.name=ji.name,this.events=new He.EventEmitter,this.on=(i,n)=>this.events.on(i,n),this.once=(i,n)=>this.events.once(i,n),this.off=(i,n)=>this.events.off(i,n),this.removeListener=(i,n)=>this.events.removeListener(i,n),this.removeAllListeners=i=>this.events.removeAllListeners(i),this.connect=async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}},this.pair=async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}},this.approve=async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}},this.reject=async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}},this.update=async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}},this.extend=async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}},this.request=async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}},this.respond=async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}},this.ping=async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}},this.emit=async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}},this.disconnect=async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}},this.find=i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}},this.authenticate=async(i,n)=>{try{return await this.engine.authenticate(i,n)}catch(s){throw this.logger.error(s.message),s}},this.formatAuthMessage=i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}},this.approveSessionAuthenticate=async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.rejectSessionAuthenticate=async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.name=(e==null?void 0:e.name)||ji.name,this.metadata=(e==null?void 0:e.metadata)||Wc(),this.signConfig=e==null?void 0:e.signConfig;const t=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:ca(wn({level:(e==null?void 0:e.logger)||ji.logger}));this.core=(e==null?void 0:e.core)||new lw(e),this.logger=pe(t,this.name),this.session=new Cw(this.core,this.logger),this.proposal=new Rw(this.core,this.logger),this.pendingRequest=new Nw(this.core,this.logger),this.engine=new Tw(this),this.auth=new Mw(this.core,this.logger)}static async init(e){const t=new ts(e);return await t.initialize(),t}get context(){return be(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),setTimeout(()=>{this.engine.processRelayMessageCache()},I.toMiliseconds(I.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}function Lw(r){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),t=0;t<e.length;t++)e[t]=255;for(var i=0;i<r.length;i++){var n=r.charAt(i),s=n.charCodeAt(0);if(e[s]!==255)throw new TypeError(n+" is ambiguous");e[s]=i}var o=r.length,a=r.charAt(0),c=Math.log(o)/Math.log(256),l=Math.log(256)/Math.log(o);function u(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var f=0,g=0,y=0,m=d.length;y!==m&&d[y]===0;)y++,f++;for(var v=(m-y)*l+1>>>0,_=new Uint8Array(v);y!==m;){for(var w=d[y],b=0,E=v-1;(w!==0||b<g)&&E!==-1;E--,b++)w+=256*_[E]>>>0,_[E]=w%o>>>0,w=w/o>>>0;if(w!==0)throw new Error("Non-zero carry");g=b,y++}for(var S=v-g;S!==v&&_[S]===0;)S++;for(var x=a.repeat(f);S<v;++S)x+=r.charAt(_[S]);return x}function h(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;for(var f=0,g=0,y=0;d[f]===a;)g++,f++;for(var m=(d.length-f)*c+1>>>0,v=new Uint8Array(m);d[f];){var _=e[d.charCodeAt(f)];if(_===255)return;for(var w=0,b=m-1;(_!==0||w<y)&&b!==-1;b--,w++)_+=o*v[b]>>>0,v[b]=_%256>>>0,_=_/256>>>0;if(_!==0)throw new Error("Non-zero carry");y=w,f++}for(var E=m-y;E!==m&&v[E]===0;)E++;for(var S=new Uint8Array(g+(m-E)),x=g;E!==m;)S[x++]=v[E++];return S}function p(d){var f=h(d);if(f)return f;throw new Error("Non-base"+o+" character")}return{encode:u,decodeUnsafe:h,decode:p}}var Dw=Lw;const Fw=Dw,qw="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var Uw=Fw(qw);const Wi=oa(Uw);class St extends Error{constructor(){super(),Object.setPrototypeOf(this,St.prototype)}}class rs extends Error{constructor(){super(),Object.setPrototypeOf(this,rs.prototype)}}var ia;(function(r){r.Mainnet="solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",r.Devnet="solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"})(ia||(ia={}));var Yt;(function(r){r.signTransaction="solana_signTransaction",r.signMessage="solana_signMessage"})(Yt||(Yt={}));const na=r=>({requiredNamespaces:{solana:{chains:[r],methods:[Yt.signTransaction,Yt.signMessage],events:[]}}}),Bw=r=>"version"in r;class s_{constructor(e){this._options=e.options,this._network=e.network}async connect(){const e=this._client??await ts.init(this._options),t=e.find(na(this._network)).filter(i=>i.acknowledged);if(t.length)return this._session=t[t.length-1],this._client=e,{publicKey:this.publicKey};{const{uri:i,approval:n}=await e.connect(na(this._network));return new Promise((s,o)=>{i&&Ls.open(i,()=>{o(new rs)}),n().then(a=>{this._session=a,this._client=e,s({publicKey:this.publicKey})}).catch(o).finally(()=>{Ls.close()})})}}async disconnect(){if(this._client&&this._session)await this._client.disconnect({topic:this._session.topic,reason:H("USER_DISCONNECTED")}),this._session=void 0;else throw new St}get client(){if(this._client)return Object.assign({},this._client,{off:this._client.removeListener});throw new St}get publicKey(){if(this._client&&this._session){const{address:e}=sp(this._session.namespaces.solana.accounts[0]);return new Jl(e)}else throw new St}async signTransaction(e){if(this._client&&this._session){let t,i;Bw(e)?(t=R.Buffer.from(e.serialize()).toString("base64"),e.version==="legacy"&&(i=Gl.from(e.serialize()))):(t=e.serialize({requireAllSignatures:!1,verifySignatures:!1}).toString("base64"),i=e);const{signature:n}=await this._client.request({chainId:this._network,topic:this._session.topic,request:{method:Yt.signTransaction,params:{...i,transaction:t}}});return e.addSignature(this.publicKey,R.Buffer.from(Wi.decode(n))),e}else throw new St}async signMessage(e){if(this._client&&this._session){const{signature:t}=await this._client.request({chainId:this._network,topic:this._session.topic,request:{method:Yt.signMessage,params:{pubkey:this.publicKey.toString(),message:Wi.encode(e)}}});return Wi.decode(t)}else throw new St}}export{St as ClientNotInitializedError,rs as QRCodeModalError,ia as WalletConnectChainID,ts as WalletConnectClient,Yt as WalletConnectRPCMethods,s_ as WalletConnectWallet};
|