@dev.sail.money/sailor 0.0.2-19 → 0.0.2-20

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 (172) hide show
  1. package/package.json +1 -1
  2. package/packages/cli/dist/index.cjs +14 -14
  3. package/packages/cli/dist/server.cjs +139 -948
  4. package/packages/sdk/dist/intelligence.d.ts +1 -1
  5. package/packages/sdk/dist/intelligence.js +1 -1
  6. package/packages/ui/dist/assets/Arc-VDBY7LNS-BChRXCXW.js +1 -0
  7. package/packages/ui/dist/assets/Brave-BRAKJXDS-mq-Xo37j.js +1 -0
  8. package/packages/ui/dist/assets/Browser-76IHF3Y2-BMhRaC5Z.js +1 -0
  9. package/packages/ui/dist/assets/Chrome-65Q5P54Y-DR9MQEVr.js +1 -0
  10. package/packages/ui/dist/assets/Edge-XSPUTORV-DEoZslQE.js +1 -0
  11. package/packages/ui/dist/assets/Firefox-AAHGJQIP-Bp_Hm04m.js +1 -0
  12. package/packages/ui/dist/assets/Linux-OO4TNCLJ-B0aw93n9.js +1 -0
  13. package/packages/ui/dist/assets/Macos-MW4AE7LN-Vvm8Drw3.js +1 -0
  14. package/packages/ui/dist/assets/Opera-KQZLSACL-Cwv5MDFy.js +1 -0
  15. package/packages/ui/dist/assets/Safari-ZPL37GXR-C4Ggg6rz.js +1 -0
  16. package/packages/ui/dist/assets/Windows-PPTHQER6-BlyV2p7Y.js +1 -0
  17. package/packages/ui/dist/assets/add-BrylwREe.js +15 -0
  18. package/packages/ui/dist/assets/all-wallets-DGR35dSU.js +6 -0
  19. package/packages/ui/dist/assets/apechain-SX5YFU6N-q5qBv-mp.js +1 -0
  20. package/packages/ui/dist/assets/app-store-BpM1x6bI.js +17 -0
  21. package/packages/ui/dist/assets/apple-xvs7JX23.js +18 -0
  22. package/packages/ui/dist/assets/ar_AR-LIPSOZP5-BQrIDibT.js +1519 -0
  23. package/packages/ui/dist/assets/arbitrum-WURIBY6W-CqVkHBr5.js +1 -0
  24. package/packages/ui/dist/assets/arrow-bottom-CF6xPQbH.js +8 -0
  25. package/packages/ui/dist/assets/arrow-bottom-circle-r0A6jlRF.js +11 -0
  26. package/packages/ui/dist/assets/arrow-left-Ce6MJKC0.js +8 -0
  27. package/packages/ui/dist/assets/arrow-right-CiCNIsI0.js +8 -0
  28. package/packages/ui/dist/assets/arrow-top-TI5RQSIc.js +8 -0
  29. package/packages/ui/dist/assets/assets-Q6ZU7ZJ5-P8HioiAD.js +1 -0
  30. package/packages/ui/dist/assets/avalanche-KOMJD3XY-Dsn_JPR4.js +1 -0
  31. package/packages/ui/dist/assets/bank-CmrK2TRa.js +14 -0
  32. package/packages/ui/dist/assets/base-OAXLRA4F-CoYTVIiL.js +1 -0
  33. package/packages/ui/dist/assets/base-QS6CYWIN-CsjdbWCf.js +1 -0
  34. package/packages/ui/dist/assets/basic-BhoXad_6.js +2128 -0
  35. package/packages/ui/dist/assets/berachain-NJECWIVC-DumxnFvf.js +1 -0
  36. package/packages/ui/dist/assets/blast-V555OVXZ-BbhJh1tj.js +1 -0
  37. package/packages/ui/dist/assets/browser-BWCT-XSy.js +14 -0
  38. package/packages/ui/dist/assets/bsc-N647EYR2-B2nLKXWV.js +1 -0
  39. package/packages/ui/dist/assets/card-v1fl0QNj.js +14 -0
  40. package/packages/ui/dist/assets/ccip-BkGqsEgG.js +1 -0
  41. package/packages/ui/dist/assets/celo-GEP4TUHG-CenIBYLU.js +1 -0
  42. package/packages/ui/dist/assets/checkmark-CiQnNFee.js +11 -0
  43. package/packages/ui/dist/assets/checkmark-bold-B63f9SW6.js +8 -0
  44. package/packages/ui/dist/assets/chevron-bottom-DpBpDiYb.js +8 -0
  45. package/packages/ui/dist/assets/chevron-left-o_G-ctyg.js +8 -0
  46. package/packages/ui/dist/assets/chevron-right-I9LAJ9De.js +8 -0
  47. package/packages/ui/dist/assets/chevron-top-JRwGHMKH.js +8 -0
  48. package/packages/ui/dist/assets/chrome-store-Cw9skzSt.js +61 -0
  49. package/packages/ui/dist/assets/clock-BK_Lu0EB.js +8 -0
  50. package/packages/ui/dist/assets/close-DWFjOyu7.js +8 -0
  51. package/packages/ui/dist/assets/coinPlaceholder-gi3wDlPb.js +8 -0
  52. package/packages/ui/dist/assets/compass-Dlpsn_k-.js +8 -0
  53. package/packages/ui/dist/assets/connect-UA7M4XW6-IY3X6Bmr.js +1 -0
  54. package/packages/ui/dist/assets/copy-BzNKdXeG.js +15 -0
  55. package/packages/ui/dist/assets/core-BN9UnMip.js +907 -0
  56. package/packages/ui/dist/assets/create-FASO7PVG-D_rvSpre.js +1 -0
  57. package/packages/ui/dist/assets/cronos-HJPAQTAE-BEOvlOC4.js +1 -0
  58. package/packages/ui/dist/assets/cursor-BWdjWDLC.js +3 -0
  59. package/packages/ui/dist/assets/cursor-transparent-B3RZ6Udt.js +12 -0
  60. package/packages/ui/dist/assets/de_DE-YE3KOFHU-BRt5ztUe.js +1519 -0
  61. package/packages/ui/dist/assets/degen-FQQ4XGHB-CeHTs88l.js +1 -0
  62. package/packages/ui/dist/assets/desktop-rngwE1T9.js +9 -0
  63. package/packages/ui/dist/assets/disconnect-_DzDsvsZ.js +8 -0
  64. package/packages/ui/dist/assets/discord-B9qQB66m.js +17 -0
  65. package/packages/ui/dist/assets/es_419-7LMPU7G4-DH7rM0yQ.js +1519 -0
  66. package/packages/ui/dist/assets/ethereum-RGGVA4PY-SWGOlkuk.js +1 -0
  67. package/packages/ui/dist/assets/etherscan-D7hlQ8Z3.js +6 -0
  68. package/packages/ui/dist/assets/events-DrkgavVp.js +1 -0
  69. package/packages/ui/dist/assets/exclamation-triangle-iCvLVoM-.js +4 -0
  70. package/packages/ui/dist/assets/extension-CjGcOeuB.js +8 -0
  71. package/packages/ui/dist/assets/external-link-DTkyjOr4.js +8 -0
  72. package/packages/ui/dist/assets/facebook-DoO2uCiE.js +26 -0
  73. package/packages/ui/dist/assets/fallback-Y8-BiCNG.js +1 -0
  74. package/packages/ui/dist/assets/farcaster-Dyz6wiZi.js +12 -0
  75. package/packages/ui/dist/assets/filters-Bd5PxMiz.js +8 -0
  76. package/packages/ui/dist/assets/flow-5FQJFCTK-CUie2reO.js +1 -0
  77. package/packages/ui/dist/assets/fr_FR-VBJP3ZLL-B-_ocunw.js +1519 -0
  78. package/packages/ui/dist/assets/github-CmqSJCq6.js +18 -0
  79. package/packages/ui/dist/assets/gnosis-37ZC4RBL-B137OtHZ.js +1 -0
  80. package/packages/ui/dist/assets/google-i_MKKqQP.js +18 -0
  81. package/packages/ui/dist/assets/gravity-J5YQHTYH-Bj6B0uod.js +1 -0
  82. package/packages/ui/dist/assets/hardhat-TX56IT5N-CV1FY-wE.js +1 -0
  83. package/packages/ui/dist/assets/help-circle-_ER8-V35.js +12 -0
  84. package/packages/ui/dist/assets/hi_IN-WBVD5XYI-D73g2UFs.js +1519 -0
  85. package/packages/ui/dist/assets/hyperevm-VKPAA4SA-CHwraEsx.js +1 -0
  86. package/packages/ui/dist/assets/id-D2adRwvh.js +12 -0
  87. package/packages/ui/dist/assets/id_ID-SBYANJ7G-Cjpa4ay6.js +1519 -0
  88. package/packages/ui/dist/assets/image-q_rpi7cn.js +4 -0
  89. package/packages/ui/dist/assets/index-B6Wb3mjQ.js +1 -0
  90. package/packages/ui/dist/assets/index-BLD08Nrb.js +1 -0
  91. package/packages/ui/dist/assets/index-Bdl623mb.js +395 -0
  92. package/packages/ui/dist/assets/index-BwoSt5mL.js +1 -0
  93. package/packages/ui/dist/assets/index-CzevBC-K.js +16 -0
  94. package/packages/ui/dist/assets/index-DDKDa0s2.css +1 -0
  95. package/packages/ui/dist/assets/index-DJQDBPts.js +1775 -0
  96. package/packages/ui/dist/assets/index.es-D6UPoR2j.js +26 -0
  97. package/packages/ui/dist/assets/info-Ck7GYYmo.js +3 -0
  98. package/packages/ui/dist/assets/info-circle-DtA5FQXd.js +12 -0
  99. package/packages/ui/dist/assets/ink-FZMYZWHG-62p-5IK5.js +1 -0
  100. package/packages/ui/dist/assets/ja_JP-ZRMWJV3I-DXbifiMm.js +1519 -0
  101. package/packages/ui/dist/assets/kaia-65D2U3PU-JmuLQ4gC.js +1 -0
  102. package/packages/ui/dist/assets/ko_KR-FR54RFUG-upinSHjQ.js +1519 -0
  103. package/packages/ui/dist/assets/lightbulb-DR3jyzkK.js +3 -0
  104. package/packages/ui/dist/assets/linea-QRMVQ5DY-DuI3vv0d.js +1 -0
  105. package/packages/ui/dist/assets/login-UP3DZBGS-Db_wM5oQ.js +1 -0
  106. package/packages/ui/dist/assets/mail-BK_pW_tL.js +8 -0
  107. package/packages/ui/dist/assets/manta-SI27YFEJ-CpVOKa06.js +1 -0
  108. package/packages/ui/dist/assets/mantle-CKIUT334-DR2WgqzU.js +1 -0
  109. package/packages/ui/dist/assets/metaMaskWallet-EI6MED72-D5HFOsnz.js +1 -0
  110. package/packages/ui/dist/assets/metamask-sdk-IZbe4GJ_.js +542 -0
  111. package/packages/ui/dist/assets/mobile-CLG-4Yut.js +9 -0
  112. package/packages/ui/dist/assets/monad-4KWC6TSS-DVXSkpiz.js +1 -0
  113. package/packages/ui/dist/assets/more-BBqkkVbe.js +11 -0
  114. package/packages/ui/dist/assets/ms_MY-EZSGYYYQ-4cPLK-3L.js +1519 -0
  115. package/packages/ui/dist/assets/native-CJ5et6AR.js +1 -0
  116. package/packages/ui/dist/assets/network-placeholder-kf7EWfmj.js +14 -0
  117. package/packages/ui/dist/assets/nftPlaceholder-BEFwtFPl.js +8 -0
  118. package/packages/ui/dist/assets/off-DKjJt-l0.js +8 -0
  119. package/packages/ui/dist/assets/optimism-HAF2GUT7-ec6Nqxs9.js +1 -0
  120. package/packages/ui/dist/assets/parseSignature-KWl5TpQf.js +1 -0
  121. package/packages/ui/dist/assets/play-store-DBVkWbwG.js +32 -0
  122. package/packages/ui/dist/assets/plus-BQzagKUL.js +13 -0
  123. package/packages/ui/dist/assets/polygon-WW6ZI7PM-DXlmm4L1.js +1 -0
  124. package/packages/ui/dist/assets/pt_BR-JQFQ3P4L-DOHfdcA2.js +1519 -0
  125. package/packages/ui/dist/assets/qr-code-DVwEgFEM.js +6 -0
  126. package/packages/ui/dist/assets/rainbowWallet-O26YNBMX-DUhYus-9.js +1 -0
  127. package/packages/ui/dist/assets/recycle-horizontal-D2E6B1Kh.js +9 -0
  128. package/packages/ui/dist/assets/refresh-CUavEsqn.js +8 -0
  129. package/packages/ui/dist/assets/refresh-S4T5V5GX-CwqIaaxK.js +1 -0
  130. package/packages/ui/dist/assets/reown-logo-mAAAaf4E.js +12 -0
  131. package/packages/ui/dist/assets/ronin-EMCPYXZT-N-QBHZdV.js +1 -0
  132. package/packages/ui/dist/assets/ru_RU-Z42UEJBP-Cvb2oWxQ.js +1519 -0
  133. package/packages/ui/dist/assets/safeWallet-5MNKTR5Z-D-5imDLD.js +1 -0
  134. package/packages/ui/dist/assets/sanko-RHQYXGM5-OX010CbN.js +1 -0
  135. package/packages/ui/dist/assets/scan-4UYSQ56Q-CjMz6-XC.js +1 -0
  136. package/packages/ui/dist/assets/scroll-5OBGQVOV-DJFECiai.js +1 -0
  137. package/packages/ui/dist/assets/search-BAnb6iT_.js +8 -0
  138. package/packages/ui/dist/assets/secp256k1-CBUZgsE-.js +1 -0
  139. package/packages/ui/dist/assets/send-BYjfitxS.js +15 -0
  140. package/packages/ui/dist/assets/sign-A7IJEUT5-CGsRnPrd.js +1 -0
  141. package/packages/ui/dist/assets/superposition-HG6MMR2Y-bRkgatRO.js +1 -0
  142. package/packages/ui/dist/assets/swapHorizontal-C-4qjxwd.js +8 -0
  143. package/packages/ui/dist/assets/swapHorizontalBold-zA-cWlfT.js +8 -0
  144. package/packages/ui/dist/assets/swapHorizontalMedium-gIIVXh3I.js +16 -0
  145. package/packages/ui/dist/assets/swapHorizontalRoundedBold-CwtQpc9E.js +8 -0
  146. package/packages/ui/dist/assets/swapVertical-wrdYsAkk.js +8 -0
  147. package/packages/ui/dist/assets/telegram-3aqbBSMX.js +16 -0
  148. package/packages/ui/dist/assets/th_TH-4YB4VSB2-BUipNP-V.js +1519 -0
  149. package/packages/ui/dist/assets/three-dots-BNRpZX3L.js +5 -0
  150. package/packages/ui/dist/assets/tr_TR-5FKHPPIO-D5jTpIm9.js +1519 -0
  151. package/packages/ui/dist/assets/twitch-Bya9c1W1.js +18 -0
  152. package/packages/ui/dist/assets/twitterIcon-1thOj_Z5.js +6 -0
  153. package/packages/ui/dist/assets/uk_UA-ZD4IBC52-DgnQrpzl.js +1519 -0
  154. package/packages/ui/dist/assets/unichain-C5BWO2ZY-BfguYsnu.js +1 -0
  155. package/packages/ui/dist/assets/verify-D8ggGSfI.js +8 -0
  156. package/packages/ui/dist/assets/verify-filled-CeZM7920.js +8 -0
  157. package/packages/ui/dist/assets/vi_VN-5EVRZKLY-x078672g.js +1519 -0
  158. package/packages/ui/dist/assets/w3m-modal-CUwD6iiA.js +642 -0
  159. package/packages/ui/dist/assets/wallet-Baz0DeMJ.js +8 -0
  160. package/packages/ui/dist/assets/wallet-placeholder-3yAnyuC4.js +14 -0
  161. package/packages/ui/dist/assets/walletConnectWallet-YHWKVTDY-D3lyiczV.js +1 -0
  162. package/packages/ui/dist/assets/walletconnect-CfkgbqAq.js +30 -0
  163. package/packages/ui/dist/assets/warning-circle-BfOqu3HN.js +12 -0
  164. package/packages/ui/dist/assets/x-CxAcJv-O.js +12 -0
  165. package/packages/ui/dist/assets/xdc-KJ3TDBYO-DNV6zchh.js +1 -0
  166. package/packages/ui/dist/assets/zetachain-TLDS5IPW-Udhyw16T.js +1 -0
  167. package/packages/ui/dist/assets/zh_CN-4XK5YJPR-Bt6Yz5Ek.js +1519 -0
  168. package/packages/ui/dist/assets/zh_HK-N4YN2WSI-Cvzl1V16.js +1519 -0
  169. package/packages/ui/dist/assets/zh_TW-CNCRXH6Z-BNelatfN.js +1519 -0
  170. package/packages/ui/dist/assets/zksync-DH7HK5U4-Dt4usFw6.js +1 -0
  171. package/packages/ui/dist/assets/zora-FYL5H3IO-iB4wygST.js +1 -0
  172. package/packages/ui/dist/index.html +14 -0
@@ -0,0 +1,542 @@
1
+ var ip=Object.defineProperty;var op=(t,e,n)=>e in t?ip(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Ht=(t,e,n)=>op(t,typeof e!="symbol"?e+"":e,n);import{bQ as ti,cS as va,bk as sp}from"./index-DJQDBPts.js";var Ts={exports:{}};(function(t,e){var n=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof ti<"u"&&ti,r=function(){function o(){this.fetch=!1,this.DOMException=n.DOMException}return o.prototype=n,new o}();(function(o){(function(a){var s=typeof o<"u"&&o||typeof self<"u"&&self||typeof ti<"u"&&ti||{},c={searchParams:"URLSearchParams"in s,iterable:"Symbol"in s&&"iterator"in Symbol,blob:"FileReader"in s&&"Blob"in s&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in s,arrayBuffer:"ArrayBuffer"in s};function l(C){return C&&DataView.prototype.isPrototypeOf(C)}if(c.arrayBuffer)var u=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],d=ArrayBuffer.isView||function(C){return C&&u.indexOf(Object.prototype.toString.call(C))>-1};function h(C){if(typeof C!="string"&&(C=String(C)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(C)||C==="")throw new TypeError('Invalid character in header field name: "'+C+'"');return C.toLowerCase()}function f(C){return typeof C!="string"&&(C=String(C)),C}function g(C){var P={next:function(){var D=C.shift();return{done:D===void 0,value:D}}};return c.iterable&&(P[Symbol.iterator]=function(){return P}),P}function m(C){this.map={},C instanceof m?C.forEach(function(P,D){this.append(D,P)},this):Array.isArray(C)?C.forEach(function(P){if(P.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+P.length);this.append(P[0],P[1])},this):C&&Object.getOwnPropertyNames(C).forEach(function(P){this.append(P,C[P])},this)}m.prototype.append=function(C,P){C=h(C),P=f(P);var D=this.map[C];this.map[C]=D?D+", "+P:P},m.prototype.delete=function(C){delete this.map[h(C)]},m.prototype.get=function(C){return C=h(C),this.has(C)?this.map[C]:null},m.prototype.has=function(C){return this.map.hasOwnProperty(h(C))},m.prototype.set=function(C,P){this.map[h(C)]=f(P)},m.prototype.forEach=function(C,P){for(var D in this.map)this.map.hasOwnProperty(D)&&C.call(P,this.map[D],D,this)},m.prototype.keys=function(){var C=[];return this.forEach(function(P,D){C.push(D)}),g(C)},m.prototype.values=function(){var C=[];return this.forEach(function(P){C.push(P)}),g(C)},m.prototype.entries=function(){var C=[];return this.forEach(function(P,D){C.push([D,P])}),g(C)},c.iterable&&(m.prototype[Symbol.iterator]=m.prototype.entries);function w(C){if(!C._noBody){if(C.bodyUsed)return Promise.reject(new TypeError("Already read"));C.bodyUsed=!0}}function p(C){return new Promise(function(P,D){C.onload=function(){P(C.result)},C.onerror=function(){D(C.error)}})}function S(C){var P=new FileReader,D=p(P);return P.readAsArrayBuffer(C),D}function _(C){var P=new FileReader,D=p(P),y=/charset=([A-Za-z0-9_-]+)/.exec(C.type),E=y?y[1]:"utf-8";return P.readAsText(C,E),D}function O(C){for(var P=new Uint8Array(C),D=new Array(P.length),y=0;y<P.length;y++)D[y]=String.fromCharCode(P[y]);return D.join("")}function I(C){if(C.slice)return C.slice(0);var P=new Uint8Array(C.byteLength);return P.set(new Uint8Array(C)),P.buffer}function K(){return this.bodyUsed=!1,this._initBody=function(C){this.bodyUsed=this.bodyUsed,this._bodyInit=C,C?typeof C=="string"?this._bodyText=C:c.blob&&Blob.prototype.isPrototypeOf(C)?this._bodyBlob=C:c.formData&&FormData.prototype.isPrototypeOf(C)?this._bodyFormData=C:c.searchParams&&URLSearchParams.prototype.isPrototypeOf(C)?this._bodyText=C.toString():c.arrayBuffer&&c.blob&&l(C)?(this._bodyArrayBuffer=I(C.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):c.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(C)||d(C))?this._bodyArrayBuffer=I(C):this._bodyText=C=Object.prototype.toString.call(C):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof C=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):c.searchParams&&URLSearchParams.prototype.isPrototypeOf(C)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},c.blob&&(this.blob=function(){var C=w(this);if(C)return C;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var C=w(this);return C||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else{if(c.blob)return this.blob().then(S);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var C=w(this);if(C)return C;if(this._bodyBlob)return _(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(O(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},c.formData&&(this.formData=function(){return this.text().then(j)}),this.json=function(){return this.text().then(JSON.parse)},this}var q=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function F(C){var P=C.toUpperCase();return q.indexOf(P)>-1?P:C}function U(C,P){if(!(this instanceof U))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');P=P||{};var D=P.body;if(C instanceof U){if(C.bodyUsed)throw new TypeError("Already read");this.url=C.url,this.credentials=C.credentials,P.headers||(this.headers=new m(C.headers)),this.method=C.method,this.mode=C.mode,this.signal=C.signal,!D&&C._bodyInit!=null&&(D=C._bodyInit,C.bodyUsed=!0)}else this.url=String(C);if(this.credentials=P.credentials||this.credentials||"same-origin",(P.headers||!this.headers)&&(this.headers=new m(P.headers)),this.method=F(P.method||this.method||"GET"),this.mode=P.mode||this.mode||null,this.signal=P.signal||this.signal||function(){if("AbortController"in s){var A=new AbortController;return A.signal}}(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&D)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(D),(this.method==="GET"||this.method==="HEAD")&&(P.cache==="no-store"||P.cache==="no-cache")){var y=/([?&])_=[^&]*/;if(y.test(this.url))this.url=this.url.replace(y,"$1_="+new Date().getTime());else{var E=/\?/;this.url+=(E.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}U.prototype.clone=function(){return new U(this,{body:this._bodyInit})};function j(C){var P=new FormData;return C.trim().split("&").forEach(function(D){if(D){var y=D.split("="),E=y.shift().replace(/\+/g," "),A=y.join("=").replace(/\+/g," ");P.append(decodeURIComponent(E),decodeURIComponent(A))}}),P}function G(C){var P=new m,D=C.replace(/\r?\n[\t ]+/g," ");return D.split("\r").map(function(y){return y.indexOf(`
2
+ `)===0?y.substr(1,y.length):y}).forEach(function(y){var E=y.split(":"),A=E.shift().trim();if(A){var T=E.join(":").trim();try{P.append(A,T)}catch(b){console.warn("Response "+b.message)}}}),P}K.call(U.prototype);function $(C,P){if(!(this instanceof $))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(P||(P={}),this.type="default",this.status=P.status===void 0?200:P.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=P.statusText===void 0?"":""+P.statusText,this.headers=new m(P.headers),this.url=P.url||"",this._initBody(C)}K.call($.prototype),$.prototype.clone=function(){return new $(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new m(this.headers),url:this.url})},$.error=function(){var C=new $(null,{status:200,statusText:""});return C.ok=!1,C.status=0,C.type="error",C};var N=[301,302,303,307,308];$.redirect=function(C,P){if(N.indexOf(P)===-1)throw new RangeError("Invalid status code");return new $(null,{status:P,headers:{location:C}})},a.DOMException=s.DOMException;try{new a.DOMException}catch{a.DOMException=function(P,D){this.message=P,this.name=D;var y=Error(P);this.stack=y.stack},a.DOMException.prototype=Object.create(Error.prototype),a.DOMException.prototype.constructor=a.DOMException}function R(C,P){return new Promise(function(D,y){var E=new U(C,P);if(E.signal&&E.signal.aborted)return y(new a.DOMException("Aborted","AbortError"));var A=new XMLHttpRequest;function T(){A.abort()}A.onload=function(){var k={statusText:A.statusText,headers:G(A.getAllResponseHeaders()||"")};E.url.indexOf("file://")===0&&(A.status<200||A.status>599)?k.status=200:k.status=A.status,k.url="responseURL"in A?A.responseURL:k.headers.get("X-Request-URL");var x="response"in A?A.response:A.responseText;setTimeout(function(){D(new $(x,k))},0)},A.onerror=function(){setTimeout(function(){y(new TypeError("Network request failed"))},0)},A.ontimeout=function(){setTimeout(function(){y(new TypeError("Network request timed out"))},0)},A.onabort=function(){setTimeout(function(){y(new a.DOMException("Aborted","AbortError"))},0)};function b(k){try{return k===""&&s.location.href?s.location.href:k}catch{return k}}if(A.open(E.method,b(E.url),!0),E.credentials==="include"?A.withCredentials=!0:E.credentials==="omit"&&(A.withCredentials=!1),"responseType"in A&&(c.blob?A.responseType="blob":c.arrayBuffer&&(A.responseType="arraybuffer")),P&&typeof P.headers=="object"&&!(P.headers instanceof m||s.Headers&&P.headers instanceof s.Headers)){var v=[];Object.getOwnPropertyNames(P.headers).forEach(function(k){v.push(h(k)),A.setRequestHeader(k,f(P.headers[k]))}),E.headers.forEach(function(k,x){v.indexOf(x)===-1&&A.setRequestHeader(x,k)})}else E.headers.forEach(function(k,x){A.setRequestHeader(x,k)});E.signal&&(E.signal.addEventListener("abort",T),A.onreadystatechange=function(){A.readyState===4&&E.signal.removeEventListener("abort",T)}),A.send(typeof E._bodyInit>"u"?null:E._bodyInit)})}return R.polyfill=!0,s.fetch||(s.fetch=R,s.Headers=m,s.Request=U,s.Response=$),a.Headers=m,a.Request=U,a.Response=$,a.fetch=R,a})({})})(r),r.fetch.ponyfill=!0,delete r.fetch.polyfill;var i=n.fetch?n:r;e=i.fetch,e.default=i.fetch,e.fetch=i.fetch,e.Headers=i.Headers,e.Request=i.Request,e.Response=i.Response,t.exports=e})(Ts,Ts.exports);var ap=Ts.exports;const Iu=va(ap);var Ms={exports:{}},Bo,fc;function cp(){if(fc)return Bo;fc=1;var t=1e3,e=t*60,n=e*60,r=n*24,i=r*7,o=r*365.25;Bo=function(u,d){d=d||{};var h=typeof u;if(h==="string"&&u.length>0)return a(u);if(h==="number"&&isFinite(u))return d.long?c(u):s(u);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(u))};function a(u){if(u=String(u),!(u.length>100)){var d=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(u);if(d){var h=parseFloat(d[1]),f=(d[2]||"ms").toLowerCase();switch(f){case"years":case"year":case"yrs":case"yr":case"y":return h*o;case"weeks":case"week":case"w":return h*i;case"days":case"day":case"d":return h*r;case"hours":case"hour":case"hrs":case"hr":case"h":return h*n;case"minutes":case"minute":case"mins":case"min":case"m":return h*e;case"seconds":case"second":case"secs":case"sec":case"s":return h*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return h;default:return}}}}function s(u){var d=Math.abs(u);return d>=r?Math.round(u/r)+"d":d>=n?Math.round(u/n)+"h":d>=e?Math.round(u/e)+"m":d>=t?Math.round(u/t)+"s":u+"ms"}function c(u){var d=Math.abs(u);return d>=r?l(u,d,r,"day"):d>=n?l(u,d,n,"hour"):d>=e?l(u,d,e,"minute"):d>=t?l(u,d,t,"second"):u+" ms"}function l(u,d,h,f){var g=d>=h*1.5;return Math.round(u/h)+" "+f+(g?"s":"")}return Bo}function lp(t){n.debug=n,n.default=n,n.coerce=c,n.disable=o,n.enable=i,n.enabled=a,n.humanize=cp(),n.destroy=l,Object.keys(t).forEach(u=>{n[u]=t[u]}),n.names=[],n.skips=[],n.formatters={};function e(u){let d=0;for(let h=0;h<u.length;h++)d=(d<<5)-d+u.charCodeAt(h),d|=0;return n.colors[Math.abs(d)%n.colors.length]}n.selectColor=e;function n(u){let d,h=null,f,g;function m(...w){if(!m.enabled)return;const p=m,S=Number(new Date),_=S-(d||S);p.diff=_,p.prev=d,p.curr=S,d=S,w[0]=n.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let O=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(K,q)=>{if(K==="%%")return"%";O++;const F=n.formatters[q];if(typeof F=="function"){const U=w[O];K=F.call(p,U),w.splice(O,1),O--}return K}),n.formatArgs.call(p,w),(p.log||n.log).apply(p,w)}return m.namespace=u,m.useColors=n.useColors(),m.color=n.selectColor(u),m.extend=r,m.destroy=n.destroy,Object.defineProperty(m,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(f!==n.namespaces&&(f=n.namespaces,g=n.enabled(u)),g),set:w=>{h=w}}),typeof n.init=="function"&&n.init(m),m}function r(u,d){const h=n(this.namespace+(typeof d>"u"?":":d)+u);return h.log=this.log,h}function i(u){n.save(u),n.namespaces=u,n.names=[],n.skips=[];let d;const h=(typeof u=="string"?u:"").split(/[\s,]+/),f=h.length;for(d=0;d<f;d++)h[d]&&(u=h[d].replace(/\*/g,".*?"),u[0]==="-"?n.skips.push(new RegExp("^"+u.slice(1)+"$")):n.names.push(new RegExp("^"+u+"$")))}function o(){const u=[...n.names.map(s),...n.skips.map(s).map(d=>"-"+d)].join(",");return n.enable(""),u}function a(u){if(u[u.length-1]==="*")return!0;let d,h;for(d=0,h=n.skips.length;d<h;d++)if(n.skips[d].test(u))return!1;for(d=0,h=n.names.length;d<h;d++)if(n.names[d].test(u))return!0;return!1}function s(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function c(u){return u instanceof Error?u.stack||u.message:u}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}var up=lp;(function(t,e){var n={};e.formatArgs=i,e.save=o,e.load=a,e.useColors=r,e.storage=s(),e.destroy=(()=>{let l=!1;return()=>{l||(l=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function r(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function i(l){if(l[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+l[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const u="color: "+this.color;l.splice(1,0,u,"color: inherit");let d=0,h=0;l[0].replace(/%[a-zA-Z%]/g,f=>{f!=="%%"&&(d++,f==="%c"&&(h=d))}),l.splice(h,0,u)}e.log=console.debug||console.log||(()=>{});function o(l){try{l?e.storage.setItem("debug",l):e.storage.removeItem("debug")}catch{}}function a(){let l;try{l=e.storage.getItem("debug")}catch{}return!l&&typeof process<"u"&&"env"in process&&(l=n.DEBUG),l}function s(){try{return localStorage}catch{}}t.exports=up(e);const{formatters:c}=t.exports;c.j=function(l){try{return JSON.stringify(l)}catch(u){return"[UnexpectedJSONParseError]: "+u.message}}})(Ms,Ms.exports);var dp=Ms.exports;const Ze=va(dp);var ba=Object.defineProperty,hp=Object.getOwnPropertyDescriptor,fp=Object.getOwnPropertyNames,pp=Object.prototype.hasOwnProperty,mp=(t,e)=>{for(var n in e)ba(t,n,{get:e[n],enumerable:!0})},gp=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of fp(e))!pp.call(t,i)&&i!==n&&ba(t,i,{get:()=>e[i],enumerable:!(r=hp(e,i))||r.enumerable});return t},yp=t=>gp(ba({},"__esModule",{value:!0}),t),Lu={};mp(Lu,{createFinalURL:()=>ju,createPathBasedClient:()=>Sp,createQuerySerializer:()=>Rs,default:()=>Du,defaultBodySerializer:()=>Ku,defaultPathSerializer:()=>$u,mergeHeaders:()=>Os,randomID:()=>Nu,removeTrailingSlash:()=>Ps,serializeArrayParam:()=>Ea,serializeObjectParam:()=>wa,serializePrimitiveParam:()=>Yr,wrapAsPathBasedClient:()=>Bu});var vp=yp(Lu),bp=/\{[^{}]+\}/g,wp=()=>{var t,e;return typeof process=="object"&&Number.parseInt((e=(t=process==null?void 0:process.versions)==null?void 0:t.node)==null?void 0:e.substring(0,2))>=18&&process.versions.undici};function Nu(){return Math.random().toString(36).slice(2,11)}function Du(t){let{baseUrl:e="",Request:n=globalThis.Request,fetch:r=globalThis.fetch,querySerializer:i,bodySerializer:o,headers:a,requestInitExt:s=void 0,...c}={...t};s=wp()?s:void 0,e=Ps(e);const l=[];async function u(d,h){const{baseUrl:f,fetch:g=r,Request:m=n,headers:w,params:p={},parseAs:S="json",querySerializer:_,bodySerializer:O=o??Ku,body:I,...K}=h||{};let q=e;f&&(q=Ps(f)??e);let F=typeof i=="function"?i:Rs(i);_&&(F=typeof _=="function"?_:Rs({...typeof i=="object"?i:{},..._}));const U=I===void 0?void 0:O(I,Os(a,w,p.header)),j=Os(U===void 0||U instanceof FormData?{}:{"Content-Type":"application/json"},a,w,p.header),G={redirect:"follow",...c,...K,body:U,headers:j};let $,N,R=new n(ju(d,{baseUrl:q,params:p,querySerializer:F}),G),C;for(const D in K)D in R||(R[D]=K[D]);if(l.length){$=Nu(),N=Object.freeze({baseUrl:q,fetch:g,parseAs:S,querySerializer:F,bodySerializer:O});for(const D of l)if(D&&typeof D=="object"&&typeof D.onRequest=="function"){const y=await D.onRequest({request:R,schemaPath:d,params:p,options:N,id:$});if(y)if(y instanceof n)R=y;else if(y instanceof Response){C=y;break}else throw new Error("onRequest: must return new Request() or Response() when modifying the request")}}if(!C){try{C=await g(R,s)}catch(D){let y=D;if(l.length)for(let E=l.length-1;E>=0;E--){const A=l[E];if(A&&typeof A=="object"&&typeof A.onError=="function"){const T=await A.onError({request:R,error:y,schemaPath:d,params:p,options:N,id:$});if(T){if(T instanceof Response){y=void 0,C=T;break}if(T instanceof Error){y=T;continue}throw new Error("onError: must return new Response() or instance of Error")}}}if(y)throw y}if(l.length)for(let D=l.length-1;D>=0;D--){const y=l[D];if(y&&typeof y=="object"&&typeof y.onResponse=="function"){const E=await y.onResponse({request:R,response:C,schemaPath:d,params:p,options:N,id:$});if(E){if(!(E instanceof Response))throw new Error("onResponse: must return new Response() when modifying the response");C=E}}}}if(C.status===204||R.method==="HEAD"||C.headers.get("Content-Length")==="0")return C.ok?{data:void 0,response:C}:{error:void 0,response:C};if(C.ok)return S==="stream"?{data:C.body,response:C}:{data:await C[S](),response:C};let P=await C.text();try{P=JSON.parse(P)}catch{}return{error:P,response:C}}return{request(d,h,f){return u(h,{...f,method:d.toUpperCase()})},GET(d,h){return u(d,{...h,method:"GET"})},PUT(d,h){return u(d,{...h,method:"PUT"})},POST(d,h){return u(d,{...h,method:"POST"})},DELETE(d,h){return u(d,{...h,method:"DELETE"})},OPTIONS(d,h){return u(d,{...h,method:"OPTIONS"})},HEAD(d,h){return u(d,{...h,method:"HEAD"})},PATCH(d,h){return u(d,{...h,method:"PATCH"})},TRACE(d,h){return u(d,{...h,method:"TRACE"})},use(...d){for(const h of d)if(h){if(typeof h!="object"||!("onRequest"in h||"onResponse"in h||"onError"in h))throw new Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");l.push(h)}},eject(...d){for(const h of d){const f=l.indexOf(h);f!==-1&&l.splice(f,1)}}}}var Ep=class{constructor(t,e){Ht(this,"GET",t=>this.client.GET(this.url,t));Ht(this,"PUT",t=>this.client.PUT(this.url,t));Ht(this,"POST",t=>this.client.POST(this.url,t));Ht(this,"DELETE",t=>this.client.DELETE(this.url,t));Ht(this,"OPTIONS",t=>this.client.OPTIONS(this.url,t));Ht(this,"HEAD",t=>this.client.HEAD(this.url,t));Ht(this,"PATCH",t=>this.client.PATCH(this.url,t));Ht(this,"TRACE",t=>this.client.TRACE(this.url,t));this.client=t,this.url=e}},_p=class{constructor(){this.client=null}get(t,e){const n=new Ep(t,e);return this.client[e]=n,n}};function Bu(t){const e=new _p,n=new Proxy(t,e);function r(){}r.prototype=n;const i=new r;return e.client=i,i}function Sp(t){return Bu(Du(t))}function Yr(t,e,n){if(e==null)return"";if(typeof e=="object")throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${(n==null?void 0:n.allowReserved)===!0?e:encodeURIComponent(e)}`}function wa(t,e,n){if(!e||typeof e!="object")return"";const r=[],i={simple:",",label:".",matrix:";"}[n.style]||"&";if(n.style!=="deepObject"&&n.explode===!1){for(const s in e)r.push(s,n.allowReserved===!0?e[s]:encodeURIComponent(e[s]));const a=r.join(",");switch(n.style){case"form":return`${t}=${a}`;case"label":return`.${a}`;case"matrix":return`;${t}=${a}`;default:return a}}for(const a in e){const s=n.style==="deepObject"?`${t}[${a}]`:a;r.push(Yr(s,e[a],n))}const o=r.join(i);return n.style==="label"||n.style==="matrix"?`${i}${o}`:o}function Ea(t,e,n){if(!Array.isArray(e))return"";if(n.explode===!1){const o={form:",",spaceDelimited:"%20",pipeDelimited:"|"}[n.style]||",",a=(n.allowReserved===!0?e:e.map(s=>encodeURIComponent(s))).join(o);switch(n.style){case"simple":return a;case"label":return`.${a}`;case"matrix":return`;${t}=${a}`;default:return`${t}=${a}`}}const r={simple:",",label:".",matrix:";"}[n.style]||"&",i=[];for(const o of e)n.style==="simple"||n.style==="label"?i.push(n.allowReserved===!0?o:encodeURIComponent(o)):i.push(Yr(t,o,n));return n.style==="label"||n.style==="matrix"?`${r}${i.join(r)}`:i.join(r)}function Rs(t){return function(n){const r=[];if(n&&typeof n=="object")for(const i in n){const o=n[i];if(o!=null){if(Array.isArray(o)){if(o.length===0)continue;r.push(Ea(i,o,{style:"form",explode:!0,...t==null?void 0:t.array,allowReserved:(t==null?void 0:t.allowReserved)||!1}));continue}if(typeof o=="object"){r.push(wa(i,o,{style:"deepObject",explode:!0,...t==null?void 0:t.object,allowReserved:(t==null?void 0:t.allowReserved)||!1}));continue}r.push(Yr(i,o,t))}}return r.join("&")}}function $u(t,e){let n=t;for(const r of t.match(bp)??[]){let i=r.substring(1,r.length-1),o=!1,a="simple";if(i.endsWith("*")&&(o=!0,i=i.substring(0,i.length-1)),i.startsWith(".")?(a="label",i=i.substring(1)):i.startsWith(";")&&(a="matrix",i=i.substring(1)),!e||e[i]===void 0||e[i]===null)continue;const s=e[i];if(Array.isArray(s)){n=n.replace(r,Ea(i,s,{style:a,explode:o}));continue}if(typeof s=="object"){n=n.replace(r,wa(i,s,{style:a,explode:o}));continue}if(a==="matrix"){n=n.replace(r,`;${Yr(i,s)}`);continue}n=n.replace(r,a==="label"?`.${encodeURIComponent(s)}`:encodeURIComponent(s))}return n}function Ku(t,e){return t instanceof FormData?t:e&&(e.get instanceof Function?e.get("Content-Type")??e.get("content-type"):e["Content-Type"]??e["content-type"])==="application/x-www-form-urlencoded"?new URLSearchParams(t).toString():JSON.stringify(t)}function ju(t,e){var i;let n=`${e.baseUrl}${t}`;(i=e.params)!=null&&i.path&&(n=$u(n,e.params.path));let r=e.querySerializer(e.params.query??{});return r.startsWith("?")&&(r=r.substring(1)),r&&(n+=`?${r}`),n}function Os(...t){const e=new Headers;for(const n of t){if(!n||typeof n!="object")continue;const r=n instanceof Headers?n.entries():Object.entries(n);for(const[i,o]of r)if(o===null)e.delete(i);else if(Array.isArray(o))for(const a of o)e.append(i,a);else o!==void 0&&e.set(i,o)}return e}function Ps(t){return t.endsWith("/")?t.substring(0,t.length-1):t}var $o={},Cp=Object.create,Eo=Object.defineProperty,kp=Object.getOwnPropertyDescriptor,Ap=Object.getOwnPropertyNames,xp=Object.getPrototypeOf,Tp=Object.prototype.hasOwnProperty,Mp=(t,e)=>{for(var n in e)Eo(t,n,{get:e[n],enumerable:!0})},Uu=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ap(e))!Tp.call(t,i)&&i!==n&&Eo(t,i,{get:()=>e[i],enumerable:!(r=kp(e,i))||r.enumerable});return t},Rp=(t,e,n)=>(n=t!=null?Cp(xp(t)):{},Uu(!t||!t.__esModule?Eo(n,"default",{value:t,enumerable:!0}):n,t)),Op=t=>Uu(Eo({},"__esModule",{value:!0}),t),Hu={};Mp(Hu,{analytics:()=>Kp});var Me=Op(Hu),Pp=Rp(vp),Ip=class{constructor(t){this.batch=[],this.maxTimeoutMs=3e4,this.timeoutId=null,this.isSending=!1,this.batchSize=t.batchSize,this.baseTimeoutMs=t.baseTimeoutMs,this.currentTimeoutMs=t.baseTimeoutMs,this.sendFn=t.sendFn}enqueue(t){this.batch.push(t),this.schedule()}schedule(){this.batch.length>0&&!this.timeoutId&&(this.timeoutId=setTimeout(()=>{this.timeoutId=null,this.flush()},this.currentTimeoutMs))}async flush(){if(this.isSending||this.batch.length===0)return;this.isSending=!0;const t=[...this.batch.slice(0,this.batchSize)];this.batch=this.batch.slice(this.batchSize);try{await this.sendFn(t),this.currentTimeoutMs=this.baseTimeoutMs}catch(e){console.error("Sender: Failed to send batch",e),this.batch=[...t,...this.batch],this.currentTimeoutMs=Math.min(this.currentTimeoutMs*2,this.maxTimeoutMs)}finally{this.isSending=!1,this.schedule()}}},Lp=Ip,Np=class{constructor(t){this.enabled=!1,this.properties={};const e=(0,Pp.default)({baseUrl:t}),n=async r=>{const i=await e.POST("/v1/events",{body:r});if(i.response.status!==200)throw new Error(i.error)};this.sender=new Lp({batchSize:100,baseTimeoutMs:200,sendFn:n})}enable(){this.enabled=!0}setGlobalProperty(t,e){this.properties[t]=e}track(t,e){if(!this.enabled)return;const n={name:t,...this.properties,...e};this.sender.enqueue(n)}},Dp=Np,Is,pc;typeof process<"u"&&$o&&(Is=(pc=$o.METAMASK_ANALYTICS_ENDPOINT)!=null?pc:$o.NEXT_PUBLIC_METAMASK_ANALYTICS_ENDPOINT);var Bp=Is??"https://mm-sdk-analytics.api.cx.metamask.io/",$p=new Dp(Bp),Kp=$p,Fu={exports:{}};/*!
3
+ * EventEmitter2
4
+ * https://github.com/hij1nx/EventEmitter2
5
+ *
6
+ * Copyright (c) 2013 hij1nx
7
+ * Licensed under the MIT license.
8
+ */(function(t,e){(function(n){var r=Object.hasOwnProperty,i=Array.isArray?Array.isArray:function(E){return Object.prototype.toString.call(E)==="[object Array]"},o=10,a=typeof process=="object"&&typeof process.nextTick=="function",s=typeof Symbol=="function",c=typeof Reflect=="object",l=typeof setImmediate=="function",u=l?setImmediate:setTimeout,d=s?c&&typeof Reflect.ownKeys=="function"?Reflect.ownKeys:function(y){var E=Object.getOwnPropertyNames(y);return E.push.apply(E,Object.getOwnPropertySymbols(y)),E}:Object.keys;function h(){this._events={},this._conf&&f.call(this,this._conf)}function f(y){y&&(this._conf=y,y.delimiter&&(this.delimiter=y.delimiter),y.maxListeners!==n&&(this._maxListeners=y.maxListeners),y.wildcard&&(this.wildcard=y.wildcard),y.newListener&&(this._newListener=y.newListener),y.removeListener&&(this._removeListener=y.removeListener),y.verboseMemoryLeak&&(this.verboseMemoryLeak=y.verboseMemoryLeak),y.ignoreErrors&&(this.ignoreErrors=y.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function g(y,E){var A="(node) warning: possible EventEmitter memory leak detected. "+y+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(A+=" Event name: "+E+"."),typeof process<"u"&&process.emitWarning){var T=new Error(A);T.name="MaxListenersExceededWarning",T.emitter=this,T.count=y,process.emitWarning(T)}else console.error(A),console.trace&&console.trace()}var m=function(y,E,A){var T=arguments.length;switch(T){case 0:return[];case 1:return[y];case 2:return[y,E];case 3:return[y,E,A];default:for(var b=new Array(T);T--;)b[T]=arguments[T];return b}};function w(y,E){for(var A={},T,b=y.length,v=0,k=0;k<b;k++)T=y[k],A[T]=k<v?E[k]:n;return A}function p(y,E,A){this._emitter=y,this._target=E,this._listeners={},this._listenersCount=0;var T,b;if((A.on||A.off)&&(T=A.on,b=A.off),E.addEventListener?(T=E.addEventListener,b=E.removeEventListener):E.addListener?(T=E.addListener,b=E.removeListener):E.on&&(T=E.on,b=E.off),!T&&!b)throw Error("target does not implement any known event API");if(typeof T!="function")throw TypeError("on method must be a function");if(typeof b!="function")throw TypeError("off method must be a function");this._on=T,this._off=b;var v=y._observers;v?v.push(this):y._observers=[this]}Object.assign(p.prototype,{subscribe:function(y,E,A){var T=this,b=this._target,v=this._emitter,k=this._listeners,x=function(){var M=m.apply(null,arguments),L={data:M,name:E,original:y};if(A){var B=A.call(b,L);B!==!1&&v.emit.apply(v,[L.name].concat(M));return}v.emit.apply(v,[E].concat(M))};if(k[y])throw Error("Event '"+y+"' is already listening");this._listenersCount++,v._newListener&&v._removeListener&&!T._onNewListener?(this._onNewListener=function(M){M===E&&k[y]===null&&(k[y]=x,T._on.call(b,y,x))},v.on("newListener",this._onNewListener),this._onRemoveListener=function(M){M===E&&!v.hasListeners(M)&&k[y]&&(k[y]=null,T._off.call(b,y,x))},k[y]=null,v.on("removeListener",this._onRemoveListener)):(k[y]=x,T._on.call(b,y,x))},unsubscribe:function(y){var E=this,A=this._listeners,T=this._emitter,b,v,k=this._off,x=this._target,M;if(y&&typeof y!="string")throw TypeError("event must be a string");function L(){E._onNewListener&&(T.off("newListener",E._onNewListener),T.off("removeListener",E._onRemoveListener),E._onNewListener=null,E._onRemoveListener=null);var B=F.call(T,E);T._observers.splice(B,1)}if(y){if(b=A[y],!b)return;k.call(x,y,b),delete A[y],--this._listenersCount||L()}else{for(v=d(A),M=v.length;M-- >0;)y=v[M],k.call(x,y,A[y]);this._listeners={},this._listenersCount=0,L()}}});function S(y,E,A,T){var b=Object.assign({},E);if(!y)return b;if(typeof y!="object")throw TypeError("options must be an object");var v=Object.keys(y),k=v.length,x,M,L;function B(z){throw Error('Invalid "'+x+'" option value'+(z?". Reason: "+z:""))}for(var H=0;H<k;H++){if(x=v[H],!r.call(E,x))throw Error('Unknown "'+x+'" option');M=y[x],M!==n&&(L=A[x],b[x]=L?L(M,B):M)}return b}function _(y,E){return(typeof y!="function"||!y.hasOwnProperty("prototype"))&&E("value must be a constructor"),y}function O(y){var E="value must be type of "+y.join("|"),A=y.length,T=y[0],b=y[1];return A===1?function(v,k){if(typeof v===T)return v;k(E)}:A===2?function(v,k){var x=typeof v;if(x===T||x===b)return v;k(E)}:function(v,k){for(var x=typeof v,M=A;M-- >0;)if(x===y[M])return v;k(E)}}var I=O(["function"]),K=O(["object","function"]);function q(y,E,A){var T,b,v=0,k,x=new y(function(M,L,B){A=S(A,{timeout:0,overload:!1},{timeout:function(Q,ne){return Q*=1,(typeof Q!="number"||Q<0||!Number.isFinite(Q))&&ne("timeout must be a positive number"),Q}}),T=!A.overload&&typeof y.prototype.cancel=="function"&&typeof B=="function";function H(){b&&(b=null),v&&(clearTimeout(v),v=0)}var z=function(Q){H(),M(Q)},J=function(Q){H(),L(Q)};T?E(z,J,B):(b=[function(Q){J(Q||Error("canceled"))}],E(z,J,function(Q){if(k)throw Error("Unable to subscribe on cancel event asynchronously");if(typeof Q!="function")throw TypeError("onCancel callback must be a function");b.push(Q)}),k=!0),A.timeout>0&&(v=setTimeout(function(){var Q=Error("timeout");Q.code="ETIMEDOUT",v=0,x.cancel(Q),L(Q)},A.timeout))});return T||(x.cancel=function(M){if(b){for(var L=b.length,B=1;B<L;B++)b[B](M);b[0](M),b=null}}),x}function F(y){var E=this._observers;if(!E)return-1;for(var A=E.length,T=0;T<A;T++)if(E[T]._target===y)return T;return-1}function U(y,E,A,T,b){if(!A)return null;if(T===0){var v=typeof E;if(v==="string"){var k,x,M=0,L=0,B=this.delimiter,H=B.length;if((x=E.indexOf(B))!==-1){k=new Array(5);do k[M++]=E.slice(L,x),L=x+H;while((x=E.indexOf(B,L))!==-1);k[M++]=E.slice(L),E=k,b=M}else E=[E],b=1}else v==="object"?b=E.length:(E=[E],b=1)}var z=null,J,Q,ne,se,le,re=E[T],ie=E[T+1],ce,ae;if(T===b)A._listeners&&(typeof A._listeners=="function"?(y&&y.push(A._listeners),z=[A]):(y&&y.push.apply(y,A._listeners),z=[A]));else if(re==="*"){for(ce=d(A),x=ce.length;x-- >0;)J=ce[x],J!=="_listeners"&&(ae=U(y,E,A[J],T+1,b),ae&&(z?z.push.apply(z,ae):z=ae));return z}else if(re==="**"){for(le=T+1===b||T+2===b&&ie==="*",le&&A._listeners&&(z=U(y,E,A,b,b)),ce=d(A),x=ce.length;x-- >0;)J=ce[x],J!=="_listeners"&&(J==="*"||J==="**"?(A[J]._listeners&&!le&&(ae=U(y,E,A[J],b,b),ae&&(z?z.push.apply(z,ae):z=ae)),ae=U(y,E,A[J],T,b)):J===ie?ae=U(y,E,A[J],T+2,b):ae=U(y,E,A[J],T,b),ae&&(z?z.push.apply(z,ae):z=ae));return z}else A[re]&&(z=U(y,E,A[re],T+1,b));if(Q=A["*"],Q&&U(y,E,Q,T+1,b),ne=A["**"],ne)if(T<b)for(ne._listeners&&U(y,E,ne,b,b),ce=d(ne),x=ce.length;x-- >0;)J=ce[x],J!=="_listeners"&&(J===ie?U(y,E,ne[J],T+2,b):J===re?U(y,E,ne[J],T+1,b):(se={},se[J]=ne[J],U(y,E,{"**":se},T+1,b)));else ne._listeners?U(y,E,ne,b,b):ne["*"]&&ne["*"]._listeners&&U(y,E,ne["*"],b,b);return z}function j(y,E,A){var T=0,b=0,v,k=this.delimiter,x=k.length,M;if(typeof y=="string")if((v=y.indexOf(k))!==-1){M=new Array(5);do M[T++]=y.slice(b,v),b=v+x;while((v=y.indexOf(k,b))!==-1);M[T++]=y.slice(b)}else M=[y],T=1;else M=y,T=y.length;if(T>1){for(v=0;v+1<T;v++)if(M[v]==="**"&&M[v+1]==="**")return}var L=this.listenerTree,B;for(v=0;v<T;v++)if(B=M[v],L=L[B]||(L[B]={}),v===T-1)return L._listeners?(typeof L._listeners=="function"&&(L._listeners=[L._listeners]),A?L._listeners.unshift(E):L._listeners.push(E),!L._listeners.warned&&this._maxListeners>0&&L._listeners.length>this._maxListeners&&(L._listeners.warned=!0,g.call(this,L._listeners.length,B))):L._listeners=E,!0;return!0}function G(y,E,A,T){for(var b=d(y),v=b.length,k,x,M,L=y._listeners,B;v-- >0;)x=b[v],k=y[x],x==="_listeners"?M=A:M=A?A.concat(x):[x],B=T||typeof x=="symbol",L&&E.push(B?M:M.join(this.delimiter)),typeof k=="object"&&G.call(this,k,E,M,B);return E}function $(y){for(var E=d(y),A=E.length,T,b,v;A-- >0;)b=E[A],T=y[b],T&&(v=!0,b!=="_listeners"&&!$(T)&&delete y[b]);return v}function N(y,E,A){this.emitter=y,this.event=E,this.listener=A}N.prototype.off=function(){return this.emitter.off(this.event,this.listener),this};function R(y,E,A){if(A===!0)b=!0;else if(A===!1)T=!0;else{if(!A||typeof A!="object")throw TypeError("options should be an object or true");var T=A.async,b=A.promisify,v=A.nextTick,k=A.objectify}if(T||v||b){var x=E,M=E._origin||E;if(v&&!a)throw Error("process.nextTick is not supported");b===n&&(b=E.constructor.name==="AsyncFunction"),E=function(){var L=arguments,B=this,H=this.event;return b?v?Promise.resolve():new Promise(function(z){u(z)}).then(function(){return B.event=H,x.apply(B,L)}):(v?process.nextTick:u)(function(){B.event=H,x.apply(B,L)})},E._async=!0,E._origin=M}return[E,k?new N(this,y,E):this]}function C(y){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,f.call(this,y)}C.EventEmitter2=C,C.prototype.listenTo=function(y,E,A){if(typeof y!="object")throw TypeError("target musts be an object");var T=this;A=S(A,{on:n,off:n,reducers:n},{on:I,off:I,reducers:K});function b(v){if(typeof v!="object")throw TypeError("events must be an object");var k=A.reducers,x=F.call(T,y),M;x===-1?M=new p(T,y,A):M=T._observers[x];for(var L=d(v),B=L.length,H,z=typeof k=="function",J=0;J<B;J++)H=L[J],M.subscribe(H,v[H]||H,z?k:k&&k[H])}return i(E)?b(w(E)):b(typeof E=="string"?w(E.split(/\s+/)):E),this},C.prototype.stopListeningTo=function(y,E){var A=this._observers;if(!A)return!1;var T=A.length,b,v=!1;if(y&&typeof y!="object")throw TypeError("target should be an object");for(;T-- >0;)b=A[T],(!y||b._target===y)&&(b.unsubscribe(E),v=!0);return v},C.prototype.delimiter=".",C.prototype.setMaxListeners=function(y){y!==n&&(this._maxListeners=y,this._conf||(this._conf={}),this._conf.maxListeners=y)},C.prototype.getMaxListeners=function(){return this._maxListeners},C.prototype.event="",C.prototype.once=function(y,E,A){return this._once(y,E,!1,A)},C.prototype.prependOnceListener=function(y,E,A){return this._once(y,E,!0,A)},C.prototype._once=function(y,E,A,T){return this._many(y,1,E,A,T)},C.prototype.many=function(y,E,A,T){return this._many(y,E,A,!1,T)},C.prototype.prependMany=function(y,E,A,T){return this._many(y,E,A,!0,T)},C.prototype._many=function(y,E,A,T,b){var v=this;if(typeof A!="function")throw new Error("many only accepts instances of Function");function k(){return--E===0&&v.off(y,k),A.apply(this,arguments)}return k._origin=A,this._on(y,k,T,b)},C.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||h.call(this);var y=arguments[0],E,A=this.wildcard,T,b,v,k,x;if(y==="newListener"&&!this._newListener&&!this._events.newListener)return!1;if(A&&(E=y,y!=="newListener"&&y!=="removeListener"&&typeof y=="object")){if(b=y.length,s){for(v=0;v<b;v++)if(typeof y[v]=="symbol"){x=!0;break}}x||(y=y.join(this.delimiter))}var M=arguments.length,L;if(this._all&&this._all.length)for(L=this._all.slice(),v=0,b=L.length;v<b;v++)switch(this.event=y,M){case 1:L[v].call(this,y);break;case 2:L[v].call(this,y,arguments[1]);break;case 3:L[v].call(this,y,arguments[1],arguments[2]);break;default:L[v].apply(this,arguments)}if(A)L=[],U.call(this,L,E,this.listenerTree,0,b);else if(L=this._events[y],typeof L=="function"){switch(this.event=y,M){case 1:L.call(this);break;case 2:L.call(this,arguments[1]);break;case 3:L.call(this,arguments[1],arguments[2]);break;default:for(T=new Array(M-1),k=1;k<M;k++)T[k-1]=arguments[k];L.apply(this,T)}return!0}else L&&(L=L.slice());if(L&&L.length){if(M>3)for(T=new Array(M-1),k=1;k<M;k++)T[k-1]=arguments[k];for(v=0,b=L.length;v<b;v++)switch(this.event=y,M){case 1:L[v].call(this);break;case 2:L[v].call(this,arguments[1]);break;case 3:L[v].call(this,arguments[1],arguments[2]);break;default:L[v].apply(this,T)}return!0}else if(!this.ignoreErrors&&!this._all&&y==="error")throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},C.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||h.call(this);var y=arguments[0],E=this.wildcard,A,T,b,v,k,x;if(y==="newListener"&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(E&&(A=y,y!=="newListener"&&y!=="removeListener"&&typeof y=="object")){if(v=y.length,s){for(k=0;k<v;k++)if(typeof y[k]=="symbol"){T=!0;break}}T||(y=y.join(this.delimiter))}var M=[],L=arguments.length,B;if(this._all)for(k=0,v=this._all.length;k<v;k++)switch(this.event=y,L){case 1:M.push(this._all[k].call(this,y));break;case 2:M.push(this._all[k].call(this,y,arguments[1]));break;case 3:M.push(this._all[k].call(this,y,arguments[1],arguments[2]));break;default:M.push(this._all[k].apply(this,arguments))}if(E?(B=[],U.call(this,B,A,this.listenerTree,0)):B=this._events[y],typeof B=="function")switch(this.event=y,L){case 1:M.push(B.call(this));break;case 2:M.push(B.call(this,arguments[1]));break;case 3:M.push(B.call(this,arguments[1],arguments[2]));break;default:for(b=new Array(L-1),x=1;x<L;x++)b[x-1]=arguments[x];M.push(B.apply(this,b))}else if(B&&B.length){if(B=B.slice(),L>3)for(b=new Array(L-1),x=1;x<L;x++)b[x-1]=arguments[x];for(k=0,v=B.length;k<v;k++)switch(this.event=y,L){case 1:M.push(B[k].call(this));break;case 2:M.push(B[k].call(this,arguments[1]));break;case 3:M.push(B[k].call(this,arguments[1],arguments[2]));break;default:M.push(B[k].apply(this,b))}}else if(!this.ignoreErrors&&!this._all&&y==="error")return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(M)},C.prototype.on=function(y,E,A){return this._on(y,E,!1,A)},C.prototype.prependListener=function(y,E,A){return this._on(y,E,!0,A)},C.prototype.onAny=function(y){return this._onAny(y,!1)},C.prototype.prependAny=function(y){return this._onAny(y,!0)},C.prototype.addListener=C.prototype.on,C.prototype._onAny=function(y,E){if(typeof y!="function")throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),E?this._all.unshift(y):this._all.push(y),this},C.prototype._on=function(y,E,A,T){if(typeof y=="function")return this._onAny(y,E),this;if(typeof E!="function")throw new Error("on only accepts instances of Function");this._events||h.call(this);var b=this,v;return T!==n&&(v=R.call(this,y,E,T),E=v[0],b=v[1]),this._newListener&&this.emit("newListener",y,E),this.wildcard?(j.call(this,y,E,A),b):(this._events[y]?(typeof this._events[y]=="function"&&(this._events[y]=[this._events[y]]),A?this._events[y].unshift(E):this._events[y].push(E),!this._events[y].warned&&this._maxListeners>0&&this._events[y].length>this._maxListeners&&(this._events[y].warned=!0,g.call(this,this._events[y].length,y))):this._events[y]=E,b)},C.prototype.off=function(y,E){if(typeof E!="function")throw new Error("removeListener only takes instances of Function");var A,T=[];if(this.wildcard){var b=typeof y=="string"?y.split(this.delimiter):y.slice();if(T=U.call(this,null,b,this.listenerTree,0),!T)return this}else{if(!this._events[y])return this;A=this._events[y],T.push({_listeners:A})}for(var v=0;v<T.length;v++){var k=T[v];if(A=k._listeners,i(A)){for(var x=-1,M=0,L=A.length;M<L;M++)if(A[M]===E||A[M].listener&&A[M].listener===E||A[M]._origin&&A[M]._origin===E){x=M;break}if(x<0)continue;return this.wildcard?k._listeners.splice(x,1):this._events[y].splice(x,1),A.length===0&&(this.wildcard?delete k._listeners:delete this._events[y]),this._removeListener&&this.emit("removeListener",y,E),this}else(A===E||A.listener&&A.listener===E||A._origin&&A._origin===E)&&(this.wildcard?delete k._listeners:delete this._events[y],this._removeListener&&this.emit("removeListener",y,E))}return this.listenerTree&&$(this.listenerTree),this},C.prototype.offAny=function(y){var E=0,A=0,T;if(y&&this._all&&this._all.length>0){for(T=this._all,E=0,A=T.length;E<A;E++)if(y===T[E])return T.splice(E,1),this._removeListener&&this.emit("removeListenerAny",y),this}else{if(T=this._all,this._removeListener)for(E=0,A=T.length;E<A;E++)this.emit("removeListenerAny",T[E]);this._all=[]}return this},C.prototype.removeListener=C.prototype.off,C.prototype.removeAllListeners=function(y){if(y===n)return!this._events||h.call(this),this;if(this.wildcard){var E=U.call(this,null,y,this.listenerTree,0),A,T;if(!E)return this;for(T=0;T<E.length;T++)A=E[T],A._listeners=null;this.listenerTree&&$(this.listenerTree)}else this._events&&(this._events[y]=null);return this},C.prototype.listeners=function(y){var E=this._events,A,T,b,v,k;if(y===n){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!E)return[];for(A=d(E),v=A.length,b=[];v-- >0;)T=E[A[v]],typeof T=="function"?b.push(T):b.push.apply(b,T);return b}else{if(this.wildcard){if(k=this.listenerTree,!k)return[];var x=[],M=typeof y=="string"?y.split(this.delimiter):y.slice();return U.call(this,x,M,k,0),x}return E?(T=E[y],T?typeof T=="function"?[T]:T:[]):[]}},C.prototype.eventNames=function(y){var E=this._events;return this.wildcard?G.call(this,this.listenerTree,[],null,y):E?d(E):[]},C.prototype.listenerCount=function(y){return this.listeners(y).length},C.prototype.hasListeners=function(y){if(this.wildcard){var E=[],A=typeof y=="string"?y.split(this.delimiter):y.slice();return U.call(this,E,A,this.listenerTree,0),E.length>0}var T=this._events,b=this._all;return!!(b&&b.length||T&&(y===n?d(T).length:T[y]))},C.prototype.listenersAny=function(){return this._all?this._all:[]},C.prototype.waitFor=function(y,E){var A=this,T=typeof E;return T==="number"?E={timeout:E}:T==="function"&&(E={filter:E}),E=S(E,{timeout:0,filter:n,handleError:!1,Promise,overload:!1},{filter:I,Promise:_}),q(E.Promise,function(b,v,k){function x(){var M=E.filter;if(!(M&&!M.apply(A,arguments)))if(A.off(y,x),E.handleError){var L=arguments[0];L?v(L):b(m.apply(null,arguments).slice(1))}else b(m.apply(null,arguments))}k(function(){A.off(y,x)}),A._on(y,x,!1)},{timeout:E.timeout,overload:E.overload})};function P(y,E,A){A=S(A,{Promise,timeout:0,overload:!1},{Promise:_});var T=A.Promise;return q(T,function(b,v,k){var x;if(typeof y.addEventListener=="function"){x=function(){b(m.apply(null,arguments))},k(function(){y.removeEventListener(E,x)}),y.addEventListener(E,x,{once:!0});return}var M=function(){L&&y.removeListener("error",L),b(m.apply(null,arguments))},L;E!=="error"&&(L=function(B){y.removeListener(E,M),v(B)},y.once("error",L)),k(function(){L&&y.removeListener("error",L),y.removeListener(E,M)}),y.once(E,M)},{timeout:A.timeout,overload:A.overload})}var D=C.prototype;Object.defineProperties(C,{defaultMaxListeners:{get:function(){return D._maxListeners},set:function(y){if(typeof y!="number"||y<0||Number.isNaN(y))throw TypeError("n must be a non-negative number");D._maxListeners=y},enumerable:!0},once:{value:P,writable:!0,configurable:!0}}),Object.defineProperties(D,{_maxListeners:{value:o,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),t.exports=C})()})(Fu);var _o=Fu.exports;const jp=va(_o);var ni,Up=new Uint8Array(16);function Hp(){if(!ni&&(ni=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!ni))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ni(Up)}const Fp=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Ls(t){return typeof t=="string"&&Fp.test(t)}var $e=[];for(var Ko=0;Ko<256;++Ko)$e.push((Ko+256).toString(16).substr(1));function zp(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=($e[t[e+0]]+$e[t[e+1]]+$e[t[e+2]]+$e[t[e+3]]+"-"+$e[t[e+4]]+$e[t[e+5]]+"-"+$e[t[e+6]]+$e[t[e+7]]+"-"+$e[t[e+8]]+$e[t[e+9]]+"-"+$e[t[e+10]]+$e[t[e+11]]+$e[t[e+12]]+$e[t[e+13]]+$e[t[e+14]]+$e[t[e+15]]).toLowerCase();if(!Ls(n))throw TypeError("Stringified UUID is invalid");return n}function yn(t,e,n){t=t||{};var r=t.random||(t.rng||Hp)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,zp(r)}const jt=Object.create(null);jt.open="0";jt.close="1";jt.ping="2";jt.pong="3";jt.message="4";jt.upgrade="5";jt.noop="6";const xi=Object.create(null);Object.keys(jt).forEach(t=>{xi[jt[t]]=t});const Ns={type:"error",data:"parser error"},zu=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",qu=typeof ArrayBuffer=="function",Vu=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,_a=({type:t,data:e},n,r)=>zu&&e instanceof Blob?n?r(e):mc(e,r):qu&&(e instanceof ArrayBuffer||Vu(e))?n?r(e):mc(new Blob([e]),r):r(jt[t]+(e||"")),mc=(t,e)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];e("b"+(r||""))},n.readAsDataURL(t)};function gc(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let jo;function qp(t,e){if(zu&&t.data instanceof Blob)return t.data.arrayBuffer().then(gc).then(e);if(qu&&(t.data instanceof ArrayBuffer||Vu(t.data)))return e(gc(t.data));_a(t,!1,n=>{jo||(jo=new TextEncoder),e(jo.encode(n))})}const yc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Er=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t<yc.length;t++)Er[yc.charCodeAt(t)]=t;const Vp=t=>{let e=t.length*.75,n=t.length,r,i=0,o,a,s,c;t[t.length-1]==="="&&(e--,t[t.length-2]==="="&&e--);const l=new ArrayBuffer(e),u=new Uint8Array(l);for(r=0;r<n;r+=4)o=Er[t.charCodeAt(r)],a=Er[t.charCodeAt(r+1)],s=Er[t.charCodeAt(r+2)],c=Er[t.charCodeAt(r+3)],u[i++]=o<<2|a>>4,u[i++]=(a&15)<<4|s>>2,u[i++]=(s&3)<<6|c&63;return l},Wp=typeof ArrayBuffer=="function",Sa=(t,e)=>{if(typeof t!="string")return{type:"message",data:Wu(t,e)};const n=t.charAt(0);return n==="b"?{type:"message",data:Gp(t.substring(1),e)}:xi[n]?t.length>1?{type:xi[n],data:t.substring(1)}:{type:xi[n]}:Ns},Gp=(t,e)=>{if(Wp){const n=Vp(t);return Wu(n,e)}else return{base64:!0,data:t}},Wu=(t,e)=>{switch(e){case"blob":return t instanceof Blob?t:new Blob([t]);case"arraybuffer":default:return t instanceof ArrayBuffer?t:t.buffer}},Gu="",Yp=(t,e)=>{const n=t.length,r=new Array(n);let i=0;t.forEach((o,a)=>{_a(o,!1,s=>{r[a]=s,++i===n&&e(r.join(Gu))})})},Zp=(t,e)=>{const n=t.split(Gu),r=[];for(let i=0;i<n.length;i++){const o=Sa(n[i],e);if(r.push(o),o.type==="error")break}return r};function Jp(){return new TransformStream({transform(t,e){qp(t,n=>{const r=n.length;let i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);const o=new DataView(i.buffer);o.setUint8(0,126),o.setUint16(1,r)}else{i=new Uint8Array(9);const o=new DataView(i.buffer);o.setUint8(0,127),o.setBigUint64(1,BigInt(r))}t.data&&typeof t.data!="string"&&(i[0]|=128),e.enqueue(i),e.enqueue(n)})}})}let Uo;function ri(t){return t.reduce((e,n)=>e+n.length,0)}function ii(t,e){if(t[0].length===e)return t.shift();const n=new Uint8Array(e);let r=0;for(let i=0;i<e;i++)n[i]=t[0][r++],r===t[0].length&&(t.shift(),r=0);return t.length&&r<t[0].length&&(t[0]=t[0].slice(r)),n}function Xp(t,e){Uo||(Uo=new TextDecoder);const n=[];let r=0,i=-1,o=!1;return new TransformStream({transform(a,s){for(n.push(a);;){if(r===0){if(ri(n)<1)break;const c=ii(n,1);o=(c[0]&128)===128,i=c[0]&127,i<126?r=3:i===126?r=1:r=2}else if(r===1){if(ri(n)<2)break;const c=ii(n,2);i=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),r=3}else if(r===2){if(ri(n)<8)break;const c=ii(n,8),l=new DataView(c.buffer,c.byteOffset,c.length),u=l.getUint32(0);if(u>Math.pow(2,21)-1){s.enqueue(Ns);break}i=u*Math.pow(2,32)+l.getUint32(4),r=3}else{if(ri(n)<i)break;const c=ii(n,i);s.enqueue(Sa(o?c:Uo.decode(c),e)),r=0}if(i===0||i>t){s.enqueue(Ns);break}}}})}const Yu=4;function Oe(t){if(t)return Qp(t)}function Qp(t){for(var e in Oe.prototype)t[e]=Oe.prototype[e];return t}Oe.prototype.on=Oe.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this};Oe.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this};Oe.prototype.off=Oe.prototype.removeListener=Oe.prototype.removeAllListeners=Oe.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+t];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+t],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===e||r.fn===e){n.splice(i,1);break}return n.length===0&&delete this._callbacks["$"+t],this};Oe.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),n=this._callbacks["$"+t],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,e)}return this};Oe.prototype.emitReserved=Oe.prototype.emit;Oe.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]};Oe.prototype.hasListeners=function(t){return!!this.listeners(t).length};const So=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,n)=>n(e,0),vt=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),e0="arraybuffer";function Zu(t,...e){return e.reduce((n,r)=>(t.hasOwnProperty(r)&&(n[r]=t[r]),n),{})}const t0=vt.setTimeout,n0=vt.clearTimeout;function Co(t,e){e.useNativeTimers?(t.setTimeoutFn=t0.bind(vt),t.clearTimeoutFn=n0.bind(vt)):(t.setTimeoutFn=vt.setTimeout.bind(vt),t.clearTimeoutFn=vt.clearTimeout.bind(vt))}const r0=1.33;function i0(t){return typeof t=="string"?o0(t):Math.ceil((t.byteLength||t.size)*r0)}function o0(t){let e=0,n=0;for(let r=0,i=t.length;r<i;r++)e=t.charCodeAt(r),e<128?n+=1:e<2048?n+=2:e<55296||e>=57344?n+=3:(r++,n+=4);return n}function Ju(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function s0(t){let e="";for(let n in t)t.hasOwnProperty(n)&&(e.length&&(e+="&"),e+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e}function a0(t){let e={},n=t.split("&");for(let r=0,i=n.length;r<i;r++){let o=n[r].split("=");e[decodeURIComponent(o[0])]=decodeURIComponent(o[1])}return e}class c0 extends Error{constructor(e,n,r){super(e),this.description=n,this.context=r,this.type="TransportError"}}class Ca extends Oe{constructor(e){super(),this.writable=!1,Co(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,n,r){return super.emitReserved("error",new c0(e,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const n=Sa(e,this.socket.binaryType);this.onPacket(n)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,n={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const n=s0(e);return n.length?"?"+n:""}}class l0 extends Ca{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const n=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};Zp(e,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,Yp(e,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=Ju()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(e,n)}}let Xu=!1;try{Xu=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const u0=Xu;function d0(){}class h0 extends l0{constructor(e){if(super(e),typeof location<"u"){const n=location.protocol==="https:";let r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||r!==e.port}}doWrite(e,n){const r=this.request({method:"POST",data:e});r.on("success",n),r.on("error",(i,o)=>{this.onError("xhr post error",i,o)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=e}}class Bt extends Oe{constructor(e,n,r){super(),this.createRequest=e,Co(this,r),this._opts=r,this._method=r.method||"GET",this._uri=n,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var e;const n=Zu(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let i in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(i)&&r.setRequestHeader(i,this._opts.extraHeaders[i])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var i;r.readyState===3&&((i=this._opts.cookieJar)===null||i===void 0||i.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(i){this.setTimeoutFn(()=>{this._onError(i)},0);return}typeof document<"u"&&(this._index=Bt.requestsCount++,Bt.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=d0,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Bt.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}Bt.requestsCount=0;Bt.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",vc);else if(typeof addEventListener=="function"){const t="onpagehide"in vt?"pagehide":"unload";addEventListener(t,vc,!1)}}function vc(){for(let t in Bt.requests)Bt.requests.hasOwnProperty(t)&&Bt.requests[t].abort()}const f0=function(){const t=Qu({xdomain:!1});return t&&t.responseType!==null}();class p0 extends h0{constructor(e){super(e);const n=e&&e.forceBase64;this.supportsBinary=f0&&!n}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new Bt(Qu,this.uri(),e)}}function Qu(t){const e=t.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||u0))return new XMLHttpRequest}catch{}if(!e)try{return new vt[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const ed=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class m0 extends Ca{get name(){return"websocket"}doOpen(){const e=this.uri(),n=this.opts.protocols,r=ed?{}:Zu(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,n,r)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const r=e[n],i=n===e.length-1;_a(r,this.supportsBinary,o=>{try{this.doWrite(r,o)}catch{}i&&So(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=Ju()),this.supportsBinary||(n.b64=1),this.createUri(e,n)}}const Ho=vt.WebSocket||vt.MozWebSocket;class g0 extends m0{createSocket(e,n,r){return ed?new Ho(e,n,r):n?new Ho(e,n):new Ho(e)}doWrite(e,n){this.ws.send(n)}}class y0 extends Ca{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const n=Xp(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(n).getReader(),i=Jp();i.readable.pipeTo(e.writable),this._writer=i.writable.getWriter();const o=()=>{r.read().then(({done:s,value:c})=>{s||(this.onPacket(c),o())}).catch(s=>{})};o();const a={type:"open"};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this._writer.write(a).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const r=e[n],i=n===e.length-1;this._writer.write(r).then(()=>{i&&So(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const v0={websocket:g0,webtransport:y0,polling:p0},b0=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,w0=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Ds(t){if(t.length>8e3)throw"URI too long";const e=t,n=t.indexOf("["),r=t.indexOf("]");n!=-1&&r!=-1&&(t=t.substring(0,n)+t.substring(n,r).replace(/:/g,";")+t.substring(r,t.length));let i=b0.exec(t||""),o={},a=14;for(;a--;)o[w0[a]]=i[a]||"";return n!=-1&&r!=-1&&(o.source=e,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=E0(o,o.path),o.queryKey=_0(o,o.query),o}function E0(t,e){const n=/\/{2,9}/g,r=e.replace(n,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&r.splice(0,1),e.slice(-1)=="/"&&r.splice(r.length-1,1),r}function _0(t,e){const n={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,i,o){i&&(n[i]=o)}),n}const Bs=typeof addEventListener=="function"&&typeof removeEventListener=="function",Ti=[];Bs&&addEventListener("offline",()=>{Ti.forEach(t=>t())},!1);class _n extends Oe{constructor(e,n){if(super(),this.binaryType=e0,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(n=e,e=null),e){const r=Ds(e);n.hostname=r.host,n.secure=r.protocol==="https"||r.protocol==="wss",n.port=r.port,r.query&&(n.query=r.query)}else n.host&&(n.hostname=Ds(n.host).host);Co(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(r=>{const i=r.prototype.name;this.transports.push(i),this._transportsByName[i]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=a0(this.opts.query)),Bs&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Ti.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const n=Object.assign({},this.opts.query);n.EIO=Yu,n.transport=e,this.id&&(n.sid=this.id);const r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const e=this.opts.rememberUpgrade&&_n.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(e);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",_n.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=e.data,this._onError(n);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){const i=this.writeBuffer[r].data;if(i&&(n+=i0(i)),r>0&&n>this._maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,So(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,n,r){return this._sendPacket("message",e,n,r),this}send(e,n,r){return this._sendPacket("message",e,n,r),this}_sendPacket(e,n,r,i){if(typeof n=="function"&&(i=n,n=void 0),typeof r=="function"&&(i=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const o={type:e,data:n,options:r};this.emitReserved("packetCreate",o),this.writeBuffer.push(o),i&&this.once("flush",i),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),e()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():e()}):this.upgrading?r():e()),this}_onError(e){if(_n.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Bs&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=Ti.indexOf(this._offlineEventListener);r!==-1&&Ti.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,n),this.writeBuffer=[],this._prevBufferLen=0}}}_n.protocol=Yu;class S0 extends _n{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let n=this.createTransport(e),r=!1;_n.priorWebsocketSuccess=!1;const i=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",d=>{if(!r)if(d.type==="pong"&&d.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;_n.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(u(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const h=new Error("probe error");h.transport=n.name,this.emitReserved("upgradeError",h)}}))};function o(){r||(r=!0,u(),n.close(),n=null)}const a=d=>{const h=new Error("probe error: "+d);h.transport=n.name,o(),this.emitReserved("upgradeError",h)};function s(){a("transport closed")}function c(){a("socket closed")}function l(d){n&&d.name!==n.name&&o()}const u=()=>{n.removeListener("open",i),n.removeListener("error",a),n.removeListener("close",s),this.off("close",c),this.off("upgrading",l)};n.once("open",i),n.once("error",a),n.once("close",s),this.once("close",c),this.once("upgrading",l),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const n=[];for(let r=0;r<e.length;r++)~this.transports.indexOf(e[r])&&n.push(e[r]);return n}}let C0=class extends S0{constructor(e,n={}){const r=typeof e=="object"?e:n;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(i=>v0[i]).filter(i=>!!i)),super(e,r)}};function k0(t,e="",n){let r=t;n=n||typeof location<"u"&&location,t==null&&(t=n.protocol+"//"+n.host),typeof t=="string"&&(t.charAt(0)==="/"&&(t.charAt(1)==="/"?t=n.protocol+t:t=n.host+t),/^(https?|wss?):\/\//.test(t)||(typeof n<"u"?t=n.protocol+"//"+t:t="https://"+t),r=Ds(t)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const o=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+o+":"+r.port+e,r.href=r.protocol+"://"+o+(n&&n.port===r.port?"":":"+r.port),r}const A0=typeof ArrayBuffer=="function",x0=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,td=Object.prototype.toString,T0=typeof Blob=="function"||typeof Blob<"u"&&td.call(Blob)==="[object BlobConstructor]",M0=typeof File=="function"||typeof File<"u"&&td.call(File)==="[object FileConstructor]";function ka(t){return A0&&(t instanceof ArrayBuffer||x0(t))||T0&&t instanceof Blob||M0&&t instanceof File}function Mi(t,e){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let n=0,r=t.length;n<r;n++)if(Mi(t[n]))return!0;return!1}if(ka(t))return!0;if(t.toJSON&&typeof t.toJSON=="function"&&arguments.length===1)return Mi(t.toJSON(),!0);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&Mi(t[n]))return!0;return!1}function R0(t){const e=[],n=t.data,r=t;return r.data=$s(n,e),r.attachments=e.length,{packet:r,buffers:e}}function $s(t,e){if(!t)return t;if(ka(t)){const n={_placeholder:!0,num:e.length};return e.push(t),n}else if(Array.isArray(t)){const n=new Array(t.length);for(let r=0;r<t.length;r++)n[r]=$s(t[r],e);return n}else if(typeof t=="object"&&!(t instanceof Date)){const n={};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=$s(t[r],e));return n}return t}function O0(t,e){return t.data=Ks(t.data,e),delete t.attachments,t}function Ks(t,e){if(!t)return t;if(t&&t._placeholder===!0){if(typeof t.num=="number"&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}else if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]=Ks(t[n],e);else if(typeof t=="object")for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(t[n]=Ks(t[n],e));return t}const P0=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var ye;(function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"})(ye||(ye={}));class I0{constructor(e){this.replacer=e}encode(e){return(e.type===ye.EVENT||e.type===ye.ACK)&&Mi(e)?this.encodeAsBinary({type:e.type===ye.EVENT?ye.BINARY_EVENT:ye.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let n=""+e.type;return(e.type===ye.BINARY_EVENT||e.type===ye.BINARY_ACK)&&(n+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(n+=e.nsp+","),e.id!=null&&(n+=e.id),e.data!=null&&(n+=JSON.stringify(e.data,this.replacer)),n}encodeAsBinary(e){const n=R0(e),r=this.encodeAsString(n.packet),i=n.buffers;return i.unshift(r),i}}class Aa extends Oe{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e=="function"?{reviver:e}:e)}add(e){let n;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(e);const r=n.type===ye.BINARY_EVENT;r||n.type===ye.BINARY_ACK?(n.type=r?ye.EVENT:ye.ACK,this.reconstructor=new L0(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(ka(e)||e.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(e),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let n=0;const r={type:Number(e.charAt(0))};if(ye[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===ye.BINARY_EVENT||r.type===ye.BINARY_ACK){const o=n+1;for(;e.charAt(++n)!=="-"&&n!=e.length;);const a=e.substring(o,n);if(a!=Number(a)||e.charAt(n)!=="-")throw new Error("Illegal attachments");const s=Number(a);if(!N0(s)||s<0)throw new Error("Illegal attachments");if(s>this.opts.maxAttachments)throw new Error("too many attachments");r.attachments=s}if(e.charAt(n+1)==="/"){const o=n+1;for(;++n&&!(e.charAt(n)===","||n===e.length););r.nsp=e.substring(o,n)}else r.nsp="/";const i=e.charAt(n+1);if(i!==""&&Number(i)==i){const o=n+1;for(;++n;){const a=e.charAt(n);if(a==null||Number(a)!=a){--n;break}if(n===e.length)break}r.id=Number(e.substring(o,n+1))}if(e.charAt(++n)){const o=this.tryParse(e.substr(n));if(Aa.isPayloadValid(r.type,o))r.data=o;else throw new Error("invalid payload")}return r}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,n){switch(e){case ye.CONNECT:return bc(n);case ye.DISCONNECT:return n===void 0;case ye.CONNECT_ERROR:return typeof n=="string"||bc(n);case ye.EVENT:case ye.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&P0.indexOf(n[0])===-1);case ye.ACK:case ye.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class L0{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const n=O0(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const N0=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t};function bc(t){return Object.prototype.toString.call(t)==="[object Object]"}const D0=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Aa,Encoder:I0,get PacketType(){return ye}},Symbol.toStringTag,{value:"Module"}));function _t(t,e,n){return t.on(e,n),function(){t.off(e,n)}}const B0=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class nd extends Oe{constructor(e,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[_t(e,"open",this.onopen.bind(this)),_t(e,"packet",this.onpacket.bind(this)),_t(e,"error",this.onerror.bind(this)),_t(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...n){var r,i,o;if(B0.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(n.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const a={type:ye.EVENT,data:n};if(a.options={},a.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const u=this.ids++,d=n.pop();this._registerAckCallback(u,d),a.id=u}const s=(i=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||i===void 0?void 0:i.writable,c=this.connected&&!(!((o=this.io.engine)===null||o===void 0)&&o._hasPingExpired());return this.flags.volatile&&!s||(c?(this.notifyOutgoingListeners(a),this.packet(a)):this.sendBuffer.push(a)),this.flags={},this}_registerAckCallback(e,n){var r;const i=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(i===void 0){this.acks[e]=n;return}const o=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let s=0;s<this.sendBuffer.length;s++)this.sendBuffer[s].id===e&&this.sendBuffer.splice(s,1);n.call(this,new Error("operation has timed out"))},i),a=(...s)=>{this.io.clearTimeoutFn(o),n.apply(this,s)};a.withError=!0,this.acks[e]=a}emitWithAck(e,...n){return new Promise((r,i)=>{const o=(a,s)=>a?i(a):r(s);o.withError=!0,n.push(o),this.emit(e,...n)})}_addToQueue(e){let n;typeof e[e.length-1]=="function"&&(n=e.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((i,...o)=>(this._queue[0],i!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(i)):(this._queue.shift(),n&&n(null,...o)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!e||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:ye.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(r=>String(r.id)===e)){const r=this.acks[e];delete this.acks[e],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case ye.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case ye.EVENT:case ye.BINARY_EVENT:this.onevent(e);break;case ye.ACK:case ye.BINARY_ACK:this.onack(e);break;case ye.DISCONNECT:this.ondisconnect();break;case ye.CONNECT_ERROR:this.destroy();const r=new Error(e.data.message);r.data=e.data.data,this.emitReserved("connect_error",r);break}}onevent(e){const n=e.data||[];e.id!=null&&n.push(this.ack(e.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const r of n)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const n=this;let r=!1;return function(...i){r||(r=!0,n.packet({type:ye.ACK,id:e,data:i}))}}onack(e){const n=this.acks[e.id];typeof n=="function"&&(delete this.acks[e.id],n.withError&&e.data.unshift(null),n.apply(this,e.data))}onconnect(e,n){this.id=e,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:ye.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const n=this._anyListeners;for(let r=0;r<n.length;r++)if(e===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(e===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const r of n)r.apply(this,e.data)}}}function dr(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}dr.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),n=Math.floor(e*this.jitter*t);t=Math.floor(e*10)&1?t+n:t-n}return Math.min(t,this.max)|0};dr.prototype.reset=function(){this.attempts=0};dr.prototype.setMin=function(t){this.ms=t};dr.prototype.setMax=function(t){this.max=t};dr.prototype.setJitter=function(t){this.jitter=t};class js extends Oe{constructor(e,n){var r;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(n=e,e=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,Co(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new dr({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=e;const i=n.parser||D0;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var n;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(n=this.backoff)===null||n===void 0||n.setMin(e),this)}randomizationFactor(e){var n;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(n=this.backoff)===null||n===void 0||n.setJitter(e),this)}reconnectionDelayMax(e){var n;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(n=this.backoff)===null||n===void 0||n.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new C0(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const i=_t(n,"open",function(){r.onopen(),e&&e()}),o=s=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",s),e?e(s):this.maybeReconnectOnOpen()},a=_t(n,"error",o);if(this._timeout!==!1){const s=this._timeout,c=this.setTimeoutFn(()=>{i(),o(new Error("timeout")),n.close()},s);this.opts.autoUnref&&c.unref(),this.subs.push(()=>{this.clearTimeoutFn(c)})}return this.subs.push(i),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(_t(e,"ping",this.onping.bind(this)),_t(e,"data",this.ondata.bind(this)),_t(e,"error",this.onerror.bind(this)),_t(e,"close",this.onclose.bind(this)),_t(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(n){this.onclose("parse error",n)}}ondecoded(e){So(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,n){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new nd(this,e,n),this.nsps[e]=r),r}_destroy(e){const n=Object.keys(this.nsps);for(const r of n)if(this.nsps[r].active)return;this._close()}_packet(e){const n=this.encoder.encode(e);for(let r=0;r<n.length;r++)this.engine.write(n[r],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,n){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(i=>{i?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",i)):e.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const mr={};function Ri(t,e){typeof t=="object"&&(e=t,t=void 0),e=e||{};const n=k0(t,e.path||"/socket.io"),r=n.source,i=n.id,o=n.path,a=mr[i]&&o in mr[i].nsps,s=e.forceNew||e["force new connection"]||e.multiplex===!1||a;let c;return s?c=new js(r,e):(mr[i]||(mr[i]=new js(r,e)),c=mr[i]),n.query&&!e.query&&(e.query=n.queryKey),c.socket(n.path,e)}Object.assign(Ri,{Manager:js,Socket:nd,io:Ri,connect:Ri});function Z(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(l){try{c(r.next(l))}catch(u){o(u)}}function s(l){try{c(r.throw(l))}catch(u){o(u)}}function c(l){var u;l.done?i(l.value):(u=l.value,u instanceof n?u:new n(function(d){d(u)})).then(a,s)}c((r=r.apply(t,e||[])).next())})}var Je=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{},Rt=[],mt=[],$0=typeof Uint8Array<"u"?Uint8Array:Array,xa=!1;function rd(){xa=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0;e<64;++e)Rt[e]=t[e],mt[t.charCodeAt(e)]=e;mt[45]=62,mt[95]=63}function K0(t,e,n){for(var r,i,o=[],a=e;a<n;a+=3)r=(t[a]<<16)+(t[a+1]<<8)+t[a+2],o.push(Rt[(i=r)>>18&63]+Rt[i>>12&63]+Rt[i>>6&63]+Rt[63&i]);return o.join("")}function wc(t){var e;xa||rd();for(var n=t.length,r=n%3,i="",o=[],a=16383,s=0,c=n-r;s<c;s+=a)o.push(K0(t,s,s+a>c?c:s+a));return r===1?(e=t[n-1],i+=Rt[e>>2],i+=Rt[e<<4&63],i+="=="):r===2&&(e=(t[n-2]<<8)+t[n-1],i+=Rt[e>>10],i+=Rt[e>>4&63],i+=Rt[e<<2&63],i+="="),o.push(i),o.join("")}function oi(t,e,n,r,i){var o,a,s=8*i-r-1,c=(1<<s)-1,l=c>>1,u=-7,d=n?i-1:0,h=n?-1:1,f=t[e+d];for(d+=h,o=f&(1<<-u)-1,f>>=-u,u+=s;u>0;o=256*o+t[e+d],d+=h,u-=8);for(a=o&(1<<-u)-1,o>>=-u,u+=r;u>0;a=256*a+t[e+d],d+=h,u-=8);if(o===0)o=1-l;else{if(o===c)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,r),o-=l}return(f?-1:1)*a*Math.pow(2,o-r)}function id(t,e,n,r,i,o){var a,s,c,l=8*o-i-1,u=(1<<l)-1,d=u>>1,h=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:o-1,g=r?1:-1,m=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=u):(a=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-a))<1&&(a--,c*=2),(e+=a+d>=1?h/c:h*Math.pow(2,1-d))*c>=2&&(a++,c/=2),a+d>=u?(s=0,a=u):a+d>=1?(s=(e*c-1)*Math.pow(2,i),a+=d):(s=e*Math.pow(2,d-1)*Math.pow(2,i),a=0));i>=8;t[n+f]=255&s,f+=g,s/=256,i-=8);for(a=a<<i|s,l+=i;l>0;t[n+f]=255&a,f+=g,a/=256,l-=8);t[n+f-g]|=128*m}var j0={}.toString,od=Array.isArray||function(t){return j0.call(t)=="[object Array]"};X.TYPED_ARRAY_SUPPORT=Je.TYPED_ARRAY_SUPPORT===void 0||Je.TYPED_ARRAY_SUPPORT;var U0=Gi();function Gi(){return X.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Yt(t,e){if(Gi()<e)throw new RangeError("Invalid typed array length");return X.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=X.prototype:(t===null&&(t=new X(e)),t.length=e),t}function X(t,e,n){if(!(X.TYPED_ARRAY_SUPPORT||this instanceof X))return new X(t,e,n);if(typeof t=="number"){if(typeof e=="string")throw new Error("If encoding is specified then the first argument must be a string");return Us(this,t)}return sd(this,t,e,n)}function sd(t,e,n,r){if(typeof e=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer?function(i,o,a,s){if(o.byteLength,a<0||o.byteLength<a)throw new RangeError("'offset' is out of bounds");if(o.byteLength<a+(s||0))throw new RangeError("'length' is out of bounds");return o=a===void 0&&s===void 0?new Uint8Array(o):s===void 0?new Uint8Array(o,a):new Uint8Array(o,a,s),X.TYPED_ARRAY_SUPPORT?(i=o).__proto__=X.prototype:i=Fo(i,o),i}(t,e,n,r):typeof e=="string"?function(i,o,a){if(typeof a=="string"&&a!==""||(a="utf8"),!X.isEncoding(a))throw new TypeError('"encoding" must be a valid string encoding');var s=0|cd(o,a);i=Yt(i,s);var c=i.write(o,a);return c!==s&&(i=i.slice(0,c)),i}(t,e,n):function(i,o){if(Ot(o)){var a=0|Ta(o.length);return(i=Yt(i,a)).length===0||o.copy(i,0,0,a),i}if(o){if(typeof ArrayBuffer<"u"&&o.buffer instanceof ArrayBuffer||"length"in o)return typeof o.length!="number"||(s=o.length)!=s?Yt(i,0):Fo(i,o);if(o.type==="Buffer"&&od(o.data))return Fo(i,o.data)}var s;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function ad(t){if(typeof t!="number")throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function Us(t,e){if(ad(e),t=Yt(t,e<0?0:0|Ta(e)),!X.TYPED_ARRAY_SUPPORT)for(var n=0;n<e;++n)t[n]=0;return t}function Fo(t,e){var n=e.length<0?0:0|Ta(e.length);t=Yt(t,n);for(var r=0;r<n;r+=1)t[r]=255&e[r];return t}function Ta(t){if(t>=Gi())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Gi().toString(16)+" bytes");return 0|t}function Ot(t){return!(t==null||!t._isBuffer)}function cd(t,e){if(Ot(t))return t.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;typeof t!="string"&&(t=""+t);var n=t.length;if(n===0)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return Yi(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return hd(t).length;default:if(r)return Yi(t).length;e=(""+e).toLowerCase(),r=!0}}function H0(t,e,n){var r=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return J0(this,e,n);case"utf8":case"utf-8":return ud(this,e,n);case"ascii":return Y0(this,e,n);case"latin1":case"binary":return Z0(this,e,n);case"base64":return G0(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return X0(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function Tn(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function Ec(t,e,n,r,i){if(t.length===0)return-1;if(typeof n=="string"?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if(typeof e=="string"&&(e=X.from(e,r)),Ot(e))return e.length===0?-1:_c(t,e,n,r,i);if(typeof e=="number")return e&=255,X.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):_c(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function _c(t,e,n,r,i){var o,a=1,s=t.length,c=e.length;if(r!==void 0&&((r=String(r).toLowerCase())==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(t.length<2||e.length<2)return-1;a=2,s/=2,c/=2,n/=2}function l(f,g){return a===1?f[g]:f.readUInt16BE(g*a)}if(i){var u=-1;for(o=n;o<s;o++)if(l(t,o)===l(e,u===-1?0:o-u)){if(u===-1&&(u=o),o-u+1===c)return u*a}else u!==-1&&(o-=o-u),u=-1}else for(n+c>s&&(n=s-c),o=n;o>=0;o--){for(var d=!0,h=0;h<c;h++)if(l(t,o+h)!==l(e,h)){d=!1;break}if(d)return o}return-1}function F0(t,e,n,r){n=Number(n)||0;var i=t.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var a=0;a<r;++a){var s=parseInt(e.substr(2*a,2),16);if(isNaN(s))return a;t[n+a]=s}return a}function z0(t,e,n,r){return ko(Yi(e,t.length-n),t,n,r)}function ld(t,e,n,r){return ko(function(i){for(var o=[],a=0;a<i.length;++a)o.push(255&i.charCodeAt(a));return o}(e),t,n,r)}function q0(t,e,n,r){return ld(t,e,n,r)}function V0(t,e,n,r){return ko(hd(e),t,n,r)}function W0(t,e,n,r){return ko(function(i,o){for(var a,s,c,l=[],u=0;u<i.length&&!((o-=2)<0);++u)s=(a=i.charCodeAt(u))>>8,c=a%256,l.push(c),l.push(s);return l}(e,t.length-n),t,n,r)}function G0(t,e,n){return e===0&&n===t.length?wc(t):wc(t.slice(e,n))}function ud(t,e,n){n=Math.min(t.length,n);for(var r=[],i=e;i<n;){var o,a,s,c,l=t[i],u=null,d=l>239?4:l>223?3:l>191?2:1;if(i+d<=n)switch(d){case 1:l<128&&(u=l);break;case 2:(192&(o=t[i+1]))==128&&(c=(31&l)<<6|63&o)>127&&(u=c);break;case 3:o=t[i+1],a=t[i+2],(192&o)==128&&(192&a)==128&&(c=(15&l)<<12|(63&o)<<6|63&a)>2047&&(c<55296||c>57343)&&(u=c);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],(192&o)==128&&(192&a)==128&&(192&s)==128&&(c=(15&l)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&c<1114112&&(u=c)}u===null?(u=65533,d=1):u>65535&&(u-=65536,r.push(u>>>10&1023|55296),u=56320|1023&u),r.push(u),i+=d}return function(h){var f=h.length;if(f<=Sc)return String.fromCharCode.apply(String,h);for(var g="",m=0;m<f;)g+=String.fromCharCode.apply(String,h.slice(m,m+=Sc));return g}(r)}X.poolSize=8192,X._augment=function(t){return t.__proto__=X.prototype,t},X.from=function(t,e,n){return sd(null,t,e,n)},X.TYPED_ARRAY_SUPPORT&&(X.prototype.__proto__=Uint8Array.prototype,X.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&X[Symbol.species]),X.alloc=function(t,e,n){return function(r,i,o,a){return ad(i),i<=0?Yt(r,i):o!==void 0?typeof a=="string"?Yt(r,i).fill(o,a):Yt(r,i).fill(o):Yt(r,i)}(null,t,e,n)},X.allocUnsafe=function(t){return Us(null,t)},X.allocUnsafeSlow=function(t){return Us(null,t)},X.isBuffer=fd,X.compare=function(t,e){if(!Ot(t)||!Ot(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,r=e.length,i=0,o=Math.min(n,r);i<o;++i)if(t[i]!==e[i]){n=t[i],r=e[i];break}return n<r?-1:r<n?1:0},X.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},X.concat=function(t,e){if(!od(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return X.alloc(0);var n;if(e===void 0)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=X.allocUnsafe(e),i=0;for(n=0;n<t.length;++n){var o=t[n];if(!Ot(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,i),i+=o.length}return r},X.byteLength=cd,X.prototype._isBuffer=!0,X.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)Tn(this,e,e+1);return this},X.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)Tn(this,e,e+3),Tn(this,e+1,e+2);return this},X.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)Tn(this,e,e+7),Tn(this,e+1,e+6),Tn(this,e+2,e+5),Tn(this,e+3,e+4);return this},X.prototype.toString=function(){var t=0|this.length;return t===0?"":arguments.length===0?ud(this,0,t):H0.apply(this,arguments)},X.prototype.equals=function(t){if(!Ot(t))throw new TypeError("Argument must be a Buffer");return this===t||X.compare(this,t)===0},X.prototype.inspect=function(){var t="";return this.length>0&&(t=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(t+=" ... ")),"<Buffer "+t+">"},X.prototype.compare=function(t,e,n,r,i){if(!Ot(t))throw new TypeError("Argument must be a Buffer");if(e===void 0&&(e=0),n===void 0&&(n=t?t.length:0),r===void 0&&(r=0),i===void 0&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(r>>>=0),a=(n>>>=0)-(e>>>=0),s=Math.min(o,a),c=this.slice(r,i),l=t.slice(e,n),u=0;u<s;++u)if(c[u]!==l[u]){o=c[u],a=l[u];break}return o<a?-1:a<o?1:0},X.prototype.includes=function(t,e,n){return this.indexOf(t,e,n)!==-1},X.prototype.indexOf=function(t,e,n){return Ec(this,t,e,n,!0)},X.prototype.lastIndexOf=function(t,e,n){return Ec(this,t,e,n,!1)},X.prototype.write=function(t,e,n,r){if(e===void 0)r="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(n)?(n|=0,r===void 0&&(r="utf8")):(r=n,n=void 0)}var i=this.length-e;if((n===void 0||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return F0(this,t,e,n);case"utf8":case"utf-8":return z0(this,t,e,n);case"ascii":return ld(this,t,e,n);case"latin1":case"binary":return q0(this,t,e,n);case"base64":return V0(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return W0(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},X.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Sc=4096;function Y0(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;i<n;++i)r+=String.fromCharCode(127&t[i]);return r}function Z0(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;i<n;++i)r+=String.fromCharCode(t[i]);return r}function J0(t,e,n){var r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);for(var i="",o=e;o<n;++o)i+=em(t[o]);return i}function X0(t,e,n){for(var r=t.slice(e,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function Ie(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function Xe(t,e,n,r,i,o){if(!Ot(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function si(t,e,n,r){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-n,2);i<o;++i)t[n+i]=(e&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function ai(t,e,n,r){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-n,4);i<o;++i)t[n+i]=e>>>8*(r?i:3-i)&255}function dd(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Cc(t,e,n,r,i){return i||dd(t,0,n,4),id(t,e,n,r,23,4),n+4}function kc(t,e,n,r,i){return i||dd(t,0,n,8),id(t,e,n,r,52,8),n+8}X.prototype.slice=function(t,e){var n,r=this.length;if((t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=e===void 0?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t),X.TYPED_ARRAY_SUPPORT)(n=this.subarray(t,e)).__proto__=X.prototype;else{var i=e-t;n=new X(i,void 0);for(var o=0;o<i;++o)n[o]=this[o+t]}return n},X.prototype.readUIntLE=function(t,e,n){t|=0,e|=0,n||Ie(t,e,this.length);for(var r=this[t],i=1,o=0;++o<e&&(i*=256);)r+=this[t+o]*i;return r},X.prototype.readUIntBE=function(t,e,n){t|=0,e|=0,n||Ie(t,e,this.length);for(var r=this[t+--e],i=1;e>0&&(i*=256);)r+=this[t+--e]*i;return r},X.prototype.readUInt8=function(t,e){return e||Ie(t,1,this.length),this[t]},X.prototype.readUInt16LE=function(t,e){return e||Ie(t,2,this.length),this[t]|this[t+1]<<8},X.prototype.readUInt16BE=function(t,e){return e||Ie(t,2,this.length),this[t]<<8|this[t+1]},X.prototype.readUInt32LE=function(t,e){return e||Ie(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},X.prototype.readUInt32BE=function(t,e){return e||Ie(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},X.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||Ie(t,e,this.length);for(var r=this[t],i=1,o=0;++o<e&&(i*=256);)r+=this[t+o]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*e)),r},X.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||Ie(t,e,this.length);for(var r=e,i=1,o=this[t+--r];r>0&&(i*=256);)o+=this[t+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},X.prototype.readInt8=function(t,e){return e||Ie(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},X.prototype.readInt16LE=function(t,e){e||Ie(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},X.prototype.readInt16BE=function(t,e){e||Ie(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},X.prototype.readInt32LE=function(t,e){return e||Ie(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},X.prototype.readInt32BE=function(t,e){return e||Ie(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},X.prototype.readFloatLE=function(t,e){return e||Ie(t,4,this.length),oi(this,t,!0,23,4)},X.prototype.readFloatBE=function(t,e){return e||Ie(t,4,this.length),oi(this,t,!1,23,4)},X.prototype.readDoubleLE=function(t,e){return e||Ie(t,8,this.length),oi(this,t,!0,52,8)},X.prototype.readDoubleBE=function(t,e){return e||Ie(t,8,this.length),oi(this,t,!1,52,8)},X.prototype.writeUIntLE=function(t,e,n,r){t=+t,e|=0,n|=0,r||Xe(this,t,e,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[e]=255&t;++o<n&&(i*=256);)this[e+o]=t/i&255;return e+n},X.prototype.writeUIntBE=function(t,e,n,r){t=+t,e|=0,n|=0,r||Xe(this,t,e,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+n},X.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||Xe(this,t,e,1,255,0),X.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},X.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||Xe(this,t,e,2,65535,0),X.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):si(this,t,e,!0),e+2},X.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||Xe(this,t,e,2,65535,0),X.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):si(this,t,e,!1),e+2},X.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||Xe(this,t,e,4,4294967295,0),X.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):ai(this,t,e,!0),e+4},X.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||Xe(this,t,e,4,4294967295,0),X.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):ai(this,t,e,!1),e+4},X.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);Xe(this,t,e,n,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o<n&&(a*=256);)t<0&&s===0&&this[e+o-1]!==0&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+n},X.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);Xe(this,t,e,n,i-1,-i)}var o=n-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&s===0&&this[e+o+1]!==0&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+n},X.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||Xe(this,t,e,1,127,-128),X.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},X.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||Xe(this,t,e,2,32767,-32768),X.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):si(this,t,e,!0),e+2},X.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||Xe(this,t,e,2,32767,-32768),X.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):si(this,t,e,!1),e+2},X.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||Xe(this,t,e,4,2147483647,-2147483648),X.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):ai(this,t,e,!0),e+4},X.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||Xe(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),X.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):ai(this,t,e,!1),e+4},X.prototype.writeFloatLE=function(t,e,n){return Cc(this,t,e,!0,n)},X.prototype.writeFloatBE=function(t,e,n){return Cc(this,t,e,!1,n)},X.prototype.writeDoubleLE=function(t,e,n){return kc(this,t,e,!0,n)},X.prototype.writeDoubleBE=function(t,e,n){return kc(this,t,e,!1,n)},X.prototype.copy=function(t,e,n,r){if(n||(n=0),r||r===0||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var i,o=r-n;if(this===t&&n<e&&e<r)for(i=o-1;i>=0;--i)t[i+e]=this[i+n];else if(o<1e3||!X.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)t[i+e]=this[i+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+o),e);return o},X.prototype.fill=function(t,e,n,r){if(typeof t=="string"){if(typeof e=="string"?(r=e,e=0,n=this.length):typeof n=="string"&&(r=n,n=this.length),t.length===1){var i=t.charCodeAt(0);i<256&&(t=i)}if(r!==void 0&&typeof r!="string")throw new TypeError("encoding must be a string");if(typeof r=="string"&&!X.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else typeof t=="number"&&(t&=255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;var o;if(e>>>=0,n=n===void 0?this.length:n>>>0,t||(t=0),typeof t=="number")for(o=e;o<n;++o)this[o]=t;else{var a=Ot(t)?t:Yi(new X(t,r).toString()),s=a.length;for(o=0;o<n-e;++o)this[o+e]=a[o%s]}return this};var Q0=/[^+\/0-9A-Za-z-_]/g;function em(t){return t<16?"0"+t.toString(16):t.toString(16)}function Yi(t,e){var n;e=e||1/0;for(var r=t.length,i=null,o=[],a=0;a<r;++a){if((n=t.charCodeAt(a))>55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function hd(t){return function(e){var n,r,i,o,a,s;xa||rd();var c=e.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");a=e[c-2]==="="?2:e[c-1]==="="?1:0,s=new $0(3*c/4-a),i=a>0?c-4:c;var l=0;for(n=0,r=0;n<i;n+=4,r+=3)o=mt[e.charCodeAt(n)]<<18|mt[e.charCodeAt(n+1)]<<12|mt[e.charCodeAt(n+2)]<<6|mt[e.charCodeAt(n+3)],s[l++]=o>>16&255,s[l++]=o>>8&255,s[l++]=255&o;return a===2?(o=mt[e.charCodeAt(n)]<<2|mt[e.charCodeAt(n+1)]>>4,s[l++]=255&o):a===1&&(o=mt[e.charCodeAt(n)]<<10|mt[e.charCodeAt(n+1)]<<4|mt[e.charCodeAt(n+2)]>>2,s[l++]=o>>8&255,s[l++]=255&o),s}(function(e){if((e=function(n){return n.trim?n.trim():n.replace(/^\s+|\s+$/g,"")}(e).replace(Q0,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(t))}function ko(t,e,n,r){for(var i=0;i<r&&!(i+n>=e.length||i>=t.length);++i)e[i+n]=t[i];return i}function fd(t){return t!=null&&(!!t._isBuffer||Ac(t)||function(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&Ac(e.slice(0,0))}(t))}function Ac(t){return!!t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}var tm=Object.freeze({__proto__:null,Buffer:X,INSPECT_MAX_BYTES:50,SlowBuffer:function(t){return+t!=t&&(t=0),X.alloc(+t)},isBuffer:fd,kMaxLength:U0}),bt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ao(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Zr(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}),n}var Wn={},lt={},ze={};function Zi(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function pd(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function md(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Ma(t,...e){if(!md(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function gd(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("hash must be wrapped by utils.wrapConstructor");Zi(t.outputLen),Zi(t.blockLen)}function yd(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function vd(t,e){Ma(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}Object.defineProperty(ze,"__esModule",{value:!0}),ze.isBytes=md,ze.number=Zi,ze.bool=pd,ze.bytes=Ma,ze.hash=gd,ze.exists=yd,ze.output=vd;const nm={number:Zi,bool:pd,bytes:Ma,hash:gd,exists:yd,output:vd};ze.default=nm,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.wrapCipher=t.Hash=t.nextTick=t.isLE=t.createView=t.u32=t.u16=t.u8=void 0,t.bytesToHex=r,t.hexToBytes=a,t.hexToNumber=s,t.bytesToNumberBE=function(d){return s(r(d))},t.numberToBytesBE=function(d,h){return a(d.toString(16).padStart(2*h,"0"))},t.asyncLoop=async function(d,h,f){let g=Date.now();for(let m=0;m<d;m++){f(m);const w=Date.now()-g;w>=0&&w<h||(await(0,t.nextTick)(),g+=w)}},t.utf8ToBytes=c,t.bytesToUtf8=function(d){return new TextDecoder().decode(d)},t.toBytes=function(d){if(typeof d=="string")d=c(d);else{if(!(0,e.isBytes)(d))throw new Error("Uint8Array expected, got "+typeof d);d=u(d)}return d},t.concatBytes=function(...d){let h=0;for(let g=0;g<d.length;g++){const m=d[g];(0,e.bytes)(m),h+=m.length}const f=new Uint8Array(h);for(let g=0,m=0;g<d.length;g++){const w=d[g];f.set(w,m),m+=w.length}return f},t.checkOpts=function(d,h){if(h==null||typeof h!="object")throw new Error("options must be defined");return Object.assign(d,h)},t.equalBytes=function(d,h){if(d.length!==h.length)return!1;let f=0;for(let g=0;g<d.length;g++)f|=d[g]^h[g];return f===0},t.setBigUint64=l,t.u64Lengths=function(d,h){const f=new Uint8Array(16),g=(0,t.createView)(f);return l(g,0,BigInt(h?h.length:0),!0),l(g,8,BigInt(d.length),!0),f},t.isAligned32=function(d){return d.byteOffset%4==0},t.copyBytes=u,t.clean=function(...d){for(let h=0;h<d.length;h++)d[h].fill(0)};const e=ze;if(t.u8=d=>new Uint8Array(d.buffer,d.byteOffset,d.byteLength),t.u16=d=>new Uint16Array(d.buffer,d.byteOffset,Math.floor(d.byteLength/2)),t.u32=d=>new Uint32Array(d.buffer,d.byteOffset,Math.floor(d.byteLength/4)),t.createView=d=>new DataView(d.buffer,d.byteOffset,d.byteLength),t.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,!t.isLE)throw new Error("Non little-endian hardware is not supported");const n=Array.from({length:256},(d,h)=>h.toString(16).padStart(2,"0"));function r(d){(0,e.bytes)(d);let h="";for(let f=0;f<d.length;f++)h+=n[d[f]];return h}const i={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function o(d){return d>=i._0&&d<=i._9?d-i._0:d>=i._A&&d<=i._F?d-(i._A-10):d>=i._a&&d<=i._f?d-(i._a-10):void 0}function a(d){if(typeof d!="string")throw new Error("hex string expected, got "+typeof d);const h=d.length,f=h/2;if(h%2)throw new Error("padded hex string expected, got unpadded hex of length "+h);const g=new Uint8Array(f);for(let m=0,w=0;m<f;m++,w+=2){const p=o(d.charCodeAt(w)),S=o(d.charCodeAt(w+1));if(p===void 0||S===void 0){const _=d[w]+d[w+1];throw new Error('hex string expected, got non-hex character "'+_+'" at index '+w)}g[m]=16*p+S}return g}function s(d){if(typeof d!="string")throw new Error("hex string expected, got "+typeof d);return BigInt(d===""?"0":`0x${d}`)}function c(d){if(typeof d!="string")throw new Error("string expected, got "+typeof d);return new Uint8Array(new TextEncoder().encode(d))}t.nextTick=async()=>{},t.Hash=class{};function l(d,h,f,g){if(typeof d.setBigUint64=="function")return d.setBigUint64(h,f,g);const m=BigInt(32),w=BigInt(4294967295),p=Number(f>>m&w),S=Number(f&w),_=g?4:0,O=g?0:4;d.setUint32(h+_,p,g),d.setUint32(h+O,S,g)}function u(d){return Uint8Array.from(d)}t.wrapCipher=(d,h)=>(Object.assign(h,d),h)}(lt);var Lr={},Le={};Object.defineProperty(Le,"__esModule",{value:!0}),Le.AEAD_TAG_LENGTH=Le.XCHACHA20_NONCE_LENGTH=Le.CURVE25519_PUBLIC_KEY_SIZE=Le.ETH_PUBLIC_KEY_SIZE=Le.UNCOMPRESSED_PUBLIC_KEY_SIZE=Le.COMPRESSED_PUBLIC_KEY_SIZE=Le.SECRET_KEY_LENGTH=void 0,Le.SECRET_KEY_LENGTH=32,Le.COMPRESSED_PUBLIC_KEY_SIZE=33,Le.UNCOMPRESSED_PUBLIC_KEY_SIZE=65,Le.ETH_PUBLIC_KEY_SIZE=64,Le.CURVE25519_PUBLIC_KEY_SIZE=32,Le.XCHACHA20_NONCE_LENGTH=24,Le.AEAD_TAG_LENGTH=16,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ephemeralKeySize=t.symmetricNonceLength=t.symmetricAlgorithm=t.isHkdfKeyCompressed=t.isEphemeralKeyCompressed=t.ellipticCurve=t.ECIES_CONFIG=void 0;var e=Le,n=function(){this.ellipticCurve="secp256k1",this.isEphemeralKeyCompressed=!1,this.isHkdfKeyCompressed=!1,this.symmetricAlgorithm="aes-256-gcm",this.symmetricNonceLength=16};t.ECIES_CONFIG=new n,t.ellipticCurve=function(){return t.ECIES_CONFIG.ellipticCurve},t.isEphemeralKeyCompressed=function(){return t.ECIES_CONFIG.isEphemeralKeyCompressed},t.isHkdfKeyCompressed=function(){return t.ECIES_CONFIG.isHkdfKeyCompressed},t.symmetricAlgorithm=function(){return t.ECIES_CONFIG.symmetricAlgorithm},t.symmetricNonceLength=function(){return t.ECIES_CONFIG.symmetricNonceLength},t.ephemeralKeySize=function(){var r={secp256k1:t.ECIES_CONFIG.isEphemeralKeyCompressed?e.COMPRESSED_PUBLIC_KEY_SIZE:e.UNCOMPRESSED_PUBLIC_KEY_SIZE,x25519:e.CURVE25519_PUBLIC_KEY_SIZE,ed25519:e.CURVE25519_PUBLIC_KEY_SIZE};if(t.ECIES_CONFIG.ellipticCurve in r)return r[t.ECIES_CONFIG.ellipticCurve];throw new Error("Not implemented")}}(Lr);var zo={},Ji={},xo={},bd={},Ra={},ci={};Object.defineProperty(ci,"__esModule",{value:!0}),ci.crypto=void 0,ci.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.gcm=t.ctr=t.cbc=t.utils=void 0,t.randomBytes=i,t.getWebcryptoSubtle=o,t.managedNonce=function(c){return(0,n.number)(c.nonceLength),(l,...u)=>({encrypt(d,...h){const{nonceLength:f}=c,g=i(f),m=c(l,g,...u).encrypt(d,...h),w=(0,r.concatBytes)(g,m);return m.fill(0),w},decrypt(d,...h){const{nonceLength:f}=c,g=d.subarray(0,f),m=d.subarray(f);return c(l,g,...u).decrypt(m,...h)}})};const e=ci,n=ze,r=lt;function i(c=32){if(e.crypto&&typeof e.crypto.getRandomValues=="function")return e.crypto.getRandomValues(new Uint8Array(c));if(e.crypto&&typeof e.crypto.randomBytes=="function")return e.crypto.randomBytes(c);throw new Error("crypto.getRandomValues must be defined")}function o(){if(e.crypto&&typeof e.crypto.subtle=="object"&&e.crypto.subtle!=null)return e.crypto.subtle;throw new Error("crypto.subtle must be defined")}t.utils={async encrypt(c,l,u,d){const h=o(),f=await h.importKey("raw",c,l,!0,["encrypt"]),g=await h.encrypt(u,f,d);return new Uint8Array(g)},async decrypt(c,l,u,d){const h=o(),f=await h.importKey("raw",c,l,!0,["decrypt"]),g=await h.decrypt(u,f,d);return new Uint8Array(g)}};const a={CBC:"AES-CBC",CTR:"AES-CTR",GCM:"AES-GCM"};function s(c){return(l,u,d)=>{(0,n.bytes)(l),(0,n.bytes)(u);const h={name:c,length:8*l.length},f=function(g,m,w){if(g===a.CBC)return{name:a.CBC,iv:m};if(g===a.CTR)return{name:a.CTR,counter:m,length:64};if(g===a.GCM)return w?{name:a.GCM,iv:m,additionalData:w}:{name:a.GCM,iv:m};throw new Error("unknown aes block mode")}(c,u,d);return{encrypt:g=>((0,n.bytes)(g),t.utils.encrypt(l,h,f,g)),decrypt:g=>((0,n.bytes)(g),t.utils.decrypt(l,h,f,g))}}}t.cbc=s(a.CBC),t.ctr=s(a.CTR),t.gcm=s(a.GCM)}(Ra);var wd={},Ne={},Zt={},at={};function Xi(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function Ed(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function _d(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Oa(t,...e){if(!_d(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function Sd(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Xi(t.outputLen),Xi(t.blockLen)}function Cd(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function kd(t,e){Oa(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}Object.defineProperty(at,"__esModule",{value:!0}),at.isBytes=_d,at.number=Xi,at.bool=Ed,at.bytes=Oa,at.hash=Sd,at.exists=Cd,at.output=kd;const rm={number:Xi,bool:Ed,bytes:Oa,hash:Sd,exists:Cd,output:kd};at.default=rm;var tn={},li={};Object.defineProperty(li,"__esModule",{value:!0}),li.crypto=void 0,li.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Hash=t.nextTick=t.byteSwapIfBE=t.byteSwap=t.isLE=t.rotl=t.rotr=t.createView=t.u32=t.u8=void 0,t.isBytes=function(l){return l instanceof Uint8Array||l!=null&&typeof l=="object"&&l.constructor.name==="Uint8Array"},t.byteSwap32=function(l){for(let u=0;u<l.length;u++)l[u]=(0,t.byteSwap)(l[u])},t.bytesToHex=function(l){(0,n.bytes)(l);let u="";for(let d=0;d<l.length;d++)u+=r[l[d]];return u},t.hexToBytes=function(l){if(typeof l!="string")throw new Error("hex string expected, got "+typeof l);const u=l.length,d=u/2;if(u%2)throw new Error("padded hex string expected, got unpadded hex of length "+u);const h=new Uint8Array(d);for(let f=0,g=0;f<d;f++,g+=2){const m=o(l.charCodeAt(g)),w=o(l.charCodeAt(g+1));if(m===void 0||w===void 0){const p=l[g]+l[g+1];throw new Error('hex string expected, got non-hex character "'+p+'" at index '+g)}h[f]=16*m+w}return h},t.asyncLoop=async function(l,u,d){let h=Date.now();for(let f=0;f<l;f++){d(f);const g=Date.now()-h;g>=0&&g<u||(await(0,t.nextTick)(),h+=g)}},t.utf8ToBytes=a,t.toBytes=s,t.concatBytes=function(...l){let u=0;for(let h=0;h<l.length;h++){const f=l[h];(0,n.bytes)(f),u+=f.length}const d=new Uint8Array(u);for(let h=0,f=0;h<l.length;h++){const g=l[h];d.set(g,f),f+=g.length}return d},t.checkOpts=function(l,u){if(u!==void 0&&c.call(u)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(l,u)},t.wrapConstructor=function(l){const u=h=>l().update(s(h)).digest(),d=l();return u.outputLen=d.outputLen,u.blockLen=d.blockLen,u.create=()=>l(),u},t.wrapConstructorWithOpts=function(l){const u=(h,f)=>l(f).update(s(h)).digest(),d=l({});return u.outputLen=d.outputLen,u.blockLen=d.blockLen,u.create=h=>l(h),u},t.wrapXOFConstructorWithOpts=function(l){const u=(h,f)=>l(f).update(s(h)).digest(),d=l({});return u.outputLen=d.outputLen,u.blockLen=d.blockLen,u.create=h=>l(h),u},t.randomBytes=function(l=32){if(e.crypto&&typeof e.crypto.getRandomValues=="function")return e.crypto.getRandomValues(new Uint8Array(l));if(e.crypto&&typeof e.crypto.randomBytes=="function")return e.crypto.randomBytes(l);throw new Error("crypto.getRandomValues must be defined")};const e=li,n=at;t.u8=l=>new Uint8Array(l.buffer,l.byteOffset,l.byteLength),t.u32=l=>new Uint32Array(l.buffer,l.byteOffset,Math.floor(l.byteLength/4)),t.createView=l=>new DataView(l.buffer,l.byteOffset,l.byteLength),t.rotr=(l,u)=>l<<32-u|l>>>u,t.rotl=(l,u)=>l<<u|l>>>32-u>>>0,t.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,t.byteSwap=l=>l<<24&4278190080|l<<8&16711680|l>>>8&65280|l>>>24&255,t.byteSwapIfBE=t.isLE?l=>l:l=>(0,t.byteSwap)(l);const r=Array.from({length:256},(l,u)=>u.toString(16).padStart(2,"0")),i={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function o(l){return l>=i._0&&l<=i._9?l-i._0:l>=i._A&&l<=i._F?l-(i._A-10):l>=i._a&&l<=i._f?l-(i._a-10):void 0}function a(l){if(typeof l!="string")throw new Error("utf8ToBytes expected string, got "+typeof l);return new Uint8Array(new TextEncoder().encode(l))}function s(l){return typeof l=="string"&&(l=a(l)),(0,n.bytes)(l),l}t.nextTick=async()=>{},t.Hash=class{clone(){return this._cloneInto()}};const c={}.toString}(tn),Object.defineProperty(Zt,"__esModule",{value:!0}),Zt.HashMD=Zt.Maj=Zt.Chi=void 0;const qo=at,gr=tn;Zt.Chi=(t,e,n)=>t&e^~t&n;Zt.Maj=(t,e,n)=>t&e^t&n^e&n;Zt.HashMD=class extends gr.Hash{constructor(t,e,n,r){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,gr.createView)(this.buffer)}update(t){(0,qo.exists)(this);const{view:e,buffer:n,blockLen:r}=this,i=(t=(0,gr.toBytes)(t)).length;for(let o=0;o<i;){const a=Math.min(r-this.pos,i-o);if(a!==r)n.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===r&&(this.process(e,0),this.pos=0);else{const s=(0,gr.createView)(t);for(;r<=i-o;o+=r)this.process(s,o)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,qo.exists)(this),(0,qo.output)(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:r,isLE:i}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>r-o&&(this.process(n,0),o=0);for(let u=o;u<r;u++)e[u]=0;(function(u,d,h,f){if(typeof u.setBigUint64=="function")return u.setBigUint64(d,h,f);const g=BigInt(32),m=BigInt(4294967295),w=Number(h>>g&m),p=Number(h&m),S=f?4:0,_=f?0:4;u.setUint32(d+S,w,f),u.setUint32(d+_,p,f)})(n,r-8,BigInt(8*this.length),i),this.process(n,0);const a=(0,gr.createView)(t),s=this.outputLen;if(s%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=s/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<c;u++)a.setUint32(4*u,l[u],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:r,finished:i,destroyed:o,pos:a}=this;return t.length=r,t.pos=a,t.finished=i,t.destroyed=o,r%e&&t.buffer.set(n),t}};var he={};Object.defineProperty(he,"__esModule",{value:!0}),he.add5L=he.add5H=he.add4H=he.add4L=he.add3H=he.add3L=he.rotlBL=he.rotlBH=he.rotlSL=he.rotlSH=he.rotr32L=he.rotr32H=he.rotrBL=he.rotrBH=he.rotrSL=he.rotrSH=he.shrSL=he.shrSH=he.toBig=void 0,he.fromBig=Pa,he.split=Ad,he.add=jd;const ui=BigInt(2**32-1),Hs=BigInt(32);function Pa(t,e=!1){return e?{h:Number(t&ui),l:Number(t>>Hs&ui)}:{h:0|Number(t>>Hs&ui),l:0|Number(t&ui)}}function Ad(t,e=!1){let n=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:o,l:a}=Pa(t[i],e);[n[i],r[i]]=[o,a]}return[n,r]}const xd=(t,e)=>BigInt(t>>>0)<<Hs|BigInt(e>>>0);he.toBig=xd;const Td=(t,e,n)=>t>>>n;he.shrSH=Td;const Md=(t,e,n)=>t<<32-n|e>>>n;he.shrSL=Md;const Rd=(t,e,n)=>t>>>n|e<<32-n;he.rotrSH=Rd;const Od=(t,e,n)=>t<<32-n|e>>>n;he.rotrSL=Od;const Pd=(t,e,n)=>t<<64-n|e>>>n-32;he.rotrBH=Pd;const Id=(t,e,n)=>t>>>n-32|e<<64-n;he.rotrBL=Id;const Ld=(t,e)=>e;he.rotr32H=Ld;const Nd=(t,e)=>t;he.rotr32L=Nd;const Dd=(t,e,n)=>t<<n|e>>>32-n;he.rotlSH=Dd;const Bd=(t,e,n)=>e<<n|t>>>32-n;he.rotlSL=Bd;const $d=(t,e,n)=>e<<n-32|t>>>64-n;he.rotlBH=$d;const Kd=(t,e,n)=>t<<n-32|e>>>64-n;function jd(t,e,n,r){const i=(e>>>0)+(r>>>0);return{h:t+n+(i/2**32|0)|0,l:0|i}}he.rotlBL=Kd;const Ud=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0);he.add3L=Ud;const Hd=(t,e,n,r)=>e+n+r+(t/2**32|0)|0;he.add3H=Hd;const Fd=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0);he.add4L=Fd;const zd=(t,e,n,r,i)=>e+n+r+i+(t/2**32|0)|0;he.add4H=zd;const qd=(t,e,n,r,i)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(i>>>0);he.add5L=qd;const Vd=(t,e,n,r,i,o)=>e+n+r+i+o+(t/2**32|0)|0;he.add5H=Vd;const im={fromBig:Pa,split:Ad,toBig:xd,shrSH:Td,shrSL:Md,rotrSH:Rd,rotrSL:Od,rotrBH:Pd,rotrBL:Id,rotr32H:Ld,rotr32L:Nd,rotlSH:Dd,rotlSL:Bd,rotlBH:$d,rotlBL:Kd,add:jd,add3L:Ud,add3H:Hd,add4L:Fd,add4H:zd,add5H:Vd,add5L:qd};he.default=im,Object.defineProperty(Ne,"__esModule",{value:!0}),Ne.sha384=Ne.sha512_256=Ne.sha512_224=Ne.sha512=Ne.SHA384=Ne.SHA512_256=Ne.SHA512_224=Ne.SHA512=void 0;const om=Zt,fe=he,di=tn,[sm,am]=fe.default.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),nn=new Uint32Array(80),rn=new Uint32Array(80);class Jr extends om.HashMD{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:n,Bh:r,Bl:i,Ch:o,Cl:a,Dh:s,Dl:c,Eh:l,El:u,Fh:d,Fl:h,Gh:f,Gl:g,Hh:m,Hl:w}=this;return[e,n,r,i,o,a,s,c,l,u,d,h,f,g,m,w]}set(e,n,r,i,o,a,s,c,l,u,d,h,f,g,m,w){this.Ah=0|e,this.Al=0|n,this.Bh=0|r,this.Bl=0|i,this.Ch=0|o,this.Cl=0|a,this.Dh=0|s,this.Dl=0|c,this.Eh=0|l,this.El=0|u,this.Fh=0|d,this.Fl=0|h,this.Gh=0|f,this.Gl=0|g,this.Hh=0|m,this.Hl=0|w}process(e,n){for(let _=0;_<16;_++,n+=4)nn[_]=e.getUint32(n),rn[_]=e.getUint32(n+=4);for(let _=16;_<80;_++){const O=0|nn[_-15],I=0|rn[_-15],K=fe.default.rotrSH(O,I,1)^fe.default.rotrSH(O,I,8)^fe.default.shrSH(O,I,7),q=fe.default.rotrSL(O,I,1)^fe.default.rotrSL(O,I,8)^fe.default.shrSL(O,I,7),F=0|nn[_-2],U=0|rn[_-2],j=fe.default.rotrSH(F,U,19)^fe.default.rotrBH(F,U,61)^fe.default.shrSH(F,U,6),G=fe.default.rotrSL(F,U,19)^fe.default.rotrBL(F,U,61)^fe.default.shrSL(F,U,6),$=fe.default.add4L(q,G,rn[_-7],rn[_-16]),N=fe.default.add4H($,K,j,nn[_-7],nn[_-16]);nn[_]=0|N,rn[_]=0|$}let{Ah:r,Al:i,Bh:o,Bl:a,Ch:s,Cl:c,Dh:l,Dl:u,Eh:d,El:h,Fh:f,Fl:g,Gh:m,Gl:w,Hh:p,Hl:S}=this;for(let _=0;_<80;_++){const O=fe.default.rotrSH(d,h,14)^fe.default.rotrSH(d,h,18)^fe.default.rotrBH(d,h,41),I=fe.default.rotrSL(d,h,14)^fe.default.rotrSL(d,h,18)^fe.default.rotrBL(d,h,41),K=d&f^~d&m,q=h&g^~h&w,F=fe.default.add5L(S,I,q,am[_],rn[_]),U=fe.default.add5H(F,p,O,K,sm[_],nn[_]),j=0|F,G=fe.default.rotrSH(r,i,28)^fe.default.rotrBH(r,i,34)^fe.default.rotrBH(r,i,39),$=fe.default.rotrSL(r,i,28)^fe.default.rotrBL(r,i,34)^fe.default.rotrBL(r,i,39),N=r&o^r&s^o&s,R=i&a^i&c^a&c;p=0|m,S=0|w,m=0|f,w=0|g,f=0|d,g=0|h,{h:d,l:h}=fe.default.add(0|l,0|u,0|U,0|j),l=0|s,u=0|c,s=0|o,c=0|a,o=0|r,a=0|i;const C=fe.default.add3L(j,$,R);r=fe.default.add3H(C,U,G,N),i=0|C}({h:r,l:i}=fe.default.add(0|this.Ah,0|this.Al,0|r,0|i)),{h:o,l:a}=fe.default.add(0|this.Bh,0|this.Bl,0|o,0|a),{h:s,l:c}=fe.default.add(0|this.Ch,0|this.Cl,0|s,0|c),{h:l,l:u}=fe.default.add(0|this.Dh,0|this.Dl,0|l,0|u),{h:d,l:h}=fe.default.add(0|this.Eh,0|this.El,0|d,0|h),{h:f,l:g}=fe.default.add(0|this.Fh,0|this.Fl,0|f,0|g),{h:m,l:w}=fe.default.add(0|this.Gh,0|this.Gl,0|m,0|w),{h:p,l:S}=fe.default.add(0|this.Hh,0|this.Hl,0|p,0|S),this.set(r,i,o,a,s,c,l,u,d,h,f,g,m,w,p,S)}roundClean(){nn.fill(0),rn.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}Ne.SHA512=Jr;class Wd extends Jr{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}Ne.SHA512_224=Wd;class Gd extends Jr{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}Ne.SHA512_256=Gd;class xc extends Jr{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}Ne.SHA384=xc,Ne.sha512=(0,di.wrapConstructor)(()=>new Jr),Ne.sha512_224=(0,di.wrapConstructor)(()=>new Wd),Ne.sha512_256=(0,di.wrapConstructor)(()=>new Gd),Ne.sha384=(0,di.wrapConstructor)(()=>new xc);var Fs={},Yn={},Ce={},pe={};Object.defineProperty(pe,"__esModule",{value:!0}),pe.notImplemented=pe.bitMask=void 0,pe.isBytes=Qi,pe.abytes=eo,pe.abool=function(t,e){if(typeof e!="boolean")throw new Error(`${t} must be valid boolean, got "${e}".`)},pe.bytesToHex=Vo,pe.numberToHexUnpadded=Tc,pe.hexToNumber=Wo,pe.hexToBytes=Pi,pe.bytesToNumberBE=function(t){return Wo(Vo(t))},pe.bytesToNumberLE=function(t){return eo(t),Wo(Vo(Uint8Array.from(t).reverse()))},pe.numberToBytesBE=Rc,pe.numberToBytesLE=function(t,e){return Rc(t,e).reverse()},pe.numberToVarBytesBE=function(t){return Pi(Tc(t))},pe.ensureBytes=function(t,e,n){let r;if(typeof e=="string")try{r=Pi(e)}catch(o){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${o}`)}else{if(!Qi(e))throw new Error(`${t} must be hex string or Uint8Array`);r=Uint8Array.from(e)}const i=r.length;if(typeof n=="number"&&i!==n)throw new Error(`${t} expected ${n} bytes, got ${i}`);return r},pe.concatBytes=Oc,pe.equalBytes=function(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return n===0},pe.utf8ToBytes=function(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))},pe.inRange=Pc,pe.aInRange=function(t,e,n,r){if(!Pc(e,n,r))throw new Error(`expected valid ${t}: ${n} <= n < ${r}, got ${typeof e} ${e}`)},pe.bitLen=function(t){let e;for(e=0;t>zs;t>>=Oi,e+=1);return e},pe.bitGet=function(t,e){return t>>BigInt(e)&Oi},pe.bitSet=function(t,e,n){return t|(n?Oi:zs)<<BigInt(e)},pe.createHmacDrbg=function(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=Yo(t),i=Yo(t),o=0;const a=()=>{r.fill(1),i.fill(0),o=0},s=(...u)=>n(i,r,...u),c=(u=Yo())=>{i=s(Ic([0]),u),r=s(),u.length!==0&&(i=s(Ic([1]),u),r=s())},l=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const d=[];for(;u<e;){r=s();const h=r.slice();d.push(h),u+=r.length}return Oc(...d)};return(u,d)=>{let h;for(a(),c(u);!(h=d(l()));)c();return a(),h}},pe.validateObject=function(t,e,n={}){const r=(i,o,a)=>{const s=um[o];if(typeof s!="function")throw new Error(`Invalid validator "${o}", expected function`);const c=t[i];if(!(a&&c===void 0||s(c,t)))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${o}`)};for(const[i,o]of Object.entries(e))r(i,o,!1);for(const[i,o]of Object.entries(n))r(i,o,!0);return t},pe.memoized=function(t){const e=new WeakMap;return(n,...r)=>{const i=e.get(n);if(i!==void 0)return i;const o=t(n,...r);return e.set(n,o),o}};const zs=BigInt(0),Oi=BigInt(1),cm=BigInt(2);function Qi(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function eo(t){if(!Qi(t))throw new Error("Uint8Array expected")}const lm=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Vo(t){eo(t);let e="";for(let n=0;n<t.length;n++)e+=lm[t[n]];return e}function Tc(t){const e=t.toString(16);return 1&e.length?`0${e}`:e}function Wo(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}const Ft={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Mc(t){return t>=Ft._0&&t<=Ft._9?t-Ft._0:t>=Ft._A&&t<=Ft._F?t-(Ft._A-10):t>=Ft._a&&t<=Ft._f?t-(Ft._a-10):void 0}function Pi(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,n=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let i=0,o=0;i<n;i++,o+=2){const a=Mc(t.charCodeAt(o)),s=Mc(t.charCodeAt(o+1));if(a===void 0||s===void 0){const c=t[o]+t[o+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+o)}r[i]=16*a+s}return r}function Rc(t,e){return Pi(t.toString(16).padStart(2*e,"0"))}function Oc(...t){let e=0;for(let r=0;r<t.length;r++){const i=t[r];eo(i),e+=i.length}const n=new Uint8Array(e);for(let r=0,i=0;r<t.length;r++){const o=t[r];n.set(o,i),i+=o.length}return n}const Go=t=>typeof t=="bigint"&&zs<=t;function Pc(t,e,n){return Go(t)&&Go(e)&&Go(n)&&e<=t&&t<n}pe.bitMask=t=>(cm<<BigInt(t-1))-Oi;const Yo=t=>new Uint8Array(t),Ic=t=>Uint8Array.from(t),um={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Qi(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};pe.notImplemented=()=>{throw new Error("not implemented")},Object.defineProperty(Ce,"__esModule",{value:!0}),Ce.isNegativeLE=void 0,Ce.mod=ot,Ce.pow=Yd,Ce.pow2=function(t,e,n){let r=t;for(;e-- >De;)r*=r,r%=n;return r},Ce.invert=hi,Ce.tonelliShanks=Zd,Ce.FpSqrt=Dc,Ce.validateField=function(t){const e=hm.reduce((n,r)=>(n[r]="function",n),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});return(0,rt.validateObject)(t,e)},Ce.FpPow=Bc,Ce.FpInvertBatch=$c,Ce.FpDiv=function(t,e,n){return t.mul(e,typeof n=="bigint"?hi(n,t.ORDER):t.inv(n))},Ce.FpLegendre=Kc,Ce.FpIsSquare=function(t){const e=Kc(t.ORDER);return n=>{const r=e(t,n);return t.eql(r,t.ZERO)||t.eql(r,t.ONE)}},Ce.nLength=Zo,Ce.Field=function(t,e,n=!1,r={}){if(t<=De)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:i,nByteLength:o}=Zo(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const a=Dc(t),s=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:(0,rt.bitMask)(i),ZERO:De,ONE:ke,create:c=>ot(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("Invalid field element: expected bigint, got "+typeof c);return De<=c&&c<t},is0:c=>c===De,isOdd:c=>(c&ke)===ke,neg:c=>ot(-c,t),eql:(c,l)=>c===l,sqr:c=>ot(c*c,t),add:(c,l)=>ot(c+l,t),sub:(c,l)=>ot(c-l,t),mul:(c,l)=>ot(c*l,t),pow:(c,l)=>Bc(s,c,l),div:(c,l)=>ot(c*hi(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>hi(c,t),sqrt:r.sqrt||(c=>a(s,c)),invertBatch:c=>$c(s,c),cmov:(c,l,u)=>u?l:c,toBytes:c=>n?(0,rt.numberToBytesLE)(c,o):(0,rt.numberToBytesBE)(c,o),fromBytes:c=>{if(c.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${c.length}`);return n?(0,rt.bytesToNumberLE)(c):(0,rt.bytesToNumberBE)(c)}});return Object.freeze(s)},Ce.FpSqrtOdd=function(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");const n=t.sqrt(e);return t.isOdd(n)?n:t.neg(n)},Ce.FpSqrtEven=function(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");const n=t.sqrt(e);return t.isOdd(n)?t.neg(n):n},Ce.hashToPrivateScalar=function(t,e,n=!1){t=(0,rt.ensureBytes)("privateHash",t);const r=t.length,i=Zo(e).nByteLength+8;if(i<24||r<i||r>1024)throw new Error(`hashToPrivateScalar: expected ${i}-1024 bytes of input, got ${r}`);const o=n?(0,rt.bytesToNumberLE)(t):(0,rt.bytesToNumberBE)(t);return ot(o,e-ke)+ke},Ce.getFieldBytesLength=Vs,Ce.getMinHashLength=jc,Ce.mapHashToField=function(t,e,n=!1){const r=t.length,i=Vs(e),o=jc(e);if(r<16||r<o||r>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${r}`);const a=ot(n?(0,rt.bytesToNumberBE)(t):(0,rt.bytesToNumberLE)(t),e-ke)+ke;return n?(0,rt.numberToBytesLE)(a,i):(0,rt.numberToBytesBE)(a,i)};const rt=pe,De=BigInt(0),ke=BigInt(1),vn=BigInt(2),dm=BigInt(3),qs=BigInt(4),Lc=BigInt(5),Nc=BigInt(8);function ot(t,e){const n=t%e;return n>=De?n:e+n}function Yd(t,e,n){if(n<=De||e<De)throw new Error("Expected power/modulo > 0");if(n===ke)return De;let r=ke;for(;e>De;)e&ke&&(r=r*t%n),t=t*t%n,e>>=ke;return r}function hi(t,e){if(t===De||e<=De)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=ot(t,e),r=e,i=De,o=ke;for(;n!==De;){const a=r%n,s=i-o*(r/n);r=n,n=a,i=o,o=s}if(r!==ke)throw new Error("invert: does not exist");return ot(i,e)}function Zd(t){const e=(t-ke)/vn;let n,r,i;for(n=t-ke,r=0;n%vn===De;n/=vn,r++);for(i=vn;i<t&&Yd(i,e,t)!==t-ke;i++);if(r===1){const a=(t+ke)/qs;return function(s,c){const l=s.pow(c,a);if(!s.eql(s.sqr(l),c))throw new Error("Cannot find square root");return l}}const o=(n+ke)/vn;return function(a,s){if(a.pow(s,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let c=r,l=a.pow(a.mul(a.ONE,i),n),u=a.pow(s,o),d=a.pow(s,n);for(;!a.eql(d,a.ONE);){if(a.eql(d,a.ZERO))return a.ZERO;let h=1;for(let g=a.sqr(d);h<c&&!a.eql(g,a.ONE);h++)g=a.sqr(g);const f=a.pow(l,ke<<BigInt(c-h-1));l=a.sqr(f),u=a.mul(u,f),d=a.mul(d,l),c=h}return u}}function Dc(t){if(t%qs===dm){const e=(t+ke)/qs;return function(n,r){const i=n.pow(r,e);if(!n.eql(n.sqr(i),r))throw new Error("Cannot find square root");return i}}if(t%Nc===Lc){const e=(t-Lc)/Nc;return function(n,r){const i=n.mul(r,vn),o=n.pow(i,e),a=n.mul(r,o),s=n.mul(n.mul(a,vn),o),c=n.mul(a,n.sub(s,n.ONE));if(!n.eql(n.sqr(c),r))throw new Error("Cannot find square root");return c}}return Zd(t)}BigInt(9),BigInt(16);Ce.isNegativeLE=(t,e)=>(ot(t,e)&ke)===ke;const hm=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Bc(t,e,n){if(n<De)throw new Error("Expected power > 0");if(n===De)return t.ONE;if(n===ke)return e;let r=t.ONE,i=e;for(;n>De;)n&ke&&(r=t.mul(r,i)),i=t.sqr(i),n>>=ke;return r}function $c(t,e){const n=new Array(e.length),r=e.reduce((o,a,s)=>t.is0(a)?o:(n[s]=o,t.mul(o,a)),t.ONE),i=t.inv(r);return e.reduceRight((o,a,s)=>t.is0(a)?o:(n[s]=t.mul(o,n[s]),t.mul(o,a)),i),n}function Kc(t){const e=(t-ke)/vn;return(n,r)=>n.pow(r,e)}function Zo(t,e){const n=e!==void 0?e:t.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Vs(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function jc(t){const e=Vs(t);return e+Math.ceil(e/2)}Object.defineProperty(Yn,"__esModule",{value:!0}),Yn.wNAF=function(t,e){const n=(o,a)=>{const s=a.negate();return o?s:a},r=o=>{if(!Number.isSafeInteger(o)||o<=0||o>e)throw new Error(`Wrong window size=${o}, should be [1..${e}]`)},i=o=>(r(o),{windows:Math.ceil(e/o)+1,windowSize:2**(o-1)});return{constTimeNegate:n,unsafeLadder(o,a){let s=t.ZERO,c=o;for(;a>fm;)a&Jo&&(s=s.add(c)),c=c.double(),a>>=Jo;return s},precomputeWindow(o,a){const{windows:s,windowSize:c}=i(a),l=[];let u=o,d=u;for(let h=0;h<s;h++){d=u,l.push(d);for(let f=1;f<c;f++)d=d.add(u),l.push(d);u=d.double()}return l},wNAF(o,a,s){const{windows:c,windowSize:l}=i(o);let u=t.ZERO,d=t.BASE;const h=BigInt(2**o-1),f=2**o,g=BigInt(o);for(let m=0;m<c;m++){const w=m*l;let p=Number(s&h);s>>=g,p>l&&(p-=f,s+=Jo);const S=w,_=w+Math.abs(p)-1,O=m%2!=0,I=p<0;p===0?d=d.add(n(O,a[S])):u=u.add(n(I,a[_]))}return{p:u,f:d}},wNAFCached(o,a,s){const c=Fc.get(o)||1;let l=Xo.get(o);return l||(l=this.precomputeWindow(o,c),c!==1&&Xo.set(o,s(l))),this.wNAF(c,l,a)},setWindowSize(o,a){r(a),Fc.set(o,a),Xo.delete(o)}}},Yn.pippenger=function(t,e,n,r){if(!Array.isArray(n)||!Array.isArray(r)||r.length!==n.length)throw new Error("arrays of points and scalars must have equal length");r.forEach((u,d)=>{if(!e.isValid(u))throw new Error(`wrong scalar at index ${d}`)}),n.forEach((u,d)=>{if(!(u instanceof t))throw new Error(`wrong point at index ${d}`)});const i=(0,Hc.bitLen)(BigInt(n.length)),o=i>12?i-3:i>4?i-2:i?2:1,a=(1<<o)-1,s=new Array(a+1).fill(t.ZERO),c=Math.floor((e.BITS-1)/o)*o;let l=t.ZERO;for(let u=c;u>=0;u-=o){s.fill(t.ZERO);for(let h=0;h<r.length;h++){const f=r[h],g=Number(f>>BigInt(u)&BigInt(a));s[g]=s[g].add(n[h])}let d=t.ZERO;for(let h=s.length-1,f=t.ZERO;h>0;h--)f=f.add(s[h]),d=d.add(f);if(l=l.add(d),u!==0)for(let h=0;h<o;h++)l=l.double()}return l},Yn.validateBasic=function(t){return(0,Uc.validateField)(t.Fp),(0,Hc.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,Uc.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})};const Uc=Ce,Hc=pe,fm=BigInt(0),Jo=BigInt(1),Xo=new WeakMap,Fc=new WeakMap;Object.defineProperty(Fs,"__esModule",{value:!0}),Fs.twistedEdwards=function(t){const e=function(N){const R=(0,Qo.validateBasic)(N);return Qe.validateObject(N,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...R})}(t),{Fp:n,n:r,prehash:i,hash:o,randomBytes:a,nByteLength:s,h:c}=e,l=fi<<BigInt(8*s)-et,u=n.create,d=(0,zc.Field)(e.n,e.nBitLength),h=e.uvRatio||((N,R)=>{try{return{isValid:!0,value:n.sqrt(N*n.inv(R))}}catch{return{isValid:!1,value:wt}}}),f=e.adjustScalarBytes||(N=>N),g=e.domain||((N,R,C)=>{if((0,it.abool)("phflag",C),R.length||C)throw new Error("Contexts/pre-hash are not supported");return N});function m(N,R){Qe.aInRange("coordinate "+N,R,wt,l)}function w(N){if(!(N instanceof _))throw new Error("ExtendedPoint expected")}const p=(0,it.memoized)((N,R)=>{const{ex:C,ey:P,ez:D}=N,y=N.is0();R==null&&(R=y?pm:n.inv(D));const E=u(C*R),A=u(P*R),T=u(D*R);if(y)return{x:wt,y:et};if(T!==et)throw new Error("invZ was invalid");return{x:E,y:A}}),S=(0,it.memoized)(N=>{const{a:R,d:C}=e;if(N.is0())throw new Error("bad point: ZERO");const{ex:P,ey:D,ez:y,et:E}=N,A=u(P*P),T=u(D*D),b=u(y*y),v=u(b*b),k=u(A*R);if(u(b*u(k+T))!==u(v+u(C*u(A*T))))throw new Error("bad point: equation left != right (1)");if(u(P*D)!==u(y*E))throw new Error("bad point: equation left != right (2)");return!0});class _{constructor(R,C,P,D){this.ex=R,this.ey=C,this.ez=P,this.et=D,m("x",R),m("y",C),m("z",P),m("t",D),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(R){if(R instanceof _)throw new Error("extended point not allowed");const{x:C,y:P}=R||{};return m("x",C),m("y",P),new _(C,P,et,u(C*P))}static normalizeZ(R){const C=n.invertBatch(R.map(P=>P.ez));return R.map((P,D)=>P.toAffine(C[D])).map(_.fromAffine)}static msm(R,C){return(0,Qo.pippenger)(_,d,R,C)}_setWindowSize(R){K.setWindowSize(this,R)}assertValidity(){S(this)}equals(R){w(R);const{ex:C,ey:P,ez:D}=this,{ex:y,ey:E,ez:A}=R,T=u(C*A),b=u(y*D),v=u(P*A),k=u(E*D);return T===b&&v===k}is0(){return this.equals(_.ZERO)}negate(){return new _(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){const{a:R}=e,{ex:C,ey:P,ez:D}=this,y=u(C*C),E=u(P*P),A=u(fi*u(D*D)),T=u(R*y),b=C+P,v=u(u(b*b)-y-E),k=T+E,x=k-A,M=T-E,L=u(v*x),B=u(k*M),H=u(v*M),z=u(x*k);return new _(L,B,z,H)}add(R){w(R);const{a:C,d:P}=e,{ex:D,ey:y,ez:E,et:A}=this,{ex:T,ey:b,ez:v,et:k}=R;if(C===BigInt(-1)){const ie=u((y-D)*(b+T)),ce=u((y+D)*(b-T)),ae=u(ce-ie);if(ae===wt)return this.double();const ge=u(E*fi*k),Ee=u(A*fi*v),de=Ee+ge,me=ce+ie,ve=Ee-ge,Pe=u(de*ae),ut=u(me*ve),Lo=u(de*ve),No=u(ae*me);return new _(Pe,ut,No,Lo)}const x=u(D*T),M=u(y*b),L=u(A*P*k),B=u(E*v),H=u((D+y)*(T+b)-x-M),z=B-L,J=B+L,Q=u(M-C*x),ne=u(H*z),se=u(J*Q),le=u(H*Q),re=u(z*J);return new _(ne,se,re,le)}subtract(R){return this.add(R.negate())}wNAF(R){return K.wNAFCached(this,R,_.normalizeZ)}multiply(R){const C=R;Qe.aInRange("scalar",C,et,r);const{p:P,f:D}=this.wNAF(C);return _.normalizeZ([P,D])[0]}multiplyUnsafe(R){const C=R;return Qe.aInRange("scalar",C,wt,r),C===wt?I:this.equals(I)||C===et?this:this.equals(O)?this.wNAF(C).p:K.unsafeLadder(this,C)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return K.unsafeLadder(this,r).is0()}toAffine(R){return p(this,R)}clearCofactor(){const{h:R}=e;return R===et?this:this.multiplyUnsafe(R)}static fromHex(R,C=!1){const{d:P,a:D}=e,y=n.BYTES;R=(0,it.ensureBytes)("pointHex",R,y),(0,it.abool)("zip215",C);const E=R.slice(),A=R[y-1];E[y-1]=-129&A;const T=Qe.bytesToNumberLE(E),b=C?l:n.ORDER;Qe.aInRange("pointHex.y",T,wt,b);const v=u(T*T),k=u(v-et),x=u(P*v-D);let{isValid:M,value:L}=h(k,x);if(!M)throw new Error("Point.fromHex: invalid y coordinate");const B=(L&et)===et,H=(128&A)!=0;if(!C&&L===wt&&H)throw new Error("Point.fromHex: x=0 and x_0=1");return H!==B&&(L=u(-L)),_.fromAffine({x:L,y:T})}static fromPrivateKey(R){return U(R).point}toRawBytes(){const{x:R,y:C}=this.toAffine(),P=Qe.numberToBytesLE(C,n.BYTES);return P[P.length-1]|=R&et?128:0,P}toHex(){return Qe.bytesToHex(this.toRawBytes())}}_.BASE=new _(e.Gx,e.Gy,et,u(e.Gx*e.Gy)),_.ZERO=new _(wt,et,et,wt);const{BASE:O,ZERO:I}=_,K=(0,Qo.wNAF)(_,8*s);function q(N){return(0,zc.mod)(N,r)}function F(N){return q(Qe.bytesToNumberLE(N))}function U(N){const R=s;N=(0,it.ensureBytes)("private key",N,R);const C=(0,it.ensureBytes)("hashed private key",o(N),2*R),P=f(C.slice(0,R)),D=C.slice(R,2*R),y=F(P),E=O.multiply(y),A=E.toRawBytes();return{head:P,prefix:D,scalar:y,point:E,pointBytes:A}}function j(N=new Uint8Array,...R){const C=Qe.concatBytes(...R);return F(o(g(C,(0,it.ensureBytes)("context",N),!!i)))}const G=mm;return O._setWindowSize(8),{CURVE:e,getPublicKey:function(N){return U(N).pointBytes},sign:function(N,R,C={}){N=(0,it.ensureBytes)("message",N),i&&(N=i(N));const{prefix:P,scalar:D,pointBytes:y}=U(R),E=j(C.context,P,N),A=O.multiply(E).toRawBytes(),T=q(E+j(C.context,A,y,N)*D);Qe.aInRange("signature.s",T,wt,r);const b=Qe.concatBytes(A,Qe.numberToBytesLE(T,n.BYTES));return(0,it.ensureBytes)("result",b,2*s)},verify:function(N,R,C,P=G){const{context:D,zip215:y}=P,E=n.BYTES;N=(0,it.ensureBytes)("signature",N,2*E),R=(0,it.ensureBytes)("message",R),y!==void 0&&(0,it.abool)("zip215",y),i&&(R=i(R));const A=Qe.bytesToNumberLE(N.slice(E,2*E));let T,b,v;try{T=_.fromHex(C,y),b=_.fromHex(N.slice(0,E),y),v=O.multiplyUnsafe(A)}catch{return!1}if(!y&&T.isSmallOrder())return!1;const k=j(D,b.toRawBytes(),T.toRawBytes(),R);return b.add(T.multiplyUnsafe(k)).subtract(v).clearCofactor().equals(_.ZERO)},ExtendedPoint:_,utils:{getExtendedPublicKey:U,randomPrivateKey:()=>a(n.BYTES),precompute:(N=8,R=_.BASE)=>(R._setWindowSize(N),R.multiply(BigInt(3)),R)}}};const Qo=Yn,zc=Ce,Qe=pe,it=pe,wt=BigInt(0),et=BigInt(1),fi=BigInt(2),pm=BigInt(8),mm={zip215:!0};var hn={};Object.defineProperty(hn,"__esModule",{value:!0}),hn.expand_message_xmd=Jd,hn.expand_message_xof=Xd,hn.hash_to_field=es,hn.isogenyMap=function(t,e){const n=e.map(r=>Array.from(r).reverse());return(r,i)=>{const[o,a,s,c]=n.map(l=>l.reduce((u,d)=>t.add(t.mul(u,r),d)));return r=t.div(o,a),i=t.mul(i,t.div(s,c)),{x:r,y:i}}},hn.createHasher=function(t,e,n){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(r,i){const o=es(r,2,{...n,DST:n.DST,...i}),a=t.fromAffine(e(o[0])),s=t.fromAffine(e(o[1])),c=a.add(s).clearCofactor();return c.assertValidity(),c},encodeToCurve(r,i){const o=es(r,1,{...n,DST:n.encodeDST,...i}),a=t.fromAffine(e(o[0])).clearCofactor();return a.assertValidity(),a},mapToCurve(r){if(!Array.isArray(r))throw new Error("mapToCurve: expected array of bigints");for(const o of r)if(typeof o!="bigint")throw new Error(`mapToCurve: expected array of bigints, got ${o} in array`);const i=t.fromAffine(e(r)).clearCofactor();return i.assertValidity(),i}}};const gm=Ce,Fe=pe,ym=Fe.bytesToNumberBE;function fn(t,e){if(Nr(t),Nr(e),t<0||t>=1<<8*e)throw new Error(`bad I2OSP call: value=${t} length=${e}`);const n=Array.from({length:e}).fill(0);for(let r=e-1;r>=0;r--)n[r]=255&t,t>>>=8;return new Uint8Array(n)}function vm(t,e){const n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t[r]^e[r];return n}function Nr(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function Jd(t,e,n,r){(0,Fe.abytes)(t),(0,Fe.abytes)(e),Nr(n),e.length>255&&(e=r((0,Fe.concatBytes)((0,Fe.utf8ToBytes)("H2C-OVERSIZE-DST-"),e)));const{outputLen:i,blockLen:o}=r,a=Math.ceil(n/i);if(n>65535||a>255)throw new Error("expand_message_xmd: invalid lenInBytes");const s=(0,Fe.concatBytes)(e,fn(e.length,1)),c=fn(0,o),l=fn(n,2),u=new Array(a),d=r((0,Fe.concatBytes)(c,t,l,fn(0,1),s));u[0]=r((0,Fe.concatBytes)(d,fn(1,1),s));for(let h=1;h<=a;h++){const f=[vm(d,u[h-1]),fn(h+1,1),s];u[h]=r((0,Fe.concatBytes)(...f))}return(0,Fe.concatBytes)(...u).slice(0,n)}function Xd(t,e,n,r,i){if((0,Fe.abytes)(t),(0,Fe.abytes)(e),Nr(n),e.length>255){const o=Math.ceil(2*r/8);e=i.create({dkLen:o}).update((0,Fe.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(e).digest()}if(n>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:n}).update(t).update(fn(n,2)).update(e).update(fn(e.length,1)).digest()}function es(t,e,n){(0,Fe.validateObject)(n,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:r,k:i,m:o,hash:a,expand:s,DST:c}=n;(0,Fe.abytes)(t),Nr(e);const l=typeof c=="string"?(0,Fe.utf8ToBytes)(c):c,u=r.toString(2).length,d=Math.ceil((u+i)/8),h=e*o*d;let f;if(s==="xmd")f=Jd(t,l,h,a);else if(s==="xof")f=Xd(t,l,h,i,a);else{if(s!=="_internal_pass")throw new Error('expand must be "xmd" or "xof"');f=t}const g=new Array(e);for(let m=0;m<e;m++){const w=new Array(o);for(let p=0;p<o;p++){const S=d*(p+m*o),_=f.subarray(S,S+d);w[p]=(0,gm.mod)(ym(_),r)}g[m]=w}return g}var Ws={};Object.defineProperty(Ws,"__esModule",{value:!0}),Ws.montgomery=function(t){const e=function(m){return(0,on.validateObject)(m,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...m})}(t),{P:n}=e,r=m=>(0,qc.mod)(m,n),i=e.montgomeryBits,o=Math.ceil(i/8),a=e.nByteLength,s=e.adjustScalarBytes||(m=>m),c=e.powPminus2||(m=>(0,qc.pow)(m,n-BigInt(2),n));function l(m,w,p){const S=r(m*(w-p));return[w=r(w-S),p=r(p+S)]}const u=(e.a-BigInt(2))/BigInt(4);function d(m){return(0,on.numberToBytesLE)(r(m),o)}function h(m,w){const p=function(O){const I=(0,on.ensureBytes)("u coordinate",O,o);return a===32&&(I[31]&=127),(0,on.bytesToNumberLE)(I)}(w),S=function(O){const I=(0,on.ensureBytes)("scalar",O),K=I.length;if(K!==o&&K!==a)throw new Error(`Expected ${o} or ${a} bytes, got ${K}`);return(0,on.bytesToNumberLE)(s(I))}(m),_=function(O,I){(0,on.aInRange)("u",O,Fn,n),(0,on.aInRange)("scalar",I,Fn,n);const K=I,q=O;let F,U=ts,j=Fn,G=O,$=ts,N=Fn;for(let C=BigInt(i-1);C>=Fn;C--){const P=K>>C&ts;N^=P,F=l(N,U,G),U=F[0],G=F[1],F=l(N,j,$),j=F[0],$=F[1],N=P;const D=U+j,y=r(D*D),E=U-j,A=r(E*E),T=y-A,b=G+$,v=r((G-$)*D),k=r(b*E),x=v+k,M=v-k;G=r(x*x),$=r(q*r(M*M)),U=r(y*A),j=r(T*(y+r(u*T)))}F=l(N,U,G),U=F[0],G=F[1],F=l(N,j,$),j=F[0],$=F[1];const R=c(j);return r(U*R)}(p,S);if(_===Fn)throw new Error("Invalid private or public key received");return d(_)}const f=d(e.Gu);function g(m){return h(m,f)}return{scalarMult:h,scalarMultBase:g,getSharedSecret:(m,w)=>h(m,w),getPublicKey:m=>g(m),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:f}};const qc=Ce,on=pe,Fn=BigInt(0),ts=BigInt(1);(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.hash_to_ristretto255=t.hashToRistretto255=t.RistrettoPoint=t.encodeToCurve=t.hashToCurve=t.edwardsToMontgomery=t.x25519=t.ed25519ph=t.ed25519ctx=t.ed25519=t.ED25519_TORSION_SUBGROUP=void 0,t.edwardsToMontgomeryPub=K,t.edwardsToMontgomeryPriv=function(k){const x=O.hash(k.subarray(0,32));return O.adjustScalarBytes(x).subarray(0,32)};const e=Ne,n=tn,r=Fs,i=hn,o=Ce,a=Ws,s=pe,c=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),u=BigInt(0),d=BigInt(1),h=BigInt(2),f=BigInt(3),g=BigInt(5),m=BigInt(8);function w(k){const x=BigInt(10),M=BigInt(20),L=BigInt(40),B=BigInt(80),H=c,z=k*k%H*k%H,J=(0,o.pow2)(z,h,H)*z%H,Q=(0,o.pow2)(J,d,H)*k%H,ne=(0,o.pow2)(Q,g,H)*Q%H,se=(0,o.pow2)(ne,x,H)*ne%H,le=(0,o.pow2)(se,M,H)*se%H,re=(0,o.pow2)(le,L,H)*le%H,ie=(0,o.pow2)(re,B,H)*re%H,ce=(0,o.pow2)(ie,B,H)*re%H,ae=(0,o.pow2)(ce,x,H)*ne%H;return{pow_p_5_8:(0,o.pow2)(ae,h,H)*k%H,b2:z}}function p(k){return k[0]&=248,k[31]&=127,k[31]|=64,k}function S(k,x){const M=c,L=(0,o.mod)(x*x*x,M),B=w(k*(0,o.mod)(L*L*x,M)).pow_p_5_8;let H=(0,o.mod)(k*L*B,M);const z=(0,o.mod)(x*H*H,M),J=H,Q=(0,o.mod)(H*l,M),ne=z===k,se=z===(0,o.mod)(-k,M),le=z===(0,o.mod)(-k*l,M);return ne&&(H=J),(se||le)&&(H=Q),(0,o.isNegativeLE)(H,M)&&(H=(0,o.mod)(-H,M)),{isValid:ne||se,value:H}}t.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];const _=(0,o.Field)(c,void 0,!0),O={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:_,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:m,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:e.sha512,randomBytes:n.randomBytes,adjustScalarBytes:p,uvRatio:S};function I(k,x,M){if(x.length>255)throw new Error("Context is too big");return(0,n.concatBytes)((0,n.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([M?1:0,x.length]),x,k)}function K(k){const{y:x}=t.ed25519.ExtendedPoint.fromHex(k),M=BigInt(1);return _.toBytes(_.create((M+x)*_.inv(M-x)))}t.ed25519=(0,r.twistedEdwards)(O),t.ed25519ctx=(0,r.twistedEdwards)({...O,domain:I}),t.ed25519ph=(0,r.twistedEdwards)(Object.assign({},O,{domain:I,prehash:e.sha512})),t.x25519=(0,a.montgomery)({P:c,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:k=>{const x=c,{pow_p_5_8:M,b2:L}=w(k);return(0,o.mod)((0,o.pow2)(M,f,x)*L,x)},adjustScalarBytes:p,randomBytes:n.randomBytes}),t.edwardsToMontgomery=K;const q=(_.ORDER+f)/m,F=_.pow(h,q),U=_.sqrt(_.neg(_.ONE)),j=(0,o.FpSqrtEven)(_,_.neg(BigInt(486664)));function G(k){const{xMn:x,xMd:M,yMn:L,yMd:B}=function(re){const ie=(_.ORDER-g)/m,ce=BigInt(486662);let ae=_.sqr(re);ae=_.mul(ae,h);let ge=_.add(ae,_.ONE),Ee=_.neg(ce),de=_.sqr(ge),me=_.mul(de,ge),ve=_.mul(ae,ce);ve=_.mul(ve,Ee),ve=_.add(ve,de),ve=_.mul(ve,Ee);let Pe=_.sqr(me);de=_.sqr(Pe),Pe=_.mul(Pe,me),Pe=_.mul(Pe,ve),de=_.mul(de,Pe);let ut=_.pow(de,ie);ut=_.mul(ut,Pe);let Lo=_.mul(ut,U);de=_.sqr(ut),de=_.mul(de,me);let No=_.eql(de,ve),hc=_.cmov(Lo,ut,No),Jf=_.mul(Ee,ae),fr=_.mul(ut,re);fr=_.mul(fr,F);let Xf=_.mul(fr,U),Qf=_.mul(ve,ae);de=_.sqr(fr),de=_.mul(de,me);let ep=_.eql(de,Qf),tp=_.cmov(Xf,fr,ep);de=_.sqr(hc),de=_.mul(de,me);let Do=_.eql(de,ve),np=_.cmov(Jf,Ee,Do),pr=_.cmov(tp,hc,Do),rp=_.isOdd(pr);return pr=_.cmov(pr,_.neg(pr),Do!==rp),{xMn:np,xMd:ge,yMn:pr,yMd:d}}(k);let H=_.mul(x,B);H=_.mul(H,j);let z=_.mul(M,L),J=_.sub(x,M),Q=_.add(x,M),ne=_.mul(z,Q),se=_.eql(ne,_.ZERO);H=_.cmov(H,_.ZERO,se),z=_.cmov(z,_.ONE,se),J=_.cmov(J,_.ONE,se),Q=_.cmov(Q,_.ONE,se);const le=_.invertBatch([z,Q]);return{x:_.mul(H,le[0]),y:_.mul(J,le[1])}}const $=(0,i.createHasher)(t.ed25519.ExtendedPoint,k=>G(k[0]),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:_.ORDER,m:1,k:128,expand:"xmd",hash:e.sha512});function N(k){if(!(k instanceof v))throw new Error("RistrettoPoint expected")}t.hashToCurve=$.hashToCurve,t.encodeToCurve=$.encodeToCurve;const R=l,C=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),P=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),D=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),y=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),E=k=>S(d,k),A=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),T=k=>t.ed25519.CURVE.Fp.create((0,s.bytesToNumberLE)(k)&A);function b(k){const{d:x}=t.ed25519.CURVE,M=t.ed25519.CURVE.Fp.ORDER,L=t.ed25519.CURVE.Fp.create,B=L(R*k*k),H=L((B+d)*D);let z=BigInt(-1);const J=L((z-x*B)*L(B+x));let{isValid:Q,value:ne}=S(H,J),se=L(ne*k);(0,o.isNegativeLE)(se,M)||(se=L(-se)),Q||(ne=se),Q||(z=B);const le=L(z*(B-d)*y-J),re=ne*ne,ie=L((ne+ne)*J),ce=L(le*C),ae=L(d-re),ge=L(d+re);return new t.ed25519.ExtendedPoint(L(ie*ge),L(ae*ce),L(ce*ge),L(ie*ae))}class v{constructor(x){this.ep=x}static fromAffine(x){return new v(t.ed25519.ExtendedPoint.fromAffine(x))}static hashToCurve(x){x=(0,s.ensureBytes)("ristrettoHash",x,64);const M=b(T(x.slice(0,32))),L=b(T(x.slice(32,64)));return new v(M.add(L))}static fromHex(x){x=(0,s.ensureBytes)("ristrettoHex",x,32);const{a:M,d:L}=t.ed25519.CURVE,B=t.ed25519.CURVE.Fp.ORDER,H=t.ed25519.CURVE.Fp.create,z="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",J=T(x);if(!(0,s.equalBytes)((0,s.numberToBytesLE)(J,32),x)||(0,o.isNegativeLE)(J,B))throw new Error(z);const Q=H(J*J),ne=H(d+M*Q),se=H(d-M*Q),le=H(ne*ne),re=H(se*se),ie=H(M*L*le-re),{isValid:ce,value:ae}=E(H(ie*re)),ge=H(ae*se),Ee=H(ae*ge*ie);let de=H((J+J)*ge);(0,o.isNegativeLE)(de,B)&&(de=H(-de));const me=H(ne*Ee),ve=H(de*me);if(!ce||(0,o.isNegativeLE)(ve,B)||me===u)throw new Error(z);return new v(new t.ed25519.ExtendedPoint(de,me,d,ve))}toRawBytes(){let{ex:x,ey:M,ez:L,et:B}=this.ep;const H=t.ed25519.CURVE.Fp.ORDER,z=t.ed25519.CURVE.Fp.create,J=z(z(L+M)*z(L-M)),Q=z(x*M),ne=z(Q*Q),{value:se}=E(z(J*ne)),le=z(se*J),re=z(se*Q),ie=z(le*re*B);let ce;if((0,o.isNegativeLE)(B*ie,H)){let ge=z(M*R),Ee=z(x*R);x=ge,M=Ee,ce=z(le*P)}else ce=re;(0,o.isNegativeLE)(x*ie,H)&&(M=z(-M));let ae=z((L-M)*ce);return(0,o.isNegativeLE)(ae,H)&&(ae=z(-ae)),(0,s.numberToBytesLE)(ae,32)}toHex(){return(0,s.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(x){N(x);const{ex:M,ey:L}=this.ep,{ex:B,ey:H}=x.ep,z=t.ed25519.CURVE.Fp.create,J=z(M*H)===z(L*B),Q=z(L*H)===z(M*B);return J||Q}add(x){return N(x),new v(this.ep.add(x.ep))}subtract(x){return N(x),new v(this.ep.subtract(x.ep))}multiply(x){return new v(this.ep.multiply(x))}multiplyUnsafe(x){return new v(this.ep.multiplyUnsafe(x))}double(){return new v(this.ep.double())}negate(){return new v(this.ep.negate())}}t.RistrettoPoint=(v.BASE||(v.BASE=new v(t.ed25519.ExtendedPoint.BASE)),v.ZERO||(v.ZERO=new v(t.ed25519.ExtendedPoint.ZERO)),v),t.hashToRistretto255=(k,x)=>{const M=x.DST,L=typeof M=="string"?(0,n.utf8ToBytes)(M):M,B=(0,i.expand_message_xmd)(k,L,64,e.sha512);return v.hashToCurve(B)},t.hash_to_ristretto255=t.hashToRistretto255})(wd);var Qd={},Jt={};Object.defineProperty(Jt,"__esModule",{value:!0}),Jt.sha224=Jt.sha256=Jt.SHA256=void 0;const ns=Zt,ft=tn,bm=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]),sn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),an=new Uint32Array(64);class Ia extends ns.HashMD{constructor(){super(64,32,8,!1),this.A=0|sn[0],this.B=0|sn[1],this.C=0|sn[2],this.D=0|sn[3],this.E=0|sn[4],this.F=0|sn[5],this.G=0|sn[6],this.H=0|sn[7]}get(){const{A:e,B:n,C:r,D:i,E:o,F:a,G:s,H:c}=this;return[e,n,r,i,o,a,s,c]}set(e,n,r,i,o,a,s,c){this.A=0|e,this.B=0|n,this.C=0|r,this.D=0|i,this.E=0|o,this.F=0|a,this.G=0|s,this.H=0|c}process(e,n){for(let d=0;d<16;d++,n+=4)an[d]=e.getUint32(n,!1);for(let d=16;d<64;d++){const h=an[d-15],f=an[d-2],g=(0,ft.rotr)(h,7)^(0,ft.rotr)(h,18)^h>>>3,m=(0,ft.rotr)(f,17)^(0,ft.rotr)(f,19)^f>>>10;an[d]=m+an[d-7]+g+an[d-16]|0}let{A:r,B:i,C:o,D:a,E:s,F:c,G:l,H:u}=this;for(let d=0;d<64;d++){const h=u+((0,ft.rotr)(s,6)^(0,ft.rotr)(s,11)^(0,ft.rotr)(s,25))+(0,ns.Chi)(s,c,l)+bm[d]+an[d]|0,f=((0,ft.rotr)(r,2)^(0,ft.rotr)(r,13)^(0,ft.rotr)(r,22))+(0,ns.Maj)(r,i,o)|0;u=l,l=c,c=s,s=a+h|0,a=o,o=i,i=r,r=h+f|0}r=r+this.A|0,i=i+this.B|0,o=o+this.C|0,a=a+this.D|0,s=s+this.E|0,c=c+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(r,i,o,a,s,c,l,u)}roundClean(){an.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}Jt.SHA256=Ia;class wm extends Ia{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}Jt.sha256=(0,ft.wrapConstructor)(()=>new Ia),Jt.sha224=(0,ft.wrapConstructor)(()=>new wm);var Ii={},La={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.hmac=t.HMAC=void 0;const e=at,n=tn;class r extends n.Hash{constructor(o,a){super(),this.finished=!1,this.destroyed=!1,(0,e.hash)(o);const s=(0,n.toBytes)(a);if(this.iHash=o.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 c=this.blockLen,l=new Uint8Array(c);l.set(s.length>c?o.create().update(s).digest():s);for(let u=0;u<l.length;u++)l[u]^=54;this.iHash.update(l),this.oHash=o.create();for(let u=0;u<l.length;u++)l[u]^=106;this.oHash.update(l),l.fill(0)}update(o){return(0,e.exists)(this),this.iHash.update(o),this}digestInto(o){(0,e.exists)(this),(0,e.bytes)(o,this.outputLen),this.finished=!0,this.iHash.digestInto(o),this.oHash.update(o),this.oHash.digestInto(o),this.destroy()}digest(){const o=new Uint8Array(this.oHash.outputLen);return this.digestInto(o),o}_cloneInto(o){o||(o=Object.create(Object.getPrototypeOf(this),{}));const{oHash:a,iHash:s,finished:c,destroyed:l,blockLen:u,outputLen:d}=this;return o.finished=c,o.destroyed=l,o.blockLen=u,o.outputLen=d,o.oHash=a._cloneInto(o.oHash),o.iHash=s._cloneInto(o.iHash),o}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}t.HMAC=r,t.hmac=(i,o,a)=>new r(i,o).update(a).digest(),t.hmac.create=(i,o)=>new r(i,o)})(La);var Na={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DER=void 0,t.weierstrassPoints=f,t.weierstrass=function(m){const w=function(k){const x=(0,e.validateBasic)(k);return r.validateObject(x,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...x})}(m),{Fp:p,n:S}=w,_=p.BYTES+1,O=2*p.BYTES+1;function I(k){return n.mod(k,S)}function K(k){return n.invert(k,S)}const{ProjectivePoint:q,normPrivateKeyToScalar:F,weierstrassEquation:U,isWithinCurveOrder:j}=f({...w,toBytes(k,x,M){const L=x.toAffine(),B=p.toBytes(L.x),H=r.concatBytes;return(0,i.abool)("isCompressed",M),M?H(Uint8Array.from([x.hasEvenY()?2:3]),B):H(Uint8Array.from([4]),B,p.toBytes(L.y))},fromBytes(k){const x=k.length,M=k[0],L=k.subarray(1);if(x!==_||M!==2&&M!==3){if(x===O&&M===4)return{x:p.fromBytes(L.subarray(0,p.BYTES)),y:p.fromBytes(L.subarray(p.BYTES,2*p.BYTES))};throw new Error(`Point of length ${x} was invalid. Expected ${_} compressed bytes or ${O} uncompressed bytes`)}{const B=r.bytesToNumberBE(L);if(!r.inRange(B,l,p.ORDER))throw new Error("Point is not on curve");const H=U(B);let z;try{z=p.sqrt(H)}catch(J){const Q=J instanceof Error?": "+J.message:"";throw new Error("Point is not on curve"+Q)}return(1&M)==1!=((z&l)===l)&&(z=p.neg(z)),{x:B,y:z}}}}),G=k=>r.bytesToHex(r.numberToBytesBE(k,w.nByteLength));function $(k){return k>S>>l}const N=(k,x,M)=>r.bytesToNumberBE(k.slice(x,M));class R{constructor(x,M,L){this.r=x,this.s=M,this.recovery=L,this.assertValidity()}static fromCompact(x){const M=w.nByteLength;return x=(0,i.ensureBytes)("compactSignature",x,2*M),new R(N(x,0,M),N(x,M,2*M))}static fromDER(x){const{r:M,s:L}=t.DER.toSig((0,i.ensureBytes)("DER",x));return new R(M,L)}assertValidity(){r.aInRange("r",this.r,l,S),r.aInRange("s",this.s,l,S)}addRecoveryBit(x){return new R(this.r,this.s,x)}recoverPublicKey(x){const{r:M,s:L,recovery:B}=this,H=y((0,i.ensureBytes)("msgHash",x));if(B==null||![0,1,2,3].includes(B))throw new Error("recovery id invalid");const z=B===2||B===3?M+w.n:M;if(z>=p.ORDER)throw new Error("recovery id 2 or 3 invalid");const J=1&B?"03":"02",Q=q.fromHex(J+G(z)),ne=K(z),se=I(-H*ne),le=I(L*ne),re=q.BASE.multiplyAndAddUnsafe(Q,se,le);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return $(this.s)}normalizeS(){return this.hasHighS()?new R(this.r,I(-this.s),this.recovery):this}toDERRawBytes(){return r.hexToBytes(this.toDERHex())}toDERHex(){return t.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return r.hexToBytes(this.toCompactHex())}toCompactHex(){return G(this.r)+G(this.s)}}const C={isValidPrivateKey(k){try{return F(k),!0}catch{return!1}},normPrivateKeyToScalar:F,randomPrivateKey:()=>{const k=n.getMinHashLength(w.n);return n.mapHashToField(w.randomBytes(k),w.n)},precompute:(k=8,x=q.BASE)=>(x._setWindowSize(k),x.multiply(BigInt(3)),x)};function P(k){const x=r.isBytes(k),M=typeof k=="string",L=(x||M)&&k.length;return x?L===_||L===O:M?L===2*_||L===2*O:k instanceof q}const D=w.bits2int||function(k){const x=r.bytesToNumberBE(k),M=8*k.length-w.nBitLength;return M>0?x>>BigInt(M):x},y=w.bits2int_modN||function(k){return I(D(k))},E=r.bitMask(w.nBitLength);function A(k){return r.aInRange(`num < 2^${w.nBitLength}`,k,c,E),r.numberToBytesBE(k,w.nByteLength)}function T(k,x,M=b){if(["recovered","canonical"].some(ie=>ie in M))throw new Error("sign() legacy options not supported");const{hash:L,randomBytes:B}=w;let{lowS:H,prehash:z,extraEntropy:J}=M;H==null&&(H=!0),k=(0,i.ensureBytes)("msgHash",k),o(M),z&&(k=(0,i.ensureBytes)("prehashed msgHash",L(k)));const Q=y(k),ne=F(x),se=[A(ne),A(Q)];if(J!=null&&J!==!1){const ie=J===!0?B(p.BYTES):J;se.push((0,i.ensureBytes)("extraEntropy",ie))}const le=r.concatBytes(...se),re=Q;return{seed:le,k2sig:function(ie){const ce=D(ie);if(!j(ce))return;const ae=K(ce),ge=q.BASE.multiply(ce).toAffine(),Ee=I(ge.x);if(Ee===c)return;const de=I(ae*I(re+Ee*ne));if(de===c)return;let me=(ge.x===Ee?0:2)|Number(ge.y&l),ve=de;return H&&$(de)&&(ve=function(Pe){return $(Pe)?I(-Pe):Pe}(de),me^=1),new R(Ee,ve,me)}}}const b={lowS:w.lowS,prehash:!1},v={lowS:w.lowS,prehash:!1};return q.BASE._setWindowSize(8),{CURVE:w,getPublicKey:function(k,x=!0){return q.fromPrivateKey(k).toRawBytes(x)},getSharedSecret:function(k,x,M=!0){if(P(k))throw new Error("first arg must be private key");if(!P(x))throw new Error("second arg must be public key");return q.fromHex(x).multiply(F(k)).toRawBytes(M)},sign:function(k,x,M=b){const{seed:L,k2sig:B}=T(k,x,M),H=w;return r.createHmacDrbg(H.hash.outputLen,H.nByteLength,H.hmac)(L,B)},verify:function(k,x,M,L=v){var Ee;const B=k;if(x=(0,i.ensureBytes)("msgHash",x),M=(0,i.ensureBytes)("publicKey",M),"strict"in L)throw new Error("options.strict was renamed to lowS");o(L);const{lowS:H,prehash:z}=L;let J,Q;try{if(typeof B=="string"||r.isBytes(B))try{J=R.fromDER(B)}catch(de){if(!(de instanceof t.DER.Err))throw de;J=R.fromCompact(B)}else{if(typeof B!="object"||typeof B.r!="bigint"||typeof B.s!="bigint")throw new Error("PARSE");{const{r:de,s:me}=B;J=new R(de,me)}}Q=q.fromHex(M)}catch(de){if(de.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(H&&J.hasHighS())return!1;z&&(x=w.hash(x));const{r:ne,s:se}=J,le=y(x),re=K(se),ie=I(le*re),ce=I(ne*re),ae=(Ee=q.BASE.multiplyAndAddUnsafe(Q,ie,ce))==null?void 0:Ee.toAffine();return ae?I(ae.x)===ne:!1},ProjectivePoint:q,Signature:R,utils:C}},t.SWUFpSqrtRatio=g,t.mapToCurveSimpleSWU=function(m,w){if(n.validateField(m),!m.isValid(w.A)||!m.isValid(w.B)||!m.isValid(w.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const p=g(m,w.Z);if(!m.isOdd)throw new Error("Fp.isOdd is not implemented!");return S=>{let _,O,I,K,q,F,U,j;_=m.sqr(S),_=m.mul(_,w.Z),O=m.sqr(_),O=m.add(O,_),I=m.add(O,m.ONE),I=m.mul(I,w.B),K=m.cmov(w.Z,m.neg(O),!m.eql(O,m.ZERO)),K=m.mul(K,w.A),O=m.sqr(I),F=m.sqr(K),q=m.mul(F,w.A),O=m.add(O,q),O=m.mul(O,I),F=m.mul(F,K),q=m.mul(F,w.B),O=m.add(O,q),U=m.mul(_,I);const{isValid:G,value:$}=p(O,F);j=m.mul(_,S),j=m.mul(j,$),U=m.cmov(U,I,G),j=m.cmov(j,$,G);const N=m.isOdd(S)===m.isOdd(j);return j=m.cmov(m.neg(j),j,N),U=m.div(U,K),{x:U,y:j}}};const e=Yn,n=Ce,r=pe,i=pe;function o(m){m.lowS!==void 0&&(0,i.abool)("lowS",m.lowS),m.prehash!==void 0&&(0,i.abool)("prehash",m.prehash)}const{bytesToNumberBE:a,hexToBytes:s}=r;t.DER={Err:class extends Error{constructor(m=""){super(m)}},_tlv:{encode:(m,w)=>{const{Err:p}=t.DER;if(m<0||m>256)throw new p("tlv.encode: wrong tag");if(1&w.length)throw new p("tlv.encode: unpadded data");const S=w.length/2,_=r.numberToHexUnpadded(S);if(_.length/2&128)throw new p("tlv.encode: long form length too big");const O=S>127?r.numberToHexUnpadded(_.length/2|128):"";return`${r.numberToHexUnpadded(m)}${O}${_}${w}`},decode(m,w){const{Err:p}=t.DER;let S=0;if(m<0||m>256)throw new p("tlv.encode: wrong tag");if(w.length<2||w[S++]!==m)throw new p("tlv.decode: wrong tlv");const _=w[S++];let O=0;if(128&_){const K=127&_;if(!K)throw new p("tlv.decode(long): indefinite length not supported");if(K>4)throw new p("tlv.decode(long): byte length is too big");const q=w.subarray(S,S+K);if(q.length!==K)throw new p("tlv.decode: length bytes not complete");if(q[0]===0)throw new p("tlv.decode(long): zero leftmost byte");for(const F of q)O=O<<8|F;if(S+=K,O<128)throw new p("tlv.decode(long): not minimal encoding")}else O=_;const I=w.subarray(S,S+O);if(I.length!==O)throw new p("tlv.decode: wrong value length");return{v:I,l:w.subarray(S+O)}}},_int:{encode(m){const{Err:w}=t.DER;if(m<c)throw new w("integer: negative integers are not allowed");let p=r.numberToHexUnpadded(m);if(8&Number.parseInt(p[0],16)&&(p="00"+p),1&p.length)throw new w("unexpected assertion");return p},decode(m){const{Err:w}=t.DER;if(128&m[0])throw new w("Invalid signature integer: negative");if(m[0]===0&&!(128&m[1]))throw new w("Invalid signature integer: unnecessary leading zero");return a(m)}},toSig(m){const{Err:w,_int:p,_tlv:S}=t.DER,_=typeof m=="string"?s(m):m;r.abytes(_);const{v:O,l:I}=S.decode(48,_);if(I.length)throw new w("Invalid signature: left bytes after parsing");const{v:K,l:q}=S.decode(2,O),{v:F,l:U}=S.decode(2,q);if(U.length)throw new w("Invalid signature: left bytes after parsing");return{r:p.decode(K),s:p.decode(F)}},hexFromSig(m){const{_tlv:w,_int:p}=t.DER,S=`${w.encode(2,p.encode(m.r))}${w.encode(2,p.encode(m.s))}`;return w.encode(48,S)}};const c=BigInt(0),l=BigInt(1),u=BigInt(2),d=BigInt(3),h=BigInt(4);function f(m){const w=function(N){const R=(0,e.validateBasic)(N);r.validateObject(R,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:C,Fp:P,a:D}=R;if(C){if(!P.eql(D,P.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof C!="object"||typeof C.beta!="bigint"||typeof C.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...R})}(m),{Fp:p}=w,S=n.Field(w.n,w.nBitLength),_=w.toBytes||((N,R,C)=>{const P=R.toAffine();return r.concatBytes(Uint8Array.from([4]),p.toBytes(P.x),p.toBytes(P.y))}),O=w.fromBytes||(N=>{const R=N.subarray(1);return{x:p.fromBytes(R.subarray(0,p.BYTES)),y:p.fromBytes(R.subarray(p.BYTES,2*p.BYTES))}});function I(N){const{a:R,b:C}=w,P=p.sqr(N),D=p.mul(P,N);return p.add(p.add(D,p.mul(N,R)),C)}if(!p.eql(p.sqr(w.Gy),I(w.Gx)))throw new Error("bad generator point: equation left != right");function K(N){const{allowedPrivateKeyLengths:R,nByteLength:C,wrapPrivateKey:P,n:D}=w;if(R&&typeof N!="bigint"){if(r.isBytes(N)&&(N=r.bytesToHex(N)),typeof N!="string"||!R.includes(N.length))throw new Error("Invalid key");N=N.padStart(2*C,"0")}let y;try{y=typeof N=="bigint"?N:r.bytesToNumberBE((0,i.ensureBytes)("private key",N,C))}catch{throw new Error(`private key must be ${C} bytes, hex or bigint, not ${typeof N}`)}return P&&(y=n.mod(y,D)),r.aInRange("private key",y,l,D),y}function q(N){if(!(N instanceof j))throw new Error("ProjectivePoint expected")}const F=(0,i.memoized)((N,R)=>{const{px:C,py:P,pz:D}=N;if(p.eql(D,p.ONE))return{x:C,y:P};const y=N.is0();R==null&&(R=y?p.ONE:p.inv(D));const E=p.mul(C,R),A=p.mul(P,R),T=p.mul(D,R);if(y)return{x:p.ZERO,y:p.ZERO};if(!p.eql(T,p.ONE))throw new Error("invZ was invalid");return{x:E,y:A}}),U=(0,i.memoized)(N=>{if(N.is0()){if(w.allowInfinityPoint&&!p.is0(N.py))return;throw new Error("bad point: ZERO")}const{x:R,y:C}=N.toAffine();if(!p.isValid(R)||!p.isValid(C))throw new Error("bad point: x or y not FE");const P=p.sqr(C),D=I(R);if(!p.eql(P,D))throw new Error("bad point: equation left != right");if(!N.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class j{constructor(R,C,P){if(this.px=R,this.py=C,this.pz=P,R==null||!p.isValid(R))throw new Error("x required");if(C==null||!p.isValid(C))throw new Error("y required");if(P==null||!p.isValid(P))throw new Error("z required");Object.freeze(this)}static fromAffine(R){const{x:C,y:P}=R||{};if(!R||!p.isValid(C)||!p.isValid(P))throw new Error("invalid affine point");if(R instanceof j)throw new Error("projective point not allowed");const D=y=>p.eql(y,p.ZERO);return D(C)&&D(P)?j.ZERO:new j(C,P,p.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(R){const C=p.invertBatch(R.map(P=>P.pz));return R.map((P,D)=>P.toAffine(C[D])).map(j.fromAffine)}static fromHex(R){const C=j.fromAffine(O((0,i.ensureBytes)("pointHex",R)));return C.assertValidity(),C}static fromPrivateKey(R){return j.BASE.multiply(K(R))}static msm(R,C){return(0,e.pippenger)(j,S,R,C)}_setWindowSize(R){$.setWindowSize(this,R)}assertValidity(){U(this)}hasEvenY(){const{y:R}=this.toAffine();if(p.isOdd)return!p.isOdd(R);throw new Error("Field doesn't support isOdd")}equals(R){q(R);const{px:C,py:P,pz:D}=this,{px:y,py:E,pz:A}=R,T=p.eql(p.mul(C,A),p.mul(y,D)),b=p.eql(p.mul(P,A),p.mul(E,D));return T&&b}negate(){return new j(this.px,p.neg(this.py),this.pz)}double(){const{a:R,b:C}=w,P=p.mul(C,d),{px:D,py:y,pz:E}=this;let A=p.ZERO,T=p.ZERO,b=p.ZERO,v=p.mul(D,D),k=p.mul(y,y),x=p.mul(E,E),M=p.mul(D,y);return M=p.add(M,M),b=p.mul(D,E),b=p.add(b,b),A=p.mul(R,b),T=p.mul(P,x),T=p.add(A,T),A=p.sub(k,T),T=p.add(k,T),T=p.mul(A,T),A=p.mul(M,A),b=p.mul(P,b),x=p.mul(R,x),M=p.sub(v,x),M=p.mul(R,M),M=p.add(M,b),b=p.add(v,v),v=p.add(b,v),v=p.add(v,x),v=p.mul(v,M),T=p.add(T,v),x=p.mul(y,E),x=p.add(x,x),v=p.mul(x,M),A=p.sub(A,v),b=p.mul(x,k),b=p.add(b,b),b=p.add(b,b),new j(A,T,b)}add(R){q(R);const{px:C,py:P,pz:D}=this,{px:y,py:E,pz:A}=R;let T=p.ZERO,b=p.ZERO,v=p.ZERO;const k=w.a,x=p.mul(w.b,d);let M=p.mul(C,y),L=p.mul(P,E),B=p.mul(D,A),H=p.add(C,P),z=p.add(y,E);H=p.mul(H,z),z=p.add(M,L),H=p.sub(H,z),z=p.add(C,D);let J=p.add(y,A);return z=p.mul(z,J),J=p.add(M,B),z=p.sub(z,J),J=p.add(P,D),T=p.add(E,A),J=p.mul(J,T),T=p.add(L,B),J=p.sub(J,T),v=p.mul(k,z),T=p.mul(x,B),v=p.add(T,v),T=p.sub(L,v),v=p.add(L,v),b=p.mul(T,v),L=p.add(M,M),L=p.add(L,M),B=p.mul(k,B),z=p.mul(x,z),L=p.add(L,B),B=p.sub(M,B),B=p.mul(k,B),z=p.add(z,B),M=p.mul(L,z),b=p.add(b,M),M=p.mul(J,z),T=p.mul(H,T),T=p.sub(T,M),M=p.mul(H,L),v=p.mul(J,v),v=p.add(v,M),new j(T,b,v)}subtract(R){return this.add(R.negate())}is0(){return this.equals(j.ZERO)}wNAF(R){return $.wNAFCached(this,R,j.normalizeZ)}multiplyUnsafe(R){r.aInRange("scalar",R,c,w.n);const C=j.ZERO;if(R===c)return C;if(R===l)return this;const{endo:P}=w;if(!P)return $.unsafeLadder(this,R);let{k1neg:D,k1:y,k2neg:E,k2:A}=P.splitScalar(R),T=C,b=C,v=this;for(;y>c||A>c;)y&l&&(T=T.add(v)),A&l&&(b=b.add(v)),v=v.double(),y>>=l,A>>=l;return D&&(T=T.negate()),E&&(b=b.negate()),b=new j(p.mul(b.px,P.beta),b.py,b.pz),T.add(b)}multiply(R){const{endo:C,n:P}=w;let D,y;if(r.aInRange("scalar",R,l,P),C){const{k1neg:E,k1:A,k2neg:T,k2:b}=C.splitScalar(R);let{p:v,f:k}=this.wNAF(A),{p:x,f:M}=this.wNAF(b);v=$.constTimeNegate(E,v),x=$.constTimeNegate(T,x),x=new j(p.mul(x.px,C.beta),x.py,x.pz),D=v.add(x),y=k.add(M)}else{const{p:E,f:A}=this.wNAF(R);D=E,y=A}return j.normalizeZ([D,y])[0]}multiplyAndAddUnsafe(R,C,P){const D=j.BASE,y=(A,T)=>T!==c&&T!==l&&A.equals(D)?A.multiply(T):A.multiplyUnsafe(T),E=y(this,C).add(y(R,P));return E.is0()?void 0:E}toAffine(R){return F(this,R)}isTorsionFree(){const{h:R,isTorsionFree:C}=w;if(R===l)return!0;if(C)return C(j,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:R,clearCofactor:C}=w;return R===l?this:C?C(j,this):this.multiplyUnsafe(w.h)}toRawBytes(R=!0){return(0,i.abool)("isCompressed",R),this.assertValidity(),_(j,this,R)}toHex(R=!0){return(0,i.abool)("isCompressed",R),r.bytesToHex(this.toRawBytes(R))}}j.BASE=new j(w.Gx,w.Gy,p.ONE),j.ZERO=new j(p.ZERO,p.ONE,p.ZERO);const G=w.nBitLength,$=(0,e.wNAF)(j,w.endo?Math.ceil(G/2):G);return{CURVE:w,ProjectivePoint:j,normPrivateKeyToScalar:K,weierstrassEquation:I,isWithinCurveOrder:function(N){return r.inRange(N,l,w.n)}}}function g(m,w){const p=m.ORDER;let S=c;for(let N=p-l;N%u===c;N/=u)S+=l;const _=S,O=u<<_-l-l,I=O*u,K=(p-l)/I,q=(K-l)/u,F=I-l,U=O,j=m.pow(w,K),G=m.pow(w,(K+l)/u);let $=(N,R)=>{let C=j,P=m.pow(R,F),D=m.sqr(P);D=m.mul(D,R);let y=m.mul(N,D);y=m.pow(y,q),y=m.mul(y,P),P=m.mul(y,R),D=m.mul(y,N);let E=m.mul(D,P);y=m.pow(E,U);let A=m.eql(y,m.ONE);P=m.mul(D,G),y=m.mul(E,C),D=m.cmov(P,D,A),E=m.cmov(y,E,A);for(let T=_;T>l;T--){let b=T-u;b=u<<b-l;let v=m.pow(E,b);const k=m.eql(v,m.ONE);P=m.mul(D,C),C=m.mul(C,C),v=m.mul(E,C),D=m.cmov(P,D,k),E=m.cmov(v,E,k)}return{isValid:A,value:D}};if(m.ORDER%h===d){const N=(m.ORDER-d)/h,R=m.sqrt(m.neg(w));$=(C,P)=>{let D=m.sqr(P);const y=m.mul(C,P);D=m.mul(D,y);let E=m.pow(D,N);E=m.mul(E,y);const A=m.mul(E,R),T=m.mul(m.sqr(E),P),b=m.eql(T,C);return{isValid:b,value:m.cmov(A,E,b)}}}return $}})(Na),Object.defineProperty(Ii,"__esModule",{value:!0}),Ii.getHash=Wc,Ii.createCurve=function(t,e){const n=r=>(0,_m.weierstrass)({...t,...Wc(r)});return Object.freeze({...n(e),create:n})};const Em=La,Vc=tn,_m=Na;function Wc(t){return{hash:t,hmac:(e,...n)=>(0,Em.hmac)(t,e,(0,Vc.concatBytes)(...n)),randomBytes:Vc.randomBytes}}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.encodeToCurve=t.hashToCurve=t.schnorr=t.secp256k1=void 0;const e=Jt,n=tn,r=Ii,i=hn,o=Ce,a=pe,s=Na,c=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),l=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),u=BigInt(1),d=BigInt(2),h=(y,E)=>(y+E/d)/E;function f(y){const E=c,A=BigInt(3),T=BigInt(6),b=BigInt(11),v=BigInt(22),k=BigInt(23),x=BigInt(44),M=BigInt(88),L=y*y*y%E,B=L*L*y%E,H=(0,o.pow2)(B,A,E)*B%E,z=(0,o.pow2)(H,A,E)*B%E,J=(0,o.pow2)(z,d,E)*L%E,Q=(0,o.pow2)(J,b,E)*J%E,ne=(0,o.pow2)(Q,v,E)*Q%E,se=(0,o.pow2)(ne,x,E)*ne%E,le=(0,o.pow2)(se,M,E)*se%E,re=(0,o.pow2)(le,x,E)*ne%E,ie=(0,o.pow2)(re,A,E)*B%E,ce=(0,o.pow2)(ie,k,E)*Q%E,ae=(0,o.pow2)(ce,T,E)*L%E,ge=(0,o.pow2)(ae,d,E);if(!g.eql(g.sqr(ge),y))throw new Error("Cannot find square root");return ge}const g=(0,o.Field)(c,void 0,void 0,{sqrt:f});t.secp256k1=(0,r.createCurve)({a:BigInt(0),b:BigInt(7),Fp:g,n:l,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:y=>{const E=l,A=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),T=-u*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),b=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),v=A,k=BigInt("0x100000000000000000000000000000000"),x=h(v*y,E),M=h(-T*y,E);let L=(0,o.mod)(y-x*A-M*b,E),B=(0,o.mod)(-x*T-M*v,E);const H=L>k,z=B>k;if(H&&(L=E-L),z&&(B=E-B),L>k||B>k)throw new Error("splitScalar: Endomorphism failed, k="+y);return{k1neg:H,k1:L,k2neg:z,k2:B}}}},e.sha256);const m=BigInt(0),w={};function p(y,...E){let A=w[y];if(A===void 0){const T=(0,e.sha256)(Uint8Array.from(y,b=>b.charCodeAt(0)));A=(0,a.concatBytes)(T,T),w[y]=A}return(0,e.sha256)((0,a.concatBytes)(A,...E))}const S=y=>y.toRawBytes(!0).slice(1),_=y=>(0,a.numberToBytesBE)(y,32),O=y=>(0,o.mod)(y,c),I=y=>(0,o.mod)(y,l),K=t.secp256k1.ProjectivePoint,q=(y,E,A)=>K.BASE.multiplyAndAddUnsafe(y,E,A);function F(y){let E=t.secp256k1.utils.normPrivateKeyToScalar(y),A=K.fromPrivateKey(E);return{scalar:A.hasEvenY()?E:I(-E),bytes:S(A)}}function U(y){(0,a.aInRange)("x",y,u,c);const E=O(y*y);let A=f(O(E*y+BigInt(7)));A%d!==m&&(A=O(-A));const T=new K(y,A,u);return T.assertValidity(),T}const j=a.bytesToNumberBE;function G(...y){return I(j(p("BIP0340/challenge",...y)))}function $(y){return F(y).bytes}function N(y,E,A=(0,n.randomBytes)(32)){const T=(0,a.ensureBytes)("message",y),{bytes:b,scalar:v}=F(E),k=(0,a.ensureBytes)("auxRand",A,32),x=_(v^j(p("BIP0340/aux",k))),M=p("BIP0340/nonce",x,b,T),L=I(j(M));if(L===m)throw new Error("sign failed: k is zero");const{bytes:B,scalar:H}=F(L),z=G(B,b,T),J=new Uint8Array(64);if(J.set(B,0),J.set(_(I(H+z*v)),32),!R(J,T,b))throw new Error("sign: Invalid signature produced");return J}function R(y,E,A){const T=(0,a.ensureBytes)("signature",y,64),b=(0,a.ensureBytes)("message",E),v=(0,a.ensureBytes)("publicKey",A,32);try{const k=U(j(v)),x=j(T.subarray(0,32));if(!(0,a.inRange)(x,u,c))return!1;const M=j(T.subarray(32,64));if(!(0,a.inRange)(M,u,l))return!1;const L=G(_(x),S(k),b),B=q(k,M,I(-L));return!(!B||!B.hasEvenY()||B.toAffine().x!==x)}catch{return!1}}t.schnorr={getPublicKey:$,sign:N,verify:R,utils:{randomPrivateKey:t.secp256k1.utils.randomPrivateKey,lift_x:U,pointToBytes:S,numberToBytesBE:a.numberToBytesBE,bytesToNumberBE:a.bytesToNumberBE,taggedHash:p,mod:o.mod}};const C=(0,i.isogenyMap)(g,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(y=>y.map(E=>BigInt(E)))),P=(0,s.mapToCurveSimpleSWU)(g,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:g.create(BigInt("-11"))}),D=(0,i.createHasher)(t.secp256k1.ProjectivePoint,y=>{const{x:E,y:A}=P(g.create(y[0]));return C(E,A)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:g.ORDER,m:1,k:128,expand:"xmd",hash:e.sha256});t.hashToCurve=D.hashToCurve,t.encodeToCurve=D.encodeToCurve})(Qd);var Gs={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.decodeHex=t.remove0x=void 0;var e=lt;t.remove0x=function(n){return n.startsWith("0x")||n.startsWith("0X")?n.slice(2):n},t.decodeHex=function(n){return(0,e.hexToBytes)((0,t.remove0x)(n))}})(Gs),function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.hexToPublicKey=t.convertPublicKeyFormat=t.getSharedPoint=t.getPublicKey=t.isValidPrivateKey=t.getValidSecret=void 0;var e=Ra,n=wd,r=Qd,i=Lr,o=Le,a=Gs;t.getValidSecret=function(){var u;do u=(0,e.randomBytes)(o.SECRET_KEY_LENGTH);while(!(0,t.isValidPrivateKey)(u));return u},t.isValidPrivateKey=function(u){return s((0,i.ellipticCurve)(),function(d){return d.utils.isValidPrivateKey(u)},function(){return!0},function(){return!0})},t.getPublicKey=function(u){return s((0,i.ellipticCurve)(),function(d){return d.getPublicKey(u)},function(d){return d.getPublicKey(u)},function(d){return d.getPublicKey(u)})},t.getSharedPoint=function(u,d,h){return s((0,i.ellipticCurve)(),function(f){return f.getSharedSecret(u,d,h)},function(f){return f.getSharedSecret(u,d)},function(f){return l(f,u,d)})},t.convertPublicKeyFormat=function(u,d){return s((0,i.ellipticCurve)(),function(h){return h.getSharedSecret(BigInt(1),u,d)},function(){return u},function(){return u})};function s(u,d,h,f){if(u==="secp256k1")return d(r.secp256k1);if(u==="x25519")return h(n.x25519);if(u==="ed25519")return f(n.ed25519);throw new Error("Not implemented")}t.hexToPublicKey=function(u){var d=(0,a.decodeHex)(u);return s((0,i.ellipticCurve)(),function(){return c(d)},function(){return d},function(){return d})};var c=function(u){if(u.length===o.ETH_PUBLIC_KEY_SIZE){var d=new Uint8Array(1+u.length);return d.set([4]),d.set(u,1),d}return u},l=function(u,d,h){var f=u.utils.getExtendedPublicKey(d).scalar;return u.ExtendedPoint.fromHex(h).multiply(f).toRawBytes()}}(bd);var eh={},Zn={};Object.defineProperty(Zn,"__esModule",{value:!0}),Zn.hkdf=void 0,Zn.extract=nh,Zn.expand=rh;const Ys=at,Gc=tn,th=La;function nh(t,e,n){return(0,Ys.hash)(t),n===void 0&&(n=new Uint8Array(t.outputLen)),(0,th.hmac)(t,(0,Gc.toBytes)(n),(0,Gc.toBytes)(e))}const rs=new Uint8Array([0]),Yc=new Uint8Array;function rh(t,e,n,r=32){if((0,Ys.hash)(t),(0,Ys.number)(r),r>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const i=Math.ceil(r/t.outputLen);n===void 0&&(n=Yc);const o=new Uint8Array(i*t.outputLen),a=th.hmac.create(t,e),s=a._cloneInto(),c=new Uint8Array(a.outputLen);for(let l=0;l<i;l++)rs[0]=l+1,s.update(l===0?Yc:c).update(n).update(rs).digestInto(c),o.set(c,t.outputLen*l),a._cloneInto(s);return a.destroy(),s.destroy(),c.fill(0),rs.fill(0),o.slice(0,r)}Zn.hkdf=(t,e,n,r,i)=>rh(t,nh(t,e,n),r,i),function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.getSharedKey=t.deriveKey=void 0;var e=lt,n=Zn,r=Jt;t.deriveKey=function(i,o,a){return(0,n.hkdf)(r.sha256,i,o,a,32)},t.getSharedKey=function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];return(0,t.deriveKey)(e.concatBytes.apply(void 0,i))}}(eh);var Zc={},nr={},xe={},Pn={};Object.defineProperty(Pn,"__esModule",{value:!0}),Pn.polyval=Pn.ghash=void 0,Pn._toGHASHKey=ih;const In=ze,Ge=lt,qt=16,Da=new Uint8Array(16),Pt=(0,Ge.u32)(Da),gt=t=>(t>>>0&255)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255|0;function ih(t){t.reverse();const e=1&t[15];let n=0;for(let r=0;r<t.length;r++){const i=t[r];t[r]=i>>>1|n,n=(1&i)<<7}return t[0]^=225&-e,t}class oh{constructor(e,n){this.blockLen=qt,this.outputLen=qt,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,e=(0,Ge.toBytes)(e),(0,In.bytes)(e,16);const r=(0,Ge.createView)(e);let i=r.getUint32(0,!1),o=r.getUint32(4,!1),a=r.getUint32(8,!1),s=r.getUint32(12,!1);const c=[];for(let p=0;p<128;p++)c.push({s0:gt(i),s1:gt(o),s2:gt(a),s3:gt(s)}),{s0:i,s1:o,s2:a,s3:s}={s3:(d=a)<<31|(h=s)>>>1,s2:(u=o)<<31|d>>>1,s1:(l=i)<<31|u>>>1,s0:l>>>1^225<<24&-(1&h)};var l,u,d,h;const f=(p=>p>65536?8:p>1024?4:2)(n||1024);if(![1,2,4,8].includes(f))throw new Error(`ghash: wrong window size=${f}, should be 2, 4 or 8`);this.W=f;const g=128/f,m=this.windowSize=2**f,w=[];for(let p=0;p<g;p++)for(let S=0;S<m;S++){let _=0,O=0,I=0,K=0;for(let q=0;q<f;q++){if(!(S>>>f-q-1&1))continue;const{s0:F,s1:U,s2:j,s3:G}=c[f*p+q];_^=F,O^=U,I^=j,K^=G}w.push({s0:_,s1:O,s2:I,s3:K})}this.t=w}_updateBlock(e,n,r,i){e^=this.s0,n^=this.s1,r^=this.s2,i^=this.s3;const{W:o,t:a,windowSize:s}=this;let c=0,l=0,u=0,d=0;const h=(1<<o)-1;let f=0;for(const g of[e,n,r,i])for(let m=0;m<4;m++){const w=g>>>8*m&255;for(let p=8/o-1;p>=0;p--){const S=w>>>o*p&h,{s0:_,s1:O,s2:I,s3:K}=a[f*s+S];c^=_,l^=O,u^=I,d^=K,f+=1}}this.s0=c,this.s1=l,this.s2=u,this.s3=d}update(e){e=(0,Ge.toBytes)(e),(0,In.exists)(this);const n=(0,Ge.u32)(e),r=Math.floor(e.length/qt),i=e.length%qt;for(let o=0;o<r;o++)this._updateBlock(n[4*o+0],n[4*o+1],n[4*o+2],n[4*o+3]);return i&&(Da.set(e.subarray(r*qt)),this._updateBlock(Pt[0],Pt[1],Pt[2],Pt[3]),(0,Ge.clean)(Pt)),this}destroy(){const{t:e}=this;for(const n of e)n.s0=0,n.s1=0,n.s2=0,n.s3=0}digestInto(e){(0,In.exists)(this),(0,In.output)(e,this),this.finished=!0;const{s0:n,s1:r,s2:i,s3:o}=this,a=(0,Ge.u32)(e);return a[0]=n,a[1]=r,a[2]=i,a[3]=o,e}digest(){const e=new Uint8Array(qt);return this.digestInto(e),this.destroy(),e}}class Sm extends oh{constructor(e,n){e=(0,Ge.toBytes)(e);const r=ih((0,Ge.copyBytes)(e));super(r,n),(0,Ge.clean)(r)}update(e){e=(0,Ge.toBytes)(e),(0,In.exists)(this);const n=(0,Ge.u32)(e),r=e.length%qt,i=Math.floor(e.length/qt);for(let o=0;o<i;o++)this._updateBlock(gt(n[4*o+3]),gt(n[4*o+2]),gt(n[4*o+1]),gt(n[4*o+0]));return r&&(Da.set(e.subarray(i*qt)),this._updateBlock(gt(Pt[3]),gt(Pt[2]),gt(Pt[1]),gt(Pt[0])),(0,Ge.clean)(Pt)),this}digestInto(e){(0,In.exists)(this),(0,In.output)(e,this),this.finished=!0;const{s0:n,s1:r,s2:i,s3:o}=this,a=(0,Ge.u32)(e);return a[0]=n,a[1]=r,a[2]=i,a[3]=o,e.reverse()}}function Jc(t){const e=(r,i)=>t(i,r.length).update((0,Ge.toBytes)(r)).digest(),n=t(new Uint8Array(16),0);return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=(r,i)=>t(r,i),e}Pn.ghash=Jc((t,e)=>new oh(t,e)),Pn.polyval=Jc((t,e)=>new Sm(t,e)),Object.defineProperty(xe,"__esModule",{value:!0}),xe.unsafe=xe.aeskwp=xe.aeskw=xe.siv=xe.gcm=xe.cfb=xe.cbc=xe.ecb=xe.ctr=void 0,xe.expandKeyLE=Ct,xe.expandKeyDecLE=Dr;const be=ze,Zs=Pn,ee=lt,nt=16,pi=new Uint8Array(nt),Cm=283;function Ba(t){return t<<1^Cm&-(t>>7)}function Jn(t,e){let n=0;for(;e>0;e>>=1)n^=t&-(1&e),t=Ba(t);return n}const Js=(()=>{const t=new Uint8Array(256);for(let n=0,r=1;n<256;n++,r^=Ba(r))t[n]=r;const e=new Uint8Array(256);e[0]=99;for(let n=0;n<255;n++){let r=t[255-n];r|=r<<8,e[t[n]]=255&(r^r>>4^r>>5^r>>6^r>>7^99)}return(0,ee.clean)(t),e})(),km=Js.map((t,e)=>Js.indexOf(e)),Am=t=>t<<24|t>>>8,is=t=>t<<8|t>>>24,to=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;function sh(t,e){if(t.length!==256)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map((l,u)=>e(t[u])),r=n.map(is),i=r.map(is),o=i.map(is),a=new Uint32Array(65536),s=new Uint32Array(65536),c=new Uint16Array(65536);for(let l=0;l<256;l++)for(let u=0;u<256;u++){const d=256*l+u;a[d]=n[l]^r[u],s[d]=i[l]^o[u],c[d]=t[l]<<8|t[u]}return{sbox:t,sbox2:c,T0:n,T1:r,T2:i,T3:o,T01:a,T23:s}}const $a=sh(Js,t=>Jn(t,3)<<24|t<<16|t<<8|Jn(t,2)),ah=sh(km,t=>Jn(t,11)<<24|Jn(t,13)<<16|Jn(t,9)<<8|Jn(t,14)),xm=(()=>{const t=new Uint8Array(16);for(let e=0,n=1;e<16;e++,n=Ba(n))t[e]=n;return t})();function Ct(t){(0,be.bytes)(t);const e=t.length;if(![16,24,32].includes(e))throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${e}`);const{sbox2:n}=$a,r=[];(0,ee.isAligned32)(t)||r.push(t=(0,ee.copyBytes)(t));const i=(0,ee.u32)(t),o=i.length,a=c=>Lt(n,c,c,c,c),s=new Uint32Array(e+28);s.set(i);for(let c=o;c<s.length;c++){let l=s[c-1];c%o==0?l=a(Am(l))^xm[c/o-1]:o>6&&c%o==4&&(l=a(l)),s[c]=s[c-o]^l}return(0,ee.clean)(...r),s}function Dr(t){const e=Ct(t),n=e.slice(),r=e.length,{sbox2:i}=$a,{T0:o,T1:a,T2:s,T3:c}=ah;for(let l=0;l<r;l+=4)for(let u=0;u<4;u++)n[l+u]=e[r-l-4+u];(0,ee.clean)(e);for(let l=4;l<r-4;l++){const u=n[l],d=Lt(i,u,u,u,u);n[l]=o[255&d]^a[d>>>8&255]^s[d>>>16&255]^c[d>>>24]}return n}function wn(t,e,n,r,i,o){return t[n<<8&65280|r>>>8&255]^e[i>>>8&65280|o>>>24&255]}function Lt(t,e,n,r,i){return t[255&e|65280&n]|t[r>>>16&255|i>>>16&65280]<<16}function Ye(t,e,n,r,i){const{sbox2:o,T01:a,T23:s}=$a;let c=0;e^=t[c++],n^=t[c++],r^=t[c++],i^=t[c++];const l=t.length/4-2;for(let u=0;u<l;u++){const d=t[c++]^wn(a,s,e,n,r,i),h=t[c++]^wn(a,s,n,r,i,e),f=t[c++]^wn(a,s,r,i,e,n),g=t[c++]^wn(a,s,i,e,n,r);e=d,n=h,r=f,i=g}return{s0:t[c++]^Lt(o,e,n,r,i),s1:t[c++]^Lt(o,n,r,i,e),s2:t[c++]^Lt(o,r,i,e,n),s3:t[c++]^Lt(o,i,e,n,r)}}function Br(t,e,n,r,i){const{sbox2:o,T01:a,T23:s}=ah;let c=0;e^=t[c++],n^=t[c++],r^=t[c++],i^=t[c++];const l=t.length/4-2;for(let u=0;u<l;u++){const d=t[c++]^wn(a,s,e,i,r,n),h=t[c++]^wn(a,s,n,e,i,r),f=t[c++]^wn(a,s,r,n,e,i),g=t[c++]^wn(a,s,i,r,n,e);e=d,n=h,r=f,i=g}return{s0:t[c++]^Lt(o,e,i,r,n),s1:t[c++]^Lt(o,n,e,i,r),s2:t[c++]^Lt(o,r,n,e,i),s3:t[c++]^Lt(o,i,r,n,e)}}function rr(t,e){if(e===void 0)return new Uint8Array(t);if((0,be.bytes)(e),e.length<t)throw new Error(`aes: wrong destination length, expected at least ${t}, got: ${e.length}`);if(!(0,ee.isAligned32)(e))throw new Error("unaligned dst");return e}function ch(t,e,n,r){(0,be.bytes)(e,nt),(0,be.bytes)(n);const i=n.length;r=rr(i,r);const o=e,a=(0,ee.u32)(o);let{s0:s,s1:c,s2:l,s3:u}=Ye(t,a[0],a[1],a[2],a[3]);const d=(0,ee.u32)(n),h=(0,ee.u32)(r);for(let g=0;g+4<=d.length;g+=4){h[g+0]=d[g+0]^s,h[g+1]=d[g+1]^c,h[g+2]=d[g+2]^l,h[g+3]=d[g+3]^u;let m=1;for(let w=o.length-1;w>=0;w--)m=m+(255&o[w])|0,o[w]=255&m,m>>>=8;({s0:s,s1:c,s2:l,s3:u}=Ye(t,a[0],a[1],a[2],a[3]))}const f=nt*Math.floor(d.length/4);if(f<i){const g=new Uint32Array([s,c,l,u]),m=(0,ee.u8)(g);for(let w=f,p=0;w<i;w++,p++)r[w]=n[w]^m[p];(0,ee.clean)(g)}return r}function Xn(t,e,n,r,i){(0,be.bytes)(n,nt),(0,be.bytes)(r),i=rr(r.length,i);const o=n,a=(0,ee.u32)(o),s=(0,ee.createView)(o),c=(0,ee.u32)(r),l=(0,ee.u32)(i),u=e?0:12,d=r.length;let h=s.getUint32(u,e),{s0:f,s1:g,s2:m,s3:w}=Ye(t,a[0],a[1],a[2],a[3]);for(let S=0;S+4<=c.length;S+=4)l[S+0]=c[S+0]^f,l[S+1]=c[S+1]^g,l[S+2]=c[S+2]^m,l[S+3]=c[S+3]^w,h=h+1>>>0,s.setUint32(u,h,e),{s0:f,s1:g,s2:m,s3:w}=Ye(t,a[0],a[1],a[2],a[3]);const p=nt*Math.floor(c.length/4);if(p<d){const S=new Uint32Array([f,g,m,w]),_=(0,ee.u8)(S);for(let O=p,I=0;O<d;O++,I++)i[O]=r[O]^_[I];(0,ee.clean)(S)}return i}function Xc(t){if((0,be.bytes)(t),t.length%nt!=0)throw new Error("aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size 16")}function Qc(t,e,n){(0,be.bytes)(t);let r=t.length;const i=r%nt;if(!e&&i!==0)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");(0,ee.isAligned32)(t)||(t=(0,ee.copyBytes)(t));const o=(0,ee.u32)(t);if(e){let s=nt-i;s||(s=nt),r+=s}const a=rr(r,n);return{b:o,o:(0,ee.u32)(a),out:a}}function el(t,e){if(!e)return t;const n=t.length;if(!n)throw new Error("aes/pcks5: empty ciphertext not allowed");const r=t[n-1];if(r<=0||r>16)throw new Error("aes/pcks5: wrong padding");const i=t.subarray(0,-r);for(let o=0;o<r;o++)if(t[n-o-1]!==r)throw new Error("aes/pcks5: wrong padding");return i}function tl(t){const e=new Uint8Array(16),n=(0,ee.u32)(e);e.set(t);const r=nt-t.length;for(let i=nt-r;i<nt;i++)e[i]=r;return n}function lh(t,e,n,r,i){const o=i==null?0:i.length,a=t.create(n,r.length+o);i&&a.update(i),a.update(r);const s=new Uint8Array(16),c=(0,ee.createView)(s);i&&(0,ee.setBigUint64)(c,0,BigInt(8*o),e),(0,ee.setBigUint64)(c,8,BigInt(8*r.length),e),a.update(s);const l=a.digest();return(0,ee.clean)(s),l}xe.ctr=(0,ee.wrapCipher)({blockSize:16,nonceLength:16},function(t,e){function n(r,i){if((0,be.bytes)(r),i!==void 0&&((0,be.bytes)(i),!(0,ee.isAligned32)(i)))throw new Error("unaligned destination");const o=Ct(t),a=(0,ee.copyBytes)(e),s=[o,a];(0,ee.isAligned32)(r)||s.push(r=(0,ee.copyBytes)(r));const c=ch(o,a,r,i);return(0,ee.clean)(...s),c}return(0,be.bytes)(t),(0,be.bytes)(e,nt),{encrypt:(r,i)=>n(r,i),decrypt:(r,i)=>n(r,i)}}),xe.ecb=(0,ee.wrapCipher)({blockSize:16},function(t,e={}){(0,be.bytes)(t);const n=!e.disablePadding;return{encrypt(r,i){const{b:o,o:a,out:s}=Qc(r,n,i),c=Ct(t);let l=0;for(;l+4<=o.length;){const{s0:u,s1:d,s2:h,s3:f}=Ye(c,o[l+0],o[l+1],o[l+2],o[l+3]);a[l++]=u,a[l++]=d,a[l++]=h,a[l++]=f}if(n){const u=tl(r.subarray(4*l)),{s0:d,s1:h,s2:f,s3:g}=Ye(c,u[0],u[1],u[2],u[3]);a[l++]=d,a[l++]=h,a[l++]=f,a[l++]=g}return(0,ee.clean)(c),s},decrypt(r,i){Xc(r);const o=Dr(t),a=rr(r.length,i),s=[o];(0,ee.isAligned32)(r)||s.push(r=(0,ee.copyBytes)(r));const c=(0,ee.u32)(r),l=(0,ee.u32)(a);for(let u=0;u+4<=c.length;){const{s0:d,s1:h,s2:f,s3:g}=Br(o,c[u+0],c[u+1],c[u+2],c[u+3]);l[u++]=d,l[u++]=h,l[u++]=f,l[u++]=g}return(0,ee.clean)(...s),el(a,n)}}}),xe.cbc=(0,ee.wrapCipher)({blockSize:16,nonceLength:16},function(t,e,n={}){(0,be.bytes)(t),(0,be.bytes)(e,16);const r=!n.disablePadding;return{encrypt(i,o){const a=Ct(t),{b:s,o:c,out:l}=Qc(i,r,o);let u=e;const d=[a];(0,ee.isAligned32)(u)||d.push(u=(0,ee.copyBytes)(u));const h=(0,ee.u32)(u);let f=h[0],g=h[1],m=h[2],w=h[3],p=0;for(;p+4<=s.length;)f^=s[p+0],g^=s[p+1],m^=s[p+2],w^=s[p+3],{s0:f,s1:g,s2:m,s3:w}=Ye(a,f,g,m,w),c[p++]=f,c[p++]=g,c[p++]=m,c[p++]=w;if(r){const S=tl(i.subarray(4*p));f^=S[0],g^=S[1],m^=S[2],w^=S[3],{s0:f,s1:g,s2:m,s3:w}=Ye(a,f,g,m,w),c[p++]=f,c[p++]=g,c[p++]=m,c[p++]=w}return(0,ee.clean)(...d),l},decrypt(i,o){Xc(i);const a=Dr(t);let s=e;const c=[a];(0,ee.isAligned32)(s)||c.push(s=(0,ee.copyBytes)(s));const l=(0,ee.u32)(s),u=rr(i.length,o);(0,ee.isAligned32)(i)||c.push(i=(0,ee.copyBytes)(i));const d=(0,ee.u32)(i),h=(0,ee.u32)(u);let f=l[0],g=l[1],m=l[2],w=l[3];for(let p=0;p+4<=d.length;){const S=f,_=g,O=m,I=w;f=d[p+0],g=d[p+1],m=d[p+2],w=d[p+3];const{s0:K,s1:q,s2:F,s3:U}=Br(a,f,g,m,w);h[p++]=K^S,h[p++]=q^_,h[p++]=F^O,h[p++]=U^I}return(0,ee.clean)(...c),el(u,r)}}}),xe.cfb=(0,ee.wrapCipher)({blockSize:16,nonceLength:16},function(t,e){function n(r,i,o){(0,be.bytes)(r);const a=r.length;o=rr(a,o);const s=Ct(t);let c=e;const l=[s];(0,ee.isAligned32)(c)||l.push(c=(0,ee.copyBytes)(c)),(0,ee.isAligned32)(r)||l.push(r=(0,ee.copyBytes)(r));const u=(0,ee.u32)(r),d=(0,ee.u32)(o),h=i?d:u,f=(0,ee.u32)(c);let g=f[0],m=f[1],w=f[2],p=f[3];for(let _=0;_+4<=u.length;){const{s0:O,s1:I,s2:K,s3:q}=Ye(s,g,m,w,p);d[_+0]=u[_+0]^O,d[_+1]=u[_+1]^I,d[_+2]=u[_+2]^K,d[_+3]=u[_+3]^q,g=h[_++],m=h[_++],w=h[_++],p=h[_++]}const S=nt*Math.floor(u.length/4);if(S<a){({s0:g,s1:m,s2:w,s3:p}=Ye(s,g,m,w,p));const _=(0,ee.u8)(new Uint32Array([g,m,w,p]));for(let O=S,I=0;O<a;O++,I++)o[O]=r[O]^_[I];(0,ee.clean)(_)}return(0,ee.clean)(...l),o}return(0,be.bytes)(t),(0,be.bytes)(e,16),{encrypt:(r,i)=>n(r,!0,i),decrypt:(r,i)=>n(r,!1,i)}}),xe.gcm=(0,ee.wrapCipher)({blockSize:16,nonceLength:12,tagLength:16},function(t,e,n){if((0,be.bytes)(t),(0,be.bytes)(e),n!==void 0&&(0,be.bytes)(n),e.length<8)throw new Error("aes/gcm: invalid nonce length");const r=16;function i(a,s,c){const l=lh(Zs.ghash,!1,a,c,n);for(let u=0;u<s.length;u++)l[u]^=s[u];return l}function o(){const a=Ct(t),s=pi.slice(),c=pi.slice();if(Xn(a,!1,c,c,s),e.length===12)c.set(e);else{const l=pi.slice(),u=(0,ee.createView)(l);(0,ee.setBigUint64)(u,8,BigInt(8*e.length),!1);const d=Zs.ghash.create(s).update(e).update(l);d.digestInto(c),d.destroy()}return{xk:a,authKey:s,counter:c,tagMask:Xn(a,!1,c,pi)}}return{encrypt(a){(0,be.bytes)(a);const{xk:s,authKey:c,counter:l,tagMask:u}=o(),d=new Uint8Array(a.length+r),h=[s,c,l,u];(0,ee.isAligned32)(a)||h.push(a=(0,ee.copyBytes)(a)),Xn(s,!1,l,a,d);const f=i(c,u,d.subarray(0,d.length-r));return h.push(f),d.set(f,a.length),(0,ee.clean)(...h),d},decrypt(a){if((0,be.bytes)(a),a.length<r)throw new Error("aes/gcm: ciphertext less than tagLen (16)");const{xk:s,authKey:c,counter:l,tagMask:u}=o(),d=[s,c,u,l];(0,ee.isAligned32)(a)||d.push(a=(0,ee.copyBytes)(a));const h=a.subarray(0,-16),f=a.subarray(-16),g=i(c,u,h);if(d.push(g),!(0,ee.equalBytes)(g,f))throw new Error("aes/gcm: invalid ghash tag");const m=Xn(s,!1,l,h);return(0,ee.clean)(...d),m}}});const mi=(t,e,n)=>r=>{if(!Number.isSafeInteger(r)||e>r||r>n)throw new Error(`${t}: invalid value=${r}, must be [${e}..${n}]`)};function uh(t){return t!=null&&typeof t=="object"&&(t instanceof Uint32Array||t.constructor.name==="Uint32Array")}function dh(t,e){if((0,be.bytes)(e,16),!uh(t))throw new Error("_encryptBlock accepts result of expandKeyLE");const n=(0,ee.u32)(e);let{s0:r,s1:i,s2:o,s3:a}=Ye(t,n[0],n[1],n[2],n[3]);return n[0]=r,n[1]=i,n[2]=o,n[3]=a,e}function hh(t,e){if((0,be.bytes)(e,16),!uh(t))throw new Error("_decryptBlock accepts result of expandKeyLE");const n=(0,ee.u32)(e);let{s0:r,s1:i,s2:o,s3:a}=Br(t,n[0],n[1],n[2],n[3]);return n[0]=r,n[1]=i,n[2]=o,n[3]=a,e}xe.siv=(0,ee.wrapCipher)({blockSize:16,nonceLength:12,tagLength:16},function(t,e,n){const r=mi("AAD",0,68719476736),i=mi("plaintext",0,2**36),o=mi("nonce",12,12),a=mi("ciphertext",16,2**36+16);function s(){const u=Ct(t),d=new Uint8Array(t.length),h=new Uint8Array(16),f=[u,d];let g=e;(0,ee.isAligned32)(g)||f.push(g=(0,ee.copyBytes)(g));const m=(0,ee.u32)(g);let w=0,p=m[0],S=m[1],_=m[2],O=0;for(const K of[h,d].map(ee.u32)){const q=(0,ee.u32)(K);for(let F=0;F<q.length;F+=2){const{s0:U,s1:j}=Ye(u,w,p,S,_);q[F+0]=U,q[F+1]=j,w=++O}}const I={authKey:h,encKey:Ct(d)};return(0,ee.clean)(...f),I}function c(u,d,h){const f=lh(Zs.polyval,!0,d,h,n);for(let _=0;_<12;_++)f[_]^=e[_];f[15]&=127;const g=(0,ee.u32)(f);let m=g[0],w=g[1],p=g[2],S=g[3];return{s0:m,s1:w,s2:p,s3:S}=Ye(u,m,w,p,S),g[0]=m,g[1]=w,g[2]=p,g[3]=S,f}function l(u,d,h){let f=(0,ee.copyBytes)(d);f[15]|=128;const g=Xn(u,!0,f,h);return(0,ee.clean)(f),g}return(0,be.bytes)(t,16,24,32),(0,be.bytes)(e),o(e.length),n!==void 0&&((0,be.bytes)(n),r(n.length)),{encrypt(u){(0,be.bytes)(u),i(u.length);const{encKey:d,authKey:h}=s(),f=c(d,h,u),g=[d,h,f];(0,ee.isAligned32)(u)||g.push(u=(0,ee.copyBytes)(u));const m=new Uint8Array(u.length+16);return m.set(f,u.length),m.set(l(d,f,u)),(0,ee.clean)(...g),m},decrypt(u){(0,be.bytes)(u),a(u.length);const d=u.subarray(-16),{encKey:h,authKey:f}=s(),g=[h,f];(0,ee.isAligned32)(u)||g.push(u=(0,ee.copyBytes)(u));const m=l(h,d,u.subarray(0,-16)),w=c(h,f,m);if(g.push(w),!(0,ee.equalBytes)(d,w))throw(0,ee.clean)(...g),new Error("invalid polyval tag");return(0,ee.clean)(...g),m}}});const no={encrypt(t,e){if(e.length>=2**32)throw new Error("plaintext should be less than 4gb");const n=Ct(t);if(e.length===16)dh(n,e);else{const r=(0,ee.u32)(e);let i=r[0],o=r[1];for(let a=0,s=1;a<6;a++)for(let c=2;c<r.length;c+=2,s++){const{s0:l,s1:u,s2:d,s3:h}=Ye(n,i,o,r[c],r[c+1]);i=l,o=u^to(s),r[c]=d,r[c+1]=h}r[0]=i,r[1]=o}n.fill(0)},decrypt(t,e){if(e.length-8>=2**32)throw new Error("ciphertext should be less than 4gb");const n=Dr(t),r=e.length/8-1;if(r===1)hh(n,e);else{const i=(0,ee.u32)(e);let o=i[0],a=i[1];for(let s=0,c=6*r;s<6;s++)for(let l=2*r;l>=1;l-=2,c--){a^=to(c);const{s0:u,s1:d,s2:h,s3:f}=Br(n,o,a,i[l],i[l+1]);o=u,a=d,i[l]=h,i[l+1]=f}i[0]=o,i[1]=a}n.fill(0)}},nl=new Uint8Array(8).fill(166);xe.aeskw=(0,ee.wrapCipher)({blockSize:8},t=>({encrypt(e){if((0,be.bytes)(e),!e.length||e.length%8!=0)throw new Error("invalid plaintext length");if(e.length===8)throw new Error("8-byte keys not allowed in AESKW, use AESKWP instead");const n=(0,ee.concatBytes)(nl,e);return no.encrypt(t,n),n},decrypt(e){if((0,be.bytes)(e),e.length%8!=0||e.length<24)throw new Error("invalid ciphertext length");const n=(0,ee.copyBytes)(e);if(no.decrypt(t,n),!(0,ee.equalBytes)(n.subarray(0,8),nl))throw new Error("integrity check failed");return n.subarray(0,8).fill(0),n.subarray(8)}}));const rl=2790873510;xe.aeskwp=(0,ee.wrapCipher)({blockSize:8},t=>({encrypt(e){if((0,be.bytes)(e),!e.length)throw new Error("invalid plaintext length");const n=8*Math.ceil(e.length/8),r=new Uint8Array(8+n);r.set(e,8);const i=(0,ee.u32)(r);return i[0]=rl,i[1]=to(e.length),no.encrypt(t,r),r},decrypt(e){if((0,be.bytes)(e),e.length<16)throw new Error("invalid ciphertext length");const n=(0,ee.copyBytes)(e),r=(0,ee.u32)(n);no.decrypt(t,n);const i=to(r[1])>>>0,o=8*Math.ceil(i/8);if(r[0]!==rl||n.length-8!==o)throw new Error("integrity check failed");for(let a=i;a<o;a++)if(n[8+a]!==0)throw new Error("integrity check failed");return n.subarray(0,8).fill(0),n.subarray(8,8+i)}})),xe.unsafe={expandKeyLE:Ct,expandKeyDecLE:Dr,encrypt:Ye,decrypt:Br,encryptBlock:dh,decryptBlock:hh,ctrCounter:ch,ctr32:Xn},Object.defineProperty(nr,"__esModule",{value:!0}),nr.aes256cbc=nr.aes256gcm=void 0;var fh=xe;nr.aes256gcm=function(t,e,n){return(0,fh.gcm)(t,e,n)};nr.aes256cbc=function(t,e,n){return(0,fh.cbc)(t,e)};var ro={},ph={},Qn={};Object.defineProperty(Qn,"__esModule",{value:!0}),Qn.sigma=void 0,Qn.rotl=function(t,e){return t<<e|t>>>32-e},Qn.createCipher=function(t,e){const{allowShortKeys:n,extendNonceFn:r,counterLength:i,counterRight:o,rounds:a}=(0,pt.checkOpts)({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return(0,zt.number)(i),(0,zt.number)(a),(0,zt.bool)(o),(0,zt.bool)(n),(s,c,l,u,d=0)=>{(0,zt.bytes)(s),(0,zt.bytes)(c),(0,zt.bytes)(l);const h=l.length;if(u===void 0&&(u=new Uint8Array(h)),(0,zt.bytes)(u),(0,zt.number)(d),d<0||d>=il)throw new Error("arx: counter overflow");if(u.length<h)throw new Error(`arx: output (${u.length}) is shorter than data (${h})`);const f=[];let g,m,w=s.length;if(w===32)f.push(g=(0,pt.copyBytes)(s)),m=gh;else{if(w!==16||!n)throw new Error(`arx: invalid 32-byte key, got length=${w}`);g=new Uint8Array(32),g.set(s),g.set(s,16),m=Rm,f.push(g)}os(c)||f.push(c=(0,pt.copyBytes)(c));const p=(0,pt.u32)(g);if(r){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");r(m,p,(0,pt.u32)(c.subarray(0,16)),p),c=c.subarray(16)}const S=16-i;if(S!==c.length)throw new Error(`arx: nonce must be ${S} or 16 bytes`);if(S!==12){const O=new Uint8Array(12);O.set(c,o?0:12-c.length),c=O,f.push(c)}const _=(0,pt.u32)(c);return function(O,I,K,q,F,U,j,G){const $=F.length,N=new Uint8Array(gi),R=(0,pt.u32)(N),C=os(F)&&os(U),P=C?(0,pt.u32)(F):ol,D=C?(0,pt.u32)(U):ol;for(let y=0;y<$;j++){if(O(I,K,q,R,j,G),j>=il)throw new Error("arx: counter overflow");const E=Math.min(gi,$-y);if(C&&E===gi){const A=y/4;if(y%4!=0)throw new Error("arx: invalid block position");for(let T,b=0;b<Om;b++)T=A+b,D[T]=P[T]^R[b];y+=gi}else{for(let A,T=0;T<E;T++)A=y+T,U[A]=F[A]^N[T];y+=E}}}(t,m,p,_,l,u,d,a),(0,pt.clean)(...f),u}};const zt=ze,pt=lt,mh=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),Tm=mh("expand 16-byte k"),Mm=mh("expand 32-byte k"),Rm=(0,pt.u32)(Tm),gh=(0,pt.u32)(Mm);function os(t){return t.byteOffset%4==0}Qn.sigma=gh.slice();const gi=64,Om=16,il=2**32-1,ol=new Uint32Array;var Ar={};Object.defineProperty(Ar,"__esModule",{value:!0}),Ar.poly1305=void 0,Ar.wrapConstructorWithKey=yh;const yi=ze,_r=lt,Be=(t,e)=>255&t[e++]|(255&t[e++])<<8;class Pm{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=(0,_r.toBytes)(e),(0,yi.bytes)(e,32);const n=Be(e,0),r=Be(e,2),i=Be(e,4),o=Be(e,6),a=Be(e,8),s=Be(e,10),c=Be(e,12),l=Be(e,14);this.r[0]=8191&n,this.r[1]=8191&(n>>>13|r<<3),this.r[2]=7939&(r>>>10|i<<6),this.r[3]=8191&(i>>>7|o<<9),this.r[4]=255&(o>>>4|a<<12),this.r[5]=a>>>1&8190,this.r[6]=8191&(a>>>14|s<<2),this.r[7]=8065&(s>>>11|c<<5),this.r[8]=8191&(c>>>8|l<<8),this.r[9]=l>>>5&127;for(let u=0;u<8;u++)this.pad[u]=Be(e,16+2*u)}process(e,n,r=!1){const i=r?0:2048,{h:o,r:a}=this,s=a[0],c=a[1],l=a[2],u=a[3],d=a[4],h=a[5],f=a[6],g=a[7],m=a[8],w=a[9],p=Be(e,n+0),S=Be(e,n+2),_=Be(e,n+4),O=Be(e,n+6),I=Be(e,n+8),K=Be(e,n+10),q=Be(e,n+12),F=Be(e,n+14);let U=o[0]+(8191&p),j=o[1]+(8191&(p>>>13|S<<3)),G=o[2]+(8191&(S>>>10|_<<6)),$=o[3]+(8191&(_>>>7|O<<9)),N=o[4]+(8191&(O>>>4|I<<12)),R=o[5]+(I>>>1&8191),C=o[6]+(8191&(I>>>14|K<<2)),P=o[7]+(8191&(K>>>11|q<<5)),D=o[8]+(8191&(q>>>8|F<<8)),y=o[9]+(F>>>5|i),E=0,A=E+U*s+j*(5*w)+G*(5*m)+$*(5*g)+N*(5*f);E=A>>>13,A&=8191,A+=R*(5*h)+C*(5*d)+P*(5*u)+D*(5*l)+y*(5*c),E+=A>>>13,A&=8191;let T=E+U*c+j*s+G*(5*w)+$*(5*m)+N*(5*g);E=T>>>13,T&=8191,T+=R*(5*f)+C*(5*h)+P*(5*d)+D*(5*u)+y*(5*l),E+=T>>>13,T&=8191;let b=E+U*l+j*c+G*s+$*(5*w)+N*(5*m);E=b>>>13,b&=8191,b+=R*(5*g)+C*(5*f)+P*(5*h)+D*(5*d)+y*(5*u),E+=b>>>13,b&=8191;let v=E+U*u+j*l+G*c+$*s+N*(5*w);E=v>>>13,v&=8191,v+=R*(5*m)+C*(5*g)+P*(5*f)+D*(5*h)+y*(5*d),E+=v>>>13,v&=8191;let k=E+U*d+j*u+G*l+$*c+N*s;E=k>>>13,k&=8191,k+=R*(5*w)+C*(5*m)+P*(5*g)+D*(5*f)+y*(5*h),E+=k>>>13,k&=8191;let x=E+U*h+j*d+G*u+$*l+N*c;E=x>>>13,x&=8191,x+=R*s+C*(5*w)+P*(5*m)+D*(5*g)+y*(5*f),E+=x>>>13,x&=8191;let M=E+U*f+j*h+G*d+$*u+N*l;E=M>>>13,M&=8191,M+=R*c+C*s+P*(5*w)+D*(5*m)+y*(5*g),E+=M>>>13,M&=8191;let L=E+U*g+j*f+G*h+$*d+N*u;E=L>>>13,L&=8191,L+=R*l+C*c+P*s+D*(5*w)+y*(5*m),E+=L>>>13,L&=8191;let B=E+U*m+j*g+G*f+$*h+N*d;E=B>>>13,B&=8191,B+=R*u+C*l+P*c+D*s+y*(5*w),E+=B>>>13,B&=8191;let H=E+U*w+j*m+G*g+$*f+N*h;E=H>>>13,H&=8191,H+=R*d+C*u+P*l+D*c+y*s,E+=H>>>13,H&=8191,E=(E<<2)+E|0,E=E+A|0,A=8191&E,E>>>=13,T+=E,o[0]=A,o[1]=T,o[2]=b,o[3]=v,o[4]=k,o[5]=x,o[6]=M,o[7]=L,o[8]=B,o[9]=H}finalize(){const{h:e,pad:n}=this,r=new Uint16Array(10);let i=e[1]>>>13;e[1]&=8191;for(let s=2;s<10;s++)e[s]+=i,i=e[s]>>>13,e[s]&=8191;e[0]+=5*i,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,r[0]=e[0]+5,i=r[0]>>>13,r[0]&=8191;for(let s=1;s<10;s++)r[s]=e[s]+i,i=r[s]>>>13,r[s]&=8191;r[9]-=8192;let o=(1^i)-1;for(let s=0;s<10;s++)r[s]&=o;o=~o;for(let s=0;s<10;s++)e[s]=e[s]&o|r[s];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);let a=e[0]+n[0];e[0]=65535&a;for(let s=1;s<8;s++)a=(e[s]+n[s]|0)+(a>>>16)|0,e[s]=65535&a;(0,_r.clean)(r)}update(e){(0,yi.exists)(this);const{buffer:n,blockLen:r}=this,i=(e=(0,_r.toBytes)(e)).length;for(let o=0;o<i;){const a=Math.min(r-this.pos,i-o);if(a!==r)n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===r&&(this.process(n,0,!1),this.pos=0);else for(;r<=i-o;o+=r)this.process(e,o)}return this}destroy(){(0,_r.clean)(this.h,this.r,this.buffer,this.pad)}digestInto(e){(0,yi.exists)(this),(0,yi.output)(e,this),this.finished=!0;const{buffer:n,h:r}=this;let{pos:i}=this;if(i){for(n[i++]=1;i<16;i++)n[i]=0;this.process(n,0,!0)}this.finalize();let o=0;for(let a=0;a<8;a++)e[o++]=r[a]>>>0,e[o++]=r[a]>>>8;return e}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}}function yh(t){const e=(r,i)=>t(i).update((0,_r.toBytes)(r)).digest(),n=t(new Uint8Array(32));return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=r=>t(r),e}Ar.poly1305=yh(t=>new Pm(t)),function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.xchacha20poly1305=t.chacha20poly1305=t._poly1305_aead=t.chacha12=t.chacha8=t.xchacha20=t.chacha20=t.chacha20orig=void 0,t.hchacha=a;const e=Qn,n=ze,r=Ar,i=lt;function o(d,h,f,g,m,w=20){let p=d[0],S=d[1],_=d[2],O=d[3],I=h[0],K=h[1],q=h[2],F=h[3],U=h[4],j=h[5],G=h[6],$=h[7],N=m,R=f[0],C=f[1],P=f[2],D=p,y=S,E=_,A=O,T=I,b=K,v=q,k=F,x=U,M=j,L=G,B=$,H=N,z=R,J=C,Q=P;for(let se=0;se<w;se+=2)D=D+T|0,H=(0,e.rotl)(H^D,16),x=x+H|0,T=(0,e.rotl)(T^x,12),D=D+T|0,H=(0,e.rotl)(H^D,8),x=x+H|0,T=(0,e.rotl)(T^x,7),y=y+b|0,z=(0,e.rotl)(z^y,16),M=M+z|0,b=(0,e.rotl)(b^M,12),y=y+b|0,z=(0,e.rotl)(z^y,8),M=M+z|0,b=(0,e.rotl)(b^M,7),E=E+v|0,J=(0,e.rotl)(J^E,16),L=L+J|0,v=(0,e.rotl)(v^L,12),E=E+v|0,J=(0,e.rotl)(J^E,8),L=L+J|0,v=(0,e.rotl)(v^L,7),A=A+k|0,Q=(0,e.rotl)(Q^A,16),B=B+Q|0,k=(0,e.rotl)(k^B,12),A=A+k|0,Q=(0,e.rotl)(Q^A,8),B=B+Q|0,k=(0,e.rotl)(k^B,7),D=D+b|0,Q=(0,e.rotl)(Q^D,16),L=L+Q|0,b=(0,e.rotl)(b^L,12),D=D+b|0,Q=(0,e.rotl)(Q^D,8),L=L+Q|0,b=(0,e.rotl)(b^L,7),y=y+v|0,H=(0,e.rotl)(H^y,16),B=B+H|0,v=(0,e.rotl)(v^B,12),y=y+v|0,H=(0,e.rotl)(H^y,8),B=B+H|0,v=(0,e.rotl)(v^B,7),E=E+k|0,z=(0,e.rotl)(z^E,16),x=x+z|0,k=(0,e.rotl)(k^x,12),E=E+k|0,z=(0,e.rotl)(z^E,8),x=x+z|0,k=(0,e.rotl)(k^x,7),A=A+T|0,J=(0,e.rotl)(J^A,16),M=M+J|0,T=(0,e.rotl)(T^M,12),A=A+T|0,J=(0,e.rotl)(J^A,8),M=M+J|0,T=(0,e.rotl)(T^M,7);let ne=0;g[ne++]=p+D|0,g[ne++]=S+y|0,g[ne++]=_+E|0,g[ne++]=O+A|0,g[ne++]=I+T|0,g[ne++]=K+b|0,g[ne++]=q+v|0,g[ne++]=F+k|0,g[ne++]=U+x|0,g[ne++]=j+M|0,g[ne++]=G+L|0,g[ne++]=$+B|0,g[ne++]=N+H|0,g[ne++]=R+z|0,g[ne++]=C+J|0,g[ne++]=P+Q|0}function a(d,h,f,g){let m=d[0],w=d[1],p=d[2],S=d[3],_=h[0],O=h[1],I=h[2],K=h[3],q=h[4],F=h[5],U=h[6],j=h[7],G=f[0],$=f[1],N=f[2],R=f[3];for(let P=0;P<20;P+=2)m=m+_|0,G=(0,e.rotl)(G^m,16),q=q+G|0,_=(0,e.rotl)(_^q,12),m=m+_|0,G=(0,e.rotl)(G^m,8),q=q+G|0,_=(0,e.rotl)(_^q,7),w=w+O|0,$=(0,e.rotl)($^w,16),F=F+$|0,O=(0,e.rotl)(O^F,12),w=w+O|0,$=(0,e.rotl)($^w,8),F=F+$|0,O=(0,e.rotl)(O^F,7),p=p+I|0,N=(0,e.rotl)(N^p,16),U=U+N|0,I=(0,e.rotl)(I^U,12),p=p+I|0,N=(0,e.rotl)(N^p,8),U=U+N|0,I=(0,e.rotl)(I^U,7),S=S+K|0,R=(0,e.rotl)(R^S,16),j=j+R|0,K=(0,e.rotl)(K^j,12),S=S+K|0,R=(0,e.rotl)(R^S,8),j=j+R|0,K=(0,e.rotl)(K^j,7),m=m+O|0,R=(0,e.rotl)(R^m,16),U=U+R|0,O=(0,e.rotl)(O^U,12),m=m+O|0,R=(0,e.rotl)(R^m,8),U=U+R|0,O=(0,e.rotl)(O^U,7),w=w+I|0,G=(0,e.rotl)(G^w,16),j=j+G|0,I=(0,e.rotl)(I^j,12),w=w+I|0,G=(0,e.rotl)(G^w,8),j=j+G|0,I=(0,e.rotl)(I^j,7),p=p+K|0,$=(0,e.rotl)($^p,16),q=q+$|0,K=(0,e.rotl)(K^q,12),p=p+K|0,$=(0,e.rotl)($^p,8),q=q+$|0,K=(0,e.rotl)(K^q,7),S=S+_|0,N=(0,e.rotl)(N^S,16),F=F+N|0,_=(0,e.rotl)(_^F,12),S=S+_|0,N=(0,e.rotl)(N^S,8),F=F+N|0,_=(0,e.rotl)(_^F,7);let C=0;g[C++]=m,g[C++]=w,g[C++]=p,g[C++]=S,g[C++]=G,g[C++]=$,g[C++]=N,g[C++]=R}t.chacha20orig=(0,e.createCipher)(o,{counterRight:!1,counterLength:8,allowShortKeys:!0}),t.chacha20=(0,e.createCipher)(o,{counterRight:!1,counterLength:4,allowShortKeys:!1}),t.xchacha20=(0,e.createCipher)(o,{counterRight:!1,counterLength:8,extendNonceFn:a,allowShortKeys:!1}),t.chacha8=(0,e.createCipher)(o,{counterRight:!1,counterLength:4,rounds:8}),t.chacha12=(0,e.createCipher)(o,{counterRight:!1,counterLength:4,rounds:12});const s=new Uint8Array(16),c=(d,h)=>{d.update(h);const f=h.length%16;f&&d.update(s.subarray(f))},l=new Uint8Array(32);function u(d,h,f,g,m){const w=d(h,f,l),p=r.poly1305.create(w);m&&c(p,m),c(p,g);const S=new Uint8Array(16),_=(0,i.createView)(S);(0,i.setBigUint64)(_,0,BigInt(m?m.length:0),!0),(0,i.setBigUint64)(_,8,BigInt(g.length),!0),p.update(S);const O=p.digest();return(0,i.clean)(w,S),O}t._poly1305_aead=d=>(h,f,g)=>((0,n.bytes)(h,32),(0,n.bytes)(f),{encrypt(w,p){const S=w.length,_=S+16;p?(0,n.bytes)(p,_):p=new Uint8Array(_),d(h,f,w,p,1);const O=u(d,h,f,p.subarray(0,-16),g);return p.set(O,S),(0,i.clean)(O),p},decrypt(w,p){const S=w.length,_=S-16;if(S<16)throw new Error("encrypted data must be at least 16 bytes");p?(0,n.bytes)(p,_):p=new Uint8Array(_);const O=w.subarray(0,-16),I=w.subarray(-16),K=u(d,h,f,O,g);if(!(0,i.equalBytes)(I,K))throw new Error("invalid tag");return d(h,f,O,p,1),(0,i.clean)(K),p}}),t.chacha20poly1305=(0,i.wrapCipher)({blockSize:64,nonceLength:12,tagLength:16},(0,t._poly1305_aead)(t.chacha20)),t.xchacha20poly1305=(0,i.wrapCipher)({blockSize:64,nonceLength:24,tagLength:16},(0,t._poly1305_aead)(t.xchacha20))}(ph),Object.defineProperty(ro,"__esModule",{value:!0}),ro.xchacha20=void 0;var zn,sl,yr,Im=ph;ro.xchacha20=function(t,e,n){return(0,Im.xchacha20poly1305)(t,e,n)},function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.aesDecrypt=t.aesEncrypt=t.symDecrypt=t.symEncrypt=void 0;var e=lt,n=Ra,r=nr,i=ro,o=Lr,a=Le;t.symEncrypt=function(u,d,h){return s(c,u,d,h)};function s(u,d,h,f){var g=(0,o.symmetricAlgorithm)();if(g==="aes-256-gcm")return u(r.aes256gcm,d,h,(0,o.symmetricNonceLength)(),a.AEAD_TAG_LENGTH,f);if(g==="xchacha20")return u(i.xchacha20,d,h,a.XCHACHA20_NONCE_LENGTH,a.AEAD_TAG_LENGTH,f);if(g==="aes-256-cbc")return u(r.aes256cbc,d,h,16,0);throw new Error("Not implemented")}function c(u,d,h,f,g,m){var w=(0,n.randomBytes)(f),p=u(d,w,m).encrypt(h);if(g===0)return(0,e.concatBytes)(w,p);var S=p.length-g,_=p.subarray(0,S),O=p.subarray(S);return(0,e.concatBytes)(w,O,_)}function l(u,d,h,f,g,m){var w=h.subarray(0,f),p=u(d,Uint8Array.from(w),m),S=h.subarray(f);if(g===0)return p.decrypt(S);var _=S.subarray(0,g),O=S.subarray(g);return p.decrypt((0,e.concatBytes)(O,_))}t.symDecrypt=function(u,d,h){return s(l,u,d,h)},t.aesEncrypt=t.symEncrypt,t.aesDecrypt=t.symDecrypt}(Zc),zn=xo,sl=bt&&bt.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),yr=bt&&bt.__exportStar||function(t,e){for(var n in t)n==="default"||Object.prototype.hasOwnProperty.call(e,n)||sl(e,t,n)},Object.defineProperty(zn,"__esModule",{value:!0}),yr(bd,zn),yr(eh,zn),yr(Gs,zn),yr(Zc,zn);var $r={};Object.defineProperty($r,"__esModule",{value:!0}),$r.PublicKey=void 0;var al=lt,vi=xo,Lm=function(){function t(e){this.data=(0,vi.convertPublicKeyFormat)(e,!0)}return t.fromHex=function(e){return new t((0,vi.hexToPublicKey)(e))},Object.defineProperty(t.prototype,"uncompressed",{get:function(){return X.from((0,vi.convertPublicKeyFormat)(this.data,!1))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"compressed",{get:function(){return X.from(this.data)},enumerable:!1,configurable:!0}),t.prototype.toHex=function(e){return e===void 0&&(e=!0),(0,al.bytesToHex)(e?this.data:this.uncompressed)},t.prototype.decapsulate=function(e,n){n===void 0&&(n=!1);var r=n?this.data:this.uncompressed,i=e.multiply(this,n);return(0,vi.getSharedKey)(r,i)},t.prototype.equals=function(e){return(0,al.equalBytes)(this.data,e.data)},t}();$r.PublicKey=Lm,Object.defineProperty(Ji,"__esModule",{value:!0}),Ji.PrivateKey=void 0;var cl=lt,qn=xo,Nm=$r,Dm=function(){function t(e){if(e===void 0)this.data=(0,qn.getValidSecret)();else{if(!(0,qn.isValidPrivateKey)(e))throw new Error("Invalid private key");this.data=e}this.publicKey=new Nm.PublicKey((0,qn.getPublicKey)(this.data))}return t.fromHex=function(e){return new t((0,qn.decodeHex)(e))},Object.defineProperty(t.prototype,"secret",{get:function(){return X.from(this.data)},enumerable:!1,configurable:!0}),t.prototype.toHex=function(){return(0,cl.bytesToHex)(this.data)},t.prototype.encapsulate=function(e,n){n===void 0&&(n=!1);var r=n?this.publicKey.compressed:this.publicKey.uncompressed,i=this.multiply(e,n);return(0,qn.getSharedKey)(r,i)},t.prototype.multiply=function(e,n){return n===void 0&&(n=!1),(0,qn.getSharedPoint)(this.data,e.compressed,n)},t.prototype.equals=function(e){return(0,cl.equalBytes)(this.data,e.data)},t}();Ji.PrivateKey=Dm,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.PublicKey=t.PrivateKey=void 0;var e=Ji;Object.defineProperty(t,"PrivateKey",{enumerable:!0,get:function(){return e.PrivateKey}});var n=$r;Object.defineProperty(t,"PublicKey",{enumerable:!0,get:function(){return n.PublicKey}})}(zo),function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.utils=t.PublicKey=t.PrivateKey=t.ECIES_CONFIG=void 0,t.encrypt=function(s,c){var l=new r.PrivateKey,u=s instanceof Uint8Array?new r.PublicKey(s):r.PublicKey.fromHex(s),d=l.encapsulate(u,(0,n.isHkdfKeyCompressed)()),h=(0,n.isEphemeralKeyCompressed)()?l.publicKey.compressed:l.publicKey.uncompressed,f=(0,i.symEncrypt)(d,c);return X.from((0,e.concatBytes)(h,f))},t.decrypt=function(s,c){var l=s instanceof Uint8Array?new r.PrivateKey(s):r.PrivateKey.fromHex(s),u=(0,n.ephemeralKeySize)(),d=new r.PublicKey(c.subarray(0,u)),h=c.subarray(u),f=d.decapsulate(l,(0,n.isHkdfKeyCompressed)());return X.from((0,i.symDecrypt)(f,h))};var e=lt,n=Lr,r=zo,i=xo,o=Lr;Object.defineProperty(t,"ECIES_CONFIG",{enumerable:!0,get:function(){return o.ECIES_CONFIG}});var a=zo;Object.defineProperty(t,"PrivateKey",{enumerable:!0,get:function(){return a.PrivateKey}}),Object.defineProperty(t,"PublicKey",{enumerable:!0,get:function(){return a.PublicKey}}),t.utils={aesEncrypt:i.aesEncrypt,aesDecrypt:i.aesDecrypt,symEncrypt:i.symEncrypt,symDecrypt:i.symDecrypt,decodeHex:i.decodeHex,getValidSecret:i.getValidSecret,remove0x:i.remove0x}}(Wn);const vh=Ze("KeyExchange:Layer"),bh=Ze("SocketService:Layer"),wh=Ze("Ecies:Layer"),Eh=Ze("RemoteCommunication:Layer");vh.color="##95c44e",bh.color="#f638d7",wh.color="#465b9c",Eh.color="#47a2be";const V={KeyExchange:vh,SocketService:bh,Ecies:wh,RemoteCommunication:Eh};let vr,bi=[],ss=[];const en=(t,e)=>Z(void 0,void 0,void 0,function*(){vr=e,ss.push(t),function(n){return Z(this,void 0,void 0,function*(){if(!vr||!n)return;(function(){const a=ss;ss=bi,bi=a})();const r=vr.endsWith("/")?`${vr}evt`:`${vr}/evt`,i=Object.assign({},n);if(delete i.params,n.params)for(const[a,s]of Object.entries(n.params))i[a]=s;const o=JSON.stringify(i);V.RemoteCommunication(`[sendBufferedEvents] Sending ${bi.length} analytics events to ${r}`);try{const a=yield Iu(r,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:o}),s=yield a.text();V.RemoteCommunication(`[sendBufferedEvents] Response: ${s}`),bi.length=0}catch{}})}(t).catch(()=>{})});class as{constructor(e){this.enabled=!0,e!=null&&e.debug&&Ze.enable("Ecies:Layer"),this.ecies=e!=null&&e.privateKey?Wn.PrivateKey.fromHex(e.privateKey):new Wn.PrivateKey,V.Ecies("[ECIES constructor()] initialized secret: ",this.ecies.toHex()),V.Ecies("[ECIES constructor()] initialized public: ",this.ecies.publicKey.toHex()),V.Ecies("[ECIES constructor()] init with",this)}generateECIES(){this.ecies=new Wn.PrivateKey}getPublicKey(){return this.ecies.publicKey.toHex()}encrypt(e,n){let r=e;if(this.enabled)try{V.Ecies("[ECIES: encrypt()] using otherPublicKey",n);const i=X.from(e),o=Wn.encrypt(n,i);r=X.from(o).toString("base64")}catch(i){throw V.Ecies("[ECIES: encrypt()] error encrypt:",i),V.Ecies("[ECIES: encrypt()] private: ",this.ecies.toHex()),V.Ecies("[ECIES: encrypt()] data: ",e),V.Ecies("[ECIES: encrypt()] otherkey: ",n),i}return r}decrypt(e){let n=e;if(this.enabled)try{V.Ecies("[ECIES: decrypt()] using privateKey",this.ecies.toHex());const r=X.from(e.toString(),"base64");n=Wn.decrypt(this.ecies.toHex(),r).toString()}catch(r){throw V.Ecies("[ECIES: decrypt()] error decrypt",r),V.Ecies("[ECIES: decrypt()] private: ",this.ecies.toHex()),V.Ecies("[ECIES: decrypt()] encryptedData: ",e),r}return n}getKeyInfo(){return{private:this.ecies.toHex(),public:this.ecies.publicKey.toHex()}}toString(){V.Ecies("[ECIES: toString()]",this.getKeyInfo())}}var kn={version:"0.33.1"};const ar="https://metamask-sdk.api.cx.metamask.io/",Bm=["websocket"],cr=6048e5,$m=3e3,He={METAMASK_CONNECTSIGN:"metamask_connectSign",METAMASK_CONNECTWITH:"metamask_connectWith",METAMASK_OPEN:"metamask_open",METAMASK_BATCH:"metamask_batch",PERSONAL_SIGN:"personal_sign",WALLET_REQUESTPERMISSIONS:"wallet_requestPermissions",WALLET_REVOKEPERMISSIONS:"wallet_revokePermissions",WALLET_WATCHASSET:"wallet_watchAsset",ETH_REQUESTACCOUNTS:"eth_requestAccounts",ETH_SENDTRANSACTION:"eth_sendTransaction",ETH_SIGNTYPEDDATA:"eth_signTypedData",ETH_SIGNTYPEDDATA_V3:"eth_signTypedData_v3",ETH_SIGNTYPEDDATA_V4:"eth_signTypedData_v4",ETH_SIGNTRANSACTION:"eth_signTransaction",ETH_SIGN:"eth_sign",PERSONAL_EC_RECOVER:"personal_ecRecover"},Km=[He.METAMASK_CONNECTSIGN,He.METAMASK_CONNECTWITH,He.METAMASK_OPEN,He.METAMASK_BATCH,He.PERSONAL_SIGN,He.WALLET_REQUESTPERMISSIONS,He.WALLET_REVOKEPERMISSIONS,He.WALLET_WATCHASSET,He.ETH_SENDTRANSACTION,He.ETH_SIGNTYPEDDATA,He.ETH_SIGNTYPEDDATA_V3,He.ETH_SIGNTYPEDDATA_V4,He.ETH_SIGNTRANSACTION,He.ETH_SIGN,He.PERSONAL_EC_RECOVER];function Xr(t){return Km.includes(t)}function _h(t){const{context:e}=t;V.RemoteCommunication(`[RemoteCommunication: clean()] context=${e}`),t.channelConfig=void 0,t.ready=!1,t.originatorConnectStarted=!1}var je,te,io,Se,Ae,Re,Vn;(Vn=je||(je={})).DISCONNECTED="disconnected",Vn.WAITING="waiting",Vn.TIMEOUT="timeout",Vn.LINKED="linked",Vn.PAUSED="paused",Vn.TERMINATED="terminated",function(t){t.KEY_INFO="key_info",t.SERVICE_STATUS="service_status",t.PROVIDER_UPDATE="provider_update",t.RPC_UPDATE="rpc_update",t.KEYS_EXCHANGED="keys_exchanged",t.JOIN_CHANNEL="join_channel",t.PUBLIC_KEY="public_key",t.CHANNEL_CREATED="channel_created",t.CLIENTS_CONNECTED="clients_connected",t.CLIENTS_DISCONNECTED="clients_disconnected",t.CLIENTS_WAITING="clients_waiting",t.CLIENTS_READY="clients_ready",t.REJECTED="rejected",t.WALLET_INIT="wallet_init",t.CHANNEL_PERSISTENCE="channel_persistence",t.CONFIG="config",t.MESSAGE_ACK="ack",t.SOCKET_DISCONNECTED="socket_disconnected",t.SOCKET_RECONNECT="socket_reconnect",t.OTP="otp",t.SDK_RPC_CALL="sdk_rpc_call",t.AUTHORIZED="authorized",t.CONNECTION_STATUS="connection_status",t.MESSAGE="message",t.TERMINATE="terminate"}(te||(te={})),(io||(io={})).KEY_EXCHANGE="key_exchange",function(t){t.KEY_HANDSHAKE_START="key_handshake_start",t.KEY_HANDSHAKE_CHECK="key_handshake_check",t.KEY_HANDSHAKE_SYN="key_handshake_SYN",t.KEY_HANDSHAKE_SYNACK="key_handshake_SYNACK",t.KEY_HANDSHAKE_ACK="key_handshake_ACK",t.KEY_HANDSHAKE_WALLET="key_handshake_wallet",t.KEY_HANDSHAKE_NONE="none"}(Se||(Se={}));class jm extends _o.EventEmitter2{constructor({communicationLayer:e,otherPublicKey:n,context:r,ecies:i,logging:o}){super(),this.keysExchanged=!1,this.step=Se.KEY_HANDSHAKE_NONE,this.debug=!1,this.context=r,this.communicationLayer=e,i!=null&&i.privateKey&&n&&(V.KeyExchange(`[KeyExchange: constructor()] otherPubKey=${n} set keysExchanged to true!`,i),this.keysExchanged=!0),this.myECIES=new as(Object.assign(Object.assign({},i),{debug:o==null?void 0:o.eciesLayer})),this.communicationLayer.state.eciesInstance=this.myECIES,this.myPublicKey=this.myECIES.getPublicKey(),this.debug=(o==null?void 0:o.keyExchangeLayer)===!0,n&&this.setOtherPublicKey(n),this.communicationLayer.on(io.KEY_EXCHANGE,this.onKeyExchangeMessage.bind(this))}onKeyExchangeMessage(e){const{relayPersistence:n}=this.communicationLayer.remote.state;if(V.KeyExchange(`[KeyExchange: onKeyExchangeMessage()] context=${this.context} keysExchanged=${this.keysExchanged} relayPersistence=${n}`,e),n)return void V.KeyExchange("[KeyExchange: onKeyExchangeMessage()] Ignoring key exchange message because relay persistence is activated");const{message:r}=e;this.keysExchanged&&V.KeyExchange(`[KeyExchange: onKeyExchangeMessage()] context=${this.context} received handshake while already exchanged. step=${this.step} otherPubKey=${this.otherPublicKey}`),this.emit(te.KEY_INFO,r.type),r.type===Se.KEY_HANDSHAKE_SYN?(this.checkStep([Se.KEY_HANDSHAKE_NONE,Se.KEY_HANDSHAKE_ACK]),V.KeyExchange("[KeyExchange: onKeyExchangeMessage()] KEY_HANDSHAKE_SYN",r),r.pubkey&&this.setOtherPublicKey(r.pubkey),this.communicationLayer.sendMessage({type:Se.KEY_HANDSHAKE_SYNACK,pubkey:this.myPublicKey}).catch(i=>{V.KeyExchange("[KeyExchange: onKeyExchangeMessage()] Error sending KEY_HANDSHAKE_SYNACK",i)}),this.setStep(Se.KEY_HANDSHAKE_ACK)):r.type===Se.KEY_HANDSHAKE_SYNACK?(this.checkStep([Se.KEY_HANDSHAKE_SYNACK,Se.KEY_HANDSHAKE_ACK,Se.KEY_HANDSHAKE_NONE]),V.KeyExchange("[KeyExchange: onKeyExchangeMessage()] KEY_HANDSHAKE_SYNACK"),r.pubkey&&this.setOtherPublicKey(r.pubkey),this.communicationLayer.sendMessage({type:Se.KEY_HANDSHAKE_ACK}).catch(i=>{V.KeyExchange("[KeyExchange: onKeyExchangeMessage()] Error sending KEY_HANDSHAKE_ACK",i)}),this.keysExchanged=!0,this.setStep(Se.KEY_HANDSHAKE_ACK),this.emit(te.KEYS_EXCHANGED)):r.type===Se.KEY_HANDSHAKE_ACK&&(V.KeyExchange("[KeyExchange: onKeyExchangeMessage()] KEY_HANDSHAKE_ACK set keysExchanged to true!"),this.checkStep([Se.KEY_HANDSHAKE_ACK,Se.KEY_HANDSHAKE_NONE]),this.keysExchanged=!0,this.setStep(Se.KEY_HANDSHAKE_ACK),this.emit(te.KEYS_EXCHANGED))}resetKeys(e){this.clean(),this.myECIES=new as(e)}clean(){V.KeyExchange(`[KeyExchange: clean()] context=${this.context} reset handshake state`),this.setStep(Se.KEY_HANDSHAKE_NONE),this.emit(te.KEY_INFO,this.step),this.keysExchanged=!1}start({isOriginator:e,force:n}){const{relayPersistence:r,protocolVersion:i}=this.communicationLayer.remote.state,o=i>=2;r?V.KeyExchange("[KeyExchange: start()] Ignoring key exchange message because relay persistence is activated"):(V.KeyExchange(`[KeyExchange: start()] context=${this.context} protocolVersion=${i} isOriginator=${e} step=${this.step} force=${n} relayPersistence=${r} keysExchanged=${this.keysExchanged}`),e?!(this.keysExchanged||this.step!==Se.KEY_HANDSHAKE_NONE&&this.step!==Se.KEY_HANDSHAKE_SYNACK)||n?(V.KeyExchange(`[KeyExchange: start()] context=${this.context} -- start key exchange (force=${n}) -- step=${this.step}`,this.step),this.clean(),this.setStep(Se.KEY_HANDSHAKE_SYNACK),this.communicationLayer.sendMessage({type:Se.KEY_HANDSHAKE_SYN,pubkey:this.myPublicKey,v:2}).catch(a=>{V.KeyExchange("[KeyExchange: start()] Error sending KEY_HANDSHAKE_SYN",a)})):V.KeyExchange(`[KeyExchange: start()] context=${this.context} -- key exchange already ${this.keysExchanged?"done":"in progress"} -- aborted.`,this.step):this.keysExchanged&&n!==!0?V.KeyExchange("[KeyExchange: start()] don't send KEY_HANDSHAKE_START -- exchange already done."):o?this.communicationLayer.sendMessage({type:Se.KEY_HANDSHAKE_SYNACK,pubkey:this.myPublicKey,v:2}).catch(a=>{V.KeyExchange("[KeyExchange: start()] Error sending KEY_HANDSHAKE_SYNACK",a)}):(this.communicationLayer.sendMessage({type:Se.KEY_HANDSHAKE_START}).catch(a=>{V.KeyExchange("[KeyExchange: start()] Error sending KEY_HANDSHAKE_START",a)}),this.clean()))}setStep(e){this.step=e,this.emit(te.KEY_INFO,e)}checkStep(e){e.length>0&&e.indexOf(this.step.toString())}setRelayPersistence({localKey:e,otherKey:n}){this.otherPublicKey=n,this.myECIES=new as({privateKey:e,debug:this.debug}),this.keysExchanged=!0}setKeysExchanged(e){this.keysExchanged=e}areKeysExchanged(){return this.keysExchanged}getMyPublicKey(){return this.myPublicKey}getOtherPublicKey(){return this.otherPublicKey}setOtherPublicKey(e){V.KeyExchange("[KeyExchange: setOtherPubKey()]",e),this.otherPublicKey=e}encryptMessage(e){if(!this.otherPublicKey)throw new Error("encryptMessage: Keys not exchanged - missing otherPubKey");return this.myECIES.encrypt(e,this.otherPublicKey)}decryptMessage(e){if(!this.otherPublicKey)throw new Error("decryptMessage: Keys not exchanged - missing otherPubKey");return this.myECIES.decrypt(e)}getKeyInfo(){return{ecies:Object.assign(Object.assign({},this.myECIES.getKeyInfo()),{otherPubKey:this.otherPublicKey}),step:this.step,keysExchanged:this.areKeysExchanged()}}toString(){const e={keyInfo:this.getKeyInfo(),keysExchanged:this.keysExchanged,step:this.step};return JSON.stringify(e)}}(function(t){t.TERMINATE="terminate",t.ANSWER="answer",t.OFFER="offer",t.CANDIDATE="candidate",t.JSONRPC="jsonrpc",t.WALLET_INFO="wallet_info",t.WALLET_INIT="wallet_init",t.ORIGINATOR_INFO="originator_info",t.PAUSE="pause",t.OTP="otp",t.AUTHORIZED="authorized",t.PING="ping",t.READY="ready"})(Ae||(Ae={})),function(t){t.REQUEST="sdk_connect_request_started",t.REQUEST_MOBILE="sdk_connect_request_started_mobile",t.RECONNECT="sdk_reconnect_request_started",t.CONNECTED="sdk_connection_established",t.CONNECTED_MOBILE="sdk_connection_established_mobile",t.AUTHORIZED="sdk_connection_authorized",t.REJECTED="sdk_connection_rejected",t.TERMINATED="sdk_connection_terminated",t.DISCONNECTED="sdk_disconnected",t.SDK_USE_EXTENSION="sdk_use_extension",t.SDK_RPC_REQUEST="sdk_rpc_request",t.SDK_RPC_REQUEST_RECEIVED="sdk_rpc_request_received",t.SDK_RPC_REQUEST_DONE="sdk_rpc_request_done",t.SDK_EXTENSION_UTILIZED="sdk_extension_utilized",t.SDK_USE_INAPP_BROWSER="sdk_use_inapp_browser"}(Re||(Re={}));const Li=(t,e,n)=>Z(void 0,void 0,void 0,function*(){var r,i,o,a,s,c;const{remote:l,state:u}=t,{channelId:d,isOriginator:h}=u;if(e==="error_terminated")return V.SocketService(`handleJoinChannelResults: Channel ${d} terminated`),void t.emit(te.TERMINATE);if(!n)return void V.SocketService(`handleJoinChannelResults: No result for channel ${d}`);const{persistence:f,walletKey:g,rejected:m}=n;if(V.SocketService(`handleJoinChannelResults: Channel ${d} persistence=${f} walletKey=${g} rejected=${m}`),m)return V.SocketService(`handleJoinChannelResults: Channel ${d} rejected`),yield t.remote.disconnect({terminate:!0}),t.remote.emit(te.REJECTED,{channelId:d}),void t.remote.emitServiceStatusEvent();if(g&&!(!((r=l.state.channelConfig)===null||r===void 0)&&r.otherKey)){t.getKeyExchange().setOtherPublicKey(g),(i=t.state.keyExchange)===null||i===void 0||i.setKeysExchanged(!0),l.state.ready=!0,l.state.authorized=!0,l.emit(te.AUTHORIZED);const{communicationLayer:w,storageManager:p}=l.state,S=Object.assign(Object.assign({},l.state.channelConfig),{channelId:(o=l.state.channelId)!==null&&o!==void 0?o:"",validUntil:Date.now()+cr,localKey:w==null?void 0:w.getKeyInfo().ecies.private,otherKey:g});t.sendMessage({type:Se.KEY_HANDSHAKE_ACK}).catch(_=>{}),(a=t.state.socket)===null||a===void 0||a.emit(Ae.PING,{id:d,clientType:h?"dapp":"wallet",context:"on_channel_reconnect",message:""}),yield p==null?void 0:p.persistChannelConfig(S),l.emitServiceStatusEvent(),l.setConnectionStatus(je.LINKED)}f&&(t.emit(te.CHANNEL_PERSISTENCE),(s=t.state.keyExchange)===null||s===void 0||s.setKeysExchanged(!0),l.state.ready=!0,l.state.authorized=!0,l.emit(te.AUTHORIZED),en(Object.assign(Object.assign({id:d??"",event:h?Re.CONNECTED:Re.CONNECTED_MOBILE},t.remote.state.originatorInfo),{sdkVersion:t.remote.state.sdkVersion,commLayer:t.state.communicationLayerPreference,commLayerVersion:kn.version,walletVersion:(c=t.remote.state.walletInfo)===null||c===void 0?void 0:c.version}),u.communicationServerUrl).catch(w=>{}))}),ir=t=>new Promise(e=>{setTimeout(e,t)}),ll=(t,e,...n)=>Z(void 0,[t,e,...n],void 0,function*(r,i,o=200){let a;const s=Date.now();let c=!1;for(;!c;){if(c=Date.now()-s>3e5,a=i[r],a.elapsedTime!==void 0)return a;yield ir(o)}throw new Error(`RPC ${r} timed out`)}),Xs=t=>Z(void 0,void 0,void 0,function*(){const{state:e}=t,{socket:n,channelId:r,context:i,isOriginator:o,isReconnecting:a}=e;if(a)return V.SocketService("[SocketService: reconnectSocket()] Reconnection already in progress, skipping",t),!1;if(!n)return V.SocketService("[SocketService: reconnectSocket()] socket is not defined",t),!1;if(!r)return!1;const{connected:s}=n;e.isReconnecting=!0,e.reconnectionAttempts=0,V.SocketService(`[SocketService: reconnectSocket()] connected=${s} trying to reconnect after socketio disconnection`,t);try{for(;3>e.reconnectionAttempts;){if(V.SocketService(`[SocketService: reconnectSocket()] Attempt ${e.reconnectionAttempts+1} of 3`,t),yield ir(200),n.connected)return V.SocketService("Socket already connected --- ping to retrieve messages"),n.emit(Ae.PING,{id:r,clientType:o?"dapp":"wallet",context:"on_channel_config",message:""}),!0;e.resumed=!0,n.connect(),t.emit(te.SOCKET_RECONNECT);try{if(yield new Promise((c,l)=>{n.emit(te.JOIN_CHANNEL,{channelId:r,context:`${i}connect_again`,clientType:o?"dapp":"wallet"},(u,d)=>Z(void 0,void 0,void 0,function*(){try{yield Li(t,u,d),c()}catch(h){l(h)}}))}),yield ir(100),n.connected)return V.SocketService(`Reconnection successful on attempt ${e.reconnectionAttempts+1}`),!0}catch(c){V.SocketService(`Error during reconnection attempt ${e.reconnectionAttempts+1}:`,c)}e.reconnectionAttempts+=1,3>e.reconnectionAttempts&&(yield ir(200))}return V.SocketService("Failed to reconnect after 3 attempts"),!1}finally{e.isReconnecting=!1,e.reconnectionAttempts=0}});function Sh(t,e){return Z(this,void 0,void 0,function*(){var n;const r=(n=t.state.keyExchange)===null||n===void 0?void 0:n.encryptMessage(JSON.stringify(e)),i={id:t.state.channelId,context:t.state.context,clientType:t.state.isOriginator?"dapp":"wallet",message:r,plaintext:t.state.hasPlaintext?JSON.stringify(e):void 0};return V.SocketService(`[SocketService: encryptAndSendMessage()] context=${t.state.context}`,i),e.type===Ae.TERMINATE&&(t.state.manualDisconnect=!0),new Promise((o,a)=>{var s;(s=t.state.socket)===null||s===void 0||s.emit(te.MESSAGE,i,(c,l)=>{var u;c&&(V.SocketService(`[SocketService: encryptAndSendMessage()] error=${c}`),a(c)),V.SocketService("[encryptAndSendMessage] response",l),o((u=l==null?void 0:l.success)!==null&&u!==void 0&&u)})})})}var er;(function(t){t.RPC_CHECK="rpcCheck",t.SKIPPED_RPC="skippedRpc"})(er||(er={}));const Ch=["eth_sendTransaction","eth_signTypedData","eth_signTransaction","personal_sign","wallet_requestPermissions","wallet_switchEthereumChain","eth_signTypedData_v3","eth_signTypedData_v4","metamask_connectSign","metamask_connectWith","metamask_batch"].map(t=>t.toLowerCase()),Um=[{event:te.CLIENTS_CONNECTED,handler:function(t,e){return n=>Z(this,void 0,void 0,function*(){var r,i,o,a,s,c,l,u,d,h,f;const g=(i=(r=t.remote.state.channelConfig)===null||r===void 0?void 0:r.relayPersistence)!==null&&i!==void 0&&i;if(V.SocketService(`[SocketService: handleClientsConnected()] context=${t.state.context} on 'clients_connected-${e}' relayPersistence=${g} resumed=${t.state.resumed} clientsPaused=${t.state.clientsPaused} keysExchanged=${(o=t.state.keyExchange)===null||o===void 0?void 0:o.areKeysExchanged()} isOriginator=${t.state.isOriginator}`),t.emit(te.CLIENTS_CONNECTED,{isOriginator:t.state.isOriginator,keysExchanged:(a=t.state.keyExchange)===null||a===void 0?void 0:a.areKeysExchanged(),context:t.state.context}),t.state.resumed)t.state.isOriginator||(V.SocketService(`[SocketService: handleClientsConnected()] context=${t.state.context} 'clients_connected' / keysExchanged=${(s=t.state.keyExchange)===null||s===void 0?void 0:s.areKeysExchanged()} -- backward compatibility`),(c=t.state.keyExchange)===null||c===void 0||c.start({isOriginator:(l=t.state.isOriginator)!==null&&l!==void 0&&l})),t.state.resumed=!1;else if(t.state.clientsPaused)V.SocketService("[SocketService: handleClientsConnected()] 'clients_connected' skip sending originatorInfo on pause");else if(!t.state.isOriginator){const m=!g;V.SocketService(`[SocketService: handleClientsConnected()] context=${t.state.context} on 'clients_connected' / keysExchanged=${(u=t.state.keyExchange)===null||u===void 0?void 0:u.areKeysExchanged()} -- force=${m} -- backward compatibility`),V.SocketService(`[SocketService: handleClientsConnected()] context=${t.state.context} on 'clients_connected' / keysExchanged=${(d=t.state.keyExchange)===null||d===void 0?void 0:d.areKeysExchanged()} -- force=${m} -- backward compatibility`),(h=t.state.keyExchange)===null||h===void 0||h.start({isOriginator:(f=t.state.isOriginator)!==null&&f!==void 0&&f,force:m})}t.state.clientsConnected=!0,t.state.clientsPaused=!1})}},{event:te.CHANNEL_CREATED,handler:function(t,e){return n=>{V.SocketService(`[SocketService: handleChannelCreated()] context=${t.state.context} on 'channel_created-${e}'`,n),t.emit(te.CHANNEL_CREATED,n)}}},{event:te.CLIENTS_DISCONNECTED,handler:function(t,e){return()=>{var n;t.state.clientsConnected=!1,V.SocketService(`[SocketService: handlesClientsDisconnected()] context=${t.state.context} on 'clients_disconnected-${e}'`),t.remote.state.relayPersistence?V.SocketService(`[SocketService: handlesClientsDisconnected()] context=${t.state.context} on 'clients_disconnected-${e}' - relayPersistence enabled, skipping key exchange cleanup.`):(t.state.isOriginator&&!t.state.clientsPaused&&((n=t.state.keyExchange)===null||n===void 0||n.clean()),t.emit(te.CLIENTS_DISCONNECTED,e))}}},{event:te.CONFIG,handler:function(t,e){return n=>Z(this,void 0,void 0,function*(){var r,i,o;V.SocketService(`[SocketService: handleChannelConfig()] update relayPersistence on 'config-${e}'`,n);const{persistence:a,walletKey:s}=n;t.state.isOriginator&&t.remote.state.channelConfig?(n.walletKey&&!t.remote.state.channelConfig.otherKey&&(V.SocketService(`Setting wallet key ${s}`),t.remote.state.channelConfig.otherKey=s,t.getKeyExchange().setOtherPublicKey(n.walletKey),(r=t.state.keyExchange)===null||r===void 0||r.setKeysExchanged(!0),yield t.remote.sendMessage({type:Se.KEY_HANDSHAKE_ACK}),yield t.remote.sendMessage({type:Ae.PING}),yield(i=t.remote.state.storageManager)===null||i===void 0?void 0:i.persistChannelConfig(t.remote.state.channelConfig)),a!==!0||t.remote.state.channelConfig.relayPersistence||(V.SocketService(`Setting relay persistence ${a}`),t.remote.state.channelConfig.relayPersistence=a,t.remote.state.relayPersistence=!0,t.remote.emit(te.CHANNEL_PERSISTENCE),t.remote.state.authorized=!0,t.remote.state.ready=!0,t.remote.emit(te.AUTHORIZED),yield(o=t.remote.state.storageManager)===null||o===void 0?void 0:o.persistChannelConfig(t.remote.state.channelConfig))):t.state.isOriginator||n.persistence&&(t.remote.state.relayPersistence=!0,t.remote.emit(te.CHANNEL_PERSISTENCE))})}},{event:te.MESSAGE,handler:function(t,e){return n=>{var r,i,o,a,s,c,l,u,d,h,f,g,m,w,p,S,_,O;const{ackId:I,message:K,error:q}=n,F=(r=t.remote.state.relayPersistence)!==null&&r!==void 0&&r;if(V.SocketService(`[SocketService handleMessage()] relayPersistence=${F} context=${t.state.context} on 'message' ${e} keysExchanged=${(i=t.state.keyExchange)===null||i===void 0?void 0:i.areKeysExchanged()}`,n),q)throw V.SocketService(`
9
+ [SocketService handleMessage()] context=${t.state.context}::on 'message' error=${q}`),new Error(q);const U=typeof K=="string";if(!U&&(K==null?void 0:K.type)===Se.KEY_HANDSHAKE_START)return F?void 0:(V.SocketService(`[SocketService handleMessage()] context=${t.state.context}::on 'message' received HANDSHAKE_START isOriginator=${t.state.isOriginator}`,K),void((o=t.state.keyExchange)===null||o===void 0||o.start({isOriginator:(a=t.state.isOriginator)!==null&&a!==void 0&&a,force:!0})));if(!U&&(!((s=K==null?void 0:K.type)===null||s===void 0)&&s.startsWith("key_handshake")))return F?void 0:(V.SocketService(`[SocketService handleMessage()] context=${t.state.context}::on 'message' emit KEY_EXCHANGE`,K),void t.emit(io.KEY_EXCHANGE,{message:K,context:t.state.context}));if(U&&!(!((c=t.state.keyExchange)===null||c===void 0)&&c.areKeysExchanged())){let $=!1;try{V.SocketService(`[SocketService handleMessage()] context=${t.state.context}::on 'message' trying to decrypt message`),(l=t.state.keyExchange)===null||l===void 0||l.decryptMessage(K),$=!0}catch(N){V.SocketService(`[SocketService handleMessage()] context=${t.state.context}::on 'message' error`,N)}if(!$)return t.state.isOriginator?(d=t.state.keyExchange)===null||d===void 0||d.start({isOriginator:(h=t.state.isOriginator)!==null&&h!==void 0&&h}):t.sendMessage({type:Se.KEY_HANDSHAKE_START}).catch(N=>{}),void V.SocketService(`Message ignored because invalid key exchange status. step=${(f=t.state.keyExchange)===null||f===void 0?void 0:f.getKeyInfo().step}`,(g=t.state.keyExchange)===null||g===void 0?void 0:g.getKeyInfo(),K);V.SocketService("Invalid key exchange status detected --- updating it."),(u=t.state.keyExchange)===null||u===void 0||u.setKeysExchanged(!0)}else if(!U&&(K!=null&&K.type))return void t.emit(te.MESSAGE,K);if(!U)return void t.emit(te.MESSAGE,K);const j=(m=t.state.keyExchange)===null||m===void 0?void 0:m.decryptMessage(K),G=JSON.parse(j??"{}");if(I&&(I==null?void 0:I.length)>0&&(V.SocketService(`[SocketService handleMessage()] context=${t.state.context}::on 'message' ackid=${I} channelId=${e}`),(w=t.state.socket)===null||w===void 0||w.emit(te.MESSAGE_ACK,{ackId:I,channelId:e,clientType:t.state.isOriginator?"dapp":"wallet"})),t.state.clientsPaused=(G==null?void 0:G.type)===Ae.PAUSE,t.state.isOriginator&&G.data){const $=G.data,N=t.state.rpcMethodTracker[$.id];if(N){const R=Date.now()-N.timestamp;V.SocketService(`[SocketService handleMessage()] context=${t.state.context}::on 'message' received answer for id=${$.id} method=${N.method} responseTime=${R}`,G),t.remote.state.analytics&&Ch.includes(N.method.toLowerCase())&&en(Object.assign(Object.assign({id:(p=t.remote.state.channelId)!==null&&p!==void 0?p:"",event:Re.SDK_RPC_REQUEST_DONE,sdkVersion:t.remote.state.sdkVersion,commLayerVersion:kn.version},t.remote.state.originatorInfo),{walletVersion:(S=t.remote.state.walletInfo)===null||S===void 0?void 0:S.version,params:{method:N.method,from:"mobile"}}),t.remote.state.communicationServerUrl).catch(P=>{}),Xr(N.method)&&Me.analytics.track($.error?$.error.code===4001?"sdk_action_rejected":"sdk_action_failed":"sdk_action_succeeded",{action:N.method});const C=Object.assign(Object.assign({},N),{result:$.result,error:$.error?{code:(_=$.error)===null||_===void 0?void 0:_.code,message:(O=$.error)===null||O===void 0?void 0:O.message}:void 0,elapsedTime:R});t.state.rpcMethodTracker[$.id]=C,t.emit(te.RPC_UPDATE,C)}}t.emit(te.MESSAGE,{message:G})}}},{event:te.REJECTED,handler:function(t,e){return n=>Z(this,void 0,void 0,function*(){var r;t.state.isOriginator&&!t.remote.state.ready?(V.SocketService(`[SocketService: handleChannelRejected()] context=${t.state.context} channelId=${e} isOriginator=${t.state.isOriginator} ready=${t.remote.state.ready}`,t.remote.state.originatorInfo),en(Object.assign(Object.assign({id:e,event:Re.REJECTED},t.remote.state.originatorInfo),{sdkVersion:t.remote.state.sdkVersion,commLayer:t.state.communicationLayerPreference,commLayerVersion:kn.version,walletVersion:(r=t.remote.state.walletInfo)===null||r===void 0?void 0:r.version}),t.remote.state.communicationServerUrl).catch(i=>{}),Me.analytics.track("sdk_connection_rejected",{transport_type:"websocket"}),yield t.remote.disconnect({terminate:!0}),t.remote.emit(te.REJECTED,{channelId:e}),t.remote.setConnectionStatus(je.DISCONNECTED)):V.SocketService(`[SocketService: handleChannelRejected()] SKIP -- channelId=${e} isOriginator=${t.state.isOriginator} ready=${t.remote.state.ready}`)})}},{event:"clients_waiting_to_join",handler:function(t,e){return n=>{V.SocketService(`[SocketService: handleClientsWaitingToJoin()] context=${t.state.context} on 'clients_waiting_to_join-${e}'`,n),t.emit(te.CLIENTS_WAITING,n)}}}],Hm=[{event:te.KEY_INFO,handler:function(t){return e=>{V.SocketService("[SocketService: handleKeyInfo()] on 'KEY_INFO'",e),t.emit(te.KEY_INFO,e)}}},{event:te.KEYS_EXCHANGED,handler:function(t){return()=>{var e,n,r;V.SocketService(`[SocketService: handleKeysExchanged()] on 'keys_exchanged' keyschanged=${(e=t.state.keyExchange)===null||e===void 0?void 0:e.areKeysExchanged()}`);const{channelConfig:i}=t.remote.state;if(i){const a=t.getKeyExchange().getKeyInfo().ecies;i.localKey=a.private,i.otherKey=a.otherPubKey,t.remote.state.channelConfig=i,(n=t.remote.state.storageManager)===null||n===void 0||n.persistChannelConfig(i).catch(s=>{})}t.emit(te.KEYS_EXCHANGED,{keysExchanged:(r=t.state.keyExchange)===null||r===void 0?void 0:r.areKeysExchanged(),isOriginator:t.state.isOriginator});const o={keyInfo:t.getKeyInfo()};t.emit(te.SERVICE_STATUS,o)}}}];function ul(t,e){V.SocketService(`[SocketService: setupChannelListener()] context=${t.state.context} setting socket listeners for channel ${e}...`);const{socket:n}=t.state,{keyExchange:r}=t.state;n&&t.state.isOriginator&&(t.state.debug&&(n==null||n.io.on("error",i=>{V.SocketService(`[SocketService: setupChannelListener()] context=${t.state.context} socket event=error`,i)}),n==null||n.io.on("reconnect",i=>{V.SocketService(`[SocketService: setupChannelListener()] context=${t.state.context} socket event=reconnect`,i),Xs(t).catch(o=>{})}),n==null||n.io.on("reconnect_error",i=>{V.SocketService(`[SocketService: setupChannelListener()] context=${t.state.context} socket event=reconnect_error`,i)}),n==null||n.io.on("reconnect_failed",()=>{V.SocketService(`[SocketService: setupChannelListener()] context=${t.state.context} socket event=reconnect_failed`)})),n==null||n.on("disconnect",i=>(V.SocketService(`[SocketService: setupChannelListener()] on 'disconnect' -- MetaMaskSDK socket disconnected '${i}' begin recovery...`),function(o){return a=>{V.SocketService(`[SocketService: handleDisconnect()] on 'disconnect' manualDisconnect=${o.state.manualDisconnect}`,a),o.state.manualDisconnect||(o.emit(te.SOCKET_DISCONNECTED),Xs(o).catch(s=>{}))}}(t)(i)))),Um.forEach(({event:i,handler:o})=>{n==null||n.on(`${i}-${e}`,o(t,e))}),Hm.forEach(({event:i,handler:o})=>{r==null||r.on(i,o(t))}),t.state.setupChannelListeners=!0}class Fm extends _o.EventEmitter2{constructor(e){super(),this.state={clientsConnected:!1,clientsPaused:!1,manualDisconnect:!1,lastRpcId:void 0,rpcMethodTracker:{},hasPlaintext:!1,communicationServerUrl:"",focusListenerAdded:!1,removeFocusListener:void 0,isReconnecting:!1,reconnectionAttempts:0},this.options=e;const{reconnect:n,communicationLayerPreference:r,communicationServerUrl:i,context:o,remote:a,logging:s}=e;this.state.resumed=n,this.state.context=o,this.state.isOriginator=a.state.isOriginator,this.state.communicationLayerPreference=r,this.state.debug=(s==null?void 0:s.serviceLayer)===!0,this.remote=a,(s==null?void 0:s.serviceLayer)===!0&&Ze.enable("SocketService:Layer"),this.state.communicationServerUrl=i,this.state.hasPlaintext=this.state.communicationServerUrl!==ar&&(s==null?void 0:s.plaintext)===!0,V.SocketService(`[SocketService: constructor()] Socket IO url: ${this.state.communicationServerUrl}`),this.initSocket()}initSocket(){var e;const{otherPublicKey:n,ecies:r,logging:i}=this.options,o={autoConnect:!1,transports:Bm,withCredentials:!0},a=this.state.communicationServerUrl;V.SocketService(`[SocketService: initSocket()] Socket IO url: ${a}`),this.state.socket=Ri(a,o),function(c){if(typeof window<"u"&&typeof document<"u"&&(V.SocketService(`[SocketService: setupSocketFocusListener()] hasFocus=${document.hasFocus()}`,c),!c.state.focusListenerAdded)){const l=()=>{V.SocketService("Document has focus --- reconnecting socket"),Xs(c).catch(u=>{})};window.addEventListener("focus",l),c.state.focusListenerAdded=!0,c.state.removeFocusListener=()=>{window.removeEventListener("focus",l),c.state.focusListenerAdded=!1}}}(this);const s={communicationLayer:this,otherPublicKey:n,sendPublicKey:!1,context:(e=this.state.context)!==null&&e!==void 0?e:"",ecies:r,logging:i};this.state.keyExchange=new jm(s)}resetKeys(){return V.SocketService("[SocketService: resetKeys()] Resetting keys."),void((e=this.state.keyExchange)===null||e===void 0||e.resetKeys());var e}createChannel(){return Z(this,void 0,void 0,function*(){return function(e){return Z(this,void 0,void 0,function*(){var n,r,i;if(V.SocketService(`[SocketService: createChannel()] context=${e.state.context}`),e.state.socket||e.initSocket(),(n=e.state.socket)===null||n===void 0?void 0:n.connected)throw new Error("socket already connected");(r=e.state.socket)===null||r===void 0||r.connect(),e.state.manualDisconnect=!1,e.state.isOriginator=!0;const o=yn();e.state.channelId=o,ul(e,o),yield new Promise((s,c)=>{var l;(l=e.state.socket)===null||l===void 0||l.emit(te.JOIN_CHANNEL,{channelId:o,context:`${e.state.context}createChannel`,clientType:"dapp"},(u,d)=>Z(this,void 0,void 0,function*(){try{yield Li(e,u,d),s()}catch(h){c(h)}}))});const a=(i=e.state.keyExchange)===null||i===void 0?void 0:i.getKeyInfo();return{channelId:o,pubKey:(a==null?void 0:a.ecies.public)||"",privKey:(a==null?void 0:a.ecies.private)||""}})}(this)})}connectToChannel({channelId:e,withKeyExchange:n=!1,authorized:r}){return function(i){return Z(this,arguments,void 0,function*({options:o,instance:a}){const{channelId:s,authorized:c,withKeyExchange:l}=o,{state:u,remote:d}=a,{isOriginator:h=!1,socket:f,keyExchange:g}=u,{channelConfig:m}=d.state;if(f!=null&&f.connected)throw new Error("socket already connected");if(h&&(m!=null&&m.relayPersistence)){const{localKey:w,otherKey:p}=m;w&&p&&(g==null||g.setRelayPersistence({localKey:w,otherKey:p}))}return Object.assign(u,{manualDisconnect:!1,withKeyExchange:l,isOriginator:h,channelId:s}),f==null||f.connect(),ul(a,s),!h&&c&&(g==null||g.setKeysExchanged(!0),Object.assign(d.state,{ready:!0,authorized:!0})),new Promise(w=>{var p;const S=(p=g==null?void 0:g.getKeyInfo())===null||p===void 0?void 0:p.ecies.public;f==null||f.emit(te.JOIN_CHANNEL,{channelId:s,context:`${u.context}_connectToChannel`,clientType:h?"dapp":"wallet",publicKey:c&&!h?S:void 0},(_,O)=>Z(this,void 0,void 0,function*(){yield Li(a,_,O),w()}))})})}({options:{channelId:e,withKeyExchange:n,authorized:r},instance:this})}getKeyInfo(){return this.state.keyExchange.getKeyInfo()}keyCheck(){var e,n;(n=(e=this).state.socket)===null||n===void 0||n.emit(te.MESSAGE,{id:e.state.channelId,context:e.state.context,message:{type:Se.KEY_HANDSHAKE_CHECK,pubkey:e.getKeyInfo().ecies.otherPubKey}})}getKeyExchange(){return this.state.keyExchange}sendMessage(e){return Z(this,void 0,void 0,function*(){return function(n,r){return Z(this,void 0,void 0,function*(){var i,o,a;if(!n.state.channelId)throw V.SocketService("handleSendMessage: no channelId - Create a channel first"),new Error("Create a channel first");if(V.SocketService(`[SocketService: handleSendMessage()] context=${n.state.context} areKeysExchanged=${(i=n.state.keyExchange)===null||i===void 0?void 0:i.areKeysExchanged()}`,r),(o=r==null?void 0:r.type)===null||o===void 0?void 0:o.startsWith("key_handshake"))return function(c,l){var u;V.SocketService(`[SocketService: handleKeyHandshake()] context=${c.state.context}`,l),(u=c.state.socket)===null||u===void 0||u.emit(te.MESSAGE,{id:c.state.channelId,context:c.state.context,clientType:c.state.isOriginator?"dapp":"wallet",message:l})}(n,r),!0;(function(c,l){var u;if(!(!((u=c.state.keyExchange)===null||u===void 0)&&u.areKeysExchanged())&&!c.remote.state.relayPersistence)throw V.SocketService(`[SocketService: validateKeyExchange()] context=${c.state.context} ERROR keys not exchanged`,l),new Error("Keys not exchanged BBB")})(n,r),function(c,l){var u;const d=(u=l==null?void 0:l.method)!==null&&u!==void 0?u:"",h=l==null?void 0:l.id;c.state.isOriginator&&h&&(c.state.rpcMethodTracker[h]={id:h,timestamp:Date.now(),method:d},c.emit(te.RPC_UPDATE,c.state.rpcMethodTracker[h]))}(n,r);const s=yield Sh(n,r);return n.remote.state.analytics&&n.remote.state.isOriginator&&r.method&&Ch.includes(r.method.toLowerCase())&&en({id:(a=n.remote.state.channelId)!==null&&a!==void 0?a:"",event:Re.SDK_RPC_REQUEST,params:{method:r.method,from:"mobile"}},n.remote.state.communicationServerUrl).catch(c=>{}),n.remote.state.isOriginator&&r.method&&Xr(r.method)&&Me.analytics.track("sdk_action_requested",{action:r.method}),function(c,l){return Z(this,void 0,void 0,function*(){var u;const d=l==null?void 0:l.id,h=(u=l==null?void 0:l.method)!==null&&u!==void 0?u:"";if(c.state.isOriginator&&d)try{const f=ll(d,c.state.rpcMethodTracker,200).then(w=>({type:er.RPC_CHECK,result:w})),g=Z(this,void 0,void 0,function*(){const w=yield(S=>Z(void 0,[S],void 0,function*({rpcId:_,instance:O}){for(;O.state.lastRpcId===_||O.state.lastRpcId===void 0;)yield ir(200);return O.state.lastRpcId}))({instance:c,rpcId:d}),p=yield ll(w,c.state.rpcMethodTracker,200);return{type:er.SKIPPED_RPC,result:p}}),m=yield Promise.race([f,g]);if(m.type===er.RPC_CHECK){const w=m.result;V.SocketService(`[SocketService:handleRpcReplies()] id=${l.id} ${h} ( ${w.elapsedTime} ms)`,w.result)}else{if(m.type!==er.SKIPPED_RPC)throw new Error(`Error handling RPC replies for ${d}`);{const w=Object.assign(Object.assign({},c.state.rpcMethodTracker[d]),{error:new Error("SDK_CONNECTION_ISSUE")});c.emit(te.RPC_UPDATE,w);const p={data:Object.assign(Object.assign({},w),{jsonrpc:"2.0"}),name:"metamask-provider"};c.emit(te.MESSAGE,{message:p})}}}catch(f){throw f}})}(n,r).catch(c=>{}),s})}(this,e)})}ping(){return function(e){return Z(this,void 0,void 0,function*(){var n,r;V.SocketService(`[SocketService: ping()] context=${e.state.context} originator=${e.state.isOriginator} keysExchanged=${(n=e.state.keyExchange)===null||n===void 0?void 0:n.areKeysExchanged()}`),(r=e.state.socket)===null||r===void 0||r.emit(Ae.PING,{id:e.state.channelId,context:"ping",clientType:e.remote.state.isOriginator?"dapp":"wallet",message:""})})}(this)}pause(){return function(e){return Z(this,void 0,void 0,function*(){var n,r;V.SocketService(`[SocketService: pause()] context=${e.state.context}`),e.state.manualDisconnect=!0,!((n=e.state.keyExchange)===null||n===void 0)&&n.areKeysExchanged()&&(yield e.sendMessage({type:Ae.PAUSE})),(r=e.state.socket)===null||r===void 0||r.disconnect()})}(this)}isConnected(){var e;return(e=this.state.socket)===null||e===void 0?void 0:e.connected}resume(){return function(e){return Z(this,void 0,void 0,function*(){const{state:n,remote:r}=e,{socket:i,channelId:o,context:a,keyExchange:s,isOriginator:c}=n,{isOriginator:l}=r.state;if(V.SocketService(`[SocketService: resume()] channelId=${o} context=${a} connected=${i==null?void 0:i.connected} manualDisconnect=${n.manualDisconnect} resumed=${n.resumed} keysExchanged=${s==null?void 0:s.areKeysExchanged()}`),!o)throw V.SocketService("[SocketService: resume()] channelId is not defined"),new Error("ChannelId is not defined");i!=null&&i.connected?(V.SocketService("[SocketService: resume()] already connected."),i.emit(Ae.PING,{id:o,clientType:l?"dapp":"wallet",context:"on_channel_config",message:""}),r.hasRelayPersistence()||s!=null&&s.areKeysExchanged()||(c?yield e.sendMessage({type:Ae.READY}):s==null||s.start({isOriginator:!1}))):(i==null||i.connect(),V.SocketService(`[SocketService: resume()] after connecting socket --> connected=${i==null?void 0:i.connected}`),i==null||i.emit(te.JOIN_CHANNEL,{channelId:o,context:`${a}_resume`,clientType:l?"dapp":"wallet"},(u,d)=>Z(this,void 0,void 0,function*(){try{yield Li(e,u,d)}catch{}}))),n.manualDisconnect=!1,n.resumed=!0})}(this)}getRPCMethodTracker(){return this.state.rpcMethodTracker}disconnect(e){return function(n,r){var i,o,a,s,c;V.SocketService(`[SocketService: disconnect()] context=${n.state.context}`,r),r!=null&&r.terminate&&((o=(i=n.state).removeFocusListener)===null||o===void 0||o.call(i),n.state.channelId=r.channelId,(a=n.state.socket)===null||a===void 0||a.removeAllListeners(),(s=n.state.keyExchange)===null||s===void 0||s.clean(),n.remote.state.ready=!1,n.state.socket=void 0,n.state.rpcMethodTracker={}),n.state.manualDisconnect=!0,(c=n.state.socket)===null||c===void 0||c.disconnect()}(this,e)}}var Bn,qe,dl;function zm(t){return()=>Z(this,void 0,void 0,function*(){var e,n,r;const{state:i}=t;if(i.authorized)return;yield Z(this,void 0,void 0,function*(){for(;!i.walletInfo;)yield ir(500)});const o="7.3".localeCompare(((e=i.walletInfo)===null||e===void 0?void 0:e.version)||"");if(V.RemoteCommunication(`[RemoteCommunication: handleAuthorizedEvent()] HACK 'authorized' version=${(n=i.walletInfo)===null||n===void 0?void 0:n.version} compareValue=${o}`),o!==1)return;const a=i.platformType===qe.MobileWeb||i.platformType===qe.ReactNative||i.platformType===qe.MetaMaskMobileWebview;V.RemoteCommunication(`[RemoteCommunication: handleAuthorizedEvent()] HACK 'authorized' platform=${i.platformType} secure=${a} channel=${i.channelId} walletVersion=${(r=i.walletInfo)===null||r===void 0?void 0:r.version}`),a&&(i.authorized=!0,t.emit(te.AUTHORIZED))})}function qm(t){return e=>{const{state:n}=t;V.RemoteCommunication(`[RemoteCommunication: handleChannelCreatedEvent()] context=${n.context} on 'channel_created' channelId=${e}`),t.emit(te.CHANNEL_CREATED,e)}}function Vm(t,e){return()=>{var n,r,i,o;const{state:a}=t;V.RemoteCommunication(`[RemoteCommunication: handleClientsConnectedEvent()] on 'clients_connected' channel=${a.channelId} keysExchanged=${(r=(n=a.communicationLayer)===null||n===void 0?void 0:n.getKeyInfo())===null||r===void 0?void 0:r.keysExchanged}`),a.analytics&&en(Object.assign(Object.assign({id:(i=a.channelId)!==null&&i!==void 0?i:"",event:a.reconnection?Re.RECONNECT:a.isOriginator?Re.REQUEST:Re.REQUEST_MOBILE},a.originatorInfo),{commLayer:e,sdkVersion:a.sdkVersion,walletVersion:(o=a.walletInfo)===null||o===void 0?void 0:o.version,commLayerVersion:kn.version}),a.communicationServerUrl).catch(s=>{}),a.isOriginator&&!a.reconnection&&Me.analytics.track("sdk_connection_established",{transport_type:"websocket"}),a.clientsConnected=!0,a.originatorInfoSent=!1,t.emit(te.CLIENTS_CONNECTED)}}function Wm(t){return e=>{const{state:n}=t;V.RemoteCommunication(`[RemoteCommunication: handleClientsDisconnectedEvent()] context=${n.context} on 'clients_disconnected' channelId=${e}`),n.relayPersistence||(n.clientsConnected=!1,n.ready=!1,n.authorized=!1),t.emit(te.CLIENTS_DISCONNECTED,n.channelId),t.setConnectionStatus(je.DISCONNECTED)}}function Gm(t){return e=>{var n;const{state:r}=t;if(V.RemoteCommunication(`[RemoteCommunication: handleClientsWaitingEvent()] context=${r.context} on 'clients_waiting' numberUsers=${e} ready=${r.ready} autoStarted=${r.originatorConnectStarted}`),t.setConnectionStatus(je.WAITING),t.emit(te.CLIENTS_WAITING,e),r.originatorConnectStarted){V.RemoteCommunication(`[RemoteCommunication: handleClientsWaitingEvent()] on 'clients_waiting' watch autoStarted=${r.originatorConnectStarted} timeout`,r.autoConnectOptions);const i=((n=r.autoConnectOptions)===null||n===void 0?void 0:n.timeout)||3e3,o=setTimeout(()=>{V.RemoteCommunication(`[RemoteCommunication: handleClientsWaitingEvent()] setTimeout(${i}) terminate channelConfig`,r.autoConnectOptions),r.originatorConnectStarted=!1,r.ready||t.setConnectionStatus(je.TIMEOUT),clearTimeout(o)},i)}}}function Ym(t,e){return n=>{var r,i,o,a,s,c,l,u;const{state:d}=t;if(V.RemoteCommunication(`[RemoteCommunication: handleKeysExchangedEvent()] context=${d.context} on commLayer.'keys_exchanged' channel=${d.channelId}`,n),(i=(r=d.communicationLayer)===null||r===void 0?void 0:r.getKeyInfo())===null||i===void 0?void 0:i.keysExchanged){const h=Object.assign(Object.assign({},d.channelConfig),{channelId:(o=d.channelId)!==null&&o!==void 0?o:"",validUntil:((a=d.channelConfig)===null||a===void 0?void 0:a.validUntil)||cr,localKey:d.communicationLayer.getKeyInfo().ecies.private,otherKey:d.communicationLayer.getKeyInfo().ecies.otherPubKey});(s=d.storageManager)===null||s===void 0||s.persistChannelConfig(h).catch(f=>{}),t.setConnectionStatus(je.LINKED)}(function(h,f){var g,m,w,p,S,_,O,I;const{state:K}=h;V.RemoteCommunication(`[RemoteCommunication: setLastActiveDate()] channel=${K.channelId}`,f);const q=Object.assign(Object.assign({},K.channelConfig),{channelId:(g=K.channelId)!==null&&g!==void 0?g:"",validUntil:(w=(m=K.channelConfig)===null||m===void 0?void 0:m.validUntil)!==null&&w!==void 0?w:0,relayPersistence:K.relayPersistence,localKey:(S=(p=K.communicationLayer)===null||p===void 0?void 0:p.state.keyExchange)===null||S===void 0?void 0:S.getKeyInfo().ecies.private,otherKey:(O=(_=K.communicationLayer)===null||_===void 0?void 0:_.state.keyExchange)===null||O===void 0?void 0:O.getKeyInfo().ecies.otherPubKey,lastActive:f.getTime()});(I=K.storageManager)===null||I===void 0||I.persistChannelConfig(q)})(t,new Date),d.analytics&&d.channelId&&en(Object.assign(Object.assign({id:d.channelId,event:n.isOriginator?Re.CONNECTED:Re.CONNECTED_MOBILE},d.originatorInfo),{sdkVersion:d.sdkVersion,commLayer:e,commLayerVersion:kn.version,walletVersion:(c=d.walletInfo)===null||c===void 0?void 0:c.version}),d.communicationServerUrl).catch(h=>{}),d.isOriginator=n.isOriginator,n.isOriginator||((l=d.communicationLayer)===null||l===void 0||l.sendMessage({type:Ae.READY}),d.ready=!0,d.paused=!1),n.isOriginator&&!d.originatorInfoSent&&((u=d.communicationLayer)===null||u===void 0||u.sendMessage({type:Ae.ORIGINATOR_INFO,originatorInfo:d.originatorInfo,originator:d.originatorInfo}),d.originatorInfoSent=!0)}}function Zm(t){return e=>{let n=e;e.message&&(n=n.message),function(r,i){const{state:o}=i;if(V.RemoteCommunication(`[RemoteCommunication: onCommunicationLayerMessage()] context=${o.context} on 'message' typeof=${typeof r}`,r),i.state.ready=!0,o.isOriginator||r.type!==Ae.ORIGINATOR_INFO)if(o.isOriginator&&r.type===Ae.WALLET_INFO)(function(a,s){const{state:c}=a;c.walletInfo=s.walletInfo,c.paused=!1})(i,r);else{if(o.isOriginator&&r.type===Ae.WALLET_INIT)(function(a,s){return Z(this,void 0,void 0,function*(){var c,l,u;const{state:d}=a;if(d.isOriginator){const h=s.data||{};if(typeof h=="object"&&"accounts"in h&&"chainId"in h&&"walletKey"in h)try{const{channelConfig:f}=a.state;if(V.RemoteCommunication("WALLET_INIT: channelConfig",JSON.stringify(f,null,2)),f){const g=h.accounts,m=h.chainId,w=h.walletKey;let p,S=!1;"deeplinkProtocol"in h&&(S=!!h.deeplinkProtocol,a.state.deeplinkProtocolAvailable=S),"walletVersion"in h&&(p=h.walletVersion),yield(c=a.state.storageManager)===null||c===void 0?void 0:c.persistChannelConfig(Object.assign(Object.assign({},f),{otherKey:w,walletVersion:p,deeplinkProtocolAvailable:S,relayPersistence:!0})),yield(l=a.state.storageManager)===null||l===void 0?void 0:l.persistAccounts(g),yield(u=a.state.storageManager)===null||u===void 0?void 0:u.persistChainId(m)}a.emit(te.WALLET_INIT,{accounts:h.accounts,chainId:h.chainId})}catch{}}})})(i,r).catch(a=>{V.RemoteCommunication(`[RemoteCommunication: onCommunicationLayerMessage()] error=${a}`)});else if(r.type===Ae.TERMINATE)(function(a){return Z(this,void 0,void 0,function*(){const{state:s}=a;s.isOriginator&&(yield kh({options:{terminate:!0,sendMessage:!1},instance:a}),a.emit(te.TERMINATE))})})(i).catch(a=>{V.RemoteCommunication(`[RemoteCommunication: onCommunicationLayerMessage()] error=${a}`)});else if(r.type===Ae.PAUSE)(function(a){const{state:s}=a;s.paused=!0,a.setConnectionStatus(je.PAUSED)})(i);else if(r.type===Ae.READY&&o.isOriginator)(function(a){const{state:s}=a;a.setConnectionStatus(je.LINKED);const c=s.paused;s.paused=!1,a.emit(te.CLIENTS_READY,{isOriginator:s.isOriginator,walletInfo:s.walletInfo}),c&&(s.authorized=!0,a.emit(te.AUTHORIZED))})(i);else{if(r.type===Ae.OTP&&o.isOriginator)return void function(a,s){var c;const{state:l}=a;a.emit(te.OTP,s.otpAnswer),"6.6".localeCompare(((c=l.walletInfo)===null||c===void 0?void 0:c.version)||"")===1&&a.emit(te.SDK_RPC_CALL,{method:He.ETH_REQUESTACCOUNTS,params:[]})}(i,r);r.type===Ae.AUTHORIZED&&o.isOriginator&&function(a){const{state:s}=a;s.authorized=!0,a.emit(te.AUTHORIZED)}(i)}i.emit(te.MESSAGE,r)}else(function(a,s){var c;const{state:l}=a;(c=l.communicationLayer)===null||c===void 0||c.sendMessage({type:Ae.WALLET_INFO,walletInfo:l.walletInfo}),l.originatorInfo=s.originatorInfo||s.originator,a.emit(te.CLIENTS_READY,{isOriginator:l.isOriginator,originatorInfo:l.originatorInfo}),l.paused=!1})(i,r)}(n,t)}}function Jm(t){return()=>{const{state:e}=t;V.RemoteCommunication("[RemoteCommunication: handleSocketReconnectEvent()] on 'socket_reconnect' -- reset key exchange status / set ready to false"),e.ready=!1,e.authorized=!1,_h(e),t.emitServiceStatusEvent({context:"socket_reconnect"})}}function Xm(t){return()=>{const{state:e}=t;V.RemoteCommunication("[RemoteCommunication: handleSocketDisconnectedEvent()] on 'socket_Disconnected' set ready to false"),e.ready=!1}}function Qm(t){return()=>Z(this,void 0,void 0,function*(){var e,n,r,i,o,a,s;const{state:c}=t;V.RemoteCommunication(`[RemoteCommunication: handleFullPersistenceEvent()] context=${c.context}`),t.state.ready=!0,t.state.clientsConnected=!0,t.state.authorized=!0,t.state.relayPersistence=!0,(e=t.state.communicationLayer)===null||e===void 0||e.getKeyExchange().setKeysExchanged(!0),t.emit(te.KEYS_EXCHANGED,{keysExchanged:!0,isOriginator:!0}),t.emit(te.AUTHORIZED),t.emit(te.CLIENTS_READY),t.emit(te.CHANNEL_PERSISTENCE);try{c.channelConfig=Object.assign(Object.assign({},c.channelConfig),{localKey:(n=c.communicationLayer)===null||n===void 0?void 0:n.getKeyExchange().getKeyInfo().ecies.private,otherKey:(r=c.communicationLayer)===null||r===void 0?void 0:r.getKeyExchange().getOtherPublicKey(),channelId:(i=c.channelId)!==null&&i!==void 0?i:"",validUntil:(a=(o=c.channelConfig)===null||o===void 0?void 0:o.validUntil)!==null&&a!==void 0?a:cr,relayPersistence:!0}),yield(s=c.storageManager)===null||s===void 0?void 0:s.persistChannelConfig(c.channelConfig)}catch{}})}function hl({communicationLayerPreference:t,otherPublicKey:e,reconnect:n,ecies:r,communicationServerUrl:i=ar,instance:o}){var a,s,c,l,u,d,h,f,g,m,w;const{state:p}=o;if(V.RemoteCommunication("[initCommunicationLayer()] ",JSON.stringify(p,null,2)),t!==Bn.SOCKET)throw new Error("Invalid communication protocol");p.communicationLayer=new Fm({communicationLayerPreference:t,otherPublicKey:e,reconnect:n,transports:p.transports,communicationServerUrl:i,context:p.context,ecies:r,logging:p.logging,remote:o});let S=typeof document<"u"&&document.URL||"",_=typeof document<"u"&&document.title||"";!((a=p.dappMetadata)===null||a===void 0)&&a.url&&(S=p.dappMetadata.url),!((s=p.dappMetadata)===null||s===void 0)&&s.name&&(_=p.dappMetadata.name);const O=(d=(l=(c=p.dappMetadata)===null||c===void 0?void 0:c.name)!==null&&l!==void 0?l:(u=p.dappMetadata)===null||u===void 0?void 0:u.url)!==null&&d!==void 0?d:"N/A",I=typeof window<"u"&&window.location!==void 0&&(h=window.location.hostname)!==null&&h!==void 0?h:O,K={url:S,title:_,source:(f=p.dappMetadata)===null||f===void 0?void 0:f.source,dappId:I,anonId:p.anonId,icon:((g=p.dappMetadata)===null||g===void 0?void 0:g.iconUrl)||((m=p.dappMetadata)===null||m===void 0?void 0:m.base64Icon),platform:p.platformType,apiVersion:kn.version,connector:(w=p.dappMetadata)===null||w===void 0?void 0:w.connector};p.originatorInfo=K;const q={[te.AUTHORIZED]:zm(o),[te.MESSAGE]:Zm(o),[te.CHANNEL_PERSISTENCE]:Qm(o),[te.CLIENTS_CONNECTED]:Vm(o,t),[te.KEYS_EXCHANGED]:Ym(o,t),[te.SOCKET_DISCONNECTED]:Xm(o),[te.SOCKET_RECONNECT]:Jm(o),[te.CLIENTS_DISCONNECTED]:Wm(o),[te.KEY_INFO]:()=>{},[te.CHANNEL_CREATED]:qm(o),[te.CLIENTS_WAITING]:Gm(o),[te.RPC_UPDATE]:F=>{o.emit(te.RPC_UPDATE,F)}};for(const[F,U]of Object.entries(q))try{p.communicationLayer.on(F,U)}catch{}}function kh(t){return Z(this,arguments,void 0,function*({options:e,instance:n}){const{state:r}=n;return V.RemoteCommunication(`[RemoteCommunication: disconnect()] channel=${r.channelId}`,e),new Promise((i,o)=>{var a,s,c,l,u,d;e!=null&&e.terminate?(n.state.ready&&en({id:(a=n.state.channelId)!==null&&a!==void 0?a:"",event:Re.TERMINATED},n.state.communicationServerUrl).catch(h=>{}),r.ready=!1,r.paused=!1,(s=r.storageManager)===null||s===void 0||s.terminate((c=r.channelId)!==null&&c!==void 0?c:""),n.state.terminated=!0,e.sendMessage?!((l=r.communicationLayer)===null||l===void 0)&&l.getKeyInfo().keysExchanged&&n.state.communicationLayer&&Sh(n.state.communicationLayer,{type:Ae.TERMINATE}).then(()=>{i(!0)}).catch(h=>{o(h)}):i(!0),r.authorized=!1,r.relayPersistence=!1,r.channelId=yn(),e.channelId=r.channelId,r.channelConfig=void 0,r.originatorConnectStarted=!1,(u=r.communicationLayer)===null||u===void 0||u.disconnect(e),n.setConnectionStatus(je.TERMINATED)):((d=r.communicationLayer)===null||d===void 0||d.disconnect(e),n.setConnectionStatus(je.DISCONNECTED),i(!0))})})}(Bn||(Bn={})).SOCKET="socket",function(t){t.NonBrowser="nodejs",t.MetaMaskMobileWebview="in-app-browser",t.DesktopWeb="web-desktop",t.MobileWeb="web-mobile",t.ReactNative="react-native"}(qe||(qe={}));class eg extends _o.EventEmitter2{constructor(e){super(),this.state={ready:!1,anonId:"",authorized:!1,isOriginator:!1,terminated:!1,protocolVersion:1,paused:!1,deeplinkProtocolAvailable:!1,platformType:"metamask-mobile",analytics:!1,reconnection:!1,originatorInfoSent:!1,communicationServerUrl:ar,context:"",persist:!1,clientsConnected:!1,sessionDuration:cr,originatorConnectStarted:!1,debug:!1,_connectionStatus:je.DISCONNECTED},this._options=e;const{anonId:n,platformType:r,communicationLayerPreference:i,otherPublicKey:o,reconnect:a,walletInfo:s,dappMetadata:c,protocolVersion:l,transports:u,context:d,relayPersistence:h,ecies:f,analytics:g=!1,storage:m,sdkVersion:w,communicationServerUrl:p=ar,logging:S,autoConnect:_={timeout:$m}}=e;this.state.anonId=n,this.state.otherPublicKey=o,this.state.dappMetadata=c,this.state.walletInfo=s,this.state.transports=u,this.state.platformType=r,this.state.analytics=g,this.state.protocolVersion=l??1,this.state.isOriginator=!o,this.state.relayPersistence=h,this.state.communicationServerUrl=p,this.state.context=d,this.state.terminated=!1,this.state.sdkVersion=w,this.setMaxListeners(50),this.setConnectionStatus(je.DISCONNECTED),m!=null&&m.duration&&(this.state.sessionDuration=cr),this.state.storageOptions=m,this.state.autoConnectOptions=_,this.state.debug=(S==null?void 0:S.remoteLayer)===!0,(S==null?void 0:S.remoteLayer)===!0&&Ze.enable("RemoteCommunication:Layer"),(S==null?void 0:S.serviceLayer)===!0&&Ze.enable("SocketService:Layer"),(S==null?void 0:S.eciesLayer)===!0&&Ze.enable("ECIES:Layer"),(S==null?void 0:S.keyExchangeLayer)===!0&&Ze.enable("KeyExchange:Layer"),this.state.logging=S,m!=null&&m.storageManager&&(this.state.storageManager=m.storageManager),V.RemoteCommunication(`[RemoteCommunication: constructor()] protocolVersion=${l} relayPersistence=${h} isOriginator=${this.state.isOriginator} communicationLayerPreference=${i} otherPublicKey=${o} reconnect=${a}`),this.state.isOriginator||hl({communicationLayerPreference:i,otherPublicKey:o,reconnect:a,ecies:f,communicationServerUrl:p,instance:this}),this.emitServiceStatusEvent({context:"constructor"})}initFromDappStorage(){return Z(this,void 0,void 0,function*(){var e;if(this.state.storageManager){const n=yield this.state.storageManager.getPersistedChannelConfig({});n&&(this.state.channelConfig=n,this.state.channelId=n.channelId,this.state.deeplinkProtocolAvailable=(e=n.deeplinkProtocolAvailable)!==null&&e!==void 0&&e,n.relayPersistence&&(this.state.authorized=!0,this.state.ready=!0,this.setConnectionStatus(je.LINKED),yield this.connectToChannel({channelId:n.channelId})))}hl({communicationLayerPreference:Bn.SOCKET,otherPublicKey:this.state.otherPublicKey,reconnect:this._options.reconnect,ecies:this._options.ecies,communicationServerUrl:this.state.communicationServerUrl,instance:this})})}originatorSessionConnect(){return Z(this,void 0,void 0,function*(){return yield function(e){return Z(this,void 0,void 0,function*(){var n;const{state:r}=e;if(!r.storageManager)return void V.RemoteCommunication("[RemoteCommunication: originatorSessionConnect()] no storage manager defined - skip");const i=yield r.storageManager.getPersistedChannelConfig({});if(V.RemoteCommunication(`[RemoteCommunication: originatorSessionConnect()] autoStarted=${r.originatorConnectStarted} channelConfig`,i),(n=r.communicationLayer)===null||n===void 0?void 0:n.isConnected())return V.RemoteCommunication("[RemoteCommunication: originatorSessionConnect()] socket already connected - skip"),i;if(i){if(i.validUntil>Date.now())return r.channelConfig=i,r.originatorConnectStarted=!0,r.channelId=i==null?void 0:i.channelId,r.reconnection=!0,i;V.RemoteCommunication("[RemoteCommunication: autoConnect()] Session has expired")}r.originatorConnectStarted=!1})}(this)})}generateChannelIdConnect(){return Z(this,void 0,void 0,function*(){return function(e){return Z(this,void 0,void 0,function*(){var n,r,i,o,a,s;if(!e.communicationLayer)throw new Error("communication layer not initialized");if(e.ready)throw new Error("Channel already connected");if(e.channelId&&(!((n=e.communicationLayer)===null||n===void 0)&&n.isConnected()))return e.channelConfig=Object.assign(Object.assign({},e.channelConfig),{channelId:e.channelId,validUntil:Date.now()+e.sessionDuration}),(r=e.storageManager)===null||r===void 0||r.persistChannelConfig(e.channelConfig),{channelId:e.channelId,privKey:(o=(i=e.communicationLayer)===null||i===void 0?void 0:i.getKeyInfo())===null||o===void 0?void 0:o.ecies.private,pubKey:(s=(a=e.communicationLayer)===null||a===void 0?void 0:a.getKeyInfo())===null||s===void 0?void 0:s.ecies.public};V.RemoteCommunication("[RemoteCommunication: generateChannelId()]");const c=yield e.communicationLayer.createChannel();V.RemoteCommunication("[RemoteCommunication: generateChannelId()] channel created",c);const l=Object.assign(Object.assign({},e.channelConfig),{channelId:c.channelId,localKey:c.privKey,validUntil:Date.now()+e.sessionDuration});return e.channelId=c.channelId,e.channelConfig=l,{channelId:e.channelId,pubKey:c.pubKey,privKey:c.privKey}})}(this.state)})}clean(){return _h(this.state)}connectToChannel({channelId:e,withKeyExchange:n,authorized:r}){return function(i){return Z(this,arguments,void 0,function*({channelId:o,withKeyExchange:a,authorized:s,state:c}){var l,u,d;if(!Ls(o))throw V.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${c.context} invalid channel channelId=${o}`),new Error(`Invalid channel ${o}`);if(V.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${c.context} channelId=${o} withKeyExchange=${a}`),(l=c.communicationLayer)===null||l===void 0?void 0:l.isConnected())return void V.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${c.context} already connected - interrupt connection.`);c.channelId=o,yield(u=c.communicationLayer)===null||u===void 0?void 0:u.connectToChannel({channelId:o,authorized:s,withKeyExchange:a});const h=Object.assign(Object.assign({},c.channelConfig),{channelId:o,validUntil:Date.now()+c.sessionDuration});c.channelConfig=h,(d=c.storageManager)===null||d===void 0||d.persistChannelConfig(h)})}({channelId:e,authorized:r,withKeyExchange:n,state:this.state})}sendMessage(e){return Z(this,void 0,void 0,function*(){const n=this.state.isOriginator&&e.method&&Xr(e.method);n&&Me.analytics.track("sdk_action_requested",{action:e.method});try{return yield function(r,i){return Z(this,void 0,void 0,function*(){var o,a;const{state:s}=r;V.RemoteCommunication(`[RemoteCommunication: sendMessage()] context=${s.context} paused=${s.paused} ready=${s.ready} relayPersistence=${s.relayPersistence} authorized=${s.authorized} socket=${(o=s.communicationLayer)===null||o===void 0?void 0:o.isConnected()} clientsConnected=${s.clientsConnected} status=${s._connectionStatus}`,i),s.relayPersistence||s.ready&&(!((a=s.communicationLayer)===null||a===void 0)&&a.isConnected())&&s.clientsConnected||(V.RemoteCommunication(`[RemoteCommunication: sendMessage()] context=${s.context} SKIP message waiting for MM mobile readiness.`),yield new Promise(c=>{r.once(te.CLIENTS_READY,c)}),V.RemoteCommunication(`[RemoteCommunication: sendMessage()] context=${s.context} AFTER SKIP / READY -- sending pending message`));try{return yield function(l,u){return Z(this,void 0,void 0,function*(){return new Promise(d=>{var h;const{state:f}=l;V.RemoteCommunication(`[RemoteCommunication: handleAuthorization()] context=${f.context} ready=${f.ready} authorized=${f.authorized} method=${u.method}`),!f.isOriginator||f.authorized||f.relayPersistence?(h=f.communicationLayer)===null||h===void 0||h.sendMessage(u).then(g=>{d(g)}).catch(g=>{d(!1)}):l.once(te.AUTHORIZED,()=>{var g;V.RemoteCommunication(`[RemoteCommunication: handleAuthorization()] context=${f.context} AFTER SKIP / AUTHORIZED -- sending pending message`),(g=f.communicationLayer)===null||g===void 0||g.sendMessage(u).then(m=>{d(m)}).catch(m=>{d(!1)})})})})}(r,i)}catch(c){throw c}})}(this,e)}catch(r){throw n&&Me.analytics.track("sdk_action_failed",{action:e.method}),r}})}testStorage(){return Z(this,void 0,void 0,function*(){return function(e){return Z(this,void 0,void 0,function*(){var n;const r=yield(n=e.storageManager)===null||n===void 0?void 0:n.getPersistedChannelConfig();V.RemoteCommunication("[RemoteCommunication: testStorage()] res",r)})}(this.state)})}hasDeeplinkProtocol(){return this.state.deeplinkProtocolAvailable}getChannelConfig(){return this.state.channelConfig}isReady(){return this.state.ready}isConnected(){var e;return(e=this.state.communicationLayer)===null||e===void 0?void 0:e.isConnected()}isAuthorized(){return this.state.authorized}isPaused(){return this.state.paused}getCommunicationLayer(){return this.state.communicationLayer}ping(){return Z(this,void 0,void 0,function*(){var e;V.RemoteCommunication(`[RemoteCommunication: ping()] channel=${this.state.channelId}`),yield(e=this.state.communicationLayer)===null||e===void 0?void 0:e.ping()})}testLogger(){V.RemoteCommunication(`testLogger() channel=${this.state.channelId}`),V.SocketService(`testLogger() channel=${this.state.channelId}`),V.Ecies(`testLogger() channel=${this.state.channelId}`),V.KeyExchange(`testLogger() channel=${this.state.channelId}`)}keyCheck(){var e;V.RemoteCommunication(`[RemoteCommunication: keyCheck()] channel=${this.state.channelId}`),(e=this.state.communicationLayer)===null||e===void 0||e.keyCheck()}setConnectionStatus(e){this.state._connectionStatus!==e&&(this.state._connectionStatus=e,this.emit(te.CONNECTION_STATUS,e),this.emitServiceStatusEvent({context:"setConnectionStatus"}))}emitServiceStatusEvent(e={}){this.emit(te.SERVICE_STATUS,this.getServiceStatus())}getConnectionStatus(){return this.state._connectionStatus}getServiceStatus(){return{originatorInfo:this.state.originatorInfo,keyInfo:this.getKeyInfo(),connectionStatus:this.state._connectionStatus,channelConfig:this.state.channelConfig,channelId:this.state.channelId}}getKeyInfo(){var e;return(e=this.state.communicationLayer)===null||e===void 0?void 0:e.getKeyInfo()}resetKeys(){var e;(e=this.state.communicationLayer)===null||e===void 0||e.resetKeys()}setOtherPublicKey(e){var n;const r=(n=this.state.communicationLayer)===null||n===void 0?void 0:n.getKeyExchange();if(!r)throw new Error("KeyExchange is not initialized.");r.getOtherPublicKey()!==e&&r.setOtherPublicKey(e)}pause(){return Z(this,void 0,void 0,function*(){var e;V.RemoteCommunication(`[RemoteCommunication: pause()] channel=${this.state.channelId}`),yield(e=this.state.communicationLayer)===null||e===void 0?void 0:e.pause(),this.setConnectionStatus(je.PAUSED)})}getVersion(){return kn.version}hasRelayPersistence(){var e;return(e=this.state.relayPersistence)!==null&&e!==void 0&&e}resume(){return Z(this,void 0,void 0,function*(){return function(e){return Z(this,void 0,void 0,function*(){var n;const{state:r}=e;V.RemoteCommunication(`[RemoteCommunication: resume()] channel=${r.channelId}`),yield(n=r.communicationLayer)===null||n===void 0?void 0:n.resume(),e.setConnectionStatus(je.LINKED)})}(this)})}encrypt(e){var n,r,i;const o=(n=this.state.communicationLayer)===null||n===void 0?void 0:n.getKeyExchange(),a=o==null?void 0:o.getOtherPublicKey();if(!a)throw new Error("KeyExchange not completed");return(i=(r=this.state.communicationLayer)===null||r===void 0?void 0:r.state.eciesInstance)===null||i===void 0?void 0:i.encrypt(e,a)}decrypt(e){var n,r,i;if(!(!((n=this.state.communicationLayer)===null||n===void 0)&&n.state.eciesInstance))throw new Error("ECIES instance is not initialized");return(i=(r=this.state.communicationLayer)===null||r===void 0?void 0:r.state.eciesInstance)===null||i===void 0?void 0:i.decrypt(e)}getChannelId(){return this.state.channelId}getRPCMethodTracker(){var e;return(e=this.state.communicationLayer)===null||e===void 0?void 0:e.getRPCMethodTracker()}reject({channelId:e}){return function(n){return Z(this,arguments,void 0,function*({channelId:r,state:i}){var o,a,s;if(!Ls(r))throw V.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${i.context} invalid channel channelId=${r}`),new Error(`Invalid channel ${r}`);if(i.isOriginator)return void V.RemoteCommunication(`[RemoteCommunication: reject()] context=${i.context} isOriginator=${i.isOriginator} channelId=${r}`);const{socket:c}=(a=(o=i.communicationLayer)===null||o===void 0?void 0:o.state)!==null&&a!==void 0?a:{};c!=null&&c.connected||(V.RemoteCommunication(`[RemoteCommunication: reject()] context=${i.context} socket already connected`),c==null||c.connect()),en(Object.assign(Object.assign({id:r,event:Re.REJECTED},i.originatorInfo),{sdkVersion:i.sdkVersion,commLayerVersion:kn.version,walletVersion:(s=i.walletInfo)===null||s===void 0?void 0:s.version}),i.communicationServerUrl).catch(l=>{}),yield new Promise((l,u)=>{c==null||c.emit(te.REJECTED,{channelId:r},(d,h)=>{V.RemoteCommunication(`[RemoteCommunication: reject()] context=${i.context} socket=${c==null?void 0:c.id}`,{error:d,response:h}),d?u(d):l(h)})})})}({channelId:e,state:this.state})}disconnect(e){return Z(this,void 0,void 0,function*(){return kh({options:e,instance:this})})}}(function(t){t.RENEW="renew",t.LINK="link"})(dl||(dl={}));var tg="ERC721",ng="ERC1155",Te={errors:{disconnected:()=>"MetaMask: Disconnected from chain. Attempting to connect.",permanentlyDisconnected:()=>"MetaMask: Disconnected from MetaMask background. Page reload required.",sendSiteMetadata:()=>"MetaMask: Failed to send site metadata. This is an internal error, please report this bug.",unsupportedSync:t=>`MetaMask: The MetaMask Ethereum provider does not support synchronous methods like ${t} without a callback parameter.`,invalidDuplexStream:()=>"Must provide a Node.js-style duplex stream.",invalidNetworkParams:()=>"MetaMask: Received invalid network parameters. Please report this bug.",invalidRequestArgs:()=>"Expected a single, non-array, object argument.",invalidRequestMethod:()=>"'args.method' must be a non-empty string.",invalidRequestParams:()=>"'args.params' must be an object or array if provided.",invalidLoggerObject:()=>"'args.logger' must be an object if provided.",invalidLoggerMethod:t=>`'args.logger' must include required method '${t}'.`},info:{connected:t=>`MetaMask: Connected to chain with ID "${t}".`},warnings:{chainIdDeprecation:`MetaMask: 'ethereum.chainId' is deprecated and may be removed in the future. Please use the 'eth_chainId' RPC method instead.
10
+ For more information, see: https://github.com/MetaMask/metamask-improvement-proposals/discussions/23`,networkVersionDeprecation:`MetaMask: 'ethereum.networkVersion' is deprecated and may be removed in the future. Please use the 'net_version' RPC method instead.
11
+ For more information, see: https://github.com/MetaMask/metamask-improvement-proposals/discussions/23`,selectedAddressDeprecation:`MetaMask: 'ethereum.selectedAddress' is deprecated and may be removed in the future. Please use the 'eth_accounts' RPC method instead.
12
+ For more information, see: https://github.com/MetaMask/metamask-improvement-proposals/discussions/23`,enableDeprecation:`MetaMask: 'ethereum.enable()' is deprecated and may be removed in the future. Please use the 'eth_requestAccounts' RPC method instead.
13
+ For more information, see: https://eips.ethereum.org/EIPS/eip-1102`,sendDeprecation:`MetaMask: 'ethereum.send(...)' is deprecated and may be removed in the future. Please use 'ethereum.sendAsync(...)' or 'ethereum.request(...)' instead.
14
+ For more information, see: https://eips.ethereum.org/EIPS/eip-1193`,events:{close:`MetaMask: The event 'close' is deprecated and may be removed in the future. Please use 'disconnect' instead.
15
+ For more information, see: https://eips.ethereum.org/EIPS/eip-1193#disconnect`,data:`MetaMask: The event 'data' is deprecated and will be removed in the future. Use 'message' instead.
16
+ For more information, see: https://eips.ethereum.org/EIPS/eip-1193#message`,networkChanged:`MetaMask: The event 'networkChanged' is deprecated and may be removed in the future. Use 'chainChanged' instead.
17
+ For more information, see: https://eips.ethereum.org/EIPS/eip-1193#chainchanged`,notification:`MetaMask: The event 'notification' is deprecated and may be removed in the future. Use 'message' instead.
18
+ For more information, see: https://eips.ethereum.org/EIPS/eip-1193#message`},rpc:{ethDecryptDeprecation:`MetaMask: The RPC method 'eth_decrypt' is deprecated and may be removed in the future.
19
+ For more information, see: https://medium.com/metamask/metamask-api-method-deprecation-2b0564a84686`,ethGetEncryptionPublicKeyDeprecation:`MetaMask: The RPC method 'eth_getEncryptionPublicKey' is deprecated and may be removed in the future.
20
+ For more information, see: https://medium.com/metamask/metamask-api-method-deprecation-2b0564a84686`,walletWatchAssetNFTExperimental:`MetaMask: The RPC method 'wallet_watchAsset' is experimental for ERC721/ERC1155 assets and may change in the future.
21
+ For more information, see: https://github.com/MetaMask/metamask-improvement-proposals/blob/main/MIPs/mip-1.md and https://github.com/MetaMask/metamask-improvement-proposals/blob/main/PROCESS-GUIDE.md#proposal-lifecycle`},experimentalMethods:"MetaMask: 'ethereum._metamask' exposes non-standard, experimental methods. They may be removed or changed without warning."}};function rg(t){const e={ethDecryptDeprecation:!1,ethGetEncryptionPublicKeyDeprecation:!1,walletWatchAssetNFTExperimental:!1};return(n,r,i)=>{var o;e.ethDecryptDeprecation||n.method!=="eth_decrypt"?e.ethGetEncryptionPublicKeyDeprecation||n.method!=="eth_getEncryptionPublicKey"?!e.walletWatchAssetNFTExperimental&&n.method==="wallet_watchAsset"&&[tg,ng].includes(((o=n.params)==null?void 0:o.type)||"")&&(t.warn(Te.warnings.rpc.walletWatchAssetNFTExperimental),e.walletWatchAssetNFTExperimental=!0):(t.warn(Te.warnings.rpc.ethGetEncryptionPublicKeyDeprecation),e.ethGetEncryptionPublicKeyDeprecation=!0):(t.warn(Te.warnings.rpc.ethDecryptDeprecation),e.ethDecryptDeprecation=!0),i()}}var Ah=4294967295,fl=Math.floor(Math.random()*Ah);function ig(){return(t,e,n,r)=>{const i=t.id,o=fl=(fl+1)%Ah;t.id=o,e.id=o,n(a=>{t.id=i,e.id=i,a()})}}var Ka=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},bn=(t,e,n)=>(Ka(t,e,"read from private field"),n?n.call(t):e.get(t)),St=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},wi=(t,e,n,r)=>(Ka(t,e,"write to private field"),e.set(t,n),n),We=(t,e,n)=>(Ka(t,e,"access private method"),n),pn={invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},pl={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."}};function ml(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}var oo=(t,e)=>Object.hasOwnProperty.call(t,e);class og extends TypeError{constructor(e,n){let r;const{message:i,explanation:o,...a}=e,{path:s}=e,c=s.length===0?i:`At path: ${s.join(".")} -- ${i}`;super(o??c),o!=null&&(this.cause=c),Object.assign(this,a),this.name=this.constructor.name,this.failures=()=>r??(r=[e,...n()])}}function Qt(t){return typeof t=="object"&&t!=null}function Ut(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function sg(t,e,n,r){if(t===!0)return;t===!1?t={}:typeof t=="string"&&(t={message:t});const{path:i,branch:o}=e,{type:a}=n,{refinement:s,message:c=`Expected a value of type \`${a}\`${s?` with refinement \`${s}\``:""}, but received: \`${Ut(r)}\``}=t;return{value:r,type:a,refinement:s,key:i[i.length-1],path:i,branch:o,...t,message:c}}function*gl(t,e,n,r){(function(i){return Qt(i)&&typeof i[Symbol.iterator]=="function"})(t)||(t=[t]);for(const i of t){const o=sg(i,e,n,r);o&&(yield o)}}function*ja(t,e,n={}){const{path:r=[],branch:i=[t],coerce:o=!1,mask:a=!1}=n,s={path:r,branch:i};if(o&&(t=e.coercer(t,s),a&&e.type!=="type"&&Qt(e.schema)&&Qt(t)&&!Array.isArray(t)))for(const l in t)e.schema[l]===void 0&&delete t[l];let c="valid";for(const l of e.validator(t,s))l.explanation=n.message,c="not_valid",yield[l,void 0];for(let[l,u,d]of e.entries(t,s)){const h=ja(u,d,{path:l===void 0?r:[...r,l],branch:l===void 0?i:[...i,u],coerce:o,mask:a,message:n.message});for(const f of h)f[0]?(c=f[0].refinement!=null?"not_refined":"not_valid",yield[f[0],void 0]):o&&(u=f[1],l===void 0?t=u:t instanceof Map?t.set(l,u):t instanceof Set?t.add(u):Qt(t)&&(u!==void 0||l in t)&&(t[l]=u))}if(c!=="not_valid")for(const l of e.refiner(t,s))l.explanation=n.message,c="not_refined",yield[l,void 0];c==="valid"&&(yield[void 0,t])}class At{constructor(e){const{type:n,schema:r,validator:i,refiner:o,coercer:a=c=>c,entries:s=function*(){}}=e;this.type=n,this.schema=r,this.entries=s,this.coercer=a,this.validator=i?(c,l)=>gl(i(c,l),l,this,c):()=>[],this.refiner=o?(c,l)=>gl(o(c,l),l,this,c):()=>[]}assert(e,n){return xh(e,this,n)}create(e,n){return Th(e,this,n)}is(e){return hr(e,this)}mask(e,n){return function(r,i,o){const a=Kr(r,i,{coerce:!0,mask:!0,message:o});if(a[0])throw a[0];return a[1]}(e,this,n)}validate(e,n={}){return Kr(e,this,n)}}function xh(t,e,n){const r=Kr(t,e,{message:n});if(r[0])throw r[0]}function Th(t,e,n){const r=Kr(t,e,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function hr(t,e){return!Kr(t,e)[0]}function Kr(t,e,n={}){const r=ja(t,e,n),i=function(o){const{done:a,value:s}=o.next();return a?void 0:s}(r);return i[0]?[new og(i[0],function*(){for(const a of r)a[0]&&(yield a[0])}),void 0]:[void 0,i[1]]}function An(t,e){return new At({type:t,schema:null,validator:e})}function yl(t){let e;return new At({type:"lazy",schema:null,*entries(n,r){e??(e=t()),yield*e.entries(n,r)},validator:(n,r)=>(e??(e=t()),e.validator(n,r)),coercer:(n,r)=>(e??(e=t()),e.coercer(n,r)),refiner:(n,r)=>(e??(e=t()),e.refiner(n,r))})}function Mh(t){return new At({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[n,r]of e.entries())yield[n,r,t]},coercer:e=>Array.isArray(e)?e.slice():e,validator:e=>Array.isArray(e)||`Expected an array value, but received: ${Ut(e)}`})}function Rh(t){const e=Ut(t),n=typeof t;return new At({type:"literal",schema:n==="string"||n==="number"||n==="boolean"?t:null,validator:r=>r===t||`Expected the literal \`${e}\`, but received: ${Ut(r)}`})}function Oh(){return An("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${Ut(t)}`)}function Ph(t){const e=t?Object.keys(t):[],n=An("never",()=>!1);return new At({type:"object",schema:t||null,*entries(r){if(t&&Qt(r)){const i=new Set(Object.keys(r));for(const o of e)i.delete(o),yield[o,r[o],t[o]];for(const o of i)yield[o,r[o],n]}},validator:r=>Qt(r)||`Expected an object, but received: ${Ut(r)}`,coercer:r=>Qt(r)?{...r}:r})}function vl(t){return new At({...t,validator:(e,n)=>e===void 0||t.validator(e,n),refiner:(e,n)=>e===void 0||t.refiner(e,n)})}function Ih(t,e){return new At({type:"record",schema:null,*entries(n){if(Qt(n))for(const r in n){const i=n[r];yield[r,r,t],yield[r,i,e]}},validator:n=>Qt(n)||`Expected an object, but received: ${Ut(n)}`})}function xn(){return An("string",t=>typeof t=="string"||`Expected a string, but received: ${Ut(t)}`)}function To(t){const e=t.map(n=>n.type).join(" | ");return new At({type:"union",schema:null,coercer(n){for(const r of t){const[i,o]=r.validate(n,{coerce:!0});if(!i)return o}return n},validator(n,r){const i=[];for(const o of t){const[...a]=ja(n,o,r),[s]=a;if(!s[0])return[];for(const[c]of a)c&&i.push(c)}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${Ut(n)}`,...i]}})}function ag(t){return function(e){return function(n){return typeof n=="object"&&n!==null&&"message"in n}(e)&&typeof e.message=="string"?e.message:e==null?"":String(e)}(t).replace(/\.$/u,"")}function cg(t,e){var r,i;return n=t,typeof((i=(r=n==null?void 0:n.prototype)==null?void 0:r.constructor)==null?void 0:i.name)=="string"?new t({message:e}):t({message:e});var n}var lg=class extends Error{constructor(t){super(t.message),this.code="ERR_ASSERTION"}};function Lh(){throw new Error("setTimeout has not been defined")}function Nh(){throw new Error("clearTimeout has not been defined")}var cn=Lh,ln=Nh;function Dh(t){if(cn===setTimeout)return setTimeout(t,0);if((cn===Lh||!cn)&&setTimeout)return cn=setTimeout,setTimeout(t,0);try{return cn(t,0)}catch{try{return cn.call(null,t,0)}catch{return cn.call(this,t,0)}}}typeof Je.setTimeout=="function"&&(cn=setTimeout),typeof Je.clearTimeout=="function"&&(ln=clearTimeout);var Ln,Xt=[],or=!1,Ni=-1;function ug(){or&&Ln&&(or=!1,Ln.length?Xt=Ln.concat(Xt):Ni=-1,Xt.length&&Bh())}function Bh(){if(!or){var t=Dh(ug);or=!0;for(var e=Xt.length;e;){for(Ln=Xt,Xt=[];++Ni<e;)Ln&&Ln[Ni].run();Ni=-1,e=Xt.length}Ln=null,or=!1,function(n){if(ln===clearTimeout)return clearTimeout(n);if((ln===Nh||!ln)&&clearTimeout)return ln=clearTimeout,clearTimeout(n);try{return ln(n)}catch{try{return ln.call(null,n)}catch{return ln.call(this,n)}}}(t)}}function $h(t,e){this.fun=t,this.array=e}$h.prototype.run=function(){this.fun.apply(null,this.array)};function Kn(){}var dg=Kn,hg=Kn,fg=Kn,pg=Kn,mg=Kn,gg=Kn,yg=Kn,Gn=Je.performance||{},vg=Gn.now||Gn.mozNow||Gn.msNow||Gn.oNow||Gn.webkitNow||function(){return new Date().getTime()},bg=new Date,we={nextTick:function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];Xt.push(new $h(t,e)),Xt.length!==1||or||Dh(Bh)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:dg,addListener:hg,once:fg,off:pg,removeListener:mg,removeAllListeners:gg,emit:yg,binding:function(t){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(t){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(t){var e=.001*vg.call(Gn),n=Math.floor(e),r=Math.floor(e%1*1e9);return t&&(n-=t[0],(r-=t[1])<0&&(n--,r+=1e9)),[n,r]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-bg)/1e3}},jr=t=>Ph(t);function bl({path:t,branch:e}){const n=t[t.length-1];return oo(e[e.length-2],n)}function so(t){return new At({...t,type:`optional ${t.type}`,validator:(e,n)=>!bl(n)||t.validator(e,n),refiner:(e,n)=>!bl(n)||t.refiner(e,n)})}var Ei,wl,El,ao=To([Rh(null),An("boolean",t=>typeof t=="boolean"),An("finite number",t=>hr(t,Oh())&&Number.isFinite(t)),xn(),Mh(yl(()=>ao)),Ih(xn(),yl(()=>ao))]),Ur=(Ei=ao,wl=An("any",()=>!0),El=t=>(function(e,n,r="Assertion failed",i=lg){try{xh(e,n)}catch(o){throw cg(i,`${r}: ${ag(o)}.`)}}(t,ao),JSON.parse(JSON.stringify(t,(e,n)=>{if(e!=="__proto__"&&e!=="constructor")return n}))),new At({...Ei,coercer:(t,e)=>hr(t,wl)?Ei.coercer(El(t,e),e):Ei.coercer(t,e)}));function Qs(t){try{return function(e){Th(e,Ur)}(t),!0}catch{return!1}}var xr=Rh("2.0"),Di=function(t){return new At({...t,validator:(e,n)=>e===null||t.validator(e,n),refiner:(e,n)=>e===null||t.refiner(e,n)})}(To([Oh(),xn()])),ea=jr({code:An("integer",t=>typeof t=="number"&&!isNaN(t)&&Number.isInteger(t)||`Expected an integer, but received: ${Ut(t)}`),message:xn(),data:so(Ur),stack:so(xn())}),Kh=To([Ih(xn(),Ur),Mh(Ur)]),wg=jr({id:Di,jsonrpc:xr,method:xn(),params:so(Kh)}),Eg=jr({jsonrpc:xr,method:xn(),params:so(Kh)});function _l(t){return hr(t,wg)}function Sl(t){return hr(t,ea)}Ph({id:Di,jsonrpc:xr,result:vl(An("unknown",()=>!0)),error:vl(ea)}),To([jr({id:Di,jsonrpc:xr,result:Ur}),jr({id:Di,jsonrpc:xr,error:ea})]);var Cl=pn.internal,_g="Unspecified error message. This is a bug, please report it.",Sg={code:Cl,message:jh(Cl)},Cg="Unspecified server error.";function jh(t,e=_g){if(function(n){return Number.isInteger(n)}(t)){const n=t.toString();if(oo(pl,n))return pl[n].message;if(function(r){return r>=-32099&&r<=-32e3}(t))return Cg}return e}function kl(t,{fallbackError:e=Sg,shouldIncludeStack:n=!0}={}){if(!Sl(e))throw new Error("Must provide fallback error with integer number code and string message.");const r=function(i,o){if(i&&typeof i=="object"&&"serialize"in i&&typeof i.serialize=="function")return i.serialize();if(Sl(i))return i;const a=Uh(i);return{...o,data:{cause:a}}}(t,e);return n||delete r.stack,r}function Uh(t){return Array.isArray(t)?t.map(e=>Qs(e)?e:ml(e)?Al(e):null):ml(t)?Al(t):Qs(t)?t:null}function Al(t){return Object.getOwnPropertyNames(t).reduce((e,n)=>{const r=t[n];return Qs(r)&&(e[n]=r),e},{})}var Hh=Sr;Sr.default=Sr,Sr.stable=xl,Sr.stableStringify=xl;var co="[...]",Fh="[Circular]",$n=[],Nn=[];function zh(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function Sr(t,e,n,r){var i;r===void 0&&(r=zh()),ta(t,"",0,[],void 0,0,r);try{i=Nn.length===0?JSON.stringify(t,e,n):JSON.stringify(t,qh(e),n)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;$n.length!==0;){var o=$n.pop();o.length===4?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}}return i}function sr(t,e,n,r){var i=Object.getOwnPropertyDescriptor(r,n);i.get!==void 0?i.configurable?(Object.defineProperty(r,n,{value:t}),$n.push([r,n,e,i])):Nn.push([e,n,t]):(r[n]=t,$n.push([r,n,e]))}function ta(t,e,n,r,i,o,a){var s;if(o+=1,typeof t=="object"&&t!==null){for(s=0;s<r.length;s++)if(r[s]===t)return void sr(Fh,t,e,i);if(a.depthLimit!==void 0&&o>a.depthLimit||a.edgesLimit!==void 0&&n+1>a.edgesLimit)return void sr(co,t,e,i);if(r.push(t),Array.isArray(t))for(s=0;s<t.length;s++)ta(t[s],s,s,r,t,o,a);else{var c=Object.keys(t);for(s=0;s<c.length;s++){var l=c[s];ta(t[l],l,s,r,t,o,a)}}r.pop()}}function kg(t,e){return t<e?-1:t>e?1:0}function xl(t,e,n,r){r===void 0&&(r=zh());var i,o=na(t,"",0,[],void 0,0,r)||t;try{i=Nn.length===0?JSON.stringify(o,e,n):JSON.stringify(o,qh(e),n)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;$n.length!==0;){var a=$n.pop();a.length===4?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return i}function na(t,e,n,r,i,o,a){var s;if(o+=1,typeof t=="object"&&t!==null){for(s=0;s<r.length;s++)if(r[s]===t)return void sr(Fh,t,e,i);try{if(typeof t.toJSON=="function")return}catch{return}if(a.depthLimit!==void 0&&o>a.depthLimit||a.edgesLimit!==void 0&&n+1>a.edgesLimit)return void sr(co,t,e,i);if(r.push(t),Array.isArray(t))for(s=0;s<t.length;s++)na(t[s],s,s,r,t,o,a);else{var c={},l=Object.keys(t).sort(kg);for(s=0;s<l.length;s++){var u=l[s];na(t[u],u,s,r,t,o,a),c[u]=t[u]}if(i===void 0)return c;$n.push([i,e,t]),i[e]=c}r.pop()}}function qh(t){return t=t!==void 0?t:function(e,n){return n},function(e,n){if(Nn.length>0)for(var r=0;r<Nn.length;r++){var i=Nn[r];if(i[1]===e&&i[0]===n){n=i[2],Nn.splice(r,1);break}}return t.call(this,e,n)}}var Ag=Ao(Hh),Vt=class extends Error{constructor(t,e,n){if(!Number.isInteger(t))throw new Error('"code" must be an integer.');if(!e||typeof e!="string")throw new Error('"message" must be a non-empty string.');super(e),this.code=t,n!==void 0&&(this.data=n)}serialize(){const t={code:this.code,message:this.message};return this.data!==void 0&&(t.data=this.data,function(e){if(typeof e!="object"||e===null)return!1;try{let n=e;for(;Object.getPrototypeOf(n)!==null;)n=Object.getPrototypeOf(n);return Object.getPrototypeOf(e)===n}catch{return!1}}(this.data)&&(t.data.cause=Uh(this.data.cause))),this.stack&&(t.stack=this.stack),t}toString(){return Ag(this.serialize(),xg,2)}};function xg(t,e){if(e!=="[Circular]")return e}var Tr=t=>Tg(pn.invalidRequest,t);function Tg(t,e){const[n,r]=function(i){if(i){if(typeof i=="string")return[i];if(typeof i=="object"&&!Array.isArray(i)){const{message:o,data:a}=i;if(o&&typeof o!="string")throw new Error("Must specify string message.");return[o??void 0,a]}}return[]}(e);return new Vt(t,n??jh(t),r)}var Vh={};function un(){}function _e(){_e.init.call(this)}function Wh(t){return t._maxListeners===void 0?_e.defaultMaxListeners:t._maxListeners}function Tl(t,e,n,r){var i,o,a;if(typeof n!="function")throw new TypeError('"listener" argument must be a function');if((o=t._events)?(o.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),a=o[e]):(o=t._events=new un,t._eventsCount=0),a){if(typeof a=="function"?a=o[e]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),!a.warned&&(i=Wh(t))&&i>0&&a.length>i){a.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+e+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=a.length,function(c){typeof console.warn=="function"?console.warn(c):console.log(c)}(s)}}else a=o[e]=n,++t._eventsCount;return t}function Ml(t,e,n){var r=!1;function i(){t.removeListener(e,i),r||(r=!0,n.apply(t,arguments))}return i.listener=n,i}function Rl(t){var e=this._events;if(e){var n=e[t];if(typeof n=="function")return 1;if(n)return n.length}return 0}function br(t,e){for(var n=new Array(e);e--;)n[e]=t[e];return n}un.prototype=Object.create(null),_e.EventEmitter=_e,_e.usingDomains=!1,_e.prototype.domain=void 0,_e.prototype._events=void 0,_e.prototype._maxListeners=void 0,_e.defaultMaxListeners=10,_e.init=function(){this.domain=null,_e.usingDomains&&(void 0).active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new un,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_e.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||isNaN(t))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=t,this},_e.prototype.getMaxListeners=function(){return Wh(this)},_e.prototype.emit=function(t){var e,n,r,i,o,a,s,c=t==="error";if(a=this._events)c=c&&a.error==null;else if(!c)return!1;if(s=this.domain,c){if(e=arguments[1],!s){if(e instanceof Error)throw e;var l=new Error('Uncaught, unspecified "error" event. ('+e+")");throw l.context=e,l}return e||(e=new Error('Uncaught, unspecified "error" event')),e.domainEmitter=this,e.domain=s,e.domainThrown=!1,s.emit("error",e),!1}if(!(n=a[t]))return!1;var u=typeof n=="function";switch(r=arguments.length){case 1:(function(d,h,f){if(h)d.call(f);else for(var g=d.length,m=br(d,g),w=0;w<g;++w)m[w].call(f)})(n,u,this);break;case 2:(function(d,h,f,g){if(h)d.call(f,g);else for(var m=d.length,w=br(d,m),p=0;p<m;++p)w[p].call(f,g)})(n,u,this,arguments[1]);break;case 3:(function(d,h,f,g,m){if(h)d.call(f,g,m);else for(var w=d.length,p=br(d,w),S=0;S<w;++S)p[S].call(f,g,m)})(n,u,this,arguments[1],arguments[2]);break;case 4:(function(d,h,f,g,m,w){if(h)d.call(f,g,m,w);else for(var p=d.length,S=br(d,p),_=0;_<p;++_)S[_].call(f,g,m,w)})(n,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),o=1;o<r;o++)i[o-1]=arguments[o];(function(d,h,f,g){if(h)d.apply(f,g);else for(var m=d.length,w=br(d,m),p=0;p<m;++p)w[p].apply(f,g)})(n,u,this,i)}return!0},_e.prototype.addListener=function(t,e){return Tl(this,t,e,!1)},_e.prototype.on=_e.prototype.addListener,_e.prototype.prependListener=function(t,e){return Tl(this,t,e,!0)},_e.prototype.once=function(t,e){if(typeof e!="function")throw new TypeError('"listener" argument must be a function');return this.on(t,Ml(this,t,e)),this},_e.prototype.prependOnceListener=function(t,e){if(typeof e!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(t,Ml(this,t,e)),this},_e.prototype.removeListener=function(t,e){var n,r,i,o,a;if(typeof e!="function")throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[t]))return this;if(n===e||n.listener&&n.listener===e)--this._eventsCount==0?this._events=new un:(delete r[t],r.removeListener&&this.emit("removeListener",t,n.listener||e));else if(typeof n!="function"){for(i=-1,o=n.length;o-- >0;)if(n[o]===e||n[o].listener&&n[o].listener===e){a=n[o].listener,i=o;break}if(i<0)return this;if(n.length===1){if(n[0]=void 0,--this._eventsCount==0)return this._events=new un,this;delete r[t]}else(function(s,c){for(var l=c,u=l+1,d=s.length;u<d;l+=1,u+=1)s[l]=s[u];s.pop()})(n,i);r.removeListener&&this.emit("removeListener",t,a||e)}return this},_e.prototype.off=function(t,e){return this.removeListener(t,e)},_e.prototype.removeAllListeners=function(t){var e,n;if(!(n=this._events))return this;if(!n.removeListener)return arguments.length===0?(this._events=new un,this._eventsCount=0):n[t]&&(--this._eventsCount==0?this._events=new un:delete n[t]),this;if(arguments.length===0){for(var r,i=Object.keys(n),o=0;o<i.length;++o)(r=i[o])!=="removeListener"&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new un,this._eventsCount=0,this}if(typeof(e=n[t])=="function")this.removeListener(t,e);else if(e)do this.removeListener(t,e[e.length-1]);while(e[0]);return this},_e.prototype.listeners=function(t){var e,n,r=this._events;return n=r&&(e=r[t])?typeof e=="function"?[e.listener||e]:function(i){for(var o=new Array(i.length),a=0;a<o.length;++a)o[a]=i[a].listener||i[a];return o}(e):[],n},_e.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Rl.call(t,e)},_e.prototype.listenerCount=Rl,_e.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var Ua=Zr(Object.freeze({__proto__:null,EventEmitter:_e,default:_e}));Object.defineProperty(Vh,"__esModule",{value:!0});const Mg=Ua;function Ol(t,e,n){try{Reflect.apply(t,e,n)}catch(r){setTimeout(()=>{throw r})}}let Rg=class extends Mg.EventEmitter{emit(t,...e){let n=t==="error";const r=this._events;if(r!==void 0)n=n&&r.error===void 0;else if(!n)return!1;if(n){let o;if(e.length>0&&([o]=e),o instanceof Error)throw o;const a=new Error("Unhandled error."+(o?` (${o.message})`:""));throw a.context=o,a}const i=r[t];if(i===void 0)return!1;if(typeof i=="function")Ol(i,this,e);else{const o=i.length,a=function(s){const c=s.length,l=new Array(c);for(let u=0;u<c;u+=1)l[u]=s[u];return l}(i);for(let s=0;s<o;s+=1)Ol(a[s],this,e)}return!0}};var lo,mn,tr,Cr,Bi,$i,ra,Ki,ia,cs,Pl,ji,oa,ls,Il,Mr,uo,us,Ll,Gh=Vh.default=Rg,Et=class Ui extends Gh{constructor({notificationHandler:e}={}){super(),St(this,Cr),St(this,$i),St(this,Ki),St(this,lo,!1),St(this,mn,void 0),St(this,tr,void 0),wi(this,mn,[]),wi(this,tr,e)}destroy(){bn(this,mn).forEach(e=>{"destroy"in e&&typeof e.destroy=="function"&&e.destroy()}),wi(this,mn,[]),wi(this,lo,!0)}push(e){We(this,Cr,Bi).call(this),bn(this,mn).push(e)}handle(e,n){if(We(this,Cr,Bi).call(this),n&&typeof n!="function")throw new Error('"callback" must be a function if provided.');return Array.isArray(e)?n?We(this,$i,ra).call(this,e,n):We(this,$i,ra).call(this,e):n?We(this,Ki,ia).call(this,e,n):this._promiseHandle(e)}asMiddleware(){return We(this,Cr,Bi).call(this),async(e,n,r,i)=>{var o,a;try{const[s,c,l]=await We(o=Ui,ji,oa).call(o,e,n,bn(this,mn));return c?(await We(a=Ui,Mr,uo).call(a,l),i(s)):r(async u=>{var d;try{await We(d=Ui,Mr,uo).call(d,l)}catch(h){return u(h)}return u()})}catch(s){return i(s)}}}async _promiseHandle(e){return new Promise((n,r)=>{We(this,Ki,ia).call(this,e,(i,o)=>{i&&o===void 0?r(i):n(o)}).catch(r)})}};lo=new WeakMap,mn=new WeakMap,tr=new WeakMap,Cr=new WeakSet,Bi=function(){if(bn(this,lo))throw new Error("This engine is destroyed and can no longer be used.")},$i=new WeakSet,ra=async function(t,e){try{if(t.length===0){const r=[{id:null,jsonrpc:"2.0",error:new Vt(pn.invalidRequest,"Request batch must contain plain objects. Received an empty array")}];return e?e(null,r):r}const n=(await Promise.all(t.map(this._promiseHandle.bind(this)))).filter(r=>r!==void 0);return e?e(null,n):n}catch(n){if(e)return e(n);throw n}},Ki=new WeakSet,ia=async function(t,e){var n;if(!t||Array.isArray(t)||typeof t!="object"){const a=new Vt(pn.invalidRequest,"Requests must be plain objects. Received: "+typeof t,{request:t});return e(a,{id:null,jsonrpc:"2.0",error:a})}if(typeof t.method!="string"){const a=new Vt(pn.invalidRequest,"Must specify a string method. Received: "+typeof t.method,{request:t});return bn(this,tr)&&!_l(t)?e(null):e(a,{id:t.id??null,jsonrpc:"2.0",error:a})}if(bn(this,tr)&&hr(t,Eg)&&!_l(t)){try{await bn(this,tr).call(this,t)}catch(a){return e(a)}return e(null)}let r=null;const i={...t},o={id:i.id,jsonrpc:i.jsonrpc};try{await We(n=Et,cs,Pl).call(n,i,o,bn(this,mn))}catch(a){r=a}return r&&(delete o.result,o.error||(o.error=kl(r))),e(r,o)},cs=new WeakSet,Pl=async function(t,e,n){var r,i,o;const[a,s,c]=await We(r=Et,ji,oa).call(r,t,e,n);if(We(i=Et,us,Ll).call(i,t,e,s),await We(o=Et,Mr,uo).call(o,c),a)throw a},ji=new WeakSet,oa=async function(t,e,n){var r;const i=[];let o=null,a=!1;for(const s of n)if([o,a]=await We(r=Et,ls,Il).call(r,t,e,s,i),a)break;return[o,a,i.reverse()]},ls=new WeakSet,Il=async function(t,e,n,r){return new Promise(i=>{const o=s=>{const c=s||e.error;c&&(e.error=kl(c)),i([c,!0])},a=s=>{e.error?o(e.error):(s&&(typeof s!="function"&&o(new Vt(pn.internal,`JsonRpcEngine: "next" return handlers must be functions. Received "${typeof s}" for request:
22
+ ${ds(t)}`,{request:t})),r.push(s)),i([null,!1]))};try{n(t,e,a,o)}catch(s){o(s)}})},Mr=new WeakSet,uo=async function(t){for(const e of t)await new Promise((n,r)=>{e(i=>i?r(i):n())})},us=new WeakSet,Ll=function(t,e,n){if(!oo(e,"result")&&!oo(e,"error"))throw new Vt(pn.internal,`JsonRpcEngine: Response has no error or result for request:
23
+ ${ds(t)}`,{request:t});if(!n)throw new Vt(pn.internal,`JsonRpcEngine: Nothing ended request:
24
+ ${ds(t)}`,{request:t})},St(Et,cs),St(Et,ji),St(Et,ls),St(Et,Mr),St(Et,us);var Og=Et;function ds(t){return JSON.stringify(t,null,2)}var Yh=Object.freeze(["eth_subscription"]),Pg=(t=console)=>[ig(),Ig(t),rg(t)];function Ig(t){return(e,n,r)=>{typeof e.method=="string"&&e.method||(n.error=Tr({message:"The request 'method' must be a non-empty string.",data:e})),r(i=>{const{error:o}=n;return o&&t.error(`MetaMask - RPC Error: ${o.message}`,o),i()})}}var Hi=(t,e,n=!0)=>(r,i)=>{r||i.error?e(r||i.error):!n||Array.isArray(i)?t(i):t(i.result)},Zh=t=>!!t&&typeof t=="string"&&t.startsWith("0x"),Jh=()=>{};async function Nl(t,e){try{const n=await async function(){return{name:Lg(window),icon:await Ng(window)}}();t.handle({jsonrpc:"2.0",id:1,method:"metamask_sendDomainMetadata",params:n},Jh)}catch(n){e.error({message:Te.errors.sendSiteMetadata(),originalError:n})}}function Lg(t){const{document:e}=t,n=e.querySelector('head > meta[property="og:site_name"]');if(n)return n.content;const r=e.querySelector('head > meta[name="title"]');return r?r.content:e.title&&e.title.length>0?e.title:window.location.hostname}async function Ng(t){const{document:e}=t,n=e.querySelectorAll('head > link[rel~="icon"]');for(const r of Array.from(n))if(r&&await Dg(r.href))return r.href;return null}async function Dg(t){return new Promise((e,n)=>{try{const r=document.createElement("img");r.onload=()=>e(!0),r.onerror=()=>e(!1),r.src=t}catch(r){n(r)}})}var Xh=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},It=(t,e,n)=>(Xh(t,e,"read from private field"),n?n.call(t):e.get(t)),sa=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},Wt=(t,e,n,r)=>(Xh(t,e,"write to private field"),e.set(t,n),n);function Dl(t,e,n){try{Reflect.apply(t,e,n)}catch(r){setTimeout(()=>{throw r})}}class Bg extends _e{emit(e,...n){let r=e==="error";const i=this._events;if(i!==void 0)r=r&&i.error===void 0;else if(!r)return!1;if(r){let a;if(n.length>0&&([a]=n),a instanceof Error)throw a;const s=new Error("Unhandled error."+(a?` (${a.message})`:""));throw s.context=a,s}const o=i[e];if(o===void 0)return!1;if(typeof o=="function")Dl(o,this,n);else{const a=o.length,s=function(c){const l=c.length,u=new Array(l);for(let d=0;d<l;d+=1)u[d]=c[d];return u}(o);for(let c=0;c<a;c+=1)Dl(s[c],this,n)}return!0}}var dn,Rn,$g=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,i,o;if(Array.isArray(e)){if((r=e.length)!=n.length)return!1;for(i=r;i--!=0;)if(!t(e[i],n[i]))return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if((r=(o=Object.keys(e)).length)!==Object.keys(n).length)return!1;for(i=r;i--!=0;)if(!Object.prototype.hasOwnProperty.call(n,o[i]))return!1;for(i=r;i--!=0;){var a=o[i];if(!t(e[a],n[a]))return!1}return!0}return e!=e&&n!=n},Kg=Ao($g),Qh=class ef extends Bg{constructor({logger:e=console,maxEventListeners:n=100,rpcMiddleware:r=[]}={}){super(),sa(this,dn,void 0),sa(this,Rn,void 0),this._log=e,this.setMaxListeners(n),this._state={...ef._defaultState},Wt(this,Rn,null),Wt(this,dn,null),this._handleAccountsChanged=this._handleAccountsChanged.bind(this),this._handleConnect=this._handleConnect.bind(this),this._handleChainChanged=this._handleChainChanged.bind(this),this._handleDisconnect=this._handleDisconnect.bind(this),this._handleUnlockStateChanged=this._handleUnlockStateChanged.bind(this),this._rpcRequest=this._rpcRequest.bind(this),this.request=this.request.bind(this);const i=new Og;r.forEach(o=>i.push(o)),this._rpcEngine=i}get chainId(){return It(this,dn)}get selectedAddress(){return It(this,Rn)}isConnected(){return this._state.isConnected}async request(e){if(!e||typeof e!="object"||Array.isArray(e))throw Tr({message:Te.errors.invalidRequestArgs(),data:e});const{method:n,params:r}=e;if(typeof n!="string"||n.length===0)throw Tr({message:Te.errors.invalidRequestMethod(),data:e});if(r!==void 0&&!Array.isArray(r)&&(typeof r!="object"||r===null))throw Tr({message:Te.errors.invalidRequestParams(),data:e});const i=r==null?{method:n}:{method:n,params:r};return new Promise((o,a)=>{this._rpcRequest(i,Hi(o,a))})}_initializeState(e){if(this._state.initialized)throw new Error("Provider already initialized.");if(e){const{accounts:n,chainId:r,isUnlocked:i,networkVersion:o}=e;this._handleConnect(r),this._handleChainChanged({chainId:r,networkVersion:o}),this._handleUnlockStateChanged({accounts:n,isUnlocked:i}),this._handleAccountsChanged(n)}this._state.initialized=!0,this.emit("_initialized")}_rpcRequest(e,n){let r=n;return Array.isArray(e)||(e.jsonrpc||(e.jsonrpc="2.0"),e.method!=="eth_accounts"&&e.method!=="eth_requestAccounts"||(r=(i,o)=>{this._handleAccountsChanged(o.result??[],e.method==="eth_accounts"),n(i,o)})),this._rpcEngine.handle(e,r)}_handleConnect(e){this._state.isConnected||(this._state.isConnected=!0,this.emit("connect",{chainId:e}),this._log.debug(Te.info.connected(e)))}_handleDisconnect(e,n){if(this._state.isConnected||!this._state.isPermanentlyDisconnected&&!e){let r;this._state.isConnected=!1,e?(r=new Vt(1013,n??Te.errors.disconnected()),this._log.debug(r)):(r=new Vt(1011,n??Te.errors.permanentlyDisconnected()),this._log.error(r),Wt(this,dn,null),this._state.accounts=null,Wt(this,Rn,null),this._state.isUnlocked=!1,this._state.isPermanentlyDisconnected=!0),this.emit("disconnect",r)}}_handleChainChanged({chainId:e}={}){Zh(e)?(this._handleConnect(e),e!==It(this,dn)&&(Wt(this,dn,e),this._state.initialized&&this.emit("chainChanged",It(this,dn)))):this._log.error(Te.errors.invalidNetworkParams(),{chainId:e})}_handleAccountsChanged(e,n=!1){let r=e;Array.isArray(e)||(this._log.error("MetaMask: Received invalid accounts parameter. Please report this bug.",e),r=[]);for(const i of e)if(typeof i!="string"){this._log.error("MetaMask: Received non-string account. Please report this bug.",e),r=[];break}if(!Kg(this._state.accounts,r)&&(n&&this._state.accounts!==null&&this._log.error("MetaMask: 'eth_accounts' unexpectedly updated accounts. Please report this bug.",r),this._state.accounts=r,It(this,Rn)!==r[0]&&Wt(this,Rn,r[0]||null),this._state.initialized)){const i=[...r];this.emit("accountsChanged",i)}}_handleUnlockStateChanged({accounts:e,isUnlocked:n}={}){typeof n=="boolean"?n!==this._state.isUnlocked&&(this._state.isUnlocked=n,this._handleAccountsChanged(e??[])):this._log.error("MetaMask: Received invalid isUnlocked parameter. Please report this bug.")}};dn=new WeakMap,Rn=new WeakMap,Qh._defaultState={accounts:null,isConnected:!1,isUnlocked:!1,initialized:!1,isPermanentlyDisconnected:!1};var Ha,jg=Qh,aa={exports:{}},tf=Ua.EventEmitter,Fa=Zr(tm);Ha=typeof Object.create=="function"?function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:function(t,e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t};var nf=Object.getOwnPropertyDescriptors||function(t){for(var e=Object.keys(t),n={},r=0;r<e.length;r++)n[e[r]]=Object.getOwnPropertyDescriptor(t,e[r]);return n},Ug=/%[sdj%]/g;function Mo(t){if(!Hr(t)){for(var e=[],n=0;n<arguments.length;n++)e.push($t(arguments[n]));return e.join(" ")}n=1;for(var r=arguments,i=r.length,o=String(t).replace(Ug,function(s){if(s==="%%")return"%";if(n>=i)return s;switch(s){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch{return"[Circular]"}default:return s}}),a=r[n];n<i;a=r[++n])Qr(a)||!jn(a)?o+=" "+a:o+=" "+$t(a);return o}function za(t,e){if(Nt(Je.process))return function(){return za(t,e).apply(this,arguments)};if(we.noDeprecation===!0)return t;var n=!1;return function(){if(!n){if(we.throwDeprecation)throw new Error(e);we.traceDeprecation?console.trace(e):console.error(e),n=!0}return t.apply(this,arguments)}}var hs,_i={};function rf(t){return Nt(hs)&&(hs=we.env.NODE_DEBUG||""),t=t.toUpperCase(),!_i[t]&&(new RegExp("\\b"+t+"\\b","i").test(hs)?_i[t]=function(){var e=Mo.apply(null,arguments);console.error("%s %d: %s",t,0,e)}:_i[t]=function(){}),_i[t]}function $t(t,e){var n={seen:[],stylize:Fg};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),Ro(e)?n.showHidden=e:e&&Ga(n,e),Nt(n.showHidden)&&(n.showHidden=!1),Nt(n.depth)&&(n.depth=2),Nt(n.colors)&&(n.colors=!1),Nt(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=Hg),ho(n,t,n.depth)}function Hg(t,e){var n=$t.styles[e];return n?"\x1B["+$t.colors[n][0]+"m"+t+"\x1B["+$t.colors[n][1]+"m":t}function Fg(t,e){return t}function ho(t,e,n){if(t.customInspect&&e&&Pr(e.inspect)&&e.inspect!==$t&&(!e.constructor||e.constructor.prototype!==e)){var r=e.inspect(n,t);return Hr(r)||(r=ho(t,r,n)),r}var i=function(h,f){if(Nt(f))return h.stylize("undefined","undefined");if(Hr(f)){var g="'"+JSON.stringify(f).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return h.stylize(g,"string")}if(Va(f))return h.stylize(""+f,"number");if(Ro(f))return h.stylize(""+f,"boolean");if(Qr(f))return h.stylize("null","null")}(t,e);if(i)return i;var o=Object.keys(e),a=function(h){var f={};return h.forEach(function(g,m){f[g]=!0}),f}(o);if(t.showHidden&&(o=Object.getOwnPropertyNames(e)),Or(e)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return fs(e);if(o.length===0){if(Pr(e)){var s=e.name?": "+e.name:"";return t.stylize("[Function"+s+"]","special")}if(Rr(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(fo(e))return t.stylize(Date.prototype.toString.call(e),"date");if(Or(e))return fs(e)}var c,l="",u=!1,d=["{","}"];return qa(e)&&(u=!0,d=["[","]"]),Pr(e)&&(l=" [Function"+(e.name?": "+e.name:"")+"]"),Rr(e)&&(l=" "+RegExp.prototype.toString.call(e)),fo(e)&&(l=" "+Date.prototype.toUTCString.call(e)),Or(e)&&(l=" "+fs(e)),o.length!==0||u&&e.length!=0?n<0?Rr(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special"):(t.seen.push(e),c=u?function(h,f,g,m,w){for(var p=[],S=0,_=f.length;S<_;++S)uf(f,String(S))?p.push(ps(h,f,g,m,String(S),!0)):p.push("");return w.forEach(function(O){O.match(/^\d+$/)||p.push(ps(h,f,g,m,O,!0))}),p}(t,e,n,a,o):o.map(function(h){return ps(t,e,n,a,h,u)}),t.seen.pop(),function(h,f,g){var m=h.reduce(function(w,p){return p.indexOf(`
25
+ `),w+p.replace(/\u001b\[\d\d?m/g,"").length+1},0);return m>60?g[0]+(f===""?"":f+`
26
+ `)+" "+h.join(`,
27
+ `)+" "+g[1]:g[0]+f+" "+h.join(", ")+" "+g[1]}(c,l,d)):d[0]+l+d[1]}function fs(t){return"["+Error.prototype.toString.call(t)+"]"}function ps(t,e,n,r,i,o){var a,s,c;if((c=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?s=c.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):c.set&&(s=t.stylize("[Setter]","special")),uf(r,i)||(a="["+i+"]"),s||(t.seen.indexOf(c.value)<0?(s=Qr(n)?ho(t,c.value,null):ho(t,c.value,n-1)).indexOf(`
28
+ `)>-1&&(s=o?s.split(`
29
+ `).map(function(l){return" "+l}).join(`
30
+ `).substr(2):`
31
+ `+s.split(`
32
+ `).map(function(l){return" "+l}).join(`
33
+ `)):s=t.stylize("[Circular]","special")),Nt(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=t.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=t.stylize(a,"string"))}return a+": "+s}function qa(t){return Array.isArray(t)}function Ro(t){return typeof t=="boolean"}function Qr(t){return t===null}function of(t){return t==null}function Va(t){return typeof t=="number"}function Hr(t){return typeof t=="string"}function sf(t){return typeof t=="symbol"}function Nt(t){return t===void 0}function Rr(t){return jn(t)&&Wa(t)==="[object RegExp]"}function jn(t){return typeof t=="object"&&t!==null}function fo(t){return jn(t)&&Wa(t)==="[object Date]"}function Or(t){return jn(t)&&(Wa(t)==="[object Error]"||t instanceof Error)}function Pr(t){return typeof t=="function"}function af(t){return t===null||typeof t=="boolean"||typeof t=="number"||typeof t=="string"||typeof t=="symbol"||t===void 0}function cf(t){return X.isBuffer(t)}function Wa(t){return Object.prototype.toString.call(t)}function ms(t){return t<10?"0"+t.toString(10):t.toString(10)}$t.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},$t.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};var zg=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function lf(){var t,e;console.log("%s - %s",(t=new Date,e=[ms(t.getHours()),ms(t.getMinutes()),ms(t.getSeconds())].join(":"),[t.getDate(),zg[t.getMonth()],e].join(" ")),Mo.apply(null,arguments))}function Ga(t,e){if(!e||!jn(e))return t;for(var n=Object.keys(e),r=n.length;r--;)t[n[r]]=e[n[r]];return t}function uf(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var On=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;function Ya(t){if(typeof t!="function")throw new TypeError('The "original" argument must be of type Function');if(On&&t[On]){var e;if(typeof(e=t[On])!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,On,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var n,r,i=new Promise(function(s,c){n=s,r=c}),o=[],a=0;a<arguments.length;a++)o.push(arguments[a]);o.push(function(s,c){s?r(s):n(c)});try{t.apply(this,o)}catch(s){r(s)}return i}return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),On&&Object.defineProperty(e,On,{value:e,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(e,nf(t))}function qg(t,e){if(!t){var n=new Error("Promise was rejected with a falsy value");n.reason=t,t=n}return e(t)}function df(t){if(typeof t!="function")throw new TypeError('The "original" argument must be of type Function');function e(){for(var n=[],r=0;r<arguments.length;r++)n.push(arguments[r]);var i=n.pop();if(typeof i!="function")throw new TypeError("The last argument must be of type Function");var o=this,a=function(){return i.apply(o,arguments)};t.apply(this,n).then(function(s){we.nextTick(a.bind(null,null,s))},function(s){we.nextTick(qg.bind(null,s,a))})}return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),Object.defineProperties(e,nf(t)),e}Ya.custom=On;var gs,Bl,Vg={inherits:Ha,_extend:Ga,log:lf,isBuffer:cf,isPrimitive:af,isFunction:Pr,isError:Or,isDate:fo,isObject:jn,isRegExp:Rr,isUndefined:Nt,isSymbol:sf,isString:Hr,isNumber:Va,isNullOrUndefined:of,isNull:Qr,isBoolean:Ro,isArray:qa,inspect:$t,deprecate:za,format:Mo,debuglog:rf,promisify:Ya,callbackify:df},hf=Zr(Object.freeze({__proto__:null,_extend:Ga,callbackify:df,debuglog:rf,default:Vg,deprecate:za,format:Mo,inherits:Ha,inspect:$t,isArray:qa,isBoolean:Ro,isBuffer:cf,isDate:fo,isError:Or,isFunction:Pr,isNull:Qr,isNullOrUndefined:of,isNumber:Va,isObject:jn,isPrimitive:af,isRegExp:Rr,isString:Hr,isSymbol:sf,isUndefined:Nt,log:lf,promisify:Ya}));function Wg(){if(Bl)return gs;function t(c,l){var u=Object.keys(c);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(c);l&&(d=d.filter(function(h){return Object.getOwnPropertyDescriptor(c,h).enumerable})),u.push.apply(u,d)}return u}function e(c){for(var l=1;l<arguments.length;l++){var u=arguments[l]!=null?arguments[l]:{};l%2?t(Object(u),!0).forEach(function(d){n(c,d,u[d])}):Object.getOwnPropertyDescriptors?Object.defineProperties(c,Object.getOwnPropertyDescriptors(u)):t(Object(u)).forEach(function(d){Object.defineProperty(c,d,Object.getOwnPropertyDescriptor(u,d))})}return c}function n(c,l,u){return(l=i(l))in c?Object.defineProperty(c,l,{value:u,enumerable:!0,configurable:!0,writable:!0}):c[l]=u,c}function r(c,l,u){return l&&function(d,h){for(var f=0;f<h.length;f++){var g=h[f];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(d,i(g.key),g)}}(c.prototype,l),Object.defineProperty(c,"prototype",{writable:!1}),c}function i(c){var l=function(u,d){if(typeof u!="object"||u===null)return u;var h=u[Symbol.toPrimitive];if(h!==void 0){var f=h.call(u,d);if(typeof f!="object")return f;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(u)}(c,"string");return typeof l=="symbol"?l:String(l)}Bl=1;var o=Fa.Buffer,a=hf.inspect,s=a&&a.custom||"inspect";return gs=function(){function c(){(function(l,u){if(!(l instanceof u))throw new TypeError("Cannot call a class as a function")})(this,c),this.head=null,this.tail=null,this.length=0}return r(c,[{key:"push",value:function(l){var u={data:l,next:null};this.length>0?this.tail.next=u:this.head=u,this.tail=u,++this.length}},{key:"unshift",value:function(l){var u={data:l,next:this.head};this.length===0&&(this.tail=u),this.head=u,++this.length}},{key:"shift",value:function(){if(this.length!==0){var l=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,l}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(l){if(this.length===0)return"";for(var u=this.head,d=""+u.data;u=u.next;)d+=l+u.data;return d}},{key:"concat",value:function(l){if(this.length===0)return o.alloc(0);for(var u,d,h,f=o.allocUnsafe(l>>>0),g=this.head,m=0;g;)u=g.data,d=f,h=m,o.prototype.copy.call(u,d,h),m+=g.data.length,g=g.next;return f}},{key:"consume",value:function(l,u){var d;return l<this.head.data.length?(d=this.head.data.slice(0,l),this.head.data=this.head.data.slice(l)):d=l===this.head.data.length?this.shift():u?this._getString(l):this._getBuffer(l),d}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(l){var u=this.head,d=1,h=u.data;for(l-=h.length;u=u.next;){var f=u.data,g=l>f.length?f.length:l;if(g===f.length?h+=f:h+=f.slice(0,l),(l-=g)===0){g===f.length?(++d,u.next?this.head=u.next:this.head=this.tail=null):(this.head=u,u.data=f.slice(g));break}++d}return this.length-=d,h}},{key:"_getBuffer",value:function(l){var u=o.allocUnsafe(l),d=this.head,h=1;for(d.data.copy(u),l-=d.data.length;d=d.next;){var f=d.data,g=l>f.length?f.length:l;if(f.copy(u,u.length-l,0,g),(l-=g)===0){g===f.length?(++h,d.next?this.head=d.next:this.head=this.tail=null):(this.head=d,d.data=f.slice(g));break}++h}return this.length-=h,u}},{key:s,value:function(l,u){return a(this,e(e({},u),{},{depth:0,customInspect:!1}))}}]),c}(),gs}function $l(t,e){ca(t,e),Fi(t)}function Fi(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function ca(t,e){t.emit("error",e)}var ff={destroy:function(t,e){var n=this,r=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return r||i?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,we.nextTick(ca,this,t)):we.nextTick(ca,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(o){!e&&o?n._writableState?n._writableState.errorEmitted?we.nextTick(Fi,n):(n._writableState.errorEmitted=!0,we.nextTick($l,n,o)):we.nextTick($l,n,o):e?(we.nextTick(Fi,n),e(o)):we.nextTick(Fi,n)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var n=t._readableState,r=t._writableState;n&&n.autoDestroy||r&&r.autoDestroy?t.destroy(e):t.emit("error",e)}},Un={},pf={};function dt(t,e,n){n||(n=Error);var r=function(i){var o,a;function s(c,l,u){return i.call(this,function(d,h,f){return typeof e=="string"?e:e(d,h,f)}(c,l,u))||this}return a=i,(o=s).prototype=Object.create(a.prototype),o.prototype.constructor=o,o.__proto__=a,s}(n);r.prototype.name=n.name,r.prototype.code=t,pf[t]=r}function Kl(t,e){if(Array.isArray(t)){var n=t.length;return t=t.map(function(r){return String(r)}),n>2?"one of ".concat(e," ").concat(t.slice(0,n-1).join(", "),", or ")+t[n-1]:n===2?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}dt("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError),dt("ERR_INVALID_ARG_TYPE",function(t,e,n){var r,i,o;if(typeof e=="string"&&(i="not ",e.substr(0,i.length)===i)?(r="must not be",e=e.replace(/^not /,"")):r="must be",function(s,c,l){return(l===void 0||l>s.length)&&(l=s.length),s.substring(l-c.length,l)===c}(t," argument"))o="The ".concat(t," ").concat(r," ").concat(Kl(e,"type"));else{var a=function(s,c,l){return typeof l!="number"&&(l=0),!(l+c.length>s.length)&&s.indexOf(c,l)!==-1}(t,".")?"property":"argument";o='The "'.concat(t,'" ').concat(a," ").concat(r," ").concat(Kl(e,"type"))}return o+=". Received type ".concat(typeof n)},TypeError),dt("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),dt("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"}),dt("ERR_STREAM_PREMATURE_CLOSE","Premature close"),dt("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"}),dt("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),dt("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),dt("ERR_STREAM_WRITE_AFTER_END","write after end"),dt("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),dt("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError),dt("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),Un.codes=pf;var Gg=Un.codes.ERR_INVALID_OPT_VALUE,ys,jl,vs,Ul,mf={getHighWaterMark:function(t,e,n,r){var i=function(o,a,s){return o.highWaterMark!=null?o.highWaterMark:a?o[s]:null}(e,r,n);if(i!=null){if(!isFinite(i)||Math.floor(i)!==i||i<0)throw new Gg(r?n:"highWaterMark",i);return Math.floor(i)}return t.objectMode?16:16384}},Yg=typeof Object.create=="function"?function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:function(t,e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t},ei=Zr(Object.freeze({__proto__:null,default:Yg})),Zg=function(t,e){if(bs("noDeprecation"))return t;var n=!1;return function(){if(!n){if(bs("throwDeprecation"))throw new Error(e);bs("traceDeprecation")?console.trace(e):console.warn(e),n=!0}return t.apply(this,arguments)}};function bs(t){try{if(!bt.localStorage)return!1}catch{return!1}var e=bt.localStorage[t];return e!=null&&String(e).toLowerCase()==="true"}function gf(){if(jl)return ys;function t($){var N=this;this.next=null,this.entry=null,this.finish=function(){(function(R,C,P){var D=R.entry;for(R.entry=null;D;){var y=D.callback;C.pendingcb--,y(P),D=D.next}C.corkedRequestsFree.next=R})(N,$)}}var e;jl=1,ys=I,I.WritableState=O;var n={deprecate:Zg},r=tf,i=Fa.Buffer,o=(bt!==void 0?bt:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){},a,s=ff,c=mf.getHighWaterMark,l=Un.codes,u=l.ERR_INVALID_ARG_TYPE,d=l.ERR_METHOD_NOT_IMPLEMENTED,h=l.ERR_MULTIPLE_CALLBACK,f=l.ERR_STREAM_CANNOT_PIPE,g=l.ERR_STREAM_DESTROYED,m=l.ERR_STREAM_NULL_VALUES,w=l.ERR_STREAM_WRITE_AFTER_END,p=l.ERR_UNKNOWN_ENCODING,S=s.errorOrDestroy;function _(){}function O($,N,R){e=e||lr(),$=$||{},typeof R!="boolean"&&(R=N instanceof e),this.objectMode=!!$.objectMode,R&&(this.objectMode=this.objectMode||!!$.writableObjectMode),this.highWaterMark=c(this,$,"writableHighWaterMark",R),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var C=$.decodeStrings===!1;this.decodeStrings=!C,this.defaultEncoding=$.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(P){(function(D,y){var E=D._writableState,A=E.sync,T=E.writecb;if(typeof T!="function")throw new h;if(function(v){v.writing=!1,v.writecb=null,v.length-=v.writelen,v.writelen=0}(E),y)(function(v,k,x,M,L){--k.pendingcb,x?(we.nextTick(L,M),we.nextTick(G,v,k),v._writableState.errorEmitted=!0,S(v,M)):(L(M),v._writableState.errorEmitted=!0,S(v,M),G(v,k))})(D,E,A,y,T);else{var b=U(E)||D.destroyed;b||E.corked||E.bufferProcessing||!E.bufferedRequest||F(D,E),A?we.nextTick(q,D,E,b,T):q(D,E,b,T)}})(N,P)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=$.emitClose!==!1,this.autoDestroy=!!$.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new t(this)}function I($){var N=this instanceof(e=e||lr());if(!N&&!a.call(I,this))return new I($);this._writableState=new O($,this,N),this.writable=!0,$&&(typeof $.write=="function"&&(this._write=$.write),typeof $.writev=="function"&&(this._writev=$.writev),typeof $.destroy=="function"&&(this._destroy=$.destroy),typeof $.final=="function"&&(this._final=$.final)),r.call(this)}function K($,N,R,C,P,D,y){N.writelen=C,N.writecb=y,N.writing=!0,N.sync=!0,N.destroyed?N.onwrite(new g("write")):R?$._writev(P,N.onwrite):$._write(P,D,N.onwrite),N.sync=!1}function q($,N,R,C){R||function(P,D){D.length===0&&D.needDrain&&(D.needDrain=!1,P.emit("drain"))}($,N),N.pendingcb--,C(),G($,N)}function F($,N){N.bufferProcessing=!0;var R=N.bufferedRequest;if($._writev&&R&&R.next){var C=N.bufferedRequestCount,P=new Array(C),D=N.corkedRequestsFree;D.entry=R;for(var y=0,E=!0;R;)P[y]=R,R.isBuf||(E=!1),R=R.next,y+=1;P.allBuffers=E,K($,N,!0,N.length,P,"",D.finish),N.pendingcb++,N.lastBufferedRequest=null,D.next?(N.corkedRequestsFree=D.next,D.next=null):N.corkedRequestsFree=new t(N),N.bufferedRequestCount=0}else{for(;R;){var A=R.chunk,T=R.encoding,b=R.callback;if(K($,N,!1,N.objectMode?1:A.length,A,T,b),R=R.next,N.bufferedRequestCount--,N.writing)break}R===null&&(N.lastBufferedRequest=null)}N.bufferedRequest=R,N.bufferProcessing=!1}function U($){return $.ending&&$.length===0&&$.bufferedRequest===null&&!$.finished&&!$.writing}function j($,N){$._final(function(R){N.pendingcb--,R&&S($,R),N.prefinished=!0,$.emit("prefinish"),G($,N)})}function G($,N){var R=U(N);if(R&&(function(P,D){D.prefinished||D.finalCalled||(typeof P._final!="function"||D.destroyed?(D.prefinished=!0,P.emit("prefinish")):(D.pendingcb++,D.finalCalled=!0,we.nextTick(j,P,D)))}($,N),N.pendingcb===0&&(N.finished=!0,$.emit("finish"),N.autoDestroy))){var C=$._readableState;(!C||C.autoDestroy&&C.endEmitted)&&$.destroy()}return R}return ei(I,r),O.prototype.getBuffer=function(){for(var $=this.bufferedRequest,N=[];$;)N.push($),$=$.next;return N},function(){try{Object.defineProperty(O.prototype,"buffer",{get:n.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}(),typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(a=Function.prototype[Symbol.hasInstance],Object.defineProperty(I,Symbol.hasInstance,{value:function($){return!!a.call(this,$)||this===I&&$&&$._writableState instanceof O}})):a=function($){return $ instanceof this},I.prototype.pipe=function(){S(this,new f)},I.prototype.write=function($,N,R){var C,P=this._writableState,D=!1,y=!P.objectMode&&(C=$,i.isBuffer(C)||C instanceof o);return y&&!i.isBuffer($)&&($=function(E){return i.from(E)}($)),typeof N=="function"&&(R=N,N=null),y?N="buffer":N||(N=P.defaultEncoding),typeof R!="function"&&(R=_),P.ending?function(E,A){var T=new w;S(E,T),we.nextTick(A,T)}(this,R):(y||function(E,A,T,b){var v;return T===null?v=new m:typeof T=="string"||A.objectMode||(v=new u("chunk",["string","Buffer"],T)),!v||(S(E,v),we.nextTick(b,v),!1)}(this,P,$,R))&&(P.pendingcb++,D=function(E,A,T,b,v,k){if(!T){var x=function(H,z,J){return H.objectMode||H.decodeStrings===!1||typeof z!="string"||(z=i.from(z,J)),z}(A,b,v);b!==x&&(T=!0,v="buffer",b=x)}var M=A.objectMode?1:b.length;A.length+=M;var L=A.length<A.highWaterMark;if(L||(A.needDrain=!0),A.writing||A.corked){var B=A.lastBufferedRequest;A.lastBufferedRequest={chunk:b,encoding:v,isBuf:T,callback:k,next:null},B?B.next=A.lastBufferedRequest:A.bufferedRequest=A.lastBufferedRequest,A.bufferedRequestCount+=1}else K(E,A,!1,M,b,v,k);return L}(this,P,y,$,N,R)),D},I.prototype.cork=function(){this._writableState.corked++},I.prototype.uncork=function(){var $=this._writableState;$.corked&&($.corked--,$.writing||$.corked||$.bufferProcessing||!$.bufferedRequest||F(this,$))},I.prototype.setDefaultEncoding=function($){if(typeof $=="string"&&($=$.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf(($+"").toLowerCase())>-1))throw new p($);return this._writableState.defaultEncoding=$,this},Object.defineProperty(I.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(I.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),I.prototype._write=function($,N,R){R(new d("_write()"))},I.prototype._writev=null,I.prototype.end=function($,N,R){var C=this._writableState;return typeof $=="function"?(R=$,$=null,N=null):typeof N=="function"&&(R=N,N=null),$!=null&&this.write($,N),C.corked&&(C.corked=1,this.uncork()),C.ending||function(P,D,y){D.ending=!0,G(P,D),y&&(D.finished?we.nextTick(y):P.once("finish",y)),D.ended=!0,P.writable=!1}(this,C,R),this},Object.defineProperty(I.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(I.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState!==void 0&&this._writableState.destroyed},set:function($){this._writableState&&(this._writableState.destroyed=$)}}),I.prototype.destroy=s.destroy,I.prototype._undestroy=s.undestroy,I.prototype._destroy=function($,N){N($)},ys}function lr(){if(Ul)return vs;Ul=1;var t=Object.keys||function(l){var u=[];for(var d in l)u.push(d);return u};vs=a;var e=yf(),n=gf();ei(a,e);for(var r=t(n.prototype),i=0;i<r.length;i++){var o=r[i];a.prototype[o]||(a.prototype[o]=n.prototype[o])}function a(l){if(!(this instanceof a))return new a(l);e.call(this,l),n.call(this,l),this.allowHalfOpen=!0,l&&(l.readable===!1&&(this.readable=!1),l.writable===!1&&(this.writable=!1),l.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",s)))}function s(){this._writableState.ended||we.nextTick(c,this)}function c(l){l.end()}return Object.defineProperty(a.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(a.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(a.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(a.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._writableState!==void 0&&this._readableState.destroyed&&this._writableState.destroyed},set:function(l){this._readableState!==void 0&&this._writableState!==void 0&&(this._readableState.destroyed=l,this._writableState.destroyed=l)}}),vs}var Jg=X.isEncoding||function(t){switch(t&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function zi(t){switch(this.encoding=(t||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!Jg(e))throw new Error("Unknown encoding: "+e)}(t),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Qg;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=ey;break;default:return void(this.write=Xg)}this.charBuffer=new X(6),this.charReceived=0,this.charLength=0}function Xg(t){return t.toString(this.encoding)}function Qg(t){this.charReceived=t.length%2,this.charLength=this.charReceived?2:0}function ey(t){this.charReceived=t.length%3,this.charLength=this.charReceived?3:0}zi.prototype.write=function(t){for(var e="";this.charLength;){var n=t.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:t.length;if(t.copy(this.charBuffer,this.charReceived,0,n),this.charReceived+=n,this.charReceived<this.charLength)return"";if(t=t.slice(n,t.length),!((i=(e=this.charBuffer.slice(0,this.charLength).toString(this.encoding)).charCodeAt(e.length-1))>=55296&&i<=56319)){if(this.charReceived=this.charLength=0,t.length===0)return e;break}this.charLength+=this.surrogateSize,e=""}this.detectIncompleteChar(t);var r=t.length;this.charLength&&(t.copy(this.charBuffer,0,t.length-this.charReceived,r),r-=this.charReceived);var i;if(r=(e+=t.toString(this.encoding,0,r)).length-1,(i=e.charCodeAt(r))>=55296&&i<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),t.copy(this.charBuffer,0,0,o),e.substring(0,r)}return e},zi.prototype.detectIncompleteChar=function(t){for(var e=t.length>=3?3:t.length;e>0;e--){var n=t[t.length-e];if(e==1&&n>>5==6){this.charLength=2;break}if(e<=2&&n>>4==14){this.charLength=3;break}if(e<=3&&n>>3==30){this.charLength=4;break}}this.charReceived=e},zi.prototype.end=function(t){var e="";if(t&&t.length&&(e=this.write(t)),this.charReceived){var n=this.charReceived,r=this.charBuffer,i=this.encoding;e+=r.slice(0,n).toString(i)}return e};var Hl=Zr(Object.freeze({__proto__:null,StringDecoder:zi})),Fl=Un.codes.ERR_STREAM_PREMATURE_CLOSE;function ty(){}var ws,zl,ql,Vl,Es,Wl,Za=function t(e,n,r){if(typeof n=="function")return t(e,null,n);n||(n={}),r=function(g){var m=!1;return function(){if(!m){m=!0;for(var w=arguments.length,p=new Array(w),S=0;S<w;S++)p[S]=arguments[S];g.apply(this,p)}}}(r||ty);var i=n.readable||n.readable!==!1&&e.readable,o=n.writable||n.writable!==!1&&e.writable,a=function(){e.writable||c()},s=e._writableState&&e._writableState.finished,c=function(){o=!1,s=!0,i||r.call(e)},l=e._readableState&&e._readableState.endEmitted,u=function(){i=!1,l=!0,o||r.call(e)},d=function(g){r.call(e,g)},h=function(){var g;return i&&!l?(e._readableState&&e._readableState.ended||(g=new Fl),r.call(e,g)):o&&!s?(e._writableState&&e._writableState.ended||(g=new Fl),r.call(e,g)):void 0},f=function(){e.req.on("finish",c)};return function(g){return g.setHeader&&typeof g.abort=="function"}(e)?(e.on("complete",c),e.on("abort",h),e.req?f():e.on("request",f)):o&&!e._writableState&&(e.on("end",a),e.on("close",a)),e.on("end",u),e.on("finish",c),n.error!==!1&&e.on("error",d),e.on("close",h),function(){e.removeListener("complete",c),e.removeListener("abort",h),e.removeListener("request",f),e.req&&e.req.removeListener("finish",c),e.removeListener("end",a),e.removeListener("close",a),e.removeListener("finish",c),e.removeListener("end",u),e.removeListener("error",d),e.removeListener("close",h)}};function ny(){if(zl)return ws;var t;function e(m,w,p){return(w=function(S){var _=function(O,I){if(typeof O!="object"||O===null)return O;var K=O[Symbol.toPrimitive];if(K!==void 0){var q=K.call(O,I);if(typeof q!="object")return q;throw new TypeError("@@toPrimitive must return a primitive value.")}return(I==="string"?String:Number)(O)}(S,"string");return typeof _=="symbol"?_:String(_)}(w))in m?Object.defineProperty(m,w,{value:p,enumerable:!0,configurable:!0,writable:!0}):m[w]=p,m}zl=1;var n=Za,r=Symbol("lastResolve"),i=Symbol("lastReject"),o=Symbol("error"),a=Symbol("ended"),s=Symbol("lastPromise"),c=Symbol("handlePromise"),l=Symbol("stream");function u(m,w){return{value:m,done:w}}function d(m){var w=m[r];if(w!==null){var p=m[l].read();p!==null&&(m[s]=null,m[r]=null,m[i]=null,w(u(p,!1)))}}function h(m){we.nextTick(d,m)}var f=Object.getPrototypeOf(function(){}),g=Object.setPrototypeOf((e(t={get stream(){return this[l]},next:function(){var m=this,w=this[o];if(w!==null)return Promise.reject(w);if(this[a])return Promise.resolve(u(void 0,!0));if(this[l].destroyed)return new Promise(function(O,I){we.nextTick(function(){m[o]?I(m[o]):O(u(void 0,!0))})});var p,S=this[s];if(S)p=new Promise(function(O,I){return function(K,q){O.then(function(){I[a]?K(u(void 0,!0)):I[c](K,q)},q)}}(S,this));else{var _=this[l].read();if(_!==null)return Promise.resolve(u(_,!1));p=new Promise(this[c])}return this[s]=p,p}},Symbol.asyncIterator,function(){return this}),e(t,"return",function(){var m=this;return new Promise(function(w,p){m[l].destroy(null,function(S){S?p(S):w(u(void 0,!0))})})}),t),f);return ws=function(m){var w,p=Object.create(g,(e(w={},l,{value:m,writable:!0}),e(w,r,{value:null,writable:!0}),e(w,i,{value:null,writable:!0}),e(w,o,{value:null,writable:!0}),e(w,a,{value:m._readableState.endEmitted,writable:!0}),e(w,c,{value:function(S,_){var O=p[l].read();O?(p[s]=null,p[r]=null,p[i]=null,S(u(O,!1))):(p[r]=S,p[i]=_)},writable:!0}),w));return p[s]=null,n(m,function(S){if(S&&S.code!=="ERR_STREAM_PREMATURE_CLOSE"){var _=p[i];return _!==null&&(p[s]=null,p[r]=null,p[i]=null,_(S)),void(p[o]=S)}var O=p[r];O!==null&&(p[s]=null,p[r]=null,p[i]=null,O(u(void 0,!0))),p[a]=!0}),m.on("readable",h.bind(null,p)),p},ws}function yf(){if(Wl)return Es;var t;Wl=1,Es=I,I.ReadableState=O,Ua.EventEmitter;var e=function(b,v){return b.listeners(v).length},n=tf,r=Fa.Buffer,i=(bt!==void 0?bt:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){},o,a=hf;o=a&&a.debuglog?a.debuglog("stream"):function(){};var s,c,l,u=Wg(),d=ff,h=mf.getHighWaterMark,f=Un.codes,g=f.ERR_INVALID_ARG_TYPE,m=f.ERR_STREAM_PUSH_AFTER_EOF,w=f.ERR_METHOD_NOT_IMPLEMENTED,p=f.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;ei(I,n);var S=d.errorOrDestroy,_=["error","close","destroy","pause","resume"];function O(b,v,k){t=t||lr(),b=b||{},typeof k!="boolean"&&(k=v instanceof t),this.objectMode=!!b.objectMode,k&&(this.objectMode=this.objectMode||!!b.readableObjectMode),this.highWaterMark=h(this,b,"readableHighWaterMark",k),this.buffer=new u,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=b.emitClose!==!1,this.autoDestroy=!!b.autoDestroy,this.destroyed=!1,this.defaultEncoding=b.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,b.encoding&&(s||(s=Hl.StringDecoder),this.decoder=new s(b.encoding),this.encoding=b.encoding)}function I(b){if(t=t||lr(),!(this instanceof I))return new I(b);var v=this instanceof t;this._readableState=new O(b,this,v),this.readable=!0,b&&(typeof b.read=="function"&&(this._read=b.read),typeof b.destroy=="function"&&(this._destroy=b.destroy)),n.call(this)}function K(b,v,k,x,M){o("readableAddChunk",v);var L,B=b._readableState;if(v===null)B.reading=!1,function(H,z){if(o("onEofChunk"),!z.ended){if(z.decoder){var J=z.decoder.end();J&&J.length&&(z.buffer.push(J),z.length+=z.objectMode?1:J.length)}z.ended=!0,z.sync?j(H):(z.needReadable=!1,z.emittedReadable||(z.emittedReadable=!0,G(H)))}}(b,B);else if(M||(L=function(H,z){var J;Q=z,r.isBuffer(Q)||Q instanceof i||typeof z=="string"||z===void 0||H.objectMode||(J=new g("chunk",["string","Buffer","Uint8Array"],z));var Q;return J}(B,v)),L)S(b,L);else if(B.objectMode||v&&v.length>0)if(typeof v=="string"||B.objectMode||Object.getPrototypeOf(v)===r.prototype||(v=function(H){return r.from(H)}(v)),x)B.endEmitted?S(b,new p):q(b,B,v,!0);else if(B.ended)S(b,new m);else{if(B.destroyed)return!1;B.reading=!1,B.decoder&&!k?(v=B.decoder.write(v),B.objectMode||v.length!==0?q(b,B,v,!1):$(b,B)):q(b,B,v,!1)}else x||(B.reading=!1,$(b,B));return!B.ended&&(B.length<B.highWaterMark||B.length===0)}function q(b,v,k,x){v.flowing&&v.length===0&&!v.sync?(v.awaitDrain=0,b.emit("data",k)):(v.length+=v.objectMode?1:k.length,x?v.buffer.unshift(k):v.buffer.push(k),v.needReadable&&j(b)),$(b,v)}Object.defineProperty(I.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._readableState.destroyed},set:function(b){this._readableState&&(this._readableState.destroyed=b)}}),I.prototype.destroy=d.destroy,I.prototype._undestroy=d.undestroy,I.prototype._destroy=function(b,v){v(b)},I.prototype.push=function(b,v){var k,x=this._readableState;return x.objectMode?k=!0:typeof b=="string"&&((v=v||x.defaultEncoding)!==x.encoding&&(b=r.from(b,v),v=""),k=!0),K(this,b,v,!1,k)},I.prototype.unshift=function(b){return K(this,b,null,!0,!1)},I.prototype.isPaused=function(){return this._readableState.flowing===!1},I.prototype.setEncoding=function(b){s||(s=Hl.StringDecoder);var v=new s(b);this._readableState.decoder=v,this._readableState.encoding=this._readableState.decoder.encoding;for(var k=this._readableState.buffer.head,x="";k!==null;)x+=v.write(k.data),k=k.next;return this._readableState.buffer.clear(),x!==""&&this._readableState.buffer.push(x),this._readableState.length=x.length,this};var F=1073741824;function U(b,v){return b<=0||v.length===0&&v.ended?0:v.objectMode?1:b!=b?v.flowing&&v.length?v.buffer.head.data.length:v.length:(b>v.highWaterMark&&(v.highWaterMark=function(k){return k>=F?k=F:(k--,k|=k>>>1,k|=k>>>2,k|=k>>>4,k|=k>>>8,k|=k>>>16,k++),k}(b)),b<=v.length?b:v.ended?v.length:(v.needReadable=!0,0))}function j(b){var v=b._readableState;o("emitReadable",v.needReadable,v.emittedReadable),v.needReadable=!1,v.emittedReadable||(o("emitReadable",v.flowing),v.emittedReadable=!0,we.nextTick(G,b))}function G(b){var v=b._readableState;o("emitReadable_",v.destroyed,v.length,v.ended),v.destroyed||!v.length&&!v.ended||(b.emit("readable"),v.emittedReadable=!1),v.needReadable=!v.flowing&&!v.ended&&v.length<=v.highWaterMark,D(b)}function $(b,v){v.readingMore||(v.readingMore=!0,we.nextTick(N,b,v))}function N(b,v){for(;!v.reading&&!v.ended&&(v.length<v.highWaterMark||v.flowing&&v.length===0);){var k=v.length;if(o("maybeReadMore read 0"),b.read(0),k===v.length)break}v.readingMore=!1}function R(b){var v=b._readableState;v.readableListening=b.listenerCount("readable")>0,v.resumeScheduled&&!v.paused?v.flowing=!0:b.listenerCount("data")>0&&b.resume()}function C(b){o("readable nexttick read 0"),b.read(0)}function P(b,v){o("resume",v.reading),v.reading||b.read(0),v.resumeScheduled=!1,b.emit("resume"),D(b),v.flowing&&!v.reading&&b.read(0)}function D(b){var v=b._readableState;for(o("flow",v.flowing);v.flowing&&b.read()!==null;);}function y(b,v){return v.length===0?null:(v.objectMode?k=v.buffer.shift():!b||b>=v.length?(k=v.decoder?v.buffer.join(""):v.buffer.length===1?v.buffer.first():v.buffer.concat(v.length),v.buffer.clear()):k=v.buffer.consume(b,v.decoder),k);var k}function E(b){var v=b._readableState;o("endReadable",v.endEmitted),v.endEmitted||(v.ended=!0,we.nextTick(A,v,b))}function A(b,v){if(o("endReadableNT",b.endEmitted,b.length),!b.endEmitted&&b.length===0&&(b.endEmitted=!0,v.readable=!1,v.emit("end"),b.autoDestroy)){var k=v._writableState;(!k||k.autoDestroy&&k.finished)&&v.destroy()}}function T(b,v){for(var k=0,x=b.length;k<x;k++)if(b[k]===v)return k;return-1}return I.prototype.read=function(b){o("read",b),b=parseInt(b,10);var v=this._readableState,k=b;if(b!==0&&(v.emittedReadable=!1),b===0&&v.needReadable&&((v.highWaterMark!==0?v.length>=v.highWaterMark:v.length>0)||v.ended))return o("read: emitReadable",v.length,v.ended),v.length===0&&v.ended?E(this):j(this),null;if((b=U(b,v))===0&&v.ended)return v.length===0&&E(this),null;var x,M=v.needReadable;return o("need readable",M),(v.length===0||v.length-b<v.highWaterMark)&&o("length less than watermark",M=!0),v.ended||v.reading?o("reading or ended",M=!1):M&&(o("do read"),v.reading=!0,v.sync=!0,v.length===0&&(v.needReadable=!0),this._read(v.highWaterMark),v.sync=!1,v.reading||(b=U(k,v))),(x=b>0?y(b,v):null)===null?(v.needReadable=v.length<=v.highWaterMark,b=0):(v.length-=b,v.awaitDrain=0),v.length===0&&(v.ended||(v.needReadable=!0),k!==b&&v.ended&&E(this)),x!==null&&this.emit("data",x),x},I.prototype._read=function(b){S(this,new w("_read()"))},I.prototype.pipe=function(b,v){var k=this,x=this._readableState;switch(x.pipesCount){case 0:x.pipes=b;break;case 1:x.pipes=[x.pipes,b];break;default:x.pipes.push(b)}x.pipesCount+=1,o("pipe count=%d opts=%j",x.pipesCount,v);var M=(!v||v.end!==!1)&&b!==we.stdout&&b!==we.stderr?B:le;function L(re,ie){o("onunpipe"),re===k&&ie&&ie.hasUnpiped===!1&&(ie.hasUnpiped=!0,o("cleanup"),b.removeListener("close",ne),b.removeListener("finish",se),b.removeListener("drain",H),b.removeListener("error",Q),b.removeListener("unpipe",L),k.removeListener("end",B),k.removeListener("end",le),k.removeListener("data",J),z=!0,!x.awaitDrain||b._writableState&&!b._writableState.needDrain||H())}function B(){o("onend"),b.end()}x.endEmitted?we.nextTick(M):k.once("end",M),b.on("unpipe",L);var H=function(re){return function(){var ie=re._readableState;o("pipeOnDrain",ie.awaitDrain),ie.awaitDrain&&ie.awaitDrain--,ie.awaitDrain===0&&e(re,"data")&&(ie.flowing=!0,D(re))}}(k);b.on("drain",H);var z=!1;function J(re){o("ondata");var ie=b.write(re);o("dest.write",ie),ie===!1&&((x.pipesCount===1&&x.pipes===b||x.pipesCount>1&&T(x.pipes,b)!==-1)&&!z&&(o("false write response, pause",x.awaitDrain),x.awaitDrain++),k.pause())}function Q(re){o("onerror",re),le(),b.removeListener("error",Q),e(b,"error")===0&&S(b,re)}function ne(){b.removeListener("finish",se),le()}function se(){o("onfinish"),b.removeListener("close",ne),le()}function le(){o("unpipe"),k.unpipe(b)}return k.on("data",J),function(re,ie,ce){if(typeof re.prependListener=="function")return re.prependListener(ie,ce);re._events&&re._events[ie]?Array.isArray(re._events[ie])?re._events[ie].unshift(ce):re._events[ie]=[ce,re._events[ie]]:re.on(ie,ce)}(b,"error",Q),b.once("close",ne),b.once("finish",se),b.emit("pipe",k),x.flowing||(o("pipe resume"),k.resume()),b},I.prototype.unpipe=function(b){var v=this._readableState,k={hasUnpiped:!1};if(v.pipesCount===0)return this;if(v.pipesCount===1)return b&&b!==v.pipes||(b||(b=v.pipes),v.pipes=null,v.pipesCount=0,v.flowing=!1,b&&b.emit("unpipe",this,k)),this;if(!b){var x=v.pipes,M=v.pipesCount;v.pipes=null,v.pipesCount=0,v.flowing=!1;for(var L=0;L<M;L++)x[L].emit("unpipe",this,{hasUnpiped:!1});return this}var B=T(v.pipes,b);return B===-1||(v.pipes.splice(B,1),v.pipesCount-=1,v.pipesCount===1&&(v.pipes=v.pipes[0]),b.emit("unpipe",this,k)),this},I.prototype.on=function(b,v){var k=n.prototype.on.call(this,b,v),x=this._readableState;return b==="data"?(x.readableListening=this.listenerCount("readable")>0,x.flowing!==!1&&this.resume()):b==="readable"&&(x.endEmitted||x.readableListening||(x.readableListening=x.needReadable=!0,x.flowing=!1,x.emittedReadable=!1,o("on readable",x.length,x.reading),x.length?j(this):x.reading||we.nextTick(C,this))),k},I.prototype.addListener=I.prototype.on,I.prototype.removeListener=function(b,v){var k=n.prototype.removeListener.call(this,b,v);return b==="readable"&&we.nextTick(R,this),k},I.prototype.removeAllListeners=function(b){var v=n.prototype.removeAllListeners.apply(this,arguments);return b!=="readable"&&b!==void 0||we.nextTick(R,this),v},I.prototype.resume=function(){var b=this._readableState;return b.flowing||(o("resume"),b.flowing=!b.readableListening,function(v,k){k.resumeScheduled||(k.resumeScheduled=!0,we.nextTick(P,v,k))}(this,b)),b.paused=!1,this},I.prototype.pause=function(){return o("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(o("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},I.prototype.wrap=function(b){var v=this,k=this._readableState,x=!1;for(var M in b.on("end",function(){if(o("wrapped end"),k.decoder&&!k.ended){var B=k.decoder.end();B&&B.length&&v.push(B)}v.push(null)}),b.on("data",function(B){o("wrapped data"),k.decoder&&(B=k.decoder.write(B)),k.objectMode&&B==null||(k.objectMode||B&&B.length)&&(v.push(B)||(x=!0,b.pause()))}),b)this[M]===void 0&&typeof b[M]=="function"&&(this[M]=function(B){return function(){return b[B].apply(b,arguments)}}(M));for(var L=0;L<_.length;L++)b.on(_[L],this.emit.bind(this,_[L]));return this._read=function(B){o("wrapped _read",B),x&&(x=!1,b.resume())},this},typeof Symbol=="function"&&(I.prototype[Symbol.asyncIterator]=function(){return c===void 0&&(c=ny()),c(this)}),Object.defineProperty(I.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(I.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(I.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(b){this._readableState&&(this._readableState.flowing=b)}}),I._fromList=y,Object.defineProperty(I.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),typeof Symbol=="function"&&(I.from=function(b,v){return l===void 0&&(l=Vl?ql:(Vl=1,ql=function(){throw new Error("Readable.from is not available in the browser")})),l(I,b,v)}),Es}var vf=Gt,Oo=Un.codes,ry=Oo.ERR_METHOD_NOT_IMPLEMENTED,iy=Oo.ERR_MULTIPLE_CALLBACK,oy=Oo.ERR_TRANSFORM_ALREADY_TRANSFORMING,sy=Oo.ERR_TRANSFORM_WITH_LENGTH_0,qi=lr();function ay(t,e){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(r===null)return this.emit("error",new iy);n.writechunk=null,n.writecb=null,e!=null&&this.push(e),r(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function Gt(t){if(!(this instanceof Gt))return new Gt(t);qi.call(this,t),this._transformState={afterTransform:ay.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&(typeof t.transform=="function"&&(this._transform=t.transform),typeof t.flush=="function"&&(this._flush=t.flush)),this.on("prefinish",cy)}function cy(){var t=this;typeof this._flush!="function"||this._readableState.destroyed?Gl(this,null,null):this._flush(function(e,n){Gl(t,e,n)})}function Gl(t,e,n){if(e)return t.emit("error",e);if(n!=null&&t.push(n),t._writableState.length)throw new sy;if(t._transformState.transforming)throw new oy;return t.push(null)}ei(Gt,qi),Gt.prototype.push=function(t,e){return this._transformState.needTransform=!1,qi.prototype.push.call(this,t,e)},Gt.prototype._transform=function(t,e,n){n(new ry("_transform()"))},Gt.prototype._write=function(t,e,n){var r=this._transformState;if(r.writecb=n,r.writechunk=t,r.writeencoding=e,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},Gt.prototype._read=function(t){var e=this._transformState;e.writechunk===null||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},Gt.prototype._destroy=function(t,e){qi.prototype._destroy.call(this,t,function(n){e(n)})};var _s,ly=Fr,bf=vf;function Fr(t){if(!(this instanceof Fr))return new Fr(t);bf.call(this,t)}ei(Fr,bf),Fr.prototype._transform=function(t,e,n){n(null,t)};var wf=Un.codes,uy=wf.ERR_MISSING_ARGS,dy=wf.ERR_STREAM_DESTROYED;function Yl(t){if(t)throw t}function Zl(t){t()}function hy(t,e){return t.pipe(e)}var fy=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r,i=function(a){return a.length?typeof a[a.length-1]!="function"?Yl:a.pop():Yl}(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new uy("streams");var o=e.map(function(a,s){var c=s<e.length-1;return function(l,u,d,h){h=function(m){var w=!1;return function(){w||(w=!0,m.apply(void 0,arguments))}}(h);var f=!1;l.on("close",function(){f=!0}),_s===void 0&&(_s=Za),_s(l,{readable:u,writable:d},function(m){if(m)return h(m);f=!0,h()});var g=!1;return function(m){if(!f&&!g)return g=!0,function(w){return w.setHeader&&typeof w.abort=="function"}(l)?l.abort():typeof l.destroy=="function"?l.destroy():void h(m||new dy("pipe"))}}(a,c,s>0,function(l){r||(r=l),l&&o.forEach(Zl),c||(o.forEach(Zl),i(r))})});return e.reduce(hy)};(function(t,e){(e=aa.exports=yf()).Stream=e,e.Readable=e,e.Writable=gf(),e.Duplex=lr(),e.Transform=vf,e.PassThrough=ly,e.finished=Za,e.pipeline=fy})(0,aa.exports);var ur=aa.exports;function py(t={}){const e={},n=new ur.Duplex({objectMode:!0,read:()=>{},write:function(o,a,s){let c=null;try{o.id?function(l){const{id:u}=l;if(u===null)return;const d=e[u];if(!d)return void console.warn(`StreamMiddleware - Unknown response id "${u}"`);delete e[u],Object.assign(d.res,l),setTimeout(d.end)}(o):function(l){t!=null&&t.retryOnMessage&&l.method===t.retryOnMessage&&Object.values(e).forEach(({req:u,retryCount:d=0})=>{if(!u.id)return;if(d>=3)throw new Error(`StreamMiddleware - Retry limit exceeded for request id "${u.id}"`);const h=e[u.id];h&&(h.retryCount=d+1),i(u)}),r.emit("notification",l)}(o)}catch(l){c=l}s(c)}}),r=new Gh;return{events:r,middleware:(o,a,s,c)=>{e[o.id]={req:o,res:a,next:s,end:c},i(o)},stream:n};function i(o){n.push(o)}}var po={},la={exports:{}},my=function t(e,n){if(e&&n)return t(e)(n);if(typeof e!="function")throw new TypeError("need wrapper function");return Object.keys(e).forEach(function(i){r[i]=e[i]}),r;function r(){for(var i=new Array(arguments.length),o=0;o<i.length;o++)i[o]=arguments[o];var a=e.apply(this,i),s=i[i.length-1];return typeof a=="function"&&a!==s&&Object.keys(s).forEach(function(c){a[c]=s[c]}),a}},Jl=my;function Si(t){var e=function(){return e.called?e.value:(e.called=!0,e.value=t.apply(this,arguments))};return e.called=!1,e}function Xl(t){var e=function(){if(e.called)throw new Error(e.onceError);return e.called=!0,e.value=t.apply(this,arguments)},n=t.name||"Function wrapped with `once`";return e.onceError=n+" shouldn't be called more than once",e.called=!1,e}la.exports=Jl(Si),la.exports.strict=Jl(Xl),Si.proto=Si(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return Si(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return Xl(this)},configurable:!0})});var gy=la.exports,mo={};Object.defineProperty(mo,"__esModule",{value:!0}),mo.Substream=void 0;const yy=ur;class vy extends yy.Duplex{constructor({parent:e,name:n}){super({objectMode:!0}),this._parent=e,this._name=n}_read(){}_write(e,n,r){this._parent.push({name:this._name,data:e}),r()}}mo.Substream=vy;var by=bt&&bt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(po,"__esModule",{value:!0}),po.ObjectMultiplex=void 0;const Ss=ur,wy=by(gy),Ey=mo,Ql=Symbol("IGNORE_SUBSTREAM");let _y=class extends Ss.Duplex{constructor(t={}){super(Object.assign(Object.assign({},t),{objectMode:!0})),this._substreams={}}createStream(t){if(this.destroyed)throw new Error(`ObjectMultiplex - parent stream for name "${t}" already destroyed`);if(this._readableState.ended||this._writableState.ended)throw new Error(`ObjectMultiplex - parent stream for name "${t}" already ended`);if(!t)throw new Error("ObjectMultiplex - name must not be empty");if(this._substreams[t])throw new Error(`ObjectMultiplex - Substream for name "${t}" already exists`);const e=new Ey.Substream({parent:this,name:t});return this._substreams[t]=e,function(n,r){const i=(0,wy.default)(r);(0,Ss.finished)(n,{readable:!1},i),(0,Ss.finished)(n,{writable:!1},i)}(this,n=>e.destroy(n||void 0)),e}ignoreStream(t){if(!t)throw new Error("ObjectMultiplex - name must not be empty");if(this._substreams[t])throw new Error(`ObjectMultiplex - Substream for name "${t}" already exists`);this._substreams[t]=Ql}_read(){}_write(t,e,n){const{name:r,data:i}=t;if(!r)return console.warn(`ObjectMultiplex - malformed chunk without name "${t}"`),n();const o=this._substreams[r];return o?(o!==Ql&&o.push(i),n()):(console.warn(`ObjectMultiplex - orphaned data for stream "${r}"`),n())}};po.ObjectMultiplex=_y;var Sy=Ao(po.ObjectMultiplex);const Tt=t=>t!==null&&typeof t=="object"&&typeof t.pipe=="function";Tt.writable=t=>Tt(t)&&t.writable!==!1&&typeof t._write=="function"&&typeof t._writableState=="object",Tt.readable=t=>Tt(t)&&t.readable!==!1&&typeof t._read=="function"&&typeof t._readableState=="object",Tt.duplex=t=>Tt.writable(t)&&Tt.readable(t),Tt.transform=t=>Tt.duplex(t)&&typeof t._transform=="function";var Mt,Cy=Tt,ky=class extends jg{constructor(t,{jsonRpcStreamName:e,logger:n=console,maxEventListeners:r=100,rpcMiddleware:i=[]}){if(super({logger:n,maxEventListeners:r,rpcMiddleware:i}),!Cy.duplex(t))throw new Error(Te.errors.invalidDuplexStream());this._handleStreamDisconnect=this._handleStreamDisconnect.bind(this);const o=new Sy;ur.pipeline(t,o,t,this._handleStreamDisconnect.bind(this,"MetaMask")),this._jsonRpcConnection=py({retryOnMessage:"METAMASK_EXTENSION_CONNECT_CAN_RETRY"}),ur.pipeline(this._jsonRpcConnection.stream,o.createStream(e),this._jsonRpcConnection.stream,this._handleStreamDisconnect.bind(this,"MetaMask RpcProvider")),this._rpcEngine.push(this._jsonRpcConnection.middleware),this._jsonRpcConnection.events.on("notification",a=>{const{method:s,params:c}=a;s==="metamask_accountsChanged"?this._handleAccountsChanged(c):s==="metamask_unlockStateChanged"?this._handleUnlockStateChanged(c):s==="metamask_chainChanged"?this._handleChainChanged(c):Yh.includes(s)?this.emit("message",{type:s,data:c}):s==="METAMASK_STREAM_FAILURE"&&t.destroy(new Error(Te.errors.permanentlyDisconnected()))})}async _initializeStateAsync(){let t;try{t=await this.request({method:"metamask_getProviderState"})}catch(e){this._log.error("MetaMask: Failed to get initial state. Please report this bug.",e)}this._initializeState(t)}_handleStreamDisconnect(t,e){let n=`MetaMask: Lost connection to "${t}".`;e!=null&&e.stack&&(n+=`
34
+ ${e.stack}`),this._log.warn(n),this.listenerCount("error")>0&&this.emit("error",n),this._handleDisconnect(!1,e?e.message:void 0)}_handleChainChanged({chainId:t,networkVersion:e}={}){Zh(t)&&(n=>!!n&&typeof n=="string")(e)?e==="loading"?this._handleDisconnect(!0):super._handleChainChanged({chainId:t}):this._log.error(Te.errors.invalidNetworkParams(),{chainId:t,networkVersion:e})}},Ay=class extends ky{constructor(t,{jsonRpcStreamName:e="metamask-provider",logger:n=console,maxEventListeners:r=100,shouldSendMetadata:i}={}){if(super(t,{jsonRpcStreamName:e,logger:n,maxEventListeners:r,rpcMiddleware:Pg(n)}),this._sentWarnings={chainId:!1,networkVersion:!1,selectedAddress:!1,enable:!1,experimentalMethods:!1,send:!1,events:{close:!1,data:!1,networkChanged:!1,notification:!1}},sa(this,Mt,void 0),this._initializeStateAsync(),Wt(this,Mt,null),this.isMetaMask=!0,this._sendSync=this._sendSync.bind(this),this.enable=this.enable.bind(this),this.send=this.send.bind(this),this.sendAsync=this.sendAsync.bind(this),this._warnOfDeprecation=this._warnOfDeprecation.bind(this),this._metamask=this._getExperimentalApi(),this._jsonRpcConnection.events.on("notification",o=>{const{method:a}=o;Yh.includes(a)&&(this.emit("data",o),this.emit("notification",o.params.result))}),i)if(document.readyState==="complete")Nl(this._rpcEngine,this._log);else{const o=()=>{Nl(this._rpcEngine,this._log),window.removeEventListener("DOMContentLoaded",o)};window.addEventListener("DOMContentLoaded",o)}}get chainId(){return this._sentWarnings.chainId||(this._log.warn(Te.warnings.chainIdDeprecation),this._sentWarnings.chainId=!0),super.chainId}get networkVersion(){return this._sentWarnings.networkVersion||(this._log.warn(Te.warnings.networkVersionDeprecation),this._sentWarnings.networkVersion=!0),It(this,Mt)}get selectedAddress(){return this._sentWarnings.selectedAddress||(this._log.warn(Te.warnings.selectedAddressDeprecation),this._sentWarnings.selectedAddress=!0),super.selectedAddress}sendAsync(t,e){this._rpcRequest(t,e)}addListener(t,e){return this._warnOfDeprecation(t),super.addListener(t,e)}on(t,e){return this._warnOfDeprecation(t),super.on(t,e)}once(t,e){return this._warnOfDeprecation(t),super.once(t,e)}prependListener(t,e){return this._warnOfDeprecation(t),super.prependListener(t,e)}prependOnceListener(t,e){return this._warnOfDeprecation(t),super.prependOnceListener(t,e)}_handleDisconnect(t,e){super._handleDisconnect(t,e),It(this,Mt)&&!t&&Wt(this,Mt,null)}_warnOfDeprecation(t){var e;((e=this._sentWarnings)==null?void 0:e.events[t])===!1&&(this._log.warn(Te.warnings.events[t]),this._sentWarnings.events[t]=!0)}async enable(){return this._sentWarnings.enable||(this._log.warn(Te.warnings.enableDeprecation),this._sentWarnings.enable=!0),new Promise((t,e)=>{try{this._rpcRequest({method:"eth_requestAccounts",params:[]},Hi(t,e))}catch(n){e(n)}})}send(t,e){return this._sentWarnings.send||(this._log.warn(Te.warnings.sendDeprecation),this._sentWarnings.send=!0),typeof t!="string"||e&&!Array.isArray(e)?t&&typeof t=="object"&&typeof e=="function"?this._rpcRequest(t,e):this._sendSync(t):new Promise((n,r)=>{try{this._rpcRequest({method:t,params:e},Hi(n,r,!1))}catch(i){r(i)}})}_sendSync(t){let e;switch(t.method){case"eth_accounts":e=this.selectedAddress?[this.selectedAddress]:[];break;case"eth_coinbase":e=this.selectedAddress??null;break;case"eth_uninstallFilter":this._rpcRequest(t,Jh),e=!0;break;case"net_version":e=It(this,Mt)??null;break;default:throw new Error(Te.errors.unsupportedSync(t.method))}return{id:t.id,jsonrpc:t.jsonrpc,result:e}}_getExperimentalApi(){return new Proxy({isUnlocked:async()=>(this._state.initialized||await new Promise(t=>{this.on("_initialized",()=>t())}),this._state.isUnlocked),requestBatch:async t=>{if(!Array.isArray(t))throw Tr({message:"Batch requests must be made with an array of request objects.",data:t});return new Promise((e,n)=>{this._rpcRequest(t,Hi(e,n))})}},{get:(t,e,...n)=>(this._sentWarnings.experimentalMethods||(this._log.warn(Te.warnings.experimentalMethods),this._sentWarnings.experimentalMethods=!0),Reflect.get(t,e,...n))})}_handleChainChanged({chainId:t,networkVersion:e}={}){super._handleChainChanged({chainId:t,networkVersion:e}),this._state.isConnected&&e!==It(this,Mt)&&(Wt(this,Mt,e),this._state.initialized&&this.emit("networkChanged",It(this,Mt)))}};Mt=new WeakMap;const W=Ze("MM_SDK");let eu;W.color="#FFAC1C";var Ef={},Sn={};Object.defineProperty(Sn,"__esModule",{value:!0}),Sn.EthereumProviderError=Sn.EthereumRpcError=void 0;const xy=Hh;class _f extends Error{constructor(e,n,r){if(!Number.isInteger(e))throw new Error('"code" must be an integer.');if(!n||typeof n!="string")throw new Error('"message" must be a nonempty string.');super(n),this.code=e,r!==void 0&&(this.data=r)}serialize(){const e={code:this.code,message:this.message};return this.data!==void 0&&(e.data=this.data),this.stack&&(e.stack=this.stack),e}toString(){return xy.default(this.serialize(),Ty,2)}}Sn.EthereumRpcError=_f;function Ty(t,e){if(e!=="[Circular]")return e}Sn.EthereumProviderError=class extends _f{constructor(t,e,n){if(!function(r){return Number.isInteger(r)&&r>=1e3&&r<=4999}(t))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(t,e,n)}};var Ja={},gn={};Object.defineProperty(gn,"__esModule",{value:!0}),gn.errorValues=gn.errorCodes=void 0,gn.errorCodes={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901}},gn.errorValues={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."}},function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.serializeError=t.isValidCode=t.getMessageFromCode=t.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;const e=gn,n=Sn,r=e.errorCodes.rpc.internal,i="Unspecified error message. This is a bug, please report it.",o={code:r,message:a(r)};function a(d,h=i){if(Number.isInteger(d)){const f=d.toString();if(u(e.errorValues,f))return e.errorValues[f].message;if(c(d))return t.JSON_RPC_SERVER_ERROR_MESSAGE}return h}function s(d){if(!Number.isInteger(d))return!1;const h=d.toString();return!!e.errorValues[h]||!!c(d)}function c(d){return d>=-32099&&d<=-32e3}function l(d){return d&&typeof d=="object"&&!Array.isArray(d)?Object.assign({},d):d}function u(d,h){return Object.prototype.hasOwnProperty.call(d,h)}t.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.",t.getMessageFromCode=a,t.isValidCode=s,t.serializeError=function(d,{fallbackError:h=o,shouldIncludeStack:f=!1}={}){var g,m;if(!h||!Number.isInteger(h.code)||typeof h.message!="string")throw new Error("Must provide fallback error with integer number code and string message.");if(d instanceof n.EthereumRpcError)return d.serialize();const w={};if(d&&typeof d=="object"&&!Array.isArray(d)&&u(d,"code")&&s(d.code)){const S=d;w.code=S.code,S.message&&typeof S.message=="string"?(w.message=S.message,u(S,"data")&&(w.data=S.data)):(w.message=a(w.code),w.data={originalError:l(d)})}else{w.code=h.code;const S=(g=d)===null||g===void 0?void 0:g.message;w.message=S&&typeof S=="string"?S:h.message,w.data={originalError:l(d)}}const p=(m=d)===null||m===void 0?void 0:m.stack;return f&&d&&p&&typeof p=="string"&&(w.stack=p),w}}(Ja);var go={};Object.defineProperty(go,"__esModule",{value:!0}),go.ethErrors=void 0;const Xa=Sn,Sf=Ja,Ue=gn;function ht(t,e){const[n,r]=Cf(e);return new Xa.EthereumRpcError(t,n||Sf.getMessageFromCode(t),r)}function wr(t,e){const[n,r]=Cf(e);return new Xa.EthereumProviderError(t,n||Sf.getMessageFromCode(t),r)}function Cf(t){if(t){if(typeof t=="string")return[t];if(typeof t=="object"&&!Array.isArray(t)){const{message:e,data:n}=t;if(e&&typeof e!="string")throw new Error("Must specify string message.");return[e||void 0,n]}}return[]}go.ethErrors={rpc:{parse:t=>ht(Ue.errorCodes.rpc.parse,t),invalidRequest:t=>ht(Ue.errorCodes.rpc.invalidRequest,t),invalidParams:t=>ht(Ue.errorCodes.rpc.invalidParams,t),methodNotFound:t=>ht(Ue.errorCodes.rpc.methodNotFound,t),internal:t=>ht(Ue.errorCodes.rpc.internal,t),server:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:e}=t;if(!Number.isInteger(e)||e>-32005||e<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return ht(e,t)},invalidInput:t=>ht(Ue.errorCodes.rpc.invalidInput,t),resourceNotFound:t=>ht(Ue.errorCodes.rpc.resourceNotFound,t),resourceUnavailable:t=>ht(Ue.errorCodes.rpc.resourceUnavailable,t),transactionRejected:t=>ht(Ue.errorCodes.rpc.transactionRejected,t),methodNotSupported:t=>ht(Ue.errorCodes.rpc.methodNotSupported,t),limitExceeded:t=>ht(Ue.errorCodes.rpc.limitExceeded,t)},provider:{userRejectedRequest:t=>wr(Ue.errorCodes.provider.userRejectedRequest,t),unauthorized:t=>wr(Ue.errorCodes.provider.unauthorized,t),unsupportedMethod:t=>wr(Ue.errorCodes.provider.unsupportedMethod,t),disconnected:t=>wr(Ue.errorCodes.provider.disconnected,t),chainDisconnected:t=>wr(Ue.errorCodes.provider.chainDisconnected,t),custom:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:e,message:n,data:r}=t;if(!n||typeof n!="string")throw new Error('"message" must be a nonempty string');return new Xa.EthereumProviderError(e,n,r)}}},function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.getMessageFromCode=t.serializeError=t.EthereumProviderError=t.EthereumRpcError=t.ethErrors=t.errorCodes=void 0;const e=Sn;Object.defineProperty(t,"EthereumRpcError",{enumerable:!0,get:function(){return e.EthereumRpcError}}),Object.defineProperty(t,"EthereumProviderError",{enumerable:!0,get:function(){return e.EthereumProviderError}});const n=Ja;Object.defineProperty(t,"serializeError",{enumerable:!0,get:function(){return n.serializeError}}),Object.defineProperty(t,"getMessageFromCode",{enumerable:!0,get:function(){return n.getMessageFromCode}});const r=go;Object.defineProperty(t,"ethErrors",{enumerable:!0,get:function(){return r.ethErrors}});const i=gn;Object.defineProperty(t,"errorCodes",{enumerable:!0,get:function(){return i.errorCodes}})}(Ef);var kf={exports:{}};kf.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(r,i,o){n.o(r,i)||Object.defineProperty(r,i,{enumerable:!0,get:o})},n.r=function(r){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},n.t=function(r,i){if(1&i&&(r=n(r)),8&i||4&i&&typeof r=="object"&&r&&r.__esModule)return r;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:r}),2&i&&typeof r!="string")for(var a in r)n.d(o,a,(function(s){return r[s]}).bind(null,a));return o},n.n=function(r){var i=r&&r.__esModule?function(){return r.default}:function(){return r};return n.d(i,"a",i),i},n.o=function(r,i){return Object.prototype.hasOwnProperty.call(r,i)},n.p="",n(n.s=90)}({17:function(t,e,n){e.__esModule=!0,e.default=void 0;var r=n(18),i=function(){function o(){}return o.getFirstMatch=function(a,s){var c=s.match(a);return c&&c.length>0&&c[1]||""},o.getSecondMatch=function(a,s){var c=s.match(a);return c&&c.length>1&&c[2]||""},o.matchAndReturnConst=function(a,s,c){if(a.test(s))return c},o.getWindowsVersionName=function(a){switch(a){case"NT":return"NT";case"XP":case"NT 5.1":return"XP";case"NT 5.0":return"2000";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},o.getMacOSVersionName=function(a){var s=a.split(".").splice(0,2).map(function(c){return parseInt(c,10)||0});if(s.push(0),s[0]===10)switch(s[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}},o.getAndroidVersionName=function(a){var s=a.split(".").splice(0,2).map(function(c){return parseInt(c,10)||0});if(s.push(0),!(s[0]===1&&s[1]<5))return s[0]===1&&s[1]<6?"Cupcake":s[0]===1&&s[1]>=6?"Donut":s[0]===2&&s[1]<2?"Eclair":s[0]===2&&s[1]===2?"Froyo":s[0]===2&&s[1]>2?"Gingerbread":s[0]===3?"Honeycomb":s[0]===4&&s[1]<1?"Ice Cream Sandwich":s[0]===4&&s[1]<4?"Jelly Bean":s[0]===4&&s[1]>=4?"KitKat":s[0]===5?"Lollipop":s[0]===6?"Marshmallow":s[0]===7?"Nougat":s[0]===8?"Oreo":s[0]===9?"Pie":void 0},o.getVersionPrecision=function(a){return a.split(".").length},o.compareVersions=function(a,s,c){c===void 0&&(c=!1);var l=o.getVersionPrecision(a),u=o.getVersionPrecision(s),d=Math.max(l,u),h=0,f=o.map([a,s],function(g){var m=d-o.getVersionPrecision(g),w=g+new Array(m+1).join(".0");return o.map(w.split("."),function(p){return new Array(20-p.length).join("0")+p}).reverse()});for(c&&(h=d-Math.min(l,u)),d-=1;d>=h;){if(f[0][d]>f[1][d])return 1;if(f[0][d]===f[1][d]){if(d===h)return 0;d-=1}else if(f[0][d]<f[1][d])return-1}},o.map=function(a,s){var c,l=[];if(Array.prototype.map)return Array.prototype.map.call(a,s);for(c=0;c<a.length;c+=1)l.push(s(a[c]));return l},o.find=function(a,s){var c,l;if(Array.prototype.find)return Array.prototype.find.call(a,s);for(c=0,l=a.length;c<l;c+=1){var u=a[c];if(s(u,c))return u}},o.assign=function(a){for(var s,c,l=a,u=arguments.length,d=new Array(u>1?u-1:0),h=1;h<u;h++)d[h-1]=arguments[h];if(Object.assign)return Object.assign.apply(Object,[a].concat(d));var f=function(){var g=d[s];typeof g=="object"&&g!==null&&Object.keys(g).forEach(function(m){l[m]=g[m]})};for(s=0,c=d.length;s<c;s+=1)f();return a},o.getBrowserAlias=function(a){return r.BROWSER_ALIASES_MAP[a]},o.getBrowserTypeByAlias=function(a){return r.BROWSER_MAP[a]||""},o}();e.default=i,t.exports=e.default},18:function(t,e,n){e.__esModule=!0,e.ENGINE_MAP=e.OS_MAP=e.PLATFORMS_MAP=e.BROWSER_MAP=e.BROWSER_ALIASES_MAP=void 0,e.BROWSER_ALIASES_MAP={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Electron:"electron",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"},e.BROWSER_MAP={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",electron:"Electron",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"},e.PLATFORMS_MAP={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},e.OS_MAP={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"},e.ENGINE_MAP={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"}},90:function(t,e,n){e.__esModule=!0,e.default=void 0;var r,i=(r=n(91))&&r.__esModule?r:{default:r},o=n(18);function a(c,l){for(var u=0;u<l.length;u++){var d=l[u];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(c,d.key,d)}}var s=function(){function c(){}var l,u,d;return c.getParser=function(h,f){if(f===void 0&&(f=!1),typeof h!="string")throw new Error("UserAgent should be a string");return new i.default(h,f)},c.parse=function(h){return new i.default(h).getResult()},l=c,d=[{key:"BROWSER_MAP",get:function(){return o.BROWSER_MAP}},{key:"ENGINE_MAP",get:function(){return o.ENGINE_MAP}},{key:"OS_MAP",get:function(){return o.OS_MAP}},{key:"PLATFORMS_MAP",get:function(){return o.PLATFORMS_MAP}}],(u=null)&&a(l.prototype,u),d&&a(l,d),c}();e.default=s,t.exports=e.default},91:function(t,e,n){e.__esModule=!0,e.default=void 0;var r=c(n(92)),i=c(n(93)),o=c(n(94)),a=c(n(95)),s=c(n(17));function c(u){return u&&u.__esModule?u:{default:u}}var l=function(){function u(h,f){if(f===void 0&&(f=!1),h==null||h==="")throw new Error("UserAgent parameter can't be empty");this._ua=h,this.parsedResult={},f!==!0&&this.parse()}var d=u.prototype;return d.getUA=function(){return this._ua},d.test=function(h){return h.test(this._ua)},d.parseBrowser=function(){var h=this;this.parsedResult.browser={};var f=s.default.find(r.default,function(g){if(typeof g.test=="function")return g.test(h);if(g.test instanceof Array)return g.test.some(function(m){return h.test(m)});throw new Error("Browser's test function is not valid")});return f&&(this.parsedResult.browser=f.describe(this.getUA())),this.parsedResult.browser},d.getBrowser=function(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()},d.getBrowserName=function(h){return h?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""},d.getBrowserVersion=function(){return this.getBrowser().version},d.getOS=function(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()},d.parseOS=function(){var h=this;this.parsedResult.os={};var f=s.default.find(i.default,function(g){if(typeof g.test=="function")return g.test(h);if(g.test instanceof Array)return g.test.some(function(m){return h.test(m)});throw new Error("Browser's test function is not valid")});return f&&(this.parsedResult.os=f.describe(this.getUA())),this.parsedResult.os},d.getOSName=function(h){var f=this.getOS().name;return h?String(f).toLowerCase()||"":f||""},d.getOSVersion=function(){return this.getOS().version},d.getPlatform=function(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()},d.getPlatformType=function(h){h===void 0&&(h=!1);var f=this.getPlatform().type;return h?String(f).toLowerCase()||"":f||""},d.parsePlatform=function(){var h=this;this.parsedResult.platform={};var f=s.default.find(o.default,function(g){if(typeof g.test=="function")return g.test(h);if(g.test instanceof Array)return g.test.some(function(m){return h.test(m)});throw new Error("Browser's test function is not valid")});return f&&(this.parsedResult.platform=f.describe(this.getUA())),this.parsedResult.platform},d.getEngine=function(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()},d.getEngineName=function(h){return h?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""},d.parseEngine=function(){var h=this;this.parsedResult.engine={};var f=s.default.find(a.default,function(g){if(typeof g.test=="function")return g.test(h);if(g.test instanceof Array)return g.test.some(function(m){return h.test(m)});throw new Error("Browser's test function is not valid")});return f&&(this.parsedResult.engine=f.describe(this.getUA())),this.parsedResult.engine},d.parse=function(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this},d.getResult=function(){return s.default.assign({},this.parsedResult)},d.satisfies=function(h){var f=this,g={},m=0,w={},p=0;if(Object.keys(h).forEach(function(U){var j=h[U];typeof j=="string"?(w[U]=j,p+=1):typeof j=="object"&&(g[U]=j,m+=1)}),m>0){var S=Object.keys(g),_=s.default.find(S,function(U){return f.isOS(U)});if(_){var O=this.satisfies(g[_]);if(O!==void 0)return O}var I=s.default.find(S,function(U){return f.isPlatform(U)});if(I){var K=this.satisfies(g[I]);if(K!==void 0)return K}}if(p>0){var q=Object.keys(w),F=s.default.find(q,function(U){return f.isBrowser(U,!0)});if(F!==void 0)return this.compareVersion(w[F])}},d.isBrowser=function(h,f){f===void 0&&(f=!1);var g=this.getBrowserName().toLowerCase(),m=h.toLowerCase(),w=s.default.getBrowserTypeByAlias(m);return f&&w&&(m=w.toLowerCase()),m===g},d.compareVersion=function(h){var f=[0],g=h,m=!1,w=this.getBrowserVersion();if(typeof w=="string")return h[0]===">"||h[0]==="<"?(g=h.substr(1),h[1]==="="?(m=!0,g=h.substr(2)):f=[],h[0]===">"?f.push(1):f.push(-1)):h[0]==="="?g=h.substr(1):h[0]==="~"&&(m=!0,g=h.substr(1)),f.indexOf(s.default.compareVersions(w,g,m))>-1},d.isOS=function(h){return this.getOSName(!0)===String(h).toLowerCase()},d.isPlatform=function(h){return this.getPlatformType(!0)===String(h).toLowerCase()},d.isEngine=function(h){return this.getEngineName(!0)===String(h).toLowerCase()},d.is=function(h,f){return f===void 0&&(f=!1),this.isBrowser(h,f)||this.isOS(h)||this.isPlatform(h)},d.some=function(h){var f=this;return h===void 0&&(h=[]),h.some(function(g){return f.is(g)})},u}();e.default=l,t.exports=e.default},92:function(t,e,n){e.__esModule=!0,e.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},o=/version\/(\d+(\.?_?\d+)+)/i,a=[{test:[/googlebot/i],describe:function(s){var c={name:"Googlebot"},l=i.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,s)||i.default.getFirstMatch(o,s);return l&&(c.version=l),c}},{test:[/opera/i],describe:function(s){var c={name:"Opera"},l=i.default.getFirstMatch(o,s)||i.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:[/opr\/|opios/i],describe:function(s){var c={name:"Opera"},l=i.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,s)||i.default.getFirstMatch(o,s);return l&&(c.version=l),c}},{test:[/SamsungBrowser/i],describe:function(s){var c={name:"Samsung Internet for Android"},l=i.default.getFirstMatch(o,s)||i.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:[/Whale/i],describe:function(s){var c={name:"NAVER Whale Browser"},l=i.default.getFirstMatch(o,s)||i.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,s);return l&&(c.version=l),c}},{test:[/MZBrowser/i],describe:function(s){var c={name:"MZ Browser"},l=i.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,s)||i.default.getFirstMatch(o,s);return l&&(c.version=l),c}},{test:[/focus/i],describe:function(s){var c={name:"Focus"},l=i.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,s)||i.default.getFirstMatch(o,s);return l&&(c.version=l),c}},{test:[/swing/i],describe:function(s){var c={name:"Swing"},l=i.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,s)||i.default.getFirstMatch(o,s);return l&&(c.version=l),c}},{test:[/coast/i],describe:function(s){var c={name:"Opera Coast"},l=i.default.getFirstMatch(o,s)||i.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe:function(s){var c={name:"Opera Touch"},l=i.default.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,s)||i.default.getFirstMatch(o,s);return l&&(c.version=l),c}},{test:[/yabrowser/i],describe:function(s){var c={name:"Yandex Browser"},l=i.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,s)||i.default.getFirstMatch(o,s);return l&&(c.version=l),c}},{test:[/ucbrowser/i],describe:function(s){var c={name:"UC Browser"},l=i.default.getFirstMatch(o,s)||i.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:[/Maxthon|mxios/i],describe:function(s){var c={name:"Maxthon"},l=i.default.getFirstMatch(o,s)||i.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:[/epiphany/i],describe:function(s){var c={name:"Epiphany"},l=i.default.getFirstMatch(o,s)||i.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:[/puffin/i],describe:function(s){var c={name:"Puffin"},l=i.default.getFirstMatch(o,s)||i.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:[/sleipnir/i],describe:function(s){var c={name:"Sleipnir"},l=i.default.getFirstMatch(o,s)||i.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:[/k-meleon/i],describe:function(s){var c={name:"K-Meleon"},l=i.default.getFirstMatch(o,s)||i.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:[/micromessenger/i],describe:function(s){var c={name:"WeChat"},l=i.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,s)||i.default.getFirstMatch(o,s);return l&&(c.version=l),c}},{test:[/qqbrowser/i],describe:function(s){var c={name:/qqbrowserlite/i.test(s)?"QQ Browser Lite":"QQ Browser"},l=i.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,s)||i.default.getFirstMatch(o,s);return l&&(c.version=l),c}},{test:[/msie|trident/i],describe:function(s){var c={name:"Internet Explorer"},l=i.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:[/\sedg\//i],describe:function(s){var c={name:"Microsoft Edge"},l=i.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:[/edg([ea]|ios)/i],describe:function(s){var c={name:"Microsoft Edge"},l=i.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:[/vivaldi/i],describe:function(s){var c={name:"Vivaldi"},l=i.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:[/seamonkey/i],describe:function(s){var c={name:"SeaMonkey"},l=i.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:[/sailfish/i],describe:function(s){var c={name:"Sailfish"},l=i.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,s);return l&&(c.version=l),c}},{test:[/silk/i],describe:function(s){var c={name:"Amazon Silk"},l=i.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:[/phantom/i],describe:function(s){var c={name:"PhantomJS"},l=i.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:[/slimerjs/i],describe:function(s){var c={name:"SlimerJS"},l=i.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(s){var c={name:"BlackBerry"},l=i.default.getFirstMatch(o,s)||i.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:[/(web|hpw)[o0]s/i],describe:function(s){var c={name:"WebOS Browser"},l=i.default.getFirstMatch(o,s)||i.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:[/bada/i],describe:function(s){var c={name:"Bada"},l=i.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:[/tizen/i],describe:function(s){var c={name:"Tizen"},l=i.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,s)||i.default.getFirstMatch(o,s);return l&&(c.version=l),c}},{test:[/qupzilla/i],describe:function(s){var c={name:"QupZilla"},l=i.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,s)||i.default.getFirstMatch(o,s);return l&&(c.version=l),c}},{test:[/firefox|iceweasel|fxios/i],describe:function(s){var c={name:"Firefox"},l=i.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:[/electron/i],describe:function(s){var c={name:"Electron"},l=i.default.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:[/MiuiBrowser/i],describe:function(s){var c={name:"Miui"},l=i.default.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:[/chromium/i],describe:function(s){var c={name:"Chromium"},l=i.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,s)||i.default.getFirstMatch(o,s);return l&&(c.version=l),c}},{test:[/chrome|crios|crmo/i],describe:function(s){var c={name:"Chrome"},l=i.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:[/GSA/i],describe:function(s){var c={name:"Google Search"},l=i.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:function(s){var c=!s.test(/like android/i),l=s.test(/android/i);return c&&l},describe:function(s){var c={name:"Android Browser"},l=i.default.getFirstMatch(o,s);return l&&(c.version=l),c}},{test:[/playstation 4/i],describe:function(s){var c={name:"PlayStation 4"},l=i.default.getFirstMatch(o,s);return l&&(c.version=l),c}},{test:[/safari|applewebkit/i],describe:function(s){var c={name:"Safari"},l=i.default.getFirstMatch(o,s);return l&&(c.version=l),c}},{test:[/.*/i],describe:function(s){var c=s.search("\\(")!==-1?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:i.default.getFirstMatch(c,s),version:i.default.getSecondMatch(c,s)}}}];e.default=a,t.exports=e.default},93:function(t,e,n){e.__esModule=!0,e.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},o=n(18),a=[{test:[/Roku\/DVP/],describe:function(s){var c=i.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,s);return{name:o.OS_MAP.Roku,version:c}}},{test:[/windows phone/i],describe:function(s){var c=i.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,s);return{name:o.OS_MAP.WindowsPhone,version:c}}},{test:[/windows /i],describe:function(s){var c=i.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,s),l=i.default.getWindowsVersionName(c);return{name:o.OS_MAP.Windows,version:c,versionName:l}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(s){var c={name:o.OS_MAP.iOS},l=i.default.getSecondMatch(/(Version\/)(\d[\d.]+)/,s);return l&&(c.version=l),c}},{test:[/macintosh/i],describe:function(s){var c=i.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,s).replace(/[_\s]/g,"."),l=i.default.getMacOSVersionName(c),u={name:o.OS_MAP.MacOS,version:c};return l&&(u.versionName=l),u}},{test:[/(ipod|iphone|ipad)/i],describe:function(s){var c=i.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,s).replace(/[_\s]/g,".");return{name:o.OS_MAP.iOS,version:c}}},{test:function(s){var c=!s.test(/like android/i),l=s.test(/android/i);return c&&l},describe:function(s){var c=i.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,s),l=i.default.getAndroidVersionName(c),u={name:o.OS_MAP.Android,version:c};return l&&(u.versionName=l),u}},{test:[/(web|hpw)[o0]s/i],describe:function(s){var c=i.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,s),l={name:o.OS_MAP.WebOS};return c&&c.length&&(l.version=c),l}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(s){var c=i.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,s)||i.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,s)||i.default.getFirstMatch(/\bbb(\d+)/i,s);return{name:o.OS_MAP.BlackBerry,version:c}}},{test:[/bada/i],describe:function(s){var c=i.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,s);return{name:o.OS_MAP.Bada,version:c}}},{test:[/tizen/i],describe:function(s){var c=i.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,s);return{name:o.OS_MAP.Tizen,version:c}}},{test:[/linux/i],describe:function(){return{name:o.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:o.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(s){var c=i.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,s);return{name:o.OS_MAP.PlayStation4,version:c}}}];e.default=a,t.exports=e.default},94:function(t,e,n){e.__esModule=!0,e.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},o=n(18),a=[{test:[/googlebot/i],describe:function(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(s){var c=i.default.getFirstMatch(/(can-l01)/i,s)&&"Nova",l={type:o.PLATFORMS_MAP.mobile,vendor:"Huawei"};return c&&(l.model=c),l}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet}}},{test:function(s){var c=s.test(/ipod|iphone/i),l=s.test(/like (ipod|iphone)/i);return c&&!l},describe:function(s){var c=i.default.getFirstMatch(/(ipod|iphone)/i,s);return{type:o.PLATFORMS_MAP.mobile,vendor:"Apple",model:c}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(s){return s.getBrowserName(!0)==="blackberry"},describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(s){return s.getBrowserName(!0)==="bada"},describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(s){return s.getBrowserName()==="windows phone"},describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(s){var c=Number(String(s.getOSVersion()).split(".")[0]);return s.getOSName(!0)==="android"&&c>=3},describe:function(){return{type:o.PLATFORMS_MAP.tablet}}},{test:function(s){return s.getOSName(!0)==="android"},describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(s){return s.getOSName(!0)==="macos"},describe:function(){return{type:o.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(s){return s.getOSName(!0)==="windows"},describe:function(){return{type:o.PLATFORMS_MAP.desktop}}},{test:function(s){return s.getOSName(!0)==="linux"},describe:function(){return{type:o.PLATFORMS_MAP.desktop}}},{test:function(s){return s.getOSName(!0)==="playstation 4"},describe:function(){return{type:o.PLATFORMS_MAP.tv}}},{test:function(s){return s.getOSName(!0)==="roku"},describe:function(){return{type:o.PLATFORMS_MAP.tv}}}];e.default=a,t.exports=e.default},95:function(t,e,n){e.__esModule=!0,e.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},o=n(18),a=[{test:function(s){return s.getBrowserName(!0)==="microsoft edge"},describe:function(s){if(/\sedg\//i.test(s))return{name:o.ENGINE_MAP.Blink};var c=i.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,s);return{name:o.ENGINE_MAP.EdgeHTML,version:c}}},{test:[/trident/i],describe:function(s){var c={name:o.ENGINE_MAP.Trident},l=i.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:function(s){return s.test(/presto/i)},describe:function(s){var c={name:o.ENGINE_MAP.Presto},l=i.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:function(s){var c=s.test(/gecko/i),l=s.test(/like gecko/i);return c&&!l},describe:function(s){var c={name:o.ENGINE_MAP.Gecko},l=i.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:o.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(s){var c={name:o.ENGINE_MAP.WebKit},l=i.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,s);return l&&(c.version=l),c}}];e.default=a,t.exports=e.default}});var Af=Ao(kf.exports);const tt={Initialized:"initialized",DisplayURI:"display_uri",ProviderUpdate:"provider_update",ConnectWithResponse:"connectWithResponse",ConnectionStatus:"connection_status",ServiceStatus:"service_status"};class kt{constructor({shouldSetOnWindow:e,connectionStream:n,shouldSendMetadata:r=!1,shouldShimWeb3:i,sdkInstance:o}){const a=new My({connectionStream:n,shouldSendMetadata:r,shouldSetOnWindow:e,shouldShimWeb3:i,autoRequestAccounts:!1}),s=new Proxy(a,{deleteProperty:()=>!0});if(this.provider=s,this.sdkInstance=o,e&&typeof window<"u")try{c=a,window.ethereum=c,window.dispatchEvent(new Event("ethereum#initialized"))}catch(l){W("[Ethereum] Unable to set global provider - window.ethereum may be read-only",l)}var c;if(i&&typeof window<"u")try{(function(l,u=console){let d=!1,h=!1;if(!window.web3){const f="__isMetaMaskShim__";let g={currentProvider:l};Object.defineProperty(g,f,{value:!0,enumerable:!0,configurable:!1,writable:!1}),g=new Proxy(g,{get:(m,w,...p)=>(w!=="currentProvider"||d?w==="currentProvider"||w===f||h||(h=!0,u.error("MetaMask no longer injects web3. For details, see: https://docs.metamask.io/guide/provider-migration.html#replacing-window-web3"),l.request({method:"metamask_logWeb3ShimUsage"}).catch(S=>{u.debug("MetaMask: Failed to log web3 shim usage.",S)})):(d=!0,u.warn("You are accessing the MetaMask window.web3.currentProvider shim. This property is deprecated; use window.ethereum instead. For details, see: https://docs.metamask.io/guide/provider-migration.html#replacing-window-web3")),Reflect.get(m,w,...p)),set:(...m)=>(u.warn("You are accessing the MetaMask window.web3 shim. This object is deprecated; use window.ethereum instead. For details, see: https://docs.metamask.io/guide/provider-migration.html#replacing-window-web3"),Reflect.set(...m))}),Object.defineProperty(window,"web3",{value:g,enumerable:!1,configurable:!0,writable:!0})}})(this.provider)}catch(l){W("[Ethereum] Unable to shim web3 - window.web3 may be read-only",l)}this.provider.on("display_uri",l=>{this.sdkInstance.emit(tt.DisplayURI,l)}),this.provider.on("_initialized",()=>{const l={chainId:this.provider.getChainId(),isConnected:this.provider.isConnected(),isMetaMask:this.provider.isMetaMask,selectedAddress:this.provider.getSelectedAddress(),networkVersion:this.provider.getNetworkVersion()};this.sdkInstance.emit(tt.Initialized,l),W("[Ethereum: constructor()] provider initialized",l)})}static init(e){var n;return W("[Ethereum: init()] Initializing Ethereum service"),this.instance=new kt(e),(n=this.instance)===null||n===void 0?void 0:n.provider}static destroy(){}static getInstance(){var e;if(!(!((e=this.instance)===null||e===void 0)&&e.provider))throw new Error("Ethereum instance not intiialized - call Ethereum.factory first.");return this.instance}static getProvider(){var e;if(!(!((e=this.instance)===null||e===void 0)&&e.provider))throw new Error("Ethereum instance not intiialized - call Ethereum.factory first.");return this.instance.provider}}class zr{constructor({useDeepLink:e,preferredOpenLink:n,debug:r=!1}){this.state={platformType:void 0,useDeeplink:!1,preferredOpenLink:void 0,debug:!1},this.state.platformType=this.getPlatformType(),this.state.useDeeplink=e,this.state.preferredOpenLink=n,this.state.debug=r}openDeeplink(e,n,r){return function(i,o,a,s){const{state:c}=i;W(`[PlatfformManager: openDeeplink()] universalLink --> ${o}`),W(`[PlatfformManager: openDeeplink()] deepLink --> ${a}`);try{if(c.preferredOpenLink)return void c.preferredOpenLink(c.useDeeplink?a:o,s);if(W(`[PlatfformManager: openDeeplink()] open link now useDeepLink=${c.useDeeplink} link=${c.useDeeplink?a:o}`),c.useDeeplink)typeof window<"u"&&(window.location.href=a);else if(typeof document<"u"){const l=document.createElement("a");l.href=o,l.target="_self",l.rel="noreferrer noopener",l.click()}}catch(l){console.log("[PlatfformManager: openDeeplink()] can't open link",l)}}(this,e,n,r)}isReactNative(){var e;return this.isNotBrowser()&&typeof window<"u"&&(window==null?void 0:window.navigator)&&((e=window.navigator)===null||e===void 0?void 0:e.product)==="ReactNative"}isMetaMaskInstalled(){return function(){const e=kt.getProvider()||(window==null?void 0:window.ethereum);return W(`[PlatfformManager: isMetaMaskInstalled()] isMetaMask=${e==null?void 0:e.isMetaMask} isConnected=${e==null?void 0:e.isConnected()}`),(e==null?void 0:e.isMetaMask)&&(e==null?void 0:e.isConnected())}()}isDesktopWeb(){return this.isBrowser()&&!this.isMobileWeb()}isMobile(){var e,n;const r=Af.parse(window.navigator.userAgent);return((e=r==null?void 0:r.platform)===null||e===void 0?void 0:e.type)==="mobile"||((n=r==null?void 0:r.platform)===null||n===void 0?void 0:n.type)==="tablet"}isSecure(){return this.isReactNative()||this.isMobileWeb()}isMetaMaskMobileWebView(){return typeof window<"u"&&!!window.ReactNativeWebView&&!!navigator.userAgent.endsWith("MetaMaskMobile")}isMobileWeb(){return this.state.platformType===qe.MobileWeb}static isNotBrowser(){var e;return typeof window>"u"||!(window!=null&&window.navigator)||Je!==void 0&&((e=Je==null?void 0:Je.navigator)===null||e===void 0?void 0:e.product)==="ReactNative"||(navigator==null?void 0:navigator.product)==="ReactNative"}isNotBrowser(){return zr.isNotBrowser()}static isBrowser(){return!this.isNotBrowser()}isBrowser(){return zr.isBrowser()}isNodeJS(){return this.isNotBrowser()&&!this.isReactNative()}isUseDeepLink(){return this.state.useDeeplink}getPlatformType(){return function(e){const{state:n}=e;return n.platformType?n.platformType:e.isReactNative()?qe.ReactNative:e.isNotBrowser()?qe.NonBrowser:e.isMetaMaskMobileWebView()?qe.MetaMaskMobileWebview:e.isMobile()?qe.MobileWeb:qe.DesktopWeb}(this)}}const xf=t=>Z(void 0,void 0,void 0,function*(){if(zr.isBrowser()){const{StorageManagerWeb:n}=yield Promise.resolve().then(function(){return rv});return new n(t)}const e={persistChannelConfig:()=>Z(void 0,void 0,void 0,function*(){}),getPersistedChannelConfig:()=>Z(void 0,void 0,void 0,function*(){}),persistAccounts:()=>Z(void 0,void 0,void 0,function*(){}),getCachedAccounts:()=>Z(void 0,void 0,void 0,function*(){return[]}),persistChainId:()=>Z(void 0,void 0,void 0,function*(){}),getCachedChainId:()=>Z(void 0,void 0,void 0,function*(){}),terminate:()=>Z(void 0,void 0,void 0,function*(){})};return Promise.resolve(e)});class My extends Ay{constructor({connectionStream:e,shouldSendMetadata:n,autoRequestAccounts:r=!1}){super(e,{logger:console,maxEventListeners:100,shouldSendMetadata:n}),this.state={accounts:null,autoRequestAccounts:!1,providerStateRequested:!1,chainId:"",networkVersion:""},W(`[SDKProvider: constructor()] autoRequestAccounts=${r}`),this.state.autoRequestAccounts=r}forceInitializeState(){return Z(this,void 0,void 0,function*(){return W(`[SDKProvider: forceInitializeState()] autoRequestAccounts=${this.state.autoRequestAccounts}`),this._initializeStateAsync()})}_setConnected(){W("[SDKProvider: _setConnected()] Setting connected state"),this._state.isConnected=!0}getState(){return this._state}getSDKProviderState(){return this.state}getSelectedAddress(){var e;const{accounts:n}=this._state;return n&&n.length!==0?((e=n[0])===null||e===void 0?void 0:e.toLowerCase())||"":(W("[SDKProvider: getSelectedAddress] No accounts found"),null)}getChainId(){return this.state.chainId}getNetworkVersion(){return this.state.networkVersion}setSDKProviderState(e){this.state=Object.assign(Object.assign({},this.state),e)}handleAccountsChanged(e,n){return this._handleAccountsChanged(e,n)}handleDisconnect({terminate:e=!1}){(function({terminate:n=!1,instance:r}){const{state:i}=r;W(`[SDKProvider: handleDisconnect()] cleaning up provider state terminate=${n}`,r),n&&(r._state.accounts=null,r._state.isUnlocked=!1,r._state.isPermanentlyDisconnected=!0,r._state.initialized=!1),r._handleAccountsChanged([]),r._state.isConnected=!1,r.emit("disconnect",Ef.ethErrors.provider.disconnected()),i.providerStateRequested=!1})({terminate:e,instance:this})}_initializeStateAsync(){return Z(this,void 0,void 0,function*(){return function(e){var n,r;return Z(this,void 0,void 0,function*(){e.state===void 0&&(e.state={accounts:null,autoRequestAccounts:!1,providerStateRequested:!1,chainId:""});const{state:i}=e;let o;if(i.providerStateRequested)W("[SDKProvider: initializeStateAsync()] initialization already in progress");else{let a;i.providerStateRequested=!0;let s=null,c=!1,l=!1;const u=yield xf({enabled:!0});if(u){const d=yield u.getPersistedChannelConfig({});c=(n=d==null?void 0:d.relayPersistence)!==null&&n!==void 0&&n,a=yield u.getCachedChainId();const h=yield u.getCachedAccounts();h.length>0&&(s=h[0])}if(W(`[SDKProvider: initializeStateAsync()] relayPersistence=${c}`,{relayPersistence:c,cachedChainId:a,cachedSelectedAddress:s}),c)if(a&&s)o={accounts:[s],chainId:a,isUnlocked:!1},l=!0;else try{o=yield e.request({method:"metamask_getProviderState"})}catch(d){return e._log.error("MetaMask: Failed to get initial state. Please report this bug.",d),void(i.providerStateRequested=!1)}if(((r=o==null?void 0:o.accounts)===null||r===void 0?void 0:r.length)===0)if(e.getSelectedAddress())o.accounts=[e.getSelectedAddress()];else{W("[SDKProvider: initializeStateAsync()] Fetch accounts remotely.");const d=yield e.request({method:"eth_requestAccounts",params:[]});o.accounts=d}e._initializeState(o),i.providerStateRequested=!1,l&&(e._state.isConnected=!0,e.emit("connect",{chainId:o==null?void 0:o.chainId}))}})}(this)})}_initializeState(e){return W("[SDKProvider: _initializeState()]",e),function(n,r,i){return W("[SDKProvider: initializeState()] set state._initialized to false"),n._state.initialized=!1,r(i)}(this,super._initializeState.bind(this),e)}_handleChainChanged({chainId:e,networkVersion:n}={}){this.state.chainId=e,this.state.networkVersion=n,function({instance:r,chainId:i,networkVersion:o,superHandleChainChanged:a}){W(`[SDKProvider: handleChainChanged()] chainId=${i} networkVersion=${o}`);let s=o;o||(W("[SDKProvider: handleChainChanged()] forced network version to prevent provider error"),s="1"),i!==eu&&(Me.analytics.track("sdk_used_chain",{caip_chain_id:`eip155:${parseInt(i??"0x1",16)}`}),eu=i),r._state.isConnected=!0,r.emit("connect",{chainId:i}),a({chainId:i,networkVersion:s})}({instance:this,chainId:e,networkVersion:n,superHandleChainChanged:super._handleChainChanged.bind(this)})}}var qr,Hn={name:"@metamask/sdk",version:"0.33.1",description:"",homepage:"https://github.com/MetaMask/metamask-sdk#readme",bugs:{url:"https://github.com/MetaMask/metamask-sdk/issues"},repository:{type:"git",url:"https://github.com/MetaMask/metamask-sdk",directory:"packages/sdk"},main:"dist/node/cjs/metamask-sdk.js",module:"dist/browser/es/metamask-sdk.js",browser:"dist/browser/es/metamask-sdk.js",unpkg:"dist/browser/umd/metamask-sdk.js","react-native":"dist/react-native/es/metamask-sdk.js",types:"dist/types/src/index.d.ts",sideEffects:!1,files:["/dist"],scripts:{"build:types":"tsc --project tsconfig.build.json --emitDeclarationOnly --outDir dist/types",build:"yarn build:types && rollup -c --bundleConfigAsCjs","build:clean":"yarn clean && yarn build","build:post-tsc":"echo 'N/A'","build:pre-tsc":"echo 'N/A'",typecheck:"tsc --noEmit",clean:"rimraf ./dist",size:"node bundle-size && size-limit",lint:"yarn lint:eslint && yarn lint:misc --check","lint:changelog":"../../scripts/validate-changelog.sh @metamask/sdk","lint:eslint":"eslint . --cache --ext js,ts","lint:fix":"yarn lint:eslint --fix && yarn lint:misc --write","lint:misc":"prettier '**/*.json' '**/*.md' '!CHANGELOG.md' --ignore-path ../../.gitignore",prepack:"../../scripts/prepack.sh","publish:preview":"yarn npm publish --tag preview",reset:"yarn clean && rimraf ./node_modules/",test:'jest --testPathIgnorePatterns "/e2e/"',"test:coverage":'jest --coverage --testPathIgnorePatterns "/e2e/"',"test:e2e":'jest --testPathPattern "/e2e/"',"test:ci":'jest --coverage --passWithNoTests --setupFilesAfterEnv ./jest-preload.js --testPathIgnorePatterns "/e2e/"',"test:dev":'jest -c ./jest.config.ts --detectOpenHandles --testPathIgnorePatterns "/e2e/"',watch:"rollup -c -w",dev:'concurrently "tsc --watch" "rollup -c -w --bundleConfigAsCjs"',"build:dev":"yarn build:types && NODE_ENV=dev rollup -c --bundleConfigAsCjs"},dependencies:{"@babel/runtime":"^7.26.0","@metamask/onboarding":"^1.0.1","@metamask/providers":"16.1.0","@metamask/sdk-analytics":"workspace:*","@metamask/sdk-communication-layer":"workspace:*","@metamask/sdk-install-modal-web":"workspace:*","@paulmillr/qr":"^0.2.1",bowser:"^2.9.0","cross-fetch":"^4.0.0",debug:"4.3.4",eciesjs:"^0.4.11","eth-rpc-errors":"^4.0.3",eventemitter2:"^6.4.9","obj-multiplex":"^1.0.0",pump:"^3.0.0","readable-stream":"^3.6.2","socket.io-client":"^4.5.1",tslib:"^2.6.0",util:"^0.12.4",uuid:"^8.3.2"},devDependencies:{"@jest/globals":"^29.3.1","@lavamoat/allow-scripts":"^2.3.1","@metamask/auto-changelog":"3.1.0","@metamask/eslint-config":"^6.0.0","@metamask/eslint-config-nodejs":"^6.0.0","@metamask/eslint-config-typescript":"^6.0.0","@react-native-async-storage/async-storage":"^1.19.6","@rollup/plugin-alias":"^5.1.1","@rollup/plugin-commonjs":"^25.0.7","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.0.2","@rollup/plugin-replace":"^6.0.1","@rollup/plugin-terser":"^0.4.1","@size-limit/preset-big-lib":"^11.0.2","@types/dom-screen-wake-lock":"^1.0.2","@types/node":"^20.1.3","@types/pump":"^1.1.1","@types/qrcode-terminal":"^0.12.0","@types/uuid":"^10.0.0","@typescript-eslint/eslint-plugin":"^4.26.0","@typescript-eslint/parser":"^4.26.0","browserify-zlib":"^0.2.0",buffer:"^6.0.3",concurrently:"^9.1.2","crypto-browserify":"^3.12.0",eslint:"^7.30.0","eslint-config-prettier":"^8.3.0","eslint-plugin-import":"^2.23.4","eslint-plugin-jest":"^24.4.0","eslint-plugin-jsdoc":"^36.1.0","eslint-plugin-node":"^11.1.0","eslint-plugin-prettier":"^3.4.0","https-browserify":"^1.0.0",jest:"^29.3.1","jest-environment-jsdom":"^29.3.1",prettier:"^2.3.0",process:"^0.11.10",rimraf:"^4.4.0",rollup:"^4.26.0","rollup-plugin-analyzer":"^4.0.0","rollup-plugin-jscc":"^2.0.0","rollup-plugin-natives":"^0.7.5","rollup-plugin-node-builtins":"^2.1.2","rollup-plugin-polyfill-node":"^0.13.0","rollup-plugin-sizes":"^1.0.6","rollup-plugin-typescript2":"^0.31.2","rollup-plugin-visualizer":"^5.12.0","size-limit":"^11.0.2","stream-browserify":"^3.0.0","stream-http":"^3.2.0","ts-jest":"^29.0.3","ts-node":"^10.9.1",typescript:"^4.3.2",url:"^0.11.0",webpack:"^5.0.0"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},lavamoat:{allowScripts:{"eciesjs>secp256k1":!1,"socket.io-client>engine.io-client>ws>bufferutil":!1,"socket.io-client>engine.io-client>ws>utf-8-validate":!1,"@metamask/sdk-communication-layer>bufferutil":!1,"@metamask/sdk-communication-layer>eciesjs>secp256k1":!1,"@metamask/sdk-communication-layer>utf-8-validate":!1}}};(function(t){t.INPAGE="metamask-inpage",t.CONTENT_SCRIPT="metamask-contentscript",t.PROVIDER="metamask-provider"})(qr||(qr={}));const tu="direct",Vr="https://metamask.app.link/connect",Wr="metamask://connect",nu={NAME:"MetaMask",RDNS:["io.metamask","io.metamask.flask"]},Ry=/(?:^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}$)|(?:^0{8}-0{4}-0{4}-0{4}-0{12}$)/u,ue={METAMASK_GETPROVIDERSTATE:"metamask_getProviderState",METAMASK_CONNECTSIGN:"metamask_connectSign",METAMASK_CONNECTWITH:"metamask_connectWith",METAMASK_OPEN:"metamask_open",METAMASK_BATCH:"metamask_batch",PERSONAL_SIGN:"personal_sign",WALLET_REQUESTPERMISSIONS:"wallet_requestPermissions",WALLET_REVOKEPERMISSIONS:"wallet_revokePermissions",WALLET_GETPERMISSIONS:"wallet_getPermissions",WALLET_WATCHASSET:"wallet_watchAsset",WALLET_ADDETHEREUMCHAIN:"wallet_addEthereumChain",WALLET_SWITCHETHETHEREUMCHAIN:"wallet_switchEthereumChain",ETH_REQUESTACCOUNTS:"eth_requestAccounts",ETH_ACCOUNTS:"eth_accounts",ETH_CHAINID:"eth_chainId",ETH_SENDTRANSACTION:"eth_sendTransaction",ETH_SIGNTYPEDDATA:"eth_signTypedData",ETH_SIGNTYPEDDATA_V3:"eth_signTypedData_v3",ETH_SIGNTYPEDDATA_V4:"eth_signTypedData_v4",ETH_SIGNTRANSACTION:"eth_signTransaction",ETH_SIGN:"eth_sign",PERSONAL_EC_RECOVER:"personal_ecRecover"},Gr={[ue.ETH_REQUESTACCOUNTS]:!0,[ue.ETH_SENDTRANSACTION]:!0,[ue.ETH_SIGNTRANSACTION]:!0,[ue.ETH_SIGN]:!0,[ue.PERSONAL_SIGN]:!0,[ue.ETH_ACCOUNTS]:!1,[ue.ETH_CHAINID]:!1,[ue.PERSONAL_SIGN]:!0,[ue.ETH_SIGNTYPEDDATA]:!0,[ue.ETH_SIGNTYPEDDATA_V3]:!0,[ue.ETH_SIGNTYPEDDATA_V4]:!0,[ue.WALLET_REQUESTPERMISSIONS]:!0,[ue.WALLET_GETPERMISSIONS]:!0,[ue.WALLET_WATCHASSET]:!0,[ue.WALLET_ADDETHEREUMCHAIN]:!0,[ue.WALLET_SWITCHETHETHEREUMCHAIN]:!0,[ue.METAMASK_CONNECTSIGN]:!0,[ue.METAMASK_CONNECTWITH]:!0,[ue.PERSONAL_EC_RECOVER]:!0,[ue.METAMASK_BATCH]:!0,[ue.METAMASK_OPEN]:!0},Oy=Object.keys(Gr).filter(t=>Gr[t]===!0).map(t=>t.toLowerCase()),Tf=["eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sign"].map(t=>t.toLowerCase()),Cs=".sdk-comm",yo="providerType",ua=".MMSDK_cached_address",da=".MMSDK_cached_chainId",xt={CHAIN_CHANGED:"chainChanged",ACCOUNTS_CHANGED:"accountsChanged",DISCONNECT:"disconnect",CONNECT:"connect",CONNECTED:"connected"},Py=1e6;var Kt;(function(t){t.TERMINATE="terminate",t.EXTENSION="extension",t.INITIALIZED="initialized"})(Kt||(Kt={}));const Iy=typeof window<"u"&&window.localStorage;function Ly({instance:t,msg:e}){return Z(this,void 0,void 0,function*(){if(t._initialized||(W("[MetaMaskSDK: connectAndSign()] provider not ready -- wait for init()"),yield t.init()),W(`[MetaMaskSDK: connectAndSign()] activeProvider=${t.activeProvider}`),!t.activeProvider)throw new Error("SDK state invalid -- undefined provider");const n=/^0x([0-9A-Fa-f]{2})*$/u.test(e)?e:function(r){let i;if(X!==void 0)i=X.from(r,"utf8").toString("hex");else if(typeof TextEncoder<"u"){const o=new TextEncoder().encode(r);i=Array.from(o).map(a=>a.toString(16).padStart(2,"0")).join("")}else{if(typeof Je!="object"||!("Buffer"in Je))throw new Error("Unable to convert string to hex: No available method.");i=Je.Buffer.from(r,"utf8").toString("hex")}return`0x${i}`}(e);return t.activeProvider.request({method:ue.METAMASK_CONNECTWITH,params:[{method:ue.PERSONAL_SIGN,params:[n]}]})})}function ru(t){var e,n;return Z(this,void 0,void 0,function*(){W("[MetaMaskSDK: connectWithExtensionProvider()] ",t),t.sdkProvider=t.activeProvider,t.activeProvider=window.extension,window.ethereum=window.extension;try{const r=yield(e=window.extension)===null||e===void 0?void 0:e.request({method:"eth_requestAccounts"});W(`[MetaMaskSDK: connectWithExtensionProvider()] accounts=${r}`)}catch(r){return void console.warn("[MetaMaskSDK: connectWithExtensionProvider()] can't request accounts error",r)}localStorage.setItem(yo,"extension"),t.extensionActive=!0,t.emit(tt.ProviderUpdate,Kt.EXTENSION),t.options.enableAnalytics&&((n=t.analytics)===null||n===void 0||n.send({event:Re.SDK_USE_EXTENSION}))})}function vo(t){let e;if(X!==void 0)e=X.from(t,"utf8").toString("base64");else if(typeof btoa=="function")e=btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/gu,(n,r)=>String.fromCharCode(parseInt(r,16))));else{if(typeof Je!="object"||!("Buffer"in Je))throw new Error("Unable to base64 encode: No available method.");e=Je.Buffer.from(t,"utf8").toString("base64")}return e}function Ny(t,e,n,r){var i,o,a,s,c,l,u,d,h,f,g,m,w,p,S,_,O,I,K,q;return Z(this,void 0,void 0,function*(){const F=(i=t.state.remote)===null||i===void 0?void 0:i.isReady(),U=(o=t.state.remote)===null||o===void 0?void 0:o.isConnected(),j=(a=t.state.remote)===null||a===void 0?void 0:a.isPaused(),G=kt.getProvider(),$=(s=t.state.remote)===null||s===void 0?void 0:s.getChannelId(),N=(c=t.state.remote)===null||c===void 0?void 0:c.isAuthorized(),{deeplinkProtocol:R}=t.state,{method:C,data:P,triggeredInstaller:D}=(T=>{var b,v,k,x;let M;X.isBuffer(T)?(M=T.toJSON(),M._isBuffer=!0):M=T;const L=(b=M==null?void 0:M.data)===null||b===void 0?void 0:b.method;let B=!1;return typeof((v=M==null?void 0:M.data)===null||v===void 0?void 0:v.params)=="object"&&((x=(k=M==null?void 0:M.data)===null||k===void 0?void 0:k.params)===null||x===void 0?void 0:x.__triggeredInstaller)===!0&&(B=!0,M.data.params=M.data.params.wrappedParams),{method:L,data:M,triggeredInstaller:B}})(e);if(W(`[RCPMS: write()] method='${C}' isRemoteReady=${F} channelId=${$} isSocketConnected=${U} isRemotePaused=${j} providerConnected=${G.isConnected()}`,e),!$)return C!==ue.METAMASK_GETPROVIDERSTATE&&W(`[RCPMS: write()] ${C} --> channelId is undefined`),r(new Error("disconnected"));W(`[RCPMS: write()] remote.isPaused()=${(l=t.state.remote)===null||l===void 0?void 0:l.isPaused()} authorized=${N} ready=${F} socketConnected=${U}`,e);const y=(u=t.state.platformManager)===null||u===void 0?void 0:u.isSecure(),E=(h=(d=t.state.platformManager)===null||d===void 0?void 0:d.isMobileWeb())!==null&&h!==void 0&&h,A=(g=(f=t.state.remote)===null||f===void 0?void 0:f.hasDeeplinkProtocol())!==null&&g!==void 0&&g&&E&&N;try{if(!D){const v=JSON.stringify(P==null?void 0:P.data);if(v.length>Py)return r(new Error(`Message size ${v.length} exceeds maximum allowed size of 1000000 bytes`));(m=t.state.remote)===null||m===void 0||m.sendMessage(P==null?void 0:P.data).then(()=>{W(`[RCPMS: _write()] ${C} sent successfully`)}).catch(k=>{W("[RCPMS: _write()] error sending message",k)})}if(!y)return W(`[RCPMS: _write()] unsecure platform for method ${C} -- return callback`),r();if(D)return W("[RCPMS: _write()] prevent deeplink -- installation completed separately."),r();const T=(S=(p=(w=t.state.remote)===null||w===void 0?void 0:w.getKeyInfo())===null||p===void 0?void 0:p.ecies.public)!==null&&S!==void 0?S:"";let b=encodeURI(`channelId=${$}&pubkey=${T}&comm=socket&t=d&v=2`);if(A){const v=JSON.stringify(P==null?void 0:P.data),k=(_=t.state.remote)===null||_===void 0?void 0:_.encrypt(v);if(!k)return W("[RCPMS: _write()] error encrypting message"),r(new Error("RemoteCommunicationPostMessageStream - disconnected"));b+=`&scheme=${R}&rpc=${vo(k)}`}if(!(!((O=t.state.platformManager)===null||O===void 0)&&O.isMetaMaskInstalled()))return W("[RCPMS: _write()] prevent deeplink until installation is completed."),r();Gr[C]?(W(`[RCPMS: _write()] redirect link for '${C}' socketConnected=${U} connect?${b}`),(I=t.state.platformManager)===null||I===void 0||I.openDeeplink(`${Vr}?${b}`,`${Wr}?${b}`,"_self")):!((K=t.state.remote)===null||K===void 0)&&K.isPaused()?(W(`[RCPMS: _write()] MM is PAUSED! deeplink with connect! targetMethod=${C}`),(q=t.state.platformManager)===null||q===void 0||q.openDeeplink(`${Vr}?redirect=true&${b}`,`${Wr}?redirect=true&${b}`,"_self")):W(`[RCPMS: _write()] method ${C} doesn't need redirect.`)}catch(T){return W("[RCPMS: _write()] error sending message",T),r(new Error("RemoteCommunicationPostMessageStream - disconnected"))}return r()})}class Dy extends ur.Duplex{constructor({name:e,remote:n,deeplinkProtocol:r,platformManager:i}){super({objectMode:!0}),this.state={_name:null,remote:null,deeplinkProtocol:!1,platformManager:null},this.state._name=e,this.state.remote=n,this.state.deeplinkProtocol=r,this.state.platformManager=i,this._onMessage=this._onMessage.bind(this),this.state.remote.on(te.MESSAGE,this._onMessage)}_write(e,n,r){return Z(this,void 0,void 0,function*(){return Ny(this,e,0,r)})}_read(){}_onMessage(e){return function(n,r){try{if(W("[RCPMS: onMessage()] message",r),!r||typeof r!="object"||typeof(r==null?void 0:r.data)!="object")return;if(!(r!=null&&r.name))return void W("[RCPMS: onMessage()] ignore message without name",r);if((r==null?void 0:r.name)!==qr.PROVIDER)return void W(`[RCPMS: onMessage()] ignore message with wrong name message=${r}`);if(X.isBuffer(r)){const i=X.from(r);n.push(i)}else n.push(r)}catch(i){W(`[RCPMS: onMessage()] ignore message error err=${i}`)}}(this,e)}start(){}}let iu=1;const Mf=t=>new Promise(e=>{setTimeout(()=>{e(!0)},t)}),By=({checkInstallationOnAllCalls:t=!1,communicationLayerPreference:e,injectProvider:n,shouldShimWeb3:r,platformManager:i,installer:o,sdk:a,remoteConnection:s,debug:c})=>Z(void 0,void 0,void 0,function*(){var l,u;const d=(({name:j,remoteConnection:G})=>{if(!G||!(G!=null&&G.getConnector()))throw new Error("Missing remote connection parameter");return new Dy({name:j,remote:G==null?void 0:G.getConnector(),deeplinkProtocol:G==null?void 0:G.state.deeplinkProtocol,platformManager:G==null?void 0:G.getPlatformManager()})})({name:qr.INPAGE,target:qr.CONTENT_SCRIPT,remoteConnection:s}),h=i.getPlatformType(),f=a.options.dappMetadata,g=`Sdk/Javascript SdkVersion/${Hn.version} Platform/${h} dApp/${(l=f.url)!==null&&l!==void 0?l:f.name} dAppTitle/${f.name}`;let m=null,w=null;const p=(u=a.options.storage)===null||u===void 0?void 0:u.storageManager;if(p){try{const j=yield p.getCachedAccounts();j.length>0&&(m=j[0])}catch(j){console.error(`[initializeMobileProvider] failed to get cached addresses: ${j}`)}try{const j=yield p.getCachedChainId();j&&(w=j)}catch(j){console.error(`[initializeMobileProvider] failed to parse cached chainId: ${j}`)}}W(`[initializeMobileProvider] cachedAccountAddress: ${m}, cachedChainId: ${w}`);const S=!(!n||h===qe.NonBrowser||h===qe.ReactNative),_=kt.init({shouldSetOnWindow:S,connectionStream:d,shouldShimWeb3:r,sdkInstance:a});let O=!1;const I=j=>{O=j},K=()=>O,q=(j,G,$,N)=>Z(void 0,void 0,void 0,function*(){var R,C,P,D,y,E,A,T,b;const v=kt.getProvider();if(O){v.emit("display_uri",(s==null?void 0:s.state.qrcodeLink)||""),s==null||s.showActiveModal();let Q=K();for(;Q;){const ne=K(),se=s==null?void 0:s.isAuthorized();Q=ne&&!se,W(`[initializeMobileProvider: sendRequest()] waiting for initialization to complete - initializing: ${ne} authorized: ${se}`),yield Mf(1e3)}return W("[initializeMobileProvider: sendRequest()] initial method completed -- prevent installation and call provider"),$(...G)}const k=i.isMetaMaskInstalled(),x=s==null?void 0:s.isConnected();let M=null,L=null,B=null;if(M=(R=v.getSelectedAddress())!==null&&R!==void 0?R:m,B=v.getChainId()||w,M&&p&&M!==m&&p.persistAccounts([M]).catch(Q=>{console.error(`[initializeMobileProvider] failed to persist account: ${Q}`)}),B&&(w=B,p&&p.persistChainId(B).catch(Q=>{console.error(`[initializeMobileProvider] failed to persist chainId: ${Q}`)})),W("[initializeMobileProvider: sendRequest()]",{selectedAddress:M,chainId:B}),N&&W(`[initializeMobileProvider: sendRequest()] method=${j} ongoing=${O} selectedAddress=${M} isInstalled=${k} checkInstallationOnAllCalls=${t} socketConnected=${x}`),M&&j.toLowerCase()===ue.ETH_ACCOUNTS.toLowerCase())return[M];if(B&&j.toLowerCase()===ue.ETH_CHAINID.toLowerCase())return B;const H=[ue.ETH_REQUESTACCOUNTS,ue.WALLET_REQUESTPERMISSIONS,ue.METAMASK_CONNECTSIGN,ue.METAMASK_CONNECTWITH],z=!Gr[j],J=(C=a.options.readonlyRPCMap)===null||C===void 0?void 0:C[B];if(J&&z)try{const Q=(P=G==null?void 0:G[0])===null||P===void 0?void 0:P.params,ne=yield(({rpcEndpoint:se,method:le,sdkInfo:re,params:ie})=>Z(void 0,void 0,void 0,function*(){const ce=JSON.stringify({jsonrpc:"2.0",method:le,params:ie,id:(iu+=1,iu)}),ae={Accept:"application/json","Content-Type":"application/json"};let ge;se.includes("infura")&&(ae["Metamask-Sdk-Info"]=re);try{ge=yield Iu(se,{method:"POST",headers:ae,body:ce})}catch(Ee){throw Ee instanceof Error?new Error(`Failed to fetch from RPC: ${Ee.message}`):new Error(`Failed to fetch from RPC: ${Ee}`)}if(!ge.ok)throw new Error(`Server responded with a status of ${ge.status}`);return(yield ge.json()).result}))({rpcEndpoint:J,sdkInfo:g,method:j,params:Q||[]});return N&&W(`initializeProvider::ReadOnlyRPCResponse ${ne}`),ne}catch(Q){console.warn(`[initializeMobileProvider: sendRequest()] method=${j} readOnlyRPCRequest failed:`,Q)}if((!k||k&&!x)&&j!==ue.METAMASK_GETPROVIDERSTATE){const Q=((D=G==null?void 0:G[0])===null||D===void 0?void 0:D.params)||[];if(H.indexOf(j)!==-1||t){I(!0);const ne=j===ue.METAMASK_CONNECTWITH,se=`${Date.now()}`;try{yield o.start({wait:!1,connectWith:ne?{method:j,id:se,params:Q}:void 0}),yield new Promise((le,re)=>{s!=null&&s.isAuthorized()&&(W("[initializeMobileProvider: sendRequest()] already authorized"),le(!0)),s==null||s.getConnector().once(te.AUTHORIZED,()=>{le(!0)}),a.once(te.PROVIDER_UPDATE,ie=>{W(`[initializeMobileProvider: sendRequest()] PROVIDER_UPDATE --- remote provider request interupted type=${ie}`),ie===Kt.EXTENSION?re(te.PROVIDER_UPDATE):re(new Error("Connection Terminated"))})})}catch(le){if(Kt.EXTENSION===le){if(W(`[initializeMobileProvider: sendRequest()] extension provider detect: re-create ${j} on the active provider`),j.toLowerCase()===ue.METAMASK_CONNECTSIGN.toLowerCase()){const re=yield(y=a.getProvider())===null||y===void 0?void 0:y.request({method:ue.ETH_REQUESTACCOUNTS,params:[]});if(!re.length)throw new Error("SDK state invalid -- undefined accounts");const ie=yield(E=a.getProvider())===null||E===void 0?void 0:E.request({method:ue.PERSONAL_SIGN,params:[Q[0],re[0]]});return a.emit(tt.ConnectWithResponse,ie),ie}if(j.toLowerCase()===ue.METAMASK_CONNECTWITH.toLowerCase()){const[re]=Q,ie=yield(({method:ce,sdk:ae,params:ge})=>Z(void 0,void 0,void 0,function*(){var Ee,de,me,ve;if(!ae.isExtensionActive())throw new Error("SDK state invalid -- extension is not active");W("[MetaMaskProvider: extensionConnectWithOverwrite()] Overwriting request method",ce,ge);const Pe=yield(Ee=ae.getProvider())===null||Ee===void 0?void 0:Ee.request({method:ue.ETH_REQUESTACCOUNTS,params:[]});if(!Pe.length)throw new Error("SDK state invalid -- undefined accounts");if((ce==null?void 0:ce.toLowerCase())===ue.PERSONAL_SIGN.toLowerCase()){const ut={method:ce,params:[ge[0],Pe[0]]};return yield(de=ae.getProvider())===null||de===void 0?void 0:de.request(ut)}if((ce==null?void 0:ce.toLowerCase())===ue.ETH_SENDTRANSACTION.toLowerCase()){const ut={method:ce,params:[Object.assign(Object.assign({},ge[0]),{from:Pe[0]})]};return yield(me=ae.getProvider())===null||me===void 0?void 0:me.request(ut)}return Tf.includes(ce.toLowerCase())?(console.warn(`MetaMaskSDK connectWith method=${ce} -- not handled by the extension -- call separately`),Pe):yield(ve=ae.getProvider())===null||ve===void 0?void 0:ve.request({method:ce,params:ge})}))({method:re.method,sdk:a,params:re.params});return a.emit(tt.ConnectWithResponse,ie),ie}return W(`[initializeMobileProvider: sendRequest()] sending '${j}' on active provider`,Q),yield(A=a.getProvider())===null||A===void 0?void 0:A.request({method:j,params:Q})}throw le===te.REJECTED?(s==null||s.closeModal(),(T=a.getProvider())===null||T===void 0||T.handleDisconnect({terminate:!1}),Object.assign(new Error("User rejected connection"),{code:4001})):(W(`[initializeMobileProvider: sendRequest()] failed to start installer: ${le}`),le)}finally{I(!1)}if(j===ue.ETH_REQUESTACCOUNTS)return L=yield new Promise(le=>{const re=setInterval(()=>{const{accounts:ie}=v.getState();ie&&(clearInterval(re),le(ie))},100)}),W(`[initializeMobileProvider: sendRequest()] selectedAddress: ${M} --- SKIP rpc call`),L;if(j===ue.METAMASK_CONNECTWITH)try{let le=0;const re=5,ie=({resolve:Ee,reject:de})=>{le+=1;const me=s==null?void 0:s.getConnector().getRPCMethodTracker(),ve=me==null?void 0:me[se];return W(`TRACKER: update method ${se}`,ve),ve!=null&&ve.result?(W("[initializeMobileProvider: sendRequest()] found result",ve.result),a.emit(tt.ConnectWithResponse,ve.result),void Ee(ve.result)):ve!=null&&ve.error?(W("[initializeMobileProvider: sendRequest()] found error",ve.error),void de(ve.error)):le>=re?(W("[initializeMobileProvider: sendRequest()] max message count reached without result"),void de(new Error("Max message count reached without result"))):void W("[initializeMobileProvider: sendRequest()] not found yet, need to wait for next update")};let ce,ae;const ge=yield new Promise((Ee,de)=>{const me=s==null?void 0:s.getConnector().getRPCMethodTracker();W(`TRACKER: method ${se}`,me),me!=null&&me[se].result?(W("[initializeMobileProvider: sendRequest()] found result",me==null?void 0:me[se].result),Ee(me==null?void 0:me[se].result)):me!=null&&me[se].error&&(W("[initializeMobileProvider: sendRequest()] found error",me==null?void 0:me[se].error),de(me==null?void 0:me[se].error)),ae=()=>ie({resolve:Ee,reject:de}),ce=s==null?void 0:s.getConnector().on(te.RPC_UPDATE,ae)});return ae&&(ce==null||ce.off(te.RPC_UPDATE,ae)),W("TRACKER: result",ge),ge}catch(le){throw W("[initializeMobileProvider: sendRequest()] error:",le),le}return G[0]&&typeof G[0]=="object"&&(G[0].params={__triggeredInstaller:!0,wrappedParams:G[0].params}),$(...G)}if(i.isSecure()&&Gr[j])return $(...G);if(a.isExtensionActive())return W(`[initializeMobileProvider: sendRequest()] EXTENSION active - redirect request '${j}' to it`,G,Q),yield(b=a.getProvider())===null||b===void 0?void 0:b.request({method:j,params:Q});throw W(`[initializeMobileProvider: sendRequest()] method=${j} --- skip --- not connected/installed`),new Error("MetaMask is not connected/installed, please call eth_requestAccounts to connect first.")}try{const Q=yield $(...G);if(W(`[initializeMobileProvider: sendRequest()] method=${j} rpcResponse`,Q),j===ue.WALLET_REQUESTPERMISSIONS){const ne=Q.reduce((se,le)=>{var re;if(le.parentCapability==="eth_accounts"){const ie=(re=le.caveats.find(ce=>ce.type==="restrictReturnedAccounts"))===null||re===void 0?void 0:re.value;ie&&se.push(...ie)}return se},[]);W("[initializeMobileProvider: sendRequest()] accountsToPersist:",ne),ne.length>0&&(v.handleAccountsChanged(ne,!1),p==null||p.persistAccounts(ne))}return Q}catch(Q){throw console.error("[initializeMobileProvider: sendRequest()] error:",Q),Q}}),{request:F}=_;_.request=(...j)=>Z(void 0,void 0,void 0,function*(){return q(j==null?void 0:j[0].method,j,F,c)});const{send:U}=_;return _.send=(...j)=>Z(void 0,void 0,void 0,function*(){return q(j==null?void 0:j[0],j,U,c)}),W("[initializeMobileProvider: sendRequest()] metamaskStream.start()"),d.start(),_});function $y(t){var e,n,r,i;return Z(this,void 0,void 0,function*(){const{options:o}=t,a={communicationLayerPreference:(e=o.communicationLayerPreference)!==null&&e!==void 0?e:Bn.SOCKET,platformManager:t.platformManager,sdk:t,checkInstallationOnAllCalls:o.checkInstallationOnAllCalls,injectProvider:(n=o.injectProvider)===null||n===void 0||n,shouldShimWeb3:(r=o.shouldShimWeb3)===null||r===void 0||r,extensionOnly:(i=o.extensionOnly)===null||i===void 0||i,installer:t.installer,remoteConnection:t.remoteConnection,debug:t.debug},s=yield By(a);t.activeProvider=s,function(c){var l,u,d,h;(u=(l=c.remoteConnection)===null||l===void 0?void 0:l.getConnector())===null||u===void 0||u.on(tt.ConnectionStatus,f=>{c.emit(tt.ConnectionStatus,f)}),(h=(d=c.remoteConnection)===null||d===void 0?void 0:d.getConnector())===null||h===void 0||h.on(tt.ServiceStatus,f=>{c.emit(tt.ServiceStatus,f)})}(t)})}const Ky="sdk";class jy{constructor({serverUrl:e,enabled:n,originatorInfo:r}){this.serverURL=ar,this.serverURL=e,this.originatorInfo=r,this.enabled=n==null||n}send({event:e,params:n}){if(!this.enabled)return;const r=Object.assign(Object.assign({id:Ky,event:e,sdkVersion:Hn.version},this.originatorInfo),{params:n});W(`[Analytics: send()] event: ${e}`,r),en(r,this.serverURL).catch(i=>{W(`[Analytics: send()] error: ${i}`)})}}const Uy=()=>{if(typeof document>"u")return;let t;const e=document.getElementsByTagName("link");for(let n=0;n<e.length;n++)e[n].getAttribute("rel")!=="icon"&&e[n].getAttribute("rel")!=="shortcut icon"||(t=e[n].getAttribute("href"));return t},Hy=163400;function ou(t){var e,n,r;const{dappMetadata:i}=t,o=function({url:u,name:d}){var h;const f=u+d,g=vo(f);if(!localStorage)return"";let m=(h=localStorage.getItem(g))!==null&&h!==void 0?h:"";if(!m){m=yn();try{localStorage.setItem(g,m)}catch{return""}}return m}({url:(e=i==null?void 0:i.url)!==null&&e!==void 0?e:"no_url",name:(n=i==null?void 0:i.name)!==null&&n!==void 0?n:"no_name"}),a=(r=t.platformManager)===null||r===void 0?void 0:r.getPlatformType(),s=a===qe.DesktopWeb,c=a===qe.MetaMaskMobileWebview;let l="N/A";return s?l="extension":c&&(l="mobile"),{id:o,from:l}}const Ci=(t,e,n)=>{if(Xr(t))if(n||e&&typeof e=="object"&&e!==null&&"error"in e){const r=n||(e==null?void 0:e.error);r&&r.code===4001?Me.analytics.track("sdk_action_rejected",{action:t}):Me.analytics.track("sdk_action_failed",{action:t})}else Me.analytics.track("sdk_action_succeeded",{action:t})},Rf=({provider:t,sdkInstance:e})=>{if("state"in t)throw new Error("INVALID EXTENSION PROVIDER");return new Proxy(t,{get:(n,r)=>r==="request"?function(i){var o,a;return Z(this,void 0,void 0,function*(){W("[wrapExtensionProvider()] Overwriting request method",i);const{method:s,params:c}=i,l=Oy.includes(s.toLowerCase()),{id:u,from:d}=ou(e);if(l&&((o=e.analytics)===null||o===void 0||o.send({event:Re.SDK_RPC_REQUEST,params:{method:s,from:d,id:u}})),Xr(s)&&Me.analytics.track("sdk_action_requested",{action:s}),s===ue.METAMASK_BATCH&&Array.isArray(c))return(({target:g,args:m,trackEvent:w,sdkInstance:p})=>Z(void 0,void 0,void 0,function*(){var S,_;if(m.method!=="metamask_batch")throw new Error("Invalid usage");const O=[],I=(S=m==null?void 0:m.params)!==null&&S!==void 0?S:[];for(const F of I){const U=yield g==null?void 0:g.request({method:F.method,params:F.params});O.push(U)}const{id:K,from:q}=ou(p);w&&((_=p.analytics)===null||_===void 0||_.send({event:Re.SDK_RPC_REQUEST_DONE,params:{method:m.method,from:q,id:K}}));for(const F of O)Ci(m.method,F,null);return O}))({target:n,args:i,trackEvent:l,sdkInstance:e});if(s.toLowerCase()===ue.METAMASK_CONNECTSIGN.toLowerCase()&&Array.isArray(c))return(({target:g,params:m})=>Z(void 0,void 0,void 0,function*(){let w,p=null;try{const S=yield g.request({method:ue.ETH_REQUESTACCOUNTS,params:[]});if(!S.length)throw new Error("SDK state invalid -- undefined accounts");return w=yield g.request({method:ue.PERSONAL_SIGN,params:[m[0],S[0]]}),w}catch(S){throw p=S,S}finally{Ci(ue.PERSONAL_SIGN,w,p)}}))({target:n,params:c});if(s.toLowerCase()===ue.METAMASK_CONNECTWITH.toLowerCase()&&Array.isArray(c))return(({target:g,params:m})=>Z(void 0,void 0,void 0,function*(){const[w]=m,p=w.method,S=w.params;let _,O=null;try{const I=yield g.request({method:ue.ETH_REQUESTACCOUNTS,params:[]});if(!Array.isArray(I)||!I.length)throw new Error("SDK state invalid -- undefined accounts");return(p==null?void 0:p.toLowerCase())===ue.PERSONAL_SIGN.toLowerCase()?(_=yield g.request({method:p,params:[S[0],I[0]]}),_):(p==null?void 0:p.toLowerCase())===ue.ETH_SENDTRANSACTION.toLowerCase()?(_=yield g.request({method:p,params:[Object.assign(Object.assign({},S[0]),{from:I[0]})]}),_):Tf.includes(p.toLowerCase())?(console.warn(`MetaMaskSDK connectWith method=${p} -- not handled by the extension -- call separately`),_=I,_):(_=yield g.request({method:p,params:S}),_)}catch(I){throw O=I,I}finally{Ci(p,_,O)}}))({target:n,params:c});let h,f=null;try{return h=yield n.request(i),h}catch(g){throw f=g,g}finally{l&&((a=e.analytics)===null||a===void 0||a.send({event:Re.SDK_RPC_REQUEST_DONE,params:{method:s,from:d,id:u}})),Ci(s,h,f)}})}:r==="getChainId"?function(){return t.chainId}:r==="getNetworkVersion"?function(){return t.networkVersion}:r==="getSelectedAddress"?function(){return t.selectedAddress}:r==="isConnected"?function(){return t._state.isConnected}:n[r]})};var bo;function Fy({mustBeMetaMask:t,sdkInstance:e}){return Z(this,void 0,void 0,function*(){if(typeof window>"u")throw new Error("window not available");try{const n=yield new Promise((r,i)=>{const o=setTimeout(()=>{i(new Error("eip6963RequestProvider timed out"))},500);window.addEventListener(bo.Announce,a=>{const s=a,{detail:{info:c,provider:l}={}}=s,{name:u,rdns:d,uuid:h}=c??{};Ry.test(h)&&u.startsWith(nu.NAME)&&nu.RDNS.includes(d)&&(clearTimeout(o),r(l))}),window.dispatchEvent(new Event(bo.Request))});return Rf({provider:n,sdkInstance:e})}catch{throw new Error("Provider not found")}})}(function(t){t.Announce="eip6963:announceProvider",t.Request="eip6963:requestProvider"})(bo||(bo={}));const zy=t=>Z(void 0,void 0,void 0,function*(){const{options:e}=t,{infuraAPIKey:n}=e;if(!n)return;const r={"0x1":`https://mainnet.infura.io/v3/${n}`,"0x5":`https://goerli.infura.io/v3/${n}`,"0xaa36a7":`https://sepolia.infura.io/v3/${n}`,"0xe708":`https://linea-mainnet.infura.io/v3/${n}`,"0xe704":`https://linea-goerli.infura.io/v3/${n}`,"0x89":`https://polygon-mainnet.infura.io/v3/${n}`,"0x13881":`https://polygon-mumbai.infura.io/v3/${n}`,"0x45":`https://optimism-mainnet.infura.io/v3/${n}`,"0x1a4":`https://optimism-goerli.infura.io/v3/${n}`,"0xa4b1":`https://arbitrum-mainnet.infura.io/v3/${n}`,"0x66eed":`https://arbitrum-goerli.infura.io/v3/${n}`,"0x2a15c308d":`https://palm-mainnet.infura.io/v3/${n}`,"0x2a15c3083":`https://palm-testnet.infura.io/v3/${n}`,"0xa86a":`https://avalanche-mainnet.infura.io/v3/${n}`,"0xa869":`https://avalanche-fuji.infura.io/v3/${n}`,"0x4e454152":`https://aurora-mainnet.infura.io/v3/${n}`,"0x4e454153":`https://aurora-testnet.infura.io/v3/${n}`,"0x534e5f4d41494e":`https://starknet-mainnet.infura.io/v3/${n}`,"0x534e5f474f45524c49":`https://starknet-goerli.infura.io/v3/${n}`,"0x534e5f474f45524c4932":`https://starknet-goerli2.infura.io/v3/${n}`,"0xa4ec":`https://celo-mainnet.infura.io/v3/${n}`,"0xaef3":`https://celo-alfajores.infura.io/v3/${n}`};t.options.readonlyRPCMap?t.options.readonlyRPCMap=Object.assign(Object.assign({},t.options.readonlyRPCMap),r):t.options.readonlyRPCMap=r}),qy=t=>Z(void 0,void 0,void 0,function*(){const{options:e}=t,{readonlyRPCMap:n}=e;if(n)try{W("[MetaMaskSDK: setupReadOnlyRPCProviders()] Setting up Readonly RPC Providers",n),t.setReadOnlyRPCCalls(!0)}catch{throw new Error("Invalid Infura Settings")}});function Vy(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(l){try{c(r.next(l))}catch(u){o(u)}}function s(l){try{c(r.throw(l))}catch(u){o(u)}}function c(l){var u;l.done?i(l.value):(u=l.value,u instanceof n?u:new n(function(d){d(u)})).then(a,s)}c((r=r.apply(t,[])).next())})}function Wy(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function s(c){return function(l){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&u[0]?r.return:u[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,u[1])).done)return i;switch(r=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(i=a.trys,!((i=i.length>0&&i[i.length-1])||u[0]!==6&&u[0]!==2)){a=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){a.label=u[1];break}if(u[0]===6&&a.label<i[1]){a.label=i[1],i=u;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(u);break}i[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(d){u=[6,d],r=0}finally{n=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([c,l])}}}var su="INSTALLED",au="NOT_INSTALLED",cu="REGISTERED",lu="REGISTERING",uu="RELOADING",du={CHROME:"https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn",FIREFOX:"https://addons.mozilla.org/firefox/addon/ether-metamask/",DEFAULT:"https://metamask.io"},ki="REGISTRATION_IN_PROGRESS",hu="FORWARDER_ID",Gy=function(){function t(e){var n=e===void 0?{}:e,r=n.forwarderOrigin,i=r===void 0?"https://fwd.metamask.io":r,o=n.forwarderMode,a=o===void 0?t.FORWARDER_MODE.INJECT:o;this.forwarderOrigin=i,this.forwarderMode=a,this.state=t.isMetaMaskInstalled()?su:au;var s=t._detectBrowser();this.downloadUrl=s?du[s]:du.DEFAULT,this._onMessage=this._onMessage.bind(this),this._onMessageFromForwarder=this._onMessageFromForwarder.bind(this),this._openForwarder=this._openForwarder.bind(this),this._openDownloadPage=this._openDownloadPage.bind(this),this.startOnboarding=this.startOnboarding.bind(this),this.stopOnboarding=this.stopOnboarding.bind(this),window.addEventListener("message",this._onMessage),a===t.FORWARDER_MODE.INJECT&&sessionStorage.getItem(ki)==="true"&&t._injectForwarder(this.forwarderOrigin)}return t.prototype._onMessage=function(e){if(e.origin===this.forwarderOrigin)return e.data.type==="metamask:reload"?this._onMessageFromForwarder(e):void console.debug("Unknown message from '"+e.origin+"' with data "+JSON.stringify(e.data))},t.prototype._onMessageUnknownStateError=function(e){throw new Error("Unknown state: '"+e+"'")},t.prototype._onMessageFromForwarder=function(e){return Vy(this,0,void 0,function(){return Wy(this,function(n){switch(n.label){case 0:switch(this.state){case uu:return[3,1];case au:return[3,2];case su:return[3,3];case lu:return[3,5];case cu:return[3,6]}return[3,7];case 1:return console.debug("Ignoring message while reloading"),[3,8];case 2:return console.debug("Reloading now to register with MetaMask"),this.state=uu,location.reload(),[3,8];case 3:return console.debug("Registering with MetaMask"),this.state=lu,[4,t._register()];case 4:return n.sent(),this.state=cu,e.source.postMessage({type:"metamask:registrationCompleted"},e.origin),this.stopOnboarding(),[3,8];case 5:return console.debug("Already registering - ignoring reload message"),[3,8];case 6:return console.debug("Already registered - ignoring reload message"),[3,8];case 7:this._onMessageUnknownStateError(this.state),n.label=8;case 8:return[2]}})})},t.prototype.startOnboarding=function(){sessionStorage.setItem(ki,"true"),this._openDownloadPage(),this._openForwarder()},t.prototype.stopOnboarding=function(){sessionStorage.getItem(ki)==="true"&&(this.forwarderMode===t.FORWARDER_MODE.INJECT&&(console.debug("Removing forwarder"),t._removeForwarder()),sessionStorage.setItem(ki,"false"))},t.prototype._openForwarder=function(){this.forwarderMode===t.FORWARDER_MODE.OPEN_TAB?window.open(this.forwarderOrigin,"_blank"):t._injectForwarder(this.forwarderOrigin)},t.prototype._openDownloadPage=function(){window.open(this.downloadUrl,"_blank")},t.isMetaMaskInstalled=function(){return!!(window.ethereum&&window.ethereum.isMetaMask)},t._register=function(){return window.ethereum.request({method:"wallet_registerOnboarding"})},t._injectForwarder=function(e){var n=document.body,r=document.createElement("iframe");r.setAttribute("height","0"),r.setAttribute("width","0"),r.setAttribute("style","display: none;"),r.setAttribute("src",e),r.setAttribute("id",hu),n.insertBefore(r,n.children[0])},t._removeForwarder=function(){var e;(e=document.getElementById(hu))===null||e===void 0||e.remove()},t._detectBrowser=function(){var e=Af.parse(window.navigator.userAgent);return e.browser.name==="Firefox"?"FIREFOX":["Chrome","Chromium"].includes(e.browser.name||"")?"CHROME":null},t.FORWARDER_MODE={INJECT:"INJECT",OPEN_TAB:"OPEN_TAB"},t}();function Yy(t,{wait:e=!1}){return Z(this,void 0,void 0,function*(){return W(`[MetamaskInstaller: startInstaller()] wait=${e}`),e&&(yield Mf(1e3)),yield t.checkInstallation()})}class Zy{constructor({remote:e,preferDesktop:n,platformManager:r,debug:i=!1}){this.state={isInstalling:!1,hasInstalled:!1,resendRequest:null,preferDesktop:!1,platformManager:null,remote:null,debug:!1,connectWith:void 0},this.state.remote=e,this.state.preferDesktop=n,this.state.platformManager=r,this.state.debug=i}startDesktopOnboarding(){return function(){return Z(this,void 0,void 0,function*(){W("[MetamaskInstaller: startDesktopOnboarding() starting desktop onboarding"),window.ethereum&&(window.ethereum=void 0),new Gy().startOnboarding()})}()}redirectToProperInstall(){return Z(this,void 0,void 0,function*(){return function(e){var n,r;return Z(this,void 0,void 0,function*(){const{state:i}=e,o=(n=i.platformManager)===null||n===void 0?void 0:n.getPlatformType();if(W(`[MetamaskInstaller: redirectToProperInstall()] platform=${o}`),o===qe.MetaMaskMobileWebview)return!1;i.isInstalling=!0;try{yield(r=i.remote)===null||r===void 0?void 0:r.startConnection({connectWith:i.connectWith}),i.isInstalling=!1,i.hasInstalled=!0}catch(a){throw i.isInstalling=!1,a}return!0})}(this)})}checkInstallation(){return Z(this,void 0,void 0,function*(){return function(e){var n;return Z(this,void 0,void 0,function*(){const{state:r}=e,i=(n=r.platformManager)===null||n===void 0?void 0:n.isMetaMaskInstalled();return W(`[MetamaskInstaller: checkInstallation()] isInstalled=${i}`),!!i||(yield e.redirectToProperInstall())})}(this)})}start({wait:e=!1,connectWith:n}){return Z(this,void 0,void 0,function*(){this.state.connectWith=n,W(`[MetaMaskInstaller: start()] wait=${e}`,n),yield Yy(this,{wait:e})})}}class Of{constructor({debug:e,sdkVersion:n}){this.containers={install:void 0,pending:void 0,select:void 0},this.defined={install:!1,pending:!1,select:!1},this.debug=e!=null&&e,this.sdkVersion=n}loadComponent(e){return Z(this,void 0,void 0,function*(){if(!this.defined[e]){this.defined[e]=!0;try{const n=yield Promise.resolve().then(function(){return Mv});console.log("loader",n),n.defineCustomElements()}catch(n){console.error(`Failed to load ${e} modal:`,n)}}})}renderInstallModal(e){var n;return Z(this,void 0,void 0,function*(){this.debug&&console.debug("ModalLoader: renderInstallModal",e),this.containers.install=e.parentElement,yield this.loadComponent("install");const r=document.createElement("mm-install-modal");r.link=e.link,r.preferDesktop=e.preferDesktop,r.sdkVersion=(n=e.sdkVersion)!==null&&n!==void 0?n:this.sdkVersion,r.addEventListener("close",({detail:{shouldTerminate:i}})=>e.onClose(i)),r.addEventListener("startDesktopOnboarding",e.metaMaskInstaller.startDesktopOnboarding),r.addEventListener("trackAnalytics",i=>{var o;return(o=e.onAnalyticsEvent)===null||o===void 0?void 0:o.call(e,i.detail)}),e.parentElement.appendChild(r)})}renderSelectModal(e){var n;return Z(this,void 0,void 0,function*(){this.containers.select=e.parentElement,yield this.loadComponent("select");const r=document.createElement("mm-select-modal");r.link=e.link,r.sdkVersion=(n=e.sdkVersion)!==null&&n!==void 0?n:this.sdkVersion,r.preferDesktop=e.preferDesktop,r.addEventListener("close",({detail:{shouldTerminate:i}})=>e.onClose(i)),r.addEventListener("connectWithExtension",e.connectWithExtension),e.parentElement.appendChild(r),setTimeout(()=>this.updateQRCode(e.link),100)})}renderPendingModal(e){var n;return Z(this,void 0,void 0,function*(){this.containers.pending=e.parentElement,yield this.loadComponent("pending");const r=document.createElement("mm-pending-modal");r.sdkVersion=(n=e.sdkVersion)!==null&&n!==void 0?n:this.sdkVersion,r.displayOTP=e.displayOTP,r.addEventListener("close",e.onClose),r.addEventListener("updateOTPValue",({detail:{otpValue:i}})=>e.updateOTPValue(i)),e.onDisconnect&&r.addEventListener("disconnect",e.onDisconnect),e.parentElement.appendChild(r)})}updateOTPValue(e){const n=()=>{var r;const i=(r=this.containers.pending)===null||r===void 0?void 0:r.querySelector("mm-pending-modal");return!!i&&(i.otpCode=e,!0)};setTimeout(()=>{n()},800)}updateQRCode(e){var n,r;const i=(n=this.containers.install)===null||n===void 0?void 0:n.querySelector("mm-install-modal");if(i)i.link=e;else{const o=(r=this.containers.select)===null||r===void 0?void 0:r.querySelector("mm-select-modal");o&&(o.link=e)}}unmount(){Object.entries(this.containers).forEach(([e,n])=>{var r;(r=n==null?void 0:n.parentNode)===null||r===void 0||r.removeChild(n),this.containers[e]=void 0})}}const Jy=({link:t,debug:e,installer:n,terminate:r,connectWithExtension:i,preferDesktop:o,onAnalyticsEvent:a})=>{let s=null,c=null;W("[UI: InstallModal-web: sdkWebInstallModal()] ################## Installing Modal #################"),W(`[UI: InstallModal-web: sdkWebInstallModal()] link=${t}`),W(`[UI: InstallModal-web: sdkWebInstallModal()] npx uri-scheme open "${t}" --ios`),W(`[UI: InstallModal-web: sdkWebInstallModal()] npx uri-scheme open "${t}" --android`),W(`[UI: InstallModal-web: sdkWebInstallModal()] adb shell am start -a android.intent.action.VIEW -d "${t}"`);const l=u=>{var d;W("[UI: InstallModal-web: sdkWebInstallModal()] installModal-web unmounting install modal -- shouldTerminate:",u,c),c!=null&&c.parentNode&&((d=c.parentNode)===null||d===void 0||d.removeChild(c)),c=null,s=null,u===!0&&(r==null||r())};return{mount:u=>{if(W("[UI: InstallModal-web: sdkWebInstallModal()] installModal-web mounting install modal",c),c)return c.style.display="block",void(s==null||s.updateQRCode(u));s=new Of({debug:e,sdkVersion:Hn.version}),c=document.createElement("div"),document.body.appendChild(c),window.extension?s.renderSelectModal({parentElement:c,connectWithExtension:()=>{l(),i==null||i()},onClose:l,link:t,preferDesktop:o!=null&&o}).catch(d=>{console.error(d)}):s.renderInstallModal({parentElement:c,preferDesktop:o!=null&&o,link:t,metaMaskInstaller:n,onClose:l,onAnalyticsEvent:a}).catch(d=>{console.error("[UI: InstallModal-web: sdkWebInstallModal()]",d)})},unmount:l}},Xy=({onDisconnect:t,debug:e})=>{let n=null,r=null;const i=()=>{W("[UI: pendingModal-web: sdkWebPendingModal()] pendingModal-web unmount",n),n!=null&&n.parentNode&&n.parentNode.removeChild(n),n=null,r=null},o=s=>{W("[UI: pendingModal-web: sdkWebPendingModal()] pendingModal-web updateOTPValue",s),r&&r.updateOTPValue(s)},a=({displayOTP:s}={displayOTP:!0})=>{W("[UI: pendingModal-web: sdkWebPendingModal()] pendingModal-web mount",n),n?n.style.display="block":(r=new Of({debug:e,sdkVersion:Hn.version}),n=document.createElement("div"),document.body.appendChild(n),r.renderPendingModal({parentElement:n,onClose:i,onDisconnect:t,updateOTPValue:o,displayOTP:s}).catch(c=>{console.error("[UI: pendingModal-web: sdkWebPendingModal()]",c)}))};return a(),{mount:a,unmount:i,updateOTPValue:o}};function Pf(t,e){var n,r,i,o;t.connector||(W("[RemoteConnection: initializeConnector()] initialize connector"),t.connector=new eg({anonId:e.anonId,platformType:e.platformManager.getPlatformType(),communicationLayerPreference:e.communicationLayerPreference,transports:e.transports,dappMetadata:Object.assign(Object.assign({},e.dappMetadata),{source:e._source}),analytics:e.enableAnalytics,communicationServerUrl:e.communicationServerUrl,sdkVersion:Hn.version,context:"dapp",ecies:e.ecies,storage:e.storage,logging:e.logging}),e.timer&&(W("[RemoteConnection: initializeConnector()] reset background timer",e.timer),(r=(n=e.timer)===null||n===void 0?void 0:n.stopBackgroundTimer)===null||r===void 0||r.call(n),(o=(i=e.timer)===null||i===void 0?void 0:i.runBackgroundTimer)===null||o===void 0||o.call(i,()=>!1,1e4)))}function ha(t){t.listeners.forEach(({event:e,handler:n})=>{var r;(r=t.connector)===null||r===void 0||r.off(e,n)}),t.listeners=[]}function Qy(t,e,n){return Z(this,void 0,void 0,function*(){const r=setTimeout(()=>{Me.analytics.track("sdk_connection_failed",{transport_type:"websocket"})},6e4);return new Promise((i,o)=>{if(!t.connector)return void o(new Error("No connector available"));W("[RemoteConnection: connectWithModalInstaller()]",{state:t,options:e,linkParams:n});const a=`${t.useDeeplink?Wr:Vr}?${n}`;(function(s,c,l){var u,d,h,f;s.installModal=(d=(u=c.modals).install)===null||d===void 0?void 0:d.call(u,{link:l,preferDesktop:s.preferDesktop,installer:c.getMetaMaskInstaller(),terminate:()=>{W("[RemoteConnection: showInstallModal() => terminate()] terminate connection"),c.sdk.terminate().catch(g=>{console.warn("[MMSDK] failed to terminate connection",g)})},debug:s.developerMode,connectWithExtension:()=>{var g;return(g=c.connectWithExtensionProvider)===null||g===void 0||g.call(c),!1},onAnalyticsEvent:({event:g,params:m})=>{var w,p,S;const _=Object.assign(Object.assign({},m),{sdkVersion:c.sdk.getVersion(),dappId:(w=c.dappMetadata)===null||w===void 0?void 0:w.name,source:c._source,url:(p=c.dappMetadata)===null||p===void 0?void 0:p.url});(S=s.analytics)===null||S===void 0||S.send({event:g,params:_})}}),(f=(h=s.installModal)===null||h===void 0?void 0:h.mount)===null||f===void 0||f.call(h,l)})(t,e,a),e.sdk.once(te.PROVIDER_UPDATE,s=>Z(this,void 0,void 0,function*(){if(W("[RemoteConnection: connectWithModalInstaller()] once provider_update -- resolving startConnection promise"),s===Kt.TERMINATE){const c={code:4001,message:"User rejected the request."};return clearTimeout(r),void o(c)}o(s)})),t.connector.once(te.AUTHORIZED,()=>{clearTimeout(r),i()}),t.connector.once(te.REJECTED,()=>{clearTimeout(r),o(te.REJECTED)}),t.connector.once(te.CLIENTS_READY,()=>Z(this,void 0,void 0,function*(){W("[RemoteConnection: connectWithModalInstaller()] once clients_ready -- resolving startConnection promise"),clearTimeout(r),i()}))})})}function If(t,e){function n(r,i){var o;(o=t.connector)===null||o===void 0||o.on(r,i),t.listeners.push({event:r,handler:i})}t.connector&&(ha(t),n(te.WALLET_INIT,({accounts:r,chainId:i})=>Z(this,void 0,void 0,function*(){W(`[RemoteConnection: setupListeners() => EventType.WALLET_INIT] 'wallet_init' accounts=${r} chainId=${i}`);const o=kt.getProvider();o._setConnected();const a={accounts:r,chainId:i,isUnlocked:!1};o._initializeState(a),o.emit("chainChanged",i),o.emit("accountsChanged",r)})),n(te.AUTHORIZED,()=>Z(this,void 0,void 0,function*(){var r,i,o,a;try{W("[RemoteConnection: setupListeners() => EventType.AUTHORIZED] 'authorized' closing modals",t.pendingModal,t.installModal);const s=kt.getProvider();s._setConnected(),(i=(r=t.pendingModal)===null||r===void 0?void 0:r.unmount)===null||i===void 0||i.call(r),(a=(o=t.installModal)===null||o===void 0?void 0:o.unmount)===null||a===void 0||a.call(o,!1),t.otpAnswer=void 0,t.authorized=!0,W("[RemoteConnection: setupListeners() => EventType.AUTHORIZED] 'authorized' provider.state",s.getState()),yield s.forceInitializeState()}catch{}})),n(te.TERMINATE,()=>{var r,i,o,a,s;(i=(r=t.pendingModal)===null||r===void 0?void 0:r.unmount)===null||i===void 0||i.call(r),(a=(o=t.installModal)===null||o===void 0?void 0:o.unmount)===null||a===void 0||a.call(o,!0),t.pendingModal=void 0,t.installModal=void 0,t.otpAnswer=void 0,(s=t.connector)===null||s===void 0||s.disconnect({terminate:!0}),t.authorized=!1,kt.getProvider().handleDisconnect({terminate:!0}),ha(t),W("[RemoteConnection: setupListeners()] All listeners cleaned up")}))}function ev(t,e,{initialCheck:n,connectWith:r}={}){var i,o,a,s,c,l,u,d,h,f,g,m,w,p,S,_,O,I,K;return Z(this,void 0,void 0,function*(){try{if(Pf(t,e),!t.connector)throw new Error("no connector defined");If(t);const q=kt.getProvider();t.authorized=!1,q.emit("connecting");const F=yield(i=t.connector)===null||i===void 0?void 0:i.originatorSessionConnect();W(`[RemoteConnection: startConnection()] after originatorSessionConnect initialCheck=${n}`,F);let U=(o=F==null?void 0:F.channelId)!==null&&o!==void 0?o:"",j=(s=(a=t.connector.getKeyInfo())===null||a===void 0?void 0:a.ecies.public)!==null&&s!==void 0?s:"",G=(l=(c=t.connector.getKeyInfo())===null||c===void 0?void 0:c.ecies.private)!==null&&l!==void 0?l:"";if(n&&!F)return Promise.resolve();if(!F&&!n){const x=yield t.connector.generateChannelIdConnect();U=(u=x.channelId)!==null&&u!==void 0?u:"",j=(d=x.pubKey)!==null&&d!==void 0?d:"",G=(h=x.privKey)!==null&&h!==void 0?h:"";const M=Date.now();(f=t.connector.state.storageManager)===null||f===void 0||f.persistChannelConfig({channelId:U,localKey:G,lastActive:M,validUntil:M+cr})}if(n&&(F!=null&&F.channelId))return!((g=t.connector)===null||g===void 0)&&g.isConnected()||(W(`[RemoteConnection: startConnection()] reconnecting to channel initialCheck=${n}`,F),yield(m=t.connector)===null||m===void 0?void 0:m.connectToChannel({channelId:U})),Promise.resolve();F&&!(!((w=t.connector)===null||w===void 0)&&w.isConnected())&&(W("[RemoteConnection: startConnection()] reconnecting to channel",F),yield(p=t.connector)===null||p===void 0?void 0:p.connectToChannel({channelId:U}));const $=!((S=t.platformManager)===null||S===void 0)&&S.isSecure()?"":"&t=q",N=Hn.version,{iconUrl:R,name:C,url:P,scheme:D}=e.dappMetadata||{},y=(_=t.platformManager)===null||_===void 0?void 0:_.getPlatformType();let E="N/A";typeof window<"u"&&window.location&&window.location.hostname?E=window.location.hostname:C!==void 0?E=C:P!==void 0&&(E=P);const A={url:P??"",title:C??"",icon:R,scheme:D??"",apiVersion:N,dappId:E||P||"N/A",anonId:e.anonId,platform:y??"",source:(O=e._source)!==null&&O!==void 0?O:""},T=vo(JSON.stringify(A));let b=`channelId=${U}&v=2&comm=${(I=t.communicationLayerPreference)!==null&&I!==void 0?I:""}&pubkey=${j}${$}&originatorInfo=${T}`;if(r){b+=`&rpc=${vo(JSON.stringify(r))}`;const x=t.connector.getRPCMethodTracker();x&&(x[`${r.id}`]=Object.assign(Object.assign({},r),{id:`${r.id}`,timestamp:Date.now()}))}const v=encodeURI(b),k=`${t.useDeeplink?Wr:Vr}?${b}`;if(t.qrcodeLink=k,t.developerMode&&W(`[RemoteConnection: startConnection()] qrcodeLink=${v}`),q.emit("display_uri",k),Me.analytics.track("sdk_connection_initiated",{transport_type:"websocket"}),(K=t.platformManager)===null||K===void 0?void 0:K.isSecure()){const x=setTimeout(()=>{Me.analytics.track("sdk_connection_failed",{transport_type:"websocket"})},6e4);return yield function(M,L){var B,H;return Z(this,void 0,void 0,function*(){const z=`${Vr}?${L}`,J=`${Wr}?${L}`;(H=(B=M.platformManager)===null||B===void 0?void 0:B.openDeeplink)===null||H===void 0||H.call(B,z,J,"_self")})}(t,v),new Promise((M,L)=>{var B,H,z;if(!((B=t.connector)===null||B===void 0)&&B.isAuthorized())return clearTimeout(x),void M();(H=t.connector)===null||H===void 0||H.once(te.AUTHORIZED,()=>{clearTimeout(x),M()}),(z=t.connector)===null||z===void 0||z.once(te.REJECTED,()=>{clearTimeout(x),L(te.REJECTED)})})}return Qy(t,e,v)}catch(q){throw console.error("[startConnection] error",q),q}})}class tv{constructor(e){var n,r,i;this.state={connector:void 0,qrcodeLink:void 0,analytics:void 0,developerMode:!1,authorized:!1,reconnection:!1,preferDesktop:!1,deeplinkProtocol:!1,listeners:[],communicationLayerPreference:void 0,platformManager:void 0,pendingModal:void 0,installModal:void 0,otpAnswer:void 0},this.options=e;const o=((n=e.logging)===null||n===void 0?void 0:n.developerMode)===!0||((r=e.logging)===null||r===void 0?void 0:r.sdk)===!0;this.state.developerMode=o,this.state.analytics=e.analytics,this.state.preferDesktop=(i=e.preferDesktop)!==null&&i!==void 0&&i,this.state.useDeeplink=e.sdk.options.useDeeplink,this.state.communicationLayerPreference=e.communicationLayerPreference,this.state.platformManager=e.platformManager,e.modals.install||(e.modals.install=Jy),e.modals.otp||(e.modals.otp=Xy)}startConnection(e){return Z(this,void 0,void 0,function*(){return ev(this.state,this.options,e)})}initRemoteCommunication({sdkInstance:e}){var n,r,i;return Z(this,void 0,void 0,function*(){const o=yield(r=(n=e.options.storage)===null||n===void 0?void 0:n.storageManager)===null||r===void 0?void 0:r.getPersistedChannelConfig();if(!this.options.ecies){const a={privateKey:o==null?void 0:o.localKey};this.options.ecies=a}Pf(this.state,this.options),yield(i=this.getConnector())===null||i===void 0?void 0:i.initFromDappStorage(),If(this.state,this.options)})}showActiveModal(){return function(e){var n,r,i,o;e.authorized?W("[RemoteConnection: showActiveModal()] already authorized"):e.pendingModal?(r=(n=e.pendingModal).mount)===null||r===void 0||r.call(n):e.installModal&&((o=(i=e.installModal).mount)===null||o===void 0||o.call(i,e.qrcodeLink||""))}(this.state)}closeModal(){var e,n,r,i;(n=(e=this.state.pendingModal)===null||e===void 0?void 0:e.unmount)===null||n===void 0||n.call(e),(i=(r=this.state.installModal)===null||r===void 0?void 0:r.unmount)===null||i===void 0||i.call(r,!1)}getUniversalLink(){if(!this.state.qrcodeLink)throw new Error("connection not started. run startConnection() first.");return this.state.qrcodeLink}getChannelConfig(){var e;return(e=this.state.connector)===null||e===void 0?void 0:e.getChannelConfig()}getKeyInfo(){var e;return(e=this.state.connector)===null||e===void 0?void 0:e.getKeyInfo()}getConnector(){if(!this.state.connector)throw new Error("invalid remote connector");return this.state.connector}getPlatformManager(){if(!this.state.platformManager)throw new Error("PlatformManager not available");return this.state.platformManager}isConnected(){var e;return((e=this.state.connector)===null||e===void 0?void 0:e.isReady())||!1}isAuthorized(){var e;return((e=this.state.connector)===null||e===void 0?void 0:e.isAuthorized())||!1}isPaused(){var e;return(e=this.state.connector)===null||e===void 0?void 0:e.isPaused()}disconnect(e){var n,r,i;W("[RemoteConnection: disconnect()]",e),e!=null&&e.terminate&&(kt.getProvider().handleDisconnect({terminate:!0}),(r=(n=this.state.pendingModal)===null||n===void 0?void 0:n.unmount)===null||r===void 0||r.call(n),this.state.otpAnswer=void 0),(i=this.state.connector)===null||i===void 0||i.disconnect(e),function(o){W("[RemoteConnection: cleanupConnector()] cleaning up connector"),o.connector&&(ha(o),o.connector.disconnect({terminate:!0}).catch(a=>{W("[RemoteConnection: cleanupConnector()] error disconnecting connector",a)}))}(this.state)}}function nv(t){var e,n,r,i,o,a,s,c,l,u,d;return Z(this,void 0,void 0,function*(){const{options:h}=t;if(h.logging=(e=h.logging)!==null&&e!==void 0?e:{},h.communicationLayerPreference=(n=h.communicationLayerPreference)!==null&&n!==void 0?n:Bn.SOCKET,h.enableDebug!==void 0&&(Ze.enable("MM_SDK"),console.warn("enableDebug is removed. Please use enableAnalytics instead.")),h.enableAnalytics=(r=h.enableAnalytics)===null||r===void 0||r,h.injectProvider=(i=h.injectProvider)===null||i===void 0||i,h.shouldShimWeb3=(o=h.shouldShimWeb3)===null||o===void 0||o,h.extensionOnly=(a=h.extensionOnly)===null||a===void 0||a,h.useDeeplink=(s=h.useDeeplink)===null||s===void 0||s,h.storage=(c=h.storage)!==null&&c!==void 0?c:{enabled:!0},h.headless){Ze("[MetaMaskSDK: performSDKInitialization()] headless mode enabled");const S=()=>{},_={install:()=>({mount:S,unmount:S})},O={installer:S};h.modals=_,h.ui=O}const f=((l=h.logging)===null||l===void 0?void 0:l.developerMode)===!0;t.debug=((u=h.logging)===null||u===void 0?void 0:u.sdk)||f,W("[MetaMaskSDK: performSDKInitialization()] options",t.options);const g=Object.assign({},h.logging);f&&(g.sdk=!0,g.eciesLayer=!0,g.keyExchangeLayer=!0,g.remoteLayer=!0,g.serviceLayer=!0,g.plaintext=!0),yield function(S){var _;return Z(this,void 0,void 0,function*(){const{options:O}=S;S.platformManager=new zr({useDeepLink:(_=O.useDeeplink)!==null&&_!==void 0&&_,preferredOpenLink:O.openDeeplink,debug:S.debug})})}(t),yield function(S){var _,O,I,K,q;return Z(this,void 0,void 0,function*(){const{options:F}=S,U=(_=S.platformManager)===null||_===void 0?void 0:_.getPlatformType();S.analytics=new jy({serverUrl:(O=F.communicationServerUrl)!==null&&O!==void 0?O:ar,enabled:F.enableAnalytics,originatorInfo:{url:(I=F.dappMetadata.url)!==null&&I!==void 0?I:"",title:(K=F.dappMetadata.name)!==null&&K!==void 0?K:"",dappId:S.getDappId(),platform:U??"",source:(q=F._source)!==null&&q!==void 0?q:"",anonId:""}})})}(t),yield function(S){var _,O,I;return Z(this,void 0,void 0,function*(){if(!S.options.enableAnalytics||!(!((_=S.platformManager)===null||_===void 0)&&_.isBrowser())&&!(!((O=S.platformManager)===null||O===void 0)&&O.isReactNative()))return;const K=S.getVersion(),q=S.getDappId(),F=yield S.getAnonId(),U=(I=S.platformManager)===null||I===void 0?void 0:I.getPlatformType(),j=S.options._source;Me.analytics.setGlobalProperty("sdk_version",K),Me.analytics.setGlobalProperty("dapp_id",q),Me.analytics.setGlobalProperty("anon_id",F),Me.analytics.setGlobalProperty("platform",U),Me.analytics.setGlobalProperty("integration_type",j),Me.analytics.enable(),Me.analytics.track("sdk_initialized",{})})}(t),yield function(S){var _;return Z(this,void 0,void 0,function*(){const{options:O}=S;((_=O.storage)===null||_===void 0?void 0:_.enabled)!==!0||O.storage.storageManager||(O.storage.storageManager=yield xf(O.storage))})}(t),yield function(S){return Z(this,void 0,void 0,function*(){const{options:_}=S,O=/^(http|https):\/\/[^\s]*$/;if(_.dappMetadata){_.dappMetadata.iconUrl&&!O.test(_.dappMetadata.iconUrl)&&(console.warn("Invalid dappMetadata.iconUrl: URL must start with http:// or https://"),_.dappMetadata.iconUrl=void 0),_.dappMetadata.base64Icon&&_.dappMetadata.base64Icon.length>Hy&&(console.warn("Invalid dappMetadata.base64Icon: Base64-encoded icon string length must be less than 163400 characters"),_.dappMetadata.base64Icon=void 0),_.dappMetadata.url&&!O.test(_.dappMetadata.url)&&console.warn("Invalid dappMetadata.url: URL must start with http:// or https://");const I=Uy();if(I&&!_.dappMetadata.iconUrl&&!_.dappMetadata.base64Icon){const K=`${window.location.protocol}//${window.location.host}${I}`;_.dappMetadata.iconUrl=K}}S.dappMetadata=_.dappMetadata})}(t),yield zy(t),yield qy(t);const{metamaskBrowserExtension:m,preferExtension:w,shouldReturn:p}=yield function(S){var _,O,I,K;return Z(this,void 0,void 0,function*(){const{options:q}=S;let F,U=!1,j=!1;if(typeof window<"u"&&window.ethereum&&!(!((_=S.platformManager)===null||_===void 0)&&_.isMetaMaskMobileWebView())){U=localStorage.getItem(yo)==="extension";try{F=yield Fy({mustBeMetaMask:!0,sdkInstance:S}),window.extension=F,F.on(xt.CHAIN_CHANGED,G=>{W(`[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE chainChanged chainId=${G}`),S.sdkProvider&&S.getMobileProvider().emit(xt.CHAIN_CHANGED,G)}),F.on(xt.ACCOUNTS_CHANGED,G=>Z(this,void 0,void 0,function*(){var $;W(`[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE accountsChanged accounts=${G}`);const N=!!S.sdkProvider,R=!!S.extensionActive;if(N&&S.getMobileProvider().emit(xt.ACCOUNTS_CHANGED,G),R&&(G==null?void 0:G.length)===0&&(yield($=S.getProvider())===null||$===void 0?void 0:$.request({method:ue.WALLET_GETPERMISSIONS,params:[]})).length===0)try{yield S.terminate()}catch(C){W("[MetaMaskSDK: setupExtensionPreferences()] error terminating on permissions revoked",C)}})),F.on(xt.DISCONNECT,G=>{W(`[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE disconnect error=${G}`),S.sdkProvider&&S.getMobileProvider().emit(xt.DISCONNECT,G)}),F.on(xt.CONNECT,G=>{W(`[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE connect args=${G}`),S.sdkProvider&&S.getMobileProvider().emit(xt.CONNECT,G)}),F.on(xt.CONNECTED,G=>{W("[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE connected",G),S.sdkProvider&&S.getMobileProvider().emit(xt.CONNECTED,G)})}catch{window.extension=void 0}}else!((O=S.platformManager)===null||O===void 0)&&O.isMetaMaskMobileWebView()&&((I=S.analytics)===null||I===void 0||I.send({event:Re.SDK_USE_INAPP_BROWSER}),S.activeProvider=Rf({provider:window.ethereum,sdkInstance:S}),S._initialized=!0,j=!0);return F&&q.extensionOnly&&(W("[MetaMaskSDK: setupExtensionPreferences()] EXTENSION ONLY --- prevent sdk initialization"),(K=S.analytics)===null||K===void 0||K.send({event:Re.SDK_USE_EXTENSION}),S.activeProvider=F,S.extensionActive=!0,S.extension=F,S._initialized=!0,j=!0),{preferExtension:U,shouldReturn:j,metamaskBrowserExtension:F}})}(t);if(p)W("[MetaMaskSDK: performSDKInitialization()] shouldReturn=true --- prevent sdk initialization");else{yield function(S,_){var O,I,K,q,F;return Z(this,void 0,void 0,function*(){const{options:U}=S,j=Object.assign({},U.logging);S.remoteConnection=new tv({anonId:yield S.getAnonId(),preferDesktop:(O=U.preferDesktop)!==null&&O!==void 0&&O,communicationLayerPreference:(I=U.communicationLayerPreference)!==null&&I!==void 0?I:Bn.SOCKET,analytics:S.analytics,dappMetadata:U.dappMetadata,_source:U._source,enableAnalytics:(K=U.enableAnalytics)===null||K===void 0||K,timer:U.timer,sdk:S,platformManager:S.platformManager,transports:U.transports,communicationServerUrl:U.communicationServerUrl,storage:(q=U.storage)!==null&&q!==void 0?q:{enabled:!0},getMetaMaskInstaller:()=>{if(!S.installer)throw new Error("Invalid SDK status -- installer not initialized");return S.installer},logging:j,connectWithExtensionProvider:_===void 0?void 0:()=>ru(S),modals:Object.assign(Object.assign({},U.modals),{onPendingModalDisconnect:S.terminate.bind(S)})}),yield S.remoteConnection.initRemoteCommunication({sdkInstance:S}),S.installer=new Zy({remote:S.remoteConnection,preferDesktop:(F=U.preferDesktop)!==null&&F!==void 0&&F,platformManager:S.platformManager,debug:S.debug})})}(t,m),yield $y(t),yield function(S,_){var O,I;return Z(this,void 0,void 0,function*(){const{options:K}=S;_?(W("[MetaMaskSDK: handleAutoAndExtensionConnections()] preferExtension is detected -- connect with it."),(O=S.analytics)===null||O===void 0||O.send({event:Re.SDK_EXTENSION_UTILIZED}),ru(S).catch(q=>{console.warn("Can't connect with MetaMask extension...",q),localStorage.removeItem(yo)})):K.checkInstallationImmediately&&(!((I=S.platformManager)===null||I===void 0)&&I.isDesktopWeb()?(W("[MetaMaskSDK: handleAutoAndExtensionConnections()] checkInstallationImmediately"),S.connect().catch(q=>{W(`[MetaMaskSDK: handleAutoAndExtensionConnections()] checkInstallationImmediately --- IGNORED --- error on autoconnect _err=${q}`)})):console.warn("[handleAutoAndExtensionConnections()] checkInstallationImmediately --- IGNORED --- only for web desktop")),S._initialized=!0})}(t,w);try{yield(d=t.remoteConnection)===null||d===void 0?void 0:d.startConnection({initialCheck:!0})}catch(S){console.error("[MetaMaskSDK: setupRemoteConnectionAndInstaller()] Error while checking installation",S)}t.emit(tt.ProviderUpdate,Kt.INITIALIZED)}})}class Vv extends jp{constructor(e={storage:{enabled:!0},injectProvider:!0,forceInjectProvider:!1,enableAnalytics:!0,shouldShimWeb3:!0,useDeeplink:!0,extensionOnly:!0,headless:!1,dappMetadata:{name:"",url:"",iconUrl:""},_source:tu,i18nOptions:{enabled:!1}}){var n,r,i;super(),this.extensionActive=!1,this._initialized=!1,this.sdkInitPromise=void 0,this.debug=!1,this.readonlyRPCCalls=!1,this.availableLanguages=["en"],this.ANON_ID_STORAGE_KEY="mm-sdk-anon-id",Ze.disable();const o=((n=e.logging)===null||n===void 0?void 0:n.developerMode)===!0;if((!((r=e.logging)===null||r===void 0)&&r.sdk||o)&&Ze.enable("MM_SDK"),W("[MetaMaskSDK: constructor()]: begin."),this.setMaxListeners(50),!(!((i=e.dappMetadata)===null||i===void 0)&&i.url)){if(typeof window>"u"||typeof document>"u")throw new Error("You must provide dAppMetadata url");e.dappMetadata=Object.assign(Object.assign({},e.dappMetadata),{url:`${window.location.protocol}//${window.location.host}`})}this.options=e,this.options._source||(e._source=tu),this.init().then(()=>{W("[MetaMaskSDK: constructor()]: initialized successfully."),typeof window<"u"&&(window.mmsdk=this)}).catch(a=>{console.error("[MetaMaskSDK: constructor()] error during initialization",a)})}init(){return Z(this,void 0,void 0,function*(){return function(e){var n;return Z(this,void 0,void 0,function*(){if(typeof window<"u"&&(!((n=window.mmsdk)===null||n===void 0)&&n.isInitialized()))return W("[MetaMaskSDK: initializeMetaMaskSDK()] already initialized"),Promise.resolve(window.mmsdk);if(e._initialized)return W("[MetaMaskSDK: initializeMetaMaskSDK()] already initialized"),e.sdkInitPromise;if(e.sdkInitPromise)return W("[MetaMaskSDK: initializeMetaMaskSDK()] already initializing"),e.sdkInitPromise;try{e.sdkInitPromise=nv(e),yield e.sdkInitPromise}catch(r){throw console.error(r),r}return e.sdkInitPromise})}(this)})}isExtensionActive(){return this.extensionActive}checkExtensionAvailability(){var e;return typeof window<"u"&&!!(!((e=window.ethereum)===null||e===void 0)&&e.isMetaMask)}connect(){return Z(this,void 0,void 0,function*(){return function(e){return Z(this,void 0,void 0,function*(){if(e._initialized||(W("[MetaMaskSDK: connect()] provider not ready -- wait for init()"),yield e.init()),W(`[MetaMaskSDK: connect()] isExtensionActive=${e.isExtensionActive()} activeProvider`,e.activeProvider),!e.activeProvider)throw new Error("SDK state invalid -- undefined provider");const n=e.activeProvider.getSelectedAddress();return n?[n]:e.activeProvider.request({method:ue.ETH_REQUESTACCOUNTS,params:[]})})}(this)})}connectAndSign({msg:e}){return Z(this,void 0,void 0,function*(){return Ly({instance:this,msg:e})})}connectWith(e){return Z(this,void 0,void 0,function*(){return function({instance:n,rpc:r}){return Z(this,void 0,void 0,function*(){if(n._initialized||(W("[MetaMaskSDK: connectWith()] provider not ready -- wait for init()"),yield n.init()),W(`[MetaMaskSDK: connectWith()] method: ${r.method} rpc=${r}`),!n.activeProvider)throw new Error("SDK state invalid -- undefined provider");return n.activeProvider.request({method:ue.METAMASK_CONNECTWITH,params:[r]})})}({instance:this,rpc:e})})}resume(){return function(e){var n,r,i;return Z(this,void 0,void 0,function*(){if(!(!((r=(n=e.remoteConnection)===null||n===void 0?void 0:n.getConnector())===null||r===void 0)&&r.isReady()))return W("[MetaMaskSDK: resume()] channel is not ready -- starting connection"),void((i=e.remoteConnection)===null||i===void 0||i.startConnection());W("[MetaMaskSDK: resume()] channel is ready")})}(this)}disconnect(){return console.warn("MetaMaskSDK.disconnect() is deprecated, use terminate()"),this.terminate()}isAuthorized(){var e;(e=this.remoteConnection)===null||e===void 0||e.isAuthorized()}terminate(){return function(e){var n,r,i;return Z(this,void 0,void 0,function*(){if(!(!((n=e.platformManager)===null||n===void 0)&&n.isMetaMaskMobileWebView())){if(Iy&&(window.localStorage.removeItem(yo),window.localStorage.removeItem(da),window.localStorage.removeItem(ua)),e.extensionActive){try{yield(r=e.activeProvider)===null||r===void 0?void 0:r.request({method:ue.WALLET_REVOKEPERMISSIONS,params:[{eth_accounts:{}}]})}catch(o){W("[MetaMaskSDK: terminate()] error revoking permissions",o)}return e.options.extensionOnly?(e.emit(tt.ProviderUpdate,Kt.TERMINATE),void W("[MetaMaskSDK: terminate()] extensionOnly --- prevent switching providers")):(e.activeProvider=e.sdkProvider,window.ethereum=e.activeProvider,e.extensionActive=!1,void e.emit(tt.ProviderUpdate,Kt.TERMINATE))}e.emit(tt.ProviderUpdate,Kt.TERMINATE),W(`[MetaMaskSDK: terminate()] remoteConnection=${e.remoteConnection}`),(i=e.remoteConnection)===null||i===void 0||i.disconnect({terminate:!0,sendMessage:!0})}})}(this)}isInitialized(){return this._initialized}setReadOnlyRPCCalls(e){this.readonlyRPCCalls=e}hasReadOnlyRPCCalls(){return this.readonlyRPCCalls}getProvider(){if(this.activeProvider)return this.activeProvider;console.warn("MetaMaskSDK: No active provider found")}getMobileProvider(){if(!this.sdkProvider)throw new Error("SDK state invalid -- undefined mobile provider");return this.sdkProvider}getUniversalLink(){var e;const n=(e=this.remoteConnection)===null||e===void 0?void 0:e.getUniversalLink();if(!n)throw new Error("No Universal Link available, please call eth_requestAccounts first.");return n}getChannelId(){var e,n;return(n=(e=this.remoteConnection)===null||e===void 0?void 0:e.getChannelConfig())===null||n===void 0?void 0:n.channelId}getRPCHistory(){var e,n;return(n=(e=this.remoteConnection)===null||e===void 0?void 0:e.getConnector())===null||n===void 0?void 0:n.getRPCMethodTracker()}getVersion(){return Hn.version}getDappId(){var e,n,r,i;return typeof window>"u"||window.location===void 0?(i=(n=(e=this.options.dappMetadata)===null||e===void 0?void 0:e.name)!==null&&n!==void 0?n:(r=this.options.dappMetadata)===null||r===void 0?void 0:r.url)!==null&&i!==void 0?i:"N/A":window.location.hostname}getAnonId(){var e,n;return Z(this,void 0,void 0,function*(){if(this._anonId)return this._anonId;let r;return r=!((e=this.platformManager)===null||e===void 0)&&e.isBrowser()?this.getBrowserAnonId():!((n=this.platformManager)===null||n===void 0)&&n.isReactNative()?yield this.getReactNativeAnonId():yn(),this._anonId=r,r})}getBrowserAnonId(){const e=this.ANON_ID_STORAGE_KEY;try{const n=localStorage.getItem(e);if(n)return n;const r=yn();return localStorage.setItem(e,r),r}catch(n){return console.error("[MetaMaskSDK: getBrowserAnonId()] LocalStorage access error:",n),yn()}}getReactNativeAnonId(){return Z(this,void 0,void 0,function*(){const e=this.ANON_ID_STORAGE_KEY;try{const n=require("@react-native-async-storage/async-storage").default,r=yield n.getItem(e);if(r)return r;const i=yn();return yield n.setItem(e,i),i}catch(n){return console.error("[MetaMaskSDK: getReactNativeAnonId()] Error accessing AsyncStorage:",n),yn()}})}getWalletStatus(){var e,n;return(n=(e=this.remoteConnection)===null||e===void 0?void 0:e.getConnector())===null||n===void 0?void 0:n.getConnectionStatus()}_getChannelConfig(){var e;return(e=this.remoteConnection)===null||e===void 0?void 0:e.getChannelConfig()}_ping(){var e,n;(n=(e=this.remoteConnection)===null||e===void 0?void 0:e.getConnector())===null||n===void 0||n.ping()}_keyCheck(){var e,n;(n=(e=this.remoteConnection)===null||e===void 0?void 0:e.getConnector())===null||n===void 0||n.keyCheck()}_getServiceStatus(){var e,n;return(n=(e=this.remoteConnection)===null||e===void 0?void 0:e.getConnector())===null||n===void 0?void 0:n.getServiceStatus()}_getRemoteConnection(){return this.remoteConnection}_getDappMetadata(){return this.dappMetadata}_getKeyInfo(){var e;return(e=this.remoteConnection)===null||e===void 0?void 0:e.getKeyInfo()}_resetKeys(){var e,n;(n=(e=this.remoteConnection)===null||e===void 0?void 0:e.getConnector())===null||n===void 0||n.resetKeys()}_getConnection(){return this.remoteConnection}emit(e,n){return super.emit(e,n)}on(e,n){return super.on(e,n)}}var rv=Object.freeze({__proto__:null,StorageManagerWeb:class{constructor({enabled:t}={enabled:!1}){this.enabled=!1,this.enabled=t}persistChannelConfig(t){return Z(this,void 0,void 0,function*(){const e=JSON.stringify(t);W(`[StorageManagerWeb: persistChannelConfig()] enabled=${this.enabled}`,t),localStorage.setItem(Cs,e)})}getPersistedChannelConfig(){return Z(this,void 0,void 0,function*(){let t;try{if(W(`[StorageManagerWeb: getPersistedChannelConfig()] enabled=${this.enabled}`),t=localStorage.getItem(Cs),W("[StorageManagerWeb: getPersistedChannelConfig()]",t),!t)return;const e=JSON.parse(t);return W("[StorageManagerWeb: getPersistedChannelConfig()] channelConfig",e),e}catch(e){return void console.error("[StorageManagerWeb: getPersistedChannelConfig()] Can't find existing channel config",e)}})}persistAccounts(t){return Z(this,void 0,void 0,function*(){W(`[StorageManagerWeb: persistAccounts()] enabled=${this.enabled}`,t);const e=JSON.stringify(t);localStorage.setItem(ua,e)})}getCachedAccounts(){return Z(this,void 0,void 0,function*(){try{const t=localStorage.getItem(ua);return t?JSON.parse(t):[]}catch(t){throw console.error("[StorageManagerWeb: getCachedAccounts()] Error reading cached accounts",t),t}})}persistChainId(t){return Z(this,void 0,void 0,function*(){W(`[StorageManagerWeb: persistChainId()] enabled=${this.enabled}`,t),localStorage.setItem(da,t)})}getCachedChainId(){return Z(this,void 0,void 0,function*(){try{const t=localStorage.getItem(da);return t??void 0}catch(t){throw console.error("[StorageManagerWeb: getCachedChainId()] Error reading cached chainId",t),t}})}terminate(){return Z(this,void 0,void 0,function*(){W(`[StorageManagerWeb: terminate()] enabled=${this.enabled}`),localStorage.removeItem(Cs)})}}});const iv="hydrated",ov=!1,sv=!0;var av=Object.defineProperty,Qa=new WeakMap,En=t=>Qa.get(t),ec=(t,e)=>Qa.set(e.$lazyInstance$=t,e),fu=(t,e)=>e in t,Dn=(t,e)=>(0,console.error)(t,e),ks=new Map,Vi=new Map,Lf="slot-fb{display:contents}slot-fb[hidden]{display:none}",Po=typeof window<"u"?window:{},Dt=Po.document||{head:{}},Ke={$flags$:0,$resourcesUrl$:"",jmp:t=>t(),raf:t=>requestAnimationFrame(t),ael:(t,e,n,r)=>t.addEventListener(e,n,r),rel:(t,e,n,r)=>t.removeEventListener(e,n,r),ce:(t,e)=>new CustomEvent(t,e)},Nf=(()=>{try{return new CSSStyleSheet,typeof new CSSStyleSheet().replaceSync=="function"}catch{}return!1})(),fa=!1,pu=[],Df=[],cv=(t,e)=>n=>{t.push(n),fa||(fa=!0,4&Ke.$flags$?tc(pa):Ke.raf(pa))},mu=t=>{for(let e=0;e<t.length;e++)try{t[e](performance.now())}catch(n){Dn(n)}t.length=0},pa=()=>{mu(pu),mu(Df),(fa=pu.length>0)&&Ke.raf(pa)},tc=t=>(e=>Promise.resolve(e))().then(t),lv=cv(Df),gu={},nc=t=>(t=typeof t)=="object"||t==="function";function Bf(t){var e,n,r;return(r=(n=(e=t.head)==null?void 0:e.querySelector('meta[name="csp-nonce"]'))==null?void 0:n.getAttribute("content"))!=null?r:void 0}((t,e)=>{for(var n in e)av(t,n,{get:e[n],enumerable:!0})})({},{err:()=>$f,map:()=>uv,ok:()=>ma,unwrap:()=>dv,unwrapErr:()=>hv});var ma=t=>({isOk:!0,isErr:!1,value:t}),$f=t=>({isOk:!1,isErr:!0,value:t});function uv(t,e){if(t.isOk){const n=e(t.value);return n instanceof Promise?n.then(r=>ma(r)):ma(n)}if(t.isErr){const n=t.value;return $f(n)}throw"should never get here"}var rc,dv=t=>{if(t.isOk)return t.value;throw t.value},hv=t=>{if(t.isErr)return t.value;throw t.value},Y=(t,e,...n)=>{let r=null,i=!1,o=!1;const a=[],s=l=>{for(let u=0;u<l.length;u++)r=l[u],Array.isArray(r)?s(r):r!=null&&typeof r!="boolean"&&((i=typeof t!="function"&&!nc(r))&&(r=String(r)),i&&o?a[a.length-1].$text$+=r:a.push(i?wo(null,r):r),o=i)};if(s(n),e){const l=e.className||e.class;l&&(e.class=typeof l!="object"?l:Object.keys(l).filter(u=>l[u]).join(" "))}if(typeof t=="function")return t(e===null?{}:e,a,pv);const c=wo(t,null);return c.$attrs$=e,a.length>0&&(c.$children$=a),c},wo=(t,e)=>({$flags$:0,$tag$:t,$text$:e,$elm$:null,$children$:null,$attrs$:null}),fv={},pv={forEach:(t,e)=>t.map(yu).forEach(e),map:(t,e)=>t.map(yu).map(e).map(mv)},yu=t=>({vattrs:t.$attrs$,vchildren:t.$children$,vkey:t.$key$,vname:t.$name$,vtag:t.$tag$,vtext:t.$text$}),mv=t=>{if(typeof t.vtag=="function"){const n={...t.vattrs};return t.vkey&&(n.key=t.vkey),t.vname&&(n.name=t.vname),Y(t.vtag,n,...t.vchildren||[])}const e=wo(t.vtag,t.vtext);return e.$attrs$=t.vattrs,e.$children$=t.vchildren,e.$key$=t.vkey,e.$name$=t.vname,e},Io=t=>En(t).$hostElement$,Cn=(t,e,n)=>{const r=Io(t);return{emit:i=>Kf(r,e,{bubbles:!0,composed:!0,cancelable:!0,detail:i})}},Kf=(t,e,n)=>{const r=Ke.ce(e,n);return t.dispatchEvent(r),r},vu=new WeakMap,gv=t=>{const e=t.$cmpMeta$,n=t.$hostElement$,r=e.$flags$;e.$tagName$;const i=((o,a,s)=>{var c;const l=jf(a),u=Vi.get(l);if(o=o.nodeType===11?o:Dt,u)if(typeof u=="string"){o=o.head||o;let d,h=vu.get(o);if(h||vu.set(o,h=new Set),!h.has(l)){{d=Dt.createElement("style"),d.innerHTML=u;const f=(c=Ke.$nonce$)!=null?c:Bf(Dt);if(f!=null&&d.setAttribute("nonce",f),!(1&a.$flags$))if(o.nodeName==="HEAD"){const g=o.querySelectorAll("link[rel=preconnect]"),m=g.length>0?g[g.length-1].nextSibling:o.querySelector("style");o.insertBefore(d,m)}else if("host"in o)if(Nf){const g=new CSSStyleSheet;g.replaceSync(u),o.adoptedStyleSheets=[g,...o.adoptedStyleSheets]}else{const g=o.querySelector("style");g?g.innerHTML=u+g.innerHTML:o.prepend(d)}else o.append(d);1&a.$flags$&&o.nodeName!=="HEAD"&&o.insertBefore(d,null)}4&a.$flags$&&(d.innerHTML+=Lf),h&&h.add(l)}}else o.adoptedStyleSheets.includes(u)||(o.adoptedStyleSheets=[...o.adoptedStyleSheets,u]);return l})(n.shadowRoot?n.shadowRoot:n.getRootNode(),e);10&r&&2&r&&(n["s-sc"]=i,n.classList.add(i+"-h"))},jf=(t,e)=>"sc-"+t.$tagName$,bu=(t,e,n,r,i,o)=>{if(n!==r){let a=fu(t,e),s=e.toLowerCase();if(e==="class"){const c=t.classList,l=wu(n),u=wu(r);c.remove(...l.filter(d=>d&&!u.includes(d))),c.add(...u.filter(d=>d&&!l.includes(d)))}else if(e==="style"){for(const c in n)r&&r[c]!=null||(c.includes("-")?t.style.removeProperty(c):t.style[c]="");for(const c in r)n&&r[c]===n[c]||(c.includes("-")?t.style.setProperty(c,r[c]):t.style[c]=r[c])}else if(a||e[0]!=="o"||e[1]!=="n"){const c=nc(r);if((a||c&&r!==null)&&!i)try{if(t.tagName.includes("-"))t[e]=r;else{const l=r??"";e==="list"?a=!1:n!=null&&t[e]==l||(typeof t.__lookupSetter__(e)=="function"?t[e]=l:t.setAttribute(e,l))}}catch{}r==null||r===!1?r===!1&&t.getAttribute(e)!==""||t.removeAttribute(e):(!a||4&o||i)&&!c&&(r=r===!0?"":r,t.setAttribute(e,r))}else if(e=e[2]==="-"?e.slice(3):fu(Po,s)?s.slice(2):s[2]+e.slice(3),n||r){const c=e.endsWith(Uf);e=e.replace(vv,""),n&&Ke.rel(t,e,n,c),r&&Ke.ael(t,e,r,c)}}},yv=/\s/,wu=t=>t?t.split(yv):[],Uf="Capture",vv=new RegExp(Uf+"$"),Hf=(t,e,n)=>{const r=e.$elm$.nodeType===11&&e.$elm$.host?e.$elm$.host:e.$elm$,i=t&&t.$attrs$||gu,o=e.$attrs$||gu;for(const a of Eu(Object.keys(i)))a in o||bu(r,a,i[a],void 0,n,e.$flags$);for(const a of Eu(Object.keys(o)))bu(r,a,i[a],o[a],n,e.$flags$)};function Eu(t){return t.includes("ref")?[...t.filter(e=>e!=="ref"),"ref"]:t}var yt=!1,ic=(t,e,n,r)=>{const i=e.$children$[n];let o,a,s=0;if(i.$text$!==null)o=i.$elm$=Dt.createTextNode(i.$text$);else{if(yt||(yt=i.$tag$==="svg"),o=i.$elm$=Dt.createElementNS(yt?"http://www.w3.org/2000/svg":"http://www.w3.org/1999/xhtml",i.$tag$),yt&&i.$tag$==="foreignObject"&&(yt=!1),Hf(null,i,yt),o.getRootNode().querySelector("body"),i.$children$)for(s=0;s<i.$children$.length;++s)a=ic(t,i,s),a&&o.appendChild(a);i.$tag$==="svg"?yt=!1:o.tagName==="foreignObject"&&(yt=!0)}return o["s-hn"]=rc,o},_u=(t,e,n,r,i,o)=>{let a,s=t;for(s.shadowRoot&&s.tagName===rc&&(s=s.shadowRoot);i<=o;++i)r[i]&&(a=ic(null,n,i),a&&(r[i].$elm$=a,Wi(s,a,e)))},Su=(t,e,n)=>{for(let r=e;r<=n;++r){const i=t[r];if(i){const o=i.$elm$;o&&o.remove()}}},Ai=(t,e,n=!1)=>t.$tag$===e.$tag$,kr=(t,e,n=!1)=>{const r=e.$elm$=t.$elm$,i=t.$children$,o=e.$children$,a=e.$tag$,s=e.$text$;s===null?(Hf(t,e,yt=a==="svg"||a!=="foreignObject"&&yt),i!==null&&o!==null?((c,l,u,d,h=!1)=>{let f,g=0,m=0,w=l.length-1,p=l[0],S=l[w],_=d.length-1,O=d[0],I=d[_];for(;g<=w&&m<=_;)p==null?p=l[++g]:S==null?S=l[--w]:O==null?O=d[++m]:I==null?I=d[--_]:Ai(p,O,h)?(kr(p,O,h),p=l[++g],O=d[++m]):Ai(S,I,h)?(kr(S,I,h),S=l[--w],I=d[--_]):Ai(p,I,h)?(kr(p,I,h),Wi(c,p.$elm$,S.$elm$.nextSibling),p=l[++g],I=d[--_]):Ai(S,O,h)?(kr(S,O,h),Wi(c,S.$elm$,p.$elm$),S=l[--w],O=d[++m]):(f=ic(l&&l[m],u,m),O=d[++m],f&&Wi(p.$elm$.parentNode,f,p.$elm$));g>w?_u(c,d[_+1]==null?null:d[_+1].$elm$,u,d,m,_):m>_&&Su(l,g,w)})(r,i,e,o,n):o!==null?(t.$text$!==null&&(r.textContent=""),_u(r,null,e,o,0,o.length-1)):!n&&sv&&i!==null&&Su(i,0,i.length-1),yt&&a==="svg"&&(yt=!1)):t.$text$!==s&&(r.data=s)},Wi=(t,e,n)=>t==null?void 0:t.insertBefore(e,n),bv=(t,e,n=!1)=>{const r=t.$hostElement$,i=t.$cmpMeta$,o=t.$vnode$||wo(null,null),a=(s=e)&&s.$tag$===fv?e:Y(null,null,e);var s;if(rc=r.tagName,n&&a.$attrs$)for(const c of Object.keys(a.$attrs$))r.hasAttribute(c)&&!["key","ref","style","class"].includes(c)&&(a.$attrs$[c]=r[c]);a.$tag$=null,a.$flags$|=4,t.$vnode$=a,a.$elm$=o.$elm$=r.shadowRoot||r,r["s-sc"],1&i.$flags$,kr(o,a,n)},Ff=(t,e)=>{e&&!t.$onRenderResolve$&&e["s-p"]&&e["s-p"].push(new Promise(n=>t.$onRenderResolve$=n))},oc=(t,e)=>(t.$flags$|=16,4&t.$flags$?void(t.$flags$|=512):(Ff(t,t.$ancestorComponent$),lv(()=>wv(t,e)))),wv=(t,e)=>{const n=t.$hostElement$;t.$cmpMeta$.$tagName$;const r=t.$lazyInstance$;if(!r)throw new Error(`Can't render component <${n.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`);return Ev(void 0,()=>Sv(t,r,e))},Ev=(t,e)=>_v(t)?t.then(e).catch(n=>{console.error(n),e()}):e(),_v=t=>t instanceof Promise||t&&t.then&&typeof t.then=="function",Sv=async(t,e,n)=>{var r;const i=t.$hostElement$;t.$cmpMeta$.$tagName$;const o=i["s-rc"];n&&gv(t),t.$cmpMeta$.$tagName$,Cv(t,e,i,n),o&&(o.map(a=>a()),i["s-rc"]=void 0);{const a=(r=i["s-p"])!=null?r:[],s=()=>kv(t);a.length===0?s():(Promise.all(a).then(s),t.$flags$|=4,a.length=0)}},Cv=(t,e,n,r)=>{try{e=e.render(),t.$flags$&=-17,t.$flags$|=2,bv(t,e,r)}catch(i){Dn(i,t.$hostElement$)}return null},kv=t=>{t.$cmpMeta$.$tagName$;const e=t.$hostElement$,n=()=>{},r=t.$lazyInstance$,i=t.$ancestorComponent$;64&t.$flags$?n():(t.$flags$|=64,qf(e),sc(r,"componentDidLoad"),t.$onReadyResolve$(e),i||zf()),t.$onRenderResolve$&&(t.$onRenderResolve$(),t.$onRenderResolve$=void 0),512&t.$flags$&&tc(()=>oc(t,!1)),t.$flags$&=-517},zf=t=>{qf(Dt.documentElement),tc(()=>Kf(Po,"appload",{detail:{namespace:"sdk-install-modal-web"}}))},sc=(t,e,n)=>{if(t&&t[e])try{return t[e](n)}catch(r){Dn(r)}},qf=t=>{var e;return t.classList.add((e=iv)!=null?e:"hydrated")},Av=(t,e,n,r)=>{const i=En(t);if(!i)throw new Error(`Couldn't find host element for "${r.$tagName$}" as it is unknown to this Stencil runtime. This usually happens when integrating a 3rd party Stencil component with another Stencil component or application. Please reach out to the maintainers of the 3rd party Stencil component or report this on the Stencil Discord server (https://chat.stenciljs.com) or comment on this similar [GitHub issue](https://github.com/ionic-team/stencil/issues/5457).`);const o=i.$hostElement$,a=i.$instanceValues$.get(e),s=i.$flags$,c=i.$lazyInstance$;var l,u;l=n,u=r.$members$[e][0],n=l==null||nc(l)?l:4&u?l!=="false"&&(l===""||!!l):1&u?String(l):l;const d=Number.isNaN(a)&&Number.isNaN(n);if((!(8&s)||a===void 0)&&n!==a&&!d&&(i.$instanceValues$.set(e,n),c)){if(r.$watchers$&&128&s){const h=r.$watchers$[e];h&&h.map(f=>{try{c[f](n,a,e)}catch(g){Dn(g,o)}})}(18&s)==2&&oc(i,!1)}},Vf=(t,e,n)=>{var r,i;const o=t.prototype;if(e.$members$||e.$watchers$||t.watchers){t.watchers&&!e.$watchers$&&(e.$watchers$=t.watchers);const a=Object.entries((r=e.$members$)!=null?r:{});if(a.map(([s,[c]])=>{(31&c||2&n&&32&c)&&Object.defineProperty(o,s,{get(){return l=s,En(this).$instanceValues$.get(l);var l},set(l){Av(this,s,l,e)},configurable:!0,enumerable:!0})}),1&n){const s=new Map;o.attributeChangedCallback=function(c,l,u){Ke.jmp(()=>{var d;const h=s.get(c);if(this.hasOwnProperty(h))u=this[h],delete this[h];else{if(o.hasOwnProperty(h)&&typeof this[h]=="number"&&this[h]==u)return;if(h==null){const f=En(this),g=f==null?void 0:f.$flags$;if(g&&!(8&g)&&128&g&&u!==l){const m=f.$lazyInstance$,w=(d=e.$watchers$)==null?void 0:d[c];w==null||w.forEach(p=>{m[p]!=null&&m[p].call(m,u,l,c)})}return}}this[h]=(u!==null||typeof this[h]!="boolean")&&u})},t.observedAttributes=Array.from(new Set([...Object.keys((i=e.$watchers$)!=null?i:{}),...a.filter(([c,l])=>15&l[0]).map(([c,l])=>{const u=l[1]||c;return s.set(u,c),u})]))}}return t},xv=async(t,e,n,r)=>{let i;if(!(32&e.$flags$)){if(e.$flags$|=32,n.$lazyBundleId$){const s=((c,l,u)=>{const d=c.$tagName$.replace(/-/g,"_"),h=c.$lazyBundleId$;if(!h)return;const f=ks.get(h);if(f)return f[d];{const g=m=>(ks.set(h,m),m[d]);if(h==="mm-install-modal_3")return Promise.resolve().then(function(){return Hv}).then(g,Dn)}return sp(()=>import(`./${h}.entry.js`),[]).then(g=>(ks.set(h,g),g[d]),Dn)})(n);if(s&&"then"in s?i=await s:i=s,!i)throw new Error(`Constructor for "${n.$tagName$}#${e.$modeName$}" was not found`);i.isProxied||(n.$watchers$=i.watchers,Vf(i,n,2),i.isProxied=!0),n.$tagName$,e.$flags$|=8;try{new i(e)}catch(c){Dn(c)}e.$flags$&=-9,e.$flags$|=128,ga(e.$lazyInstance$)}else{i=t.constructor;const s=t.localName;customElements.whenDefined(s).then(()=>e.$flags$|=128)}if(i&&i.style){let s;typeof i.style=="string"&&(s=i.style);const c=jf(n);Vi.has(c)||(n.$tagName$,((l,u,d)=>{let h=Vi.get(l);Nf&&d?(h=h||new CSSStyleSheet,typeof h=="string"?h=u:h.replaceSync(u)):h=u,Vi.set(l,h)})(c,s,!!(1&n.$flags$)))}}const o=e.$ancestorComponent$,a=()=>oc(e,!0);o&&o["s-rc"]?o["s-rc"].push(a):a()},ga=t=>{sc(t,"connectedCallback")},Cu=t=>{sc(t,"disconnectedCallback")},Tv=(t,e={})=>{var n;const r=[],i=e.exclude||[],o=Po.customElements,a=Dt.head,s=a.querySelector("meta[charset]"),c=Dt.createElement("style"),l=[];let u,d=!0;Object.assign(Ke,e),Ke.$resourcesUrl$=new URL(e.resourcesUrl||"./",Dt.baseURI).href;let h=!1;if(t.map(f=>{f[1].map(g=>{var m;const w={$flags$:g[0],$tagName$:g[1],$members$:g[2],$listeners$:g[3]};4&w.$flags$&&(h=!0),w.$members$=g[2],w.$watchers$=(m=g[4])!=null?m:{};const p=w.$tagName$,S=class extends HTMLElement{constructor(_){if(super(_),this.hasRegisteredEventListeners=!1,((O,I)=>{const K={$flags$:0,$hostElement$:O,$cmpMeta$:I,$instanceValues$:new Map};K.$onReadyPromise$=new Promise(q=>K.$onReadyResolve$=q),O["s-p"]=[],O["s-rc"]=[],Qa.set(O,K)})(_=this,w),1&w.$flags$)if(_.shadowRoot){if(_.shadowRoot.mode!=="open")throw new Error(`Unable to re-use existing shadow root for ${w.$tagName$}! Mode is set to ${_.shadowRoot.mode} but Stencil only supports open shadow roots.`)}else _.attachShadow({mode:"open"})}connectedCallback(){En(this),this.hasRegisteredEventListeners||(this.hasRegisteredEventListeners=!0),u&&(clearTimeout(u),u=null),d?l.push(this):Ke.jmp(()=>(_=>{if(!(1&Ke.$flags$)){const O=En(_),I=O.$cmpMeta$;if(I.$tagName$,1&O.$flags$)O!=null&&O.$lazyInstance$?ga(O.$lazyInstance$):O!=null&&O.$onReadyPromise$&&O.$onReadyPromise$.then(()=>ga(O.$lazyInstance$));else{O.$flags$|=1;{let K=_;for(;K=K.parentNode||K.host;)if(K["s-p"]){Ff(O,O.$ancestorComponent$=K);break}}I.$members$&&Object.entries(I.$members$).map(([K,[q]])=>{if(31&q&&_.hasOwnProperty(K)){const F=_[K];delete _[K],_[K]=F}}),xv(_,O,I)}}})(this))}disconnectedCallback(){Ke.jmp(()=>(async _=>{if(!(1&Ke.$flags$)){const O=En(_);O!=null&&O.$lazyInstance$?Cu(O.$lazyInstance$):O!=null&&O.$onReadyPromise$&&O.$onReadyPromise$.then(()=>Cu(O.$lazyInstance$))}})(this))}componentOnReady(){return En(this).$onReadyPromise$}};w.$lazyBundleId$=f[0],i.includes(p)||o.get(p)||(r.push(p),o.define(p,Vf(S,w,1)))})}),r.length>0&&(h&&(c.textContent+=Lf),c.textContent+=r.sort()+"{visibility:hidden}.hydrated{visibility:inherit}",c.innerHTML.length)){c.setAttribute("data-styles","");const f=(n=Ke.$nonce$)!=null?n:Bf(Dt);f!=null&&c.setAttribute("nonce",f),a.insertBefore(c,s?s.nextSibling:a.firstChild)}d=!1,l.length?l.map(f=>f.connectedCallback()):Ke.jmp(()=>u=setTimeout(zf,30))};(function(){if(typeof window<"u"&&window.Reflect!==void 0&&window.customElements!==void 0){var t=HTMLElement;window.HTMLElement=function(){return Reflect.construct(t,[],this.constructor)},HTMLElement.prototype=t.prototype,HTMLElement.prototype.constructor=HTMLElement,Object.setPrototypeOf(HTMLElement,t)}})();var Mv=Object.freeze({__proto__:null,defineCustomElements:async(t,e)=>{if(typeof window<"u")return await void 0,Tv([["mm-install-modal_3",[[1,"mm-install-modal",{link:[1],sdkVersion:[1,"sdk-version"],preferDesktop:[4,"prefer-desktop"],tab:[32],isDefaultTab:[32],translationsLoaded:[32]},null,{preferDesktop:["updatePreferDesktop"]}],[1,"mm-pending-modal",{displayOTP:[4,"display-o-t-p"],sdkVersion:[1,"sdk-version"],otpCode:[1,"otp-code"],translationsLoaded:[32]}],[1,"mm-select-modal",{link:[1],sdkVersion:[1,"sdk-version"],preferDesktop:[4,"prefer-desktop"],tab:[32],isDefaultTab:[32],translationsLoaded:[32]},null,{preferDesktop:["updatePreferDesktop"]}]]]],e)},setNonce:t=>Ke.$nonce$=t});const Rv={fontFamily:"Roboto, sans-serif"},ac=({className:t},e)=>Y("div",{style:Rv,class:t},e),As=({Icon:t,text:e})=>Y("div",{class:"flexContainer",style:{padding:"6",flexDirection:"row"}},Y("div",{class:"flexItem1"},Y(t,null)),Y("div",{class:"flexItem11"},Y("span",{style:{lineHeight:"2",color:"black"}},e))),Ov=()=>Y("svg",{width:"20",height:"18",viewBox:"0 0 20 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Y("path",{d:"M20.0002 7.9702V10.0302C20.0002 10.5802 19.5602 11.0302 19.0002 11.0502H17.0402C15.9602 11.0502 14.9702 10.2602 14.8802 9.1802C14.8202 8.5502 15.0602 7.9602 15.4802 7.5502C15.8502 7.1702 16.3602 6.9502 16.9202 6.9502H19.0002C19.5602 6.9702 20.0002 7.4202 20.0002 7.9702Z",fill:"#037DD6"}),Y("path",{d:"M18.47 12.55H17.04C15.14 12.55 13.54 11.12 13.38 9.3C13.29 8.26 13.67 7.22 14.43 6.48C15.07 5.82 15.96 5.45 16.92 5.45H18.47C18.76 5.45 19 5.21 18.97 4.92C18.75 2.49 17.14 0.83 14.75 0.55C14.51 0.51 14.26 0.5 14 0.5H5C4.72 0.5 4.45 0.52 4.19 0.56C1.64 0.88 0 2.78 0 5.5V12.5C0 15.26 2.24 17.5 5 17.5H14C16.8 17.5 18.73 15.75 18.97 13.08C19 12.79 18.76 12.55 18.47 12.55ZM11 6.75H5C4.59 6.75 4.25 6.41 4.25 6C4.25 5.59 4.59 5.25 5 5.25H11C11.41 5.25 11.75 5.59 11.75 6C11.75 6.41 11.41 6.75 11 6.75Z",fill:"#037DD6"})),Pv=()=>Y("svg",{width:"20",height:"18",viewBox:"0 0 20 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Y("path",{d:"M14.44 0.0999756C12.63 0.0999756 11.01 0.979976 10 2.32998C8.99 0.979976 7.37 0.0999756 5.56 0.0999756C2.49 0.0999756 0 2.59998 0 5.68998C0 6.87998 0.19 7.97998 0.52 8.99998C2.1 14 6.97 16.99 9.38 17.81C9.72 17.93 10.28 17.93 10.62 17.81C13.03 16.99 17.9 14 19.48 8.99998C19.81 7.97998 20 6.87998 20 5.68998C20 2.59998 17.51 0.0999756 14.44 0.0999756Z",fill:"#037DD6"})),Iv=()=>Y("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Y("path",{d:"M16.28 7.53V6.28C16.28 3.58 15.63 0 10 0C4.37 0 3.72 3.58 3.72 6.28V7.53C0.92 7.88 0 9.3 0 12.79V14.65C0 18.75 1.25 20 5.35 20H14.65C18.75 20 20 18.75 20 14.65V12.79C20 9.3 19.08 7.88 16.28 7.53ZM10 16.74C8.33 16.74 6.98 15.38 6.98 13.72C6.98 12.05 8.34 10.7 10 10.7C11.66 10.7 13.02 12.06 13.02 13.72C13.02 15.39 11.67 16.74 10 16.74ZM5.35 7.44C5.27 7.44 5.2 7.44 5.12 7.44V6.28C5.12 3.35 5.95 1.4 10 1.4C14.05 1.4 14.88 3.35 14.88 6.28V7.45C14.8 7.45 14.73 7.45 14.65 7.45H5.35V7.44Z",fill:"#037DD6"})),Lv=()=>Y("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Y("path",{d:"M16.4405 8.8999C20.0405 9.2099 21.5105 11.0599 21.5105 15.1099V15.2399C21.5105 19.7099 19.7205 21.4999 15.2505 21.4999H8.74047C4.27047 21.4999 2.48047 19.7099 2.48047 15.2399V15.1099C2.48047 11.0899 3.93047 9.2399 7.47047 8.9099",stroke:"white","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),Y("path",{d:"M12 2V14.88",stroke:"white","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),Y("path",{d:"M15.3504 12.6499L12.0004 15.9999L8.65039 12.6499",stroke:"white","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}));function cc({version:t}){return Y("div",{style:{textAlign:"center",color:"#BBC0C5",fontSize:"12"}},"SDK Version ",t?`v${t}`:"unknown")}const lc=()=>Y("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Y("rect",{width:"16",height:"16",fill:"white"}),Y("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2.40554 2.40554C2.94627 1.86482 3.82296 1.86482 4.36369 2.40554L8 6.04186L11.6363 2.40554C12.177 1.86482 13.0537 1.86482 13.5945 2.40554C14.1352 2.94627 14.1352 3.82296 13.5945 4.36369L9.95814 8L13.5945 11.6363C14.1352 12.177 14.1352 13.0537 13.5945 13.5945C13.0537 14.1352 12.177 14.1352 11.6363 13.5945L8 9.95814L4.36369 13.5945C3.82296 14.1352 2.94627 14.1352 2.40554 13.5945C1.86482 13.0537 1.86482 12.177 2.40554 11.6363L6.04186 8L2.40554 4.36369C1.86482 3.82296 1.86482 2.94627 2.40554 2.40554Z",fill:"#BBC0C5"})),uc=()=>Y("svg",{width:"120",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 127 63"},Y("path",{fill:"currentColor",d:"M71.554 48.607v13.81h-7.072v-9.568l-8.059.945c-1.77.205-2.548.79-2.548 1.864 0 1.575 1.478 2.239 4.648 2.239 1.932 0 4.073-.29 5.963-.79l-3.66 5.225c-1.479.332-2.92.496-4.44.496-6.414 0-10.074-2.57-10.074-7.132 0-4.023 2.877-6.136 9.416-6.884l8.638-1.012c-.467-2.532-2.362-3.633-6.13-3.633-3.537 0-7.443.912-10.937 2.613l1.111-6.18c3.248-1.369 6.95-2.074 10.69-2.074 8.226 0 12.461 3.444 12.461 10.075l-.008.005ZM7.938 31.315.208 62.416h7.73l3.836-15.628 6.65 8.039h8.06l6.65-8.039 3.836 15.628h7.73l-7.73-31.105-14.518 17.388L7.934 31.311l.004.004ZM36.97.21 22.452 17.598 7.938.21.208 31.315h7.73l3.836-15.628 6.65 8.039h8.06l6.65-8.039 3.836 15.628h7.73L36.97.21Zm53.17 48.107-6.25-.912c-1.562-.247-2.178-.747-2.178-1.617 0-1.41 1.52-2.032 4.647-2.032 3.62 0 6.868.747 10.283 2.364l-.862-6.094c-2.757-.995-5.922-1.491-9.212-1.491-7.688 0-11.886 2.696-11.886 7.547 0 3.776 2.303 5.889 7.196 6.636l6.335.954c1.603.248 2.261.87 2.261 1.865 0 1.41-1.478 2.074-4.481 2.074-3.948 0-8.225-.953-11.72-2.654l.7 6.094c3.003 1.122 6.91 1.785 10.57 1.785 7.896 0 12.007-2.78 12.007-7.715 0-3.94-2.303-6.057-7.4-6.8l-.01-.004ZM100.3 34.09v28.325h7.071V34.091H100.3Zm15.334 15.595 9.833-10.744h-8.8l-9.296 11.114 9.912 12.356h8.925l-10.574-12.73v.004Zm-16.321-25.09c0 4.56 3.66 7.13 10.074 7.13 1.52 0 2.961-.167 4.44-.495l3.66-5.225c-1.89.496-4.031.79-5.963.79-3.166 0-4.648-.664-4.648-2.239 0-1.079.783-1.659 2.549-1.864l8.058-.945v9.567h7.072v-13.81c0-6.635-4.236-10.075-12.461-10.075-3.744 0-7.442.705-10.691 2.075l-1.112 6.178c3.495-1.701 7.401-2.613 10.937-2.613 3.769 0 5.664 1.1 6.13 3.633l-8.637 1.013c-6.539.747-9.417 2.86-9.417 6.883l.009-.004Zm-19.779-1.492c0 5.725 3.29 8.627 9.787 8.627 2.59 0 4.732-.416 6.785-1.37l.903-6.261c-1.974 1.2-3.99 1.822-6.005 1.822-3.044 0-4.402-1.243-4.402-4.023v-8.295h10.732V7.84H86.601V2.948l-13.448 7.174v3.482h6.372V23.1l.008.004Zm-6.95-2.612v1.411H53.47c.862 2.873 3.423 4.187 7.97 4.187 3.62 0 6.993-.747 9.992-2.196l-.862 6.056c-2.757 1.16-6.251 1.785-9.829 1.785-9.5 0-14.68-4.23-14.68-12.066 0-7.838 5.264-12.235 13.406-12.235s13.119 4.771 13.119 13.062l-.005-.004ZM53.378 17.09h12.086c-.637-2.751-2.732-4.188-6.08-4.188-3.349 0-5.335 1.399-6.006 4.188Z"}));function Mn(t,e){return t.toString(2).padStart(e,"0")}function ku(t,e){const n=t%e;return n>=0?n:e+n}function ct(t,e){return new Array(t).fill(e)}function Au(...t){let e=0;for(const r of t)e=Math.max(e,r.length);const n=[];for(let r=0;r<e;r++)for(const i of t)r>=i.length||n.push(i[r]);return new Uint8Array(n)}function xu(t,e,n){if(n<0||n+e.length>t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[n+r])return!1;return!0}function Tu(t){return{has:e=>t.includes(e),decode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="string")throw new Error("alphabet.decode input should be array of strings");return e.map(n=>{if(typeof n!="string")throw new Error(`alphabet.decode: not string element=${n}`);const r=t.indexOf(n);if(r===-1)throw new Error(`Unknown letter: "${n}". Allowed: ${t}`);return r})},encode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return e.map(n=>{if(function(r){if(!Number.isSafeInteger(r))throw new Error(`Wrong integer: ${r}`)}(n),n<0||n>=t.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${t.length})`);return t[n]})}}}class st{static size(e,n){if(typeof e=="number"&&(e={height:e,width:e}),!Number.isSafeInteger(e.height)&&e.height!==1/0)throw new Error(`Bitmap: wrong height=${e.height} (${typeof e.height})`);if(!Number.isSafeInteger(e.width)&&e.width!==1/0)throw new Error(`Bitmap: wrong width=${e.width} (${typeof e.width})`);return n!==void 0&&(e={width:Math.min(e.width,n.width),height:Math.min(e.height,n.height)}),e}static fromString(e){const n=(e=e.replace(/^\n+/g,"").replace(/\n+$/g,"")).split(`
35
+ `),r=n.length,i=new Array(r);let o;for(const a of n){const s=a.split("").map(c=>{if(c==="X")return!0;if(c===" ")return!1;if(c!=="?")throw new Error(`Bitmap.fromString: unknown symbol=${c}`)});if(o&&s.length!==o)throw new Error(`Bitmap.fromString different row sizes: width=${o} cur=${s.length}`);o=s.length,i.push(s)}return o||(o=0),new st({height:r,width:o},i)}constructor(e,n){const{height:r,width:i}=st.size(e);this.data=n||Array.from({length:r},()=>ct(i,void 0)),this.height=r,this.width=i}point(e){return this.data[e.y][e.x]}isInside(e){return 0<=e.x&&e.x<this.width&&0<=e.y&&e.y<this.height}size(e){if(!e)return{height:this.height,width:this.width};const{x:n,y:r}=this.xy(e);return{height:this.height-r,width:this.width-n}}xy(e){if(typeof e=="number"&&(e={x:e,y:e}),!Number.isSafeInteger(e.x))throw new Error(`Bitmap: wrong x=${e.x}`);if(!Number.isSafeInteger(e.y))throw new Error(`Bitmap: wrong y=${e.y}`);return e.x=ku(e.x,this.width),e.y=ku(e.y,this.height),e}rect(e,n,r){const{x:i,y:o}=this.xy(e),{height:a,width:s}=st.size(n,this.size({x:i,y:o}));for(let c=0;c<a;c++)for(let l=0;l<s;l++)this.data[o+c][i+l]=typeof r=="function"?r({x:l,y:c},this.data[o+c][i+l]):r;return this}rectRead(e,n,r){return this.rect(e,n,(i,o)=>(r(i,o),o))}hLine(e,n,r){return this.rect(e,{width:n,height:1},r)}vLine(e,n,r){return this.rect(e,{width:1,height:n},r)}border(e=2,n){const r=this.height+2*e,i=this.width+2*e,o=ct(e,n),a=Array.from({length:e},()=>ct(i,n));return new st({height:r,width:i},[...a,...this.data.map(s=>[...o,...s,...o]),...a])}embed(e,n){return this.rect(e,n.size(),({x:r,y:i})=>n.data[i][r])}rectSlice(e,n=this.size()){const r=new st(st.size(n,this.size(this.xy(e))));return this.rect(e,n,({x:i,y:o},a)=>r.data[o][i]=a),r}inverse(){const{height:e,width:n}=this;return new st({height:n,width:e}).rect({x:0,y:0},1/0,({x:r,y:i})=>this.data[r][i])}scale(e){if(!Number.isSafeInteger(e)||e>1024)throw new Error(`Wrong scale factor: ${e}`);const{height:n,width:r}=this;return new st({height:e*n,width:e*r}).rect({x:0,y:0},1/0,({x:i,y:o})=>this.data[Math.floor(o/e)][Math.floor(i/e)])}clone(){return new st(this.size()).rect({x:0,y:0},this.size(),({x:e,y:n})=>this.data[n][e])}assertDrawn(){this.rectRead(0,1/0,(e,n)=>{if(typeof n!="boolean")throw new Error("Invalid color type="+typeof n)})}toString(){return this.data.map(e=>e.map(n=>n===void 0?"?":n?"X":" ").join("")).join(`
36
+ `)}toASCII(){const{height:e,width:n,data:r}=this;let i="";for(let o=0;o<e;o+=2){for(let a=0;a<n;a++){const s=r[o][a],c=o+1>=e||r[o+1][a];s||c?!s&&c?i+="▀":s&&!c?i+="▄":s&&c&&(i+=" "):i+="█"}i+=`
37
+ `}return i}toTerm(){const e="\x1B[0m",n=`\x1B[1;47m ${e}`,r=`\x1B[40m ${e}`;return this.data.map(i=>i.map(o=>o?r:n).join("")).join(`
38
+ `)}toSVG(){let e=`<svg xmlns:svg="http://www.w3.org/2000/svg" viewBox="0 0 ${this.width} ${this.height}" version="1.1" xmlns="http://www.w3.org/2000/svg">`;return this.rectRead(0,1/0,({x:n,y:r},i)=>{i&&(e+=`<rect x="${n}" y="${r}" width="1" height="1" />`)}),e+="</svg>",e}toGIF(){const e=s=>[255&s,s>>>8&255],n=[...e(this.width),...e(this.height)],r=[];this.rectRead(0,1/0,(s,c)=>r.push(+(c===!0)));const i=126,o=[71,73,70,56,55,97,...n,246,0,0,255,255,255,...ct(381,0),44,0,0,0,0,...n,0,7],a=Math.floor(r.length/i);for(let s=0;s<a;s++)o.push(127,128,...r.slice(i*s,i*(s+1)).map(c=>+c));return o.push(r.length%i+1,128,...r.slice(a*i).map(s=>+s)),o.push(1,129,0,59),new Uint8Array(o)}toImage(e=!1){const{height:n,width:r}=this.size(),i=new Uint8Array(n*r*(e?3:4));let o=0;for(let a=0;a<n;a++)for(let s=0;s<r;s++){const c=this.data[a][s]?0:255;i[o++]=c,i[o++]=c,i[o++]=c,e||(i[o++]=255)}return{height:n,width:r,data:i}}}const Mu=["low","medium","quartile","high"],Ru=["numeric","alphanumeric","byte","kanji","eci"],Nv=[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],Dv={low:[7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],medium:[10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],quartile:[13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],high:[17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]},Bv={low:[1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],medium:[1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],quartile:[1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],high:[1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]},Ve={size:{encode:t=>21+4*(t-1),decode:t=>(t-17)/4},sizeType:t=>Math.floor((t+7)/17),alignmentPatterns(t){if(t===1)return[];const e=Ve.size.encode(t)-6-1,n=e-6,r=Math.ceil(n/28);let i=Math.floor(n/r);i%2?i+=1:n%r*2>=r&&(i+=2);const o=[6];for(let a=1;a<r;a++)o.push(e-(r-a)*i);return o.push(e),o},ECCode:{low:1,medium:0,quartile:3,high:2},formatMask:21522,formatBits(t,e){const n=Ve.ECCode[t]<<3|e;let r=n;for(let i=0;i<10;i++)r=r<<1^1335*(r>>9);return(n<<10|r)^Ve.formatMask},versionBits(t){let e=t;for(let n=0;n<12;n++)e=e<<1^7973*(e>>11);return t<<12|e},alphabet:{numeric:Tu("0123456789"),alphanumerc:Tu("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:")},lengthBits:(t,e)=>({numeric:[10,12,14],alphanumeric:[9,11,13],byte:[8,16,16],kanji:[8,10,12],eci:[0,0,0]})[e][Ve.sizeType(t)],modeBits:{numeric:"0001",alphanumeric:"0010",byte:"0100",kanji:"1000",eci:"0111"},capacity(t,e){const n=Nv[t-1],r=Dv[e][t-1],i=Bv[e][t-1],o=Math.floor(n/i)-r,a=i-n%i;return{words:r,numBlocks:i,shortBlocks:a,blockLen:o,capacity:8*(n-r*i),total:(r+o)*i+i-a}}},ya=[(t,e)=>(t+e)%2==0,(t,e)=>e%2==0,(t,e)=>t%3==0,(t,e)=>(t+e)%3==0,(t,e)=>(Math.floor(e/2)+Math.floor(t/3))%2==0,(t,e)=>t*e%2+t*e%3==0,(t,e)=>(t*e%2+t*e%3)%2==0,(t,e)=>((t+e)%2+t*e%3)%2==0],oe={tables:(t=>{const e=ct(256,0),n=ct(256,0);for(let r=0,i=1;r<256;r++)e[r]=i,n[i]=r,i<<=1,256&i&&(i^=285);return{exp:e,log:n}})(),exp:t=>oe.tables.exp[t],log(t){if(t===0)throw new Error(`GF.log: wrong arg=${t}`);return oe.tables.log[t]%255},mul:(t,e)=>t===0||e===0?0:oe.tables.exp[(oe.tables.log[t]+oe.tables.log[e])%255],add:(t,e)=>t^e,pow:(t,e)=>oe.tables.exp[oe.tables.log[t]*e%255],inv(t){if(t===0)throw new Error(`GF.inverse: wrong arg=${t}`);return oe.tables.exp[255-oe.tables.log[t]]},polynomial(t){if(t.length==0)throw new Error("GF.polymomial: wrong length");if(t[0]!==0)return t;let e=0;for(;e<t.length-1&&t[e]==0;e++);return t.slice(e)},monomial(t,e){if(t<0)throw new Error(`GF.monomial: wrong degree=${t}`);if(e==0)return[0];let n=ct(t+1,0);return n[0]=e,oe.polynomial(n)},degree:t=>t.length-1,coefficient:(t,e)=>t[oe.degree(t)-e],mulPoly(t,e){if(t[0]===0||e[0]===0)return[0];const n=ct(t.length+e.length-1,0);for(let r=0;r<t.length;r++)for(let i=0;i<e.length;i++)n[r+i]=oe.add(n[r+i],oe.mul(t[r],e[i]));return oe.polynomial(n)},mulPolyScalar(t,e){if(e==0)return[0];if(e==1)return t;const n=ct(t.length,0);for(let r=0;r<t.length;r++)n[r]=oe.mul(t[r],e);return oe.polynomial(n)},mulPolyMonomial(t,e,n){if(e<0)throw new Error("GF.mulPolyMonomial: wrong degree");if(n==0)return[0];const r=ct(t.length+e,0);for(let i=0;i<t.length;i++)r[i]=oe.mul(t[i],n);return oe.polynomial(r)},addPoly(t,e){if(t[0]===0)return e;if(e[0]===0)return t;let n=t,r=e;n.length>r.length&&([n,r]=[r,n]);let i=ct(r.length,0),o=r.length-n.length,a=r.slice(0,o);for(let s=0;s<a.length;s++)i[s]=a[s];for(let s=o;s<r.length;s++)i[s]=oe.add(n[s-o],r[s]);return oe.polynomial(i)},remainderPoly(t,e){const n=Array.from(t);for(let r=0;r<t.length-e.length+1;r++){const i=n[r];if(i!==0)for(let o=1;o<e.length;o++)e[o]!==0&&(n[r+o]=oe.add(n[r+o],oe.mul(e[o],i)))}return n.slice(t.length-e.length+1,n.length)},divisorPoly(t){let e=[1];for(let n=0;n<t;n++)e=oe.mulPoly(e,[1,oe.pow(2,n)]);return e},evalPoly(t,e){if(e==0)return oe.coefficient(t,0);let n=t[0];for(let r=1;r<t.length;r++)n=oe.add(oe.mul(e,n),t[r]);return n},euclidian(t,e,n){oe.degree(t)<oe.degree(e)&&([t,e]=[e,t]);let r=t,i=e,o=[0],a=[1];for(;2*oe.degree(i)>=n;){let l=r,u=o;if(r=i,o=a,r[0]===0)throw new Error("rLast[0] === 0");i=l;let d=[0];const h=oe.inv(r[0]);for(;oe.degree(i)>=oe.degree(r)&&i[0]!==0;){const f=oe.degree(i)-oe.degree(r),g=oe.mul(i[0],h);d=oe.addPoly(d,oe.monomial(f,g)),i=oe.addPoly(i,oe.mulPolyMonomial(r,f,g))}if(d=oe.mulPoly(d,o),a=oe.addPoly(d,u),oe.degree(i)>=oe.degree(r))throw new Error(`Division failed r: ${i}, rLast: ${r}`)}const s=oe.coefficient(a,0);if(s==0)throw new Error("sigmaTilde(0) was zero");const c=oe.inv(s);return[oe.mulPolyScalar(a,c),oe.mulPolyScalar(i,c)]}};function $v(t,e){const{words:n,shortBlocks:r,numBlocks:i,blockLen:o,total:a}=Ve.capacity(t,e),s=(c=n,{encode(l){const u=oe.divisorPoly(c),d=Array.from(l);return d.push(...u.slice(0,-1).fill(0)),Uint8Array.from(oe.remainderPoly(d,u))},decode(l){const u=l.slice(),d=oe.polynomial(Array.from(l));let h=ct(c,0),f=!1;for(let _=0;_<c;_++){const O=oe.evalPoly(d,oe.exp(_));h[h.length-1-_]=O,O!==0&&(f=!0)}if(!f)return u;h=oe.polynomial(h);const g=oe.monomial(c,1),[m,w]=oe.euclidian(g,h,c),p=ct(oe.degree(m),0);let S=0;for(let _=1;_<256&&S<p.length;_++)oe.evalPoly(m,_)===0&&(p[S++]=oe.inv(_));if(S!==p.length)throw new Error("RS.decode: wrong errors number");for(let _=0;_<p.length;_++){const O=u.length-1-oe.log(p[_]);if(O<0)throw new Error("RS.decode: wrong error location");const I=oe.inv(p[_]);let K=1;for(let q=0;q<p.length;q++)_!==q&&(K=oe.mul(K,oe.add(1,oe.mul(p[q],I))));u[O]=oe.add(u[O],oe.mul(oe.evalPoly(w,I),oe.inv(K)))}return u}});var c;return{encode(l){const u=[],d=[];for(let m=0;m<i;m++){const w=o+(m<r?0:1);u.push(l.subarray(0,w)),d.push(s.encode(l.subarray(0,w))),l=l.subarray(w)}const h=Au(...u),f=Au(...d),g=new Uint8Array(h.length+f.length);return g.set(h),g.set(f,h.length),g},decode(l){if(l.length!==a)throw new Error(`interleave.decode: len(data)=${l.length}, total=${a}`);const u=[];for(let f=0;f<i;f++){const g=f<r;u.push(new Uint8Array(n+o+(g?0:1)))}let d=0;for(let f=0;f<o;f++)for(let g=0;g<i;g++)u[g][f]=l[d++];for(let f=r;f<i;f++)u[f][o]=l[d++];for(let f=o;f<o+n;f++)for(let g=0;g<i;g++){const m=g<r;u[g][f+(m?0:1)]=l[d++]}const h=[];for(const f of u)h.push(...Array.from(s.decode(f)).slice(0,-n));return Uint8Array.from(h)}}}function Ou(t,e,n,r){let i="",o=n.length;if(r==="numeric"){const d=Ve.alphabet.numeric.decode(n.split("")),h=d.length;for(let f=0;f<h-2;f+=3)i+=Mn(100*d[f]+10*d[f+1]+d[f+2],10);h%3==1?i+=Mn(d[h-1],4):h%3==2&&(i+=Mn(10*d[h-2]+d[h-1],7))}else if(r==="alphanumeric"){const d=Ve.alphabet.alphanumerc.decode(n.split("")),h=d.length;for(let f=0;f<h-1;f+=2)i+=Mn(45*d[f]+d[f+1],11);h%2==1&&(i+=Mn(d[h-1],6))}else{if(r!=="byte")throw new Error("encode: unsupported type");{const d=function(h){if(typeof h!="string")throw new Error("utf8ToBytes expected string, got "+typeof h);return new Uint8Array(new TextEncoder().encode(h))}(n);o=d.length,i=Array.from(d).map(h=>Mn(h,8)).join("")}}const{capacity:a}=Ve.capacity(t,e),s=Mn(o,Ve.lengthBits(t,r));let c=Ve.modeBits[r]+s+i;if(c.length>a)throw new Error("Capacity overflow");c+="0".repeat(Math.min(4,Math.max(0,a-c.length))),c.length%8&&(c+="0".repeat(8-c.length%8));const l="1110110000010001";for(let d=0;c.length!==a;d++)c+=l[d%16];const u=Uint8Array.from(c.match(/(.{8})/g).map(d=>+`0b${d}`));return $v(t,e).encode(u)}function Pu(t,e,n,r,i=!1){const o=function(c,l,u,d=!1){const h=Ve.size.encode(c);let f=new st(h+2);const g=new st(3).rect(0,3,!0).border(1,!1).border(1,!0).border(1,!1);f=f.embed(0,g).embed({x:-g.width,y:0},g).embed({x:0,y:-g.height},g),f=f.rectSlice(1,h);const m=new st(1).rect(0,1,!0).border(1,!1).border(1,!0),w=Ve.alignmentPatterns(c);for(const p of w)for(const S of w)f.data[p][S]===void 0&&f.embed({x:S-2,y:p-2},m);f=f.hLine({x:0,y:6},1/0,({x:p},S)=>S===void 0?p%2==0:S).vLine({x:6,y:0},1/0,({y:p},S)=>S===void 0?p%2==0:S);{const p=Ve.formatBits(l,u),S=_=>!d&&(p>>_&1)==1;for(let _=0;_<6;_++)f.data[_][8]=S(_);for(let _=6;_<8;_++)f.data[_+1][8]=S(_);for(let _=8;_<15;_++)f.data[h-15+_][8]=S(_);for(let _=0;_<8;_++)f.data[8][h-_-1]=S(_);for(let _=8;_<9;_++)f.data[8][15-_-1+1]=S(_);for(let _=9;_<15;_++)f.data[8][15-_-1]=S(_);f.data[h-8][8]=!d}if(c>=7){const p=Ve.versionBits(c);for(let S=0;S<18;S+=1){const _=!d&&(p>>S&1)==1,O=Math.floor(S/3),I=S%3+h-8-3;f.data[O][I]=_,f.data[I][O]=_}}return f}(t,e,r,i);let a=0;const s=8*n.length;if(function(c,l,u){const d=c.height,h=ya[l];let f=-1,g=d-1;for(let m=d-1;m>0;m-=2){for(m==6&&(m=5);;g+=f){for(let w=0;w<2;w+=1){const p=m-w;c.data[g][p]===void 0&&u(p,g,h(p,g))}if(g+f<0||g+f>=d)break}f=-f}}(o,r,(c,l,u)=>{let d=!1;a<s&&(d=(n[a>>>3]>>(7-a&7)&1)!=0,a++),o.data[l][c]=d!==u}),a!==s)throw new Error("QR: bytes left after draw");return o}function Kv(t){const e=t.inverse(),n=f=>{let g=0;for(let m,w=0,p=1;w<f.length;w++)m===f[w]&&(p++,w!==f.length-1)||(p>=5&&(g+=p-5+3),m=f[w],p=1);return g};let r=0;t.data.forEach(f=>r+=n(f)),e.data.forEach(f=>r+=n(f));let i=0,o=t.data;const a=t.width-1,s=t.height-1;for(let f=0;f<a;f++)for(let g=0;g<s;g++){const m=f+1,w=g+1;o[f][g]===o[m][g]&&o[m][g]===o[f][w]&&o[m][g]===o[m][w]&&(i+=3)}const c=f=>{const g=[!0,!1,!0,!0,!0,!1,!0],m=[!1,!1,!1,!1],w=[...g,...m],p=[...m,...g];let S=0;for(let _=0;_<f.length;_++)xu(f,w,_)&&(S+=40),xu(f,p,_)&&(S+=40);return S};let l=0;for(const f of t.data)l+=c(f);for(const f of e.data)l+=c(f);let u=0;t.rectRead(0,1/0,(f,g)=>u+=g?1:0);const d=u/(t.height*t.width)*100,h=10*Math.floor(Math.abs(d-50)/5);return r+i+l+h}function Wf(t,e="raw",n={}){const r=n.ecc!==void 0?n.ecc:"medium";(function(u){if(!Mu.includes(u))throw new Error(`Invalid error correction mode=${u}. Expected: ${Mu}`)})(r);const i=n.encoding!==void 0?n.encoding:function(u){let d="numeric";for(let h of u)if(!Ve.alphabet.numeric.has(h)&&(d="alphanumeric",!Ve.alphabet.alphanumerc.has(h)))return"byte";return d}(t);(function(u){if(!Ru.includes(u))throw new Error(`Encoding: invalid mode=${u}. Expected: ${Ru}`);if(u==="kanji"||u==="eci")throw new Error(`Encoding: ${u} is not supported (yet?).`)})(i),n.mask!==void 0&&function(u){if(![0,1,2,3,4,5,6,7].includes(u)||!ya[u])throw new Error(`Invalid mask=${u}. Expected number [0..7]`)}(n.mask);let o,a=n.version,s=new Error("Unknown error");if(a!==void 0)(function(u){if(!Number.isSafeInteger(u)||u<1||u>40)throw new Error(`Invalid version=${u}. Expected number [1..40]`)})(a),o=Ou(a,r,t,i);else for(let u=1;u<=40;u++)try{o=Ou(u,r,t,i),a=u;break}catch(d){s=d}if(!a||!o)throw s;let c=function(u,d,h,f){if(f===void 0){const g=function(){let m,w=1/0;return{add(p,S){p>=w||(m=S,w=p)},get:()=>m,score:()=>w}}();for(let m=0;m<ya.length;m++)g.add(Kv(Pu(u,d,h,m,!0)),m);f=g.get()}if(f===void 0)throw new Error("Cannot find mask");return Pu(u,d,h,f)}(a,r,o,n.mask);c.assertDrawn();const l=n.border===void 0?2:n.border;if(!Number.isSafeInteger(l))throw new Error("Wrong border type="+typeof l);if(c=c.border(l,!1),n.scale!==void 0&&(c=c.scale(n.scale)),e==="raw")return c.data;if(e==="ascii")return c.toASCII();if(e==="svg")return c.toSVG();if(e==="gif")return c.toGIF();if(e==="term")return c.toTerm();throw new Error(`Unknown output: ${e}`)}const xs={DESKTOP:"Desktop",MOBILE:"Mobile",META_MASK_MOBILE_APP:"MetaMask mobile app",SCAN_TO_CONNECT:"Scan to connect and sign with",CONNECT_WITH_EXTENSION:"Connect With MetaMask Extension",INSTALL_MODAL:{TRUSTED_BY_USERS:"Trusted by over 30 million users to buy, store, send and swap crypto securely",LEADING_CRYPTO_WALLET:"The leading crypto wallet & gateway to blockchain apps built on Ethereum Mainnet, Polygon, Optimism, and many other networks",CONTROL_DIGITAL_INTERACTIONS:"Puts you in control of your digital interactions by making power of cryptography more accessible",INSTALL_META_MASK_EXTENSION:"Install MetaMask Extension"},PENDING_MODAL:{OPEN_META_MASK_SELECT_CODE:"Please open the MetaMask wallet app and select the code on the screen OR disconnect",OPEN_META_MASK_CONTINUE:"Open the MetaMask app to continue with your session.",NUMBER_AFTER_OPEN_NOTICE:"If a number doesn't appear after opening MetaMask, please click disconnect and re-scan the QRCode.",DISCONNECT:"Disconnect"},SELECT_MODAL:{CRYPTO_TAKE_CONTROL_TEXT:"Take control of your crypto and explore the blockchain with the wallet trusted by over 30 million people worldwide"},META_MASK_MODAL:{ADDRESS_COPIED:"Address copied to clipboard!",DISCONNECT:"Disconnect",ACTIVE_NETWORK:"Active Network"}};class dc{constructor(e){var n;this.translations=xs,this.supportedLocales=["es","fr","he","it","pt","tr"],this.baseUrl=(n=e==null?void 0:e.baseUrl)!==null&&n!==void 0?n:"https://raw.githubusercontent.com/MetaMask/metamask-sdk/refs/heads/gh-pages/locales"}getBrowserLanguage(){if((navigator.languages||[navigator.language]).some(n=>n.toLowerCase().startsWith("en")))return"en";const e=navigator.language.toLowerCase().split("-")[0];return this.supportedLocales.includes(e)?e:"en"}async init(e){const n=this.getBrowserLanguage()||e.fallbackLng;await this.loadTranslations(n)}async loadTranslations(e){const n=e.split("-")[0];if(n!=="en"&&this.supportedLocales.includes(n))try{const r=`${this.baseUrl}/${n}.json`,i=await fetch(r);if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);this.translations=await i.json()}catch(r){console.warn(`❌ Failed to load ${n} translations, falling back to English:`,r),this.translations=xs}else this.translations=xs}t(e){return this.getNestedTranslation(e,this.translations)||e}getNestedTranslation(e,n){const r=e.split(".");let i=n;for(const o of r){if(typeof i!="object")return"";i=i[o]}return typeof i=="string"?i:""}}var Ir;(function(t){t.SDK_MODAL_VIEWED="sdk_modal_viewed",t.SDK_MODAL_BUTTON_CLICKED="sdk_modal_button_clicked",t.SDK_MODAL_TOGGLE_CHANGED="sdk_modal_toggle_changed"})(Ir||(Ir={}));const Gf=class{constructor(t){ec(this,t),this.close=Cn(this,"close"),this.startDesktopOnboarding=Cn(this,"startDesktopOnboarding"),this.trackAnalytics=Cn(this,"trackAnalytics"),this.link=void 0,this.sdkVersion=void 0,this.preferDesktop=void 0,this.tab=1,this.isDefaultTab=!0,this.translationsLoaded=!1,this.onClose=this.onClose.bind(this),this.onStartDesktopOnboardingHandler=this.onStartDesktopOnboardingHandler.bind(this),this.setTab=this.setTab.bind(this),this.render=this.render.bind(this),this.setTab(this.preferDesktop?1:2),this.i18nInstance=new dc}componentDidLoad(){this.trackAnalytics.emit({event:Ir.SDK_MODAL_VIEWED,params:{extensionInstalled:!1,tab:this.tab===1?"desktop":"mobile"}})}async connectedCallback(){await this.i18nInstance.init({fallbackLng:"en"}),this.translationsLoaded=!0}updatePreferDesktop(t){t?this.setTab(1):this.setTab(2)}onClose(t=!1){this.close.emit({shouldTerminate:t})}onStartDesktopOnboardingHandler(){this.trackAnalytics.emit({event:Ir.SDK_MODAL_BUTTON_CLICKED,params:{button_type:"install_extension",tab:"desktop"}}),this.startDesktopOnboarding.emit()}setTab(t,e=!1){e&&this.trackAnalytics.emit({event:Ir.SDK_MODAL_TOGGLE_CHANGED,params:{toggle:this.tab===1?"desktop_to_mobile":"mobile_to_desktop"}}),this.tab=t,this.isDefaultTab=!1}render(){if(!this.translationsLoaded)return null;const t=r=>this.i18nInstance.t(r),e=this.isDefaultTab?this.preferDesktop?1:2:this.tab,n=Wf(this.link,"svg",{ecc:"medium",scale:2});return Y(ac,{className:"install-model"},Y("div",{class:"backdrop",onClick:()=>this.onClose(!0)}),Y("div",{class:"modal"},Y("div",{class:"closeButtonContainer"},Y("div",{class:"right"},Y("span",{class:"closeButton",onClick:()=>this.onClose(!0)},Y(lc,null)))),Y("div",{class:"logoContainer"},Y(uc,null)),Y("div",null,Y("div",{class:"tabcontainer"},Y("div",{class:"flexContainer"},Y("div",{onClick:()=>this.setTab(1,!0),class:"tab flexItem "+(e===1?"tabactive":"")},t("DESKTOP")),Y("div",{onClick:()=>this.setTab(2,!0),class:"tab flexItem "+(e===2?"tabactive":"")},t("MOBILE")))),Y("div",{style:{display:e===1?"none":"block"}},Y("div",{class:"flexContainer"},Y("div",{class:"flexItem",style:{textAlign:"center",marginTop:"4"}},n&&Y("div",{id:"sdk-mm-qrcode",class:"center",innerHTML:n}),Y("div",{class:"connectMobileText"},t("SCAN_TO_CONNECT")," ",Y("br",null),Y("span",{class:"blue"},Y("b",null,t("META_MASK_MOBILE_APP"))))))),Y("div",{style:{display:e===2?"none":"block"}},Y("div",{class:"item"},Y(As,{Icon:Pv,text:t("INSTALL_MODAL.TRUSTED_BY_USERS")})),Y("div",{class:"item"},Y(As,{Icon:Ov,text:t("INSTALL_MODAL.LEADING_CRYPTO_WALLET")})),Y("div",{class:"item"},Y(As,{Icon:Iv,text:t("INSTALL_MODAL.CONTROL_DIGITAL_INTERACTIONS")})),Y("button",{class:"button",onClick:()=>this.onStartDesktopOnboardingHandler()},Y(Lv,null),Y("span",{class:"installExtensionText"},t("INSTALL_MODAL.INSTALL_META_MASK_EXTENSION"))))),Y(cc,{version:this.sdkVersion})))}get el(){return Io(this)}static get watchers(){return{preferDesktop:["updatePreferDesktop"]}}};Gf.style=`.flexContainer {
39
+ display: flex;
40
+ justify-content: center;
41
+ align-items: center;
42
+ flex-direction: row;
43
+ }
44
+
45
+ .flexItem {
46
+ flex: 1;
47
+ justify-content: center;
48
+ align-items: center;
49
+ }
50
+
51
+ .flexItem11 {
52
+ flex: 11;
53
+ justify-content: center;
54
+ align-items: center;
55
+ }
56
+
57
+ .flexItem1 {
58
+ flex: 1;
59
+ justify-content: center;
60
+ align-items: center;
61
+ }
62
+
63
+ .tab {
64
+ padding: 8px;
65
+ cursor: pointer;
66
+ background-color: #F2F4F6;
67
+ font-size: 12px;
68
+ text-align: center;
69
+ color: #24292E;
70
+ }
71
+
72
+ .tabcontainer {
73
+ padding: 4px;
74
+ background-color: #F2F4F6;
75
+ border-radius: 8px;
76
+ margin-bottom: 30px;
77
+ margin-top: 30px;
78
+ }
79
+
80
+ .tabactive {
81
+ background-color: white;
82
+ -webkit-transition: background-color 300ms linear;
83
+ -ms-transition: background-color 300ms linear;
84
+ transition: background-color 300ms linear;
85
+ border-radius: 8px;
86
+ }
87
+
88
+ .item {
89
+ font-size: 12px;
90
+ margin-bottom: 16px;
91
+ border-radius: 8px;
92
+ padding: 10px;
93
+ border: 2px #F2F4F6 solid;
94
+ color: #24292E;
95
+ }
96
+
97
+ .extensionLabel {
98
+ font-style: normal;
99
+ font-weight: bold;
100
+ font-size: 14px;
101
+ text-align: cetner;
102
+ color: #24272A;
103
+ }
104
+
105
+ .notice {
106
+ font-size: 12px;
107
+ margin-left: 10px;
108
+ margin-right: 10px;
109
+ color: grey;
110
+ }
111
+
112
+ .button {
113
+ margin-top: 41.5px;
114
+ margin-bottom: 20px;
115
+ width: 100%;
116
+ display: flex;
117
+ flex-direction: row;
118
+ justify-content: center;
119
+ align-items: center;
120
+ padding: 12px 20px;
121
+ background: #037DD6;
122
+ border-radius: 32px;
123
+ color: white;
124
+ border: 0;
125
+ font-size: 14px;
126
+ cursor: pointer;
127
+ }
128
+
129
+ .backdrop {
130
+ visibility: visible;
131
+ position: fixed;
132
+ top: 0;
133
+ left: 0;
134
+ right: 0;
135
+ bottom: 0;
136
+ width: 100%;
137
+ z-index: 99998;
138
+ background: rgba(0, 0, 0, 0.87);
139
+ opacity: 0.3;
140
+ }
141
+
142
+ .modal {
143
+ visibility: visible;
144
+ position: fixed;
145
+ left: 50%;
146
+ transform: translate(-50%, -50%);
147
+ z-index: 99999;
148
+ background: white;
149
+ padding: 20px;
150
+ border-radius: 8px;
151
+ top: 50%;
152
+ max-width: 100%;
153
+ width: 460px;
154
+ min-width: 300px;
155
+ box-shadow: rgba(0, 0, 0, 0.2) 0px 11px 15px -7px, rgba(0, 0, 0, 0.14) 0px 24px 38px 3px, rgba(0, 0, 0, 0.12) 0px 9px 46px 8px;
156
+ -webkit-font-smoothing: antialiased;
157
+ }
158
+
159
+ .closeButton {
160
+ color: #BBC0C5;
161
+ cursor: pointer;
162
+ }
163
+
164
+ .logoContainer {
165
+ margin-left: 24px;
166
+ margin-right: 24px;
167
+ margin-top: 24px;
168
+ display: flex;
169
+ align-items: center;
170
+ justify-content: center;
171
+ }
172
+
173
+ .connectMobileText {
174
+ font-size: 14px;
175
+ color: black;
176
+ margin-top: 28px;
177
+ margin-bottom: 28px;
178
+ line-height: 2;
179
+ }
180
+
181
+ .blue {
182
+ color: #037DD6;
183
+ font-weight: 700;
184
+ }
185
+
186
+ .installExtensionText {
187
+ margin-left: 10px;
188
+ }
189
+
190
+ .center {
191
+ display: flex;
192
+ justify-content: center;
193
+ align-items: center;
194
+ }
195
+
196
+ .right {
197
+ display: flex;
198
+ align-items: center;
199
+ justify-content: right;
200
+ }
201
+
202
+ #sdk-mm-qrcode {
203
+ svg {
204
+ width: 50%;
205
+ }
206
+ }`;const Yf=class{constructor(t){ec(this,t),this.close=Cn(this,"close"),this.disconnect=Cn(this,"disconnect"),this.updateOTPValue=Cn(this,"updateOTPValue"),this.displayOTP=void 0,this.sdkVersion=void 0,this.otpCode=void 0,this.translationsLoaded=!1,this.i18nInstance=new dc}async connectedCallback(){await this.i18nInstance.init({fallbackLng:"en"}),this.translationsLoaded=!0}onClose(){this.close.emit()}onDisconnect(){this.disconnect.emit()}onUpdateOTPValueHandler(t){this.updateOTPValue.emit({otpValue:t})}disconnectedCallback(){this.onClose()}render(){var t;if(!this.translationsLoaded)return null;const e=(t=this.displayOTP)===null||t===void 0||t,n=this.sdkVersion,r=i=>this.i18nInstance.t(i);return Y(ac,{className:"pending-modal"},Y("div",{class:"backdrop",onClick:()=>this.onClose()}),Y("div",{class:"modal"},Y("div",{class:"closeButtonContainer"},Y("div",{class:"right"},Y("span",{class:"closeButton",onClick:()=>this.onClose()},Y(lc,null)))),Y("div",{class:"logoContainer"},Y(uc,null)),Y("div",null,Y("div",{class:"flexContainer",style:{flexDirection:"column",color:"black"}},Y("div",{class:"flexItem",style:{textAlign:"center",marginTop:"30px",marginBottom:"30px",fontSize:"16px"}},r(e?"PENDING_MODAL.OPEN_META_MASK_SELECT_CODE":"PENDING_MODAL.OPEN_META_MASK_CONTINUE")),Y("div",{id:"sdk-mm-otp-value",style:{padding:"10px",fontSize:"32px",display:this.otpCode?"block":"none"}},this.otpCode),e&&Y("div",{class:"notice"},"* ",r("PENDING_MODAL.NUMBER_AFTER_OPEN_NOTICE"))),Y("div",{style:{marginTop:"20px"}},Y("button",{class:"button blue",style:{marginTop:"5px",color:"#0376C9",borderColor:"#0376C9",borderWidth:"1px",borderStyle:"solid",backgroundColor:"white"},onClick:()=>this.onDisconnect()},r("PENDING_MODAL.DISCONNECT")))),Y(cc,{version:n})))}get el(){return Io(this)}};Yf.style=`.flexContainer {
207
+ display: flex;
208
+ justify-content: center;
209
+ align-items: center;
210
+ flex-direction: row;
211
+ }
212
+
213
+ .flexItem {
214
+ flex: 1;
215
+ justify-content: center;
216
+ align-items: center;
217
+ }
218
+
219
+ .flexItem11 {
220
+ flex: 11;
221
+ justify-content: center;
222
+ align-items: center;
223
+ }
224
+
225
+ .flexItem1 {
226
+ flex: 1;
227
+ justify-content: center;
228
+ align-items: center;
229
+ }
230
+
231
+ .tab {
232
+ padding: 8px;
233
+ cursor: pointer;
234
+ background-color: #F2F4F6;
235
+ font-size: 12px;
236
+ text-align: center;
237
+ color: #24292E;
238
+ }
239
+
240
+ .tabcontainer {
241
+ padding: 4px;
242
+ background-color: #F2F4F6;
243
+ border-radius: 8px;
244
+ margin-bottom: 30px;
245
+ margin-top: 30px;
246
+ }
247
+
248
+ .tabactive {
249
+ background-color: white;
250
+ -webkit-transition: background-color 300ms linear;
251
+ -ms-transition: background-color 300ms linear;
252
+ transition: background-color 300ms linear;
253
+ border-radius: 8px;
254
+ }
255
+
256
+ .item {
257
+ font-size: 12px;
258
+ margin-bottom: 16px;
259
+ border-radius: 8px;
260
+ padding: 10px;
261
+ border: 2px #F2F4F6 solid;
262
+ color: #24292E;
263
+ }
264
+
265
+ .extensionLabel {
266
+ font-style: normal;
267
+ font-weight: bold;
268
+ font-size: 14px;
269
+ text-align: cetner;
270
+ color: #24272A;
271
+ }
272
+
273
+ .notice {
274
+ font-size: 12px;
275
+ margin-left: 10px;
276
+ margin-right: 10px;
277
+ color: grey;
278
+ }
279
+
280
+ .button {
281
+ margin-top: 41.5px;
282
+ margin-bottom: 20px;
283
+ width: 100%;
284
+ display: flex;
285
+ flex-direction: row;
286
+ justify-content: center;
287
+ align-items: center;
288
+ padding: 12px 20px;
289
+ background: #037DD6;
290
+ border-radius: 32px;
291
+ color: white;
292
+ border: 0;
293
+ font-size: 14px;
294
+ cursor: pointer;
295
+ }
296
+
297
+ .backdrop {
298
+ visibility: visible;
299
+ position: fixed;
300
+ top: 0;
301
+ left: 0;
302
+ right: 0;
303
+ bottom: 0;
304
+ width: 100%;
305
+ z-index: 99998;
306
+ background: rgba(0, 0, 0, 0.87);
307
+ opacity: 0.3;
308
+ }
309
+
310
+ .modal {
311
+ visibility: visible;
312
+ position: fixed;
313
+ left: 50%;
314
+ transform: translate(-50%, -50%);
315
+ z-index: 99999;
316
+ background: white;
317
+ padding: 20px;
318
+ border-radius: 8px;
319
+ top: 50%;
320
+ max-width: 100%;
321
+ width: 460px;
322
+ min-width: 300px;
323
+ box-shadow: rgba(0, 0, 0, 0.2) 0px 11px 15px -7px, rgba(0, 0, 0, 0.14) 0px 24px 38px 3px, rgba(0, 0, 0, 0.12) 0px 9px 46px 8px;
324
+ -webkit-font-smoothing: antialiased;
325
+ }
326
+
327
+ .closeButton {
328
+ color: #BBC0C5;
329
+ cursor: pointer;
330
+ }
331
+
332
+ .logoContainer {
333
+ margin-left: 24px;
334
+ margin-right: 24px;
335
+ margin-top: 24px;
336
+ display: flex;
337
+ align-items: center;
338
+ justify-content: center;
339
+ }
340
+
341
+ .connectMobileText {
342
+ font-size: 14px;
343
+ color: black;
344
+ margin-top: 28px;
345
+ margin-bottom: 28px;
346
+ line-height: 2;
347
+ }
348
+
349
+ .blue {
350
+ color: #037DD6;
351
+ font-weight: 700;
352
+ }
353
+
354
+ .installExtensionText {
355
+ margin-left: 10px;
356
+ }
357
+
358
+ .center {
359
+ display: flex;
360
+ justify-content: center;
361
+ align-items: center;
362
+ }
363
+
364
+ .right {
365
+ display: flex;
366
+ align-items: center;
367
+ justify-content: right;
368
+ }
369
+
370
+ #sdk-mm-qrcode {
371
+ svg {
372
+ width: 50%;
373
+ }
374
+ }`;const jv=()=>Y("svg",{width:"21",height:"15",viewBox:"0 0 21 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Y("path",{d:"M14.1364 14.9851C13.5909 14.9851 13.2273 14.5851 13.2273 13.9851C13.2273 13.3851 13.5909 12.9851 14.1364 12.9851C16.6818 12.9851 18.6818 10.7851 18.6818 7.98508C18.6818 5.18508 16.6818 2.98508 14.1364 2.98508C11.5909 2.98508 9.59091 5.18508 9.59091 7.98508C9.59091 8.58508 9.22727 8.98508 8.68182 8.98508C8.13636 8.98508 7.77273 8.58508 7.77273 7.98508C7.77273 4.08508 10.5909 0.985077 14.1364 0.985077C17.6818 0.985077 20.5 4.08508 20.5 7.98508C20.5 11.8851 17.6818 14.9851 14.1364 14.9851ZM6.68182 14.7851C3.22727 14.7851 0.5 11.6851 0.5 7.98508C0.5 4.28508 3.22727 1.18508 6.68182 1.18508C7.22727 1.18508 7.59091 1.58508 7.59091 2.18508C7.59091 2.78508 7.22727 3.18508 6.68182 3.18508C4.22727 3.18508 2.31818 5.38508 2.31818 7.98508C2.31818 10.5851 4.22727 12.7851 6.68182 12.7851C9.13636 12.7851 11.0455 10.6851 11.0455 7.98508C11.0455 7.38508 11.4091 6.98508 11.9545 6.98508C12.5 6.98508 12.8636 7.38508 12.8636 7.98508C12.7727 11.6851 10.0455 14.7851 6.68182 14.7851Z",fill:"white"})),Uv=()=>Y("svg",{width:"400",height:"300",viewBox:"0 0 400 300",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Y("rect",{width:"400",height:"300",fill:"white"}),Y("path",{d:"M300.116 242.46L250.485 227.681L213.057 250.055L186.944 250.045L149.493 227.681L99.8843 242.46L84.7939 191.518L99.8843 134.979L84.7939 87.1777L99.8843 27.9336L177.402 74.2466H222.598L300.116 27.9336L315.206 87.1777L300.116 134.979L315.206 191.518L300.116 242.46Z",fill:"#FF5C16"}),Y("path",{d:"M99.8955 27.9336L177.414 74.2792L174.331 106.085L99.8955 27.9336Z",fill:"#FF5C16"}),Y("path",{d:"M149.505 191.539L183.612 217.521L149.505 227.681V191.539Z",fill:"#FF5C16"}),Y("path",{d:"M180.886 148.585L174.33 106.107L132.369 134.991L132.348 134.98V135.001L132.477 164.732L149.493 148.585H149.504H180.886Z",fill:"#FF5C16"}),Y("path",{d:"M300.116 27.9336L222.598 74.2792L225.67 106.085L300.116 27.9336Z",fill:"#FF5C16"}),Y("path",{d:"M250.508 191.539L216.4 217.521L250.508 227.681V191.539Z",fill:"#FF5C16"}),Y("path",{d:"M267.652 135.001H267.663H267.652V134.98L267.641 134.991L225.68 106.107L219.125 148.585H250.507L267.533 164.732L267.652 135.001Z",fill:"#FF5C16"}),Y("path",{d:"M149.493 227.681L99.8843 242.46L84.7939 191.54H149.493V227.681Z",fill:"#E34807"}),Y("path",{d:"M180.875 148.574L190.351 209.98L177.219 175.838L132.456 164.732L149.483 148.574H180.864H180.875Z",fill:"#E34807"}),Y("path",{d:"M250.507 227.681L300.116 242.46L315.206 191.54H250.507V227.681Z",fill:"#E34807"}),Y("path",{d:"M219.126 148.574L209.649 209.98L222.782 175.838L267.545 164.732L250.507 148.574H219.126Z",fill:"#E34807"}),Y("path",{d:"M84.7939 191.517L99.8843 134.979H132.337L132.456 164.721L177.219 175.826L190.351 209.969L183.601 217.488L149.493 191.506H84.7939V191.517Z",fill:"#FF8D5D"}),Y("path",{d:"M315.206 191.517L300.116 134.979H267.664L267.545 164.721L222.782 175.826L209.649 209.969L216.4 217.488L250.507 191.506H315.206V191.517Z",fill:"#FF8D5D"}),Y("path",{d:"M222.598 74.2466H200H177.402L174.33 106.053L190.351 209.936H209.649L225.681 106.053L222.598 74.2466Z",fill:"#FF8D5D"}),Y("path",{d:"M99.8843 27.9336L84.7939 87.1777L99.8843 134.979H132.337L174.319 106.085L99.8843 27.9336Z",fill:"#661800"}),Y("path",{d:"M171.496 160.906H156.795L148.79 168.752L177.229 175.804L171.496 160.896V160.906Z",fill:"#661800"}),Y("path",{d:"M300.116 27.9336L315.206 87.1777L300.116 134.979H267.663L225.681 106.085L300.116 27.9336Z",fill:"#661800"}),Y("path",{d:"M228.525 160.906H243.248L251.253 168.763L222.781 175.826L228.525 160.896V160.906Z",fill:"#661800"}),Y("path",{d:"M213.046 229.789L216.399 217.51L209.649 209.991H190.34L183.59 217.51L186.943 229.789",fill:"#661800"}),Y("path",{d:"M213.047 229.789V250.066H186.944V229.789H213.047Z",fill:"#C0C4CD"}),Y("path",{d:"M149.504 227.66L186.965 250.056V229.779L183.611 217.5L149.504 227.66Z",fill:"#E7EBF6"}),Y("path",{d:"M250.506 227.66L213.045 250.056V229.779L216.398 217.5L250.506 227.66Z",fill:"#E7EBF6"})),Zf=class{constructor(t){ec(this,t),this.close=Cn(this,"close"),this.connectWithExtension=Cn(this,"connectWithExtension"),this.link=void 0,this.sdkVersion=void 0,this.preferDesktop=void 0,this.tab=1,this.isDefaultTab=!0,this.translationsLoaded=!1,this.i18nInstance=new dc,this.setTab(this.preferDesktop?1:2)}async connectedCallback(){await this.i18nInstance.init({fallbackLng:"en"}),this.translationsLoaded=!0}onClose(t=!1){this.close.emit({shouldTerminate:t})}connectWithExtensionHandler(){this.connectWithExtension.emit()}setTab(t){this.tab=t,this.isDefaultTab=!1}disconnectedCallback(){this.onClose()}updatePreferDesktop(t){t?this.setTab(1):this.setTab(2)}render(){if(!this.translationsLoaded)return null;const t=i=>this.i18nInstance.t(i),e=this.sdkVersion,n=this.isDefaultTab?this.preferDesktop?1:2:this.tab,r=Wf(this.link,"svg",{ecc:"medium",scale:2});return Y(ac,{className:"select-modal"},Y("div",{class:"backdrop",onClick:()=>this.onClose(!0)}),Y("div",{class:"modal"},Y("div",{class:"closeButtonContainer"},Y("div",{class:"right"},Y("span",{class:"closeButton",onClick:()=>this.onClose(!0)},Y(lc,null)))),Y("div",{class:"logoContainer"},Y(uc,null)),Y("div",null,Y("div",{class:"tabcontainer"},Y("div",{class:"flexContainer"},Y("div",{onClick:()=>this.setTab(1),class:"tab flexItem "+(n===1?"tabactive":"")},t("DESKTOP")),Y("div",{onClick:()=>this.setTab(2),class:"tab flexItem "+(n===2?"tabactive":"")},t("MOBILE")))),Y("div",{style:{display:n===1?"none":"block"}},Y("div",{class:"flexContainer"},Y("div",{class:"flexItem",style:{textAlign:"center",marginTop:"4"}},Y("div",{class:"center",id:"sdk-mm-qrcode",innerHTML:r}),Y("div",{class:"connectMobileText"},t("SCAN_TO_CONNECT"),Y("br",null),Y("span",{class:"blue"},Y("b",null,t("META_MASK_MOBILE_APP"))))))),Y("div",{style:{display:n===2?"none":"block"}},Y("div",{style:{display:"flex",justifyContent:"center",height:"300",marginTop:"-20"}},Y(Uv,null)),Y("div",{class:"extensionLabel"},t("SELECT_MODAL.CRYPTO_TAKE_CONTROL_TEXT")),Y("button",{class:"button",onClick:()=>this.connectWithExtensionHandler()},Y(jv,null),Y("span",{class:"installExtensionText"},t("CONNECT_WITH_EXTENSION"))))),Y(cc,{version:e})))}get el(){return Io(this)}static get watchers(){return{preferDesktop:["updatePreferDesktop"]}}};Zf.style=`.flexContainer {
375
+ display: flex;
376
+ justify-content: center;
377
+ align-items: center;
378
+ flex-direction: row;
379
+ }
380
+
381
+ .flexItem {
382
+ flex: 1;
383
+ justify-content: center;
384
+ align-items: center;
385
+ }
386
+
387
+ .flexItem11 {
388
+ flex: 11;
389
+ justify-content: center;
390
+ align-items: center;
391
+ }
392
+
393
+ .flexItem1 {
394
+ flex: 1;
395
+ justify-content: center;
396
+ align-items: center;
397
+ }
398
+
399
+ .tab {
400
+ padding: 8px;
401
+ cursor: pointer;
402
+ background-color: #F2F4F6;
403
+ font-size: 12px;
404
+ text-align: center;
405
+ color: #24292E;
406
+ }
407
+
408
+ .tabcontainer {
409
+ padding: 4px;
410
+ background-color: #F2F4F6;
411
+ border-radius: 8px;
412
+ margin-bottom: 30px;
413
+ margin-top: 30px;
414
+ }
415
+
416
+ .tabactive {
417
+ background-color: white;
418
+ -webkit-transition: background-color 300ms linear;
419
+ -ms-transition: background-color 300ms linear;
420
+ transition: background-color 300ms linear;
421
+ border-radius: 8px;
422
+ }
423
+
424
+ .item {
425
+ font-size: 12px;
426
+ margin-bottom: 16px;
427
+ border-radius: 8px;
428
+ padding: 10px;
429
+ border: 2px #F2F4F6 solid;
430
+ color: #24292E;
431
+ }
432
+
433
+ .extensionLabel {
434
+ font-style: normal;
435
+ font-weight: bold;
436
+ font-size: 14px;
437
+ text-align: cetner;
438
+ color: #24272A;
439
+ }
440
+
441
+ .notice {
442
+ font-size: 12px;
443
+ margin-left: 10px;
444
+ margin-right: 10px;
445
+ color: grey;
446
+ }
447
+
448
+ .button {
449
+ margin-top: 41.5px;
450
+ margin-bottom: 20px;
451
+ width: 100%;
452
+ display: flex;
453
+ flex-direction: row;
454
+ justify-content: center;
455
+ align-items: center;
456
+ padding: 12px 20px;
457
+ background: #037DD6;
458
+ border-radius: 32px;
459
+ color: white;
460
+ border: 0;
461
+ font-size: 14px;
462
+ cursor: pointer;
463
+ }
464
+
465
+ .backdrop {
466
+ visibility: visible;
467
+ position: fixed;
468
+ top: 0;
469
+ left: 0;
470
+ right: 0;
471
+ bottom: 0;
472
+ width: 100%;
473
+ z-index: 99998;
474
+ background: rgba(0, 0, 0, 0.87);
475
+ opacity: 0.3;
476
+ }
477
+
478
+ .modal {
479
+ visibility: visible;
480
+ position: fixed;
481
+ left: 50%;
482
+ transform: translate(-50%, -50%);
483
+ z-index: 99999;
484
+ background: white;
485
+ padding: 20px;
486
+ border-radius: 8px;
487
+ top: 50%;
488
+ max-width: 100%;
489
+ width: 460px;
490
+ min-width: 300px;
491
+ box-shadow: rgba(0, 0, 0, 0.2) 0px 11px 15px -7px, rgba(0, 0, 0, 0.14) 0px 24px 38px 3px, rgba(0, 0, 0, 0.12) 0px 9px 46px 8px;
492
+ -webkit-font-smoothing: antialiased;
493
+ }
494
+
495
+ .closeButton {
496
+ color: #BBC0C5;
497
+ cursor: pointer;
498
+ }
499
+
500
+ .logoContainer {
501
+ margin-left: 24px;
502
+ margin-right: 24px;
503
+ margin-top: 24px;
504
+ display: flex;
505
+ align-items: center;
506
+ justify-content: center;
507
+ }
508
+
509
+ .connectMobileText {
510
+ font-size: 14px;
511
+ color: black;
512
+ margin-top: 28px;
513
+ margin-bottom: 28px;
514
+ line-height: 2;
515
+ }
516
+
517
+ .blue {
518
+ color: #037DD6;
519
+ font-weight: 700;
520
+ }
521
+
522
+ .installExtensionText {
523
+ margin-left: 10px;
524
+ }
525
+
526
+ .center {
527
+ display: flex;
528
+ justify-content: center;
529
+ align-items: center;
530
+ }
531
+
532
+ .right {
533
+ display: flex;
534
+ align-items: center;
535
+ justify-content: right;
536
+ }
537
+
538
+ #sdk-mm-qrcode {
539
+ svg {
540
+ width: 50%;
541
+ }
542
+ }`;var Hv=Object.freeze({__proto__:null,mm_install_modal:Gf,mm_pending_modal:Yf,mm_select_modal:Zf});export{Bn as CommunicationLayerPreference,je as ConnectionStatus,ar as DEFAULT_SERVER_URL,te as EventType,Ae as MessageType,Vv as MetaMaskSDK,tt as MetaMaskSDKEvent,Kt as PROVIDER_UPDATE_TYPE,qe as PlatformType,My as SDKProvider,Vv as default};