@wormhole-foundation/wormhole-connect 2.1.0-beta.1-development → 2.1.0-beta.2-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/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 +3 -3
- package/lib/{aptos-CzT6f7Ba.js → aptos-7G9wZkGW.js} +2 -2
- package/lib/{aptos-wFa1-xae.mjs → aptos-BlOWGpyT.mjs} +2 -2
- package/lib/{aptos-CqfHXKy7.js → aptos-CYxRBLR_.js} +1 -1
- package/lib/{aptos-DxhN-FI3.mjs → aptos-Ckopfy7I.mjs} +5 -5
- package/lib/{base64-C_XWimVd.js → base64-CFR5QWTY.js} +1 -1
- package/lib/{base64-L1vzz0KI.mjs → base64-HSuzVIKw.mjs} +1 -1
- package/lib/{ccip-z81HbzxN.mjs → ccip-Bntg_vPp.mjs} +1 -1
- package/lib/{ccip-D6aPw5Ue.js → ccip-CVUhxB0q.js} +1 -1
- package/lib/{chunk-IMTC3J2M-CazR2ogu.mjs → chunk-IMTC3J2M-BADDWO3l.mjs} +3 -3
- package/lib/{chunk-IMTC3J2M-WMj1Jt5m.js → chunk-IMTC3J2M-ByR5Yjf4.js} +1 -1
- package/lib/{events-D4Mv_WYU.js → events-jATx_JnD.js} +1 -1
- package/lib/{events-BrdIAbQL.mjs → events-lD3LhLH0.mjs} +1 -1
- package/lib/{evm-CB6zu7io.mjs → evm-BW0CHBCG.mjs} +5 -5
- package/lib/{evm-Fk4wBAda.js → evm-Bh1Y4eUx.js} +1 -1
- package/lib/{evm-CULALpUt.mjs → evm-ColKfWEz.mjs} +10 -6
- package/lib/{evm-BJL8RjTB.js → evm-z5yFHxM9.js} +3 -3
- package/lib/{index-D2y7My6x.mjs → index-2fBRXVP8.mjs} +2 -2
- package/lib/{index-Cuov-W4s.js → index-8-70GvMi.js} +1 -1
- package/lib/{index-Xy8XaqU-.js → index-8JCep4IW.js} +1 -1
- package/lib/{index-BTmEJpYG.mjs → index-B9GU1bLs.mjs} +1 -1
- package/lib/{index-CS3t6bxx.mjs → index-BXkdaYu_.mjs} +1 -1
- package/lib/{index-DEpSdwA-.mjs → index-BZ0W_BZS.mjs} +2 -2
- package/lib/{index-CtpCK8QC.js → index-BcdbCktu.js} +1 -1
- package/lib/{index-BnVRRJvv.js → index-BhexWYVn.js} +1 -1
- package/lib/{index-BT_eiQVC.js → index-C-OIv0gT.js} +1 -1
- package/lib/{index-CAqS4koK.js → index-C6WDEDwO.js} +1 -1
- package/lib/{index-BqaYMlOq.mjs → index-CAUvtNGE.mjs} +3 -3
- package/lib/{index-DpfI-2hT.mjs → index-CBxgME-2.mjs} +2 -2
- package/lib/{index-Dtg6idl8.js → index-CCUy1jes.js} +1 -1
- package/lib/{index-DGcrnWdu.mjs → index-CYBM2IeY.mjs} +13 -12
- package/lib/{index-DJJ3umH8.mjs → index-CcFpkXPM.mjs} +2 -2
- package/lib/{index-BqCducVx.mjs → index-CfnNi3Zd.mjs} +3 -3
- package/lib/{index-DdRe9fUB.mjs → index-Cl6LSKsg.mjs} +1 -1
- package/lib/{index-DtqIOAjg.mjs → index-CxQ-swIQ.mjs} +1 -1
- package/lib/index-Cxw9PIcl.js +531 -0
- package/lib/{index-CGdGYg5B.mjs → index-D0XcjaUl.mjs} +2 -2
- package/lib/{index-B9FwYN90.js → index-D7IcLxQc.js} +1 -1
- package/lib/index-DAzDpd7U.js +14 -0
- package/lib/{index-jC1hUxPJ.mjs → index-DB_r424l.mjs} +1 -1
- package/lib/{index-C_2eG0Va.mjs → index-DECw2aR6.mjs} +1 -1
- package/lib/{index-CuPOodtE.js → index-DGgQSMuG.js} +1 -1
- package/lib/{index-BsmdxKnE.mjs → index-DIAuhm70.mjs} +3008 -3525
- package/lib/{index-CuWt4RaJ.js → index-DOXMkFA4.js} +1 -1
- package/lib/{index-BGZONAdj.js → index-DQVQrflZ.js} +1 -1
- package/lib/{index-GM4m48QO.js → index-DUXnbpVg.js} +1 -1
- package/lib/{index-DUGwXho3.js → index-DZvLy2Dr.js} +3 -3
- package/lib/{index-BsYhqVq_.js → index-DjkMeATf.js} +1 -1
- package/lib/{index-C0MgLwy8.js → index-DleO04Ea.js} +1 -1
- package/lib/{index-HeldZ3mJ.mjs → index-InC6In6o.mjs} +2 -2
- package/lib/{index-CkUMgihl.js → index-V7kxzAZX.js} +1 -1
- package/lib/{index-B5TOuhBB.js → index-WLqZ1uO7.js} +1 -1
- package/lib/{index-Cf2BEUjb.mjs → index-gd_dleYk.mjs} +1 -1
- package/lib/{index-CayMgbM_.js → index-l0NqjNj9.js} +1 -1
- package/lib/{index-wAClTIQn.mjs → index-lEBTHIqm.mjs} +2 -2
- package/lib/{index-DsYAlD9Y.mjs → index-lHA40g0z.mjs} +2 -2
- package/lib/index-oPxOJfPK.mjs +3236 -0
- package/lib/{index-ChzkRsG0.js → index-rFhS51F6.js} +1 -1
- package/lib/{index-DXIpHh2N.mjs → index-y_DeeCWD.mjs} +4 -4
- package/lib/index.es-Doowrf9a.js +46 -0
- package/lib/index.es-YqKQxHG6.mjs +7725 -0
- package/lib/index.js +1 -1
- package/lib/index.mjs +1 -1
- package/lib/{signer-BBJR-S7u.mjs → signer-CfU9wW3f.mjs} +1 -1
- package/lib/{signer-D8m72nd4.js → signer-eoVHaZz7.js} +1 -1
- package/lib/{solana-DB5vwgKO.mjs → solana-CHUnEnef.mjs} +4 -4
- package/lib/{solana-tZZpsxE8.js → solana-C_d_AKET.js} +1 -1
- package/lib/solana-SFHXHGL2.js +1 -0
- package/lib/{solana-DdLCPKF2.mjs → solana-y-l38J4U.mjs} +5 -5
- package/lib/{solanaEmbed.esm-TpsYEDsw.js → solanaEmbed.esm-B4tNQ7S7.js} +10 -10
- package/lib/{solanaEmbed.esm-ANGjgiaN.mjs → solanaEmbed.esm-DVOHg5WI.mjs} +1559 -1560
- package/lib/{sui-BFNsLy1t.mjs → sui-1fbLRIUL.mjs} +5 -5
- package/lib/{sui-UELhAZj0.js → sui-BN1m6APK.js} +1 -1
- package/lib/{sui-DKw9LmTC.mjs → sui-D9frS9ki.mjs} +1 -1
- package/lib/{sui-D9F11hKw.js → sui-K20aVxqE.js} +2 -2
- package/package.json +5 -1
- 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/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
|
@@ -0,0 +1,531 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./index-DZvLy2Dr.js"),gl=require("./dijkstra-CtFxn7S9.js"),Re=require("./events-jATx_JnD.js"),I=require("./index-DQVQrflZ.js"),_=require("./index-DAzDpd7U.js"),W=require("./index-DUXnbpVg.js");let yl=class extends _.r{constructor(e){super(e),this.events=new Re.eventsExports.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(_.formatJsonRpcRequest(e.method,e.params||[],e.id||_.getBigIntRpcId().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=>{_.isJsonRpcError(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),_.isJsonRpcResponse(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 ml=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()}},vl=ml,Dn={"text/plain":"Text","text/html":"Url",default:"Text"},wl="Copy to clipboard: #{key}, Enter";function _l(r){var e=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return r.replace(/#{\s*key\s*}/g,e)}function bl(r,e){var t,i,n,s,o,a,c=!1;e||(e={}),t=e.debug||!1;try{n=vl(),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=Dn[e.format]||Dn.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=_l("message"in e?e.message:wl),window.prompt(i,r)}}finally{o&&(typeof o.removeRange=="function"?o.removeRange(s):o.removeAllRanges()),a&&document.body.removeChild(a),n()}return c}var El=bl,Sl={}.toString,rn=Array.isArray||function(r){return Sl.call(r)=="[object Array]"},Il=E.requireElliptic(),nn={},Q={};Object.defineProperty(Q,"__esModule",{value:!0});var ko=Q.getLocalStorage=Vo=Q.getLocalStorageOrThrow=Ko=Q.getCrypto=zo=Q.getCryptoOrThrow=jo=Q.getLocation=Uo=Q.getLocationOrThrow=Bo=Q.getNavigator=qo=Q.getNavigatorOrThrow=Fo=Q.getDocument=Do=Q.getDocumentOrThrow=Lo=Q.getFromWindowOrThrow=Mo=Q.getFromWindow=void 0;function wt(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}var Mo=Q.getFromWindow=wt;function qt(r){const e=wt(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}var Lo=Q.getFromWindowOrThrow=qt;function xl(){return qt("document")}var Do=Q.getDocumentOrThrow=xl;function Pl(){return wt("document")}var Fo=Q.getDocument=Pl;function Al(){return qt("navigator")}var qo=Q.getNavigatorOrThrow=Al;function Rl(){return wt("navigator")}var Bo=Q.getNavigator=Rl;function Nl(){return qt("location")}var Uo=Q.getLocationOrThrow=Nl;function Tl(){return wt("location")}var jo=Q.getLocation=Tl;function Cl(){return qt("crypto")}var zo=Q.getCryptoOrThrow=Cl;function Ol(){return wt("crypto")}var Ko=Q.getCrypto=Ol;function $l(){return qt("localStorage")}var Vo=Q.getLocalStorageOrThrow=$l;function kl(){return wt("localStorage")}ko=Q.getLocalStorage=kl;Object.defineProperty(nn,"__esModule",{value:!0});var Wo=nn.getWindowMetadata=void 0;const Fn=Q;function Ml(){let r,e;try{r=Fn.getDocumentOrThrow(),e=Fn.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 b=v.join("/");m+=b+"/"+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}}Wo=nn.getWindowMetadata=Ml;var Ll=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},Dl=function(){function r(e,t,i){this.name=e,this.version=t,this.os=i,this.type="browser"}return r}(),Fl=function(){function r(e){this.version=e,this.type="node",this.name="node",this.os=E.dist.process.platform}return r}(),ql=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}(),Bl=function(){function r(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return r}(),Ul=function(){function r(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return r}(),jl=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,zl=/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,qn=3,Kl=[["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",jl]],Bn=[["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 Vl(r){return r?Un(r):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Ul:typeof navigator<"u"?Un(navigator.userAgent):Jl()}function Wl(r){return r!==""&&Kl.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 Un(r){var e=Wl(r);if(!e)return null;var t=e[0],i=e[1];if(t==="searchbot")return new Bl;var n=i[1]&&i[1].split(/[._]/).slice(0,3);n?n.length<qn&&(n=Ll(n,Gl(qn-n.length))):n=[];var s=n.join("."),o=Hl(r),a=zl.exec(r);return a&&a[1]?new ql(t,s,o,a[1]):new Dl(t,s,o)}function Hl(r){for(var e=0,t=Bn.length;e<t;e++){var i=Bn[e],n=i[0],s=i[1],o=s.exec(r);if(o)return n}return null}function Jl(){var r=typeof E.dist.process<"u"&&E.dist.process.version;return r?new Fl(E.dist.process.version.slice(1)):null}function Gl(r){for(var e=[],t=0;t<r;t++)e.push("0");return e}function sn(r){return Vl(r)}function Vr(){const r=sn();return r&&r.os?r.os:void 0}function Ho(){const r=Vr();return r?r.toLowerCase().includes("android"):!1}function Jo(){const r=Vr();return r?r.toLowerCase().includes("ios")||r.toLowerCase().includes("mac")&&navigator.maxTouchPoints>1:!1}function Yl(){return Vr()?Ho()||Jo():!1}function Go(){const r=sn();return r&&r.name?r.name.toLowerCase()==="node":!1}function Ql(){return!Go()&&!!Yo()}const Xl=Mo,Zl=Lo,eu=Do,tu=Fo,ru=qo,Yo=Bo,iu=Uo,nu=jo,su=zo,ou=Ko,au=Vo,Wr=ko;function cu(){return Wo()}function lu(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 uu(r){return typeof r=="string"?r:JSON.stringify(r)}const Qo=lu,Xo=uu;function Zo(r,e){const t=Xo(e),i=Wr();i&&i.setItem(r,t)}function hu(r){let e=null,t=null;const i=Wr();return i&&(t=i.getItem(r)),e=t&&Qo(t),e}function du(r){const e=Wr();e&&e.removeItem(r)}const ea="WALLETCONNECT_DEEPLINK_CHOICE";function fu(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 pu(r){const e=r.href.split("?")[0];Zo(ea,Object.assign(Object.assign({},r),{href:e}))}function ta(r,e){return r.filter(t=>t.name.toLowerCase().includes(e.toLowerCase()))[0]}function gu(r,e){let t=r;return e&&(t=e.map(i=>ta(r,i)).filter(Boolean)),t}const ra="https://registry.walletconnect.com";function yu(){return ra+"/api/v2/wallets"}function mu(){return ra+"/api/v2/dapps"}function ia(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 vu(r,e="mobile"){return Object.values(r).filter(t=>!!t[e].universal||!!t[e].native).map(t=>ia(t,e))}const wu=Object.freeze(Object.defineProperty({__proto__:null,detectEnv:sn,detectOS:Vr,formatIOSMobile:fu,formatMobileRegistry:vu,formatMobileRegistryEntry:ia,getClientMeta:cu,getCrypto:ou,getCryptoOrThrow:su,getDappRegistryUrl:mu,getDocument:tu,getDocumentOrThrow:eu,getFromWindow:Xl,getFromWindowOrThrow:Zl,getLocal:hu,getLocalStorage:Wr,getLocalStorageOrThrow:au,getLocation:nu,getLocationOrThrow:iu,getMobileLinkRegistry:gu,getMobileRegistryEntry:ta,getNavigator:Yo,getNavigatorOrThrow:ru,getWalletRegistryUrl:yu,isAndroid:Ho,isBrowser:Ql,isIOS:Jo,isMobile:Yl,isNode:Go,mobileLinkChoiceKey:ea,removeLocal:du,safeJsonParse:Qo,safeJsonStringify:Xo,saveMobileLinkInfo:pu,setLocal:Zo},Symbol.toStringTag,{value:"Module"})),_u=E.getAugmentedNamespace(wu);var hr={},bu=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},na={},ct={},Eu=rn;function Su(){try{var r=new Uint8Array(1);return r.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},r.foo()===42}catch{return!1}}j.TYPED_ARRAY_SUPPORT=Su();var jn=j.TYPED_ARRAY_SUPPORT?2147483647:1073741823;function j(r,e,t){return!j.TYPED_ARRAY_SUPPORT&&!(this instanceof j)?new j(r,e,t):typeof r=="number"?sa(this,r):Tu(this,r,e,t)}j.TYPED_ARRAY_SUPPORT&&(j.prototype.__proto__=Uint8Array.prototype,j.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&j[Symbol.species]===j&&Object.defineProperty(j,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}));function on(r){if(r>=jn)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+jn.toString(16)+" bytes");return r|0}function Iu(r){return r!==r}function Tt(r,e){var t;return j.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=j.prototype):(t=r,t===null&&(t=new j(e)),t.length=e),t}function sa(r,e){var t=Tt(r,e<0?0:on(e)|0);if(!j.TYPED_ARRAY_SUPPORT)for(var i=0;i<e;++i)t[i]=0;return t}function xu(r,e){var t=aa(e)|0,i=Tt(r,t),n=i.write(e);return n!==t&&(i=i.slice(0,n)),i}function $i(r,e){for(var t=e.length<0?0:on(e.length)|0,i=Tt(r,t),n=0;n<t;n+=1)i[n]=e[n]&255;return i}function Pu(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),j.TYPED_ARRAY_SUPPORT?n.__proto__=j.prototype:n=$i(r,n),n}function Au(r,e){if(j.isBuffer(e)){var t=on(e.length)|0,i=Tt(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"||Iu(e.length)?Tt(r,0):$i(r,e);if(e.type==="Buffer"&&Array.isArray(e.data))return $i(r,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function oa(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 aa(r){if(j.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:oa(r).length}function Ru(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 Nu(r,e,t,i){return Ru(oa(e,r.length-t),r,t,i)}function Tu(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?Pu(r,e,t,i):typeof e=="string"?xu(r,e):Au(r,e)}j.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 Nu(this,e,t,i)};j.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(j.TYPED_ARRAY_SUPPORT)n=this.subarray(e,t),n.__proto__=j.prototype;else{var s=t-e;n=new j(s,void 0);for(var o=0;o<s;++o)n[o]=this[o+e]}return n};j.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||!j.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};j.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=j.isBuffer(e)?e:new j(e),a=o.length;for(s=0;s<i-t;++s)this[s+t]=o[s%a]}return this};j.concat=function(e,t){if(!Eu(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return Tt(null,0);var i;if(t===void 0)for(t=0,i=0;i<e.length;++i)t+=e[i].length;var n=sa(null,t),s=0;for(i=0;i<e.length;++i){var o=e[i];if(!j.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,s),s+=o.length}return n};j.byteLength=aa;j.prototype._isBuffer=!0;j.isBuffer=function(e){return!!(e!=null&&e._isBuffer)};ct.alloc=function(r){var e=new j(r);return e.fill(0),e};ct.from=function(r){return new j(r)};var _e={},an,Cu=[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];_e.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};_e.getSymbolTotalCodewords=function(e){return Cu[e]};_e.getBCHDigit=function(r){for(var e=0;r!==0;)e++,r>>>=1;return e};_e.setToSJISFunction=function(e){if(typeof e!="function")throw new Error('"toSJISFunc" is not a valid function.');an=e};_e.isKanjiModeEnabled=function(){return typeof an<"u"};_e.toSJIS=function(e){return an(e)};var Hr={};(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}}})(Hr);function ca(){this.buffer=[],this.length=0}ca.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 Ou=ca,zn=ct;function dr(r){if(!r||r<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=r,this.data=zn.alloc(r*r),this.reservedBit=zn.alloc(r*r)}dr.prototype.set=function(r,e,t,i){var n=r*this.size+e;this.data[n]=t,i&&(this.reservedBit[n]=!0)};dr.prototype.get=function(r,e){return this.data[r*this.size+e]};dr.prototype.xor=function(r,e,t){this.data[r*this.size+e]^=t};dr.prototype.isReserved=function(r,e){return this.reservedBit[r*this.size+e]};var $u=dr,la={};(function(r){var e=_e.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}})(la);var ua={},ku=_e.getSymbolSize,Kn=7;ua.getPositions=function(e){var t=ku(e);return[[0,0],[t-Kn,0],[0,t-Kn]]};var ha={};(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}})(ha);var Jr={},rt=Hr,_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],br=[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];Jr.getBlocksCount=function(e,t){switch(t){case rt.L:return _r[(e-1)*4+0];case rt.M:return _r[(e-1)*4+1];case rt.Q:return _r[(e-1)*4+2];case rt.H:return _r[(e-1)*4+3];default:return}};Jr.getTotalCodewordsCount=function(e,t){switch(t){case rt.L:return br[(e-1)*4+0];case rt.M:return br[(e-1)*4+1];case rt.Q:return br[(e-1)*4+2];case rt.H:return br[(e-1)*4+3];default:return}};var da={},Gr={},fa=ct,er=fa.alloc(512),$r=fa.alloc(256);(function(){for(var e=1,t=0;t<255;t++)er[t]=e,$r[e]=t,e<<=1,e&256&&(e^=285);for(t=255;t<512;t++)er[t]=er[t-255]})();Gr.log=function(e){if(e<1)throw new Error("log("+e+")");return $r[e]};Gr.exp=function(e){return er[e]};Gr.mul=function(e,t){return e===0||t===0?0:er[$r[e]+$r[t]]};(function(r){var e=ct,t=Gr;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}})(da);var Vn=ct,pa=da,Mu=E.bufferPolyfill.Buffer;function cn(r){this.genPoly=void 0,this.degree=r,this.degree&&this.initialize(this.degree)}cn.prototype.initialize=function(e){this.degree=e,this.genPoly=pa.generateECPolynomial(this.degree)};cn.prototype.encode=function(e){if(!this.genPoly)throw new Error("Encoder not initialized");var t=Vn.alloc(this.degree),i=Mu.concat([e,t],e.length+this.degree),n=pa.mod(i,this.genPoly),s=this.degree-n.length;if(s>0){var o=Vn.alloc(this.degree);return n.copy(o,s),o}return n};var Lu=cn,ga={},lt={},ln={};ln.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40};var ze={},ya="[0-9]+",Du="[A-Z $%*+\\-./:]+",sr="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";sr=sr.replace(/u/g,"\\u");var Fu="(?:(?![A-Z0-9 $%*+\\-./:]|"+sr+`)(?:.|[\r
|
|
2
|
+
]))+`;ze.KANJI=new RegExp(sr,"g");ze.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");ze.BYTE=new RegExp(Fu,"g");ze.NUMERIC=new RegExp(ya,"g");ze.ALPHANUMERIC=new RegExp(Du,"g");var qu=new RegExp("^"+sr+"$"),Bu=new RegExp("^"+ya+"$"),Uu=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");ze.testKanji=function(e){return qu.test(e)};ze.testNumeric=function(e){return Bu.test(e)};ze.testAlphanumeric=function(e){return Uu.test(e)};(function(r){var e=ln,t=ze;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}}})(lt);(function(r){var e=_e,t=Jr,i=Hr,n=lt,s=ln,o=rn,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),b=(m-v)*8;if(y===n.MIXED)return b;var w=b-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}})(ga);var ma={},ki=_e,va=1335,ju=21522,Wn=ki.getBCHDigit(va);ma.getEncodedBits=function(e,t){for(var i=e.bit<<3|t,n=i<<10;ki.getBCHDigit(n)-Wn>=0;)n^=va<<ki.getBCHDigit(n)-Wn;return(i<<10|n)^ju};var wa={},zu=lt;function Ct(r){this.mode=zu.NUMERIC,this.data=r.toString()}Ct.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)};Ct.prototype.getLength=function(){return this.data.length};Ct.prototype.getBitsLength=function(){return Ct.getBitsLength(this.data.length)};Ct.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 Ku=Ct,Vu=lt,hi=["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 Ot(r){this.mode=Vu.ALPHANUMERIC,this.data=r}Ot.getBitsLength=function(e){return 11*Math.floor(e/2)+6*(e%2)};Ot.prototype.getLength=function(){return this.data.length};Ot.prototype.getBitsLength=function(){return Ot.getBitsLength(this.data.length)};Ot.prototype.write=function(e){var t;for(t=0;t+2<=this.data.length;t+=2){var i=hi.indexOf(this.data[t])*45;i+=hi.indexOf(this.data[t+1]),e.put(i,11)}this.data.length%2&&e.put(hi.indexOf(this.data[t]),6)};var Wu=Ot,Hu=ct,Ju=lt;function $t(r){this.mode=Ju.BYTE,this.data=Hu.from(r)}$t.getBitsLength=function(e){return e*8};$t.prototype.getLength=function(){return this.data.length};$t.prototype.getBitsLength=function(){return $t.getBitsLength(this.data.length)};$t.prototype.write=function(r){for(var e=0,t=this.data.length;e<t;e++)r.put(this.data[e],8)};var Gu=$t,Yu=lt,Qu=_e;function kt(r){this.mode=Yu.KANJI,this.data=r}kt.getBitsLength=function(e){return e*13};kt.prototype.getLength=function(){return this.data.length};kt.prototype.getBitsLength=function(){return kt.getBitsLength(this.data.length)};kt.prototype.write=function(r){var e;for(e=0;e<this.data.length;e++){var t=Qu.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 Xu=kt;(function(r){var e=lt,t=Ku,i=Wu,n=Gu,s=Xu,o=ze,a=_e,c=gl.dijkstraExports;function l(m){return unescape(encodeURIComponent(m)).length}function u(m,v,b){for(var w=[],S;(S=m.exec(b))!==null;)w.push({data:S[0],index:S.index,mode:v,length:S[0].length});return w}function h(m){var v=u(o.NUMERIC,e.NUMERIC,m),b=u(o.ALPHANUMERIC,e.ALPHANUMERIC,m),w,S;a.isKanjiModeEnabled()?(w=u(o.BYTE,e.BYTE,m),S=u(o.KANJI,e.KANJI,m)):(w=u(o.BYTE_KANJI,e.BYTE,m),S=[]);var x=v.concat(b,w,S);return x.sort(function(P,A){return P.index-A.index}).map(function(P){return{data:P.data,mode:P.mode,length:P.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,b){var w=v.length-1>=0?v[v.length-1]:null;return w&&w.mode===b.mode?(v[v.length-1].data+=b.data,v):(v.push(b),v)},[])}function f(m){for(var v=[],b=0;b<m.length;b++){var w=m[b];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 b={},w={start:{}},S=["start"],x=0;x<m.length;x++){for(var P=m[x],A=[],C=0;C<P.length;C++){var O=P[C],$=""+x+C;A.push($),b[$]={node:O,lastCount:0},w[$]={};for(var D=0;D<S.length;D++){var k=S[D];b[k]&&b[k].node.mode===O.mode?(w[k][$]=p(b[k].lastCount+O.length,O.mode)-p(b[k].lastCount,O.mode),b[k].lastCount+=O.length):(b[k]&&(b[k].lastCount=O.length),w[k][$]=p(O.length,O.mode)+4+e.getCharCountIndicator(O.mode,v))}}S=A}for(D=0;D<S.length;D++)w[S[D]].end=0;return{map:w,table:b}}function y(m,v){var b,w=e.getBestModeForData(m);if(b=e.from(v,w),b!==e.BYTE&&b.bit<w.bit)throw new Error('"'+m+'" cannot be encoded with mode '+e.toString(b)+`.
|
|
4
|
+
Suggested mode is: `+e.toString(w));switch(b===e.KANJI&&!a.isKanjiModeEnabled()&&(b=e.BYTE),b){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(b,w){return typeof w=="string"?b.push(y(w,null)):w.data&&b.push(y(w.data,w.mode)),b},[])},r.fromString=function(v,b){for(var w=h(v,a.isKanjiModeEnabled()),S=f(w),x=g(S,b),P=c.find_path(x.map,"start","end"),A=[],C=1;C<P.length-1;C++)A.push(x.table[P[C]].node);return r.fromArray(d(A))},r.rawSplit=function(v){return r.fromArray(h(v,a.isKanjiModeEnabled()))}})(wa);var Hn=ct,Yr=_e,di=Hr,Zu=Ou,eh=$u,th=la,rh=ua,Mi=ha,Li=Jr,ih=Lu,kr=ga,nh=ma,sh=lt,fi=wa,oh=rn;function ah(r,e){for(var t=r.size,i=rh.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 ch(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 lh(r,e){for(var t=th.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 uh(r,e){for(var t=r.size,i=kr.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 pi(r,e,t){var i=r.size,n=nh.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 hh(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 dh(r,e,t){var i=new Zu;t.forEach(function(l){i.put(l.mode.bit,4),i.put(l.getLength(),sh.getCharCountIndicator(l.mode,r)),l.write(i)});var n=Yr.getSymbolTotalCodewords(r),s=Li.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 fh(i,r,e)}function fh(r,e,t){for(var i=Yr.getSymbolTotalCodewords(e),n=Li.getTotalCodewordsCount(e,t),s=i-n,o=Li.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 ih(p),f=0,g=new Array(o),y=new Array(o),m=0,v=Hn.from(r.buffer),b=0;b<o;b++){var w=b<c?u:h;g[b]=v.slice(f,f+w),y[b]=d.encode(g[b]),f+=w,m=Math.max(m,w)}var S=Hn.alloc(i),x=0,P,A;for(P=0;P<m;P++)for(A=0;A<o;A++)P<g[A].length&&(S[x++]=g[A][P]);for(P=0;P<p;P++)for(A=0;A<o;A++)S[x++]=y[A][P];return S}function ph(r,e,t,i){var n;if(oh(r))n=fi.fromArray(r);else if(typeof r=="string"){var s=e;if(!s){var o=fi.rawSplit(r);s=kr.getBestVersionForData(o,t)}n=fi.fromString(r,s||40)}else throw new Error("Invalid data");var a=kr.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=dh(e,t,n),l=Yr.getSymbolSize(e),u=new eh(l);return ah(u,e),ch(u),lh(u,e),pi(u,t,0),e>=7&&uh(u,e),hh(u,c),isNaN(i)&&(i=Mi.getBestMask(u,pi.bind(null,u,t))),Mi.applyMask(i,u),pi(u,t,i),{modules:u,version:e,errorCorrectionLevel:t,maskPattern:i,segments:n}}na.create=function(e,t){if(typeof e>"u"||e==="")throw new Error("No input text");var i=di.M,n,s;return typeof t<"u"&&(i=di.from(t.errorCorrectionLevel,di.M),n=kr.from(t.version),s=Mi.from(t.maskPattern),t.toSJISFunc&&Yr.setToSJISFunction(t.toSJISFunc)),ph(e,n,i,s)};var _a={},un={};(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}}})(un);(function(r){var e=un;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)}})(_a);var ba={},gh=un;function Jn(r,e){var t=r.a/255,i=e+'="'+r.hex+'"';return t<1?i+" "+e+'-opacity="'+t.toFixed(2).slice(1)+'"':i}function gi(r,e,t){var i=r+e;return typeof t<"u"&&(i+=" "+t),i}function yh(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?gi("M",c+t,.5+l+t):gi("m",n,0),n=0,s=!1),c+1<e&&r[a+1]||(i+=gi("h",o),o=0)):n++}return i}ba.render=function(e,t,i){var n=gh.getOptions(t),s=e.modules.size,o=e.modules.data,a=s+n.margin*2,c=n.color.light.a?"<path "+Jn(n.color.light,"fill")+' d="M0 0h'+a+"v"+a+'H0z"/>':"",l="<path "+Jn(n.color.dark,"stroke")+' d="'+yh(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 mh=bu,Di=na,Ea=_a,vh=ba;function hn(r,e,t,i,n){var s=[].slice.call(arguments,1),o=s.length,a=typeof s[o-1]=="function";if(!a&&!mh())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=Di.create(t,i);l(r(h,e,i))}catch(p){u(p)}})}try{var c=Di.create(t,i);n(null,r(c,e,i))}catch(l){n(l)}}hr.create=Di.create;hr.toCanvas=hn.bind(null,Ea.render);hr.toDataURL=hn.bind(null,Ea.renderToDataURL);hr.toString=hn.bind(null,function(r,e,t){return vh.render(r,t)});var M,tr,dn,Sa,Gn,fn,Ia,Je={},Qr=[],wh=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord/i;function He(r,e){for(var t in e)r[t]=e[t];return r}function xa(r){var e=r.parentNode;e&&e.removeChild(r)}function Ye(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 Mr(r,s,e&&e.key,e&&e.ref,null)}function Mr(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),M.vnode&&M.vnode(s),s}function Pa(){return{}}function fr(r){return r.children}function De(r,e){this.props=r,this.context=e}function or(r,e){if(e==null)return r.__?or(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"?or(r):null}function Aa(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 Aa(r)}}function Pr(r){(!r.__d&&(r.__d=!0)&&tr.push(r)&&!dn++||Gn!==M.debounceRendering)&&((Gn=M.debounceRendering)||Sa)(_h)}function _h(){for(var r;dn=tr.length;)r=tr.sort(function(e,t){return e.__v.__b-t.__v.__b}),tr=[],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=He({},o)).__v=n,s=pn(c,o,n,t.__n,c.ownerSVGElement!==void 0,null,i,a??or(o)),Na(i,o),s!=a&&Aa(o)))})}function Ra(r,e,t,i,n,s,o,a,c){var l,u,h,p,d,f,g,y=t&&t.__k||Qr,m=y.length;if(a==Je&&(a=s!=null?s[0]:m?or(t,0):null),l=0,e.__k=st(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=pn(r,v,h=h||Je,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 b;if(f==null&&(f=p),v.__d!==void 0)b=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),b=null;else{for(d=a,u=0;(d=d.nextSibling)&&u<m;u+=2)if(d==p)break e;r.insertBefore(p,a),b=a}e.type=="option"&&(r.value="")}a=b!==void 0?b:p.nextSibling,typeof e.type=="function"&&(e.__d=a)}else a&&h.__e==a&&a.parentNode!=r&&(a=or(h))}return l++,v}),e.__e=f,s!=null&&typeof e.type!="function")for(l=s.length;l--;)s[l]!=null&&xa(s[l]);for(l=m;l--;)y[l]!=null&&rr(y[l],y[l]);if(g)for(l=0;l<g.length;l++)Ta(g[l],g[++l],g[++l])}function st(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++)st(r[i],e,t);else t.push(e?e(typeof r=="string"||typeof r=="number"?Mr(null,r,null,null,r):r.__e!=null||r.__c!=null?Mr(r.type,r.props,r.key,null,r.__v):r):r);return t}function bh(r,e,t,i,n){var s;for(s in t)s==="children"||s==="key"||s in e||Lr(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]||Lr(r,s,e[s],t[s],i)}function Yn(r,e,t){e[0]==="-"?r.setProperty(e,t):r[e]=typeof t=="number"&&wh.test(e)===!1?t+"px":t??""}function Lr(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||Yn(s,c,"");if(t)for(l in t)i&&t[l]===i[l]||Yn(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,Qn,o),(r.l||(r.l={}))[e]=t):r.removeEventListener(e,Qn,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 Qn(r){this.l[r.type](M.event?M.event(r):r)}function pn(r,e,t,i,n,s,o,a,c){var l,u,h,p,d,f,g,y,m,v,b=e.type;if(e.constructor!==void 0)return null;(l=M.__b)&&l(e);try{e:if(typeof b=="function"){if(y=e.props,m=(l=b.contextType)&&i[l.__c],v=l?m?m.props.value:l.__:i,t.__c?g=(u=e.__c=t.__c).__=u.__E:("prototype"in b&&b.prototype.render?e.__c=u=new b(y,v):(e.__c=u=new De(y,v),u.constructor=b,u.render=Sh),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),b.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=He({},u.__s)),He(u.__s,b.getDerivedStateFromProps(y,u.__s))),p=u.props,d=u.state,h)b.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(b.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=M.__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==fr&&l.key==null?l.props.children:Array.isArray(l)?l:[l],u.getChildContext!=null&&(i=He(He({},i),u.getChildContext())),h||u.getSnapshotBeforeUpdate==null||(f=u.getSnapshotBeforeUpdate(p,d)),Ra(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=Eh(t.__e,e,t,i,n,s,o,c);(l=M.diffed)&&l(e)}catch(w){e.__v=null,M.__e(w,e,t)}return e.__e}function Na(r,e){M.__c&&M.__c(e,r),r.some(function(t){try{r=t.__h,t.__h=[],r.some(function(i){i.call(t)})}catch(i){M.__e(i,t.__v)}})}function Eh(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=Qr.slice.call(r.childNodes)),u=(d=t.props||Je).dangerouslySetInnerHTML,h=f.dangerouslySetInnerHTML,!a){if(d===Je)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||""))}bh(r,f,d,n,a),h?e.__k=[]:(e.__k=e.props.children,Ra(r,e,t,i,e.type!=="foreignObject"&&n,s,o,Je,a)),a||("value"in f&&(c=f.value)!==void 0&&c!==r.value&&Lr(r,"value",c,d.value,!1),"checked"in f&&(c=f.checked)!==void 0&&c!==r.checked&&Lr(r,"checked",c,d.checked,!1))}return r}function Ta(r,e,t){try{typeof r=="function"?r(e):r.current=e}catch(i){M.__e(i,t)}}function rr(r,e,t){var i,n,s;if(M.unmount&&M.unmount(r),(i=r.ref)&&(i.current&&i.current!==r.__e||Ta(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){M.__e(o,e)}i.base=i.__P=null}if(i=r.__k)for(s=0;s<i.length;s++)i[s]&&rr(i[s],e,t);n!=null&&xa(n)}function Sh(r,e,t){return this.constructor(r,t)}function ar(r,e,t){var i,n,s;M.__&&M.__(r,e),n=(i=t===fn)?null:t&&t.__k||e.__k,r=Ye(fr,null,[r]),s=[],pn(e,(i?e:t||e).__k=r,n||Je,Je,e.ownerSVGElement!==void 0,t&&!i?[t]:n?null:Qr.slice.call(e.childNodes),s,t||Je,i),Na(s,r)}function Ca(r,e){ar(r,e,fn)}function Ih(r,e){var t,i;for(i in e=He(He({},r.props),e),arguments.length>2&&(e.children=Qr.slice.call(arguments,2)),t={},e)i!=="key"&&i!=="ref"&&(t[i]=e[i]);return Mr(r.type,t,e.key||r.key,e.ref||r.ref,null)}function Oa(r){var e={},t={__c:"__cC"+Ia++,__: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,Pr(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}M={__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 Pr(t.__E=t)}catch(n){r=n}throw r}},De.prototype.setState=function(r,e){var t;t=this.__s!==this.state?this.__s:this.__s=He({},this.state),typeof r=="function"&&(r=r(t,this.props)),r&&He(t,r),r!=null&&this.__v&&(e&&this.__h.push(e),Pr(this))},De.prototype.forceUpdate=function(r){this.__v&&(this.__e=!0,r&&this.__h.push(r),Pr(this))},De.prototype.render=fr,tr=[],dn=0,Sa=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,fn=Je,Ia=0;var _t,ge,Xn,Mt=0,Fi=[],Zn=M.__r,es=M.diffed,ts=M.__c,rs=M.unmount;function Bt(r,e){M.__h&&M.__h(ge,r,Mt||e),Mt=0;var t=ge.__H||(ge.__H={__:[],__h:[]});return r>=t.__.length&&t.__.push({}),t.__[r]}function gn(r){return Mt=1,yn(qa,r)}function yn(r,e,t){var i=Bt(_t++,2);return i.__c||(i.__c=ge,i.__=[t?t(e):qa(void 0,e),function(n){var s=r(i.__[0],n);i.__[0]!==s&&(i.__[0]=s,i.__c.setState({}))}]),i.__}function $a(r,e){var t=Bt(_t++,3);!M.__s&&vn(t.__H,e)&&(t.__=r,t.__H=e,ge.__H.__h.push(t))}function mn(r,e){var t=Bt(_t++,4);!M.__s&&vn(t.__H,e)&&(t.__=r,t.__H=e,ge.__h.push(t))}function ka(r){return Mt=5,Xr(function(){return{current:r}},[])}function Ma(r,e,t){Mt=6,mn(function(){typeof r=="function"?r(e()):r&&(r.current=e())},t==null?t:t.concat(r))}function Xr(r,e){var t=Bt(_t++,7);return vn(t.__H,e)?(t.__H=e,t.__h=r,t.__=r()):t.__}function La(r,e){return Mt=8,Xr(function(){return r},e)}function Da(r){var e=ge.context[r.__c],t=Bt(_t++,9);return t.__c=r,e?(t.__==null&&(t.__=!0,e.sub(ge)),e.props.value):r.__}function Fa(r,e){M.useDebugValue&&M.useDebugValue(e?e(r):r)}function xh(r){var e=Bt(_t++,10),t=gn();return e.__=r,ge.componentDidCatch||(ge.componentDidCatch=function(i){e.__&&e.__(i),t[1](i)}),[t[0],function(){t[1](void 0)}]}function Ph(){Fi.some(function(r){if(r.__P)try{r.__H.__h.forEach(qi),r.__H.__h.forEach(Bi),r.__H.__h=[]}catch(e){return r.__H.__h=[],M.__e(e,r.__v),!0}}),Fi=[]}function qi(r){r.t&&r.t()}function Bi(r){var e=r.__();typeof e=="function"&&(r.t=e)}function vn(r,e){return!r||e.some(function(t,i){return t!==r[i]})}function qa(r,e){return typeof e=="function"?e(r):e}M.__r=function(r){Zn&&Zn(r),_t=0,(ge=r.__c).__H&&(ge.__H.__h.forEach(qi),ge.__H.__h.forEach(Bi),ge.__H.__h=[])},M.diffed=function(r){es&&es(r);var e=r.__c;if(e){var t=e.__H;t&&t.__h.length&&(Fi.push(e)!==1&&Xn===M.requestAnimationFrame||((Xn=M.requestAnimationFrame)||function(i){var n,s=function(){clearTimeout(o),cancelAnimationFrame(n),setTimeout(i)},o=setTimeout(s,100);typeof window<"u"&&(n=requestAnimationFrame(s))})(Ph))}},M.__c=function(r,e){e.some(function(t){try{t.__h.forEach(qi),t.__h=t.__h.filter(function(i){return!i.__||Bi(i)})}catch(i){e.some(function(n){n.__h&&(n.__h=[])}),e=[],M.__e(i,t.__v)}}),ts&&ts(r,e)},M.unmount=function(r){rs&&rs(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){M.__e(i,e.__v)}}};function wn(r,e){for(var t in e)r[t]=e[t];return r}function Ui(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 Ba=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 Ui(this.props,n)||Ui(this.state,s)},i}(De);function Ua(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:Ui(this.props,n)}function i(n){return this.shouldComponentUpdate=t,Ye(r,wn({},n))}return i.prototype.isReactComponent=!0,i.displayName="Memo("+(r.displayName||r.name)+")",i.t=!0,i}var is=M.__b;function ja(r){function e(t){var i=wn({},t);return delete i.ref,r(i,t.ref)}return e.prototype.isReactComponent=e.t=!0,e.displayName="ForwardRef("+(r.displayName||r.name)+")",e}M.__b=function(r){r.type&&r.type.t&&r.ref&&(r.props.ref=r.ref,r.ref=null),is&&is(r)};var ns=function(r,e){return r?st(r).reduce(function(t,i,n){return t.concat(e(i,n))},[]):null},za={map:ns,forEach:ns,count:function(r){return r?st(r).length:0},only:function(r){if((r=st(r)).length!==1)throw new Error("Children.only() expects only one child.");return r[0]},toArray:st},Ah=M.__e;function Ka(r){return r&&((r=wn({},r)).__c=null,r.__k=r.__k&&r.__k.map(Ka)),r}function Dr(){this.__u=0,this.o=null,this.__b=null}function Va(r){var e=r.__.__c;return e&&e.u&&e.u(r)}function Wa(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 Ye(t,s)}return n.displayName="Lazy",n.t=!0,n}function Rt(){this.i=null,this.l=null}M.__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)}Ah(r,e,t)},(Dr.prototype=new De).__c=function(r,e){var t=this;t.o==null&&(t.o=[]),t.o.push(e);var i=Va(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)},Dr.prototype.render=function(r,e){return this.__b&&(this.__v.__k[0]=Ka(this.__b),this.__b=null),[Ye(De,null,e.u?null:r.children),e.u&&r.fallback]};var ss=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]}};(Rt.prototype=new De).u=function(r){var e=this,t=Va(e.__v),i=e.l.get(r);return i[0]++,function(n){var s=function(){e.props.revealOrder?(i.push(n),ss(e,r,i)):n()};t?t(s):s()}},Rt.prototype.render=function(r){this.i=null,this.l=new Map;var e=st(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},Rt.prototype.componentDidUpdate=Rt.prototype.componentDidMount=function(){var r=this;r.l.forEach(function(e,t){ss(r,t,e)})};var Rh=function(){function r(){}var e=r.prototype;return e.getChildContext=function(){return this.props.context},e.render=function(t){return t.children},r}();function Nh(r){var e=this,t=r.container,i=Ye(Rh,{context:e.context},r.vnode);return e.s&&e.s!==t&&(e.v.parentNode&&e.s.removeChild(e.v),rr(e.h),e.p=!1),r.vnode?e.p?(t.__k=e.__k,ar(i,t),e.__k=t.__k):(e.v=document.createTextNode(""),Ca("",t),t.appendChild(e.v),e.p=!0,e.s=t,ar(i,t,e.v),e.__k=e.v.__k):e.p&&(e.v.parentNode&&e.s.removeChild(e.v),rr(e.h)),e.h=i,e.componentWillUnmount=function(){e.v.parentNode&&e.s.removeChild(e.v),rr(e.h)},null}function Ha(r,e){return Ye(Nh,{vnode:r,container:e})}var os=/^(?: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]/;De.prototype.isReactComponent={};var Ja=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103;function ji(r,e,t){if(e.__k==null)for(;e.firstChild;)e.removeChild(e.firstChild);return ar(r,e),typeof t=="function"&&t(),r?r.__c:null}function Th(r,e,t){return Ca(r,e),typeof t=="function"&&t(),r?r.__c:null}var as=M.event;function yi(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}})}M.event=function(r){as&&(r=as(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 cs={configurable:!0,get:function(){return this.class}},ls=M.vnode;M.vnode=function(r){r.$$typeof=Ja;var e=r.type,t=r.props;if(e){if(t.class!=t.className&&(cs.enumerable="className"in t,t.className!=null&&(t.class=t.className),Object.defineProperty(t,"className",cs)),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"&&(st(t.children).forEach(function(o){t.value.indexOf(o.props.value)!=-1&&(o.props.selected=!0)}),delete t.value),t)if(i=os.test(s))break;if(i)for(s in n=r.props={},t)n[os.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&&(yi(e.prototype,"componentWillMount"),yi(e.prototype,"componentWillReceiveProps"),yi(e.prototype,"componentWillUpdate"),e.m=!0)}ls&&ls(r)};var Ch="16.8.0";function Ga(r){return Ye.bind(null,r)}function _n(r){return!!r&&r.$$typeof===Ja}function Ya(r){return _n(r)?Ih.apply(null,arguments):r}function Qa(r){return!!r.__k&&(ar(null,r),!0)}function Xa(r){return r&&(r.base||r.nodeType===1&&r)||null}var Za=function(r,e){return r(e)};const Oh={useState:gn,useReducer:yn,useEffect:$a,useLayoutEffect:mn,useRef:ka,useImperativeHandle:Ma,useMemo:Xr,useCallback:La,useContext:Da,useDebugValue:Fa,version:"16.8.0",Children:za,render:ji,hydrate:ji,unmountComponentAtNode:Qa,createPortal:Ha,createElement:Ye,createContext:Oa,createFactory:Ga,cloneElement:Ya,createRef:Pa,Fragment:fr,isValidElement:_n,findDOMNode:Xa,Component:De,PureComponent:Ba,memo:Ua,forwardRef:ja,unstable_batchedUpdates:Za,Suspense:Dr,SuspenseList:Rt,lazy:Wa},$h=Object.freeze(Object.defineProperty({__proto__:null,Children:za,Component:De,Fragment:fr,PureComponent:Ba,Suspense:Dr,SuspenseList:Rt,cloneElement:Ya,createContext:Oa,createElement:Ye,createFactory:Ga,createPortal:Ha,createRef:Pa,default:Oh,findDOMNode:Xa,forwardRef:ja,hydrate:Th,isValidElement:_n,lazy:Wa,memo:Ua,render:ji,unmountComponentAtNode:Qa,unstable_batchedUpdates:Za,useCallback:La,useContext:Da,useDebugValue:Fa,useEffect:$a,useErrorBoundary:xh,useImperativeHandle:Ma,useLayoutEffect:mn,useMemo:Xr,useReducer:yn,useRef:ka,useState:gn,version:Ch},Symbol.toStringTag,{value:"Module"})),kh=E.getAugmentedNamespace($h);function ec(r){return r&&typeof r=="object"&&"default"in r?r.default:r}var de=_u,tc=ec(hr),Mh=ec(El),T=kh;function Lh(r){tc.toString(r,{type:"terminal"}).then(console.log)}var Dh=`: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 Fh(r,e){try{var t=r()}catch(i){return e(i)}return t&&t.then?t.then(void 0,e):t}var qh="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",Bh="WalletConnect",Uh=300,jh="rgb(64, 153, 255)",rc="walletconnect-wrapper",us="walletconnect-style-sheet",ic="walletconnect-qrcode-modal",zh="walletconnect-qrcode-close",nc="walletconnect-qrcode-text",Kh="walletconnect-connect-button";function Vh(r){return T.createElement("div",{className:"walletconnect-modal__header"},T.createElement("img",{src:qh,className:"walletconnect-modal__headerLogo"}),T.createElement("p",null,Bh),T.createElement("div",{className:"walletconnect-modal__close__wrapper",onClick:r.onClose},T.createElement("div",{id:zh,className:"walletconnect-modal__close__icon"},T.createElement("div",{className:"walletconnect-modal__close__line1"}),T.createElement("div",{className:"walletconnect-modal__close__line2"}))))}function Wh(r){return T.createElement("a",{className:"walletconnect-connect__button",href:r.href,id:Kh+"-"+r.name,onClick:r.onClick,rel:"noopener noreferrer",style:{backgroundColor:r.color},target:"_blank"},r.name)}var Hh="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 Jh(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:Hh,className:"walletconnect-modal__base__row__right__caret"})))}function Gh(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 Yh=5,mi=12;function Qh(r){var e=de.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>Yh,f=Math.ceil(h.length/mi),g=[(l-1)*mi+1,l*mi],y=h.length?h.filter(function(w,S){return S+1>=g[0]&&S+1<=g[1]}):[],m=!e&&f>1,v=void 0;function b(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:nc,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:b}),T.createElement("div",{className:"walletconnect-connect__buttons__wrapper"+(e?"__android":d&&h.length?"__wrap":"")},e?T.createElement(Wh,{name:r.text.connect,color:jh,href:r.uri,onClick:T.useCallback(function(){de.saveMobileLinkInfo({name:"Unknown",href:r.uri})},[])}):y.length?y.map(function(w){var S=w.color,x=w.name,P=w.shortName,A=w.logo,C=de.formatIOSMobile(r.uri,w),O=T.useCallback(function(){de.saveMobileLinkInfo({name:x,href:C})},[y]);return d?T.createElement(Gh,{color:S,href:C,name:P||x,logo:A,onClick:O}):T.createElement(Jh,{color:S,href:C,name:x,logo:A,onClick:O})}):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,S){var x=S+1,P=l===x;return T.createElement("a",{style:{margin:"auto 10px",fontWeight:P?"bold":"normal"},onClick:function(){return u(x)}},x)})))}function Xh(r){var e=!!r.message.trim();return T.createElement("div",{className:"walletconnect-qrcode__notification"+(e?" notification__show":"")},r.message)}var Zh=function(r){try{var e="";return Promise.resolve(tc.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 ed(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(Zh(r.uri)).then(function(c){o(c)})}catch(c){Promise.reject(c)}},[]);var a=function(){var c=Mh(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:nc,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(Xh,{message:t}))}function td(r){var e=de.isAndroid(),t=de.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],b=m[1],w=T.useState([]),S=w[0],x=w[1],P=T.useState(""),A=P[0],C=P[1],O=function(){c||s||i&&!i.length||S.length>0||T.useEffect(function(){var D=function(){try{if(e)return Promise.resolve();o(!0);var k=Fh(function(){var q=r.qrcodeModalOptions&&r.qrcodeModalOptions.registryUrl?r.qrcodeModalOptions.registryUrl:de.getWalletRegistryUrl();return Promise.resolve(fetch(q)).then(function(F){return Promise.resolve(F.json()).then(function(U){var z=U.listings,L=t?"mobile":"desktop",N=de.getMobileLinkRegistry(de.formatMobileRegistry(z,L),i);o(!1),l(!0),C(N.length?"":r.text.no_supported_wallets),x(N);var K=N.length===1;K&&(y(de.formatIOSMobile(r.uri,N[0])),p(!0)),b(K)})})},function(q){o(!1),l(!0),C(r.text.something_went_wrong),console.error(q)});return Promise.resolve(k&&k.then?k.then(function(){}):void 0)}catch(q){return Promise.reject(q)}};D()})};O();var $=t?h:!h;return T.createElement("div",{id:ic,className:"walletconnect-qrcode__base animated fadeIn"},T.createElement("div",{className:"walletconnect-modal__base"},T.createElement(Vh,{onClose:r.onClose}),v&&h?T.createElement("div",{className:"walletconnect-modal__single_wallet"},T.createElement("a",{onClick:function(){return de.saveMobileLinkInfo({name:S[0].name,href:g})},href:g,rel:"noopener noreferrer",target:"_blank"},r.text.connect_with+" "+(v?S[0].name:"")+" ›")):e||s||!s&&S.length?T.createElement("div",{className:"walletconnect-modal__mobile__toggle"+($?" 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),O()}},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),O()}},r.text.desktop))):null,T.createElement("div",null,h||!e&&!s&&!S.length?T.createElement(ed,Object.assign({},d)):T.createElement(Qh,Object.assign({},d,{links:S,errorMessage:A})))))}var rd={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"},id={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"},nd={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"},sd={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é"},od={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:"지갑을 찾을 수 없습니다"},ad={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"},cd={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:"没有找到钱包"},ld={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:"هیچ کیف پولی پیدا نشد"},hs={de:rd,en:id,es:nd,fr:sd,ko:od,pt:ad,zh:cd,fa:ld};function ud(){var r=de.getDocumentOrThrow(),e=r.getElementById(us);e&&r.head.removeChild(e);var t=r.createElement("style");t.setAttribute("id",us),t.innerText=Dh,r.head.appendChild(t)}function hd(){var r=de.getDocumentOrThrow(),e=r.createElement("div");return e.setAttribute("id",rc),r.body.appendChild(e),e}function sc(){var r=de.getDocumentOrThrow(),e=r.getElementById(ic);e&&(e.className=e.className.replace("fadeIn","fadeOut"),setTimeout(function(){var t=r.getElementById(rc);t&&r.body.removeChild(t)},Uh))}function dd(r){return function(){sc(),r&&r()}}function fd(){var r=de.getNavigatorOrThrow().language.split("-")[0]||"en";return hs[r]||hs.en}function pd(r,e,t){ud();var i=hd();T.render(T.createElement(td,{text:fd(),uri:r,onClose:dd(e),qrcodeModalOptions:t}),i)}function gd(){sc()}var oc=function(){return typeof E.dist.process<"u"&&typeof E.dist.process.versions<"u"&&typeof E.dist.process.versions.node<"u"};function yd(r,e,t){console.log(r),oc()?Lh(r):pd(r,e,t)}function md(){oc()||gd()}var vd={open:yd,close:md},wd=vd;const ds=E.getDefaultExportFromCjs(wd);let _d=class extends _.IEvents{constructor(e){super()}};const fs=I.cjs.FIVE_SECONDS,Ut={pulse:"heartbeat_pulse"};class bn extends _d{constructor(e){super(e),this.events=new Re.eventsExports.EventEmitter,this.interval=fs,this.interval=(e==null?void 0:e.interval)||fs}static async init(e){const t=new bn(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.cjs.toMiliseconds(this.interval))}pulse(){this.events.emit(Ut.pulse)}}class bd extends _.IEvents{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}let Ed=class extends _.IEvents{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}};class Sd{constructor(e,t){this.logger=e,this.core=t}}class Id extends _.IEvents{constructor(e,t){super(),this.relayer=e,this.logger=t}}class xd extends _.IEvents{constructor(e){super()}}class Pd{constructor(e,t,i,n){this.core=e,this.logger=t,this.name=i}}let Ad=class extends _.IEvents{constructor(e,t){super(),this.relayer=e,this.logger=t}},Rd=class extends _.IEvents{constructor(e,t){super(),this.core=e,this.logger=t}};class Nd{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}}let Td=class{constructor(e,t){this.projectId=e,this.logger=t}},Cd=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}};const Od=r=>JSON.stringify(r,(e,t)=>typeof t=="bigint"?t.toString()+"n":t),$d=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 ps(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return $d(r)}catch{return r}}function kd(r){return typeof r=="string"?r:Od(r)||""}var X={};Object.defineProperty(X,"__esModule",{value:!0});X.getLocalStorage=X.getLocalStorageOrThrow=X.getCrypto=X.getCryptoOrThrow=ac=X.getLocation=X.getLocationOrThrow=En=X.getNavigator=X.getNavigatorOrThrow=Zr=X.getDocument=X.getDocumentOrThrow=X.getFromWindowOrThrow=X.getFromWindow=void 0;function bt(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}X.getFromWindow=bt;function jt(r){const e=bt(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}X.getFromWindowOrThrow=jt;function Md(){return jt("document")}X.getDocumentOrThrow=Md;function Ld(){return bt("document")}var Zr=X.getDocument=Ld;function Dd(){return jt("navigator")}X.getNavigatorOrThrow=Dd;function Fd(){return bt("navigator")}var En=X.getNavigator=Fd;function qd(){return jt("location")}X.getLocationOrThrow=qd;function Bd(){return bt("location")}var ac=X.getLocation=Bd;function Ud(){return jt("crypto")}X.getCryptoOrThrow=Ud;function jd(){return bt("crypto")}X.getCrypto=jd;function zd(){return jt("localStorage")}X.getLocalStorageOrThrow=zd;function Kd(){return bt("localStorage")}X.getLocalStorage=Kd;var Sn={};Object.defineProperty(Sn,"__esModule",{value:!0});var cc=Sn.getWindowMetadata=void 0;const gs=X;function Vd(){let r,e;try{r=gs.getDocumentOrThrow(),e=gs.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 b=v.join("/");m+=b+"/"+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}}cc=Sn.getWindowMetadata=Vd;function zt(r,e,t){return t={path:e,exports:{},require:function(i,n){return Wd(i,n??t.path)}},r(t,t.exports),t.exports}function Wd(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var In=lc;function lc(r,e){if(!r)throw new Error(e||"Assertion failed")}lc.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)};var Le=zt(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}}),be=zt(function(r,e){var t=e;t.assert=In,t.toArray=Le.toArray,t.zero2=Le.zero2,t.toHex=Le.toHex,t.encode=Le.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 E.BN(c,"hex","le")}t.intFromLE=a}),Fr=be.getNAF,Hd=be.getJSF,qr=be.assert;function ut(r,e){this.type=r,this.p=new E.BN(e.p,16),this.red=e.prime?E.BN.red(e.prime):E.BN.mont(this.p),this.zero=new E.BN(0).toRed(this.red),this.one=new E.BN(1).toRed(this.red),this.two=new E.BN(2).toRed(this.red),this.n=e.n&&new E.BN(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 Et=ut;ut.prototype.point=function(){throw new Error("Not implemented")};ut.prototype.validate=function(){throw new Error("Not implemented")};ut.prototype._fixedNafMul=function(e,t){qr(e.precomputed);var i=e._getDoubles(),n=Fr(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()};ut.prototype._wnafMul=function(e,t){var i=4,n=e._getNAFPoints(i);i=n.wnd;for(var s=n.points,o=Fr(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];qr(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};ut.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]=Fr(i[f],o[f],this._bitLength),c[g]=Fr(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=Hd(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 b=v[0][h]|0,w=v[1][h]|0;c[f][h]=m[(b+1)*3+(w+1)],c[g][h]=0,a[f]=y}}var S=this.jpoint(null,null,null),x=this._wnafT4;for(u=l;u>=0;u--){for(var P=0;u>=0;){var A=!0;for(h=0;h<n;h++)x[h]=c[h][u]|0,x[h]!==0&&(A=!1);if(!A)break;P++,u--}if(u>=0&&P++,S=S.dblp(P),u<0)break;for(h=0;h<n;h++){var C=x[h];C!==0&&(C>0?p=a[h][C-1>>1]:C<0&&(p=a[h][-C-1>>1].neg()),p.type==="affine"?S=S.mixedAdd(p):S=S.add(p))}}for(u=0;u<n;u++)a[u]=null;return s?S:S.toP()};function Ne(r,e){this.curve=r,this.type=e,this.precomputed=null}ut.BasePoint=Ne;Ne.prototype.eq=function(){throw new Error("Not implemented")};Ne.prototype.validate=function(){return this.curve.validate(this)};ut.prototype.decodePoint=function(e,t){e=be.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?qr(e[e.length-1]%2===0):e[0]===7&&qr(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")};Ne.prototype.encodeCompressed=function(e){return this.encode(e,!0)};Ne.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))};Ne.prototype.encode=function(e,t){return be.encode(this._encode(t),e)};Ne.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};Ne.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};Ne.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}};Ne.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}};Ne.prototype._getBeta=function(){return null};Ne.prototype.dblp=function(e){for(var t=this,i=0;i<e;i++)t=t.dbl();return t};var xn=zt(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}}}),Jd=be.assert;function Te(r){Et.call(this,"short",r),this.a=new E.BN(r.a,16).toRed(this.red),this.b=new E.BN(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)}xn(Te,Et);var Gd=Te;Te.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,i;if(e.beta)t=new E.BN(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 E.BN(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],Jd(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 E.BN(a.a,16),b:new E.BN(a.b,16)}}):o=this._getEndoBasis(i),{beta:t,lambda:i,basis:o}}};Te.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:E.BN.mont(e),i=new E.BN(2).toRed(t).redInvm(),n=i.redNeg(),s=new E.BN(3).toRed(t).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),a=n.redSub(s).fromRed();return[o,a]};Te.prototype._getEndoBasis=function(e){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new E.BN(1),o=new E.BN(0),a=new E.BN(0),c=new E.BN(1),l,u,h,p,d,f,g,y=0,m,v;i.cmpn(0)!==0;){var b=n.div(i);m=n.sub(b.mul(i)),v=a.sub(b.mul(s));var w=c.sub(b.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 S=h.sqr().add(p.sqr()),x=d.sqr().add(f.sqr());return x.cmp(S)>=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}]};Te.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}};Te.prototype.pointFromX=function(e,t){e=new E.BN(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)};Te.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};Te.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 oe(r,e,t,i){Et.BasePoint.call(this,r,"affine"),e===null&&t===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new E.BN(e,16),this.y=new E.BN(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)}xn(oe,Et.BasePoint);Te.prototype.point=function(e,t,i){return new oe(this,e,t,i)};Te.prototype.pointFromJSON=function(e,t){return oe.fromJSON(this,e,t)};oe.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}};oe.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]};oe.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};oe.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)+">"};oe.prototype.isInfinity=function(){return this.inf};oe.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)};oe.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)};oe.prototype.getX=function(){return this.x.fromRed()};oe.prototype.getY=function(){return this.y.fromRed()};oe.prototype.mul=function(e){return e=new E.BN(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)};oe.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)};oe.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)};oe.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)};oe.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};oe.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 ce(r,e,t,i){Et.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new E.BN(0)):(this.x=new E.BN(e,16),this.y=new E.BN(t,16),this.z=new E.BN(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}xn(ce,Et.BasePoint);Te.prototype.jpoint=function(e,t,i){return new ce(this,e,t,i)};ce.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)};ce.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};ce.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)};ce.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)};ce.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 b=u.redMul(c);t+1<e&&(l=l.redMul(d)),o=y,c=b,u=v}return this.curve.jpoint(o,u.redMul(s),c)};ce.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()};ce.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)};ce.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)};ce.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)};ce.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)};ce.prototype.mul=function(e,t){return e=new E.BN(e,t),this.curve._wnafMul(this,e)};ce.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};ce.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}};ce.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)+">"};ce.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Ar=zt(function(r,e){var t=e;t.base=Et,t.short=Gd,t.mont=null,t.edwards=null}),Rr=zt(function(r,e){var t=e,i=be.assert;function n(a){a.type==="short"?this.curve=new Ar.short(a):a.type==="edwards"?this.curve=new Ar.edwards(a):this.curve=new Ar.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:I.hash.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:I.hash.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:I.hash.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:I.hash.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:I.hash.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:I.hash.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:I.hash.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:I.hash.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function at(r){if(!(this instanceof at))return new at(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=Le.toArray(r.entropy,r.entropyEnc||"hex"),t=Le.toArray(r.nonce,r.nonceEnc||"hex"),i=Le.toArray(r.pers,r.persEnc||"hex");In(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}var uc=at;at.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};at.prototype._hmac=function(){return new I.hash.hmac(this.hash,this.K)};at.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())};at.prototype.reseed=function(e,t,i,n){typeof t!="string"&&(n=i,i=t,t=null),e=Le.toArray(e,t),i=Le.toArray(i,n),In(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1};at.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=Le.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++,Le.encode(o,t)};var zi=be.assert;function ue(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 Pn=ue;ue.fromPublic=function(e,t,i){return t instanceof ue?t:new ue(e,{pub:t,pubEnc:i})};ue.fromPrivate=function(e,t,i){return t instanceof ue?t:new ue(e,{priv:t,privEnc:i})};ue.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"}};ue.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};ue.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv};ue.prototype._importPrivate=function(e,t){this.priv=new E.BN(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)};ue.prototype._importPublic=function(e,t){if(e.x||e.y){this.ec.curve.type==="mont"?zi(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&zi(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)};ue.prototype.derive=function(e){return e.validate()||zi(e.validate(),"public point not validated"),e.mul(this.priv).getX()};ue.prototype.sign=function(e,t,i){return this.ec.sign(e,this,t,i)};ue.prototype.verify=function(e,t){return this.ec.verify(e,t,this)};ue.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var Yd=be.assert;function ei(r,e){if(r instanceof ei)return r;this._importDER(r,e)||(Yd(r.r&&r.s,"Signature without r or s"),this.r=new E.BN(r.r,16),this.s=new E.BN(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var ti=ei;function Qd(){this.place=0}function vi(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 ys(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)}ei.prototype._importDER=function(e,t){e=be.toArray(e,t);var i=new Qd;if(e[i.place++]!==48)return!1;var n=vi(e,i);if(n===!1||n+i.place!==e.length||e[i.place++]!==2)return!1;var s=vi(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=vi(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 E.BN(o),this.s=new E.BN(c),this.recoveryParam=null,!0};function wi(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)}ei.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=ys(t),i=ys(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];wi(n,t.length),n=n.concat(t),n.push(2),wi(n,i.length);var s=n.concat(i),o=[48];return wi(o,s.length),o=o.concat(s),be.encode(o,e)};var Xd=function(){throw new Error("unsupported")},hc=be.assert;function Ae(r){if(!(this instanceof Ae))return new Ae(r);typeof r=="string"&&(hc(Object.prototype.hasOwnProperty.call(Rr,r),"Unknown curve "+r),r=Rr[r]),r instanceof Rr.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 Zd=Ae;Ae.prototype.keyPair=function(e){return new Pn(this,e)};Ae.prototype.keyFromPrivate=function(e,t){return Pn.fromPrivate(this,e,t)};Ae.prototype.keyFromPublic=function(e,t){return Pn.fromPublic(this,e,t)};Ae.prototype.genKeyPair=function(e){e||(e={});for(var t=new uc({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||Xd(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new E.BN(2));;){var s=new E.BN(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}};Ae.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};Ae.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 E.BN(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),a=e.toArray("be",s),c=new uc({hash:this.hash,entropy:o,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),l=this.n.sub(new E.BN(1)),u=0;;u++){var h=n.k?n.k(u):new E.BN(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 ti({r:f,s:g,recoveryParam:y})}}}}}};Ae.prototype.verify=function(e,t,i,n){e=this._truncateToN(new E.BN(e,16)),i=this.keyFromPublic(i,n),t=new ti(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)};Ae.prototype.recoverPubKey=function(r,e,t,i){hc((3&t)===t,"The recovery param is more than two bits"),e=new ti(e,i);var n=this.n,s=new E.BN(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)};Ae.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new ti(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 ef=zt(function(r,e){var t=e;t.version="6.5.4",t.utils=be,t.rand=function(){throw new Error("unsupported")},t.curve=Ar,t.curves=Rr,t.ec=Zd,t.eddsa=null}),tf=ef.ec;const rf="signing-key/5.7.0",Ki=new W.Logger(rf);let _i=null;function Ze(){return _i||(_i=new tf("secp256k1")),_i}class nf{constructor(e){W.defineReadOnly(this,"curve","secp256k1"),W.defineReadOnly(this,"privateKey",W.hexlify(e)),W.hexDataLength(this.privateKey)!==32&&Ki.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const t=Ze().keyFromPrivate(W.arrayify(this.privateKey));W.defineReadOnly(this,"publicKey","0x"+t.getPublic(!1,"hex")),W.defineReadOnly(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),W.defineReadOnly(this,"_isSigningKey",!0)}_addPoint(e){const t=Ze().keyFromPublic(W.arrayify(this.publicKey)),i=Ze().keyFromPublic(W.arrayify(e));return"0x"+t.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){const t=Ze().keyFromPrivate(W.arrayify(this.privateKey)),i=W.arrayify(e);i.length!==32&&Ki.throwArgumentError("bad digest length","digest",e);const n=t.sign(i,{canonical:!0});return W.splitSignature({recoveryParam:n.recoveryParam,r:W.hexZeroPad("0x"+n.r.toString(16),32),s:W.hexZeroPad("0x"+n.s.toString(16),32)})}computeSharedSecret(e){const t=Ze().keyFromPrivate(W.arrayify(this.privateKey)),i=Ze().keyFromPublic(W.arrayify(dc(e)));return W.hexZeroPad("0x"+t.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}}function sf(r,e){const t=W.splitSignature(e),i={r:W.arrayify(t.r),s:W.arrayify(t.s)};return"0x"+Ze().recoverPubKey(W.arrayify(r),i,t.recoveryParam).encode("hex",!1)}function dc(r,e){const t=W.arrayify(r);return t.length===32?new nf(t).publicKey:t.length===33?"0x"+Ze().keyFromPublic(t).getPublic(!1,"hex"):t.length===65?W.hexlify(t):Ki.throwArgumentError("invalid public or private key","key","[REDACTED]")}var ms;(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(ms||(ms={}));function of(r){const e=dc(r);return W.getAddress(W.hexDataSlice(W.keccak256(W.hexDataSlice(e,1)),12))}function af(r,e){return of(sf(W.arrayify(r),e))}const fc=":";function Nr(r){const[e,t]=r.split(fc);return{namespace:e,reference:t}}function cf(r){const[e,t,i]=r.split(fc);return{namespace:e,reference:t,address:i}}function pc(r,e){return r.includes(":")?[r]:e.chains||[]}const lf="ReactNative",we={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},uf="js";function Br(){return typeof E.dist.process<"u"&&typeof E.dist.process.versions<"u"&&typeof E.dist.process.versions.node<"u"}function ht(){return!Zr()&&!!En()&&navigator.product===lf}function hf(){return ht()&&typeof E.dist.global<"u"&&typeof(E.dist.global==null?void 0:E.dist.global.Platform)<"u"&&(E.dist.global==null?void 0:E.dist.global.Platform.OS)==="android"}function df(){return ht()&&typeof E.dist.global<"u"&&typeof(E.dist.global==null?void 0:E.dist.global.Platform)<"u"&&(E.dist.global==null?void 0:E.dist.global.Platform.OS)==="ios"}function pr(){return!Br()&&!!En()&&!!Zr()}function gr(){return ht()?we.reactNative:Br()?we.node:pr()?we.browser:we.unknown}function vs(){var r;try{return ht()&&typeof E.dist.global<"u"&&typeof(E.dist.global==null?void 0:E.dist.global.Application)<"u"?(r=E.dist.global.Application)==null?void 0:r.applicationId:void 0}catch{return}}function ff(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 gc(){return cc()||{name:"",description:"",url:"",icons:[""]}}function pf(){if(gr()===we.reactNative&&typeof E.dist.global<"u"&&typeof(E.dist.global==null?void 0:E.dist.global.Platform)<"u"){const{OS:t,Version:i}=E.dist.global.Platform;return[t,i].join("-")}const r=_.detect();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 gf(){var r;const e=gr();return e===we.browser?[e,((r=ac())==null?void 0:r.host)||"unknown"].join(":"):e}function yc(r,e,t){const i=pf(),n=gf();return[[r,e].join("-"),[uf,t].join("-"),i,n].join("/")}function yf({protocol:r,version:e,relayUrl:t,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:a,packageName:c}){const l=t.split("?"),u=yc(r,e,i),h={auth:n,ua:u,projectId:s,useOnCloseEvent:o,packageName:c||void 0,bundleId:a||void 0},p=ff(l[1]||"",h);return l[0]+"?"+p}function yt(r,e){return r.filter(t=>e.includes(t)).length===r.length}function mc(r){return Object.fromEntries(r.entries())}function vc(r){return new Map(Object.entries(r))}function pt(r=I.cjs.FIVE_MINUTES,e){const t=I.cjs.toMiliseconds(r||I.cjs.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 it(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 wc(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 mf(r){return wc("topic",r)}function vf(r){return wc("id",r)}function _c(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 ie(r,e){return I.cjs.fromMiliseconds(Date.now()+I.cjs.toMiliseconds(r))}function et(r){return Date.now()>=I.cjs.toMiliseconds(r)}function B(r,e){return`${r}${e?`:${e}`:""}`}function wf(r=[],e=[]){return[...new Set([...r,...e])]}async function _f({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=bf(s,r,e),a=gr();if(a===we.browser){if(!((i=Zr())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}Ef(o)}else a===we.reactNative&&typeof(E.dist.global==null?void 0:E.dist.global.Linking)<"u"&&await E.dist.global.Linking.openURL(o)}catch(n){console.error(n)}}function bf(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}${Pf(i,!0)}`}else n=`${n}/wc?${i}`;return n}function Ef(r){let e="_self";xf()?e="_top":(If()||r.startsWith("https://")||r.startsWith("http://"))&&(e="_blank"),window.open(r,e,"noreferrer noopener")}async function Sf(r,e){let t="";try{if(pr()&&(t=localStorage.getItem(e),t))return t;t=await r.getItem(e)}catch(i){console.error(i)}return t}function ws(r,e){if(!r.includes(e))return null;const t=r.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function _s(){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 An(){return typeof E.dist.process<"u"&&E.dist.process.env.IS_VITEST==="true"}function If(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function xf(){try{return window.self!==window.top}catch{return!1}}function Pf(r,e=!1){const t=E.dist.Buffer.from(r).toString("base64");return e?t.replace(/[=]/g,""):t}function bc(r){return E.dist.Buffer.from(r,"base64").toString("utf-8")}function Af(r){return new Promise(e=>setTimeout(e,r))}function cr(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Rf(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function ri(r,...e){if(!Rf(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 Rn(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");cr(r.outputLen),cr(r.blockLen)}function Lt(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 Ec(r,e){ri(r);const t=e.outputLen;if(r.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const Er=BigInt(2**32-1),bs=BigInt(32);function Nf(r,e=!1){return e?{h:Number(r&Er),l:Number(r>>bs&Er)}:{h:Number(r>>bs&Er)|0,l:Number(r&Er)|0}}function Tf(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}=Nf(r[n],e);[t[n],i[n]]=[s,o]}return[t,i]}const Cf=(r,e,t)=>r<<t|e>>>32-t,Of=(r,e,t)=>e<<t|r>>>32-t,$f=(r,e,t)=>e<<t-32|r>>>64-t,kf=(r,e,t)=>r<<t-32|e>>>64-t,xt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Mf(r){return new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4))}function bi(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function qe(r,e){return r<<32-e|r>>>e}const Es=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Lf(r){return r<<24&4278190080|r<<8&16711680|r>>>8&65280|r>>>24&255}function Ss(r){for(let e=0;e<r.length;e++)r[e]=Lf(r[e])}function Df(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function Dt(r){return typeof r=="string"&&(r=Df(r)),ri(r),r}let Nn=class{clone(){return this._cloneInto()}};function Sc(r){const e=i=>r().update(Dt(i)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function yr(r=32){if(xt&&typeof xt.getRandomValues=="function")return xt.getRandomValues(new Uint8Array(r));if(xt&&typeof xt.randomBytes=="function")return xt.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}const Ic=[],xc=[],Pc=[],Ff=BigInt(0),Wt=BigInt(1),qf=BigInt(2),Bf=BigInt(7),Uf=BigInt(256),jf=BigInt(113);for(let r=0,e=Wt,t=1,i=0;r<24;r++){[t,i]=[i,(2*t+3*i)%5],Ic.push(2*(5*i+t)),xc.push((r+1)*(r+2)/2%64);let n=Ff;for(let s=0;s<7;s++)e=(e<<Wt^(e>>Bf)*jf)%Uf,e&qf&&(n^=Wt<<(Wt<<BigInt(s))-Wt);Pc.push(n)}const[zf,Kf]=Tf(Pc,!0),Is=(r,e,t)=>t>32?$f(r,e,t):Cf(r,e,t),xs=(r,e,t)=>t>32?kf(r,e,t):Of(r,e,t);function Vf(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=Is(l,u,1)^t[a],p=xs(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=xc[o],c=Is(n,s,a),l=xs(n,s,a),u=Ic[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]^=zf[i],r[1]^=Kf[i]}t.fill(0)}let Wf=class Ac extends Nn{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,cr(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Mf(this.state)}keccak(){Es||Ss(this.state32),Vf(this.state32,this.rounds),Es||Ss(this.state32),this.posOut=0,this.pos=0}update(e){Lt(this);const{blockLen:t,state:i}=this;e=Dt(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){Lt(this,!1),ri(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 cr(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Ec(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 Ac(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 Hf=(r,e,t)=>Sc(()=>new Wf(e,r,t)),Jf=Hf(1,136,256/8),Gf="https://rpc.walletconnect.org/v1";function Rc(r){const e=`Ethereum Signed Message:
|
|
523
|
+
${r.length}`,t=new TextEncoder().encode(e+r);return"0x"+E.dist.Buffer.from(Jf(t)).toString("hex")}async function Yf(r,e,t,i,n,s){switch(t.t){case"eip191":return Qf(r,e,t.s);case"eip1271":return await Xf(r,e,t.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}function Qf(r,e,t){return af(Rc(e),t).toLowerCase()===r.toLowerCase()}async function Xf(r,e,t,i,n,s){const o=Nr(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=Rc(e).substring(2),p=a+h+c+l+u,d=await fetch(`${s||Gf}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:Zf(),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 Zf(){return Date.now()+Math.floor(Math.random()*1e3)}var ep=Object.defineProperty,tp=Object.defineProperties,rp=Object.getOwnPropertyDescriptors,Ps=Object.getOwnPropertySymbols,ip=Object.prototype.hasOwnProperty,np=Object.prototype.propertyIsEnumerable,As=(r,e,t)=>e in r?ep(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,sp=(r,e)=>{for(var t in e||(e={}))ip.call(e,t)&&As(r,t,e[t]);if(Ps)for(var t of Ps(e))np.call(e,t)&&As(r,t,e[t]);return r},op=(r,e)=>tp(r,rp(e));const ap="did:pkh:",Tn=r=>r==null?void 0:r.split(":"),cp=r=>{const e=r&&Tn(r);if(e)return r.includes(ap)?e[3]:e[1]},Vi=r=>{const e=r&&Tn(r);if(e)return e[2]+":"+e[3]},Ur=r=>{const e=r&&Tn(r);if(e)return e.pop()};async function Rs(r){const{cacao:e,projectId:t}=r,{s:i,p:n}=e,s=Nc(n,n.iss),o=Ur(n.iss);return await Yf(o,s,i,Vi(n.iss),t)}const Nc=(r,e)=>{const t=`${r.domain} wants you to sign in with your Ethereum account:`,i=Ur(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: ${cp(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=Tr(r.resources);if(f){const g=lr(f);n=mp(n,g)}return[t,i,"",n,"",s,o,a,c,l,u,h,p,d].filter(g=>g!=null).join(`
|
|
525
|
+
`)};function lp(r){return E.dist.Buffer.from(JSON.stringify(r)).toString("base64")}function up(r){return JSON.parse(E.dist.Buffer.from(r,"base64").toString("utf-8"))}function mt(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 hp(r,e,t,i={}){return t==null||t.sort((n,s)=>n.localeCompare(s)),{att:{[r]:dp(e,t,i)}}}function dp(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 Tc(r){return mt(r),`urn:recap:${lp(r).replace(/=/g,"")}`}function lr(r){const e=up(r.replace("urn:recap:",""));return mt(e),e}function fp(r,e,t){const i=hp(r,e,t);return Tc(i)}function pp(r){return r&&r.includes("urn:recap:")}function gp(r,e){const t=lr(r),i=lr(e),n=yp(t,i);return Tc(n)}function yp(r,e){mt(r),mt(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]=op(sp({},i.att[n]),{[a]:((c=r.att[n])==null?void 0:c[a])||((l=e.att[n])==null?void 0:l[a])})})}),i}function mp(r="",e){mt(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 Ns(r){var e;const t=lr(r);mt(t);const i=(e=t.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function Ts(r){const e=lr(r);mt(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 Tr(r){if(!r)return;const e=r==null?void 0:r[r.length-1];return pp(e)?e:void 0}function Ei(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Cc(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function ve(r,...e){if(!Cc(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 Cs(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 vp(r,e){ve(r);const t=e.outputLen;if(r.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}function Os(r){if(typeof r!="boolean")throw new Error(`boolean expected, not ${r}`)}const ot=r=>new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4)),wp=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),_p=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!_p)throw new Error("Non little-endian hardware is not supported");function bp(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function Wi(r){if(typeof r=="string")r=bp(r);else if(Cc(r))r=Hi(r);else throw new Error("Uint8Array expected, got "+typeof r);return r}function Ep(r,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(r,e)}function Sp(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 Ip=(r,e)=>{function t(i,...n){if(ve(i),r.nonceLength!==void 0){const l=n[0];if(!l)throw new Error("nonce / iv required");r.varSizeNonce?ve(l):ve(l,r.nonceLength)}const s=r.tagLength;s&&n[1]!==void 0&&ve(n[1]);const o=e(i,...n),a=(l,u)=>{if(u!==void 0){if(l!==2)throw new Error("cipher output not supported");ve(u)}};let c=!1;return{encrypt(l,u){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,ve(l),a(o.encrypt.length,u),o.encrypt(l,u)},decrypt(l,u){if(ve(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 $s(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&&!xp(e))throw new Error("invalid output, must be aligned");return e}function ks(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 xp(r){return r.byteOffset%4===0}function Hi(r){return Uint8Array.from(r)}function Ft(...r){for(let e=0;e<r.length;e++)r[e].fill(0)}const Oc=r=>Uint8Array.from(r.split("").map(e=>e.charCodeAt(0))),Pp=Oc("expand 16-byte k"),Ap=Oc("expand 32-byte k"),Rp=ot(Pp),Np=ot(Ap);function V(r,e){return r<<e|r>>>32-e}function Ji(r){return r.byteOffset%4===0}const Sr=64,Tp=16,$c=2**32-1,Ms=new Uint32Array;function Cp(r,e,t,i,n,s,o,a){const c=n.length,l=new Uint8Array(Sr),u=ot(l),h=Ji(n)&&Ji(s),p=h?ot(n):Ms,d=h?ot(s):Ms;for(let f=0;f<c;o++){if(r(e,t,i,u,o,a),o>=$c)throw new Error("arx: counter overflow");const g=Math.min(Sr,c-f);if(h&&g===Sr){const y=f/4;if(f%4!==0)throw new Error("arx: invalid block position");for(let m=0,v;m<Tp;m++)v=y+m,d[v]=p[v]^u[m];f+=Sr;continue}for(let y=0,m;y<g;y++)m=f+y,s[m]=n[m]^l[y];f+=g}}function Op(r,e){const{allowShortKeys:t,extendNonceFn:i,counterLength:n,counterRight:s,rounds:o}=Ep({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof r!="function")throw new Error("core must be a function");return Ei(n),Ei(o),Os(s),Os(t),(a,c,l,u,h=0)=>{ve(a),ve(c),ve(l);const p=l.length;if(u===void 0&&(u=new Uint8Array(p)),ve(u),Ei(h),h<0||h>=$c)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=Hi(a)),y=Np;else if(f===16&&t)g=new Uint8Array(32),g.set(a),g.set(a,16),y=Rp,d.push(g);else throw new Error(`arx: invalid 32-byte key, got length=${f}`);Ji(c)||d.push(c=Hi(c));const m=ot(g);if(i){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");i(y,m,ot(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 b=ot(c);return Cp(r,y,m,b,l,u,h,o),Ft(...d),u}}const ae=(r,e)=>r[e++]&255|(r[e++]&255)<<8;let $p=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=Wi(e),ve(e,32);const t=ae(e,0),i=ae(e,2),n=ae(e,4),s=ae(e,6),o=ae(e,8),a=ae(e,10),c=ae(e,12),l=ae(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]=ae(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=ae(e,t+0),v=ae(e,t+2),b=ae(e,t+4),w=ae(e,t+6),S=ae(e,t+8),x=ae(e,t+10),P=ae(e,t+12),A=ae(e,t+14);let C=s[0]+(m&8191),O=s[1]+((m>>>13|v<<3)&8191),$=s[2]+((v>>>10|b<<6)&8191),D=s[3]+((b>>>7|w<<9)&8191),k=s[4]+((w>>>4|S<<12)&8191),q=s[5]+(S>>>1&8191),F=s[6]+((S>>>14|x<<2)&8191),U=s[7]+((x>>>11|P<<5)&8191),z=s[8]+((P>>>8|A<<8)&8191),L=s[9]+(A>>>5|n),N=0,K=N+C*a+O*(5*y)+$*(5*g)+D*(5*f)+k*(5*d);N=K>>>13,K&=8191,K+=q*(5*p)+F*(5*h)+U*(5*u)+z*(5*l)+L*(5*c),N+=K>>>13,K&=8191;let G=N+C*c+O*a+$*(5*y)+D*(5*g)+k*(5*f);N=G>>>13,G&=8191,G+=q*(5*d)+F*(5*p)+U*(5*h)+z*(5*u)+L*(5*l),N+=G>>>13,G&=8191;let H=N+C*l+O*c+$*a+D*(5*y)+k*(5*g);N=H>>>13,H&=8191,H+=q*(5*f)+F*(5*d)+U*(5*p)+z*(5*h)+L*(5*u),N+=H>>>13,H&=8191;let re=N+C*u+O*l+$*c+D*a+k*(5*y);N=re>>>13,re&=8191,re+=q*(5*g)+F*(5*f)+U*(5*d)+z*(5*p)+L*(5*h),N+=re>>>13,re&=8191;let ye=N+C*h+O*u+$*l+D*c+k*a;N=ye>>>13,ye&=8191,ye+=q*(5*y)+F*(5*g)+U*(5*f)+z*(5*d)+L*(5*p),N+=ye>>>13,ye&=8191;let Ee=N+C*p+O*h+$*u+D*l+k*c;N=Ee>>>13,Ee&=8191,Ee+=q*a+F*(5*y)+U*(5*g)+z*(5*f)+L*(5*d),N+=Ee>>>13,Ee&=8191;let Se=N+C*d+O*p+$*h+D*u+k*l;N=Se>>>13,Se&=8191,Se+=q*c+F*a+U*(5*y)+z*(5*g)+L*(5*f),N+=Se>>>13,Se&=8191;let Ce=N+C*f+O*d+$*p+D*h+k*u;N=Ce>>>13,Ce&=8191,Ce+=q*l+F*c+U*a+z*(5*y)+L*(5*g),N+=Ce>>>13,Ce&=8191;let Ie=N+C*g+O*f+$*d+D*p+k*h;N=Ie>>>13,Ie&=8191,Ie+=q*u+F*l+U*c+z*a+L*(5*y),N+=Ie>>>13,Ie&=8191;let Fe=N+C*y+O*g+$*f+D*d+k*p;N=Fe>>>13,Fe&=8191,Fe+=q*h+F*u+U*l+z*c+L*a,N+=Fe>>>13,Fe&=8191,N=(N<<2)+N|0,N=N+K|0,K=N&8191,N=N>>>13,G+=N,s[0]=K,s[1]=G,s[2]=H,s[3]=re,s[4]=ye,s[5]=Ee,s[6]=Se,s[7]=Ce,s[8]=Ie,s[9]=Fe}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;Ft(i)}update(e){Cs(this);const{buffer:t,blockLen:i}=this;e=Wi(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(){Ft(this.h,this.r,this.buffer,this.pad)}digestInto(e){Cs(this),vp(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 kp(r){const e=(i,n)=>r(n).update(Wi(i)).digest(),t=r(new Uint8Array(32));return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=i=>r(i),e}const Mp=kp(r=>new $p(r));function Lp(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,b=t[0],w=t[1],S=t[2],x=o,P=a,A=c,C=l,O=u,$=h,D=p,k=d,q=f,F=g,U=y,z=m,L=v,N=b,K=w,G=S;for(let re=0;re<s;re+=2)x=x+O|0,L=V(L^x,16),q=q+L|0,O=V(O^q,12),x=x+O|0,L=V(L^x,8),q=q+L|0,O=V(O^q,7),P=P+$|0,N=V(N^P,16),F=F+N|0,$=V($^F,12),P=P+$|0,N=V(N^P,8),F=F+N|0,$=V($^F,7),A=A+D|0,K=V(K^A,16),U=U+K|0,D=V(D^U,12),A=A+D|0,K=V(K^A,8),U=U+K|0,D=V(D^U,7),C=C+k|0,G=V(G^C,16),z=z+G|0,k=V(k^z,12),C=C+k|0,G=V(G^C,8),z=z+G|0,k=V(k^z,7),x=x+$|0,G=V(G^x,16),U=U+G|0,$=V($^U,12),x=x+$|0,G=V(G^x,8),U=U+G|0,$=V($^U,7),P=P+D|0,L=V(L^P,16),z=z+L|0,D=V(D^z,12),P=P+D|0,L=V(L^P,8),z=z+L|0,D=V(D^z,7),A=A+k|0,N=V(N^A,16),q=q+N|0,k=V(k^q,12),A=A+k|0,N=V(N^A,8),q=q+N|0,k=V(k^q,7),C=C+O|0,K=V(K^C,16),F=F+K|0,O=V(O^F,12),C=C+O|0,K=V(K^C,8),F=F+K|0,O=V(O^F,7);let H=0;i[H++]=o+x|0,i[H++]=a+P|0,i[H++]=c+A|0,i[H++]=l+C|0,i[H++]=u+O|0,i[H++]=h+$|0,i[H++]=p+D|0,i[H++]=d+k|0,i[H++]=f+q|0,i[H++]=g+F|0,i[H++]=y+U|0,i[H++]=m+z|0,i[H++]=v+L|0,i[H++]=b+N|0,i[H++]=w+K|0,i[H++]=S+G|0}const Dp=Op(Lp,{counterRight:!1,counterLength:4,allowShortKeys:!1}),Fp=new Uint8Array(16),Ls=(r,e)=>{r.update(e);const t=e.length%16;t&&r.update(Fp.subarray(t))},qp=new Uint8Array(32);function Ds(r,e,t,i,n){const s=r(e,t,qp),o=Mp.create(s);n&&Ls(o,n),Ls(o,i);const a=new Uint8Array(16),c=wp(a);ks(c,0,BigInt(n?n.length:0),!0),ks(c,8,BigInt(i.length),!0),o.update(a);const l=o.digest();return Ft(s,a),l}const Bp=r=>(e,t,i)=>({encrypt(n,s){const o=n.length;s=$s(o+16,s,!1),s.set(n);const a=s.subarray(0,-16);r(e,t,a,a,1);const c=Ds(r,e,t,a,i);return s.set(c,o),Ft(c),s},decrypt(n,s){s=$s(n.length-16,s,!1);const o=n.subarray(0,-16),a=n.subarray(-16),c=Ds(r,e,t,o,i);if(!Sp(a,c))throw new Error("invalid tag");return s.set(n.subarray(0,-16)),r(e,t,s,s,1),Ft(c),s}}),kc=Ip({blockSize:64,nonceLength:12,tagLength:16},Bp(Dp));class Mc extends Nn{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Rn(e);const i=Dt(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 Lt(this),this.iHash.update(e),this}digestInto(e){Lt(this),ri(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 Cn=(r,e,t)=>new Mc(r,e).update(t).digest();Cn.create=(r,e)=>new Mc(r,e);function Up(r,e,t){return Rn(r),t===void 0&&(t=new Uint8Array(r.outputLen)),Cn(r,Dt(t),Dt(e))}const Si=new Uint8Array([0]),Fs=new Uint8Array;function jp(r,e,t,i=32){if(Rn(r),cr(i),i>255*r.outputLen)throw new Error("Length should be <= 255*HashLen");const n=Math.ceil(i/r.outputLen);t===void 0&&(t=Fs);const s=new Uint8Array(n*r.outputLen),o=Cn.create(r,e),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let l=0;l<n;l++)Si[0]=l+1,a.update(l===0?Fs:c).update(t).update(Si).digestInto(c),s.set(c,r.outputLen*l),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),Si.fill(0),s.slice(0,i)}const zp=(r,e,t,i,n)=>jp(r,Up(r,e,t),i,n);function Kp(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 Vp(r,e,t){return r&e^~r&t}function Wp(r,e,t){return r&e^r&t^e&t}let Hp=class extends Nn{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=bi(this.buffer)}update(e){Lt(this);const{view:t,buffer:i,blockLen:n}=this;e=Dt(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=bi(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){Lt(this),Ec(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;Kp(i,n-8,BigInt(this.length*8),s),this.process(i,0);const a=bi(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 Jp=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]),Qe=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Xe=new Uint32Array(64);let Gp=class extends Hp{constructor(){super(64,32,8,!1),this.A=Qe[0]|0,this.B=Qe[1]|0,this.C=Qe[2]|0,this.D=Qe[3]|0,this.E=Qe[4]|0,this.F=Qe[5]|0,this.G=Qe[6]|0,this.H=Qe[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)Xe[h]=e.getUint32(t,!1);for(let h=16;h<64;h++){const p=Xe[h-15],d=Xe[h-2],f=qe(p,7)^qe(p,18)^p>>>3,g=qe(d,17)^qe(d,19)^d>>>10;Xe[h]=g+Xe[h-7]+f+Xe[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=qe(a,6)^qe(a,11)^qe(a,25),d=u+p+Vp(a,c,l)+Jp[h]+Xe[h]|0,f=(qe(i,2)^qe(i,13)^qe(i,22))+Wp(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(){Xe.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const ii=Sc(()=>new Gp);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Lc=BigInt(0);function On(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Dc(r){if(!On(r))throw new Error("Uint8Array expected")}const Yp=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Qp(r){Dc(r);let e="";for(let t=0;t<r.length;t++)e+=Yp[r[t]];return e}function Xp(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Lc:BigInt("0x"+r)}const Ke={_0:48,_9:57,A:65,F:70,a:97,f:102};function qs(r){if(r>=Ke._0&&r<=Ke._9)return r-Ke._0;if(r>=Ke.A&&r<=Ke.F)return r-(Ke.A-10);if(r>=Ke.a&&r<=Ke.f)return r-(Ke.a-10)}function Fc(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=qs(r.charCodeAt(s)),a=qs(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 Bs(r){return Dc(r),Xp(Qp(Uint8Array.from(r).reverse()))}function Zp(r,e){return Fc(r.toString(16).padStart(e*2,"0"))}function eg(r,e){return Zp(r,e).reverse()}function Us(r,e,t){let i;if(typeof e=="string")try{i=Fc(e)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(On(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 Ii=r=>typeof r=="bigint"&&Lc<=r;function tg(r,e,t){return Ii(r)&&Ii(e)&&Ii(t)&&e<=r&&r<t}function js(r,e,t,i){if(!tg(e,t,i))throw new Error("expected valid "+r+": "+t+" <= n < "+i+", got "+e)}const rg={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"||On(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 ig(r,e,t={}){const i=(n,s,o)=>{const a=rg[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 Nt=BigInt(0),Ir=BigInt(1);function qc(r,e){const t=r%e;return t>=Nt?t:e+t}function ng(r,e,t){if(e<Nt)throw new Error("invalid exponent, negatives unsupported");if(t<=Nt)throw new Error("invalid modulus");if(t===Ir)return Nt;let i=Ir;for(;e>Nt;)e&Ir&&(i=i*r%t),r=r*r%t,e>>=Ir;return i}function Me(r,e,t){let i=r;for(;e-- >Nt;)i*=i,i%=t;return i}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);const Pt=BigInt(0),xi=BigInt(1);function sg(r){return ig(r,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...r})}function og(r){const e=sg(r),{P:t}=e,i=v=>qc(v,t),n=e.montgomeryBits,s=Math.ceil(n/8),o=e.nByteLength,a=e.adjustScalarBytes||(v=>v),c=e.powPminus2||(v=>ng(v,t-BigInt(2),t));function l(v,b,w){const S=i(v*(b-w));return b=i(b-S),w=i(w+S),[b,w]}const u=(e.a-BigInt(2))/BigInt(4);function h(v,b){js("u",v,Pt,t),js("scalar",b,Pt,t);const w=b,S=v;let x=xi,P=Pt,A=v,C=xi,O=Pt,$;for(let k=BigInt(n-1);k>=Pt;k--){const q=w>>kξO^=q,$=l(O,x,A),x=$[0],A=$[1],$=l(O,P,C),P=$[0],C=$[1],O=q;const F=x+P,U=i(F*F),z=x-P,L=i(z*z),N=U-L,K=A+C,G=A-C,H=i(G*F),re=i(K*z),ye=H+re,Ee=H-re;A=i(ye*ye),C=i(S*i(Ee*Ee)),x=i(U*L),P=i(N*(U+i(u*N)))}$=l(O,x,A),x=$[0],A=$[1],$=l(O,P,C),P=$[0],C=$[1];const D=c(P);return i(x*D)}function p(v){return eg(i(v),s)}function d(v){const b=Us("u coordinate",v,s);return o===32&&(b[31]&=127),Bs(b)}function f(v){const b=Us("scalar",v),w=b.length;if(w!==s&&w!==o){let S=""+s+" or "+o;throw new Error("invalid scalar, expected "+S+" bytes, got "+w)}return Bs(a(b))}function g(v,b){const w=d(b),S=f(v),x=h(w,S);if(x===Pt)throw new Error("invalid private or public key received");return p(x)}const y=p(e.Gu);function m(v){return g(v,y)}return{scalarMult:g,scalarMultBase:m,getSharedSecret:(v,b)=>g(v,b),getPublicKey:v=>m(v),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:y}}const Gi=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const ag=BigInt(1),zs=BigInt(2),cg=BigInt(3),lg=BigInt(5);BigInt(8);function ug(r){const e=BigInt(10),t=BigInt(20),i=BigInt(40),n=BigInt(80),s=Gi,o=r*r%s*r%s,a=Me(o,zs,s)*o%s,c=Me(a,ag,s)*r%s,l=Me(c,lg,s)*c%s,u=Me(l,e,s)*l%s,h=Me(u,t,s)*u%s,p=Me(h,i,s)*h%s,d=Me(p,n,s)*p%s,f=Me(d,n,s)*p%s,g=Me(f,e,s)*l%s;return{pow_p_5_8:Me(g,zs,s)*r%s,b2:o}}function hg(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}const Yi=og({P:Gi,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:r=>{const e=Gi,{pow_p_5_8:t,b2:i}=ug(r);return qc(Me(t,cg,e)*i,e)},adjustScalarBytes:hg,randomBytes:yr}),Bc="base10",he="base16",nt="base64pad",Ht="base64url",mr="utf8",Uc=0,Ge=1,vr=2,dg=0,Ks=1,ir=12,$n=32;function fg(){const r=Yi.utils.randomPrivateKey(),e=Yi.getPublicKey(r);return{privateKey:_.toString(r,he),publicKey:_.toString(e,he)}}function Qi(){const r=yr($n);return _.toString(r,he)}function pg(r,e){const t=Yi.getSharedSecret(_.fromString(r,he),_.fromString(e,he)),i=zp(ii,t,void 0,void 0,$n);return _.toString(i,he)}function Cr(r){const e=ii(_.fromString(r,he));return _.toString(e,he)}function We(r){const e=ii(_.fromString(r,mr));return _.toString(e,he)}function jc(r){return _.fromString(`${r}`,Bc)}function vt(r){return Number(_.toString(r,Bc))}function gg(r){const e=jc(typeof r.type<"u"?r.type:Uc);if(vt(e)===Ge&&typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const t=typeof r.senderPublicKey<"u"?_.fromString(r.senderPublicKey,he):void 0,i=typeof r.iv<"u"?_.fromString(r.iv,he):yr(ir),n=_.fromString(r.symKey,he),s=kc(n,i).encrypt(_.fromString(r.message,mr));return zc({type:e,sealed:s,iv:i,senderPublicKey:t,encoding:r.encoding})}function yg(r){const e=_.fromString(r.symKey,he),{sealed:t,iv:i}=ur(r),n=kc(e,i).decrypt(t);if(n===null)throw new Error("Failed to decrypt");return _.toString(n,mr)}function mg(r,e){const t=jc(vr),i=yr(ir),n=_.fromString(r,mr);return zc({type:t,sealed:n,iv:i,encoding:e})}function vg(r,e){const{sealed:t}=ur({encoded:r,encoding:e});return _.toString(t,mr)}function zc(r){const{encoding:e=nt}=r;if(vt(r.type)===vr)return _.toString(_.concat([r.type,r.sealed]),e);if(vt(r.type)===Ge){if(typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return _.toString(_.concat([r.type,r.senderPublicKey,r.iv,r.sealed]),e)}return _.toString(_.concat([r.type,r.iv,r.sealed]),e)}function ur(r){const{encoded:e,encoding:t=nt}=r,i=_.fromString(e,t),n=i.slice(dg,Ks),s=Ks;if(vt(n)===Ge){const l=s+$n,u=l+ir,h=i.slice(s,l),p=i.slice(l,u),d=i.slice(u);return{type:n,sealed:d,iv:p,senderPublicKey:h}}if(vt(n)===vr){const l=i.slice(s),u=yr(ir);return{type:n,sealed:l,iv:u}}const o=s+ir,a=i.slice(s,o),c=i.slice(o);return{type:n,sealed:c,iv:a}}function wg(r,e){const t=ur({encoded:r,encoding:e==null?void 0:e.encoding});return Kc({type:vt(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?_.toString(t.senderPublicKey,he):void 0,receiverPublicKey:e==null?void 0:e.receiverPublicKey})}function Kc(r){const e=(r==null?void 0:r.type)||Uc;if(e===Ge){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 Vs(r){return r.type===Ge&&typeof r.senderPublicKey=="string"&&typeof r.receiverPublicKey=="string"}function Ws(r){return r.type===vr}function _g(r){return new Il.ec("p256").keyFromPublic({x:E.dist.Buffer.from(r.x,"base64").toString("hex"),y:E.dist.Buffer.from(r.y,"base64").toString("hex")},"hex")}function bg(r){let e=r.replace(/-/g,"+").replace(/_/g,"/");const t=e.length%4;return t>0&&(e+="=".repeat(4-t)),e}function Eg(r){return E.dist.Buffer.from(bg(r),"base64")}function Sg(r,e){const[t,i,n]=r.split("."),s=Eg(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=ii(c),u=_g(e),h=_.toString(l,he);if(!u.verify(h,{r:o,s:a}))throw new Error("Invalid signature");return _.sn(r).payload}const Ig="irn";function jr(r){return(r==null?void 0:r.relay)||{protocol:Ig}}function Zt(r){const e=_.C[r];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${r}`);return e}function xg(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 Hs(r){if(!r.includes("wc:")){const l=bc(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:Pg(n[0]),version:parseInt(n[1],10),symKey:a.symKey,relay:xg(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function Pg(r){return r.startsWith("//")?r.substring(2):r}function Ag(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 Js(r){const e=new URLSearchParams,t=Ag(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 xr(r,e,t){return`${r}?wc_ev=${t}&topic=${e}`}function Kt(r){const e=[];return r.forEach(t=>{const[i,n]=t.split(":");e.push(`${i}:${n}`)}),e}function Rg(r){const e=[];return Object.values(r).forEach(t=>{e.push(...Kt(t.accounts))}),e}function Ng(r,e){const t=[];return Object.values(r).forEach(i=>{Kt(i.accounts).includes(e)&&t.push(...i.methods)}),t}function Tg(r,e){const t=[];return Object.values(r).forEach(i=>{Kt(i.accounts).includes(e)&&t.push(...i.events)}),t}function Cg(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 Gs(r,e){e=e.map(i=>i.replace("did:pkh:",""));const t=Cg(e);for(const[i,n]of Object.entries(t))n.methods?n.methods=wf(n.methods,r):n.methods=r,n.events=["chainChanged","accountsChanged"];return t}const Og={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}},$g={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 R(r,e){const{message:t,code:i}=$g[r];return{message:e?`${t} ${e}`:t,code:i}}function J(r,e){const{message:t,code:i}=Og[r];return{message:e?`${t} ${e}`:t,code:i}}function ni(r,e){return!!Array.isArray(r)}function zr(r){return Object.getPrototypeOf(r)===Object.prototype&&Object.keys(r).length}function fe(r){return typeof r>"u"}function te(r,e){return e&&fe(r)?!0:typeof r=="string"&&!!r.trim().length}function kn(r,e){return e&&fe(r)?!0:typeof r=="number"&&!isNaN(r)}function kg(r,e){const{requiredNamespaces:t}=e,i=Object.keys(r.namespaces),n=Object.keys(t);let s=!0;return yt(n,i)?(i.forEach(o=>{const{accounts:a,methods:c,events:l}=r.namespaces[o],u=Kt(a),h=t[o];(!yt(pc(o,h),u)||!yt(h.methods,c)||!yt(h.events,l))&&(s=!1)}),s):!1}function Kr(r){return te(r,!1)&&r.includes(":")?r.split(":").length===2:!1}function Mg(r){if(te(r,!1)&&r.includes(":")){const e=r.split(":");if(e.length===3){const t=e[0]+":"+e[1];return!!e[2]&&Kr(t)}}return!1}function Lg(r){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(te(r,!1)){if(e(r))return!0;const t=bc(r);return e(t)}}catch{}return!1}function Dg(r){var e;return(e=r==null?void 0:r.proposer)==null?void 0:e.publicKey}function Fg(r){return r==null?void 0:r.topic}function qg(r,e){let t=null;return te(r==null?void 0:r.publicKey,!1)||(t=R("MISSING_OR_INVALID",`${e} controller public key should be a string`)),t}function Ys(r){let e=!0;return ni(r)?r.length&&(e=r.every(t=>te(t,!1))):e=!1,e}function Bg(r,e,t){let i=null;return ni(e)&&e.length?e.forEach(n=>{i||Kr(n)||(i=J("UNSUPPORTED_CHAINS",`${t}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):Kr(r)||(i=J("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 Ug(r,e,t){let i=null;return Object.entries(r).forEach(([n,s])=>{if(i)return;const o=Bg(n,pc(n,s),`${e} ${t}`);o&&(i=o)}),i}function jg(r,e){let t=null;return ni(r)?r.forEach(i=>{t||Mg(i)||(t=J("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):t=J("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}function zg(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;const n=jg(i==null?void 0:i.accounts,`${e} namespace`);n&&(t=n)}),t}function Kg(r,e){let t=null;return Ys(r==null?void 0:r.methods)?Ys(r==null?void 0:r.events)||(t=J("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=J("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}function Vc(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;const n=Kg(i,`${e}, namespace`);n&&(t=n)}),t}function Vg(r,e,t){let i=null;if(r&&zr(r)){const n=Vc(r,e);n&&(i=n);const s=Ug(r,e,t);s&&(i=s)}else i=R("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return i}function Pi(r,e){let t=null;if(r&&zr(r)){const i=Vc(r,e);i&&(t=i);const n=zg(r,e);n&&(t=n)}else t=R("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function Wc(r){return te(r.protocol,!0)}function Wg(r,e){let t=!1;return r?r&&ni(r)&&r.length&&r.forEach(i=>{t=Wc(i)}):t=!0,t}function Hg(r){return typeof r=="number"}function pe(r){return typeof r<"u"&&typeof r!==null}function Jg(r){return!(!r||typeof r!="object"||!r.code||!kn(r.code,!1)||!r.message||!te(r.message,!1))}function Gg(r){return!(fe(r)||!te(r.method,!1))}function Yg(r){return!(fe(r)||fe(r.result)&&fe(r.error)||!kn(r.id,!1)||!te(r.jsonrpc,!1))}function Qg(r){return!(fe(r)||!te(r.name,!1))}function Qs(r,e){return!(!Kr(e)||!Rg(r).includes(e))}function Xg(r,e,t){return te(t,!1)?Ng(r,e).includes(t):!1}function Zg(r,e,t){return te(t,!1)?Tg(r,e).includes(t):!1}function Xs(r,e,t){let i=null;const n=ey(r),s=ty(e),o=Object.keys(n),a=Object.keys(s),c=Zs(Object.keys(r)),l=Zs(Object.keys(e)),u=c.filter(h=>!l.includes(h));return u.length&&(i=R("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces.
|
|
526
|
+
Required: ${u.toString()}
|
|
527
|
+
Received: ${Object.keys(e).toString()}`)),yt(o,a)||(i=R("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=Kt(e[h].accounts);p.includes(h)||(i=R("NON_CONFORMING_NAMESPACES",`${t} namespaces accounts don't satisfy namespace accounts for ${h}
|
|
530
|
+
Required: ${h}
|
|
531
|
+
Approved: ${p.toString()}`))}),o.forEach(h=>{i||(yt(n[h].methods,s[h].methods)?yt(n[h].events,s[h].events)||(i=R("NON_CONFORMING_NAMESPACES",`${t} namespaces events don't satisfy namespace events for ${h}`)):i=R("NON_CONFORMING_NAMESPACES",`${t} namespaces methods don't satisfy namespace methods for ${h}`))}),i}function ey(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 Zs(r){return[...new Set(r.map(e=>e.includes(":")?e.split(":")[0]:e))]}function ty(r){const e={};return Object.keys(r).forEach(t=>{if(t.includes(":"))e[t]=r[t];else{const i=Kt(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 ry(r,e){return kn(r,!1)&&r<=e.max&&r>=e.min}function eo(){const r=gr();return new Promise(e=>{switch(r){case we.browser:e(iy());break;case we.reactNative:e(ny());break;case we.node:e(sy());break;default:e(!0)}})}function iy(){return pr()&&(navigator==null?void 0:navigator.onLine)}async function ny(){if(ht()&&typeof E.dist.global<"u"&&E.dist.global!=null&&E.dist.global.NetInfo){const r=await(E.dist.global==null?void 0:E.dist.global.NetInfo.fetch());return r==null?void 0:r.isConnected}return!0}function sy(){return!0}function oy(r){switch(gr()){case we.browser:ay(r);break;case we.reactNative:cy(r);break}}function ay(r){!ht()&&pr()&&(window.addEventListener("online",()=>r(!0)),window.addEventListener("offline",()=>r(!1)))}function cy(r){var e;ht()&&typeof E.dist.global<"u"&&E.dist.global!=null&&E.dist.global.NetInfo&&((e=E.dist.global)==null||e.NetInfo.addEventListener(t=>r(t==null?void 0:t.isConnected)))}const Ai={};class Jt{static get(e){return Ai[e]}static set(e,t){Ai[e]=t}static delete(e){delete Ai[e]}}const ly=r=>JSON.stringify(r,(e,t)=>typeof t=="bigint"?t.toString()+"n":t),uy=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 hy(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return uy(r)}catch{return r}}function dy(r){return typeof r=="string"?r:ly(r)||""}const fy=()=>typeof WebSocket<"u"?WebSocket:typeof E.dist.global<"u"&&typeof E.dist.global.WebSocket<"u"?E.dist.global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),py=()=>typeof WebSocket<"u"||typeof E.dist.global<"u"&&typeof E.dist.global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",to=r=>r.split("?")[0],ro=10,gy=fy();class yy{constructor(e){if(this.url=e,this.events=new Re.eventsExports.EventEmitter,this.registering=!1,!_.isWsUrl(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(dy(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!_.isWsUrl(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=_.cjs.isReactNative()?void 0:{rejectUnauthorized:!_.isLocalhostUrl(e)},s=new gy(e,[],n);py()?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"?hy(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const i=this.parseError(t),n=i.message||i.toString(),s=_.formatJsonRpcError(e,n);this.events.emit("payload",s)}parseError(e,t=this.url){return _.parseConnectionError(e,to(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>ro&&this.events.setMaxListeners(ro)}emitError(e){const t=this.parseError(new Error((e==null?void 0:e.message)||`WebSocket connection failed for host: ${to(this.url)}`));return this.events.emit("register_error",t),t}}var Z={};Object.defineProperty(Z,"__esModule",{value:!0});Z.getLocalStorage=Z.getLocalStorageOrThrow=Z.getCrypto=Z.getCryptoOrThrow=Z.getLocation=Z.getLocationOrThrow=Z.getNavigator=Z.getNavigatorOrThrow=Hc=Z.getDocument=Z.getDocumentOrThrow=Z.getFromWindowOrThrow=Z.getFromWindow=void 0;function St(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}Z.getFromWindow=St;function Vt(r){const e=St(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}Z.getFromWindowOrThrow=Vt;function my(){return Vt("document")}Z.getDocumentOrThrow=my;function vy(){return St("document")}var Hc=Z.getDocument=vy;function wy(){return Vt("navigator")}Z.getNavigatorOrThrow=wy;function _y(){return St("navigator")}Z.getNavigator=_y;function by(){return Vt("location")}Z.getLocationOrThrow=by;function Ey(){return St("location")}Z.getLocation=Ey;function Sy(){return Vt("crypto")}Z.getCryptoOrThrow=Sy;function Iy(){return St("crypto")}Z.getCrypto=Iy;function xy(){return Vt("localStorage")}Z.getLocalStorageOrThrow=xy;function Py(){return St("localStorage")}Z.getLocalStorage=Py;const Jc="wc",Gc=2,Xi="core",je=`${Jc}@2:${Xi}:`,Ay={logger:"error"},Ry={database:":memory:"},Ny="crypto",io="client_ed25519_seed",Ty=I.cjs.ONE_DAY,Cy="keychain",Oy="0.3",$y="messages",ky="0.3",no=I.cjs.SIX_HOURS,My="publisher",Yc="irn",Ly="error",Qc="wss://relay.walletconnect.org",Dy="relayer",se={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"},Fy="_subscription",xe={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},qy=.1,Zi="2.18.0",Y={link_mode:"link_mode",relay:"relay"},By="0.3",Uy="WALLETCONNECT_CLIENT_ID",so="WALLETCONNECT_LINK_MODE_APPS",me={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},jy="subscription",zy="0.3",Ky=I.cjs.FIVE_SECONDS*1e3,Vy="pairing",Wy="0.3",Gt={wc_pairingDelete:{req:{ttl:I.cjs.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:I.cjs.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:I.cjs.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:I.cjs.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:I.cjs.ONE_DAY,prompt:!1,tag:0},res:{ttl:I.cjs.ONE_DAY,prompt:!1,tag:0}}},gt={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Oe={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},Hy="history",Jy="0.3",Gy="expirer",Pe={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},Yy="0.3",Qy="verify-api",Xy="https://verify.walletconnect.com",Xc="https://verify.walletconnect.org",nr=Xc,Zy=`${nr}/v3`,em=[Xy,Xc],tm="echo",rm="https://echo.walletconnect.com",Ue={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"},Ve={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"},$e={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"},dt={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"},ft={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"},Yt={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"},im=.1,nm="event-client",sm=86400,om="https://pulse.walletconnect.org/batch";function am(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 b=(v-m)*u+1>>>0,w=new Uint8Array(b);m!==v;){for(var S=f[m],x=0,P=b-1;(S!==0||x<y)&&P!==-1;P--,x++)S+=256*w[P]>>>0,w[P]=S%a>>>0,S=S/a>>>0;if(S!==0)throw new Error("Non-zero carry");y=x,m++}for(var A=b-y;A!==b&&w[A]===0;)A++;for(var C=c.repeat(g);A<b;++A)C+=r.charAt(w[A]);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,b=new Uint8Array(v);f[g];){var w=t[f.charCodeAt(g)];if(w===255)return;for(var S=0,x=v-1;(w!==0||S<m)&&x!==-1;x--,S++)w+=a*b[x]>>>0,b[x]=w%256>>>0,w=w/256>>>0;if(w!==0)throw new Error("Non-zero carry");m=S,g++}if(f[g]!==" "){for(var P=v-m;P!==v&&b[P]===0;)P++;for(var A=new Uint8Array(y+(v-P)),C=y;P!==v;)A[C++]=b[P++];return A}}}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 cm=am,lm=cm;const Zc=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")},um=r=>new TextEncoder().encode(r),hm=r=>new TextDecoder().decode(r);class dm{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 fm{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 el(this,e)}}class pm{constructor(e){this.decoders=e}or(e){return el(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 el=(r,e)=>new pm({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}});class gm{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new dm(e,t,i),this.decoder=new fm(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const si=({name:r,prefix:e,encode:t,decode:i})=>new gm(r,e,t,i),wr=({prefix:r,name:e,alphabet:t})=>{const{encode:i,decode:n}=lm(t,e);return si({prefix:r,name:e,encode:i,decode:s=>Zc(n(s))})},ym=(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},mm=(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},le=({name:r,prefix:e,bitsPerChar:t,alphabet:i})=>si({prefix:e,name:r,encode(n){return mm(n,i,t)},decode(n){return ym(n,i,t,r)}}),vm=si({prefix:"\0",name:"identity",encode:r=>hm(r),decode:r=>um(r)});var wm=Object.freeze({__proto__:null,identity:vm});const _m=le({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var bm=Object.freeze({__proto__:null,base2:_m});const Em=le({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Sm=Object.freeze({__proto__:null,base8:Em});const Im=wr({prefix:"9",name:"base10",alphabet:"0123456789"});var xm=Object.freeze({__proto__:null,base10:Im});const Pm=le({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Am=le({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Rm=Object.freeze({__proto__:null,base16:Pm,base16upper:Am});const Nm=le({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Tm=le({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Cm=le({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Om=le({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),$m=le({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),km=le({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Mm=le({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Lm=le({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Dm=le({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Fm=Object.freeze({__proto__:null,base32:Nm,base32upper:Tm,base32pad:Cm,base32padupper:Om,base32hex:$m,base32hexupper:km,base32hexpad:Mm,base32hexpadupper:Lm,base32z:Dm});const qm=wr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Bm=wr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Um=Object.freeze({__proto__:null,base36:qm,base36upper:Bm});const jm=wr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),zm=wr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Km=Object.freeze({__proto__:null,base58btc:jm,base58flickr:zm});const Vm=le({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Wm=le({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Hm=le({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Jm=le({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Gm=Object.freeze({__proto__:null,base64:Vm,base64pad:Wm,base64url:Hm,base64urlpad:Jm});const tl=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),Ym=tl.reduce((r,e,t)=>(r[t]=e,r),[]),Qm=tl.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function Xm(r){return r.reduce((e,t)=>(e+=Ym[t],e),"")}function Zm(r){const e=[];for(const t of r){const i=Qm[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}const e0=si({prefix:"🚀",name:"base256emoji",encode:Xm,decode:Zm});var t0=Object.freeze({__proto__:null,base256emoji:e0}),r0=rl,oo=128,i0=-128,n0=Math.pow(2,31);function rl(r,e,t){e=e||[],t=t||0;for(var i=t;r>=n0;)e[t++]=r&255|oo,r/=128;for(;r&i0;)e[t++]=r&255|oo,r>>>=7;return e[t]=r|0,rl.bytes=t-i+1,e}var s0=en,o0=128,ao=127;function en(r,i){var t=0,i=i||0,n=0,s=i,o,a=r.length;do{if(s>=a)throw en.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&ao)<<n:(o&ao)*Math.pow(2,n),n+=7}while(o>=o0);return en.bytes=s-i,t}var a0=Math.pow(2,7),c0=Math.pow(2,14),l0=Math.pow(2,21),u0=Math.pow(2,28),h0=Math.pow(2,35),d0=Math.pow(2,42),f0=Math.pow(2,49),p0=Math.pow(2,56),g0=Math.pow(2,63),y0=function(r){return r<a0?1:r<c0?2:r<l0?3:r<u0?4:r<h0?5:r<d0?6:r<f0?7:r<p0?8:r<g0?9:10},m0={encode:r0,decode:s0,encodingLength:y0},il=m0;const co=(r,e,t=0)=>(il.encode(r,e,t),e),lo=r=>il.encodingLength(r),tn=(r,e)=>{const t=e.byteLength,i=lo(r),n=i+lo(t),s=new Uint8Array(n+t);return co(r,s,0),co(t,s,i),s.set(e,n),new v0(r,t,e,s)};class v0{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}}const nl=({name:r,code:e,encode:t})=>new w0(r,e,t);class w0{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?tn(this.code,t):t.then(i=>tn(this.code,i))}else throw Error("Unknown type, must be binary type")}}const sl=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),_0=nl({name:"sha2-256",code:18,encode:sl("SHA-256")}),b0=nl({name:"sha2-512",code:19,encode:sl("SHA-512")});var E0=Object.freeze({__proto__:null,sha256:_0,sha512:b0});const ol=0,S0="identity",al=Zc,I0=r=>tn(ol,al(r)),x0={code:ol,name:S0,encode:al,digest:I0};var P0=Object.freeze({__proto__:null,identity:x0});new TextEncoder,new TextDecoder;const uo={...wm,...bm,...Sm,...xm,...Rm,...Fm,...Um,...Km,...Gm,...t0};({...E0,...P0});function A0(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function cl(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}const ho=cl("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ri=cl("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=A0(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),R0={utf8:ho,"utf-8":ho,hex:uo.base16,latin1:Ri,ascii:Ri,binary:Ri,...uo};function N0(r,e="utf8"){const t=R0[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 T0{constructor(e,t){this.core=e,this.logger=t,this.keychain=new Map,this.name=Cy,this.version=Oy,this.initialized=!1,this.storagePrefix=je,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}=R("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=_.E(t,this.name)}get context(){return _.y(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,mc(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?vc(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=R("NOT_INITIALIZED",this.name);throw new Error(e)}}}class C0{constructor(e,t,i){this.core=e,this.logger=t,this.name=Ny,this.randomSessionIdentifier=Qi(),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=_.Po(n);return _.Qe(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const n=fg();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();const s=await this.getClientSeed(),o=_.Po(s),a=this.randomSessionIdentifier,c=Ty;return await _.Qo(a,n,c,o)},this.generateSharedKey=(n,s,o)=>{this.isInitialized();const a=this.getPrivateKey(n),c=pg(a,s);return this.setSymKey(c,o)},this.setSymKey=async(n,s)=>{this.isInitialized();const o=s||Cr(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=Kc(o),c=kd(s);if(Ws(a))return mg(c,o==null?void 0:o.encoding);if(Vs(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 gg({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=wg(s,o);if(Ws(a)){const c=vg(s,o==null?void 0:o.encoding);return ps(c)}if(Vs(a)){const c=a.receiverPublicKey,l=a.senderPublicKey;n=await this.generateSharedKey(c,l)}try{const c=this.getSymKey(n),l=yg({symKey:c,encoded:s,encoding:o==null?void 0:o.encoding});return ps(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=nt)=>{const o=ur({encoded:n,encoding:s});return vt(o.type)},this.getPayloadSenderPublicKey=(n,s=nt)=>{const o=ur({encoded:n,encoding:s});return o.senderPublicKey?_.toString(o.senderPublicKey,he):void 0},this.core=e,this.logger=_.E(t,this.name),this.keychain=i||new T0(this.core,this.logger)}get context(){return _.y(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(io)}catch{e=Qi(),await this.keychain.set(io,e)}return N0(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=R("NOT_INITIALIZED",this.name);throw new Error(e)}}}class O0 extends Sd{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name=$y,this.version=ky,this.initialized=!1,this.storagePrefix=je,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=We(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=We(n);return typeof s[o]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=_.E(e,this.name),this.core=t}get context(){return _.y(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,mc(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?vc(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=R("NOT_INITIALIZED",this.name);throw new Error(e)}}}var $0=Object.defineProperty,k0=Object.defineProperties,M0=Object.getOwnPropertyDescriptors,fo=Object.getOwnPropertySymbols,L0=Object.prototype.hasOwnProperty,D0=Object.prototype.propertyIsEnumerable,po=(r,e,t)=>e in r?$0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,go=(r,e)=>{for(var t in e||(e={}))L0.call(e,t)&&po(r,t,e[t]);if(fo)for(var t of fo(e))D0.call(e,t)&&po(r,t,e[t]);return r},yo=(r,e)=>k0(r,M0(e));class F0 extends Id{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new Re.eventsExports.EventEmitter,this.name=My,this.queue=new Map,this.publishTimeout=I.cjs.toMiliseconds(I.cjs.ONE_MINUTE),this.initialPublishTimeout=I.cjs.toMiliseconds(I.cjs.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)||no,c=jr(s),l=(s==null?void 0:s.prompt)||!1,u=(s==null?void 0:s.tag)||0,h=(s==null?void 0:s.id)||_.getBigIntRpcId().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(se.publish,y),g(p))};this.relayer.events.on(se.publish,y);const m=it(new Promise((v,b)=>{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),b(w)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${h} tag:${u}`);try{await m,this.events.removeListener(se.publish,y)}catch(v){this.queue.set(h,yo(go({},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 it(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=_.E(t,this.name),this.registerEventListeners()}get context(){return _.y(this.logger)}async rpcPublish(e){var t,i,n,s;const{topic:o,message:a,ttl:c=no,prompt:l,tag:u,id:h,attestation:p}=e,d={method:Zt(jr().protocol).publish,params:{topic:o,message:a,ttl:c,prompt:l,tag:u,attestation:p},id:h};fe((t=d.params)==null?void 0:t.prompt)&&((i=d.params)==null||delete i.prompt),fe((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(se.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,yo(go({},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(Ut.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(se.connection_stalled);return}this.checkQueue()}),this.relayer.on(se.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}class q0{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 B0=Object.defineProperty,U0=Object.defineProperties,j0=Object.getOwnPropertyDescriptors,mo=Object.getOwnPropertySymbols,z0=Object.prototype.hasOwnProperty,K0=Object.prototype.propertyIsEnumerable,vo=(r,e,t)=>e in r?B0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Qt=(r,e)=>{for(var t in e||(e={}))z0.call(e,t)&&vo(r,t,e[t]);if(mo)for(var t of mo(e))K0.call(e,t)&&vo(r,t,e[t]);return r},Ni=(r,e)=>U0(r,j0(e));class V0 extends Ad{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new q0,this.events=new Re.eventsExports.EventEmitter,this.name=jy,this.version=zy,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=je,this.subscribeTimeout=I.cjs.toMiliseconds(I.cjs.ONE_MINUTE),this.initialSubscribeTimeout=I.cjs.toMiliseconds(I.cjs.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=jr(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.cjs.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)>=Ky&&(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(Ut.pulse,async()=>{await this.checkPending()}),this.events.on(me.created,async i=>{const n=me.created;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()}),this.events.on(me.deleted,async i=>{const n=me.deleted;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()})},this.relayer=e,this.logger=_.E(t,this.name),this.clientId=""}get context(){return _.y(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=jr(i);await this.rpcUnsubscribe(e,t,n);const s=J("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)===Y.relay&&await this.restartToComplete();const s={method:Zt(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)===Y.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(u=>this.logger.warn(u))},I.cjs.toMiliseconds(I.cjs.ONE_SECOND)),a;const c=new Promise(async u=>{const h=p=>{p.topic===e&&(this.events.removeListener(me.created,h),u(p.id))};this.events.on(me.created,h);try{const p=await it(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(me.created,h),u(p)}catch{}}),l=await it(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(se.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;const t=e[0].relay,i={method:Zt(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 it(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(se.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const t=e[0].relay,i={method:Zt(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 it(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(se.connection_stalled)}return n}rpcUnsubscribe(e,t,i){const n={method:Zt(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,Ni(Qt({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,Qt({},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,Qt({},t)),this.topicMap.set(t.topic,e),this.events.emit(me.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}=R("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(me.deleted,Ni(Qt({},i),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(me.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(me.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:t}=R("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=>Ni(Qt({},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 Af(I.cjs.toMiliseconds(I.cjs.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}=R("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen()}getSubscriptionId(e){return We(e+this.clientId)}}var W0=Object.defineProperty,wo=Object.getOwnPropertySymbols,H0=Object.prototype.hasOwnProperty,J0=Object.prototype.propertyIsEnumerable,_o=(r,e,t)=>e in r?W0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,bo=(r,e)=>{for(var t in e||(e={}))H0.call(e,t)&&_o(r,t,e[t]);if(wo)for(var t of wo(e))J0.call(e,t)&&_o(r,t,e[t]);return r};class G0 extends xd{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new Re.eventsExports.EventEmitter,this.name=Dy,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.hasExperiencedNetworkDisruption=!1,this.heartBeatTimeout=I.cjs.toMiliseconds(I.cjs.THIRTY_SECONDS+I.cjs.FIVE_SECONDS),this.requestsInFlight=[],this.connectTimeout=I.cjs.toMiliseconds(I.cjs.ONE_SECOND*15),this.request=async t=>{var i,n;this.logger.debug("Publishing Request Payload");const s=t.id||_.getBigIntRpcId().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(Br())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(se.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(se.error,t),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(xe.payload,this.onPayloadHandler),this.provider.on(xe.connect,this.onConnectHandler),this.provider.on(xe.disconnect,this.onDisconnectHandler),this.provider.on(xe.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?_.E(e.logger,this.name):_.Tt(_.k({level:e.logger||Ly})),this.messages=new O0(this.logger,e.core),this.subscriber=new V0(this,this.logger),this.publisher=new F0(this,this.logger),this.relayUrl=(e==null?void 0:e.relayUrl)||Qc,this.projectId=e.projectId,hf()?this.packageName=vs():df()&&(this.bundleId=vs()),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 _.y(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:Y.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(me.created,l),c())};return await Promise.all([new Promise(u=>{c=u,this.subscriber.on(me.created,l)}),new Promise(async(u,h)=>{a=await this.subscriber.subscribe(e,bo({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 it(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 eo())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=ie(I.cjs.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(se.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(xe.disconnect,s),await it(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(xe.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(xe.disconnect,c),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(xe.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.cjs.toMiliseconds(t*1))),t++}}startPingTimeout(){var e,t,i,n,s;if(Br())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 yl(new yy(yf({sdkVersion:Zi,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}),_.isJsonRpcRequest(e)){if(!e.method.endsWith(Fy))return;const t=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=t.data,a={topic:i,message:n,publishedAt:s,transportType:Y.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(bo({type:"event",event:t.id},a)),this.events.emit(t.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else _.isJsonRpcResponse(e)&&this.events.emit(se.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(se.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const t=_.formatJsonRpcResult(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(xe.payload,this.onPayloadHandler),this.provider.off(xe.connect,this.onConnectHandler),this.provider.off(xe.disconnect,this.onDisconnectHandler),this.provider.off(xe.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await eo();oy(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(se.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.cjs.toMiliseconds(qy))))}isInitialized(){if(!this.initialized){const{message:e}=R("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&await this.transportOpen()}}var Y0=Object.defineProperty,Eo=Object.getOwnPropertySymbols,Q0=Object.prototype.hasOwnProperty,X0=Object.prototype.propertyIsEnumerable,So=(r,e,t)=>e in r?Y0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Io=(r,e)=>{for(var t in e||(e={}))Q0.call(e,t)&&So(r,t,e[t]);if(Eo)for(var t of Eo(e))X0.call(e,t)&&So(r,t,e[t]);return r};class It extends Pd{constructor(e,t,i,n=je,s=void 0){super(e,t,i,n),this.core=e,this.logger=t,this.name=i,this.map=new Map,this.version=By,this.cached=[],this.initialized=!1,this.storagePrefix=je,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&&!fe(o)?this.map.set(this.getKey(o),o):Dg(o)?this.map.set(o.id,o):Fg(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=>_._s(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=Io(Io({},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=_.E(t,this.name),this.storagePrefix=n,this.getKey=s}get context(){return _.y(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}=R("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}const{message:i}=R("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}=R("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}=R("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Z0{constructor(e,t){this.core=e,this.logger=t,this.name=Vy,this.version=Wy,this.events=new Re.ss,this.initialized=!1,this.storagePrefix=je,this.ignoredPayloadTypes=[Ge],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=Qi(),s=await this.core.crypto.setSymKey(n),o=ie(I.cjs.FIVE_MINUTES),a={protocol:Yc},c={topic:s,expiry:o,relay:a,active:!1,methods:i==null?void 0:i.methods},l=Js({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(gt.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:[Ue.pairing_started]}});this.isValidPair(i,n);const{topic:s,symKey:o,relay:a,expiryTimestamp:c,methods:l}=Hs(i.uri);n.props.properties.topic=s,n.addTrace(Ue.pairing_uri_validation_success),n.addTrace(Ue.pairing_uri_not_expired);let u;if(this.pairings.keys.includes(s)){if(u=this.pairings.get(s),n.addTrace(Ue.existing_pairing),u.active)throw n.setError(Ve.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);n.addTrace(Ue.pairing_not_expired)}const h=c||ie(I.cjs.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(Ue.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(gt.create,p),n.addTrace(Ue.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(Ue.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(Ve.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:a})}catch(d){throw n.setError(Ve.subscribe_pairing_topic_failure),d}return n.addTrace(Ue.subscribe_pairing_topic_success),p},this.activate=async({topic:i})=>{this.isInitialized();const n=ie(I.cjs.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}=pt();this.events.once(B("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",J("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 Js({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=_.formatJsonRpcRequest(n,s),a=await this.core.crypto.encode(i,o),c=Gt[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=_.formatJsonRpcResult(i,s),a=await this.core.crypto.encode(n,o),c=await this.core.history.get(n,i),l=Gt[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=_.formatJsonRpcError(i,s),a=await this.core.crypto.encode(n,o),c=await this.core.history.get(n,i),l=Gt[c.request.method]?Gt[c.request.method].res:Gt.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,J("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=>et(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(gt.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(()=>{_.isJsonRpcResult(n)?this.events.emit(B("pairing_ping",s),{}):_.isJsonRpcError(n)&&this.events.emit(B("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(gt.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=J("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(J("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=(i,n)=>{var s;if(!pe(i)){const{message:a}=R("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(Ve.malformed_pairing_uri),new Error(a)}if(!Lg(i.uri)){const{message:a}=R("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(Ve.malformed_pairing_uri),new Error(a)}const o=Hs(i==null?void 0:i.uri);if(!((s=o==null?void 0:o.relay)!=null&&s.protocol)){const{message:a}=R("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(Ve.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=R("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(Ve.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&I.cjs.toMiliseconds(o==null?void 0:o.expiryTimestamp)<Date.now()){n.setError(Ve.pairing_expired);const{message:a}=R("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}},this.isValidPing=async i=>{if(!pe(i)){const{message:s}=R("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidDisconnect=async i=>{if(!pe(i)){const{message:s}=R("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidPairingTopic=async i=>{if(!te(i,!1)){const{message:n}=R("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){const{message:n}=R("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(et(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:n}=R("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}},this.core=e,this.logger=_.E(t,this.name),this.pairings=new It(this.core,this.logger,this.name,this.storagePrefix)}get context(){return _.y(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=R("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(se.message,async e=>{const{topic:t,message:i,transportType:n}=e;if(!this.pairings.keys.includes(t)||n===Y.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const s=await this.core.crypto.decode(t,i);try{_.isJsonRpcRequest(s)?(this.core.history.set(t,s),this.onRelayEventRequest({topic:t,payload:s})):_.isJsonRpcResponse(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(Pe.expired,async e=>{const{topic:t}=_c(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(gt.expire,{topic:t}))})}}class ev extends Ed{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new Re.eventsExports.EventEmitter,this.name=Hy,this.version=Jy,this.cached=[],this.initialized=!1,this.storagePrefix=je,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:ie(I.cjs.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Oe.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=_.isJsonRpcError(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(Oe.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(Oe.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=_.E(t,this.name)}get context(){return _.y(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:_.formatJsonRpcRequest(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}=R("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Oe.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:t}=R("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(Oe.created,e=>{const t=Oe.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(Oe.updated,e=>{const t=Oe.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(Oe.deleted,e=>{const t=Oe.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(Ut.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{I.cjs.toMiliseconds(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(Oe.deleted,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=R("NOT_INITIALIZED",this.name);throw new Error(e)}}}class tv extends Rd{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new Re.eventsExports.EventEmitter,this.name=Gy,this.version=Yy,this.cached=[],this.initialized=!1,this.storagePrefix=je,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(Pe.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(Pe.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=_.E(t,this.name)}get context(){return _.y(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 mf(e);if(typeof e=="number")return vf(e);const{message:t}=R("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(Pe.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:t}=R("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}=R("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return t}checkExpiry(e,t){const{expiry:i}=t;I.cjs.toMiliseconds(i)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(Pe.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(Ut.pulse,()=>this.checkExpirations()),this.events.on(Pe.created,e=>{const t=Pe.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Pe.expired,e=>{const t=Pe.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Pe.deleted,e=>{const t=Pe.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=R("NOT_INITIALIZED",this.name);throw new Error(e)}}}class rv extends Nd{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,this.name=Qy,this.verifyUrlV3=Zy,this.storagePrefix=je,this.version=Gc,this.init=async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&I.cjs.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(!pr()||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=Hc(),u=this.startAbortTimer(I.cjs.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(_.sn(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(_.sn(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.cjs.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||nr;return em.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${nr}`),s=nr),s},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const n=this.startAbortTimer(I.cjs.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=Sg(n,s.publicKey),a={hasExpired:I.cjs.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=_.E(t,this.name),this.abortController=new AbortController,this.isDevEnv=An(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return _.y(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),I.cjs.toMiliseconds(e))}}class iv extends Td{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.context=tm,this.registerDeviceToken=async i=>{const{clientId:n,token:s,notificationType:o,enableEncrypted:a=!1}=i,c=`${rm}/${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=_.E(t,this.context)}}var nv=Object.defineProperty,xo=Object.getOwnPropertySymbols,sv=Object.prototype.hasOwnProperty,ov=Object.prototype.propertyIsEnumerable,Po=(r,e,t)=>e in r?nv(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Xt=(r,e)=>{for(var t in e||(e={}))sv.call(e,t)&&Po(r,t,e[t]);if(xo)for(var t of xo(e))ov.call(e,t)&&Po(r,t,e[t]);return r};class av extends Cd{constructor(e,t,i=!0){super(e,t,i),this.core=e,this.logger=t,this.context=nm,this.storagePrefix=je,this.storageVersion=im,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!An())try{const n={eventId:_s(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:yc(this.core.relayer.protocol,this.core.relayer.version,Zi)}}};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=_s(),u=this.core.projectId||"",h=Date.now(),p=Xt({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 Xt(Xt({},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(Ut.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{I.cjs.fromMiliseconds(Date.now())-I.cjs.fromMiliseconds(n.timestamp)>sm&&(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,Xt(Xt({},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(`${om}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Zi}${s}`,{method:"POST",body:JSON.stringify(n)})},this.getAppDomain=()=>gc().url,this.logger=_.E(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 cv=Object.defineProperty,Ao=Object.getOwnPropertySymbols,lv=Object.prototype.hasOwnProperty,uv=Object.prototype.propertyIsEnumerable,Ro=(r,e,t)=>e in r?cv(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,No=(r,e)=>{for(var t in e||(e={}))lv.call(e,t)&&Ro(r,t,e[t]);if(Ao)for(var t of Ao(e))uv.call(e,t)&&Ro(r,t,e[t]);return r};let hv=class ll extends bd{constructor(e){var t;super(e),this.protocol=Jc,this.version=Gc,this.name=Xi,this.events=new Re.eventsExports.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:Y.link_mode};this.relayer.onLinkMessageEvent(l,{sessionExists:c})},this.projectId=e==null?void 0:e.projectId,this.relayUrl=(e==null?void 0:e.relayUrl)||Qc,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=_.k({level:typeof(e==null?void 0:e.logger)=="string"&&e.logger?e.logger:Ay.logger,name:Xi}),{logger:n,chunkLoggerController:s}=_.A({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=_.E(n,this.name),this.heartbeat=new bn,this.crypto=new C0(this,this.logger,e==null?void 0:e.keychain),this.history=new ev(this,this.logger),this.expirer=new tv(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new _.h(No(No({},Ry),e==null?void 0:e.storageOptions)),this.relayer=new G0({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Z0(this,this.logger),this.verify=new rv(this,this.logger,this.storage),this.echoClient=new iv(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new av(this,this.logger,e==null?void 0:e.telemetryEnabled)}static async init(e){const t=new ll(e);await t.initialize();const i=await t.crypto.getClientId();return await t.storage.setItem(Uy,i),t}get context(){return _.y(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(so,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(so)||[],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 dv=hv;class fv{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class pv{constructor(e){this.client=e}}const ul="wc",hl=2,dl="client",Mn=`${ul}@${hl}:${dl}:`,Ti={name:dl,logger:"error"},To="WALLETCONNECT_DEEPLINK_CHOICE",gv="proposal",yv="Proposal expired",mv="session",At=I.cjs.SEVEN_DAYS,vv="engine",ne={wc_sessionPropose:{req:{ttl:I.cjs.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:I.cjs.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:I.cjs.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:I.cjs.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:I.cjs.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:I.cjs.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:I.cjs.ONE_DAY,prompt:!1,tag:1104},res:{ttl:I.cjs.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:I.cjs.ONE_DAY,prompt:!1,tag:1106},res:{ttl:I.cjs.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:I.cjs.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:I.cjs.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:I.cjs.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:I.cjs.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:I.cjs.ONE_DAY,prompt:!1,tag:1112},res:{ttl:I.cjs.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:I.cjs.ONE_DAY,prompt:!1,tag:1114},res:{ttl:I.cjs.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:I.cjs.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:I.cjs.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:I.cjs.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:I.cjs.FIVE_MINUTES,prompt:!1,tag:1119}}},Ci={min:I.cjs.FIVE_MINUTES,max:I.cjs.SEVEN_DAYS},Be={idle:"IDLE",active:"ACTIVE"},wv="request",_v=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],bv="wc",Ev="auth",Sv="authKeys",Iv="pairingTopics",xv="requests",oi=`${bv}@${1.5}:${Ev}:`,Or=`${oi}:PUB_KEY`;var Pv=Object.defineProperty,Av=Object.defineProperties,Rv=Object.getOwnPropertyDescriptors,Co=Object.getOwnPropertySymbols,Nv=Object.prototype.hasOwnProperty,Tv=Object.prototype.propertyIsEnumerable,Oo=(r,e,t)=>e in r?Pv(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ee=(r,e)=>{for(var t in e||(e={}))Nv.call(e,t)&&Oo(r,t,e[t]);if(Co)for(var t of Co(e))Tv.call(e,t)&&Oo(r,t,e[t]);return r},ke=(r,e)=>Av(r,Rv(e));class Cv extends pv{constructor(e){super(e),this.name=vv,this.events=new Re.ss,this.initialized=!1,this.requestQueue={state:Be.idle,queue:[]},this.sessionRequestQueue={state:Be.idle,queue:[]},this.requestQueueDelay=I.cjs.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(ne)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},I.cjs.toMiliseconds(this.requestQueueDelay)))},this.connect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const i=ke(ee({},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:S}=await this.client.core.pairing.create();l=w,u=S}if(!l){const{message:w}=R("NO_MATCHING_KEY",`connect() pairing topic: ${l}`);throw new Error(w)}const p=await this.client.core.crypto.generateKeyPair(),d=ne.wc_sessionPropose.req.ttl||I.cjs.FIVE_MINUTES,f=ie(d),g=ee({requiredNamespaces:s,optionalNamespaces:o,relays:c??[{protocol:Yc}],proposer:{publicKey:p,metadata:this.client.metadata},expiryTimestamp:f,pairingTopic:l},a&&{sessionProperties:a}),{reject:y,resolve:m,done:v}=pt(d,yv);this.events.once(B("session_connect"),async({error:w,session:S})=>{if(w)y(w);else if(S){S.self.publicKey=p;const x=ke(ee({},S),{pairingTopic:g.pairingTopic,requiredNamespaces:g.requiredNamespaces,optionalNamespaces:g.optionalNamespaces,transportType:Y.relay});await this.client.session.set(S.topic,x),await this.setExpiry(S.topic,S.expiry),l&&await this.client.core.pairing.updateMetadata({topic:l,metadata:S.peer.metadata}),this.cleanupDuplicatePairings(x),m(x)}});const b=await this.sendRequest({topic:l,method:"wc_sessionPropose",params:g,throwOnFailedPublish:!0});return await this.setProposal(b,ee({id:b},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:[$e.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(A){throw o.setError(dt.no_internet_connection),A}try{await this.isValidProposalId(t==null?void 0:t.id)}catch(A){throw this.client.logger.error(`approve() -> proposal.get(${t==null?void 0:t.id}) failed`),o.setError(dt.proposal_not_found),A}try{await this.isValidApprove(t)}catch(A){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(dt.session_approve_namespace_validation_failure),A}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:$e.session_approve_started,properties:{topic:d,trace:[$e.session_approve_started,$e.session_namespaces_validation_success]}}));const v=await this.client.core.crypto.generateKeyPair(),b=f.publicKey,w=await this.client.core.crypto.generateSharedKey(v,b),S=ee(ee({relay:{protocol:c??"irn"},namespaces:l,controller:{publicKey:v,metadata:this.client.metadata},expiry:ie(At)},u&&{sessionProperties:u}),h&&{sessionConfig:h}),x=Y.relay;m.addTrace($e.subscribing_session_topic);try{await this.client.core.relayer.subscribe(w,{transportType:x})}catch(A){throw m.setError(dt.subscribe_session_topic_failure),A}m.addTrace($e.subscribe_session_topic_success);const P=ke(ee({},S),{topic:w,requiredNamespaces:g,optionalNamespaces:y,pairingTopic:d,acknowledged:!1,self:S.controller,peer:{publicKey:f.publicKey,metadata:f.metadata},controller:v,transportType:Y.relay});await this.client.session.set(w,P),m.addTrace($e.store_session);try{m.addTrace($e.publishing_session_settle),await this.sendRequest({topic:w,method:"wc_sessionSettle",params:S,throwOnFailedPublish:!0}).catch(A=>{throw m==null||m.setError(dt.session_settle_publish_failure),A}),m.addTrace($e.session_settle_publish_success),m.addTrace($e.publishing_session_approve),await this.sendResult({id:a,topic:d,result:{relay:{protocol:c??"irn"},responderPublicKey:v},throwOnFailedPublish:!0}).catch(A=>{throw m==null||m.setError(dt.session_approve_publish_failure),A}),m.addTrace($e.session_approve_publish_success)}catch(A){throw this.client.logger.error(A),this.client.session.delete(w,J("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(w),A}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,J("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:d}),await this.setExpiry(w,ie(At)),{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:ne.wc_sessionPropose.reject}),await this.client.proposal.delete(i,J("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}=pt(),c=_.payloadId(),l=_.getBigIntRpcId().toString(),u=this.client.session.get(i).namespaces;return this.events.once(B("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=_.payloadId(),{done:s,resolve:o,reject:a}=pt();return this.events.once(B("session_extend",n),({error:c})=>{c?a(c):o()}),await this.setExpiry(i,ie(At)),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=ne.wc_sessionRequest.req.ttl}=t,a=this.client.session.get(s);(a==null?void 0:a.transportType)===Y.relay&&await this.confirmOnlineStateOrThrow();const c=_.payloadId(),l=_.getBigIntRpcId().toString(),{done:u,resolve:h,reject:p}=pt(o,"Request expired. Please try again.");this.events.once(B("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:ke(ee({},n),{expiryTimestamp:ie(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:ke(ee({},n),{expiryTimestamp:ie(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 Sf(this.client.core.storage,To);await _f({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===Y.relay&&await this.confirmOnlineStateOrThrow();const a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);_.isJsonRpcResult(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:a}):_.isJsonRpcError(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=_.payloadId(),s=_.getBigIntRpcId().toString(),{done:o,resolve:a,reject:c}=pt();this.events.once(B("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=_.getBigIntRpcId().toString(),a=_.payloadId();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:J("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}=R("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}},this.find=t=>(this.isInitialized(),this.client.session.getAll().filter(i=>kg(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?Y.link_mode:Y.relay;o===Y.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:b}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:v,uri:b}});const w=await this.client.core.crypto.generateKeyPair(),S=Cr(w);if(await Promise.all([this.client.auth.authKeys.set(Or,{responseTopic:S,publicKey:w}),this.client.auth.pairingTopics.set(S,{topic:S,pairingTopic:v})]),await this.client.core.relayer.subscribe(S,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${v}`),g.length>0){const{namespace:L}=Nr(a[0]);let N=fp(L,"request",g);Tr(m)&&(N=gp(N,m.pop())),m.push(N)}const x=y&&y>ne.wc_sessionAuthenticate.req.ttl?y:ne.wc_sessionAuthenticate.req.ttl,P={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:ie(x)},A={eip155:{chains:a,methods:[...new Set(["personal_sign",...g])],events:["chainChanged","accountsChanged"]}},C={requiredNamespaces:{},optionalNamespaces:A,relays:[{protocol:"irn"}],pairingTopic:v,proposer:{publicKey:w,metadata:this.client.metadata},expiryTimestamp:ie(ne.wc_sessionPropose.req.ttl)},{done:O,resolve:$,reject:D}=pt(x,"Request expired"),k=async({error:L,session:N})=>{if(this.events.off(B("session_request",F),q),L)D(L);else if(N){N.self.publicKey=w,await this.client.session.set(N.topic,N),await this.setExpiry(N.topic,N.expiry),v&&await this.client.core.pairing.updateMetadata({topic:v,metadata:N.peer.metadata});const K=this.client.session.get(N.topic);await this.deleteProposal(U),$({session:K})}},q=async L=>{var N,K,G;if(await this.deletePendingAuthRequest(F,{message:"fulfilled",code:0}),L.error){const Ie=J("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return L.error.code===Ie.code?void 0:(this.events.off(B("session_connect"),k),D(L.error.message))}await this.deleteProposal(U),this.events.off(B("session_connect"),k);const{cacaos:H,responder:re}=L.result,ye=[],Ee=[];for(const Ie of H){await Rs({cacao:Ie,projectId:this.client.core.projectId})||(this.client.logger.error(Ie,"Signature verification failed"),D(J("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:Fe}=Ie,li=Tr(Fe.resources),Ln=[Vi(Fe.iss)],fl=Ur(Fe.iss);if(li){const ui=Ns(li),pl=Ts(li);ye.push(...ui),Ln.push(...pl)}for(const ui of Ln)Ee.push(`${ui}:${fl}`)}const Se=await this.client.core.crypto.generateSharedKey(w,re.publicKey);let Ce;ye.length>0&&(Ce={topic:Se,acknowledged:!0,self:{publicKey:w,metadata:this.client.metadata},peer:re,controller:re.publicKey,expiry:ie(At),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:v,namespaces:Gs([...new Set(ye)],[...new Set(Ee)]),transportType:o},await this.client.core.relayer.subscribe(Se,{transportType:o}),await this.client.session.set(Se,Ce),v&&await this.client.core.pairing.updateMetadata({topic:v,metadata:re.metadata}),Ce=this.client.session.get(Se)),(N=this.client.metadata.redirect)!=null&&N.linkMode&&(K=re.metadata.redirect)!=null&&K.linkMode&&(G=re.metadata.redirect)!=null&&G.universal&&i&&(this.client.core.addLinkModeSupportedApp(re.metadata.redirect.universal),this.client.session.update(Se,{transportType:Y.link_mode})),$({auths:H,session:Ce})},F=_.payloadId(),U=_.payloadId();this.events.once(B("session_connect"),k),this.events.once(B("session_request",F),q);let z;try{if(s){const L=_.formatJsonRpcRequest("wc_sessionAuthenticate",P,F);this.client.core.history.set(v,L);const N=await this.client.core.crypto.encode("",L,{type:vr,encoding:Ht});z=xr(i,v,N)}else await Promise.all([this.sendRequest({topic:v,method:"wc_sessionAuthenticate",params:P,expiry:t.expiry,throwOnFailedPublish:!0,clientRpcId:F}),this.sendRequest({topic:v,method:"wc_sessionPropose",params:C,expiry:ne.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:U})])}catch(L){throw this.events.off(B("session_connect"),k),this.events.off(B("session_request",F),q),L}return await this.setProposal(U,ee({id:U},C)),await this.setAuthRequest(F,{request:ke(ee({},P),{verifyContext:{}}),pairingTopic:v,transportType:o}),{uri:z??b,response:O}},this.approveSessionAuthenticate=async t=>{const{id:i,auths:n}=t,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[ft.authenticated_session_approve_started]}});try{this.isInitialized()}catch(y){throw s.setError(Yt.no_internet_connection),y}const o=this.getPendingAuthRequest(i);if(!o)throw s.setError(Yt.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);const a=o.transportType||Y.relay;a===Y.relay&&await this.confirmOnlineStateOrThrow();const c=o.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),u=Cr(c),h={type:Ge,receiverPublicKey:c,senderPublicKey:l},p=[],d=[];for(const y of n){if(!await Rs({cacao:y,projectId:this.client.core.projectId})){s.setError(Yt.invalid_cacao);const S=J("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:u,error:S,encodeOpts:h}),new Error(S.message)}s.addTrace(ft.cacaos_verified);const{p:m}=y,v=Tr(m.resources),b=[Vi(m.iss)],w=Ur(m.iss);if(v){const S=Ns(v),x=Ts(v);p.push(...S),b.push(...x)}for(const S of b)d.push(`${S}:${w}`)}const f=await this.client.core.crypto.generateSharedKey(l,c);s.addTrace(ft.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:ie(At),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:Gs([...new Set(p)],[...new Set(d)]),transportType:a},s.addTrace(ft.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(f,{transportType:a})}catch(y){throw s.setError(Yt.subscribe_authenticated_session_topic_failure),y}s.addTrace(ft.subscribe_authenticated_session_topic_success),await this.client.session.set(f,g),s.addTrace(ft.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(ft.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(Yt.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===Y.relay&&await this.confirmOnlineStateOrThrow();const o=s.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),c=Cr(o),l={type:Ge,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:i,topic:c,error:n,encodeOpts:l,rpcOpts:ne.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,J("USER_DISCONNECTED"))},this.formatAuthMessage=t=>{this.isInitialized();const{request:i,iss:n}=t;return Nc(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,J("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(To).catch(l=>this.client.logger.warn(l)),this.getPendingSessionRequests().forEach(l=>{l.topic===n&&this.deletePendingSessionRequest(l.id,J("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=Be.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(dt.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(t,J("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=Be.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,ie(ne.wc_sessionPropose.req.ttl)),await this.client.proposal.set(t,i)},this.setAuthRequest=async(t,i)=>{const{request:n,pairingTopic:s,transportType:o=Y.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||ie(ne.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=_.formatJsonRpcRequest(n,s,c);let p;const d=!!u;try{const y=d?Ht:nt;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(_v.includes(n)){const y=We(JSON.stringify(h)),m=We(p);f=await this.client.core.verify.register({id:m,decryptedId:y})}const g=ne[n].req;if(g.attestation=f,o&&(g.ttl=o),a&&(g.id=a),this.client.core.history.set(i,h),d){const y=xr(u,i,p);await E.dist.global.Linking.openURL(y,this.client.name)}else{const y=ne[n].req;o&&(y.ttl=o),a&&(y.id=a),l?(y.internal=ke(ee({},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=_.formatJsonRpcResult(i,s);let u;const h=c&&typeof(E.dist.global==null?void 0:E.dist.global.Linking)<"u";try{const d=h?Ht:nt;u=await this.client.core.crypto.encode(n,l,ke(ee({},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=xr(c,n,u);await E.dist.global.Linking.openURL(d,this.client.name)}else{const d=ne[p.request.method].res;o?(d.internal=ke(ee({},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=_.formatJsonRpcError(i,s);let u;const h=c&&typeof(E.dist.global==null?void 0:E.dist.global.Linking)<"u";try{const d=h?Ht:nt;u=await this.client.core.crypto.encode(n,l,ke(ee({},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=xr(c,n,u);await E.dist.global.Linking.openURL(d,this.client.name)}else{const d=a||ne[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;et(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=>{et(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===Be.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=Be.active;const t=this.requestQueue.queue.shift();if(t)try{await this.processRequest(t)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=Be.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}=R("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(Ve.proposal_listener_not_found)),this.isValidConnect(ee({},n.params));const u=a.expiryTimestamp||ie(ne.wc_sessionPropose.req.ttl),h=ee({id:c,pairingTopic:i,expiryTimestamp:u},a);await this.setProposal(c,h);const p=await this.getVerifyContext({attestationId:s,hash:We(JSON.stringify(n)),encryptedId:o,metadata:h.proposer.metadata});l==null||l.addTrace(Ue.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:ne.wc_sessionPropose.autoReject}),this.client.logger.error(l)}},this.onSessionProposeResponse=async(t,i,n)=>{const{id:s}=i;if(_.isJsonRpcResult(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(_.isJsonRpcError(i)){await this.client.proposal.delete(s,J("USER_DISCONNECTED"));const o=B("session_connect");if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(B("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=ke(ee(ee({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:Y.relay}),d=B("session_connect");if(this.events.listenerCount(d)===0)throw new Error(`emitting ${d} without any listeners 997`);this.events.emit(B("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;_.isJsonRpcResult(i)?(await this.client.session.update(t,{acknowledged:!0}),this.events.emit(B("session_approve",n),{})):_.isJsonRpcError(i)&&(await this.client.session.delete(t,J("USER_DISCONNECTED")),this.events.emit(B("session_approve",n),{error:i.error}))},this.onSessionUpdateRequest=async(t,i)=>{const{params:n,id:s}=i;try{const o=`${t}_session_update`,a=Jt.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:J("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(ee({topic:t},n));try{Jt.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 Jt.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=B("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);_.isJsonRpcResult(i)?this.events.emit(B("session_update",n),{}):_.isJsonRpcError(i)&&this.events.emit(B("session_update",n),{error:i.error})},this.onSessionExtendRequest=async(t,i)=>{const{id:n}=i;try{this.isValidExtend({topic:t}),await this.setExpiry(t,ie(At)),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=B("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);_.isJsonRpcResult(i)?this.events.emit(B("session_extend",n),{}):_.isJsonRpcError(i)&&this.events.emit(B("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=B("session_ping",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{_.isJsonRpcResult(i)?this.events.emit(B("session_ping",n),{}):_.isJsonRpcError(i)&&this.events.emit(B("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(se.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:J("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(ee({topic:o},p));const d=this.client.session.get(o),f=await this.getVerifyContext({attestationId:c,hash:We(JSON.stringify(_.formatJsonRpcRequest("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===Y.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=B("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);_.isJsonRpcResult(i)?this.events.emit(B("session_request",n),{result:i.result}):_.isJsonRpcError(i)&&this.events.emit(B("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=Jt.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(ee({topic:t},s)),this.client.events.emit("session_event",{id:n,topic:t,params:s}),Jt.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}),_.isJsonRpcResult(i)?this.events.emit(B("session_request",n),{result:i.result}):_.isJsonRpcError(i)&&this.events.emit(B("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:We(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===Y.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:Ge,receiverPublicKey:u,senderPublicKey:h};await this.sendError({id:s.id,topic:n,error:l,encodeOpts:d,rpcOpts:ne.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=Be.idle,this.processSessionRequestQueue()},I.cjs.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=B("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(B("session_request",s.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===Be.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=Be.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:_.formatJsonRpcRequest("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})},this.isValidConnect=async t=>{if(!pe(t)){const{message:c}=R("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(fe(i)||await this.isValidPairingTopic(i),!Wg(a)){const{message:c}=R("MISSING_OR_INVALID",`connect() relays: ${a}`);throw new Error(c)}!fe(n)&&zr(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!fe(s)&&zr(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),fe(o)||this.validateSessionProps(o,"sessionProperties")},this.validateNamespaces=(t,i)=>{const n=Vg(t,"connect()",i);if(n)throw new Error(n.message)},this.isValidApprove=async t=>{if(!pe(t))throw new Error(R("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=Pi(n,"approve()");if(c)throw new Error(c.message);const l=Xs(a.requiredNamespaces,n,"approve()");if(l)throw new Error(l.message);if(!te(s,!0)){const{message:u}=R("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(u)}fe(o)||this.validateSessionProps(o,"sessionProperties")},this.isValidReject=async t=>{if(!pe(t)){const{message:s}=R("MISSING_OR_INVALID",`reject() params: ${t}`);throw new Error(s)}const{id:i,reason:n}=t;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!Jg(n)){const{message:s}=R("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidSessionSettleRequest=t=>{if(!pe(t)){const{message:l}=R("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${t}`);throw new Error(l)}const{relay:i,controller:n,namespaces:s,expiry:o}=t;if(!Wc(i)){const{message:l}=R("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(l)}const a=qg(n,"onSessionSettleRequest()");if(a)throw new Error(a.message);const c=Pi(s,"onSessionSettleRequest()");if(c)throw new Error(c.message);if(et(o)){const{message:l}=R("EXPIRED","onSessionSettleRequest()");throw new Error(l)}},this.isValidUpdate=async t=>{if(!pe(t)){const{message:c}=R("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=Pi(n,"update()");if(o)throw new Error(o.message);const a=Xs(s.requiredNamespaces,n,"update()");if(a)throw new Error(a.message)},this.isValidExtend=async t=>{if(!pe(t)){const{message:n}=R("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(!pe(t)){const{message:c}=R("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(!Qs(a,s)){const{message:c}=R("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(c)}if(!Gg(n)){const{message:c}=R("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(c)}if(!Xg(a,s,n.method)){const{message:c}=R("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(c)}if(o&&!ry(o,Ci)){const{message:c}=R("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${Ci.min} and ${Ci.max}`);throw new Error(c)}},this.isValidRespond=async t=>{var i;if(!pe(t)){const{message:o}=R("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(!Yg(s)){const{message:o}=R("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}},this.isValidPing=async t=>{if(!pe(t)){const{message:n}=R("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(n)}const{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async t=>{if(!pe(t)){const{message:a}=R("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(!Qs(o,s)){const{message:a}=R("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(a)}if(!Qg(n)){const{message:a}=R("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}if(!Zg(o,s,n.name)){const{message:a}=R("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}},this.isValidDisconnect=async t=>{if(!pe(t)){const{message:n}=R("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(!te(n,!1))throw new Error("uri is required parameter");if(!te(s,!1))throw new Error("domain is required parameter");if(!te(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(c=>Nr(c).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=Nr(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||nr,validation:"UNKNOWN",origin:o.url||""}};try{if(a===Y.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(!te(n,!1)){const{message:s}=R("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}=R("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!==Y.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(E.dist.global==null?void 0:E.dist.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=ws(t,"topic")||"",n=decodeURIComponent(ws(t,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:Y.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})},this.registerLinkModeListeners=async()=>{var t;if(An()||ht()&&(t=this.client.metadata.redirect)!=null&&t.linkMode){const i=E.dist.global==null?void 0:E.dist.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}=R("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(se.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(Or)?this.client.auth.authKeys.get(Or):{publicKey:void 0},a=await this.client.core.crypto.decode(t,i,{receiverPublicKey:o,encoding:s===Y.link_mode?Ht:nt});try{_.isJsonRpcRequest(a)?(this.client.core.history.set(t,a),this.onRelayEventRequest({topic:t,payload:a,attestation:n,transportType:s,encryptedId:We(i)})):_.isJsonRpcResponse(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(Pe.expired,async e=>{const{topic:t,id:i}=_c(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,R("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,R("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(gt.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(gt.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!te(e,!1)){const{message:t}=R("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}=R("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(et(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=R("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!te(e,!1)){const{message:t}=R("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}=R("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(et(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:t}=R("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){const{message:t}=R("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(te(e,!1)){const{message:t}=R("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}else{const{message:t}=R("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}async isValidProposalId(e){if(!Hg(e)){const{message:t}=R("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=R("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(et(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:t}=R("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class Ov extends It{constructor(e,t){super(e,t,gv,Mn),this.core=e,this.logger=t}}class $v extends It{constructor(e,t){super(e,t,mv,Mn),this.core=e,this.logger=t}}class kv extends It{constructor(e,t){super(e,t,wv,Mn,i=>i.id),this.core=e,this.logger=t}}class Mv extends It{constructor(e,t){super(e,t,Sv,oi,()=>Or),this.core=e,this.logger=t}}class Lv extends It{constructor(e,t){super(e,t,Iv,oi),this.core=e,this.logger=t}}class Dv extends It{constructor(e,t){super(e,t,xv,oi,i=>i.id),this.core=e,this.logger=t}}class Fv{constructor(e,t){this.core=e,this.logger=t,this.authKeys=new Mv(this.core,this.logger),this.pairingTopics=new Lv(this.core,this.logger),this.requests=new Dv(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}class ai extends fv{constructor(e){super(e),this.protocol=ul,this.version=hl,this.name=Ti.name,this.events=new Re.eventsExports.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)||Ti.name,this.metadata=(e==null?void 0:e.metadata)||gc(),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:_.Tt(_.k({level:(e==null?void 0:e.logger)||Ti.logger}));this.core=(e==null?void 0:e.core)||new dv(e),this.logger=_.E(t,this.name),this.session=new $v(this.core,this.logger),this.proposal=new Ov(this.core,this.logger),this.pendingRequest=new kv(this.core,this.logger),this.engine=new Cv(this),this.auth=new Fv(this.core,this.logger)}static async init(e){const t=new ai(e);return await t.initialize(),t}get context(){return _.y(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.cjs.toMiliseconds(I.cjs.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}function qv(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,b=new Uint8Array(v);y!==m;){for(var w=d[y],S=0,x=v-1;(w!==0||S<g)&&x!==-1;x--,S++)w+=256*b[x]>>>0,b[x]=w%o>>>0,w=w/o>>>0;if(w!==0)throw new Error("Non-zero carry");g=S,y++}for(var P=v-g;P!==v&&b[P]===0;)P++;for(var A=a.repeat(f);P<v;++P)A+=r.charAt(b[P]);return A}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 b=e[d.charCodeAt(f)];if(b===255)return;for(var w=0,S=m-1;(b!==0||w<y)&&S!==-1;S--,w++)b+=o*v[S]>>>0,v[S]=b%256>>>0,b=b/256>>>0;if(b!==0)throw new Error("Non-zero carry");y=w,f++}for(var x=m-y;x!==m&&v[x]===0;)x++;for(var P=new Uint8Array(g+(m-x)),A=g;x!==m;)P[A++]=v[x++];return P}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 Bv=qv;const Uv=Bv,jv="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var zv=Uv(jv);const Oi=E.getDefaultExportFromCjs(zv);class tt extends Error{constructor(){super(),Object.setPrototypeOf(this,tt.prototype)}}class ci extends Error{constructor(){super(),Object.setPrototypeOf(this,ci.prototype)}}exports.WalletConnectChainID=void 0;(function(r){r.Mainnet="solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",r.Devnet="solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"})(exports.WalletConnectChainID||(exports.WalletConnectChainID={}));exports.WalletConnectRPCMethods=void 0;(function(r){r.signTransaction="solana_signTransaction",r.signMessage="solana_signMessage"})(exports.WalletConnectRPCMethods||(exports.WalletConnectRPCMethods={}));const $o=r=>({requiredNamespaces:{solana:{chains:[r],methods:[exports.WalletConnectRPCMethods.signTransaction,exports.WalletConnectRPCMethods.signMessage],events:[]}}}),Kv=r=>"version"in r;class Vv{constructor(e){this._options=e.options,this._network=e.network}async connect(){const e=this._client??await ai.init(this._options),t=e.find($o(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($o(this._network));return new Promise((s,o)=>{i&&ds.open(i,()=>{o(new ci)}),n().then(a=>{this._session=a,this._client=e,s({publicKey:this.publicKey})}).catch(o).finally(()=>{ds.close()})})}}async disconnect(){if(this._client&&this._session)await this._client.disconnect({topic:this._session.topic,reason:J("USER_DISCONNECTED")}),this._session=void 0;else throw new tt}get client(){if(this._client)return Object.assign({},this._client,{off:this._client.removeListener});throw new tt}get publicKey(){if(this._client&&this._session){const{address:e}=cf(this._session.namespaces.solana.accounts[0]);return new E.PublicKey(e)}else throw new tt}async signTransaction(e){if(this._client&&this._session){let t,i;Kv(e)?(t=E.dist.Buffer.from(e.serialize()).toString("base64"),e.version==="legacy"&&(i=E.Transaction.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:exports.WalletConnectRPCMethods.signTransaction,params:{...i,transaction:t}}});return e.addSignature(this.publicKey,E.dist.Buffer.from(Oi.decode(n))),e}else throw new tt}async signMessage(e){if(this._client&&this._session){const{signature:t}=await this._client.request({chainId:this._network,topic:this._session.topic,request:{method:exports.WalletConnectRPCMethods.signMessage,params:{pubkey:this.publicKey.toString(),message:Oi.encode(e)}}});return Oi.decode(t)}else throw new tt}}exports.ClientNotInitializedError=tt;exports.QRCodeModalError=ci;exports.WalletConnectClient=ai;exports.WalletConnectWallet=Vv;
|