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